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 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
40 #if GNULIB_defined_ETXTBSY
42 return "Text file busy";
45 #if GNULIB_defined_ESOCK /* native Windows platforms */
46 /* EWOULDBLOCK is the same as EAGAIN. */
48 return "Operation now in progress";
50 return "Operation already in progress";
52 return "Socket operation on non-socket";
54 return "Destination address required";
56 return "Message too long";
58 return "Protocol wrong type for socket";
60 return "Protocol not available";
62 return "Protocol not supported";
64 return "Socket type not supported";
66 return "Operation not supported";
68 return "Protocol family not supported";
70 return "Address family not supported by protocol";
72 return "Address already in use";
74 return "Cannot assign requested address";
76 return "Network is down";
78 return "Network is unreachable";
80 return "Network dropped connection on reset";
82 return "Software caused connection abort";
84 return "Connection reset by peer";
86 return "No buffer space available";
88 return "Transport endpoint is already connected";
90 return "Transport endpoint is not connected";
92 return "Cannot send after transport endpoint shutdown";
94 return "Too many references: cannot splice";
96 return "Connection timed out";
98 return "Connection refused";
100 return "Too many levels of symbolic links";
102 return "Host is down";
104 return "No route to host";
106 return "Too many processes";
108 return "Too many users";
110 return "Disk quota exceeded";
112 return "Stale NFS file handle";
114 return "Object is remote";
116 /* WSA_INVALID_HANDLE maps to EBADF */
117 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
118 /* WSA_INVALID_PARAMETER maps to EINVAL */
119 case WSA_OPERATION_ABORTED:
120 return "Overlapped operation aborted";
121 case WSA_IO_INCOMPLETE:
122 return "Overlapped I/O event object not in signaled state";
124 return "Overlapped operations will complete later";
125 /* WSAEINTR maps to EINTR */
126 /* WSAEBADF maps to EBADF */
127 /* WSAEACCES maps to EACCES */
128 /* WSAEFAULT maps to EFAULT */
129 /* WSAEINVAL maps to EINVAL */
130 /* WSAEMFILE maps to EMFILE */
131 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
132 /* WSAEINPROGRESS is EINPROGRESS */
133 /* WSAEALREADY is EALREADY */
134 /* WSAENOTSOCK is ENOTSOCK */
135 /* WSAEDESTADDRREQ is EDESTADDRREQ */
136 /* WSAEMSGSIZE is EMSGSIZE */
137 /* WSAEPROTOTYPE is EPROTOTYPE */
138 /* WSAENOPROTOOPT is ENOPROTOOPT */
139 /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
140 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
141 /* WSAEOPNOTSUPP is EOPNOTSUPP */
142 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
143 /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
144 /* WSAEADDRINUSE is EADDRINUSE */
145 /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
146 /* WSAENETDOWN is ENETDOWN */
147 /* WSAENETUNREACH is ENETUNREACH */
148 /* WSAENETRESET is ENETRESET */
149 /* WSAECONNABORTED is ECONNABORTED */
150 /* WSAECONNRESET is ECONNRESET */
151 /* WSAENOBUFS is ENOBUFS */
152 /* WSAEISCONN is EISCONN */
153 /* WSAENOTCONN is ENOTCONN */
154 /* WSAESHUTDOWN is ESHUTDOWN */
155 /* WSAETOOMANYREFS is ETOOMANYREFS */
156 /* WSAETIMEDOUT is ETIMEDOUT */
157 /* WSAECONNREFUSED is ECONNREFUSED */
158 /* WSAELOOP is ELOOP */
159 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
160 /* WSAEHOSTDOWN is EHOSTDOWN */
161 /* WSAEHOSTUNREACH is EHOSTUNREACH */
162 /* WSAENOTEMPTY maps to ENOTEMPTY */
163 /* WSAEPROCLIM is EPROCLIM */
164 /* WSAEUSERS is EUSERS */
165 /* WSAEDQUOT is EDQUOT */
166 /* WSAESTALE is ESTALE */
167 /* WSAEREMOTE is EREMOTE */
169 return "Network subsystem is unavailable";
170 case WSAVERNOTSUPPORTED:
171 return "Winsock.dll version out of range";
172 case WSANOTINITIALISED:
173 return "Successful WSAStartup not yet performed";
175 return "Graceful shutdown in progress";
176 case WSAENOMORE: case WSA_E_NO_MORE:
177 return "No more results";
178 case WSAECANCELLED: case WSA_E_CANCELLED:
179 return "Call was canceled";
180 case WSAEINVALIDPROCTABLE:
181 return "Procedure call table is invalid";
182 case WSAEINVALIDPROVIDER:
183 return "Service provider is invalid";
184 case WSAEPROVIDERFAILEDINIT:
185 return "Service provider failed to initialize";
186 case WSASYSCALLFAILURE:
187 return "System call failure";
188 case WSASERVICE_NOT_FOUND:
189 return "Service not found";
190 case WSATYPE_NOT_FOUND:
191 return "Class type not found";
193 return "Database query was refused";
194 case WSAHOST_NOT_FOUND:
195 return "Host not found";
197 return "Nonauthoritative host not found";
199 return "Nonrecoverable error";
201 return "Valid name, no data record of requested type";
202 /* WSA_QOS_* omitted */
206 #if GNULIB_defined_ENOMSG
208 return "No message of desired type";
211 #if GNULIB_defined_EIDRM
213 return "Identifier removed";
216 #if GNULIB_defined_ENOLINK
218 return "Link has been severed";
221 #if GNULIB_defined_EPROTO
223 return "Protocol error";
226 #if GNULIB_defined_EMULTIHOP
228 return "Multihop attempted";
231 #if GNULIB_defined_EBADMSG
233 return "Bad message";
236 #if GNULIB_defined_EOVERFLOW
238 return "Value too large for defined data type";
241 #if GNULIB_defined_ENOTSUP
243 return "Not supported";
246 #if GNULIB_defined_ESTALE
248 return "Stale NFS file handle";
251 #if GNULIB_defined_EDQUOT
253 return "Disk quota exceeded";
256 #if GNULIB_defined_ECANCELED
258 return "Operation canceled";