rd_bytes.c

Go to the documentation of this file.
00001 /* $Header: /opt/proj/minix/cvsroot/src/commands/aal/rd_bytes.c,v 1.1.1.1 2005/04/21 14:53:58 beng Exp $ */
00002 /*
00003  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00004  * See the copyright notice in the ACK home directory, in the file "Copyright".
00005  */
00006 #define MININT          (1 << (sizeof(int) * 8 - 1))
00007 #define MAXCHUNK        (~MININT)       /* Highest count we read(2).    */
00008 /* Unfortunately, MAXCHUNK is too large with some  compilers. Put it in
00009    an int!
00010 */
00011 
00012 static int maxchunk = MAXCHUNK;
00013 
00014 /*
00015  * We don't have to worry about byte order here.
00016  * Just read "cnt" bytes from file-descriptor "fd".
00017  */
00018 int 
00019 rd_bytes(fd, string, cnt)
00020         register char   *string;
00021         register long   cnt;
00022 {
00023 
00024         while (cnt) {
00025                 register int n = cnt >= maxchunk ? maxchunk : cnt;
00026 
00027                 if (read(fd, string, n) != n)
00028                         rd_fatal();
00029                 string += n;
00030                 cnt -= n;
00031         }
00032 }

Generated on Fri Apr 14 22:56:37 2006 for minix by  doxygen 1.4.6