aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog5
-rw-r--r--src/include/open-axiom.h3
-rw-r--r--src/lib/cfuns-c.c5
-rw-r--r--src/lib/sockio-c.c18
4 files changed, 26 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 525b044c..308bcac0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-25 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * include/open-axiom.h: Define WIN32_LEAN_AND_MEAN
+ * lib/sockio-c.c (oa_inet_pton) [__WIN32__]: Use inet_addr.
+
2008-10-24 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/sys-os.boot: Import oa_socket_read_byte as
diff --git a/src/include/open-axiom.h b/src/include/open-axiom.h
index 4ecfd16b..d4790120 100644
--- a/src/include/open-axiom.h
+++ b/src/include/open-axiom.h
@@ -43,6 +43,9 @@
# elif defined(OPENAXIOM_DLL_IMPORT)
# define OPENAXIOM_EXPORT __declspec(dllimport)
# endif /* DLL_EXPORT */
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
#endif /* __WIN32__ */
#ifndef OPENAXIOM_EXPORT
# define OPENAXIOM_EXPORT /* nothing */
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;
}