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