Annotation of researchv10dc/libI77/notused/ftell.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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