diff plugins/jabber/jabber.c @ 1713:14caa7df478c

[gaim-migrate @ 1723] fun stuff committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 13 Apr 2001 23:18:02 +0000
parents 5417bf0c8e28
children 4104a30264b7
line wrap: on
line diff
--- a/plugins/jabber/jabber.c	Fri Apr 13 17:47:06 2001 +0000
+++ b/plugins/jabber/jabber.c	Fri Apr 13 23:18:02 2001 +0000
@@ -1354,6 +1354,35 @@
 	reginpa = gdk_input_add(jab_getfd(regjconn), GDK_INPUT_READ, regjcall, NULL);
 }
 
+static char *jabber_normalize(const char *s)
+{
+	static char buf[BUF_LEN];
+	char *t, *u;
+	int x = 0;
+
+	g_return_val_if_fail((s != NULL), NULL);
+
+	u = t = g_strdup(s);
+
+	g_strdown(t);
+
+	while (*t && (x < BUF_LEN - 1)) {
+		if (*t != ' ')
+			buf[x++] = *t;
+		t++;
+	}
+	buf[x] = '\0';
+	g_free(u);
+
+	if (!strchr(buf, '@')) {
+		strcat(buf, "@jabber.org"); /* this isn't always right, but eh */
+	} else if ((u = strchr(strchr(buf, '@'), '/')) != NULL) {
+		*u = '\0';
+	}
+
+	return buf;
+}
+
 static struct prpl *my_protocol = NULL;
 
 void Jabber_init(struct prpl *ret)
@@ -1394,6 +1423,7 @@
 	ret->chat_whisper = NULL;
 	ret->chat_send = jabber_chat_send;
 	ret->keepalive = NULL;
+	ret->normalize = jabber_normalize;
 
 	my_protocol = ret;
 }