1 /* strerror-override.c --- POSIX compatible system error routine
3 Copyright (C) 2010-2024 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://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 !GNULIB_defined_strerror_override_macro
34 /* If ERRNUM maps to an errno value defined by gnulib, return a string
35 describing the error. Otherwise return NULL. */
37 strerror_override (int errnum
)
39 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
42 # if REPLACE_STRERROR_0
47 # if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
49 return "Operation now in progress";
51 return "Operation already in progress";
53 return "Socket operation on non-socket";
55 return "Destination address required";
57 return "Message too long";
59 return "Protocol wrong type for socket";
61 return "Protocol not available";
63 return "Protocol not supported";
65 return "Operation not supported";
67 return "Address family not supported by protocol";
69 return "Address already in use";
71 return "Cannot assign requested address";
73 return "Network is down";
75 return "Network is unreachable";
77 return "Connection reset by peer";
79 return "No buffer space available";
81 return "Transport endpoint is already connected";
83 return "Transport endpoint is not connected";
85 return "Connection timed out";
87 return "Connection refused";
89 return "Too many levels of symbolic links";
91 return "No route to host";
93 return "Operation would block";
95 # if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
97 return "Text file busy";
99 return "No data available";
101 return "Out of streams resources";
103 return "Device not a stream";
105 return "Timer expired";
107 return "Other error";
109 # if GNULIB_defined_EWINSOCK /* native Windows platforms */
110 case ESOCKTNOSUPPORT
:
111 return "Socket type not supported";
113 return "Protocol family not supported";
115 return "Cannot send after transport endpoint shutdown";
117 return "Too many references: cannot splice";
119 return "Host is down";
121 return "Too many processes";
123 return "Too many users";
125 return "Disk quota exceeded";
127 return "Stale NFS file handle";
129 return "Object is remote";
131 /* WSA_INVALID_HANDLE maps to EBADF */
132 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
133 /* WSA_INVALID_PARAMETER maps to EINVAL */
134 case WSA_OPERATION_ABORTED
:
135 return "Overlapped operation aborted";
136 case WSA_IO_INCOMPLETE
:
137 return "Overlapped I/O event object not in signaled state";
139 return "Overlapped operations will complete later";
140 /* WSAEINTR maps to EINTR */
141 /* WSAEBADF maps to EBADF */
142 /* WSAEACCES maps to EACCES */
143 /* WSAEFAULT maps to EFAULT */
144 /* WSAEINVAL maps to EINVAL */
145 /* WSAEMFILE maps to EMFILE */
146 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
147 /* WSAEINPROGRESS maps to EINPROGRESS */
148 /* WSAEALREADY maps to EALREADY */
149 /* WSAENOTSOCK maps to ENOTSOCK */
150 /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
151 /* WSAEMSGSIZE maps to EMSGSIZE */
152 /* WSAEPROTOTYPE maps to EPROTOTYPE */
153 /* WSAENOPROTOOPT maps to ENOPROTOOPT */
154 /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
155 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
156 /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
157 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
158 /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
159 /* WSAEADDRINUSE maps to EADDRINUSE */
160 /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
161 /* WSAENETDOWN maps to ENETDOWN */
162 /* WSAENETUNREACH maps to ENETUNREACH */
163 /* WSAENETRESET maps to ENETRESET */
164 /* WSAECONNABORTED maps to ECONNABORTED */
165 /* WSAECONNRESET maps to ECONNRESET */
166 /* WSAENOBUFS maps to ENOBUFS */
167 /* WSAEISCONN maps to EISCONN */
168 /* WSAENOTCONN maps to ENOTCONN */
169 /* WSAESHUTDOWN is ESHUTDOWN */
170 /* WSAETOOMANYREFS is ETOOMANYREFS */
171 /* WSAETIMEDOUT maps to ETIMEDOUT */
172 /* WSAECONNREFUSED maps to ECONNREFUSED */
173 /* WSAELOOP maps to ELOOP */
174 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
175 /* WSAEHOSTDOWN is EHOSTDOWN */
176 /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
177 /* WSAENOTEMPTY maps to ENOTEMPTY */
178 /* WSAEPROCLIM is EPROCLIM */
179 /* WSAEUSERS is EUSERS */
180 /* WSAEDQUOT is EDQUOT */
181 /* WSAESTALE is ESTALE */
182 /* WSAEREMOTE is EREMOTE */
184 return "Network subsystem is unavailable";
185 case WSAVERNOTSUPPORTED
:
186 return "Winsock.dll version out of range";
187 case WSANOTINITIALISED
:
188 return "Successful WSAStartup not yet performed";
190 return "Graceful shutdown in progress";
191 case WSAENOMORE
: case WSA_E_NO_MORE
:
192 return "No more results";
193 case WSAECANCELLED
: case WSA_E_CANCELLED
:
194 return "Call was canceled";
195 case WSAEINVALIDPROCTABLE
:
196 return "Procedure call table is invalid";
197 case WSAEINVALIDPROVIDER
:
198 return "Service provider is invalid";
199 case WSAEPROVIDERFAILEDINIT
:
200 return "Service provider failed to initialize";
201 case WSASYSCALLFAILURE
:
202 return "System call failure";
203 case WSASERVICE_NOT_FOUND
:
204 return "Service not found";
205 case WSATYPE_NOT_FOUND
:
206 return "Class type not found";
208 return "Database query was refused";
209 case WSAHOST_NOT_FOUND
:
210 return "Host not found";
212 return "Nonauthoritative host not found";
214 return "Nonrecoverable error";
216 return "Valid name, no data record of requested type";
217 /* WSA_QOS_* omitted */
221 # if GNULIB_defined_ENOMSG
223 return "No message of desired type";
226 # if GNULIB_defined_EIDRM
228 return "Identifier removed";
231 # if GNULIB_defined_ENOLINK
233 return "Link has been severed";
236 # if GNULIB_defined_EPROTO
238 return "Protocol error";
241 # if GNULIB_defined_EMULTIHOP
243 return "Multihop attempted";
246 # if GNULIB_defined_EBADMSG
248 return "Bad message";
251 # if GNULIB_defined_EOVERFLOW
253 return "Value too large for defined data type";
256 # if GNULIB_defined_ENOTSUP
258 return "Not supported";
261 # if GNULIB_defined_ENETRESET
263 return "Network dropped connection on reset";
266 # if GNULIB_defined_ECONNABORTED
268 return "Software caused connection abort";
271 # if GNULIB_defined_ESTALE
273 return "Stale NFS file handle";
276 # if GNULIB_defined_EDQUOT
278 return "Disk quota exceeded";
281 # if GNULIB_defined_ECANCELED
283 return "Operation canceled";
286 # if GNULIB_defined_EOWNERDEAD
291 # if GNULIB_defined_ENOTRECOVERABLE
292 case ENOTRECOVERABLE
:
293 return "State not recoverable";
296 # if GNULIB_defined_EILSEQ
298 return "Invalid or incomplete multibyte or wide character";