1 /* strerror-override.c --- POSIX compatible system error routine
3 Copyright (C) 2010-2011 Free Software Foundation, Inc.
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
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* Written by Bruno Haible <bruno@clisp.org>, 2010. */
22 #include "strerror-override.h"
26 #if GNULIB_defined_ESOCK /* native Windows platforms */
28 # include <winsock2.h>
32 /* If ERRNUM maps to an errno value defined by gnulib, return a string
33 describing the error. Otherwise return NULL. */
35 strerror_override (int errnum)
37 const char *msg = NULL;
39 #if GNULIB_defined_ETXTBSY \
40 || GNULIB_defined_ESOCK \
41 || GNULIB_defined_ENOMSG \
42 || GNULIB_defined_EIDRM \
43 || GNULIB_defined_ENOLINK \
44 || GNULIB_defined_EPROTO \
45 || GNULIB_defined_EMULTIHOP \
46 || GNULIB_defined_EBADMSG \
47 || GNULIB_defined_EOVERFLOW \
48 || GNULIB_defined_ENOTSUP \
49 || GNULIB_defined_ESTALE \
50 || GNULIB_defined_EDQUOT \
51 || GNULIB_defined_ECANCELED
52 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
55 # if GNULIB_defined_ETXTBSY
57 msg = "Text file busy";
61 # if GNULIB_defined_ESOCK /* native Windows platforms */
62 /* EWOULDBLOCK is the same as EAGAIN. */
64 msg = "Operation now in progress";
67 msg = "Operation already in progress";
70 msg = "Socket operation on non-socket";
73 msg = "Destination address required";
76 msg = "Message too long";
79 msg = "Protocol wrong type for socket";
82 msg = "Protocol not available";
85 msg = "Protocol not supported";
88 msg = "Socket type not supported";
91 msg = "Operation not supported";
94 msg = "Protocol family not supported";
97 msg = "Address family not supported by protocol";
100 msg = "Address already in use";
103 msg = "Cannot assign requested address";
106 msg = "Network is down";
109 msg = "Network is unreachable";
112 msg = "Network dropped connection on reset";
115 msg = "Software caused connection abort";
118 msg = "Connection reset by peer";
121 msg = "No buffer space available";
124 msg = "Transport endpoint is already connected";
127 msg = "Transport endpoint is not connected";
130 msg = "Cannot send after transport endpoint shutdown";
133 msg = "Too many references: cannot splice";
136 msg = "Connection timed out";
139 msg = "Connection refused";
142 msg = "Too many levels of symbolic links";
145 msg = "Host is down";
148 msg = "No route to host";
151 msg = "Too many processes";
154 msg = "Too many users";
157 msg = "Disk quota exceeded";
160 msg = "Stale NFS file handle";
163 msg = "Object is remote";
166 /* WSA_INVALID_HANDLE maps to EBADF */
167 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
168 /* WSA_INVALID_PARAMETER maps to EINVAL */
169 case WSA_OPERATION_ABORTED:
170 msg = "Overlapped operation aborted";
172 case WSA_IO_INCOMPLETE:
173 msg = "Overlapped I/O event object not in signaled state";
176 msg = "Overlapped operations will complete later";
178 /* WSAEINTR maps to EINTR */
179 /* WSAEBADF maps to EBADF */
180 /* WSAEACCES maps to EACCES */
181 /* WSAEFAULT maps to EFAULT */
182 /* WSAEINVAL maps to EINVAL */
183 /* WSAEMFILE maps to EMFILE */
184 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
185 /* WSAEINPROGRESS is EINPROGRESS */
186 /* WSAEALREADY is EALREADY */
187 /* WSAENOTSOCK is ENOTSOCK */
188 /* WSAEDESTADDRREQ is EDESTADDRREQ */
189 /* WSAEMSGSIZE is EMSGSIZE */
190 /* WSAEPROTOTYPE is EPROTOTYPE */
191 /* WSAENOPROTOOPT is ENOPROTOOPT */
192 /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
193 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
194 /* WSAEOPNOTSUPP is EOPNOTSUPP */
195 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
196 /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
197 /* WSAEADDRINUSE is EADDRINUSE */
198 /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
199 /* WSAENETDOWN is ENETDOWN */
200 /* WSAENETUNREACH is ENETUNREACH */
201 /* WSAENETRESET is ENETRESET */
202 /* WSAECONNABORTED is ECONNABORTED */
203 /* WSAECONNRESET is ECONNRESET */
204 /* WSAENOBUFS is ENOBUFS */
205 /* WSAEISCONN is EISCONN */
206 /* WSAENOTCONN is ENOTCONN */
207 /* WSAESHUTDOWN is ESHUTDOWN */
208 /* WSAETOOMANYREFS is ETOOMANYREFS */
209 /* WSAETIMEDOUT is ETIMEDOUT */
210 /* WSAECONNREFUSED is ECONNREFUSED */
211 /* WSAELOOP is ELOOP */
212 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
213 /* WSAEHOSTDOWN is EHOSTDOWN */
214 /* WSAEHOSTUNREACH is EHOSTUNREACH */
215 /* WSAENOTEMPTY maps to ENOTEMPTY */
216 /* WSAEPROCLIM is EPROCLIM */
217 /* WSAEUSERS is EUSERS */
218 /* WSAEDQUOT is EDQUOT */
219 /* WSAESTALE is ESTALE */
220 /* WSAEREMOTE is EREMOTE */
222 msg = "Network subsystem is unavailable";
224 case WSAVERNOTSUPPORTED:
225 msg = "Winsock.dll version out of range";
227 case WSANOTINITIALISED:
228 msg = "Successful WSAStartup not yet performed";
231 msg = "Graceful shutdown in progress";
233 case WSAENOMORE: case WSA_E_NO_MORE:
234 msg = "No more results";
236 case WSAECANCELLED: case WSA_E_CANCELLED:
237 msg = "Call was canceled";
239 case WSAEINVALIDPROCTABLE:
240 msg = "Procedure call table is invalid";
242 case WSAEINVALIDPROVIDER:
243 msg = "Service provider is invalid";
245 case WSAEPROVIDERFAILEDINIT:
246 msg = "Service provider failed to initialize";
248 case WSASYSCALLFAILURE:
249 msg = "System call failure";
251 case WSASERVICE_NOT_FOUND:
252 msg = "Service not found";
254 case WSATYPE_NOT_FOUND:
255 msg = "Class type not found";
258 msg = "Database query was refused";
260 case WSAHOST_NOT_FOUND:
261 msg = "Host not found";
264 msg = "Nonauthoritative host not found";
267 msg = "Nonrecoverable error";
270 msg = "Valid name, no data record of requested type";
272 /* WSA_QOS_* omitted */
276 # if GNULIB_defined_ENOMSG
278 msg = "No message of desired type";
282 # if GNULIB_defined_EIDRM
284 msg = "Identifier removed";
288 # if GNULIB_defined_ENOLINK
290 msg = "Link has been severed";
294 # if GNULIB_defined_EPROTO
296 msg = "Protocol error";
300 # if GNULIB_defined_EMULTIHOP
302 msg = "Multihop attempted";
306 # if GNULIB_defined_EBADMSG
312 # if GNULIB_defined_EOVERFLOW
314 msg = "Value too large for defined data type";
318 # if GNULIB_defined_ENOTSUP
320 msg = "Not supported";
324 # if GNULIB_defined_ESTALE
326 msg = "Stale NFS file handle";
330 # if GNULIB_defined_EDQUOT
332 msg = "Disk quota exceeded";
336 # if GNULIB_defined_ECANCELED
338 msg = "Operation canceled";