Annotation of 42BSD/lib/libc/stdio/setbuffer.c, revision 1.1

1.1     ! root        1: /* @(#)setbuffer.c     4.2 (Berkeley) 2/27/83 */
        !             2: #include       <stdio.h>
        !             3: 
        !             4: setbuffer(iop, buf, size)
        !             5:        register struct _iobuf *iop;
        !             6:        char *buf;
        !             7:        int size;
        !             8: {
        !             9:        if (iop->_base != NULL && iop->_flag&_IOMYBUF)
        !            10:                free(iop->_base);
        !            11:        iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF);
        !            12:        if ((iop->_base = buf) == NULL) {
        !            13:                iop->_flag |= _IONBF;
        !            14:                iop->_bufsiz = NULL;
        !            15:        } else {
        !            16:                iop->_ptr = iop->_base;
        !            17:                iop->_bufsiz = size;
        !            18:        }
        !            19:        iop->_cnt = 0;
        !            20: }
        !            21: 
        !            22: /*
        !            23:  * set line buffering for either stdout or stderr
        !            24:  */
        !            25: setlinebuf(iop)
        !            26:        register struct _iobuf *iop;
        !            27: {
        !            28:        static char _sebuf[BUFSIZ];
        !            29:        extern char _sobuf[];
        !            30: 
        !            31:        if (iop != stdout && iop != stderr)
        !            32:                return;
        !            33:        fflush(iop);
        !            34:        setbuffer(iop, NULL, 0);
        !            35:        setbuffer(iop, iop == stderr ? _sebuf : _sobuf, BUFSIZ);
        !            36:        iop->_flag |= _IOLBF;
        !            37: }

unix.superglobalmegacorp.com

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