File: ftello.c

package info (click to toggle)
inn2 2.4.5-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,912 kB
  • ctags: 7,860
  • sloc: ansic: 85,104; perl: 11,427; sh: 9,863; makefile: 2,498; yacc: 1,563; python: 298; lex: 252; tcl: 7
file content (38 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*  $Id: ftello.c 3681 2000-07-29 22:55:18Z rra $
**
**  Replacement for a missing ftello.
**
**  ftello is a version of ftell that returns an off_t instead of a long.
**  For large file support (and because it's a more logical interface), INN
**  uses ftello unconditionally; if ftello isn't provided by a platform but
**  fpos_t is compatible with off_t (as in BSDI), define it in terms of
**  fgetpos.  Otherwise, just call ftell (which won't work for files over
**  2GB).
*/

#include "config.h"
#include "clibrary.h"

#if HAVE_LARGE_FPOS_T

off_t
ftello(FILE *stream)
{
    fpos_t fpos;

    if (fgetpos(stream, &fpos) < 0) {
        return -1;
    } else {
        return (off_t) fpos;
    }
}

#else /* !HAVE_LARGE_FPOS_T */

off_t
ftello(FILE *stream)
{
    return (off_t) ftell(stream);
}

#endif /* !HAVE_LARGE_FPOS_T */