File loudmouth-1.4.3-mingw.patch of Package mingw64-loudmouth

--- loudmouth-1.4.3/configure.ac	2011-04-03 09:01:50.733491207 +0200
+++ loudmouth-1.4.3/configure.ac	2011-04-03 09:03:12.508316406 +0200
@@ -34,7 +34,6 @@
   enable_shared=yes
 
   CFLAGS="$CFLAGS -mms-bitfields"
-  LDFLAGS="$LDFLAGS -no-undefined"
 fi
 
 AC_PROG_CC
@@ -53,12 +52,14 @@
 AM_PATH_GLIB_2_0
 
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h memory.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) 
-AC_CHECK_HEADERS([winsock2.h arpa/nameser_compat.h])
+AC_CHECK_HEADERS([winsock2.h wspiapi.h arpa/nameser_compat.h])
 
 if test "$ac_cv_header_winsock2_h" = "yes"; then
   # If we have <winsock2.h>, assume we find the functions
   # in -lws2_32 (ws2_32 is winsock v2, wsock32 is v1.1)
-  LIBS="-lws2_32 -lgdi32 $LIBS"
+  LIBS="-lws2_32 -lgdi32 -ldnsapi $LIBS"
+else
+  LIBS="-lresolv $LIBS"
 fi
 
 IDT_COMPILE_WARNINGS
@@ -95,6 +96,8 @@
 # Check Unit test framework (defined in acinclude.m4)
 IDT_PATH_CHECK(0.9.2, have_check=yes, have_check=no)
 
+AC_CHECK_HEADER(check.h,,have_check=no)
+
 AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)
 
 dnl Gtk doc
@@ -146,10 +149,12 @@
 enable_ssl=no
 if test "x$ac_ssl" = "xgnutls"; then
   dnl Look for GnuTLS
-  AM_PATH_LM_LIBGNUTLS($GNUTLS_REQUIRED, have_libgnutls=yes, have_libgnutls=no)
-  if test "x$have_libgnutls" = "xyes"; then
-    CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
-    LIBS="$LIBS $LIBGNUTLS_LIBS"
+  PKG_CHECK_MODULES(GNUTLS, gnutls >= $GNUTLS_REQUIRED, have_gnutls=yes, have_gnutls=no)
+  if test "x$have_gnutls" = "xyes"; then
+    AC_SUBST(GNUTLS_CFLAGS)
+    AC_SUBST(GNUTLS_LIBS)
+    CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
+    LIBS="$LIBS $GNUTLS_LIBS"
     AC_DEFINE(HAVE_GNUTLS, 1, [whether to use GnuTSL support.])
     enable_ssl=GnuTLS
   else
@@ -212,6 +217,8 @@
 	echo "Not using asynchronous dns lookups"
 fi
 
+AM_CONDITIONAL(USE_ASYNCNS, test x$enable_asyncns = xyes)
+
 dnl +-------------------------------------------------------------------+
 dnl | Checking for Linux TCP/IP stack                                   |
 dnl +-------------------------------------------------------------------+
--- loudmouth-1.4.3/loudmouth/lm-connection.c	2011-04-03 09:01:50.724490562 +0200
+++ loudmouth-1.4.3/loudmouth/lm-connection.c	2011-04-03 09:02:12.590052861 +0200
@@ -32,10 +32,12 @@
 #include <netinet/in.h>
 #endif
 
+#include <glib.h>
+
+#ifndef G_OS_WIN32 
 #include <arpa/nameser.h>
 #include <resolv.h>
-
-#include <glib.h>
+#endif
 
 #include "lm-sock.h"
 #include "lm-debug.h"
--- loudmouth-1.4.3/loudmouth/lm-sock.c	2011-04-03 09:01:50.724490562 +0200
+++ loudmouth-1.4.3/loudmouth/lm-sock.c	2011-04-03 09:02:12.591052929 +0200
@@ -295,8 +295,10 @@
 		return _("The remote host exists but no address "
 			 "is available");
 #endif
+#ifndef G_OS_WIN32
 	case EAI_NONAME:   
 		return _("The remote address is unknown");
+#endif
 	case EAI_FAMILY:
 	case EAI_SERVICE:
 	case EAI_SOCKTYPE:
--- loudmouth-1.4.3/loudmouth/lm-socket.c	2011-04-03 09:01:50.723490490 +0200
+++ loudmouth-1.4.3/loudmouth/lm-socket.c	2011-04-03 09:02:12.592052997 +0200
@@ -23,6 +23,8 @@
 #include <config.h>
 
 #include <string.h>
+#include <stdio.h>
+
 #include <sys/types.h>
 
 /* Needed on Mac OS X */
@@ -35,8 +37,17 @@
 #include <arpa/nameser_compat.h>
 #endif
 
+#if !defined(_WIN32) && !defined(WIN32) //! rxt
 #include <arpa/nameser.h>
 #include <resolv.h>
