nova proba

Revision:
8:c0f54b381346
Parent:
5:c9a908749d4c
diff -r 7ea932eb31f6 -r c0f54b381346 clubbing.cpp
--- a/clubbing.cpp	Sat Apr 18 22:32:13 2020 +0000
+++ b/clubbing.cpp	Sun Apr 19 22:13:45 2020 +0000
@@ -8,6 +8,10 @@
 #include <ctype.h>
 
 
+
+#define IN_RANGE( MIN, a, MAX ) ((a >= MIN) ?  (( a<=MAX) ? 1:0) : 0)
+
+
 /********************** PRINT-ovi *********************************/
 
 void P_niz( const char *s, const char *niz, int val )
@@ -31,7 +35,7 @@
 
 
 /************************ IP testovi ****************************/
-int test_num( const char *s )
+int _test_num( const char *s )
 {
   int m=strlen(s), n=0, i;
     for( i=0; i<m; i++)
@@ -40,6 +44,13 @@
     return 0;
 }
 
+int test_num( const char *s )
+{
+  if ( _test_num( s ) )
+    if( IN_RANGE( 1000, atoi(s), 65535-1) ) return 1;
+  return 0;
+}
+
 int test_ip( const char *s )
 {
    char str[16];
@@ -60,7 +71,7 @@
         token = strtok(str, ".");
         while( token != NULL ) 
         {
-            if( test_num(token) )  k++;
+            if( _test_num(token) )  k++;
             token = strtok(NULL, ".");
         }
         if(k==4) return 1;