Adding upstream version 3.50~pre5.
[syslinux-debian/hramrach.git] / com32 / lib / fread.c
blob76fdda8c60e6853ab095cb302db12cd052059a83
1 /*
2 * fread.c
3 */
5 #include <errno.h>
6 #include <unistd.h>
7 #include <stdio.h>
9 size_t _fread(void *buf, size_t count, FILE *f)
11 size_t bytes = 0;
12 ssize_t rv;
13 char *p = buf;
15 while ( count ) {
16 rv = read(fileno(f), p, count);
17 if ( rv == -1 ) {
18 if ( errno == EINTR || errno == EAGAIN )
19 continue;
20 else
21 break;
22 } else if ( rv == 0 ) {
23 break;
26 p += rv;
27 bytes += rv;
28 count -= rv;
31 return bytes;