pidgin: e7d6a0a2: A patch from Peter O'Gorman at The Writt...

rlaager at pidgin.im rlaager at pidgin.im
Mon May 26 21:25:48 EDT 2008


-----------------------------------------------------------------
Revision: e7d6a0a271d8fe8435f200e0f1ec123053e57493
Ancestor: 04d1cb7493b8f54f33a413d3a60468704ab4be4b
Author: pogma at thewrittenword.com
Date: 2008-05-27T01:11:46
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e7d6a0a271d8fe8435f200e0f1ec123053e57493

Modified files:
        COPYRIGHT configure.ac libpurple/dnsquery.c
        libpurple/dnssrv.c libpurple/internal.h libpurple/nat-pmp.c
        libpurple/network.c libpurple/protocols/zephyr/Makefile.am
        libpurple/protocols/zephyr/zephyr.c libpurple/proxy.c

ChangeLog: 

A patch from Peter O'Gorman at The Written Word, Inc. to fix various
portability issues.  These changes seemed reasonable, even though I wasn't
able to test or verify them all in particular.  Hopefully we don't break
anything on another OS.
Refs #3798

-------------- next part --------------
============================================================
--- COPYRIGHT	fec5303736008db5dc49fb153d998cf8a32cd5bd
+++ COPYRIGHT	3ba2175d8ac07cfadcfe324153b4990000a45ed1
@@ -278,6 +278,7 @@ Christopher O'Brien (siege)
 Novell
 Padraig O'Briain
 Christopher O'Brien (siege)
+Peter O'Gorman
 Jon Oberheide
 Yusuke Odate
 Ruediger Oertel
@@ -449,6 +450,7 @@ Scott Wolchok
 Matt Wilson
 Dan Winship
 Scott Wolchok
+The Written Word, Inc.
 Kevin Wu Won
 Pui Lam Wong
 Justin Wood
============================================================
--- configure.ac	5687d5e2342e7223dae8fe2c5bc4005503332581
+++ configure.ac	52f3c1c25225b8f21bae8143f790022ef26b0326
@@ -108,13 +108,14 @@ AC_PROG_CC
 
 dnl Checks for programs.
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_DISABLE_STATIC
-AM_PROG_LIBTOOL
+AC_PROG_LIBTOOL
 LIBTOOL="$LIBTOOL --silent"
 AC_PROG_INSTALL
 AC_PROG_INTLTOOL
 PKG_PROG_PKG_CONFIG
-
+AC_FUNC_ALLOCA
 GETTEXT_PACKAGE=pidgin
 AC_SUBST(GETTEXT_PACKAGE)
 
@@ -210,7 +211,7 @@ AC_CHECK_FUNC(getaddrinfo,
 		[Define to 1 if you have the getaddrinfo function.])],
 	[AC_CHECK_LIB(socket, getaddrinfo,
 		[AC_DEFINE([HAVE_GETADDRINFO]) LIBS="-lsocket -lsnl $LIBS"], , , -lnsl)])
-
+AC_CHECK_FUNCS(inet_ntop)
 dnl Check for socklen_t (in Unix98)
 AC_MSG_CHECKING(for socklen_t)
 AC_TRY_COMPILE([
@@ -234,6 +235,12 @@ AC_TRY_COMPILE([
 	])
 ])
 
