1989-05-30 13:34:25 +00:00
|
|
|
/*
|
|
|
|
* fread.c - read a number of members into an array
|
|
|
|
*/
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1989-05-30 13:34:25 +00:00
|
|
|
|
2018-06-21 20:33:47 +00:00
|
|
|
#include <stdio.h>
|
1989-05-30 13:34:25 +00:00
|
|
|
|
2018-06-23 16:54:40 +00:00
|
|
|
#if ACKCONF_WANT_STDIO
|
|
|
|
|
1989-05-30 13:34:25 +00:00
|
|
|
size_t
|
2018-06-21 20:33:47 +00:00
|
|
|
fread(void* ptr, size_t size, size_t nmemb, register FILE* stream)
|
1989-05-30 13:34:25 +00:00
|
|
|
{
|
2018-06-21 20:33:47 +00:00
|
|
|
register char* cp = ptr;
|
1989-12-18 15:04:14 +00:00
|
|
|
register int c;
|
|
|
|
size_t ndone = 0;
|
|
|
|
register size_t s;
|
1989-05-30 13:34:25 +00:00
|
|
|
|
|
|
|
if (size)
|
2018-06-21 20:33:47 +00:00
|
|
|
while (ndone < nmemb)
|
|
|
|
{
|
1989-05-30 13:34:25 +00:00
|
|
|
s = size;
|
2018-06-21 20:33:47 +00:00
|
|
|
do
|
|
|
|
{
|
1989-05-30 13:34:25 +00:00
|
|
|
if ((c = getc(stream)) != EOF)
|
1989-12-18 15:04:14 +00:00
|
|
|
*cp++ = c;
|
1989-05-30 13:34:25 +00:00
|
|
|
else
|
|
|
|
return ndone;
|
|
|
|
} while (--s);
|
|
|
|
ndone++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ndone;
|
|
|
|
}
|
2018-06-23 16:54:40 +00:00
|
|
|
|
|
|
|
#endif
|