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