comparison src/util.c @ 7078:acd2a66e59ed

[gaim-migrate @ 7643] robot101 gave us images in notify_formatted windows. very cool. This lets what I committed earlier (which was support for images in jabber vcards) to work. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 30 Sep 2003 18:41:28 +0000
parents 9d038cc7e825
children 2343c3aa1dec
comparison
equal deleted inserted replaced
7077:6d10bf28be0e 7078:acd2a66e59ed
1001 const char *cur = haystack; 1001 const char *cur = haystack;
1002 char *name = NULL; 1002 char *name = NULL;
1003 gboolean found = FALSE; 1003 gboolean found = FALSE;
1004 gboolean in_tag = FALSE; 1004 gboolean in_tag = FALSE;
1005 gboolean in_attr = FALSE; 1005 gboolean in_attr = FALSE;
1006 gboolean in_quotes = FALSE; 1006 char *in_quotes = NULL;
1007 size_t needlelen = strlen(needle); 1007 size_t needlelen = strlen(needle);
1008 1008
1009 g_datalist_init(&attribs); 1009 g_datalist_init(&attribs);
1010 1010
1011 while (*cur && !found) { 1011 while (*cur && !found) {
1012 if (in_tag) { 1012 if (in_tag) {
1013 if (in_quotes) { 1013 if (in_quotes) {
1014 const char *close = cur; 1014 const char *close = cur;
1015 1015
1016 while (*close && *close != '"') 1016 while (*close && *close != *in_quotes)
1017 close++; 1017 close++;
1018 1018
1019 /* if we got the close quote, store the value and carry on from * 1019 /* if we got the close quote, store the value and carry on from *
1020 * after it. if we ran to the end of the string, point to the NULL * 1020 * after it. if we ran to the end of the string, point to the NULL *
1021 * and we're outta here */ 1021 * and we're outta here */
1028 g_datalist_set_data_full(&attribs, name, val, g_free); 1028 g_datalist_set_data_full(&attribs, name, val, g_free);
1029 g_free(name); 1029 g_free(name);
1030 name = NULL; 1030 name = NULL;
1031 } 1031 }
1032 1032
1033 in_quotes = FALSE; 1033 in_quotes = NULL;
1034 cur = close + 1; 1034 cur = close + 1;
1035 } else { 1035 } else {
1036 cur = close; 1036 cur = close;
1037 } 1037 }
1038 } else if (in_attr) { 1038 } else if (in_attr) {
1039 const char *close = cur; 1039 const char *close = cur;
1040 1040
1041 while (*close && *close != '>' && *close != '"' && *close != ' ' && *close != '=') 1041 while (*close && *close != '>' && *close != '"' &&
1042 *close != '\'' && *close != ' ' && *close != '=')
1042 close++; 1043 close++;
1043 1044
1044 /* if we got the equals, store the name of the attribute. if we got 1045 /* if we got the equals, store the name of the attribute. if we got
1045 * the quote, save the attribute and go straight to quote mode. 1046 * the quote, save the attribute and go straight to quote mode.
1046 * otherwise the tag closed or we reached the end of the string, 1047 * otherwise the tag closed or we reached the end of the string,
1047 * so we can get outta here */ 1048 * so we can get outta here */
1048 switch (*close) { 1049 switch (*close) {
1049 case '"': 1050 case '"':
1050 in_quotes = TRUE; 1051 case '\'':
1052 in_quotes = close;
1051 case '=': 1053 case '=':
1052 { 1054 {
1053 size_t len = close - cur; 1055 size_t len = close - cur;
1054 1056
1055 /* don't store a blank attribute name */ 1057 /* don't store a blank attribute name */
1080 case '>': 1082 case '>':
1081 found = TRUE; 1083 found = TRUE;
1082 *end = cur; 1084 *end = cur;
1083 break; 1085 break;
1084 case '"': 1086 case '"':
1085 in_quotes = TRUE; 1087 case '\'':
1088 in_quotes = cur;
1086 default: 1089 default:
1087 cur++; 1090 cur++;
1088 break; 1091 break;
1089 } 1092 }
1090 } 1093 }