xref: /freebsd/lib/libc/stdio/ferror.3 (revision f0a75d274af375d15b97b830966b99a02b7db911)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)ferror.3	8.2 (Berkeley) 4/19/94
33.\" $FreeBSD$
34.\"
35.Dd January 10, 2003
36.Dt FERROR 3
37.Os
38.Sh NAME
39.Nm clearerr ,
40.Nm clearerr_unlocked ,
41.Nm feof ,
42.Nm feof_unlocked ,
43.Nm ferror ,
44.Nm ferror_unlocked ,
45.Nm fileno ,
46.Nm fileno_unlocked
47.Nd check and reset stream status
48.Sh LIBRARY
49.Lb libc
50.Sh SYNOPSIS
51.In stdio.h
52.Ft void
53.Fn clearerr "FILE *stream"
54.Ft void
55.Fn clearerr_unlocked "FILE *stream"
56.Ft int
57.Fn feof "FILE *stream"
58.Ft int
59.Fn feof_unlocked "FILE *stream"
60.Ft int
61.Fn ferror "FILE *stream"
62.Ft int
63.Fn ferror_unlocked "FILE *stream"
64.Ft int
65.Fn fileno "FILE *stream"
66.Ft int
67.Fn fileno_unlocked "FILE *stream"
68.Sh DESCRIPTION
69The function
70.Fn clearerr
71clears the end-of-file and error indicators for the stream pointed
72to by
73.Fa stream .
74.Pp
75The function
76.Fn feof
77tests the end-of-file indicator for the stream pointed to by
78.Fa stream ,
79returning non-zero if it is set.
80The end-of-file indicator can only be cleared by the function
81.Fn clearerr .
82.Pp
83The function
84.Fn ferror
85tests the error indicator for the stream pointed to by
86.Fa stream ,
87returning non-zero if it is set.
88The error indicator can only be reset by the
89.Fn clearerr
90function.
91.Pp
92The function
93.Fn fileno
94examines the argument
95.Fa stream
96and returns its integer descriptor.
97.Pp
98The
99.Fn clearerr_unlocked ,
100.Fn feof_unlocked ,
101.Fn ferror_unlocked ,
102and
103.Fn fileno_unlocked
104functions are equivalent to
105.Fn clearerr ,
106.Fn feof ,
107.Fn ferror ,
108and
109.Fn fileno
110respectively, except that the caller is responsible for locking the stream
111with
112.Xr flockfile 3
113before calling them.
114These functions may be used to avoid the overhead of locking the stream
115and to prevent races when multiple threads are operating on the same stream.
116.Sh ERRORS
117These functions should not fail and do not set the external
118variable
119.Va errno .
120.Sh SEE ALSO
121.Xr open 2 ,
122.Xr fdopen 3 ,
123.Xr flockfile 3 ,
124.Xr stdio 3
125.Sh STANDARDS
126The functions
127.Fn clearerr ,
128.Fn feof ,
129and
130.Fn ferror
131conform to
132.St -isoC .
133