[444] | 1 | /* |
---|
| 2 | FUNCTION |
---|
| 3 | <<fsetpos64>>---restore position of a large stream or file |
---|
| 4 | |
---|
| 5 | INDEX |
---|
| 6 | fsetpos64 |
---|
| 7 | INDEX |
---|
| 8 | _fsetpos64_r |
---|
| 9 | |
---|
| 10 | SYNOPSIS |
---|
| 11 | #include <stdio.h> |
---|
| 12 | int fsetpos64(FILE *<[fp]>, const _fpos64_t *<[pos]>); |
---|
| 13 | int _fsetpos64_r(struct _reent *<[ptr]>, FILE *<[fp]>, |
---|
| 14 | const _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 <<fsetpos64>> to return the large file identified by <[fp]> to a |
---|
| 22 | previous position <<*<[pos]>>> (after first recording it with <<fgetpos64>>). |
---|
| 23 | |
---|
| 24 | See <<fseeko64>> for a similar facility. |
---|
| 25 | |
---|
| 26 | RETURNS |
---|
| 27 | <<fgetpos64>> returns <<0>> when successful. If <<fgetpos64>> fails, the |
---|
| 28 | result is <<1>>. The reason for failure is indicated in <<errno>>: |
---|
| 29 | either <<ESPIPE>> (the stream identified by <[fp]> doesn't support |
---|
| 30 | 64-bit repositioning) or <<EINVAL>> (invalid file position). |
---|
| 31 | |
---|
| 32 | PORTABILITY |
---|
| 33 | <<fsetpos64>> is a glibc extension. |
---|
| 34 | |
---|
| 35 | Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
---|
| 36 | <<lseek64>>, <<read>>, <<sbrk>>, <<write>>. |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #include <stdio.h> |
---|
| 40 | |
---|
| 41 | #ifdef __LARGE64_FILES |
---|
| 42 | |
---|
| 43 | int |
---|
| 44 | _fsetpos64_r (struct _reent *ptr, |
---|
| 45 | FILE * iop, |
---|
| 46 | const _fpos64_t * pos) |
---|
| 47 | { |
---|
| 48 | int x = _fseeko64_r (ptr, iop, (_off64_t)(*pos), SEEK_SET); |
---|
| 49 | |
---|
| 50 | if (x != 0) |
---|
| 51 | return 1; |
---|
| 52 | return 0; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | #ifndef _REENT_ONLY |
---|
| 56 | |
---|
| 57 | int |
---|
| 58 | fsetpos64 (FILE * iop, |
---|
| 59 | const _fpos64_t * pos) |
---|
| 60 | { |
---|
| 61 | return _fsetpos64_r (_REENT, iop, pos); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | #endif /* !_REENT_ONLY */ |
---|
| 65 | |
---|
| 66 | #endif /* __LARGE64_FILES */ |
---|