# HG changeset patch # User Elliott Sales de Andrade # Date 1246598666 0 # Node ID 1e91cc59ab3d1db860db0c100a46e7f48f51059f # Parent 975a29213f358b9de59073528ec8952353146730 Sadrul and etan point out that using an existing function is better than attempting to re-invent the wheel. diff -r 975a29213f35 -r 1e91cc59ab3d pidgin/gtkprefs.c --- 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;