e3aaff8e |
/* |
6d6e8271 |
* Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net> |
e3aaff8e |
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
|
6d6e8271 |
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
|
e3aaff8e |
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h> |
fe6c6a02 |
#include <signal.h> |
e3aaff8e |
#include "options.h"
#include "others.h"
#include "shared.h"
#include "defaults.h" |
2d70a403 |
#include "client.h" |
afb48b28 |
#include "output.h" |
7b304dee |
#include "misc.h" |
e3aaff8e |
void help(void);
|
07a73978 |
short printinfected = 0;
|
63abd169 |
extern int notremoved, notmoved;
|
5def21ff |
void clamscan(struct optstruct *opt) |
e3aaff8e |
{ |
fe6c6a02 |
int ds, dms, ret, infected; |
e3aaff8e |
struct timeval t1, t2;
struct timezone tz;
time_t starttime;
/* initialize some important variables */
|
afb48b28 |
if(optc(opt, 'v')) {
mprintf_verbose = 1;
logg_verbose = 1;
} |
e3aaff8e |
|
58bcf502 |
if(optl(opt, "quiet"))
mprintf_quiet = 1; |
e3aaff8e |
|
58bcf502 |
if(optl(opt, "stdout"))
mprintf_stdout = 1; |
e3aaff8e |
if(optc(opt, 'V')) { |
7b304dee |
print_version(); |
58bcf502 |
exit(0); |
e3aaff8e |
}
if(optc(opt, 'h')) {
free_opt(opt);
help();
}
|
58bcf502 |
if(optc(opt, 'i'))
printinfected = 1; |
e3aaff8e |
/* initialize logger */
if(optc(opt, 'l')) { |
afb48b28 |
logg_file = getargc(opt, 'l'); |
e3aaff8e |
if(logg("--------------------------------------\n")) {
mprintf("!Problem with internal logger.\n"); |
58bcf502 |
exit(2); |
e3aaff8e |
}
} else |
afb48b28 |
logg_file = NULL; |
e3aaff8e |
time(&starttime);
/* ctime() does \n, but I need it once more */
logg("Scan started: %s\n", ctime(&starttime));
gettimeofday(&t1, &tz); |
fe6c6a02 |
ret = client(opt, &infected); |
e3aaff8e |
|
bf5a1ce7 |
/* Implement STATUS in clamd */ |
25ea9cb9 |
if(!optl(opt, "disable-summary") && !optl(opt, "no-summary")) { |
e3aaff8e |
gettimeofday(&t2, &tz);
ds = t2.tv_sec - t1.tv_sec;
dms = t2.tv_usec - t1.tv_usec;
ds -= (dms < 0) ? (1):(0);
dms += (dms < 0) ? (1000000):(0);
mprintf("\n----------- SCAN SUMMARY -----------\n");
logg("\n-- summary --\n"); |
fe6c6a02 |
mprintf("Infected files: %d\n", infected);
logg("Infected files: %d\n", infected); |
63abd169 |
if(notremoved) {
mprintf("Not removed: %d\n", notremoved);
logg("Not removed: %d\n", notremoved);
}
if(notmoved) {
mprintf("Not moved: %d\n", notmoved);
logg("Not moved: %d\n", notmoved);
} |
e3aaff8e |
mprintf("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60);
logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60);
}
|
58bcf502 |
exit(ret); |
e3aaff8e |
}
void help(void)
{
mprintf_stdout = 1;
mprintf("\n"); |
4d89cb07 |
mprintf(" ClamAV Daemon Client "VERSION"\n");
mprintf(" (C) 2002 - 2005 ClamAV Team - http://www.clamav.net/team.html\n\n"); |
5def21ff |
mprintf(" --help -h Show help\n");
mprintf(" --version -V Print version number and exit\n");
mprintf(" --verbose -v Be verbose\n");
mprintf(" --quiet Be quiet, only output error messages\n");
mprintf(" --stdout Write to stdout instead of stderr\n");
mprintf(" (this help is always written to stdout)\n");
mprintf(" --log=FILE -l FILE Save scan report in FILE\n"); |
63abd169 |
mprintf(" --remove Remove infected files. Be careful!\n");
mprintf(" --move=DIRECTORY Move infected files into DIRECTORY\n"); |
5def21ff |
mprintf(" --config-file=FILE Read configuration from FILE.\n"); |
dc1e77db |
mprintf(" --no-summary Disable summary at end of scanning\n"); |
5def21ff |
mprintf("\n"); |
e3aaff8e |
exit(0);
} |