Correct BSD License clause numbering from 1-2-4 to 1-2-3.
[dragonfly.git] / lib / libc / stdio / ferror.3
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 .\" 3. 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: src/lib/libc/stdio/ferror.3,v 1.13 2009/01/28 14:38:41 trhodes Exp $
34 .\" $DragonFly: src/lib/libc/stdio/ferror.3,v 1.2 2003/06/17 04:26:45 dillon Exp $
35 .\"
36 .Dd January 28, 2009
37 .Dt FERROR 3
38 .Os
39 .Sh NAME
40 .Nm clearerr ,
41 .Nm clearerr_unlocked ,
42 .Nm feof ,
43 .Nm feof_unlocked ,
44 .Nm ferror ,
45 .Nm ferror_unlocked ,
46 .Nm fileno ,
47 .Nm fileno_unlocked
48 .Nd check and reset stream status
49 .Sh LIBRARY
50 .Lb libc
51 .Sh SYNOPSIS
52 .In stdio.h
53 .Ft void
54 .Fn clearerr "FILE *stream"
55 .Ft void
56 .Fn clearerr_unlocked "FILE *stream"
57 .Ft int
58 .Fn feof "FILE *stream"
59 .Ft int
60 .Fn feof_unlocked "FILE *stream"
61 .Ft int
62 .Fn ferror "FILE *stream"
63 .Ft int
64 .Fn ferror_unlocked "FILE *stream"
65 .Ft int
66 .Fn fileno "FILE *stream"
67 .Ft int
68 .Fn fileno_unlocked "FILE *stream"
69 .Sh DESCRIPTION
70 The function
71 .Fn clearerr
72 clears the end-of-file and error indicators for the stream pointed
73 to by
74 .Fa stream .
75 .Pp
76 The function
77 .Fn feof
78 tests the end-of-file indicator for the stream pointed to by
79 .Fa stream ,
80 returning non-zero if it is set.
81 The end-of-file indicator may be cleared by explicitly calling
82 .Fn clearerr ,
83 or as a side-effect of other operations, e.g.\&
84 .Fn fseek .
85 .Pp
86 The function
87 .Fn ferror
88 tests the error indicator for the stream pointed to by
89 .Fa stream ,
90 returning non-zero if it is set.
91 .Pp
92 The function
93 .Fn fileno
94 examines the argument
95 .Fa stream
96 and returns its integer descriptor.
97 .Pp
98 The
99 .Fn clearerr_unlocked ,
100 .Fn feof_unlocked ,
101 .Fn ferror_unlocked ,
102 and
103 .Fn fileno_unlocked
104 functions are equivalent to
105 .Fn clearerr ,
106 .Fn feof ,
107 .Fn ferror ,
108 and
109 .Fn fileno
110 respectively, except that the caller is responsible for locking the stream
111 with
112 .Xr flockfile 3
113 before calling them.
114 These functions may be used to avoid the overhead of locking the stream
115 and to prevent races when multiple threads are operating on the same stream.
116 .Sh ERRORS
117 These functions should not fail and do not set the external
118 variable
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
126 The functions
127 .Fn clearerr ,
128 .Fn feof ,
129 and
130 .Fn ferror
131 conform to
132 .St -isoC .