Mercurial > pidgin
diff libpurple/util.c @ 23855:e23b447aa5ca
propagate from branch 'im.pidgin.pidgin' (head e3ceb09b71185a9074ce73733f2a65b437c9a545)
to branch 'im.pidgin.soc.2008.vv' (head a94b36f0065825b75de573746f680ae616b34f41)
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Wed, 16 Jul 2008 21:55:08 +0000 |
parents | 399975ad001c |
children | 27eacd38c721 2ecd716746e6 |
line wrap: on
line diff
--- a/libpurple/util.c Wed Jul 16 21:42:13 2008 +0000 +++ b/libpurple/util.c Wed Jul 16 21:55:08 2008 +0000 @@ -4723,3 +4723,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 +}