Browse code

shared/optparser.c, clamav-milter: use the new option parser (bb#1215)

git-svn: trunk@4588

Tomasz Kojm authored on 2009/01/03 00:30:17
Showing 12 changed files
... ...
@@ -1,5 +1,9 @@
1 1
 Fri Jan  2 13:08:09 CET 2009 (tk)
2 2
 ---------------------------------
3
+ * shared/optparser.c, clamav-milter: use the new option parser (bb#1215)
4
+
5
+Fri Jan  2 13:08:09 CET 2009 (tk)
6
+---------------------------------
3 7
  * shared/optparser.c, sigtool: use the new option parser (bb#1215)
4 8
 
5 9
 Thu Jan  1 22:56:40 EET 2009 (edwin)
... ...
@@ -22,16 +22,14 @@ if HAVE_MILTER
22 22
 sbin_PROGRAMS = clamav-milter
23 23
 
24 24
 clamav_milter_SOURCES = \
25
-    $(top_srcdir)/shared/cfgparser.c \
26
-    $(top_srcdir)/shared/cfgparser.h \
25
+    $(top_srcdir)/shared/optparser.c \
26
+    $(top_srcdir)/shared/optparser.h \
27 27
     $(top_srcdir)/shared/output.c \
28 28
     $(top_srcdir)/shared/output.h \
29 29
     $(top_srcdir)/shared/getopt.c \
30 30
     $(top_srcdir)/shared/getopt.h \
31 31
     $(top_srcdir)/shared/misc.c \
32 32
     $(top_srcdir)/shared/misc.h \
33
-    $(top_srcdir)/shared/options.c \
34
-    $(top_srcdir)/shared/options.h \
35 33
     whitelist.c \
36 34
     whitelist.h \
37 35
     connpool.c \
... ...
@@ -72,20 +72,18 @@ CONFIG_CLEAN_FILES =
72 72
 am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"
73 73
 sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
74 74
 PROGRAMS = $(sbin_PROGRAMS)
75
-am__clamav_milter_SOURCES_DIST = $(top_srcdir)/shared/cfgparser.c \
76
-	$(top_srcdir)/shared/cfgparser.h $(top_srcdir)/shared/output.c \
75
+am__clamav_milter_SOURCES_DIST = $(top_srcdir)/shared/optparser.c \
76
+	$(top_srcdir)/shared/optparser.h $(top_srcdir)/shared/output.c \
77 77
 	$(top_srcdir)/shared/output.h $(top_srcdir)/shared/getopt.c \
78 78
 	$(top_srcdir)/shared/getopt.h $(top_srcdir)/shared/misc.c \
79
-	$(top_srcdir)/shared/misc.h $(top_srcdir)/shared/options.c \
80
-	$(top_srcdir)/shared/options.h whitelist.c whitelist.h \
81
-	connpool.c connpool.h netcode.c netcode.h clamfi.c clamfi.h \
79
+	$(top_srcdir)/shared/misc.h whitelist.c whitelist.h connpool.c \
80
+	connpool.h netcode.c netcode.h clamfi.c clamfi.h \
82 81
 	clamav-milter.c
83 82
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@am_clamav_milter_OBJECTS =  \
84
-@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	cfgparser.$(OBJEXT) \
83
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	optparser.$(OBJEXT) \
85 84
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	output.$(OBJEXT) \
86 85
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	getopt.$(OBJEXT) \
87 86
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	misc.$(OBJEXT) \
88
-@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	options.$(OBJEXT) \
89 87
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	whitelist.$(OBJEXT) \
90 88
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	connpool.$(OBJEXT) \
91 89
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@	netcode.$(OBJEXT) \
... ...
@@ -270,16 +268,14 @@ target_vendor = @target_vendor@
270 270
 top_builddir = @top_builddir@
271 271
 top_srcdir = @top_srcdir@
272 272
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@clamav_milter_SOURCES = \
273
-@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/cfgparser.c \
274
-@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/cfgparser.h \
273
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/optparser.c \
274
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/optparser.h \
275 275
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/output.c \
276 276
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/output.h \
277 277
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/getopt.c \
278 278
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/getopt.h \
279 279
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/misc.c \
280 280
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/misc.h \
281
-@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/options.c \
282
-@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    $(top_srcdir)/shared/options.h \
283 281
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    whitelist.c \
284 282
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    whitelist.h \
285 283
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@    connpool.c \
... ...
@@ -381,14 +377,13 @@ mostlyclean-compile:
381 381
 distclean-compile:
382 382
 	-rm -f *.tab.c
383 383
 
384
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgparser.Po@am__quote@
385 384
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamav-milter.Po@am__quote@
386 385
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamfi.Po@am__quote@
387 386
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connpool.Po@am__quote@
388 387
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
389 388
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@
390 389
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netcode.Po@am__quote@
391
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
390
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optparser.Po@am__quote@
392 391
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@
393 392
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/whitelist.Po@am__quote@
394 393
 
... ...
@@ -413,19 +408,19 @@ distclean-compile:
413 413
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
414 414
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
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
 output.o: $(top_srcdir)/shared/output.c
431 431
 @am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT output.o -MD -MP -MF $(DEPDIR)/output.Tpo -c -o output.o `test -f '$(top_srcdir)/shared/output.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/output.c
... ...
@@ -469,20 +464,6 @@ misc.obj: $(top_srcdir)/shared/misc.c
469 469
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
470 470
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o misc.obj `if test -f '$(top_srcdir)/shared/misc.c'; then $(CYGPATH_W) '$(top_srcdir)/shared/misc.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/shared/misc.c'; fi`
471 471
 
472
-options.o: $(top_srcdir)/shared/options.c
473
-@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
474
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/options.Tpo $(DEPDIR)/options.Po
475
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_srcdir)/shared/options.c' object='options.o' libtool=no @AMDEPBACKSLASH@
476
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
477
-@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
478
-
479
-options.obj: $(top_srcdir)/shared/options.c
480
-@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`
481
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/options.Tpo $(DEPDIR)/options.Po
482
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(top_srcdir)/shared/options.c' object='options.obj' libtool=no @AMDEPBACKSLASH@
483
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
484
-@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`
485
-
486 472
 mostlyclean-libtool:
487 473
 	-rm -f *.lo
488 474
 
... ...
@@ -34,9 +34,8 @@
34 34
 
35 35
 #include "clamav.h"
36 36
 
37
-#include "shared/options.h"
38 37
 #include "shared/output.h"
39
-#include "shared/cfgparser.h"
38
+#include "shared/optparser.h"
40 39
 #include "shared/misc.h"
41 40
 
42 41
 #include "connpool.h"
... ...
@@ -64,91 +63,79 @@ struct smfiDesc descr = {
64 64
 };
65 65
 
66 66
 int main(int argc, char **argv) {
67
-    static struct cfgstruct *copt;
68
-    char *my_socket;
69
-    const struct cfgstruct *cpt;
70
-    struct optstruct *opt;
71
-    const char *short_options = "c:hV";
72
-    static struct option long_options[] = {
73
-	{"config-file", required_argument, NULL, 'c'},
74
-	{"help", no_argument, NULL, 'h'},
75
-	{"version", no_argument, NULL, 'V'},
76
-	{NULL, 0, NULL, 0}
77
-    };
78
-    const char *my_conf = CONFDIR "/clamav-milter.conf";
67
+    char *my_socket, *pt;
68
+    const struct optstruct *opt;
69
+    struct optstruct *opts;
79 70
     int ret;
80 71
 
81
-    opt = opt_parse(argc, argv, short_options, long_options, NULL, NULL);	
82
-    if (!opt) {
83
-	mprintf("!Can't parse the command line\n");
72
+    opts = optparse(NULL, argc, argv, 1, OPT_MILTER, 0, NULL);
73
+    if (!opts) {
74
+	mprintf("!Can't parse command line options\n");
84 75
 	return 1;
85 76
     }
86 77
 
87
-    if(opt_check(opt, "help")) {
78
+    if(optget(opts, "help")->enabled) {
88 79
 	printf("Usage: %s [-c <config-file>]\n\n", argv[0]);
89 80
 	printf("    --help                   -h       Show this help\n");
90 81
 	printf("    --version                -V       Show version and exit\n");
91 82
 	printf("    --config-file <file>     -c       Read configuration from file\n\n");
92
-	opt_free(opt);
83
+	optfree(opts);
93 84
 	return 0;
94 85
     }
95 86
 	
96
-    if(opt->filename)
97
-	mprintf("^Ignoring option %s\n", opt->filename);
87
+    if(opts->filename)
88
+	mprintf("^Ignoring option %s\n", opts->filename);
98 89
 
99
-    if(opt_check(opt, "version")) {
90
+    if(optget(opts, "version")->enabled) {
100 91
 	printf("clamav-milter %s\n", get_version());
101
-	opt_free(opt);
92
+	optfree(opts);
102 93
 	return 0;
103 94
     }
104 95
 
105
-    if(opt_check(opt, "config-file"))
106
-	my_conf = opt_arg(opt, "config-file");
107
-
108
-    if((copt = getcfg(my_conf, 1, OPT_MILTER)) == NULL) {
109
-	printf("%s: cannot parse config file %s\n", argv[0], my_conf);
110
-	opt_free(opt);
96
+    pt = strdup(optget(opts, "config-file")->strarg);
97
+    if((opts = optparse(pt, 0, NULL, 1, OPT_MILTER, 0, opts)) == NULL) {
98
+	printf("%s: cannot parse config file %s\n", argv[0], pt);
99
+	free(pt);
111 100
 	return 1;
112 101
     }
102
+    free(pt);
113 103
 
114
-    opt_free(opt);
115
-
116
-    if((cpt = cfgopt(copt, "Chroot"))->enabled) {
117
-	if(chdir(cpt->strarg) != 0) {
118
-	    logg("!Cannot change directory to %s\n", cpt->strarg);
104
+    if((opt = optget(opts, "Chroot"))->enabled) {
105
+	if(chdir(opt->strarg) != 0) {
106
+	    logg("!Cannot change directory to %s\n", opt->strarg);
119 107
 	    return 1;
120 108
 	}
121
-	if(chroot(cpt->strarg) != 0) {
122
-	    logg("!chroot to %s failed. Are you root?\n", cpt->strarg);
109
+	if(chroot(opt->strarg) != 0) {
110
+	    logg("!chroot to %s failed. Are you root?\n", opt->strarg);
123 111
 	    return 1;
124 112
 	}
125 113
     }
126 114
 
127
-    if(geteuid() == 0 && (cpt = cfgopt(copt, "User"))->enabled) {
115
+    if(geteuid() == 0 && (opt = optget(opts, "User"))->enabled) {
128 116
         struct passwd *user = NULL;
129
-	if((user = getpwnam(cpt->strarg)) == NULL) {
130
-	    fprintf(stderr, "ERROR: Can't get information about user %s.\n", cpt->strarg);
131
-	    freecfg(copt);
117
+	if((user = getpwnam(opt->strarg)) == NULL) {
118
+	    fprintf(stderr, "ERROR: Can't get information about user %s.\n", opt->strarg);
119
+	    optfree(opts);
132 120
 	    return 1;
133 121
 	}
134 122
 
135
-	if(cfgopt(copt, "AllowSupplementaryGroups")->enabled) {
123
+	if(optget(opts, "AllowSupplementaryGroups")->enabled) {
136 124
 #ifdef HAVE_INITGROUPS
137
-	    if(initgroups(cpt->strarg, user->pw_gid)) {
125
+	    if(initgroups(opt->strarg, user->pw_gid)) {
138 126
 		fprintf(stderr, "ERROR: initgroups() failed.\n");
139
-		freecfg(copt);
127
+		optfree(opts);
140 128
 		return 1;
141 129
 	    }
142 130
 #else
143 131
 	    mprintf("!AllowSupplementaryGroups: initgroups() is not available, please disable AllowSupplementaryGroups\n");
144
-	    freecfg(copt);
132
+	    optfree(opts);
145 133
 	    return 1;
146 134
 #endif
147 135
 	} else {
148 136
 #ifdef HAVE_SETGROUPS
149 137
 	    if(setgroups(1, &user->pw_gid)) {
150 138
 		fprintf(stderr, "ERROR: setgroups() failed.\n");
151
-		freecfg(copt);
139
+		optfree(opts);
152 140
 		return 1;
153 141
 	    }
154 142
 #endif
... ...
@@ -156,50 +143,50 @@ int main(int argc, char **argv) {
156 156
 
157 157
 	if(setgid(user->pw_gid)) {
158 158
 	    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
159
-	    freecfg(copt);
159
+	    optfree(opts);
160 160
 	    return 1;
161 161
 	}
162 162
 
163 163
 	if(setuid(user->pw_uid)) {
164 164
 	    fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid);
165
-	    freecfg(copt);
165
+	    optfree(opts);
166 166
 	    return 1;
167 167
 	}
168 168
     }
169 169
 
170
-    logg_lock = !cfgopt(copt, "LogFileUnlock")->enabled;
171
-    logg_time = cfgopt(copt, "LogTime")->enabled;
172
-    logg_size = cfgopt(copt, "LogFileMaxSize")->numarg;
173
-    logg_verbose = mprintf_verbose = cfgopt(copt, "LogVerbose")->enabled;
170
+    logg_lock = !optget(opts, "LogFileUnlock")->enabled;
171
+    logg_time = optget(opts, "LogTime")->enabled;
172
+    logg_size = optget(opts, "LogFileMaxSize")->numarg;
173
+    logg_verbose = mprintf_verbose = optget(opts, "LogVerbose")->enabled;
174 174
 
175
-    if((cpt = cfgopt(copt, "LogFile"))->enabled) {
175
+    if((opt = optget(opts, "LogFile"))->enabled) {
176 176
 	time_t currtime;
177
-	logg_file = cpt->strarg;
177
+	logg_file = opt->strarg;
178 178
 	if(strlen(logg_file) < 2 || logg_file[0] != '/') {
179 179
 	    fprintf(stderr, "ERROR: LogFile requires full path.\n");
180 180
 	    logg_close();
181
-	    freecfg(copt);
181
+	    optfree(opts);
182 182
 	    return 1;
183 183
 	}
184 184
 	time(&currtime);
185 185
 	if(logg("#+++ Started at %s", ctime(&currtime))) {
186 186
 	    fprintf(stderr, "ERROR: Can't initialize the internal logger\n");
187 187
 	    logg_close();
188
-	    freecfg(copt);
188
+	    optfree(opts);
189 189
 	    return 1;
190 190
 	}
191 191
     } else
192 192
 	logg_file = NULL;
193 193
 
194 194
 #if defined(USE_SYSLOG) && !defined(C_AIX)
195
-    if(cfgopt(copt, "LogSyslog")->enabled) {
195
+    if(optget(opts, "LogSyslog")->enabled) {
196 196
 	int fac;
197 197
 
198
-	cpt = cfgopt(copt, "LogFacility");
199
-	if((fac = logg_facility(cpt->strarg)) == -1) {
200
-	    logg("!LogFacility: %s: No such facility.\n", cpt->strarg);
198
+	opt = optget(opts, "LogFacility");
199
+	if((fac = logg_facility(opt->strarg)) == -1) {
200
+	    logg("!LogFacility: %s: No such facility.\n", opt->strarg);
201 201
 	    logg_close();
202
-	    freecfg(copt);
202
+	    optfree(opts);
203 203
 	    return 1;
204 204
 	}
205 205
 
... ...
@@ -208,23 +195,23 @@ int main(int argc, char **argv) {
208 208
     }
209 209
 #endif
210 210
 
211
-    if((cpt = cfgopt(copt, "TemporaryDirectory"))->enabled)
212
-	tempdir = cpt->strarg;
211
+    if((opt = optget(opts, "TemporaryDirectory"))->enabled)
212
+	tempdir = opt->strarg;
213 213
 
214
-    if(localnets_init(copt) || init_actions(copt)) {
214
+    if(localnets_init(opts) || init_actions(opts)) {
215 215
 	logg_close();
216
-	freecfg(copt);
216
+	optfree(opts);
217 217
 	return 1;
218 218
     }
219 219
 
220
-    if((cpt = cfgopt(copt, "Whitelist"))->enabled && whitelist_init(cpt->strarg)) {
220
+    if((opt = optget(opts, "Whitelist"))->enabled && whitelist_init(opt->strarg)) {
221 221
 	localnets_free();
222 222
 	logg_close();
223
-	freecfg(copt);
223
+	optfree(opts);
224 224
 	return 1;
225 225
     }
226 226
 
227
-    if(cfgopt(copt, "AddHeader")->enabled) {
227
+    if(optget(opts, "AddHeader")->enabled) {
228 228
 	char myname[255];
229 229
 
230 230
 	if(!gethostname(myname, sizeof(myname))) {
... ...
@@ -239,12 +226,12 @@ int main(int argc, char **argv) {
239 239
     }
240 240
     
241 241
     umask(0007); /* FIXME */
242
-    if(!(my_socket = cfgopt(copt, "MilterSocket")->strarg)) {
242
+    if(!(my_socket = optget(opts, "MilterSocket")->strarg)) {
243 243
 	logg("!Please configure the MilterSocket directive\n");
244 244
 	localnets_free();
245 245
 	whitelist_free();
246 246
 	logg_close();
247
-	freecfg(copt);
247
+	optfree(opts);
248 248
 	return 1;
249 249
     }
250 250
     if(smfi_setconn(my_socket) == MI_FAILURE) {
... ...
@@ -252,7 +239,7 @@ int main(int argc, char **argv) {
252 252
 	localnets_free();
253 253
 	whitelist_free();
254 254
 	logg_close();
255
-	freecfg(copt);
255
+	optfree(opts);
256 256
 	return 1;
257 257
     }
258 258
     if(smfi_register(descr) == MI_FAILURE) {
... ...
@@ -260,55 +247,55 @@ int main(int argc, char **argv) {
260 260
 	localnets_free();
261 261
 	whitelist_free();
262 262
 	logg_close();
263
-	freecfg(copt);
263
+	optfree(opts);
264 264
 	return 1;
265 265
     }
266
-    cpt = cfgopt(copt, "FixStaleSocket");
267
-    if(smfi_opensocket(cpt->enabled) == MI_FAILURE) {
266
+    opt = optget(opts, "FixStaleSocket");
267
+    if(smfi_opensocket(opt->enabled) == MI_FAILURE) {
268 268
 	logg("!Failed to create socket %s\n", my_socket);
269 269
 	localnets_free();
270 270
 	whitelist_free();
271 271
 	logg_close();
272
-	freecfg(copt);
272
+	optfree(opts);
273 273
 	return 1;
274 274
     }
275 275
 
276
-    maxfilesize = cfgopt(copt, "MaxFileSize")->numarg;
277
-    readtimeout = cfgopt(copt, "ReadTimeout")->numarg;
276
+    maxfilesize = optget(opts, "MaxFileSize")->numarg;
277
+    readtimeout = optget(opts, "ReadTimeout")->numarg;
278 278
 
279
-    cpool_init(copt);
279
+    cpool_init(opts);
280 280
     if (!cp) {
281 281
 	logg("!Failed to init the socket pool\n");
282 282
 	localnets_free();
283 283
 	whitelist_free();
284 284
 	logg_close();
285
-	freecfg(copt);
285
+	optfree(opts);
286 286
 	return 1;
287 287
     }	
288 288
 
289
-    if(!cfgopt(copt, "Foreground")->enabled) {
289
+    if(!optget(opts, "Foreground")->enabled) {
290 290
 	if(daemonize() == -1) {
291 291
 	    logg("!daemonize() failed\n");
292 292
 	    localnets_free();
293 293
 	    whitelist_free();
294 294
 	    cpool_free();
295 295
 	    logg_close();
296
-	    freecfg(copt);
296
+	    optfree(opts);
297 297
 	    return 1;
298 298
 	}
299 299
 	if(chdir("/") == -1)
300 300
 	    logg("^Can't change current working directory to root\n");
301 301
     }
302 302
 
303
-    if((cpt = cfgopt(copt, "PidFile"))->enabled) {
303
+    if((opt = optget(opts, "PidFile"))->enabled) {
304 304
 	FILE *fd;
305 305
 	mode_t old_umask = umask(0006);
306 306
 
307
-	if((fd = fopen(cpt->strarg, "w")) == NULL) {
308
-	    logg("!Can't save PID in file %s\n", cpt->strarg);
307
+	if((fd = fopen(opt->strarg, "w")) == NULL) {
308
+	    logg("!Can't save PID in file %s\n", opt->strarg);
309 309
 	} else {
310 310
 	    if (fprintf(fd, "%u", (unsigned int)getpid())<0) {
311
-	    	logg("!Can't save PID in file %s\n", cpt->strarg);
311
+	    	logg("!Can't save PID in file %s\n", opt->strarg);
312 312
 	    }
313 313
 	    fclose(fd);
314 314
 	}
... ...
@@ -317,7 +304,7 @@ int main(int argc, char **argv) {
317 317
 
318 318
     ret = smfi_main();
319 319
 
320
-    freecfg(copt);
320
+    optfree(opts);
321 321
 
322 322
     logg_close();
323 323
     cpool_free();
... ...
@@ -30,12 +30,13 @@
30 30
 
31 31
 #include <libmilter/mfapi.h>
32 32
 
33
-#include "shared/cfgparser.h"
33
+#include "shared/optparser.h"
34 34
 #include "shared/output.h"
35 35
 
36 36
 #include "connpool.h"
37 37
 #include "netcode.h"
38 38
 #include "whitelist.h"
39
+#include "clamfi.h"
39 40
 
40 41
 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
41 42
 #define _UNUSED_ __attribute__ ((__unused__))
... ...
@@ -65,7 +66,7 @@ struct CLAMFI {
65 65
 };
66 66
 
67 67
 
68
-void add_x_header(SMFICTX *ctx, char *st) {
68
+static void add_x_header(SMFICTX *ctx, char *st) {
69 69
     smfi_chgheader(ctx, (char *)"X-Virus-Scanned", 1, xvirushdr);
70 70
     smfi_chgheader(ctx, (char *)"X-Virus-Status", 1, st);
71 71
 }
... ...
@@ -308,11 +309,11 @@ static sfsistat action_quarantine(SMFICTX *ctx) {
308 308
     return SMFIS_ACCEPT;
309 309
 }
310 310
 
311
-int init_actions(struct cfgstruct *copt) {
312
-    const struct cfgstruct *cpt;
311
+int init_actions(struct optstruct *opts) {
312
+    const struct optstruct *opt;
313 313
 
314
-    if((cpt = cfgopt(copt, "OnFail"))->enabled) {
315
-	switch(parse_action(cpt->strarg)) {
314
+    if((opt = optget(opts, "OnFail"))->enabled) {
315
+	switch(parse_action(opt->strarg)) {
316 316
 	case 0:
317 317
 	    FailAction = SMFIS_ACCEPT;
318 318
 	    break;
... ...
@@ -323,13 +324,13 @@ int init_actions(struct cfgstruct *copt) {
323 323
 	    FailAction = SMFIS_REJECT;
324 324
 	    break;
325 325
 	default:
326
-	    logg("!Invalid action %s for option OnFail", cpt->strarg);
326
+	    logg("!Invalid action %s for option OnFail", opt->strarg);
327 327
 	    return 1;
328 328
 	}
329 329
     } else FailAction = SMFIS_TEMPFAIL;
330 330
 
331
-    if((cpt = cfgopt(copt, "OnClean"))->enabled) {
332
-	switch(parse_action(cpt->strarg)) {
331
+    if((opt = optget(opts, "OnClean"))->enabled) {
332
+	switch(parse_action(opt->strarg)) {
333 333
 	case 0:
334 334
 	    CleanAction = action_accept;
335 335
 	    break;
... ...
@@ -346,13 +347,13 @@ int init_actions(struct cfgstruct *copt) {
346 346
 	    CleanAction = action_quarantine;
347 347
 	    break;
348 348
 	default:
349
-	    logg("!Invalid action %s for option OnClean", cpt->strarg);
349
+	    logg("!Invalid action %s for option OnClean", opt->strarg);
350 350
 	    return 1;
351 351
 	}
352 352
     } else CleanAction = action_accept;
353 353
 
354
-    if((cpt = cfgopt(copt, "OnInfected"))->enabled) {
355
-	switch(parse_action(cpt->strarg)) {
354
+    if((opt = optget(opts, "OnInfected"))->enabled) {
355
+	switch(parse_action(opt->strarg)) {
356 356
 	case 0:
357 357
 	    InfectedAction = action_accept;
358 358
 	    break;
... ...
@@ -369,7 +370,7 @@ int init_actions(struct cfgstruct *copt) {
369 369
 	    InfectedAction = action_quarantine;
370 370
 	    break;
371 371
 	default:
372
-	    logg("!Invalid action %s for option OnInfected", cpt->strarg);
372
+	    logg("!Invalid action %s for option OnInfected", opt->strarg);
373 373
 	    return 1;
374 374
 	}
375 375
     } else InfectedAction = action_quarantine;
... ...
@@ -1,7 +1,7 @@
1 1
 #ifndef _CLAMFI_H
2 2
 #define _CLAMFI_H
3 3
 
4
-#include "shared/cfgparser.h"
4
+#include "shared/optparser.h"
5 5
 #include <libmilter/mfapi.h>
6 6
 
7 7
 extern uint64_t maxfilesize;
... ...
@@ -15,6 +15,6 @@ sfsistat clamfi_header(SMFICTX *ctx, char *headerf, char *headerv);
15 15
 sfsistat clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr);
16 16
 sfsistat clamfi_envfrom(SMFICTX *ctx, char **argv);
17 17
 sfsistat clamfi_envrcpt(SMFICTX *ctx, char **argv);
18
-int init_actions(struct cfgstruct *copt);
18
+int init_actions(struct optstruct *opts);
19 19
 
20 20
 #endif
... ...
@@ -35,7 +35,7 @@
35 35
 #include <time.h>
36 36
 #include <netdb.h>
37 37
 
38
-#include "shared/cfgparser.h"
38
+#include "shared/optparser.h"
39 39
 #include "shared/output.h"
40 40
 
41 41
 #include "connpool.h"
... ...
@@ -126,7 +126,7 @@ static int cpool_addtcp(char *addr, char *port) {
126 126
 }
127 127
 
128 128
 
129
-int addslot(void) {
129
+static int addslot(void) {
130 130
     struct CP_ENTRY *cpe;
131 131
 
132 132
     if(!(cpe = realloc(cp->pool, (cp->entries + 1) * sizeof(struct CP_ENTRY)))) {
... ...
@@ -149,7 +149,7 @@ int addslot(void) {
149 149
 - probe dead if (last check > 2 min || no clamd available)
150 150
 */
151 151
 
152
-void cpool_probe(void) {
152
+static void cpool_probe(void) {
153 153
     unsigned int i, dead=0;
154 154
     struct CP_ENTRY *cpe = cp->pool;
155 155
     time_t now = time(NULL);
... ...
@@ -170,7 +170,7 @@ void cpool_probe(void) {
170 170
 }
171 171
 
172 172
 
173
-void *cpool_mon(_UNUSED_ void *v) {
173
+static void *cpool_mon(_UNUSED_ void *v) {
174 174
     pthread_mutex_t conv;
175 175
 
176 176
     pthread_mutex_init(&conv, NULL);
... ...
@@ -190,8 +190,8 @@ void *cpool_mon(_UNUSED_ void *v) {
190 190
 }
191 191
 
192 192
 
193
-void cpool_init(struct cfgstruct *copt) {
194
-    const struct cfgstruct *cpt;
193
+void cpool_init(struct optstruct *opts) {
194
+    const struct optstruct *opt;
195 195
     int failed = 0;
196 196
 
197 197
     if(!(cp=calloc(sizeof(*cp), 1))) {
... ...
@@ -201,9 +201,9 @@ void cpool_init(struct cfgstruct *copt) {
201 201
 
202 202
     cp->local_cpe = NULL;
203 203
 
204
-    if((cpt = cfgopt(copt, "ClamdSocket"))->enabled) {
205
-	while(cpt) {
206
-	    char *socktype = cpt->strarg;
204
+    if((opt = optget(opts, "ClamdSocket"))->enabled) {
205
+	while(opt) {
206
+	    char *socktype = opt->strarg;
207 207
 
208 208
 	    if(addslot()) return;
209 209
 	    if(!strncasecmp(socktype, "unix:", 5)) {
... ...
@@ -220,7 +220,7 @@ void cpool_init(struct cfgstruct *copt) {
220 220
 		failed = 1;
221 221
 	    }
222 222
 	    if(failed) break;
223
-	    cpt = (struct cfgstruct *) cpt->nextarg;
223
+	    opt = opt->nextarg;
224 224
 	}
225 225
 	if(failed) {
226 226
 	    cpool_free();
... ...
@@ -11,7 +11,7 @@
11 11
 #include <netinet/ip.h>
12 12
 #include <pthread.h>
13 13
 
14
-#include "shared/cfgparser.h"
14
+#include "shared/optparser.h"
15 15
 
16 16
 struct CP_ENTRY {
17 17
     struct sockaddr *server;
... ...
@@ -30,7 +30,7 @@ struct CPOOL {
30 30
     struct CP_ENTRY *pool;
31 31
 };
32 32
 
33
-void cpool_init(struct cfgstruct *copt);
33
+void cpool_init(struct optstruct *copt);
34 34
 void cpool_free(void);
35 35
 struct CP_ENTRY *cpool_get_rand(int *s);
36 36
 
... ...
@@ -38,6 +38,7 @@
38 38
 
39 39
 
40 40
 #include "shared/output.h"
41
+#include "shared/optparser.h"
41 42
 #include "libclamav/others.h"
42 43
 #include "netcode.h"
43 44
 
... ...
@@ -65,7 +66,7 @@ char *tempdir = NULL;
65 65
 long readtimeout;
66 66
 
67 67
 
68
-int nc_socket(struct CP_ENTRY *cpe) {
68
+static int nc_socket(struct CP_ENTRY *cpe) {
69 69
     int flags, s = socket(cpe->server->sa_family, SOCK_STREAM, 0);
70 70
     char er[256];
71 71
 
... ...
@@ -92,7 +93,7 @@ int nc_socket(struct CP_ENTRY *cpe) {
92 92
 }
93 93
 
94 94
 
95
-int nc_connect(int s, struct CP_ENTRY *cpe) {
95
+static int nc_connect(int s, struct CP_ENTRY *cpe) {
96 96
     time_t timeout = time(NULL) + TIMEOUT;
97 97
     int res = connect(s, cpe->server, cpe->socklen);
98 98
     struct timeval tv;
... ...
@@ -351,7 +352,7 @@ int nc_connect_rand(int *main, int *alt, int *local) {
351 351
 }
352 352
 
353 353
 
354
-int resolve(char *name, uint32_t *family, uint32_t *host) {
354
+static int resolve(char *name, uint32_t *family, uint32_t *host) {
355 355
     struct addrinfo hints, *res;
356 356
 
357 357
     if(!name) {
... ...
@@ -397,7 +398,7 @@ int resolve(char *name, uint32_t *family, uint32_t *host) {
397 397
 }
398 398
 
399 399
 
400
-struct LOCALNET *localnet(char *name, char *mask) {
400
+static struct LOCALNET *localnet(char *name, char *mask) {
401 401
     struct LOCALNET *l = (struct LOCALNET *)malloc(sizeof(*l));
402 402
     uint32_t nmask;
403 403
     unsigned int i;
... ...
@@ -505,12 +506,12 @@ void localnets_free(void) {
505 505
 }
506 506
 
507 507
 
508
-int localnets_init(struct cfgstruct *copt) {
509
-    const struct cfgstruct *cpt;
508
+int localnets_init(struct optstruct *opts) {
509
+    const struct optstruct *opt;
510 510
 
511
-    if((cpt = cfgopt(copt, "LocalNet"))->enabled) {
512
-	while(cpt) {
513
-	    char *lnetname = cpt->strarg;
511
+    if((opt = optget(opts, "LocalNet"))->enabled) {
512
+	while(opt) {
513
+	    char *lnetname = opt->strarg;
514 514
 	    struct LOCALNET *l;
515 515
 	    char *mask = strrchr(lnetname, '/');
516 516
 
... ...
@@ -525,7 +526,7 @@ int localnets_init(struct cfgstruct *copt) {
525 525
 	    }
526 526
 	    l->next = lnet;
527 527
 	    lnet = l;
528
-	    cpt = (struct cfgstruct *) cpt->nextarg;
528
+	    opt = opt->nextarg;
529 529
 	}
530 530
     }
531 531
     return 0;
... ...
@@ -4,7 +4,7 @@
4 4
 #include <sys/types.h>
5 5
 #include <sys/socket.h>
6 6
 
7
-#include "shared/cfgparser.h"
7
+#include "shared/optparser.h"
8 8
 #include "connpool.h"
9 9
 
10 10
 void nc_ping_entry(struct CP_ENTRY *cpe);
... ...
@@ -13,7 +13,7 @@ int nc_send(int s, const void *buf, size_t len);
13 13
 char *nc_recv(int s);
14 14
 int nc_sendmsg(int s, int fd);
15 15
 int nc_connect_entry(struct CP_ENTRY *cpe);
16
-int localnets_init(struct cfgstruct *copt);
16
+int localnets_init(struct optstruct *opts);
17 17
 void localnets_free(void);
18 18
 int islocalnet_name(char *name);
19 19
 int islocalnet_sock(struct sockaddr *sa);
... ...
@@ -28,6 +28,7 @@
28 28
 #include <regex.h>
29 29
 
30 30
 #include "shared/output.h"
31
+#include "whitelist.h"
31 32
 
32 33
 struct WHLST {
33 34
     regex_t preg;
... ...
@@ -75,10 +75,11 @@ static const struct clam_option {
75 75
     /* name,   longopt, sopt, argtype, regex, num, str, mul, owner, description, suggested */
76 76
 
77 77
     /* cmdline only */
78
-    { NULL, "help", 'h', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL, "", "" },
78
+    { NULL, "help", 'h', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_MILTER, "", "" },
79 79
     { NULL, "config-file", 'c', TYPE_STRING, NULL, 0, CONFDIR"/clamd.conf", FLAG_REQUIRED, OPT_CLAMD | OPT_CLAMDSCAN, "", "" },
80 80
     { NULL, "config-file", 0, TYPE_STRING, NULL, 0, CONFDIR"/freshclam.conf", FLAG_REQUIRED, OPT_FRESHCLAM, "", "" },
81
-    { NULL, "version", 'V', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL, "", "" },
81
+    { NULL, "config-file", 'c', TYPE_STRING, NULL, 0, CONFDIR"/clamav-milter.conf", FLAG_REQUIRED, OPT_MILTER, "", "" },
82
+    { NULL, "version", 'V', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_MILTER, "", "" },
82 83
     { NULL, "debug", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_SIGTOOL, "", "" },
83 84
     { NULL, "verbose", 'v', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL, "", "" },
84 85
     { NULL, "quiet", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL, "", "" },
... ...
@@ -364,40 +365,48 @@ static const struct clam_option {
364 364
     { "ArchiveLimitMemoryUsage", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_CLAMD | OPT_DEPRECATED, "", "" },
365 365
 
366 366
     /* Milter specific options */
367
-/*
368
-    {"ClamdSocket", OPT_QUOTESTR, -1, NULL, 1, OPT_MILTER},
369
-    {"MilterSocket", OPT_QUOTESTR, -1, NULL, 1, OPT_MILTER},
370
-    {"LocalNet", OPT_QUOTESTR, -1, NULL, 1, OPT_MILTER},
371
-    {"OnClean", OPT_QUOTESTR, -1, "Accept", 0, OPT_MILTER},
372
-    {"OnInfected", OPT_QUOTESTR, -1, "Quarantine", 0, OPT_MILTER},
373
-    {"OnFail", OPT_QUOTESTR, -1, "Defer", 0, OPT_MILTER},
374
-    {"AddHeader", TYPE_BOOL, 0, NULL, 0, OPT_MILTER},
375
-    {"Chroot", OPT_QUOTESTR, -1, NULL, 0, OPT_MILTER},
376
-    {"Whitelist", OPT_QUOTESTR, -1, NULL, 0, OPT_MILTER},
377
-*/
367
+
368
+    { "ClamdSocket", NULL, 0, TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_MILTER, "", "" },
369
+
370
+    { "MilterSocket",NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "", "" },
371
+
372
+    { "LocalNet", NULL, 0, TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_MILTER, "", "" },
373
+
374
+    { "OnClean", NULL, 0, TYPE_STRING, NULL, -1, "Accept", 0, OPT_MILTER, "", "" },
375
+
376
+    { "OnInfected", NULL, 0, TYPE_STRING, NULL, -1, "Quarantine", 0, OPT_MILTER, "", "" },
377
+
378
+    { "OnFail", NULL, 0, TYPE_STRING, NULL, -1, "Defer", 0, OPT_MILTER, "", "" },
379
+
380
+    { "AddHeader", NULL, 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_MILTER, "", "" },
381
+
382
+    { "Chroot", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "", "" },
383
+
384
+    { "Whitelist", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "", "" },
385
+
378 386
     /* Deprecated milter options */
379
-/*
380
-    {"ArchiveBlockEncrypted", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
381
-    {"DatabaseDirectory", OPT_QUOTESTR, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
382
-    {"Debug", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
383
-    {"DetectBrokenExecutables", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
384
-    {"LeaveTemporaryFiles", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
385
-    {"LocalSocket", OPT_QUOTESTR, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
386
-    {"MailFollowURLs", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
387
-    {"MaxScanSize", OPT_COMPSIZE, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
388
-    {"MaxFiles", OPT_NUM, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
389
-    {"MaxRecursion", OPT_NUM, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
390
-    {"PhishingSignatures", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
391
-    {"ScanArchive", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
392
-    {"ScanHTML", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
393
-    {"ScanMail", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
394
-    {"ScanOLE2", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
395
-    {"ScanPE", TYPE_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
396
-    {"StreamMaxLength", OPT_COMPSIZE, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
397
-    {"TCPAddr", OPT_QUOTESTR, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
398
-    {"TCPSocket", OPT_NUM, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
399
-    {"TemporaryDirectory", OPT_QUOTESTR, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED},
400
-*/
387
+
388
+    { "ArchiveBlockEncrypted", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
389
+    { "DatabaseDirectory", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
390
+    { "Debug", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
391
+    { "DetectBrokenExecutables", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
392
+    { "LeaveTemporaryFiles", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
393
+    { "LocalSocket", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
394
+    { "MailFollowURLs", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
395
+    { "MaxScanSize", NULL, 0, TYPE_SIZE, MATCH_SIZE, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
396
+    { "MaxFiles", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
397
+    { "MaxRecursion", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
398
+    { "PhishingSignatures", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
399
+    { "ScanArchive", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
400
+    { "ScanHTML", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
401
+    { "ScanMail", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
402
+    { "ScanOLE2", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
403
+    { "ScanPE", NULL, 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
404
+    { "StreamMaxLength", NULL, 0, TYPE_SIZE, MATCH_SIZE, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
405
+    { "TCPAddr", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
406
+    { "TCPSocket", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
407
+    { "TemporaryDirectory", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER | OPT_DEPRECATED, "", "" },
408
+
401 409
     { NULL, NULL, 0, 0, NULL, 0, NULL, 0, 0, NULL, NULL }
402 410
 };
403 411