Mercurial > pidgin.yaz
comparison libpurple/network.c @ 27711:7fbf964c6c6c
Move the IDN support into the DNS routines.
This turned out to be cleaner than I first thought, so here we go.
All libpurple DNS routines support IDN when built against GNU libidn.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 19 Jul 2009 23:45:13 +0000 |
parents | 627d23bfdb05 |
children | 02f6f49da454 |
comparison
equal
deleted
inserted
replaced
27710:91333c6c16ef | 27711:7fbf964c6c6c |
---|---|
47 #include "network.h" | 47 #include "network.h" |
48 #include "prefs.h" | 48 #include "prefs.h" |
49 #include "stun.h" | 49 #include "stun.h" |
50 #include "upnp.h" | 50 #include "upnp.h" |
51 #include "dnsquery.h" | 51 #include "dnsquery.h" |
52 | |
53 #ifdef USE_IDN | |
54 #include <idna.h> | |
55 #endif | |
52 | 56 |
53 /* | 57 /* |
54 * Calling sizeof(struct ifreq) isn't always correct on | 58 * Calling sizeof(struct ifreq) isn't always correct on |
55 * Mac OS X (and maybe others). | 59 * Mac OS X (and maybe others). |
56 */ | 60 */ |
964 purple_network_nat_pmp_mapping_remove(&port, protocol, NULL); | 968 purple_network_nat_pmp_mapping_remove(&port, protocol, NULL); |
965 g_hash_table_remove(nat_pmp_port_mappings, protocol); | 969 g_hash_table_remove(nat_pmp_port_mappings, protocol); |
966 } | 970 } |
967 } | 971 } |
968 } | 972 } |
969 | 973 |
974 int purple_network_convert_idn_to_ascii(const gchar *in, gchar **out) | |
975 { | |
976 #ifdef USE_IDN | |
977 char *tmp; | |
978 int ret; | |
979 | |
980 g_return_val_if_fail(out != NULL, -1); | |
981 | |
982 ret = idna_to_ascii_8z(in, &tmp, IDNA_USE_STD3_ASCII_RULES); | |
983 if (ret != IDNA_SUCCESS) { | |
984 *out = NULL; | |
985 return ret; | |
986 } | |
987 | |
988 *out = g_strdup(tmp); | |
989 /* This *MUST* be freed with free, not g_free */ | |
990 free(tmp); | |
991 return 0; | |
992 #else | |
993 g_return_val_if_fail(out != NULL, -1); | |
994 | |
995 *out = g_strdup(in); | |
996 return 0; | |
997 #endif | |
998 } | |
999 | |
970 void | 1000 void |
971 purple_network_init(void) | 1001 purple_network_init(void) |
972 { | 1002 { |
973 #ifdef HAVE_NETWORKMANAGER | 1003 #ifdef HAVE_NETWORKMANAGER |
974 GError *error = NULL; | 1004 GError *error = NULL; |