diff libpurple/protocols/oscar/util.c @ 25416:6e1967b0f90b

Change "screen name" to "username" or "buddy name" in a whole bunch of places in the code. I've been using the definitions from the jabber specs, where "user" is me and "buddy" is someone on my buddy list.
author Mark Doliner <mark@kingant.net>
date Mon, 26 Jan 2009 09:12:04 +0000
parents a184ac4eace6
children 4f24d5da4cb3
line wrap: on
line diff
--- a/libpurple/protocols/oscar/util.c	Mon Jan 26 06:44:00 2009 +0000
+++ b/libpurple/protocols/oscar/util.c	Mon Jan 26 09:12:04 2009 +0000
@@ -136,27 +136,27 @@
 }
 
 /**
- * Check if the given screen name is a valid AIM screen name.
+ * Check if the given name is a valid AIM username.
  * Example: BobDole
  * Example: Henry_Ford@mac.com
  * Example: 1KrazyKat@example.com
  *
- * @return TRUE if the screen name is valid, FALSE if not.
+ * @return TRUE if the name is valid, FALSE if not.
  */
 static gboolean
-aim_snvalid_aim(const char *sn)
+oscar_util_valid_name_aim(const char *name)
 {
 	int i;
 
-	if (purple_email_is_valid(sn))
+	if (purple_email_is_valid(name))
 		return TRUE;
 
-	/* Normal AIM screen names can't start with a number */
-	if (isdigit(sn[0]))
+	/* Normal AIM usernames can't start with a number */
+	if (isdigit(name[0]))
 		return FALSE;
 
-	for (i = 0; sn[i] != '\0'; i++) {
-		if (!isalnum(sn[i]) && (sn[i] != ' '))
+	for (i = 0; name[i] != '\0'; i++) {
+		if (!isalnum(name[i]) && (name[i] != ' '))
 			return FALSE;
 	}
 
@@ -164,18 +164,18 @@
 }
 
 /**
- * Check if the given screen name is a valid ICQ screen name.
+ * Check if the given name is a valid ICQ username.
  * Example: 1234567
  *
- * @return TRUE if the screen name is valid, FALSE if not.
+ * @return TRUE if the name is valid, FALSE if not.
  */
 gboolean
-aim_snvalid_icq(const char *sn)
+oscar_util_valid_name_icq(const char *name)
 {
 	int i;
 
-	for (i = 0; sn[i] != '\0'; i++) {
-		if (!isdigit(sn[i]))
+	for (i = 0; name[i] != '\0'; i++) {
+		if (!isdigit(name[i]))
 			return FALSE;
 	}
 
@@ -183,21 +183,21 @@
 }
 
 /**
- * Check if the given screen name is a valid SMS screen name.
+ * Check if the given name is a valid SMS username.
  * Example: +19195551234
  *
- * @return TRUE if the screen name is valid, FALSE if not.
+ * @return TRUE if the name is valid, FALSE if not.
  */
 gboolean
-aim_snvalid_sms(const char *sn)
+oscar_util_valid_name_sms(const char *name)
 {
 	int i;
 
-	if (sn[0] != '+')
+	if (name[0] != '+')
 		return FALSE;
 
-	for (i = 1; sn[i] != '\0'; i++) {
-		if (!isdigit(sn[i]))
+	for (i = 1; name[i] != '\0'; i++) {
+		if (!isdigit(name[i]))
 			return FALSE;
 	}
 
@@ -205,44 +205,46 @@
 }
 
 /**
- * Check if the given screen name is a valid oscar screen name.
+ * Check if the given name is a valid oscar username.
  *
- * @return TRUE if the screen name is valid, FALSE if not.
+ * @return TRUE if the name is valid, FALSE if not.
  */
 gboolean
-aim_snvalid(const char *sn)
+oscar_util_valid_name(const char *name)
 {
-	if ((sn == NULL) || (*sn == '\0'))
+	if ((name == NULL) || (*name == '\0'))
 		return FALSE;
 
-	return aim_snvalid_icq(sn) || aim_snvalid_sms(sn) || aim_snvalid_aim(sn);
+	return oscar_util_valid_name_icq(name)
+			|| oscar_util_valid_name_sms(name)
+			|| oscar_util_valid_name_aim(name);
 }
 
 /**
- * This takes two screen names and compares them using the rules
- * on screen names for AIM/AOL.  Mainly, this means case and space
+ * This takes two names and compares them using the rules
+ * on usernames for AIM/AOL.  Mainly, this means case and space
  * insensitivity (all case differences and spacing differences are
- * ignored, with the exception that screen names can not start with
+ * ignored, with the exception that usernames can not start with
  * a space).
  *
  * @return 0 if equal, non-0 if different
  */
 /* TODO: Do something different for email addresses. */
 int
-aim_sncmp(const char *sn1, const char *sn2)
+oscar_util_name_compare(const char *name1, const char *name2)
 {
 
-	if ((sn1 == NULL) || (sn2 == NULL))
+	if ((name1 == NULL) || (name2 == NULL))
 		return -1;
 
 	do {
-		while (*sn2 == ' ')
-			sn2++;
-		while (*sn1 == ' ')
-			sn1++;
-		if (toupper(*sn1) != toupper(*sn2))
+		while (*name2 == ' ')
+			name2++;
+		while (*name1 == ' ')
+			name1++;
+		if (toupper(*name1) != toupper(*name2))
 			return 1;
-	} while ((*sn1 != '\0') && sn1++ && sn2++);
+	} while ((*name1 != '\0') && name1++ && name2++);
 
 	return 0;
 }