18
18
#include <config.h>
27
# if GNULIB_defined_ESOCK /* native Windows platforms */
29
# include <winsock2.h>
33
# include "intprops.h"
36
# if ! HAVE_DECL_STRERROR
37
# define strerror(n) NULL
29
#include "strerror-override.h"
32
/* Use the system functions, not the gnulib overrides in this file. */
43
char const *msg = NULL;
44
/* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
39
static char buf[STACKBUF_LEN];
42
/* Cast away const, due to the historical signature of strerror;
43
callers should not be modifying the string. */
44
const char *msg = strerror_override (n);
50
/* Our strerror_r implementation might use the system's strerror
51
buffer, so all other clients of strerror have to see the error
52
copied into a buffer that we manage. This is not thread-safe,
53
even if the system strerror is, but portable programs shouldn't
54
be using strerror if they care about thread-safety. */
47
# if GNULIB_defined_ETXTBSY
49
msg = "Text file busy";
53
# if GNULIB_defined_ESOCK /* native Windows platforms */
54
/* EWOULDBLOCK is the same as EAGAIN. */
56
msg = "Operation now in progress";
59
msg = "Operation already in progress";
62
msg = "Socket operation on non-socket";
65
msg = "Destination address required";
68
msg = "Message too long";
71
msg = "Protocol wrong type for socket";
74
msg = "Protocol not available";
77
msg = "Protocol not supported";
80
msg = "Socket type not supported";
83
msg = "Operation not supported";
86
msg = "Protocol family not supported";
89
msg = "Address family not supported by protocol";
92
msg = "Address already in use";
95
msg = "Cannot assign requested address";
98
msg = "Network is down";
101
msg = "Network is unreachable";
104
msg = "Network dropped connection on reset";
107
msg = "Software caused connection abort";
110
msg = "Connection reset by peer";
113
msg = "No buffer space available";
116
msg = "Transport endpoint is already connected";
119
msg = "Transport endpoint is not connected";
122
msg = "Cannot send after transport endpoint shutdown";
125
msg = "Too many references: cannot splice";
128
msg = "Connection timed out";
131
msg = "Connection refused";
134
msg = "Too many levels of symbolic links";
137
msg = "Host is down";
140
msg = "No route to host";
143
msg = "Too many processes";
146
msg = "Too many users";
149
msg = "Disk quota exceeded";
152
msg = "Stale NFS file handle";
155
msg = "Object is remote";
158
/* WSA_INVALID_HANDLE maps to EBADF */
159
/* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
160
/* WSA_INVALID_PARAMETER maps to EINVAL */
161
case WSA_OPERATION_ABORTED:
162
msg = "Overlapped operation aborted";
164
case WSA_IO_INCOMPLETE:
165
msg = "Overlapped I/O event object not in signaled state";
168
msg = "Overlapped operations will complete later";
170
/* WSAEINTR maps to EINTR */
171
/* WSAEBADF maps to EBADF */
172
/* WSAEACCES maps to EACCES */
173
/* WSAEFAULT maps to EFAULT */
174
/* WSAEINVAL maps to EINVAL */
175
/* WSAEMFILE maps to EMFILE */
176
/* WSAEWOULDBLOCK maps to EWOULDBLOCK */
177
/* WSAEINPROGRESS is EINPROGRESS */
178
/* WSAEALREADY is EALREADY */
179
/* WSAENOTSOCK is ENOTSOCK */
180
/* WSAEDESTADDRREQ is EDESTADDRREQ */
181
/* WSAEMSGSIZE is EMSGSIZE */
182
/* WSAEPROTOTYPE is EPROTOTYPE */
183
/* WSAENOPROTOOPT is ENOPROTOOPT */
184
/* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
185
/* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
186
/* WSAEOPNOTSUPP is EOPNOTSUPP */
187
/* WSAEPFNOSUPPORT is EPFNOSUPPORT */
188
/* WSAEAFNOSUPPORT is EAFNOSUPPORT */
189
/* WSAEADDRINUSE is EADDRINUSE */
190
/* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
191
/* WSAENETDOWN is ENETDOWN */
192
/* WSAENETUNREACH is ENETUNREACH */
193
/* WSAENETRESET is ENETRESET */
194
/* WSAECONNABORTED is ECONNABORTED */
195
/* WSAECONNRESET is ECONNRESET */
196
/* WSAENOBUFS is ENOBUFS */
197
/* WSAEISCONN is EISCONN */
198
/* WSAENOTCONN is ENOTCONN */
199
/* WSAESHUTDOWN is ESHUTDOWN */
200
/* WSAETOOMANYREFS is ETOOMANYREFS */
201
/* WSAETIMEDOUT is ETIMEDOUT */
202
/* WSAECONNREFUSED is ECONNREFUSED */
203
/* WSAELOOP is ELOOP */
204
/* WSAENAMETOOLONG maps to ENAMETOOLONG */
205
/* WSAEHOSTDOWN is EHOSTDOWN */
206
/* WSAEHOSTUNREACH is EHOSTUNREACH */
207
/* WSAENOTEMPTY maps to ENOTEMPTY */
208
/* WSAEPROCLIM is EPROCLIM */
209
/* WSAEUSERS is EUSERS */
210
/* WSAEDQUOT is EDQUOT */
211
/* WSAESTALE is ESTALE */
212
/* WSAEREMOTE is EREMOTE */
214
msg = "Network subsystem is unavailable";
216
case WSAVERNOTSUPPORTED:
217
msg = "Winsock.dll version out of range";
219
case WSANOTINITIALISED:
220
msg = "Successful WSAStartup not yet performed";
223
msg = "Graceful shutdown in progress";
225
case WSAENOMORE: case WSA_E_NO_MORE:
226
msg = "No more results";
228
case WSAECANCELLED: case WSA_E_CANCELLED:
229
msg = "Call was canceled";
231
case WSAEINVALIDPROCTABLE:
232
msg = "Procedure call table is invalid";
234
case WSAEINVALIDPROVIDER:
235
msg = "Service provider is invalid";
237
case WSAEPROVIDERFAILEDINIT:
238
msg = "Service provider failed to initialize";
240
case WSASYSCALLFAILURE:
241
msg = "System call failure";
243
case WSASERVICE_NOT_FOUND:
244
msg = "Service not found";
246
case WSATYPE_NOT_FOUND:
247
msg = "Class type not found";
250
msg = "Database query was refused";
252
case WSAHOST_NOT_FOUND:
253
msg = "Host not found";
256
msg = "Nonauthoritative host not found";
259
msg = "Nonrecoverable error";
262
msg = "Valid name, no data record of requested type";
264
/* WSA_QOS_* omitted */
268
# if GNULIB_defined_ENOMSG
270
msg = "No message of desired type";
274
# if GNULIB_defined_EIDRM
276
msg = "Identifier removed";
280
# if GNULIB_defined_ENOLINK
282
msg = "Link has been severed";
286
# if GNULIB_defined_EPROTO
288
msg = "Protocol error";
292
# if GNULIB_defined_EMULTIHOP
294
msg = "Multihop attempted";
298
# if GNULIB_defined_EBADMSG
304
# if GNULIB_defined_EOVERFLOW
306
msg = "Value too large for defined data type";
310
# if GNULIB_defined_ENOTSUP
312
msg = "Not supported";
316
# if GNULIB_defined_ESTALE
318
msg = "Stale NFS file handle";
322
# if GNULIB_defined_ECANCELED
324
msg = "Operation canceled";
57
static char const fmt[] = "Unknown error %d";
58
verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n));
59
sprintf (buf, fmt, n);
333
char *result = strerror (n);
335
if (result == NULL || result[0] == '\0')
337
static char const fmt[] = "Unknown error (%d)";
338
static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
339
sprintf (msg_buf, fmt, n);
64
/* Fix STACKBUF_LEN if this ever aborts. */
66
if (sizeof buf <= len)
69
return memcpy (buf, msg, len + 1);