Pristine Ack-5.5
[Ack-5.5.git] / modules / src / object / rd_bytes.c
1 /* $Id: rd_bytes.c,v 1.7 1994/06/24 11:18:59 ceriel Exp $ */
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
7 #include "obj.h"
8
9 #define MININT          (1 << (sizeof(int) * 8 - 1))
10 #define MAXCHUNK        (~MININT)       /* Highest count we read(2).    */
11 /* Unfortunately, MAXCHUNK is too large with some  compilers. Put it in
12    an int!
13 */
14
15 static int maxchunk = MAXCHUNK;
16
17 /*
18  * We don't have to worry about byte order here.
19  * Just read "cnt" bytes from file-descriptor "fd".
20  */
21 void 
22 rd_bytes(fd, string, cnt)
23         register char   *string;
24         register long   cnt;
25 {
26
27         while (cnt) {
28                 register int n = cnt >= maxchunk ? maxchunk : cnt;
29
30                 if (read(fd, string, n) != n)
31                         rd_fatal();
32                 string += n;
33                 cnt -= n;
34         }
35 }