Browse code

clamscan: bb#5350 Add command-line option to suppress printing clean files [so infected and errors get printed]

David Raynor authored on 2012/08/11 00:39:48
Showing 4 changed files
... ...
@@ -53,7 +53,8 @@
53 53
 void help(void);
54 54
 
55 55
 struct s_info info;
56
-short recursion = 0, printinfected = 0, bell = 0;
56
+short recursion = 0, bell = 0;
57
+short printinfected = 0, printclean = 1;
57 58
 
58 59
 int main(int argc, char **argv)
59 60
 {
... ...
@@ -123,6 +124,9 @@ int main(int argc, char **argv)
123 123
     if(optget(opts, "infected")->enabled)
124 124
 	printinfected = 1;
125 125
 
126
+    if(optget(opts, "suppress-ok-results")->enabled)
127
+	printclean = 0;
128
+
126 129
     if(optget(opts, "bell")->enabled)
127 130
 	bell = 1;
128 131
 
... ...
@@ -201,6 +205,7 @@ void help(void)
201 201
     mprintf("    --stdout                             Write to stdout instead of stderr\n");
202 202
     mprintf("    --no-summary                         Disable summary at end of scanning\n");
203 203
     mprintf("    --infected            -i             Only print infected files\n");
204
+    mprintf("    --suppress-ok-results -o             Skip printing OK files\n");
204 205
     mprintf("    --bell                               Sound bell on virus detection\n");
205 206
     mprintf("\n");
206 207
     mprintf("    --tempdir=DIRECTORY                  Create temporary files in DIRECTORY\n");
... ...
@@ -32,6 +32,7 @@ struct s_info {
32 32
 };
33 33
 
34 34
 extern struct s_info info;
35
-extern short recursion, printinfected, bell;
35
+extern short recursion, bell;
36
+extern short printinfected, printclean;
36 37
 
37 38
 #endif
... ...
@@ -213,7 +213,7 @@ static cl_error_t meta(const char* container_type, unsigned long fsize_container
213 213
 
214 214
 static void scanfile(const char *filename, struct cl_engine *engine, const struct optstruct *opts, unsigned int options)
215 215
 {
216
-	int ret = 0, fd, included, printclean = 1;
216
+	int ret = 0, fd, included;
217 217
 	unsigned i;
218 218
 	const struct optstruct *opt;
219 219
 	const char *virname;
... ...
@@ -89,6 +89,7 @@ const struct clam_option __clam_options[] = {
89 89
     { NULL, "no-summary", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" },
90 90
     { NULL, "file-list", 'f', TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" },
91 91
     { NULL, "infected", 'i', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" },
92
+    { NULL, "suppress-ok-results", 'o', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" },
92 93
     { NULL, "move", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" },
93 94
     { NULL, "copy", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" },
94 95
     { NULL, "remove", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" },