1__fbufsize(3C) Standard C Library Functions __fbufsize(3C)
2
3
4
6 __fbufsize, __flbf, __fpending, __fpurge, __freadable, __freading,
7 __fsetlocking, __fwritable, __fwriting, _flushlbf - interfaces to stdio
8 FILE structure
9
11 #include <stdio.h>
12 #include <stdio_ext.h>
13
14 size_t __fbufsiz(FILE *stream);
15
16
17 int __flbf(FILE *stream);
18
19
20 size_t __fpending(FILE *stream);
21
22
23 void __fpurge(FILE *stream);
24
25
26 int __freadable(FILE *stream);
27
28
29 int __freading(FILE *stream);
30
31
32 int __fsetlocking(FILE *stream, int type);
33
34
35 int __fwritable(FILE *stream);
36
37
38 int __fwriting(FILE *stream);
39
40
41 void _flushlbf(void);
42
43
45 These functions provide portable access to the members of the stdio(3C)
46 FILE structure.
47
48
49 The __fbufsize() function returns in bytes the size of the buffer cur‐
50 rently in use by the given stream.
51
52
53 The __flbf() function returns non-zero if the stream is line-buffered.
54
55
56 The __fpending function returns in bytes the amount of output pending
57 on a stream.
58
59
60 The __fpurge() function discards any pending buffered I/O on the
61 stream.
62
63
64 The __freadable() function returns non-zero if it is possible to read
65 from a stream.
66
67
68 The __freading() function returns non-zero if the file is open read‐
69 only, or if the last operation on the stream was a read operation such
70 as fread(3C) or fgetc(3C). Otherwise it returns 0.
71
72
73 The __fsetlocking() function allows the type of locking performed by
74 stdio on a given stream to be controlled by the programmer.
75
76
77 If type is FSETLOCKING_INTERNAL, stdio performs implicit locking around
78 every operation on the given stream. This is the default system behav‐
79 ior on that stream.
80
81
82 If type is FSETLOCKING_BYCALLER, stdio assumes that the caller is
83 responsible for maintaining the integrity of the stream in the face of
84 access by multiple threads. If there is only one thread accessing the
85 stream, nothing further needs to be done. If multiple threads are
86 accessing the stream, then the caller can use the flockfile(), funlock‐
87 file(), and ftrylockfile() functions described on the flockfile(3C)
88 manual page to provide the appropriate locking. In both this and the
89 case where type is FSETLOCKING_INTERNAL, __fsetlocking() returns the
90 previous state of the stream.
91
92
93 If type is FSETLOCKING_QUERY, __fsetlocking() returns the current state
94 of the stream without changing it.
95
96
97 The __fwritable() function returns non-zero if it is possible to write
98 on a stream.
99
100
101 The __fwriting() function returns non-zero if the file is open write-
102 only or append-only, or if the last operation on the stream was a write
103 operation such as fwrite(3C) or fputc(3C). Otherwise it returns 0.
104
105
106 The _flushlbf() function flushes all line-buffered files. It is used
107 when reading from a line-buffered file.
108
110 Although the contents of the stdio FILE structure have always been pri‐
111 vate to the stdio implementation, some applications have needed to
112 obtain information about a stdio stream that was not accessible through
113 a supported interface. These applications have resorted to accessing
114 fields of the FILE structure directly, rendering them possibly non-por‐
115 table to new implementations of stdio, or more likely, preventing
116 enhancements to stdio that would cause those applications to break.
117
118
119 In the 64-bit environment, the FILE structure is opaque. The functions
120 described here are provided as a means of obtaining the information
121 that up to now has been retrieved directly from the FILE structure.
122 Because they are based on the needs of existing applications (such as
123 mh and emacs), they may be extended as other programs are ported.
124 Although they may still be non-portable to other operating systems,
125 they will be compatible from each Solaris release to the next. Inter‐
126 faces that are more portable are under development.
127
129 See attributes(5) for descriptions of the following attributes:
130
131
132
133
134 ┌─────────────────────────────┬─────────────────────────────┐
135 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
136 ├─────────────────────────────┼─────────────────────────────┤
137 │MT-Level │__fsetlocking() is Unsafe; │
138 │ │all others are MT-Safe │
139 ├─────────────────────────────┼─────────────────────────────┤
140 │Interface Stability │Evolving │
141 └─────────────────────────────┴─────────────────────────────┘
142
144 fgetc(3C), flockfile(3C), fputc(3C), fread(3C), fwrite(3C), stdio(3C),
145 attributes(5)
146
147
148
149SunOS 5.11 5 Feb 1998 __fbufsize(3C)