diff src/util.c @ 7564:54b370f7d9bf

[gaim-migrate @ 8180] /me-ify logs, and maybe fix the random directories problem. maybe. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Wed, 19 Nov 2003 05:34:50 +0000
parents 3c21f3084ff0
children 3ae88e96dde2
line wrap: on
line diff
--- a/src/util.c	Wed Nov 19 00:33:01 2003 +0000
+++ b/src/util.c	Wed Nov 19 05:34:50 2003 +0000
@@ -2101,3 +2101,33 @@
 	return ret;
 }
 
+gboolean gaim_message_meify(char *message, size_t len)
+{
+	char *c;
+	gboolean inside_html = FALSE;
+
+	g_return_val_if_fail(message != NULL, FALSE);
+
+	if(len == -1)
+		len = strlen(message);
+
+	for (c = message; *c; c++, len--) {
+		if(inside_html) {
+			if(*c == '>')
+				inside_html = FALSE;
+		} else {
+			if(*c == '<')
+				inside_html = TRUE;
+			else
+				break;
+		}
+	}
+
+	if(*c && !g_ascii_strncasecmp(c, "/me ", 4)) {
+		memmove(c, c+4, len-3);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+