diff libpurple/protocols/bonjour/bonjour.c @ 23538:399975ad001c

Add purple_get_host_name to get the hostname of the machine. This is a replacement for g_get_host_name in glib2.8+. Thanks to Phil Hannent and Marcus Lundblad for the initial patch. References #5627.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 13 Jul 2008 18:01:57 +0000
parents 5c70d953a497
children e23b447aa5ca c06b85e1d020 16734635febf
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/bonjour.c	Sun Jul 13 17:20:41 2008 +0000
+++ b/libpurple/protocols/bonjour/bonjour.c	Sun Jul 13 18:01:57 2008 +0000
@@ -641,7 +641,6 @@
 	struct passwd *info;
 #endif
 	const char *fullname = NULL, *splitpoint, *tmp;
-	char hostname[255];
 	gchar *conv = NULL;
 
 #ifndef _WIN32
@@ -691,13 +690,7 @@
 
 	/* Try to figure out a good host name to use */
 	/* TODO: Avoid 'localhost,' if possible */
-	if (gethostname(hostname, sizeof(hostname)) != 0) {
-		purple_debug_warning("bonjour", "Error when getting host name: %s.  Using \"localhost.\"\n",
-				g_strerror(errno));
-		strcpy(hostname, "localhost");
-	}
-	hostname[sizeof(hostname) - 1] = '\0';
-	default_hostname = g_strdup(hostname);
+	default_hostname = g_strdup(purple_get_host_name());
 }
 
 static void