changeset 27263:1e91cc59ab3d

Sadrul and etan point out that using an existing function is better than attempting to re-invent the wheel.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 03 Jul 2009 05:24:26 +0000
parents 975a29213f35
children 46e182c1c14f
files pidgin/gtkprefs.c
diffstat 1 files changed, 1 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkprefs.c	Fri Jul 03 05:03:20 2009 +0000
+++ b/pidgin/gtkprefs.c	Fri Jul 03 05:24:26 2009 +0000
@@ -1636,67 +1636,13 @@
 	return ret;
 }
 
-/* This isn't a very strict check, but should give the user a clue. */
-static gboolean
-verify_ip_address(const gchar *text)
-{
-	char *tmp;
-	long octet;
-
-	if (!text && !isdigit(*text))
-		return FALSE;
-
-	tmp = NULL;
-	octet = strtol(text, &tmp, 10);
-	if (octet < 0 || octet > 255)
-		return FALSE;
-
-	if (!tmp || *tmp != '.')
-		return FALSE;
-
-	text = tmp + 1;
-	if (!isdigit(*text))
-		return FALSE;
-
-	tmp = NULL;
-	octet = strtol(text, &tmp, 10);
-	if (octet < 0 || octet > 255)
-		return FALSE;
-
-	if (!tmp || *tmp != '.')
-		return FALSE;
-
-	text = tmp + 1;
-	if (!isdigit(*text))
-		return FALSE;
-
-	tmp = NULL;
-	octet = strtol(text, &tmp, 10);
-	if (octet < 0 || octet > 255)
-		return FALSE;
-
-	text = tmp + 1;
-	if (!isdigit(*text))
-		return FALSE;
-
-	tmp = NULL;
-	octet = strtol(text, &tmp, 10);
-	if (octet < 0 || octet > 255)
-		return FALSE;
-
-	if (!tmp || *tmp != '\0')
-		return FALSE;
-
-	return TRUE;
-}
-
 static void
 network_ip_changed(GtkEntry *entry, gpointer data)
 {
 	const gchar *text = gtk_entry_get_text(entry);
 	GdkColor color;
 
-	if (verify_ip_address(text))
+	if (purple_ip_address_is_valid(text))
 	{
 		color.red = 0xAFFF;
 		color.green = 0xFFFF;