src/protocols/msn/utils.c

changeset 6358
c3347685b9ef
parent 6093
2095841fde03
child 6359
5b1705ffdd55
equal deleted inserted replaced
6357:f83643b0a067 6358:c3347685b9ef
78 buf[j] = '\0'; 78 buf[j] = '\0';
79 79
80 return buf; 80 return buf;
81 } 81 }
82 82
83 char * 83 void
84 msn_parse_format(const char *mime) 84 msn_parse_format(const char *mime, char **pre_ret, char **post_ret)
85 { 85 {
86 char *cur; 86 char *cur;
87 GString *ret = g_string_new(NULL); 87 GString *pre = g_string_new(NULL);
88 GString *post = g_string_new(NULL);
88 unsigned int colors[3]; 89 unsigned int colors[3];
90
91 if (pre_ret != NULL) *pre_ret = NULL;
92 if (post_ret != NULL) *post_ret = NULL;
89 93
90 cur = strstr(mime, "FN="); 94 cur = strstr(mime, "FN=");
91 95
92 if (cur && (*(cur = cur + 3) != ';')) { 96 if (cur && (*(cur = cur + 3) != ';')) {
93 ret = g_string_append(ret, "<FONT FACE=\""); 97 pre = g_string_append(pre, "<FONT FACE=\"");
94 98
95 while (*cur && *cur != ';') { 99 while (*cur && *cur != ';') {
96 ret = g_string_append_c(ret, *cur); 100 pre = g_string_append_c(pre, *cur);
97 cur++; 101 cur++;
98 } 102 }
99 103
100 ret = g_string_append(ret, "\">"); 104 pre = g_string_append(pre, "\">");
105 post = g_string_prepend(post, "</FONT>");
101 } 106 }
102 107
103 cur = strstr(mime, "EF="); 108 cur = strstr(mime, "EF=");
104 109
105 if (cur && (*(cur = cur + 3) != ';')) { 110 if (cur && (*(cur = cur + 3) != ';')) {
106 while (*cur && *cur != ';') { 111 while (*cur && *cur != ';') {
107 ret = g_string_append_c(ret, '<'); 112 pre = g_string_append_c(pre, '<');
108 ret = g_string_append_c(ret, *cur); 113 pre = g_string_append_c(pre, *cur);
109 ret = g_string_append_c(ret, '>'); 114 pre = g_string_append_c(pre, '>');
110 cur++; 115 cur++;
111 } 116 }
112 } 117 }
113 118
114 cur = strstr(mime, "CO="); 119 cur = strstr(mime, "CO=");
134 139
135 g_snprintf(tag, sizeof(tag), 140 g_snprintf(tag, sizeof(tag),
136 "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">", 141 "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">",
137 colors[2], colors[1], colors[0]); 142 colors[2], colors[1], colors[0]);
138 143
139 ret = g_string_append(ret, tag); 144 pre = g_string_append(pre, tag);
145 post = g_string_prepend(post, "</FONT>");
140 } 146 }
141 } 147 }
142 148
143 cur = msn_url_decode(ret->str); 149 cur = msn_url_decode(pre->str);
144 g_string_free(ret, TRUE); 150 g_string_free(pre, TRUE);
145 151
146 return cur; 152 if (pre_ret != NULL)
153 *pre_ret = cur;
154
155 cur = msn_url_decode(post->str);
156 g_string_free(post, TRUE);
157
158 if (post_ret != NULL)
159 *post_ret = cur;
147 } 160 }

mercurial