Back to index

glibc  2.9
Functions
ioftell.c File Reference
#include "libioP.h"
#include <stdlib.h>
#include <errno.h>

Go to the source code of this file.

Functions

long int _IO_ftell (_IO_FILE *fp)

Function Documentation

long int _IO_ftell ( _IO_FILE fp)

Definition at line 35 of file ioftell.c.

{
  _IO_off64_t pos;
  CHECK_FILE (fp, -1L);
  _IO_acquire_lock (fp);
  pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0);
  if (_IO_in_backup (fp) && pos != _IO_pos_BAD)
    {
      if (_IO_vtable_offset (fp) != 0 || fp->_mode <= 0)
       pos -= fp->_IO_save_end - fp->_IO_save_base;
    }
  _IO_release_lock (fp);
  if (pos == _IO_pos_BAD)
    {
#ifdef EIO
      if (errno == 0)
       __set_errno (EIO);
#endif
      return -1L;
    }
  if ((_IO_off64_t) (long int) pos != pos)
    {
#ifdef EOVERFLOW
      __set_errno (EOVERFLOW);
#endif
      return -1L;
    }
  return pos;
}

Here is the call graph for this function: