major stdio overhaul, using readv/writev, plus other changes
[musl] / src / stdio / __toread.c
1 #include <stdio_impl.h>
2
3 int __toread(FILE *f)
4 {
5         f->mode |= f->mode-1;
6         if (f->wpos > f->buf) f->write(f, 0, 0);
7         f->wpos = f->wbase = f->wend = 0;
8         if (f->flags & (F_EOF|F_NORD)) {
9                 if (f->flags & F_NORD) f->flags |= F_ERR;
10                 return EOF;
11         }
12         f->rpos = f->rend = f->buf;
13         return 0;
14 }