source: trunk/minix/commands/aal/rd_bytes.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 819 bytes
Line 
1/* $Header: /cvsup/minix/src/commands/aal/rd_bytes.c,v 1.1.1.1 2005/04/21 14:53:58 beng 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#define MININT (1 << (sizeof(int) * 8 - 1))
7#define MAXCHUNK (~MININT) /* Highest count we read(2). */
8/* Unfortunately, MAXCHUNK is too large with some compilers. Put it in
9 an int!
10*/
11
12static int maxchunk = MAXCHUNK;
13
14/*
15 * We don't have to worry about byte order here.
16 * Just read "cnt" bytes from file-descriptor "fd".
17 */
18int
19rd_bytes(fd, string, cnt)
20 register char *string;
21 register long cnt;
22{
23
24 while (cnt) {
25 register int n = cnt >= maxchunk ? maxchunk : cnt;
26
27 if (read(fd, string, n) != n)
28 rd_fatal();
29 string += n;
30 cnt -= n;
31 }
32}
Note: See TracBrowser for help on using the repository browser.