diff libpurple/protocols/myspace/user.c @ 22305:bf4902fce6e4

In msimprpl, add msim_is_valid_username() to check whether a username is valid (not whether it exists). Not used anywhere, but will help #4855.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sat, 16 Feb 2008 21:29:02 +0000
parents c3dc9e0d2c08
children 7d0e93198c39
line wrap: on
line diff
--- a/libpurple/protocols/myspace/user.c	Sat Feb 16 21:07:09 2008 +0000
+++ b/libpurple/protocols/myspace/user.c	Sat Feb 16 21:29:02 2008 +0000
@@ -496,6 +496,19 @@
 	return strspn(user, "0123456789") == strlen(user);
 }
 
+/** Return whether a given username is syntactically valid. 
+ * Note: does not actually check that the user exists. */
+gboolean
+msim_is_valid_username(const gchar *user)
+{
+	return !msim_is_userid(user) &&  /* Not all numeric */
+		strlen(user) <= MSIM_MAX_USERNAME_LENGTH
+		&& strspn(user, "0123456789"
+			"abcdefghijklmnopqrstuvwxyz"
+			"_"
+			"ABCDEFGHIJKLMNOPQRSTUVWXYZ") == strlen(user);
+}
+
 /**
  * Check if a string is an email address (contains an @).
  *