From e5888a1ffdae813d7575f5fb02275c6bb07e5199 Mon Sep 17 00:00:00 2001 From: Taru Karttunen Date: Wed, 30 Mar 2011 15:46:40 +0300 Subject: Import sources from 2011-03-30 iso image --- sys/src/libstdio/fseeko.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 sys/src/libstdio/fseeko.c (limited to 'sys/src/libstdio/fseeko.c') diff --git a/sys/src/libstdio/fseeko.c b/sys/src/libstdio/fseeko.c new file mode 100755 index 000000000..48b627bc8 --- /dev/null +++ b/sys/src/libstdio/fseeko.c @@ -0,0 +1,23 @@ +/* + * pANS stdio -- fseeko + */ +#include "iolib.h" +int fseeko(FILE *f, long long offs, int type){ + switch(f->state){ + case ERR: + case CLOSED: + return -1; + case WR: + fflush(f); + break; + case RD: + if(type==1 && f->buf!=f->unbuf) + offs-=f->wp-f->rp; + break; + } + if(f->flags&STRING || seek(f->fd, offs, type)==-1) return -1; + if(f->state==RD) f->rp=f->wp=f->buf; + if(f->state!=OPEN) + f->state=RDWR; + return 0; +} -- cgit v1.2.3