shithub: riscv

ref: 3bd5ff9583c4b33aa27754fb4c3b6792261feb8a
dir: /sys/src/ape/lib/ap/stdio/setbuf.c/

View raw version
/*
 * pANS stdio -- setbuf
 */
#include "iolib.h"
void setbuf(FILE *f, char *buf){
	if(f->state==OPEN){
		if(buf)
			f->bufl=BUFSIZ;
		else{
			buf=f->unbuf;
			f->bufl=0;
		}
		f->rp=f->wp=f->lp=f->buf=buf;
		f->state=RDWR;
	}
	/* else error, but there's no way to report it */
}