]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/xstrerror.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "compat/xstrerror.h"
15 static struct _wsaerrtext
{
21 { WSA_E_CANCELLED
, "WSA_E_CANCELLED", "Lookup cancelled." },
22 { WSA_E_NO_MORE
, "WSA_E_NO_MORE", "No more data available." },
23 { WSAEACCES
, "WSAEACCES", "Permission denied." },
24 { WSAEADDRINUSE
, "WSAEADDRINUSE", "Address already in use." },
25 { WSAEADDRNOTAVAIL
, "WSAEADDRNOTAVAIL", "Cannot assign requested address." },
26 { WSAEAFNOSUPPORT
, "WSAEAFNOSUPPORT", "Address family not supported by protocol family." },
27 { WSAEALREADY
, "WSAEALREADY", "Operation already in progress." },
28 { WSAEBADF
, "WSAEBADF", "Bad file number." },
29 { WSAECANCELLED
, "WSAECANCELLED", "Operation cancelled." },
30 { WSAECONNABORTED
, "WSAECONNABORTED", "Software caused connection abort." },
31 { WSAECONNREFUSED
, "WSAECONNREFUSED", "Connection refused." },
32 { WSAECONNRESET
, "WSAECONNRESET", "Connection reset by peer." },
33 { WSAEDESTADDRREQ
, "WSAEDESTADDRREQ", "Destination address required." },
34 { WSAEDQUOT
, "WSAEDQUOT", "Disk quota exceeded." },
35 { WSAEFAULT
, "WSAEFAULT", "Bad address." },
36 { WSAEHOSTDOWN
, "WSAEHOSTDOWN", "Host is down." },
37 { WSAEHOSTUNREACH
, "WSAEHOSTUNREACH", "No route to host." },
38 { WSAEINPROGRESS
, "WSAEINPROGRESS", "Operation now in progress." },
39 { WSAEINTR
, "WSAEINTR", "Interrupted function call." },
40 { WSAEINVAL
, "WSAEINVAL", "Invalid argument." },
41 { WSAEINVALIDPROCTABLE
, "WSAEINVALIDPROCTABLE", "Invalid procedure table from service provider." },
42 { WSAEINVALIDPROVIDER
, "WSAEINVALIDPROVIDER", "Invalid service provider version number." },
43 { WSAEISCONN
, "WSAEISCONN", "Socket is already connected." },
44 { WSAELOOP
, "WSAELOOP", "Too many levels of symbolic links." },
45 { WSAEMFILE
, "WSAEMFILE", "Too many open files." },
46 { WSAEMSGSIZE
, "WSAEMSGSIZE", "Message too long." },
47 { WSAENAMETOOLONG
, "WSAENAMETOOLONG", "File name is too long." },
48 { WSAENETDOWN
, "WSAENETDOWN", "Network is down." },
49 { WSAENETRESET
, "WSAENETRESET", "Network dropped connection on reset." },
50 { WSAENETUNREACH
, "WSAENETUNREACH", "Network is unreachable." },
51 { WSAENOBUFS
, "WSAENOBUFS", "No buffer space available." },
52 { WSAENOMORE
, "WSAENOMORE", "No more data available." },
53 { WSAENOPROTOOPT
, "WSAENOPROTOOPT", "Bad protocol option." },
54 { WSAENOTCONN
, "WSAENOTCONN", "Socket is not connected." },
55 { WSAENOTEMPTY
, "WSAENOTEMPTY", "Directory is not empty." },
56 { WSAENOTSOCK
, "WSAENOTSOCK", "Socket operation on nonsocket." },
57 { WSAEOPNOTSUPP
, "WSAEOPNOTSUPP", "Operation not supported." },
58 { WSAEPFNOSUPPORT
, "WSAEPFNOSUPPORT", "Protocol family not supported." },
59 { WSAEPROCLIM
, "WSAEPROCLIM", "Too many processes." },
60 { WSAEPROTONOSUPPORT
, "WSAEPROTONOSUPPORT", "Protocol not supported." },
61 { WSAEPROTOTYPE
, "WSAEPROTOTYPE", "Protocol wrong type for socket." },
62 { WSAEPROVIDERFAILEDINIT
, "WSAEPROVIDERFAILEDINIT", "Unable to initialise a service provider." },
63 { WSAEREFUSED
, "WSAEREFUSED", "Refused." },
64 { WSAEREMOTE
, "WSAEREMOTE", "Too many levels of remote in path." },
65 { WSAESHUTDOWN
, "WSAESHUTDOWN", "Cannot send after socket shutdown." },
66 { WSAESOCKTNOSUPPORT
, "WSAESOCKTNOSUPPORT", "Socket type not supported." },
67 { WSAESTALE
, "WSAESTALE", "Stale NFS file handle." },
68 { WSAETIMEDOUT
, "WSAETIMEDOUT", "Connection timed out." },
69 { WSAETOOMANYREFS
, "WSAETOOMANYREFS", "Too many references." },
70 { WSAEUSERS
, "WSAEUSERS", "Too many users." },
71 { WSAEWOULDBLOCK
, "WSAEWOULDBLOCK", "Resource temporarily unavailable." },
72 { WSANOTINITIALISED
, "WSANOTINITIALISED", "Successful WSAStartup not yet performed." },
73 { WSASERVICE_NOT_FOUND
, "WSASERVICE_NOT_FOUND", "Service not found." },
74 { WSASYSCALLFAILURE
, "WSASYSCALLFAILURE", "System call failure." },
75 { WSASYSNOTREADY
, "WSASYSNOTREADY", "Network subsystem is unavailable." },
76 { WSATYPE_NOT_FOUND
, "WSATYPE_NOT_FOUND", "Class type not found." },
77 { WSAVERNOTSUPPORTED
, "WSAVERNOTSUPPORTED", "Winsock.dll version out of range." },
78 { WSAEDISCON
, "WSAEDISCON", "Graceful shutdown in progress." }
85 static char xstrerror_buf
[BUFSIZ
];
88 return "(0) No error.";
91 // Description of WSAGetLastError()
92 for (size_t i
= 0; i
< sizeof(_wsaerrtext
) / sizeof(struct _wsaerrtext
); ++i
) {
93 if (_wsaerrtext
[i
].err
== error
) {
94 // small optimization, save using a temporary buffer and two copies...
95 snprintf(xstrerror_buf
, BUFSIZ
, "(%d) %s, %s", error
, _wsaerrtext
[i
].errconst
, _wsaerrtext
[i
].errdesc
);
101 const char *errmsg
= strerror(error
);
103 if (!errmsg
|| !*errmsg
)
104 errmsg
= "Unknown error";
106 snprintf(xstrerror_buf
, BUFSIZ
, "(%d) %s", error
, errmsg
);
108 return xstrerror_buf
;