Annotation of 40BSD/libc/stdio/ftell.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Return file offset.
                      3:  * Coordinates with buffering.
                      4:  */
                      5: 
                      6: #include       <stdio.h>
                      7: long   lseek();
                      8: 
                      9: 
                     10: long ftell(iop)
                     11: FILE *iop;
                     12: {
                     13:        long tres;
                     14:        register adjust;
                     15: 
                     16:        if (iop->_cnt < 0)
                     17:                iop->_cnt = 0;
                     18:        if (iop->_flag&_IOREAD)
                     19:                adjust = - iop->_cnt;
                     20:        else if (iop->_flag&_IOWRT) {
                     21:                adjust = 0;
                     22:                if (iop->_base && (iop->_flag&_IONBF)==0)
                     23:                        adjust = iop->_ptr - iop->_base;
                     24:        } else
                     25:                return(-1);
                     26:        tres = lseek(fileno(iop), 0L, 1);
                     27:        if (tres<0)
                     28:                return(tres);
                     29:        tres += adjust;
                     30:        return(tres);
                     31: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.