Pristine Ack-5.5
[Ack-5.5.git] / modules / src / object / wr_bytes.c
1 /* $Id: wr_bytes.c,v 1.7 1994/06/24 11:19:19 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 write(2).   */
11 /* Notice that MAXCHUNK itself might be too large with some compilers.
12    You have to put it in an int!
13 */
14
15 static int maxchunk = MAXCHUNK;
16
17 /*
18  * Just write "cnt" bytes to file-descriptor "fd".
19  */
20 void
21 wr_bytes(fd, string, cnt)
22         register char   *string;
23         register long   cnt;
24 {
25
26         while (cnt) {
27                 register int n = cnt >= maxchunk ? maxchunk : cnt;
28
29                 if (write(fd, string, n) != n)
30                         wr_fatal();
31                 string += n;
32                 cnt -= n;
33         }
34 }