winverbs: map WSA error codes to winverbs status values
[mirror/winof/.git] / core / winverbs / user / wv_main.cpp
index 361d04b..32d1aae 100644 (file)
@@ -131,3 +131,22 @@ HRESULT WvConvertIbStatus(ib_api_status_t status)
        default:                                                return WV_UNKNOWN_ERROR;\r
        }\r
 }\r
+\r
+HRESULT WvConvertWSAStatus(int status)\r
+{\r
+       switch (status) {\r
+       case 0:                                                 return WV_SUCCESS;\r
+       case WSAEADDRINUSE:                             return WV_ADDRESS_ALREADY_EXISTS;\r
+       case WSAEADDRNOTAVAIL:                  return WV_INVALID_ADDRESS;\r
+       case WSAENETDOWN:                               return WV_HOST_UNREACHABLE;\r
+       case WSAENETUNREACH:                    return WV_HOST_UNREACHABLE;\r
+       case WSAECONNABORTED:                   return WV_CONNECTION_ABORTED;\r
+       case WSAEISCONN:                                return WV_CONNECTION_ACTIVE;\r
+       case WSAENOTCONN:                               return WV_CONNECTION_INVALID;\r
+       case WSAETIMEDOUT:                              return WV_IO_TIMEOUT;\r
+       case WSAECONNREFUSED:                   return WV_CONNECTION_REFUSED;\r
+       case WSAEHOSTUNREACH:                   return WV_HOST_UNREACHABLE;\r
+       case WSAEACCES:                                 return WV_ADDRESS_ALREADY_EXISTS;\r
+       default:                                                return WV_UNKNOWN_ERROR;\r
+       }\r
+}
\ No newline at end of file