1: #if defined(LIBC_SCCS) && !defined(lint)
   2: static char sccsid[] = "@(#)ftell.c	5.2 (Berkeley) 3/9/86";
   3: #endif LIBC_SCCS and not lint
   4: 
   5: /*
   6:  * Return file offset.
   7:  * Coordinates with buffering.
   8:  */
   9: 
  10: #include    <stdio.h>
  11: long    lseek();
  12: 
  13: 
  14: long ftell(iop)
  15: register FILE *iop;
  16: {
  17:     register long tres;
  18:     register adjust;
  19: 
  20:     if (iop->_cnt < 0)
  21:         iop->_cnt = 0;
  22:     if (iop->_flag&_IOREAD)
  23:         adjust = - iop->_cnt;
  24:     else if (iop->_flag&(_IOWRT|_IORW)) {
  25:         adjust = 0;
  26:         if (iop->_flag&_IOWRT && iop->_base && (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:         return(tres);
  33:     tres += adjust;
  34:     return(tres);
  35: }

Defined functions

ftell defined in line 14; used 182 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1151
Valid CSS Valid XHTML 1.0 Strict