@@ -27,10 +27,15 @@ #import "OFException.h" #import "OFString.h" #import "OFArray.h" #import "autorelease.h" + +#ifdef _WIN32 +# include +# include +#endif struct _Unwind_Context; typedef enum { _URC_OK = 0, _URC_END_OF_STACK = 5 @@ -66,10 +71,39 @@ return _URC_OK; } return _URC_END_OF_STACK; } + +#if defined(_WIN32) && defined(OF_HAVE_SOCKETS) +int +of_wsaerr_to_errno(int wsaerr) +{ + switch (wsaerr) { + case WSAEACCES: + return EACCES; + case WSAEBADF: + return EBADF; + case WSAEDISCON: + return EPIPE; + case WSAEFAULT: + return EFAULT; + case WSAEINTR: + return EINTR; + case WSAEINVAL: + return EINVAL; + case WSAENAMETOOLONG: + return ENAMETOOLONG; + case WSAENOTEMPTY: + return ENOTEMPTY; + case WSAEWOULDBLOCK: + return EAGAIN; + default: + return wsaerr; + } +} +#endif @implementation OFException + (instancetype)exception { return [[[self alloc] init] autorelease];