Commit 0629f30c 0629f30c46c8b574f13d747ea3fd0c7215933df2 by Sam Roberts

Added :mailer group, with option --mailer,-M to set the default mailer URL.

1 parent 5559b5ce
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 Copyright (C) 1999, 2001 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option) 6 the Free Software Foundation; either version 2, or (at your option)
7 any later version. 7 any later version.
8 8
...@@ -35,11 +35,13 @@ ...@@ -35,11 +35,13 @@
35 # include <strings.h> 35 # include <strings.h>
36 #endif 36 #endif
37 37
38 #include <mailutils/argp.h>
38 #include <mailutils/error.h> 39 #include <mailutils/error.h>
39 #include <mailutils/errno.h> 40 #include <mailutils/errno.h>
40 #include <mailutils/mutil.h> 41 #include <mailutils/mutil.h>
41 #include <mailutils/locker.h> 42 #include <mailutils/locker.h>
42 #include <mailutils/mu_argp.h> 43 #include <mailutils/mailer.h>
44 #include <mailutils/mailbox.h>
43 45
44 #include <argcv.h> 46 #include <argcv.h>
45 #include <mu_asprintf.h> 47 #include <mu_asprintf.h>
...@@ -90,6 +92,13 @@ static struct argp_option mu_address_argp_option[] = { ...@@ -90,6 +92,13 @@ static struct argp_option mu_address_argp_option[] = {
90 { NULL, 0, NULL, 0, NULL, 0 } 92 { NULL, 0, NULL, 0, NULL, 0 }
91 }; 93 };
92 94
95 /* Options used by programs that send mail. */
96 static struct argp_option mu_mailer_argp_option[] = {
97 {"mailer", 'M', "MAILER", 0,
98 "Use specified URL as the default mailer", 0},
99 { NULL, 0, NULL, 0, NULL, 0 }
100 };
101
93 /* Options used by programs that log to syslog. */ 102 /* Options used by programs that log to syslog. */
94 static struct argp_option mu_logging_argp_option[] = { 103 static struct argp_option mu_logging_argp_option[] = {
95 {"log-facility", ARG_LOG_FACILITY, "FACILITY", 0, 104 {"log-facility", ARG_LOG_FACILITY, "FACILITY", 0,
...@@ -190,6 +199,18 @@ struct argp_child mu_address_argp_child = { ...@@ -190,6 +199,18 @@ struct argp_child mu_address_argp_child = {
190 0 199 0
191 }; 200 };
192 201
202 struct argp mu_mailer_argp = {
203 mu_mailer_argp_option,
204 mu_common_argp_parser,
205 };
206
207 struct argp_child mu_mailer_argp_child = {
208 &mu_mailer_argp,
209 0,
210 NULL,
211 0
212 };
213
193 struct argp mu_logging_argp = { 214 struct argp mu_logging_argp = {
194 mu_logging_argp_option, 215 mu_logging_argp_option,
195 mu_common_argp_parser, 216 mu_common_argp_parser,
...@@ -291,10 +312,6 @@ int sql_port = MPORT; ...@@ -291,10 +312,6 @@ int sql_port = MPORT;
291 char *pam_service = NULL; 312 char *pam_service = NULL;
292 #endif 313 #endif
293 314
294 void
295 mu_argp_fake()
296 {
297 }
298 static error_t 315 static error_t
299 mu_common_argp_parser (int key, char *arg, struct argp_state *state) 316 mu_common_argp_parser (int key, char *arg, struct argp_state *state)
300 { 317 {
...@@ -358,6 +375,16 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -358,6 +375,16 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state)
358 } 375 }
359 break; 376 break;
360 377
378 /* mailer */
379 case 'M':
380 if ((err = mailer_set_url_default(arg)) != 0)
381 {
382 argp_error (state, "invalid mailer url '%s': %s",
383 arg, mu_errstring(err));
384 }
385 break;
386
387
361 /* log */ 388 /* log */
362 case ARG_LOG_FACILITY: 389 case ARG_LOG_FACILITY:
363 log_facility = parse_log_facility (arg); 390 log_facility = parse_log_facility (arg);
...@@ -713,6 +740,7 @@ struct argp_capa { ...@@ -713,6 +740,7 @@ struct argp_capa {
713 {"license", &mu_license_argp_child}, 740 {"license", &mu_license_argp_child},
714 {"mailbox", &mu_mailbox_argp_child}, 741 {"mailbox", &mu_mailbox_argp_child},
715 {"address", &mu_address_argp_child}, 742 {"address", &mu_address_argp_child},
743 {"mailer", &mu_mailer_argp_child},
716 {"logging", &mu_logging_argp_child}, 744 {"logging", &mu_logging_argp_child},
717 {"auth", &mu_auth_argp_child}, 745 {"auth", &mu_auth_argp_child},
718 {"daemon", &mu_daemon_argp_child}, 746 {"daemon", &mu_daemon_argp_child},
......