1989-05-30 13:34:25 +00:00
|
|
|
/*
|
|
|
|
* fwrite.c - write a number of array elements on a file
|
|
|
|
*/
|
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
|
|
|
fwrite(const 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 const unsigned char* cp = ptr;
|
1989-12-18 15:04:14 +00:00
|
|
|
register size_t s;
|
|
|
|
size_t ndone = 0;
|
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-12-18 15:04:14 +00:00
|
|
|
if (putc((int)*cp, stream)
|
2018-06-21 20:33:47 +00:00
|
|
|
== EOF)
|
1989-06-26 10:37:05 +00:00
|
|
|
return ndone;
|
1989-12-18 15:04:14 +00:00
|
|
|
cp++;
|
2018-06-21 20:33:47 +00:00
|
|
|
} while (--s);
|
1989-05-30 13:34:25 +00:00
|
|
|
ndone++;
|
|
|
|
}
|
1989-06-26 10:37:05 +00:00
|
|
|
return ndone;
|
1989-05-30 13:34:25 +00:00
|
|
|
}
|
2018-06-23 16:54:40 +00:00
|
|
|
|
|
|
|
#endif
|