summaryrefslogtreecommitdiff
path: root/sys/src/libstdio/fseeko.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/libstdio/fseeko.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/libstdio/fseeko.c')
-rwxr-xr-xsys/src/libstdio/fseeko.c23
1 files changed, 23 insertions, 0 deletions
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;
+}