+#else
+#include <winsock2.h>
+#include <windns.h>
+#ifndef DNS_TYPE_SRV  /* on my mingw this is not defined */
+  /* Service location */
+  #define DNS_TYPE_SRV 0x21  // 33
+ #endif
+#endif //! rxt end
 
 #include "lm-debug.h"
 #include "lm-internals.h"
@@ -120,10 +131,13 @@
 static gboolean     socket_buffered_write_cb  (GIOChannel     *source, 
 					       GIOCondition    condition,
 					       LmSocket       *socket);
+#ifndef _WIN32 //! rxt
 static gboolean     socket_parse_srv_response (unsigned char  *srv, 
 					       int             srv_len, 
 					       gchar         **out_server, 
 					       guint          *out_port);
+#endif
+
 static void         socket_close_io_channel   (GIOChannel     *io_channel);
 
 static void
@@ -151,6 +165,7 @@
 lm_socket_do_write (LmSocket *socket, const gchar *buf, gint len)
 {
 	gint b_written;
+	char str[10];//
 
 	if (socket->ssl_started) {
 		b_written = _lm_ssl_send (socket->ssl, buf, len);
@@ -159,6 +174,7 @@
 		gsize     bytes_written;
 
 		while (io_status == G_IO_STATUS_AGAIN) {
+			lm_verbose ("g_io_channel_write_chars\n");
 			io_status = g_io_channel_write_chars (socket->io_channel, 
 							      buf, len, 
 							      &bytes_written,
@@ -170,6 +186,10 @@
 		if (io_status != G_IO_STATUS_NORMAL) {
 			b_written = -1;
 		}
+		sprintf(str, "%d", b_written);
+
+		lm_verbose (str);
+		lm_verbose ("bytes_written\n");
 	}
 
 	return b_written;
@@ -337,7 +357,7 @@
 
 #ifdef HAVE_GNUTLS
 	/* GNU TLS requires the socket to be blocking */
-	_lm_sock_set_blocking (socket->fd, TRUE);
+	_lm_sock_set_blocking (socket->fd, TRUE); //! rxt!
 #endif
 
 	/* If we're using StartTLS, the correct thing is to verify against
@@ -739,6 +759,8 @@
 	return TRUE;
 }
 
+
+#ifndef _WIN32
 static gboolean
 socket_parse_srv_response (unsigned char  *srv, 
 			   int             srv_len, 
@@ -800,6 +822,7 @@
 	} 
 	return FALSE;
 }
+#endif
 
 static void
 socket_close_io_channel (GIOChannel *io_channel)
@@ -816,11 +839,67 @@
 	_lm_sock_close (fd);
 }
 
+
 static void
 _lm_socket_create_phase1 (LmSocket *socket, unsigned char *srv_ans, int len);
+
+//! rxt
 static void
 _lm_socket_create_phase2 (LmSocket *socket, struct addrinfo *ans);
 
+
+//! rxt
+static void
+_lm_socket_create_phase1_win32 (LmSocket *socket,
+			  unsigned char* srv_name,
+			  int srv_port)
+{
+	const char          *remote_addr;
+	LmConnectData       *data;
+	struct addrinfo      req;
+#ifndef HAVE_ASYNCNS
+	struct addrinfo *ans;
+	int              err;
+#endif
+
+	g_free (socket->server);
+	socket->server = srv_name;
+	socket->port = srv_port;
+
+	/* If server wasn't specified and SRV failed, use domain */
+	if (!socket->server) {
+		lm_verbose ("SRV lookup failed, trying jid domain\n");
+		socket->server = g_strdup (socket->domain);
+	}
+
+	if (socket->proxy) {
+		remote_addr = lm_proxy_get_server (socket->proxy);
+	} else {
+		remote_addr = socket->server;
+	}
+
+	g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
+	       "Going to connect to %s%s:%u\n", (socket->proxy) ? "proxy " : "",
+	       remote_addr, socket->port);
+
+	data = g_new0 (LmConnectData, 1);
+
+	data->socket        = socket;
+	data->connection    = socket->connection;
+	data->fd            = -1;
+	socket->connect_data = data;
+
+	memset (&req, 0, sizeof(req));
+	req.ai_family   = AF_UNSPEC;
+	req.ai_socktype = SOCK_STREAM;
+	req.ai_protocol = IPPROTO_TCP;
+
+	err = getaddrinfo (remote_addr, NULL, &req, &ans);
+	_lm_socket_create_phase2 (socket, (err) ? NULL : ans);
+	if (err != 0)
+		return;
+}
+
 #ifdef HAVE_ASYNCNS
 #define PHASE_1 0
 #define PHASE_2 1
@@ -950,6 +1029,7 @@
 	int              err;
 #endif
 
+	#ifndef _WIN32 //! rxt
 	if (srv_ans != NULL) {
 		gchar    *new_server;
 		guint     new_port;
@@ -963,6 +1043,7 @@
 			socket->port = new_port;
 		}
 	}
