git-svn: trunk@4581
Tomasz Kojm authored on 2008/12/31 06:16:02... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Tue Dec 30 22:29:50 CET 2008 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * shared/optparser.c, clamdscan: use the new option parser (bb#1215) |
|
4 |
+ |
|
1 | 5 |
Tue Dec 30 11:43:10 CET 2008 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* shared/optparser.c, clamscan: use the new option parser; changes in switches: |
... | ... |
@@ -115,7 +115,7 @@ int main(int argc, char **argv) |
115 | 115 |
} |
116 | 116 |
#endif |
117 | 117 |
|
118 |
- if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMD, NULL)) == NULL) { |
|
118 |
+ if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMD, 0, NULL)) == NULL) { |
|
119 | 119 |
mprintf("!Can't parse command line options\n"); |
120 | 120 |
return 1; |
121 | 121 |
} |
... | ... |
@@ -141,7 +141,7 @@ int main(int argc, char **argv) |
141 | 141 |
/* parse the config file */ |
142 | 142 |
cfgfile = optget(opts, "config-file")->strarg; |
143 | 143 |
pt = strdup(cfgfile); |
144 |
- if((opts = optparse(cfgfile, 0, NULL, 1, OPT_CLAMD, opts)) == NULL) { |
|
144 |
+ if((opts = optparse(cfgfile, 0, NULL, 1, OPT_CLAMD, 0, opts)) == NULL) { |
|
145 | 145 |
fprintf(stderr, "ERROR: Can't open/parse the config file %s\n", pt); |
146 | 146 |
free(pt); |
147 | 147 |
return 1; |
... | ... |
@@ -23,21 +23,18 @@ bin_PROGRAMS = clamdscan |
23 | 23 |
clamdscan_SOURCES = \ |
24 | 24 |
$(top_srcdir)/shared/output.c \ |
25 | 25 |
$(top_srcdir)/shared/output.h \ |
26 |
- $(top_srcdir)/shared/cfgparser.c \ |
|
27 |
- $(top_srcdir)/shared/cfgparser.h \ |
|
26 |
+ $(top_srcdir)/shared/optparser.c \ |
|
27 |
+ $(top_srcdir)/shared/optparser.h \ |
|
28 | 28 |
$(top_srcdir)/shared/misc.c \ |
29 | 29 |
$(top_srcdir)/shared/misc.h \ |
30 | 30 |
$(top_srcdir)/shared/getopt.c \ |
31 | 31 |
$(top_srcdir)/shared/getopt.h \ |
32 |
- $(top_srcdir)/shared/options.c \ |
|
33 |
- $(top_srcdir)/shared/options.h \ |
|
34 | 32 |
$(top_srcdir)/libclamav/regex/strlcpy.c\ |
35 | 33 |
clamd_fdscan.c \ |
36 | 34 |
clamd_fdscan.h \ |
37 | 35 |
clamdscan.c \ |
38 | 36 |
client.c \ |
39 |
- client.h \ |
|
40 |
- defaults.h |
|
37 |
+ client.h |
|
41 | 38 |
|
42 | 39 |
endif |
43 | 40 |
|
... | ... |
@@ -72,18 +72,17 @@ am__installdirs = "$(DESTDIR)$(bindir)" |
72 | 72 |
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) |
73 | 73 |
PROGRAMS = $(bin_PROGRAMS) |
74 | 74 |
am__clamdscan_SOURCES_DIST = $(top_srcdir)/shared/output.c \ |
75 |
- $(top_srcdir)/shared/output.h $(top_srcdir)/shared/cfgparser.c \ |
|
76 |
- $(top_srcdir)/shared/cfgparser.h $(top_srcdir)/shared/misc.c \ |
|
75 |
+ $(top_srcdir)/shared/output.h $(top_srcdir)/shared/optparser.c \ |
|
76 |
+ $(top_srcdir)/shared/optparser.h $(top_srcdir)/shared/misc.c \ |
|
77 | 77 |
$(top_srcdir)/shared/misc.h $(top_srcdir)/shared/getopt.c \ |
78 |
- $(top_srcdir)/shared/getopt.h $(top_srcdir)/shared/options.c \ |
|
79 |
- $(top_srcdir)/shared/options.h \ |
|
78 |
+ $(top_srcdir)/shared/getopt.h \ |
|
80 | 79 |
$(top_srcdir)/libclamav/regex/strlcpy.c clamd_fdscan.c \ |
81 |
- clamd_fdscan.h clamdscan.c client.c client.h defaults.h |
|
80 |
+ clamd_fdscan.h clamdscan.c client.c client.h |
|
82 | 81 |
@BUILD_CLAMD_TRUE@am_clamdscan_OBJECTS = output.$(OBJEXT) \ |
83 |
-@BUILD_CLAMD_TRUE@ cfgparser.$(OBJEXT) misc.$(OBJEXT) \ |
|
84 |
-@BUILD_CLAMD_TRUE@ getopt.$(OBJEXT) options.$(OBJEXT) \ |
|
85 |
-@BUILD_CLAMD_TRUE@ strlcpy.$(OBJEXT) clamd_fdscan.$(OBJEXT) \ |
|
86 |
-@BUILD_CLAMD_TRUE@ clamdscan.$(OBJEXT) client.$(OBJEXT) |
|
82 |
+@BUILD_CLAMD_TRUE@ optparser.$(OBJEXT) misc.$(OBJEXT) \ |
|
83 |
+@BUILD_CLAMD_TRUE@ getopt.$(OBJEXT) strlcpy.$(OBJEXT) \ |
|
84 |
+@BUILD_CLAMD_TRUE@ clamd_fdscan.$(OBJEXT) clamdscan.$(OBJEXT) \ |
|
85 |
+@BUILD_CLAMD_TRUE@ client.$(OBJEXT) |
|
87 | 86 |
clamdscan_OBJECTS = $(am_clamdscan_OBJECTS) |
88 | 87 |
clamdscan_LDADD = $(LDADD) |
89 | 88 |
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) |
... | ... |
@@ -262,21 +261,18 @@ top_srcdir = @top_srcdir@ |
262 | 262 |
@BUILD_CLAMD_TRUE@clamdscan_SOURCES = \ |
263 | 263 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/output.c \ |
264 | 264 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/output.h \ |
265 |
-@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/cfgparser.c \ |
|
266 |
-@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/cfgparser.h \ |
|
265 |
+@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/optparser.c \ |
|
266 |
+@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/optparser.h \ |
|
267 | 267 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/misc.c \ |
268 | 268 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/misc.h \ |
269 | 269 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/getopt.c \ |
270 | 270 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/getopt.h \ |
271 |
-@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/options.c \ |
|
272 |
-@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/options.h \ |
|
273 | 271 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/libclamav/regex/strlcpy.c\ |
274 | 272 |
@BUILD_CLAMD_TRUE@ clamd_fdscan.c \ |
275 | 273 |
@BUILD_CLAMD_TRUE@ clamd_fdscan.h \ |
276 | 274 |
@BUILD_CLAMD_TRUE@ clamdscan.c \ |
277 | 275 |
@BUILD_CLAMD_TRUE@ client.c \ |
278 |
-@BUILD_CLAMD_TRUE@ client.h \ |
|
279 |
-@BUILD_CLAMD_TRUE@ defaults.h |
|
276 |
+@BUILD_CLAMD_TRUE@ client.h |
|
280 | 277 |
|
281 | 278 |
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav |
282 | 279 |
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = clamdscan$(EXEEXT) |
... | ... |
@@ -368,13 +364,12 @@ mostlyclean-compile: |
368 | 368 |
distclean-compile: |
369 | 369 |
-rm -f *.tab.c |
370 | 370 |
|
371 |
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgparser.Po@am__quote@ |
|
372 | 371 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamd_fdscan.Po@am__quote@ |
373 | 372 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamdscan.Po@am__quote@ |
374 | 373 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@ |
375 | 374 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ |
376 | 375 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@ |
377 |
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ |
|
376 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optparser.Po@am__quote@ |
|
378 | 377 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@ |
379 | 378 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Po@am__quote@ |
380 | 379 |
|
... | ... |
@@ -413,19 +408,19 @@ output.obj: $(top_srcdir)/shared/output.c |
413 | 413 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
414 | 414 |
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o output.obj `if test -f '$(top_srcdir)/shared/output.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/output.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/output.c'; fi` |
415 | 415 |
|
416 |
-cfgparser.o: $(top_srcdir)/shared/cfgparser.c |
|
417 |
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cfgparser.o -MD -MP -MF $(DEPDIR)/cfgparser.Tpo -c -o cfgparser.o `test -f '$(top_srcdir)/shared/cfgparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cfgparser.c |
|
418 |
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cfgparser.Tpo $(DEPDIR)/cfgparser.Po |
|
419 |
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.o' libtool=no @AMDEPBACKSLASH@ |
|
416 |
+optparser.o: $(top_srcdir)/shared/optparser.c |
|
417 |
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT optparser.o -MD -MP -MF $(DEPDIR)/optparser.Tpo -c -o optparser.o `test -f '$(top_srcdir)/shared/optparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/optparser.c |
|
418 |
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/optparser.Tpo $(DEPDIR)/optparser.Po |
|
419 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/optparser.c' object='optparser.o' libtool=no @AMDEPBACKSLASH@ |
|
420 | 420 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
421 |
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.o `test -f '$(top_srcdir)/shared/cfgparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/cfgparser.c |
|
421 |
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o optparser.o `test -f '$(top_srcdir)/shared/optparser.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/optparser.c |
|
422 | 422 |
|
423 |
-cfgparser.obj: $(top_srcdir)/shared/cfgparser.c |
|
424 |
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cfgparser.obj -MD -MP -MF $(DEPDIR)/cfgparser.Tpo -c -o cfgparser.obj `if test -f '$(top_srcdir)/shared/cfgparser.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/cfgparser.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/cfgparser.c'; fi` |
|
425 |
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cfgparser.Tpo $(DEPDIR)/cfgparser.Po |
|
426 |
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/cfgparser.c' object='cfgparser.obj' libtool=no @AMDEPBACKSLASH@ |
|
423 |
+optparser.obj: $(top_srcdir)/shared/optparser.c |
|
424 |
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT optparser.obj -MD -MP -MF $(DEPDIR)/optparser.Tpo -c -o optparser.obj `if test -f '$(top_srcdir)/shared/optparser.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/optparser.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/optparser.c'; fi` |
|
425 |
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/optparser.Tpo $(DEPDIR)/optparser.Po |
|
426 |
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/optparser.c' object='optparser.obj' libtool=no @AMDEPBACKSLASH@ |
|
427 | 427 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
428 |
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cfgparser.obj `if test -f '$(top_srcdir)/shared/cfgparser.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/cfgparser.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/cfgparser.c'; fi` |
|
428 |
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o optparser.obj `if test -f '$(top_srcdir)/shared/optparser.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/optparser.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/optparser.c'; fi` |
|
429 | 429 |
|
430 | 430 |
misc.o: $(top_srcdir)/shared/misc.c |
431 | 431 |
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT misc.o -MD -MP -MF $(DEPDIR)/misc.Tpo -c -o misc.o `test -f '$(top_srcdir)/shared/misc.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/misc.c |
... | ... |
@@ -455,20 +450,6 @@ getopt.obj: $(top_srcdir)/shared/getopt.c |
455 | 455 |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
456 | 456 |
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getopt.obj `if test -f '$(top_srcdir)/shared/getopt.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/getopt.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/getopt.c'; fi` |
457 | 457 |
|
458 |
-options.o: $(top_srcdir)/shared/options.c |
|
459 |
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT options.o -MD -MP -MF $(DEPDIR)/options.Tpo -c -o options.o `test -f '$(top_srcdir)/shared/options.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/options.c |
|
460 |
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/options.Tpo $(DEPDIR)/options.Po |
|
461 |
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/options.c' object='options.o' libtool=no @AMDEPBACKSLASH@ |
|
462 |
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
463 |
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o options.o `test -f '$(top_srcdir)/shared/options.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/options.c |
|
464 |
- |
|
465 |
-options.obj: $(top_srcdir)/shared/options.c |
|
466 |
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT options.obj -MD -MP -MF $(DEPDIR)/options.Tpo -c -o options.obj `if test -f '$(top_srcdir)/shared/options.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/options.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/options.c'; fi` |
|
467 |
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/options.Tpo $(DEPDIR)/options.Po |
|
468 |
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/shared/options.c' object='options.obj' libtool=no @AMDEPBACKSLASH@ |
|
469 |
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
470 |
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o options.obj `if test -f '$(top_srcdir)/shared/options.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/options.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/options.c'; fi` |
|
471 |
- |
|
472 | 458 |
strlcpy.o: $(top_srcdir)/libclamav/regex/strlcpy.c |
473 | 459 |
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcpy.o -MD -MP -MF $(DEPDIR)/strlcpy.Tpo -c -o strlcpy.o `test -f '$(top_srcdir)/libclamav/regex/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/libclamav/regex/strlcpy.c |
474 | 460 |
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/strlcpy.Tpo $(DEPDIR)/strlcpy.Po |
... | ... |
@@ -28,14 +28,11 @@ |
28 | 28 |
#include <time.h> |
29 | 29 |
#include <signal.h> |
30 | 30 |
|
31 |
-#include "options.h" |
|
32 |
-#include "others.h" |
|
33 |
-#include "defaults.h" |
|
34 |
-#include "client.h" |
|
35 |
-#include "output.h" |
|
36 |
-#include "misc.h" |
|
31 |
+#include "shared/output.h" |
|
32 |
+#include "shared/misc.h" |
|
33 |
+#include "shared/optparser.h" |
|
37 | 34 |
|
38 |
-#include "clamscan/clamscan_opt.h" |
|
35 |
+#include "client.h" |
|
39 | 36 |
|
40 | 37 |
void help(void); |
41 | 38 |
|
... | ... |
@@ -65,62 +62,56 @@ int main(int argc, char **argv) |
65 | 65 |
struct timeval t1, t2; |
66 | 66 |
struct timezone tz; |
67 | 67 |
time_t starttime; |
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", |
|
73 |
- "infected", |
|
74 |
- NULL }; |
|
75 |
- |
|
76 |
- |
|
77 |
- opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, clamdscan_accepted, NULL); |
|
78 |
- if(!opt) { |
|
79 |
- mprintf("!Can't parse the command line\n"); |
|
68 |
+ struct optstruct *opts; |
|
69 |
+ const struct optstruct *opt; |
|
70 |
+ |
|
71 |
+ |
|
72 |
+ if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMDSCAN, OPT_CLAMSCAN, NULL)) == NULL) { |
|
73 |
+ mprintf("!Can't parse command line options\n"); |
|
80 | 74 |
return 2; |
81 | 75 |
} |
82 | 76 |
|
83 |
- if(opt_check(opt, "verbose")) { |
|
77 |
+ if(optget(opts, "verbose")->enabled) { |
|
84 | 78 |
mprintf_verbose = 1; |
85 | 79 |
logg_verbose = 1; |
86 | 80 |
} |
87 | 81 |
|
88 |
- if(opt_check(opt, "quiet")) |
|
82 |
+ if(optget(opts, "quiet")->enabled) |
|
89 | 83 |
mprintf_quiet = 1; |
90 | 84 |
|
91 |
- if(opt_check(opt, "stdout")) |
|
85 |
+ if(optget(opts, "stdout")->enabled) |
|
92 | 86 |
mprintf_stdout = 1; |
93 | 87 |
|
94 |
- if(opt_check(opt, "version")) { |
|
95 |
- print_server_version(opt); |
|
96 |
- opt_free(opt); |
|
88 |
+ if(optget(opts, "version")->enabled) { |
|
89 |
+ print_server_version(opts); |
|
90 |
+ optfree(opts); |
|
97 | 91 |
exit(0); |
98 | 92 |
} |
99 | 93 |
|
100 |
- if(opt_check(opt, "help")) { |
|
101 |
- opt_free(opt); |
|
94 |
+ if(optget(opts, "help")->enabled) { |
|
95 |
+ optfree(opts); |
|
102 | 96 |
help(); |
103 | 97 |
} |
104 | 98 |
|
105 |
- if(opt_check(opt, "infected")) |
|
99 |
+ if(optget(opts, "infected")->enabled) |
|
106 | 100 |
printinfected = 1; |
107 | 101 |
|
108 | 102 |
/* initialize logger */ |
109 | 103 |
|
110 |
- if(opt_check(opt, "log")) { |
|
111 |
- logg_file = opt_arg(opt, "log"); |
|
104 |
+ if((opt = optget(opts, "log"))->enabled) { |
|
105 |
+ logg_file = opt->strarg; |
|
112 | 106 |
if(logg("--------------------------------------\n")) { |
113 | 107 |
mprintf("!Problem with internal logger.\n"); |
114 |
- opt_free(opt); |
|
108 |
+ optfree(opts); |
|
115 | 109 |
exit(2); |
116 | 110 |
} |
117 | 111 |
} else |
118 | 112 |
logg_file = NULL; |
119 | 113 |
|
120 | 114 |
|
121 |
- if(opt_check(opt, "reload")) { |
|
122 |
- ret = reload_server_database(opt); |
|
123 |
- opt_free(opt); |
|
115 |
+ if(optget(opts, "reload")->enabled) { |
|
116 |
+ ret = reload_server_database(opts); |
|
117 |
+ optfree(opts); |
|
124 | 118 |
logg_close(); |
125 | 119 |
exit(ret); |
126 | 120 |
} |
... | ... |
@@ -130,10 +121,10 @@ int main(int argc, char **argv) |
130 | 130 |
|
131 | 131 |
gettimeofday(&t1, &tz); |
132 | 132 |
|
133 |
- ret = client(opt, &infected); |
|
133 |
+ ret = client(opts, &infected); |
|
134 | 134 |
|
135 | 135 |
/* TODO: Implement STATUS in clamd */ |
136 |
- if((infected || ret != 2) && !opt_check(opt, "disable-summary") && !opt_check(opt, "no-summary")) { |
|
136 |
+ if((infected || ret != 2) && !optget(opts, "no-summary")->enabled) { |
|
137 | 137 |
gettimeofday(&t2, &tz); |
138 | 138 |
ds = t2.tv_sec - t1.tv_sec; |
139 | 139 |
dms = t2.tv_usec - t1.tv_usec; |
... | ... |
@@ -151,7 +142,7 @@ int main(int argc, char **argv) |
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
logg_close(); |
154 |
- opt_free(opt); |
|
154 |
+ optfree(opts); |
|
155 | 155 |
exit(ret); |
156 | 156 |
} |
157 | 157 |
|
... | ... |
@@ -40,23 +40,21 @@ |
40 | 40 |
#include <sys/uio.h> |
41 | 41 |
#endif |
42 | 42 |
|
43 |
-#include "others.h" |
|
44 |
-#include "defaults.h" |
|
45 |
-#include "options.h" |
|
46 |
-#include "cfgparser.h" |
|
47 |
-#include "output.h" |
|
48 |
-#include "misc.h" |
|
49 |
-#include "str.h" |
|
43 |
+#include "shared/optparser.h" |
|
44 |
+#include "shared/output.h" |
|
45 |
+#include "shared/misc.h" |
|
46 |
+#include "libclamav/str.h" |
|
47 |
+ |
|
50 | 48 |
#include "client.h" |
51 | 49 |
#include "clamd_fdscan.h" |
52 | 50 |
|
53 | 51 |
#define SOCKET_INET AF_INET |
54 | 52 |
|
55 |
-void move_infected(const char *filename, const struct optstruct *opt); |
|
53 |
+void move_infected(const char *filename, const struct optstruct *opts); |
|
56 | 54 |
int notremoved = 0, notmoved = 0; |
57 | 55 |
int printinfected = 0; |
58 | 56 |
|
59 |
-static int dsresult(int sockd, const struct optstruct *opt) |
|
57 |
+static int dsresult(int sockd, const struct optstruct *opts) |
|
60 | 58 |
{ |
61 | 59 |
int infected = 0, waserror = 0; |
62 | 60 |
char buff[4096], *pt; |
... | ... |
@@ -68,7 +66,7 @@ static int dsresult(int sockd, const struct optstruct *opt) |
68 | 68 |
#else /* FIXME: accoriding to YD OS/2 does not support dup() for sockets */ |
69 | 69 |
if((fd = fdopen(sockd, "r")) == NULL) { |
70 | 70 |
#endif |
71 |
- logg("^Can't open descriptor for reading.\n"); |
|
71 |
+ logg("!Can't open descriptor for reading.\n"); |
|
72 | 72 |
return -1; |
73 | 73 |
} |
74 | 74 |
|
... | ... |
@@ -76,16 +74,16 @@ static int dsresult(int sockd, const struct optstruct *opt) |
76 | 76 |
if(strstr(buff, "FOUND\n")) { |
77 | 77 |
infected++; |
78 | 78 |
logg("%s", buff); |
79 |
- if(opt_check(opt, "move") || opt_check(opt, "copy")) { |
|
79 |
+ if(optget(opts, "move")->enabled || optget(opts, "copy")->enabled) { |
|
80 | 80 |
/* filename: Virus FOUND */ |
81 | 81 |
if((pt = strrchr(buff, ':'))) { |
82 | 82 |
*pt = 0; |
83 |
- move_infected(buff, opt); |
|
83 |
+ move_infected(buff, opts); |
|
84 | 84 |
} else { |
85 |
- logg("!Incorrect output from clamd. File not %s.\n", opt_check(opt, "move") ? "moved" : "copied"); |
|
85 |
+ logg("!Incorrect output from clamd. File not %s.\n", optget(opts, "move")->enabled ? "moved" : "copied"); |
|
86 | 86 |
} |
87 | 87 |
|
88 |
- } else if(opt_check(opt, "remove")) { |
|
88 |
+ } else if(optget(opts, "remove")->enabled) { |
|
89 | 89 |
if(!(pt = strrchr(buff, ':'))) { |
90 | 90 |
logg("!Incorrect output from clamd. File not removed.\n"); |
91 | 91 |
} else { |
... | ... |
@@ -113,7 +111,7 @@ static int dsresult(int sockd, const struct optstruct *opt) |
113 | 113 |
return infected ? infected : (waserror ? -1 : 0); |
114 | 114 |
} |
115 | 115 |
|
116 |
-static int dsfile(int sockd, const char *scantype, const char *filename, const struct optstruct *opt) |
|
116 |
+static int dsfile(int sockd, const char *scantype, const char *filename, const struct optstruct *opts) |
|
117 | 117 |
{ |
118 | 118 |
int ret; |
119 | 119 |
char *scancmd; |
... | ... |
@@ -130,7 +128,7 @@ static int dsfile(int sockd, const char *scantype, const char *filename, const s |
130 | 130 |
|
131 | 131 |
free(scancmd); |
132 | 132 |
|
133 |
- ret = dsresult(sockd, opt); |
|
133 |
+ ret = dsresult(sockd, opts); |
|
134 | 134 |
|
135 | 135 |
if(!ret && !printinfected) |
136 | 136 |
logg("~%s: OK\n", filename); |
... | ... |
@@ -138,7 +136,7 @@ static int dsfile(int sockd, const char *scantype, const char *filename, const s |
138 | 138 |
return ret; |
139 | 139 |
} |
140 | 140 |
|
141 |
-static int dsstream(int sockd, const struct optstruct *opt) |
|
141 |
+static int dsstream(int sockd, const struct optstruct *opts) |
|
142 | 142 |
{ |
143 | 143 |
int wsockd, loopw = 60, bread, port, infected = 0; |
144 | 144 |
struct sockaddr_in server; |
... | ... |
@@ -148,7 +146,7 @@ static int dsstream(int sockd, const struct optstruct *opt) |
148 | 148 |
|
149 | 149 |
|
150 | 150 |
if(write(sockd, "STREAM", 6) <= 0) { |
151 |
- logg("^Can't write to the socket.\n"); |
|
151 |
+ logg("!Can't write to the socket.\n"); |
|
152 | 152 |
return 2; |
153 | 153 |
} |
154 | 154 |
|
... | ... |
@@ -165,7 +163,7 @@ static int dsstream(int sockd, const struct optstruct *opt) |
165 | 165 |
} |
166 | 166 |
|
167 | 167 |
if(!loopw) { |
168 |
- logg("^Daemon not ready for stream scanning.\n"); |
|
168 |
+ logg("!Daemon not ready for stream scanning.\n"); |
|
169 | 169 |
return -1; |
170 | 170 |
} |
171 | 171 |
|
... | ... |
@@ -173,7 +171,7 @@ static int dsstream(int sockd, const struct optstruct *opt) |
173 | 173 |
|
174 | 174 |
if((wsockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) { |
175 | 175 |
perror("socket()"); |
176 |
- logg("^Can't create the socket.\n"); |
|
176 |
+ logg("!Can't create the socket.\n"); |
|
177 | 177 |
return -1; |
178 | 178 |
} |
179 | 179 |
|
... | ... |
@@ -183,7 +181,7 @@ static int dsstream(int sockd, const struct optstruct *opt) |
183 | 183 |
peer_size = sizeof(peer); |
184 | 184 |
if(getpeername(sockd, (struct sockaddr *) &peer, &peer_size) < 0) { |
185 | 185 |
perror("getpeername()"); |
186 |
- logg("^Can't get socket peer name.\n"); |
|
186 |
+ logg("!Can't get socket peer name.\n"); |
|
187 | 187 |
return -1; |
188 | 188 |
} |
189 | 189 |
|
... | ... |
@@ -195,20 +193,20 @@ static int dsstream(int sockd, const struct optstruct *opt) |
195 | 195 |
server.sin_addr.s_addr = peer.sin_addr.s_addr; |
196 | 196 |
break; |
197 | 197 |
default: |
198 |
- logg("^Unexpected socket type: %d.\n", peer.sin_family); |
|
198 |
+ logg("!Unexpected socket type: %d.\n", peer.sin_family); |
|
199 | 199 |
return -1; |
200 | 200 |
} |
201 | 201 |
|
202 | 202 |
if(connect(wsockd, (struct sockaddr *) &server, sizeof(struct sockaddr_in)) < 0) { |
203 | 203 |
close(wsockd); |
204 | 204 |
perror("connect()"); |
205 |
- logg("^Can't connect to clamd [port: %d].\n", port); |
|
205 |
+ logg("!Can't connect to clamd [port: %d].\n", port); |
|
206 | 206 |
return -1; |
207 | 207 |
} |
208 | 208 |
|
209 | 209 |
while((bread = read(0, buff, sizeof(buff))) > 0) { |
210 | 210 |
if(write(wsockd, buff, bread) <= 0) { |
211 |
- logg("^Can't write to the socket.\n"); |
|
211 |
+ logg("!Can't write to the socket.\n"); |
|
212 | 212 |
close(wsockd); |
213 | 213 |
return -1; |
214 | 214 |
} |
... | ... |
@@ -256,23 +254,21 @@ static char *abpath(const char *filename) |
256 | 256 |
return fullpath; |
257 | 257 |
} |
258 | 258 |
|
259 |
-static int dconnect(const struct optstruct *opt, int *is_unix) |
|
259 |
+static int dconnect(const struct optstruct *opts, int *is_unix) |
|
260 | 260 |
{ |
261 | 261 |
struct sockaddr_un server; |
262 | 262 |
struct sockaddr_in server2; |
263 | 263 |
struct hostent *he; |
264 |
- struct cfgstruct *copt; |
|
265 |
- const struct cfgstruct *cpt; |
|
266 |
- const char *clamav_conf = opt_arg(opt, "config-file"); |
|
264 |
+ struct optstruct *clamdopts; |
|
265 |
+ const struct optstruct *opt; |
|
266 |
+ const char *clamd_conf = optget(opts, "config-file")->strarg; |
|
267 | 267 |
int sockd; |
268 | 268 |
|
269 | 269 |
if(is_unix) |
270 |
- *is_unix = 0; |
|
271 |
- if(!clamav_conf) |
|
272 |
- clamav_conf = DEFAULT_CFG; |
|
270 |
+ *is_unix = 0; |
|
273 | 271 |
|
274 |
- if((copt = getcfg(clamav_conf, 1, OPT_CLAMD)) == NULL) { |
|
275 |
- logg("^Can't parse the configuration file.\n"); |
|
272 |
+ if((clamdopts = optparse(clamd_conf, 0, NULL, 1, OPT_CLAMD, 0, NULL)) == NULL) { |
|
273 |
+ logg("!Can't parse clamd configuration file %s\n", clamd_conf); |
|
276 | 274 |
return -1; |
277 | 275 |
} |
278 | 276 |
|
... | ... |
@@ -282,46 +278,46 @@ static int dconnect(const struct optstruct *opt, int *is_unix) |
282 | 282 |
/* Set default address to connect to */ |
283 | 283 |
server2.sin_addr.s_addr = inet_addr("127.0.0.1"); |
284 | 284 |
|
285 |
- if((cpt = cfgopt(copt, "LocalSocket"))->enabled) { |
|
285 |
+ if((opt = optget(clamdopts, "LocalSocket"))->enabled) { |
|
286 | 286 |
|
287 | 287 |
server.sun_family = AF_UNIX; |
288 |
- strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); |
|
288 |
+ strncpy(server.sun_path, opt->strarg, sizeof(server.sun_path)); |
|
289 | 289 |
server.sun_path[sizeof(server.sun_path)-1]='\0'; |
290 | 290 |
|
291 | 291 |
if((sockd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
292 | 292 |
perror("socket()"); |
293 |
- logg("^Can't create the socket.\n"); |
|
294 |
- freecfg(copt); |
|
293 |
+ logg("!Can't create the socket.\n"); |
|
294 |
+ optfree(clamdopts); |
|
295 | 295 |
return -1; |
296 | 296 |
} |
297 | 297 |
|
298 | 298 |
if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { |
299 | 299 |
close(sockd); |
300 | 300 |
perror("connect()"); |
301 |
- logg("^Can't connect to clamd.\n"); |
|
302 |
- freecfg(copt); |
|
301 |
+ logg("!Can't connect to clamd.\n"); |
|
302 |
+ optfree(clamdopts); |
|
303 | 303 |
return -1; |
304 | 304 |
} |
305 | 305 |
if(is_unix) |
306 | 306 |
*is_unix = 1; |
307 |
- } else if((cpt = cfgopt(copt, "TCPSocket"))->enabled) { |
|
307 |
+ } else if((opt = optget(clamdopts, "TCPSocket"))->enabled) { |
|
308 | 308 |
|
309 | 309 |
if((sockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) { |
310 | 310 |
perror("socket()"); |
311 |
- logg("^Can't create the socket.\n"); |
|
312 |
- freecfg(copt); |
|
311 |
+ logg("!Can't create the socket.\n"); |
|
312 |
+ optfree(clamdopts); |
|
313 | 313 |
return -1; |
314 | 314 |
} |
315 | 315 |
|
316 | 316 |
server2.sin_family = AF_INET; |
317 |
- server2.sin_port = htons(cpt->numarg); |
|
317 |
+ server2.sin_port = htons(opt->numarg); |
|
318 | 318 |
|
319 |
- if((cpt = cfgopt(copt, "TCPAddr"))->enabled) { |
|
320 |
- if ((he = gethostbyname(cpt->strarg)) == 0) { |
|
319 |
+ if((opt = optget(clamdopts, "TCPAddr"))->enabled) { |
|
320 |
+ if ((he = gethostbyname(opt->strarg)) == 0) { |
|
321 | 321 |
close(sockd); |
322 | 322 |
perror("gethostbyname()"); |
323 |
- logg("^Can't lookup clamd hostname.\n"); |
|
324 |
- freecfg(copt); |
|
323 |
+ logg("!Can't lookup clamd hostname.\n"); |
|
324 |
+ optfree(clamdopts); |
|
325 | 325 |
return -1; |
326 | 326 |
} |
327 | 327 |
server2.sin_addr = *(struct in_addr *) he->h_addr_list[0]; |
... | ... |
@@ -330,33 +326,33 @@ static int dconnect(const struct optstruct *opt, int *is_unix) |
330 | 330 |
if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) { |
331 | 331 |
close(sockd); |
332 | 332 |
perror("connect()"); |
333 |
- logg("^Can't connect to clamd.\n"); |
|
334 |
- freecfg(copt); |
|
333 |
+ logg("!Can't connect to clamd.\n"); |
|
334 |
+ optfree(clamdopts); |
|
335 | 335 |
return -1; |
336 | 336 |
} |
337 | 337 |
|
338 | 338 |
} else { |
339 |
- logg("^Clamd is not configured properly.\n"); |
|
340 |
- freecfg(copt); |
|
339 |
+ logg("!Clamd is not configured properly.\n"); |
|
340 |
+ optfree(clamdopts); |
|
341 | 341 |
return -1; |
342 | 342 |
} |
343 | 343 |
|
344 |
- freecfg(copt); |
|
344 |
+ optfree(clamdopts); |
|
345 | 345 |
|
346 | 346 |
return sockd; |
347 | 347 |
} |
348 | 348 |
|
349 |
-int get_clamd_version(const struct optstruct *opt) |
|
349 |
+int get_clamd_version(const struct optstruct *opts) |
|
350 | 350 |
{ |
351 | 351 |
char buff[64]; |
352 | 352 |
int bread, sockd; |
353 | 353 |
|
354 | 354 |
|
355 |
- if((sockd = dconnect(opt, NULL)) < 0) |
|
355 |
+ if((sockd = dconnect(opts, NULL)) < 0) |
|
356 | 356 |
return 2; |
357 | 357 |
|
358 | 358 |
if(write(sockd, "VERSION", 7) <= 0) { |
359 |
- logg("^Can't write to the socket.\n"); |
|
359 |
+ logg("!Can't write to the socket.\n"); |
|
360 | 360 |
close(sockd); |
361 | 361 |
return 2; |
362 | 362 |
} |
... | ... |
@@ -370,13 +366,13 @@ int get_clamd_version(const struct optstruct *opt) |
370 | 370 |
return 0; |
371 | 371 |
} |
372 | 372 |
|
373 |
-int reload_clamd_database(const struct optstruct *opt) |
|
373 |
+int reload_clamd_database(const struct optstruct *opts) |
|
374 | 374 |
{ |
375 | 375 |
char buff[64]; |
376 | 376 |
int bread, sockd; |
377 | 377 |
|
378 | 378 |
|
379 |
- if((sockd = dconnect(opt, NULL)) < 0) |
|
379 |
+ if((sockd = dconnect(opts, NULL)) < 0) |
|
380 | 380 |
return 2; |
381 | 381 |
|
382 | 382 |
if(write(sockd, "RELOAD", 6) <= 0) { |
... | ... |
@@ -396,7 +392,7 @@ int reload_clamd_database(const struct optstruct *opt) |
396 | 396 |
return 0; |
397 | 397 |
} |
398 | 398 |
|
399 |
-int client(const struct optstruct *opt, int *infected) |
|
399 |
+int client(const struct optstruct *opts, int *infected) |
|
400 | 400 |
{ |
401 | 401 |
char cwd[PATH_MAX+1], *fullpath; |
402 | 402 |
int sockd, ret, errors = 0; |
... | ... |
@@ -406,41 +402,41 @@ int client(const struct optstruct *opt, int *infected) |
406 | 406 |
|
407 | 407 |
*infected = 0; |
408 | 408 |
|
409 |
- if(opt_check(opt, "multiscan")) |
|
409 |
+ if(optget(opts, "multiscan")->enabled) |
|
410 | 410 |
scantype = "MULTISCAN"; |
411 | 411 |
|
412 | 412 |
/* parse argument list */ |
413 |
- if(opt->filename == NULL || strlen(opt->filename) == 0) { |
|
413 |
+ if(opts->filename == NULL || strlen(opts->filename) == 0) { |
|
414 | 414 |
/* scan current directory */ |
415 | 415 |
if(!getcwd(cwd, PATH_MAX)) { |
416 | 416 |
logg("^Can't get absolute pathname of current working directory.\n"); |
417 | 417 |
return 2; |
418 | 418 |
} |
419 | 419 |
|
420 |
- if((sockd = dconnect(opt, NULL)) < 0) |
|
420 |
+ if((sockd = dconnect(opts, NULL)) < 0) |
|
421 | 421 |
return 2; |
422 | 422 |
|
423 |
- if((ret = dsfile(sockd, scantype, cwd, opt)) >= 0) |
|
423 |
+ if((ret = dsfile(sockd, scantype, cwd, opts)) >= 0) |
|
424 | 424 |
*infected += ret; |
425 | 425 |
else |
426 | 426 |
errors++; |
427 | 427 |
|
428 | 428 |
close(sockd); |
429 | 429 |
|
430 |
- } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */ |
|
430 |
+ } else if(!strcmp(opts->filename, "-")) { /* scan data from stdin */ |
|
431 | 431 |
int is_unix; |
432 |
- if((sockd = dconnect(opt, &is_unix)) < 0) |
|
432 |
+ if((sockd = dconnect(opts, &is_unix)) < 0) |
|
433 | 433 |
return 2; |
434 | 434 |
|
435 |
- if(opt_check(opt,"fdpass")) { |
|
435 |
+ if(optget(opts,"fdpass")->enabled) { |
|
436 | 436 |
#ifndef HAVE_FD_PASSING |
437 | 437 |
logg("^File descriptor pass support not compiled in, falling back to stream scan\n"); |
438 |
- ret = dsstream(sockd, opt); |
|
438 |
+ ret = dsstream(sockd, opts); |
|
439 | 439 |
#else |
440 | 440 |
if(!is_unix) { |
441 | 441 |
logg("^File descriptor passing can only work on local (unix) sockets! Falling back to stream scan\n"); |
442 | 442 |
/* fall back to stream */ |
443 |
- ret = dsstream(sockd, opt); |
|
443 |
+ ret = dsstream(sockd, opts); |
|
444 | 444 |
} else { |
445 | 445 |
char buff[4096]; |
446 | 446 |
memset(buff, 0, sizeof(buff)); |
... | ... |
@@ -452,7 +448,7 @@ int client(const struct optstruct *opt, int *infected) |
452 | 452 |
} |
453 | 453 |
#endif |
454 | 454 |
} else |
455 |
- ret = dsstream(sockd, opt); |
|
455 |
+ ret = dsstream(sockd, opts); |
|
456 | 456 |
if(ret >= 0) |
457 | 457 |
*infected += ret; |
458 | 458 |
else |
... | ... |
@@ -463,7 +459,7 @@ int client(const struct optstruct *opt, int *infected) |
463 | 463 |
} else { |
464 | 464 |
int x; |
465 | 465 |
char *thefilename; |
466 |
- for (x = 0; (thefilename = cli_strtok(opt->filename, x, "\t")) != NULL; x++) { |
|
466 |
+ for (x = 0; (thefilename = cli_strtok(opts->filename, x, "\t")) != NULL; x++) { |
|
467 | 467 |
fullpath = thefilename; |
468 | 468 |
|
469 | 469 |
if(stat(fullpath, &sb) == -1) { |
... | ... |
@@ -484,10 +480,10 @@ int client(const struct optstruct *opt, int *infected) |
484 | 484 |
switch(sb.st_mode & S_IFMT) { |
485 | 485 |
case S_IFREG: |
486 | 486 |
case S_IFDIR: |
487 |
- if((sockd = dconnect(opt, NULL)) < 0) |
|
487 |
+ if((sockd = dconnect(opts, NULL)) < 0) |
|
488 | 488 |
return 2; |
489 | 489 |
|
490 |
- if((ret = dsfile(sockd, scantype, fullpath, opt)) >= 0) |
|
490 |
+ if((ret = dsfile(sockd, scantype, fullpath, opts)) >= 0) |
|
491 | 491 |
*infected += ret; |
492 | 492 |
else |
493 | 493 |
errors++; |
... | ... |
@@ -508,26 +504,26 @@ int client(const struct optstruct *opt, int *infected) |
508 | 508 |
return *infected ? 1 : (errors ? 2 : 0); |
509 | 509 |
} |
510 | 510 |
|
511 |
-void move_infected(const char *filename, const struct optstruct *opt) |
|
511 |
+void move_infected(const char *filename, const struct optstruct *opts) |
|
512 | 512 |
{ |
513 | 513 |
char *movedir, *movefilename, numext[4 + 1]; |
514 | 514 |
const char *tmp; |
515 | 515 |
struct stat ofstat, mfstat; |
516 | 516 |
int n, len, movefilename_size; |
517 |
- int moveflag = opt_check(opt, "move"); |
|
517 |
+ int moveflag = optget(opts, "move")->enabled; |
|
518 | 518 |
struct utimbuf ubuf; |
519 | 519 |
|
520 | 520 |
|
521 |
- if((moveflag && !(movedir = opt_arg(opt, "move"))) || |
|
522 |
- (!moveflag && !(movedir = opt_arg(opt, "copy")))) { |
|
521 |
+ if((moveflag && !(movedir = optget(opts, "move")->strarg)) || |
|
522 |
+ (!moveflag && !(movedir = optget(opts, "copy")->strarg))) { |
|
523 | 523 |
/* Should never reach here */ |
524 |
- logg("^opt_arg() returned NULL\n"); |
|
524 |
+ logg("!optget() returned NULL\n"); |
|
525 | 525 |
notmoved++; |
526 | 526 |
return; |
527 | 527 |
} |
528 | 528 |
|
529 | 529 |
if(access(movedir, W_OK|X_OK) == -1) { |
530 |
- logg("^error %s file '%s': cannot write to '%s': %s\n", (moveflag) ? "moving" : "copying", filename, movedir, strerror(errno)); |
|
530 |
+ logg("!problem %s file '%s': cannot write to '%s': %s\n", (moveflag) ? "moving" : "copying", filename, movedir, strerror(errno)); |
|
531 | 531 |
notmoved++; |
532 | 532 |
return; |
533 | 533 |
} |
... | ... |
@@ -545,12 +541,12 @@ void move_infected(const char *filename, const struct optstruct *opt) |
545 | 545 |
movefilename_size = sizeof(char) * (strlen(movedir) + strlen(tmp) + sizeof(numext) + 2); |
546 | 546 |
|
547 | 547 |
if(!(movefilename = malloc(movefilename_size))) { |
548 |
- logg("^Memory allocation error\n"); |
|
548 |
+ logg("!Memory allocation error\n"); |
|
549 | 549 |
exit(2); |
550 | 550 |
} |
551 | 551 |
|
552 | 552 |
if(!(cli_strrcpy(movefilename, movedir))) { |
553 |
- logg("^cli_strrcpy() returned NULL\n"); |
|
553 |
+ logg("!cli_strrcpy() returned NULL\n"); |
|
554 | 554 |
notmoved++; |
555 | 555 |
free(movefilename); |
556 | 556 |
return; |
... | ... |
@@ -559,7 +555,7 @@ void move_infected(const char *filename, const struct optstruct *opt) |
559 | 559 |
strcat(movefilename, "/"); |
560 | 560 |
|
561 | 561 |
if(!(strcat(movefilename, tmp))) { |
562 |
- logg("^strcat() returned NULL\n"); |
|
562 |
+ logg("!strcat() returned NULL\n"); |
|
563 | 563 |
notmoved++; |
564 | 564 |
free(movefilename); |
565 | 565 |
return; |
... | ... |
@@ -19,10 +19,10 @@ |
19 | 19 |
#ifndef __CLIENT_H |
20 | 20 |
#define __CLIENT_H |
21 | 21 |
|
22 |
-#include "options.h" |
|
22 |
+#include "shared/optparser.h" |
|
23 | 23 |
|
24 |
-int client(const struct optstruct *opt, int *infected); |
|
25 |
-int get_clamd_version(const struct optstruct *opt); |
|
26 |
-int reload_clamd_database(const struct optstruct *opt); |
|
24 |
+int client(const struct optstruct *opts, int *infected); |
|
25 |
+int get_clamd_version(const struct optstruct *opts); |
|
26 |
+int reload_clamd_database(const struct optstruct *opts); |
|
27 | 27 |
|
28 | 28 |
#endif |
29 | 29 |
deleted file mode 100644 |
... | ... |
@@ -1,20 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2002 Tomasz Kojm <tkojm@clamav.net> |
|
3 |
- * |
|
4 |
- * This program is free software; you can redistribute it and/or modify |
|
5 |
- * it under the terms of the GNU General Public License as published by |
|
6 |
- * the Free Software Foundation; either version 2 of the License, or |
|
7 |
- * (at your option) any later version. |
|
8 |
- * |
|
9 |
- * This program is distributed in the hope that it will be useful, |
|
10 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
- * GNU General Public License for more details. |
|
13 |
- * |
|
14 |
- * You should have received a copy of the GNU General Public License |
|
15 |
- * along with this program; if not, write to the Free Software |
|
16 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
- * MA 02110-1301, USA. |
|
18 |
- */ |
|
19 |
- |
|
20 |
-#define DEFAULT_CFG CONFDIR"/clamd.conf" |
... | ... |
@@ -84,7 +84,7 @@ int main(int argc, char **argv) |
84 | 84 |
#endif |
85 | 85 |
|
86 | 86 |
|
87 |
- if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMSCAN, NULL)) == NULL) { |
|
87 |
+ if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMSCAN, 0, NULL)) == NULL) { |
|
88 | 88 |
mprintf("!Can't parse command line options\n"); |
89 | 89 |
return 40; |
90 | 90 |
} |
91 | 91 |
deleted file mode 100644 |
... | ... |
@@ -1,127 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2002 - 2006 Tomasz Kojm <tkojm@clamav.net> |
|
3 |
- * |
|
4 |
- * This program is free software; you can redistribute it and/or modify |
|
5 |
- * it under the terms of the GNU General Public License version 2 as |
|
6 |
- * published by the Free Software Foundation. |
|
7 |
- * |
|
8 |
- * This program is distributed in the hope that it will be useful, |
|
9 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
- * GNU General Public License for more details. |
|
12 |
- * |
|
13 |
- * You should have received a copy of the GNU General Public License |
|
14 |
- * along with this program; if not, write to the Free Software |
|
15 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
16 |
- * MA 02110-1301, USA. |
|
17 |
- * |
|
18 |
- */ |
|
19 |
- |
|
20 |
-#ifndef __CLAMSCAN_OPT_H |
|
21 |
-#define __CLAMSCAN_OPT_H |
|
22 |
- |
|
23 |
-#if HAVE_CONFIG_H |
|
24 |
-#include "clamav-config.h" |
|
25 |
-#endif |
|
26 |
- |
|
27 |
-#include "getopt.h" |
|
28 |
- |
|
29 |
-const char *clamscan_shortopt = "hvd:wriVl:m"; |
|
30 |
-static struct option clamscan_longopt[] = { |
|
31 |
- {"help", 0, 0, 'h'}, /* clamscan + clamdscan */ |
|
32 |
- {"quiet", 0, 0, 0}, /* clamscan + clamdscan */ |
|
33 |
- {"stdout", 0, 0, 0}, /* clamscan + clamdscan */ |
|
34 |
- {"verbose", 0, 0, 'v'}, /* clamscan + clamdscan */ |
|
35 |
- {"debug", 0, 0, 0}, |
|
36 |
- {"version", 0, 0, 'V'}, /* clamscan + clamdscan */ |
|
37 |
- {"tempdir", 1, 0, 0}, |
|
38 |
- {"leave-temps", 0, 0, 0}, |
|
39 |
- {"config-file", 1, 0, 0}, /* clamdscan */ |
|
40 |
- {"reload", 0, 0, 0}, /* clamdscan */ |
|
41 |
- {"multiscan", 0, 0, 'm'}, |
|
42 |
- {"database", 1, 0, 'd'}, |
|
43 |
- {"force", 0, 0, 0}, |
|
44 |
- {"recursive", 0, 0, 'r'}, |
|
45 |
- {"bell", 0, 0, 0}, |
|
46 |
- {"disable-summary", 0, 0, 0}, /* obsolete */ |
|
47 |
- {"no-summary", 0, 0, 0}, |
|
48 |
- {"infected", 0, 0, 'i'}, |
|
49 |
- {"log", 1, 0, 'l'}, |
|
50 |
- {"move", 1, 0, 0}, |
|
51 |
- {"copy", 1, 0, 0}, |
|
52 |
- {"remove", 0, 0, 0}, |
|
53 |
- {"exclude", 1, 0, 0}, |
|
54 |
- {"exclude-dir", 1, 0, 0}, |
|
55 |
- {"include", 1, 0, 0}, |
|
56 |
- {"include-dir", 1, 0, 0}, |
|
57 |
- {"max-files", 1, 0, 0}, |
|
58 |
- {"max-filesize", 1, 0, 0}, |
|
59 |
- {"max-scansize", 1, 0, 0}, |
|
60 |
- {"max-recursion", 1, 0, 0}, |
|
61 |
- {"max-dir-recursion", 1, 0, 0}, |
|
62 |
- {"detect-pua", 0, 0, 0}, |
|
63 |
- {"exclude-pua", 1, 0, 0}, |
|
64 |
- {"include-pua", 1, 0, 0}, |
|
65 |
- {"detect-structured", 0, 0, 0}, |
|
66 |
- {"structured-ssn-format", 1, 0, 0}, |
|
67 |
- {"structured-ssn-count", 1, 0, 0}, |
|
68 |
- {"structured-cc-count", 1, 0, 0}, |
|
69 |
- {"disable-archive", 0, 0, 0}, |
|
70 |
- {"no-archive", 0, 0, 0}, |
|
71 |
- {"detect-broken", 0, 0, 0}, |
|
72 |
- {"block-encrypted", 0, 0, 0}, |
|
73 |
- {"no-pe", 0, 0, 0}, |
|
74 |
- {"no-elf", 0, 0, 0}, |
|
75 |
- {"no-ole2", 0, 0, 0}, |
|
76 |
- {"no-pdf", 0, 0, 0}, |
|
77 |
- {"no-html", 0, 0, 0}, |
|
78 |
- {"no-mail", 0, 0, 0}, |
|
79 |
- {"mail-follow-urls", 0, 0, 0}, |
|
80 |
- {"no-phishing-sigs", 0, 0, 0}, |
|
81 |
- {"no-phishing-scan-urls", 0, 0, 0}, |
|
82 |
- {"heuristic-scan-precedence", 0, 0, 0}, |
|
83 |
- {"phishing-ssl", 0, 0, 0}, |
|
84 |
- {"phishing-cloak", 0, 0, 0}, |
|
85 |
- {"no-algorithmic", 0, 0, 0}, |
|
86 |
- |
|
87 |
- /* developers only */ |
|
88 |
- {"dev-ac-only", 0, 0, 0}, |
|
89 |
- {"dev-ac-depth", 1, 0, 0}, |
|
90 |
- {"fdpass", 0, 0, 0}, |
|
91 |
- |
|
92 |
- /* deprecated (please also add to clamscan_deprecated[]) */ |
|
93 |
- {"no-phishing-restrictedscan", 0, 0, 0}, |
|
94 |
- {"max-ratio", 1, 0, 0}, |
|
95 |
- {"max-space", 1, 0, 0}, |
|
96 |
- {"block-max", 0, 0, 0}, |
|
97 |
- {"unzip", 2, 0, 0}, |
|
98 |
- {"unrar", 2, 0, 0}, |
|
99 |
- {"arj", 2, 0, 0}, |
|
100 |
- {"unzoo", 2, 0, 0}, |
|
101 |
- {"lha", 2, 0, 0}, |
|
102 |
- {"jar", 2, 0, 0}, |
|
103 |
- {"tar", 2, 0, 0}, |
|
104 |
- {"tgz", 2, 0, 0}, |
|
105 |
- {"deb", 2, 0, 0}, |
|
106 |
- |
|
107 |
- {0, 0, 0, 0} |
|
108 |
-}; |
|
109 |
- |
|
110 |
-const char *clamscan_deprecated[] = { |
|
111 |
- "no-phishing-restrictedscan", |
|
112 |
- "max-ratio", |
|
113 |
- "max-space", |
|
114 |
- "block-max", |
|
115 |
- "unzip", |
|
116 |
- "unrar", |
|
117 |
- "arj", |
|
118 |
- "unzoo", |
|
119 |
- "lha", |
|
120 |
- "jar", |
|
121 |
- "tar", |
|
122 |
- "tgz", |
|
123 |
- "deb", |
|
124 |
- NULL |
|
125 |
-}; |
|
126 |
- |
|
127 |
-#endif |
... | ... |
@@ -209,7 +209,7 @@ int main(int argc, char **argv) |
209 | 209 |
struct mirdat mdat; |
210 | 210 |
|
211 | 211 |
|
212 |
- if((opts = optparse(NULL, argc, argv, 1, OPT_FRESHCLAM, NULL)) == NULL) { |
|
212 |
+ if((opts = optparse(NULL, argc, argv, 1, OPT_FRESHCLAM, 0, NULL)) == NULL) { |
|
213 | 213 |
mprintf("!Can't parse command line options\n"); |
214 | 214 |
return 1; |
215 | 215 |
} |
... | ... |
@@ -223,7 +223,7 @@ int main(int argc, char **argv) |
223 | 223 |
/* parse the config file */ |
224 | 224 |
cfgfile = optget(opts, "config-file")->strarg; |
225 | 225 |
pt = strdup(cfgfile); |
226 |
- if((opts = optparse(cfgfile, 0, NULL, 1, OPT_FRESHCLAM, opts)) == NULL) { |
|
226 |
+ if((opts = optparse(cfgfile, 0, NULL, 1, OPT_FRESHCLAM, 0, opts)) == NULL) { |
|
227 | 227 |
fprintf(stderr, "ERROR: Can't open/parse the config file %s\n", pt); |
228 | 228 |
free(pt); |
229 | 229 |
return 1; |
... | ... |
@@ -559,7 +559,7 @@ int submitstats(const char *clamdcfg, const struct optstruct *opts) |
559 | 559 |
country = opt->strarg; |
560 | 560 |
} |
561 | 561 |
|
562 |
- if(!(clamdopt = optparse(clamdcfg, 0, NULL, 1, OPT_CLAMD, NULL))) { |
|
562 |
+ if(!(clamdopt = optparse(clamdcfg, 0, NULL, 1, OPT_CLAMD, 0, NULL))) { |
|
563 | 563 |
logg("!SubmitDetectionStats: Can't open or parse configuration file %s\n", clamdcfg); |
564 | 564 |
return 56; |
565 | 565 |
} |
... | ... |
@@ -70,7 +70,7 @@ int notify(const char *cfgfile) |
70 | 70 |
const char *socktype; |
71 | 71 |
|
72 | 72 |
|
73 |
- if((opts = optparse(cfgfile, 0, NULL, 1, OPT_CLAMD, NULL)) == NULL) { |
|
73 |
+ if((opts = optparse(cfgfile, 0, NULL, 1, OPT_CLAMD, 0, NULL)) == NULL) { |
|
74 | 74 |
logg("^Clamd was NOT notified: Can't find or parse configuration file %s\n", cfgfile); |
75 | 75 |
return 1; |
76 | 76 |
} |
... | ... |
@@ -20,7 +20,7 @@ |
20 | 20 |
|
21 | 21 |
/* |
22 | 22 |
* TODO: |
23 |
- * - clamdscan, clamconf, milter |
|
23 |
+ * - clamconf, milter |
|
24 | 24 |
* - clamconf: generation/verification/updating of config files and man page entries |
25 | 25 |
* - automatically generate --help pages (use the first line from the description) |
26 | 26 |
*/ |
... | ... |
@@ -44,7 +44,7 @@ |
44 | 44 |
|
45 | 45 |
#include "getopt.h" |
46 | 46 |
|
47 |
-#define MAXCMDOPTS 80 |
|
47 |
+#define MAXCMDOPTS 100 |
|
48 | 48 |
#define MAX(a,b) (a > b ? a : b) |
49 | 49 |
|
50 | 50 |
#define MATCH_NUMBER "^[0-9]+$" |
... | ... |
@@ -83,15 +83,15 @@ static const struct clam_option { |
83 | 83 |
{ NULL, "submit-stats", 0, OPT_STRING, NULL, 0, CONFDIR"/clamd.conf", 0, OPT_FRESHCLAM, "", "" }, /* Don't merge this one with SubmitDetectionStats */ |
84 | 84 |
{ NULL, "reload", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, |
85 | 85 |
{ NULL, "multiscan", 'm', OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, |
86 |
+ { NULL, "fdpass", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMDSCAN, "", "" }, |
|
86 | 87 |
{ NULL, "database", 'd', OPT_STRING, NULL, -1, DATADIR, 0, OPT_CLAMSCAN, "", "" }, /* merge it with DatabaseDirectory (and fix conflict with --datadir */ |
87 | 88 |
{ NULL, "recursive", 'r', OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" }, |
88 | 89 |
{ NULL, "bell", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" }, |
89 |
- { NULL, "no-summary", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" }, |
|
90 |
- { NULL, "infected", 'i', OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" }, |
|
91 |
- { NULL, "log", 'l', OPT_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN, "", "" }, |
|
92 |
- { NULL, "move", 0, OPT_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN, "", "" }, |
|
93 |
- { NULL, "copy", 0, OPT_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN, "", "" }, |
|
94 |
- { NULL, "remove", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN, "", "" }, |
|
90 |
+ { NULL, "no-summary", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" }, |
|
91 |
+ { NULL, "infected", 'i', OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" }, |
|
92 |
+ { NULL, "move", 0, OPT_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" }, |
|
93 |
+ { NULL, "copy", 0, OPT_STRING, NULL, -1, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" }, |
|
94 |
+ { NULL, "remove", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN, "", "" }, |
|
95 | 95 |
{ NULL, "exclude", 0, OPT_STRING, NULL, -1, NULL, 1, OPT_CLAMSCAN, "", "" }, |
96 | 96 |
{ NULL, "exclude-dir", 0, OPT_STRING, NULL, -1, NULL, 1, OPT_CLAMSCAN, "", "" }, |
97 | 97 |
{ NULL, "include", 0, OPT_STRING, NULL, -1, NULL, 1, OPT_CLAMSCAN, "", "" }, |
... | ... |
@@ -102,7 +102,7 @@ static const struct clam_option { |
102 | 102 |
{ NULL, "http-proxy", 0, OPT_STRING, NULL, 0, NULL, 0, OPT_FRESHCLAM | OPT_DEPRECATED, "", "" }, |
103 | 103 |
{ NULL, "proxy-user", 0, OPT_STRING, NULL, 0, NULL, 0, OPT_FRESHCLAM | OPT_DEPRECATED, "", "" }, |
104 | 104 |
{ NULL, "force", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, |
105 |
- { NULL, "disable-summary", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, |
|
105 |
+ { NULL, "disable-summary", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_DEPRECATED, "", "" }, |
|
106 | 106 |
{ NULL, "disable-archive", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, |
107 | 107 |
{ NULL, "no-archive", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, |
108 | 108 |
{ NULL, "no-pe", 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, |
... | ... |
@@ -129,7 +129,7 @@ static const struct clam_option { |
129 | 129 |
{ NULL, "deb", 0, OPT_STRING, NULL, -1, "foo", 0, OPT_CLAMSCAN | OPT_DEPRECATED, "", "" }, |
130 | 130 |
|
131 | 131 |
/* config file/cmdline options */ |
132 |
- { "LogFile", "log", 'l', OPT_STRING, NULL, -1, NULL, 0, OPT_CLAMD | OPT_MILTER, "Save all reports to a log file.", "/tmp/clamav.log" }, |
|
132 |
+ { "LogFile", "log", 'l', OPT_STRING, NULL, -1, NULL, 0, OPT_CLAMD | OPT_MILTER | OPT_CLAMSCAN | OPT_CLAMDSCAN, "Save all reports to a log file.", "/tmp/clamav.log" }, |
|
133 | 133 |
|
134 | 134 |
{ "LogFileUnlock", NULL, 0, OPT_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_MILTER, "By default the log file is locked for writing and only a single\ndaemon process can write to it. This option disables the lock.", "no" }, |
135 | 135 |
|
... | ... |
@@ -573,7 +573,7 @@ void optfree(struct optstruct *opts) |
573 | 573 |
return; |
574 | 574 |
} |
575 | 575 |
|
576 |
-struct optstruct *optparse(const char *cfgfile, int argc, char * const *argv, int verbose, int toolmask, struct optstruct *oldopts) |
|
576 |
+struct optstruct *optparse(const char *cfgfile, int argc, char * const *argv, int verbose, int toolmask, int ignore, struct optstruct *oldopts) |
|
577 | 577 |
{ |
578 | 578 |
FILE *fs = NULL; |
579 | 579 |
const struct clam_option *optentry; |
... | ... |
@@ -596,7 +596,7 @@ struct optstruct *optparse(const char *cfgfile, int argc, char * const *argv, in |
596 | 596 |
if(!optentry->name && !optentry->longopt) |
597 | 597 |
break; |
598 | 598 |
|
599 |
- if(optentry->owner & toolmask) { |
|
599 |
+ if((optentry->owner & toolmask) || (ignore && (optentry->owner & ignore))) { |
|
600 | 600 |
if(!oldopts && optadd(&opts, optentry->name, optentry->longopt, optentry->strarg, optentry->numarg, optentry->multiple, i) < 0) { |
601 | 601 |
fprintf(stderr, "ERROR: optparse: Can't register new option (not enough memory)\n"); |
602 | 602 |
optfree(opts); |
... | ... |
@@ -759,6 +759,21 @@ struct optstruct *optparse(const char *cfgfile, int argc, char * const *argv, in |
759 | 759 |
} |
760 | 760 |
optentry = &clam_options[opt->idx]; |
761 | 761 |
|
762 |
+ if(ignore && (optentry->owner & ignore) && !(optentry->owner & toolmask)) { |
|
763 |
+ if(cfgfile) { |
|
764 |
+ if(verbose) |
|
765 |
+ fprintf(stderr, "WARNING: Ignoring unsupported option %s at line %u\n", opt->name, line); |
|
766 |
+ } else { |
|
767 |
+ if(verbose) { |
|
768 |
+ if(optentry->shortopt) |
|
769 |
+ fprintf(stderr, "WARNING: Ignoring unsupported option --%s (-%c)\n", optentry->longopt, optentry->shortopt); |
|
770 |
+ else |
|
771 |
+ fprintf(stderr, "WARNING: Ignoring unsupported option --%s\n", optentry->longopt); |
|
772 |
+ } |
|
773 |
+ } |
|
774 |
+ continue; |
|
775 |
+ } |
|
776 |
+ |
|
762 | 777 |
if(optentry->owner & OPT_DEPRECATED) { |
763 | 778 |
if(toolmask & OPT_DEPRECATED) { |
764 | 779 |
/* FIXME: optadd() -- needed for clamconf */ |
... | ... |
@@ -53,6 +53,6 @@ const struct optstruct *optget(const struct optstruct *opts, const char *name); |
53 | 53 |
|
54 | 54 |
void optfree(struct optstruct *opts); |
55 | 55 |
|
56 |
-struct optstruct *optparse(const char *cfgfile, int argc, char * const *argv, int verbose, int toolmask, struct optstruct *oldopts); |
|
56 |
+struct optstruct *optparse(const char *cfgfile, int argc, char * const *argv, int verbose, int toolmask, int ignore, struct optstruct *oldopts); |
|
57 | 57 |
|
58 | 58 |
#endif |