Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/src/ape/lib/ap/stdio/fflush.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/*
2
 * pANS stdio -- fflush
3
 */
4
#include "iolib.h"
5
int fflush(FILE *f){
6
	int error, cnt;
7
	if(f==NULL){
8
		error=0;
9
		for(f=_IO_stream;f!=&_IO_stream[FOPEN_MAX];f++)
10
			if(f->state==WR && fflush(f)==EOF)
11
				error=EOF;
12
		return error;
13
	}
14
	if(f->flags&STRING) return EOF;
15
	switch(f->state){
16
	default:	/* OPEN RDWR EOF RD */
17
		return 0;
18
	case CLOSED:
19
	case ERR:
20
		return EOF;
21
	case WR:
22
		cnt=(f->flags&LINEBUF?f->lp:f->wp)-f->buf;
23
		if(cnt && write(f->fd, f->buf, cnt)!=cnt){
24
			f->state=ERR;
25
			return EOF;
26
		}
27
		f->rp=f->wp=f->buf;
28
		f->state=RDWR;
29
		return 0;
30
	}
31
}