aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/mailutils/mailutils.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/modules/mailutils/mailutils.c b/modules/mailutils/mailutils.c
index c75f9cd..b838317 100644
--- a/modules/mailutils/mailutils.c
+++ b/modules/mailutils/mailutils.c
@@ -560,12 +560,21 @@ create_log_stream (mu_stream_t *pstream)
# define MU_PARSE_CONFIG_PLAIN 0
#endif
+static void
+init_hints(struct mu_cfg_parse_hints *hints)
+{
+ hints->flags |= MU_PARSE_CONFIG_PLAIN |
+ MU_CFG_PARSE_SITE_RCFILE | MU_CFG_PARSE_PROGRAM;
+ hints->site_rcfile = mu_site_rcfile;
+ hints->program = (char*) mu_program_name;
+}
+
static int
mod_mailutils_init(int argc, char **argv)
{
int rc;
struct mu_cfg_tree *parse_tree = NULL;
- int cfgflags = MU_PARSE_CONFIG_PLAIN;
+ struct mu_cfg_parse_hints hints = { 0 };
mu_stream_t logstr;
struct smap_option init_option[] = {
@@ -576,9 +585,9 @@ mod_mailutils_init(int argc, char **argv)
{ SMAP_OPTSTR(onerror-reply), smap_opt_string,
&dfl_onerror_reply },
{ SMAP_OPTSTR(config-verbose), smap_opt_bitmask,
- &cfgflags, { MU_PARSE_CONFIG_VERBOSE } },
+ &hints.flags, { MU_PARSE_CONFIG_VERBOSE } },
{ SMAP_OPTSTR(config-dump), smap_opt_bitmask,
- &cfgflags, { MU_PARSE_CONFIG_DUMP } },
+ &hints.flags, { MU_PARSE_CONFIG_DUMP } },
{ NULL }
};
@@ -593,10 +602,8 @@ mod_mailutils_init(int argc, char **argv)
dbgid = smap_debug_alloc("mailutils");
if (smap_parseopt(init_option, argc, argv, 0, NULL))
return 1;
- if (cfgflags & MU_PARSE_CONFIG_VERBOSE)
- mu_cfg_parser_verbose++;
- if (cfgflags & MU_PARSE_CONFIG_DUMP)
- mu_cfg_parser_verbose++;
+
+ init_hints(&hints);
MU_AUTH_REGISTER_ALL_MODULES();
/* register the formats. */
@@ -605,14 +612,15 @@ mod_mailutils_init(int argc, char **argv)
if (init_cfg_capa())
return 1;
- rc = mu_libcfg_parse_config(&parse_tree);
+ rc = mu_cfg_parse_config(&parse_tree, &hints);
if (rc == 0)
- rc = mu_cfg_tree_reduce(parse_tree, mu_program_name,
- cfg_param, cfgflags, NULL);
+ rc = mu_cfg_tree_reduce(parse_tree, &hints, cfg_param, NULL);
mu_gocs_flush();
/* mu_gocs_flush may have reset the error stream, so restore it */
mu_stream_unref(mu_strerr);
mu_strerr = logstr;
+ mu_cfg_destroy_tree(&parse_tree);
+
return !!(rc || mu_cfg_error_count);
}
@@ -687,31 +695,32 @@ mod_mailutils_open(smap_database_t dbp)
struct _mu_smap_db *db = (struct _mu_smap_db *)dbp;
if (db->config_file) {
+ struct mu_cfg_parse_hints hints = { db->config_flags };
mu_cfg_tree_t *tree = NULL;
int rc;
+ init_hints(&hints);
if (init_cfg_capa())
return 1;
+ mu_cfg_error_count = 0;
+ mu_cfg_parser_verbose = 0;
+ if (db->config_flags & MU_PARSE_CONFIG_VERBOSE)
+ mu_cfg_parser_verbose++;
+ if (db->config_flags & MU_PARSE_CONFIG_DUMP)
+ mu_cfg_parser_verbose++;
rc = mu_cfg_parse_file(&tree, db->config_file,
- db->config_flags);
-
+ db->config_flags);
+
if (rc) {
mu_error("error parsing %s: %s", db->config_file,
mu_strerror(rc));
return 1;
}
- mu_cfg_error_count = 0;
- mu_cfg_parser_verbose = 0;
- if (db->config_flags & MU_PARSE_CONFIG_VERBOSE)
- mu_cfg_parser_verbose++;
- if (db->config_flags & MU_PARSE_CONFIG_DUMP)
- mu_cfg_parser_verbose++;
- mu_cfg_tree_postprocess(tree, db->config_flags);
+ mu_cfg_tree_postprocess(tree, &hints);
- rc = mu_cfg_tree_reduce(tree, mu_program_name, cfg_param,
- db->config_flags, NULL);
+ rc = mu_cfg_tree_reduce(tree, &hints, cfg_param, NULL);
mu_gocs_flush();
mu_cfg_destroy_tree(&tree);

Return to:

Send suggestions and report system problems to the System administrator.