+dnl Some systems do not have sa_len field for struct sockaddr.
+AC_CHECK_MEMBER([struct sockaddr.sa_len],
+	[AC_DEFINE([HAVE_STRUCT_SOCKADDR_SA_LEN],[1],
+	[Define if struct sockaddr has an sa_len member])],[:],
+	[#include <sys/socket.h>])
+
 dnl to prevent the g_stat()/g_unlink() crash,
 dnl (09:50:07) Robot101: LSchiere2: it's easy. +LC_SYS_LARGEFILE somewhere in configure.ac
 AC_SYS_LARGEFILE
============================================================
--- libpurple/dnsquery.c	d248338535a85030214ef837622fe09220efa606
+++ libpurple/dnsquery.c	c4cf150193a2be8b58173dfb91b0dfd02d8e0576
@@ -32,6 +32,9 @@
 #include "prefs.h"
 #include "util.h"
 
+#if (defined(__APPLE__) || defined (__unix__)) && !defined(__osf__)
+#define PURPLE_DNSQUERY_USE_FORK
+#endif
 /**************************************************************************
  * DNS query API
  **************************************************************************/
@@ -47,16 +50,16 @@ struct _PurpleDnsQueryData {
 	gpointer data;
 	guint timeout;
 
-#if defined(__unix__) || defined(__APPLE__)
+#if defined(PURPLE_DNSQUERY_USE_FORK)
 	PurpleDnsQueryResolverProcess *resolver;
-#elif defined _WIN32 /* end __unix__ || __APPLE__ */
+#elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK  */
 	GThread *resolver;
 	GSList *hosts;
 	gchar *error_message;
 #endif
 };
 
-#if defined(__unix__) || defined(__APPLE__)
+#if defined(PURPLE_DNSQUERY_USE_FORK)
 
 #define MAX_DNS_CHILDREN 4
 
@@ -131,7 +134,7 @@ purple_dnsquery_ui_resolve(PurpleDnsQuer
 	return FALSE;
 }
 
-#if defined(__unix__) || defined(__APPLE__)
+#if defined(PURPLE_DNSQUERY_USE_FORK)
 
 /*
  * Unix!
@@ -649,7 +652,7 @@ purple_dnsquery_a(const char *hostname, 
 	return query_data;
 }
 
-#elif defined _WIN32 /* end __unix__ || __APPLE__ */
+#elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK  */
 
 /*
  * Windows!
@@ -821,7 +824,7 @@ purple_dnsquery_a(const char *hostname, 
 	return query_data;
 }
 
-#else /* not __unix__ or __APPLE__ or _WIN32 */
+#else /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
 
 /*
  * We weren't able to do anything fancier above, so use the
@@ -897,7 +900,7 @@ purple_dnsquery_a(const char *hostname, 
 	return query_data;
 }
 
-#endif /* not __unix__ or __APPLE__ or _WIN32 */
+#endif /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
 
 void
 purple_dnsquery_destroy(PurpleDnsQueryData *query_data)
@@ -907,7 +910,7 @@ purple_dnsquery_destroy(PurpleDnsQueryDa
 	if (ops && ops->destroy)
 		ops->destroy(query_data);
 
-#if defined(__unix__) || defined(__APPLE__)
+#if defined(PURPLE_DNSQUERY_USE_FORK)
 	queued_requests = g_slist_remove(queued_requests, query_data);
 
 	if (query_data->resolver != NULL)
@@ -918,7 +921,7 @@ purple_dnsquery_destroy(PurpleDnsQueryDa
 		 * they just don't listen.
 		 */
 		purple_dnsquery_resolver_destroy(query_data->resolver);
-#elif defined _WIN32 /* end __unix__ || __APPLE__ */
+#elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK */
 	if (query_data->resolver != NULL)
 	{
 		/*
@@ -987,7 +990,7 @@ purple_dnsquery_uninit(void)
 void
 purple_dnsquery_uninit(void)
 {
-#if defined(__unix__) || defined(__APPLE__)
+#if defined(PURPLE_DNSQUERY_USE_FORK)
 	while (free_dns_children != NULL)
 	{
 		purple_dnsquery_resolver_destroy(free_dns_children->data);
============================================================
--- libpurple/dnssrv.c	80dad502d3a922fd2d8433e40942d1cb657531f5
+++ libpurple/dnssrv.c	b27bf5a97d652bb86861f274528bba2a355f3384
@@ -25,8 +25,8 @@
 #include "util.h"
 
 #ifndef _WIN32
+#include <arpa/nameser.h>
 #include <resolv.h>
-#include <arpa/nameser.h>
 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
 #include <arpa/nameser_compat.h>
 #endif
============================================================
--- libpurple/internal.h	0762159cb0d27d5537e611db67c6d7625d0bf5b0
+++ libpurple/internal.h	a6383f7bdfdc1815f74d7d60963bd5c74eceaf20
@@ -102,7 +102,7 @@
 #include <gmodule.h>
 
 #ifdef PURPLE_PLUGINS
-# ifndef _WIN32
+# ifdef HAVE_DLFCN_H 
 #  include <dlfcn.h>
 # endif
 #endif
============================================================
--- libpurple/nat-pmp.c	f56e00f82aabec30fe98b3af40d0d9f5e90322f1
+++ libpurple/nat-pmp.c	f88925cb7dce1f2553f6f8487a787b8fe52543dd
@@ -125,7 +125,16 @@ get_rtaddrs(int bitmask, struct sockaddr
 		if (bitmask & (1 << i)) 
 		{
 			addrs[i] = sa;
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
 			sa = (struct sockaddr *)(ROUNDUP(sa->sa_len) + (char *)sa);
+#else
+			if (sa->sa_family == AF_INET)
+				sa = (struct sockaddr*)(sizeof(struct sockaddr_in) + (char *)sa);
+#ifdef AF_INET6
+			else if (sa->sa_family == AF_INET6)
+				sa = (struct sockaddr*)(sizeof(struct sockaddr_in6) + (char *)sa);
+#endif
+#endif
 		} 
 		else
 		{
@@ -146,7 +155,12 @@ is_default_route(struct sockaddr *sa, st
     if ((sin->sin_addr.s_addr == INADDR_ANY) &&
 		mask &&
 		(ntohl(((struct sockaddr_in *)mask)->sin_addr.s_addr) == 0L ||
-		 mask->sa_len == 0))
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+		 mask->sa_len == 0
+#else
+		0
+#endif
+		))
 		return 1;
     else
 		return 0;
============================================================
--- libpurple/network.c	e23154bedd473ccb41348ccb2d864543f1019499
+++ libpurple/network.c	9e14534d108bdb718f02bb05f2eeada3ba75d18e
@@ -27,9 +27,9 @@
 #include "internal.h"
 
 #ifndef _WIN32
+#include <arpa/nameser.h>
 #include <resolv.h>
 #include <netinet/in.h>
-#include <arpa/nameser.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
 #else
============================================================
--- libpurple/protocols/zephyr/Makefile.am	bd999a1285b73ad59dee14591f1d14f0f1038ff2
+++ libpurple/protocols/zephyr/Makefile.am	f64380a954909958eb6ec689d52c959e01f8d792
@@ -104,7 +104,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_builddir)/libpurple \
 	-I$(top_srcdir)/libpurple/protocols \
-	-DCONFDIR=\"$(confdir)\" \
+	-DCONFDIR=\"$(sysconfdir)\" \
 	$(GLIB_CFLAGS) \
 	$(KRB4_CFLAGS) \
 	$(DEBUG_CFLAGS)
============================================================
--- libpurple/protocols/zephyr/zephyr.c	aea1b1c7db11574e57dfa320816b27c9ee8823ed
+++ libpurple/protocols/zephyr/zephyr.c	c6a3eb210389c26225c50bdd12fd16d47d4a4967
@@ -892,11 +892,16 @@ static void handle_message(PurpleConnect
 			gconv1 = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
 														 zt2->name, gc->account);
 			gcc = purple_conversation_get_chat_data(gconv1);
-
+#ifndef INET_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#endif
 			if (!purple_conv_chat_find_user(gcc, sendertmp)) {
 				gchar ipaddr[INET_ADDRSTRLEN];
+#ifdef HAVE_INET_NTOP
 				inet_ntop(AF_INET, &notice.z_sender_addr.s_addr, ipaddr, sizeof(ipaddr));
-
+#else
+				memcpy(ipaddr,inet_ntoa(notice.z_sender_addr),sizeof(ipaddr));
+#endif
 				purple_conv_chat_add_user(gcc, sendertmp, ipaddr, PURPLE_CBFLAGS_NONE, TRUE);
 			}
 			g_free(sendertmp);
============================================================
--- libpurple/proxy.c	079719d988d356ed029d43599fda286cb54b33bb
+++ libpurple/proxy.c	a05468748e9b9038e90aaccc835057b75b112753
@@ -1726,6 +1726,10 @@ proxy_connect_socks5(PurpleProxyConnectD
  * resolved, and each time a connection attempt fails (assuming there
  * is another IP address to try).
  */
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
 static void try_connect(PurpleProxyConnectData *connect_data)
 {
 	size_t addrlen;
@@ -1736,9 +1740,13 @@ static void try_connect(PurpleProxyConne
 	connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data);
 	addr = connect_data->hosts->data;
 	connect_data->hosts = g_slist_remove(connect_data->hosts, connect_data->hosts->data);
-
+#ifdef HAVE_INET_NTOP
 	inet_ntop(addr->sa_family, &((struct sockaddr_in *)addr)->sin_addr,
 			ipaddr, sizeof(ipaddr));
+#else
+	memcpy(ipaddr,inet_ntoa(((struct sockaddr_in *)addr)->sin_addr),
+			sizeof(ipaddr));
+#endif
 	purple_debug_info("proxy", "Attempting connection to %s\n", ipaddr);
 
 	switch (purple_proxy_info_get_type(connect_data->gpi)) {


More information about the Commits mailing list