Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / gpl2 / xcvs / dist / lib / fseeko.c
blobd4c0ee0be2f0c4f336bfb634f3156b3a469f85cc
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)
7 any later version.
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. */
14 #ifdef HAVE_CONFIG_H
15 #include "config.h"
16 #endif
18 #include <stdio.h>
19 #include <sys/types.h>
21 #ifdef HAVE_LIMITS_H
22 #include <limits.h>
23 #endif
24 #ifndef LONG_MAX
25 #define LONG_MAX ((long) ((unsigned long) ~0 >> 1))
26 #endif
27 #ifndef LONG_MIN
28 #define LONG_MIN (-1 - LONG_MAX)
29 #endif
32 * A replacement/substitute for fseeko, for hosts that don't have it.
35 int
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)
43 return -1;
44 offset -= pos;
45 whence = SEEK_CUR;
47 return fseek (stream, (long) offset, whence);