changeset 31474:74e2492967be

Consolidate duplicated implementations of purple_dnsquery_a
author Daniel Atallah <daniel.atallah@gmail.com>
date Sat, 16 Apr 2011 03:08:03 +0000
parents ba00769a1493
children 68a1efda3654
files libpurple/dnsquery.c
diffstat 1 files changed, 7 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/dnsquery.c	Sun Apr 10 19:21:27 2011 +0000
+++ b/libpurple/dnsquery.c	Sat Apr 16 03:08:03 2011 +0000
@@ -696,37 +696,6 @@
 	return FALSE;
 }
 
-PurpleDnsQueryData *
-purple_dnsquery_a(const char *hostname, int port,
-				PurpleDnsQueryConnectFunction callback, gpointer data)
-{
-	PurpleDnsQueryData *query_data;
-
-	g_return_val_if_fail(hostname != NULL, NULL);
-	g_return_val_if_fail(port	  != 0, NULL);
-	g_return_val_if_fail(callback != NULL, NULL);
-
-	query_data = g_new(PurpleDnsQueryData, 1);
-	query_data->hostname = g_strdup(hostname);
-	g_strstrip(query_data->hostname);
-	query_data->port = port;
-	query_data->callback = callback;
-	query_data->data = data;
-	query_data->resolver = NULL;
-
-	if (*query_data->hostname == '\0')
-	{
-		purple_dnsquery_destroy(query_data);
-		g_return_val_if_reached(NULL);
-	}
-
-	purple_debug_info("dns", "DNS query for '%s' queued\n", query_data->hostname);
-
-	query_data->timeout = purple_timeout_add(0, resolve_host, query_data);
-
-	return query_data;
-}
-
 #elif defined _WIN32 /* end PURPLE_DNSQUERY_USE_FORK  */
 
 /*
@@ -873,37 +842,6 @@
 	return FALSE;
 }
 
-PurpleDnsQueryData *
-purple_dnsquery_a(const char *hostname, int port,
-				PurpleDnsQueryConnectFunction callback, gpointer data)
-{
-	PurpleDnsQueryData *query_data;
-
-	g_return_val_if_fail(hostname != NULL, NULL);
-	g_return_val_if_fail(port	  != 0, NULL);
-	g_return_val_if_fail(callback != NULL, NULL);
-
-	purple_debug_info("dnsquery", "Performing DNS lookup for %s\n", hostname);
-
-	query_data = g_new0(PurpleDnsQueryData, 1);
-	query_data->hostname = g_strdup(hostname);
-	g_strstrip(query_data->hostname);
-	query_data->port = port;
-	query_data->callback = callback;
-	query_data->data = data;
-
-	if (strlen(query_data->hostname) == 0)
-	{
-		purple_dnsquery_destroy(query_data);
-		g_return_val_if_reached(NULL);
-	}
-
-	/* Don't call the callback before returning */
-	query_data->timeout = purple_timeout_add(0, resolve_host, query_data);
-
-	return query_data;
-}
-
 #else /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
 
 /*
@@ -969,6 +907,8 @@
 	return FALSE;
 }
 
+#endif /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
+
 PurpleDnsQueryData *
 purple_dnsquery_a(const char *hostname, int port,
 				PurpleDnsQueryConnectFunction callback, gpointer data)
@@ -976,29 +916,29 @@
 	PurpleDnsQueryData *query_data;
 
 	g_return_val_if_fail(hostname != NULL, NULL);
-	g_return_val_if_fail(port	  != 0, NULL);
+	g_return_val_if_fail(port != 0, NULL);
 	g_return_val_if_fail(callback != NULL, NULL);
 
-	query_data = g_new(PurpleDnsQueryData, 1);
+	purple_debug_info("dnsquery", "Performing DNS lookup for %s\n", hostname);
+
+	query_data = g_new0(PurpleDnsQueryData, 1);
 	query_data->hostname = g_strdup(hostname);
 	g_strstrip(query_data->hostname);
 	query_data->port = port;
 	query_data->callback = callback;
 	query_data->data = data;
 
-	if (strlen(query_data->hostname) == 0)
+	if (*query_data->hostname == '\0')
 	{
 		purple_dnsquery_destroy(query_data);
 		g_return_val_if_reached(NULL);
 	}
 
-	/* Don't call the callback before returning */
 	query_data->timeout = purple_timeout_add(0, resolve_host, query_data);
 
 	return query_data;
 }
 
-#endif /* not PURPLE_DNSQUERY_USE_FORK or _WIN32 */
 
 void
 purple_dnsquery_destroy(PurpleDnsQueryData *query_data)