1explain_setvbuf(3) Library Functions Manual explain_setvbuf(3)
2
3
4
6 explain_setvbuf - explain setvbuf(3) errors
7
9 #include <libexplain/setvbuf.h>
10 const char *explain_setvbuf(FILE *fp, char *data, int mode, size_t
11 size);
12 const char *explain_errno_setvbuf(int errnum, FILE *fp, char *data, int
13 mode, size_t size);
14 void explain_message_setvbuf(char *message, int message_size, FILE *fp,
15 char *data, int mode, size_t size);
16 void explain_message_errno_setvbuf(char *message, int message_size, int
17 errnum, FILE *fp, char *data, int mode, size_t size);
18
20 These functions may be used to obtain explanations for errors returned
21 by the setvbuf(3) system call.
22
23 explain_setvbuf
24 const char *explain_setvbuf(FILE *fp, char *data, int mode, size_t
25 size);
26
27 The explain_setvbuf function is used to obtain an explanation of an
28 error returned by the setvbuf(3) system call. The least the message
29 will contain is the value of strerror(errno), but usually it will do
30 much better, and indicate the underlying cause in more detail.
31
32 The errno global variable will be used to obtain the error value to be
33 decoded.
34
35 fp The original fp, exactly as passed to the setvbuf(3) system
36 call.
37
38 data The original data, exactly as passed to the setvbuf(3) system
39 call.
40
41 mode The original mode, exactly as passed to the setvbuf(3) system
42 call.
43
44 size The original size, exactly as passed to the setvbuf(3) system
45 call.
46
47 Returns:
48 The message explaining the error. This message buffer is shared
49 by all libexplain functions which do not supply a buffer in
50 their argument list. This will be overwritten by the next call
51 to any libexplain function which shares this buffer, including
52 other threads.
53
54 Note: This function is not thread safe, because it shares a return buf‐
55 fer across all threads, and many other functions in this library.
56
57 Example: This function is intended to be used in a fashion similar to
58 the following example:
59 if (setvbuf(fp, data, mode, size) < 0)
60 {
61 fprintf(stderr, "%s\n", explain_setvbuf(fp, data, mode,
62 size));
63 exit(EXIT_FAILURE);
64 }
65
66 The above code example is available pre‐packaged as the
67 explain_setvbuf_or_die(3) function.
68
69 explain_errno_setvbuf
70 const char *explain_errno_setvbuf(int errnum, FILE *fp, char *data, int
71 mode, size_t size);
72
73 The explain_errno_setvbuf function is used to obtain an explanation of
74 an error returned by the setvbuf(3) system call. The least the message
75 will contain is the value of strerror(errno), but usually it will do
76 much better, and indicate the underlying cause in more detail.
77
78 errnum The error value to be decoded, usually obtained from the errno
79 global variable just before this function is called. This is
80 necessary if you need to call any code between the system call
81 to be explained and this function, because many libc functions
82 will alter the value of errno.
83
84 fp The original fp, exactly as passed to the setvbuf(3) system
85 call.
86
87 data The original data, exactly as passed to the setvbuf(3) system
88 call.
89
90 mode The original mode, exactly as passed to the setvbuf(3) system
91 call.
92
93 size The original size, exactly as passed to the setvbuf(3) system
94 call.
95
96 Returns:
97 The message explaining the error. This message buffer is shared
98 by all libexplain functions which do not supply a buffer in
99 their argument list. This will be overwritten by the next call
100 to any libexplain function which shares this buffer, including
101 other threads.
102
103 Note: This function is not thread safe, because it shares a return buf‐
104 fer across all threads, and many other functions in this library.
105
106 Example: This function is intended to be used in a fashion similar to
107 the following example:
108 if (setvbuf(fp, data, mode, size) < 0)
109 {
110 int err = errno;
111 fprintf(stderr, "%s\n", explain_errno_setvbuf(err, fp, data,
112 mode, size));
113 exit(EXIT_FAILURE);
114 }
115
116 The above code example is available pre‐packaged as the
117 explain_setvbuf_or_die(3) function.
118
119 explain_message_setvbuf
120 void explain_message_setvbuf(char *message, int message_size, FILE *fp,
121 char *data, int mode, size_t size);
122
123 The explain_message_setvbuf function is used to obtain an explanation
124 of an error returned by the setvbuf(3) system call. The least the mes‐
125 sage will contain is the value of strerror(errno), but usually it will
126 do much better, and indicate the underlying cause in more detail.
127
128 The errno global variable will be used to obtain the error value to be
129 decoded.
130
131 message The location in which to store the returned message. If a suit‐
132 able message return buffer is supplied, this function is thread
133 safe.
134
135 message_size
136 The size in bytes of the location in which to store the
137 returned message.
138
139 fp The original fp, exactly as passed to the setvbuf(3) system
140 call.
141
142 data The original data, exactly as passed to the setvbuf(3) system
143 call.
144
145 mode The original mode, exactly as passed to the setvbuf(3) system
146 call.
147
148 size The original size, exactly as passed to the setvbuf(3) system
149 call.
150
151 Example: This function is intended to be used in a fashion similar to
152 the following example:
153 if (setvbuf(fp, data, mode, size) < 0)
154 {
155 char message[3000];
156 explain_message_setvbuf(message, sizeof(message), fp, data,
157 mode, size);
158 fprintf(stderr, "%s\n", message);
159 exit(EXIT_FAILURE);
160 }
161
162 The above code example is available pre‐packaged as the
163 explain_setvbuf_or_die(3) function.
164
165 explain_message_errno_setvbuf
166 void explain_message_errno_setvbuf(char *message, int message_size, int
167 errnum, FILE *fp, char *data, int mode, size_t size);
168
169 The explain_message_errno_setvbuf function is used to obtain an expla‐
170 nation of an error returned by the setvbuf(3) system call. The least
171 the message will contain is the value of strerror(errno), but usually
172 it will do much better, and indicate the underlying cause in more
173 detail.
174
175 message The location in which to store the returned message. If a suit‐
176 able message return buffer is supplied, this function is thread
177 safe.
178
179 message_size
180 The size in bytes of the location in which to store the
181 returned message.
182
183 errnum The error value to be decoded, usually obtained from the errno
184 global variable just before this function is called. This is
185 necessary if you need to call any code between the system call
186 to be explained and this function, because many libc functions
187 will alter the value of errno.
188
189 fp The original fp, exactly as passed to the setvbuf(3) system
190 call.
191
192 data The original data, exactly as passed to the setvbuf(3) system
193 call.
194
195 mode The original mode, exactly as passed to the setvbuf(3) system
196 call.
197
198 size The original size, exactly as passed to the setvbuf(3) system
199 call.
200
201 Example: This function is intended to be used in a fashion similar to
202 the following example:
203 if (setvbuf(fp, data, mode, size) < 0)
204 {
205 int err = errno;
206 char message[3000];
207 explain_message_errno_setvbuf(message, sizeof(message), err,
208 fp, data, mode, size);
209 fprintf(stderr, "%s\n", message);
210 exit(EXIT_FAILURE);
211 }
212
213 The above code example is available pre‐packaged as the
214 explain_setvbuf_or_die(3) function.
215
217 setvbuf(3)
218 stream buffering operations
219
220 explain_setvbuf_or_die(3)
221 stream buffering operations and report errors
222
224 libexplain version 1.4
225 Copyright (C) 2010 Peter Miller
226
227
228
229 explain_setvbuf(3)