3131dc9915
getting way too complicated (stdio is horribly subtle). I think I need to rethink things.
36 lines
476 B
C
36 lines
476 B
C
/*
|
|
* fread.c - read a number of members into an array
|
|
*/
|
|
/* $Id$ */
|
|
|
|
#include <stdio.h>
|
|
|
|
#if ACKCONF_WANT_STDIO
|
|
|
|
size_t
|
|
fread(void* ptr, size_t size, size_t nmemb, register FILE* stream)
|
|
{
|
|
register char* cp = ptr;
|
|
register int c;
|
|
size_t ndone = 0;
|
|
register size_t s;
|
|
|
|
if (size)
|
|
while (ndone < nmemb)
|
|
{
|
|
s = size;
|
|
do
|
|
{
|
|
if ((c = getc(stream)) != EOF)
|
|
*cp++ = c;
|
|
else
|
|
return ndone;
|
|
} while (--s);
|
|
ndone++;
|
|
}
|
|
|
|
return ndone;
|
|
}
|
|
|
|
#endif
|