Line | |
---|
1 | /* $Id: rd_bytes.c,v 1.1 2005/06/23 09:50:54 philip 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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.