chiark / gitweb /
debugging for thing that crashed
[inn-innduct.git] / lib / ftello.c
1 /*  $Id: ftello.c 3681 2000-07-29 22:55:18Z rra $
2 **
3 **  Replacement for a missing ftello.
4 **
5 **  ftello is a version of ftell that returns an off_t instead of a long.
6 **  For large file support (and because it's a more logical interface), INN
7 **  uses ftello unconditionally; if ftello isn't provided by a platform but
8 **  fpos_t is compatible with off_t (as in BSDI), define it in terms of
9 **  fgetpos.  Otherwise, just call ftell (which won't work for files over
10 **  2GB).
11 */
12
13 #include "config.h"
14 #include "clibrary.h"
15
16 #if HAVE_LARGE_FPOS_T
17
18 off_t
19 ftello(FILE *stream)
20 {
21     fpos_t fpos;
22
23     if (fgetpos(stream, &fpos) < 0) {
24         return -1;
25     } else {
26         return (off_t) fpos;
27     }
28 }
29
30 #else /* !HAVE_LARGE_FPOS_T */
31
32 off_t
33 ftello(FILE *stream)
34 {
35     return (off_t) ftell(stream);
36 }
37
38 #endif /* !HAVE_LARGE_FPOS_T */