Debian Codegraph @

upstream/debian-unstable/man3/stdio_ext.3

raw
1 '\" t
2 .\" Copyright 2001, Andries E. Brouwer <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH stdio_ext 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 __fbufsize, __flbf, __fpending, __fpurge, __freadable,
10 __freading, __fsetlocking, __fwritable, __fwriting, _flushlbf \-
11 interfaces to stdio FILE structure
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ,\~ \-lc )
15 .SH SYNOPSIS
16 .nf
17 .B #include <stdio.h>
18 .B #include <stdio_ext.h>
19 .P
20 .BI "size_t __fbufsize(FILE *" stream );
21 .BI "size_t __fpending(FILE *" stream );
22 .BI "int __flbf(FILE *" stream );
23 .BI "int __freadable(FILE *" stream );
24 .BI "int __fwritable(FILE *" stream );
25 .BI "int __freading(FILE *" stream );
26 .BI "int __fwriting(FILE *" stream );
27 .BI "int __fsetlocking(FILE *" stream ", int " type );
28 .B "void _flushlbf(void);"
29 .BI "void __fpurge(FILE *" stream );
30 .fi
31 .SH DESCRIPTION
32 Solaris introduced routines to allow portable access to the
33 internals of the
34 .I FILE
35 structure, and glibc also implemented these.
36 .P
37 The
38 .BR __fbufsize ()
39 function returns the size of the buffer currently used
40 by the given stream.
41 .P
42 The
43 .BR __fpending ()
44 function returns the number of characters in the output buffer.
45 For wide-oriented streams the unit is wide characters.
46 This function is undefined on buffers in reading mode,
47 or opened read-only.
48 .P
49 The
50 .BR __flbf ()
51 function returns a nonzero value if the stream is line-buffered,
52 and zero otherwise.
53 .P
54 The
55 .BR __freadable ()
56 function returns a nonzero value if the stream allows reading,
57 and zero otherwise.
58 .P
59 The
60 .BR __fwritable ()
61 function returns a nonzero value if the stream allows writing,
62 and zero otherwise.
63 .P
64 The
65 .BR __freading ()
66 function returns a nonzero value if the stream is read-only, or
67 if the last operation on the stream was a read operation,
68 and zero otherwise.
69 .P
70 The
71 .BR __fwriting ()
72 function returns a nonzero value if the stream is write-only (or
73 append-only), or if the last operation on the stream was a write
74 operation, and zero otherwise.
75 .P
76 The
77 .BR __fsetlocking ()
78 function can be used to select the desired type of locking on the stream.
79 It returns the current type.
80 The
81 .I type
82 argument can take the following three values:
83 .TP
84 .B FSETLOCKING_INTERNAL
85 Perform implicit locking around every operation on the given stream
86 (except for the *_unlocked ones).
87 This is the default.
88 .TP
89 .B FSETLOCKING_BYCALLER
90 The caller will take care of the locking (possibly using
91 .BR flockfile (3)
92 in case there is more than one thread), and the stdio routines
93 will not do locking until the state is reset to
94 .BR FSETLOCKING_INTERNAL .
95 .TP
96 .B FSETLOCKING_QUERY
97 Don't change the type of locking.
98 (Only return it.)
99 .P
100 The
101 .BR _flushlbf ()
102 function flushes all line-buffered streams.
103 (Presumably so that
104 output to a terminal is forced out, say before reading keyboard input.)
105 .P
106 The
107 .BR __fpurge ()
108 function discards the contents of the stream's buffer.
109 .SH ATTRIBUTES
110 For an explanation of the terms used in this section, see
111 .BR attributes (7).
112 .TS
113 allbox;
114 lbx lb lb
115 l l l.
116 Interface Attribute Value
117 T{
118 .na
119 .nh
120 .BR __fbufsize (),
121 .BR __fpending (),
122 .BR __fpurge (),
123 .BR __fsetlocking ()
124 T} Thread safety MT-Safe race:stream
125 T{
126 .na
127 .nh
128 .BR __flbf (),
129 .BR __freadable (),
130 .BR __freading (),
131 .BR __fwritable (),
132 .BR __fwriting (),
133 .BR _flushlbf ()
134 T} Thread safety MT-Safe
135 .TE
136 .SH SEE ALSO
137 .BR flockfile (3),
138 .BR fpurge (3)