annotate src/protocols/yahoo/util.c @ 9322:119f8a2c00b6

[gaim-migrate @ 10130] Move a function, and add a debug statement. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sun, 20 Jun 2004 04:21:47 +0000
parents 76125b842b23
children 34bce9529cf4
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"
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
29 #include "yahoo.h"
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
31 #include <string.h>
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
32
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
33 /**
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
34 * Encode some text to send to the yahoo server.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
35 *
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
36 * @param gc The connection handle.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
37 * @param str The null terminated utf8 string to encode.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
38 * @param utf8 If not @c NULL, whether utf8 is okay or not.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
39 * Even if it is okay, we may not use it. If we
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
40 * used it, we set this to @c TRUE, else to
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
41 * @c FALSE. If @c NULL, false is assumed, and
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
42 * it is not dereferenced.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
43 * @return The g_malloced string in the appropriate encoding.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
44 */
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
45 char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
46 {
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
47 struct yahoo_data *yd = gc->proto_data;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
48 char *ret;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
49 char *to_codeset;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
50
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
51 if (yd->jp && utf8 && *utf8)
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
52 *utf8 = FALSE;
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
53
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
54 if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
55 return g_strdup(str);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
56
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
57 if (yd->jp)
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
58 to_codeset = "SHIFT_JIS";
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
59 else
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
60 to_codeset = "ISO-8859-1";
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
61
8955
eb3c59b0a16c [gaim-migrate @ 9728]
Tim Ringenbach <marv@pidgin.im>
parents: 8735
diff changeset
62 ret = g_convert_with_fallback(str, strlen(str), to_codeset, "UTF-8", "?", NULL, NULL, NULL);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
63 if (ret)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
64 return ret;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
65 else
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
66 return g_strdup("");
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
67 }
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
68
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
69 /**
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
70 * Decode some text received from the server.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
71 *
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
72 * @param gc The gc handle.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
73 * @param str The null terminated string to decode.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
74 * @param utf8 Did the server tell us it was supposed to be utf8?
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
75 * @return The decoded, utf-8 string, which must be g_free()'d.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
76 */
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
77 char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
78 {
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
79 struct yahoo_data *yd = gc->proto_data;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
80 char *ret;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
81 char *from_codeset;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
82
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
83 if (utf8) {
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
84 if (g_utf8_validate(str, -1, NULL))
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
85 return g_strdup(str);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
86 }
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
87
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
88 if (yd->jp)
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
89 from_codeset = "SHIFT_JIS";
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
90 else
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
91 from_codeset = "ISO-8859-1";
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
92
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
93 ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
94
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
95 if (ret)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
96 return ret;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
97 else
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
98 return g_strdup("");
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
99 }
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
100
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
101
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 /*
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 * I found these on some website but i don't know that they actually
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8533
diff changeset
105 * work (or are supposed to work). I didn't implement them yet.
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 * [0;30m ---black
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 * [1;37m ---white
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 * [0;37m ---tan
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 * [0;38m ---light black
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 * [1;39m ---dark blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112 * [0;32m ---green
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 * [0;33m ---yellow
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114 * [0;35m ---pink
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 * [1;35m ---purple
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 * [1;30m ---light blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 * [0;31m ---red
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 * [0;34m ---blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119 * [0;36m ---aqua
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 * (shift+comma)lyellow(shift+period) ---light yellow
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121 * (shift+comma)lgreen(shift+period) ---light green
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 [2;30m <--white out
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 static GHashTable *ht = NULL;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129 void yahoo_init_colorht()
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
130 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 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
132 /* 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
133 g_hash_table_insert(ht, "30", "<FONT COLOR=\"#000000\">"); /* black */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 g_hash_table_insert(ht, "31", "<FONT COLOR=\"#0000FF\">"); /* blue */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 g_hash_table_insert(ht, "32", "<FONT COLOR=\"#008080\">"); /* cyan */ /* 00b2b2 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136 g_hash_table_insert(ht, "33", "<FONT COLOR=\"#808080\">"); /* gray */ /* 808080 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
137 g_hash_table_insert(ht, "34", "<FONT COLOR=\"#008000\">"); /* green */ /* 00c200 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138 g_hash_table_insert(ht, "35", "<FONT COLOR=\"#FF0080\">"); /* pink */ /* ffafaf */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139 g_hash_table_insert(ht, "36", "<FONT COLOR=\"#800080\">"); /* purple */ /* b200b2 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140 g_hash_table_insert(ht, "37", "<FONT COLOR=\"#FF8000\">"); /* orange */ /* ffff00 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 g_hash_table_insert(ht, "38", "<FONT COLOR=\"#FF0000\">"); /* red */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142 g_hash_table_insert(ht, "39", "<FONT COLOR=\"#808000\">"); /* olive */ /* 546b50 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144 g_hash_table_insert(ht, "1", "<B>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145 g_hash_table_insert(ht, "x1", "</B>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 g_hash_table_insert(ht, "2", "<I>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147 g_hash_table_insert(ht, "x2", "</I>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148 g_hash_table_insert(ht, "4", "<U>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149 g_hash_table_insert(ht, "x4", "</U>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
150
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
151 /* these just tell us the text they surround is supposed
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
152 * 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
153 * just ignore it.
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 g_hash_table_insert(ht, "l", ""); /* link start */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
156 g_hash_table_insert(ht, "xl", ""); /* link end */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
157
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
158
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 g_hash_table_insert(ht, "<black>", "<FONT COLOR=\"#000000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160 g_hash_table_insert(ht, "<blue>", "<FONT COLOR=\"#0000FF\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 g_hash_table_insert(ht, "<cyan>", "<FONT COLOR=\"#008284\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162 g_hash_table_insert(ht, "<gray>", "<FONT COLOR=\"#848284\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 g_hash_table_insert(ht, "<green>", "<FONT COLOR=\"#008200\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 g_hash_table_insert(ht, "<pink>", "<FONT COLOR=\"#FF0084\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 g_hash_table_insert(ht, "<purple>", "<FONT COLOR=\"#840084\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 g_hash_table_insert(ht, "<orange>", "<FONT COLOR=\"#FF8000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 g_hash_table_insert(ht, "<red>", "<FONT COLOR=\"#FF0000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 g_hash_table_insert(ht, "<yellow>", "<FONT COLOR=\"#848200\">");
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 g_hash_table_insert(ht, "</black>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 g_hash_table_insert(ht, "</blue>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 g_hash_table_insert(ht, "</cyan>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173 g_hash_table_insert(ht, "</gray>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 g_hash_table_insert(ht, "</green>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175 g_hash_table_insert(ht, "</pink>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 g_hash_table_insert(ht, "</purple>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177 g_hash_table_insert(ht, "</orange>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 g_hash_table_insert(ht, "</red>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 g_hash_table_insert(ht, "</yellow>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 /* remove these once we have proper support for <FADE> and <ALT> */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 g_hash_table_insert(ht, "</fade>", "");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 g_hash_table_insert(ht, "</alt>", "");
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
184
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
185 /* these are the normal html yahoo sends (besides <font>).
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
186 * anything else will get turned into &lt;tag&gt;, so if I forgot
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
187 * about something, please add it. Why Yahoo! has to send unescaped
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
188 * <'s and >'s that aren't supposed to be html is beyond me.
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
189 */
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
190 g_hash_table_insert(ht, "<b>", "<b>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
191 g_hash_table_insert(ht, "<i>", "<i>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
192 g_hash_table_insert(ht, "<u>", "<u>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
193
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
194 g_hash_table_insert(ht, "</b>", "</b>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
195 g_hash_table_insert(ht, "</i>", "</i>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
196 g_hash_table_insert(ht, "</u>", "</u>");
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
197 g_hash_table_insert(ht, "</font>", "</font>");
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
198 }
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 void yahoo_dest_colorht()
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
202 g_hash_table_destroy(ht);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
203 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
204
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
205 static int point_to_html(int x)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
206 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
207 if (x < 9)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
208 return 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
209 if (x < 11)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
210 return 2;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
211 if (x < 13)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
212 return 3;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
213 if (x < 17)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
214 return 4;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
215 if (x < 25)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
216 return 5;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
217 if (x < 35)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
218 return 6;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
219 return 7;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
220 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
221 static void _font_tags_fix_size(GString *tag, GString *dest)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
222 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
223 char *x, *end;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
224 int size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
225
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
226 if (((x = strstr(tag->str, "size"))) && ((x = strchr(tag->str, '=')))) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
227 while (*x && !g_ascii_isdigit(*x))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
228 x++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
229 if (*x) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
230 size = strtol(x, &end, 10);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
231 size = point_to_html(size);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
232 g_string_append_len(dest, tag->str, x - tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
233 g_string_append_printf(dest, "%d", size);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
234 g_string_append(dest, end);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
235 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
236 g_string_append(dest, tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
237 return;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
238 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
239 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
240 g_string_append(dest, tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
241 return;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
242 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
243 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
244
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
245 char *yahoo_codes_to_html(const char *x)
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
247 GString *s, *tmp;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
248 int i, j, xs, nomoreendtags = 0; /* s/endtags/closinganglebrackets */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 char *match, *ret;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
252 s = g_string_sized_new(strlen(x));
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
253
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
254 for (i = 0, xs = strlen(x); i < xs; i++) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
255 if ((x[i] == 0x1b) && (x[i+1] == '[')) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256 j = i + 1;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258 while (j++ < xs) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
259 if (x[j] != 'm')
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 continue;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 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
263 if (tmp->str[0] == '#')
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
264 g_string_append_printf(s, "<FONT COLOR=\"%s\">", tmp->str);
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
265 else if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
266 g_string_append(s, match);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
267 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
268 gaim_debug(GAIM_DEBUG_ERROR, "yahoo",
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
269 "Unknown ansi code 'ESC[%sm'.\n", tmp->str);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
270 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
271 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
276 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
277 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
280
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 } else if (!nomoreendtags && (x[i] == '<')) {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
282 j = i;
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
283
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
284 while (j++ < xs) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
285 if (x[j] != '>')
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
286 if (j == xs) {
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
287 g_string_append(s, "&lt;");
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
288 nomoreendtags = 1;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
289 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
290 else
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
291 continue;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
292 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
293 tmp = g_string_new_len(x + i, j - i + 1);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
294 g_string_ascii_down(tmp);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
295
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
296 if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
297 g_string_append(s, match);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
298 else if (!strncmp(tmp->str, "<fade ", 6) ||
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
299 !strncmp(tmp->str, "<alt ", 5) ||
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
300 !strncmp(tmp->str, "<snd ", 5)) {
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
301
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
302 /* remove this if gtkimhtml ever supports any of these */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
303 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
304 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
305 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
306
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
307 } else if (!strncmp(tmp->str, "<font ", 6)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
308 _font_tags_fix_size(tmp, s);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
309 } else {
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
310 g_string_append(s, "&lt;");
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
311 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
312 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
313 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
314
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
315 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
316 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
317 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
318 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
319
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
320 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
321
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
322
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
323
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
324 } else {
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
325 if (x[i] == '<')
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
326 g_string_append(s, "&lt;");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
327 else if (x[i] == '>')
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
328 g_string_append(s, "&gt;");
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
329 else if (x[i] == '&')
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
330 g_string_append(s, "&amp;");
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
331 else if (x[i] == '"')
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
332 g_string_append(s, "&quot;");
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
333 else
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
334 g_string_append_c(s, x[i]);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
335 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
336 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
337
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
338 ret = s->str;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
339 g_string_free(s, FALSE);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
340 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
341 return ret;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
342 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
343
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
344 /* borrowed from gtkimhtml */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
345 #define MAX_FONT_SIZE 7
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
346 #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
347 static gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 };
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
348
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
349 enum fatype { size, color, face, junk };
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
350 typedef struct {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
351 enum fatype type;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
352 union {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
353 int size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
354 char *color;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
355 char *face;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
356 char *junk;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
357 } u;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
358 } fontattr;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
359
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
360 static void fontattr_free(fontattr *f)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
361 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
362 if (f->type == color)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
363 g_free(f->u.color);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
364 else if (f->type == face)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
365 g_free(f->u.face);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
366 g_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
367 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
368
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
369 static void yahoo_htc_queue_cleanup(GQueue *q)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
370 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
371 char *tmp;
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 while ((tmp = g_queue_pop_tail(q)))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
374 g_free(tmp);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
375 g_queue_free(q);
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
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
378 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
379 int len, GQueue *colors, GQueue *tags, GQueue *ftattr)
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 int m, n, vstart;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
383 gboolean quote = 0, done = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
384
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
385 m = *j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
386
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
387 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
388 m++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
389
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
390 if (m >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
391 g_string_append(dest, &src[*i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
392 *i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
393 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
394 }
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 if (src[m] == '=') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
397 n = vstart = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
398 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
399 n++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
400
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
401 if (n >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
402 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
403 break;
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
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
406 if (src[n] == '"') {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
407 if (!quote) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
408 quote = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
409 vstart = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
410 continue;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
411 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
412 done = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
413 }
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
414 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
415
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
416 if (!quote && ((src[n] == ' ') || (src[n] == '>')))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
417 done = 1;
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 if (done) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
420 if (!g_ascii_strncasecmp(&src[*j+1], "FACE", m - *j - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
421 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
422
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
423 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
424 f->type = face;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
425 f->u.face = g_strndup(&src[vstart+1], n-vstart-1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
426 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
427 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
428 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
429 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
430 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
431 } 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
432 fontattr *f;
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 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
435 f->type = size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
436 f->u.size = POINT_SIZE(strtol(&src[vstart+1], NULL, 10));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
437 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
438 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
439 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
440 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
441 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
442 } 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
443 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
444
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
445 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
446 f->type = color;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
447 f->u.color = g_strndup(&src[vstart+1], n-vstart-1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
448 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
449 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
450 g_queue_push_head(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
451 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
452 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
453 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
454 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
455
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
456 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
457 f->type = junk;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
458 f->u.junk = g_strndup(&src[*j+1], n-*j);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
459 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
460 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
461 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
462 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
463 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
464 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
465
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 }
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
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
470 if (src[m] == ' ')
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
471 *j = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
472
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
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
475 if (src[m] == '>') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
476 gboolean needendtag = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
477 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
478 GString *tmp = g_string_new(NULL);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
479 char *colorstr;
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 if (!g_queue_is_empty(ftattr)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
482 while ((f = g_queue_pop_tail(ftattr))) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
483 switch (f->type) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
484 case size:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
485 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
486 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
487 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
488 }
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 g_string_append_printf(dest, "size=\"%d\" ", f->u.size);
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 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
493 case face:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
494 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
495 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
496 g_string_append(dest, "<font ");
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
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
499 g_string_append_printf(dest, "face=\"%s\" ", f->u.face);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
500 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
501 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
502 case junk:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
503 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
504 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
505 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
506 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
507
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
508 g_string_append(dest, f->u.junk);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
509 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
510 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
511
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
512 case color:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
513 if (needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
514 g_string_append(tmp, "</font>");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
515 dest->str[dest->len-1] = '>';
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
516 needendtag = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
517 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
518
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
519 colorstr = g_queue_peek_tail(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
520 g_string_append(tmp, colorstr ? colorstr : "\033[#000000m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
521 g_string_append_printf(dest, "\033[%sm", f->u.color);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
522 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
523 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
524 break;
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 }
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 g_queue_free(ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
529 ftattr = NULL;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
530
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
531 if (needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
532 dest->str[dest->len-1] = '>';
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
533 g_queue_push_tail(tags, g_strdup("</font>"));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
534 g_string_free(tmp, TRUE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
535 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
536 g_queue_push_tail(tags, tmp->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
537 g_string_free(tmp, FALSE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
538 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
539 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
540
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
541 *i = *j = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
542 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
543 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
544 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
545
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
546 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
547
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
548 char *yahoo_html_to_codes(const char *src)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
549 {
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
550 int i, j, len;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
551 GString *dest;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
552 char *ret, *esc;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
553 GQueue *colors, *tags;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
554 GQueue *ftattr = NULL;
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
555 gboolean no_more_specials = FALSE;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
556
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 colors = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
559 tags = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
560
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
561 dest = g_string_sized_new(strlen(src));
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 for (i = 0, len = strlen(src); i < len; i++) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
564
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
565 if (!no_more_specials && src[i] == '<') {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
566 j = i;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
567
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
568 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
569 j++;
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 if (j >= len) { /* no '>' */
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
572 g_string_append_c(dest, src[i]);
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
573 no_more_specials = TRUE;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
574 break;
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 if (src[j] == '<') {
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
578 /* FIXME: This doesn't convert outgoing entities.
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
579 * However, I suspect this case may never
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
580 * happen anymore because of the entities.
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
581 */
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
582 g_string_append_len(dest, &src[i], j - i);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
583 i = j - 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
584 if (ftattr) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
585 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
586
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
587 while ((f = g_queue_pop_head(ftattr)))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
588 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
589 g_queue_free(ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
590 ftattr = NULL;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
591 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
592 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
593 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
594
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
595 if (src[j] == ' ') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
596 if (!g_ascii_strncasecmp(&src[i+1], "BODY", j - i - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
597 char *t = strchr(&src[j], '>');
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
598 if (!t) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
599 g_string_append(dest, &src[i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
600 i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
601 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
602 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
603 i = t - src;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
604 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
605 }
8533
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
606 } else if (!g_ascii_strncasecmp(&src[i+1], "A HREF=\"", j - i - 1)) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
607 j += 7;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
608 g_string_append(dest, "\033[lm");
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
609 while (1) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
610 g_string_append_c(dest, src[j]);
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
611 if (++j >= len) {
8480
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
612 i = len;
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
613 break;
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
614 }
8533
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
615 if (src[j] == '"') {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
616 g_string_append(dest, "\033[xlm");
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
617 while (1) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
618 if (++j >= len) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
619 i = len;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
620 break;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
621 }
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
622 if (!g_ascii_strncasecmp(&src[j], "</A>", 4)) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
623 j += 3;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
624 break;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
625 }
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
626 }
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
627 i = j;
8480
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
628 break;
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
629 }
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
630 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
631 } 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
632 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
633 if (++j >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
634 g_string_append(dest, &src[i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
635 i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
636 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
637 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
638 if (src[j] == '>') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
639 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
640 i = j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
641 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
642 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
643 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
644 } else { /* yay we have a font tag */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
645 _parse_font_tag(src, dest, &i, &j, len, colors, tags, ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
646 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
647
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
648 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
649 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
650
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
651 if (src[j] == '>') {
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
652 /* This has some problems like the FIXME for the
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
653 * '<' case. and like that case, I suspect the case
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
654 * that this has problems is won't happen anymore anyway.
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
655 */
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
656 int sublen = j - i - 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
657
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
658 if (sublen) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
659 if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
660 g_string_append(dest, "\033[1m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
661 } else if (!g_ascii_strncasecmp(&src[i+1], "/B", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
662 g_string_append(dest, "\033[x1m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
663 } else if (!g_ascii_strncasecmp(&src[i+1], "I", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
664 g_string_append(dest, "\033[2m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
665 } else if (!g_ascii_strncasecmp(&src[i+1], "/I", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
666 g_string_append(dest, "\033[x2m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
667 } else if (!g_ascii_strncasecmp(&src[i+1], "U", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
668 g_string_append(dest, "\033[4m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
669 } else if (!g_ascii_strncasecmp(&src[i+1], "/U", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
670 g_string_append(dest, "\033[x4m");
8480
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
671 } else if (!g_ascii_strncasecmp(&src[i+1], "/A", sublen)) {
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
672 g_string_append(dest, "\033[xlm");
8455
622fd4e800b4 [gaim-migrate @ 9185]
Luke Schierer <lschiere@pidgin.im>
parents: 8440
diff changeset
673 } else if (!g_ascii_strncasecmp(&src[i+1], "BR", sublen)) {
622fd4e800b4 [gaim-migrate @ 9185]
Luke Schierer <lschiere@pidgin.im>
parents: 8440
diff changeset
674 g_string_append_c(dest, '\n');
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
675 } else if (!g_ascii_strncasecmp(&src[i+1], "/BODY", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
676 /* mmm, </body> tags. *BURP* */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
677 } 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
678 char *etag, *cl;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
679
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
680 etag = g_queue_pop_tail(tags);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
681 if (etag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
682 g_string_append(dest, etag);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
683 if (!strcmp(etag, "</font>")) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
684 cl = g_queue_pop_tail(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
685 if (cl)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
686 g_free(cl);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
687 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
688 g_free(etag);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
689 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
690 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
691 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
692 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
693 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
694 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
695 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
696
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
697 i = j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
698 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
699 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
700
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
701 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
702
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
703 } else {
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
704 if (((len - i) >= 4) && !strncmp(&src[i], "&lt;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
705 g_string_append_c(dest, '<');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
706 i += 3;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
707 } else if (((len - i) >= 4) && !strncmp(&src[i], "&gt;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
708 g_string_append_c(dest, '>');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
709 i += 3;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
710 } else if (((len - i) >= 5) && !strncmp(&src[i], "&amp;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
711 g_string_append_c(dest, '&');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
712 i += 4;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
713 } else if (((len - i) >= 6) && !strncmp(&src[i], "&quot;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
714 g_string_append_c(dest, '"');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
715 i += 5;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
716 } else {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
717 g_string_append_c(dest, src[i]);
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
718 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
719 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
720 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
721
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
722 ret = dest->str;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
723 g_string_free(dest, FALSE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
724
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
725 esc = g_strescape(ret, NULL);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
726 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
727 g_free(esc);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
728
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
729 yahoo_htc_queue_cleanup(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
730 yahoo_htc_queue_cleanup(tags);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
731
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
732 return ret;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
733 }