aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-03-05 18:24:25 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-03-05 18:24:25 +0200
commitdc600bc236006a0ad672d2f07145576a7584bab5 (patch)
tree4f5eef79ea40172a9b6981f9a277e4788bb4e751
parent013f3f0998c47a99ba497a20ea0322bf0227a41c (diff)
downloadmailfromd-dc600bc236006a0ad672d2f07145576a7584bab5.tar.gz
mailfromd-dc600bc236006a0ad672d2f07145576a7584bab5.tar.bz2
Sync with MU commit ad938c5af.
* lib/appinit.c (mfd_parse_config_files): Remove. (mfd_app_init): Use new API.
-rw-r--r--lib/appinit.c113
1 files changed, 36 insertions, 77 deletions
diff --git a/lib/appinit.c b/lib/appinit.c
index 622d8563..add05224 100644
--- a/lib/appinit.c
+++ b/lib/appinit.c
@@ -47,75 +47,6 @@ get_canonical_name ()
return name;
}
-int
-mfd_parse_config_files (struct mu_cfg_param *param, void *target)
-{
- int flags = 0;
- int rc;
-
- if (mu_cfg_parser_verbose)
- flags |= MU_PARSE_CONFIG_VERBOSE;
- if (mu_cfg_parser_verbose > 1)
- flags |= MU_PARSE_CONFIG_DUMP;
-
- if (mu_load_site_rcfile)
- {
- rc = mu_parse_config (MU_CONFIG_FILE, mu_program_name, param,
- flags | MU_PARSE_CONFIG_GLOBAL, target);
- if (rc == ENOMEM)
- {
- mu_error ("%s", mu_strerror (rc));
- return rc;
- }
-
- if (mu_app_rcfile)
- {
- rc = mu_parse_config (mu_app_rcfile, mu_program_name, param,
- flags, target);
- if (rc == ENOMEM)
- {
- mu_error ("%s", mu_strerror (rc));
- return rc;
- }
- }
- }
-
- if (mu_load_user_rcfile && mu_program_name)
- {
- size_t size = 3 + strlen (mu_program_name) + 1;
- char *file_name = malloc (size);
- if (file_name)
- {
- strcpy (file_name, "~/.");
- strcat (file_name, mu_program_name);
-
- rc = mu_parse_config (file_name, mu_program_name, param, flags,
- target);
- if (rc == ENOMEM)
- {
- mu_error ("%s", mu_strerror (rc));
- return rc;
- }
-
- free (file_name);
- }
- }
-
- if (mu_load_rcfile)
- {
- rc = mu_parse_config (mu_load_rcfile, mu_program_name, param,
- flags, target);
- if (rc)
- {
- mu_error (_("errors parsing file %s: %s"), mu_load_rcfile,
- mu_strerror (rc));
- return rc;
- }
- }
-
- return 0;
-}
-
static void
fixup_capa (char **excapa)
{
@@ -139,7 +70,8 @@ mfd_app_init (struct argp *myargp, const char **capa,
struct argp *argp;
struct argp argpnull = { 0 };
char **excapa;
- int cfgflags = 0;
+ 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;
@@ -183,20 +115,45 @@ mfd_app_init (struct argp *myargp, const char **capa,
mu_cfg_format_docstring (stream, comment, 0);
free (comment);
- mu_format_config_tree (stream, mu_program_name, cfg_param, 0);
+ mu_format_config_tree (stream, cfg_param);
mu_stream_destroy (&stream);
exit (0);
}
- else
- mfd_parse_config_files (cfg_param, cfg_data);
+ /* Set up hints */
if (mu_cfg_parser_verbose)
- cfgflags |= MU_PARSE_CONFIG_VERBOSE;
+ hints.flags |= MU_PARSE_CONFIG_VERBOSE;
if (mu_cfg_parser_verbose > 1)
- cfgflags |= MU_PARSE_CONFIG_DUMP;
- rc = mu_cfg_tree_reduce (mu_argp_tree, mu_program_name, cfg_param,
- cfgflags, cfg_data);
+ 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)
@@ -208,6 +165,8 @@ mfd_app_init (struct argp *myargp, const char **capa,
mu_gocs_flush ();
mu_cfg_destroy_tree (&mu_argp_tree);
+ mu_cfg_destroy_tree (&parse_tree);
return !!(rc || mu_cfg_error_count);
}
+

Return to:

Send suggestions and report system problems to the System administrator.