xref: /csrg-svn/lib/libc/stdio/setbuf.c (revision 17951)
1*17951Sserge /* @(#)setbuf.c	4.3 (Berkeley) 02/13/85 */
22032Swnj #include	<stdio.h>
32032Swnj 
42032Swnj setbuf(iop, buf)
5*17951Sserge register FILE *iop;
62032Swnj char *buf;
72032Swnj {
82032Swnj 	if (iop->_base != NULL && iop->_flag&_IOMYBUF)
92032Swnj 		free(iop->_base);
102032Swnj 	iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF);
118326Smckusick 	if ((iop->_base = buf) == NULL) {
122032Swnj 		iop->_flag |= _IONBF;
138326Smckusick 		iop->_bufsiz = NULL;
148326Smckusick 	} else {
152032Swnj 		iop->_ptr = iop->_base;
168326Smckusick 		iop->_bufsiz = BUFSIZ;
178326Smckusick 	}
182032Swnj 	iop->_cnt = 0;
192032Swnj }
20