diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-10-19 17:20:42 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-10-19 19:20:31 +0300 |
commit | dc78d43ff77a65e3400af0401142aca2ebb6cd1e (patch) | |
tree | 61b7442d72109e743527a19e5e4ae575a749ed2d | |
parent | d1339b3ffaa3d82e21c3a36e5bdfccee3246904d (diff) | |
download | mailutils-dc78d43ff77a65e3400af0401142aca2ebb6cd1e.tar.gz mailutils-dc78d43ff77a65e3400af0401142aca2ebb6cd1e.tar.bz2 |
Convert remaining utilities (except mh) to mu_cli.
* Makefile.am: Remove libmu_argp and libmu_cfg
* configure.ac: Likewise.
* libmu_argp/: Remove.
* libmu_cfg/: Remove.
* include/mailutils/Makefile.am (pkginclude_HEADERS): Remove gocs.h,
libargp.h, libcfg.h
* frm/frm.c: Register tls auth module
* frm/from.c: Likewise.
* maidag/maidag.c: Likewise.
* mail/mail.c: Likewise.
* messages/messages.c: Likewise.
* movemail/movemail.c: Likewise.
* readmsg/readmsg.c: Likewise.
* sieve/sieve.c: Likewise.
* frm/frm.h: Remove obsolete includes
* imap4d/Makefile.am: Update.
* imap4d/imap4d.c: Use mu_cli for command line and configuration
parsing.
* imap4d/imap4d.h: Update.
* include/mailutils/gocs.h: Remove.
* libmailutils/cfg/gocs.c: Remove.
* libmailutils/cfg/Makefile.am: Remove gocs.c
* include/mailutils/cli.h (mu_cli_capa_apply): Rename to
mu_cli_capa_extend_settings
(mu_cli_setup) <inorder, prog_doc_hook>: New fields.
* include/mailutils/daemon.h: Remove obsolete includes.
* include/mailutils/gsasl.h: Likewise.
* include/mailutils/mailutils.h: Update.
* include/mailutils/mu_auth.h (mu_auth_mode): New enum
(mu_auth_module): Redo structure.
* include/mailutils/opt.h (mu_parseopt) <po_prog_doc_hook>: New field.
* include/mailutils/sql.h (mu_sql_module_config): New extern.
(mu_sql_interface_index): Change proto.
* libmailutils/auth/mu_auth.c: Rewrite.
* libmailutils/auth/system.c (mu_auth_system_module): Update structure
* libmailutils/cli/capa.c (mu_cli_capa_apply): Rename to
mu_cli_capa_extend_settings
* libmailutils/cli/cli.c: Extend settings from auth modules as well.
* libmailutils/opt/help.c (mu_program_help): Invoke po_prog_doc_hook
if defined.
* libmailutils/opt/opt.c (parseopt_init): Check the
MU_PARSEOPT_PROG_DOC_HOOK flag.
(find_long_option): Fix recognition of ambiguous options in case
of exact match.
* libmu_auth/gsasl.c: Add configuration.
* libmu_auth/ldap.c: Likewise.
* libmu_auth/pam.c: Likewise.
* libmu_auth/radius.c: Likewise.
* libmu_auth/sql.c: Likewise.
* libmu_auth/tls.c: Likewise.
* libmu_auth/virtual.c: Likewise.
* mu/Makefile.am: Update.
* mu/mu.c: Rewrite using mu_cli
* mu/mu.h: Likewise.
* mu/acl.c: Likewise.
* mu/cflags.c: Likewise.
* mu/dbm.c: Likewise.
* mu/dispatch.c: Likewise.
* mu/filter.c: Likewise.
* mu/flt2047.c: Likewise.
* mu/getans.c: Likewise.
* mu/getarg.c: Likewise.
* mu/getyn.c: Likewise.
* mu/help.c: Likewise.
* mu/imap.c: Likewise.
* mu/info.c: Likewise.
* mu/ldflags.c: Likewise.
* mu/logger.c: Likewise.
* mu/pop.c: Likewise.
* mu/query.c: Likewise.
* mu/send.c: Likewise.
* mu/shell.c: Likewise.
* mu/smtp.c: Likewise.
* mu/util.c: Likewise.
* mu/verbose.c: Likewise.
* mu/wicket.c: Likewise.
* pop3d/Makefile.am: Update.
* pop3d/pop3d.c: Convert to mu_cli interface.
* pop3d/pop3d.h: Likewise.
* sql/sql.c (mu_sql_interface_index): Change argument qualifiers.
99 files changed, 1147 insertions, 4921 deletions
diff --git a/Makefile.am b/Makefile.am index 941eb3a5c..3f1b6d592 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,8 +97,6 @@ SUBDIRS = . \ libmu_compat\ testsuite\ lib\ - libmu_argp\ - libmu_cfg\ $(LIBMU_CPP_DIR)\ $(GINT_DIR)\ $(LIBMU_SCM_DIR)\ diff --git a/configure.ac b/configure.ac index d9f1b588f..089419ae6 100644 --- a/configure.ac +++ b/configure.ac @@ -1480,9 +1480,7 @@ AC_CONFIG_FILES([ include/mailutils/cpp/Makefile lib/Makefile lib/gnu/Makefile - libmu_argp/Makefile libmu_auth/Makefile - libmu_cfg/Makefile libmu_cpp/Makefile libmu_scm/Makefile libmu_scm/mailutils/Makefile @@ -181,7 +181,6 @@ static char *frm_argp_capa[] = { "debug", "mailbox", "locking", - "tls", NULL }; @@ -328,7 +327,7 @@ main (int argc, char **argv) /* register the formats. */ mu_register_all_mbox_formats (); - mu_cli_capa_register (&mu_cli_capa_tls); + mu_auth_register_module (&mu_auth_tls_module); mu_cli (argc, argv, &cli, frm_argp_capa, NULL, &argc, &argv); if (align && (s = util_getcols ())) @@ -63,6 +63,7 @@ #include <mailutils/error.h> #include <mailutils/util.h> #include <mailutils/mime.h> +#include <mailutils/mu_auth.h> #include "mailutils/cli.h" diff --git a/frm/from.c b/frm/from.c index 7995bb472..588f76679 100644 --- a/frm/from.c +++ b/frm/from.c @@ -48,7 +48,6 @@ static char *capa[] = { "debug", "mailbox", "locking", - "tls", NULL }; @@ -89,7 +88,7 @@ main (int argc, char **argv) /* register the formats. */ mu_register_all_mbox_formats (); - mu_cli_capa_register (&mu_cli_capa_tls); + mu_auth_register_module (&mu_auth_tls_module); mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); if (argc > 1) diff --git a/imap4d/Makefile.am b/imap4d/Makefile.am index d0f0e81a6..ab421cc73 100644 --- a/imap4d/Makefile.am +++ b/imap4d/Makefile.am @@ -72,7 +72,7 @@ imap4d_SOURCES = \ util.c imap4d_LDADD = \ - ${MU_APP_LIBRARIES}\ + ${MU_APP_NEW_LIBRARIES}\ ${MU_LIB_MBOX}\ ${MU_LIB_MH}\ ${MU_LIB_MAILDIR}\ diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c index a256dd46a..2c975056e 100644 --- a/imap4d/imap4d.c +++ b/imap4d/imap4d.c @@ -17,7 +17,7 @@ #include "imap4d.h" #include <mailutils/gsasl.h> -#include "mailutils/libargp.h" +#include "mailutils/cli.h" #include "mailutils/kwd.h" #include "tcpwrap.h" @@ -56,93 +56,79 @@ int ident_encrypt_only; int test_mode; const char *program_version = "imap4d (" PACKAGE_STRING ")"; -static char doc[] = N_("GNU imap4d -- the IMAP4D daemon."); - -#define OPT_PREAUTH 259 -#define OPT_FOREGROUND 260 -#define OPT_TEST_MODE 261 - -static struct argp_option options[] = { - { "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0}, - { "inetd", 'i', 0, 0, N_("run in inetd mode"), 0}, - { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL, - N_("runs in daemon mode with a maximum of NUMBER children"), 0 }, - { "test", OPT_TEST_MODE, 0, 0, - N_("run in test mode"), 0 }, - { "preauth", OPT_PREAUTH, NULL, 0, - N_("start in preauth mode") }, + + +static void +set_foreground (struct mu_parseopt *po, struct mu_option *opt, + char const *arg) +{ + mu_m_server_set_foreground (server, 1); +} + +static void +set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt, + char const *arg) +{ + mu_m_server_set_mode (server, MODE_INTERACTIVE); +} - {NULL, 0, NULL, 0, NULL, 0} -}; +static void +set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt, + char const *arg) +{ + mu_m_server_set_mode (server, MODE_DAEMON); + if (arg) + { + size_t max_children; + char *errmsg; + int rc = mu_str_to_c (arg, mu_c_size, &max_children, &errmsg); + if (rc) + { + mu_parseopt_error (po, _("%s: bad argument"), arg); + exit (po->po_exit_error); + } + mu_m_server_set_max_children (server, max_children); + } +} +static void +set_preauth (struct mu_parseopt *po, struct mu_option *opt, char const *arg) +{ + preauth_mode = preauth_stdio; +} -static error_t imap4d_parse_opt (int key, char *arg, - struct argp_state *state); +static struct mu_option imap4d_options[] = { + { "foreground", 0, NULL, MU_OPTION_DEFAULT, + N_("remain in foreground"), + mu_c_bool, NULL, set_foreground }, + { "inetd", 'i', NULL, MU_OPTION_DEFAULT, + N_("run in inetd mode"), + mu_c_bool, NULL, set_inetd_mode }, + { "daemon", 'd', N_("NUMBER"), MU_OPTION_ARG_OPTIONAL, + N_("runs in daemon mode with a maximum of NUMBER children"), + mu_c_string, NULL, set_daemon_mode }, -static struct argp argp = { - options, - imap4d_parse_opt, - NULL, - doc, - NULL, - NULL, NULL -}; + { "test", 0, NULL, MU_OPTION_DEFAULT, + N_("run in test mode"), + mu_c_bool, &test_mode }, -static const char *imap4d_capa[] = { - "mailutils", + { "preauth", 0, NULL, MU_OPTION_DEFAULT, + N_("start in preauth mode"), + mu_c_string, NULL, set_preauth }, + + MU_OPTION_END +}, *options[] = { imap4d_options, NULL }; + + +static char *capa[] = { "auth", - "common", "debug", "mailbox", "locking", "logging", NULL }; - -static error_t -imap4d_parse_opt (int key, char *arg, struct argp_state *state) -{ - static mu_list_t lst; - - switch (key) - { - case 'd': - mu_argp_node_list_new (lst, "mode", "daemon"); - if (arg) - mu_argp_node_list_new (lst, "max-children", arg); - break; - - case 'i': - mu_argp_node_list_new (lst, "mode", "inetd"); - break; - - case OPT_FOREGROUND: - mu_argp_node_list_new (lst, "foreground", "yes"); - break; - - case OPT_PREAUTH: - preauth_mode = preauth_stdio; - break; - - case OPT_TEST_MODE: - mu_argp_node_list_new (lst, "mode", "inetd"); - test_mode = 1; - break; - - case ARGP_KEY_INIT: - mu_argp_node_list_init (&lst); - break; - - case ARGP_KEY_FINI: - mu_argp_node_list_finish (lst, NULL, NULL); - break; - - default: - return ARGP_ERR_UNKNOWN; - } - return 0; -} - + static int cb_mode (void *data, mu_config_value_t *val) { @@ -455,6 +441,12 @@ static struct mu_cfg_param imap4d_cfg_param[] = { { NULL } }; +struct mu_cli_setup cli = { + options, + imap4d_cfg_param, + N_("GNU imap4d -- the IMAP4D daemon.") +}; + int mu_get_user_groups (const char *user, mu_list_t retain, mu_list_t *pgrouplist) { @@ -933,18 +925,10 @@ main (int argc, char **argv) mu_register_local_mbox_formats (); imap4d_capability_init (); -#ifdef WITH_TLS - mu_gocs_register ("tls", mu_tls_module_init); -#endif /* WITH_TLS */ -#ifdef WITH_GSASL - mu_gocs_register ("gsasl", mu_gsasl_module_init); -#endif mu_tcpwrapper_cfg_init (); manlock_cfg_init (); mu_acl_cfg_init (); - mu_argp_init (NULL, NULL); - mu_m_server_create (&server, program_version); |