aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-03-07 15:52:54 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-03-07 15:52:54 +0200
commite473ab7df422543a458a1226b1dd8e5febea2c35 (patch)
tree3e31e4ba702c090144daf1a277f6867ce2063a88
parentdc600bc236006a0ad672d2f07145576a7584bab5 (diff)
downloadmailfromd-e473ab7df422543a458a1226b1dd8e5febea2c35.tar.gz
mailfromd-e473ab7df422543a458a1226b1dd8e5febea2c35.tar.bz2
Sync with MU commit 4bcd5c9de0cb6ca85bcc3a35b1518739b939b009.
* lib/appinit.c: Remove. * lib/Makefile.am (libmf_a_SOURCES): Remove appinit.c * lib/libmf.h (mu_app_rcfile, mfd_app_init): Remove. * src/calloutd.c (main): Use mu_app_init. Set mu_site_rcfile beforehand. * src/main.c (main): Likewise. * src/mfdbtool.c (main): Likewise.
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/appinit.c172
-rw-r--r--lib/libmf.h11
-rw-r--r--src/calloutd.c6
-rw-r--r--src/main.c6
-rw-r--r--src/mfdbtool.c6
6 files changed, 9 insertions, 193 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 71d8d18b..d3854538 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -30,7 +30,6 @@ EXTRA_DIST = syslog_async.c
SYSLOG_ASYNC_O=syslog_async.o
libmf_a_SOURCES=\
- appinit.c\
close-fds.c\
dns.c\
dict.c\
diff --git a/lib/appinit.c b/lib/appinit.c
deleted file mode 100644
index add05224..00000000
--- a/lib/appinit.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* This file is part of Mailfromd.
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Sergey
- Poznyakoff
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/libargp.h>
-#include <mailutils/gocs.h>
-#include "libmf.h"
-
-extern struct mu_cfg_tree *mu_argp_tree;
-
-char *mu_app_rcfile;
-
-static char *
-get_canonical_name ()
-{
- char *name;
- size_t len;
- char *p = strchr (argp_program_version, ' ');
- if (!p)
- return strdup (mu_program_name);
- len = p - argp_program_version;
- name = malloc (len + 1);
- if (!name)
- abort ();
- memcpy (name, argp_program_version, len);
- name[len] = 0;
- return name;
-}
-
-static void
-fixup_capa (char **excapa)
-{
- char **p, **q;
-
- for (p = q = excapa; *q; q++)
- {
- if (**q != '.')
- *p++ = *q;
- }
- *p = NULL;
-}
-
-int
-mfd_app_init (struct argp *myargp, const char **capa,
- struct mu_cfg_param *cfg_param,
- int argc, char **argv, int flags, int *pindex,
- void *opt_data, void *cfg_data)
-{
- int rc, i;
- struct argp *argp;
- struct argp argpnull = { 0 };
- char **excapa;
- struct mu_cfg_tree *parse_tree = NULL;
- struct mu_cfg_parse_hints hints = { MU_PARSE_CONFIG_PLAIN };
-
- mu_set_program_name (argv[0]);
- mu_log_tag = (char*)mu_program_name;
- mu_stdstream_setup ();
- mu_libargp_init ();
- if (capa)
- for (i = 0; capa[i]; i++)
- mu_gocs_register_std (capa[i]);
- if (!myargp)
- myargp = &argpnull;
- argp = mu_argp_build (myargp, &excapa);
-
- fixup_capa (excapa);
-
- mu_cfg_tree_create (&mu_argp_tree);
- rc = argp_parse (argp, argc, argv, flags, pindex, opt_data);
- mu_argp_done (argp);
- if (rc)
- return rc;
-
- /* Reset program name, it may have been changed using the `--program-name'
- option. */
- mu_set_program_name (program_invocation_name);
-
- mu_libcfg_init (excapa);
- free (excapa);
-
- if (mu_help_config_mode)
- {
- char *comment;
- char *canonical_name = get_canonical_name ();
- mu_stream_t stream;
- mu_stdio_stream_create (&stream, MU_STDOUT_FD, 0);
- asprintf (&comment,
- _("This is a template for %s: the configuration file for %s."),
- mu_app_rcfile, canonical_name);
- mu_cfg_format_docstring (stream, comment, 0);
- free (comment);
- asprintf (&comment, "For more information, use `info %s'.",
- canonical_name);
- mu_cfg_format_docstring (stream, comment, 0);
- free (comment);
-
- mu_format_config_tree (stream, cfg_param);
- mu_stream_destroy (&stream);
- exit (0);
- }
-
- /* Set up hints */
- if (mu_cfg_parser_verbose)
- hints.flags |= MU_PARSE_CONFIG_VERBOSE;
- if (mu_cfg_parser_verbose > 1)
- hints.flags |= MU_PARSE_CONFIG_DUMP;
-
- if (mu_load_site_rcfile)
- {
- hints.flags |= MU_CFG_PARSE_SITE_RCFILE;
- hints.site_rcfile = mu_app_rcfile;
- }
- if (mu_load_user_rcfile && mu_program_name)
- {
- hints.flags |= MU_CFG_PARSE_PROGRAM;
- hints.program = (char*) mu_program_name;
- }
- if (mu_load_rcfile)
- {
- hints.flags |= MU_CFG_PARSE_CUSTOM_RCFILE;
- hints.custom_rcfile = mu_load_rcfile;
- }
-
- rc = mu_cfg_parse_config (&parse_tree, &hints);
- if (rc == 0)
- {
- if (mu_cfg_parser_verbose)
- hints.flags |= MU_PARSE_CONFIG_VERBOSE;
- if (mu_cfg_parser_verbose > 1)
- hints.flags |= MU_PARSE_CONFIG_DUMP;
- mu_cfg_tree_postprocess (mu_argp_tree, &hints);
- mu_cfg_tree_union (&parse_tree, &mu_argp_tree);
- rc = mu_cfg_tree_reduce (parse_tree, &hints, cfg_param, cfg_data);
- }
-
- if (mu_rcfile_lint)
- {
- if (rc || mu_cfg_error_count)
- exit (1);
- if (mu_app_cfg_verifier)
- rc = mu_app_cfg_verifier ();
- exit (rc ? 1 : 0);
- }
-
- mu_gocs_flush ();
- mu_cfg_destroy_tree (&mu_argp_tree);
- mu_cfg_destroy_tree (&parse_tree);
-
- return !!(rc || mu_cfg_error_count);
-}
-
diff --git a/lib/libmf.h b/lib/libmf.h
index 9ff51c39..130a2cc1 100644
--- a/lib/libmf.h
+++ b/lib/libmf.h
@@ -200,17 +200,6 @@ char *transform_string (transform_t tf, const char *input,
void close_fds_above(int fd);
void close_fds_except(fd_set *exfd);
-/* appinit.c */
-
-extern char *mu_app_rcfile;
-
-struct argp;
-int mfd_app_init (struct argp *myargp, const char **capa,
- struct mu_cfg_param *cfg_param,
- int argc, char **argv, int flags, int *pindex,
- void *app_data, void *cfg_data);
-
-
/* logger.c */
#ifdef DEFAULT_SYSLOG_ASYNC
# define DEFAULT_LOG_STREAM "syslog:async"
diff --git a/src/calloutd.c b/src/calloutd.c
index 663732b3..6d51ed68 100644
--- a/src/calloutd.c
+++ b/src/calloutd.c
@@ -135,9 +135,9 @@ main(int argc, char **argv)
mf_srvcfg_init(argv[0], NULL);
mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">");
- mu_app_rcfile = SYSCONFDIR "/calloutd.conf";
- rc = mfd_app_init(&argp, capa, callout_cfg_param, argc, argv,
- 0, NULL, NULL, NULL);
+ mu_site_rcfile = SYSCONFDIR "/calloutd.conf";
+ rc = mu_app_init(&argp, capa, callout_cfg_param, argc, argv,
+ 0, NULL, NULL);
if (rc)
exit(EX_CONFIG);
mf_srvcfg_flush();
diff --git a/src/main.c b/src/main.c
index 5ac3d8fd..01fd14b6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1160,10 +1160,10 @@ main(int argc, char **argv)
mf_srvcfg_init(argv[0], N_("(milter | callout)"));
mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">");
- mu_app_rcfile = DEFAULT_CONFIG_FILE;
+ mu_site_rcfile = DEFAULT_CONFIG_FILE;
init_arguments(&args);
- rc = mfd_app_init(&argp, capa, mf_cfg_param, argc, argv,
- argpflag(argc, argv), &index, &args, NULL);
+ rc = mu_app_init(&argp, capa, mf_cfg_param, argc, argv,
+ argpflag(argc, argv), &index, &args);
if (rc)
exit(EX_CONFIG);
flush_arguments(&args);
diff --git a/src/mfdbtool.c b/src/mfdbtool.c
index 6d63a447..77e2bb64 100644
--- a/src/mfdbtool.c
+++ b/src/mfdbtool.c
@@ -441,10 +441,10 @@ main(int argc, char **argv)
mf_optcache_add(option_cache, 0, MF_OCF_NULL|MF_OCF_STATIC);
mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">");
- mu_app_rcfile = SYSCONFDIR "/mfdbtool.conf";
/* FIXME: Use mailfromd.conf somehow? */
- rc = mfd_app_init(&argp, capa, callout_cfg_param, argc, argv,
- 0, &index, NULL, NULL);
+ mu_site_rcfile = SYSCONFDIR "/mfdbtool.conf";
+ rc = mu_app_init(&argp, capa, callout_cfg_param, argc, argv,
+ 0, &index, NULL);
if (rc)
exit(EX_CONFIG);

Return to:

Send suggestions and report system problems to the System administrator.