From: Sven M. Hallberg Date: Tue, 26 Aug 2014 18:49:49 +0000 (+0200) Subject: add uname and socklen_t to windows compat layer X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=45fd76be0ef793b130720bb64b0356aa4e4566ec;p=catta add uname and socklen_t to windows compat layer --- diff --git a/compat/windows/include/arpa/inet.h b/compat/windows/include/arpa/inet.h deleted file mode 100644 index cc77ee8..0000000 --- a/compat/windows/include/arpa/inet.h +++ /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 index cc77ee8..0000000 --- a/compat/windows/include/net/if.h +++ /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 index cc77ee8..0000000 --- a/compat/windows/include/netinet/in.h +++ /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 index cc77ee8..0000000 --- a/compat/windows/include/sys/ioctl.h +++ /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 index cc77ee8..0000000 --- a/compat/windows/include/sys/poll.h +++ /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 index cc77ee8..0000000 --- a/compat/windows/include/sys/select.h +++ /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 index cc77ee8..0000000 --- a/compat/windows/include/sys/socket.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../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/src/compat/windows/include/arpa/inet.h b/src/compat/windows/include/arpa/inet.h new file mode 100644 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/arpa/inet.h @@ -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 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/net/if.h @@ -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 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/netinet/in.h @@ -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 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/sys/ioctl.h @@ -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 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/sys/poll.h @@ -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 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/sys/select.h @@ -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 index 0000000..cc77ee8 --- /dev/null +++ b/src/compat/windows/include/sys/socket.h @@ -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 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