Browse code

improve isnumb() (thanks to NJH) and move it to misc.c

git-svn: trunk@1505

Tomasz Kojm authored on 2005/04/29 10:21:12
Showing 7 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Apr 29 03:19:44 CEST 2005 (tk)
2
+----------------------------------
3
+  * shared/misc.c: improve isnumb() (thanks to NJH) and move it to misc.c
4
+
1 5
 Fri Apr 29 02:57:07 CEST 2005 (tk)
2 6
 ----------------------------------
3 7
   * freshclam/manager.c: allow warning control via txt record
... ...
@@ -117,17 +117,6 @@ int checkaccess(const char *path, const char *username, int mode)
117 117
     return ret;
118 118
 }
119 119
 
120
-int isnumb(const char *str)
121
-{
122
-	int i;
123
-
124
-    for(i = 0; i < strlen(str); i++)
125
-	if(!isdigit(str[i]))
126
-	    return 0;
127
-
128
-    return 1;
129
-}
130
-
131 120
 int match_regex(const char *filename, const char *pattern)
132 121
 {
133 122
 #ifdef HAVE_REGEX_H
... ...
@@ -21,7 +21,6 @@
21 21
 
22 22
 int fileinfo(const char *filename, short i);
23 23
 int checkaccess(const char *path, const char *username, int mode);
24
-int isnumb(const char *str);
25 24
 int match_regex(const char *filename, const char *pattern);
26 25
 
27 26
 #endif
... ...
@@ -46,6 +46,7 @@
46 46
 #include "notify.h"
47 47
 #include "memory.h"
48 48
 #include "output.h"
49
+#include "misc.h"
49 50
 #include "../libclamav/others.h"
50 51
 #include "../libclamav/str.h" /* cli_strtok */
51 52
 #include "dns.h"
... ...
@@ -220,17 +221,6 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
220 220
 	return 1;
221 221
 }
222 222
 
223
-static int isnumb(const char *str)
224
-{
225
-	int i;
226
-
227
-    for(i = 0; i < strlen(str); i++)
228
-	if(!isdigit(str[i]))
229
-	    return 0;
230
-
231
-    return 1;
232
-}
233
-
234 223
 int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt, const char *dnsreply, char *localip)
235 224
 {
236 225
 	struct cl_cvd *current, *remote;
... ...
@@ -30,17 +30,7 @@
30 30
 #include "defaults.h"
31 31
 #include "str.h"
32 32
 #include "memory.h"
33
-
34
-static int isnumb(const char *str)
35
-{
36
-	int i;
37
-
38
-    for(i = 0; i < strlen(str); i++)
39
-	if(!isdigit(str[i]))
40
-	    return 0;
41
-
42
-    return 1;
43
-}
33
+#include "misc.h"
44 34
 
45 35
 struct cfgstruct *parsecfg(const char *cfgfile, int messages)
46 36
 {
... ...
@@ -147,3 +147,14 @@ int filecopy(const char *src, const char *dest)
147 147
 #endif
148 148
 
149 149
 }
150
+
151
+int isnumb(const char *str)
152
+{
153
+    while(*str) {
154
+	if(!isdigit(*str))
155
+	    return 0;
156
+	str++;
157
+    }
158
+
159
+    return 1;
160
+}
... ...
@@ -24,5 +24,6 @@
24 24
 char *freshdbdir(void);
25 25
 void print_version(void);
26 26
 int filecopy(const char *src, const char *dest);
27
+int isnumb(const char *str);
27 28
 
28 29
 #endif