OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man3 / stdio_ext.3
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH STDIO_EXT 3 2013-06-21 "" "Linux Programmer's Manual"
26 .SH NAME
27 __fbufsize, __flbf, __fpending, __fpurge, __freadable,
28 __freading, __fsetlocking, __fwritable, __fwriting, _flushlbf \-
29 interfaces to stdio FILE structure
30 .SH SYNOPSIS
31 .B #include <stdio.h>
32 .br
33 .B #include <stdio_ext.h>
34 .sp
35 .BI "size_t __fbufsize(FILE *" stream );
36 .br
37 .BI "size_t __fpending(FILE *" stream );
38 .br
39 .BI "int __flbf(FILE *" stream );
40 .br
41 .BI "int __freadable(FILE *" stream );
42 .br
43 .BI "int __fwritable(FILE *" stream );
44 .br
45 .BI "int __freading(FILE *" stream );
46 .br
47 .BI "int __fwriting(FILE *" stream );
48 .br
49 .BI "int __fsetlocking(FILE *" stream ", int " type );
50 .br
51 .B "void _flushlbf(void);"
52 .br
53 .BI "void __fpurge(FILE *" stream );
54 .SH DESCRIPTION
55 Solaris introduced routines to allow portable access to the
56 internals of the
57 .I FILE
58 structure, and glibc also implemented these.
59 .LP
60 The
61 .BR __fbufsize ()
62 function returns the size of the buffer currently used
63 by the given stream.
64 .LP
65 The
66 .BR __fpending ()
67 function returns the number of bytes in the output buffer.
68 For wide-oriented streams the unit is wide characters.
69 This function is undefined on buffers in reading mode,
70 or opened read-only.
71 .LP
72 The
73 .BR __flbf ()
74 function returns a nonzero value if the stream is line-buffered,
75 and zero otherwise.
76 .LP
77 The
78 .BR __freadable ()
79 function returns a nonzero value if the stream allows reading,
80 and zero otherwise.
81 .LP
82 The
83 .BR __fwritable ()
84 function returns a nonzero value if the stream allows writing,
85 and zero otherwise.
86 .LP
87 The
88 .BR __freading ()
89 function returns a nonzero value if the stream is read-only, or
90 if the last operation on the stream was a read operation,
91 and zero otherwise.
92 .LP
93 The
94 .BR __fwriting ()
95 function returns a nonzero value if the stream is write-only (or
96 append-only), or if the last operation on the stream was a write
97 operation, and zero otherwise.
98 .LP
99 The
100 .BR __fsetlocking ()
101 function can be used to select the desired type of locking on the stream.
102 It returns the current type.
103 The
104 .I type
105 argument can take the following three values:
106 .TP
107 .B FSETLOCKING_INTERNAL
108 Perform implicit locking around every operation on the given stream
109 (except for the *_unlocked ones).
110 This is the default.
111 .TP
112 .B FSETLOCKING_BYCALLER
113 The caller will take care of the locking (possibly using
114 .BR flockfile (3)
115 in case there is more than one thread), and the stdio routines
116 will not do locking until the state is reset to
117 .BR FSETLOCKING_INTERNAL .
118 .TP
119 .B FSETLOCKING_QUERY
120 Don't change the type of locking.
121 (Only return it.)
122 .LP
123 The
124 .BR _flushlbf ()
125 function flushes all line-buffered streams.
126 (Presumably so that
127 output to a terminal is forced out, say before reading keyboard input.)
128 .LP
129 The
130 .BR __fpurge ()
131 function discards the contents of the stream's buffer.
132 .SH ATTRIBUTES
133 .SS Multithreading (see pthreads(7))
134 The
135 .BR __fbufsize (),
136 .BR __fpending (),
137 .BR __fpurge ()
138 and
139 .BR __fsetlocking ()
140 functions do not lock the stream, so they are not thread-safe.
141 .LP
142 The
143 .BR __flbf (),
144 .BR __freadable (),
145 .BR __freading (),
146 .BR __fwritable (),
147 .BR __fwriting ()
148 and
149 .BR _flushlbf ()
150 functions are thread-safe.
151 .SH SEE ALSO
152 .BR flockfile (3),
153 .BR fpurge (3)
154 .SH COLOPHON
155 This page is part of release 3.68 of the Linux
156 .I man-pages
157 project.
158 A description of the project,
159 information about reporting bugs,
160 and the latest version of this page,
161 can be found at
162 \%http://www.kernel.org/doc/man\-pages/.