1*16491Sralph /* @(#)setbuffer.c 4.3 (Berkeley) 05/15/84 */ 28327Smckusick #include <stdio.h> 38327Smckusick 48327Smckusick setbuffer(iop, buf, size) 58327Smckusick register struct _iobuf *iop; 68327Smckusick char *buf; 78327Smckusick int size; 88327Smckusick { 98327Smckusick if (iop->_base != NULL && iop->_flag&_IOMYBUF) 108327Smckusick free(iop->_base); 118327Smckusick iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF); 128327Smckusick if ((iop->_base = buf) == NULL) { 138327Smckusick iop->_flag |= _IONBF; 148327Smckusick iop->_bufsiz = NULL; 158327Smckusick } else { 168327Smckusick iop->_ptr = iop->_base; 178327Smckusick iop->_bufsiz = size; 188327Smckusick } 198327Smckusick iop->_cnt = 0; 208327Smckusick } 2111307Smckusick 2211307Smckusick /* 2311307Smckusick * set line buffering for either stdout or stderr 2411307Smckusick */ 2511307Smckusick setlinebuf(iop) 2611307Smckusick register struct _iobuf *iop; 2711307Smckusick { 28*16491Sralph extern char *malloc(); 2911307Smckusick 3011307Smckusick fflush(iop); 31*16491Sralph setbuffer(iop, malloc(BUFSIZ), BUFSIZ); 32*16491Sralph iop->_flag |= _IOLBF|_IOMYBUF; 3311307Smckusick } 34