1 /* strerror-override.c --- POSIX compatible system error routine
3 Copyright (C) 2010-2012 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_EWINSOCK /* 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 REPLACE_STRERROR_0
45 #if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
47 return "Operation now in progress";
49 return "Operation already in progress";
51 return "Socket operation on non-socket";
53 return "Destination address required";
55 return "Message too long";
57 return "Protocol wrong type for socket";
59 return "Protocol not available";
61 return "Protocol not supported";
63 return "Operation not supported";
65 return "Address family not supported by protocol";
67 return "Address already in use";
69 return "Cannot assign requested address";
71 return "Network is down";
73 return "Network is unreachable";
75 return "Connection reset by peer";
77 return "No buffer space available";
79 return "Transport endpoint is already connected";
81 return "Transport endpoint is not connected";
83 return "Connection timed out";
85 return "Connection refused";
87 return "Too many levels of symbolic links";
89 return "No route to host";
91 return "Operation would block";
93 #if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
95 return "Text file busy";
97 return "No data available";
99 return "Out of streams resources";
101 return "Device not a stream";
103 return "Timer expired";
105 return "Other error";
107 #if GNULIB_defined_EWINSOCK /* native Windows platforms */
108 case ESOCKTNOSUPPORT
:
109 return "Socket type not supported";
111 return "Protocol family not supported";
113 return "Cannot send after transport endpoint shutdown";
115 return "Too many references: cannot splice";
117 return "Host is down";
119 return "Too many processes";
121 return "Too many users";
123 return "Disk quota exceeded";
125 return "Stale NFS file handle";
127 return "Object is remote";
129 /* WSA_INVALID_HANDLE maps to EBADF */
130 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
131 /* WSA_INVALID_PARAMETER maps to EINVAL */
132 case WSA_OPERATION_ABORTED
:
133 return "Overlapped operation aborted";
134 case WSA_IO_INCOMPLETE
:
135 return "Overlapped I/O event object not in signaled state";
137 return "Overlapped operations will complete later";
138 /* WSAEINTR maps to EINTR */
139 /* WSAEBADF maps to EBADF */
140 /* WSAEACCES maps to EACCES */
141 /* WSAEFAULT maps to EFAULT */
142 /* WSAEINVAL maps to EINVAL */
143 /* WSAEMFILE maps to EMFILE */
144 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
145 /* WSAEINPROGRESS maps to EINPROGRESS */
146 /* WSAEALREADY maps to EALREADY */
147 /* WSAENOTSOCK maps to ENOTSOCK */
148 /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
149 /* WSAEMSGSIZE maps to EMSGSIZE */
150 /* WSAEPROTOTYPE maps to EPROTOTYPE */
151 /* WSAENOPROTOOPT maps to ENOPROTOOPT */
152 /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
153 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
154 /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
155 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
156 /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
157 /* WSAEADDRINUSE maps to EADDRINUSE */
158 /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
159 /* WSAENETDOWN maps to ENETDOWN */
160 /* WSAENETUNREACH maps to ENETUNREACH */
161 /* WSAENETRESET maps to ENETRESET */
162 /* WSAECONNABORTED maps to ECONNABORTED */
163 /* WSAECONNRESET maps to ECONNRESET */
164 /* WSAENOBUFS maps to ENOBUFS */
165 /* WSAEISCONN maps to EISCONN */
166 /* WSAENOTCONN maps to ENOTCONN */
167 /* WSAESHUTDOWN is ESHUTDOWN */
168 /* WSAETOOMANYREFS is ETOOMANYREFS */
169 /* WSAETIMEDOUT maps to ETIMEDOUT */
170 /* WSAECONNREFUSED maps to ECONNREFUSED */
171 /* WSAELOOP maps to ELOOP */
172 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
173 /* WSAEHOSTDOWN is EHOSTDOWN */
174 /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
175 /* WSAENOTEMPTY maps to ENOTEMPTY */
176 /* WSAEPROCLIM is EPROCLIM */
177 /* WSAEUSERS is EUSERS */
178 /* WSAEDQUOT is EDQUOT */
179 /* WSAESTALE is ESTALE */
180 /* WSAEREMOTE is EREMOTE */
182 return "Network subsystem is unavailable";
183 case WSAVERNOTSUPPORTED
:
184 return "Winsock.dll version out of range";
185 case WSANOTINITIALISED
:
186 return "Successful WSAStartup not yet performed";
188 return "Graceful shutdown in progress";
189 case WSAENOMORE
: case WSA_E_NO_MORE
:
190 return "No more results";
191 case WSAECANCELLED
: case WSA_E_CANCELLED
:
192 return "Call was canceled";
193 case WSAEINVALIDPROCTABLE
:
194 return "Procedure call table is invalid";
195 case WSAEINVALIDPROVIDER
:
196 return "Service provider is invalid";
197 case WSAEPROVIDERFAILEDINIT
:
198 return "Service provider failed to initialize";
199 case WSASYSCALLFAILURE
:
200 return "System call failure";
201 case WSASERVICE_NOT_FOUND
:
202 return "Service not found";
203 case WSATYPE_NOT_FOUND
:
204 return "Class type not found";
206 return "Database query was refused";
207 case WSAHOST_NOT_FOUND
:
208 return "Host not found";
210 return "Nonauthoritative host not found";
212 return "Nonrecoverable error";
214 return "Valid name, no data record of requested type";
215 /* WSA_QOS_* omitted */
219 #if GNULIB_defined_ENOMSG
221 return "No message of desired type";
224 #if GNULIB_defined_EIDRM
226 return "Identifier removed";
229 #if GNULIB_defined_ENOLINK
231 return "Link has been severed";
234 #if GNULIB_defined_EPROTO
236 return "Protocol error";
239 #if GNULIB_defined_EMULTIHOP
241 return "Multihop attempted";
244 #if GNULIB_defined_EBADMSG
246 return "Bad message";
249 #if GNULIB_defined_EOVERFLOW
251 return "Value too large for defined data type";
254 #if GNULIB_defined_ENOTSUP
256 return "Not supported";
259 #if GNULIB_defined_ENETRESET
261 return "Network dropped connection on reset";
264 #if GNULIB_defined_ECONNABORTED
266 return "Software caused connection abort";
269 #if GNULIB_defined_ESTALE
271 return "Stale NFS file handle";
274 #if GNULIB_defined_EDQUOT
276 return "Disk quota exceeded";
279 #if GNULIB_defined_ECANCELED
281 return "Operation canceled";
284 #if GNULIB_defined_EOWNERDEAD
289 #if GNULIB_defined_ENOTRECOVERABLE
290 case ENOTRECOVERABLE
:
291 return "State not recoverable";