|
Packit |
6c4009 |
/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
As a special exception, if you link the code in this file with
|
|
Packit |
6c4009 |
files compiled with a GNU compiler to produce an executable,
|
|
Packit |
6c4009 |
that does not cause the resulting executable to be covered by
|
|
Packit |
6c4009 |
the GNU Lesser General Public License. This exception does not
|
|
Packit |
6c4009 |
however invalidate any other reasons why the executable file
|
|
Packit |
6c4009 |
might be covered by the GNU Lesser General Public License.
|
|
Packit |
6c4009 |
This exception applies to code released by its copyright holders
|
|
Packit |
6c4009 |
in files containing the exception. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* We need to avoid the header declarations of these, because
|
|
Packit |
6c4009 |
the types don't match _IO_fgetpos and then the compiler will
|
|
Packit |
6c4009 |
complain about the mismatch when we do the alias below. */
|
|
Packit |
6c4009 |
#define _IO_new_fgetpos64 __renamed__IO_new_fgetpos64
|
|
Packit |
6c4009 |
#define _IO_fgetpos64 __renamed__IO_fgetpos64
|
|
Packit |
6c4009 |
#define fgetpos64 __renamed_fgetpos64
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include "libioP.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#undef _IO_new_fgetpos64
|
|
Packit |
6c4009 |
#undef _IO_fgetpos64
|
|
Packit |
6c4009 |
#undef fgetpos64
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <errno.h>
|
|
Packit |
6c4009 |
#include <stdlib.h>
|
|
Packit |
6c4009 |
#include <shlib-compat.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int
|
|
Packit |
6c4009 |
_IO_new_fgetpos (FILE *fp, __fpos_t *posp)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
off64_t pos;
|
|
Packit |
6c4009 |
int result = 0;
|
|
Packit |
6c4009 |
CHECK_FILE (fp, EOF);
|
|
Packit |
6c4009 |
_IO_acquire_lock (fp);
|
|
Packit |
6c4009 |
pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0);
|
|
Packit |
6c4009 |
if (_IO_in_backup (fp) && pos != _IO_pos_BAD)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (fp->_mode <= 0)
|
|
Packit |
6c4009 |
pos -= fp->_IO_save_end - fp->_IO_save_base;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (pos == _IO_pos_BAD)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* ANSI explicitly requires setting errno to a positive value on
|
|
Packit |
6c4009 |
failure. */
|
|
Packit |
6c4009 |
if (errno == 0)
|
|
Packit |
6c4009 |
__set_errno (EIO);
|
|
Packit |
6c4009 |
result = EOF;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else if ((off64_t) (__typeof (posp->__pos)) pos != pos)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
__set_errno (EOVERFLOW);
|
|
Packit |
6c4009 |
result = EOF;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
posp->__pos = pos;
|
|
Packit Service |
3b0880 |
if (fp->_mode > 0
|
|
Packit Service |
3b0880 |
&& (*fp->_codecvt->__codecvt_do_encoding) (fp->_codecvt) < 0)
|
|
Packit |
6c4009 |
/* This is a stateful encoding, safe the state. */
|
|
Packit |
6c4009 |
posp->__state = fp->_wide_data->_IO_state;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
_IO_release_lock (fp);
|
|
Packit |
6c4009 |
return result;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
strong_alias (_IO_new_fgetpos, __new_fgetpos)
|
|
Packit |
6c4009 |
versioned_symbol (libc, _IO_new_fgetpos, _IO_fgetpos, GLIBC_2_2);
|
|
Packit |
6c4009 |
versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __OFF_T_MATCHES_OFF64_T
|
|
Packit |
6c4009 |
strong_alias (_IO_new_fgetpos, _IO_new_fgetpos64)
|
|
Packit |
6c4009 |
strong_alias (_IO_new_fgetpos64, __new_fgetpos64)
|
|
Packit |
6c4009 |
versioned_symbol (libc, _IO_new_fgetpos64, _IO_fgetpos64, GLIBC_2_2);
|
|
Packit |
6c4009 |
versioned_symbol (libc, __new_fgetpos64, fgetpos64, GLIBC_2_2);
|
|
Packit |
6c4009 |
#endif
|