]> pd.if.org Git - pdclib.old/blob - functions/stdio/fwrite.c
Yet closer to functional output.
[pdclib.old] / functions / stdio / fwrite.c
1 /* $Id$ */
2
3 /* fwrite( const void *, size_t, size_t, FILE * )
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #include <stdio.h>
10 #include <_PDCLIB_glue.h>
11
12 #ifndef REGTEST
13
14 size_t fwrite( const void * _PDCLIB_restrict ptr, size_t size, size_t nmemb, struct _PDCLIB_file_t * _PDCLIB_restrict stream )
15 {
16     return _PDCLIB_write( stream->handle, ptr, size * nmemb );
17 }
18
19 #endif
20
21 #ifdef TEST
22 #include <_PDCLIB_test.h>
23
24 int main( void )
25 {
26     FILE * fh;
27     TESTCASE( ( fh = fopen( "testfile", "w" ) ) != NULL );
28     TESTCASE( fwrite( "SUCCESS testing fwrite()\n", 1, 25, fh ) == 25 );
29     TESTCASE( fclose( fh ) == 0 );
30     /* TODO: Add readback test. */
31     TESTCASE( remove( "testfile" ) == 0 );
32     return TEST_RESULTS;
33 }
34
35 #endif