Implement the wsa_error_no function with switch-case (#3044)

* Implement the wsa_error_no function with switch-case

Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
This commit is contained in:
asafkahlon 2018-04-13 17:16:54 +03:00 committed by Luca Boccassi
parent bb4fb32925
commit 8e8009ec5d

View File

@ -100,128 +100,112 @@ const char *zmq::wsa_error_no (int no_, const char *wsae_wouldblock_string)
// TODO: It seems that list of Windows socket errors is longer than this. // TODO: It seems that list of Windows socket errors is longer than this.
// Investigate whether there's a way to convert it into the string // Investigate whether there's a way to convert it into the string
// automatically (wsaError->HRESULT->string?). // automatically (wsaError->HRESULT->string?).
return (no_ == WSABASEERR) switch (no_) {
? "No Error" case WSABASEERR:
: (no_ == WSAEINTR) return "No Error";
? "Interrupted system call" case WSAEINTR:
: (no_ == WSAEBADF) return "Interrupted system call";
? "Bad file number" case WSAEBADF:
: (no_ == WSAEACCES) return "Bad file number";
? "Permission denied" case WSAEACCES:
: (no_ == WSAEFAULT) return "Permission denied";
? "Bad address" case WSAEFAULT:
: (no_ == WSAEINVAL) return "Bad address";
? "Invalid argument" case WSAEINVAL:
: (no_ == WSAEMFILE) return "Invalid argument";
? "Too many open files" case WSAEMFILE:
: (no_ == WSAEWOULDBLOCK) return "Too many open files";
? wsae_wouldblock_string case WSAEWOULDBLOCK:
: (no_ == WSAEINPROGRESS) return wsae_wouldblock_string;
? "Operation now in progress" case WSAEINPROGRESS:
: (no_ == WSAEALREADY) return "Operation now in progress";
? "Operation already in " case WSAEALREADY:
"progress" return "Operation already in progress";
: (no_ == WSAENOTSOCK) case WSAENOTSOCK:
? "Socket operation on " return "Socket operation on non-socket";
"non-socket" case WSAEDESTADDRREQ:
: (no_ == WSAEDESTADDRREQ) return "Destination address required";
? "Destination " case WSAEMSGSIZE:
"address required" return "Message too long";
: (no_ == WSAEMSGSIZE) case WSAEPROTOTYPE:
? "Message too " return "Protocol wrong type for socket";
"long" case WSAENOPROTOOPT:
: (no_ return "Bas protocol option";
== WSAEPROTOTYPE) case WSAEPROTONOSUPPORT:
? "Protocol " return "Protocol not supported";
"wrong type " case WSAESOCKTNOSUPPORT:
"for socket" return "Socket type not supported";
: (no_ case WSAEOPNOTSUPP:
== WSAENOPROTOOPT) return "Operation not supported on socket";
? "Bad " case WSAEPFNOSUPPORT:
"protoco" return "Protocol family not supported";
"l " case WSAEAFNOSUPPORT:
"option" return "Address family not supported by protocol family";
: (no_ case WSAEADDRINUSE:
== WSAEPROTONOSUPPORT) return "Address already in use";
? "Pro" case WSAEADDRNOTAVAIL:
"toc" return "Can't assign requested address";
"ol " case WSAENETDOWN:
"not" return "Network is down";
" su" case WSAENETUNREACH:
"ppo" return "Network is unreachable";
"rte" case WSAENETRESET:
"d" return "Net dropped connection or reset";
: (no_ case WSAECONNABORTED:
== WSAESOCKTNOSUPPORT) return "Software caused connection abort";
? "Socket type not supported" case WSAECONNRESET:
: (no_ return "Connection reset by peer";
== WSAEOPNOTSUPP) case WSAENOBUFS:
? "Operation not supported on socket" return "No buffer space available";
: (no_ case WSAEISCONN:
== WSAEPFNOSUPPORT) return "Socket is already connected";
? "Protocol family not supported" case WSAENOTCONN:
: (no_ return "Socket is not connected";
== WSAEAFNOSUPPORT) case WSAESHUTDOWN:
? "Address family not supported by protocol family" return "Can't send after socket shutdown";
: (no_ == WSAEADDRINUSE) ? "Address already in use" case WSAETOOMANYREFS:
: (no_ == WSAEADDRNOTAVAIL) ? "Can't assign requested address" return "Too many references can't splice";
: (no_ == WSAENETDOWN) ? "Network is down" case WSAETIMEDOUT:
: (no_ == WSAENETUNREACH) ? "Network is unreachable" return "Connection timed out";
: (no_ == WSAENETRESET) ? "Net dropped connection or reset" case WSAECONNREFUSED:
: (no_ == WSAECONNABORTED) ? "Software caused connection abort" return "Connection refused";
: (no_ == WSAECONNRESET) ? "Connection reset by peer" case WSAELOOP:
: (no_ return "Too many levels of symbolic links";
== WSAENOBUFS) case WSAENAMETOOLONG:
? "No buffer space available" return "File name too long";
: (no_ == WSAEISCONN) ? "Socket is already connected" case WSAEHOSTDOWN:
: (no_ return "Host is down";
== WSAENOTCONN) case WSAEHOSTUNREACH:
? "Socket is not connected" return "No Route to Host";
: (no_ == WSAESHUTDOWN) ? "Can't send after socket shutdown" case WSAENOTEMPTY:
: (no_ == WSAETOOMANYREFS) ? "Too many references can't splice" return "Directory not empty";
: (no_ == WSAETIMEDOUT) ? "Connection timed out" case WSAEPROCLIM:
: (no_ return "Too many processes";
== WSAECONNREFUSED) case WSAEUSERS:
? "Connection refused" return "Too many users";
: (no_ case WSAEDQUOT:
== WSAELOOP) return "Disc Quota Exceeded";
? "Too many levels of symbolic links" case WSAESTALE:
: (no_ return "Stale NFS file handle";
== WSAENAMETOOLONG) case WSAEREMOTE:
? "File name too long" return "Too many levels of remote in path";
: (no_ == WSAEHOSTDOWN) ? "Host is down" case WSASYSNOTREADY:
: (no_ return "Network SubSystem is unavailable";
== WSAEHOSTUNREACH) case WSAVERNOTSUPPORTED:
? "No Route to Host" return "WINSOCK DLL Version out of range";
: (no_ == WSAENOTEMPTY) ? "Directory not empty" case WSANOTINITIALISED:
: (no_ == WSAEPROCLIM) ? "Too many processes" return "Successful WSASTARTUP not yet performed";
: ( case WSAHOST_NOT_FOUND:
no_ return "Host not found";
== WSAEUSERS) case WSATRY_AGAIN:
? "Too many users" return "Non-Authoritative Host not found";
: (no_ case WSANO_RECOVERY:
== WSAEDQUOT) return "Non-Recoverable errors: FORMERR REFUSED NOTIMP";
? "Disc Quota Exceeded" case WSANO_DATA:
: (no_ return "Valid name no data record of requested";
== WSAESTALE) default:
? "Stale NFS file handle" return "error not defined";
: (no_ == WSAEREMOTE) ? "Too many levels of remote in path" }
: (no_
== WSASYSNOTREADY)
? "Network SubSystem is unavailable"
: (no_ == WSAVERNOTSUPPORTED) ? "WINSOCK DLL Version out of range"
: (no_
== WSANOTINITIALISED)
? "Successful WSASTARTUP not yet performed"
: (no_ == WSAHOST_NOT_FOUND) ? "Host not found"
: (no_
== WSATRY_AGAIN)
? "Non-Authoritative Host not found"
: (no_ == WSANO_RECOVERY) ? "Non-Recoverable errors: FORMERR REFUSED NOTIMP"
: (no_
== WSANO_DATA)
? "Valid name no data record of requested"
: "error not defined";
} }
void zmq::win_error (char *buffer_, size_t buffer_size_) void zmq::win_error (char *buffer_, size_t buffer_size_)