53
static int reload_server_database(const struct optstruct *opt)
55
if(reload_clamd_database(opt)) {
56
logg("!Clamd did not reload the database\n");
62
52
int main(int argc, char **argv)
64
54
int ds, dms, ret, infected;
65
55
struct timeval t1, t2;
66
56
struct timezone tz;
68
struct optstruct *opt;
69
const char *clamdscan_accepted[] = { "help", "version", "verbose", "quiet",
70
"stdout", "log", "move", "copy", "remove",
71
"config-file", "no-summary", "fdpass",
72
"disable-summary", "multiscan", "reload",
77
opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, clamdscan_accepted, NULL);
79
mprintf("!Can't parse the command line\n");
58
struct optstruct *opts;
59
const struct optstruct *opt;
60
struct sigaction sigact;
63
if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMDSCAN, OPT_CLAMSCAN, NULL)) == NULL) {
64
mprintf("!Can't parse command line options\n");
83
if(opt_check(opt, "verbose")) {
68
if(optget(opts, "verbose")->enabled) {
84
69
mprintf_verbose = 1;
88
if(opt_check(opt, "quiet"))
73
if(optget(opts, "quiet")->enabled)
91
if(opt_check(opt, "stdout"))
76
if(optget(opts, "stdout")->enabled)
92
77
mprintf_stdout = 1;
94
if(opt_check(opt, "version")) {
95
print_server_version(opt);
79
if(optget(opts, "version")->enabled) {
80
print_server_version(opts);
100
if(opt_check(opt, "help")) {
85
if(optget(opts, "help")->enabled) {
105
if(opt_check(opt, "infected"))
90
if(optget(opts, "infected")->enabled)
106
91
printinfected = 1;
108
93
/* initialize logger */
110
if(opt_check(opt, "log")) {
111
logg_file = opt_arg(opt, "log");
95
if((opt = optget(opts, "log"))->enabled) {
96
logg_file = opt->strarg;
112
97
if(logg("--------------------------------------\n")) {
113
98
mprintf("!Problem with internal logger.\n");
118
103
logg_file = NULL;
121
if(opt_check(opt, "reload")) {
122
ret = reload_server_database(opt);
106
if(optget(opts, "reload")->enabled) {
107
ret = reload_clamd_database(opts);
119
memset(&sigact, 0, sizeof(struct sigaction));
120
sigact.sa_handler = SIG_IGN;
121
sigemptyset(&sigact.sa_mask);
122
sigaddset(&sigact.sa_mask, SIGPIPE);
123
sigaction(SIGPIPE, &sigact, NULL);
128
125
time(&starttime);
129
126
/* ctime() does \n, but I need it once more */
131
128
gettimeofday(&t1, &tz);
133
ret = client(opt, &infected);
130
ret = client(opts, &infected);
135
132
/* TODO: Implement STATUS in clamd */
136
if((infected || ret != 2) && !opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) {
133
if((infected || ret != 2) && !optget(opts, "no-summary")->enabled) {
137
134
gettimeofday(&t2, &tz);
138
135
ds = t2.tv_sec - t1.tv_sec;
139
136
dms = t2.tv_usec - t1.tv_usec;