blob: a98c30365eef773c46fd895c0807b39eaabf2609 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <qstringlist.h>
#include "GUIUtils.h"
bool validIP( const QString & S ) {
QStringList SL = QStringList::split( '.', S, TRUE );
if( SL.count() != 4 )
return 0;
for( int i = 0; i < 4 ; i ++ ) {
if( SL[i].isEmpty() )
return 0;
}
short x = SL[0].toShort();
if( x < 1 || x > 255 )
return 0;
for( int i = 1; i < 4 ; i ++ ) {
x = SL[i].toShort();
if( x < 0 || x > 255 )
return 0;
}
return 1;
}
|