libpurple/util.c

branch
soc.2008.themes
changeset 23962
3ce62da60970
parent 23654
ee5f1cc604f8
parent 23850
b68e174fffc2
child 24137
677fde176897
--- a/libpurple/util.c	Fri Aug 01 22:57:11 2008 +0000
+++ b/libpurple/util.c	Wed Aug 06 02:39:40 2008 +0000
@@ -4660,3 +4660,21 @@
 	return g_string_free(string, FALSE);
 }
 
+const gchar *
+purple_get_host_name(void)
+{
+#if GLIB_CHECK_VERSION(2,8,0)
+	return g_get_host_name();
+#else
+	static char hostname[256];
+	int ret = gethostname(hostname, sizeof(hostname));
+	hostname[sizeof(hostname) - 1] = '\0';
+
+	if (ret == -1 || hostname[0] == '\0') {
+		purple_debug_info("purple_get_host_name: ", "could not find host name");
+		return "localhost";
+	} else {
+		return hostname;
+	}
+#endif
+}

mercurial