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 return "Text file busy";
95 return "No data available";
97 return "Out of streams resources";
99 return "Device not a stream";
101 return "Timer expired";
103 return "Other error";
105 #if GNULIB_defined_EWINSOCK /* native Windows platforms */
106 case ESOCKTNOSUPPORT:
107 return "Socket type not supported";
109 return "Protocol family not supported";
111 return "Cannot send after transport endpoint shutdown";
113 return "Too many references: cannot splice";
115 return "Host is down";
117 return "Too many processes";
119 return "Too many users";
121 return "Disk quota exceeded";
123 return "Stale NFS file handle";
125 return "Object is remote";
127 /* WSA_INVALID_HANDLE maps to EBADF */
128 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
129 /* WSA_INVALID_PARAMETER maps to EINVAL */
130 case WSA_OPERATION_ABORTED:
131 return "Overlapped operation aborted";
132 case WSA_IO_INCOMPLETE:
133 return "Overlapped I/O event object not in signaled state";
135 return "Overlapped operations will complete later";
136 /* WSAEINTR maps to EINTR */
137 /* WSAEBADF maps to EBADF */
138 /* WSAEACCES maps to EACCES */
139 /* WSAEFAULT maps to EFAULT */
140 /* WSAEINVAL maps to EINVAL */
141 /* WSAEMFILE maps to EMFILE */
142 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
143 /* WSAEINPROGRESS maps to EINPROGRESS */
144 /* WSAEALREADY maps to EALREADY */
145 /* WSAENOTSOCK maps to ENOTSOCK */
146 /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
147 /* WSAEMSGSIZE maps to EMSGSIZE */
148 /* WSAEPROTOTYPE maps to EPROTOTYPE */
149 /* WSAENOPROTOOPT maps to ENOPROTOOPT */
150 /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
151 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
152 /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
153 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
154 /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
155 /* WSAEADDRINUSE maps to EADDRINUSE */
156 /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
157 /* WSAENETDOWN maps to ENETDOWN */
158 /* WSAENETUNREACH maps to ENETUNREACH */
159 /* WSAENETRESET maps to ENETRESET */
160 /* WSAECONNABORTED maps to ECONNABORTED */
161 /* WSAECONNRESET maps to ECONNRESET */
162 /* WSAENOBUFS maps to ENOBUFS */
163 /* WSAEISCONN maps to EISCONN */
164 /* WSAENOTCONN maps to ENOTCONN */
165 /* WSAESHUTDOWN is ESHUTDOWN */
166 /* WSAETOOMANYREFS is ETOOMANYREFS */
167 /* WSAETIMEDOUT maps to ETIMEDOUT */
168 /* WSAECONNREFUSED maps to ECONNREFUSED */
169 /* WSAELOOP maps to ELOOP */
170 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
171 /* WSAEHOSTDOWN is EHOSTDOWN */
172 /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
173 /* WSAENOTEMPTY maps to ENOTEMPTY */
174 /* WSAEPROCLIM is EPROCLIM */
175 /* WSAEUSERS is EUSERS */
176 /* WSAEDQUOT is EDQUOT */
177 /* WSAESTALE is ESTALE */
178 /* WSAEREMOTE is EREMOTE */
180 return "Network subsystem is unavailable";
181 case WSAVERNOTSUPPORTED:
182 return "Winsock.dll version out of range";
183 case WSANOTINITIALISED:
184 return "Successful WSAStartup not yet performed";
186 return "Graceful shutdown in progress";
187 case WSAENOMORE: case WSA_E_NO_MORE:
188 return "No more results";
189 case WSAECANCELLED: case WSA_E_CANCELLED:
190 return "Call was canceled";
191 case WSAEINVALIDPROCTABLE:
192 return "Procedure call table is invalid";
193 case WSAEINVALIDPROVIDER:
194 return "Service provider is invalid";
195 case WSAEPROVIDERFAILEDINIT:
196 return "Service provider failed to initialize";
197 case WSASYSCALLFAILURE:
198 return "System call failure";
199 case WSASERVICE_NOT_FOUND:
200 return "Service not found";
201 case WSATYPE_NOT_FOUND:
202 return "Class type not found";
204 return "Database query was refused";
205 case WSAHOST_NOT_FOUND:
206 return "Host not found";
208 return "Nonauthoritative host not found";
210 return "Nonrecoverable error";
212 return "Valid name, no data record of requested type";
213 /* WSA_QOS_* omitted */
217 #if GNULIB_defined_ENOMSG
219 return "No message of desired type";
222 #if GNULIB_defined_EIDRM
224 return "Identifier removed";
227 #if GNULIB_defined_ENOLINK
229 return "Link has been severed";
232 #if GNULIB_defined_EPROTO
234 return "Protocol error";
237 #if GNULIB_defined_EMULTIHOP
239 return "Multihop attempted";
242 #if GNULIB_defined_EBADMSG
244 return "Bad message";
247 #if GNULIB_defined_EOVERFLOW
249 return "Value too large for defined data type";
252 #if GNULIB_defined_ENOTSUP
254 return "Not supported";
257 #if GNULIB_defined_ENETRESET
259 return "Network dropped connection on reset";
262 #if GNULIB_defined_ECONNABORTED
264 return "Software caused connection abort";
267 #if GNULIB_defined_ESTALE
269 return "Stale NFS file handle";
272 #if GNULIB_defined_EDQUOT
274 return "Disk quota exceeded";
277 #if GNULIB_defined_ECANCELED
279 return "Operation canceled";
282 #if GNULIB_defined_EOWNERDEAD
285 case ENOTRECOVERABLE:
286 return "State not recoverable";