Mercurial > pidgin
annotate src/protocols/msn/utils.c @ 10093:9d839c9f6c2d
[gaim-migrate @ 11111]
Some more great MSN bugfixes from the patch tracker:
Patch: 1045196:
Fixed sending messages to MSN Web Messenger users (Damien Ayers)
Patches 1045834 & 1044931:
Fixed some memory leaks in the MSN plugin (Evan Schoenberg)
Patch 1046398:
Fixed a potential crash viewing MSN user profiles (Evan Schoenberg)
(this also fixed a double-"Has You" bug that was only present in HEAD)
Thanks guys!
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Wed, 13 Oct 2004 17:54:11 +0000 |
parents | e6a3aa978a44 |
children | 3016b1b32339 |
rev | line source |
---|---|
5309 | 1 /** |
5312
89948fedf782
[gaim-migrate @ 5684]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
2 * @file utils.c Utility functions |
5309 | 3 * |
4 * gaim | |
5 * | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
6 * Gaim is the legal property of its developers, whose names are too numerous |
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
8 * source distribution. |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6359
diff
changeset
|
9 * |
5309 | 10 * This program is free software; you can redistribute it and/or modify |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
24 #include "msn.h" | |
25 | |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
26 void |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
27 msn_parse_format(const char *mime, char **pre_ret, char **post_ret) |
5309 | 28 { |
29 char *cur; | |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
30 GString *pre = g_string_new(NULL); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
31 GString *post = g_string_new(NULL); |
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
32 unsigned int colors[3]; |
5309 | 33 |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
34 if (pre_ret != NULL) *pre_ret = NULL; |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
35 if (post_ret != NULL) *post_ret = NULL; |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
36 |
5309 | 37 cur = strstr(mime, "FN="); |
38 | |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
39 if (cur && (*(cur = cur + 3) != ';')) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
40 { |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
41 pre = g_string_append(pre, "<FONT FACE=\""); |
5309 | 42 |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
43 while (*cur && *cur != ';') |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
44 { |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
45 pre = g_string_append_c(pre, *cur); |
5309 | 46 cur++; |
47 } | |
48 | |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
49 pre = g_string_append(pre, "\">"); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
50 post = g_string_prepend(post, "</FONT>"); |
5309 | 51 } |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
52 |
5309 | 53 cur = strstr(mime, "EF="); |
54 | |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
55 if (cur && (*(cur = cur + 3) != ';')) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
56 { |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
57 while (*cur && *cur != ';') |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
58 { |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
59 pre = g_string_append_c(pre, '<'); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
60 pre = g_string_append_c(pre, *cur); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
61 pre = g_string_append_c(pre, '>'); |
8691
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8678
diff
changeset
|
62 post = g_string_prepend_c(post, '>'); |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8678
diff
changeset
|
63 post = g_string_prepend_c(post, *cur); |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8678
diff
changeset
|
64 post = g_string_prepend_c(post, '/'); |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8678
diff
changeset
|
65 post = g_string_prepend_c(post, '<'); |
5309 | 66 cur++; |
67 } | |
68 } | |
69 | |
70 cur = strstr(mime, "CO="); | |
71 | |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
72 if (cur && (*(cur = cur + 3) != ';')) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
73 { |
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
74 int i; |
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
75 |
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
76 i = sscanf(cur, "%02x%02x%02x;", &colors[0], &colors[1], &colors[2]); |
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
77 |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
78 if (i > 0) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
79 { |
5309 | 80 char tag[64]; |
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
81 |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
82 if (i == 1) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
83 { |
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
84 colors[1] = 0; |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
85 colors[2] = 0; |
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
86 } |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
87 else if (i == 2) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
88 { |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
89 unsigned int temp = colors[0]; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
90 |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
91 colors[0] = colors[1]; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
92 colors[1] = temp; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
93 colors[2] = 0; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
94 } |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
95 else if (i == 3) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
96 { |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
97 unsigned int temp = colors[2]; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
98 |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
99 colors[2] = colors[0]; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
100 colors[0] = temp; |
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
101 } |
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
102 |
5309 | 103 g_snprintf(tag, sizeof(tag), |
104 "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">", | |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
105 colors[0], colors[1], colors[2]); |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
106 |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
107 pre = g_string_append(pre, tag); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
108 post = g_string_prepend(post, "</FONT>"); |
5309 | 109 } |
110 } | |
111 | |
7134 | 112 cur = g_strdup(gaim_url_decode(pre->str)); |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
113 g_string_free(pre, TRUE); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
114 |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
115 if (pre_ret != NULL) |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
116 *pre_ret = cur; |
6359
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
117 else |
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
118 g_free(cur); |
5309 | 119 |
7134 | 120 cur = g_strdup(gaim_url_decode(post->str)); |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
121 g_string_free(post, TRUE); |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
122 |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
123 if (post_ret != NULL) |
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
124 *post_ret = cur; |
6359
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
125 else |
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
126 g_free(cur); |
5309 | 127 } |
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
128 |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
129 /* |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
130 * We need this because we're only supposed to encode spaces in the font |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
131 * names. gaim_url_encode() isn't acceptable. |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
132 */ |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
133 const char * |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
134 encode_spaces(const char *str) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
135 { |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
136 static char buf[BUF_LEN]; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
137 const char *c; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
138 char *d; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
139 |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
140 g_return_val_if_fail(str != NULL, NULL); |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
141 |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
142 for (c = str, d = buf; *c != '\0'; c++) |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
143 { |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
144 if (*c == ' ') |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
145 { |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
146 *d++ = '%'; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
147 *d++ = '2'; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
148 *d++ = '0'; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
149 } |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
150 else |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
151 *d++ = *c; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
152 } |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
153 |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
154 return buf; |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
155 } |
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
156 |
8595
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
157 /* |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
158 * Taken from the zephyr plugin. |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
159 * This parses HTML formatting (put out by one of the gtkimhtml widgets |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
160 * and converts it to msn formatting. It doesn't deal with the tag closing, |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
161 * but gtkimhtml widgets give valid html. |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
162 * It currently deals properly with <b>, <u>, <i>, <font face=...>, |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
163 * <font color=...>. |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
164 * It ignores <font back=...> and <font size=...> |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
165 */ |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
166 void |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
167 msn_import_html(const char *html, char **attributes, char **message) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
168 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
169 int len, retcount = 0; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
170 const char *c; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
171 char *msg; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
172 char *fontface = NULL; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
173 char fonteffect[4]; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
174 char fontcolor[7]; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
175 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
176 g_return_if_fail(html != NULL); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
177 g_return_if_fail(attributes != NULL); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
178 g_return_if_fail(message != NULL); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
179 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
180 len = strlen(html); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
181 msg = g_malloc0(len + 1); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
182 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
183 memset(fontcolor, 0, sizeof(fontcolor)); |
10093 | 184 strcat(fontcolor, "0"); |
10041 | 185 memset(fonteffect, 0, sizeof(fonteffect)); |
8595
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
186 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
187 for (c = html; *c != '\0';) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
188 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
189 if (*c == '<') |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
190 { |
8923 | 191 if (!g_ascii_strncasecmp(c + 1, "br>", 3)) |
192 { | |
193 msg[retcount++] = '\r'; | |
194 msg[retcount++] = '\n'; | |
195 c += 4; | |
196 } | |
197 else if (!g_ascii_strncasecmp(c + 1, "i>", 2)) | |
8595
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
198 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
199 strcat(fonteffect, "I"); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
200 c += 3; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
201 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
202 else if (!g_ascii_strncasecmp(c + 1, "b>", 2)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
203 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
204 strcat(fonteffect, "B"); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
205 c += 3; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
206 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
207 else if (!g_ascii_strncasecmp(c + 1, "u>", 2)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
208 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
209 strcat(fonteffect, "U"); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
210 c += 3; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
211 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
212 else if (!g_ascii_strncasecmp(c + 1, "a href=\"", 8)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
213 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
214 c += 9; |
9331
851b8c672011
[gaim-migrate @ 10139]
Christian Hammond <chipx86@chipx86.com>
parents:
9264
diff
changeset
|
215 |
851b8c672011
[gaim-migrate @ 10139]
Christian Hammond <chipx86@chipx86.com>
parents:
9264
diff
changeset
|
216 if (!g_ascii_strncasecmp(c, "mailto:", 7)) |
851b8c672011
[gaim-migrate @ 10139]
Christian Hammond <chipx86@chipx86.com>
parents:
9264
diff
changeset
|
217 c += 7; |
8595
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
218 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
219 while (g_ascii_strncasecmp(c, "\">", 2)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
220 msg[retcount++] = *c++; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
221 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
222 c += 2; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
223 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
224 /* ignore descriptive string */ |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
225 while (g_ascii_strncasecmp(c, "</a>", 4)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
226 c++; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
227 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
228 c += 4; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
229 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
230 else if (!g_ascii_strncasecmp(c + 1, "font", 4)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
231 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
232 c += 5; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
233 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
234 while (!g_ascii_strncasecmp(c, " ", 1)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
235 c++; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
236 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
237 if (!g_ascii_strncasecmp(c, "color=\"#", 7)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
238 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
239 c += 8; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
240 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
241 fontcolor[0] = *(c + 4); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
242 fontcolor[1] = *(c + 5); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
243 fontcolor[2] = *(c + 2); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
244 fontcolor[3] = *(c + 3); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
245 fontcolor[4] = *c; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
246 fontcolor[5] = *(c + 1); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
247 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
248 c += 8; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
249 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
250 else if (!g_ascii_strncasecmp(c, "face=\"", 6)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
251 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
252 const char *end = NULL; |
8921 | 253 const char *comma = NULL; |
8595
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
254 unsigned int namelen = 0; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
255 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
256 c += 6; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
257 end = strchr(c, '\"'); |
8921 | 258 comma = strchr(c, ','); |
259 | |
9090
cab225a333b5
[gaim-migrate @ 9867]
Christian Hammond <chipx86@chipx86.com>
parents:
8923
diff
changeset
|
260 if (comma == NULL || comma > end) |
cab225a333b5
[gaim-migrate @ 9867]
Christian Hammond <chipx86@chipx86.com>
parents:
8923
diff
changeset
|
261 namelen = (unsigned int)(end - c); |
cab225a333b5
[gaim-migrate @ 9867]
Christian Hammond <chipx86@chipx86.com>
parents:
8923
diff
changeset
|
262 else |
cab225a333b5
[gaim-migrate @ 9867]
Christian Hammond <chipx86@chipx86.com>
parents:
8923
diff
changeset
|
263 namelen = (unsigned int)(comma - c); |
8921 | 264 |
8595
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
265 fontface = g_strndup(c, namelen); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
266 c = end + 2; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
267 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
268 else |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
269 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
270 /* Drop all unrecognized/misparsed font tags */ |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
271 while (g_ascii_strncasecmp(c, "\">", 2)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
272 c++; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
273 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
274 c += 2; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
275 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
276 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
277 else |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
278 { |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
279 while (g_ascii_strncasecmp(c, ">", 1)) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
280 c++; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
281 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
282 c++; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
283 } |
8921 | 284 } |
285 else if (*c == '&') | |
286 { | |
287 if (!g_ascii_strncasecmp(c, "<", 4)) | |
288 { | |
8678 | 289 msg[retcount++] = '<'; |
290 c += 4; | |
8921 | 291 } |
292 else if (!g_ascii_strncasecmp(c, ">", 4)) | |
293 { | |
8678 | 294 msg[retcount++] = '>'; |
295 c += 4; | |
8921 | 296 } |
9264
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
297 else if (!g_ascii_strncasecmp(c, " ", 6)) |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
298 { |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
299 msg[retcount++] = ' '; |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
300 c += 6; |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
301 } |
8921 | 302 else if (!g_ascii_strncasecmp(c, """, 6)) |
303 { | |
8678 | 304 msg[retcount++] = '"'; |
305 c += 6; | |
8921 | 306 } |
307 else if (!g_ascii_strncasecmp(c, "&", 5)) | |
308 { | |
8678 | 309 msg[retcount++] = '&'; |
310 c += 5; | |
311 } | |
9264
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
312 else if (!g_ascii_strncasecmp(c, "'", 6)) |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
313 { |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
314 msg[retcount++] = '\''; |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
315 c += 6; |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
316 } |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
317 else |
cea7eba5f494
[gaim-migrate @ 10063]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
318 msg[retcount++] = *c++; |
8921 | 319 } |
320 else | |
8595
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
321 msg[retcount++] = *c++; |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
322 } |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
323 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
324 if (fontface == NULL) |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
325 fontface = g_strdup("MS Sans Serif"); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
326 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
327 *attributes = g_strdup_printf("FN=%s; EF=%s; CO=%s; PF=0", |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
328 encode_spaces(fontface), |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
329 fonteffect, fontcolor); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
330 *message = g_strdup(msg); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
331 |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
332 g_free(fontface); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
333 g_free(msg); |
1d5e31e518fc
[gaim-migrate @ 9346]
Christian Hammond <chipx86@chipx86.com>
parents:
8530
diff
changeset
|
334 } |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
335 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
336 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
337 msn_parse_socket(const char *str, char **ret_host, int *ret_port) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
338 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
339 char *host; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
340 char *c; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
341 int port; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
342 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
343 host = g_strdup(str); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
344 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
345 if ((c = strchr(host, ':')) != NULL) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
346 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
347 *c = '\0'; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
348 port = atoi(c + 1); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
349 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
350 else |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
351 port = 1863; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
352 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
353 *ret_host = host; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
354 *ret_port = port; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9090
diff
changeset
|
355 } |