comparison src/protocols/yahoo/yahoo.c @ 11188:12fc7a3fbc88

[gaim-migrate @ 13305] It'll be nice not to crash when logging in with the wrong password. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 04 Aug 2005 01:08:01 +0000
parents 8dca96cbcd64
children 4e25fb6678bd
comparison
equal deleted inserted replaced
11187:744c0708d11f 11188:12fc7a3fbc88
2298 { 2298 {
2299 GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 2299 GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
2300 const char *c = buf; 2300 const char *c = buf;
2301 char *d; 2301 char *d;
2302 char name[64], value[64]; 2302 char name[64], value[64];
2303 int count = sizeof(name)-1; 2303 int count;
2304 while ((c < (buf + len)) && (c = strstr(c, "<input "))) { 2304 int input_len = strlen("<input ");
2305 c = strstr(c, "name=\"") + strlen("name=\""); 2305 int name_len = strlen("name=\"");
2306 for (d = name; *c!='"' && count; c++, d++, count--) 2306 int value_len = strlen("value=\"");
2307 while ((len > ((c - buf) + input_len))
2308 && (c = strstr(c, "<input "))) {
2309 if (!(c = g_strstr_len(c, len - (c - buf), "name=\"")))
2310 continue;
2311 c += name_len;
2312 count = sizeof(name)-1;
2313 for (d = name; (len > ((c - buf) + 1)) && *c!='"'
2314 && count; c++, d++, count--)
2307 *d = *c; 2315 *d = *c;
2308 *d = '\0'; 2316 *d = '\0';
2309 count = sizeof(value)-1; 2317 count = sizeof(value)-1;
2310 d = strstr(c, "value=\"") + strlen("value=\""); 2318 if (!(d = g_strstr_len(c, len - (c - buf), "value=\"")))
2319 continue;
2320 d += value_len;
2311 if (strchr(c, '>') < d) 2321 if (strchr(c, '>') < d)
2312 break; 2322 break;
2313 for (c = d, d = value; *c!='"' && count; c++, d++, count--) 2323 for (c = d, d = value; (len > ((c - buf) + 1))
2324 && *c!='"' && count; c++, d++, count--)
2314 *d = *c; 2325 *d = *c;
2315 *d = '\0'; 2326 *d = '\0';
2316 g_hash_table_insert(hash, g_strdup(name), g_strdup(value)); 2327 g_hash_table_insert(hash, g_strdup(name), g_strdup(value));
2317 } 2328 }
2318 return hash; 2329 return hash;