3 fopen, freopen, fdopen, fileno, fclose, sopenr, sopenw, sclose, fflush, setvbuf, setbuf, fgetpos, ftell, fsetpos, fseek, rewind, feof, ferror, clearerr \- standard buffered input/output package
11 FILE *fopen(char *filename, char *mode)
14 FILE *freopen(char *filename, char *mode, FILE *f)
17 FILE *fdopen(int fd, char *mode)
38 int setvbuf(FILE *f, char *buf, int type, long size)
41 void setbuf(FILE *f, char *buf)
44 int fgetpos(FILE *f, long *pos)
50 int fsetpos(FILE *f, long *pos)
53 int fseek(FILE *f, long offset, int whence)
65 void clearerr(FILE *f)
67 The functions described in this and related pages
74 ANSI C buffered I/O package with extensions.
76 A file with associated buffering is called a
78 and is declared to be a pointer to a defined type
81 creates certain descriptive data for a stream
82 and returns a pointer to designate the stream in all
84 There are three normally open streams with constant
86 the include file and associated with the standard open files:
103 designates no stream at all.
106 opens the file named by
108 and associates a stream with it.
110 returns a pointer to be used to identify
111 the stream in subsequent operations, or
115 is a character string having one of the following values:
118 \fL"r"\fP open for reading
119 \fL"w"\fP truncate to zero length or create for writing
120 \fL"a"\fP append; open or create for writing at end of file
121 \fL"r+"\fP open for update (reading and writing)
122 \fL"w+"\fP truncate to zero length or create for update
123 \fL"a+"\fP append; open or create for update at end of file
126 In addition, each of the above strings can have a
128 somewhere after the first character,
129 meaning `binary file', but this implementation makes no distinction
130 between binary and text files.
133 causes the stream pointed to by
135 to be flushed (see below) and does a
139 on the associated file.
140 It frees any automatically allocated buffer.
142 is called automatically on
144 for all open streams.
147 is like open except that it reuses stream pointer
150 first attempts to close any file associated with
152 it ignores any errors in that close.
155 associates a stream with an open Plan 9 file descriptor.
158 returns the number of the Plan 9 file descriptor associated with the stream.
161 associates a read-only stream with a null-terminated string.
164 opens a stream for writing.
165 No file descriptor is associated with the stream;
166 instead, all output is written to the stream buffer.
169 closes a stream opened with
173 It returns a pointer to the 0 terminated buffer associated with the stream.
175 By default, output to a stream is fully buffered: it is accumulated in
176 a buffer until the buffer is full, and then
180 is used to write the buffer.
181 An exception is standard error, which is line buffered:
182 output is accumulated in a buffer until
183 a newline is written.
184 Input is also fully buffered by default; this means that
186 is used to fill a buffer as much as it can, and then characters
187 are taken from that buffer until it empties.
189 changes the buffering method for file
200 for unbuffered (each character causes a
206 is supplied, it is used as the buffer and
211 is zero, a buffer of the given size is allocated (except for the unbuffered case) using
215 is an older method for changing buffering. If
217 is supplied, it changes to fully buffered with the given buffer, which should
224 is zero, the buffering method changes to unbuffered.
227 flushes the buffer of output stream
229 delivering any unwritten buffered data to the host file.
232 .I file position indicator
233 associated with each stream.
234 It starts out pointing at the first character (unless the file is opened
235 with append mode, in which case the indicator is always ignored).
236 The file position indicator is maintained by the reading and writing
237 functions described in
241 stores the current value of the file position indicator for stream
243 in the object pointed to by
245 It returns zero on success, nonzero otherwise.
247 returns the current value of the file position indicator.
248 The file position indicator is to
249 be used only as an argument to
253 sets the file position indicator for stream
255 to the value of the object pointed to by
257 which shall be a value returned by an earlier call to
260 It returns zero on success, nonzero otherwise.
262 obtains a new position, measured in characters from the beginning
263 of the file, by adding
265 to the position specified by
267 the beginning of the file if
271 the current value of the file position indicator for
273 and the end-of-file for
276 sets the file position indicator to the beginning of the file.
281 upon end of file or error by integer-valued functions that
284 returns non-zero if and only if
286 is at its end of file.
289 returns non-zero if and only if
291 is in the error state. It can get into the error state
292 if a system call failed on the associated file
293 or a memory allocation failed.
295 takes a stream out of the error state.
308 is returned uniformly to indicate that a
310 pointer has not been initialized with
312 input (output) has been attempted on an output (input) stream,
315 pointer designates corrupt or otherwise unintelligible
319 Some of these functions set
322 Buffering of output can prevent output data
323 from being seen until long after it is computed \- perhaps
324 never, as when an abort occurs between buffer filling and flushing.
326 Buffering of input can cause a process to consume
327 more input than it actually uses.
328 This can cause trouble across
331 Buffering may delay the receipt of a write error until a subsequent
333 writing, seeking, or file-closing call.
335 ANSI says that a file can be fully buffered only if
336 the file is not attached to an interactive device.
337 In Plan 9 all are fully buffered except standard error.
345 are not ANSI Stdio functions.
347 Stdio offers no support for runes or
350 Unless external compatibility is necessary, use
354 and is smaller, faster, and simpler than Stdio.