summaryrefslogtreecommitdiffstats
path: root/gl/strerror.c
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2009-05-19 22:32:10 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2009-05-19 22:32:10 (GMT)
commit50b3ff7b91e78a61aca93247bee586d6d7eb27c8 (patch)
treedb4c7eee24479ac7ee6888ce1562facf60159b71 /gl/strerror.c
parent2701ccd500e60537a8c2977a81549ff33eeaef3f (diff)
downloadmonitoring-plugins-50b3ff7b91e78a61aca93247bee586d6d7eb27c8.tar.gz
Sync with the latest Gnulib code (cb75dc5)
Signed-off-by: Holger Weiss <holger@zedat.fu-berlin.de>
Diffstat (limited to 'gl/strerror.c')
-rw-r--r--gl/strerror.c204
1 files changed, 136 insertions, 68 deletions
diff --git a/gl/strerror.c b/gl/strerror.c
index 787575f..798d854 100644
--- a/gl/strerror.c
+++ b/gl/strerror.c
@@ -1,6 +1,6 @@
1/* strerror.c --- POSIX compatible system error routine 1/* strerror.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2007-2008 Free Software Foundation, Inc. 3 Copyright (C) 2007-2009 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -40,94 +40,133 @@
40char * 40char *
41rpl_strerror (int n) 41rpl_strerror (int n)
42{ 42{
43 char const *msg = NULL;
43 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ 44 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
44 switch (n) 45 switch (n)
45 { 46 {
46# if GNULIB_defined_ETXTBSY 47# if GNULIB_defined_ETXTBSY
47 case ETXTBSY: 48 case ETXTBSY:
48 return "Text file busy"; 49 msg = "Text file busy";
50 break;
49# endif 51# endif
50 52
51# if GNULIB_defined_ESOCK /* native Windows platforms */ 53# if GNULIB_defined_ESOCK /* native Windows platforms */
52 /* EWOULDBLOCK is the same as EAGAIN. */ 54 /* EWOULDBLOCK is the same as EAGAIN. */
53 case EINPROGRESS: 55 case EINPROGRESS:
54 return "Operation now in progress"; 56 msg = "Operation now in progress";
57 break;
55 case EALREADY: 58 case EALREADY:
56 return "Operation already in progress"; 59 msg = "Operation already in progress";
60 break;
57 case ENOTSOCK: 61 case ENOTSOCK:
58 return "Socket operation on non-socket"; 62 msg = "Socket operation on non-socket";
63 break;
59 case EDESTADDRREQ: 64 case EDESTADDRREQ:
60 return "Destination address required"; 65 msg = "Destination address required";
66 break;
61 case EMSGSIZE: 67 case EMSGSIZE:
62 return "Message too long"; 68 msg = "Message too long";
69 break;
63 case EPROTOTYPE: 70 case EPROTOTYPE:
64 return "Protocol wrong type for socket"; 71 msg = "Protocol wrong type for socket";
72 break;
65 case ENOPROTOOPT: 73 case ENOPROTOOPT:
66 return "Protocol not available"; 74 msg = "Protocol not available";
75 break;
67 case EPROTONOSUPPORT: 76 case EPROTONOSUPPORT:
68 return "Protocol not supported"; 77 msg = "Protocol not supported";
78 break;
69 case ESOCKTNOSUPPORT: 79 case ESOCKTNOSUPPORT:
70 return "Socket type not supported"; 80 msg = "Socket type not supported";
81 break;
71 case EOPNOTSUPP: 82 case EOPNOTSUPP:
72 return "Operation not supported"; 83 msg = "Operation not supported";
84 break;
73 case EPFNOSUPPORT: 85 case EPFNOSUPPORT:
74 return "Protocol family not supported"; 86 msg = "Protocol family not supported";
87 break;
75 case EAFNOSUPPORT: 88 case EAFNOSUPPORT:
76 return "Address family not supported by protocol"; 89 msg = "Address family not supported by protocol";
90 break;
77 case EADDRINUSE: 91 case EADDRINUSE:
78 return "Address already in use"; 92 msg = "Address already in use";
93 break;
79 case EADDRNOTAVAIL: 94 case EADDRNOTAVAIL:
80 return "Cannot assign requested address"; 95 msg = "Cannot assign requested address";
96 break;
81 case ENETDOWN: 97 case ENETDOWN:
82 return "Network is down"; 98 msg = "Network is down";
99 break;
83 case ENETUNREACH: 100 case ENETUNREACH:
84 return "Network is unreachable"; 101 msg = "Network is unreachable";
102 break;
85 case ENETRESET: 103 case ENETRESET:
86 return "Network dropped connection on reset"; 104 msg = "Network dropped connection on reset";
105 break;
87 case ECONNABORTED: 106 case ECONNABORTED:
88 return "Software caused connection abort"; 107 msg = "Software caused connection abort";
108 break;
89 case ECONNRESET: 109 case ECONNRESET:
90 return "Connection reset by peer"; 110 msg = "Connection reset by peer";
111 break;
91 case ENOBUFS: 112 case ENOBUFS:
92 return "No buffer space available"; 113 msg = "No buffer space available";
114 break;
93 case EISCONN: 115 case EISCONN:
94 return "Transport endpoint is already connected"; 116 msg = "Transport endpoint is already connected";
117 break;
95 case ENOTCONN: 118 case ENOTCONN:
96 return "Transport endpoint is not connected"; 119 msg = "Transport endpoint is not connected";
120 break;
97 case ESHUTDOWN: 121 case ESHUTDOWN:
98 return "Cannot send after transport endpoint shutdown"; 122 msg = "Cannot send after transport endpoint shutdown";
123 break;
99 case ETOOMANYREFS: 124 case ETOOMANYREFS:
100 return "Too many references: cannot splice"; 125 msg = "Too many references: cannot splice";
126 break;
101 case ETIMEDOUT: 127 case ETIMEDOUT:
102 return "Connection timed out"; 128 msg = "Connection timed out";
129 break;
103 case ECONNREFUSED: 130 case ECONNREFUSED:
104 return "Connection refused"; 131 msg = "Connection refused";
132 break;
105 case ELOOP: 133 case ELOOP:
106 return "Too many levels of symbolic links"; 134 msg = "Too many levels of symbolic links";
135 break;
107 case EHOSTDOWN: 136 case EHOSTDOWN:
108 return "Host is down"; 137 msg = "Host is down";
138 break;
109 case EHOSTUNREACH: 139 case EHOSTUNREACH:
110 return "No route to host"; 140 msg = "No route to host";
141 break;
111 case EPROCLIM: 142 case EPROCLIM:
112 return "Too many processes"; 143 msg = "Too many processes";
144 break;
113 case EUSERS: 145 case EUSERS:
114 return "Too many users"; 146 msg = "Too many users";
147 break;
115 case EDQUOT: 148 case EDQUOT:
116 return "Disk quota exceeded"; 149 msg = "Disk quota exceeded";
150 break;
117 case ESTALE: 151 case ESTALE:
118 return "Stale NFS file handle"; 152 msg = "Stale NFS file handle";
153 break;
119 case EREMOTE: 154 case EREMOTE:
120 return "Object is remote"; 155 msg = "Object is remote";
156 break;
121# if HAVE_WINSOCK2_H 157# if HAVE_WINSOCK2_H
122 /* WSA_INVALID_HANDLE maps to EBADF */ 158 /* WSA_INVALID_HANDLE maps to EBADF */
123 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ 159 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
124 /* WSA_INVALID_PARAMETER maps to EINVAL */ 160 /* WSA_INVALID_PARAMETER maps to EINVAL */
125 case WSA_OPERATION_ABORTED: 161 case WSA_OPERATION_ABORTED:
126 return "Overlapped operation aborted"; 162 msg = "Overlapped operation aborted";
163 break;
127 case WSA_IO_INCOMPLETE: 164 case WSA_IO_INCOMPLETE:
128 return "Overlapped I/O event object not in signaled state"; 165 msg = "Overlapped I/O event object not in signaled state";
166 break;
129 case WSA_IO_PENDING: 167 case WSA_IO_PENDING:
130 return "Overlapped operations will complete later"; 168 msg = "Overlapped operations will complete later";
169 break;
131 /* WSAEINTR maps to EINTR */ 170 /* WSAEINTR maps to EINTR */
132 /* WSAEBADF maps to EBADF */ 171 /* WSAEBADF maps to EBADF */
133 /* WSAEACCES maps to EACCES */ 172 /* WSAEACCES maps to EACCES */
@@ -172,98 +211,127 @@ rpl_strerror (int n)
172 /* WSAESTALE is ESTALE */ 211 /* WSAESTALE is ESTALE */
173 /* WSAEREMOTE is EREMOTE */ 212 /* WSAEREMOTE is EREMOTE */
174 case WSASYSNOTREADY: 213 case WSASYSNOTREADY:
175 return "Network subsystem is unavailable"; 214 msg = "Network subsystem is unavailable";
215 break;
176 case WSAVERNOTSUPPORTED: 216 case WSAVERNOTSUPPORTED:
177 return "Winsock.dll version out of range"; 217 msg = "Winsock.dll version out of range";
218 break;
178 case WSANOTINITIALISED: 219 case WSANOTINITIALISED:
179 return "Successful WSAStartup not yet performed"; 220 msg = "Successful WSAStartup not yet performed";
221 break;
180 case WSAEDISCON: 222 case WSAEDISCON:
181 return "Graceful shutdown in progress"; 223 msg = "Graceful shutdown in progress";
224 break;
182 case WSAENOMORE: case WSA_E_NO_MORE: 225 case WSAENOMORE: case WSA_E_NO_MORE:
183 return "No more results"; 226 msg = "No more results";
227 break;
184 case WSAECANCELLED: case WSA_E_CANCELLED: 228 case WSAECANCELLED: case WSA_E_CANCELLED:
185 return "Call was canceled"; 229 msg = "Call was canceled";
230 break;
186 case WSAEINVALIDPROCTABLE: 231 case WSAEINVALIDPROCTABLE:
187 return "Procedure call table is invalid"; 232 msg = "Procedure call table is invalid";
233 break;
188 case WSAEINVALIDPROVIDER: 234 case WSAEINVALIDPROVIDER:
189 return "Service provider is invalid"; 235 msg = "Service provider is invalid";
236 break;
190 case WSAEPROVIDERFAILEDINIT: 237 case WSAEPROVIDERFAILEDINIT:
191 return "Service provider failed to initialize"; 238 msg = "Service provider failed to initialize";
239 break;
192 case WSASYSCALLFAILURE: 240 case WSASYSCALLFAILURE:
193 return "System call failure"; 241 msg = "System call failure";
242 break;
194 case WSASERVICE_NOT_FOUND: 243 case WSASERVICE_NOT_FOUND:
195 return "Service not found"; 244 msg = "Service not found";
245 break;
196 case WSATYPE_NOT_FOUND: 246 case WSATYPE_NOT_FOUND:
197 return "Class type not found"; 247 msg = "Class type not found";
248 break;
198 case WSAEREFUSED: 249 case WSAEREFUSED:
199 return "Database query was refused"; 250 msg = "Database query was refused";
251 break;
200 case WSAHOST_NOT_FOUND: 252 case WSAHOST_NOT_FOUND:
201 return "Host not found"; 253 msg = "Host not found";
254 break;
202 case WSATRY_AGAIN: 255 case WSATRY_AGAIN:
203 return "Nonauthoritative host not found"; 256 msg = "Nonauthoritative host not found";
257 break;
204 case WSANO_RECOVERY: 258 case WSANO_RECOVERY:
205 return "Nonrecoverable error"; 259 msg = "Nonrecoverable error";
260 break;
206 case WSANO_DATA: 261 case WSANO_DATA:
207 return "Valid name, no data record of requested type"; 262 msg = "Valid name, no data record of requested type";
263 break;
208 /* WSA_QOS_* omitted */ 264 /* WSA_QOS_* omitted */
209# endif 265# endif
210# endif 266# endif
211 267
212# if GNULIB_defined_ENOMSG 268# if GNULIB_defined_ENOMSG
213 case ENOMSG: 269 case ENOMSG:
214 return "No message of desired type"; 270 msg = "No message of desired type";
271 break;
215# endif 272# endif
216 273
217# if GNULIB_defined_EIDRM 274# if GNULIB_defined_EIDRM
218 case EIDRM: 275 case EIDRM:
219 return "Identifier removed"; 276 msg = "Identifier removed";
277 break;
220# endif 278# endif
221 279
222# if GNULIB_defined_ENOLINK 280# if GNULIB_defined_ENOLINK
223 case ENOLINK: 281 case ENOLINK:
224 return "Link has been severed"; 282 msg = "Link has been severed";
283 break;
225# endif 284# endif
226 285
227# if GNULIB_defined_EPROTO 286# if GNULIB_defined_EPROTO
228 case EPROTO: 287 case EPROTO:
229 return "Protocol error"; 288 msg = "Protocol error";
289 break;
230# endif 290# endif
231 291
232# if GNULIB_defined_EMULTIHOP 292# if GNULIB_defined_EMULTIHOP
233 case EMULTIHOP: 293 case EMULTIHOP:
234 return "Multihop attempted"; 294 msg = "Multihop attempted";
295 break;
235# endif 296# endif
236 297
237# if GNULIB_defined_EBADMSG 298# if GNULIB_defined_EBADMSG
238 case EBADMSG: 299 case EBADMSG:
239 return "Bad message"; 300 msg = "Bad message";
301 break;
240# endif 302# endif
241 303
242# if GNULIB_defined_EOVERFLOW 304# if GNULIB_defined_EOVERFLOW
243 case EOVERFLOW: 305 case EOVERFLOW:
244 return "Value too large for defined data type"; 306 msg = "Value too large for defined data type";
307 break;
245# endif 308# endif
246 309
247# if GNULIB_defined_ENOTSUP 310# if GNULIB_defined_ENOTSUP
248 case ENOTSUP: 311 case ENOTSUP:
249 return "Not supported"; 312 msg = "Not supported";
313 break;
250# endif 314# endif
251 315
252# if GNULIB_defined_ 316# if GNULIB_defined_
253 case ECANCELED: 317 case ECANCELED:
254 return "Operation canceled"; 318 msg = "Operation canceled";
319 break;
255# endif 320# endif
256 } 321 }
257 322
323 if (msg)
324 return (char *) msg;
325
258 { 326 {
259 char *result = strerror (n); 327 char *result = strerror (n);
260 328
261 if (result == NULL || result[0] == '\0') 329 if (result == NULL || result[0] == '\0')
262 { 330 {
263 static char const fmt[] = "Unknown error (%d)"; 331 static char const fmt[] = "Unknown error (%d)";
264 static char mesg[sizeof fmt + INT_STRLEN_BOUND (n)]; 332 static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
265 sprintf (mesg, fmt, n); 333 sprintf (msg_buf, fmt, n);
266 return mesg; 334 return msg_buf;
267 } 335 }
268 336
269 return result; 337 return result;