aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--lib/libmf.h3
-rw-r--r--lib/version.c23
-rw-r--r--src/main.c135
-rw-r--r--src/srvcfg.c1
5 files changed, 85 insertions, 81 deletions
diff --git a/configure.ac b/configure.ac
index 73713291..0a1a1746 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,9 @@ m4_define([MF_VERSION_MINOR], 99)
m4_define([MF_VERSION_PATCH], 95)
AC_INIT([mailfromd],
MF_VERSION_MAJOR.MF_VERSION_MINOR[]m4_ifdef([MF_VERSION_PATCH],.MF_VERSION_PATCH),
- [bug-mailfromd@gnu.org.ua])
+ [bug-mailfromd@gnu.org.ua],
+ [mailfromd],
+ [http://www.gnu.org.ua/software/mailfromd])
AC_CONFIG_SRCDIR([src/mailfromd.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
diff --git a/lib/libmf.h b/lib/libmf.h
index e27e27c4..41815574 100644
--- a/lib/libmf.h
+++ b/lib/libmf.h
@@ -101,7 +101,8 @@ enum smtp_timeout {
#define SMTP_NUM_TIMEOUT (smtp_timeout_quit+1)
-void mailfromd_version(const char *progname, FILE *stream);
+struct mu_parseopt;
+void mailfromd_version(struct mu_parseopt *po, mu_stream_t stream);
int mf_vercmp(const char *a, const char *b, int *pres);
void mf_init_nls (void);
int parse_time_interval(const char *str, time_t *pint, const char **endp);
diff --git a/lib/version.c b/lib/version.c
index d4dd0485..fb0d696f 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -21,38 +21,41 @@
#include <stdio.h>
#include <gettext.h>
#define _(String) gettext(String)
+#include <mailutils/cli.h>
+#include "libmf.h"
const char mailfromd_version_etc_copyright[] =
/* Do *not* mark this string for translation. %s is a copyright
symbol suitable for this locale, and %d is the copyright
year. */
- "Copyright %s 2005, 2006, 2007, 2008, 2009, 2010 Sergey Poznyakoff";
+ "Copyright %s 2005-2016 Sergey Poznyakoff";
void
-mailfromd_version(const char *progname, FILE *stream)
+mailfromd_version(struct mu_parseopt *po, mu_stream_t stream)
{
#ifdef GIT_DESCRIBE
- fprintf (stream, "%s (%s) %s [%s]\n",
- progname, PACKAGE, PACKAGE_VERSION, GIT_DESCRIBE);
+ mu_stream_printf (stream, "%s (%s) %s [%s]\n",
+ po->po_prog_name,
+ PACKAGE, PACKAGE_VERSION, GIT_DESCRIBE);
#else
- fprintf (stream, "%s (%s) %s\n", progname, PACKAGE, PACKAGE_VERSION);
+ mu_stream_printf (stream, "%s (%s) %s\n",
+ po->po_prog_name, PACKAGE, PACKAGE_VERSION);
#endif
/* TRANSLATORS: Translate "(C)" to the copyright symbol
(C-in-a-circle), if this symbol is available in the user's
locale. Otherwise, do not translate "(C)"; leave it as-is. */
- fprintf (stream, mailfromd_version_etc_copyright, _("(C)"));
+ mu_stream_printf (stream, mailfromd_version_etc_copyright, _("(C)"));
- fputs (_("\
+ mu_stream_printf (stream, "%s", _("\
\n\
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n\
\n\
-"),
- stream);
+"));
/* TRANSLATORS: %s denotes an author name. */
- fprintf (stream, _("Written by %s.\n"), "Sergey Poznyakoff");
+ mu_stream_printf (stream, _("Written by %s.\n"), "Sergey Poznyakoff");
}
diff --git a/src/main.c b/src/main.c
index 3c4b8462..2e143011 100644
--- a/src/main.c
+++ b/src/main.c
@@ -273,7 +273,7 @@ static void
init_relayed_domains(void)
{
mu_list_foreach(relayed_domain_files, load_relay_file, NULL);
- mu_list_destroy(relayed_domain_files);
+ mu_list_destroy(&relayed_domain_files);
}
/* Command line parsing */
@@ -289,7 +289,7 @@ opt_testmode(struct mu_parseopt *po, struct mu_option *op, char const *arg)
if (arg) {
test_state = string_to_state(arg);
if (test_state == smtp_state_none) {
- mu_parseopt_error(op,
+ mu_parseopt_error(po,
_("unknown smtp state tag: %s"),
arg);
exit(po->po_exit_error);
@@ -304,7 +304,7 @@ opt_runmode(struct mu_parseopt *po, struct mu_option *op, char const *arg)
{
mode = MAILFROMD_RUN;
if (arg)
- main_function_name = arg;
+ main_function_name = mu_strdup (arg);
log_stream = "stderr";
need_script = 1;
}
@@ -395,7 +395,6 @@ opt_relayed_domain_file(struct mu_parseopt *po, struct mu_option *op,
if (!relayed_domain_files)
mu_list_create(&relayed_domain_files);
mu_list_append(relayed_domain_files, mu_strdup(arg));
- return 0;
}
static void
@@ -437,6 +436,12 @@ opt_set_milter_timeout(struct mu_parseopt *po, struct mu_option *op,
}
static void
+destroy_trace_item(void *ptr)
+{
+ free(ptr);
+}
+
+static void
opt_trace_program(struct mu_parseopt *po, struct mu_option *op,
char const *arg)
{
@@ -493,7 +498,7 @@ opt_gacopyz_log(struct mu_parseopt *po, struct mu_option *op,
{
int lev = gacopyz_string_to_log_level(arg);
if (lev == -1) {
- mu_parser_error(po, _("%s: invalid log level"), arg);
+ mu_parseopt_error(po, _("%s: invalid log level"), arg);
exit(po->po_exit_error);
}
milter_setlogmask(SMI_LOG_FROM(lev));
@@ -507,7 +512,7 @@ opt_dump_xref(struct mu_parseopt *po, struct mu_option *op,
log_stream = "stderr";
}
-static struct mu_option options[] = {
+static struct mu_option mailfromd_options[] = {
MU_OPTION_GROUP(N_("Operation modifiers")),
{ "test", 't', N_("HANDLER"), MU_OPTION_ARG_OPTIONAL,
N_("run in test mode"),
@@ -598,10 +603,10 @@ static struct mu_option options[] = {
{ "dump-grammar-trace", 0, NULL, MU_OPTION_DEFAULT,
N_("dump grammar traces"),
- mu_c_string, NULL, opt_dump_grammar_trace }
+ mu_c_string, NULL, opt_dump_grammar_trace },
{ "dump-lex-trace", 0, NULL, MU_OPTION_DEFAULT,
N_("dump lexical analyzer traces"),
- mu_c_string, NULL, opt_dump_lex_trace }
+ mu_c_string, NULL, opt_dump_lex_trace },
{ "dump-tree", 0, NULL, MU_OPTION_DEFAULT,
N_("dump parser tree"),
mu_c_string, NULL, opt_dump_tree },
@@ -620,7 +625,7 @@ static struct mu_option options[] = {
mu_c_bool, &stack_trace_option },
MU_OPTION_END
-};
+}, *options[] = { mailfromd_options, NULL };
static int
validate_options()
@@ -636,26 +641,8 @@ flush_trace_module(void *item, void *data)
return 0;
}
-static void
-flush_arguments(struct arguments *args)
-{
- if (trace_option != ARG_UNSET)
- do_trace = trace_option;
- if (trace_modules) {
- mu_list_foreach(trace_modules, flush_trace_module, NULL);
- mu_list_destroy(&trace_modules);
- }
-}
-
-static void
-destroy_trace_item(void *ptr)
-{
- free(ptr);
-}
-
-static const char *capa[] = {
+static char *capa[] = {
"auth",
- "common",
"debug",
"logging",
"locking",
@@ -663,18 +650,8 @@ static const char *capa[] = {
NULL
};
-static struct argp argp = {
- options,
- parse_opt,
- args_doc,
- doc,
- NULL,
- NULL,
- NULL
-};
-
-/* Mailutils-2.0 configuration */
+/* Mailutils configuration */
static int
cb_milter_timeout(void *data, mu_config_value_t *arg)
@@ -850,27 +827,27 @@ cb_relayed_domain_file(void *data, mu_config_value_t *val)
struct mu_cfg_param mf_cfg_param[] = {
{ ".mfd:server", mu_cfg_section, NULL, 0, NULL, NULL },
- { "stack-trace", mu_cfg_bool, &stack_trace_option, 0, NULL,
+ { "stack-trace", mu_c_bool, &stack_trace_option, 0, NULL,
N_("Dump stack traces on runtime errors.") },
{ "milter-timeout", mu_cfg_callback, NULL, 0, cb_milter_timeout,
N_("Set milter timeout."),
- N_("time") },
- { "callout-url", mu_cfg_string, &callout_server_url, 0, NULL,
+ N_("time: interval") },
+ { "callout-url", mu_c_string, &callout_server_url, 0, NULL,
N_("Sets the URL of the default callout server."),
N_("url") },
{ "include-path", mu_cfg_callback, NULL, 0, cb_include_path,
N_("Add directories to the list of directories to be searched for "
"header files. Argument is a list of directory names "
"separated by colons."),
- N_("path") },
+ N_("path: string") },
{ "setvar", mu_cfg_callback, NULL, 0, cb_set_variable,
N_("Initialize a mailfromd variable <var> to <value>."),
N_("var: string> <value: string-or-number") },
- { "script-file", mu_cfg_string, &script_file, 0, NULL,
+ { "script-file", mu_c_string, &script_file, 0, NULL,
N_("Read filter script from <file>."),
N_("file") },
- { "trace-actions", mu_cfg_bool, &do_trace, 0, NULL,
+ { "trace-actions", mu_c_bool, &do_trace, 0, NULL,
N_("Trace executed actions.") },
{ "trace-program", mu_cfg_callback, NULL, 0, cb_trace_program,
N_("Enable filter program tracing."),
@@ -891,7 +868,7 @@ struct mu_cfg_param mf_cfg_param[] = {
N_("Set the time span between the two DBM locking attempts."),
N_("time") },
- { "max-match-mx", mu_cfg_size, &max_match_mx, 0, NULL,
+ { "max-match-mx", mu_c_size, &max_match_mx, 0, NULL,
N_("Maximum number of MXs used by MFL \"mx match\" operation.") },
{ "runtime", mu_cfg_section, NULL },
@@ -1030,12 +1007,6 @@ mailfromd_show_defaults()
db_format_enumerate(db_format_enumerator, NULL);
}
-static void
-version(FILE *stream, struct argp_state *state)
-{
- mailfromd_version("mailfromd", stream);
-}
-
static int
argpflag(int argc, char **argv)
{
@@ -1155,15 +1126,46 @@ mailfromd_alloc_die()
}
extern char **environ;
-extern char *program_invocation_short_name;//FIXME
+struct mu_cli_setup cli = {
+ .optv = options,
+ .cfg = mf_cfg_param,
+ .prog_doc = prog_doc,
+ .prog_args = args_doc
+};
+
+int
+mf_getopt(struct mu_cli_setup *cli, int *pargc, char ***pargv, char **capa)
+{
+ struct mu_parseopt pohint;
+ struct mu_cfg_parse_hints cfhint;
+
+ cfhint.site_rcfile = DEFAULT_CONFIG_FILE;
+ cfhint.flags = MU_CFG_PARSE_SITE_RCFILE;
+
+ pohint.po_flags = 0;
+
+ pohint.po_package_name = PACKAGE_NAME;
+ pohint.po_flags |= MU_PARSEOPT_PACKAGE_NAME;
+
+ pohint.po_package_url = PACKAGE_URL;
+ pohint.po_flags |= MU_PARSEOPT_PACKAGE_URL;
+
+ pohint.po_bug_address = PACKAGE_BUGREPORT;
+ pohint.po_flags |= MU_PARSEOPT_BUG_ADDRESS;
+
+ pohint.po_version_hook = mailfromd_version;
+ pohint.po_flags |= MU_PARSEOPT_VERSION_HOOK;
+
+ mu_cli_ext (*pargc, *pargv, cli, &pohint, &cfhint, capa, NULL,
+ pargc, pargv);
+}
+
int
main(int argc, char **argv)
{
int rc;
- int index;
prog_counter_t entry_point;
- struct arguments args;
int stderr_is_closed = stderr_closed_p();
mf_init_nls();
@@ -1173,9 +1175,6 @@ main(int argc, char **argv)
MU_AUTH_REGISTER_ALL_MODULES();
mu_register_all_formats();
mu_register_all_mailer_formats();
- if (!program_invocation_short_name)
- program_invocation_short_name = argv[0];
- argp_program_version_hook = version;
yy_flex_debug = 0;
/* Initialize milter */
@@ -1198,7 +1197,6 @@ main(int argc, char **argv)
db_format_setup();
include_path_setup();
pragma_setup();
- mf_init_lock_options();
mf_server_save_cmdline(argc, argv);
@@ -1208,25 +1206,26 @@ main(int argc, char **argv)
srvman_init();
mf_srvcfg_init(argv[0], "(milter | callout)");
- mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">");
- mu_site_rcfile = DEFAULT_CONFIG_FILE;
- init_arguments(&args);
- rc = mu_app_init(&argp, capa, mf_cfg_param, argc, argv,
- argpflag(argc, argv), &index, &args);
+ mf_getopt(&cli, &argc, &argv, capa);
+
if (validate_options())
exit(EX_USAGE);
if (rc)
exit(EX_CONFIG);
init_relayed_domains();
- flush_arguments(&args);
+
+ if (trace_option != ARG_UNSET)
+ do_trace = trace_option;
+ if (trace_modules) {
+ mu_list_foreach(trace_modules, flush_trace_module, NULL);
+ mu_list_destroy(&trace_modules);
+ }
+
mf_srvcfg_flush();
alloc_ext_pp();
- argv += index;
- argc -= index;
-
if (need_script) {
char *new_script = NULL;
if (argc) {
diff --git a/src/srvcfg.c b/src/srvcfg.c
index 68c89081..b6a8f92a 100644
--- a/src/srvcfg.c
+++ b/src/srvcfg.c
@@ -737,7 +737,6 @@ mf_srvcfg_flush()
{
int i;
- mf_optcache_flush();
if (transcript_option)
smtp_transcript = transcript_option;

Return to:

Send suggestions and report system problems to the System administrator.