_flsbuf.c (313B)
1 #include <errno.h> 2 #include <stdio.h> 3 4 #include "../libc.h" 5 #include "../syscall.h" 6 7 int 8 _flsbuf(FILE *fp) 9 { 10 size_t cnt; 11 12 if (fp->flags&_IOREAD) 13 return 0; 14 15 cnt = fp->wp - fp->buf; 16 if (cnt > 0 && _write(fp->fd, fp->buf, cnt) != cnt) { 17 fp->flags |= _IOERR; 18 return EOF; 19 } 20 fp->wp = fp->buf; 21 22 return 0; 23 }