]> pd.if.org Git - pdclib/blob - functions/stdio/fflush.c
Comment 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 #include <_PDCLIB_glue.h>
11
12 extern struct _PDCLIB_file_t * _PDCLIB_filelist;
13
14 int fflush( struct _PDCLIB_file_t * stream )
15 {
16     if ( stream == NULL )
17     {
18         stream = _PDCLIB_filelist;
19         /* TODO: Check what happens when fflush( NULL ) encounters write errors, in other libs */
20         int rc = 0;
21         while ( stream != NULL )
22         {
23             if ( stream->status & _PDCLIB_FWRITE )
24             {
25                 if ( _PDCLIB_flushbuffer( stream ) == EOF )
26                 {
27                     rc = EOF;
28                 }
29             }
30             stream = stream->next;
31         }
32         return rc;
33     }
34     else
35     {
36         return _PDCLIB_flushbuffer( stream );
37     }
38 }
39                 
40 #endif
41
42 #ifdef TEST
43 #include <_PDCLIB_test.h>
44
45 int main( void )
46 {
47     /* Testing covered by ftell.c */
48     return TEST_RESULTS;
49 }
50
51 #endif
52