xref: /csrg-svn/lib/libc/stdio/setbuf.c (revision 21409)
1*21409Sdist /*
2*21409Sdist  * Copyright (c) 1980 Regents of the University of California.
3*21409Sdist  * All rights reserved.  The Berkeley software License Agreement
4*21409Sdist  * specifies the terms and conditions for redistribution.
5*21409Sdist  */
6*21409Sdist 
7*21409Sdist #ifndef lint
8*21409Sdist static char sccsid[] = "@(#)setbuf.c	5.1 (Berkeley) 05/30/85";
9*21409Sdist #endif not lint
10*21409Sdist 
112032Swnj #include	<stdio.h>
122032Swnj 
132032Swnj setbuf(iop, buf)
1417951Sserge register FILE *iop;
152032Swnj char *buf;
162032Swnj {
172032Swnj 	if (iop->_base != NULL && iop->_flag&_IOMYBUF)
182032Swnj 		free(iop->_base);
192032Swnj 	iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF);
208326Smckusick 	if ((iop->_base = buf) == NULL) {
212032Swnj 		iop->_flag |= _IONBF;
228326Smckusick 		iop->_bufsiz = NULL;
238326Smckusick 	} else {
242032Swnj 		iop->_ptr = iop->_base;
258326Smckusick 		iop->_bufsiz = BUFSIZ;
268326Smckusick 	}
272032Swnj 	iop->_cnt = 0;
282032Swnj }
29