1: /*	@(#)ftell.c	2.1	SCCS id keyword	*/
   2: /*
   3:  * Return file offset.
   4:  * Coordinates with buffering.
   5:  */
   6: 
   7: #include    <stdio.h>
   8: long    lseek();
   9: 
  10: 
  11: long ftell(iop)
  12: FILE *iop;
  13: {
  14:     long tres;
  15:     register adjust;
  16: 
  17:     if (iop->_cnt < 0)
  18:         iop->_cnt = 0;
  19:     if (iop->_flag&_IOREAD)
  20:         adjust = - iop->_cnt;
  21:     else if(iop->_flag&(_IOWRT|_IORW)) {
  22:         adjust = 0;
  23:         if (iop->_flag&_IOWRT && iop->_base && (iop->_flag&_IONBF)==0)
  24:             adjust = iop->_ptr - iop->_base;
  25:     } else
  26:         return(-1);
  27:     tres = lseek(fileno(iop), 0L, 1);
  28:     if (tres<0)
  29:         return(tres);
  30:     tres += adjust;
  31:     return(tres);
  32: }
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 738
Valid CSS Valid XHTML 1.0 Strict