Commit | Line | Data |
---|---|---|
d0391c55 KS |
1 | /* Copyright (c) 1979 Regents of the University of California */ |
2 | #include <stdio.h> | |
3 | ||
4 | /* | |
5 | * Return file offset. | |
6 | * Coordinates with buffering. | |
7 | */ | |
8 | ||
9 | long tell(); | |
10 | ||
11 | long ftell(iop) | |
12 | register FILE *iop; | |
13 | { | |
14 | long tres; | |
15 | register adjust; | |
16 | ||
17 | if (iop->_cnt < 0) | |
18 | iop->_cnt = 0; | |
19 | if (!(iop->_flag & (_IOREAD|_IOWRT))) | |
20 | _error("ftell\n"); | |
21 | tres = tell(fileno(iop)); | |
22 | if (tres<0) | |
23 | return(tres); | |
24 | return(tres - iop->_delta + iop->_ptr - iop->_base); | |
25 | } |