+	#endif
 
 	/* If server wasn't specified and SRV failed, use domain */
 	if (!socket->server) {
@@ -1050,10 +1131,15 @@
 {
 	LmSocket        *socket;
 
-#ifndef HAVE_ASYNCNS
+//#ifndef HAVE_ASYNCNS
+#if !defined(HAVE_ASYNCNS) && !defined(_WIN32) //! rxt
 	unsigned char    srv_ans[SRV_LEN];
 	int              len;
 #endif
+#if defined (_WIN32) || defined (WIN32)//! rxt
+    DNS_STATUS      dns_status;
+    PDNS_RECORD     dns_record;
+#endif
 	
 	g_return_val_if_fail (domain != NULL, NULL);
 	g_return_val_if_fail ((port >= MIN_PORT && port <= MAX_PORT), NULL);
@@ -1096,11 +1182,25 @@
 			asyncns_res_query (socket->asyncns_ctx, srv, C_IN, T_SRV);
 		asyncns_setuserdata (socket->asyncns_ctx, socket->resolv_query, (gpointer) PHASE_1);
 #else
+#ifndef _WIN32
 		res_init ();
 
 		len = res_query (srv, C_IN, T_SRV, srv_ans, SRV_LEN);
 		_lm_socket_create_phase1 (socket, (len < 1) ? NULL : srv_ans, len);
 		g_free (srv);
+#else //! rxt
+		dns_status = DnsQuery_A(srv, DNS_TYPE_SRV, DNS_QUERY_BYPASS_CACHE, NULL, &dns_record, NULL);
+		if (dns_status != NO_ERROR) {
+			lm_verbose ("SRV lookup failed for %s\n", socket->server);
+			_lm_socket_create_phase1 (socket, NULL, 0);
+		}
+		else if (dns_record != NULL) {
+			_lm_socket_create_phase1_win32 (socket, g_strdup(dns_record->pName), dns_record->Data.SRV.wPort);
+			DnsRecordListFree(dns_record, 0);
+		}
+
+		g_free (srv);
+#endif //! rxt end
 #endif
 	} else {
 		lm_verbose ("SRV lookup disabled for %s\n", socket->server);
--- loudmouth-1.4.3/loudmouth/lm-sock.h	2011-04-03 09:01:50.722490419 +0200
+++ loudmouth-1.4.3/loudmouth/lm-sock.h	2011-04-03 09:02:12.594053136 +0200
@@ -66,6 +66,18 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
+/* Make use of the wspiapi.h header for Windows 2000 compatibility
+ * if it is present.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_WSPIAPI_H
+#include <wspiapi.h>
+#endif
+
 #define _LM_SOCK_EINPROGRESS WSAEINPROGRESS
 #define _LM_SOCK_EWOULDBLOCK WSAEWOULDBLOCK
 #define _LM_SOCK_EALREADY    WSAEALREADY
--- loudmouth-1.4.3/loudmouth/lm-ssl-openssl.c	2011-04-03 09:01:50.725490634 +0200
+++ loudmouth-1.4.3/loudmouth/lm-ssl-openssl.c	2011-04-03 09:02:12.594053136 +0200
@@ -23,8 +23,10 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <glib.h>
+#ifndef G_OS_WIN32 
+#include <unistd.h>
+#endif
 
 #include "lm-debug.h"
 #include "lm-error.h"
--- loudmouth-1.4.3/loudmouth/Makefile.am	2011-04-03 09:01:50.723490490 +0200
+++ loudmouth-1.4.3/loudmouth/Makefile.am	2011-04-03 09:05:29.050864913 +0200
@@ -23,6 +23,12 @@
 	lm-ssl-openssl.c
 endif
 
+if USE_ASYNCNS
+asyncns_sources =     \
+	asyncns.c     \
+	asyncns.h
+endif
+
 libloudmouth_1_la_SOURCES =		\
 	lm-connection.c	 		\
 	lm-debug.c                      \
@@ -51,8 +57,6 @@
 	lm-sock.c			\
 	lm-socket.c                     \
 	lm-socket.h                     \
-	asyncns.c     \
-	asyncns.h     \
 	lm-sasl.c                       \
 	lm-sasl.h                       \
 	md5.c                           \
@@ -75,12 +79,11 @@
 
 libloudmouth_1_la_LIBADD = 		\
 	$(LOUDMOUTH_LIBS)		\
-	$(LIBIDN_LIBS) \
-	-lresolv
+	$(LIBIDN_LIBS)
 
 libloudmouth_1_la_LDFLAGS = \
 	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-	-export-symbols $(srcdir)/loudmouth.sym
+	-export-symbols $(srcdir)/loudmouth.sym -no-undefined
 libloudmouthincludedir = $(includedir)/loudmouth-1.0/loudmouth
 
 # an explicit dependency here so alm generated files get built
openSUSE Build Service is sponsored by