[444] | 1 | /* |
---|
| 2 | FUNCTION |
---|
| 3 | <<fgetpos64>>---record position in a large stream or file |
---|
| 4 | |
---|
| 5 | INDEX |
---|
| 6 | fgetpos64 |
---|
| 7 | INDEX |
---|
| 8 | _fgetpos64_r |
---|
| 9 | |
---|
| 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]>); |
---|
| 15 | |
---|
| 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. |
---|
| 20 | |
---|
| 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. |
---|
| 26 | |
---|
| 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>>. |
---|
| 30 | |
---|
| 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>>. |
---|
| 36 | |
---|
| 37 | PORTABILITY |
---|
| 38 | <<fgetpos64>> is a glibc extension. |
---|
| 39 | |
---|
| 40 | No supporting OS subroutines are required. |
---|
| 41 | */ |
---|
| 42 | |
---|
| 43 | #include <stdio.h> |
---|
| 44 | |
---|
| 45 | #ifdef __LARGE64_FILES |
---|
| 46 | |
---|
| 47 | int |
---|
| 48 | _fgetpos64_r (struct _reent * ptr, |
---|
| 49 | FILE * fp, |
---|
| 50 | _fpos64_t * pos) |
---|
| 51 | { |
---|
| 52 | *pos = (_fpos64_t)_ftello64_r (ptr, fp); |
---|
| 53 | |
---|
| 54 | if (*pos != -1) |
---|
| 55 | { |
---|
| 56 | return 0; |
---|
| 57 | } |
---|
| 58 | return 1; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | #ifndef _REENT_ONLY |
---|
| 62 | |
---|
| 63 | int |
---|
| 64 | fgetpos64 (FILE * fp, |
---|
| 65 | _fpos64_t * pos) |
---|
| 66 | { |
---|
| 67 | return _fgetpos64_r (_REENT, fp, pos); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | #endif /* !_REENT_ONLY */ |
---|
| 71 | |
---|
| 72 | #endif /* __LARGE64_FILES */ |
---|