From caa66b610f90ddc5989b72bc2b437869e74c4421 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sat, 25 Oct 2008 07:38:03 +0000 Subject: Fix build on Win32 --- src/lib/cfuns-c.c | 5 +++-- src/lib/sockio-c.c | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index ff5b5966..31cfff6e 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -331,7 +331,8 @@ std_stream_is_terminal(int fd) case 0: handle = STD_INPUT_HANDLE; break; case 1: handle = STD_OUTPUT_HANDLE; break; case 2: handle = STD_ERROR_HANDLE; break; - + /* Next code is never executed but it makes the compiler happy. */ + default: return 0; } /* The MS documentation suggests `GetFileType' for determining the nature of the file handle. The return value, in our case, @@ -595,7 +596,7 @@ oa_get_tmpdir(void) int new_size; buf = (char*) malloc(bufsz + 1); new_size = GetTempPath(bufsz, buf); - if(new_size = 0 || new_size >= bufsz) { + if(new_size == 0 || new_size >= bufsz) { perror("oa_get_tmpdir"); free(buf); exit(1); 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 #include #include -#include -#include +#ifdef __WIN32__ +# include +# include +#else +# include +# include +#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; } -- cgit v1.2.3