|
Packit |
549fdc |
/* An ftell() function that works around platform bugs.
|
|
Packit |
549fdc |
Copyright (C) 2007-2016 Free Software Foundation, Inc.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
This program is free software: you can redistribute it and/or modify
|
|
Packit |
549fdc |
it under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
549fdc |
the Free Software Foundation; either version 2.1 of the License, or
|
|
Packit |
549fdc |
(at your option) any later version.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
This program is distributed in the hope that it will be useful,
|
|
Packit |
549fdc |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
549fdc |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
549fdc |
GNU Lesser General Public License for more details.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
549fdc |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#include <config.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
/* Specification. */
|
|
Packit |
549fdc |
#include <stdio.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#include <errno.h>
|
|
Packit |
549fdc |
#include <limits.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
long
|
|
Packit |
549fdc |
ftell (FILE *fp)
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
/* Use the replacement ftello function with all its workarounds. */
|
|
Packit |
549fdc |
off_t offset = ftello (fp);
|
|
Packit |
549fdc |
if (LONG_MIN <= offset && offset <= LONG_MAX)
|
|
Packit |
549fdc |
return /* (long) */ offset;
|
|
Packit |
549fdc |
else
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
errno = EOVERFLOW;
|
|
Packit |
549fdc |
return -1;
|
|
Packit |
549fdc |
}
|
|
Packit |
549fdc |
}
|