modern syntax for asgops & inits cause Donn's latest ccom rejects the old.
[unix-history] / usr / src / lib / libc / stdio / rdwr.c
CommitLineData
b8f253e8
KM
1#ifndef lint
2static char sccsid[] = "@(#)rdwr.c 5.1 (Berkeley) %G%";
3#endif not lint
4
e87a2aef
BJ
5#include <stdio.h>
6
7fread(ptr, size, count, iop)
8unsigned size, count;
9register char *ptr;
10register FILE *iop;
11{
12 register c;
13 unsigned ndone, s;
14
15 ndone = 0;
16 if (size)
17 for (; ndone<count; ndone++) {
18 s = size;
19 do {
20 if ((c = getc(iop)) >= 0)
21 *ptr++ = c;
22 else
23 return(ndone);
24 } while (--s);
25 }
26 return(ndone);
27}
28
29fwrite(ptr, size, count, iop)
30unsigned size, count;
31register char *ptr;
32register FILE *iop;
33{
34 register unsigned s;
35 unsigned ndone;
36
37 ndone = 0;
38 if (size)
39 for (; ndone<count; ndone++) {
40 s = size;
41 do {
42 putc(*ptr++, iop);
43 } while (--s);
44 if (ferror(iop))
45 break;
46 }
47 return(ndone);
48}