Mercurial > pidgin.yaz
comparison libpurple/protocols/bonjour/bonjour.c @ 23583: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 | 16734635febf c06b85e1d020 e23b447aa5ca |
comparison
equal
deleted
inserted
replaced
23582:ad0d0efa30dd | 23583:399975ad001c |
---|---|
639 { | 639 { |
640 #ifndef _WIN32 | 640 #ifndef _WIN32 |
641 struct passwd *info; | 641 struct passwd *info; |
642 #endif | 642 #endif |
643 const char *fullname = NULL, *splitpoint, *tmp; | 643 const char *fullname = NULL, *splitpoint, *tmp; |
644 char hostname[255]; | |
645 gchar *conv = NULL; | 644 gchar *conv = NULL; |
646 | 645 |
647 #ifndef _WIN32 | 646 #ifndef _WIN32 |
648 /* Try to figure out the user's real name */ | 647 /* Try to figure out the user's real name */ |
649 info = getpwuid(getuid()); | 648 info = getpwuid(getuid()); |
689 | 688 |
690 g_free(conv); | 689 g_free(conv); |
691 | 690 |
692 /* Try to figure out a good host name to use */ | 691 /* Try to figure out a good host name to use */ |
693 /* TODO: Avoid 'localhost,' if possible */ | 692 /* TODO: Avoid 'localhost,' if possible */ |
694 if (gethostname(hostname, sizeof(hostname)) != 0) { | 693 default_hostname = g_strdup(purple_get_host_name()); |
695 purple_debug_warning("bonjour", "Error when getting host name: %s. Using \"localhost.\"\n", | |
696 g_strerror(errno)); | |
697 strcpy(hostname, "localhost"); | |
698 } | |
699 hostname[sizeof(hostname) - 1] = '\0'; | |
700 default_hostname = g_strdup(hostname); | |
701 } | 694 } |
702 | 695 |
703 static void | 696 static void |
704 init_plugin(PurplePlugin *plugin) | 697 init_plugin(PurplePlugin *plugin) |
705 { | 698 { |