Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdio64 / fgetpos64.c
blob52ead9d0d29a486756bd3104ecf7d04158ef86cc
1 /*
2 FUNCTION
3 <<fgetpos64>>---record position in a large stream or file
5 INDEX
6 fgetpos64
7 INDEX
8 _fgetpos64_r
10 SYNOPSIS
11 #include <stdio.h>
12 int fgetpos64(FILE *<[fp]>, _fpos64_t *<[pos]>);
13 int _fgetpos64_r(struct _reent *<[ptr]>, FILE *<[fp]>,
14 _fpos64_t *<[pos]>);
16 DESCRIPTION
17 Objects of type <<FILE>> can have a ``position'' that records how much
18 of the file your program has already read. Many of the <<stdio>> functions
19 depend on this position, and many change it as a side effect.
21 You can use <<fgetpos64>> to report on the current position for a file
22 identified by <[fp]> that was opened by <<fopen64>>; <<fgetpos>> will write
23 a value representing that position at <<*<[pos]>>>. Later, you can
24 use this value with <<fsetpos64>> to return the file to this
25 position.
27 In the current implementation, <<fgetpos64>> simply uses a character
28 count to represent the file position; this is the same number that
29 would be returned by <<ftello64>>.
31 RETURNS
32 <<fgetpos64>> returns <<0>> when successful. If <<fgetpos64>> fails, the
33 result is <<1>>. Failure occurs on streams that do not support
34 positioning or streams not opened via <<fopen64>>; the global <<errno>>
35 indicates these conditions with the value <<ESPIPE>>.
37 PORTABILITY
38 <<fgetpos64>> is a glibc extension.
40 No supporting OS subroutines are required.
43 #include <stdio.h>
45 #ifdef __LARGE64_FILES
47 int
48 _fgetpos64_r (struct _reent * ptr,
49 FILE * fp,
50 _fpos64_t * pos)
52 *pos = (_fpos64_t)_ftello64_r (ptr, fp);
54 if (*pos != -1)
56 return 0;
58 return 1;
61 #ifndef _REENT_ONLY
63 int
64 fgetpos64 (FILE * fp,
65 _fpos64_t * pos)
67 return _fgetpos64_r (_REENT, fp, pos);
70 #endif /* !_REENT_ONLY */
72 #endif /* __LARGE64_FILES */