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

1.1       root        1: /*     @(#)setbuf.c    2.2     */
                      2: /*     3.0 SID #       1.2     */
                      3: /*LINTLIBRARY*/
                      4: #include <stdio.h>
                      5: 
                      6: extern void free();
                      7: extern int isatty();
                      8: extern unsigned char _smbuf[][_SBFSIZ];
                      9: #if !u370
                     10: extern unsigned char *_stdbuf[];
                     11: #else
                     12: extern char *malloc();
                     13: #endif
                     14: 
                     15: void
                     16: setbuf(iop, buf)
                     17: register FILE *iop;
                     18: char   *buf;
                     19: {
                     20:        register int fno = fileno(iop);  /* file number */
                     21: 
                     22:        if(iop->_base != NULL && iop->_flag & _IOMYBUF)
                     23:                free((char*)iop->_base);
                     24:        iop->_flag &= ~(_IOMYBUF | _IONBF | _IOLBF);
                     25:        if((iop->_base = (unsigned char*)buf) == NULL) {
                     26:                iop->_flag |= _IONBF; /* file unbuffered except in fastio */
                     27: #if u370
                     28:                if ( (iop->_base = (unsigned char *) malloc(BUFSIZ+8)) != NULL){
                     29:                        iop->_flag |= _IOMYBUF;
                     30:                        _bufend(iop) = iop->_base + BUFSIZ;
                     31:                }
                     32: #else
                     33:                if (fno < 2)  /* for stdin, stdout, use the existing bufs */
                     34:                        _bufend(iop) = (iop->_base = _stdbuf[fno]) + BUFSIZ;
                     35: #endif
                     36: 
                     37:                else   /* otherwise, use small buffers reserved for this */
                     38:                        _bufend(iop) = (iop->_base = _smbuf[fno]) + _SBFSIZ;
                     39:        }
                     40:        else {  /* regular buffered I/O, standard buffer size */
                     41:                _bufend(iop) = iop->_base + BUFSIZ;
                     42:                if (isatty(fno))
                     43:                        iop->_flag |= _IOLBF;
                     44:        }
                     45:        iop->_ptr = iop->_base;
                     46:        iop->_cnt = 0;
                     47: }

unix.superglobalmegacorp.com

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