wr_bytes.c 725 B

12345678910111213141516171819202122232425262728293031323334
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. #include "obj.h"
  7. #define MININT (1 << (sizeof(int) * 8 - 1))
  8. #define MAXCHUNK (~MININT) /* Highest count we write(2). */
  9. /* Notice that MAXCHUNK itself might be too large with some compilers.
  10. You have to put it in an int!
  11. */
  12. static int maxchunk = MAXCHUNK;
  13. /*
  14. * Just write "cnt" bytes to file-descriptor "fd".
  15. */
  16. void
  17. wr_bytes(fd, string, cnt)
  18. register char *string;
  19. register long cnt;
  20. {
  21. while (cnt) {
  22. register int n = cnt >= maxchunk ? maxchunk : cnt;
  23. if (write(fd, string, n) != n)
  24. wr_fatal();
  25. string += n;
  26. cnt -= n;
  27. }
  28. }