application.mui: implemented MUIM_Application_UnpushMethod
[AROS.git] / compiler / stdc / fflush.c
blob08062e9397924cc3c83cab99035a5ae532f600ae
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function fflush().
6 */
7 #include <exec/lists.h>
8 #include <proto/dos.h>
9 #include <errno.h>
11 #include "__stdio.h"
12 #include "__stdcio_intbase.h"
14 /*****************************************************************************
16 NAME */
17 #include <stdio.h>
19 int fflush (
21 /* SYNOPSIS */
22 FILE * stream)
24 /* FUNCTION
25 Flush a stream. If the stream is an input stream, then the stream
26 is synchronised for unbuffered I/O. If the stream is an output
27 stream, then any buffered data is written.
29 INPUTS
30 stream - Flush this stream. May be NULL. In this case, all
31 output streams are flushed.
33 RESULT
34 0 on success or EOF on error.
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 ******************************************************************************/
48 if (stream == NULL)
50 /* flush all streams opened for output */
51 struct StdCIOIntBase *StdCIOBase =
52 (struct StdCIOIntBase *)__aros_getbase_StdCIOBase();
53 FILE *f;
55 ForeachNode (&StdCIOBase->files, f)
57 if (fflush(f) == EOF)
58 return EOF;
61 else
63 if (!Flush(stream->fh))
65 errno = __stdc_ioerr2errno(IoErr());
66 return EOF;
70 return 0;
71 } /* fflush */