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