diff options
author | dos-reis <gdr@axiomatics.org> | 2008-10-25 07:38:03 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-10-25 07:38:03 +0000 |
commit | caa66b610f90ddc5989b72bc2b437869e74c4421 (patch) | |
tree | 6d2dfae1dd36c5faad8d68079c551a6b46327464 /src/lib/sockio-c.c | |
parent | a3dccc344e57259f113b7f2d7e2761ad8131e60b (diff) | |
download | open-axiom-caa66b610f90ddc5989b72bc2b437869e74c4421.tar.gz |
Fix build on Win32
Diffstat (limited to 'src/lib/sockio-c.c')
-rw-r--r-- | src/lib/sockio-c.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c index 51c04bfe..75f94390 100644 --- a/src/lib/sockio-c.c +++ b/src/lib/sockio-c.c @@ -47,8 +47,13 @@ #include <sys/time.h> #include <string.h> #include <signal.h> -#include <arpa/inet.h> -#include <netdb.h> +#ifdef __WIN32__ +# include <winsock2.h> +# include <ws2tcpip.h> +#else +# include <arpa/inet.h> +# include <netdb.h> +#endif #include "cfuns.h" #include "sockio.h" @@ -143,14 +148,21 @@ oa_inet_pton(const char* addr, int prot, openaxiom_byte* bytes) { switch (prot) { case 4: { +#ifdef __WIN32__ + unsigned long inet_val = inet_addr(addr); + if (inet_val == INADDR_NONE || inet_val == INADDR_ANY) + return -1; + memcpy(bytes, &inet_val, 4); + return 0; +#else struct in_addr inet_val; if (inet_aton(addr, &inet_val) != 0) { memcpy(bytes, &inet_val, 4); return 0; } return -1; +#endif } - default: return -1; } |