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|_IORW)) {
  21:         adjust = 0;
  22:         if (iop->_flag&_IOWRT && 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: }
Last modified: 1979-05-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 443
Valid CSS Valid XHTML 1.0 Strict