#include <ws2tcpip.h>
#define ECONNABORTED WSAECONNABORTED
-#define EINPROGRESS WSAEINPROGRESS
-#define EWOULDBLOCK WSAEWOULDBLOCK
+#define EMSGSIZE WSAEMSGSIZE
+#define EINPROGRESS WSAEWOULDBLOCK // WSAEINPROGRESS
+
#undef EAGAIN
#define EAGAIN WSAEWOULDBLOCK // WSAEAGAIN
-#define EMSGSIZE WSAEMSGSIZE
/* dummy types / functions */
#define uid_t int
}
#define gethostbyname(a) w_gethostbyname(a)
+const char *wsa_strerror(int e);
+
static inline const char *w_strerror(int e) {
- /* wsa does not have its own strerror, maybe main one works */
+ if (e > 900)
+ return wsa_strerror(e);
return strerror(e);
}
#define strerror(x) w_strerror(x)
void closelog(void)
{
}
+
+#define WCASE(x) case x: return #x
+const char *wsa_strerror(int e)
+{
+ static char wsa_buf[256];
+ switch (e) {
+ /* display few common ones by name */
+ WCASE(WSAEWOULDBLOCK);
+ WCASE(WSAEINPROGRESS);
+ WCASE(WSAECONNABORTED);
+ WCASE(WSAEINTR);
+ default:
+ snprintf(wsa_buf, sizeof(wsa_buf), "wsa_error: %d", e);
+ return wsa_buf;
+ }
+}
+#define strerror(x) w_strerror(x)
+
+