Browse code

Cleanups

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@385 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/03/10 07:46:28
Showing 7 changed files
... ...
@@ -1,3 +1,9 @@
1
+Tue Mar  9 23:49:06 CET 2004 (tk)
2
+---------------------------------
3
+  * libclamav, sigtool: small code cleanups (Dirk Mueller <mueller*kde.org>)
4
+  * libclamav: unrarlib: properly detect little endian (Dirk Mueller)
5
+  * clamscan: do not print "Excluded" messages with -i (reported by Gordon E.)
6
+
1 7
 Tue Mar  9 12:36:10 GMT 2004 (trog)
2 8
 -----------------------------------
3 9
   * clamd/others.c: fix includes
... ...
@@ -309,7 +309,8 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us
309 309
     if(procdev)
310 310
 	if(stat(filename, &sb) != -1)
311 311
 	    if(sb.st_dev == procdev) {
312
-		mprintf("%s: Excluded (/proc).\n", filename);
312
+		if(!printinfected)
313
+		    mprintf("%s: Excluded (/proc).\n", filename);
313 314
 		return 0;
314 315
 	    }
315 316
 #endif
... ...
@@ -79,7 +79,7 @@ int cli_addpatt(struct cl_node *root, struct cli_patt *pattern)
79 79
     return 0;
80 80
 }
81 81
 
82
-int cli_enqueue(struct nodelist **bfs, struct cl_node *n)
82
+static int cli_enqueue(struct nodelist **bfs, struct cl_node *n)
83 83
 {
84 84
 	struct nodelist *new;
85 85
 
... ...
@@ -95,7 +95,7 @@ int cli_enqueue(struct nodelist **bfs, struct cl_node *n)
95 95
     return 0;
96 96
 }
97 97
 
98
-struct cl_node *cli_dequeue(struct nodelist **bfs)
98
+static struct cl_node *cli_dequeue(struct nodelist **bfs)
99 99
 {
100 100
 	struct nodelist *handler, *prev = NULL;
101 101
 	struct cl_node *pt;
... ...
@@ -121,7 +121,7 @@ struct cl_node *cli_dequeue(struct nodelist **bfs)
121 121
     }
122 122
 }
123 123
 
124
-int cli_maketrans(struct cl_node *root)
124
+static int cli_maketrans(struct cl_node *root)
125 125
 {
126 126
 	struct nodelist *bfs = NULL;
127 127
 	struct cl_node *child, *node;
... ...
@@ -164,7 +164,7 @@ int cl_buildtrie(struct cl_node *root)
164 164
     return cli_maketrans(root);
165 165
 }
166 166
 
167
-void cli_freepatt(struct cli_patt *list)
167
+static void cli_freepatt(struct cli_patt *list)
168 168
 {
169 169
 	struct cli_patt *handler, *prev;
170 170
 
... ...
@@ -182,7 +182,7 @@ void cli_freepatt(struct cli_patt *list)
182 182
 
183 183
 void cl_freetrie(struct cl_node *root)
184 184
 {
185
-	int i;
185
+	unsigned int i;
186 186
 
187 187
     for(i = 0; i < root->nodes; i++) {
188 188
 	cli_freepatt(root->nodetable[i]->list);
... ...
@@ -197,7 +197,8 @@ int cl_scanbuff(const char *buffer, unsigned int length, char **virname, const s
197 197
 {
198 198
 	struct cl_node *current;
199 199
 	struct cli_patt *pt;
200
-	int i, position, *partcnt;
200
+	int position, *partcnt;
201
+        unsigned int i;
201 202
 
202 203
     current = (struct cl_node *) root;
203 204
 
... ...
@@ -248,7 +249,7 @@ int cli_findpos(const char *buffer, int offset, int length, const struct cli_pat
248 248
 {
249 249
 	int bufferpos = offset + CL_MIN_LENGTH;
250 250
 	int postfixend = offset + length;
251
-	int i;
251
+	unsigned int i;
252 252
 
253 253
 
254 254
     for(i = CL_MIN_LENGTH; i < pattern->length; i++) {
... ...
@@ -20,6 +20,8 @@
20 20
 #include "clamav-config.h"
21 21
 #endif
22 22
 
23
+#include "str.h"
24
+
23 25
 #include <stdio.h>
24 26
 #include <stdlib.h>
25 27
 #include <string.h>
... ...
@@ -29,7 +31,7 @@
29 29
 #include "others.h"
30 30
 #include "defaults.h"
31 31
 
32
-int cli_hex2int(int c)
32
+static int cli_hex2int(int c)
33 33
 {
34 34
 	int l = tolower(c);
35 35
 
... ...
@@ -91,7 +93,7 @@ char *cl_str2hex(const char *string, unsigned int len)
91 91
 	char *hexstr;
92 92
 	char HEX[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
93 93
 		       'a', 'b', 'c', 'd', 'e', 'f' };
94
-	int i, j;
94
+	unsigned int i, j;
95 95
 
96 96
     if((hexstr = (char *) cli_calloc(2 * len + 1, sizeof(char))) == NULL)
97 97
 	return NULL;
... ...
@@ -148,7 +150,7 @@ void cli_chomp(char *string)
148 148
  * doesn't have <fieldno> fields or not enough memory is available.
149 149
  * The caller has to free() the result afterwards.
150 150
  */
151
-char *cli_strtok(const char *line, int fieldno, char *delim)
151
+char *cli_strtok(const char *line, int fieldno, const char *delim)
152 152
 {
153 153
     int counter = 0, i, j;
154 154
     char *buffer = NULL;
... ...
@@ -21,6 +21,6 @@
21 21
 
22 22
 int cli_strbcasestr(const char *haystack, const char *needle);
23 23
 void cli_chomp(char *string);
24
-char *cli_strtok(const char *line, int field, char *delim);
24
+char *cli_strtok(const char *line, int field, const char *delim);
25 25
 
26 26
 #endif
... ...
@@ -80,7 +80,7 @@ extern "C"
80 80
 /* ------------------------------------------------------------------------ */
81 81
 
82 82
 /* detected by clamav/configure */
83
-#if WORDS_LITTLEENDIAN
83
+#if 1 - WORDS_BIGENDIAN
84 84
 #define NON_INTEL_BYTE_ORDER
85 85
 #endif
86 86
 
... ...
@@ -80,6 +80,7 @@ int scanfile(const char *cmd, const char *str, const char *file)
80 80
     while(fgets(buffer, LINE, pd)) {
81 81
 	if(strstr(buffer, str)) {
82 82
 	    free(command);
83
+            fclose(pd);
83 84
 	    return 1; /* found */
84 85
 	}
85 86
     }