ack/modules/src/object/rd_bytes.c

28 lines
551 B
C
Raw Normal View History

1987-01-05 17:31:38 +00:00
#define MININT (1 << (sizeof(int) * 8 - 1))
1987-02-13 09:40:08 +00:00
#define MAXCHUNK (~MININT) /* Highest count we read(2). */
/* Unfortunately, MAXCHUNK is too large with some compilers. Put it in
an int!
*/
int maxchunk = MAXCHUNK;
1987-01-05 17:31:38 +00:00
/*
* 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) {
1987-02-13 09:40:08 +00:00
register int n = cnt >= maxchunk ? maxchunk : cnt;
1987-01-05 17:31:38 +00:00
if (read(fd, string, n) != n)
rd_fatal();
string += n;
cnt -= n;
}
}