/pidgin/main: 0e80c61f83d3: Remove all of the dns code

Gary Kramlich grim at reaperworld.com
Wed Dec 23 23:33:34 EST 2015


Changeset: 0e80c61f83d35df3e793e0dd2cb184b33e76f68e
Author:	 Gary Kramlich <grim at reaperworld.com>
Date:	 2015-12-15 22:03 -0600
Branch:	 use-gresolver
URL: https://hg.pidgin.im/pidgin/main/rev/0e80c61f83d3

Description:

Remove all of the dns code

diffstat:

 libpurple/Makefile.am |     4 -
 libpurple/dnsquery.c  |  1080 ---------------------------------------------
 libpurple/dnsquery.h  |   195 --------
 libpurple/dnssrv.c    |  1163 -------------------------------------------------
 libpurple/dnssrv.h    |   213 --------
 5 files changed, 0 insertions(+), 2655 deletions(-)

diffs (truncated from 2692 to 300 lines):

diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -106,8 +106,6 @@ purple_coresources = \
 	smiley-parser.c \
 	smiley-theme.c \
 	smiley.c \
-	dnsquery.c \
-	dnssrv.c\
 	status.c \
 	stringref.c \
 	stun.c \
@@ -187,8 +185,6 @@ purple_coreheaders = \
 	smiley-parser.h \
 	smiley-theme.h \
 	smiley.h \
-	dnsquery.h \
-	dnssrv.h \
 	status.h \
 	stringref.h \
 	stun.h \
diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c
deleted file mode 100644
--- a/libpurple/dnsquery.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here.  Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
- *
- */
-#define _PURPLE_DNSQUERY_C_
-
-#include "internal.h"
-#include "debug.h"
-#include "dnsquery.h"
-#include "network.h"
-#include "notify.h"
-#include "prefs.h"
-#include "util.h"
-
-#ifndef _WIN32
-#include <resolv.h>
-#endif
-
-#define MAX_ADDR_RESPONSE_LEN 1048576
-
-#if (defined(__APPLE__) || defined (__unix__)) && !defined(__osf__)
-#define PURPLE_DNSQUERY_USE_FORK
-#endif
-/**************************************************************************
- * DNS query API
- **************************************************************************/
-
-static PurpleDnsQueryUiOps *dns_query_ui_ops = NULL;
-
-typedef struct _PurpleDnsQueryResolverProcess PurpleDnsQueryResolverProcess;
-
-struct _PurpleDnsQueryData {
-	char *hostname;
-	int port;
-	PurpleDnsQueryConnectFunction callback;
-	gpointer data;
-	guint timeout;
-	PurpleAccount *account;
-
-#if defined(PURPLE_DNSQUERY_USE_FORK)
-	PurpleDnsQueryResolverProcess *resolver;
-#elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK  */
-	GThread *resolver;
-	GSList *hosts;
-	gchar *error_message;
-#endif
-};
-
-#if defined(PURPLE_DNSQUERY_USE_FORK)
-
-#define MAX_DNS_CHILDREN 4
-
-/*
- * This structure keeps a reference to a child resolver process.
- */
-struct _PurpleDnsQueryResolverProcess {
-	guint inpa;
-	int fd_in, fd_out;
-	pid_t dns_pid;
-};
-
-static GSList *free_dns_children = NULL;
-static GQueue *queued_requests = NULL;
-
-static int number_of_dns_children = 0;
-
-/*
- * This is a convenience struct used to pass data to
- * the child resolver process.
- */
-typedef struct {
-	char hostname[512];
-	int port;
-} dns_params_t;
-#endif /* end PURPLE_DNSQUERY_USE_FORK */
-
-static void
-purple_dnsquery_resolved(PurpleDnsQueryData *query_data, GSList *hosts)
-{
-	purple_debug_info("dnsquery", "IP resolved for %s\n", query_data->hostname);
-	if (query_data->callback != NULL)
-		query_data->callback(hosts, query_data->data, NULL);
-	else
-	{
-		/*
-		 * Callback is a required parameter, but it can get set to
-		 * NULL if we cancel a thread-based DNS lookup.  So we need
-		 * to free hosts.
-		 */
-		while (hosts != NULL)
-		{
-			hosts = g_slist_remove(hosts, hosts->data);
-			g_free(hosts->data);
-			hosts = g_slist_remove(hosts, hosts->data);
-		}
-	}
-
-#ifdef PURPLE_DNSQUERY_USE_FORK
-	/*
-	 * Add the resolver to the list of available resolvers, and set it
-	 * to NULL so that it doesn't get destroyed along with the query_data
-	 */
-	if (query_data->resolver)
-	{
-		free_dns_children = g_slist_prepend(free_dns_children, query_data->resolver);
-		query_data->resolver = NULL;
-	}
-#endif /* PURPLE_DNSQUERY_USE_FORK */
-
-	purple_dnsquery_destroy(query_data);
-}
-
-static void
-purple_dnsquery_failed(PurpleDnsQueryData *query_data, const gchar *error_message)
-{
-	purple_debug_error("dnsquery", "%s\n", error_message);
-	if (query_data->callback != NULL)
-		query_data->callback(NULL, query_data->data, error_message);
-	purple_dnsquery_destroy(query_data);
-}
-
-static gboolean
-purple_dnsquery_ui_resolve(PurpleDnsQueryData *query_data)
-{
-	PurpleDnsQueryUiOps *ops = purple_dnsquery_get_ui_ops();
-
-	if (ops && ops->resolve_host)
-		return ops->resolve_host(query_data, purple_dnsquery_resolved, purple_dnsquery_failed);
-
-	return FALSE;
-}
-
-static gboolean
-resolve_ip(PurpleDnsQueryData *query_data)
-{
-#if defined(HAVE_GETADDRINFO) && defined(AI_NUMERICHOST)
-	struct addrinfo hints, *res;
-	char servname[20];
-
-	g_snprintf(servname, sizeof(servname), "%d", query_data->port);
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = AF_UNSPEC;
-	hints.ai_flags |= AI_NUMERICHOST;
-
-	if (0 == getaddrinfo(query_data->hostname, servname, &hints, &res))
-	{
-		GSList *hosts = NULL;
-		hosts = g_slist_append(hosts, GINT_TO_POINTER(res->ai_addrlen));
-		hosts = g_slist_append(hosts, g_memdup(res->ai_addr, res->ai_addrlen));
-		purple_dnsquery_resolved(query_data, hosts);
-
-		freeaddrinfo(res);
-		return TRUE;
-	}
-#else /* defined(HAVE_GETADDRINFO) && defined(AI_NUMERICHOST) */
-	struct sockaddr_in sin;
-	if (inet_aton(query_data->hostname, &sin.sin_addr))
-	{
-		/*
-		 * The given "hostname" is actually an IP address, so we
-		 * don't need to do anything.
-		 */
-		GSList *hosts = NULL;
-		sin.sin_family = AF_INET;
-		sin.sin_port = htons(query_data->port);
-		hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin)));
-		hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin)));
-		purple_dnsquery_resolved(query_data, hosts);
-
-		return TRUE;
-	}
-#endif
-
-	return FALSE;
-}
-
-#ifdef USE_IDN
-static gboolean
-dns_str_is_ascii(const char *name)
-{
-	guchar *c;
-	for (c = (guchar *)name; c && *c; ++c) {
-		if (*c > 0x7f)
-			return FALSE;
-	}
-
-	return TRUE;
-}
-#endif
-
-#if defined(PURPLE_DNSQUERY_USE_FORK)
-
-/*
- * Unix!
- */
-
-/*
- * Begin the DNS resolver child process functions.
- */
-#ifdef HAVE_SIGNAL_H
-G_GNUC_NORETURN static void
-trap_gdb_bug(int sig)
-{
-	const char *message =
-		"Purple's DNS child got a SIGTRAP signal.\n"
-		"This can be caused by trying to run purple inside gdb.\n"
-		"There is a known gdb bug which prevents this.  Supposedly purple\n"
-		"should have detected you were using gdb and used an ugly hack,\n"
-		"check cope_with_gdb_brokenness() in dnsquery.c.\n\n"
-		"For more info about this bug, see http://sources.redhat.com/ml/gdb/2001-07/msg00349.html\n";
-	fputs("\n* * *\n",stderr);
-	fputs(message,stderr);
-	fputs("* * *\n\n",stderr);
-	execlp("xmessage","xmessage","-center", message, NULL);
-	_exit(1);
-}
-#endif
-
-static void
-write_to_parent(int fd, const void *buf, size_t count)
-{
-	ssize_t written;
-
-	written = write(fd, buf, count);
-	if (written < 0 || (gsize)written != count) {
-		if (written < 0)
-			fprintf(stderr, "dns[%d]: Error writing data to "
-					"parent: %s\n", getpid(), strerror(errno));
-		else
-			fprintf(stderr, "dns[%d]: Error: Tried to write %"
-					G_GSIZE_FORMAT " bytes to parent but instead "
-					"wrote %" G_GSIZE_FORMAT " bytes\n",
-					getpid(), count, written);
-	}
-}
-
-G_GNUC_NORETURN static void
-purple_dnsquery_resolver_run(int child_out, int child_in, gboolean show_debug)
-{
-	dns_params_t dns_params;
-	const size_t zero = 0;
-	int rc;
-#ifdef HAVE_GETADDRINFO
-	struct addrinfo hints, *res, *tmp;
-	char servname[20];
-#else
-	struct sockaddr_in sin;
-	const size_t addrlen = sizeof(sin);
-#endif
-	char *hostname;
-
-#ifdef HAVE_SIGNAL_H
-	purple_restore_default_signal_handlers();
-	signal(SIGTRAP, trap_gdb_bug);
-#endif
-
-	/*



More information about the Commits mailing list