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