shithub: scc

ref: 87b202a67e2d27f83702b4c353f8f66bc8d8056a
dir: /lib/c/_flsbuf.c/

View raw version

#include <errno.h>
#include <stdio.h>
#include "syscall.h"

int
_flsbuf(FILE *fp)
{
	int lnbuf = fp->flags & _IOLBF;
	size_t cnt;

	cnt = ((lnbuf) ? fp->lp : fp->wp) - fp->buf;

	if (_write(fp->fd, fp->buf, cnt) != cnt) {
		fp->flags |= _IOERR;
		return EOF;
	}
	fp->rp = fp->wp = fp->buf;

	return 0;
}