Commit bace81e8d0394b40cae433ba8f64af739ab0788f

Thomas de Grivel 2024-11-26T01:11:25

wip win32

diff --git a/.gitmodules b/.gitmodules
index a71fa1a..b025d7a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -15,3 +15,6 @@
 [submodule "libmd"]
 	path = libmd
 	url = https://git.hadrons.org/git/libmd.git
+[submodule "sys_wait_h"]
+	path = sys_wait_h
+	url = https://github.com/win32ports/sys_wait_h
diff --git a/libkc3/configure b/libkc3/configure
index f8731fc..968e741 100755
--- a/libkc3/configure
+++ b/libkc3/configure
@@ -45,6 +45,10 @@ LDFLAGS="-export-dynamic $LDFLAGS -rdynamic"
 config_asan
 config_gnu
 config_i386
+config_win32
+if $HAVE_WIN32; then
+    CPPFLAGS="$CPPFLAGS -I../sys_wait_h/"
+fi
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd
diff --git a/socket/configure b/socket/configure
index 89da0a0..1bc1ab2 100755
--- a/socket/configure
+++ b/socket/configure
@@ -46,6 +46,7 @@ LDFLAGS="-export-dynamic $LDFLAGS -rdynamic"
 config_asan
 config_gnu
 config_i386
+config_win32
 pkg_config libbsd-overlay
 pkg_config libevent
 pkg_config libffi
diff --git a/socket/socket.c b/socket/socket.c
index 2e47430..ba616e9 100644
--- a/socket/socket.c
+++ b/socket/socket.c
@@ -12,8 +12,12 @@
  */
 #include <errno.h>
 #include <string.h>
-#include <netdb.h>
-#include <netinet/in.h>
+
+#ifndef WIN32
+# include <netdb.h>
+# include <netinet/in.h>
+#endif
+
 #include <unistd.h>
 #include <libkc3/kc3.h>
 #include "socket.h"
diff --git a/socket/socket_addr.c b/socket/socket_addr.c
index 031a4ba..b3d359a 100644
--- a/socket/socket_addr.c
+++ b/socket/socket_addr.c
@@ -12,11 +12,15 @@
  */
 #include <errno.h>
 #include <string.h>
-#include <netdb.h>
-#include <netinet/in.h>
+
+#ifndef WIN32
+# include <netdb.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+#endif
+
 #include <unistd.h>
 #include <libkc3/kc3.h>
-#include <arpa/inet.h>
 #include "socket.h"
 #include "socket_buf.h"
 
diff --git a/socket/socket_buf.c b/socket/socket_buf.c
index bc2fc8b..7667174 100644
--- a/socket/socket_buf.c
+++ b/socket/socket_buf.c
@@ -12,8 +12,12 @@
  */
 #include <errno.h>
 #include <string.h>
-#include <netdb.h>
-#include <netinet/in.h>
+
+#ifndef WIN32
+# include <netdb.h>
+# include <netinet/in.h>
+#endif
+
 #include <unistd.h>
 #include <libkc3/kc3.h>
 #include "socket_addr.h"
diff --git a/socket/types.h b/socket/types.h
index c2460f0..58eca24 100644
--- a/socket/types.h
+++ b/socket/types.h
@@ -13,7 +13,12 @@
 #ifndef HTTP_TYPES_H
 #define HTTP_TYPES_H
 
-#include <sys/socket.h>
+#ifdef WIN32
+# include <winsock2.h>
+#else
+# include <sys/socket.h>
+#endif
+
 #include <libkc3/types.h>
 
 /* 1 */
diff --git a/sys_wait_h b/sys_wait_h
new file mode 160000
index 0000000..229dee8
--- /dev/null
+++ b/sys_wait_h
@@ -0,0 +1 @@
+Subproject commit 229dee8de9cb4c29a3a31115112a4175df84a8eb
diff --git a/test/configure b/test/configure
index 72aba84..2f34c6f 100755
--- a/test/configure
+++ b/test/configure
@@ -47,6 +47,7 @@ LDFLAGS="$LDFLAGS -rdynamic"
 config_asan
 config_gnu
 config_i386
+config_win32
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd