aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-10-25 07:38:03 +0000
committerdos-reis <gdr@axiomatics.org>2008-10-25 07:38:03 +0000
commitcaa66b610f90ddc5989b72bc2b437869e74c4421 (patch)
tree6d2dfae1dd36c5faad8d68079c551a6b46327464 /src/lib
parenta3dccc344e57259f113b7f2d7e2761ad8131e60b (diff)
downloadopen-axiom-caa66b610f90ddc5989b72bc2b437869e74c4421.tar.gz
Fix build on Win32
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cfuns-c.c5
-rw-r--r--src/lib/sockio-c.c18
2 files changed, 18 insertions, 5 deletions
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 <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;
}