]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libstdio/ftell.c
add HISTORY to various man pages
[plan9front.git] / sys / src / libstdio / ftell.c
1 /*
2  * pANS stdio -- ftell
3  */
4 #include "iolib.h"
5 long ftell(FILE *f){
6         long seekp=seek(f->fd, 0L, 1);
7         if(seekp<0) return -1;          /* enter error state? */
8         switch(f->state){
9         default:
10                 return seekp;
11         case RD:
12                 return seekp-(f->wp-f->rp);
13         case WR:
14                 return (f->flags&LINEBUF?f->lp:f->wp)-f->buf+seekp;
15         }
16 }