Annotation of coherent/b/lib/libc/stdio/fflush.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libc/stdio/fflush.c
                      3:  * ANSI-compliant C standard i/o library.
                      4:  * fflush()
                      5:  * ANSI 4.9.5.2.
                      6:  * Write out unwritten data in buffer.
                      7:  */
                      8: 
                      9: #include <stdio.h>
                     10: #if    COHERENT || GEMDOS
                     11: #include <errno.h>
                     12: #endif
                     13: 
                     14: int
                     15: fflush(stream) register FILE *stream;
                     16: {
                     17:        register int n;
                     18:        register FILE **fpp;
                     19:        register _FILE2 *f2p;
                     20: 
                     21:        if (stream == NULL) {
                     22:                /* fflush all streams. */
                     23:                n = 0;
                     24:                for (fpp = _fp+_NFILE; --fpp >= _fp; )
                     25:                        if ((stream = *fpp) != NULL
                     26:                         && (stream->_ff2 & _FINUSE)
                     27:                         && fflush(stream) == EOF)
                     28:                                n = EOF;
                     29:                return n;
                     30:        }
                     31:        stream->_cc = 0;
                     32:        if ((stream->_ff1 & _FERR) != 0)
                     33:                return EOF;
                     34:        f2p = stream->_f2p;
                     35:        if ((n = stream->_cp - f2p->_dp) <= 0
                     36:          || write(fileno(stream), f2p->_dp, n) == n ) {
                     37:                if (n < 0)
                     38:                        ;
                     39:                else if (stream->_cp == f2p->_ep)
                     40:                        f2p->_dp = stream->_cp = f2p->_bp;
                     41:                else
                     42:                        f2p->_dp = stream->_cp;
                     43:                return 0;
                     44:        } else {
                     45: #if    COHERENT || GEMDOS
                     46:                if (errno == EINTR)
                     47:                        errno = 0;
                     48:                else
                     49: #endif
                     50:                stream->_ff1 |= _FERR;
                     51:                return EOF;
                     52:        }
                     53: }
                     54: 
                     55: /* end of libc/stdio/fflush.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.