1 /*
2 Copyright (c) 1990 The Regents of the University of California.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms are permitted
6 provided that the above copyright notice and this paragraph are
7 duplicated in all such forms and that any documentation,
8 and/or other materials related to such
9 distribution and use acknowledge that the software was developed
10 by the University of California, Berkeley.  The name of the
11 University may not be used to endorse or promote products derived
12 from this software without specific prior written permission.
13 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  */
17 /*
18 FUNCTION
19 <<fsetpos64>>---restore position of a large stream or file
20 
21 INDEX
22 	fsetpos64
23 INDEX
24 	_fsetpos64_r
25 
26 SYNOPSIS
27 	#include <stdio.h>
28 	int fsetpos64(FILE *<[fp]>, const _fpos64_t *<[pos]>);
29 	int _fsetpos64_r(struct _reent *<[ptr]>, FILE *<[fp]>,
30 	                 const _fpos64_t *<[pos]>);
31 
32 DESCRIPTION
33 Objects of type <<FILE>> can have a ``position'' that records how much
34 of the file your program has already read.  Many of the <<stdio>> functions
35 depend on this position, and many change it as a side effect.
36 
37 You can use <<fsetpos64>> to return the large file identified by <[fp]> to a
38 previous position <<*<[pos]>>> (after first recording it with <<fgetpos64>>).
39 
40 See <<fseeko64>> for a similar facility.
41 
42 RETURNS
43 <<fgetpos64>> returns <<0>> when successful.  If <<fgetpos64>> fails, the
44 result is <<1>>.  The reason for failure is indicated in <<errno>>:
45 either <<ESPIPE>> (the stream identified by <[fp]> doesn't support
46 64-bit repositioning) or <<EINVAL>> (invalid file position).
47 
48 PORTABILITY
49 <<fsetpos64>> is a glibc extension.
50 
51 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
52 <<lseek64>>, <<read>>, <<sbrk>>, <<write>>.
53 */
54 
55 #define _DEFAULT_SOURCE
56 #include <stdio.h>
57 
58 #ifdef __LARGE64_FILES
59 
60 int
fsetpos64(FILE * iop,const _fpos64_t * pos)61 fsetpos64 (
62 	FILE * iop,
63 	const _fpos64_t * pos)
64 {
65   int x = fseeko64 (iop, (_off64_t)(*pos), SEEK_SET);
66 
67   if (x != 0)
68     return 1;
69   return 0;
70 }
71 
72 #endif /* __LARGE64_FILES */
73