00001 #include <qstringlist.h>
00002 #include "GUIUtils.h"
00003
00004 bool validIP( const QString & S ) {
00005
00006 QStringList SL = QStringList::split( '.', S, TRUE );
00007 if( SL.count() != 4 )
00008 return 0;
00009
00010 for( int i = 0; i < 4 ; i ++ ) {
00011 if( SL[i].isEmpty() )
00012 return 0;
00013 }
00014
00015 short x = SL[0].toShort();
00016
00017 if( x < 1 || x > 255 )
00018 return 0;
00019
00020 for( int i = 1; i < 4 ; i ++ ) {
00021 x = SL[i].toShort();
00022 if( x < 0 || x > 255 )
00023 return 0;
00024 }
00025 return 1;
00026
00027 }