comparison src/protocols/irc/parse.c @ 8529:2f505651ac03

[gaim-migrate @ 9268] This strips mIRC color and formatting codes from topics and provides a generic function for stripping mirc color codes and returning plain text (irc_mirc2txt()). This should fix Bug #923672. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Tue, 30 Mar 2004 17:44:40 +0000
parents 3f384e95c5c0
children 478b6184152d
comparison
equal deleted inserted replaced
8528:a48da599fd75 8529:2f505651ac03
32 #include <stdlib.h> 32 #include <stdlib.h>
33 #include <ctype.h> 33 #include <ctype.h>
34 34
35 static char *irc_send_convert(struct irc_conn *irc, const char *string); 35 static char *irc_send_convert(struct irc_conn *irc, const char *string);
36 static char *irc_recv_convert(struct irc_conn *irc, const char *string); 36 static char *irc_recv_convert(struct irc_conn *irc, const char *string);
37
38 char *irc_mirc2html(const char *string);
39 37
40 static void irc_parse_error_cb(struct irc_conn *irc, char *input); 38 static void irc_parse_error_cb(struct irc_conn *irc, char *input);
41 39
42 static char *irc_mirc_colors[16] = { 40 static char *irc_mirc_colors[16] = {
43 "white", "black", "blue", "dark green", "red", "brown", "purple", 41 "white", "black", "blue", "dark green", "red", "brown", "purple",
267 } while (*cur); 265 } while (*cur);
268 266
269 return g_string_free(decoded, FALSE); 267 return g_string_free(decoded, FALSE);
270 } 268 }
271 269
270 char *irc_mirc2txt (const char *string)
271 {
272 char *result = g_strdup (string);
273 int i, j;
274
275 for (i = 0, j = 0; result[i]; i++) {
276 switch (result[i]) {
277 case '\002':
278 case '\003':
279 case '\007':
280 case '\017':
281 case '\026':
282 case '\037':
283 continue;
284 default:
285 result[j++] = result[i];
286 }
287 }
288 result[i] = '\0';
289 return result;
290 }
291
272 char *irc_parse_ctcp(struct irc_conn *irc, const char *from, const char *to, const char *msg, int notice) 292 char *irc_parse_ctcp(struct irc_conn *irc, const char *from, const char *to, const char *msg, int notice)
273 { 293 {
274 GaimConnection *gc; 294 GaimConnection *gc;
275 const char *cur = msg + 1; 295 const char *cur = msg + 1;
276 char *buf, *ctcp; 296 char *buf, *ctcp;