ack/modules/src/object/rd_bytes.c

23 lines
446 B
C
Raw Normal View History

1987-01-05 17:31:38 +00:00
#define MININT (1 << (sizeof(int) * 8 - 1))
#define MAXCHUNK (-(MININT + 1)) /* Highest count we write(2). */
/*
* We don't have to worry about byte order here.
* Just read "cnt" bytes from file-descriptor "fd".
*/
int
rd_bytes(fd, string, cnt)
register char *string;
register long cnt;
{
while (cnt) {
register int n = cnt >= MAXCHUNK ? MAXCHUNK : cnt;
if (read(fd, string, n) != n)
rd_fatal();
string += n;
cnt -= n;
}
}