home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / JPLC2.ZIP / FTELL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-22  |  928 b   |  28 lines

  1. /* 1.0  12-17-84 */
  2. /************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1984        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10. #include "stdio.h"
  11.  
  12. /************************************************************************/
  13.     long
  14. ftell(fp)        /* Return offset in bytes relative to ORIGIN of
  15.                FILE fp.                    */
  16. /*----------------------------------------------------------------------*/
  17. FAST FILE *fp;
  18. {
  19.     long offset, lseek();
  20.  
  21.     offset = lseek(fp->_unit, 0L, CURPOS);    /* locate current position */
  22.     if (fp->_flags & _DIRTY)        /* add that in the buffer  */
  23.         offset += (fp->_bptr - fp->_buff); /* not yet written.       */
  24.     else if (fp->_bptr)            /* or in read buffer       */
  25.         offset -= (fp->_bend - fp->_bptr);
  26.     return offset;
  27. }
  28.