* include/mailutils/argp.h (mu_argp_set_config_param): New
function. * include/mailutils/cfg.h (mu_cfg_time): New value (struct mu_cfg_section): Rewamp using lists. (enum mu_cfg_cont_type, struct mu_cfg_cont): New types. (mu_config_create_container, mu_config_clone_container) (mu_config_destroy_container): New functions. (mu_parse_config): New function. * include/mailutils/mu_auth.h (mu_authentication_clear_list) (mu_authorization_clear_list): New functions. * mailbox/cfg_lexer.c: Add missing includes (mu_config_create_container, mu_config_clone_container) (mu_config_destroy_container): New functions. (mu_parse_config): New function. (_mu_config_register_section): New function. (mu_config_register_section): New function. (_mu_parse_config): Fully implement system-wide/per-user configuration semantics. (mu_parse_config): Take two more arguments. * mailbox/cfg_parser.h: Remove automatically generated file. * mailbox/cfg_parser.y (find_container): New function (find_subsection,find_param): Rewrite using find_container (parse_param): Implement new data type mu_cfg_time (time_t value). (_scan_tree_helper): Complain about unknown sections only if MU_CONFIG_VERBOSE environment variable is set. * mailbox/mu_argp.c (assign_string): Bugfix. (mu_argp_set_config_param): New function. (mu_argp_parse): Remove eventual `lt-' prefix from program names. * mailbox/mu_auth.c: New options --clear-authorization and --clear-authentication. (mu_authorization_clear_list,mu_authentication_clear_list): New functions. * include/mailutils/refcount.h (struct _mu_refcount): Move ro refcount.c (mu_refcount_inc,mu_refcount_dec): Change return value. (mu_refcount_value): New function. * mailbox/refcount.c (struct _mu_refcount): Moved from refcount.h (mu_refcount_value): New function. (mu_refcount_create,mu_refcount_destroy,mu_refcount_inc) (mu_refcount_dec): Fix monitor usage. (mu_refcount_inc,mu_refcount_dec): Fix return type. * mailbox/Makefile.am (libmailutils_la_SOURCES): Add refcount.c * dotlock/dotlock.c, imap4d/imap4d.c, mail.local/main.c, mail.remote/mail.remote.c, mimeview/mimeview.c, movemail/movemail.c, pop3d/pop3d.c, pop3d/signal.c, readmsg/readmsg.c, sieve/sieve.c: Implement new configuration. * testsuite/lib/mailutils.exp: Set MU_CONFIG_FLAVOR envar to `none' to avoid reading configuration files.
Showing
22 changed files
with
570 additions
and
213 deletions
1 | 2007-11-08 Sergey Poznyakoff <gray@gnu.org.ua> | ||
2 | |||
3 | * include/mailutils/argp.h (mu_argp_set_config_param): New | ||
4 | function. | ||
5 | * include/mailutils/cfg.h (mu_cfg_time): New value | ||
6 | (struct mu_cfg_section): Rewamp using lists. | ||
7 | (enum mu_cfg_cont_type, struct mu_cfg_cont): New types. | ||
8 | (mu_config_create_container, mu_config_clone_container) | ||
9 | (mu_config_destroy_container): New functions. | ||
10 | (mu_parse_config): New function. | ||
11 | * include/mailutils/mu_auth.h (mu_authentication_clear_list) | ||
12 | (mu_authorization_clear_list): New functions. | ||
13 | * mailbox/cfg_lexer.c: Add missing includes | ||
14 | (mu_config_create_container, mu_config_clone_container) | ||
15 | (mu_config_destroy_container): New functions. | ||
16 | (mu_parse_config): New function. | ||
17 | (_mu_config_register_section): New function. | ||
18 | (mu_config_register_section): New function. | ||
19 | (_mu_parse_config): Fully implement system-wide/per-user | ||
20 | configuration semantics. | ||
21 | (mu_parse_config): Take two more arguments. | ||
22 | * mailbox/cfg_parser.h: Remove automatically generated file. | ||
23 | * mailbox/cfg_parser.y (find_container): New function | ||
24 | (find_subsection,find_param): Rewrite using find_container | ||
25 | (parse_param): Implement new data type mu_cfg_time (time_t value). | ||
26 | (_scan_tree_helper): Complain about unknown sections only if | ||
27 | MU_CONFIG_VERBOSE environment variable is set. | ||
28 | * mailbox/mu_argp.c (assign_string): Bugfix. | ||
29 | (mu_argp_set_config_param): New function. | ||
30 | (mu_argp_parse): Remove eventual `lt-' prefix from program names. | ||
31 | * mailbox/mu_auth.c: New options --clear-authorization and | ||
32 | --clear-authentication. | ||
33 | (mu_authorization_clear_list,mu_authentication_clear_list): New | ||
34 | functions. | ||
35 | |||
36 | * include/mailutils/refcount.h (struct _mu_refcount): Move ro | ||
37 | refcount.c | ||
38 | (mu_refcount_inc,mu_refcount_dec): Change return value. | ||
39 | (mu_refcount_value): New function. | ||
40 | * mailbox/refcount.c (struct _mu_refcount): Moved from refcount.h | ||
41 | (mu_refcount_value): New function. | ||
42 | (mu_refcount_create,mu_refcount_destroy,mu_refcount_inc) | ||
43 | (mu_refcount_dec): Fix monitor usage. | ||
44 | (mu_refcount_inc,mu_refcount_dec): Fix return type. | ||
45 | |||
46 | * mailbox/Makefile.am (libmailutils_la_SOURCES): Add refcount.c | ||
47 | * dotlock/dotlock.c, imap4d/imap4d.c, mail.local/main.c, | ||
48 | mail.remote/mail.remote.c, mimeview/mimeview.c, | ||
49 | movemail/movemail.c, pop3d/pop3d.c, pop3d/signal.c, | ||
50 | readmsg/readmsg.c, sieve/sieve.c: Implement new configuration. | ||
51 | |||
52 | * testsuite/lib/mailutils.exp: Set MU_CONFIG_FLAVOR envar to | ||
53 | `none' to avoid reading configuration files. | ||
54 | |||
1 | 2007-11-06 Sergey Poznyakoff <gray@gnu.org.ua> | 55 | 2007-11-06 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 56 | ||
3 | * mailbox/message.c (message_stream_size): Bugfix. | 57 | * mailbox/message.c (message_stream_size): Bugfix. | ... | ... |
... | @@ -70,7 +70,7 @@ static const char *file; | ... | @@ -70,7 +70,7 @@ static const char *file; |
70 | static int unlock; | 70 | static int unlock; |
71 | static int flags; | 71 | static int flags; |
72 | static int retries; | 72 | static int retries; |
73 | static int force; | 73 | static time_t force; |
74 | static int debug; | 74 | static int debug; |
75 | 75 | ||
76 | static error_t | 76 | static error_t |
... | @@ -102,9 +102,7 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -102,9 +102,7 @@ parse_opt (int key, char *arg, struct argp_state *state) |
102 | force = atoi (arg); | 102 | force = atoi (arg); |
103 | if (force <= 0) | 103 | if (force <= 0) |
104 | argp_error (state, _("MINUTES must be greater than 0")); | 104 | argp_error (state, _("MINUTES must be greater than 0")); |
105 | force *= 60; | ||
106 | } | 105 | } |
107 | flags |= MU_LOCKER_TIME; | ||
108 | break; | 106 | break; |
109 | 107 | ||
110 | case ARGP_KEY_ARG: | 108 | case ARGP_KEY_ARG: |
... | @@ -122,6 +120,21 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -122,6 +120,21 @@ parse_opt (int key, char *arg, struct argp_state *state) |
122 | return 0; | 120 | return 0; |
123 | } | 121 | } |
124 | 122 | ||
123 | |||
124 | struct mu_cfg_param dotlock_cfg_param[] = { | ||
125 | { "force", mu_cfg_time, &force }, | ||
126 | { "retry", mu_cfg_int, &retries }, | ||
127 | { "debug", mu_cfg_bool, &debug }, | ||
128 | { NULL } | ||
129 | }; | ||
130 | |||
131 | |||
132 | |||
133 | const char *dotlock_capa[] = { | ||
134 | "license", | ||
135 | NULL | ||
136 | }; | ||
137 | |||
125 | int | 138 | int |
126 | main (int argc, char *argv[]) | 139 | main (int argc, char *argv[]) |
127 | { | 140 | { |
... | @@ -140,8 +153,15 @@ main (int argc, char *argv[]) | ... | @@ -140,8 +153,15 @@ main (int argc, char *argv[]) |
140 | 153 | ||
141 | mu_argp_init (program_version, NULL); | 154 | mu_argp_init (program_version, NULL); |
142 | argp_err_exit_status = MU_DL_EX_ERROR; | 155 | argp_err_exit_status = MU_DL_EX_ERROR; |
143 | argp_parse (&argp, argc, argv, 0, NULL, NULL); | ||
144 | 156 | ||
157 | mu_argp_set_config_param (dotlock_cfg_param); | ||
158 | mu_argp_parse (&argp, &argc, &argv, 0, dotlock_capa, NULL, NULL); | ||
159 | if (force) | ||
160 | { | ||
161 | force *= 60; | ||
162 | flags |= MU_LOCKER_TIME; | ||
163 | } | ||
164 | |||
145 | if ((err = mu_locker_create (&locker, file, flags))) | 165 | if ((err = mu_locker_create (&locker, file, flags))) |
146 | { | 166 | { |
147 | if (debug) | 167 | if (debug) | ... | ... |
... | @@ -204,7 +204,7 @@ main (int argc, char **argv) | ... | @@ -204,7 +204,7 @@ main (int argc, char **argv) |
204 | #ifdef WITH_GSASL | 204 | #ifdef WITH_GSASL |
205 | mu_gsasl_init_argp (); | 205 | mu_gsasl_init_argp (); |
206 | #endif | 206 | #endif |
207 | mu_config_register_plain_section (NULL, NULL, imap4d_cfg_param); | 207 | mu_argp_set_config_param (imap4d_cfg_param); |
208 | mu_argp_parse (&argp, &argc, &argv, 0, imap4d_capa, NULL, &daemon_param); | 208 | mu_argp_parse (&argp, &argc, &argv, 0, imap4d_capa, NULL, &daemon_param); |
209 | 209 | ||
210 | if (login_disabled) | 210 | if (login_disabled) | ... | ... |
... | @@ -60,7 +60,8 @@ extern int mu_register_capa (const char *name, struct argp_child *child, | ... | @@ -60,7 +60,8 @@ extern int mu_register_capa (const char *name, struct argp_child *child, |
60 | 60 | ||
61 | extern void mu_print_options (void); | 61 | extern void mu_print_options (void); |
62 | extern const char *mu_check_option (char *name); | 62 | extern const char *mu_check_option (char *name); |
63 | 63 | extern void mu_argp_set_config_param (struct mu_cfg_param *); | |
64 | |||
64 | #ifdef __cplusplus | 65 | #ifdef __cplusplus |
65 | } | 66 | } |
66 | #endif | 67 | #endif | ... | ... |
... | @@ -98,6 +98,7 @@ enum mu_cfg_param_data_type | ... | @@ -98,6 +98,7 @@ enum mu_cfg_param_data_type |
98 | mu_cfg_ulong, | 98 | mu_cfg_ulong, |
99 | mu_cfg_size, | 99 | mu_cfg_size, |
100 | mu_cfg_off, | 100 | mu_cfg_off, |
101 | mu_cfg_time, | ||
101 | mu_cfg_bool, | 102 | mu_cfg_bool, |
102 | mu_cfg_ipv4, | 103 | mu_cfg_ipv4, |
103 | mu_cfg_cidr, | 104 | mu_cfg_cidr, |
... | @@ -130,8 +131,26 @@ struct mu_cfg_section | ... | @@ -130,8 +131,26 @@ struct mu_cfg_section |
130 | const char *ident; | 131 | const char *ident; |
131 | mu_cfg_section_fp parser; | 132 | mu_cfg_section_fp parser; |
132 | void *data; | 133 | void *data; |
133 | struct mu_cfg_section *subsec; | 134 | mu_list_t /* of mu_cfg_cont/mu_cfg_section */ subsec; |
134 | struct mu_cfg_param *param; | 135 | mu_list_t /* of mu_cfg_cont/mu_cfg_param */ param; |
136 | }; | ||
137 | |||
138 | enum mu_cfg_cont_type | ||
139 | { | ||
140 | mu_cfg_cont_section, | ||
141 | mu_cfg_cont_param | ||
142 | }; | ||
143 | |||
144 | struct mu_cfg_cont | ||
145 | { | ||
146 | enum mu_cfg_cont_type type; | ||
147 | mu_refcount_t refcount; | ||
148 | union | ||
149 | { | ||
150 | const char *ident; | ||
151 | struct mu_cfg_section section; | ||
152 | struct mu_cfg_param param; | ||
153 | } v; | ||
135 | }; | 154 | }; |
136 | 155 | ||
137 | typedef struct mu_cfg_cidr mu_cfg_cidr_t; | 156 | typedef struct mu_cfg_cidr mu_cfg_cidr_t; |
... | @@ -142,6 +161,11 @@ struct mu_cfg_cidr | ... | @@ -142,6 +161,11 @@ struct mu_cfg_cidr |
142 | unsigned long mask; | 161 | unsigned long mask; |
143 | }; | 162 | }; |
144 | 163 | ||
164 | int mu_config_create_container (struct mu_cfg_cont **pcont, | ||
165 | enum mu_cfg_cont_type type); | ||
166 | int mu_config_clone_container (struct mu_cfg_cont *cont); | ||
167 | void mu_config_destroy_container (struct mu_cfg_cont **pcont); | ||
168 | |||
145 | int mu_cfg_scan_tree (mu_cfg_node_t *node, | 169 | int mu_cfg_scan_tree (mu_cfg_node_t *node, |
146 | struct mu_cfg_section *sections, | 170 | struct mu_cfg_section *sections, |
147 | void *data, mu_cfg_perror_t perror, | 171 | void *data, mu_cfg_perror_t perror, |
... | @@ -159,4 +183,7 @@ int mu_config_register_plain_section (const char *parent_path, | ... | @@ -159,4 +183,7 @@ int mu_config_register_plain_section (const char *parent_path, |
159 | const char *ident, | 183 | const char *ident, |
160 | struct mu_cfg_param *params); | 184 | struct mu_cfg_param *params); |
161 | 185 | ||
186 | int mu_parse_config (char *file, char *progname, | ||
187 | struct mu_cfg_param *progparam, int global); | ||
188 | |||
162 | #endif | 189 | #endif | ... | ... |
... | @@ -103,6 +103,8 @@ extern void mu_auth_register_module (struct mu_auth_module *mod); | ... | @@ -103,6 +103,8 @@ extern void mu_auth_register_module (struct mu_auth_module *mod); |
103 | 103 | ||
104 | extern void mu_authorization_add_module_list (const char *modlist); | 104 | extern void mu_authorization_add_module_list (const char *modlist); |
105 | extern void mu_authentication_add_module_list (const char *modlist); | 105 | extern void mu_authentication_add_module_list (const char *modlist); |
106 | extern void mu_authentication_clear_list (void); | ||
107 | extern void mu_authorization_clear_list (void); | ||
106 | 108 | ||
107 | extern void mu_auth_init (void); | 109 | extern void mu_auth_init (void); |
108 | extern int mu_auth_data_alloc (struct mu_auth_data **ptr, | 110 | extern int mu_auth_data_alloc (struct mu_auth_data **ptr, | ... | ... |
... | @@ -26,17 +26,11 @@ | ... | @@ -26,17 +26,11 @@ |
26 | extern "C" { | 26 | extern "C" { |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | /* FIXME: Declaration should be hidden in mailutils/sys/refcount.h */ | ||
30 | struct _mu_refcount | ||
31 | { | ||
32 | unsigned int ref; | ||
33 | mu_monitor_t lock; | ||
34 | }; | ||
35 | |||
36 | extern int mu_refcount_create (mu_refcount_t *); | 29 | extern int mu_refcount_create (mu_refcount_t *); |
37 | extern void mu_refcount_destroy (mu_refcount_t *); | 30 | extern void mu_refcount_destroy (mu_refcount_t *); |
38 | extern int mu_refcount_inc (mu_refcount_t); | 31 | extern unsigned mu_refcount_value (mu_refcount_t); |
39 | extern int mu_refcount_dec (mu_refcount_t); | 32 | extern unsigned mu_refcount_inc (mu_refcount_t); |
33 | extern unsigned mu_refcount_dec (mu_refcount_t); | ||
40 | 34 | ||
41 | #ifdef __cplusplus | 35 | #ifdef __cplusplus |
42 | } | 36 | } | ... | ... |
... | @@ -128,6 +128,52 @@ char *saved_envelope; /* A hack to spare mu_envelope_ calls */ | ... | @@ -128,6 +128,52 @@ char *saved_envelope; /* A hack to spare mu_envelope_ calls */ |
128 | 128 | ||
129 | #define D_DEFAULT "9s" | 129 | #define D_DEFAULT "9s" |
130 | 130 | ||
131 | static void | ||
132 | set_debug_flags (const mu_cfg_locus_t *locus, const char *arg) | ||
133 | { | ||
134 | for (; *arg; arg++); | ||
135 | { | ||
136 | switch (*arg) | ||
137 | { | ||
138 | case 'g': | ||
139 | #ifdef WITH_GUILE | ||
140 | debug_guile = 1; | ||
141 | #endif | ||
142 | break; | ||
143 | |||
144 | case 't': | ||
145 | sieve_debug_flags |= MU_SIEVE_DEBUG_TRACE; | ||
146 | break; | ||
147 | |||
148 | case 'i': | ||
149 | sieve_debug_flags |= MU_SIEVE_DEBUG_INSTR; | ||
150 | break; | ||
151 | |||
152 | case 'l': | ||
153 | sieve_enable_log = 1; | ||
154 | break; | ||
155 | |||
156 | case 'T': | ||
157 | debug_flags |= MU_DEBUG_TRACE; | ||
158 | break; | ||
159 | |||
160 | case 'P': | ||
161 | debug_flags |= MU_DEBUG_PROT; | ||
162 | break; | ||
163 | |||
164 | default: | ||
165 | if (isdigit (*arg)) | ||
166 | debug_level = *arg - '0'; | ||
167 | else if (locus) | ||
168 | mu_error (_("%s:%d: %c is not a valid debug flag"), | ||
169 | locus->file, locus->line, *arg); | ||
170 | else | ||
171 | mu_error (_("%c is not a valid debug flag"), *arg); | ||
172 | break; | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | |||
131 | static error_t | 177 | static error_t |
132 | parse_opt (int key, char *arg, struct argp_state *state) | 178 | parse_opt (int key, char *arg, struct argp_state *state) |
133 | { | 179 | { |
... | @@ -176,47 +222,9 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -176,47 +222,9 @@ parse_opt (int key, char *arg, struct argp_state *state) |
176 | break; | 222 | break; |
177 | 223 | ||
178 | case 'x': | 224 | case 'x': |
179 | do | 225 | if (!arg) |
180 | { | 226 | arg = D_DEFAULT; |
181 | if (!arg) | 227 | set_debug_flags (NULL, arg); |
182 | arg = D_DEFAULT; | ||
183 | switch (*arg) | ||
184 | { | ||
185 | case 'g': | ||
186 | #ifdef WITH_GUILE | ||
187 | debug_guile = 1; | ||
188 | #endif | ||
189 | break; | ||
190 | |||
191 | case 't': | ||
192 | sieve_debug_flags |= MU_SIEVE_DEBUG_TRACE; | ||
193 | break; | ||
194 | |||
195 | case 'i': | ||
196 | sieve_debug_flags |= MU_SIEVE_DEBUG_INSTR; | ||
197 | break; | ||
198 | |||
199 | case 'l': | ||
200 | sieve_enable_log = 1; | ||
201 | break; | ||
202 | |||
203 | case 'T': | ||
204 | debug_flags |= MU_DEBUG_TRACE; | ||
205 | break; | ||
206 | |||
207 | case 'P': | ||
208 | debug_flags |= MU_DEBUG_PROT; | ||
209 | break; | ||
210 | |||
211 | default: | ||
212 | if (isdigit (*arg)) | ||
213 | debug_level = *arg - '0'; | ||
214 | else | ||
215 | argp_error (state, _("%c is not a valid debug flag"), *arg); | ||
216 | break; | ||
217 | } | ||
218 | } | ||
219 | while (*++arg); | ||
220 | break; | 228 | break; |
221 | 229 | ||
222 | default: | 230 | default: |
... | @@ -228,6 +236,34 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -228,6 +236,34 @@ parse_opt (int key, char *arg, struct argp_state *state) |
228 | return 0; | 236 | return 0; |
229 | } | 237 | } |
230 | 238 | ||
239 | |||
240 | static int | ||
241 | cb_debug (mu_cfg_locus_t *locus, void *data, char *arg) | ||
242 | { | ||
243 | set_debug_flags (locus, arg); | ||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | struct mu_cfg_param mail_local_cfg_param[] = { | ||
248 | { "ex-multiple-delivery-success", mu_cfg_bool, &multiple_delivery }, | ||
249 | { "ex-quota-tempfail", mu_cfg_bool, &ex_quota_tempfail }, | ||
250 | { "from", mu_cfg_string, &from }, | ||
251 | #ifdef USE_DBM | ||
252 | { "quota-db", mu_cfg_string, "adbname }, | ||
253 | #endif | ||
254 | #ifdef USE_SQL | ||
255 | { "quota-query", mu_cfg_string, "a_query }, | ||
256 | #endif | ||
257 | { "sieve", mu_cfg_string, &sieve_pattern }, | ||
258 | { "message-id-header", mu_cfg_string, &message_id_header }, | ||
259 | #ifdef WITH_GUILE | ||
260 | { "source", mu_cfg_string, &progfile_pattern }, | ||
261 | #endif | ||
262 | { "debug", mu_cfg_callback, NULL, cb_debug }, | ||
263 | { NULL } | ||
264 | }; | ||
265 | |||
266 | |||
231 | 267 | ||
232 | static int | 268 | static int |
233 | _mu_debug_printer (mu_debug_t unused, size_t level, const char *fmt, | 269 | _mu_debug_printer (mu_debug_t unused, size_t level, const char *fmt, |
... | @@ -246,7 +282,8 @@ _sieve_debug_printer (void *unused, const char *fmt, va_list ap) | ... | @@ -246,7 +282,8 @@ _sieve_debug_printer (void *unused, const char *fmt, va_list ap) |
246 | 282 | ||
247 | static void | 283 | static void |
248 | _sieve_action_log (void *user_name, | 284 | _sieve_action_log (void *user_name, |
249 | const mu_sieve_locus_t *locus, size_t msgno, mu_message_t msg, | 285 | const mu_sieve_locus_t *locus, size_t msgno, |
286 | mu_message_t msg, | ||
250 | const char *action, const char *fmt, va_list ap) | 287 | const char *action, const char *fmt, va_list ap) |
251 | { | 288 | { |
252 | char *text = NULL; | 289 | char *text = NULL; |
... | @@ -334,6 +371,7 @@ main (int argc, char *argv[]) | ... | @@ -334,6 +371,7 @@ main (int argc, char *argv[]) |
334 | mu_argp_init (program_version, NULL); | 371 | mu_argp_init (program_version, NULL); |
335 | mu_sieve_argp_init (); | 372 | mu_sieve_argp_init (); |
336 | /* Parse command line */ | 373 | /* Parse command line */ |
374 | mu_argp_set_config_param (mail_local_cfg_param); | ||
337 | mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &arg_index, NULL); | 375 | mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &arg_index, NULL); |
338 | 376 | ||
339 | uid = getuid (); | 377 | uid = getuid (); | ... | ... |
... | @@ -119,6 +119,15 @@ static struct argp argp = { | ... | @@ -119,6 +119,15 @@ static struct argp argp = { |
119 | doc, | 119 | doc, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | |||
123 | struct mu_cfg_param mail_remote_cfg_param[] = { | ||
124 | { "from", mu_cfg_string, &optfrom }, | ||
125 | { "read-recipients", mu_cfg_string, &read_recipients }, | ||
126 | { "debug", mu_cfg_int, &optdebug }, | ||
127 | { NULL} | ||
128 | }; | ||
129 | |||
130 | |||
122 | static const char *capa[] = { | 131 | static const char *capa[] = { |
123 | "auth", | 132 | "auth", |
124 | "common", | 133 | "common", |
... | @@ -162,6 +171,7 @@ main (int argc, char **argv) | ... | @@ -162,6 +171,7 @@ main (int argc, char **argv) |
162 | 171 | ||
163 | MU_AUTH_REGISTER_ALL_MODULES(); | 172 | MU_AUTH_REGISTER_ALL_MODULES(); |
164 | mu_argp_init (program_version, NULL); | 173 | mu_argp_init (program_version, NULL); |
174 | mu_argp_set_config_param (mail_remote_cfg_param); | ||
165 | mu_argp_parse (&argp, &argc, &argv, 0, capa, &optind, NULL); | 175 | mu_argp_parse (&argp, &argc, &argv, 0, capa, &optind, NULL); |
166 | 176 | ||
167 | if (optfrom) | 177 | if (optfrom) | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -26,6 +26,8 @@ | ... | @@ -26,6 +26,8 @@ |
26 | #include <mailutils/cfg.h> | 26 | #include <mailutils/cfg.h> |
27 | #include <mailutils/errno.h> | 27 | #include <mailutils/errno.h> |
28 | #include <mailutils/error.h> | 28 | #include <mailutils/error.h> |
29 | #include <mailutils/list.h> | ||
30 | #include <mailutils/iterator.h> | ||
29 | 31 | ||
30 | static mu_cfg_node_t *parse_tree; | 32 | static mu_cfg_node_t *parse_tree; |
31 | mu_cfg_locus_t mu_cfg_locus; | 33 | mu_cfg_locus_t mu_cfg_locus; |
... | @@ -487,21 +489,43 @@ struct scan_tree_data | ... | @@ -487,21 +489,43 @@ struct scan_tree_data |
487 | int error; | 489 | int error; |
488 | }; | 490 | }; |
489 | 491 | ||
492 | static struct mu_cfg_cont * | ||
493 | find_container (mu_list_t list, const char *ident, size_t len) | ||
494 | { | ||
495 | mu_iterator_t iter; | ||
496 | struct mu_cfg_cont *ret = NULL; | ||
497 | |||
498 | if (len == 0) | ||
499 | len = strlen (ident); | ||
500 | |||
501 | mu_list_get_iterator (list, &iter); | ||
502 | for (mu_iterator_first (iter); !mu_iterator_is_done (iter); | ||
503 | mu_iterator_next (iter)) | ||
504 | { | ||
505 | struct mu_cfg_cont *cont; | ||
506 | mu_iterator_current (iter, (void**) &cont); | ||
507 | |||
508 | if (strlen (cont->v.ident) == len | ||
509 | && memcmp (cont->v.ident, ident, len) == 0) | ||
510 | { | ||
511 | ret = cont; | ||
512 | break; | ||
513 | } | ||
514 | } | ||
515 | mu_iterator_destroy (&iter); | ||
516 | return ret; | ||
517 | } | ||
518 | |||
490 | static struct mu_cfg_section * | 519 | static struct mu_cfg_section * |
491 | find_subsection (struct mu_cfg_section *sec, const char *ident, size_t len) | 520 | find_subsection (struct mu_cfg_section *sec, const char *ident, size_t len) |
492 | { | 521 | { |
493 | if (sec) | 522 | if (sec) |
494 | { | 523 | { |
495 | sec = sec->subsec; | 524 | if (sec->subsec) |
496 | if (sec) | ||
497 | { | 525 | { |
498 | if (len == 0) | 526 | struct mu_cfg_cont *cont = find_container (sec->subsec, ident, len); |
499 | len = strlen (ident); | 527 | if (cont) |
500 | 528 | return &cont->v.section; | |
501 | for (; sec->ident; sec++) | ||
502 | if (strlen (sec->ident) == len | ||
503 | && memcmp (sec->ident, ident, len) == 0) | ||
504 | return sec; | ||
505 | } | 529 | } |
506 | } | 530 | } |
507 | return NULL; | 531 | return NULL; |
... | @@ -512,14 +536,11 @@ find_param (struct mu_cfg_section *sec, const char *ident, size_t len) | ... | @@ -512,14 +536,11 @@ find_param (struct mu_cfg_section *sec, const char *ident, size_t len) |
512 | { | 536 | { |
513 | if (sec) | 537 | if (sec) |
514 | { | 538 | { |
515 | struct mu_cfg_param *p = sec->param; | 539 | if (sec->param) |
516 | if (p) | ||
517 | { | 540 | { |
518 | if (len == 0) | 541 | struct mu_cfg_cont *cont = find_container (sec->param, ident, len); |
519 | len = strlen (ident); | 542 | if (cont) |
520 | for (; p->ident; p++) | 543 | return &cont->v.param; |
521 | if (strlen (p->ident) == len && memcmp (p->ident, ident, len) == 0) | ||
522 | return p; | ||
523 | } | 544 | } |
524 | } | 545 | } |
525 | return NULL; | 546 | return NULL; |
... | @@ -874,6 +895,10 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node) | ... | @@ -874,6 +895,10 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node) |
874 | /* GETSNUM(node->tag_label, off_t, *(off_t*)param->data); */ | 895 | /* GETSNUM(node->tag_label, off_t, *(off_t*)param->data); */ |
875 | return 1; | 896 | return 1; |
876 | 897 | ||
898 | case mu_cfg_time: | ||
899 | GETUNUM (node->tag_label, time_t, *(time_t*)param->data); | ||
900 | break; | ||
901 | |||
877 | case mu_cfg_bool: | 902 | case mu_cfg_bool: |
878 | if (parse_bool (sdata, node, (int*) param->data)) | 903 | if (parse_bool (sdata, node, (int*) param->data)) |
879 | return 1; | 904 | return 1; |
... | @@ -921,11 +946,14 @@ _scan_tree_helper (const mu_cfg_node_t *node, void *data) | ... | @@ -921,11 +946,14 @@ _scan_tree_helper (const mu_cfg_node_t *node, void *data) |
921 | sec = find_subsection (sdata->list->sec, node->tag_name, 0); | 946 | sec = find_subsection (sdata->list->sec, node->tag_name, 0); |
922 | if (!sec) | 947 | if (!sec) |
923 | { | 948 | { |
924 | mu_cfg_perror (sdata->call_data, | 949 | if (getenv ("MU_CONFIG_VERBOSE")) |
925 | &node->locus, | 950 | { |
926 | _("unknown section `%s'"), | 951 | mu_cfg_perror (sdata->call_data, |
927 | node->tag_name); | 952 | &node->locus, |
928 | sdata->error++; | 953 | _("unknown section `%s'"), |
954 | node->tag_name); | ||
955 | sdata->error++; | ||
956 | } | ||
929 | return MU_CFG_ITER_SKIP; | 957 | return MU_CFG_ITER_SKIP; |
930 | } | 958 | } |
931 | if (!sec->subsec && !sec->param) | 959 | if (!sec->subsec && !sec->param) | ... | ... |
... | @@ -252,7 +252,7 @@ assign_string (char **pstr, char *val) | ... | @@ -252,7 +252,7 @@ assign_string (char **pstr, char *val) |
252 | { | 252 | { |
253 | size_t size = strlen (val); | 253 | size_t size = strlen (val); |
254 | char *p = realloc (*pstr, size + 1); | 254 | char *p = realloc (*pstr, size + 1); |
255 | if (!*p) | 255 | if (!p) |
256 | { | 256 | { |
257 | mu_error ("%s", mu_strerror (ENOMEM)); | 257 | mu_error ("%s", mu_strerror (ENOMEM)); |
258 | exit (1); | 258 | exit (1); |
... | @@ -1291,6 +1291,14 @@ mu_create_argcv (const char *capa[], | ... | @@ -1291,6 +1291,14 @@ mu_create_argcv (const char *capa[], |
1291 | 1291 | ||
1292 | /* ************************************************************************* */ | 1292 | /* ************************************************************************* */ |
1293 | 1293 | ||
1294 | static struct mu_cfg_param *prog_param; | ||
1295 | |||
1296 | void | ||
1297 | mu_argp_set_config_param (struct mu_cfg_param *p) | ||
1298 | { | ||
1299 | prog_param = p; | ||
1300 | } | ||
1301 | |||
1294 | static void | 1302 | static void |
1295 | read_configs (char *progname, enum mu_config_flavor cfl[CF_SIZE]) | 1303 | read_configs (char *progname, enum mu_config_flavor cfl[CF_SIZE]) |
1296 | { | 1304 | { |
... | @@ -1307,7 +1315,7 @@ read_configs (char *progname, enum mu_config_flavor cfl[CF_SIZE]) | ... | @@ -1307,7 +1315,7 @@ read_configs (char *progname, enum mu_config_flavor cfl[CF_SIZE]) |
1307 | { | 1315 | { |
1308 | case mu_config_auto: | 1316 | case mu_config_auto: |
1309 | case mu_config_resource: | 1317 | case mu_config_resource: |
1310 | mu_parse_config (MU_CONFIG_FILE, progname); | 1318 | mu_parse_config (MU_CONFIG_FILE, progname, prog_param, 1); |
1311 | break; | 1319 | break; |
1312 | 1320 | ||
1313 | default: | 1321 | default: |
... | @@ -1329,7 +1337,7 @@ read_configs (char *progname, enum mu_config_flavor cfl[CF_SIZE]) | ... | @@ -1329,7 +1337,7 @@ read_configs (char *progname, enum mu_config_flavor cfl[CF_SIZE]) |
1329 | strcpy (file_name, "~/."); | 1337 | strcpy (file_name, "~/."); |
1330 | strcat (file_name, progname); | 1338 | strcat (file_name, progname); |
1331 | 1339 | ||
1332 | mu_parse_config (file_name, progname); | 1340 | mu_parse_config (file_name, progname, prog_param, 0); |
1333 | 1341 | ||
1334 | free (file_name); | 1342 | free (file_name); |
1335 | } | 1343 | } |
... | @@ -1365,6 +1373,9 @@ mu_argp_parse (const struct argp *argp, | ... | @@ -1365,6 +1373,9 @@ mu_argp_parse (const struct argp *argp, |
1365 | else | 1373 | else |
1366 | progname = (*pargv)[0]; | 1374 | progname = (*pargv)[0]; |
1367 | 1375 | ||
1376 | if (strlen (progname) > 3 && memcmp (progname, "lt-", 3) == 0) | ||
1377 | progname += 3; | ||
1378 | |||
1368 | get_default_config_flavor (progname, cfl); | 1379 | get_default_config_flavor (progname, cfl); |
1369 | 1380 | ||
1370 | if (!argp) | 1381 | if (!argp) | ... | ... |
... | @@ -248,6 +248,8 @@ mu_authenticate (struct mu_auth_data *auth_data, char *pass) | ... | @@ -248,6 +248,8 @@ mu_authenticate (struct mu_auth_data *auth_data, char *pass) |
248 | 248 | ||
249 | #define ARG_AUTHORIZATION 1 | 249 | #define ARG_AUTHORIZATION 1 |
250 | #define ARG_AUTHENTICATION 2 | 250 | #define ARG_AUTHENTICATION 2 |
251 | #define ARG_CLEAR_AUTHORIZATION 3 | ||
252 | #define ARG_CLEAR_AUTHENTICATION 4 | ||
251 | 253 | ||
252 | static error_t mu_auth_argp_parser (int key, char *arg, | 254 | static error_t mu_auth_argp_parser (int key, char *arg, |
253 | struct argp_state *state); | 255 | struct argp_state *state); |
... | @@ -258,6 +260,10 @@ static struct argp_option mu_auth_argp_option[] = { | ... | @@ -258,6 +260,10 @@ static struct argp_option mu_auth_argp_option[] = { |
258 | N_("Set the list of modules to be used for authentication"), 0 }, | 260 | N_("Set the list of modules to be used for authentication"), 0 }, |
259 | { "authorization", ARG_AUTHORIZATION, N_("MODLIST"), OPTION_HIDDEN, | 261 | { "authorization", ARG_AUTHORIZATION, N_("MODLIST"), OPTION_HIDDEN, |
260 | N_("Set list of modules to be used for authorization"), 0 }, | 262 | N_("Set list of modules to be used for authorization"), 0 }, |
263 | { "clear-authorization", ARG_CLEAR_AUTHORIZATION, NULL, OPTION_HIDDEN, | ||
264 | N_("Clear the list of authorization modules"), 0 }, | ||
265 | { "clear-authentication", ARG_CLEAR_AUTHENTICATION, NULL, OPTION_HIDDEN, | ||
266 | N_("Clear the list of authentication modules"), 0 }, | ||
261 | { NULL, 0, NULL, 0, NULL, 0 } | 267 | { NULL, 0, NULL, 0, NULL, 0 } |
262 | }; | 268 | }; |
263 | 269 | ||
... | @@ -291,6 +297,14 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state) | ... | @@ -291,6 +297,14 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state) |
291 | mu_authentication_add_module_list (arg); | 297 | mu_authentication_add_module_list (arg); |
292 | break; | 298 | break; |
293 | 299 | ||
300 | case ARG_CLEAR_AUTHENTICATION: | ||
301 | mu_authentication_clear_list (); | ||
302 | break; | ||
303 | |||
304 | case ARG_CLEAR_AUTHORIZATION: | ||
305 | mu_authorization_clear_list (); | ||
306 | break; | ||
307 | |||
294 | default: | 308 | default: |
295 | return ARGP_ERR_UNKNOWN; | 309 | return ARGP_ERR_UNKNOWN; |
296 | } | 310 | } |
... | @@ -304,14 +318,20 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state) | ... | @@ -304,14 +318,20 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state) |
304 | static int | 318 | static int |
305 | cb_authentication (mu_cfg_locus_t *locus, void *data, char *arg) | 319 | cb_authentication (mu_cfg_locus_t *locus, void *data, char *arg) |
306 | { | 320 | { |
307 | mu_authentication_add_module_list (arg);/*FIXME: error reporting*/ | 321 | if (strcmp (arg, "clear") == 0) |
322 | mu_authentication_clear_list (); | ||
323 | else | ||
324 | mu_authentication_add_module_list (arg);/*FIXME: error reporting*/ | ||
308 | return 0; | 325 | return 0; |
309 | } | 326 | } |
310 | 327 | ||
311 | static int | 328 | static int |
312 | cb_authorization (mu_cfg_locus_t *locus, void *data, char *arg) | 329 | cb_authorization (mu_cfg_locus_t *locus, void *data, char *arg) |
313 | { | 330 | { |
314 | mu_authorization_add_module_list (arg); | 331 | if (strcmp (arg, "clear") == 0) |
332 | mu_authorization_clear_list (); | ||
333 | else | ||
334 | mu_authorization_add_module_list (arg); | ||
315 | return 0; | 335 | return 0; |
316 | } | 336 | } |
317 | 337 | ||
... | @@ -451,6 +471,7 @@ _add_module_list (const char *modlist, int (*fun)(const char *name)) | ... | @@ -451,6 +471,7 @@ _add_module_list (const char *modlist, int (*fun)(const char *name)) |
451 | } | 471 | } |
452 | } | 472 | } |
453 | 473 | ||
474 | |||
454 | int | 475 | int |
455 | mu_authorization_add_module (const char *name) | 476 | mu_authorization_add_module (const char *name) |
456 | { | 477 | { |
... | @@ -472,6 +493,14 @@ mu_authorization_add_module_list (const char *modlist) | ... | @@ -472,6 +493,14 @@ mu_authorization_add_module_list (const char *modlist) |
472 | _add_module_list (modlist, mu_authorization_add_module); | 493 | _add_module_list (modlist, mu_authorization_add_module); |
473 | } | 494 | } |
474 | 495 | ||
496 | void | ||
497 | mu_authorization_clear_list () | ||
498 | { | ||
499 | mu_list_destroy (&_tmp_auth_by_name_list); | ||
500 | mu_list_destroy (&_tmp_auth_by_uid_list); | ||
501 | } | ||
502 | |||
503 | |||
475 | int | 504 | int |
476 | mu_authentication_add_module (const char *name) | 505 | mu_authentication_add_module (const char *name) |
477 | { | 506 | { |
... | @@ -492,6 +521,13 @@ mu_authentication_add_module_list (const char *modlist) | ... | @@ -492,6 +521,13 @@ mu_authentication_add_module_list (const char *modlist) |
492 | _add_module_list (modlist, mu_authentication_add_module); | 521 | _add_module_list (modlist, mu_authentication_add_module); |
493 | } | 522 | } |
494 | 523 | ||
524 | void | ||
525 | mu_authentication_clear_list () | ||
526 | { | ||
527 | mu_list_destroy (&_tmp_authenticate_list); | ||
528 | } | ||
529 | |||
530 | |||
495 | /* ************************************************************************ */ | 531 | /* ************************************************************************ */ |
496 | 532 | ||
497 | /* Setup functions. Note that: | 533 | /* Setup functions. Note that: | ... | ... |
... | @@ -23,9 +23,16 @@ | ... | @@ -23,9 +23,16 @@ |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <errno.h> | 24 | #include <errno.h> |
25 | 25 | ||
26 | #include <mailutils/errno.h> | ||
26 | #include <mailutils/monitor.h> | 27 | #include <mailutils/monitor.h> |
27 | #include <mailutils/refcount.h> | 28 | #include <mailutils/refcount.h> |
28 | 29 | ||
30 | struct _mu_refcount | ||
31 | { | ||
32 | unsigned int ref; | ||
33 | mu_monitor_t lock; | ||
34 | }; | ||
35 | |||
29 | int | 36 | int |
30 | mu_refcount_create (mu_refcount_t *prefcount) | 37 | mu_refcount_create (mu_refcount_t *prefcount) |
31 | { | 38 | { |
... | @@ -37,7 +44,7 @@ mu_refcount_create (mu_refcount_t *prefcount) | ... | @@ -37,7 +44,7 @@ mu_refcount_create (mu_refcount_t *prefcount) |
37 | if (refcount != NULL) | 44 | if (refcount != NULL) |
38 | { | 45 | { |
39 | refcount->ref = 1; | 46 | refcount->ref = 1; |
40 | status = monitor_create (&(refcount->lock)); | 47 | status = mu_monitor_create (&refcount->lock, 0, refcount); |
41 | if (status == 0) | 48 | if (status == 0) |
42 | { | 49 | { |
43 | *prefcount = refcount; | 50 | *prefcount = refcount; |
... | @@ -54,41 +61,47 @@ mu_refcount_create (mu_refcount_t *prefcount) | ... | @@ -54,41 +61,47 @@ mu_refcount_create (mu_refcount_t *prefcount) |
54 | return status; | 61 | return status; |
55 | } | 62 | } |
56 | 63 | ||
64 | unsigned | ||
65 | mu_refcount_value (mu_refcount_t refcount) | ||
66 | { | ||
67 | return refcount ? refcount->ref : 0; | ||
68 | } | ||
69 | |||
57 | void | 70 | void |
58 | mu_refcount_destroy (mu_refcount_t *prefcount) | 71 | mu_refcount_destroy (mu_refcount_t *prefcount) |
59 | { | 72 | { |
60 | if (prefcount && *prefcount) | 73 | if (prefcount && *prefcount) |
61 | { | 74 | { |
62 | mu_refcount_t refcount = *prefcount; | 75 | mu_refcount_t refcount = *prefcount; |
63 | monitor_destroy (&refcount->lock); | 76 | mu_monitor_destroy (&refcount->lock, refcount); |
64 | free (refcount); | 77 | free (refcount); |
65 | *prefcount = NULL; | 78 | *prefcount = NULL; |
66 | } | 79 | } |
67 | } | 80 | } |
68 | 81 | ||
69 | int | 82 | unsigned |
70 | mu_refcount_inc (mu_refcount_t refcount) | 83 | mu_refcount_inc (mu_refcount_t refcount) |
71 | { | 84 | { |
72 | int count = 0; | 85 | int count = 0; |
73 | if (refcount) | 86 | if (refcount) |
74 | { | 87 | { |
75 | monitor_lock (refcount->lock); | 88 | mu_monitor_wrlock (refcount->lock); |
76 | count = ++refcount->ref; | 89 | count = ++refcount->ref; |
77 | monitor_unlock (refcount->lock); | 90 | mu_monitor_wrlock (refcount->lock); |
78 | } | 91 | } |
79 | return count; | 92 | return count; |
80 | } | 93 | } |
81 | 94 | ||
82 | int | 95 | unsigned |
83 | mu_refcount_dec (mu_refcount_t refcount) | 96 | mu_refcount_dec (mu_refcount_t refcount) |
84 | { | 97 | { |
85 | int count = 0; | 98 | int count = 0; |
86 | if (refcount) | 99 | if (refcount) |
87 | { | 100 | { |
88 | monitor_lock (refcount->lock); | 101 | mu_monitor_wrlock (refcount->lock); |
89 | if (refcount->ref) | 102 | if (refcount->ref) |
90 | count = --refcount->ref; | 103 | count = --refcount->ref; |
91 | monitor_unlock (refcount->lock); | 104 | mu_monitor_wrlock (refcount->lock); |
92 | } | 105 | } |
93 | return count; | 106 | return count; |
94 | } | 107 | } | ... | ... |
... | @@ -63,6 +63,27 @@ static int interactive = -1; | ... | @@ -63,6 +63,27 @@ static int interactive = -1; |
63 | char *mimeview_file; /* Name of the file to view */ | 63 | char *mimeview_file; /* Name of the file to view */ |
64 | FILE *mimeview_fp; /* Its descriptor */ | 64 | FILE *mimeview_fp; /* Its descriptor */ |
65 | 65 | ||
66 | static void | ||
67 | set_debug_flags (mu_cfg_locus_t *locus, char *arg) | ||
68 | { | ||
69 | for (; *arg; arg++) | ||
70 | { | ||
71 | switch (*arg) | ||
72 | { | ||
73 | case 'l': | ||
74 | mimetypes_lex_debug (1); | ||
75 | break; | ||
76 | |||
77 | case 'g': | ||
78 | mimetypes_gram_debug (1); | ||
79 | break; | ||
80 | |||
81 | default: | ||
82 | debug_level = *arg - '0'; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
66 | static error_t | 87 | static error_t |
67 | parse_opt (int key, char *arg, struct argp_state *state) | 88 | parse_opt (int key, char *arg, struct argp_state *state) |
68 | { | 89 | { |
... | @@ -88,22 +109,7 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -88,22 +109,7 @@ parse_opt (int key, char *arg, struct argp_state *state) |
88 | case 'd': | 109 | case 'd': |
89 | if (!arg) | 110 | if (!arg) |
90 | arg = "9"; | 111 | arg = "9"; |
91 | for (; *arg; arg++) | 112 | set_debug_flags (NULL, arg); |
92 | { | ||
93 | switch (*arg) | ||
94 | { | ||
95 | case 'l': | ||
96 | mimetypes_lex_debug (1); | ||
97 | break; | ||
98 | |||
99 | case 'g': | ||
100 | mimetypes_gram_debug (1); | ||
101 | break; | ||
102 | |||
103 | default: | ||
104 | debug_level = *arg - '0'; | ||
105 | } | ||
106 | } | ||
107 | break; | 113 | break; |
108 | 114 | ||
109 | case 'h': | 115 | case 'h': |
... | @@ -137,6 +143,23 @@ static struct argp argp = { | ... | @@ -137,6 +143,23 @@ static struct argp argp = { |
137 | NULL, NULL | 143 | NULL, NULL |
138 | }; | 144 | }; |
139 | 145 | ||
146 | |||
147 | static int | ||
148 | cb_debug (mu_cfg_locus_t *locus, void *data, char *arg) | ||
149 | { | ||
150 | set_debug_flags (locus, arg); | ||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | struct mu_cfg_param mimeview_cfg_param[] = { | ||
155 | {"debug", mu_cfg_callback, NULL, cb_debug }, | ||
156 | {"mimetypes", mu_cfg_string, &mimetypes_config }, | ||
157 | {"metamail", mu_cfg_string, &metamail }, | ||
158 | { NULL } | ||
159 | }; | ||
160 | |||
161 | |||
162 | |||
140 | static const char *capa[] = { | 163 | static const char *capa[] = { |
141 | "common", | 164 | "common", |
142 | "license", | 165 | "license", |
... | @@ -239,6 +262,7 @@ main (int argc, char **argv) | ... | @@ -239,6 +262,7 @@ main (int argc, char **argv) |
239 | 262 | ||
240 | mu_init_nls (); | 263 | mu_init_nls (); |
241 | mu_argp_init (program_version, NULL); | 264 | mu_argp_init (program_version, NULL); |
265 | mu_argp_set_config_param (mimeview_cfg_param); | ||
242 | mu_argp_parse (&argp, &argc, &argv, 0, capa, &index, NULL); | 266 | mu_argp_parse (&argp, &argc, &argv, 0, capa, &index, NULL); |
243 | 267 | ||
244 | argc -= index; | 268 | argc -= index; | ... | ... |
... | @@ -77,6 +77,14 @@ static struct argp argp = { | ... | @@ -77,6 +77,14 @@ static struct argp argp = { |
77 | NULL, NULL | 77 | NULL, NULL |
78 | }; | 78 | }; |
79 | 79 | ||
80 | |||
81 | struct mu_cfg_param movemail_cfg_param[] = { | ||
82 | { "preserve", mu_cfg_bool, &preserve_mail }, | ||
83 | { "reverse", mu_cfg_bool, &reverse_order }, | ||
84 | { NULL } | ||
85 | }; | ||
86 | |||
87 | |||
80 | static const char *mail_capa[] = { | 88 | static const char *mail_capa[] = { |
81 | "common", | 89 | "common", |
82 | "license", | 90 | "license", |
... | @@ -84,7 +92,7 @@ static const char *mail_capa[] = { | ... | @@ -84,7 +92,7 @@ static const char *mail_capa[] = { |
84 | #ifdef WITH_TLS | 92 | #ifdef WITH_TLS |
85 | "tls", | 93 | "tls", |
86 | #endif | 94 | #endif |
87 | NULL | 95 | NULL |
88 | }; | 96 | }; |
89 | 97 | ||
90 | int | 98 | int |
... | @@ -281,13 +289,14 @@ main (int argc, char **argv) | ... | @@ -281,13 +289,14 @@ main (int argc, char **argv) |
281 | mu_register_all_mbox_formats (); | 289 | mu_register_all_mbox_formats (); |
282 | 290 | ||
283 | /* argument parsing */ | 291 | /* argument parsing */ |
284 | 292 | ||
285 | mu_error_set_print (movemail_error_printer); | 293 | mu_error_set_print (movemail_error_printer); |
286 | 294 | ||
287 | mu_argp_init (program_version, NULL); | 295 | mu_argp_init (program_version, NULL); |
288 | #ifdef WITH_TLS | 296 | #ifdef WITH_TLS |
289 | mu_tls_init_client_argp (); | 297 | mu_tls_init_client_argp (); |
290 | #endif | 298 | #endif |
299 | mu_argp_set_config_param (movemail_cfg_param); | ||
291 | mu_argp_parse (&argp, &argc, &argv, 0, mail_capa, &index, NULL); | 300 | mu_argp_parse (&argp, &argc, &argv, 0, mail_capa, &index, NULL); |
292 | 301 | ||
293 | argc -= index; | 302 | argc -= index; | ... | ... |
... | @@ -74,39 +74,33 @@ static char doc[] = N_("GNU pop3d -- the POP3 daemon"); | ... | @@ -74,39 +74,33 @@ static char doc[] = N_("GNU pop3d -- the POP3 daemon"); |
74 | 74 | ||
75 | static struct argp_option options[] = { | 75 | static struct argp_option options[] = { |
76 | #define GRP 0 | 76 | #define GRP 0 |
77 | { NULL, 0, NULL, 0, | 77 | {"undelete", 'u', NULL, OPTION_HIDDEN, |
78 | N_("General options"), GRP }, | ||
79 | {"undelete", 'u', NULL, 0, | ||
80 | N_("Undelete all messages on startup"), GRP+1}, | 78 | N_("Undelete all messages on startup"), GRP+1}, |
81 | {"expire", OPT_EXPIRE, N_("DAYS"), 0, | 79 | {"expire", OPT_EXPIRE, N_("DAYS"), OPTION_HIDDEN, |
82 | N_("Expire read messages after the given number of days"), GRP+1}, | 80 | N_("Expire read messages after the given number of days"), GRP+1}, |
83 | {"delete-expired", OPT_EXPIRE_ON_EXIT, NULL, 0, | 81 | {"delete-expired", OPT_EXPIRE_ON_EXIT, NULL, OPTION_HIDDEN, |
84 | N_("Delete expired messages upon closing the mailbox"), GRP+1}, | 82 | N_("Delete expired messages upon closing the mailbox"), GRP+1}, |
85 | #ifdef WITH_TLS | 83 | #ifdef WITH_TLS |
86 | {"tls-required", OPT_TLS_REQUIRED, NULL, 0, | 84 | {"tls-required", OPT_TLS_REQUIRED, NULL, OPTION_HIDDEN, |
87 | N_("Always require STLS before entering authentication phase")}, | 85 | N_("Always require STLS before entering authentication phase")}, |
88 | #endif | 86 | #endif |
89 | #undef GRP | 87 | #undef GRP |
90 | 88 | ||
91 | #define GRP 10 | 89 | #define GRP 10 |
92 | #ifdef ENABLE_LOGIN_DELAY | 90 | #ifdef ENABLE_LOGIN_DELAY |
93 | { NULL, 0, NULL, 0, | 91 | {"login-delay", OPT_LOGIN_DELAY, N_("SECONDS"), OPTION_HIDDEN, |
94 | N_("Login delay control"), GRP }, | ||
95 | {"login-delay", OPT_LOGIN_DELAY, N_("SECONDS"), 0, | ||
96 | N_("Allowed delay between the two successive logins"), GRP+1}, | 92 | N_("Allowed delay between the two successive logins"), GRP+1}, |
97 | {"stat-file", OPT_STAT_FILE, N_("FILENAME"), 0, | 93 | {"stat-file", OPT_STAT_FILE, N_("FILENAME"), OPTION_HIDDEN, |
98 | N_("Name of login statistics file"), GRP+1}, | 94 | N_("Name of login statistics file"), GRP+1}, |
99 | #endif | 95 | #endif |
100 | 96 | ||
101 | #undef GRP | 97 | #undef GRP |
102 | 98 | ||
103 | #define GRP 20 | 99 | #define GRP 20 |
104 | { NULL, 0, NULL, 0, | 100 | { "bulletin-source", OPT_BULLETIN_SOURCE, N_("MBOX"), OPTION_HIDDEN, |
105 | N_("Bulletin control"), GRP }, | ||
106 | { "bulletin-source", OPT_BULLETIN_SOURCE, N_("MBOX"), 0, | ||
107 | N_("Set source mailbox to get bulletins from"), GRP+1 }, | 101 | N_("Set source mailbox to get bulletins from"), GRP+1 }, |
108 | #ifdef USE_DBM | 102 | #ifdef USE_DBM |
109 | { "bulletin-db", OPT_BULLETIN_DB, N_("FILE"), 0, | 103 | { "bulletin-db", OPT_BULLETIN_DB, N_("FILE"), OPTION_HIDDEN, |
110 | N_("Set the bulletin database file name"), GRP+1 }, | 104 | N_("Set the bulletin database file name"), GRP+1 }, |
111 | #endif | 105 | #endif |
112 | #undef GRP | 106 | #undef GRP |
... | @@ -114,6 +108,43 @@ static struct argp_option options[] = { | ... | @@ -114,6 +108,43 @@ static struct argp_option options[] = { |
114 | {NULL, 0, NULL, 0, NULL, 0} | 108 | {NULL, 0, NULL, 0, NULL, 0} |
115 | }; | 109 | }; |
116 | 110 | ||
111 | #ifdef WITH_TLS | ||
112 | static int | ||
113 | cb_tls_expired (mu_cfg_locus_t *locus, void *data, char *arg) | ||
114 | { | ||
115 | initial_state = INITIAL; | ||
116 | return 0; | ||
117 | } | ||
118 | #endif | ||
119 | |||
120 | static int | ||
121 | cb_bulletin_source (mu_cfg_locus_t *locus, void *data, char *arg) | ||
122 | { | ||
123 | set_bulletin_source (arg); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int | ||
128 | cb_bulletin_db (mu_cfg_locus_t *locus, void *data, char *arg) | ||
129 | { | ||
130 | set_bulletin_source (arg); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static struct mu_cfg_param pop3d_cfg_param[] = { | ||
135 | { "undelete", mu_cfg_int, &undelete_on_startup }, | ||
136 | { "expire", mu_cfg_time, &expire }, | ||
137 | { "delete-expired", mu_cfg_int, &expire_on_exit }, | ||
138 | #ifdef WITH_TLS | ||
139 | { "tls-required", mu_cfg_callback, NULL, cb_tls_expired }, | ||
140 | #endif | ||
141 | { "login-delay", mu_cfg_time, &login_delay }, | ||
142 | { "stat-file", mu_cfg_string, &login_stat_file }, | ||
143 | { "bulletin-source", mu_cfg_callback, NULL, cb_bulletin_source }, | ||
144 | { "bulletin-db", mu_cfg_callback, NULL, cb_bulletin_db }, | ||
145 | { NULL } | ||
146 | }; | ||
147 | |||
117 | static struct argp argp = { | 148 | static struct argp argp = { |
118 | options, | 149 | options, |
119 | pop3d_parse_opt, | 150 | pop3d_parse_opt, |
... | @@ -221,8 +252,12 @@ main (int argc, char **argv) | ... | @@ -221,8 +252,12 @@ main (int argc, char **argv) |
221 | #ifdef WITH_TLS | 252 | #ifdef WITH_TLS |
222 | mu_tls_init_argp (); | 253 | mu_tls_init_argp (); |
223 | #endif /* WITH_TLS */ | 254 | #endif /* WITH_TLS */ |
255 | mu_argp_set_config_param (pop3d_cfg_param); | ||
224 | mu_argp_parse (&argp, &argc, &argv, 0, pop3d_argp_capa, NULL, &daemon_param); | 256 | mu_argp_parse (&argp, &argc, &argv, 0, pop3d_argp_capa, NULL, &daemon_param); |
225 | 257 | ||
258 | if (expire == 0) | ||
259 | expire_on_exit = 1; | ||
260 | |||
226 | #ifdef USE_LIBPAM | 261 | #ifdef USE_LIBPAM |
227 | if (!pam_service) | 262 | if (!pam_service) |
228 | pam_service = "gnu-pop3d"; | 263 | pam_service = "gnu-pop3d"; | ... | ... |
... | @@ -114,6 +114,18 @@ readmsg_parse_opt (int key, char *arg, struct argp_state *astate) | ... | @@ -114,6 +114,18 @@ readmsg_parse_opt (int key, char *arg, struct argp_state *astate) |
114 | return 0; | 114 | return 0; |
115 | } | 115 | } |
116 | 116 | ||
117 | |||
118 | struct mu_cfg_param readmsg_cfg_param[] = { | ||
119 | { "debug", mu_cfg_int, &dbug }, | ||
120 | { "header", mu_cfg_bool, &all_header }, | ||
121 | { "weedlist", mu_cfg_string, &weedlist }, | ||
122 | { "folder", mu_cfg_string, &mailbox_name }, | ||
123 | { "no-header", mu_cfg_bool, &no_header }, | ||
124 | { "form-feeds", mu_cfg_bool, &form_feed }, | ||
125 | { "show-all-match", mu_cfg_bool, &show_all }, | ||
126 | { NULL } | ||
127 | }; | ||
128 | |||
117 | static int | 129 | static int |
118 | string_starts_with (const char * s1, const char *s2) | 130 | string_starts_with (const char * s1, const char *s2) |
119 | { | 131 | { |
... | @@ -268,6 +280,7 @@ main (int argc, char **argv) | ... | @@ -268,6 +280,7 @@ main (int argc, char **argv) |
268 | #ifdef WITH_TLS | 280 | #ifdef WITH_TLS |
269 | mu_tls_init_client_argp (); | 281 | mu_tls_init_client_argp (); |
270 | #endif | 282 | #endif |
283 | mu_argp_set_config_param (readmsg_cfg_param); | ||
271 | mu_argp_parse (&argp, &argc, &argv, 0, readmsg_argp_capa, &index, NULL); | 284 | mu_argp_parse (&argp, &argc, &argv, 0, readmsg_argp_capa, &index, NULL); |
272 | 285 | ||
273 | /* register the formats. */ | 286 | /* register the formats. */ | ... | ... |
... | @@ -97,17 +97,15 @@ static struct argp_option options[] = | ... | @@ -97,17 +97,15 @@ static struct argp_option options[] = |
97 | {0} | 97 | {0} |
98 | }; | 98 | }; |
99 | 99 | ||
100 | struct options { | 100 | int keep_going; |
101 | int keep_going; | 101 | int compile_only; |
102 | int compile_only; | 102 | char *mbox_url; |
103 | char *mbox; | 103 | char *tickets; |
104 | char *tickets; | 104 | int tickets_default; |
105 | int tickets_default; | 105 | int debug_level; |
106 | int debug_level; | 106 | int sieve_debug; |
107 | int sieve_debug; | 107 | int verbose; |
108 | int verbose; | 108 | char *script; |
109 | char *script; | ||
110 | }; | ||
111 | 109 | ||
112 | static int sieve_print_locus = 1; /* Should the log messages include the | 110 | static int sieve_print_locus = 1; /* Should the log messages include the |
113 | locus */ | 111 | locus */ |
... | @@ -123,25 +121,50 @@ is_true_p (char *p) | ... | @@ -123,25 +121,50 @@ is_true_p (char *p) |
123 | return rc; | 121 | return rc; |
124 | } | 122 | } |
125 | 123 | ||
124 | static void | ||
125 | set_debug_level (mu_cfg_locus_t *locus, const char *arg) | ||
126 | { | ||
127 | for (; *arg; arg++) | ||
128 | { | ||
129 | switch (*arg) | ||
130 | { | ||
131 | case 'T': | ||
132 | debug_level |= MU_DEBUG_TRACE; | ||
133 | break; | ||
134 | |||
135 | case 'P': | ||
136 | debug_level |= MU_DEBUG_PROT; | ||
137 | break; | ||
138 | |||
139 | case 'g': | ||
140 | mu_sieve_yydebug = 1; | ||
141 | break; | ||
142 | |||
143 | case 't': | ||
144 | sieve_debug |= MU_SIEVE_DEBUG_TRACE; | ||
145 | break; | ||
146 | |||
147 | case 'i': | ||
148 | sieve_debug |= MU_SIEVE_DEBUG_INSTR; | ||
149 | break; | ||
150 | |||
151 | default: | ||
152 | if (locus) | ||
153 | mu_error (_("%s:%d: %c is not a valid debug flag"), | ||
154 | locus->file, locus->line, *arg); | ||
155 | else | ||
156 | mu_error (_("%c is not a valid debug flag"), *arg); | ||
157 | } | ||
158 | } | ||
159 | } | ||
160 | |||
126 | static error_t | 161 | static error_t |
127 | parser (int key, char *arg, struct argp_state *state) | 162 | parser (int key, char *arg, struct argp_state *state) |
128 | { | 163 | { |
129 | struct options *opts = state->input; | ||
130 | int rc; | 164 | int rc; |
131 | 165 | ||
132 | switch (key) | 166 | switch (key) |
133 | { | 167 | { |
134 | case ARGP_KEY_INIT: | ||
135 | if (!opts->tickets) | ||
136 | { | ||
137 | opts->tickets = mu_tilde_expansion ("~/.tickets", "/", NULL); | ||
138 | opts->tickets_default = 1; | ||
139 | } | ||
140 | if (!opts->debug_level) | ||
141 | opts->debug_level = MU_DEBUG_ERROR; | ||
142 | log_facility = 0; | ||
143 | break; | ||
144 | |||
145 | case 'e': | 168 | case 'e': |
146 | rc = mu_set_user_email (arg); | 169 | rc = mu_set_user_email (arg); |
147 | if (rc) | 170 | if (rc) |
... | @@ -149,69 +172,41 @@ parser (int key, char *arg, struct argp_state *state) | ... | @@ -149,69 +172,41 @@ parser (int key, char *arg, struct argp_state *state) |
149 | break; | 172 | break; |
150 | 173 | ||
151 | case 'n': | 174 | case 'n': |
152 | opts->sieve_debug |= MU_SIEVE_DRY_RUN; | 175 | sieve_debug |= MU_SIEVE_DRY_RUN; |
153 | break; | 176 | break; |
154 | 177 | ||
155 | case 'k': | 178 | case 'k': |
156 | opts->keep_going = 1; | 179 | keep_going = 1; |
157 | break; | 180 | break; |
158 | 181 | ||
159 | case 'c': | 182 | case 'c': |
160 | opts->compile_only = 1; | 183 | compile_only = 1; |
161 | break; | 184 | break; |
162 | 185 | ||
163 | case 'D': | 186 | case 'D': |
164 | opts->compile_only = 2; | 187 | compile_only = 2; |
165 | break; | 188 | break; |
166 | 189 | ||
167 | case 'f': | 190 | case 'f': |
168 | if (opts->mbox) | 191 | if (mbox_url) |
169 | argp_error (state, _("Only one MBOX can be specified")); | 192 | free (mbox_url); |
170 | opts->mbox = strdup (arg); | 193 | mbox_url = strdup (arg); |
171 | break; | 194 | break; |
172 | 195 | ||
173 | case 't': | 196 | case 't': |
174 | free (opts->tickets); | 197 | free (tickets); |
175 | opts->tickets = mu_tilde_expansion (arg, "/", NULL); | 198 | tickets = mu_tilde_expansion (arg, "/", NULL); |
176 | opts->tickets_default = 0; | 199 | tickets_default = 0; |
177 | break; | 200 | break; |
178 | 201 | ||
179 | case 'd': | 202 | case 'd': |
180 | if (!arg) | 203 | if (!arg) |
181 | arg = D_DEFAULT; | 204 | arg = D_DEFAULT; |
182 | for (; *arg; arg++) | 205 | set_debug_level (NULL, arg); |
183 | { | ||
184 | switch (*arg) | ||
185 | { | ||
186 | case 'T': | ||
187 | opts->debug_level |= MU_DEBUG_TRACE; | ||
188 | break; | ||
189 | |||
190 | case 'P': | ||
191 | opts->debug_level |= MU_DEBUG_PROT; | ||
192 | break; | ||
193 | |||
194 | case 'g': | ||
195 | mu_sieve_yydebug = 1; | ||
196 | break; | ||
197 | |||
198 | case 't': | ||
199 | opts->sieve_debug |= MU_SIEVE_DEBUG_TRACE; | ||
200 | break; | ||
201 | |||
202 | case 'i': | ||
203 | opts->sieve_debug |= MU_SIEVE_DEBUG_INSTR; | ||
204 | break; | ||
205 | |||
206 | default: | ||
207 | argp_error (state, _("%c is not a valid debug flag"), *arg); | ||
208 | break; | ||
209 | } | ||
210 | } | ||
211 | break; | 206 | break; |
212 | 207 | ||
213 | case 'v': | 208 | case 'v': |
214 | opts->verbose = 1; | 209 | verbose = 1; |
215 | break; | 210 | break; |
216 | 211 | ||
217 | case ARG_LINE_INFO: | 212 | case ARG_LINE_INFO: |
... | @@ -219,9 +214,9 @@ parser (int key, char *arg, struct argp_state *state) | ... | @@ -219,9 +214,9 @@ parser (int key, char *arg, struct argp_state *state) |
219 | break; | 214 | break; |
220 | 215 | ||
221 | case ARGP_KEY_ARG: | 216 | case ARGP_KEY_ARG: |
222 | if (opts->script) | 217 | if (script) |
223 | argp_error (state, _("Only one SCRIPT can be specified")); | 218 | argp_error (state, _("Only one SCRIPT can be specified")); |
224 | opts->script = mu_tilde_expansion (arg, "/", NULL); | 219 | script = mu_tilde_expansion (arg, "/", NULL); |
225 | break; | 220 | break; |
226 | 221 | ||
227 | case ARGP_KEY_NO_ARGS: | 222 | case ARGP_KEY_NO_ARGS: |
... | @@ -242,6 +237,45 @@ static struct argp argp = | ... | @@ -242,6 +237,45 @@ static struct argp argp = |
242 | doc | 237 | doc |
243 | }; | 238 | }; |
244 | 239 | ||
240 | |||
241 | static int | ||
242 | cb_debug (mu_cfg_locus_t *locus, void *data, char *arg) | ||
243 | { | ||
244 | set_debug_level (locus, arg); | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static int | ||
249 | cb_email (mu_cfg_locus_t *locus, void *data, char *arg) | ||
250 | { | ||
251 | int rc = mu_set_user_email (arg); | ||
252 | if (rc) | ||
253 | mu_error (_("%s:%d: Invalid email: %s"), | ||
254 | locus->file, locus->line, mu_strerror (rc)); | ||
255 | return rc; | ||
256 | } | ||
257 | |||
258 | static int | ||
259 | cb_ticket (mu_cfg_locus_t *locus, void *data, char *arg) | ||
260 | { | ||
261 | free (tickets); | ||
262 | tickets = mu_tilde_expansion (arg, "/", NULL); | ||
263 | tickets_default = 0; | ||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | static struct mu_cfg_param sieve_cfg_param[] = { | ||
268 | { "keep-going", mu_cfg_int, &keep_going }, | ||
269 | { "mbox-url", mu_cfg_string, &mbox_url }, | ||
270 | { "ticket", mu_cfg_callback, NULL, cb_ticket }, | ||
271 | { "debug", mu_cfg_callback, NULL, cb_debug }, | ||
272 | { "verbose", mu_cfg_bool, &verbose }, | ||
273 | { "line-info", mu_cfg_bool, &sieve_print_locus }, | ||
274 | { "email", mu_cfg_callback, NULL, cb_email }, | ||
275 | { NULL } | ||
276 | }; | ||
277 | |||
278 | |||
245 | static const char *sieve_argp_capa[] = | 279 | static const char *sieve_argp_capa[] = |
246 | { | 280 | { |
247 | "common", | 281 | "common", |
... | @@ -348,7 +382,6 @@ main (int argc, char *argv[]) | ... | @@ -348,7 +382,6 @@ main (int argc, char *argv[]) |
348 | mu_debug_t debug = 0; | 382 | mu_debug_t debug = 0; |
349 | mu_mailbox_t mbox = 0; | 383 | mu_mailbox_t mbox = 0; |
350 | int rc; | 384 | int rc; |
351 | struct options opts = {0}; | ||
352 | int (*debugfp) (mu_debug_t, size_t level, const char *, va_list); | 385 | int (*debugfp) (mu_debug_t, size_t level, const char *, va_list); |
353 | 386 | ||
354 | /* Native Language Support */ | 387 | /* Native Language Support */ |
... | @@ -360,9 +393,15 @@ main (int argc, char *argv[]) | ... | @@ -360,9 +393,15 @@ main (int argc, char *argv[]) |
360 | #endif | 393 | #endif |
361 | mu_sieve_argp_init (); | 394 | mu_sieve_argp_init (); |
362 | mu_register_all_formats (); | 395 | mu_register_all_formats (); |
396 | |||
397 | tickets = mu_tilde_expansion ("~/.tickets", "/", NULL); | ||
398 | tickets_default = 1; | ||
399 | debug_level = MU_DEBUG_ERROR; | ||
400 | log_facility = 0; | ||
363 | 401 | ||
402 | mu_argp_set_config_param (sieve_cfg_param); | ||
364 | rc = mu_argp_parse (&argp, &argc, &argv, ARGP_IN_ORDER, sieve_argp_capa, | 403 | rc = mu_argp_parse (&argp, &argc, &argv, ARGP_IN_ORDER, sieve_argp_capa, |
365 | 0, &opts); | 404 | 0, 0); |
366 | 405 | ||
367 | if (rc) | 406 | if (rc) |
368 | return 1; | 407 | return 1; |
... | @@ -382,34 +421,34 @@ main (int argc, char *argv[]) | ... | @@ -382,34 +421,34 @@ main (int argc, char *argv[]) |
382 | openlog ("sieve", LOG_PID, log_facility); | 421 | openlog ("sieve", LOG_PID, log_facility); |
383 | mu_error_set_print (mu_syslog_error_printer); | 422 | mu_error_set_print (mu_syslog_error_printer); |
384 | mu_sieve_set_debug (mach, sieve_syslog_debug_printer); | 423 | mu_sieve_set_debug (mach, sieve_syslog_debug_printer); |
385 | if (opts.verbose) | 424 | if (verbose) |
386 | mu_sieve_set_logger (mach, syslog_action_log); | 425 | mu_sieve_set_logger (mach, syslog_action_log); |
387 | debugfp = syslog_debug_print; | 426 | debugfp = syslog_debug_print; |
388 | } | 427 | } |
389 | else | 428 | else |
390 | { | 429 | { |
391 | mu_sieve_set_debug (mach, sieve_stderr_debug_printer); | 430 | mu_sieve_set_debug (mach, sieve_stderr_debug_printer); |
392 | if (opts.verbose) | 431 | if (verbose) |
393 | mu_sieve_set_logger (mach, stdout_action_log); | 432 | mu_sieve_set_logger (mach, stdout_action_log); |
394 | debugfp = stderr_debug_print; | 433 | debugfp = stderr_debug_print; |
395 | } | 434 | } |
396 | 435 | ||
397 | rc = mu_sieve_compile (mach, opts.script); | 436 | rc = mu_sieve_compile (mach, script); |
398 | if (rc) | 437 | if (rc) |
399 | return 1; | 438 | return 1; |
400 | 439 | ||
401 | /* We can finish if its only a compilation check. */ | 440 | /* We can finish if its only a compilation check. */ |
402 | if (opts.compile_only) | 441 | if (compile_only) |
403 | { | 442 | { |
404 | if (opts.compile_only == 2) | 443 | if (compile_only == 2) |
405 | mu_sieve_disass (mach); | 444 | mu_sieve_disass (mach); |
406 | return 0; | 445 | return 0; |
407 | } | 446 | } |
408 | 447 | ||
409 | /* Create a ticket, if we can. */ | 448 | /* Create a ticket, if we can. */ |
410 | if (opts.tickets) | 449 | if (tickets) |
411 | { | 450 | { |
412 | if ((rc = mu_wicket_create (&wicket, opts.tickets)) == 0) | 451 | if ((rc = mu_wicket_create (&wicket, tickets)) == 0) |
413 | { | 452 | { |
414 | if ((rc = mu_wicket_get_ticket (wicket, &ticket, 0, 0)) != 0) | 453 | if ((rc = mu_wicket_get_ticket (wicket, &ticket, 0, 0)) != 0) |
415 | { | 454 | { |
... | @@ -417,10 +456,10 @@ main (int argc, char *argv[]) | ... | @@ -417,10 +456,10 @@ main (int argc, char *argv[]) |
417 | goto cleanup; | 456 | goto cleanup; |
418 | } | 457 | } |
419 | } | 458 | } |
420 | else if (!(opts.tickets_default && errno == ENOENT)) | 459 | else if (!(tickets_default && errno == ENOENT)) |
421 | { | 460 | { |
422 | mu_error (_("mu_wicket_create `%s' failed: %s"), | 461 | mu_error (_("mu_wicket_create `%s' failed: %s"), |
423 | opts.tickets, mu_strerror (rc)); | 462 | tickets, mu_strerror (rc)); |
424 | goto cleanup; | 463 | goto cleanup; |
425 | } | 464 | } |
426 | if (ticket) | 465 | if (ticket) |
... | @@ -428,14 +467,14 @@ main (int argc, char *argv[]) | ... | @@ -428,14 +467,14 @@ main (int argc, char *argv[]) |
428 | } | 467 | } |
429 | 468 | ||
430 | /* Create a debug object, if needed. */ | 469 | /* Create a debug object, if needed. */ |
431 | if (opts.debug_level) | 470 | if (debug_level) |
432 | { | 471 | { |
433 | if ((rc = mu_debug_create (&debug, mach))) | 472 | if ((rc = mu_debug_create (&debug, mach))) |
434 | { | 473 | { |
435 | mu_error (_("mu_debug_create failed: %s"), mu_strerror (rc)); | 474 | mu_error (_("mu_debug_create failed: %s"), mu_strerror (rc)); |
436 | goto cleanup; | 475 | goto cleanup; |
437 | } | 476 | } |
438 | if ((rc = mu_debug_set_level (debug, opts.debug_level))) | 477 | if ((rc = mu_debug_set_level (debug, debug_level))) |
439 | { | 478 | { |
440 | mu_error (_("mu_debug_set_level failed: %s"), | 479 | mu_error (_("mu_debug_set_level failed: %s"), |
441 | mu_strerror (rc)); | 480 | mu_strerror (rc)); |
... | @@ -449,14 +488,14 @@ main (int argc, char *argv[]) | ... | @@ -449,14 +488,14 @@ main (int argc, char *argv[]) |
449 | } | 488 | } |
450 | } | 489 | } |
451 | 490 | ||
452 | mu_sieve_set_debug_level (mach, debug, opts.sieve_debug); | 491 | mu_sieve_set_debug_level (mach, debug, sieve_debug); |
453 | 492 | ||
454 | /* Create, give a ticket to, and open the mailbox. */ | 493 | /* Create, give a ticket to, and open the mailbox. */ |
455 | if ((rc = mu_mailbox_create_default (&mbox, opts.mbox)) != 0) | 494 | if ((rc = mu_mailbox_create_default (&mbox, mbox_url)) != 0) |
456 | { | 495 | { |
457 | if (opts.mbox) | 496 | if (mbox) |
458 | mu_error (_("Could not create mailbox `%s': %s"), | 497 | mu_error (_("Could not create mailbox `%s': %s"), |
459 | opts.mbox, mu_strerror (rc)); | 498 | mbox_url, mu_strerror (rc)); |
460 | else | 499 | else |
461 | mu_error (_("Could not create default mailbox: %s"), | 500 | mu_error (_("Could not create default mailbox: %s"), |
462 | mu_strerror (rc)); | 501 | mu_strerror (rc)); |
... | @@ -498,16 +537,16 @@ main (int argc, char *argv[]) | ... | @@ -498,16 +537,16 @@ main (int argc, char *argv[]) |
498 | } | 537 | } |
499 | 538 | ||
500 | /* Open the mailbox read-only if we aren't going to modify it. */ | 539 | /* Open the mailbox read-only if we aren't going to modify it. */ |
501 | if (opts.sieve_debug & MU_SIEVE_DRY_RUN) | 540 | if (sieve_debug & MU_SIEVE_DRY_RUN) |
502 | rc = mu_mailbox_open (mbox, MU_STREAM_READ); | 541 | rc = mu_mailbox_open (mbox, MU_STREAM_READ); |
503 | else | 542 | else |
504 | rc = mu_mailbox_open (mbox, MU_STREAM_RDWR); | 543 | rc = mu_mailbox_open (mbox, MU_STREAM_RDWR); |
505 | 544 | ||
506 | if (rc != 0) | 545 | if (rc != 0) |
507 | { | 546 | { |
508 | if (opts.mbox) | 547 | if (mbox) |
509 | mu_error (_("Opening mailbox `%s' failed: %s"), | 548 | mu_error (_("Opening mailbox `%s' failed: %s"), |
510 | opts.mbox, mu_strerror (rc)); | 549 | mbox_url, mu_strerror (rc)); |
511 | else | 550 | else |
512 | mu_error (_("Opening default mailbox failed: %s"), | 551 | mu_error (_("Opening default mailbox failed: %s"), |
513 | mu_strerror (rc)); | 552 | mu_strerror (rc)); |
... | @@ -519,7 +558,7 @@ main (int argc, char *argv[]) | ... | @@ -519,7 +558,7 @@ main (int argc, char *argv[]) |
519 | rc = mu_sieve_mailbox (mach, mbox); | 558 | rc = mu_sieve_mailbox (mach, mbox); |
520 | 559 | ||
521 | cleanup: | 560 | cleanup: |
522 | if (mbox && !(opts.sieve_debug & MU_SIEVE_DRY_RUN)) | 561 | if (mbox && !(sieve_debug & MU_SIEVE_DRY_RUN)) |
523 | { | 562 | { |
524 | int e; | 563 | int e; |
525 | 564 | ||
... | @@ -529,9 +568,9 @@ cleanup: | ... | @@ -529,9 +568,9 @@ cleanup: |
529 | on a later message. */ | 568 | on a later message. */ |
530 | if ((e = mu_mailbox_expunge (mbox)) != 0) | 569 | if ((e = mu_mailbox_expunge (mbox)) != 0) |
531 | { | 570 | { |
532 | if (opts.mbox) | 571 | if (mbox) |
533 | mu_error (_("Expunge on mailbox `%s' failed: %s"), | 572 | mu_error (_("Expunge on mailbox `%s' failed: %s"), |
534 | opts.mbox, mu_strerror (e)); | 573 | mbox_url, mu_strerror (e)); |
535 | else | 574 | else |
536 | mu_error (_("Expunge on default mailbox failed: %s"), | 575 | mu_error (_("Expunge on default mailbox failed: %s"), |
537 | mu_strerror (e)); | 576 | mu_strerror (e)); | ... | ... |
... | @@ -21,6 +21,7 @@ verbose "STARTED" 1 | ... | @@ -21,6 +21,7 @@ verbose "STARTED" 1 |
21 | 21 | ||
22 | # Make sure we use POSIX locale | 22 | # Make sure we use POSIX locale |
23 | set env(LC_ALL) "C" | 23 | set env(LC_ALL) "C" |
24 | set env(MU_CONFIG_FLAVOR) "none" | ||
24 | 25 | ||
25 | proc mu_init {args} { | 26 | proc mu_init {args} { |
26 | global TOOL_EXECUTABLE | 27 | global TOOL_EXECUTABLE | ... | ... |
-
Please register or sign in to post a comment