Annotation of researchv10dc/libI77/notused/filbuf.c, revision 1.1.1.1

1.1       root        1: /*     @(#)filbuf.c    2.1     */
                      2: /*     3.0 SID #       1.2     */
                      3: /*LINTLIBRARY*/
                      4: #include <stdio.h>
                      5: 
                      6: extern _findbuf();
                      7: extern int read();
                      8: extern int fflush();
                      9: extern FILE *_lastbuf;
                     10: 
                     11: int
                     12: _filbuf(iop)
                     13: register FILE *iop;
                     14: {
                     15:        register FILE *diop;
                     16: 
                     17:        if (iop->_base == NULL)  /* get buffer if we don't have one */
                     18:                _findbuf(iop);
                     19: 
                     20:        if ( !(iop->_flag & _IOREAD) )
                     21:                if (iop->_flag & _IORW)
                     22:                        iop->_flag |= _IOREAD;
                     23:                else
                     24:                        return(EOF);
                     25: 
                     26:        /* if this device is a terminal (line-buffered) or unbuffered, then */
                     27:        /* flush buffers of all line-buffered devices currently writing */
                     28: 
                     29:        if (iop->_flag & (_IOLBF | _IONBF))
                     30:                for (diop = _iob; diop < _lastbuf; diop++ )
                     31:                        if (diop->_flag & _IOLBF)
                     32:                                (void) fflush(diop);
                     33: 
                     34:        iop->_ptr = iop->_base;
                     35:        iop->_cnt = read(fileno(iop), (char *)iop->_base,
                     36:            (unsigned)((iop->_flag & _IONBF) ? 1 : _bufsiz(iop) ));
                     37:        if (--iop->_cnt >= 0)           /* success */
                     38:                return (*iop->_ptr++);
                     39:        if (iop->_cnt != -1)            /* error */
                     40:                iop->_flag |= _IOERR;
                     41:        else {                          /* end-of-file */
                     42:                iop->_flag |= _IOEOF;
                     43:                if (iop->_flag & _IORW)
                     44:                        iop->_flag &= ~_IOREAD;
                     45:        }
                     46:        iop->_cnt = 0;
                     47:        return (EOF);
                     48: }

unix.superglobalmegacorp.com

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