]> git.meshlink.io Git - catta/commitdiff
add uname and socklen_t to windows compat layer
authorSven M. Hallberg <pesco@khjk.org>
Tue, 26 Aug 2014 18:49:49 +0000 (20:49 +0200)
committerSven M. Hallberg <pesco@khjk.org>
Tue, 26 Aug 2014 18:49:49 +0000 (20:49 +0200)
21 files changed:
compat/windows/include/arpa/inet.h [deleted file]
compat/windows/include/net/if.h [deleted file]
compat/windows/include/netinet/in.h [deleted file]
compat/windows/include/sys/ioctl.h [deleted file]
compat/windows/include/sys/poll.h [deleted file]
compat/windows/include/sys/select.h [deleted file]
compat/windows/include/sys/socket.h [deleted file]
compat/windows/wincompat.h [deleted file]
configure.ac
src/Makefile.am
src/compat/windows/include/arpa/inet.h [new file with mode: 0644]
src/compat/windows/include/net/if.h [new file with mode: 0644]
src/compat/windows/include/netinet/in.h [new file with mode: 0644]
src/compat/windows/include/sys/ioctl.h [new file with mode: 0644]
src/compat/windows/include/sys/poll.h [new file with mode: 0644]
src/compat/windows/include/sys/select.h [new file with mode: 0644]
src/compat/windows/include/sys/socket.h [new file with mode: 0644]
src/compat/windows/include/sys/utsname.h [new file with mode: 0644]
src/compat/windows/wincompat.c [new file with mode: 0644]
src/compat/windows/wincompat.h [new file with mode: 0644]
src/entry.c

diff --git a/compat/windows/include/arpa/inet.h b/compat/windows/include/arpa/inet.h
deleted file mode 100644 (file)
index cc77ee8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../wincompat.h"
diff --git a/compat/windows/include/net/if.h b/compat/windows/include/net/if.h
deleted file mode 100644 (file)
index cc77ee8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../wincompat.h"
diff --git a/compat/windows/include/netinet/in.h b/compat/windows/include/netinet/in.h
deleted file mode 100644 (file)
index cc77ee8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../wincompat.h"
diff --git a/compat/windows/include/sys/ioctl.h b/compat/windows/include/sys/ioctl.h
deleted file mode 100644 (file)
index cc77ee8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../wincompat.h"
diff --git a/compat/windows/include/sys/poll.h b/compat/windows/include/sys/poll.h
deleted file mode 100644 (file)
index cc77ee8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../wincompat.h"
diff --git a/compat/windows/include/sys/select.h b/compat/windows/include/sys/select.h
deleted file mode 100644 (file)
index cc77ee8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../wincompat.h"
diff --git a/compat/windows/include/sys/socket.h b/compat/windows/include/sys/socket.h
deleted file mode 100644 (file)
index cc77ee8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../wincompat.h"
diff --git a/compat/windows/wincompat.h b/compat/windows/wincompat.h
deleted file mode 100644 (file)
index 37ba883..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef foowincompatfoo
-#define foowincompatfoo
-
-#undef WINVER
-#undef _WIN32_WINNT
-
-#define WINVER 0x0600       // Vista
-#define _WIN32_WINNT WINVER
-
-#include <winsock2.h>
-
-#endif
index 7a7dc40f528f9d4532703be58b037c7920b9e3ed..21d24b57ec17eec19843e1b5f4741f5bd749ad67 100644 (file)
@@ -23,7 +23,7 @@ AC_INIT([catta],[0.1],[])
 AC_CONFIG_SRCDIR([src/server.c])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax])
+AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax subdir-objects])
 
 AC_SUBST(PACKAGE_URL, [http://github.com/everbase/catta/])
 
index ebc34c14ecb2dc1041c8d2302c6c10b9ec9df9b1..b37886270b68347eea37f30f3ebdd1b01678679e 100644 (file)
@@ -18,7 +18,7 @@
 AM_CFLAGS=-I$(top_srcdir)/include
 
 if WINDOWS
-AM_CFLAGS += -I$(top_srcdir)/compat/windows/include
+AM_CFLAGS += -Icompat/windows/include
 endif
 
 # This cool debug trap works on i386/gcc only
@@ -84,6 +84,12 @@ libcatta_la_SOURCES += \
 endif
 endif
 
+if WINDOWS
+libcatta_la_SOURCES += \
+       compat/windows/wincompat.c \
+       compat/windows/wincompat.h
+endif
+
 libcatta_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)
 libcatta_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(INTLLIBS)
 libcatta_la_LDFLAGS = $(AM_LDFLAGS)  -version-info $(LIBCATTA_VERSION_INFO)
diff --git a/src/compat/windows/include/arpa/inet.h b/src/compat/windows/include/arpa/inet.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/include/net/if.h b/src/compat/windows/include/net/if.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/include/netinet/in.h b/src/compat/windows/include/netinet/in.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/include/sys/ioctl.h b/src/compat/windows/include/sys/ioctl.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/include/sys/poll.h b/src/compat/windows/include/sys/poll.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/include/sys/select.h b/src/compat/windows/include/sys/select.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/include/sys/socket.h b/src/compat/windows/include/sys/socket.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/include/sys/utsname.h b/src/compat/windows/include/sys/utsname.h
new file mode 100644 (file)
index 0000000..cc77ee8
--- /dev/null
@@ -0,0 +1 @@
+#include "../../wincompat.h"
diff --git a/src/compat/windows/wincompat.c b/src/compat/windows/wincompat.c
new file mode 100644 (file)
index 0000000..985ca6d
--- /dev/null
@@ -0,0 +1,14 @@
+#include "wincompat.h"
+#include <errno.h>
+
+int uname(struct utsname *buf)
+{
+    memset(buf, 0, sizeof(struct utsname));
+    strncpy(buf->sysname, "Windows", sizeof(buf->sysname)-1);
+    if(GetComputerName(buf->nodename, sizeof(buf->nodename)-1) == 0) {
+        errno = EFAULT;
+        return -1;
+    }
+
+    return 0;
+}
diff --git a/src/compat/windows/wincompat.h b/src/compat/windows/wincompat.h
new file mode 100644 (file)
index 0000000..c82ca6c
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef foowincompatfoo
+#define foowincompatfoo
+
+#undef WINVER
+#undef _WIN32_WINNT
+
+#define WINVER 0x0600       // Vista
+#define _WIN32_WINNT WINVER
+
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+
+typedef int socklen_t;
+
+
+struct utsname {
+   char sysname[9];    /* Operating system name (e.g., "Linux") */
+   char nodename[MAX_COMPUTERNAME_LENGTH+1];
+                       /* Name within "some implementation-defined network" */
+   char release[9];    /* Operating system release (e.g., "2.6.28") */
+   char version[9];    /* Operating system version */
+   char machine[9];    /* Hardware identifier */
+};
+
+int uname(struct utsname *buf);
+
+
+#endif
index cd3c6e2f7230218ba0b58edefb83868a1fed55fa..afa972adb4bc5d1dbc56766e6042575af6cc7a84 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <arpa/inet.h>
 
-#include <sys/utsname.h>
 #include <sys/types.h>
 #include <sys/socket.h>