1 /* fseeko.c -- an implementation of fseek() with an off_t argument.
2 Copyright (C) 2003, Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. */
19 #include <sys/types.h>
25 #define LONG_MAX ((long) ((unsigned long) ~0 >> 1))
28 #define LONG_MIN (-1 - LONG_MAX)
32 * A replacement/substitute for fseeko, for hosts that don't have it.
36 fseeko (FILE *stream
, off_t offset
, int whence
)
38 while (offset
!= (long) offset
)
40 long pos
= (offset
< 0) ? LONG_MIN
: LONG_MAX
;
42 if (fseek (stream
, pos
, whence
) != 0)
47 return fseek (stream
, (long) offset
, whence
);