1 .\" $NetBSD: fseek.3,v 1.25 2010/10/22 21:29:31 christos Exp $
3 .\" Copyright (c) 1990, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" Chris Torek and the American National Standards Committee X3,
8 .\" on Information Processing Systems.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)fseek.3 8.1 (Berkeley) 6/4/93
47 .Nd reposition a stream
53 .Fn fseek "FILE *stream" "long int offset" "int whence"
55 .Fn fseeko "FILE *stream" "off_t offset" "int whence"
57 .Fn ftell "FILE *stream"
59 .Fn ftello "FILE *stream"
61 .Fn rewind "FILE *stream"
63 .Fn fgetpos "FILE * restrict stream" "fpos_t * restrict pos"
65 .Fn fsetpos "FILE * restrict stream" "const fpos_t * restrict pos"
69 function sets the file position indicator for the stream pointed
72 The new position, measured in bytes, is obtained by adding
74 bytes to the position specified by
83 the offset is relative to the
84 start of the file, the current position indicator, or end-of-file,
86 A successful call to the
88 function clears the end-of-file indicator for the stream and undoes
91 function on the same stream.
95 function is identical to the
97 function except that the
105 obtains the current value of the file position indicator for the
111 function is identical to the
113 function except that the return value is of type
118 function sets the file position indicator for the stream pointed
121 to the beginning of the file.
124 .Dl (void)fseek(stream, 0L, SEEK_SET)
126 except that the error indicator for the stream is also cleared
130 In this implementation, the
135 are alternative interfaces equivalent to
143 setting and storing the current value of
144 the file offset into or from the object referenced by
146 In others implementations, an
148 object may be a complex object
149 and these routines may be the only way to portably reposition a text stream.
155 Upon successful completion,
166 return the current offset.
177 return a nonzero value.
178 On error all functions the global variable
180 is set to indicate the error.
183 function does not return an error code, applications need to clear
185 before calling it in order to detect errors.
192 is not a seekable stream.
206 the current file offset cannot be represented correctly in an object of type
219 may also fail and set
221 for any of the errors specified for the routines
251 functions don't store/set shift states of the stream in this implementation.