xref: /plan9/sys/src/ape/lib/ap/stdio/setbuf.c (revision 3e12c5d1bb89fc02707907988834ef147769ddaf)
1 /*
2  * pANS stdio -- setbuf
3  */
4 #include "iolib.h"
setbuf(FILE * f,char * buf)5 void setbuf(FILE *f, char *buf){
6 	if(f->state==OPEN){
7 		if(buf)
8 			f->bufl=BUFSIZ;
9 		else{
10 			buf=f->unbuf;
11 			f->bufl=0;
12 		}
13 		f->rp=f->wp=f->lp=f->buf=buf;
14 		f->state=RDWR;
15 	}
16 	/* else error, but there's no way to report it */
17 }
18