git-svn: trunk@1612
Tomasz Kojm authored on 2005/06/12 18:27:00... | ... |
@@ -1,7 +1,11 @@ |
1 |
+Sun Jun 12 11:24:59 CEST 2005 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * clamscan: improve output handling |
|
4 |
+ |
|
1 | 5 |
Wed Jun 8 16:01:22 CEST 2005 (tk) |
2 | 6 |
---------------------------------- |
3 |
- * libclamav/zziplib/zzip-file.c: add method id for AES encrypted archives (thanks to |
|
4 |
- David Majorel <dm*lagoon.nc>). |
|
7 |
+ * libclamav/zziplib/zzip-file.c: add method id for AES encrypted archives |
|
8 |
+ (thanks to David Majorel <dm*lagoon.nc>). |
|
5 | 9 |
|
6 | 10 |
Wed Jun 8 15:37:34 CEST 2005 (tk) |
7 | 11 |
---------------------------------- |
... | ... |
@@ -109,7 +109,7 @@ int clamscan(struct optstruct *opt) |
109 | 109 |
|
110 | 110 |
if(optc(opt, 'l')) { |
111 | 111 |
logg_file = getargc(opt, 'l'); |
112 |
- if(logg("--------------------------------------\n")) { |
|
112 |
+ if(logg("#\n-------------------------------------------------------------------------------\n\n")) { |
|
113 | 113 |
mprintf("!Problem with internal logger.\n"); |
114 | 114 |
return 62; |
115 | 115 |
} |
... | ... |
@@ -293,7 +293,7 @@ int scanmanager(const struct optstruct *opt) |
293 | 293 |
|
294 | 294 |
int scanfile(const char *filename, struct cl_node *root, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options) |
295 | 295 |
{ |
296 |
- int ret, included; |
|
296 |
+ int ret, included, printclean = 1; |
|
297 | 297 |
struct optnode *optnode; |
298 | 298 |
char *argument; |
299 | 299 |
#ifdef C_LINUX |
... | ... |
@@ -384,6 +384,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
384 | 384 |
|
385 | 385 |
/* in other case try to continue with external archivers */ |
386 | 386 |
options &= ~CL_SCAN_ARCHIVE; /* and disable decompression for the checkfile() below */ |
387 |
+ printclean = 0; |
|
387 | 388 |
} |
388 | 389 |
|
389 | 390 |
if((cli_strbcasestr(filename, ".zip") && optl(opt, "unzip")) |
... | ... |
@@ -426,7 +427,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
426 | 426 |
} |
427 | 427 |
} |
428 | 428 |
|
429 |
- if((ret = checkfile(filename, root, limits, options, 0)) == CL_VIRUS) { |
|
429 |
+ if((ret = checkfile(filename, root, limits, options, printclean)) == CL_VIRUS) { |
|
430 | 430 |
if(optl(opt, "remove")) { |
431 | 431 |
if(unlink(filename)) { |
432 | 432 |
logg("%s: Can't remove\n", filename); |
... | ... |
@@ -754,7 +755,7 @@ int checkfile(const char *filename, const struct cl_node *root, const struct cl_ |
754 | 754 |
|
755 | 755 |
} else if(ret == CL_CLEAN) { |
756 | 756 |
if(!printinfected && printclean) |
757 |
- logg("%s: OK\n", filename); |
|
757 |
+ mprintf("%s: OK\n", filename); |
|
758 | 758 |
} else |
759 | 759 |
if(!printinfected) |
760 | 760 |
logg("%s: %s\n", filename, cl_strerror(ret)); |
... | ... |
@@ -810,7 +811,7 @@ int checkstdin(const struct cl_node *root, const struct cl_limits *limits, int o |
810 | 810 |
|
811 | 811 |
} else if(ret == CL_CLEAN) { |
812 | 812 |
if(!printinfected) |
813 |
- logg("stdin: OK\n"); |
|
813 |
+ mprintf("stdin: OK\n"); |
|
814 | 814 |
} else |
815 | 815 |
if(!printinfected) |
816 | 816 |
logg("stdin: %s\n", cl_strerror(ret)); |
... | ... |
@@ -193,6 +193,8 @@ int logg(const char *str, ...) |
193 | 193 |
} else if(*str == '*') { |
194 | 194 |
if(logg_verbose) |
195 | 195 |
vfprintf(logg_fd, str + 1, args); |
196 |
+ } else if(*str == '#') { |
|
197 |
+ vfprintf(logg_fd, str + 1, args); |
|
196 | 198 |
} else vfprintf(logg_fd, str, args); |
197 | 199 |
|
198 | 200 |
|
... | ... |
@@ -227,15 +229,19 @@ int logg(const char *str, ...) |
227 | 227 |
if(logg_verbose) { |
228 | 228 |
syslog(LOG_DEBUG, vbuff + 1); |
229 | 229 |
} |
230 |
+ } else if(vbuff[0] == '#') { |
|
231 |
+ syslog(LOG_INFO, vbuff + 1); |
|
230 | 232 |
} else syslog(LOG_INFO, vbuff); |
231 | 233 |
|
232 | 234 |
} |
233 | 235 |
#endif |
234 | 236 |
|
235 | 237 |
if(foreground) { |
236 |
- _(str); |
|
237 |
- vsnprintf(vbuff, 1024, str, argsout); |
|
238 |
- mprintf(vbuff, str); |
|
238 |
+ _(str); |
|
239 |
+ vsnprintf(vbuff, 1024, str, argsout); |
|
240 |
+ vbuff[1024] = 0; |
|
241 |
+ if(vbuff[0] != '#') |
|
242 |
+ mprintf(vbuff, str); |
|
239 | 243 |
} |
240 | 244 |
|
241 | 245 |
va_end(args); |