Commit d39f4c2d d39f4c2db3ea8bc387cde7dcc2825598aa166ff6 by Sergey Poznyakoff

Improve configuration parsing (step 1).

Remove obsolete options (these have been made hidden in
v. 2.0).  Handle "include" and "program" after parsing
the sources, not while reducing the tree, as was
previously.  Retain, however, old functions for compatibility,
making them deprecated.  Add "query" mode to mailutils-config.

* include/mailutils/cfg.h (mu_cfg_node_tag): Remove
(mu_cfg_statement): Rename to mu_cfg_node_statement.
(mu_cfg_tree): New member: tail.
(mu_cfg_perror): Change signature.
(mu_cfg_vperror, mu_cfg_parse_error): New protos.
(MU_CFG_PATH_DELIM, MU_CFG_PATH_DELIM_STR): New defines.
(MU_PARSE_CONFIG_PLAIN,MU_CFG_FMT_LOCUS): New constant.
(MU_CFG_DEPRECATED): New macro.
(mu_parse_config,mu_get_config): Deprecated.
(mu_cfg_format_parse_tree): Change signature.
(mu_cfg_format_node, mu_cfg_parse_file): New protos.
(mu_cfg_tree_free): Remove stale proto.
(mu_cfg_find_node, mu_cfg_create_subtree): New protos.
* include/mailutils/libcfg.h (mu_libcfg_parse_config): New proto.
(mu_parse_config_files): Deprecated.

* include/mailutils/mutil.h (mu_make_file_name): New proto.
(mu_retrieve_fp, mu_register_retriever)
(mu_retrieve): Remove unused prototypes.
* include/mailutils/opool.h (mu_opool_union): New proto.

* libmu_argp/Makefile.am (libmu_argp_a_SOURCES): Remove
sources (see below):
* po/POTFILES.in: Likewise.
* libmu_argp/gsasl.c: Remove.
* libmu_argp/pam.c: Remove.
* libmu_argp/radius.c: Remove.
* libmu_argp/sql.c: Remove.
* libmu_argp/tls.c: Remove.
* libmu_argp/virtdomain.c: Remove.

* config/mailutils-config.c: New option --query (-q)
(main): Handle query mode.

* comsat/comsat.c: Define MU_CFG_COMPATIBILITY to suppress
deprecation warnings.

* bootstrap.conf (XGETTEXT_OPTIONS): Add mu_cfg
error reporting functions.

* mailbox/Makefile.am (libmailutils_la_SOURCES): Add
mkfilename.c
* mailbox/mkfilename.c: New file.

* imap4d/imap4d.c: Remove obsolete option (hidden since 2.0)
* libmu_argp/auth.c: Likewise.
* libmu_argp/cmdline.c: Likewise.
* libmu_argp/tls.c: Likewise.
* pop3d/pop3d.c: Likewise.
* libmu_argp/common.c: Likewise.
(mu_common_argp_options): New option --set.

* libmu_argp/muinit.c (mu_app_init): Rewrite using parse
tree as a principal entity.
* libmu_cfg/init.c (mu_libcfg_parse_config): New function.
* mailbox/cfg_driver.c (make_file_name): Remove.
(_cb_include): Use mu_make_file_name.
(mu_build_container): Use deprecated code only unless MU_PARSE_CONFIG_PLAIN
flag is set.
(mu_cfg_tree_reduce): Do nothing if the tree is NULL.
* mailbox/cfg_format.c (format_node): Print locus optionally.
(mu_cfg_format_parse_tree): Take additional argument.
(mu_cfg_format_node): New function.
* mailbox/cfg_lexer.l: Update calls to diagnostic functions.
(mu_cfg_parse_file): New function.
(mu_get_config): Rewrite.
* mailbox/cfg_parser.y (parse_tree): Replace with
parse_head, parse_tail. All usages updated.
(mu_cfg_free_node): New function.
(mu_cfg_vperror): New function.
(mu_cfg_perror,mu_cfg_parse_error): New function.
(mu_cfg_tree_union): New function.
(mu_cfg_tree_postprocess): New function.
(mu_cfg_find_section): Use MU_CFG_PATH_DELIM instead
of hardcoded slash.
(mu_cfg_value_eq): New function.
(mu_cfg_find_node): New function. Redesign of an old idea.
(mu_cfg_create_subtree): New function.
* mailbox/opool.c (mu_opool_union): New function.

* frm/testsuite/frm/test.exp: use --set option instead of
the obsolete --mail-folder.
* messages/testsuite/messages/test.exp: Likewise.
* sieve/testsuite/sieve/action.exp: Likewise.
* mail/testsuite/lib/mail.exp: use --set option instead of
the obsolete --mail-spool.
* mailbox/testsuite/lib/mailbox.exp: Likewise.
* testsuite/lib/mailutils.exp: Likewise.
* mailbox/mutil.c (mu_register_retriever)
(mu_retrieve): Remove unused functions.

Minor fix:

