X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=platform%2Faltos%2Ffunctions%2Fstdio%2Ffwrite.c;fp=platform%2Faltos%2Ffunctions%2Fstdio%2Ffwrite.c;h=3c1ac29dd68d0a274c0dffd70bcb490572e6a8c7;hb=aca4bf7601bc9aa2a80b71c435166c15968e142a;hp=0000000000000000000000000000000000000000;hpb=4348b127b85c6d8f8fb870635c30a42bfa20d689;p=fw%2Fpdclib diff --git a/platform/altos/functions/stdio/fwrite.c b/platform/altos/functions/stdio/fwrite.c new file mode 100644 index 0000000..3c1ac29 --- /dev/null +++ b/platform/altos/functions/stdio/fwrite.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* fwrite( const void *, size_t, size_t, FILE * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +#include <_PDCLIB_glue.h> + +#include +#include + +size_t fwrite( const void * _PDCLIB_restrict ptr, size_t size, size_t nmemb, struct _PDCLIB_file_t * _PDCLIB_restrict stream ) +{ + size_t total = size * nmemb; + size_t written = 0; + char *data = ptr; + + while (total-- > 0) + { + char c = *data++; + if (putc(c, stream) != c) + break; + written++; + } + return written / size; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +int main( void ) +{ + /* Testing covered by fread(). */ + return TEST_RESULTS; +} + +#endif +