exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / strerror-override.c
blobb9c1c7aba83ebd6a6bdec0a7c7de6e1bcbec94dc
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. */
20 #include <config.h>
22 #include "strerror-override.h"
24 #include <errno.h>
26 #if GNULIB_defined_EWINSOCK /* native Windows platforms */
27 # if HAVE_WINSOCK2_H
28 # include <winsock2.h>
29 # endif
30 #endif
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. */
36 const char *
37 strerror_override (int errnum)
39 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
40 switch (errnum)
42 # if REPLACE_STRERROR_0
43 case 0:
44 return "Success";
45 # endif
47 # if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
48 case EINPROGRESS:
49 return "Operation now in progress";
50 case EALREADY:
51 return "Operation already in progress";
52 case ENOTSOCK:
53 return "Socket operation on non-socket";
54 case EDESTADDRREQ:
55 return "Destination address required";
56 case EMSGSIZE:
57 return "Message too long";
58 case EPROTOTYPE:
59 return "Protocol wrong type for socket";
60 case ENOPROTOOPT:
61 return "Protocol not available";
62 case EPROTONOSUPPORT:
63 return "Protocol not supported";
64 case EOPNOTSUPP:
65 return "Operation not supported";
66 case EAFNOSUPPORT:
67 return "Address family not supported by protocol";
68 case EADDRINUSE:
69 return "Address already in use";
70 case EADDRNOTAVAIL:
71 return "Cannot assign requested address";
72 case ENETDOWN:
73 return "Network is down";
74 case ENETUNREACH:
75 return "Network is unreachable";
76 case ECONNRESET:
77 return "Connection reset by peer";
78 case ENOBUFS:
79 return "No buffer space available";
80 case EISCONN:
81 return "Transport endpoint is already connected";
82 case ENOTCONN:
83 return "Transport endpoint is not connected";
84 case ETIMEDOUT:
85 return "Connection timed out";
86 case ECONNREFUSED:
87 return "Connection refused";
88 case ELOOP:
89 return "Too many levels of symbolic links";
90 case EHOSTUNREACH:
91 return "No route to host";
92 case EWOULDBLOCK:
93 return "Operation would block";
94 # endif
95 # if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
96 case ETXTBSY:
97 return "Text file busy";
98 case ENODATA:
99 return "No data available";
100 case ENOSR:
101 return "Out of streams resources";
102 case ENOSTR:
103 return "Device not a stream";
104 case ETIME:
105 return "Timer expired";
106 case EOTHER:
107 return "Other error";
108 # endif
109 # if GNULIB_defined_EWINSOCK /* native Windows platforms */
110 case ESOCKTNOSUPPORT:
111 return "Socket type not supported";
112 case EPFNOSUPPORT:
113 return "Protocol family not supported";
114 case ESHUTDOWN:
115 return "Cannot send after transport endpoint shutdown";
116 case ETOOMANYREFS:
117 return "Too many references: cannot splice";
118 case EHOSTDOWN:
119 return "Host is down";
120 case EPROCLIM:
121 return "Too many processes";
122 case EUSERS:
123 return "Too many users";
124 case EDQUOT:
125 return "Disk quota exceeded";
126 case ESTALE:
127 return "Stale NFS file handle";
128 case EREMOTE:
129 return "Object is remote";
130 # if HAVE_WINSOCK2_H
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";
138 case WSA_IO_PENDING:
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 */
183 case WSASYSNOTREADY:
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";
189 case WSAEDISCON:
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";
207 case WSAEREFUSED:
208 return "Database query was refused";
209 case WSAHOST_NOT_FOUND:
210 return "Host not found";
211 case WSATRY_AGAIN:
212 return "Nonauthoritative host not found";
213 case WSANO_RECOVERY:
214 return "Nonrecoverable error";
215 case WSANO_DATA:
216 return "Valid name, no data record of requested type";
217 /* WSA_QOS_* omitted */
218 # endif
219 # endif
221 # if GNULIB_defined_ENOMSG
222 case ENOMSG:
223 return "No message of desired type";
224 # endif
226 # if GNULIB_defined_EIDRM
227 case EIDRM:
228 return "Identifier removed";
229 # endif
231 # if GNULIB_defined_ENOLINK
232 case ENOLINK:
233 return "Link has been severed";
234 # endif
236 # if GNULIB_defined_EPROTO
237 case EPROTO:
238 return "Protocol error";
239 # endif
241 # if GNULIB_defined_EMULTIHOP
242 case EMULTIHOP:
243 return "Multihop attempted";
244 # endif
246 # if GNULIB_defined_EBADMSG
247 case EBADMSG:
248 return "Bad message";
249 # endif
251 # if GNULIB_defined_EOVERFLOW
252 case EOVERFLOW:
253 return "Value too large for defined data type";
254 # endif
256 # if GNULIB_defined_ENOTSUP
257 case ENOTSUP:
258 return "Not supported";
259 # endif
261 # if GNULIB_defined_ENETRESET
262 case ENETRESET:
263 return "Network dropped connection on reset";
264 # endif
266 # if GNULIB_defined_ECONNABORTED
267 case ECONNABORTED:
268 return "Software caused connection abort";
269 # endif
271 # if GNULIB_defined_ESTALE
272 case ESTALE:
273 return "Stale NFS file handle";
274 # endif
276 # if GNULIB_defined_EDQUOT
277 case EDQUOT:
278 return "Disk quota exceeded";
279 # endif
281 # if GNULIB_defined_ECANCELED
282 case ECANCELED:
283 return "Operation canceled";
284 # endif
286 # if GNULIB_defined_EOWNERDEAD
287 case EOWNERDEAD:
288 return "Owner died";
289 # endif
291 # if GNULIB_defined_ENOTRECOVERABLE
292 case ENOTRECOVERABLE:
293 return "State not recoverable";
294 # endif
296 # if GNULIB_defined_EILSEQ
297 case EILSEQ:
298 return "Invalid or incomplete multibyte or wide character";
299 # endif
301 default:
302 return NULL;
306 #endif