* frm/common.c (frm_abort): Initialize URL
before usage.
(frm_scan): Don't call frm_abort on a mailbox
that was not opened successfully.
1 parent 6dad17fe
...@@ -53,6 +53,9 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\ ...@@ -53,6 +53,9 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
53 --flag=mh_getyn:1:c-format\\\ 53 --flag=mh_getyn:1:c-format\\\
54 --flag=mh_getyn_interactive:1:c-format\\\ 54 --flag=mh_getyn_interactive:1:c-format\\\
55 --flag=mh_error:1:c-format\\\ 55 --flag=mh_error:1:c-format\\\
56 --flag=mu_cfg_perror:3:c-format\\\
57 --flag=mu_cfg_parse_error:1:c-format\\\
58 --flag=mu_cfg_format_error:3:c-format\\\
56 --flag=ali_parse_error:1:c-format\\\ 59 --flag=ali_parse_error:1:c-format\\\
57 --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\ 60 --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\
58 --flag=argp_error:2:c-format\\\ 61 --flag=argp_error:2:c-format\\\
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
18 MA 02110-1301 USA */ 18 MA 02110-1301 USA */
19 19
20 #include "comsat.h" 20 #include "comsat.h"
21 #define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
22 #include "mailutils/libcfg.h"
21 #include "mailutils/libargp.h" 23 #include "mailutils/libargp.h"
22 24
23 #ifndef PATH_DEV 25 #ifndef PATH_DEV
......
...@@ -39,6 +39,9 @@ static struct argp_option options[] = { ...@@ -39,6 +39,9 @@ static struct argp_option options[] = {
39 N_("print a list of configuration options used to build mailutils; " 39 N_("print a list of configuration options used to build mailutils; "
40 "optional arguments are interpreted as a list of configuration " 40 "optional arguments are interpreted as a list of configuration "
41 "options to check for"), 0}, 41 "options to check for"), 0},
42 {"query", 'q', N_("FILE"), OPTION_ARG_OPTIONAL,
43 N_("query configuration values from FILE (default mailutils.rc)"),
44 0 },
42 {"verbose", 'v', NULL, 0, 45 {"verbose", 'v', NULL, 0,
43 N_("increase output verbosity"), 0}, 46 N_("increase output verbosity"), 0},
44 {0, 0, 0, 0} 47 {0, 0, 0, 0}
...@@ -48,11 +51,13 @@ enum config_mode { ...@@ -48,11 +51,13 @@ enum config_mode {
48 MODE_VOID, 51 MODE_VOID,
49 MODE_COMPILE, 52 MODE_COMPILE,
50 MODE_LINK, 53 MODE_LINK,
51 MODE_INFO 54 MODE_INFO,
55 MODE_QUERY
52 }; 56 };
53 57
54 enum config_mode mode; 58 enum config_mode mode;
55 int verbose; 59 int verbose;
60 char *query_config_file;
56 61
57 static error_t 62 static error_t
58 parse_opt (int key, char *arg, struct argp_state *state) 63 parse_opt (int key, char *arg, struct argp_state *state)
...@@ -71,6 +76,12 @@ parse_opt (int key, char *arg, struct argp_state *state) ...@@ -71,6 +76,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
71 mode = MODE_INFO; 76 mode = MODE_INFO;
72 break; 77 break;
73 78
79 case 'q':
80 if (arg)
81 query_config_file = arg;
82 mode = MODE_QUERY;
83 break;
84
74 case 'v': 85 case 'v':
75 verbose++; 86 verbose++;
76 break; 87 break;
...@@ -170,13 +181,28 @@ int ...@@ -170,13 +181,28 @@ int
170 main (int argc, char **argv) 181 main (int argc, char **argv)
171 { 182 {
172 int index; 183 int index;
184 int i, rc;
185 struct argp *myargp;
186 char **excapa;
187 mu_cfg_tree_t *tree = NULL;
188 mu_stream_t stream;
189 int fmtflags = 0;
173 190
174 mu_argp_init (program_version, NULL); 191 mu_argp_init (program_version, NULL);
175 if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, &index, NULL)) 192
193 mu_set_program_name (argv[0]);
194 mu_libargp_init ();
195 for (i = 0; argp_capa[i]; i++)
196 mu_gocs_register_std (argp_capa[i]); /*FIXME*/
197 myargp = mu_argp_build (&argp, &excapa);
198
199 if (argp_parse (myargp, argc, argv, 0, &index, NULL))
176 { 200 {
177 argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name); 201 argp_help (myargp, stdout, ARGP_HELP_SEE, program_invocation_short_name);
178 return 1; 202 return 1;
179 } 203 }
204 mu_argp_done (myargp);
205 mu_set_program_name (program_invocation_name);
180 206
181 argc -= index; 207 argc -= index;
182 argv += index; 208 argv += index;
...@@ -298,6 +324,44 @@ main (int argc, char **argv) ...@@ -298,6 +324,44 @@ main (int argc, char **argv)
298 return found == argc ? 0 : 1; 324 return found == argc ? 0 : 1;
299 } 325 }
300 return 0; 326 return 0;
327
328 case MODE_QUERY:
329 if (argc == 0)
330 {
331 mu_error (_("not enough arguments"));
332 return 1;
333 }
334
335 if (query_config_file)
336 {
337 mu_load_site_rcfile = 0;
338 mu_load_user_rcfile = 0;
339 mu_load_rcfile = query_config_file;
340 }
341
342 if (mu_libcfg_parse_config (&tree))
343 exit (1);
344 if (!tree)
345 exit (0);
346 rc = mu_stdio_stream_create (&stream, stdout, 0);
347 if (rc)
348 {
349 mu_error ("mu_stdio_stream_create: %s", mu_strerror (rc));
350 exit (1);
351 }
352 if (verbose)
353 fmtflags = MU_CFG_FMT_LOCUS;
354 for ( ; argc > 0; argc--, argv++)
355 {
356 char *path = *argv;
357 mu_cfg_node_t *node;
358
359 if (mu_cfg_find_node (tree->head, path, &node) == 0)
360 {
361 mu_cfg_format_node (stream, node, fmtflags);
362 }
363 }
364 exit (0);
301 } 365 }
302 366
303 argp_help (&argp, stdout, ARGP_HELP_USAGE, program_invocation_short_name); 367 argp_help (&argp, stdout, ARGP_HELP_USAGE, program_invocation_short_name);
......
...@@ -527,7 +527,7 @@ frm_abort (mu_mailbox_t *mbox) ...@@ -527,7 +527,7 @@ frm_abort (mu_mailbox_t *mbox)
527 if ((status = mu_mailbox_close (*mbox)) != 0) 527 if ((status = mu_mailbox_close (*mbox)) != 0)
528 { 528 {
529 mu_url_t url; 529 mu_url_t url;
530 530 mu_mailbox_get_url (*mbox, &url);
531 mu_error (_("could not close mailbox `%s': %s"), 531 mu_error (_("could not close mailbox `%s': %s"),
532 mu_url_to_string (url), mu_strerror (status)); 532 mu_url_to_string (url), mu_strerror (status));
533 exit (3); 533 exit (3);
...@@ -580,7 +580,8 @@ frm_scan (char *mailbox_name, frm_select_t fun, size_t *total) ...@@ -580,7 +580,8 @@ frm_scan (char *mailbox_name, frm_select_t fun, size_t *total)
580 { 580 {
581 mu_error (_("could not open mailbox `%s': %s"), 581 mu_error (_("could not open mailbox `%s': %s"),
582 mu_url_to_string (url), mu_strerror (status)); 582 mu_url_to_string (url), mu_strerror (status));
583 frm_abort (&mbox); 583 mu_mailbox_destroy (&mbox);
584 exit (3);
584 } 585 }
585 else 586 else
586 { 587 {
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007 Free Software Foundation 3 # Copyright (C) 2002, 2007, 2009 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -51,7 +51,7 @@ mu_exec -retcode 1 -message "frm -qS" -arg -qS \ ...@@ -51,7 +51,7 @@ mu_exec -retcode 1 -message "frm -qS" -arg -qS \
51 mu_exec -retcode 1 -arg -q -message "frm -q" \ 51 mu_exec -retcode 1 -arg -q -message "frm -q" \
52 "There are messages in that folder." 52 "There are messages in that folder."
53 53
54 mu_exec -retcode 1 -arg "--mail-folder=$MU_SPOOL_DIR" -arg +mbox -message "frm +mbox" \ 54 mu_exec -retcode 1 -arg "--set mailbox.folder=$MU_SPOOL_DIR" -arg +mbox -message "frm +mbox" \
55 "Sergey Poznyakoff\tMBOX" 55 "Sergey Poznyakoff\tMBOX"
56 56
57 mu_exec -arg -q -arg %nonexistent -retcode 2 -message "frm -q %nonexistent" \ 57 mu_exec -arg -q -arg %nonexistent -retcode 2 -message "frm -q %nonexistent" \
......
...@@ -57,9 +57,6 @@ int ident_encrypt_only; ...@@ -57,9 +57,6 @@ int ident_encrypt_only;
57 const char *program_version = "imap4d (" PACKAGE_STRING ")"; 57 const char *program_version = "imap4d (" PACKAGE_STRING ")";
58 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon."); 58 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon.");
59 59
60 #define OPT_LOGIN_DISABLED 256
61 #define OPT_TLS_REQUIRED 257
62 #define OPT_CREATE_HOME_DIR 258
63 #define OPT_PREAUTH 259 60 #define OPT_PREAUTH 259
64 #define OPT_FOREGROUND 260 61 #define OPT_FOREGROUND 260
65 62
...@@ -69,21 +66,9 @@ static struct argp_option options[] = { ...@@ -69,21 +66,9 @@ static struct argp_option options[] = {
69 { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL, 66 { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL,
70 N_("runs in daemon mode with a maximum of NUMBER children"), 0 }, 67 N_("runs in daemon mode with a maximum of NUMBER children"), 0 },
71 68
72 {"other-namespace", 'O', N_("PATHLIST"), OPTION_HIDDEN,
73 N_("set the `other' namespace"), 0},
74 {"shared-namespace", 'S', N_("PATHLIST"), OPTION_HIDDEN,
75 N_("set the `shared' namespace"), 0},
76 {"login-disabled", OPT_LOGIN_DISABLED, NULL, OPTION_HIDDEN,
77 N_("disable LOGIN command")},
78 {"create-home-dir", OPT_CREATE_HOME_DIR, N_("MODE"),
79 OPTION_ARG_OPTIONAL|OPTION_HIDDEN,
80 N_("create home directory, if it does not exist")},
81 {"preauth", OPT_PREAUTH, NULL, 0, 69 {"preauth", OPT_PREAUTH, NULL, 0,
82 N_("start in preauth mode") }, 70 N_("start in preauth mode") },
83 #ifdef WITH_TLS 71
84 {"tls-required", OPT_TLS_REQUIRED, NULL, OPTION_HIDDEN,
85 N_("always require STARTTLS before entering authentication phase")},
86 #endif
87 {NULL, 0, NULL, 0, NULL, 0} 72 {NULL, 0, NULL, 0, NULL, 0}
88 }; 73 };
89 74
...@@ -134,30 +119,6 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state) ...@@ -134,30 +119,6 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state)
134 mu_argp_node_list_new (&lst, "foreground", "yes"); 119 mu_argp_node_list_new (&lst, "foreground", "yes");
135 break; 120 break;
136 121
137 case 'O':
138 mu_argp_node_list_new (&lst, "other-namespace", arg);
139 break;
140
141 case 'S':
142 mu_argp_node_list_new (&lst, "shared-namespace", arg);
143 break;
144
145 case OPT_LOGIN_DISABLED:
146 mu_argp_node_list_new (&lst, "login-disabled", "yes");
147 break;
148
149 case OPT_CREATE_HOME_DIR:
150 mu_argp_node_list_new (&lst, "create-home-dir", "yes");
151 if (arg)
152 mu_argp_node_list_new (&lst, "home-dir-mode", arg);
153 break;
154
155 #ifdef WITH_TLS
156 case OPT_TLS_REQUIRED:
157 mu_argp_node_list_new (&lst, "tls-required", "yes");
158 break;
159 #endif
160
161 case OPT_PREAUTH: 122 case OPT_PREAUTH:
162 preauth_mode = preauth_stdio; 123 preauth_mode = preauth_stdio;
163 break; 124 break;
......
1 /* cfg.h -- general-purpose configuration file parser 1 /* cfg.h -- general-purpose configuration file parser
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
3 3
4 GNU Mailutils is free software; you can redistribute it and/or 4 GNU Mailutils is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as 5 modify it under the terms of the GNU General Public License as
...@@ -58,8 +58,7 @@ struct mu_config_value ...@@ -58,8 +58,7 @@ struct mu_config_value
58 enum mu_cfg_node_type 58 enum mu_cfg_node_type
59 { 59 {
60 mu_cfg_node_undefined, 60 mu_cfg_node_undefined,
61 mu_cfg_statement, 61 mu_cfg_node_statement,
62 mu_cfg_node_tag=mu_cfg_statement, /* FIXME: remove */
63 mu_cfg_node_param 62 mu_cfg_node_param
64 }; 63 };
65 64
...@@ -81,19 +80,24 @@ struct mu_cfg_node ...@@ -81,19 +80,24 @@ struct mu_cfg_node
81 80
82 struct mu_cfg_tree 81 struct mu_cfg_tree
83 { 82 {
84 mu_cfg_node_t *node; 83 mu_cfg_node_t *head, *tail;
85 mu_debug_t debug; 84 mu_debug_t debug;
86 mu_opool_t pool; 85 mu_opool_t pool;
87 }; 86 };
88 87
89 int mu_cfg_parse (mu_cfg_tree_t **ptree); 88 int mu_cfg_parse (mu_cfg_tree_t **ptree);
89 int mu_cfg_tree_union (mu_cfg_tree_t **pa, mu_cfg_tree_t **pb);
90 int mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, int flags);
90 91
91 extern mu_cfg_locus_t mu_cfg_locus; 92 extern mu_cfg_locus_t mu_cfg_locus;
92 93
93 mu_opool_t mu_cfg_lexer_pool (void); 94 mu_opool_t mu_cfg_lexer_pool (void);
94 95
95 void mu_cfg_perror (const mu_cfg_locus_t *, const char *, ...) 96 void mu_cfg_vperror (mu_debug_t, const mu_cfg_locus_t *,
96 MU_PRINTFLIKE(2,3); 97 const char *fmt, va_list ap);
98 void mu_cfg_perror (mu_debug_t debug, const mu_cfg_locus_t *,
99 const char *, ...) MU_PRINTFLIKE(3,4);
100 void mu_cfg_parse_error (const char *, ...) MU_PRINTFLIKE(1,2);
97 void mu_cfg_format_error (mu_debug_t debug, size_t, const char *fmt, ...) 101 void mu_cfg_format_error (mu_debug_t debug, size_t, const char *fmt, ...)
98 MU_PRINTFLIKE(3,4); 102 MU_PRINTFLIKE(3,4);
99 103
...@@ -205,6 +209,9 @@ struct mu_cfg_cidr ...@@ -205,6 +209,9 @@ struct mu_cfg_cidr
205 unsigned long mask; 209 unsigned long mask;
206 }; 210 };
207 211
212 #define MU_CFG_PATH_DELIM '.'
213 #define MU_CFG_PATH_DELIM_STR "."
214
208 int mu_config_create_container (struct mu_cfg_cont **pcont, 215 int mu_config_create_container (struct mu_cfg_cont **pcont,
209 enum mu_cfg_cont_type type); 216 enum mu_cfg_cont_type type);
210 int mu_config_clone_container (struct mu_cfg_cont *cont); 217 int mu_config_clone_container (struct mu_cfg_cont *cont);
...@@ -240,19 +247,32 @@ mu_debug_t mu_cfg_get_debug (void); ...@@ -240,19 +247,32 @@ mu_debug_t mu_cfg_get_debug (void);
240 #define MU_PARSE_CONFIG_GLOBAL 0x1 247 #define MU_PARSE_CONFIG_GLOBAL 0x1
241 #define MU_PARSE_CONFIG_VERBOSE 0x2 248 #define MU_PARSE_CONFIG_VERBOSE 0x2
242 #define MU_PARSE_CONFIG_DUMP 0x4 249 #define MU_PARSE_CONFIG_DUMP 0x4
250 #define MU_PARSE_CONFIG_PLAIN 0x8
251
252 #ifdef MU_CFG_COMPATIBILITY
253 # define MU_CFG_DEPRECATED
254 #else
255 # define MU_CFG_DEPRECATED __attribute__ ((deprecated))
256 #endif
243 257
244 int mu_parse_config (const char *file, const char *progname, 258 int mu_parse_config (const char *file, const char *progname,
245 struct mu_cfg_param *progparam, int flags, 259 struct mu_cfg_param *progparam, int flags,
246 void *target_ptr); 260 void *target_ptr) MU_CFG_DEPRECATED;
247 261
248 int mu_cfg_parse_boolean (const char *str, int *res); 262 int mu_cfg_parse_boolean (const char *str, int *res);
249 263
250 extern int mu_cfg_parser_verbose; 264 extern int mu_cfg_parser_verbose;
251 extern size_t mu_cfg_error_count; 265 extern size_t mu_cfg_error_count;
252 266
267 #define MU_CFG_FMT_LOCUS 0x01
268
253 void mu_cfg_format_docstring (mu_stream_t stream, const char *docstring, 269 void mu_cfg_format_docstring (mu_stream_t stream, const char *docstring,
254 int level); 270 int level);
255 void mu_cfg_format_parse_tree (mu_stream_t stream, struct mu_cfg_tree *tree); 271 void mu_cfg_format_parse_tree (mu_stream_t stream, struct mu_cfg_tree *tree,
272 int flags);
273 void mu_cfg_format_node (mu_stream_t stream, const mu_cfg_node_t *node,
274 int flags);
275
256 void mu_cfg_format_container (mu_stream_t stream, struct mu_cfg_cont *cont); 276 void mu_cfg_format_container (mu_stream_t stream, struct mu_cfg_cont *cont);
257 void mu_format_config_tree (mu_stream_t stream, const char *progname, 277 void mu_format_config_tree (mu_stream_t stream, const char *progname,
258 struct mu_cfg_param *progparam, int flags); 278 struct mu_cfg_param *progparam, int flags);
...@@ -265,14 +285,16 @@ int mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val, ...@@ -265,14 +285,16 @@ int mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val,
265 int (*fun) (mu_debug_t, const char *, void *), 285 int (*fun) (mu_debug_t, const char *, void *),
266 void *data); 286 void *data);
267 287
288 int mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file,
289 int flags);
290
291
268 int mu_get_config (const char *file, const char *progname, 292 int mu_get_config (const char *file, const char *progname,
269 struct mu_cfg_param *progparam, int flags, 293 struct mu_cfg_param *progparam, int flags,
270 void *target_ptr); 294 void *target_ptr) MU_CFG_DEPRECATED;
271
272 295
273 int mu_cfg_tree_create (struct mu_cfg_tree **ptree); 296 int mu_cfg_tree_create (struct mu_cfg_tree **ptree);
274 void mu_cfg_tree_set_debug (struct mu_cfg_tree *tree, mu_debug_t debug); 297 void mu_cfg_tree_set_debug (struct mu_cfg_tree *tree, mu_debug_t debug);
275 void mu_cfg_tree_free (struct mu_cfg_tree *tree, void *mem);
276 mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree, 298 mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
277 enum mu_cfg_node_type type, 299 enum mu_cfg_node_type type,
278 const mu_cfg_locus_t *loc, 300 const mu_cfg_locus_t *loc,
...@@ -281,6 +303,10 @@ mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree, ...@@ -281,6 +303,10 @@ mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
281 mu_cfg_node_t *node); 303 mu_cfg_node_t *node);
282 void mu_cfg_tree_add_node (mu_cfg_tree_t *tree, mu_cfg_node_t *node); 304 void mu_cfg_tree_add_node (mu_cfg_tree_t *tree, mu_cfg_node_t *node);
283 305
306 int mu_cfg_find_node (mu_cfg_node_t *tree, const char *path,
307 mu_cfg_node_t **pnode);
308 int mu_cfg_create_subtree (const char *path, mu_cfg_node_t **pnode);
309
284 #ifdef __cplusplus 310 #ifdef __cplusplus
285 } 311 }
286 #endif 312 #endif
......
...@@ -50,7 +50,9 @@ extern int mu_register_cfg_capa (const char *name, ...@@ -50,7 +50,9 @@ extern int mu_register_cfg_capa (const char *name,
50 50
51 extern void mu_libcfg_init (char **cnames); 51 extern void mu_libcfg_init (char **cnames);
52 extern int mu_parse_config_files (struct mu_cfg_param *param, 52 extern int mu_parse_config_files (struct mu_cfg_param *param,
53 void *target_ptr); 53 void *target_ptr) MU_CFG_DEPRECATED;
54 int mu_libcfg_parse_config (mu_cfg_tree_t **ptree);
55
54 extern void mu_acl_cfg_init (void); 56 extern void mu_acl_cfg_init (void);
55 57
56 #define __mu_common_cat2__(a,b) a ## b 58 #define __mu_common_cat2__(a,b) a ## b
......
...@@ -99,6 +99,7 @@ extern int mu_aget_user_email_domain (char **pdomain); ...@@ -99,6 +99,7 @@ extern int mu_aget_user_email_domain (char **pdomain);
99 */ 99 */
100 extern char *mu_get_user_email (const char *name); 100 extern char *mu_get_user_email (const char *name);
101 101
102 extern char *mu_make_file_name (const char *dir, const char *file);
102 extern char *mu_normalize_path (char *path); 103 extern char *mu_normalize_path (char *path);
103 extern int mu_tempfile (const char *tmpdir, char **namep); 104 extern int mu_tempfile (const char *tmpdir, char **namep);
104 extern char *mu_tempname (const char *tmpdir); 105 extern char *mu_tempname (const char *tmpdir);
...@@ -108,10 +109,6 @@ extern char * mu_getcwd (void); ...@@ -108,10 +109,6 @@ extern char * mu_getcwd (void);
108 109
109 extern int mu_spawnvp(const char *prog, char *av[], int *stat); 110 extern int mu_spawnvp(const char *prog, char *av[], int *stat);
110 111
111 typedef void *(*mu_retrieve_fp) (void *);
112 extern void mu_register_retriever (mu_list_t *pflist, mu_retrieve_fp fun);
113 extern void * mu_retrieve (mu_list_t flist, void *data);
114
115 extern int mu_unroll_symlink (char *out, size_t outsz, const char *in); 112 extern int mu_unroll_symlink (char *out, size_t outsz, const char *in);
116 113
117 extern char * mu_expand_path_pattern (const char *pattern, const char *username); 114 extern char * mu_expand_path_pattern (const char *pattern, const char *username);
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2008 Free Software Foundation, Inc. 2 Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public 5 modify it under the terms of the GNU Lesser General Public
...@@ -32,6 +32,10 @@ int mu_opool_create (mu_opool_t *pret, int memerr); ...@@ -32,6 +32,10 @@ int mu_opool_create (mu_opool_t *pret, int memerr);
32 int mu_opool_set_bucket_size (mu_opool_t opool, size_t size); 32 int mu_opool_set_bucket_size (mu_opool_t opool, size_t size);
33 int mu_opool_get_bucket_size (mu_opool_t opool, size_t *psize); 33 int mu_opool_get_bucket_size (mu_opool_t opool, size_t *psize);
34 34
35 /* Merge all data from *SRC into *DST. If the latter is NULL, create
36 it. On success, free *SRC and initialize it with NULL. */
37 int mu_opool_union (mu_opool_t *dst, mu_opool_t *src);
38
35 /* Clear all data from the pool, so next mu_opool_append* call will 39 /* Clear all data from the pool, so next mu_opool_append* call will
36 begin a new object. */ 40 begin a new object. */
37 void mu_opool_clear (mu_opool_t opool); 41 void mu_opool_clear (mu_opool_t opool);
......
...@@ -32,14 +32,9 @@ libmu_argp_a_SOURCES =\ ...@@ -32,14 +32,9 @@ libmu_argp_a_SOURCES =\
32 cmdline.h\ 32 cmdline.h\
33 common.c\ 33 common.c\
34 compat.c\ 34 compat.c\
35 gsasl.c\
36 mu_argp.h\ 35 mu_argp.h\
37 mu_argp.c\ 36 mu_argp.c\
38 muinit.c\ 37 muinit.c\
39 pam.c\
40 radius.c\
41 sieve.c\ 38 sieve.c\
42 sql.c\ 39 tls.c
43 tls.c\
44 virtdomain.c
45 40
......
...@@ -28,11 +28,7 @@ ...@@ -28,11 +28,7 @@
28 /* ************************************************************************* */ 28 /* ************************************************************************* */
29 29
30 enum { 30 enum {
31 OPT_AUTHORIZATION=256, 31 OPT_DEBUG_AUTH=256
32 OPT_AUTHENTICATION,
33 OPT_CLEAR_AUTHORIZATION,
34 OPT_CLEAR_AUTHENTICATION,
35 OPT_DEBUG_AUTH
36 }; 32 };
37 33
38 static error_t mu_auth_argp_parser (int key, char *arg, 34 static error_t mu_auth_argp_parser (int key, char *arg,
...@@ -40,14 +36,6 @@ static error_t mu_auth_argp_parser (int key, char *arg, ...@@ -40,14 +36,6 @@ static error_t mu_auth_argp_parser (int key, char *arg,
40 36
41 /* Options used by programs that use extended authentication mechanisms. */ 37 /* Options used by programs that use extended authentication mechanisms. */
42 static struct argp_option mu_auth_argp_option[] = { 38 static struct argp_option mu_auth_argp_option[] = {
43 { "authentication", OPT_AUTHENTICATION, N_("MODLIST"), OPTION_HIDDEN,
44 N_("set the list of modules to be used for authentication"), 0 },
45 { "authorization", OPT_AUTHORIZATION, N_("MODLIST"), OPTION_HIDDEN,
46 N_("set list of modules to be used for authorization"), 0 },
47 { "clear-authorization", OPT_CLEAR_AUTHORIZATION, NULL, OPTION_HIDDEN,
48 N_("clear the list of authorization modules"), 0 },
49 { "clear-authentication", OPT_CLEAR_AUTHENTICATION, NULL, OPTION_HIDDEN,
50 N_("clear the list of authentication modules"), 0 },
51 { "debug-auth", OPT_DEBUG_AUTH, NULL, 0, 39 { "debug-auth", OPT_DEBUG_AUTH, NULL, 0,
52 N_("debug authentication functions") }, 40 N_("debug authentication functions") },
53 { NULL, 0, NULL, 0, NULL, 0 } 41 { NULL, 0, NULL, 0, NULL, 0 }
...@@ -92,22 +80,6 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -92,22 +80,6 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state)
92 mu_argp_node_list_finish (&lst, "auth", NULL); 80 mu_argp_node_list_finish (&lst, "auth", NULL);
93 break; 81 break;
94 82
95 case OPT_AUTHORIZATION:
96 mu_argp_node_list_new (&lst, "authorization", arg);
97 break;
98
99 case OPT_AUTHENTICATION:
100 mu_argp_node_list_new (&lst, "authentication", arg);
101 break;
102
103 case OPT_CLEAR_AUTHENTICATION:
104 mu_argp_node_list_new (&lst, "authentication", "clear");
105 break;
106
107 case OPT_CLEAR_AUTHORIZATION:
108 mu_argp_node_list_new (&lst, "authorization", "clear");
109 break;
110
111 case OPT_DEBUG_AUTH: 83 case OPT_DEBUG_AUTH:
112 auth_set_debug (); 84 auth_set_debug ();
113 break; 85 break;
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public 5 modify it under the terms of the GNU Lesser General Public
...@@ -26,17 +26,9 @@ static struct mu_cmdline_capa *all_cmdline_capa[] = { ...@@ -26,17 +26,9 @@ static struct mu_cmdline_capa *all_cmdline_capa[] = {
26 &mu_common_cmdline, 26 &mu_common_cmdline,
27 &mu_logging_cmdline, 27 &mu_logging_cmdline,
28 &mu_license_cmdline, 28 &mu_license_cmdline,
29 &mu_mailbox_cmdline,
30 &mu_locking_cmdline,
31 &mu_address_cmdline,
32 &mu_mailer_cmdline, 29 &mu_mailer_cmdline,
33 &mu_debug_cmdline, 30 &mu_debug_cmdline,
34 &mu_pam_cmdline,
35 &mu_gsasl_cmdline,
36 &mu_tls_cmdline, 31 &mu_tls_cmdline,
37 &mu_radius_cmdline,
38 &mu_sql_cmdline,
39 &mu_virtdomain_cmdline,
40 &mu_auth_cmdline, 32 &mu_auth_cmdline,
41 &mu_sieve_cmdline, 33 &mu_sieve_cmdline,
42 NULL 34 NULL
...@@ -104,7 +96,7 @@ mu_argp_node_list_finish (struct mu_argp_node_list *lst, char *tag, ...@@ -104,7 +96,7 @@ mu_argp_node_list_finish (struct mu_argp_node_list *lst, char *tag,
104 return; 96 return;
105 if (tag) 97 if (tag)
106 node = mu_cfg_tree_create_node (mu_argp_tree, 98 node = mu_cfg_tree_create_node (mu_argp_tree,
107 mu_cfg_node_tag, 99 mu_cfg_node_statement,
108 NULL, 100 NULL,
109 tag, label, 101 tag, label,
110 lst->head); 102 lst->head);
...@@ -113,3 +105,4 @@ mu_argp_node_list_finish (struct mu_argp_node_list *lst, char *tag, ...@@ -113,3 +105,4 @@ mu_argp_node_list_finish (struct mu_argp_node_list *lst, char *tag,
113 mu_cfg_tree_add_node (mu_argp_tree, node); 105 mu_cfg_tree_add_node (mu_argp_tree, node);
114 mu_argp_node_list_init (lst); 106 mu_argp_node_list_init (lst);
115 } 107 }
108
......
...@@ -38,18 +38,11 @@ enum { ...@@ -38,18 +38,11 @@ enum {
38 OPT_RCFILE_LINT, 38 OPT_RCFILE_LINT,
39 OPT_RCFILE_VERBOSE, 39 OPT_RCFILE_VERBOSE,
40 OPT_LOG_FACILITY, 40 OPT_LOG_FACILITY,
41 OPT_LOCK_FLAGS,
42 OPT_LOCK_RETRY_COUNT,
43 OPT_LOCK_RETRY_TIMEOUT,
44 OPT_LOCK_EXPIRE_TIMEOUT,
45 OPT_LOCK_EXTERNAL_PROGRAM,
46 OPT_LICENSE, 41 OPT_LICENSE,
47 OPT_MAILBOX_PATTERN,
48 OPT_MAILBOX_TYPE,
49 OPT_MAIL_FOLDER,
50 OPT_DEBUG_LEVEL, 42 OPT_DEBUG_LEVEL,
51 OPT_LINE_INFO, 43 OPT_LINE_INFO,
52 OPT_HELP_CONFIG 44 OPT_HELP_CONFIG,
45 OPT_SET
53 }; 46 };
54 47
55 static struct argp_option mu_common_argp_options[] = 48 static struct argp_option mu_common_argp_options[] =
...@@ -74,9 +67,21 @@ static struct argp_option mu_common_argp_options[] = ...@@ -74,9 +67,21 @@ static struct argp_option mu_common_argp_options[] =
74 { "config-lint", OPT_RCFILE_LINT, NULL, 0, 67 { "config-lint", OPT_RCFILE_LINT, NULL, 0,
75 N_("check configuration file syntax and exit"), 0 }, 68 N_("check configuration file syntax and exit"), 0 },
76 { "rcfile-lint", 0, NULL, OPTION_ALIAS, NULL }, 69 { "rcfile-lint", 0, NULL, OPTION_ALIAS, NULL },
70 { "set", OPT_SET, N_("PARAM=VALUE"), 0,
71 N_("set configuration parameter"), 0 },
77 { NULL, 0, NULL, 0, NULL, 0 } 72 { NULL, 0, NULL, 0, NULL, 0 }
78 }; 73 };
79 74
75 static void
76 set_config_param (const char *path, struct argp_state *state)
77 {
78 mu_cfg_node_t *node;
79 int rc = mu_cfg_create_subtree (path, &node);
80 if (rc)
81 argp_error (state, "cannot create node: %s", mu_strerror (rc));
82 mu_cfg_tree_add_node (mu_argp_tree, node);
83 }
84
80 static error_t 85 static error_t
81 mu_common_argp_parser (int key, char *arg, struct argp_state *state) 86 mu_common_argp_parser (int key, char *arg, struct argp_state *state)
82 { 87 {
...@@ -111,6 +116,10 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -111,6 +116,10 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state)
111 mu_help_config_mode = 1; 116 mu_help_config_mode = 1;
112 break; 117 break;
113 118
119 case OPT_SET:
120 set_config_param (arg, state);
121 break;
122
114 default: 123 default:
115 return ARGP_ERR_UNKNOWN; 124 return ARGP_ERR_UNKNOWN;
116 } 125 }
...@@ -231,215 +240,6 @@ struct mu_cmdline_capa mu_license_cmdline = { ...@@ -231,215 +240,6 @@ struct mu_cmdline_capa mu_license_cmdline = {
231 240
232 241
233 /* ************************************************************************* */ 242 /* ************************************************************************* */
234 /* Mailbox */
235 /* ************************************************************************* */
236
237 /* Options used by programs that access mailboxes. */
238 static struct argp_option mu_mailbox_argp_option[] = {
239 { "mail-spool", 'm', N_("URL"), OPTION_HIDDEN,
240 N_("use specified URL as a mailspool directory"), 0 },
241 { "mailbox-pattern", OPT_MAILBOX_PATTERN, N_("pat"), OPTION_HIDDEN,
242 "", 0 },
243 { "mailbox-type", OPT_MAILBOX_TYPE, N_("PROTO"), OPTION_HIDDEN,
244 N_("default mailbox type to use"), 0 },
245 { "mail-folder", OPT_MAIL_FOLDER, N_("DIR"), OPTION_HIDDEN,
246 N_("default user mail folder"), 0 },
247 { NULL }
248 };
249
250 static error_t
251 mu_mailbox_argp_parser (int key, char *arg, struct argp_state *state)
252 {
253 static struct mu_argp_node_list lst;
254
255 switch (key)
256 {
257 /* mailbox */
258 case 'm':
259 mu_argp_node_list_new (&lst, "mail-spool", arg);
260 break;
261
262 case OPT_MAILBOX_PATTERN:
263 mu_argp_node_list_new (&lst, "mailbox-pattern", arg);
264 break;
265
266 case OPT_MAILBOX_TYPE:
267 mu_argp_node_list_new (&lst, "mailbox-type", arg);
268 break;
269
270 case OPT_MAIL_FOLDER:
271 mu_argp_node_list_new (&lst, "folder", arg);
272 break;
273
274 case ARGP_KEY_INIT:
275 mu_argp_node_list_init (&lst);
276 break;
277
278 case ARGP_KEY_FINI:
279 mu_argp_node_list_finish (&lst, "mailbox", NULL);
280 break;
281
282 default:
283 return ARGP_ERR_UNKNOWN;
284 }
285 return 0;
286 }
287
288 struct argp mu_mailbox_argp = {
289 mu_mailbox_argp_option,
290 mu_mailbox_argp_parser,
291 };
292
293 struct argp_child mu_mailbox_argp_child = {
294 &mu_mailbox_argp,
295 0,
296 NULL,
297 0
298 };
299
300 struct mu_cmdline_capa mu_mailbox_cmdline = {
301 "mailbox", &mu_mailbox_argp_child
302 };
303
304
305 /* ************************************************************************* */
306 /* Locking */
307 /* ************************************************************************* */
308
309 /* Options used by programs that access mailboxes. */
310 static struct argp_option mu_locking_argp_option[] = {
311 {"lock-flags", OPT_LOCK_FLAGS, N_("FLAGS"), OPTION_HIDDEN,
312 N_("default locker flags (E=external, R=retry, T=time, P=pid)"), 0},
313 {"lock-retry-timeout", OPT_LOCK_RETRY_TIMEOUT, N_("SECONDS"), OPTION_HIDDEN,
314 N_("set timeout for acquiring the lockfile") },
315 {"lock-retry-count", OPT_LOCK_RETRY_COUNT, N_("NUMBER"), OPTION_HIDDEN,
316 N_("set the maximum number of times to retry acquiring the lockfile") },
317 {"lock-expire-timeout", OPT_LOCK_EXPIRE_TIMEOUT, N_("SECONDS"),
318 OPTION_HIDDEN,
319 N_("number of seconds after which the lock expires"), },
320 {"external-locker", OPT_LOCK_EXTERNAL_PROGRAM, N_("PATH"), OPTION_HIDDEN,
321 N_("set full path to the external locker program") },
322 { NULL, 0, NULL, 0, NULL, 0 }
323 };
324
325 static error_t
326 mu_locking_argp_parser (int key, char *arg, struct argp_state *state)
327 {
328 static struct mu_argp_node_list lst;
329
330 switch (key)
331 {
332 case OPT_LOCK_FLAGS:
333 mu_argp_node_list_new (&lst, "flags", arg);
334 break;
335
336 case OPT_LOCK_RETRY_COUNT:
337 mu_argp_node_list_new (&lst, "retry-count", arg);
338 break;
339
340 case OPT_LOCK_RETRY_TIMEOUT:
341 mu_argp_node_list_new (&lst, "retry-timeout", arg);
342 break;
343
344 case OPT_LOCK_EXPIRE_TIMEOUT:
345 mu_argp_node_list_new (&lst, "expire-timeout", arg);
346 break;
347
348 case OPT_LOCK_EXTERNAL_PROGRAM:
349 mu_argp_node_list_new (&lst, "external-locker", arg);
350 break;
351
352 case ARGP_KEY_INIT:
353 mu_argp_node_list_init (&lst);
354 break;
355
356 case ARGP_KEY_FINI:
357 mu_argp_node_list_finish (&lst, "locking", NULL);
358 break;
359
360 default:
361 return ARGP_ERR_UNKNOWN;
362 }
363 return 0;
364 }
365
366 struct argp mu_locking_argp = {
367 mu_locking_argp_option,
368 mu_locking_argp_parser,
369 };
370
371 struct argp_child mu_locking_argp_child = {
372 &mu_locking_argp,
373 0,
374 NULL,
375 0
376 };
377
378 struct mu_cmdline_capa mu_locking_cmdline = {
379 "locking", &mu_locking_argp_child
380 };
381
382
383 /* ************************************************************************* */
384 /* Address */
385 /* ************************************************************************* */
386
387 /* Options used by programs that do address mapping. */
388 static struct argp_option mu_address_argp_option[] = {
389 {"email-addr", 'E', N_("EMAIL"), OPTION_HIDDEN,
390 N_("set current user's email address (default is loginname@defaultdomain)"), 0},
391 {"email-domain", 'D', N_("DOMAIN"), OPTION_HIDDEN,
392 N_("set domain for unqualified user names (default is this host)"), 0},
393 { NULL, 0, NULL, 0, NULL, 0 }
394 };
395
396 static error_t
397 mu_address_argp_parser (int key, char *arg, struct argp_state *state)
398 {
399 static struct mu_argp_node_list lst;
400
401 switch (key)
402 {
403 case 'E':
404 mu_argp_node_list_new (&lst, "email-addr", arg);
405 break;
406
407 case 'D':
408 mu_argp_node_list_new (&lst, "email-domain", arg);
409 break;
410
411 case ARGP_KEY_INIT:
412 mu_argp_node_list_init (&lst);
413 break;
414
415 case ARGP_KEY_FINI:
416 mu_argp_node_list_finish (&lst, "address", NULL);
417 break;
418
419 default:
420 return ARGP_ERR_UNKNOWN;
421 }
422 return 0;
423 }
424
425 struct argp mu_address_argp = {
426 mu_address_argp_option,
427 mu_address_argp_parser,
428 };
429
430 struct argp_child mu_address_argp_child = {
431 &mu_address_argp,
432 0,
433 NULL,
434 0
435 };
436
437 struct mu_cmdline_capa mu_address_cmdline = {
438 "address", &mu_address_argp_child
439 };
440
441
442 /* ************************************************************************* */
443 /* Mailer */ 243 /* Mailer */
444 /* ************************************************************************* */ 244 /* ************************************************************************* */
445 245
...@@ -511,7 +311,7 @@ mu_debug_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -511,7 +311,7 @@ mu_debug_argp_parser (int key, char *arg, struct argp_state *state)
511 { 311 {
512 case OPT_DEBUG_LEVEL: 312 case OPT_DEBUG_LEVEL:
513 mu_global_debug_from_string (arg, "command line"); 313 mu_global_debug_from_string (arg, "command line");
514 //mu_argp_node_list_new (&lst, "level", arg); 314 /*mu_argp_node_list_new (&lst, "level", arg);*/
515 break; 315 break;
516 316
517 case OPT_LINE_INFO: 317 case OPT_LINE_INFO:
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library; if not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22 #include "cmdline.h"
23 #include <mailutils/gsasl.h>
24
25 #define OPT_CRAM_PASSWD 256
26
27 static struct argp_option _gsasl_argp_options[] = {
28 {"cram-passwd", OPT_CRAM_PASSWD, N_("FILE"), OPTION_HIDDEN,
29 N_("specify password file for CRAM-MD5 authentication"), 0},
30 { NULL, 0, NULL, 0, NULL, 0 }
31 };
32
33 static error_t
34 _gsasl_argp_parser (int key, char *arg, struct argp_state *state)
35 {
36 static struct mu_argp_node_list lst;
37
38 switch (key)
39 {
40 case OPT_CRAM_PASSWD:
41 mu_argp_node_list_new (&lst, "cram-passwd", arg);
42 break;
43
44 case ARGP_KEY_INIT:
45 mu_argp_node_list_init (&lst);
46 break;
47
48 case ARGP_KEY_FINI:
49 mu_argp_node_list_finish (&lst, "gsasl", NULL);
50 break;
51
52 default:
53 return ARGP_ERR_UNKNOWN;
54 }
55 return 0;
56 }
57
58 static struct argp _gsasl_argp = {
59 _gsasl_argp_options,
60 _gsasl_argp_parser
61 };
62
63 struct argp_child mu_gsasl_argp_child = {
64 &_gsasl_argp,
65 0,
66 NULL,
67 0
68 };
69
70 struct mu_cmdline_capa mu_gsasl_cmdline = {
71 "gsasl", &mu_gsasl_argp_child
72 };
73
74
...@@ -66,7 +66,7 @@ mu_app_init (struct argp *myargp, const char **capa, ...@@ -66,7 +66,7 @@ mu_app_init (struct argp *myargp, const char **capa,
66 struct argp *argp; 66 struct argp *argp;
67 struct argp argpnull = { 0 }; 67 struct argp argpnull = { 0 };
68 char **excapa; 68 char **excapa;
69 int cfgflags = 0; 69 struct mu_cfg_tree *parse_tree = NULL;
70 70
71 mu_set_program_name (argv[0]); 71 mu_set_program_name (argv[0]);
72 mu_libargp_init (); 72 mu_libargp_init ();
...@@ -119,15 +119,21 @@ mu_app_init (struct argp *myargp, const char **capa, ...@@ -119,15 +119,21 @@ mu_app_init (struct argp *myargp, const char **capa,
119 mu_stream_destroy (&stream, NULL); 119 mu_stream_destroy (&stream, NULL);
120 exit (0); 120 exit (0);
121 } 121 }
122 else 122
123 mu_parse_config_files (cfg_param, data); 123 rc = mu_libcfg_parse_config (&parse_tree);
124 if (rc == 0)
125 {
126 int cfgflags = MU_PARSE_CONFIG_PLAIN;
124 127
125 if (mu_cfg_parser_verbose) 128 if (mu_cfg_parser_verbose)
126 cfgflags |= MU_PARSE_CONFIG_VERBOSE; 129 cfgflags |= MU_PARSE_CONFIG_VERBOSE;
127 if (mu_cfg_parser_verbose > 1) 130 if (mu_cfg_parser_verbose > 1)
128 cfgflags |= MU_PARSE_CONFIG_DUMP; 131 cfgflags |= MU_PARSE_CONFIG_DUMP;
129 rc = mu_cfg_tree_reduce (mu_argp_tree, mu_program_name, cfg_param, 132 mu_cfg_tree_postprocess (mu_argp_tree, cfgflags);
133 mu_cfg_tree_union (&parse_tree, &mu_argp_tree);
134 rc = mu_cfg_tree_reduce (parse_tree, mu_program_name, cfg_param,
130 cfgflags, data); 135 cfgflags, data);
136 }
131 137
132 if (mu_rcfile_lint) 138 if (mu_rcfile_lint)
133 { 139 {
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library; if not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 #include "cmdline.h"
24 #include <mailutils/pam.h>
25
26 #define OPT_PAM_SERVICE 256
27
28 static error_t
29 mu_pam_argp_parser (int key, char *arg, struct argp_state *state)
30 {
31 static struct mu_argp_node_list lst;
32
33 switch (key)
34 {
35 case OPT_PAM_SERVICE:
36 mu_argp_node_list_new (&lst, "service", arg);
37 break;
38
39 case ARGP_KEY_INIT:
40 mu_argp_node_list_init (&lst);
41 break;
42
43 case ARGP_KEY_FINI:
44 mu_argp_node_list_finish (&lst, "pam", NULL);
45 break;
46
47 default:
48 return ARGP_ERR_UNKNOWN;
49 }
50 return 0;
51 }
52
53 static struct argp_option mu_pam_argp_option[] = {
54 { "pam-service", OPT_PAM_SERVICE, N_("STRING"), OPTION_HIDDEN,
55 N_("use STRING as PAM service name"), 0},
56 { NULL, 0, NULL, 0, NULL, 0 }
57 };
58
59 static struct argp mu_pam_argp = {
60 mu_pam_argp_option,
61 mu_pam_argp_parser,
62 };
63
64 struct argp_child mu_pam_argp_child = {
65 &mu_pam_argp,
66 0,
67 NULL,
68 0
69 };
70
71 struct mu_cmdline_capa mu_pam_cmdline = {
72 "pam", &mu_pam_argp_child
73 };
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library; if not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 #include "cmdline.h"
24 #include <mailutils/radius.h>
25
26 enum {
27 OPT_AUTH_REQUEST = 256,
28 OPT_GETPWNAM_REQUEST,
29 OPT_GETPWUID_REQUEST,
30 OPT_RADIUS_DIR
31 };
32
33 static struct argp_option mu_radius_argp_option[] = {
34 { "radius-auth-request", OPT_AUTH_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
35 N_("radius request to authenticate the user"), 0 },
36 { "radius-getpwnam-request", OPT_GETPWNAM_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
37 N_("radius request to retrieve a passwd entry based on username"), 0 },
38 { "radius-getpwuid-request", OPT_GETPWUID_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
39 N_("radius request to retrieve a passwd entry based on UID"), 0 },
40 { "radius-directory", OPT_RADIUS_DIR, N_("DIR"), OPTION_HIDDEN,
41 N_("set name of the radius configuration directory"), 0 },
42 { NULL }
43 };
44
45 static error_t
46 mu_radius_argp_parser (int key, char *arg, struct argp_state *state)
47 {
48 static struct mu_argp_node_list lst;
49
50 switch (key)
51 {
52 case OPT_AUTH_REQUEST:
53 mu_argp_node_list_new (&lst, "auth-request", arg);
54 break;
55
56 case OPT_GETPWNAM_REQUEST:
57 mu_argp_node_list_new (&lst, "getwnam-request", arg);
58 break;
59
60 case OPT_GETPWUID_REQUEST:
61 mu_argp_node_list_new (&lst, "getwuid-request", arg);
62 break;
63
64 case OPT_RADIUS_DIR:
65 mu_argp_node_list_new (&lst, "directory", arg);
66 break;
67
68 case ARGP_KEY_INIT:
69 mu_argp_node_list_init (&lst);
70 break;
71
72 case ARGP_KEY_FINI:
73 mu_argp_node_list_finish (&lst, "radius", NULL);
74 break;
75
76 default:
77 return ARGP_ERR_UNKNOWN;
78 }
79 return 0;
80 }
81
82 static struct argp mu_radius_argp = {
83 mu_radius_argp_option,
84 mu_radius_argp_parser,
85 };
86
87 struct argp_child mu_radius_argp_child = {
88 &mu_radius_argp,
89 0,
90 NULL,
91 0
92 };
93
94 struct mu_cmdline_capa mu_radius_cmdline = {
95 "radius", &mu_radius_argp_child
96 };
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library; if not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 #include "cmdline.h"
24
25 enum {
26 OPT_SQL_INTERFACE = 256,
27 OPT_SQL_GETPWNAM,
28 OPT_SQL_GETPWUID,
29 OPT_SQL_GETPASS,
30 OPT_SQL_HOST,
31 OPT_SQL_USER,
32 OPT_SQL_PASSWD,
33 OPT_SQL_DB,
34 OPT_SQL_PORT,
35 OPT_SQL_MU_PASSWORD_TYPE,
36 OPT_SQL_FIELD_MAP,
37 };
38
39 static struct argp_option mu_sql_argp_option[] = {
40 {"sql-interface", OPT_SQL_INTERFACE, N_("NAME"), OPTION_HIDDEN,
41 N_("type of SQL interface to use"), },
42 {"sql-getpwnam", OPT_SQL_GETPWNAM, N_("QUERY"), OPTION_HIDDEN,
43 N_("SQL query to retrieve a passwd entry based on username"), 0},
44 {"sql-getpwuid", OPT_SQL_GETPWUID, N_("QUERY"), OPTION_HIDDEN,
45 N_("SQL query to retrieve a passwd entry based on UID"), 0},
46 {"sql-getpass", OPT_SQL_GETPASS, N_("QUERY"), OPTION_HIDDEN,
47 N_("SQL query to retrieve a password from the database"), 0},
48 {"sql-host", OPT_SQL_HOST, N_("HOSTNAME"), OPTION_HIDDEN,
49 N_("name or IP of MySQL server to connect to"), 0},
50 {"sql-user", OPT_SQL_USER, N_("NAME"), OPTION_HIDDEN,
51 N_("SQL user name"), 0},
52 {"sql-passwd", OPT_SQL_PASSWD, N_("STRING"), OPTION_HIDDEN,
53 N_("SQL connection password"), 0},
54 {"sql-db", OPT_SQL_DB, N_("STRING"), OPTION_HIDDEN,
55 N_("name of the database to connect to"), 0},
56 {"sql-port", OPT_SQL_PORT, N_("NUMBER"), OPTION_HIDDEN,
57 N_("port to use"), 0},
58 {"sql-password-type", OPT_SQL_MU_PASSWORD_TYPE, N_("STRING"), OPTION_HIDDEN,
59 N_("type of password returned by --sql-getpass query. STRING is one of: plain, hash, scrambled"), 0},
60 {"sql-field-map", OPT_SQL_FIELD_MAP, N_("MAP"), OPTION_HIDDEN,
61 N_("declare a name translation map for SQL fields in results of sql-getpwnam and "
62 "sql-getpwuid queries"), 0},
63 { NULL, 0, NULL, 0, NULL, 0 }
64 };
65
66 static error_t
67 mu_sql_argp_parser (int key, char *arg, struct argp_state *state)
68 {
69 static struct mu_argp_node_list lst;
70
71 switch (key)
72 {
73 case OPT_SQL_INTERFACE:
74 mu_argp_node_list_new (&lst, "interface", arg);
75 break;
76
77 case OPT_SQL_GETPWNAM:
78 mu_argp_node_list_new (&lst, "getpwnam", arg);
79 break;
80
81 case OPT_SQL_GETPWUID:
82 mu_argp_node_list_new (&lst, "getpwuid", arg);
83 break;
84
85 case OPT_SQL_GETPASS:
86 mu_argp_node_list_new (&lst, "getpass", arg);
87 break;
88
89 case OPT_SQL_HOST:
90 mu_argp_node_list_new (&lst, "host", arg);
91 break;
92
93 case OPT_SQL_USER:
94 mu_argp_node_list_new (&lst, "user", arg);
95 break;
96
97 case OPT_SQL_PASSWD:
98 mu_argp_node_list_new (&lst, "passwd", arg);
99 break;
100
101 case OPT_SQL_DB:
102 mu_argp_node_list_new (&lst, "db", arg);
103 break;
104
105 case OPT_SQL_PORT:
106 mu_argp_node_list_new (&lst, "port", arg);
107 break;
108
109 case OPT_SQL_MU_PASSWORD_TYPE:
110 mu_argp_node_list_new (&lst, "password-type", arg);
111 break;
112
113 case OPT_SQL_FIELD_MAP:
114 mu_argp_node_list_new (&lst, "field-map", arg);
115 break;
116
117 case ARGP_KEY_INIT:
118 mu_argp_node_list_init (&lst);
119 break;
120
121 case ARGP_KEY_FINI:
122 mu_argp_node_list_finish (&lst, "sql", NULL);
123 break;
124
125 default:
126 return ARGP_ERR_UNKNOWN;
127 }
128 return 0;
129 }
130
131 static struct argp mu_sql_argp = {
132 mu_sql_argp_option,
133 mu_sql_argp_parser,
134 };
135
136 struct argp_child mu_sql_argp_child = {
137 &mu_sql_argp,
138 0,
139 NULL,
140 0
141 };
142
143 struct mu_cmdline_capa mu_sql_cmdline = {
144 "sql", &mu_sql_argp_child
145 };
...@@ -24,18 +24,9 @@ ...@@ -24,18 +24,9 @@
24 24
25 enum { 25 enum {
26 OPT_TLS = 256, 26 OPT_TLS = 256,
27 OPT_SSL_CERT,
28 OPT_SSL_KEY,
29 OPT_SSL_CAFILE
30 }; 27 };
31 28
32 static struct argp_option _tls_argp_options[] = { 29 static struct argp_option _tls_argp_options[] = {
33 {"ssl-cert", OPT_SSL_CERT, N_("FILE"), OPTION_HIDDEN,
34 N_("specify SSL certificate file"), 0},
35 {"ssl-key", OPT_SSL_KEY, N_("FILE"), OPTION_HIDDEN,
36 N_("specify SSL certificate key"), },
37 {"ssl-cafile", OPT_SSL_CAFILE, N_("FILE"), OPTION_HIDDEN,
38 N_("specify trusted CAs file"), 0},
39 {"tls", OPT_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL, 30 {"tls", OPT_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL,
40 N_("enable TLS support") }, 31 N_("enable TLS support") },
41 {NULL, 0, NULL, 0, NULL, 0} 32 {NULL, 0, NULL, 0, NULL, 0}
...@@ -52,18 +43,6 @@ _tls_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -52,18 +43,6 @@ _tls_argp_parser (int key, char *arg, struct argp_state *state)
52 mu_argp_node_list_new (&lst, "enable", arg ? arg : "yes"); 43 mu_argp_node_list_new (&lst, "enable", arg ? arg : "yes");
53 break; 44 break;
54 45
55 case OPT_SSL_CERT:
56 mu_argp_node_list_new (&lst, "ssl-cert", arg);
57 break;
58
59 case OPT_SSL_KEY:
60 mu_argp_node_list_new (&lst, "ssl-key", arg);
61 break;
62
63 case OPT_SSL_CAFILE:
64 mu_argp_node_list_new (&lst, "ssl-cafile", arg);
65 break;
66
67 case ARGP_KEY_INIT: 46 case ARGP_KEY_INIT:
68 mu_argp_node_list_init (&lst); 47 mu_argp_node_list_init (&lst);
69 break; 48 break;
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library; if not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 #include "cmdline.h"
24
25 #define OPT_PWDDIR 256
26
27 static error_t
28 mu_virt_argp_parser (int key, char *arg, struct argp_state *state)
29 {
30 static struct mu_argp_node_list lst;
31
32 switch (key)
33 {
34 case OPT_PWDDIR:
35 mu_argp_node_list_new (&lst, "passwd-dir", arg);
36 break;
37
38 case ARGP_KEY_INIT:
39 mu_argp_node_list_init (&lst);
40 break;
41
42 case ARGP_KEY_FINI:
43 mu_argp_node_list_finish (&lst, "virtdomain", NULL);
44 break;
45
46 default:
47 return ARGP_ERR_UNKNOWN;
48 }
49 return 0;
50 }
51
52 static struct argp_option mu_virt_argp_option[] = {
53 { "virtual-passwd-dir", OPT_PWDDIR, N_("DIR"), OPTION_HIDDEN,
54 N_("search for virtual passwd file in DIR"), 0},
55 { NULL, 0, NULL, 0, NULL, 0 }
56 };
57
58 static struct argp mu_virt_argp = {
59 mu_virt_argp_option,
60 mu_virt_argp_parser,
61 };
62
63 struct argp_child mu_virt_argp_child = {
64 &mu_virt_argp,
65 0,
66 NULL,
67 0
68 };
69
70 struct mu_cmdline_capa mu_virtdomain_cmdline = {
71 "virtdomain", &mu_virt_argp_child
72 };
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
18 #ifdef HAVE_CONFIG_H 18 #ifdef HAVE_CONFIG_H
19 # include <config.h> 19 # include <config.h>
20 #endif 20 #endif
21 #define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
21 #include "mailutils/libcfg.h" 22 #include "mailutils/libcfg.h"
22 #include <string.h> 23 #include <string.h>
23 #include <stdlib.h> 24 #include <stdlib.h>
...@@ -84,6 +85,83 @@ mu_libcfg_init (char **cnames) ...@@ -84,6 +85,83 @@ mu_libcfg_init (char **cnames)
84 } 85 }
85 86
86 int 87 int
88 mu_libcfg_parse_config (mu_cfg_tree_t **ptree)
89 {
90 int flags = 0;
91 int rc = 0;
92 mu_cfg_tree_t *tree = NULL, *tmp;
93
94 if (mu_cfg_parser_verbose)
95 flags |= MU_PARSE_CONFIG_VERBOSE;
96 if (mu_cfg_parser_verbose > 1)
97 flags |= MU_PARSE_CONFIG_DUMP;
98
99 if (mu_load_site_rcfile)
100 {
101 rc = mu_cfg_parse_file (&tmp, MU_CONFIG_FILE, flags);
102
103 if (rc == ENOMEM)
104 {
105 mu_error ("%s", mu_strerror (rc));
106 return rc;
107 }
108 else if (rc == 0)
109 {
110 mu_cfg_tree_postprocess (tmp, flags | MU_PARSE_CONFIG_GLOBAL);
111 mu_cfg_tree_union (&tree, &tmp);
112 }
113 }
114
115 if (mu_load_user_rcfile && mu_program_name)
116 {
117 size_t size = 3 + strlen (mu_program_name) + 1;
118 char *file_name = malloc (size);
119 if (file_name)
120 {
121 strcpy (file_name, "~/.");
122 strcat (file_name, mu_program_name);
123
124 rc = mu_cfg_parse_file (&tmp, file_name, flags);
125 if (rc == ENOMEM)
126 {
127 mu_error ("%s", mu_strerror (rc));
128 mu_cfg_destroy_tree (&tree);
129 return rc;
130 }
131 else if (rc == 0)
132 {
133 mu_cfg_tree_postprocess (tmp, flags);
134 mu_cfg_tree_union (&tree, &tmp);
135 }
136 free (file_name);
137 }
138 }
139
140 if (mu_load_rcfile)
141 {
142 rc = mu_cfg_parse_file (&tmp, mu_load_rcfile, flags);
143 if (rc)
144 {
145 mu_error (_("errors parsing file %s: %s"), mu_load_rcfile,
146 mu_strerror (rc));
147 mu_cfg_destroy_tree (&tree);
148 return rc;
149 }
150 else
151 {
152 mu_cfg_tree_postprocess (tmp, flags);
153 mu_cfg_tree_union (&tree, &tmp);
154 }
155 }
156
157 *ptree = tree;
158 return rc;
159 }
160
161
162
163 /* FIXME: Deprecated */
164 int
87 mu_parse_config_files (struct mu_cfg_param *param, void *target) 165 mu_parse_config_files (struct mu_cfg_param *param, void *target)
88 { 166 {
89 int flags = 0; 167 int flags = 0;
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007 Free Software Foundation 3 # Copyright (C) 2002, 2007, 2009 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -64,7 +64,7 @@ proc default_mail_start {args} { ...@@ -64,7 +64,7 @@ proc default_mail_start {args} {
64 64
65 if [info exists host_board] { 65 if [info exists host_board] {
66 if [board_info $host_board exists top_srcdir] { 66 if [board_info $host_board exists top_srcdir] {
67 append sw " --mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool" 67 append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
68 } 68 }
69 } 69 }
70 70
......
...@@ -98,6 +98,7 @@ libmailutils_la_SOURCES = \ ...@@ -98,6 +98,7 @@ libmailutils_la_SOURCES = \
98 memory_stream.c\ 98 memory_stream.c\
99 message_stream.c\ 99 message_stream.c\
100 mime.c\ 100 mime.c\
101 mkfilename.c\
101 monitor.c\ 102 monitor.c\
102 msrv.c\ 103 msrv.c\
103 mu_auth.c\ 104 mu_auth.c\
......
1 /* cfg_driver.c -- Main driver for Mailutils configuration files 1 /* cfg_driver.c -- Main driver for Mailutils configuration files
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
3 3
4 GNU Mailutils is free software; you can redistribute it and/or 4 GNU Mailutils is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as 5 modify it under the terms of the GNU General Public License as
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
27 #include <ctype.h> 27 #include <ctype.h>
28 #include <mailutils/argcv.h> 28 #include <mailutils/argcv.h>
29 #include <mailutils/nls.h> 29 #include <mailutils/nls.h>
30 #define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
30 #include <mailutils/cfg.h> 31 #include <mailutils/cfg.h>
31 #include <mailutils/errno.h> 32 #include <mailutils/errno.h>
32 #include <mailutils/error.h> 33 #include <mailutils/error.h>
...@@ -453,23 +454,6 @@ prog_parser (enum mu_cfg_section_stage stage, ...@@ -453,23 +454,6 @@ prog_parser (enum mu_cfg_section_stage stage,
453 return 0; 454 return 0;
454 } 455 }
455 456
456 static char *
457 make_file_name (const char *dir, const char *file)
458 {
459 char *tmp;
460 size_t len = strlen (dir) + 1 + strlen (file);
461 tmp = malloc (len + 1);
462 if (!tmp)
463 {
464 mu_error ("%s", mu_strerror (errno));
465 exit (1);
466 }
467 strcpy (tmp, dir);
468 strcat (tmp, "/");
469 strcat (tmp, file);
470 return tmp;
471 }
472
473 struct include_data 457 struct include_data
474 { 458 {
475 const char *progname; 459 const char *progname;
...@@ -492,13 +476,20 @@ _cb_include (mu_debug_t debug, void *data, mu_config_value_t *val) ...@@ -492,13 +476,20 @@ _cb_include (mu_debug_t debug, void *data, mu_config_value_t *val)
492 476
493 dirname = val->v.string; 477 dirname = val->v.string;
494 if (dirname[0] != '/') 478 if (dirname[0] != '/')
495 dirname = tmp = make_file_name (SYSCONFDIR, dirname); 479 {
480 dirname = tmp = mu_make_file_name (SYSCONFDIR, dirname);
481 if (!dirname)
482 {
483 mu_error ("%s", mu_strerror (errno));
484 return 1;
485 }
486 }
496 487
497 if (stat (dirname, &sb) == 0) 488 if (stat (dirname, &sb) == 0)
498 { 489 {
499 if (S_ISDIR (sb.st_mode)) 490 if (S_ISDIR (sb.st_mode))
500 { 491 {
501 char *file = make_file_name (dirname, idp->progname); 492 char *file = mu_make_file_name (dirname, idp->progname);
502 ret = mu_get_config (file, idp->progname, idp->progparam, 493 ret = mu_get_config (file, idp->progname, idp->progparam,
503 idp->flags & ~MU_PARSE_CONFIG_GLOBAL, 494 idp->flags & ~MU_PARSE_CONFIG_GLOBAL,
504 idp->target); 495 idp->target);
...@@ -528,20 +519,25 @@ struct mu_cfg_cont * ...@@ -528,20 +519,25 @@ struct mu_cfg_cont *
528 mu_build_container (const char *progname, struct include_data *idp) 519 mu_build_container (const char *progname, struct include_data *idp)
529 { 520 {
530 struct mu_cfg_cont *cont = root_container; 521 struct mu_cfg_cont *cont = root_container;
522
523 mu_config_clone_container (cont);
524
525 if (idp->flags & MU_PARSE_CONFIG_PLAIN)
526 {
531 struct mu_cfg_param mu_include_param[] = { 527 struct mu_cfg_param mu_include_param[] = {
532 { "include", mu_cfg_callback, NULL, 0, _cb_include, 528 { "include", mu_cfg_callback, NULL, 0, _cb_include,
533 N_("Include contents of the given file. If a directory is given, " 529 N_("Include contents of the given file. If a directory is given, "
534 "include contents of the file <file>/<program>, where <program> is " 530 "include contents of the file <file>/<program>, where "
535 "the name of the program. This latter form is allowed only in " 531 "<program> is the name of the program. This latter form is "
536 "the site-wide configuration file."), 532 "allowed only in the site-wide configuration file."),
537 N_("file-or-directory") }, 533 N_("file-or-directory") },
538 { NULL } 534 { NULL }
539 }; 535 };
540 536
541 mu_include_param[0].data = idp; 537 mu_include_param[0].data = idp;
542 mu_config_clone_container (cont);
543 _mu_config_register_section (&cont, NULL, NULL, NULL, 538 _mu_config_register_section (&cont, NULL, NULL, NULL,
544 (void*) progname, mu_include_param, NULL); 539 (void*) progname, mu_include_param, NULL);
540
545 if (idp->flags & MU_PARSE_CONFIG_GLOBAL) 541 if (idp->flags & MU_PARSE_CONFIG_GLOBAL)
546 { 542 {
547 mu_iterator_t iter; 543 mu_iterator_t iter;
...@@ -573,6 +569,11 @@ mu_build_container (const char *progname, struct include_data *idp) ...@@ -573,6 +569,11 @@ mu_build_container (const char *progname, struct include_data *idp)
573 else if (idp->progparam) 569 else if (idp->progparam)
574 _mu_config_register_section (&cont, NULL, NULL, NULL, NULL, 570 _mu_config_register_section (&cont, NULL, NULL, NULL, NULL,
575 idp->progparam, NULL); 571 idp->progparam, NULL);
572 }
573 else if (idp->progparam)
574 _mu_config_register_section (&cont, NULL, NULL, NULL, NULL,
575 idp->progparam, NULL);
576
576 return cont; 577 return cont;
577 } 578 }
578 579
...@@ -583,13 +584,15 @@ mu_cfg_tree_reduce (mu_cfg_tree_t *parse_tree, const char *progname, ...@@ -583,13 +584,15 @@ mu_cfg_tree_reduce (mu_cfg_tree_t *parse_tree, const char *progname,
583 { 584 {
584 int rc = 0; 585 int rc = 0;
585 586
587 if (!parse_tree)
588 return 0;
586 if (flags & MU_PARSE_CONFIG_DUMP) 589 if (flags & MU_PARSE_CONFIG_DUMP)
587 { 590 {
588 mu_stream_t stream; 591 mu_stream_t stream;
589 mu_stdio_stream_create (&stream, stderr, 592 mu_stdio_stream_create (&stream, stderr,
590 MU_STREAM_NO_CHECK|MU_STREAM_NO_CLOSE); 593 MU_STREAM_NO_CHECK|MU_STREAM_NO_CLOSE);
591 mu_stream_open (stream); 594 mu_stream_open (stream);
592 mu_cfg_format_parse_tree (stream, parse_tree); 595 mu_cfg_format_parse_tree (stream, parse_tree, MU_CFG_FMT_LOCUS);
593 mu_stream_destroy (&stream, NULL); 596 mu_stream_destroy (&stream, NULL);
594 } 597 }
595 598
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
29 29
30 struct tree_print 30 struct tree_print
31 { 31 {
32 int flags;
32 unsigned level; 33 unsigned level;
33 mu_stream_t stream; 34 mu_stream_t stream;
34 char *buf; 35 char *buf;
...@@ -131,7 +132,7 @@ format_node (const mu_cfg_node_t *node, void *data) ...@@ -131,7 +132,7 @@ format_node (const mu_cfg_node_t *node, void *data)
131 { 132 {
132 struct tree_print *tp = data; 133 struct tree_print *tp = data;
133 134
134 if (node->locus.file) 135 if ((tp->flags & MU_CFG_FMT_LOCUS) && node->locus.file)
135 mu_stream_sequential_printf (tp->stream, "# %lu \"%s\"\n", 136 mu_stream_sequential_printf (tp->stream, "# %lu \"%s\"\n",
136 (unsigned long) node->locus.line, 137 (unsigned long) node->locus.line,
137 node->locus.file); 138 node->locus.file);
...@@ -143,7 +144,7 @@ format_node (const mu_cfg_node_t *node, void *data) ...@@ -143,7 +144,7 @@ format_node (const mu_cfg_node_t *node, void *data)
143 _("ERROR: undefined statement")); 144 _("ERROR: undefined statement"));
144 break; 145 break;
145 146
146 case mu_cfg_node_tag: 147 case mu_cfg_node_statement:
147 { 148 {
148 mu_stream_sequential_write (tp->stream, node->tag, 149 mu_stream_sequential_write (tp->stream, node->tag,
149 strlen (node->tag)); 150 strlen (node->tag));
...@@ -183,17 +184,36 @@ format_node_end (const mu_cfg_node_t *node, void *data) ...@@ -183,17 +184,36 @@ format_node_end (const mu_cfg_node_t *node, void *data)
183 } 184 }
184 185
185 void 186 void
186 mu_cfg_format_parse_tree (mu_stream_t stream, mu_cfg_tree_t *tree) 187 mu_cfg_format_parse_tree (mu_stream_t stream, mu_cfg_tree_t *tree, int flags)
187 { 188 {
188 struct tree_print t; 189 struct tree_print t;
190 t.flags = flags;
189 t.level = 0; 191 t.level = 0;
190 t.stream = stream; 192 t.stream = stream;
191 t.buf = NULL; 193 t.buf = NULL;
192 t.bufsize = 0; 194 t.bufsize = 0;
193 mu_cfg_preorder (tree->node, format_node, format_node_end, &t); 195 mu_cfg_preorder (tree->head, format_node, format_node_end, &t);
194 free (t.buf); 196 free (t.buf);
195 } 197 }
196 198
199 void
200 mu_cfg_format_node (mu_stream_t stream, const mu_cfg_node_t *node, int flags)
201 {
202 struct tree_print t;
203 t.flags = flags;
204 t.level = 0;
205 t.stream = stream;
206 t.buf = NULL;
207 t.bufsize = 0;
208 format_node (node, &t);
209 if (node->type == mu_cfg_node_statement)
210 {
211 mu_cfg_preorder (node->node, format_node, format_node_end, &t);
212 format_node_end (node, &t);
213 }
214 }
215
216
197 217
198 const char * 218 const char *
199 mu_cfg_data_type_string (enum mu_cfg_param_data_type type) 219 mu_cfg_data_type_string (enum mu_cfg_param_data_type type)
......
...@@ -150,11 +150,9 @@ P [1-9][0-9]* ...@@ -150,11 +150,9 @@ P [1-9][0-9]*
150 \n { mu_cfg_locus.line++; } 150 \n { mu_cfg_locus.line++; }
151 [,;{}()] return yytext[0]; 151 [,;{}()] return yytext[0];
152 . { if (mu_isprint (yytext[0])) 152 . { if (mu_isprint (yytext[0]))
153 mu_cfg_perror (&mu_cfg_locus, 153 mu_cfg_parse_error (_("stray character %c"), yytext[0]);
154 _("stray character %c"), yytext[0]);
155 else 154 else
156 mu_cfg_perror (&mu_cfg_locus, 155 mu_cfg_parse_error (_("stray character \\%03o"),
157 _("stray character \\%03o"),
158 (unsigned char) yytext[0]); 156 (unsigned char) yytext[0]);
159 } 157 }
160 %% 158 %%
...@@ -172,7 +170,7 @@ unescape_to_line (int c) ...@@ -172,7 +170,7 @@ unescape_to_line (int c)
172 { 170 {
173 char t = mu_argcv_unquote_char (c); 171 char t = mu_argcv_unquote_char (c);
174 if (t == c && t != '\\' && t != '\"') 172 if (t == c && t != '\\' && t != '\"')
175 mu_cfg_perror (&mu_cfg_locus, _("unknown escape sequence '\\%c'"), c); 173 mu_cfg_parse_error (_("unknown escape sequence '\\%c'"), c);
176 mu_opool_append_char (pool, t); 174 mu_opool_append_char (pool, t);
177 } 175 }
178 } 176 }
...@@ -317,13 +315,11 @@ multiline_finish () ...@@ -317,13 +315,11 @@ multiline_finish ()
317 315
318 316
319 int 317 int
320 mu_get_config (const char *file, const char *progname, 318 mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags)
321 struct mu_cfg_param *progparam, int flags, void *target_ptr)
322 { 319 {
323 struct stat st; 320 struct stat st;
324 FILE *fp; 321 FILE *fp;
325 int rc; 322 int rc;
326 mu_cfg_tree_t *parse_tree;
327 323
328 if (stat (file, &st)) 324 if (stat (file, &st))
329 { 325 {
...@@ -348,20 +344,30 @@ mu_get_config (const char *file, const char *progname, ...@@ -348,20 +344,30 @@ mu_get_config (const char *file, const char *progname,
348 mu_cfg_locus.file = (char*) file; 344 mu_cfg_locus.file = (char*) file;
349 mu_cfg_locus.line = 1; 345 mu_cfg_locus.line = 1;
350 yyrestart (fp); 346 yyrestart (fp);
351 rc = mu_cfg_parse (&parse_tree); 347 rc = mu_cfg_parse (return_tree);
352 fclose (fp); 348 fclose (fp);
349 if (flags & MU_PARSE_CONFIG_VERBOSE)
350 mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"), file);
351 return rc == 0 ? 0 : MU_ERR_FAILURE;
352 }
353
354 /* FIXME: Deprecated interface */
355 int
356 mu_get_config (const char *file, const char *progname,
357 struct mu_cfg_param *progparam, int flags, void *target_ptr)
358 {
359 mu_cfg_tree_t *parse_tree;
360 int rc = mu_cfg_parse_file (&parse_tree, file, flags);
353 if (rc == 0) 361 if (rc == 0)
354 rc = mu_cfg_tree_reduce (parse_tree, progname, progparam, flags, 362 rc = mu_cfg_tree_reduce (parse_tree, progname, progparam, flags,
355 target_ptr); 363 target_ptr);
356 364
357 mu_cfg_destroy_tree (&parse_tree); 365 mu_cfg_destroy_tree (&parse_tree);
358 366
359 if (flags & MU_PARSE_CONFIG_VERBOSE)
360 mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"), file);
361
362 return rc == 0 ? 0 : MU_ERR_FAILURE; 367 return rc == 0 ? 0 : MU_ERR_FAILURE;
363 } 368 }
364 369
370
365 mu_opool_t 371 mu_opool_t
366 mu_cfg_lexer_pool () 372 mu_cfg_lexer_pool ()
367 { 373 {
......
...@@ -18,12 +18,15 @@ ...@@ -18,12 +18,15 @@
18 #ifdef HAVE_CONFIG_H 18 #ifdef HAVE_CONFIG_H
19 # include <config.h> 19 # include <config.h>
20 #endif 20 #endif
21 #include <sys/types.h>
22 #include <sys/stat.h>
21 #include <stdio.h> 23 #include <stdio.h>
22 #include <stdlib.h> 24 #include <stdlib.h>
23 #include <stdarg.h> 25 #include <stdarg.h>
24 #include <string.h> 26 #include <string.h>
25 #include <netdb.h> 27 #include <netdb.h>
26 #include "intprops.h" 28 #include "intprops.h"
29 #include <mailutils/argcv.h>
27 #include <mailutils/nls.h> 30 #include <mailutils/nls.h>
28 #include <mailutils/cfg.h> 31 #include <mailutils/cfg.h>
29 #include <mailutils/alloc.h> 32 #include <mailutils/alloc.h>
...@@ -32,9 +35,10 @@ ...@@ -32,9 +35,10 @@
32 #include <mailutils/list.h> 35 #include <mailutils/list.h>
33 #include <mailutils/iterator.h> 36 #include <mailutils/iterator.h>
34 #include <mailutils/debug.h> 37 #include <mailutils/debug.h>
38 #include <mailutils/mutil.h>
35 39
36 int mu_cfg_parser_verbose; 40 int mu_cfg_parser_verbose;
37 static mu_cfg_node_t *parse_tree; 41 static mu_cfg_node_t *parse_head, *parse_tail;
38 mu_cfg_locus_t mu_cfg_locus; 42 mu_cfg_locus_t mu_cfg_locus;
39 size_t mu_cfg_error_count; 43 size_t mu_cfg_error_count;
40 44
...@@ -50,7 +54,7 @@ char *_mu_line_finish (void); ...@@ -50,7 +54,7 @@ char *_mu_line_finish (void);
50 static int 54 static int
51 yyerror (char *s) 55 yyerror (char *s)
52 { 56 {
53 mu_cfg_perror (&mu_cfg_locus, "%s", s); 57 mu_cfg_parse_error ("%s", s);
54 return 0; 58 return 0;
55 } 59 }
56 60
...@@ -89,6 +93,13 @@ mu_cfg_alloc_node (enum mu_cfg_node_type type, mu_cfg_locus_t *loc, ...@@ -89,6 +93,13 @@ mu_cfg_alloc_node (enum mu_cfg_node_type type, mu_cfg_locus_t *loc,
89 } 93 }
90 94
91 void 95 void
96 mu_cfg_free_node (mu_cfg_node_t *node)
97 {
98 free (node->label);
99 free (node);
100 }
101
102 void
92 mu_cfg_format_error (mu_debug_t debug, size_t level, const char *fmt, ...) 103 mu_cfg_format_error (mu_debug_t debug, size_t level, const char *fmt, ...)
93 { 104 {
94 va_list ap; 105 va_list ap;
...@@ -110,8 +121,8 @@ _mu_cfg_debug_set_locus (mu_debug_t debug, const mu_cfg_locus_t *loc) ...@@ -110,8 +121,8 @@ _mu_cfg_debug_set_locus (mu_debug_t debug, const mu_cfg_locus_t *loc)
110 loc->line); 121 loc->line);
111 } 122 }
112 123
113 static void 124 void
114 _mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc, 125 mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc,
115 const char *fmt, va_list ap) 126 const char *fmt, va_list ap)
116 { 127 {
117 if (!debug) 128 if (!debug)
...@@ -123,28 +134,28 @@ _mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc, ...@@ -123,28 +134,28 @@ _mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc,
123 mu_cfg_error_count++; 134 mu_cfg_error_count++;
124 } 135 }
125 136
126 static void 137 void
127 _mu_cfg_perror (mu_debug_t debug, const mu_cfg_locus_t *loc, 138 mu_cfg_perror (mu_debug_t debug, const mu_cfg_locus_t *loc,
128 const char *fmt, ...) 139 const char *fmt, ...)
129 { 140 {
130 va_list ap; 141 va_list ap;
131 142
132 va_start (ap, fmt); 143 va_start (ap, fmt);
133 _mu_cfg_vperror (debug, loc, fmt, ap); 144 mu_cfg_vperror (debug, loc, fmt, ap);
134 va_end (ap); 145 va_end (ap);
135 } 146 }
136 147
137 void 148 void
138 mu_cfg_perror (const mu_cfg_locus_t *loc, const char *fmt, ...) 149 mu_cfg_parse_error (const char *fmt, ...)
139 { 150 {
140 va_list ap; 151 va_list ap;
141 152
142 va_start (ap, fmt); 153 va_start (ap, fmt);
143 _mu_cfg_vperror (_mu_cfg_debug, loc, fmt, ap); 154 mu_cfg_vperror (_mu_cfg_debug, &mu_cfg_locus, fmt, ap);
144 va_end (ap); 155 va_end (ap);
145 } 156 }
146 157
147 #define node_type_str(t) (((t) == mu_cfg_node_tag) ? "tag" : "param") 158 #define node_type_str(t) (((t) == mu_cfg_node_statement) ? "stmt" : "param")
148 159
149 static void 160 static void
150 debug_print_node (mu_cfg_node_t *node) 161 debug_print_node (mu_cfg_node_t *node)
...@@ -194,7 +205,8 @@ debug_print_node (mu_cfg_node_t *node) ...@@ -194,7 +205,8 @@ debug_print_node (mu_cfg_node_t *node)
194 205
195 input : stmtlist 206 input : stmtlist
196 { 207 {
197 parse_tree = $1.head; 208 parse_head = $1.head;
209 parse_tail = $1.tail;
198 } 210 }
199 ; 211 ;
200 212
...@@ -226,14 +238,14 @@ simple : ident vallist ';' ...@@ -226,14 +238,14 @@ simple : ident vallist ';'
226 238
227 block : ident tag '{' '}' opt_sc 239 block : ident tag '{' '}' opt_sc
228 { 240 {
229 $$ = mu_cfg_alloc_node (mu_cfg_node_tag, &$1.locus, 241 $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &$1.locus,
230 $1.name, $2, 242 $1.name, $2,
231 NULL); 243 NULL);
232 244
233 } 245 }
234 | ident tag '{' stmtlist '}' opt_sc 246 | ident tag '{' stmtlist '}' opt_sc
235 { 247 {
236 $$ = mu_cfg_alloc_node (mu_cfg_node_tag, &$1.locus, 248 $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &$1.locus,
237 $1.name, $2, 249 $1.name, $2,
238 $4.head); 250 $4.head);
239 251
...@@ -273,7 +285,7 @@ vallist : vlist ...@@ -273,7 +285,7 @@ vallist : vlist
273 val.v.arg.v = mu_alloc (n * sizeof (val.v.arg.v[0])); 285 val.v.arg.v = mu_alloc (n * sizeof (val.v.arg.v[0]));
274 if (!val.v.arg.v) 286 if (!val.v.arg.v)
275 { 287 {
276 mu_cfg_perror (&mu_cfg_locus, _("not enough memory")); 288 mu_cfg_parse_error (_("not enough memory"));
277 abort(); 289 abort();
278 } 290 }
279 291
...@@ -294,7 +306,7 @@ vlist : value ...@@ -294,7 +306,7 @@ vlist : value
294 int rc = mu_list_create (&$$); 306 int rc = mu_list_create (&$$);
295 if (rc) 307 if (rc)
296 { 308 {
297 mu_cfg_perror (&mu_cfg_locus, _("cannot create list: %s"), 309 mu_cfg_parse_error (_("cannot create list: %s"),
298 mu_strerror (rc)); 310 mu_strerror (rc));
299 abort (); 311 abort ();
300 } 312 }
...@@ -430,13 +442,184 @@ mu_cfg_parse (mu_cfg_tree_t **ptree) ...@@ -430,13 +442,184 @@ mu_cfg_parse (mu_cfg_tree_t **ptree)
430 442
431 tree = mu_alloc (sizeof (*tree)); 443 tree = mu_alloc (sizeof (*tree));
432 tree->debug = _mu_cfg_debug; 444 tree->debug = _mu_cfg_debug;
433 tree->node = parse_tree; 445 tree->head = parse_head;
446 tree->tail = parse_tail;
434 tree->pool = mu_cfg_lexer_pool (); 447 tree->pool = mu_cfg_lexer_pool ();
435 parse_tree = NULL; 448 parse_head = parse_tail = NULL;
436 *ptree = tree; 449 *ptree = tree;
437 return rc; 450 return rc;
438 } 451 }
439 452
453 int
454 mu_cfg_tree_union (mu_cfg_tree_t **pa, mu_cfg_tree_t **pb)
455 {
456 mu_cfg_tree_t *a, *b;
457 int rc;
458
459 if (!pb)
460 return EINVAL;
461 if (!*pb)
462 return 0;
463 b = *pb;
464 if (!pa)
465 return EINVAL;
466 if (!*pa)
467 {
468 *pa = b;
469 *pb = NULL;
470 return 0;
471 }
472 else
473 a = *pa;
474
475 /* Merge opools */
476 rc = mu_opool_union (&b->pool, &a->pool);
477 if (rc)
478 return rc;
479
480 /* Link node lists */
481 if (a->tail)
482 a->tail->next = b->head;
483 else
484 a->head = b->head;
485 a->tail = b->tail;
486
487 mu_debug_destroy (&b->debug, mu_debug_get_owner (b->debug));
488 free (b);
489 *pb = NULL;
490 return 0;
491 }
492
493 static mu_cfg_tree_t *
494 do_include (const char *name, int flags, mu_cfg_locus_t *loc)
495 {
496 struct stat sb;
497 char *tmpname = NULL;
498 mu_cfg_tree_t *tree = NULL;
499
500 if (name[0] != '/')
501 {
502 name = tmpname = mu_make_file_name (SYSCONFDIR, name);
503 if (!name)
504 {
505 mu_error ("%s", mu_strerror (errno));
506 return NULL;
507 }
508 }
509 if (stat (name, &sb) == 0)
510 {
511 int rc = 0;
512
513 if (S_ISDIR (sb.st_mode))
514 {
515 if (flags & MU_PARSE_CONFIG_GLOBAL)
516 {
517 char *file = mu_make_file_name (name, mu_program_name);
518 rc = mu_cfg_parse_file (&tree, file, flags);
519 }
520 }
521 else
522 rc = mu_cfg_parse_file (&tree, name, flags);
523
524 if (rc == 0 && tree)
525 mu_cfg_tree_postprocess (tree, flags & ~MU_PARSE_CONFIG_GLOBAL);
526 }
527 else if (errno == ENOENT)
528 mu_cfg_perror (tree->debug, loc,
529 _("include file or directory does not exist"));
530 else
531 mu_cfg_perror (tree->debug, loc,
532 _("cannot stat include file or directory: %s"),
533 mu_strerror (errno));
534 free (tmpname);
535 return tree;
536 }
537
538 int
539 mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, int flags)
540 {
541 mu_cfg_node_t *prev, *node;
542
543 for (prev = NULL, node = tree->head; node; )
544 {
545 mu_cfg_node_t *next = node->next;
546
547 if (node->type == mu_cfg_node_statement)
548 {
549 if ((flags & MU_PARSE_CONFIG_GLOBAL) &&
550 strcmp (node->tag, "program") == 0)
551 {
552 if (node->label->type == MU_CFG_STRING)
553 {
554 if (strcmp (node->label->v.string, mu_program_name) == 0)
555 {
556 mu_cfg_node_t *p;
557
558 /* Move all nodes from this block to the topmost
559 level */
560 if (prev)
561 prev->next = node->node;
562 else
563 tree->head = node->node;
564 p = node->node;
565 mu_cfg_free_node (node);
566 for (node = prev->next; node->next; node = node->next)
567 ;
568 node->next = next;
569 }
570 }
571 else
572 {
573 mu_cfg_perror (tree->debug, &node->locus,
574 _("argument to `program' is not a string"));
575 if (prev)
576 prev->next = next;
577 else
578 tree->head = next;
579 mu_cfg_free_node (node);
580 }
581 }
582 }
583 else if (node->type == mu_cfg_node_param &&
584 strcmp (node->tag, "include") == 0)
585 {
586 /* Remove node from the list */
587 if (prev)
588 prev->next = next;
589 else
590 tree->head = next;
591
592 if (node->label->type == MU_CFG_STRING)
593 {
594 mu_cfg_tree_t *t = do_include (node->label->v.string, flags,
595 &node->locus);
596 if (t)
597 {
598 if (prev)
599 prev->next = t->head;
600 else
601 tree->head = t->head;
602
603 t->tail->next = next;
604
605 /* FIXME: check return value */
606 mu_opool_union (&tree->pool, &t->pool);
607 mu_debug_destroy (&t->debug, NULL);
608 free (t);
609 }
610 }
611 else
612 mu_cfg_perror (tree->debug, &node->locus,
613 _("argument to `include' is not a string"));
614 mu_cfg_free_node (node);
615 }
616
617 prev = node;
618 node = next;
619 }
620 return 0;
621 }
622
440 static int 623 static int
441 _mu_cfg_preorder_recursive (mu_cfg_node_t *node, 624 _mu_cfg_preorder_recursive (mu_cfg_node_t *node,
442 mu_cfg_iter_func_t beg, mu_cfg_iter_func_t end, 625 mu_cfg_iter_func_t beg, mu_cfg_iter_func_t end,
...@@ -447,7 +630,7 @@ _mu_cfg_preorder_recursive (mu_cfg_node_t *node, ...@@ -447,7 +630,7 @@ _mu_cfg_preorder_recursive (mu_cfg_node_t *node,
447 case mu_cfg_node_undefined: 630 case mu_cfg_node_undefined:
448 abort (); 631 abort ();
449 632
450 case mu_cfg_node_tag: 633 case mu_cfg_node_statement:
451 switch (beg (node, data)) 634 switch (beg (node, data))
452 { 635 {
453 case MU_CFG_ITER_OK: 636 case MU_CFG_ITER_OK:
...@@ -491,7 +674,7 @@ _mu_cfg_postorder_recursive(mu_cfg_node_t *node, ...@@ -491,7 +674,7 @@ _mu_cfg_postorder_recursive(mu_cfg_node_t *node,
491 case mu_cfg_node_undefined: 674 case mu_cfg_node_undefined:
492 abort (); 675 abort ();
493 676
494 case mu_cfg_node_tag: 677 case mu_cfg_node_statement:
495 switch (beg (node, data)) 678 switch (beg (node, data))
496 { 679 {
497 case MU_CFG_ITER_OK: 680 case MU_CFG_ITER_OK:
...@@ -532,7 +715,7 @@ mu_cfg_postorder (mu_cfg_node_t *node, ...@@ -532,7 +715,7 @@ mu_cfg_postorder (mu_cfg_node_t *node,
532 static int 715 static int
533 free_section (const mu_cfg_node_t *node, void *data) 716 free_section (const mu_cfg_node_t *node, void *data)
534 { 717 {
535 if (node->type == mu_cfg_node_tag) 718 if (node->type == mu_cfg_node_statement)
536 free ((void *) node); 719 free ((void *) node);
537 return MU_CFG_ITER_OK; 720 return MU_CFG_ITER_OK;
538 } 721 }
...@@ -551,7 +734,7 @@ mu_cfg_destroy_tree (mu_cfg_tree_t **ptree) ...@@ -551,7 +734,7 @@ mu_cfg_destroy_tree (mu_cfg_tree_t **ptree)
551 if (ptree && *ptree) 734 if (ptree && *ptree)
552 { 735 {
553 mu_cfg_tree_t *tree = *ptree; 736 mu_cfg_tree_t *tree = *ptree;
554 mu_cfg_postorder (tree->node, free_param, free_section, NULL); 737 mu_cfg_postorder (tree->head, free_param, free_section, NULL);
555 mu_opool_destroy (&tree->pool); 738 mu_opool_destroy (&tree->pool);
556 *ptree = NULL; 739 *ptree = NULL;
557 } 740 }
...@@ -643,7 +826,7 @@ push_section (struct scan_tree_data *dat, struct mu_cfg_section *sec) ...@@ -643,7 +826,7 @@ push_section (struct scan_tree_data *dat, struct mu_cfg_section *sec)
643 struct mu_cfg_section_list *p = mu_alloc (sizeof *p); 826 struct mu_cfg_section_list *p = mu_alloc (sizeof *p);
644 if (!p) 827 if (!p)
645 { 828 {
646 _mu_cfg_perror (dat->tree->debug, NULL, _("not enough memory")); 829 mu_cfg_perror (dat->tree->debug, NULL, _("not enough memory"));
647 return 1; 830 return 1;
648 } 831 }
649 p->sec = sec; 832 p->sec = sec;
...@@ -680,12 +863,12 @@ pop_section (struct scan_tree_data *dat) ...@@ -680,12 +863,12 @@ pop_section (struct scan_tree_data *dat)
680 break; \ 863 break; \
681 if (x <= sum) \ 864 if (x <= sum) \
682 { \ 865 { \
683 _mu_cfg_perror (d, loc, _("numeric overflow")); \ 866 mu_cfg_perror (d, loc, _("numeric overflow")); \
684 return 1; \ 867 return 1; \
685 } \ 868 } \
686 else if (limit && x > limit) \ 869 else if (limit && x > limit) \
687 { \ 870 { \
688 _mu_cfg_perror (d, loc, \ 871 mu_cfg_perror (d, loc, \
689 _("value out of allowed range")); \ 872 _("value out of allowed range")); \
690 return 1; \ 873 return 1; \
691 } \ 874 } \
...@@ -721,7 +904,7 @@ pop_section (struct scan_tree_data *dat) ...@@ -721,7 +904,7 @@ pop_section (struct scan_tree_data *dat)
721 STRxTONUM (s, type, tmpres, 0, d, loc); \ 904 STRxTONUM (s, type, tmpres, 0, d, loc); \
722 if (*s) \ 905 if (*s) \
723 { \ 906 { \
724 _mu_cfg_perror (d, loc, \ 907 mu_cfg_perror (d, loc, \
725 _("not a number (stopped near `%s')"), \ 908 _("not a number (stopped near `%s')"), \
726 s); \ 909 s); \
727 return 1; \ 910 return 1; \
...@@ -752,7 +935,7 @@ pop_section (struct scan_tree_data *dat) ...@@ -752,7 +935,7 @@ pop_section (struct scan_tree_data *dat)
752 STRxTONUM (s, unsigned type, tmpres, limit, d, loc); \ 935 STRxTONUM (s, unsigned type, tmpres, limit, d, loc); \
753 if (*s) \ 936 if (*s) \
754 { \ 937 { \
755 _mu_cfg_perror (d, loc, \ 938 mu_cfg_perror (d, loc, \
756 _("not a number (stopped near `%s')"), \ 939 _("not a number (stopped near `%s')"), \
757 s); \ 940 s); \
758 return 1; \ 941 return 1; \
...@@ -767,7 +950,7 @@ parse_ipv4 (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -767,7 +950,7 @@ parse_ipv4 (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
767 struct in_addr addr; 950 struct in_addr addr;
768 if (inet_aton (str, &addr) == 0) 951 if (inet_aton (str, &addr) == 0)
769 { 952 {
770 _mu_cfg_perror (sdata->tree->debug, locus, _("not an IPv4")); 953 mu_cfg_perror (sdata->tree->debug, locus, _("not an IPv4"));
771 return 1; 954 return 1;
772 } 955 }
773 addr.s_addr = ntohl (addr.s_addr); 956 addr.s_addr = ntohl (addr.s_addr);
...@@ -787,7 +970,7 @@ parse_host (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -787,7 +970,7 @@ parse_host (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
787 } 970 }
788 else if (inet_aton (str, &addr) == 0) 971 else if (inet_aton (str, &addr) == 0)
789 { 972 {
790 _mu_cfg_perror (sdata->tree->debug, locus, 973 mu_cfg_perror (sdata->tree->debug, locus,
791 _("cannot resolve hostname `%s'"), 974 _("cannot resolve hostname `%s'"),
792 str); 975 str);
793 return 1; 976 return 1;
...@@ -811,7 +994,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -811,7 +994,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
811 { 994 {
812 int len = p - str; 995 int len = p - str;
813 if (len > sizeof astr - 1) { 996 if (len > sizeof astr - 1) {
814 _mu_cfg_perror (sdata->tree->debug, locus, 997 mu_cfg_perror (sdata->tree->debug, locus,
815 _("not a valid IPv4 address in CIDR")); 998 _("not a valid IPv4 address in CIDR"));
816 return 1; 999 return 1;
817 } 1000 }
...@@ -819,7 +1002,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -819,7 +1002,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
819 astr[len] = 0; 1002 astr[len] = 0;
820 if (inet_aton (astr, &addr) == 0) 1003 if (inet_aton (astr, &addr) == 0)
821 { 1004 {
822 _mu_cfg_perror (sdata->tree->debug, locus, 1005 mu_cfg_perror (sdata->tree->debug, locus,
823 _("not a valid IPv4 address in CIDR")); 1006 _("not a valid IPv4 address in CIDR"));
824 return 1; 1007 return 1;
825 } 1008 }
...@@ -833,7 +1016,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -833,7 +1016,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
833 struct in_addr a; 1016 struct in_addr a;
834 if (inet_aton (p, &a) == 0) 1017 if (inet_aton (p, &a) == 0)
835 { 1018 {
836 _mu_cfg_perror (sdata->tree->debug, locus, 1019 mu_cfg_perror (sdata->tree->debug, locus,
837 _("not a valid network in CIDR")); 1020 _("not a valid network in CIDR"));
838 return 1; 1021 return 1;
839 } 1022 }
...@@ -847,7 +1030,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -847,7 +1030,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
847 } 1030 }
848 else if (mask > 32) 1031 else if (mask > 32)
849 { 1032 {
850 _mu_cfg_perror (sdata->tree->debug, locus, 1033 mu_cfg_perror (sdata->tree->debug, locus,
851 _("not a valid network mask in CIDR")); 1034 _("not a valid network mask in CIDR"));
852 return 1; 1035 return 1;
853 } 1036 }
...@@ -869,7 +1052,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -869,7 +1052,7 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
869 1052
870 if (*p) 1053 if (*p)
871 { 1054 {
872 _mu_cfg_perror (sdata->tree->debug, locus, 1055 mu_cfg_perror (sdata->tree->debug, locus,
873 _("not a CIDR (stopped near `%s')"), 1056 _("not a CIDR (stopped near `%s')"),
874 p); 1057 p);
875 return 1; 1058 return 1;
...@@ -911,7 +1094,7 @@ parse_bool (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -911,7 +1094,7 @@ parse_bool (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
911 { 1094 {
912 if (mu_cfg_parse_boolean (str, res)) 1095 if (mu_cfg_parse_boolean (str, res))
913 { 1096 {
914 _mu_cfg_perror (sdata->tree->debug, locus, _("not a boolean")); 1097 mu_cfg_perror (sdata->tree->debug, locus, _("not a boolean"));
915 return 1; 1098 return 1;
916 } 1099 }
917 return 0; 1100 return 0;
...@@ -924,8 +1107,7 @@ valcvt (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -924,8 +1107,7 @@ valcvt (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
924 { 1107 {
925 if (val->type != MU_CFG_STRING) 1108 if (val->type != MU_CFG_STRING)
926 { 1109 {
927 _mu_cfg_perror (sdata->tree->debug, locus, 1110 mu_cfg_perror (sdata->tree->debug, locus, _("expected string value"));
928 _("expected string value"));
929 return 1; 1111 return 1;
930 } 1112 }
931 switch (type) 1113 switch (type)
...@@ -972,8 +1154,7 @@ valcvt (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus, ...@@ -972,8 +1154,7 @@ valcvt (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
972 break; 1154 break;
973 1155
974 case mu_cfg_off: 1156 case mu_cfg_off:
975 _mu_cfg_perror (sdata->tree->debug, locus, 1157 mu_cfg_perror (sdata->tree->debug, locus, _("not implemented yet"));
976 _("not implemented yet"));
977 /* GETSNUM(node->tag_label, off_t, *(off_t*)tgt); */ 1158 /* GETSNUM(node->tag_label, off_t, *(off_t*)tgt); */
978 return 1; 1159 return 1;
979 1160
...@@ -1046,7 +1227,7 @@ _set_fun (void *item, void *data) ...@@ -1046,7 +1227,7 @@ _set_fun (void *item, void *data)
1046 if (clos->type >= MU_ARRAY_SIZE(config_type_size) 1227 if (clos->type >= MU_ARRAY_SIZE(config_type_size)
1047 || (size = config_type_size[clos->type]) == 0) 1228 || (size = config_type_size[clos->type]) == 0)
1048 { 1229 {
1049 _mu_cfg_perror (clos->sdata->tree->debug, clos->locus, 1230 mu_cfg_perror (clos->sdata->tree->debug, clos->locus,
1050 _("INTERNAL ERROR at %s:%d: unhandled data type %d"), 1231 _("INTERNAL ERROR at %s:%d: unhandled data type %d"),
1051 __FILE__, __LINE__, clos->type); 1232 __FILE__, __LINE__, clos->type);
1052 return 1; 1233 return 1;
...@@ -1055,7 +1236,7 @@ _set_fun (void *item, void *data) ...@@ -1055,7 +1236,7 @@ _set_fun (void *item, void *data)
1055 tgt = mu_alloc (size); 1236 tgt = mu_alloc (size);
1056 if (!tgt) 1237 if (!tgt)
1057 { 1238 {
1058 _mu_cfg_perror (clos->sdata->tree->debug, clos->locus, 1239 mu_cfg_perror (clos->sdata->tree->debug, clos->locus,
1059 _("not enough memory")); 1240 _("not enough memory"));
1060 return 1; 1241 return 1;
1061 } 1242 }
...@@ -1075,7 +1256,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node) ...@@ -1075,7 +1256,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
1075 1256
1076 if (!param) 1257 if (!param)
1077 { 1258 {
1078 _mu_cfg_perror (sdata->tree->debug, &node->locus, 1259 mu_cfg_perror (sdata->tree->debug, &node->locus,
1079 _("unknown keyword `%s'"), 1260 _("unknown keyword `%s'"),
1080 node->tag); 1261 node->tag);
1081 return 1; 1262 return 1;
...@@ -1091,7 +1272,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node) ...@@ -1091,7 +1272,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
1091 tgt = NULL; 1272 tgt = NULL;
1092 else 1273 else
1093 { 1274 {
1094 _mu_cfg_perror (sdata->tree->debug, &node->locus, 1275 mu_cfg_perror (sdata->tree->debug, &node->locus,
1095 _("INTERNAL ERROR: cannot determine target offset for " 1276 _("INTERNAL ERROR: cannot determine target offset for "
1096 "%s"), param->ident); 1277 "%s"), param->ident);
1097 abort (); 1278 abort ();
...@@ -1119,7 +1300,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node) ...@@ -1119,7 +1300,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
1119 break; 1300 break;
1120 1301
1121 case MU_CFG_ARRAY: 1302 case MU_CFG_ARRAY:
1122 _mu_cfg_perror (sdata->tree->debug, &node->locus, 1303 mu_cfg_perror (sdata->tree->debug, &node->locus,
1123 _("expected list, but found array")); 1304 _("expected list, but found array"));
1124 return 1; 1305 return 1;
1125 } 1306 }
...@@ -1134,7 +1315,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node) ...@@ -1134,7 +1315,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
1134 node->locus.line); 1315 node->locus.line);
1135 if (!param->callback) 1316 if (!param->callback)
1136 { 1317 {
1137 _mu_cfg_perror (sdata->tree->debug, &node->locus, 1318 mu_cfg_perror (sdata->tree->debug, &node->locus,
1138 _("INTERNAL ERROR: %s: callback not defined"), 1319 _("INTERNAL ERROR: %s: callback not defined"),
1139 node->tag); 1320 node->tag);
1140 abort (); 1321 abort ();
...@@ -1161,7 +1342,7 @@ _scan_tree_helper (const mu_cfg_node_t *node, void *data) ...@@ -1161,7 +1342,7 @@ _scan_tree_helper (const mu_cfg_node_t *node, void *data)
1161 case mu_cfg_node_undefined: 1342 case mu_cfg_node_undefined:
1162 abort (); 1343 abort ();
1163 1344
1164 case mu_cfg_node_tag: 1345 case mu_cfg_node_statement:
1165 sec = find_subsection (sdata->list->sec, node->tag, 0); 1346 sec = find_subsection (sdata->list->sec, node->tag, 0);
1166 if (!sec) 1347 if (!sec)
1167 { 1348 {
...@@ -1219,7 +1400,7 @@ _scan_tree_end_helper (const mu_cfg_node_t *node, void *data) ...@@ -1219,7 +1400,7 @@ _scan_tree_end_helper (const mu_cfg_node_t *node, void *data)
1219 default: 1400 default:
1220 abort (); 1401 abort ();
1221 1402
1222 case mu_cfg_node_tag: 1403 case mu_cfg_node_statement:
1223 sec = pop_section (sdata); 1404 sec = pop_section (sdata);
1224 if (sec && sec->parser) 1405 if (sec && sec->parser)
1225 { 1406 {
...@@ -1253,7 +1434,7 @@ mu_cfg_scan_tree (mu_cfg_tree_t *tree, struct mu_cfg_section *sections, ...@@ -1253,7 +1434,7 @@ mu_cfg_scan_tree (mu_cfg_tree_t *tree, struct mu_cfg_section *sections,
1253 } 1434 }
1254 if (push_section (&dat, sections)) 1435 if (push_section (&dat, sections))
1255 return 1; 1436 return 1;
1256 mu_cfg_preorder (tree->node, _scan_tree_helper, _scan_tree_end_helper, &dat); 1437 mu_cfg_preorder (tree->head, _scan_tree_helper, _scan_tree_end_helper, &dat);
1257 if (debug) 1438 if (debug)
1258 { 1439 {
1259 mu_debug_set_locus (debug, NULL, 0); 1440 mu_debug_set_locus (debug, NULL, 0);
...@@ -1273,13 +1454,13 @@ mu_cfg_find_section (struct mu_cfg_section *root_sec, ...@@ -1273,13 +1454,13 @@ mu_cfg_find_section (struct mu_cfg_section *root_sec,
1273 size_t len; 1454 size_t len;
1274 const char *p; 1455 const char *p;
1275 1456
1276 while (*path == '/') 1457 while (*path == MU_CFG_PATH_DELIM)
1277 path++; 1458 path++;
1278 1459
1279 if (*path == 0) 1460 if (*path == 0)
1280 return MU_ERR_NOENT; 1461 return MU_ERR_NOENT;
1281 1462
1282 p = strchr (path, '/'); 1463 p = strchr (path, MU_CFG_PATH_DELIM);
1283 if (p) 1464 if (p)
1284 len = p - path; 1465 len = p - path;
1285 else 1466 else
...@@ -1354,13 +1535,275 @@ mu_cfg_tree_create_node (struct mu_cfg_tree *tree, ...@@ -1354,13 +1535,275 @@ mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
1354 void 1535 void
1355 mu_cfg_tree_add_node (mu_cfg_tree_t *tree, mu_cfg_node_t *node) 1536 mu_cfg_tree_add_node (mu_cfg_tree_t *tree, mu_cfg_node_t *node)
1356 { 1537 {
1357 if (!tree->node) 1538 if (!tree->head)
1358 tree->node = node; 1539 tree->head = node;
1359 else 1540 else
1360 { 1541 {
1361 mu_cfg_node_t *p; 1542 mu_cfg_node_t *p;
1362 for (p = tree->node; p->next; p = p->next) 1543 for (p = tree->head; p->next; p = p->next)
1363 ; 1544 ;
1364 p->next = node; 1545 p->next = node;
1365 } 1546 }
1366 } 1547 }
1548
1549 /* Return 1 if configuration value A equals B */
1550 int
1551 mu_cfg_value_eq (mu_config_value_t *a, mu_config_value_t *b)
1552 {
1553 if (a->type != b->type)
1554 return 0;
1555 switch (a->type)
1556 {
1557 case MU_CFG_STRING:
1558 if (a->v.string == NULL)
1559 return b->v.string == NULL;
1560 return strcmp (a->v.string, b->v.string) == 0;
1561
1562 case MU_CFG_LIST:
1563 {
1564 int ret = 1;
1565 size_t cnt;
1566 size_t i;
1567 mu_iterator_t aitr, bitr;
1568
1569 mu_list_count (a->v.list, &cnt);
1570 mu_list_count (b->v.list, &i);
1571 if (i != cnt)
1572 return 1;
1573
1574 mu_list_get_iterator (a->v.list, &aitr);
1575 mu_list_get_iterator (b->v.list, &bitr);
1576 for (i = 0,
1577 mu_iterator_first (aitr),
1578 mu_iterator_first (bitr);
1579 !mu_iterator_is_done (aitr) && !mu_iterator_is_done (bitr);
1580 mu_iterator_next (aitr),
1581 mu_iterator_next (bitr),
1582 i++)
1583 {
1584 mu_config_value_t *ap, *bp;
1585 mu_iterator_current (aitr, (void**)&ap);
1586 mu_iterator_current (bitr, (void**)&bp);
1587 ret = mu_cfg_value_eq (ap, bp);
1588 if (!ret)
1589 break;
1590 }
1591 mu_iterator_destroy (&aitr);
1592 mu_iterator_destroy (&bitr);
1593 return ret && i == cnt;
1594 }
1595
1596 case MU_CFG_ARRAY:
1597 if (a->v.arg.c == b->v.arg.c)
1598 {
1599 size_t i;
1600 for (i = 0; i < a->v.arg.c; i++)
1601 if (!mu_cfg_value_eq (&a->v.arg.v[i], &b->v.arg.v[i]))
1602 return 0;
1603 return 1;
1604 }
1605 }
1606 return 0;
1607 }
1608
1609
1610 struct find_data
1611 {
1612 int argc;
1613 char **argv;
1614 int tag;
1615 mu_config_value_t *label;
1616 const mu_cfg_node_t *node;
1617 };
1618
1619 static void
1620 free_value_mem (mu_config_value_t *p)
1621 {
1622 switch (p->type)
1623 {
1624 case MU_CFG_STRING:
1625 free ((char*)p->v.string);
1626 break;
1627
1628 case MU_CFG_LIST:
1629 /* FIXME */
1630 break;
1631
1632 case MU_CFG_ARRAY:
1633 {
1634 size_t i;
1635 for (i = 0; i < p->v.arg.c; i++)
1636 free_value_mem (&p->v.arg.v[i]);
1637 }
1638 }
1639 }
1640
1641 static void
1642 destroy_value (void *p)
1643 {
1644 mu_config_value_t *val = p;
1645 if (val)
1646 {
1647 free_value_mem (val);
1648 free (val);
1649 }
1650 }
1651
1652 static mu_config_value_t *
1653 parse_label (const char *str)
1654 {
1655 mu_config_value_t *val = NULL;
1656 int count, i;
1657 char **vect;
1658 size_t len = strlen (str);
1659
1660 if (len > 1 && str[0] == '(' && str[len-1] == ')')
1661 {
1662 mu_list_t lst;
1663 mu_argcv_get_np (str + 1, len - 2,
1664 ", \t", NULL,
1665 0,
1666 &count, &vect, NULL);
1667 mu_list_create (&lst);
1668 mu_list_set_destroy_item (lst, destroy_value);
1669 for (i = 0; i < count; i++)
1670 {
1671 mu_config_value_t *p = mu_alloc (sizeof (*p));
1672 p->type = MU_CFG_STRING;
1673 p->v.string = vect[i];
1674 mu_list_append (lst, p);
1675 }
1676 free (vect);
1677 val = mu_alloc (sizeof (*val));
1678 val->type = MU_CFG_LIST;
1679 val->v.list = lst;
1680 }
1681 else
1682 {
1683 mu_argcv_get (str, NULL, NULL, &count, &vect);
1684 val = mu_alloc (sizeof (*val));
1685 if (count == 1)
1686 {
1687 val->type = MU_CFG_STRING;
1688 val->v.string = vect[0];
1689 free (vect);
1690 }
1691 else
1692 {
1693 val->type = MU_CFG_ARRAY;
1694 val->v.arg.c = count;
1695 val->v.arg.v = mu_alloc (count * sizeof (val->v.arg.v[0]));
1696 for (i = 0; i < count; i++)
1697 {
1698 val->v.arg.v[i].type = MU_CFG_STRING;
1699 val->v.arg.v[i].v.string = vect[i];
1700 }
1701 free (vect);
1702 }
1703 }
1704 return val;
1705 }
1706
1707 static void
1708 parse_tag (struct find_data *fptr)
1709 {
1710 char *p = strchr (fptr->argv[fptr->tag], '=');
1711 if (p)
1712 {
1713 *p++ = 0;
1714 fptr->label = parse_label (p);
1715 }
1716 else
1717 fptr->label = NULL;
1718 }
1719
1720 static int
1721 node_finder (const mu_cfg_node_t *node, void *data)
1722 {
1723 struct find_data *fdptr = data;
1724 if (strcmp (fdptr->argv[fdptr->tag], node->tag) == 0
1725 && (!fdptr->label || mu_cfg_value_eq (fdptr->label, node->label)))
1726 {
1727 fdptr->tag++;
1728 if (fdptr->tag == fdptr->argc)
1729 {
1730 fdptr->node = node;
1731 return MU_CFG_ITER_STOP;
1732 }
1733 parse_tag (fdptr);
1734 return MU_CFG_ITER_OK;
1735 }
1736
1737 return node->type == mu_cfg_node_statement ?
1738 MU_CFG_ITER_SKIP : MU_CFG_ITER_OK;
1739 }
1740
1741 int
1742 mu_cfg_find_node (mu_cfg_node_t *tree, const char *path, mu_cfg_node_t **pval)
1743 {
1744 int rc;
1745 struct find_data data;
1746
1747 rc = mu_argcv_get_np (path, strlen (path),
1748 MU_CFG_PATH_DELIM_STR, NULL,
1749 0, &data.argc, &data.argv, NULL);
1750 if (rc)
1751 return rc;
1752 data.tag = 0;
1753 parse_tag (&data);
1754 rc = mu_cfg_preorder (tree, node_finder, NULL, &data);
1755 destroy_value (data.label);
1756 if (rc)
1757 {
1758 *pval = (mu_cfg_node_t *) data.node;
1759 return 0;
1760 }
1761 return MU_ERR_NOENT;
1762 }
1763
1764
1765
1766 int
1767 mu_cfg_create_subtree (const char *path, mu_cfg_node_t **pnode)
1768 {
1769 int rc;
1770 int argc, i;
1771 char **argv;
1772 mu_cfg_locus_t locus;
1773 enum mu_cfg_node_type type;
1774 mu_cfg_node_t *node = NULL;
1775
1776 locus.file = "<int>";
1777 locus.line = 0;
1778
1779 rc = mu_argcv_get_np (path, strlen (path), MU_CFG_PATH_DELIM_STR, NULL, 0,
1780 &argc, &argv, NULL);
1781 if (rc)
1782 return rc;
1783
1784 for (i = argc - 1; i >= 0; i--)
1785 {
1786 char *p = strrchr (argv[i], '=');
1787 mu_config_value_t *label = NULL;
1788
1789 type = mu_cfg_node_statement;
1790 if (p)
1791 {
1792 *p++ = 0;
1793 label = parse_label (p);
1794 if (i == argc - 1)
1795 type = mu_cfg_node_param;
1796 }
1797
1798 node = mu_cfg_alloc_node (type, &locus, argv[i], label, node);
1799 }
1800
1801 mu_argcv_free (argc, argv);
1802 *pnode = node;
1803 return 0;
1804 }
1805
1806
1807
1808
1809
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2009 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library. If not,
16 see <http://www.gnu.org/licenses/>. */
17
18 #if HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <mailutils/alloc.h>
25 #include <mailutils/mutil.h>
26
27 char *
28 mu_make_file_name (const char *dir, const char *file)
29 {
30 char *tmp;
31 size_t dirlen = strlen (dir);
32 size_t len;
33
34 while (dirlen > 0 && dir[dirlen-1] == '/')
35 dirlen--;
36
37 len = dirlen + 1 + strlen (file);
38 tmp = mu_alloc (len + 1);
39 if (tmp)
40 {
41 memcpy (tmp, dir, dirlen);
42 tmp[dirlen++] = '/';
43 strcpy (tmp + dirlen, file);
44 }
45 return tmp;
46 }
...@@ -291,37 +291,6 @@ mu_cpystr (char *dst, const char *src, size_t size) ...@@ -291,37 +291,6 @@ mu_cpystr (char *dst, const char *src, size_t size)
291 return len; 291 return len;
292 } 292 }
293 293
294 /* General retrieve stack support: */
295
296 void
297 mu_register_retriever (mu_list_t *pflist, mu_retrieve_fp fun)
298 {
299 if (!*pflist && mu_list_create (pflist))
300 return;
301 mu_list_append (*pflist, fun);
302 }
303
304 void *
305 mu_retrieve (mu_list_t flist, void *data)
306 {
307 void *p = NULL;
308 mu_iterator_t itr;
309
310 if (mu_list_get_iterator (flist, &itr) == 0)
311 {
312 mu_retrieve_fp fun;
313 for (mu_iterator_first (itr); !p && !mu_iterator_is_done (itr);
314 mu_iterator_next (itr))
315 {
316 mu_iterator_current (itr, (void **)&fun);
317 p = (*fun) (data);
318 }
319
320 mu_iterator_destroy (&itr);
321 }
322 return p;
323 }
324
325 int 294 int
326 mu_get_host_name (char **host) 295 mu_get_host_name (char **host)
327 { 296 {
......
1 /* String-list functions for GNU Mailutils. 1 /* String-list functions for GNU Mailutils.
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
3 3
4 Based on slist module from GNU Radius. Written by Sergey Poznyakoff. 4 Based on slist module from GNU Radius. Written by Sergey Poznyakoff.
5 5
...@@ -255,6 +255,49 @@ mu_opool_finish (mu_opool_t opool, size_t *psize) ...@@ -255,6 +255,49 @@ mu_opool_finish (mu_opool_t opool, size_t *psize)
255 return opool->free->buf; 255 return opool->free->buf;
256 } 256 }
257 257
258 int
259 mu_opool_union (mu_opool_t *pdst, mu_opool_t *psrc)
260 {
261 mu_opool_t src, dst;
262
263 if (!psrc)
264 return EINVAL;
265 if (!*psrc)
266 return 0;
267 src = *psrc;
268
269 if (!pdst)
270 return EINVAL;
271 if (!*pdst)
272 {
273 *pdst = src;
274 *psrc = NULL;
275 return 0;
276 }
277 else
278 dst = *pdst;
279
280 if (dst->tail)
281 dst->tail->next = src->head;
282 else
283 dst->head = src->head;
284 dst->tail = src->tail;
285
286 if (src->free)
287 {
288 struct mu_opool_bucket *p;
289
290 for (p = src->free; p->next; p = p->next)
291 ;
292 p->next = dst->free;
293 dst->free = src->free;
294 }
295
296 free (src);
297 *psrc = NULL;
298 return 0;
299 }
300
258 301
259 /* Iterator support */ 302 /* Iterator support */
260 struct opool_iterator 303 struct opool_iterator
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007 Free Software Foundation 3 # Copyright (C) 2002, 2007, 2009 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -31,7 +31,7 @@ proc mailbox_run {args} { ...@@ -31,7 +31,7 @@ proc mailbox_run {args} {
31 if {"$a" == "-mail-spool"} { 31 if {"$a" == "-mail-spool"} {
32 if [info exists host_board] { 32 if [info exists host_board] {
33 if [board_info $host_board exists top_srcdir] { 33 if [board_info $host_board exists top_srcdir] {
34 append sw "--mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool" 34 append sw "--set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
35 } 35 }
36 } 36 }
37 if {![info exists init_spool]} { 37 if {![info exists init_spool]} {
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007 Free Software Foundation 3 # Copyright (C) 2002, 2007, 2009 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -31,7 +31,7 @@ mu_exec -message "messages" \ ...@@ -31,7 +31,7 @@ mu_exec -message "messages" \
31 mu_exec -message "messages -q" -arg -q "5" 31 mu_exec -message "messages -q" -arg -q "5"
32 32
33 mu_exec -message "messages +teaparty.mbox" \ 33 mu_exec -message "messages +teaparty.mbox" \
34 -arg "--mail-folder=$MU_SPOOL_DIR" -arg +teaparty.mbox \ 34 -arg "--set mailbox.folder=$MU_SPOOL_DIR" -arg +teaparty.mbox \
35 "Number of messages in $MU_SPOOL_DIR/teaparty.mbox: 95" 35 "Number of messages in $MU_SPOOL_DIR/teaparty.mbox: 95"
36 36
37 #end of test.exp 37 #end of test.exp
......
...@@ -43,14 +43,9 @@ libmu_argp/auth.c ...@@ -43,14 +43,9 @@ libmu_argp/auth.c
43 libmu_argp/cmdline.c 43 libmu_argp/cmdline.c
44 libmu_argp/common.c 44 libmu_argp/common.c
45 libmu_argp/compat.c 45 libmu_argp/compat.c
46 libmu_argp/gsasl.c
47 libmu_argp/mu_argp.c 46 libmu_argp/mu_argp.c
48 libmu_argp/pam.c
49 libmu_argp/radius.c
50 libmu_argp/sieve.c 47 libmu_argp/sieve.c
51 libmu_argp/sql.c
52 libmu_argp/tls.c 48 libmu_argp/tls.c
53 libmu_argp/virtdomain.c
54 49
55 libmu_auth/ldap.c 50 libmu_auth/ldap.c
56 libmu_auth/radius.c 51 libmu_auth/radius.c
......
...@@ -56,14 +56,7 @@ static error_t pop3d_parse_opt (int key, char *arg, struct argp_state *astate); ...@@ -56,14 +56,7 @@ static error_t pop3d_parse_opt (int key, char *arg, struct argp_state *astate);
56 const char *program_version = "pop3d (" PACKAGE_STRING ")"; 56 const char *program_version = "pop3d (" PACKAGE_STRING ")";
57 static char doc[] = N_("GNU pop3d -- the POP3 daemon."); 57 static char doc[] = N_("GNU pop3d -- the POP3 daemon.");
58 58
59 #define OPT_LOGIN_DELAY 257 59 #define OPT_FOREGROUND 256
60 #define OPT_STAT_FILE 258
61 #define OPT_EXPIRE 259
62 #define OPT_EXPIRE_ON_EXIT 260
63 #define OPT_TLS_REQUIRED 261
64 #define OPT_BULLETIN_SOURCE 262
65 #define OPT_BULLETIN_DB 263
66 #define OPT_FOREGROUND 264
67 60
68 static struct argp_option options[] = { 61 static struct argp_option options[] = {
69 #define GRP 0 62 #define GRP 0
...@@ -73,38 +66,6 @@ static struct argp_option options[] = { ...@@ -73,38 +66,6 @@ static struct argp_option options[] = {
73 N_("runs in daemon mode with a maximum of NUMBER children"), GRP+1 }, 66 N_("runs in daemon mode with a maximum of NUMBER children"), GRP+1 },
74 #undef GRP 67 #undef GRP
75 68
76 #define GRP 5
77 {"undelete", 'u', NULL, OPTION_HIDDEN,
78 N_("undelete all messages on startup"), GRP+1},
79 {"expire", OPT_EXPIRE, N_("DAYS"), OPTION_HIDDEN,
80 N_("expire read messages after the given number of days"), GRP+1},
81 {"delete-expired", OPT_EXPIRE_ON_EXIT, NULL, OPTION_HIDDEN,
82 N_("delete expired messages upon closing the mailbox"), GRP+1},
83 #ifdef WITH_TLS
84 {"tls-required", OPT_TLS_REQUIRED, NULL, OPTION_HIDDEN,
85 N_("always require STLS before entering authentication phase")},
86 #endif
87 #undef GRP
88
89 #define GRP 10
90 #ifdef ENABLE_LOGIN_DELAY
91 {"login-delay", OPT_LOGIN_DELAY, N_("SECONDS"), OPTION_HIDDEN,
92 N_("allowed delay between two successive logins"), GRP+1},
93 {"stat-file", OPT_STAT_FILE, N_("FILENAME"), OPTION_HIDDEN,
94 N_("name of login statistics file"), GRP+1},
95 #endif
96
97 #undef GRP
98
99 #define GRP 20
100 { "bulletin-source", OPT_BULLETIN_SOURCE, N_("MBOX"), OPTION_HIDDEN,
101 N_("set source mailbox to get bulletins from"), GRP+1 },
102 #ifdef USE_DBM
103 { "bulletin-db", OPT_BULLETIN_DB, N_("FILE"), OPTION_HIDDEN,
104 N_("set the bulletin database file name"), GRP+1 },
105 #endif
106 #undef GRP
107
108 {NULL, 0, NULL, 0, NULL, 0} 69 {NULL, 0, NULL, 0, NULL, 0}
109 }; 70 };
110 71
...@@ -203,44 +164,6 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate) ...@@ -203,44 +164,6 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate)
203 mu_argp_node_list_new (&lst, "foreground", "yes"); 164 mu_argp_node_list_new (&lst, "foreground", "yes");
204 break; 165 break;
205 166
206 case 'u':
207 mu_argp_node_list_new (&lst, "undelete", "yes");
208 break;
209
210 #ifdef ENABLE_LOGIN_DELAY
211 case OPT_LOGIN_DELAY:
212 mu_argp_node_list_new (&lst, "login-delay", arg);
213 break;
214
215 case OPT_STAT_FILE:
216 mu_argp_node_list_new (&lst, "stat-file", arg);
217 break;
218 #endif
219
220 case OPT_EXPIRE:
221 mu_argp_node_list_new (&lst, "expire", arg);
222 break;
223
224 case OPT_EXPIRE_ON_EXIT:
225 mu_argp_node_list_new (&lst, "delete-expired", "yes");
226 break;
227
228 #ifdef WITH_TLS
229 case OPT_TLS_REQUIRED:
230 mu_argp_node_list_new (&lst, "tls-required", "yes");
231 break;
232 #endif
233
234 case OPT_BULLETIN_SOURCE:
235 mu_argp_node_list_new (&lst, "bulletin-source", arg);
236 break;
237
238 #ifdef USE_DBM
239 case OPT_BULLETIN_DB:
240 mu_argp_node_list_new (&lst, "bulletin-db", arg);
241 break;
242 #endif
243
244 case ARGP_KEY_INIT: 167 case ARGP_KEY_INIT:
245 mu_argp_node_list_init (&lst); 168 mu_argp_node_list_init (&lst);
246 break; 169 break;
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007 Free Software Foundation 3 # Copyright (C) 2002, 2007, 2009 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -37,7 +37,7 @@ sieve_test discard.sv -pattern\ ...@@ -37,7 +37,7 @@ sieve_test discard.sv -pattern\
37 "DISCARD on msg uid 2: marking as deleted"\ 37 "DISCARD on msg uid 2: marking as deleted"\
38 "DISCARD on msg uid 3: marking as deleted" 38 "DISCARD on msg uid 3: marking as deleted"
39 39
40 sieve_test --mail-folder='$MU_SPOOL_DIR' fileinto.sv -pattern\ 40 sieve_test --set "mailbox.folder='$MU_SPOOL_DIR'" fileinto.sv -pattern\
41 "FILEINTO on msg uid 1: delivering into +file"\ 41 "FILEINTO on msg uid 1: delivering into +file"\
42 "FILEINTO on msg uid 2: delivering into +file"\ 42 "FILEINTO on msg uid 2: delivering into +file"\
43 "FILEINTO on msg uid 3: delivering into +file" 43 "FILEINTO on msg uid 3: delivering into +file"
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2005, 2007, 2008 Free Software Foundation 3 # Copyright (C) 2002, 2005, 2007, 2008, 2009 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -152,7 +152,7 @@ proc mu_init {args} { ...@@ -152,7 +152,7 @@ proc mu_init {args} {
152 if {[llength $args] == 1 && [lindex $args 0] == "-noflags"} { 152 if {[llength $args] == 1 && [lindex $args 0] == "-noflags"} {
153 set MU_TOOL_FLAGS "--no-site-rcfile --no-user-rcfile" 153 set MU_TOOL_FLAGS "--no-site-rcfile --no-user-rcfile"
154 } else { 154 } else {
155 set MU_TOOL_FLAGS "--mail-spool $MU_SPOOL_DIR --no-site-rcfile --no-user-rcfile" 155 set MU_TOOL_FLAGS "--set mailbox.mail-spool=$MU_SPOOL_DIR --no-site-rcfile --no-user-rcfile"
156 for {set i 0} {$i < [llength $args]} {incr i} { 156 for {set i 0} {$i < [llength $args]} {incr i} {
157 append MU_TOOL_FLAGS " [lindex $args $i]" 157 append MU_TOOL_FLAGS " [lindex $args $i]"
158 } 158 }
...@@ -181,7 +181,7 @@ proc mu_start {args} { ...@@ -181,7 +181,7 @@ proc mu_start {args} {
181 181
182 if [info exists host_board] { 182 if [info exists host_board] {
183 if [board_info $host_board exists top_srcdir] { 183 if [board_info $host_board exists top_srcdir] {
184 append sw " --mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool" 184 append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
185 } 185 }
186 } 186 }
187 187
...@@ -263,7 +263,7 @@ proc mu_exec {args} { ...@@ -263,7 +263,7 @@ proc mu_exec {args} {
263 263
264 if [info exists host_board] { 264 if [info exists host_board] {
265 if [board_info $host_board exists top_srcdir] { 265 if [board_info $host_board exists top_srcdir] {
266 append sw " --mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool" 266 append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
267 } 267 }
268 } 268 }
269 269
......