annotate src/protocols/yahoo/util.c @ 6735:b0913ab92893

[gaim-migrate @ 7267] This is some compile warning cleanup stuff. I tried compiling with CFLAGS="-ansi -ggdb -pedantic -Wall" It's fun. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 04 Sep 2003 03:50:22 +0000
parents f80e23e66de0
children ee32e030c9be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /*
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * gaim
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 * Some code copyright 2003 Tim Ringenbach <omarvo@hotmail.com>
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 * (marv on irc.freenode.net)
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 * (at your option) any later version.
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * GNU General Public License for more details.
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 #include "config.h"
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25 #endif
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 #include "prpl.h"
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28 #include "debug.h"
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
30 #include <string.h>
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
31
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 /*
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
34 * I found these on some website but i don't know that they actually
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35 * work (or are supposed to work). I didn't impliment them yet.
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 * [0;30m ---black
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38 * [1;37m ---white
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39 * [0;37m ---tan
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40 * [0;38m ---light black
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
41 * [1;39m ---dark blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42 * [0;32m ---green
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
43 * [0;33m ---yellow
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
44 * [0;35m ---pink
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
45 * [1;35m ---purple
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46 * [1;30m ---light blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
47 * [0;31m ---red
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
48 * [0;34m ---blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
49 * [0;36m ---aqua
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
50 * (shift+comma)lyellow(shift+period) ---light yellow
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
51 * (shift+comma)lgreen(shift+period) ---light green
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
52 [2;30m <--white out
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
55
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57 static GHashTable *ht = NULL;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
58
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
59 void yahoo_init_colorht()
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
60 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
61 ht = g_hash_table_new(g_str_hash, g_str_equal);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
62 /* the numbers in comments are what gyach uses, but i think they're incorrect */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63 g_hash_table_insert(ht, "30", "<FONT COLOR=\"#000000\">"); /* black */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
64 g_hash_table_insert(ht, "31", "<FONT COLOR=\"#0000FF\">"); /* blue */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
65 g_hash_table_insert(ht, "32", "<FONT COLOR=\"#008080\">"); /* cyan */ /* 00b2b2 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
66 g_hash_table_insert(ht, "33", "<FONT COLOR=\"#808080\">"); /* gray */ /* 808080 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67 g_hash_table_insert(ht, "34", "<FONT COLOR=\"#008000\">"); /* green */ /* 00c200 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
68 g_hash_table_insert(ht, "35", "<FONT COLOR=\"#FF0080\">"); /* pink */ /* ffafaf */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69 g_hash_table_insert(ht, "36", "<FONT COLOR=\"#800080\">"); /* purple */ /* b200b2 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
70 g_hash_table_insert(ht, "37", "<FONT COLOR=\"#FF8000\">"); /* orange */ /* ffff00 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
71 g_hash_table_insert(ht, "38", "<FONT COLOR=\"#FF0000\">"); /* red */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
72 g_hash_table_insert(ht, "39", "<FONT COLOR=\"#808000\">"); /* olive */ /* 546b50 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
74 g_hash_table_insert(ht, "1", "<B>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
75 g_hash_table_insert(ht, "x1", "</B>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76 g_hash_table_insert(ht, "2", "<I>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77 g_hash_table_insert(ht, "x2", "</I>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78 g_hash_table_insert(ht, "4", "<U>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79 g_hash_table_insert(ht, "x4", "</U>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
81 /* these just tell us the text they surround is supposed
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
82 * to be a link. gaim figures that out on its own so we
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
83 * just ignore it.
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
84 */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
85 g_hash_table_insert(ht, "l", ""); /* link start */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
86 g_hash_table_insert(ht, "xl", ""); /* link end */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
87
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
88
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 g_hash_table_insert(ht, "<black>", "<FONT COLOR=\"#000000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90 g_hash_table_insert(ht, "<blue>", "<FONT COLOR=\"#0000FF\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 g_hash_table_insert(ht, "<cyan>", "<FONT COLOR=\"#008284\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 g_hash_table_insert(ht, "<gray>", "<FONT COLOR=\"#848284\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93 g_hash_table_insert(ht, "<green>", "<FONT COLOR=\"#008200\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 g_hash_table_insert(ht, "<pink>", "<FONT COLOR=\"#FF0084\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 g_hash_table_insert(ht, "<purple>", "<FONT COLOR=\"#840084\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96 g_hash_table_insert(ht, "<orange>", "<FONT COLOR=\"#FF8000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 g_hash_table_insert(ht, "<red>", "<FONT COLOR=\"#FF0000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98 g_hash_table_insert(ht, "<yellow>", "<FONT COLOR=\"#848200\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 g_hash_table_insert(ht, "</black>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101 g_hash_table_insert(ht, "</blue>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 g_hash_table_insert(ht, "</cyan>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 g_hash_table_insert(ht, "</gray>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 g_hash_table_insert(ht, "</green>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 g_hash_table_insert(ht, "</pink>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 g_hash_table_insert(ht, "</purple>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 g_hash_table_insert(ht, "</orange>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 g_hash_table_insert(ht, "</red>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 g_hash_table_insert(ht, "</yellow>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 /* remove these once we have proper support for <FADE> and <ALT> */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112 g_hash_table_insert(ht, "</fade>", "");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 g_hash_table_insert(ht, "</alt>", "");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 void yahoo_dest_colorht()
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 g_hash_table_destroy(ht);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
121 static int point_to_html(int x)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
122 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
123 if (x < 9)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
124 return 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
125 if (x < 11)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
126 return 2;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
127 if (x < 13)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
128 return 3;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
129 if (x < 17)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
130 return 4;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
131 if (x < 25)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
132 return 5;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
133 if (x < 35)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
134 return 6;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
135 return 7;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
136 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
137 static void _font_tags_fix_size(GString *tag, GString *dest)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
138 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
139 char *x, *end;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
140 int size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
141
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
142 if (((x = strstr(tag->str, "size"))) && ((x = strchr(tag->str, '=')))) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
143 while (*x && !g_ascii_isdigit(*x))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
144 x++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
145 if (*x) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
146 size = strtol(x, &end, 10);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
147 size = point_to_html(size);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
148 g_string_append_len(dest, tag->str, x - tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
149 g_string_append_printf(dest, "%d", size);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
150 g_string_append(dest, end);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
151 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
152 g_string_append(dest, tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
153 return;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
154 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
155 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
156 g_string_append(dest, tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
157 return;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
158 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
159 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
160
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
161 char *yahoo_codes_to_html(const char *x)
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 GString *s, *tmp;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
164 int i, j, xs, nomoreendtags = 0; /* s/endtags/closinganglebrackets */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 char *match, *ret;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 s = g_string_sized_new(strlen(x));
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170 for (i = 0, xs = strlen(x); i < xs; i++) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 if ((x[i] == 0x1b) && (x[i+1] == '[')) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 j = i + 1;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 while (j++ < xs) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175 if (x[j] != 'm')
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 continue;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 tmp = g_string_new_len(x + i + 2, j - i - 2);
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6546
diff changeset
179 if (tmp->str[0] == '#')
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180 g_string_append_printf(s, "<FONT COLOR=\"%s\">", tmp->str);
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
181 else if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 g_string_append(s, match);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
184 gaim_debug(GAIM_DEBUG_ERROR, "yahoo",
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
185 "Unknown ansi code 'ESC[%sm'.\n", tmp->str);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
186 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
190 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
191 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
192 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 } else if (!nomoreendtags && (x[i] == '<')) {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
198 j = i;
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
199
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
200 while (j++ < xs) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201 if (x[j] != '>')
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
202 if (j == xs) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
203 g_string_append_c(s, '<');
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
204 nomoreendtags = 1;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
205 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
206 else
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
207 continue;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
208 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
209 tmp = g_string_new_len(x + i, j - i + 1);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
210 g_string_ascii_down(tmp);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
211
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
212 if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
213 g_string_append(s, match);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
214 else if (!strncmp(tmp->str, "<fade ", 6) ||
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
215 !strncmp(tmp->str, "<alt ", 5) ||
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
216 !strncmp(tmp->str, "<snd ", 5)) {
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
217
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
218 /* remove this if gtkimhtml ever supports any of these */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
220 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
221 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
222
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
223 } else if (!strncmp(tmp->str, "<font ", 6)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
224 _font_tags_fix_size(tmp, s);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
225 } else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
226 g_string_append_c(s, '<');
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
227 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
228 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
229 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
230
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
231 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
232 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
233 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
234 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
235
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
236 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
237
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
238
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
239
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
240 } else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
241 g_string_append_c(s, x[i]);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
242 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
243 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
244
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
245 ret = s->str;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 g_string_free(s, FALSE);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
247 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "yahoo_codes_to_html: Returning string: '%s'.\n", ret);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248 return ret;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
250
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
251 /* borrowed from gtkimhtml */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
252 #define MAX_FONT_SIZE 7
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
253 #define POINT_SIZE(x) (_point_sizes [MIN ((x), MAX_FONT_SIZE) - 1])
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
254 static gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 };
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
255
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
256 enum fatype { size, color, face, junk };
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
257 typedef struct {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
258 enum fatype type;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
259 union {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
260 int size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
261 char *color;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
262 char *face;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
263 char *junk;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
264 } u;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
265 } fontattr;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
266
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
267 static void fontattr_free(fontattr *f)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
268 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
269 if (f->type == color)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
270 g_free(f->u.color);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
271 else if (f->type == face)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
272 g_free(f->u.face);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
273 g_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
274 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
275
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
276 static void yahoo_htc_queue_cleanup(GQueue *q)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
277 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
278 char *tmp;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
279
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
280 while ((tmp = g_queue_pop_tail(q)))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
281 g_free(tmp);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
282 g_queue_free(q);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
283 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
284
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
285 static void _parse_font_tag(const char *src, GString *dest, int *i, int *j,
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
286 int len, GQueue *colors, GQueue *tags, GQueue *ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
287 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
288
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
289 int m, n, vstart;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
290 gboolean quote = 0, done = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
291
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
292 m = *j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
293
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
294 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
295 m++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
296
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
297 if (m >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
298 g_string_append(dest, &src[*i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
299 *i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
300 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
301 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
302
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
303 if (src[m] == '=') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
304 n = vstart = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
305 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
306 n++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
307
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
308 if (n >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
309 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
310 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
311 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
312
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
313 if (src[n] == '"') {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
314 if (!quote) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
315 quote = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
316 vstart = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
317 continue;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
318 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
319 done = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
320 }
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
321 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
322
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
323 if (!quote && ((src[n] == ' ') || (src[n] == '>')))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
324 done = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
325
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
326 if (done) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
327 if (!g_ascii_strncasecmp(&src[*j+1], "FACE", m - *j - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
328 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
329
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
330 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
331 f->type = face;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
332 f->u.face = g_strndup(&src[vstart+1], n-vstart-1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
333 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
334 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
335 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
336 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
337 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
338 } else if (!g_ascii_strncasecmp(&src[*j+1], "SIZE", m - *j - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
339 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
340
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
341 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
342 f->type = size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
343 f->u.size = POINT_SIZE(strtol(&src[vstart+1], NULL, 10));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
344 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
345 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
346 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
347 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
348 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
349 } else if (!g_ascii_strncasecmp(&src[*j+1], "COLOR", m - *j - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
350 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
351
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
352 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
353 f->type = color;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
354 f->u.color = g_strndup(&src[vstart+1], n-vstart-1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
355 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
356 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
357 g_queue_push_head(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
358 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
359 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
360 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
361 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
362
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
363 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
364 f->type = junk;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
365 f->u.junk = g_strndup(&src[*j+1], n-*j);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
366 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
367 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
368 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
369 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
370 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
371 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
372
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
373 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
374 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
375 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
376
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
377 if (src[m] == ' ')
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
378 *j = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
379
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
380
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
381
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
382 if (src[m] == '>') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
383 gboolean needendtag = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
384 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
385 GString *tmp = g_string_new(NULL);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
386 char *colorstr;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
387
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
388 if (!g_queue_is_empty(ftattr)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
389 while ((f = g_queue_pop_tail(ftattr))) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
390 switch (f->type) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
391 case size:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
392 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
393 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
394 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
395 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
396
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
397 g_string_append_printf(dest, "size=\"%d\" ", f->u.size);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
398 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
399 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
400 case face:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
401 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
402 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
403 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
404 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
405
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
406 g_string_append_printf(dest, "face=\"%s\" ", f->u.face);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
407 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
408 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
409 case junk:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
410 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
411 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
412 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
413 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
414
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
415 g_string_append(dest, f->u.junk);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
416 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
417 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
418
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
419 case color:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
420 if (needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
421 g_string_append(tmp, "</font>");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
422 dest->str[dest->len-1] = '>';
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
423 needendtag = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
424 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
425
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
426 colorstr = g_queue_peek_tail(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
427 g_string_append(tmp, colorstr ? colorstr : "\033[#000000m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
428 g_string_append_printf(dest, "\033[%sm", f->u.color);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
429 g_queue_push_tail(colors, g_strdup_printf("\033[%sm", f->u.color));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
430 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
431 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
432 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
433 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
434
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
435 g_queue_free(ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
436 ftattr = NULL;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
437
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
438 if (needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
439 dest->str[dest->len-1] = '>';
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
440 g_queue_push_tail(tags, g_strdup("</font>"));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
441 g_string_free(tmp, TRUE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
442 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
443 g_queue_push_tail(tags, tmp->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
444 g_string_free(tmp, FALSE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
445 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
446 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
447
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
448 *i = *j = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
449 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
450 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
451 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
452
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
453 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
454
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
455 char *yahoo_html_to_codes(const char *src)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
456 {
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
457 int i, j, len;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
458 GString *dest;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
459 char *ret, *esc;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
460 GQueue *colors, *tags;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
461 GQueue *ftattr = NULL;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
462
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
463
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
464 colors = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
465 tags = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
466
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
467 dest = g_string_sized_new(strlen(src));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
468
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
469 for (i = 0, len = strlen(src); i < len; i++) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
470
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
471 if (src[i] == '<') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
472 j = i;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
473
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
474 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
475 j++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
476
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
477 if (j >= len) { /* no '>' */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
478 g_string_append_len(dest, &src[i], len - i);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
479 i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
480
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
481 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
482 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
483
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
484 if (src[j] == '<') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
485 g_string_append_len(dest, &src[i], j - i);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
486 i = j - 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
487 if (ftattr) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
488 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
489
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
490 while ((f = g_queue_pop_head(ftattr)))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
491 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
492 g_queue_free(ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
493 ftattr = NULL;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
494 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
495 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
496 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
497
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
498 if (src[j] == ' ') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
499 if (!g_ascii_strncasecmp(&src[i+1], "BODY", j - i - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
500 char *t = strchr(&src[j], '>');
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
501 if (!t) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
502 g_string_append(dest, &src[i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
503 i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
504 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
505 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
506 i = t - src;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
507 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
508 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
509 } else if (g_ascii_strncasecmp(&src[i+1], "FONT", j - i - 1)) { /* not interested! */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
510 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
511 if (++j >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
512 g_string_append(dest, &src[i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
513 i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
514 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
515 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
516 if (src[j] == '>') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
517 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
518 i = j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
519 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
520 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
521 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
522 } else { /* yay we have a font tag */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
523 _parse_font_tag(src, dest, &i, &j, len, colors, tags, ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
524 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
525
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
526 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
527 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
528
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
529 if (src[j] == '>') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
530 int sublen = j - i - 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
531
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
532 if (sublen) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
533 if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
534 g_string_append(dest, "\033[1m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
535 } else if (!g_ascii_strncasecmp(&src[i+1], "/B", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
536 g_string_append(dest, "\033[x1m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
537 } else if (!g_ascii_strncasecmp(&src[i+1], "I", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
538 g_string_append(dest, "\033[2m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
539 } else if (!g_ascii_strncasecmp(&src[i+1], "/I", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
540 g_string_append(dest, "\033[x2m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
541 } else if (!g_ascii_strncasecmp(&src[i+1], "U", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
542 g_string_append(dest, "\033[4m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
543 } else if (!g_ascii_strncasecmp(&src[i+1], "/U", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
544 g_string_append(dest, "\033[x4m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
545 } else if (!g_ascii_strncasecmp(&src[i+1], "/BODY", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
546 /* mmm, </body> tags. *BURP* */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
547 } else if (!g_ascii_strncasecmp(&src[i+1], "/FONT", sublen) && g_queue_peek_tail(tags)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
548 char *etag, *cl;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
549
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
550 etag = g_queue_pop_tail(tags);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
551 if (etag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
552 g_string_append(dest, etag);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
553 if (!strcmp(etag, "</font>")) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
554 cl = g_queue_pop_tail(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
555 if (cl)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
556 g_free(cl);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
557 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
558 g_free(etag);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
559 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
560 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
561 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
562 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
563 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
564 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
565 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
566
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
567 i = j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
568 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
569 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
570
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
571 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
572
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
573 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
574 g_string_append_c(dest, src[i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
575 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
576 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
577
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
578 ret = dest->str;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
579 g_string_free(dest, FALSE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
580
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
581 esc = g_strescape(ret, NULL);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
582 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "yahoo_html_to_codes: Returning string: '%s'.\n", esc);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
583 g_free(esc);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
584
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
585 yahoo_htc_queue_cleanup(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
586 yahoo_htc_queue_cleanup(tags);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
587
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
588 return ret;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
589 }