Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/message.c @ 19252:cfbd89a98431
Remove msim_parse_body(), obsoleted by msim_msg_get_dictionary().
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sun, 19 Aug 2007 06:57:41 +0000 |
parents | d34e49d8fac7 |
children | b66c5991c011 |
comparison
equal
deleted
inserted
replaced
19251:78558930d9f3 | 19252:cfbd89a98431 |
---|---|
170 /* First parameter can be given explicitly. */ | 170 /* First parameter can be given explicitly. */ |
171 first = first_key != NULL; | 171 first = first_key != NULL; |
172 | 172 |
173 /* Read key, type, value triplets until NULL. */ | 173 /* Read key, type, value triplets until NULL. */ |
174 do { | 174 do { |
175 if (first) | 175 if (first) { |
176 { | |
177 key = first_key; | 176 key = first_key; |
178 first = FALSE; | 177 first = FALSE; |
179 } else { | 178 } else { |
180 key = va_arg(argp, gchar *); | 179 key = va_arg(argp, gchar *); |
181 if (!key) { | 180 if (!key) { |
986 | 985 |
987 /* Can free now since all data was copied to hash key/values */ | 986 /* Can free now since all data was copied to hash key/values */ |
988 g_free(raw); | 987 g_free(raw); |
989 | 988 |
990 return msg; | 989 return msg; |
991 } | |
992 | |
993 /** | |
994 * Parse a \x1c-separated "dictionary" of key=value pairs into a hash table. | |
995 * | |
996 * @param body_str The text of the dictionary to parse. Often the | |
997 * value for the 'body' field. | |
998 * | |
999 * @return Hash table of the keys and values. Must g_hash_table_destroy() when done. | |
1000 * | |
1001 * XXX TODO: This is deprecated in favor of msim_msg_dictionary_parse(); remove it. | |
1002 */ | |
1003 GHashTable * | |
1004 msim_parse_body(const gchar *body_str) | |
1005 { | |
1006 GHashTable *table; | |
1007 gchar *item; | |
1008 gchar **items; | |
1009 gchar **elements; | |
1010 guint i; | |
1011 | |
1012 g_return_val_if_fail(body_str != NULL, NULL); | |
1013 | |
1014 table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
1015 | |
1016 for (items = g_strsplit(body_str, "\x1c", 0), i = 0; | |
1017 (item = items[i]); | |
1018 i++) { | |
1019 gchar *key, *value; | |
1020 | |
1021 elements = g_strsplit(item, "=", 2); | |
1022 | |
1023 key = elements[0]; | |
1024 if (!key) { | |
1025 purple_debug_info("msim", "msim_parse_body(%s): null key\n", | |
1026 body_str); | |
1027 g_strfreev(elements); | |
1028 break; | |
1029 } | |
1030 | |
1031 value = elements[1]; | |
1032 if (!value) { | |
1033 purple_debug_info("msim", "msim_parse_body(%s): null value\n", | |
1034 body_str); | |
1035 g_strfreev(elements); | |
1036 break; | |
1037 } | |
1038 | |
1039 #ifdef MSIM_DEBUG_PARSE | |
1040 purple_debug_info("msim", "-- %s: %s\n", key ? key : "(NULL)", | |
1041 value ? value : "(NULL)"); | |
1042 #endif | |
1043 | |
1044 /* XXX: This overwrites duplicates. */ | |
1045 /* TODO: make the GHashTable values be GList's, and append to the list if | |
1046 * there is already a value of the same key name. This is important for | |
1047 * the WebChallenge message. */ | |
1048 g_hash_table_insert(table, g_strdup(key), g_strdup(value)); | |
1049 | |
1050 g_strfreev(elements); | |
1051 } | |
1052 | |
1053 g_strfreev(items); | |
1054 | |
1055 return table; | |
1056 } | 990 } |
1057 | 991 |
1058 /** Search for and return the node in msg, matching name, or NULL. | 992 /** Search for and return the node in msg, matching name, or NULL. |
1059 * | 993 * |
1060 * @param msg Message to search within. | 994 * @param msg Message to search within. |