2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 ANSI C function fflush().
8 #include "__arosc_privdata.h"
10 #include <exec/types.h>
11 #include <exec/lists.h>
12 #include <dos/dosextens.h>
13 #include <proto/exec.h>
14 #include <proto/dos.h>
19 /*****************************************************************************
30 Flush a stream. If the stream is an input stream, then the stream
31 is synchronised for unbuffered I/O. If the stream is an output
32 stream, then any buffered data is written.
35 stream - Flush this stream. May be NULL. In this case, all
36 output streams are flushed.
39 0 on success or EOF on error.
51 ******************************************************************************/
53 struct aroscbase
*aroscbase
= __GM_GetBase();
55 /* flush all streams opened for output */
60 ForeachNode (&aroscbase
->acb_stdio_files
, fn
)
62 if (fn
->File
.flags
& _STDIO_WRITE
)
64 fdesc
*fdesc
= __getfdesc(fn
->File
.fd
);
72 if (!Flush((BPTR
)fdesc
->fcb
->fh
))
74 errno
= __arosc_ioerr2errno(IoErr());
82 fdesc
*fdesc
= __getfdesc(stream
->fd
);
84 if (!fdesc
|| !(stream
->flags
& _STDIO_WRITE
))
90 if (Flush((BPTR
)fdesc
->fcb
->fh
))
94 errno
= __arosc_ioerr2errno(IoErr());