diff options
author | Sam Roberts <sroberts@uniserve.com> | 2002-04-16 03:33:31 +0000 |
---|---|---|
committer | Sam Roberts <sroberts@uniserve.com> | 2002-04-16 03:33:31 +0000 |
commit | d34dce058f84dc219231d0abb31ff798c5e3ba79 (patch) | |
tree | 49868ff277a0c5c67c09b0bba0120039babfe77a /lib | |
parent | d4a000cbb6f6c40384f6ffefda5796aff362bccc (diff) | |
download | mailutils-d34dce058f84dc219231d0abb31ff798c5e3ba79.tar.gz mailutils-d34dce058f84dc219231d0abb31ff798c5e3ba79.tar.bz2 |
new mu_set_user_email() - email address to use for NULL (current) user
new mu_set_user_email_domain() - domain to use to qualify an @-less username
modified mu_get_user_email() - now uses default address and domain, if set
-E,--email-addr - config option, calls mu_set_user_email
-D,--email-domain - config option, calls mu_set_user_email_domain
:address group for the above config options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mu_argp.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/lib/mu_argp.c b/lib/mu_argp.c index ca90cb09d..03b24e540 100644 --- a/lib/mu_argp.c +++ b/lib/mu_argp.c @@ -36,11 +36,13 @@ #endif #include <mailutils/error.h> +#include <mailutils/errno.h> #include <mailutils/mutil.h> #include <mailutils/locker.h> #include <argcv.h> #include <mu_argp.h> +#include <mu_asprintf.h> #ifdef HAVE_MYSQL # include "../MySql/MySql.h" @@ -79,6 +81,15 @@ static struct argp_option mu_mailbox_argp_option[] = { { NULL, 0, NULL, 0, NULL, 0 } }; +/* Options used by programs that do address mapping. */ +static struct argp_option mu_address_argp_option[] = { + {"email-addr", 'E', "EMAIL", 0, + "Set current user's email address (default is loginname@defaultdomain)", 0}, + {"email-domain", 'D', "DOMAIN", 0, + "Set domain for unqualified user names (default is this host)", 0}, + { NULL, 0, NULL, 0, NULL, 0 } +}; + /* Options used by programs that log to syslog. */ static struct argp_option mu_logging_argp_option[] = { {"log-facility", ARG_LOG_FACILITY, "FACILITY", 0, @@ -167,6 +178,18 @@ struct argp_child mu_mailbox_argp_child = { 0 }; +struct argp mu_address_argp = { + mu_address_argp_option, + mu_common_argp_parser, +}; + +struct argp_child mu_address_argp_child = { + &mu_address_argp, + 0, + NULL, + 0 +}; + struct argp mu_logging_argp = { mu_logging_argp_option, mu_common_argp_parser, @@ -271,6 +294,7 @@ char *pam_service = NULL; static error_t mu_common_argp_parser (int key, char *arg, struct argp_state *state) { + int err = 0; char *p; switch (key) @@ -313,6 +337,23 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) } break; + /* address */ + case 'E': + if ((err = mu_set_user_email(arg)) != 0) + { + argp_error (state, "invalid email-addr '%s': %s", + arg, mu_errstring(err)); + } + break; + + case 'D': + if ((err = mu_set_user_email_domain(arg)) != 0) + { + argp_error (state, "invalid email-domain '%s': %s", + arg, mu_errstring(err)); + } + break; + /* log */ case ARG_LOG_FACILITY: log_facility = parse_log_facility (arg); @@ -618,7 +659,7 @@ mu_create_argcv (const char *capa[], { char* userrc = NULL; - asprintf(&userrc, "%s/mailutils", MU_USER_CONFIG_FILE); + mu_asprintf(&userrc, "%s/mailutils", MU_USER_CONFIG_FILE); if (!userrc) { @@ -635,9 +676,9 @@ mu_create_argcv (const char *capa[], char* progrc = NULL; if(rcdir) - asprintf(&progrc, "%s/%src", MU_USER_CONFIG_FILE, progname); + mu_asprintf(&progrc, "%s/%src", MU_USER_CONFIG_FILE, progname); else - asprintf(&progrc, "~/.mu.%src", progname); + mu_asprintf(&progrc, "~/.mu.%src", progname); if (!progrc) { @@ -667,6 +708,7 @@ struct argp_capa { {"common", &mu_common_argp_child}, {"license", &mu_license_argp_child}, {"mailbox", &mu_mailbox_argp_child}, + {"address", &mu_address_argp_child}, {"logging", &mu_logging_argp_child}, {"auth", &mu_auth_argp_child}, {"daemon", &mu_daemon_argp_child}, @@ -689,7 +731,7 @@ mu_build_argp (const struct argp *template, const char *capa[]) int n; int nchild; struct argp_child *ap; - struct argp_option *opt; + const struct argp_option *opt; struct argp *argp; int group = 0; @@ -761,6 +803,10 @@ mu_argp_parse(const struct argp *argp, void *input) { error_t ret; + const struct argp argpnull = { 0 }; + + if(!argp) + argp = &argpnull; argp = mu_build_argp (argp, capa); mu_create_argcv (capa, *pargc, *pargv, pargc, pargv); |