2 .\" Copyright (c) 1998, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH __FBUFSIZE 3C "Feb 5, 1998"
8 __fbufsize, __flbf, __fpending, __fpurge, __freadable, __freading,
9 __fsetlocking, __fwritable, __fwriting, _flushlbf \- interfaces to stdio FILE
15 #include <stdio_ext.h>
17 \fBsize_t\fR \fB__fbufsiz\fR(\fBFILE *\fR\fIstream\fR);
22 \fBint\fR \fB__flbf\fR(\fBFILE *\fR\fIstream\fR);
27 \fBsize_t\fR \fB__fpending\fR(\fBFILE *\fR\fIstream\fR);
32 \fBvoid\fR \fB__fpurge\fR(\fBFILE *\fR\fIstream\fR);
37 \fBint\fR \fB__freadable\fR(\fBFILE *\fR\fIstream\fR);
42 \fBint\fR \fB__freading\fR(\fBFILE *\fR\fIstream\fR);
47 \fBint\fR \fB__fsetlocking\fR(\fBFILE *\fR\fIstream\fR, \fBint\fR \fItype\fR);
52 \fBint\fR \fB__fwritable\fR(\fBFILE *\fR\fIstream\fR);
57 \fBint\fR \fB__fwriting\fR(\fBFILE *\fR\fIstream\fR);
62 \fBvoid\fR \fB_flushlbf\fR(\fBvoid\fR);
68 These functions provide portable access to the members of the \fBstdio\fR(3C)
72 The \fB__fbufsize()\fR function returns in bytes the size of the buffer
73 currently in use by the given stream.
76 The \fB__flbf()\fR function returns non-zero if the stream is line-buffered.
79 The \fB__fpending\fR function returns in bytes the amount of output pending on
83 The \fB__fpurge()\fR function discards any pending buffered I/O on the stream.
86 The \fB__freadable()\fR function returns non-zero if it is possible to read
90 The \fB__freading()\fR function returns non-zero if the file is open readonly,
91 or if the last operation on the stream was a read operation such as
92 \fBfread\fR(3C) or \fBfgetc\fR(3C). Otherwise it returns 0.
95 The \fB__fsetlocking()\fR function allows the type of locking performed by
96 \fBstdio\fR on a given stream to be controlled by the programmer.
99 If \fItype\fR is \fBFSETLOCKING_INTERNAL\fR, \fBstdio\fR performs implicit
100 locking around every operation on the given stream. This is the default system
101 behavior on that stream.
104 If \fItype\fR is \fBFSETLOCKING_BYCALLER\fR, \fBstdio\fR assumes that the
105 caller is responsible for maintaining the integrity of the stream in the face
106 of access by multiple threads. If there is only one thread accessing the
107 stream, nothing further needs to be done. If multiple threads are accessing
108 the stream, then the caller can use the \fBflockfile()\fR, \fBfunlockfile()\fR,
109 and \fBftrylockfile()\fR functions described on the \fBflockfile\fR(3C) manual
110 page to provide the appropriate locking. In both this and the case where
111 \fItype\fR is \fBFSETLOCKING_INTERNAL\fR, \fB__fsetlocking()\fR returns the
112 previous state of the stream.
115 If \fItype\fR is \fBFSETLOCKING_QUERY\fR, \fB__fsetlocking()\fR returns the
116 current state of the stream without changing it.
119 The \fB__fwritable()\fR function returns non-zero if it is possible to write on
123 The \fB__fwriting()\fR function returns non-zero if the file is open write-only
124 or append-only, or if the last operation on the stream was a write operation
125 such as \fBfwrite\fR(3C) or \fBfputc\fR(3C). Otherwise it returns 0.
128 The \fB_flushlbf()\fR function flushes all line-buffered files. It is used
129 when reading from a line-buffered file.
133 Although the contents of the \fBstdio FILE\fR structure have always been
134 private to the \fBstdio\fR implementation, some applications have needed to
135 obtain information about a \fBstdio\fR stream that was not accessible through a
136 supported interface. These applications have resorted to accessing fields of
137 the \fBFILE\fR structure directly, rendering them possibly non-portable to new
138 implementations of \fBstdio\fR, or more likely, preventing enhancements to
139 \fBstdio\fR that would cause those applications to break.
142 In the 64-bit environment, the \fBFILE\fR structure is opaque. The functions
143 described here are provided as a means of obtaining the information that up to
144 now has been retrieved directly from the \fBFILE\fR structure. Because they
145 are based on the needs of existing applications (such as \fBmh\fR and
146 \fBemacs\fR), they may be extended as other programs are ported. Although they
147 may still be non-portable to other operating systems, they will be compatible
148 from each Solaris release to the next. Interfaces that are more portable are
153 See \fBattributes\fR(5) for descriptions of the following attributes:
161 ATTRIBUTE TYPE ATTRIBUTE VALUE
164 \fB__fsetlocking()\fR is Unsafe; all others are MT-Safe
167 Interface Stability Evolving
173 \fBfgetc\fR(3C), \fBflockfile\fR(3C), \fBfputc\fR(3C), \fBfread\fR(3C),
174 \fBfwrite\fR(3C), \fBstdio\fR(3C), \fBattributes\fR(5)