changeset 32484:0ab12023a1bc

Add a function for parsing a network:username for MSNP18.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 03 Feb 2012 01:14:41 +0000
parents 1b15d0fd9c34
children d1ac0c771e19
files libpurple/protocols/msn/msnutils.c libpurple/protocols/msn/msnutils.h
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msnutils.c	Sat Jan 28 07:56:14 2012 +0000
+++ b/libpurple/protocols/msn/msnutils.c	Fri Feb 03 01:14:41 2012 +0000
@@ -490,6 +490,21 @@
 	*ret_port = port;
 }
 
+void
+msn_parse_user(const char *str, char **ret_user, int *ret_network)
+{
+	char **tokens;
+
+	tokens = g_strsplit(str, ":", 2);
+
+	*ret_network = atoi(tokens[0]);
+	*ret_user = tokens[1];
+
+	g_free(tokens[0]);
+	/* tokens[1] is returned */
+	g_free(tokens);
+}
+
 gboolean
 msn_email_is_valid(const char *passport)
 {
--- a/libpurple/protocols/msn/msnutils.h	Sat Jan 28 07:56:14 2012 +0000
+++ b/libpurple/protocols/msn/msnutils.h	Fri Feb 03 01:14:41 2012 +0000
@@ -76,6 +76,15 @@
 void msn_parse_socket(const char *str, char **ret_host, int *ret_port);
 
 /**
+ * Parses a user name
+ *
+ * @param str         A network:username string.
+ * @param ret_user    Return of the user's passport.
+ * @param ret_network Return of the user's network.
+ */
+void msn_parse_user(const char *str, char **ret_user, int *ret_network);
+
+/**
  * Verify if the email is a vaild passport.
  *
  * @param passport 	The email