diff options
author | Siraj Razick <siraj.razick@collabora.co.uk> | 2011-12-21 12:29:29 -0500 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2012-01-02 12:57:22 +0000 |
commit | 44a326f3ab2aafea7a78df6ac75e9b4c014fe0e8 (patch) | |
tree | c2f250af4d9eb7b694d34946d2bb8a04a57174ca | |
parent | 8a1a8d94d40d731a8045d4fb2a67a65484a7983c (diff) |
Build fixes for Windows
These changes enables us to cross-compile wocky for windows with mingw32
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/test-resolver.c | 6 | ||||
-rw-r--r-- | tests/wocky-connector-test.c | 24 | ||||
-rw-r--r-- | wocky/wocky-meta-porter.c | 8 |
4 files changed, 35 insertions, 5 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 7be6c8f..0a0e3ed 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -267,7 +267,7 @@ check_PROGRAMS = $(TEST_PROGS) check_c_sources = $(notdir $(wildcard $(srcdir)/*.c) $(wildcard $(srcdir)/*.h)) -all: $(TEST_PROGS) +noinst_PROGRAMS = $(TEST_PROGS) test-report: test-report.xml gtester-report $(top_builddir)/tests/$@.xml > \ diff --git a/tests/test-resolver.c b/tests/test-resolver.c index 409e599..323e5e5 100644 --- a/tests/test-resolver.c +++ b/tests/test-resolver.c @@ -34,9 +34,15 @@ #include <stdio.h> #include <glib.h> + +#ifdef G_OS_WIN32 +#include <windows.h> +#include <ws2tcpip.h> +#else #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> +#endif #include "test-resolver.h" diff --git a/tests/wocky-connector-test.c b/tests/wocky-connector-test.c index 42eab7c..624a551 100644 --- a/tests/wocky-connector-test.c +++ b/tests/wocky-connector-test.c @@ -4,14 +4,20 @@ #include <stdlib.h> #include <string.h> #include <fcntl.h> +#include <config.h> +#include <glib.h> +#include <glib/gstdio.h> + +#ifdef G_OS_WIN32 +#include <windows.h> +#include <ws2tcpip.h> +#else #include <sys/socket.h> #include <sys/stat.h> #include <sys/wait.h> #include <netinet/in.h> #include <arpa/inet.h> - -#include <glib.h> -#include <glib/gstdio.h> +#endif #include <wocky/wocky-connector.h> #include <wocky/wocky-namespaces.h> @@ -3132,6 +3138,9 @@ client_connected (GIOChannel *channel, GSocket *gsock = g_socket_new_from_fd (csock, NULL); test_t *test = data; ConnectorProblem *cproblem = &test->server_parameters.problem.conn; +#ifdef G_OS_WIN32 + u_long mode = 0; +#endif GSocketConnection *gconn; long flags; @@ -3146,9 +3155,14 @@ client_connected (GIOChannel *channel, if (!test->server_parameters.features.tls) cproblem->xmpp |= XMPP_PROBLEM_NO_TLS; +#ifdef G_OS_WIN32 + WSAEventSelect( csock, 0, 0); + ioctlsocket (csock, FIONBIO, &mode); +#else flags = fcntl (csock, F_GETFL ); flags = flags & ~O_NONBLOCK; fcntl (csock, F_SETFL, flags); +#endif gconn = g_object_new (G_TYPE_SOCKET_CONNECTION, "socket", gsock, NULL); g_object_unref (gsock); test->server = test_connector_server_new (G_IO_STREAM (gconn), @@ -3180,7 +3194,9 @@ start_dummy_xmpp_server (test_t *test) memset (&server, 0, sizeof (server)); server.sin_family = AF_INET; - inet_aton (REACHABLE, &server.sin_addr); + + /* mingw doesn't support aton or pton so using more portable inet_addr */ + server.sin_addr.s_addr = inet_addr ((const char * ) REACHABLE); server.sin_port = htons (port); ssock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); setsockopt (ssock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse)); diff --git a/wocky/wocky-meta-porter.c b/wocky/wocky-meta-porter.c index 773023a..a511db3 100644 --- a/wocky/wocky-meta-porter.c +++ b/wocky/wocky-meta-porter.c @@ -23,8 +23,16 @@ #include <stdlib.h> #include <string.h> +#ifdef G_OS_WIN32 +#include <windows.h> +#include <ws2tcpip.h> +#include <stdint.h> +typedef uint32_t u_int32_t; +typedef uint16_t u_int16_t; +#else #include <sys/socket.h> #include <netinet/in.h> +#endif #include "wocky-ll-connection-factory.h" #include "wocky-contact-factory.h" |