From 45fd76be0ef793b130720bb64b0356aa4e4566ec Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" Date: Tue, 26 Aug 2014 20:49:49 +0200 Subject: [PATCH] add uname and socklen_t to windows compat layer --- compat/windows/wincompat.h | 12 -------- configure.ac | 2 +- src/Makefile.am | 8 ++++- .../compat}/windows/include/arpa/inet.h | 0 .../compat}/windows/include/net/if.h | 0 .../compat}/windows/include/netinet/in.h | 0 .../compat}/windows/include/sys/ioctl.h | 0 .../compat}/windows/include/sys/poll.h | 0 .../compat}/windows/include/sys/select.h | 0 .../compat}/windows/include/sys/socket.h | 0 src/compat/windows/include/sys/utsname.h | 1 + src/compat/windows/wincompat.c | 14 +++++++++ src/compat/windows/wincompat.h | 29 +++++++++++++++++++ src/entry.c | 1 - 14 files changed, 52 insertions(+), 15 deletions(-) delete mode 100644 compat/windows/wincompat.h rename {compat => src/compat}/windows/include/arpa/inet.h (100%) rename {compat => src/compat}/windows/include/net/if.h (100%) rename {compat => src/compat}/windows/include/netinet/in.h (100%) rename {compat => src/compat}/windows/include/sys/ioctl.h (100%) rename {compat => src/compat}/windows/include/sys/poll.h (100%) rename {compat => src/compat}/windows/include/sys/select.h (100%) rename {compat => src/compat}/windows/include/sys/socket.h (100%) create mode 100644 src/compat/windows/include/sys/utsname.h create mode 100644 src/compat/windows/wincompat.c create mode 100644 src/compat/windows/wincompat.h diff --git a/compat/windows/wincompat.h b/compat/windows/wincompat.h deleted file mode 100644 index 37ba883..0000000 --- a/compat/windows/wincompat.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef foowincompatfoo -#define foowincompatfoo - -#undef WINVER -#undef _WIN32_WINNT - -#define WINVER 0x0600 // Vista -#define _WIN32_WINNT WINVER - -#include - -#endif diff --git a/configure.ac b/configure.ac index 7a7dc40..21d24b5 100644 --- a/configure.ac +++ b/configure.ac @@ -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/]) diff --git a/src/Makefile.am b/src/Makefile.am index ebc34c1..b378862 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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/compat/windows/include/arpa/inet.h b/src/compat/windows/include/arpa/inet.h similarity index 100% rename from compat/windows/include/arpa/inet.h rename to src/compat/windows/include/arpa/inet.h diff --git a/compat/windows/include/net/if.h b/src/compat/windows/include/net/if.h similarity index 100% rename from compat/windows/include/net/if.h rename to src/compat/windows/include/net/if.h diff --git a/compat/windows/include/netinet/in.h b/src/compat/windows/include/netinet/in.h similarity index 100% rename from compat/windows/include/netinet/in.h rename to src/compat/windows/include/netinet/in.h diff --git a/compat/windows/include/sys/ioctl.h b/src/compat/windows/include/sys/ioctl.h similarity index 100% rename from compat/windows/include/sys/ioctl.h rename to src/compat/windows/include/sys/ioctl.h diff --git a/compat/windows/include/sys/poll.h b/src/compat/windows/include/sys/poll.h similarity index 100% rename from compat/windows/include/sys/poll.h rename to src/compat/windows/include/sys/poll.h diff --git a/compat/windows/include/sys/select.h b/src/compat/windows/include/sys/select.h similarity index 100% rename from compat/windows/include/sys/select.h rename to src/compat/windows/include/sys/select.h diff --git a/compat/windows/include/sys/socket.h b/src/compat/windows/include/sys/socket.h similarity index 100% rename from compat/windows/include/sys/socket.h rename to src/compat/windows/include/sys/socket.h diff --git a/src/compat/windows/include/sys/utsname.h b/src/compat/windows/include/sys/utsname.h new file mode 100644 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/sys/utsname.h @@ -0,0 +1 @@ +#include "../../wincompat.h" diff --git a/src/compat/windows/wincompat.c b/src/compat/windows/wincompat.c new file mode 100644 index 0000000..985ca6d --- /dev/null +++ b/src/compat/windows/wincompat.c @@ -0,0 +1,14 @@ +#include "wincompat.h" +#include + +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 index 0000000..c82ca6c --- /dev/null +++ b/src/compat/windows/wincompat.h @@ -0,0 +1,29 @@ +#ifndef foowincompatfoo +#define foowincompatfoo + +#undef WINVER +#undef _WIN32_WINNT + +#define WINVER 0x0600 // Vista +#define _WIN32_WINNT WINVER + +#include +#include + + +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 diff --git a/src/entry.c b/src/entry.c index cd3c6e2..afa972a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -30,7 +30,6 @@ #include -#include #include #include -- 2.39.5