]> pd.if.org Git - pdclib/blob - functions/stdio/fflush.c
Whitespace cleanups.
[pdclib] / functions / stdio / fflush.c
1 /* fflush( FILE * )
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #include <stdio.h>
8
9 #ifndef REGTEST
10
11 #include "_PDCLIB_glue.h"
12
13 extern struct _PDCLIB_file_t * _PDCLIB_filelist;
14
15 int fflush( struct _PDCLIB_file_t * stream )
16 {
17     if ( stream == NULL )
18     {
19         stream = _PDCLIB_filelist;
20         /* TODO: Check what happens when fflush( NULL ) encounters write errors, in other libs */
21         int rc = 0;
22         while ( stream != NULL )
23         {
24             if ( stream->status & _PDCLIB_FWRITE )
25             {
26                 if ( _PDCLIB_flushbuffer( stream ) == EOF )
27                 {
28                     rc = EOF;
29                 }
30             }
31             stream = stream->next;
32         }
33         return rc;
34     }
35     else
36     {
37         return _PDCLIB_flushbuffer( stream );
38     }
39 }
40
41 #endif
42
43 #ifdef TEST
44
45 #include "_PDCLIB_test.h"
46
47 int main( void )
48 {
49     /* Testing covered by ftell.c */
50     return TEST_RESULTS;
51 }
52
53 #endif