~ubuntu-branches/ubuntu/trusty/clamav/trusty-proposed

« back to all changes in this revision

Viewing changes to clamdscan/clamdscan.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2005-09-19 09:05:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050919090559-hikpqduq8yx5qxo2
Tags: 0.87-1
* New upstream version
  - Fixes CAN-2005-2920 and CAN-2005-2919 (closes: #328660)
* New logcheck line for clamav-daemon (closes: #323132)
* relibtoolize and apply kfreebsd patch (closes: #327707)
* Make sure init.d script starts freshclam up again after upgrade when run
  from if-up.d (closes: #328912)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <unistd.h>
27
27
#include <sys/time.h>
28
28
#include <time.h>
 
29
#include <signal.h>
29
30
 
30
31
#include "options.h"
31
32
#include "others.h"
33
34
#include "defaults.h"
34
35
#include "client.h"
35
36
#include "output.h"
 
37
#include "misc.h"
36
38
 
37
39
void help(void);
38
40
 
39
 
struct s_info claminfo;
40
41
short printinfected = 0;
41
42
 
 
43
extern int notremoved, notmoved;
 
44
 
42
45
void clamscan(struct optstruct *opt)
43
46
{
44
 
        int ds, dms, ret;
 
47
        int ds, dms, ret, infected;
45
48
        struct timeval t1, t2;
46
49
        struct timezone tz;
47
50
        time_t starttime;
61
64
        mprintf_stdout = 1;
62
65
 
63
66
    if(optc(opt, 'V')) {
64
 
        mprintf("clamdscan / ClamAV version "VERSION"\n");
 
67
        print_version();
65
68
        exit(0);
66
69
    }
67
70
 
89
92
    /* ctime() does \n, but I need it once more */
90
93
    logg("Scan started: %s\n", ctime(&starttime));
91
94
 
92
 
    memset(&claminfo, 0, sizeof(struct s_info));
93
 
 
94
95
    gettimeofday(&t1, &tz);
95
 
    ret = client(opt);
 
96
 
 
97
    ret = client(opt, &infected);
96
98
 
97
99
/* Implement STATUS in clamd */
98
 
    if(!optl(opt, "disable-summary")) {
 
100
    if(!optl(opt, "disable-summary") && !optl(opt, "no-summary")) {
99
101
        gettimeofday(&t2, &tz);
100
102
        ds = t2.tv_sec - t1.tv_sec;
101
103
        dms = t2.tv_usec - t1.tv_usec;
103
105
        dms += (dms < 0) ? (1000000):(0);
104
106
        mprintf("\n----------- SCAN SUMMARY -----------\n");
105
107
            logg("\n-- summary --\n");
106
 
        mprintf("Infected files: %d\n", claminfo.ifiles);
107
 
            logg("Infected files: %d\n", claminfo.ifiles);
 
108
        mprintf("Infected files: %d\n", infected);
 
109
            logg("Infected files: %d\n", infected);
 
110
        if(notremoved) {
 
111
            mprintf("Not removed: %d\n", notremoved);
 
112
                logg("Not removed: %d\n", notremoved);
 
113
        }
 
114
        if(notmoved) {
 
115
            mprintf("Not moved: %d\n", notmoved);
 
116
                logg("Not moved: %d\n", notmoved);
 
117
        }
108
118
        mprintf("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60);
109
119
            logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60);
110
120
    }
118
128
    mprintf_stdout = 1;
119
129
 
120
130
    mprintf("\n");
121
 
    mprintf("                          ClamAV Daemon Client "VERSION"\n");
122
 
    mprintf("                (c) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>\n\n");
 
131
    mprintf("                       ClamAV Daemon Client "VERSION"\n");
 
132
    mprintf("     (C) 2002 - 2005 ClamAV Team - http://www.clamav.net/team.html\n\n");
123
133
 
124
134
    mprintf("    --help              -h             Show help\n");
125
135
    mprintf("    --version           -V             Print version number and exit\n");
128
138
    mprintf("    --stdout                           Write to stdout instead of stderr\n");
129
139
    mprintf("                                       (this help is always written to stdout)\n");
130
140
    mprintf("    --log=FILE          -l FILE        Save scan report in FILE\n");
131
 
    mprintf("    --log-verbose                      Log additional messages\n");
 
141
    mprintf("    --remove                           Remove infected files. Be careful!\n");
 
142
    mprintf("    --move=DIRECTORY                   Move infected files into DIRECTORY\n");
132
143
    mprintf("    --config-file=FILE                 Read configuration from FILE.\n");
133
144
    mprintf("    --no-summary                       Disable summary at end of scanning\n");
134
145
    mprintf("\n");