commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-783-g3dc3771


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-783-g3dc3771
Date: Wed, 19 Oct 2016 16:25:44 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=3dc377159eb6afba231bcbdaf6a2d4331c0c337d

The branch, master has been updated
       via  3dc377159eb6afba231bcbdaf6a2d4331c0c337d (commit)
       via  dc78d43ff77a65e3400af0401142aca2ebb6cd1e (commit)
      from  d1339b3ffaa3d82e21c3a36e5bdfccee3246904d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3dc377159eb6afba231bcbdaf6a2d4331c0c337d
Author: Sergey Poznyakoff <address@hidden>
Date:   Wed Oct 19 19:20:58 2016 +0300

    Rename MU_APP_NEW_LIBRARIES back to MU_APP_LIBRARIES. Version 2.99.991.

commit dc78d43ff77a65e3400af0401142aca2ebb6cd1e
Author: Sergey Poznyakoff <address@hidden>
Date:   Wed Oct 19 17:20:42 2016 +0300

    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.

-----------------------------------------------------------------------

Summary of changes:
 Makefile.am                   |    2 -
 NEWS                          |    4 +-
 comsat/Makefile.am            |    2 +-
 configure.ac                  |    7 +-
 dotlock/Makefile.am           |    2 +-
 examples/Makefile.am          |    4 +-
 frm/Makefile.am               |    2 +-
 frm/frm.c                     |    3 +-
 frm/frm.h                     |    1 +
 frm/from.c                    |    3 +-
 gnulib.modules                |    1 -
 imap4d/imap4d.c               |  166 +++++++++---------
 imap4d/imap4d.h               |    1 +
 include/mailutils/Makefile.am |    3 -
 include/mailutils/cli.h       |    5 +-
 include/mailutils/daemon.h    |    3 -
 include/mailutils/gocs.h      |   98 -----------
 include/mailutils/gsasl.h     |    6 +-
 include/mailutils/libargp.h   |   97 -----------
 include/mailutils/libcfg.h    |  101 -----------
 include/mailutils/mailutils.h |    2 +-
 include/mailutils/mu_auth.h   |   42 +++--
 include/mailutils/opt.h       |    2 +
 include/mailutils/radius.h    |    2 -
 include/mailutils/sieve.h     |   11 --
 include/mailutils/sql.h       |   22 +--
 include/mailutils/tls.h       |    2 -
 include/mailutils/types.hin   |    6 -
 lib/Makefile.am               |    1 -
 lib/argp_base.c               |   31 ----
 libmailutils/auth/mu_auth.c   |  191 ++++++++++----------
 libmailutils/auth/system.c    |   26 ++-
 libmailutils/cfg/Makefile.am  |    3 +-
 libmailutils/cfg/gocs.c       |  387 -----------------------------------------
 libmailutils/cli/capa.c       |    7 +-
 libmailutils/cli/cli.c        |   37 +++-
 libmailutils/opt/help.c       |    6 +
 libmailutils/opt/opt.c        |    4 +
 libmu_argp/.gitignore         |    7 -
 libmu_argp/Makefile.am        |   39 -----
 libmu_argp/cmdline.c          |  111 ------------
 libmu_argp/cmdline.h          |   22 ---
 libmu_argp/common.c           |  306 --------------------------------
 libmu_argp/mailutils.c        |  146 ----------------
 libmu_argp/mu_argp.c          |  227 ------------------------
 libmu_argp/muinit.c           |  213 -----------------------
 libmu_argp/sieve.c            |  103 -----------
 libmu_auth/gsasl.c            |   37 +++-
 libmu_auth/ldap.c             |  101 +++++++++--
 libmu_auth/pam.c              |   48 ++---
 libmu_auth/radius.c           |  147 ++++++++--------
 libmu_auth/sql.c              |  136 ++++++++++-----
 libmu_auth/tls.c              |   30 +---
 libmu_auth/virtual.c          |   51 ++----
 libmu_cfg/.gitignore          |    7 -
 libmu_cfg/Makefile.am         |   38 ----
 libmu_cfg/acl.c               |  265 ----------------------------
 libmu_cfg/auth.c              |  131 --------------
 libmu_cfg/common.c            |  213 -----------------------
 libmu_cfg/gsasl.c             |   52 ------
 libmu_cfg/init.c              |  197 ---------------------
 libmu_cfg/ldap.c              |  101 -----------
 libmu_cfg/pam.c               |   35 ----
 libmu_cfg/radius.c            |   43 -----
 libmu_cfg/sieve.c             |  121 -------------
 libmu_cfg/sql.c               |  100 -----------
 libmu_cfg/tls.c               |  126 --------------
 libmu_cfg/virtdomain.c        |   36 ----
 libmu_sieve/conf.c            |   62 +++----
 maidag/Makefile.am            |    2 +-
 maidag/maidag.c               |    3 +-
 mail/Makefile.am              |    2 +-
 mail/mail.c                   |    5 +-
 messages/Makefile.am          |    2 +-
 messages/messages.c           |    3 +-
 mimeview/Makefile.am          |    2 +-
 movemail/Makefile.am          |    2 +-
 movemail/movemail.c           |    7 +-
 mu/acl.c                      |   77 ++------
 mu/cflags.c                   |   29 +--
 mu/dbm.c                      |  297 ++++++++++++++++---------------
 mu/dispatch.c                 |   41 ++---
 mu/filter.c                   |   77 +++-----
 mu/flt2047.c                  |   87 +++------
 mu/getans.c                   |    4 -
 mu/getarg.c                   |   10 +-
 mu/getyn.c                    |    4 -
 mu/help.c                     |   25 +--
 mu/imap.c                     |   36 +---
 mu/info.c                     |   49 +-----
 mu/ldflags.c                  |   27 +--
 mu/logger.c                   |  197 ++++++++++-----------
 mu/mu.c                       |  141 +++++++--------
 mu/mu.h                       |   17 +-
 mu/pop.c                      |   47 +----
 mu/query.c                    |  113 ++++--------
 mu/send.c                     |   81 +++------
 mu/shell.c                    |   10 +-
 mu/smtp.c                     |   35 +---
 mu/util.c                     |    8 -
 mu/verbose.c                  |    6 -
 mu/wicket.c                   |   69 ++------
 po/POTFILES.in                |   22 ---
 pop3d/Makefile.am             |    2 +-
 pop3d/pop3d.c                 |    5 +-
 pop3d/pop3d.h                 |    1 +
 readmsg/Makefile.am           |    2 +-
 readmsg/readmsg.c             |    4 +-
 sieve/Makefile.am             |    2 +-
 sieve/sieve.c                 |    4 +-
 sql/sql.c                     |    2 +-
 111 files changed, 1161 insertions(+), 4942 deletions(-)
 delete mode 100644 include/mailutils/gocs.h
 delete mode 100644 include/mailutils/libargp.h
 delete mode 100644 include/mailutils/libcfg.h
 delete mode 100644 lib/argp_base.c
 delete mode 100644 libmailutils/cfg/gocs.c
 delete mode 100644 libmu_argp/.gitignore
 delete mode 100644 libmu_argp/Makefile.am
 delete mode 100644 libmu_argp/cmdline.c
 delete mode 100644 libmu_argp/cmdline.h
 delete mode 100644 libmu_argp/common.c
 delete mode 100644 libmu_argp/mailutils.c
 delete mode 100644 libmu_argp/mu_argp.c
 delete mode 100644 libmu_argp/muinit.c
 delete mode 100644 libmu_argp/sieve.c
 delete mode 100644 libmu_cfg/.gitignore
 delete mode 100644 libmu_cfg/Makefile.am
 delete mode 100644 libmu_cfg/acl.c
 delete mode 100644 libmu_cfg/auth.c
 delete mode 100644 libmu_cfg/common.c
 delete mode 100644 libmu_cfg/gsasl.c
 delete mode 100644 libmu_cfg/init.c
 delete mode 100644 libmu_cfg/ldap.c
 delete mode 100644 libmu_cfg/pam.c
 delete mode 100644 libmu_cfg/radius.c
 delete mode 100644 libmu_cfg/sieve.c
 delete mode 100644 libmu_cfg/sql.c
 delete mode 100644 libmu_cfg/tls.c
 delete mode 100644 libmu_cfg/virtdomain.c

diff --git a/Makefile.am b/Makefile.am
index 941eb3a..3f1b6d5 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/NEWS b/NEWS
index 4614802..7ebc72a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,11 @@
-GNU mailutils NEWS -- history of user-visible changes. 2016-01-22
+GNU mailutils NEWS -- history of user-visible changes. 2016-10-19
 Copyright (C) 2002-2016 Free Software Foundation, Inc.
 See the end of file for copying conditions.
 
 Please send mailutils bug reports to <address@hidden>.
 
 
-Version 2.99.99 (Git)
+Version 2.99.991 (Git)
 
 This version is a major rewrite of GNU Mailutils.  Quite a few parts
 of the basic framework were rewritten from scratch, while some others
diff --git a/comsat/Makefile.am b/comsat/Makefile.am
index a661ffe..e67b218 100644
--- a/comsat/Makefile.am
+++ b/comsat/Makefile.am
@@ -31,7 +31,7 @@ biff.rc.h: $(top_srcdir)/comsat/biff.rc
          $(top_srcdir)/comsat/biff.rc > biff.rc.h
 
 comsatd_LDADD = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
  ${MU_LIB_POP}\
diff --git a/configure.ac b/configure.ac
index d9f1b58..5fd7d85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU General Public 
License along
 dnl with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
 AC_PREREQ(2.63)
-AC_INIT([GNU Mailutils], [2.99.99], address@hidden, [mailutils],
+AC_INIT([GNU Mailutils], [2.99.991], address@hidden, [mailutils],
         [http://mailutils.org])
 AC_CONFIG_SRCDIR([libmailutils/mailbox/mailbox.c])
 AC_CONFIG_AUX_DIR([build-aux])
@@ -57,8 +57,7 @@ AC_SUBST(mu_aux_dir,'$(top_srcdir)/mu-aux')
 AC_SUBST(MU_SIEVE_MODDIR,'$(libdir)/$(PACKAGE)')
 
 AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)')
-AC_SUBST(MU_APP_LIBRARIES,'${top_builddir}/libmu_argp/libmu_argp.la 
${top_builddir}/libmu_cfg/libmu_cfg.la ${top_builddir}/lib/libmuaux.la')
-AC_SUBST(MU_APP_NEW_LIBRARIES,'${top_builddir}/lib/libmuaux.la')
+AC_SUBST(MU_APP_LIBRARIES,'${top_builddir}/lib/libmuaux.la')
 
 # There are two sets of include directories: MU_LIB_COMMON_INCLUDES, used
 # by the libraries, and MU_APP_COMMON_INCLUDES, which is used by applications.
@@ -1480,9 +1479,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
diff --git a/dotlock/Makefile.am b/dotlock/Makefile.am
index 0ab3f34..3425b0f 100644
--- a/dotlock/Makefile.am
+++ b/dotlock/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS = @MU_APP_COMMON_INCLUDES@
 bin_PROGRAMS = dotlock
 
 dotlock_LDADD = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MAILUTILS}\
  @MU_COMMON_LIBRARIES@
 
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 5ffabeb..55b53df 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -113,14 +113,14 @@ lsf_LDADD = \
 
 muauth_CPPFLAGS = @MU_APP_COMMON_INCLUDES@
 muauth_LDADD = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_AUTH}\
  @MU_AUTHLIBS@ \
  ${MU_LIB_MAILUTILS}
 
 muemail_CPPFLAGS = @MU_APP_COMMON_INCLUDES@
 muemail_LDADD = \
- ${MU_APP_NEW_LIBRARIES} \
+ ${MU_APP_LIBRARIES} \
  ${MU_LIB_MAILUTILS}
 
 mboxidx_CPPFLAGS = @MU_APP_COMMON_INCLUDES@
diff --git a/frm/Makefile.am b/frm/Makefile.am
index 8678e2f..7861b51 100644
--- a/frm/Makefile.am
+++ b/frm/Makefile.am
@@ -27,7 +27,7 @@ frm_LDADD =  $(common_ldadd)
 from_LDADD = $(common_ldadd)
 
 common_ldadd = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
  ${MU_LIB_POP}\
diff --git a/frm/frm.c b/frm/frm.c
index 99db191..192521c 100644
--- a/frm/frm.c
+++ b/frm/frm.c
@@ -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 ()))
diff --git a/frm/frm.h b/frm/frm.h
index 60b10a0..b6d3237 100644
--- a/frm/frm.h
+++ b/frm/frm.h
@@ -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 7995bb4..588f766 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/gnulib.modules b/gnulib.modules
index a552282..b672acc 100644
--- a/gnulib.modules
+++ b/gnulib.modules
@@ -4,7 +4,6 @@
 # FIXME: fnmatch, regex and glob are used by libmailutils...
 
 autobuild
-argp
 crypto/des
 gettext
 gitlog-to-changelog
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index a256dd4..2c97505 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);
   mu_m_server_set_config_size (server, sizeof (struct imap4d_srv_config));
   mu_m_server_set_conn (server, imap4d_connection);
@@ -961,10 +945,16 @@ main (int argc, char **argv)
 
   mu_log_syslog = 1;
 
-  if (mu_app_init (&argp, imap4d_capa, imap4d_cfg_param, 
-                  argc, argv, 0, NULL, server))
-    exit (EX_CONFIG); /* FIXME: No way to discern from EX_USAGE? */
-
+  mu_cli (argc, argv, &cli, capa, server, &argc, &argv);
+  if (argc)
+    {
+      mu_error (_("too many arguments"));
+      exit (EX_USAGE);
+    }
+  
+  if (test_mode)
+    mu_m_server_set_mode (server, MODE_INTERACTIVE);
+  
   if (login_disabled)
     imap4d_capability_add (IMAP_CAPA_LOGINDISABLED);
 
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index c1182f4..d547287 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -106,6 +106,7 @@
 #include <mailutils/imapio.h>
 #include <mailutils/imaputil.h>
 #include <mailutils/msgset.h>
+#include <mailutils/syslog.h>
 
 #include <mu_umaxtostr.h>
 #include <muaux.h>
diff --git a/include/mailutils/Makefile.am b/include/mailutils/Makefile.am
index 9ae3929..d1e0019 100644
--- a/include/mailutils/Makefile.am
+++ b/include/mailutils/Makefile.am
@@ -48,7 +48,6 @@ pkginclude_HEADERS = \
  error.h\
  filter.h\
  folder.h\
- gocs.h\
  gsasl.h\
  guile.h\
  header.h\
@@ -59,8 +58,6 @@ pkginclude_HEADERS = \
  iterator.h\
  kwd.h\
  ldap.h\
- libargp.h\
- libcfg.h\
  list.h\
  locker.h\
  log.h\
diff --git a/include/mailutils/cli.h b/include/mailutils/cli.h
index 7067f21..d2964ff 100644
--- a/include/mailutils/cli.h
+++ b/include/mailutils/cli.h
@@ -35,7 +35,8 @@ struct mu_cli_capa
 
 void mu_cli_capa_init (void);
 void mu_cli_capa_register (struct mu_cli_capa *capa);
-void mu_cli_capa_apply (char const *name, mu_list_t opts, mu_list_t commits);
+void mu_cli_capa_extend_settings (char const *name, mu_list_t opts,
+                                 mu_list_t commits);
 
 struct mu_cli_setup
 {
@@ -49,6 +50,8 @@ struct mu_cli_setup
   int ex_usage;                /* If not 0, exit code on usage errors */
   int ex_config;               /* If not 0, exit code on configuration
                                  errors */
+  int inorder;
+  void (*prog_doc_hook) (mu_stream_t);
 };
 
 void mu_version_func (struct mu_parseopt *po, mu_stream_t stream);
diff --git a/include/mailutils/daemon.h b/include/mailutils/daemon.h
index fa29b41..2fa699e 100644
--- a/include/mailutils/daemon.h
+++ b/include/mailutils/daemon.h
@@ -20,7 +20,6 @@
 #define _MAILUTILS_DAEMON_H
 
 #include <mailutils/types.h>
-#include <mailutils/gocs.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -33,8 +32,6 @@ extern "C" {
 extern int  mu_daemon_create_pidfile  (const char *);
 extern void mu_daemon_remove_pidfile  (void);
 
-extern struct mu_gocs_daemon mu_gocs_daemon;  
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/gocs.h b/include/mailutils/gocs.h
deleted file mode 100644
index be3de55..0000000
--- a/include/mailutils/gocs.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007-2008, 2010-2012, 2014-2016 Free Software
-   Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifndef _MAILUTILS_GOCS_H
-#define _MAILUTILS_GOCS_H
-
-#include <mailutils/types.h>
-#include <mailutils/list.h>
-#include <mailutils/syslog.h>
-
-#ifdef __cplusplus
-extern "C" { 
-#endif
-
-struct mu_gocs_debug
-{
-  char *string;
-  int line_info;
-};
-
-struct mu_gocs_mailbox
-{
-  char *mail_spool;
-  char *mailbox_pattern;
-  char *mailbox_type;
-};
-
-struct mu_gocs_locking
-{
-  char *lock_flags;
-  unsigned long lock_retry_timeout;
-  unsigned long lock_retry_count;
-  unsigned long lock_expire_timeout;
-  char *external_locker;
-};
-
-struct mu_gocs_source_email
-{
-  char *address;
-  char *domain;
-};
-
-struct mu_gocs_mailer
-{
-  char *mailer;
-};
-
-struct mu_gocs_pam
-{
-  char *service;
-};
-
-struct mu_gocs_virtual
-{
-  char *pwddir;
-};
-
-/* Auxiliary variables for use by libargp/libcfg */
-extern char *mu_site_rcfile;
-extern int mu_load_user_rcfile;
-extern int mu_load_site_rcfile;
-extern char *mu_load_rcfile;
-
-typedef int (*mu_gocs_init_fp) (enum mu_gocs_op op, void *data);
-
-void mu_gocs_register (const char *capa, mu_gocs_init_fp init);
-void mu_gocs_register_std (const char *name);
-void mu_gocs_store (char *capa, void *data);
-void mu_gocs_flush (void);
-int mu_gocs_enumerate (mu_list_action_t action, void *data);
-
-int mu_gocs_mailbox_init (enum mu_gocs_op, void *data);
-int mu_gocs_locking_init (enum mu_gocs_op, void *data);
-int mu_gocs_source_email_init (enum mu_gocs_op, void *data);
-int mu_gocs_mailer_init (enum mu_gocs_op, void *data);
-int mu_gocs_logging_init (enum mu_gocs_op, void *data);
-int mu_gocs_debug_init (enum mu_gocs_op, void *data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/mailutils/gsasl.h b/include/mailutils/gsasl.h
index ba61370..c9e3a6a 100644
--- a/include/mailutils/gsasl.h
+++ b/include/mailutils/gsasl.h
@@ -18,6 +18,7 @@
 
 #ifndef _MAILUTILS_GSASL_H
 #define _MAILUTILS_GSASL_H
+#include <mailutils/cli.h>
 
 struct mu_gsasl_module_data
 {
@@ -28,16 +29,13 @@ struct mu_gsasl_module_data
   char *anon_user;
   char *cram_md5_pwd;
 };
+extern struct mu_gsasl_module_data mu_gsasl_module_data;
 
 int mu_gsasl_enabled (void);
 
 #ifdef WITH_GSASL
 #include <gsasl.h>
 
-int mu_gsasl_module_init (enum mu_gocs_op, void *);
-extern struct mu_gsasl_module_data mu_gsasl_module_data;
-
-
 int gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport,
                          Gsasl_session *ctx, int flags);
 int gsasl_decoder_stream (mu_stream_t *pstr, mu_stream_t transport,
diff --git a/include/mailutils/libargp.h b/include/mailutils/libargp.h
deleted file mode 100644
index c2ef992..0000000
--- a/include/mailutils/libargp.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999-2001, 2004-2005, 2007-2008, 2010-2012, 2014-2016
-   Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifndef _MAILUTILS_LIBARGP_H
-#define _MAILUTILS_LIBARGP_H
-
-#include "mailutils/types.h"
-#include "mailutils/gocs.h"
-#include "mailutils/nls.h"
-#include "mailutils/error.h"
-#include "mailutils/errno.h"
-#include "mailutils/version.h"
-#include "argp.h"
-#include "errno.h" 
-#include "strings.h"
-
-#include "mailutils/libcfg.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct mu_cmdline_capa
-{
-  char *name;
-  struct argp_child *child;
-  void (*modflags) (int *);
-};
-
-extern int mu_help_config_mode;
-extern int mu_rcfile_lint;
-extern int (*mu_app_cfg_verifier) (void);
-
-extern struct mu_cmdline_capa mu_mailutils_cmdline;
-extern struct mu_cmdline_capa mu_common_cmdline;
-extern struct mu_cmdline_capa mu_logging_cmdline;
-extern struct mu_cmdline_capa mu_mailbox_cmdline;
-extern struct mu_cmdline_capa mu_locking_cmdline;
-extern struct mu_cmdline_capa mu_address_cmdline;
-extern struct mu_cmdline_capa mu_mailer_cmdline;
-extern struct mu_cmdline_capa mu_sieve_cmdline;
-extern struct mu_cmdline_capa mu_debug_cmdline;
-  
-extern struct mu_cmdline_capa mu_pam_cmdline;
-extern struct mu_cmdline_capa mu_gsasl_cmdline;
-extern struct mu_cmdline_capa mu_radius_cmdline;
-extern struct mu_cmdline_capa mu_sql_cmdline;
-extern struct mu_cmdline_capa mu_virtdomain_cmdline;
-
-extern void mu_libargp_init (void);
-  
-extern struct argp *mu_argp_build (const struct argp *argp, char ***pcapa,
-                                  int *flags);
-extern void mu_argp_done (struct argp *argp);
-  
-extern int mu_register_argp_capa (const char *name, struct argp_child *child,
-                                 void (*modflags) (int*));
-
-void mu_argp_init (const char *vers, const char *bugaddr);
-int mu_app_init (struct argp *myargp, const char **capa,
-                struct mu_cfg_param *cfg_param, 
-                int argc, char **argv, int flags, int *pindex, void *data);
-extern void mu_program_version_hook (FILE *stream, struct argp_state *state);
-
-error_t mu_argp_parse (const struct argp *myargp, 
-                      int *pargc, char **pargv[],  
-                      unsigned flags,
-                      const char *capa[],
-                      int *arg_index,     
-                      void *input) MU_DEPRECATED;
-
-void mu_argp_node_list_init (mu_list_t *);
-void mu_argp_node_list_add (mu_list_t, mu_cfg_node_t *);
-void mu_argp_node_list_new (mu_list_t, const char *, const char *);
-void mu_argp_node_list_finish (mu_list_t, char *, char *);
-  
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/include/mailutils/libcfg.h b/include/mailutils/libcfg.h
deleted file mode 100644
index c7730ad..0000000
--- a/include/mailutils/libcfg.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifndef _MAILUTILS_LIBCFG_H
-#define _MAILUTILS_LIBCFG_H
-
-#include <mailutils/cfg.h>
-#include <mailutils/gocs.h>
-#include <mailutils/nls.h>
-#include <mailutils/error.h>
-#include <mailutils/errno.h>
-
-#ifndef MU_USER_CONFIG_FILE
-# define MU_USER_CONFIG_FILE "~/.mailutils"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct mu_cfg_capa
-{
-  char *name;
-  struct mu_cfg_param *cfgparam;
-  mu_cfg_section_fp parser;
-};
-
-extern int mu_libcfg_register_capa (struct mu_cfg_capa *capa);
-extern void mu_libcfg_init (char **cnames);
-extern int mu_parse_config_files (struct mu_cfg_param *param,
-                                 void *target_ptr) MU_CFG_DEPRECATED;
-int mu_libcfg_parse_config (mu_cfg_tree_t **ptree);
-  
-extern void mu_acl_cfg_init (void);
-
-#define __mu_common_cat2__(a,b) a ## b
-#define __mu_common_cat3__(a,b,c) a ## b ## c
-#define DCL_PARSER(capa)                                                     \
-int                                                                          \
-__mu_common_cat3__(mu_,capa,_section_parser)                                 \
-     (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node,            \
-      const char *section_label, void **section_data,                         \
-      void *call_data, mu_cfg_tree_t *tree)                                  \
-{                                                                            \
-  switch (stage)                                                             \
-    {                                                                        \
-    case mu_cfg_section_start:                                               \
-      break;                                                                 \
-                                                                             \
-    case mu_cfg_section_end:                                                 \
-      mu_gocs_store (#capa, &__mu_common_cat2__(capa, _settings));           \
-    }                                                                        \
-  return 0;                                                                  \
-}
-
-#define DCL_DEFAULT_CFG_CAPA(capa)                                            \
- struct mu_cfg_capa __mu_common_cat3__(mu_,capa,_cfg_capa) = {                \
-      #capa,                                                                  \
-      __mu_common_cat3__(mu_,capa,_param),                                    \
-      __mu_common_cat3__(mu_,capa,_section_parser)                            \
- }
-
-#define DCL_CFG_CAPA(capa)                                                    \
-  DCL_PARSER (capa)                                                           \
-  DCL_DEFAULT_CFG_CAPA (capa) 
-
-extern struct mu_cfg_capa mu_mailbox_cfg_capa;
-extern struct mu_cfg_capa mu_locking_cfg_capa;
-extern struct mu_cfg_capa mu_address_cfg_capa;
-extern struct mu_cfg_capa mu_mailer_cfg_capa;
-extern struct mu_cfg_capa mu_logging_cfg_capa;
-extern struct mu_cfg_capa mu_debug_cfg_capa;
-extern struct mu_cfg_capa mu_gsasl_cfg_capa;
-extern struct mu_cfg_capa mu_pam_cfg_capa;
-extern struct mu_cfg_capa mu_radius_cfg_capa;
-extern struct mu_cfg_capa mu_sql_cfg_capa;
-extern struct mu_cfg_capa mu_tls_cfg_capa;
-extern struct mu_cfg_capa mu_virtdomain_cfg_capa;
-extern struct mu_cfg_capa mu_sieve_cfg_capa;
-extern struct mu_cfg_capa mu_auth_cfg_capa;
-extern struct mu_cfg_capa mu_ldap_cfg_capa;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/mailutils/mailutils.h b/include/mailutils/mailutils.h
index 5ed71d2..cc14889 100644
--- a/include/mailutils/mailutils.h
+++ b/include/mailutils/mailutils.h
@@ -58,7 +58,6 @@
 #include <mailutils/stream.h>
 #include <mailutils/tls.h>
 #include <mailutils/url.h>
-#include <mailutils/gocs.h>
 #include <mailutils/version.h>
 #include <mailutils/io.h>
 #include <mailutils/secret.h>
@@ -66,6 +65,7 @@
 #include <mailutils/cstr.h>
 #include <mailutils/wordsplit.h>
 #include <mailutils/log.h>
+#include <mailutils/syslog.h>
 #include <mailutils/stdstream.h>
 #include <mailutils/prog.h>
 #include <mailutils/sockaddr.h>
diff --git a/include/mailutils/mu_auth.h b/include/mailutils/mu_auth.h
index 4355d93..a67cc61 100644
--- a/include/mailutils/mu_auth.h
+++ b/include/mailutils/mu_auth.h
@@ -20,8 +20,8 @@
 #define _MAILUTILS_MU_AUTH_H
 
 #include <mailutils/types.h>
-#include <mailutils/gocs.h>
 #include <mailutils/debug.h>
+#include <mailutils/cli.h>
 
 #define MU_AUTH_NAME    "name"
 #define MU_AUTH_PASSWD  "passwd"
@@ -64,30 +64,41 @@ typedef int (*mu_auth_fp) (struct mu_auth_data **data,
                           void *func_data,
                           void *call_data);
 
+enum mu_auth_mode
+  {
+    mu_auth_authenticate,
+    mu_auth_getpwnam,
+    mu_auth_getpwuid
+  };
+
+#define MU_AUTH_MODE_COUNT 3
+
 struct mu_auth_module
 {
   char            *name;
-  mu_gocs_init_fp init;
-  mu_auth_fp      authenticate;
-  void            *authenticate_data;
-  mu_auth_fp      auth_by_name;
-  void            *auth_by_name_data;
-  mu_auth_fp      auth_by_uid;
-  void            *auth_by_uid_data;
+  mu_auth_fp      handler[MU_AUTH_MODE_COUNT];
+  void            *data[MU_AUTH_MODE_COUNT];
+
+  struct mu_option *opt;
+  struct mu_cfg_param *cfg;
+  mu_cfg_section_fp parser;
+  mu_cli_capa_commit_fp commit;
 };
 
 enum mu_auth_key_type
   {
-    mu_auth_key_name,
-    mu_auth_key_uid
+    mu_auth_key_name = mu_auth_getpwnam,
+    mu_auth_key_uid = mu_auth_getpwuid
   };
 
 void mu_auth_begin_setup (void);
 void mu_auth_finish_setup (void);
+void mu_auth_extend_settings (mu_list_t opts, mu_list_t commits);
 
-extern int mu_auth_runlist (mu_list_t flist,
-                           struct mu_auth_data **return_data,
-                           const void *key, void *data);
+int mu_auth_runlist (mu_list_t flist,
+                    enum mu_auth_mode mode,
+                    const void *key, void *data,
+                    struct mu_auth_data **return_data);
 
 extern int mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type,
                        const void *key);
@@ -116,7 +127,6 @@ extern void mu_authentication_add_module_list (const char 
*modlist);
 extern void mu_authentication_clear_list (void);
 extern void mu_authorization_clear_list (void);
 
-extern void mu_auth_init (void);
 extern int mu_auth_data_alloc (struct mu_auth_data **ptr,
                               const char *name,
                               const char *passwd,
@@ -138,6 +148,8 @@ extern struct mu_auth_module mu_auth_sql_module;
 extern struct mu_auth_module mu_auth_virtual_module;
 extern struct mu_auth_module mu_auth_radius_module;
 extern struct mu_auth_module mu_auth_ldap_module;
+extern struct mu_auth_module mu_auth_gsasl_module;
+extern struct mu_auth_module mu_auth_tls_module;
 
 #define MU_AUTH_REGISTER_ALL_MODULES() do {\
   mu_auth_register_module (&mu_auth_generic_module); \
@@ -147,6 +159,8 @@ extern struct mu_auth_module mu_auth_ldap_module;
   mu_auth_register_module (&mu_auth_virtual_module);\
   mu_auth_register_module (&mu_auth_radius_module);\
   mu_auth_register_module (&mu_auth_ldap_module);\
+  mu_auth_register_module (&mu_auth_gsasl_module);\
+  mu_auth_register_module (&mu_auth_tls_module);\
   } while (0)
 
 #endif
diff --git a/include/mailutils/opt.h b/include/mailutils/opt.h
index 87a9839..fc40824 100644
--- a/include/mailutils/opt.h
+++ b/include/mailutils/opt.h
@@ -102,6 +102,7 @@ struct mu_option_cache
 #define MU_PARSEOPT_HELP_HOOK      0x00200000
 #define MU_PARSEOPT_DATA           0x00400000
 #define MU_PARSEOPT_VERSION_HOOK   0x00800000
+#define MU_PARSEOPT_PROG_DOC_HOOK  0x01000000
 
 /* Reuse mu_parseopt struct initialized previously */
 #define MU_PARSEOPT_REUSE          0x80000000
@@ -131,6 +132,7 @@ struct mu_parseopt
   char const *po_package_url;
   char const *po_extra_info;
 
+  void (*po_prog_doc_hook) (struct mu_parseopt *po, mu_stream_t stream);
   void (*po_help_hook) (struct mu_parseopt *po, mu_stream_t stream); 
   void (*po_version_hook) (struct mu_parseopt *po, mu_stream_t stream);
   
diff --git a/include/mailutils/radius.h b/include/mailutils/radius.h
index 2fe70b2..67d39ff 100644
--- a/include/mailutils/radius.h
+++ b/include/mailutils/radius.h
@@ -28,6 +28,4 @@ struct mu_radius_module_data
   char *getpwuid_request;
 };
 
-extern int mu_radius_module_init (enum mu_gocs_op, void *data);
-
 #endif
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 1ba1a72..9aab6c6 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -272,17 +272,6 @@ int mu_sieve_disass (mu_sieve_machine_t mach);
 #define MU_SIEVE_CLEAR_INCLUDE_PATH 0x1
 #define MU_SIEVE_CLEAR_LIBRARY_PATH 0x2
 
-struct mu_gocs_sieve
-{
-  int clearflags;
-  /*  mu_list_t include_path_prefix;*/
-  mu_list_t include_path;
-  mu_list_t library_path_prefix;
-  mu_list_t library_path;
-};
-
-int mu_sieve_module_init (enum mu_gocs_op, void *);
-
 extern struct mu_cli_capa mu_cli_capa_sieve;
   
 #ifdef __cplusplus
diff --git a/include/mailutils/sql.h b/include/mailutils/sql.h
index e08f49b..ff3a16e 100644
--- a/include/mailutils/sql.h
+++ b/include/mailutils/sql.h
@@ -29,24 +29,6 @@ enum mu_password_type
 
 struct mu_sql_module_config
 {
-  char *interface;
-  char *getpwnam_query;
-  char *getpass_query;
-  char *getpwuid_query;
-  char *host;
-  char *user;
-  char *passwd;
-  char *db;
-  int port;
-  enum mu_password_type password_type;
-  int positional;
-  mu_assoc_t field_map;
-};
-
-/* FIXME: Should not be here, but needed for several other sources
-   (imap4d/auth_gsasl.c, for instance) */
-struct mu_internal_sql_config
-{
   int interface;
   char *getpwnam_query;
   char *getpass_query;
@@ -61,7 +43,7 @@ struct mu_internal_sql_config
   mu_assoc_t field_map;
 };
 
-extern struct mu_internal_sql_config mu_sql_module_config;
+extern struct mu_sql_module_config mu_sql_module_config;
 
 /* Loadable Modules Support */
 #define __s_cat2__(a,b) a ## b
@@ -131,7 +113,7 @@ struct mu_sql_dispatch
 };
 
 /* Public interfaces */
-int mu_sql_interface_index (char *name);
+int mu_sql_interface_index (char const *name);
 
 int mu_sql_connection_init (mu_sql_connection_t *conn, int interface,
                            char *server, int  port, char *login,
diff --git a/include/mailutils/tls.h b/include/mailutils/tls.h
index db6e420..16b1ecb 100644
--- a/include/mailutils/tls.h
+++ b/include/mailutils/tls.h
@@ -42,8 +42,6 @@ struct mu_tls_module_config
   char *priorities;
 };
 
-extern int mu_tls_module_init (enum mu_gocs_op, void *);
-
 extern int mu_tls_server_stream_create (mu_stream_t *stream, 
                                        mu_stream_t strin, mu_stream_t strout,
                                        int flags);
diff --git a/include/mailutils/types.hin b/include/mailutils/types.hin
index 770b989..1057239 100644
--- a/include/mailutils/types.hin
+++ b/include/mailutils/types.hin
@@ -151,12 +151,6 @@ struct mu_locus
   unsigned mu_col;
 };
   
-enum mu_gocs_op
-  {
-    mu_gocs_op_set,
-    mu_gocs_op_flush
-  };
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0cc9731..2cdff6f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -28,7 +28,6 @@ lib_LTLIBRARIES = libmuaux.la
 noinst_LIBRARIES = libmuscript.a libmutcpwrap.a
 
 libmuaux_la_SOURCES = \
- argp_base.c\
  daemon.c\
  mailcap.c\
  manlock.c\
diff --git a/lib/argp_base.c b/lib/argp_base.c
deleted file mode 100644
index 06e7e49..0000000
--- a/lib/argp_base.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2009-2012, 2014-2016 Free Software Foundation,
-   Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <unistd.h>
-#include <string.h>
-
-char *
-__argp_base_name (const char *arg)
-{
-  char *p = strrchr (arg, '/');
-  return (char *)(p ? p + 1 : arg);
-}
-
diff --git a/libmailutils/auth/mu_auth.c b/libmailutils/auth/mu_auth.c
index 2d4f14d..54896e1 100644
--- a/libmailutils/auth/mu_auth.c
+++ b/libmailutils/auth/mu_auth.c
@@ -161,23 +161,19 @@ mu_auth_data_destroy (struct mu_auth_data **pptr)
 
 /* Generic functions */
 
-struct auth_stack_entry {
-  char *name;        /* for diagnostics purposes */
-  mu_auth_fp fun;
-  void *func_data;
-};
-
-void
-mu_insert_stack_entry (mu_list_t *pflist, struct auth_stack_entry *entry)
+static void
+append_auth_module (mu_list_t *pflist, struct mu_auth_module *mod)
 {
   if (!*pflist && mu_list_create (pflist))
     return;
-  mu_list_append (*pflist, entry);
+  mu_list_append (*pflist, mod);
 }
 
 int
-mu_auth_runlist (mu_list_t flist, struct mu_auth_data **return_data,
-                 const void *key, void *data)
+mu_auth_runlist (mu_list_t flist,
+                enum mu_auth_mode mode,
+                 const void *key, void *data,
+                struct mu_auth_data **return_data)
 {
   int status = MU_ERR_AUTH_FAILURE;
   int rc;
@@ -185,15 +181,17 @@ mu_auth_runlist (mu_list_t flist, struct mu_auth_data 
**return_data,
 
   if (mu_list_get_iterator (flist, &itr) == 0)
     {
-      struct auth_stack_entry *ep;
+      struct mu_auth_module *ep;
       
       for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
            mu_iterator_next (itr))
         {
           mu_iterator_current (itr, (void **)&ep);
+         if (!ep->handler[mode])
+           continue;
           mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2,
                    ("Trying %s...", ep->name));
-          rc = ep->fun (return_data, key, ep->func_data, data);
+          rc = ep->handler[mode] (return_data, key, ep->data[mode], data);
          mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2, 
                    ("%s yields %d=%s", ep->name, rc, mu_strerror (rc)));
           if (rc == 0)
@@ -230,30 +228,25 @@ mu_auth_nosupport (struct mu_auth_data **return_data 
MU_ARG_UNUSED,
 
 /* II. Authorization: retrieving information about user */
 
-static mu_list_t mu_auth_by_name_list, _tmp_auth_by_name_list;
-static mu_list_t mu_auth_by_uid_list, _tmp_auth_by_uid_list;
+static mu_list_t mu_getpw_modules, selected_getpw_modules;
 
 int
 mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type,
              const void *key)
 {
-  mu_list_t list;
-  
-  if (!mu_auth_by_name_list)
+  if (!mu_getpw_modules)
     mu_auth_begin_setup ();
   switch (type)
     {
     case mu_auth_key_name:
       mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1,
                 ("Getting auth info for user %s", (char*) key));
-      list = mu_auth_by_name_list;
       break;
 
     case mu_auth_key_uid:
       mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, 
                 ("Getting auth info for UID %lu",
                 (unsigned long) *(uid_t*) key));
-      list = mu_auth_by_uid_list;
       break;
 
     default:
@@ -261,7 +254,7 @@ mu_get_auth (struct mu_auth_data **auth, enum 
mu_auth_key_type type,
                 ("Unknown mu_auth_key_type: %d", type));
       return EINVAL;
     }
-  return mu_auth_runlist (list, auth, key, NULL);
+  return mu_auth_runlist (mu_getpw_modules, type, key, NULL, auth);
 }
 
 struct mu_auth_data *
@@ -282,7 +275,7 @@ mu_get_auth_by_uid (uid_t uid)
 
 /* III. Authentication: determining the authenticity of a user */
 
-static mu_list_t mu_authenticate_list, _tmp_authenticate_list;
+static mu_list_t mu_auth_modules, selected_auth_modules;
 
 int
 mu_authenticate (struct mu_auth_data *auth_data, const char *pass)
@@ -292,68 +285,52 @@ mu_authenticate (struct mu_auth_data *auth_data, const 
char *pass)
   mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, 
             ("mu_authenticate, user %s, source %s", 
              auth_data->name, auth_data->source));
-  if (!mu_authenticate_list)
+  if (!mu_auth_modules)
     mu_auth_begin_setup ();
-  return mu_auth_runlist (mu_authenticate_list, NULL, auth_data, (void*) pass);
+  return mu_auth_runlist (mu_auth_modules,
+                         mu_auth_authenticate,
+                         auth_data, pass, NULL);
 }
 
 
 /* ************************************************************************* */
 
-struct _module_handler {
-  struct auth_stack_entry authenticate;
-  struct auth_stack_entry auth_by_name;
-  struct auth_stack_entry auth_by_uid;
-};
+static mu_list_t module_list;
 
-static mu_list_t module_handler_list;
+static void
+module_list_init (void)
+{
+  if (!module_list)
+    {
+      if (mu_list_create (&module_list))
+       abort ();
+      mu_list_append (module_list, &mu_auth_generic_module); 
+      mu_list_append (module_list, &mu_auth_system_module);
+    }
+}
 
 void
 mu_auth_register_module (struct mu_auth_module *mod)
 {
-  struct _module_handler *entry;
-  
-  if (mod->init)
-    mu_gocs_register (mod->name, mod->init);
-  
-  if (!module_handler_list && mu_list_create (&module_handler_list))
-    abort ();
-
-  entry = malloc (sizeof (*entry));
-  if (!entry)
-    {
-      mu_error ("not enough memory");
-      exit (1);
-    }
-  entry->authenticate.name = mod->name;
-  entry->authenticate.fun  = mod->authenticate;
-  entry->authenticate.func_data = mod->authenticate_data;
-  entry->auth_by_name.name = mod->name;
-  entry->auth_by_name.fun = mod->auth_by_name;
-  entry->auth_by_name.func_data = mod->auth_by_name_data;
-  entry->auth_by_uid.name = mod->name;
-  entry->auth_by_uid.fun = mod->auth_by_uid;
-  entry->auth_by_uid.func_data = mod->auth_by_uid_data;
-    
-  mu_list_append (module_handler_list, entry);
-  
+  module_list_init ();
+  mu_list_append (module_list, mod);  
 }
 
-static struct _module_handler *
+static struct mu_auth_module *
 _locate (const char *name)
 {
-  struct _module_handler *rp = NULL;
+  struct mu_auth_module *rp = NULL;
   mu_iterator_t itr;
 
-  if (mu_list_get_iterator (module_handler_list, &itr) == 0)
+  if (mu_list_get_iterator (module_list, &itr) == 0)
     {
-      struct _module_handler *p;
+      struct mu_auth_module *p;
       
       for (mu_iterator_first (itr); !rp && !mu_iterator_is_done (itr);
            mu_iterator_next (itr))
         {
           mu_iterator_current (itr, (void **)&p);
-          if (strcmp (p->authenticate.name, name) == 0)
+          if (strcmp (p->name, name) == 0)
             rp = p;
         }
 
@@ -397,15 +374,14 @@ _add_module_list (const char *modlist, int (*fun)(const 
char *name))
 int
 mu_authorization_add_module (const char *name)
 {
-  struct _module_handler *mod = _locate (name);
+  struct mu_auth_module *mod = _locate (name);
   
   if (!mod)
     {
       errno = MU_ERR_NOENT;
       return 1;
     }
-  mu_insert_stack_entry (&_tmp_auth_by_name_list, &mod->auth_by_name);
-  mu_insert_stack_entry (&_tmp_auth_by_uid_list, &mod->auth_by_uid);
+  append_auth_module (&selected_getpw_modules, mod);
   return 0;
 }
 
@@ -418,22 +394,21 @@ mu_authorization_add_module_list (const char *modlist)
 void
 mu_authorization_clear_list ()
 {
-  mu_list_destroy (&_tmp_auth_by_name_list);
-  mu_list_destroy (&_tmp_auth_by_uid_list);
+  mu_list_destroy (&selected_getpw_modules);
 }
 
 
 int
 mu_authentication_add_module (const char *name)
 {
-  struct _module_handler *mod = _locate (name);
+  struct mu_auth_module *mod = _locate (name);
 
   if (!mod)
     {
       errno = MU_ERR_NOENT;
       return 1;
     }
-  mu_insert_stack_entry (&_tmp_authenticate_list, &mod->authenticate);
+  append_auth_module (&selected_auth_modules, mod);
   return 0;
 }
 
@@ -446,7 +421,7 @@ mu_authentication_add_module_list (const char *modlist)
 void
 mu_authentication_clear_list ()
 {
-  mu_list_destroy (&_tmp_authenticate_list);
+  mu_list_destroy (&selected_auth_modules);
 }
 
 
@@ -462,45 +437,39 @@ mu_authentication_clear_list ()
       argp_parse() exits. */
    
 void
-mu_auth_begin_setup ()
+mu_auth_begin_setup (void)
 {
   mu_iterator_t itr;
 
-  if (!module_handler_list)
-    {
-      mu_auth_register_module (&mu_auth_generic_module); 
-      mu_auth_register_module (&mu_auth_system_module);
-    }
-  
-  if (!mu_authenticate_list)
+  module_list_init ();
+
+  if (!mu_auth_modules)
     {
-      if (mu_list_get_iterator (module_handler_list, &itr) == 0)
+      if (mu_list_get_iterator (module_list, &itr) == 0)
         {
-          struct _module_handler *mod;
+          struct mu_auth_module *mod;
           
           for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
                mu_iterator_next (itr))
             {
               mu_iterator_current (itr, (void **)&mod);
-              mu_insert_stack_entry (&mu_authenticate_list,
-                                     &mod->authenticate);
+             append_auth_module (&mu_auth_modules, mod);
             }
           mu_iterator_destroy (&itr);
         }
     }
 
-  if (!mu_auth_by_name_list)
+  if (!mu_getpw_modules)
     {
-      if (mu_list_get_iterator (module_handler_list, &itr) == 0)
+      if (mu_list_get_iterator (module_list, &itr) == 0)
         {
-          struct _module_handler *mod;
+          struct mu_auth_module *mod;
           
           for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
                mu_iterator_next (itr))
             {
               mu_iterator_current (itr, (void **)&mod);
-              mu_insert_stack_entry (&mu_auth_by_name_list, 
&mod->auth_by_name);
-              mu_insert_stack_entry (&mu_auth_by_uid_list, &mod->auth_by_uid);
+              append_auth_module (&mu_getpw_modules, mod);
             }
           mu_iterator_destroy (&itr);
         }
@@ -508,20 +477,48 @@ mu_auth_begin_setup ()
 }
 
 void
-mu_auth_finish_setup ()
+mu_auth_finish_setup (void)
 {
-  mu_list_destroy (&mu_authenticate_list);
-  mu_list_destroy (&mu_auth_by_name_list);
-  mu_list_destroy (&mu_auth_by_uid_list);
-  
-  mu_authenticate_list = _tmp_authenticate_list;
-  _tmp_authenticate_list = NULL;
-  mu_auth_by_name_list = _tmp_auth_by_name_list;
-  _tmp_auth_by_name_list = NULL;
-  mu_auth_by_uid_list = _tmp_auth_by_uid_list;
-  _tmp_auth_by_uid_list = NULL;
+  mu_list_destroy (&mu_auth_modules);
+  mu_auth_modules = selected_auth_modules;
+  selected_auth_modules = NULL;
+
+  mu_list_destroy (&mu_getpw_modules);
+  mu_getpw_modules = selected_getpw_modules;
+  selected_getpw_modules = NULL;
   
   mu_auth_begin_setup ();
 }
+
+struct settings
+{
+  mu_list_t opts;
+  mu_list_t commits;
+};
+  
+static int
+do_extend (void *item, void *data)
+{
+  struct mu_auth_module *mod = item;
+  struct settings *set = data;
+  
+  if (mod->opt)
+    mu_list_append (set->opts, mod->opt);
+  if (mod->commit)
+    mu_list_append (set->commits, mod->commit);
+  if (mod->parser || mod->cfg)
+    mu_config_root_register_section (NULL, mod->name, NULL,
+                                    mod->parser, mod->cfg);
+  return 0;
+}
+
+void
+mu_auth_extend_settings (mu_list_t opts, mu_list_t commits)
+{
+  struct settings s;
+  s.opts = opts;
+  s.commits = commits;
+  mu_list_foreach (module_list, do_extend, &s);
+}
 
 
diff --git a/libmailutils/auth/system.c b/libmailutils/auth/system.c
index ac6455e..1094232 100644
--- a/libmailutils/auth/system.c
+++ b/libmailutils/auth/system.c
@@ -141,25 +141,19 @@ mu_authenticate_system (struct mu_auth_data **return_data 
MU_ARG_UNUSED,
 
 
 struct mu_auth_module mu_auth_system_module = {
-  "system",
-  NULL,
-  mu_authenticate_system,
-  NULL,
-  mu_auth_system_by_name,
-  NULL,
-  mu_auth_system_by_uid,
-  NULL
+  .name = "system",
+  .handler = {
+    [mu_auth_authenticate] = mu_authenticate_system,
+    [mu_auth_getpwnam]     = mu_auth_system_by_name,
+    [mu_auth_getpwuid]     = mu_auth_system_by_uid
+  }
 };
 
 
 struct mu_auth_module mu_auth_generic_module = {
-  "generic",
-  NULL,
-  mu_authenticate_generic,
-  NULL,
-  mu_auth_nosupport,
-  NULL,
-  mu_auth_nosupport,
-  NULL
+  .name = "generic",
+  .handler = {
+    [mu_auth_authenticate] = mu_authenticate_generic
+  }
 };
 
diff --git a/libmailutils/cfg/Makefile.am b/libmailutils/cfg/Makefile.am
index 89ab1de..9530303 100644
--- a/libmailutils/cfg/Makefile.am
+++ b/libmailutils/cfg/Makefile.am
@@ -21,8 +21,7 @@ libcfg_la_SOURCES = \
  driver.c\
  format.c\
  lexer.c\
- parser.c\
- gocs.c
+ parser.c
 
 localedir = $(datadir)/locale
 AM_CPPFLAGS = \
diff --git a/libmailutils/cfg/gocs.c b/libmailutils/cfg/gocs.c
deleted file mode 100644
index ec2dd92..0000000
--- a/libmailutils/cfg/gocs.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <mailutils/types.h>
-#include <mailutils/gocs.h>
-#include <mailutils/mailbox.h>
-#include <mailutils/locker.h>
-#include <mailutils/util.h>
-#include <mailutils/mailer.h>
-#include <mailutils/error.h>
-#include <mailutils/errno.h>
-#include <mailutils/nls.h>
-#include <mailutils/debug.h>
-#include <mailutils/syslog.h>
-#include <mailutils/registrar.h>
-#include <mailutils/stdstream.h>
-#include <mailutils/stream.h>
-#include <mailutils/log.h>
-#include <syslog.h>
-
-#ifndef MU_CONFIG_FILE
-# define MU_CONFIG_FILE SYSCONFDIR "/mailutils.rc"
-#endif
-
-char *mu_site_rcfile = MU_CONFIG_FILE;
-int mu_load_user_rcfile = 1;
-int mu_load_site_rcfile = 1;
-char *mu_load_rcfile = NULL;
-
-
-int
-mu_gocs_dummy (enum mu_gocs_op op, void *data)
-{
-  return 0;
-}
-
-int
-mu_gocs_mailbox_init (enum mu_gocs_op op, void *data)
-{
-  int rc;
-  struct mu_gocs_mailbox *p = data;
-
-  if (op == mu_gocs_op_set && p)
-    {
-      if (p->mail_spool)
-       {
-         rc = mu_set_mail_directory (p->mail_spool);
-         if (rc)
-           mu_error (_("cannot set mail directory name to `%s': %s"),
-                     p->mail_spool, mu_strerror (rc));
-         free (p->mail_spool);
-         p->mail_spool = NULL;
-       }
-      if (p->mailbox_pattern)
-       {
-         rc = mu_set_mailbox_pattern (p->mailbox_pattern);
-         if (rc)
-           mu_error (_("cannot set mailbox pattern to `%s': %s"),
-                     p->mailbox_pattern, mu_strerror (rc));
-         free (p->mailbox_pattern);
-         p->mailbox_pattern = NULL;
-       }
-      if (p->mailbox_type)
-       {
-         if (mu_registrar_set_default_scheme (p->mailbox_type))
-           mu_error (_("invalid mailbox type: %s"), p->mailbox_type);
-         free (p->mailbox_type);
-         p->mailbox_type = NULL;
-       }
-    }
-  return 0;
-}
-
-int
-mu_gocs_locking_init (enum mu_gocs_op op, void *data)
-{
-  struct mu_gocs_locking *p = data;
-  
-  if (!(op == mu_gocs_op_set && p))
-    return 0;
-
-  if (p->lock_flags)
-    {
-      int flags = 0;
-      char *s;
-      
-      for (s = p->lock_flags; *s; s++)
-       {
-         switch (*s)
-           {
-           case 'E':
-             flags |= MU_LOCKER_EXTERNAL;
-             break;
-             
-           case 'R':
-             flags |= MU_LOCKER_RETRY;
-             break;
-             
-           case 'T':
-             flags |= MU_LOCKER_TIME;
-             break;
-             
-           case 'P':
-             flags |= MU_LOCKER_PID;
-             break;
-             
-           default:
-             mu_error (_("invalid lock flag `%c'"), *s);
-           }
-       }
-      mu_locker_set_default_flags (flags, mu_locker_assign);
-      free (p->lock_flags);
-      p->lock_flags = NULL;
-    }
-
-  if (p->lock_retry_count)
-    {
-      mu_locker_set_default_retry_count (p->lock_retry_count);
-      mu_locker_set_default_flags (MU_LOCKER_RETRY, mu_locker_set_bit);
-      p->lock_retry_count = 0;
-    }
-
-  if (p->lock_retry_timeout)
-    {
-      mu_locker_set_default_retry_timeout (p->lock_retry_timeout);
-      mu_locker_set_default_flags (MU_LOCKER_RETRY, mu_locker_set_bit);
-      p->lock_retry_timeout = 0;
-    }
-
-  if (p->lock_expire_timeout)
-    {
-      mu_locker_set_default_expire_timeout (p->lock_expire_timeout);
-      mu_locker_set_default_flags (MU_LOCKER_EXTERNAL, mu_locker_set_bit);
-      p->lock_expire_timeout = 0;
-    }
-
-  if (p->external_locker)
-    {
-      mu_locker_set_default_external_program (p->external_locker);
-      mu_locker_set_default_flags (MU_LOCKER_TIME, mu_locker_set_bit);
-      free (p->external_locker);
-      p->external_locker = NULL;
-    }
-  return 0;
-}
-
-int
-mu_gocs_source_email_init (enum mu_gocs_op op, void *data)
-{
-  struct mu_gocs_source_email *p = data;
-  int rc;
-
-  if (!(op == mu_gocs_op_set && p))
-    return 0;
-  
-  if (p->address)
-    {
-      if ((rc = mu_set_user_email (p->address)) != 0)
-       mu_error (_("invalid email address `%s': %s"),
-                 p->address, mu_strerror (rc));
-      free (p->address);
-      p->address = NULL;
-    }
-
-  if (p->domain)
-    {
-      if ((rc = mu_set_user_email_domain (p->domain)) != 0)
-       mu_error (_("invalid email domain `%s': %s"),
-                 p->domain, mu_strerror (rc));
-
-      free (p->domain);
-      p->domain = NULL;
-    }
-  return 0;
-}
-
-int
-mu_gocs_mailer_init (enum mu_gocs_op op, void *data)
-{
-  struct mu_gocs_mailer *p = data;
-  int rc;
-
-  if (!(op == mu_gocs_op_set && p))
-    return 0;
-  
-  if (p->mailer)
-    {
-      if ((rc = mu_mailer_set_url_default (p->mailer)) != 0)
-       mu_error (_("invalid mailer URL `%s': %s"),
-                 p->mailer, mu_strerror (rc));
-      free (p->mailer);
-      p->mailer = NULL;
-    }
-  return 0;
-}
-
-int
-mu_gocs_logging_init (enum mu_gocs_op op, void *data)
-{
-  if (mu_log_syslog >= 0)
-    mu_stdstream_strerr_setup (mu_log_syslog ?
-                              MU_STRERR_SYSLOG : MU_STRERR_STDERR);
-  return 0;
-}
-
-int
-mu_gocs_debug_init (enum mu_gocs_op op, void *data)
-{
-  if (op == mu_gocs_op_set && data)
-    {
-      struct mu_gocs_debug *p = data;
-      if (p->string)
-       mu_debug_parse_spec (p->string);
-      if (p->line_info >= 0)
-       mu_debug_line_info = p->line_info;
-    }
-  return 0;
-}
-
-
-struct mu_gocs_entry
-{
-  const char *name;
-  mu_gocs_init_fp init;
-};
-
-#define MAX_GOCS 512
-
-static struct mu_gocs_entry _gocs_table[MAX_GOCS];
-
-void
-mu_gocs_register (const char *capa, mu_gocs_init_fp init)
-{
-  int i;
-  for (i = 0; _gocs_table[i].name; i++)
-    {
-      if (i == MAX_GOCS-1)
-       {
-         mu_error (_("gocs table overflow"));
-         abort ();
-       }
-      else if (strcmp (_gocs_table[i].name, capa) == 0)
-       return;
-    }
-  _gocs_table[i].name = capa;
-  _gocs_table[i].init = init;
-}
-
-int
-mu_gocs_enumerate (mu_list_action_t action, void *data)
-{
-  int i;
-  
-  for (i = 0; _gocs_table[i].name; i++)
-    {
-      int rc = action ((void*) _gocs_table[i].name, data);
-      if (rc)
-       return rc;
-    }
-  return 0;
-}
-
-static mu_gocs_init_fp
-find_init_function (struct mu_gocs_entry *tab, const char *capa)
-{
-  for (; tab->name; tab++)
-    if (strcmp (tab->name, capa) == 0)
-      return tab->init;
-  return NULL;
-}
-
-static struct mu_gocs_entry std_gocs_table[] = {
-  { "mailutils", mu_gocs_dummy },
-  { "common", mu_gocs_dummy },
-  { "mailbox", mu_gocs_mailbox_init },
-  { "locking", mu_gocs_locking_init },
-  { "address", mu_gocs_source_email_init },
-  { "mailer", mu_gocs_mailer_init },
-  { "logging", mu_gocs_logging_init },
-  { "debug", mu_gocs_debug_init },
-  { "auth", mu_gocs_dummy },
-  { NULL }
-};
-
-void
-mu_gocs_register_std (const char *name)
-{
-  mu_gocs_init_fp init = find_init_function (std_gocs_table, name);
-  if (!init)
-    {
-      mu_error (_("INTERNAL ERROR at %s:%d: unknown standard capability `%s'"),
-               __FILE__, __LINE__, name);
-      abort ();
-    }
-  mu_gocs_register (name, init);
-}
-
-
-struct mu_gocs_data
-{
-  char *capa;
-  void *data;
-};
-
-static mu_list_t /* of struct mu_gocs_data */ data_list;
-
-static int
-_gocs_comp (const void *a, const void *b)
-{
-  const struct mu_gocs_data *da = a, *db = b;
-  return !(strcmp (da->capa, db->capa) == 0 && da->data == db->data);
-}
-
-void
-mu_gocs_store (char *capa, void *data)
-{
-  struct mu_gocs_data *s;
-  if (!data_list)
-    {
-      mu_list_create (&data_list);
-      mu_list_set_destroy_item (data_list, mu_list_free_item);
-      mu_list_set_comparator (data_list, _gocs_comp);
-    }
-  s = malloc (sizeof *s);
-  if (!s)
-    {
-      mu_error ("%s", mu_strerror (ENOMEM));
-      exit (1);
-    }
-  s->capa = capa;
-  s->data = data;
-  if (mu_list_locate (data_list, s, NULL) == 0)
-    free (s);
-  else
-    mu_list_prepend (data_list, s);
-}
-
-int
-_gocs_flush (void *item, void *data)
-{
-  struct mu_gocs_data *s = item;
-  mu_gocs_init_fp initfun = find_init_function (_gocs_table, s->capa);
-
-  if (!initfun)
-    {
-      mu_error (_("INTERNAL ERROR at %s:%d: unknown capability `%s'"),
-               __FILE__, __LINE__, s->capa);
-      abort ();
-    }
-
-  if (initfun (mu_gocs_op_set, s->data))
-    {
-      mu_error (_("initialization of GOCS `%s' failed"), s->capa);
-      return 1;
-    }
-  
-  return 0;
-}
-
-void
-mu_gocs_flush ()
-{
-  int i;
-  mu_list_foreach (data_list, _gocs_flush, NULL);
-
-  for (i = 0; _gocs_table[i].name; i++)
-    _gocs_table[i].init (mu_gocs_op_flush, NULL);
-}
diff --git a/libmailutils/cli/capa.c b/libmailutils/cli/capa.c
index bd5c557..a3523e2 100644
--- a/libmailutils/cli/capa.c
+++ b/libmailutils/cli/capa.c
@@ -60,7 +60,7 @@ struct capa_apply
 };
 
 static int
-capa_apply (void *item, void *data)
+capa_extend (void *item, void *data)
 {
   struct mu_cli_capa *cp = item;
   struct capa_apply *ap = data;
@@ -80,14 +80,15 @@ capa_apply (void *item, void *data)
 }
 
 void
-mu_cli_capa_apply (char const *name, mu_list_t opts, mu_list_t commits)
+mu_cli_capa_extend_settings (char const *name, mu_list_t opts,
+                            mu_list_t commits)
 {
   struct capa_apply app;
   app.name = name;
   app.opts = opts;
   app.commits = commits;
   app.found = 0;
-  mu_list_foreach (capa_list, capa_apply, &app);
+  mu_list_foreach (capa_list, capa_extend, &app);
   if (!app.found)
     mu_error (_("INTERNAL ERROR at %s:%d: unknown standard capability `%s'"),
              __FILE__, __LINE__, name);
diff --git a/libmailutils/cli/cli.c b/libmailutils/cli/cli.c
index 2dd142a..0a608ba 100644
--- a/libmailutils/cli/cli.c
+++ b/libmailutils/cli/cli.c
@@ -31,6 +31,7 @@
 #include <mailutils/stdstream.h>
 #include <mailutils/io.h>
 #include <mailutils/syslog.h>
+#include <mailutils/mu_auth.h>
 
 #ifndef MU_SITE_CONFIG_FILE
 # define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.rc"
@@ -85,6 +86,14 @@ extra_help_hook (struct mu_parseopt *po, mu_stream_t stream)
   struct mu_cli_setup *setup = hints->data;
   mu_stream_printf (stream, "%s\n", _(setup->prog_extra_doc));
 }
+
+static void
+prog_doc_hook (struct mu_parseopt *po, mu_stream_t stream)
+{
+  struct mu_cfg_parse_hints *hints = po->po_data;
+  struct mu_cli_setup *setup = hints->data;
+  setup->prog_doc_hook (stream);
+}
 
 static void
 change_progname (struct mu_parseopt *po, struct mu_option *opt,
@@ -283,6 +292,7 @@ init_options (char **capa, struct mu_cli_setup *setup,
 {
   size_t i, s;
   mu_list_t oplist;
+  mu_list_t comlist;
   struct mu_parseopt po;
   
   mu_list_create (&oplist);
@@ -291,16 +301,16 @@ init_options (char **capa, struct mu_cli_setup *setup,
       for (i = 0; setup->optv[i]; i++)
        mu_list_append (oplist, setup->optv[i]);
     }
+
+  mu_list_create (&comlist);
+  mu_auth_extend_settings (oplist, comlist);
   if (capa)
     {
-      mu_list_t comlist;
-      mu_list_create (&comlist);
       for (i = 0; capa[i]; i++)
-       mu_cli_capa_apply (capa[i], oplist, comlist);
-      *ret_comlist = comlist;
+       mu_cli_capa_extend_settings (capa[i], oplist, comlist);
     }
-  else
-    *ret_comlist = NULL;
+
+  *ret_comlist = comlist;
   
   mu_list_append (oplist, mu_common_options);
   mu_list_append (oplist, mu_extra_help_options);
@@ -346,7 +356,9 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, 
char **capa,
     setup->ex_usage = EX_USAGE;
   if (setup->ex_config == 0)
     setup->ex_config = EX_CONFIG;
-  
+  if (setup->inorder)
+    flags |= MU_PARSEOPT_IN_ORDER;
+    
   /* Set program name */
   mu_set_program_name (argv[0]);
 
@@ -358,7 +370,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, 
char **capa,
 
   /* Initialize standard capabilities */
   mu_cli_capa_init ();
-  
+
   /* Initialize hints */
   memset (&hints, 0, sizeof (hints));
   hints.flags |= MU_CFG_PARSE_SITE_RCFILE;
@@ -370,6 +382,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, 
char **capa,
   hints.data = setup;
   
   /* Initialize po */
+  
   if (setup->prog_doc)
     {
       po.po_prog_doc = setup->prog_doc;
@@ -423,6 +436,12 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, 
char **capa,
       po.po_help_hook = extra_help_hook;
       flags |= MU_PARSEOPT_HELP_HOOK;
     }
+
+  if (setup->prog_doc_hook)
+    {
+      po.po_prog_doc_hook = prog_doc_hook;
+      flags |= MU_PARSEOPT_PROG_DOC_HOOK;
+    }
   
   po.po_data = &hints;
   flags |= MU_PARSEOPT_DATA;
@@ -458,7 +477,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, 
char **capa,
 
   mu_list_foreach (com_list, run_commit, NULL);
   mu_list_destroy (&com_list);
-  
+
   if (hints.flags & MU_PARSE_CONFIG_LINT)
     exit (0);
 
diff --git a/libmailutils/opt/help.c b/libmailutils/opt/help.c
index b1a81ea..8e54578 100644
--- a/libmailutils/opt/help.c
+++ b/libmailutils/opt/help.c
@@ -352,6 +352,12 @@ mu_program_help (struct mu_parseopt *po, mu_stream_t 
outstr)
     }
   mu_stream_printf (str, "\n");
   
+  if (po->po_prog_doc_hook)
+    {
+      po->po_prog_doc_hook (po, str);
+      mu_stream_printf (str, "\n");
+    }
+  
   mu_option_describe_options (str, po->po_optv, po->po_optc);
 
   if (po->po_help_hook)
diff --git a/libmailutils/opt/opt.c b/libmailutils/opt/opt.c
index 7dd28a1..967cf89 100644
--- a/libmailutils/opt/opt.c
+++ b/libmailutils/opt/opt.c
@@ -213,6 +213,8 @@ find_long_option (struct mu_parseopt *po, char const 
*optstr,
            case 0:
              ind = i;
              found++;
+             if (optlen == strlen (po->po_optv[i]->opt_long))
+               i = po->po_optc - 1; /* exact match: break the loop */
              break;
 
            case 1:
@@ -511,6 +513,8 @@ parseopt_init (struct mu_parseopt *po, struct mu_option 
**options,
     po->po_exit_error = EXIT_ERROR;
   if (!(flags & MU_PARSEOPT_VERSION_HOOK))
     po->po_version_hook = NULL;
+  if (!(flags & MU_PARSEOPT_PROG_DOC_HOOK))
+    po->po_prog_doc_hook = NULL;
   
   /* Count the options */
   po->po_optc = 0;
diff --git a/libmu_argp/.gitignore b/libmu_argp/.gitignore
deleted file mode 100644
index 2248e8c..0000000
--- a/libmu_argp/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-.gdbinit
diff --git a/libmu_argp/Makefile.am b/libmu_argp/Makefile.am
deleted file mode 100644
index 675ee62..0000000
--- a/libmu_argp/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-# This file is part of GNU Mailutils
-# Copyright (C) 2007, 2009-2012, 2014-2016 Free Software Foundation,
-# Inc.
-#
-# GNU Mailutils is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3, or (at
-# your option) any later version.
-#
-# GNU Mailutils is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. 
-
-# This library uses gnulib calls and is always linked with gnulib, therefore
-# we use application includes here.
-AM_CPPFLAGS = \
- @address@hidden
- -DSYSCONFDIR=\"$(sysconfdir)\"\
- -DSITE_VIRTUAL_PWDDIR=\"@address@hidden"\
- -DSITE_CRAM_MD5_PWD=\"@address@hidden"
-
-lib_LTLIBRARIES = libmu_argp.la
-
-libmu_argp_la_SOURCES =\
- cmdline.c\
- cmdline.h\
- common.c\
- mailutils.c\
- mu_argp.c\
- muinit.c\
- sieve.c
-
-libmu_argp_la_LIBADD=../lib/libmuaux.la
-
-libmu_argp_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
diff --git a/libmu_argp/cmdline.c b/libmu_argp/cmdline.c
deleted file mode 100644
index 55dabed..0000000
--- a/libmu_argp/cmdline.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "cmdline.h"
-
-static struct mu_cmdline_capa *all_cmdline_capa[] = {
-  &mu_mailutils_cmdline,
-  &mu_common_cmdline,
-  &mu_logging_cmdline,
-  &mu_mailer_cmdline,
-  &mu_debug_cmdline,
-  &mu_sieve_cmdline,
-  NULL
-};
-
-static int libargp_init_passed = 0;
-
-void
-mu_libargp_init ()
-{
-  struct mu_cmdline_capa **cpp;
-  if (libargp_init_passed)
-    return;
-  libargp_init_passed = 1;
-  for (cpp = all_cmdline_capa; *cpp; cpp++)
-    {
-      struct mu_cmdline_capa *cp = *cpp;
-      if (mu_register_argp_capa (cp->name, cp->child, cp->modflags))
-       {
-         mu_error (_("INTERNAL ERROR: cannot register argp capability `%s'"),
-                   cp->name);
-         abort ();
-       }
-    }
-}
-
-void
-mu_argp_node_list_init (mu_list_t *plist)
-{
-  int rc = mu_cfg_create_node_list (plist);
-  if (rc)
-    {
-      mu_diag_funcall (MU_DIAG_ERROR, "mu_cfg_create_node_list", NULL, rc);
-      abort ();
-    }
-}
-
-void
-mu_argp_node_list_add (mu_list_t lst, mu_cfg_node_t *node)
-{
-  int rc = mu_list_append (lst, node);
-  if (rc)
-    {
-      mu_diag_funcall (MU_DIAG_ERROR, "mu_list_append", NULL, rc);
-      abort ();
-    }
-}
-                  
-void
-mu_argp_node_list_new (mu_list_t lst, const char *tag, const char *label)
-{
-  mu_cfg_node_t *node;
-  size_t n;
-  struct mu_locus loc = { "command line", 0 };
-
-  mu_list_count (lst, &n);
-  loc.mu_line = n;
-  node = mu_cfg_tree_create_node (mu_argp_tree, mu_cfg_node_param,
-                                 &loc, tag, label, NULL);
-  mu_argp_node_list_add (lst, node);
-}
-
-void
-mu_argp_node_list_finish (mu_list_t lst, char *tag, char *label)
-{
-  if (mu_list_is_empty (lst))
-    return;
-  if (tag)
-    {
-      mu_cfg_node_t *node = mu_cfg_tree_create_node (mu_argp_tree,
-                                                    mu_cfg_node_statement,
-                                                    NULL,
-                                                    tag, label,
-                                                    lst);
-      mu_cfg_tree_add_node (mu_argp_tree, node);
-    }
-  else
-    {
-      mu_cfg_tree_add_nodelist (mu_argp_tree, lst);
-      mu_list_destroy (&lst);
-    }
-}
-
diff --git a/libmu_argp/cmdline.h b/libmu_argp/cmdline.h
deleted file mode 100644
index 46d5463..0000000
--- a/libmu_argp/cmdline.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation,
-   Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see 
-   <http://www.gnu.org/licenses/>. */
-
-#include "mailutils/libcfg.h"
-#include "mailutils/libargp.h"
-
-extern struct mu_cfg_tree *mu_argp_tree;
diff --git a/libmu_argp/common.c b/libmu_argp/common.c
deleted file mode 100644
index 3f245c8..0000000
--- a/libmu_argp/common.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "cmdline.h"
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <mailutils/syslog.h>
-#include <mailutils/mailbox.h>
-
-
-/* ************************************************************************* */
-/* Common                                                                    */
-/* ************************************************************************* */
-
-enum {
-  OPT_SHOW_OPTIONS=256,          
-  OPT_NO_USER_RCFILE,
-  OPT_NO_SITE_RCFILE,
-  OPT_RCFILE,
-  OPT_RCFILE_LINT,
-  OPT_RCFILE_VERBOSE,
-  OPT_LOG_FACILITY,          
-  OPT_LICENSE,
-  OPT_DEBUG_LEVEL,
-  OPT_LINE_INFO,
-  OPT_HELP_CONFIG,
-  OPT_SET
-};
-
-static struct argp_option mu_common_argp_options[] = 
-{
-  { NULL, 0, NULL, 0, N_("Common options"), 0},
-  { "show-config-options", OPT_SHOW_OPTIONS, NULL, 0,
-    N_("show compilation options"), 0 },
-  { "config-help", OPT_HELP_CONFIG, NULL, 0,
-    N_("show configuration file summary"), 0 },
-  { "no-user-config", OPT_NO_USER_RCFILE, NULL, 0,
-    N_("do not load user configuration file"), 0 },
-  { "no-user-rcfile", 0, NULL, OPTION_ALIAS, NULL },
-  { "no-site-config", OPT_NO_SITE_RCFILE, NULL, 0,
-    N_("do not load site configuration file"), 0 },
-  { "no-site-rcfile", 0, NULL, OPTION_ALIAS, NULL },
-  { "config-file", OPT_RCFILE, N_("FILE"), 0,
-    N_("load this configuration file"), 0, },
-  { "rcfile", 0, NULL, OPTION_ALIAS, NULL },
-  { "config-verbose", OPT_RCFILE_VERBOSE, NULL, 0,
-    N_("verbosely log parsing of the configuration files"), 0 },
-  { "rcfile-verbose", 0, NULL, OPTION_ALIAS, NULL },
-  { "config-lint", OPT_RCFILE_LINT, NULL, 0,
-    N_("check configuration file syntax and exit"), 0 },
-  { "rcfile-lint", 0, NULL, OPTION_ALIAS, NULL },
-  { "set", OPT_SET, N_("PARAM=VALUE"), 0,
-    N_("set configuration parameter"), 0 },
-  { NULL, 0, NULL, 0, NULL, 0 }
-};
-
-static void
-set_config_param (const char *path, struct argp_state *state)
-{
-  mu_cfg_node_t *node;
-  int rc = mu_cfg_create_subtree (path, &node);
-  if (rc)
-    argp_error (state, "cannot create node: %s", mu_strerror (rc));
-  mu_cfg_tree_add_node (mu_argp_tree, node);
-}
-
-static error_t
-mu_common_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    case OPT_SHOW_OPTIONS:
-      mu_print_options ();
-      exit (0);
-
-    case OPT_NO_USER_RCFILE:
-      mu_load_user_rcfile = 0;
-      break;
-      
-    case OPT_NO_SITE_RCFILE:
-      mu_load_site_rcfile = 0;
-      break;
-      
-    case OPT_RCFILE:
-      mu_load_rcfile = arg;
-      break;
-
-    case OPT_RCFILE_LINT:
-      mu_cfg_parser_verbose++;
-      mu_rcfile_lint = 1;
-      break;
-      
-    case OPT_RCFILE_VERBOSE:
-      mu_cfg_parser_verbose++;
-      break;
-
-    case OPT_HELP_CONFIG:
-      mu_help_config_mode = 1;
-      break;
-
-    case OPT_SET:
-      set_config_param (arg, state);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-struct argp mu_common_argp = {
-  mu_common_argp_options,
-  mu_common_argp_parser,
-};
-
-struct argp_child mu_common_argp_child = {
-  &mu_common_argp,
-  0,
-  NULL,
-  0,
-};
-
-struct mu_cmdline_capa mu_common_cmdline = {
-  "common", &mu_common_argp_child
-};
-
-
-/* ************************************************************************* */
-/* Logging                                                                   */
-/* ************************************************************************* */
-
-static struct argp_option mu_logging_argp_option[] = {
-  {"log-facility", OPT_LOG_FACILITY, N_("FACILITY"), 0,
-   N_("output logs to syslog FACILITY"), 0},
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static error_t
-mu_logging_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static mu_list_t lst;
-  
-  switch (key)
-    {
-      /* log */
-    case OPT_LOG_FACILITY:
-      mu_argp_node_list_new (lst, "facility", arg);
-      break;
-         
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (lst, "logging", NULL);
-      break;
-
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-struct argp mu_logging_argp = {
-  mu_logging_argp_option,
-  mu_logging_argp_parser,
-};
-
-struct argp_child mu_logging_argp_child = {
-  &mu_logging_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_logging_cmdline = {
-  "logging", &mu_logging_argp_child
-};
-
-
-/* ************************************************************************* */
-/* Mailer                                                                    */
-/* ************************************************************************* */
-
-/* Options used by programs that send mail. */
-static struct argp_option mu_mailer_argp_option[] = {
-  {"mailer", 'M', N_("MAILER"), 0,
-   N_("use specified URL as the default mailer"), 0},
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static error_t
-mu_mailer_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static mu_list_t lst;
-
-  switch (key)
-    {
-      /* mailer */
-    case 'M':
-      mu_argp_node_list_new (lst, "url", arg);
-      break;
-
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (lst, "mailer", NULL);
-      break;
-
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-struct argp mu_mailer_argp = {
-  mu_mailer_argp_option,
-  mu_mailer_argp_parser,
-};
-
-struct argp_child mu_mailer_argp_child = {
-  &mu_mailer_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_mailer_cmdline = {
-  "mailer", &mu_mailer_argp_child
-};
-
-
-static struct argp_option mu_debug_argp_options[] = 
-{
-  { "debug-level", OPT_DEBUG_LEVEL, N_("LEVEL"), 0,
-    N_("set Mailutils debugging level"), 0 },
-  { "debug-line-info", OPT_LINE_INFO, NULL, 0,
-    N_("show source info with debugging messages"), 0 },
-  { NULL }
-};
-
-static error_t
-mu_debug_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static mu_list_t lst;
-
-  switch (key)
-    {
-    case OPT_DEBUG_LEVEL:
-      mu_debug_parse_spec (arg);
-      /*mu_argp_node_list_new (lst, "level", arg);*/
-      break;
-
-    case OPT_LINE_INFO:
-      mu_argp_node_list_new (lst, "line-info", "yes");
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (lst, "debug", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-struct argp mu_debug_argp = {
-  mu_debug_argp_options,
-  mu_debug_argp_parser,
-};
-
-struct argp_child mu_debug_argp_child = {
-  &mu_debug_argp,
-  0,
-  N_("Global debugging settings"),
-  0
-};
-
-struct mu_cmdline_capa mu_debug_cmdline = {
-  "debug", &mu_debug_argp_child
-};
diff --git a/libmu_argp/mailutils.c b/libmu_argp/mailutils.c
deleted file mode 100644
index 83ed9a8..0000000
--- a/libmu_argp/mailutils.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "cmdline.h"
-#include <unistd.h>
-#include <stdlib.h>
-/* Provide declaration of __argp_base_name: */
-#include <argp-namefrob.h> 
-
-
-/* ************************************************************************* */
-/* GNU Mailutils help and version output                                     */
-/* ************************************************************************* */
-
-#define OPT_PROGNAME    -2
-#define OPT_USAGE       -3
-#define OPT_HANG        -4
-
-static struct argp_option mu_mailutils_argp_options[] = 
-{
-  {"help",        '?',          0, 0,  N_("give this help list"), -1},
-  {"usage",       OPT_USAGE,    0, 0,  N_("give a short usage message"), 0},
-  {"version",     'V',          0, 0,  N_("print program version"), -1},
-  {"program-name",OPT_PROGNAME,N_("NAME"), OPTION_HIDDEN, N_("set the program 
name"), 0},
-  {"HANG",        OPT_HANG,    N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
-     N_("hang for SECS seconds (default 3600)"), 0},
-  { NULL }
-};
-
-static error_t
-mu_mailutils_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    case '?':
-      argp_state_help (state, state->out_stream,
-                      ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_DOC);
-      /* TRANSLATORS: The placeholder indicates the bug-reporting address
-        for this package.  Please add _another line_ saying
-        "Report translation bugs to <...>\n" with the address for translation
-        bugs (typically your translation team's web or email address).  */
-      printf (_("\nReport bugs to: %s\n"), "<" PACKAGE_BUGREPORT ">");
-      
-#ifdef PACKAGE_PACKAGER_BUG_REPORTS
-      printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER,
-             PACKAGE_PACKAGER_BUG_REPORTS);
-#endif
-      
-#ifdef PACKAGE_URL
-      printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
-#endif
-      fputs (_("General help using GNU software: 
<http://www.gnu.org/gethelp/>\n"),
-       stdout);
-      exit (0);
-
-    case OPT_USAGE:
-      argp_state_help (state, state->out_stream,
-                      ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
-      break;
-
-    case 'V':
-      if (argp_program_version_hook)
-        (*argp_program_version_hook) (state->out_stream, state);
-      else if (argp_program_version)
-        fprintf (state->out_stream, "%s\n", argp_program_version);
-      else
-        argp_error (state, "%s",
-                   dgettext (state->root_argp->argp_domain,
-                             "(PROGRAM ERROR) No version known!?"));
-      exit(0);
-      
-    case OPT_PROGNAME:          /* Set the program name.  */
-#if HAVE_DECL_PROGRAM_INVOCATION_NAME
-      program_invocation_name = arg;
-#endif
-      /* Update what we use for messages.  */
-      state->name = __argp_base_name (arg);
-
-#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
-      program_invocation_short_name = state->name;
-#endif
-
-      if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
-         == ARGP_PARSE_ARGV0)
-        /* Update what getopt uses too.  */
-        state->argv[0] = arg;
-      break;
-
-    case OPT_HANG:
-      {
-       int hang = atoi (arg ? arg : "3600");
-       while (hang-- > 0)
-         sleep (1);
-       break;      
-      }
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-struct argp mu_mailutils_argp = {
-  mu_mailutils_argp_options,
-  mu_mailutils_argp_parser,
-};
-
-struct argp_child mu_mailutils_argp_child = {
-  &mu_mailutils_argp,
-  0,
-  NULL,
-  -1,
-};
-
-static void
-mu_mailutils_modflags(int *flags)
-{
-  *flags |= ARGP_NO_HELP;
-}
-
-struct mu_cmdline_capa mu_mailutils_cmdline = {
-  "mailutils", &mu_mailutils_argp_child, mu_mailutils_modflags
-};
-
-
-    
-
-
-  
diff --git a/libmu_argp/mu_argp.c b/libmu_argp/mu_argp.c
deleted file mode 100644
index 74b0b30..0000000
--- a/libmu_argp/mu_argp.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001-2007, 2009-2012, 2014-2016 Free Software
-   Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see 
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "mailutils/libargp.h"
-
-
-/* ************************************************************************* */
-/* Capability array and auxiliary functions.                                 */
-/* ************************************************************************* */
-
-#define MU_MAX_CAPA 24
-
-struct argp_capa {
-  char *capability;
-  struct argp_child *child;
-  void (*modflags)(int*);
-} mu_argp_capa[MU_MAX_CAPA] = {
-  {NULL,}
-};
-
-int
-mu_register_argp_capa (const char *name, struct argp_child *child,
-                      void (*modflags)(int*))
-{
-  int i;
-  
-  for (i = 0; i < MU_MAX_CAPA; i++)
-    if (mu_argp_capa[i].capability == NULL)
-      {
-        if ((mu_argp_capa[i].capability = strdup (name)) == NULL)
-          return ENOMEM;
-       mu_argp_capa[i].child = child;
-       mu_argp_capa[i].modflags = modflags;
-       return 0;
-      }
-  return 1;
-}
-
-static struct argp_capa *
-find_capa (const char *name)
-{
-  int i;
-  for (i = 0; mu_argp_capa[i].capability; i++)
-    if (strcmp (mu_argp_capa[i].capability, name) == 0)
-      return &mu_argp_capa[i];
-  return NULL;
-}
-
-static struct argp *
-mu_build_argp (const struct argp *template, char **capa, int *flags)
-{
-  int n;
-  int nchild;
-  struct argp_child *ap;
-  const struct argp_option *opt;
-  struct argp *argp;
-  int group = 0;
-
-  /* Count the capabilities. */
-  for (n = 0; capa && capa[n]; n++)
-    ;
-  if (template->children)
-    for (; template->children[n].argp; n++)
-      ;
-
-  ap = calloc (n + 1, sizeof (*ap));
-  if (!ap)
-    {
-      mu_error (_("not enough memory"));
-      abort ();
-    }
-
-  /* Copy the template's children. */
-  nchild = 0;
-  if (template->children)
-    for (n = 0; template->children[n].argp; n++, nchild++)
-      ap[nchild] = template->children[n];
-
-  /* Find next group number */
-  for (opt = template->options;
-       opt && ((opt->name && opt->key) || opt->doc); opt++)
-    if (opt->group > group)
-      group = opt->group;
-
-  group++;
-    
-  /* Append any capabilities to the children or options, as appropriate. */
-  for (n = 0; capa && capa[n]; n++)
-    {
-      struct argp_capa *cp = find_capa (capa[n]);
-      if (cp)
-       {
-         if (cp->modflags)
-           cp->modflags (flags);
-         if (cp->child)
-           {
-             ap[nchild] = *cp->child;
-             if (ap[nchild].group < 0)
-               ap[nchild].group = 0;
-             else
-               ap[nchild].group = group++;
-             nchild++;
-           }
-       }
-    }
-  ap[nchild].argp = NULL;
-
-  /* Copy the template, and give it the expanded children. */
-  argp = malloc (sizeof (*argp));
-  if (!argp)
-    {
-      mu_error (_("not enough memory"));
-      abort ();
-    }
-
-  memcpy (argp, template, sizeof (*argp));
-
-  argp->children = ap;
-
-  return argp;
-}
-
-struct cap_buf
-{
-  char **capa;
-  size_t numcapa;
-  size_t maxcapa;
-};
-
-static void
-cap_buf_init (struct cap_buf *bp)
-{
-  bp->numcapa = 0;
-  bp->maxcapa = 2;
-  bp->capa = calloc (bp->maxcapa, sizeof bp->capa[0]);
-  if (!bp->capa)
-    {
-      mu_error ("%s", mu_strerror (errno));
-      abort ();
-    }
-  bp->capa[0] = NULL;
-}
-
-static void
-cap_buf_add (struct cap_buf *bp, char *str)
-{
-  if (bp->numcapa == bp->maxcapa)
-    {
-      bp->maxcapa *= 2;
-      bp->capa = realloc (bp->capa, bp->maxcapa * sizeof bp->capa[0]);
-      if (!bp->capa)
-       {
-         mu_error ("%s", mu_strerror (errno));
-         abort ();
-       }
-    }
-  bp->capa[bp->numcapa] = str;
-  if (str)
-    bp->numcapa++;
-}
-
-static void
-cap_buf_free (struct cap_buf *bp)
-{
-  free (bp->capa);
-}
-
-static int
-argp_reg_action (void *item, void *data)
-{
-  struct cap_buf *bp = data;
-  cap_buf_add (bp, item);
-  return 0;
-}
-
-struct argp *
-mu_argp_build (const struct argp *init_argp, char ***pcapa, int *flags)
-{
-  struct cap_buf cb;
-  struct argp *argp;
-
-  cap_buf_init (&cb);
-  mu_gocs_enumerate (argp_reg_action, &cb);
-  cap_buf_add (&cb, NULL);
-  mu_libargp_init ();
-  argp = mu_build_argp (init_argp, cb.capa, flags);
-  if (pcapa)
-    *pcapa = cb.capa;
-  else
-    cap_buf_free (&cb);
-  return argp;
-}
-
-void
-mu_argp_done (struct argp *argp)
-{
-  free ((void*) argp->children);
-  free ((void*) argp);
-}
diff --git a/libmu_argp/muinit.c b/libmu_argp/muinit.c
deleted file mode 100644
index 50a4a9b..0000000
--- a/libmu_argp/muinit.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "cmdline.h"
-#include <unistd.h>
-#include <stdlib.h>
-#include <mailutils/alloc.h>
-#include <mailutils/stream.h>
-#include <mailutils/io.h>
-#include <mailutils/stdstream.h>
-#include <string.h>
-#ifdef MU_ALPHA_RELEASE
-# include <git-describe.h>
-#endif
-struct mu_cfg_tree *mu_argp_tree;
-
-const char version_etc_copyright[] =
-  /* Do *not* mark this string for translation.  %s is a copyright
-     symbol suitable for this locale, and %d is the copyright
-     year.  */
-  "Copyright %s 2007-2015 Free Software Foundation, inc.";
-
-void
-mu_program_version_hook (FILE *stream, struct argp_state *state)
-{
-#ifdef GIT_DESCRIBE
-  fprintf (stream, "%s (%s) %s [%s]\n",
-          mu_program_name, PACKAGE_NAME, PACKAGE_VERSION, GIT_DESCRIBE);
-#else
-  fprintf (stream, "%s (%s) %s\n", mu_program_name,
-          PACKAGE_NAME, PACKAGE_VERSION);
-#endif
-  /* TRANSLATORS: Translate "(C)" to the copyright symbol
-     (C-in-a-circle), if this symbol is available in the user's
-     locale.  Otherwise, do not translate "(C)"; leave it as-is.  */
-  fprintf (stream, version_etc_copyright, _("(C)"));
-
-  fputs (_("\
-\n\
-License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to 
change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law.\n\
-\n\
-"),
-        stream);
-}
-
-void
-mu_argp_init (const char *vers, const char *bugaddr)
-{
-  if (vers)
-    argp_program_version = vers;
-  else
-    argp_program_version_hook = mu_program_version_hook;
-  argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">";
-}
-
-static char *
-get_canonical_name ()
-{
-  char *name;
-  size_t len;
-  char *p;
-
-  if (!argp_program_version ||
-      !(p = strchr (argp_program_version, ' ')))
-    return strdup (mu_program_name);
-  len = p - argp_program_version;
-  name = mu_alloc (len + 1);
-  memcpy (name, argp_program_version, len);
-  name[len] = 0;
-  return name;
-}
-
-int mu_help_config_mode;
-int mu_rcfile_lint;
-
-int (*mu_app_cfg_verifier) (void) = NULL;
-
-int
-mu_app_init (struct argp *myargp, const char **capa,
-            struct mu_cfg_param *cfg_param,
-            int argc, char **argv, int flags, int *pindex, void *data)
-{
-  int rc, i;
-  struct argp *argp;
-  struct argp argpnull = { 0 };
-  char **excapa;
-  struct mu_cfg_tree *parse_tree = NULL;
-  
-  if (!mu_program_name)
-    mu_set_program_name (argv[0]);
-  if (!mu_log_tag)
-    mu_log_tag = (char*)mu_program_name;
-  mu_stdstream_setup (MU_STDSTREAM_RESET_NONE);
-  
-  mu_libargp_init ();
-  if (capa)
-    for (i = 0; capa[i]; i++)
-      mu_gocs_register_std (capa[i]); /*FIXME*/
-  if (!myargp)
-    myargp = &argpnull;
-  argp = mu_argp_build (myargp, &excapa, &flags);
-
-  mu_cfg_tree_create (&mu_argp_tree);
-  rc = argp_parse (argp, argc, argv, flags, pindex, data);
-  mu_argp_done (argp);
-  if (rc)
-    return rc;
-
-  /* Reset program name, it may have been changed using the `--program-name'
-     option. */
-  mu_set_program_name (program_invocation_name);
-  
-  mu_libcfg_init (excapa);
-  free (excapa);
-
-  if (mu_help_config_mode)
-    {
-      char *comment;
-      char *canonical_name = get_canonical_name ();
-      mu_stream_t stream;
-      struct mu_cfg_cont *cont;
-      static struct mu_cfg_param dummy_include_param[] = {
-       { "include", mu_c_string, NULL, 0, NULL,
-         N_("Include contents of the given file.  If a directory is given, "
-            "include contents of the file <file>/<program>, where "
-            "<program> is the name of the program.  This latter form is "
-            "allowed only in the site-wide configuration file."),
-         N_("file-or-directory") },
-       { NULL }
-      };
-
-      mu_stdio_stream_create (&stream, MU_STDOUT_FD, 0);
-
-      mu_asprintf (&comment,
-                  "Configuration file structure for %s utility.",
-                  mu_program_name);
-      mu_cfg_format_docstring (stream, comment, 0);
-      free (comment);
-      mu_asprintf (&comment,
-                  "For use in global configuration file (%s), enclose it "
-                  "in `program %s { ... };",
-                  mu_site_rcfile,
-                  mu_program_name);               
-      mu_cfg_format_docstring (stream, comment, 0);
-      free (comment);
-      mu_asprintf (&comment, "For more information, use `info %s'.",
-                  canonical_name);
-      mu_cfg_format_docstring (stream, comment, 0);
-      free (comment);
-
-      cont = mu_config_clone_root_container ();
-      mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL,
-                                           dummy_include_param, NULL);
-      mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL,
-                                           cfg_param, NULL);
-      mu_cfg_format_container (stream, cont);
-      mu_config_destroy_container (&cont);
-      
-      mu_stream_destroy (&stream);
-      exit (0);
-    }
-
-  rc = mu_libcfg_parse_config (&parse_tree);
-  if (rc == 0)
-    {
-      struct mu_cfg_parse_hints hints = { MU_PARSE_CONFIG_PLAIN };
-
-      hints.flags |= MU_CFG_PARSE_PROGRAM;
-      hints.program = (char*)mu_program_name;
-
-      if (mu_cfg_parser_verbose)
-       hints.flags |= MU_PARSE_CONFIG_VERBOSE;
-      if (mu_cfg_parser_verbose > 1)
-       hints.flags |= MU_PARSE_CONFIG_DUMP;
-      mu_cfg_tree_postprocess (mu_argp_tree, &hints);
-      mu_cfg_tree_union (&parse_tree, &mu_argp_tree);
-      rc = mu_cfg_tree_reduce (parse_tree, &hints, cfg_param, data);
-    }
-  
-  if (mu_rcfile_lint)
-    {
-      if (rc || mu_cfg_error_count)
-       exit (1);
-      if (mu_app_cfg_verifier)
-       rc = mu_app_cfg_verifier ();
-      exit (rc ? 1 : 0);
-    }
-  
-  mu_gocs_flush ();
-  mu_cfg_destroy_tree (&mu_argp_tree);
-  mu_cfg_destroy_tree (&parse_tree);
-
-  return !!(rc || mu_cfg_error_count);
-}
-
diff --git a/libmu_argp/sieve.c b/libmu_argp/sieve.c
deleted file mode 100644
index efed372..0000000
--- a/libmu_argp/sieve.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999-2002, 2005, 2007, 2009-2012, 2014-2016 Free
-   Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif  
-#include "cmdline.h"
-#include "mailutils/sieve.h"
-
-enum {
-  OPT_CLEAR_INCLUDE_PATH = 256,
-  OPT_CLEAR_LIBRARY_PATH,
-  OPT_PREFIX_LIBRARY_PATH
-};  
-
-static struct argp_option sieve_argp_option[] = {
-  { "includedir", 'I', N_("DIR"), 0,
-    N_("append DIR to the list of directories searched for include files"), 0 
},
-  { "libdir", 'L', N_("DIR"), 0,
-    N_("append DIR to the list of directories searched for library files"), 0 
},
-  { "libdir-prefix", OPT_PREFIX_LIBRARY_PATH, N_("DIR"), 0,
-    N_("add DIR to the beginning of the list of directories searched for "
-       "library files"), 0 },
-  { "clear-include-path", OPT_CLEAR_INCLUDE_PATH, NULL, 0,
-    N_("clear Sieve include path"), 0 },
-  { "clear-library-path", OPT_CLEAR_LIBRARY_PATH, NULL, 0,
-    N_("clear Sieve library path"), 0 },
-  { "clearpath", 0, NULL, OPTION_ALIAS, NULL },
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static error_t
-sieve_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static mu_list_t lst;
-  
-  switch (key)
-    {
-    case 'I':
-      mu_argp_node_list_new (lst, "include-path", arg);
-      break;
-
-    case 'L':
-      mu_argp_node_list_new (lst, "library-path", arg);
-      break;
-
-    case OPT_PREFIX_LIBRARY_PATH:
-      mu_argp_node_list_new (lst, "library-path-prefix", arg);
-      break;
-      
-    case OPT_CLEAR_INCLUDE_PATH:
-      mu_argp_node_list_new (lst, "clear-include-path", "yes");
-      break;
-
-    case OPT_CLEAR_LIBRARY_PATH:
-      mu_argp_node_list_new (lst, "clear-library-path", "yes");
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (lst, "sieve", NULL);
-      break;
-                          
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp sieve_argp = {
-  sieve_argp_option,
-  sieve_argp_parser,
-};
-
-static struct argp_child sieve_argp_child = {
-  &sieve_argp,
-  0,
-  N_("Sieve options"),
-  0
-};
-
-struct mu_cmdline_capa mu_sieve_cmdline = {
-  "sieve", &sieve_argp_child
-};
-
diff --git a/libmu_auth/gsasl.c b/libmu_auth/gsasl.c
index 5ffd0fe..e8c50dc 100644
--- a/libmu_auth/gsasl.c
+++ b/libmu_auth/gsasl.c
@@ -19,6 +19,7 @@
 #if HAVE_CONFIG_H
 # include <config.h>
 #endif
+#include <mailutils/cli.h>
 
 #ifdef WITH_GSASL
 
@@ -45,14 +46,28 @@ struct mu_gsasl_module_data mu_gsasl_module_data = {
   NULL,
   SITE_CRAM_MD5_PWD
 };
-
-int
-mu_gsasl_module_init (enum mu_gocs_op op, void *data)
-{
-  if (op == mu_gocs_op_set && data)
-    memcpy (&mu_gsasl_module_data, data, sizeof (mu_gsasl_module_data));
-  return 0;
-}
+
+static struct mu_cfg_param mu_gsasl_param[] = {
+  { "enable", mu_c_bool, &mu_gsasl_module_data.enable, 0, NULL,
+    N_("Enable GSASL (default)") },
+  { "cram-passwd", mu_c_string, &mu_gsasl_module_data.cram_md5_pwd, 0, NULL,
+    N_("Name of GSASL password file."),
+    N_("file") },
+  { "service", mu_c_string, &mu_gsasl_module_data.service, 0, NULL,
+    N_("SASL service name."),
+    N_("name") },
+  { "realm", mu_c_string, &mu_gsasl_module_data.realm, 0, NULL,
+    N_("SASL realm name."),
+    N_("name") },
+  { "hostname", mu_c_string, &mu_gsasl_module_data.hostname, 0, NULL,
+    N_("SASL host name."),
+    N_("name") },
+  { "anonymous-user", mu_c_string, &mu_gsasl_module_data.anon_user, 0, NULL,
+    N_("Anonymous user name."),
+    N_("name") },
+
+  { NULL }
+};
 
 int
 mu_gsasl_enabled (void)
@@ -231,4 +246,10 @@ mu_gsasl_enabled (void)
 {
   return 0;
 }
+#define mu_gsasl_param NULL
 #endif
+
+struct mu_auth_module mu_auth_gsasl_module = {
+  .name = "gsasl",
+  .cfg = mu_gsasl_param
+};
diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c
index 7c321f2..246f802 100644
--- a/libmu_auth/ldap.c
+++ b/libmu_auth/ldap.c
@@ -61,17 +61,82 @@ const char *default_field_map =
 
 static struct mu_ldap_module_config ldap_param;
 
-int
-mu_ldap_module_init (enum mu_gocs_op op, void *data)
+
+
+static int
+_cb2_field_map (const char *arg, void *data)
+{
+  int err;
+  int rc = mutil_parse_field_map (arg, &ldap_param.field_map, &err);
+  if (rc)
+    /* FIXME: this message can be misleading */
+    mu_error (_("error near element %d: %s"), err, mu_strerror (rc));
+  return 0;
+}
+
+static int
+cb_field_map (void *data, mu_config_value_t *val)
 {
-  struct mu_ldap_module_config *cfg = data;
+  return mu_cfg_string_value_cb (val, _cb2_field_map, NULL);
+}
 
-  if (op != mu_gocs_op_set)
-    return 0;
-  
-  if (cfg)
-    ldap_param = *cfg;
+static struct mu_cfg_param mu_ldap_param[] = {
+  { "enable", mu_c_bool, &ldap_param.enable, 0, NULL,
+    N_("Enable LDAP lookups.") },
+  { "url", mu_c_string, &ldap_param.url, 0, NULL,
+    N_("Set URL of the LDAP server."),
+    N_("url") },
+  { "base", mu_c_string, &ldap_param.base, 0, NULL,
+    N_("Base DN for LDAP lookups."),
+    N_("dn") },
+  { "binddn", mu_c_string, &ldap_param.binddn, 0, NULL,
+    N_("DN for accessing LDAP database."),
+    N_("dn") },
+  { "passwd", mu_c_string, &ldap_param.passwd, 0, NULL,
+    N_("Password for use with binddn.") },
+  { "tls", mu_c_bool, &ldap_param.tls, 0, NULL,
+    N_("Use TLS encryption.") },
+  { "debug", mu_c_int, &ldap_param.debug, 0, NULL,
+    N_("Set LDAP debugging level.") },
+  { "field-map", mu_cfg_callback, NULL, 0, cb_field_map,
+    N_("Set a field-map for parsing LDAP replies.  The map is a "
+       "column-separated list of definitions.  Each definition has the "
+       "following form:\n"
+       "   <name: string>=<attr: string>\n"
+       "where <name> is one of the following: name, passwd, uid, gid, "
+       "gecos, dir, shell, mailbox, quota, and <attr> is the name of "
+       "the corresponding LDAP attribute."),
+    N_("map") },
+  { "getpwnam", mu_c_string, &ldap_param.getpwnam_filter, 0, NULL,
+    N_("LDAP filter to use for getpwnam requests."),
+    N_("filter") },
+  { "getpwuid", mu_c_string, &ldap_param.getpwuid_filter, 0, NULL,
+    N_("LDAP filter to use for getpwuid requests."),
+    N_("filter") },
+  { NULL }
+};
+
+int                                                                          
+mu_ldap_section_parser
+   (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node,              
+    const char *section_label, void **section_data,
+    void *call_data, mu_cfg_tree_t *tree)
+{                                                                            
+  switch (stage)                                                             
+    {                                                                        
+    case mu_cfg_section_start:
+      ldap_param.enable = 1;
+      break;
+    default:
+      break;
+    }                                                                        
+  return 0;                                                                  
+}
 
+
+static void
+module_init (void *ptr)
+{
   if (ldap_param.enable)
     {
       if (!ldap_param.getpwnam_filter)
@@ -85,7 +150,6 @@ mu_ldap_module_init (enum mu_gocs_op op, void *data)
          mutil_parse_field_map (default_field_map, &ldap_param.field_map, &d);
        }
     }
-  return 0;
 }
 
 static int
@@ -271,8 +335,6 @@ _mu_conn_setup (LDAP **pld)
   *pld = ld;
   return 0;
 }
-  
-     
 
 static int
 _mu_ldap_bind (LDAP *ld)
@@ -862,15 +924,16 @@ mu_auth_ldap_user_by_uid (struct mu_auth_data 
**return_data,
 # define mu_ldap_authenticate mu_auth_nosupport
 # define mu_auth_ldap_user_by_name mu_auth_nosupport 
 # define mu_auth_ldap_user_by_uid mu_auth_nosupport
+
 #endif
 
 struct mu_auth_module mu_auth_ldap_module = {
-  "ldap",
-  mu_ldap_module_init,
-  mu_ldap_authenticate,
-  NULL,
-  mu_auth_ldap_user_by_name,
-  NULL,
-  mu_auth_ldap_user_by_uid,
-  NULL
+  .name = "ldap",
+  .commit = module_init,
+  .handler = {
+    [mu_auth_authenticate] = mu_ldap_authenticate,
+    [mu_auth_getpwnam]     = mu_auth_ldap_user_by_name,
+    [mu_auth_getpwuid]     = mu_auth_ldap_user_by_uid
+  },
+  .cfg = mu_ldap_param
 };
diff --git a/libmu_auth/pam.c b/libmu_auth/pam.c
index 2bf3683..fbc3e3e 100644
--- a/libmu_auth/pam.c
+++ b/libmu_auth/pam.c
@@ -49,6 +49,14 @@
 char *mu_pam_service = PACKAGE;
 
 #ifdef USE_LIBPAM
+static struct mu_cfg_param mu_pam_param[] = {
+  { "service", mu_c_string, &mu_pam_service, 0, NULL,
+    N_("Set PAM service name."),
+    N_("name") },
+  { NULL }
+};
+
+
 #define COPY_STRING(s) (s) ? strdup(s) : NULL
 
 static char *_pwd;
@@ -175,43 +183,13 @@ mu_authenticate_pam (struct mu_auth_data **return_data 
MU_ARG_UNUSED,
 }
 
 #else
-
-int
-mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED,
-                    const void *key MU_ARG_UNUSED,
-                    void *func_data MU_ARG_UNUSED,
-                    void *call_data MU_ARG_UNUSED)
-{
-  return ENOSYS;
-}
-
+# define mu_pam_param NULL
+# define mu_authenticate_pam NULL
 #endif
 
-int
-mu_pam_module_init (enum mu_gocs_op op, void *data)
-{
-  if (op == mu_gocs_op_set && data)
-    {
-      struct mu_gocs_pam *p = data;
-      if (p->service)
-        {
-          if ((mu_pam_service = strdup (p->service)) == NULL)
-            return ENOMEM;
-        }
-      else
-        mu_pam_service = NULL;
-    }
-  return 0;
-}
-
 struct mu_auth_module mu_auth_pam_module = {
-  "pam",
-  mu_pam_module_init,
-  mu_authenticate_pam,
-  NULL,
-  mu_auth_nosupport,
-  NULL,
-  mu_auth_nosupport,
-  NULL
+  .name = "pam",
+  .handler = { [mu_auth_authenticate] = mu_authenticate_pam },
+  .cfg = mu_pam_param
 };
 
diff --git a/libmu_auth/radius.c b/libmu_auth/radius.c
index f6e7e28..4d6c380 100644
--- a/libmu_auth/radius.c
+++ b/libmu_auth/radius.c
@@ -42,6 +42,9 @@
 #include <mailutils/nls.h>
 #include <mailutils/io.h>
 #include <mailutils/cctype.h>
+#include <mailutils/cli.h>
+#include <mailutils/stream.h>
+#include <mailutils/stdstream.h>
 
 #ifdef ENABLE_RADIUS
 
@@ -62,7 +65,6 @@ static grad_avp_t *auth_request;
 static grad_avp_t *getpwnam_request;
 static grad_avp_t *getpwuid_request;
 
-
 int
 get_attribute (int *pattr, char *name)
 {
@@ -84,30 +86,41 @@ enum parse_state
     state_delim
   };
 
-int
-parse_pairlist (grad_avp_t **plist, char *input)
+static int
+cb_request (void *data, mu_config_value_t *val)
 {
+  grad_avp_t **plist = data;
   size_t i;
   struct mu_wordsplit ws;
   enum parse_state state;
   grad_locus_t loc;
   char *name;
-  char *op; /* FIXME: It is actually ignored. Should it be? */
-
-  if (!input)
+  struct mu_locus locus;
+  
+  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
     return 1;
 
   ws.ws_delim = ",";
-  if (mu_wordsplit (input, &ws,
+  if (mu_wordsplit (val->v.string, &ws,
                    MU_WRDSF_DEFFLAGS|MU_WRDSF_DELIM|MU_WRDSF_RETURN_DELIMS))
     {
-      mu_error (_("cannot parse input `%s': %s"), input,
+      mu_error (_("cannot parse input `%s': %s"), val->v.string,
                mu_wordsplit_strerror (&ws));
       return 1;
     }
 
-  loc.file = "<configuration>"; /*FIXME*/
-  loc.line = 0;
+  if (mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, 
+                      MU_IOCTL_LOGSTREAM_GET_LOCUS,
+                      &locus) == 0)
+    {
+      loc.file = locus.mu_file;
+      loc.line = locus.mu_line;
+    }
+  else
+    {
+      loc.file = "<unknown>";
+      loc.line = 0;
+    }
 
   for (i = 0, state = state_lhs; i < ws.ws_wordc; i++)
     {
@@ -121,7 +134,7 @@ parse_pairlist (grad_avp_t **plist, char *input)
          break;
 
        case state_op:
-         op = ws.ws_wordv[i];
+         //op = ws.ws_wordv[i];
          state = state_rhs;
          break;
 
@@ -155,16 +168,45 @@ parse_pairlist (grad_avp_t **plist, char *input)
       return 1;
     }
 
+  return 0;  
+}
+
+static int
+cb_config_dir (void *data, mu_config_value_t *val)
+{
+  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
+    return 1;
+  grad_config_dir = grad_estrdup (val->v.string);
   return 0;
 }
 
+static struct mu_cfg_param mu_radius_param[] = {
+  { "auth", mu_cfg_callback, &auth_request, 0, cb_request,
+    N_("Radius request for authorization."),
+    N_("request: string") },
+  { "getpwnam", mu_cfg_callback, &getpwnam_request, 0, cb_request,
+    N_("Radius request for getpwnam."),
+    N_("request: string") },
+  { "getpwuid", mu_cfg_callback, &getpwuid_request, 0, cb_request,
+    N_("Radius request for getpwuid."),
+    N_("request: string") },
+  { "directory", mu_cfg_callback, NULL, 0, cb_config_dir,
+    N_("Set radius configuration directory.") },
+  { NULL }
+};
+
+struct mu_cli_capa mu_cli_capa_radius = {
+  "radius",
+  NULL,
+  mu_radius_param
+};
+
 /* Assume radius support is needed if any of the above requests is
    defined. Actually, all of them should be, but it is the responsibility
    of init to check for consistency of the configuration */
 
-#define NEED_RADIUS_P(cfg) \
-  ((cfg) && \
-   ((cfg)->auth_request || (cfg)->getpwnam_request || (cfg)->getpwuid_request))
+#define NEED_RADIUS_P() \
+  (auth_request || getpwnam_request || getpwuid_request)
 
 static void
 mu_grad_logger(int level,
@@ -196,21 +238,16 @@ mu_grad_logger(int level,
     }
   mu_diag_voutput (mlevel[level & GRAD_LOG_PRIMASK], pfx ? pfx : fmt, ap);
   if (pfx)
-    free(pfx);
+    free (pfx);
 }
 
-int
-mu_radius_module_init (enum mu_gocs_op op, void *data)
+static void
+module_init (void *ptr)
 {
-  struct mu_radius_module_data *cfg = data;
-
-  if (op != mu_gocs_op_set)
-    return 0;
-  if (!NEED_RADIUS_P (cfg))
-    return 0;
+  if (!NEED_RADIUS_P ())
+    return;
 
   grad_set_logger (mu_grad_logger);
-  grad_config_dir = grad_estrdup (cfg->config_dir);
 
   grad_path_init ();
   srand (time (NULL) + getpid ());
@@ -218,7 +255,7 @@ mu_radius_module_init (enum mu_gocs_op op, void *data)
   if (grad_dict_init ())
     {
       mu_error (_("cannot read radius dictionaries"));
-      return 1;
+      return;
     }
 
   /* Check whether mailutils attributes are defined */
@@ -229,16 +266,9 @@ mu_radius_module_init (enum mu_gocs_op op, void *data)
       || get_attribute (&MU_Dir, "MU-Dir")
       || get_attribute (&MU_Shell, "MU-Shell")
       || get_attribute (&MU_Mailbox, "MU-Mailbox"))
-    return 1;
-
-  /* Parse saved requests */
-  if (parse_pairlist (&auth_request, cfg->auth_request)
-      || parse_pairlist (&getpwnam_request, cfg->getpwnam_request)
-      || parse_pairlist (&getpwuid_request, cfg->getpwuid_request))
-    return 1;
+    return;
 
   radius_auth_enabled = 1;
-  return 0;
 }
 
 static char *
@@ -518,44 +548,19 @@ mu_auth_radius_user_by_uid (struct mu_auth_data 
**return_data,
   return rc;
 }
 
-#else
-static int
-mu_radius_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
-                       const void *key,
-                       void *func_data MU_ARG_UNUSED, void *call_data)
-{
-  return ENOSYS;
-}
-
-static int
-mu_auth_radius_user_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED,
-                            const void *key MU_ARG_UNUSED,
-                            void *func_data MU_ARG_UNUSED,
-                            void *call_data MU_ARG_UNUSED)
-{
-  return ENOSYS;
-}
-
-static int
-mu_auth_radius_user_by_uid (struct mu_auth_data **return_data,
-                           const void *key,
-                           void *func_data, void *call_data)
-{
-  return ENOSYS;
-}
-#endif
-
 struct mu_auth_module mu_auth_radius_module = {
-  "radius",
-#ifdef ENABLE_RADIUS
-  mu_radius_module_init,
+  .name = "radius",
+  .cfg  = mu_radius_param,
+  .commit = module_init,
+  .handler = {
+    [mu_auth_authenticate] = mu_radius_authenticate,
+    [mu_auth_getpwnam] = mu_auth_radius_user_by_name,
+    [mu_auth_getpwuid] = mu_auth_radius_user_by_uid
+  }
+};
 #else
-  NULL,
-#endif
-  mu_radius_authenticate,
-  NULL,
-  mu_auth_radius_user_by_name,
-  NULL,
-  mu_auth_radius_user_by_uid,
-  NULL
+struct mu_auth_module mu_auth_radius_module = {
+  .name = "radius"
 };
+#endif
+
diff --git a/libmu_auth/sql.c b/libmu_auth/sql.c
index f84d9b0..eeb3e3f 100644
--- a/libmu_auth/sql.c
+++ b/libmu_auth/sql.c
@@ -50,12 +50,97 @@
 #include <mailutils/sql.h>
 #include <mailutils/cstr.h>
 #include <mailutils/wordsplit.h>
+#include <mailutils/cli.h>
 #include "sql.h"
 
 #ifdef USE_SQL
 
-struct mu_internal_sql_config mu_sql_module_config;
+struct mu_sql_module_config mu_sql_module_config;
+/* Resource file configuration */
+static int
+cb_password_type (void *data, mu_config_value_t *val)
+{
+  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
+    return 1;
+  
+  if (mu_sql_decode_password_type (val->v.string, 
&mu_sql_module_config.password_type))
+    mu_error (_("unknown password type `%s'"), val->v.string);
+  return 0;
+}
+
+static int
+_cb2_field_map (const char *arg, void *data)
+{
+  int err;
+  int rc = mutil_parse_field_map (arg, &mu_sql_module_config.field_map, &err);
+  if (rc)
+    /* FIXME: this message may be misleading */
+    mu_error (_("error near element %d: %s"), err, mu_strerror (rc));
+  return 0;
+}
 
+static int
+cb_field_map (void *data, mu_config_value_t *val)
+{
+  return mu_cfg_string_value_cb (val, _cb2_field_map, NULL);
+}
+
+static int
+cb_interface (void *data, mu_config_value_t *val)
+{
+  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
+    return 1;
+  mu_sql_module_config.interface = mu_sql_interface_index (val->v.string);
+  if (mu_sql_module_config.interface == 0)
+    {
+      mu_error (_("unknown SQL interface `%s'"), val->v.string);
+      return 1;
+    }
+  return 0;
+}
+  
+static struct mu_cfg_param mu_sql_param[] = {
+  { "interface", mu_cfg_callback, &mu_sql_module_config.interface, 0,
+    cb_interface,
+    N_("Set SQL interface to use."),
+    N_("iface: mysql|odbc|postgres") },
+  { "getpwnam", mu_c_string, &mu_sql_module_config.getpwnam_query, 0, NULL,
+    N_("SQL query to use for getpwnam requests."),
+    N_("query") },
+  { "getpwuid", mu_c_string, &mu_sql_module_config.getpwuid_query, 0, NULL,
+    N_("SQL query to use for getpwuid requests."),
+    N_("query") },
+  { "getpass", mu_c_string, &mu_sql_module_config.getpass_query, 0, NULL,
+    N_("SQL query returning the user's password."),
+    N_("query") },
+  { "host", mu_c_string, &mu_sql_module_config.host, 0, NULL,
+    N_("SQL server host name.") },
+  { "user", mu_c_string, &mu_sql_module_config.user, 0, NULL,
+    N_("SQL user name.") },
+  { "passwd", mu_c_string, &mu_sql_module_config.passwd, 0, NULL,
+    N_("Password for the SQL user.") },
+  { "port", mu_c_int, &mu_sql_module_config.port, 0, NULL,
+    N_("SQL server port.") },
+  { "db", mu_c_string, &mu_sql_module_config.db, 0, NULL,
+    N_("Database name.") },
+  { "password-type", mu_cfg_callback, NULL, 0, cb_password_type,
+    N_("Type of password returned by getpass query (one of: plain, hash, "
+       "scrambled).") },
+  { "positional", mu_c_bool, &mu_sql_module_config.positional, 0, NULL,
+    N_("Use positional (v1.0 compatible) field interface.") },
+  { "field-map", mu_cfg_callback, NULL, 0, cb_field_map,
+    N_("Set a field-map for parsing SQL replies.  The map is a "
+       "column-separated list of definitions.  Each definition has the "
+       "following form:\n"
+       "   <name: string>=<column: string>\n"
+       "where <name> is one of the following: name, passwd, uid, gid, "
+       "gecos, dir, shell, mailbox, quota, and <column> is the name of "
+       "the corresponding SQL column."),
+    N_("map") },
+  { NULL }
+};
+
+
 static char *
 sql_escape_string (const char *ustr)
 {
@@ -668,55 +753,22 @@ mu_sql_authenticate (struct mu_auth_data **return_data 
MU_ARG_UNUSED,
   return rc == 0 ? 0 : MU_ERR_AUTH_FAILURE;
 }
 
-int
-mu_sql_module_init (enum mu_gocs_op op, void *data)
-{
-  struct mu_sql_module_config *cfg = data;
-
-  if (op != mu_gocs_op_set)
-    return 0;
-  mu_sql_module_config.interface = mu_sql_interface_index (cfg->interface);
-  if (mu_sql_module_config.interface == 0)
-    {
-      mu_error (_("unknown SQL interface `%s'"), cfg->interface);
-      return 1;
-    }
-
-  mu_sql_module_config.getpwnam_query = cfg->getpwnam_query;   
-  mu_sql_module_config.getpass_query  = cfg->getpass_query;    
-  mu_sql_module_config.getpwuid_query = cfg->getpwuid_query;   
-  mu_sql_module_config.host = cfg->host;             
-  mu_sql_module_config.user = cfg->user;             
-  mu_sql_module_config.passwd = cfg->passwd;           
-  mu_sql_module_config.db = cfg->db;               
-  mu_sql_module_config.port = cfg->port;             
-  mu_sql_module_config.password_type = cfg->password_type;    
-  mu_sql_module_config.field_map = cfg->field_map;        
-
-  return 0;
-}
-
 #else
 
 # define mu_sql_authenticate mu_auth_nosupport
 # define mu_auth_sql_by_name mu_auth_nosupport
 # define mu_auth_sql_by_uid mu_auth_nosupport
-
+# define mu_sql_param NULL
 #endif
 
 
 struct mu_auth_module mu_auth_sql_module = {
-  "sql",
-#ifdef USE_SQL
-  mu_sql_module_init,
-#else
-  NULL,
-#endif
-  mu_sql_authenticate,
-  NULL,
-  mu_auth_sql_by_name,
-  NULL,
-  mu_auth_sql_by_uid,
-  NULL
+  .name = "sql",
+  .cfg = mu_sql_param,
+  .handler = {
+    [mu_auth_authenticate] = mu_sql_authenticate,
+    [mu_auth_getpwnam]     = mu_auth_sql_by_name,
+    [mu_auth_getpwuid]     = mu_auth_sql_by_uid
+  }
 };
 
diff --git a/libmu_auth/tls.c b/libmu_auth/tls.c
index 89e3b52..656ff2c 100644
--- a/libmu_auth/tls.c
+++ b/libmu_auth/tls.c
@@ -64,22 +64,6 @@ struct mu_tls_module_config mu_tls_module_config = {
   0
 #endif
 };
-//FIXME: REMOVE  
-int
-mu_tls_module_init (enum mu_gocs_op op, void *data)
-{
-  switch (op)
-    {
-    case mu_gocs_op_set:
-      if (data)
-       memcpy (&mu_tls_module_config, data, sizeof mu_tls_module_config);
-      break;
-      
-    case mu_gocs_op_flush:
-      break;
-    }
-  return 0;
-}
 
 #ifdef WITH_TLS
 
@@ -870,16 +854,14 @@ static struct mu_cfg_param mu_tls_param[] = {
   { NULL }
 }; 
 
-struct mu_cli_capa mu_cli_capa_tls = {
-  "tls",
-  NULL,
-  mu_tls_param,
-  NULL, NULL
+struct mu_auth_module mu_auth_tls_module = {
+  .name = "tls",
+  .cfg = mu_tls_param
 };
+
 #else
-struct mu_cli_capa mu_cli_capa_tls = {
-  "tls",
-  NULL
+struct mu_auth_module mu_auth_tls_module = {
+  .name = "tls"
 };
 #endif /* WITH_TLS */
 
diff --git a/libmu_auth/virtual.c b/libmu_auth/virtual.c
index b97a96b..171b893 100644
--- a/libmu_auth/virtual.c
+++ b/libmu_auth/virtual.c
@@ -53,22 +53,20 @@
 #include <mailutils/nls.h>
 #include <mailutils/errno.h>
 #include <mailutils/util.h>
+#include <mailutils/cli.h>
 
 #ifdef ENABLE_VIRTUAL_DOMAINS
 
-struct mu_gocs_virtual mu_virtual_module_config = { SITE_VIRTUAL_PWDDIR };
-
-int
-mu_virtual_module_init (enum mu_gocs_op op, void *data)
-{
-  if (op == mu_gocs_op_set && data)
-    {
-      struct mu_gocs_virtual *p = data;
-      mu_virtual_module_config = *p;
-    }
-  return 0;
-}
+static char *pwddir = { SITE_VIRTUAL_PWDDIR };
 
+static struct mu_cfg_param mu_virtdomain_param[] = {
+  { "passwd-dir", mu_c_string, &pwddir, 0, NULL,
+    N_("Name of the directory where virtual domain password files are "
+       "located."),
+    N_("dir") },
+  { NULL }
+};
+
 #if !HAVE_FGETPWENT
 /* FIXME: A temporary solution. Need proper declaration in .h */
 extern struct passwd *mu_fgetpwent (FILE *fp);
@@ -90,7 +88,7 @@ getpwnam_virtual (const char *u)
   if (delim == 0)
     return NULL;
 
-  filename = mu_make_file_name (mu_virtual_module_config.pwddir, &u[delim + 
1]);
+  filename = mu_make_file_name (pwddir, &u[delim + 1]);
   if (filename == NULL)
     return NULL;
 
@@ -191,28 +189,15 @@ mu_auth_virt_domain_by_name (struct mu_auth_data 
**return_data,
 }
 
 #else
-static int
-mu_auth_virt_domain_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED,
-                            const void *key MU_ARG_UNUSED,
-                            void *func_data MU_ARG_UNUSED,
-                            void *call_data MU_ARG_UNUSED)
-{
-  return ENOSYS;
-}
+# define mu_virtdomain_param NULL
+# define mu_auth_virt_domain_by_name NULL
 #endif
 
 struct mu_auth_module mu_auth_virtual_module = {
-  "virtdomain",
-#ifdef ENABLE_VIRTUAL_DOMAINS
-  mu_virtual_module_init,
-#else
-  NULL,
-#endif
-  mu_auth_nosupport,
-  NULL,
-  mu_auth_virt_domain_by_name,
-  NULL,
-  mu_auth_nosupport,
-  NULL
+  .name = "virtdomain",
+  .cfg = mu_virtdomain_param,
+  .handler = {
+    [mu_auth_getpwnam] = mu_auth_virt_domain_by_name,
+  }
 };
     
diff --git a/libmu_cfg/.gitignore b/libmu_cfg/.gitignore
deleted file mode 100644
index 2248e8c..0000000
--- a/libmu_cfg/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-.gdbinit
diff --git a/libmu_cfg/Makefile.am b/libmu_cfg/Makefile.am
deleted file mode 100644
index 800cf37..0000000
--- a/libmu_cfg/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-# This file is part of GNU Mailutils
-# Copyright (C) 2007, 2009-2012, 2014-2016 Free Software Foundation,
-# Inc.
-#
-# GNU Mailutils is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3, or (at
-# your option) any later version.
-#
-# GNU Mailutils is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-AM_CPPFLAGS = \
- @address@hidden
- -DSITE_VIRTUAL_PWDDIR=\"@address@hidden" \
- -DSITE_CRAM_MD5_PWD=\"@address@hidden"
-
-lib_LTLIBRARIES = libmu_cfg.la
-libmu_cfg_la_SOURCES=\
- acl.c\
- auth.c\
- common.c\
- init.c\
- gsasl.c\
- ldap.c\
- pam.c\
- radius.c\
- sieve.c\
- sql.c\
- tls.c\
- virtdomain.c
-
-libmu_cfg_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
diff --git a/libmu_cfg/acl.c b/libmu_cfg/acl.c
deleted file mode 100644
index b4bfded..0000000
--- a/libmu_cfg/acl.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "mailutils/libcfg.h"
-#include "mailutils/acl.h"
-#include "mailutils/argcv.h"
-#include "mailutils/cidr.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#define ISSPACE(c) ((c)==' '||(c)=='\t')
-
-#define SKIPWS(p) while (*(p) && ISSPACE (*(p))) (p)++;
-
-static const char *
-getword (mu_config_value_t *val, int *pn)
-{
-  int n = (*pn)++;
-  mu_config_value_t *v;
-
-  if (n >= val->v.arg.c)
-    {
-      mu_error (_("not enough arguments"));
-      return NULL;
-    }
-  v = &val->v.arg.v[n];
-  if (mu_cfg_assert_value_type (v, MU_CFG_STRING))
-    return NULL;
-  return v->v.string;
-}
-
-static int
-parsearg (mu_config_value_t *val, struct mu_cidr *cidr, char **prest) 
-{
-  const char *w;
-  int n = 0;
-  int rc;
-  
-  if (mu_cfg_assert_value_type (val, MU_CFG_ARRAY))
-    return 1;
-  
-  w = getword (val, &n);
-  if (!w)
-    return 1;
-  if (strcmp (w, "from") == 0) {
-    w = getword (val, &n);
-    if (!w)
-      return 1;
-  }
-
-  if (strcmp (w, "any") == 0)
-    cidr->len = 0;
-  else
-    {
-      rc = mu_cidr_from_string (cidr, w);
-      if (rc)
-       {
-         mu_error (_("invalid source CIDR: %s"), mu_strerror (rc));
-         return 1;
-       }
-    }
-  
-  if (prest)
-    {
-      if (n == val->v.arg.c)
-       *prest = NULL;
-      else
-       {
-         size_t size = 0;
-         int i;
-         char *buf;
-         
-         for (i = n; i < val->v.arg.c; i++)
-           {
-             if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING))
-               return 1;
-             size += strlen (val->v.arg.v[i].v.string) + 1;
-           }
-
-         buf = malloc (size);
-         if (!buf)
-           {
-             mu_error ("%s", mu_strerror (errno));
-             return 1;
-           }       
-
-         *prest = buf;
-         for (i = n; i < val->v.arg.c; i++)
-           {
-             if (i > n)
-               *buf++ = ' ';
-             strcpy (buf, val->v.arg.v[i].v.string);
-             buf += strlen (buf);
-           }
-         *buf = 0;
-       }
-    }
-  else if (n != val->v.arg.c)
-    {
-      mu_error (_("junk after IP address"));
-      return 1;
-    }
-  return 0;
-}
-
-static int
-cb_allow (void *data, mu_config_value_t *val)
-{
-  int rc;
-  mu_acl_t acl = *(mu_acl_t*)data;
-  struct mu_cidr cidr;
-  
-  if (parsearg (val, &cidr, NULL))
-    return 1;
-  rc = mu_acl_append (acl, mu_acl_accept, NULL, &cidr);
-  if (rc)
-    mu_error (_("cannot append acl entry: %s"), mu_strerror (rc));
-  return rc;
-}
-
-static int
-cb_deny (void *data, mu_config_value_t *val)
-{
-  int rc;
-  mu_acl_t acl = *(mu_acl_t*)data;
-  struct mu_cidr cidr;
-  
-  if (parsearg (val, &cidr, NULL))
-    return 1;
-  rc = mu_acl_append (acl, mu_acl_deny, NULL, &cidr);
-  if (rc)
-    mu_error (_("cannot append acl entry: %s"), mu_strerror (rc));
-  return rc;
-}
-
-static int
-cb_log (void *data, mu_config_value_t *val)
-{
-  int rc;
-  mu_acl_t acl = *(mu_acl_t*)data;
-  struct mu_cidr cidr;
-  char *rest;
-  
-  if (parsearg (val, &cidr, &rest))
-    return 1;
-  rc = mu_acl_append (acl, mu_acl_log, rest, &cidr);
-  if (rc)
-    mu_error (_("cannot append acl entry: %s"), mu_strerror (rc));
-  return rc;
-}
-
-static int
-cb_exec (void *data, mu_config_value_t *val)
-{
-  int rc;
-  mu_acl_t acl = *(mu_acl_t*)data;
-  struct mu_cidr cidr;
-  char *rest;
-  
-  if (parsearg (val, &cidr, &rest))
-    return 1;
-  rc = mu_acl_append (acl, mu_acl_exec, rest, &cidr);
-  if (rc)
-    mu_error (_("cannot append acl entry: %s"), mu_strerror (rc));
-  return rc;
-}
-
-static int
-cb_ifexec (void *data, mu_config_value_t *val)
-{
-  int rc;
-  mu_acl_t acl = *(mu_acl_t*)data;
-  struct mu_cidr cidr;
-  char *rest;
-  
-  if (parsearg (val, &cidr, &rest))
-    return 1;
-  rc = mu_acl_append (acl, mu_acl_ifexec, rest, &cidr);
-  if (rc)
-    mu_error (_("cannot append acl entry: %s"), mu_strerror (rc));
-  return rc;
-}
-
-static struct mu_cfg_param acl_param[] = {
-  { "allow", mu_cfg_callback, NULL, 0, cb_allow,
-    N_("Allow connections from this IP address. Optional word `from' is "
-       "allowed between it and its argument. The same holds true for other "
-       "actions below."),
-    N_("addr: IP") },
-  { "deny", mu_cfg_callback, NULL, 0, cb_deny,
-    N_("Deny connections from this IP address."),
-    N_("addr: IP") },
-  { "log", mu_cfg_callback, NULL, 0, cb_log,
-    N_("Log connections from this IP address."),
-    N_("addr: IP") },
-  { "exec", mu_cfg_callback, NULL, 0, cb_exec,
-    N_("Execute supplied program if a connection from this IP address is "
-       "requested. Arguments are:\n"
-       "  <addr: IP> <program: string>\n"
-       "Following macros are expanded in <program> before executing:\n"
-       "  address  -  Source IP address\n"
-       "  port     -  Source port number\n") },
-  { "ifexec", mu_cfg_callback, NULL, 0, cb_ifexec,
-    N_("If a connection from this IP address is requested, execute supplied "
-       "program and allow or deny the connection depending on its exit code. "
-       "See `exec' for a description of its arguments.") },
-  { NULL }
-};
-
-static int
-acl_section_parser (enum mu_cfg_section_stage stage,
-                   const mu_cfg_node_t *node,
-                   const char *section_label, void **section_data,
-                   void *call_data,
-                   mu_cfg_tree_t *tree)
-{
-  switch (stage)
-    {
-    case mu_cfg_section_start:
-      {
-       void *data = *section_data;
-       mu_acl_create ((mu_acl_t*)data);
-      }
-      break;
-      
-    case mu_cfg_section_end:
-      break;
-    }
-  return 0;
-}
-
-void
-mu_acl_cfg_init ()
-{
-  struct mu_cfg_section *section;
-  if (mu_create_canned_section ("acl", &section) == 0)
-    {
-      section->parser = acl_section_parser;
-      mu_cfg_section_add_params (section, acl_param);
-    }
-}
diff --git a/libmu_cfg/auth.c b/libmu_cfg/auth.c
deleted file mode 100644
index 98aa772..0000000
--- a/libmu_cfg/auth.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2008, 2010-2012, 2014-2016 Free Software
-   Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "mailutils/libcfg.h"
-#include <mailutils/mu_auth.h>
-#include <string.h>
-
-/* FIXME: mu_auth.c should be reviewed */
-
-
-/* ************************************************************************* */
-/* Resource-style configuration                                              */
-/* ************************************************************************* */
-static int
-cb_authentication (void *data, mu_config_value_t *val)
-{
-  if (val->type == MU_CFG_STRING)
-    {
-      if (strcmp (val->v.string, "clear") == 0)
-       mu_authentication_clear_list ();
-      else
-       /*FIXME: use err for error reporting*/
-       mu_authentication_add_module_list (val->v.string);
-    }
-  else if (val->type == MU_CFG_LIST)
-    {
-      int i;
-      for (i = 0; i < val->v.arg.c; i++)
-       {
-         if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING))
-           return 1;
-         if (strcmp (val->v.arg.v[i].v.string, "clear") == 0)
-           mu_authentication_clear_list ();
-         else
-           mu_authentication_add_module (val->v.arg.v[i].v.string);
-       }
-    }
-  else
-    {
-      mu_error (_("expected string value"));
-      return 1;
-    }
-  return 0;
-}
-
-static int
-cb_authorization (void *data, mu_config_value_t *val)
-{
-  if (val->type == MU_CFG_STRING)
-    {
-      if (strcmp (val->v.string, "clear") == 0)
-       mu_authorization_clear_list ();
-      else
-       /*FIXME: use err for error reporting*/
-       mu_authorization_add_module_list (val->v.string);
-    }
-  else if (val->type == MU_CFG_LIST)
-    {
-      int i;
-      for (i = 0; i < val->v.arg.c; i++)
-       {
-         if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING))
-           return 1;
-         if (strcmp (val->v.arg.v[i].v.string, "clear") == 0)
-           mu_authorization_clear_list ();
-         else
-           mu_authorization_add_module (val->v.arg.v[i].v.string);
-       }
-    }
-  else
-    {
-      mu_error (_("expected string value"));
-      return 1;
-    }
-  return 0;
-}
-
-static struct mu_cfg_param mu_auth_param[] = {
-  { "authentication", mu_cfg_callback, NULL, 0, cb_authentication,
-    /* FIXME: The description is incomplete. MU-list is also allowed as
-       argument */
-    N_("Set a list of modules for authentication. Modlist is a "
-       "colon-separated list of module names or a word `clear' to "
-       "clear the previously set up values."),
-    N_("modlist") },
-  { "authorization", mu_cfg_callback, NULL, 0, cb_authorization,
-    N_("Set a list of modules for authorization. Modlist is a "
-       "colon-separated list of module names or a word `clear' to "
-       "clear the previously set up values."),
-    N_("modlist") },
-  { NULL }
-};
-
-int
-mu_auth_section_parser
-   (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node,
-    const char *section_label, void **section_data, void *call_data,
-    mu_cfg_tree_t *tree)
-{
-  switch (stage)
-    {
-    case mu_cfg_section_start:
-      break;
-
-    case mu_cfg_section_end:
-      mu_auth_finish_setup ();
-    }
-  return 0;
-}
-
-struct mu_cfg_capa mu_auth_cfg_capa = {
-  "auth",  mu_auth_param, mu_auth_section_parser
-};
diff --git a/libmu_cfg/common.c b/libmu_cfg/common.c
deleted file mode 100644
index 1684b7f..0000000
--- a/libmu_cfg/common.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include "mailutils/libcfg.h"
-#include <mailutils/debug.h>
-#include <mailutils/syslog.h>
-#include <mailutils/mailbox.h>
-#include <mailutils/io.h>
-#include <mailutils/stream.h>
-#include <mailutils/stdstream.h>
-
-static struct mu_gocs_locking locking_settings;
-static struct mu_gocs_mailbox mailbox_settings;
-static struct mu_gocs_source_email address_settings;
-static struct mu_gocs_mailer mailer_settings;
-static struct mu_gocs_debug debug_settings;
-
-
-/* ************************************************************************* */
-/* Mailbox                                                                   */
-/* ************************************************************************* */
-
-static int
-_cb_folder (void *data, mu_config_value_t *val)
-{
-  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
-    return 1;
-  mu_set_folder_directory (val->v.string);
-  return 0;
-}
-
-static struct mu_cfg_param mu_mailbox_param[] = {
-  { "mail-spool", mu_c_string, &mailbox_settings.mail_spool, 0, NULL,
-    N_("Use specified URL as a mailspool directory."),
-    N_("url") },
-  { "mailbox-pattern", mu_c_string, &mailbox_settings.mailbox_pattern,
-    0, NULL,
-    N_("Create mailbox URL using <pattern>."),
-    N_("pattern") },
-  { "mailbox-type", mu_c_string, &mailbox_settings.mailbox_type, 0, NULL,
-    N_("Default mailbox type."), N_("protocol") },
-  { "folder", mu_cfg_callback, NULL, 0, _cb_folder,
-    N_("Default user mail folder"),
-    N_("dir") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (mailbox);
-
-
-/* ************************************************************************* */
-/* Locking                                                                   */
-/* ************************************************************************* */
-
-static struct mu_cfg_param mu_locking_param[] = {
-  /* FIXME: Flags are superfluous. */
-  { "flags", mu_c_string, &locking_settings.lock_flags, 0, NULL,
-    N_("Default locker flags (E=external, R=retry, T=time, P=pid).") },
-  { "retry-timeout", mu_c_ulong, &locking_settings.lock_retry_timeout,
-    0, NULL,
-    N_("Set timeout for acquiring the lock.") },
-  { "retry-count", mu_c_ulong, &locking_settings.lock_retry_count, 0, NULL,
-    N_("Set the maximum number of times to retry acquiring the lock.") },
-  { "expire-timeout", mu_c_ulong, &locking_settings.lock_expire_timeout,
-    0, NULL,
-    N_("Expire locks older than this amount of time.") },
-  { "external-locker", mu_c_string, &locking_settings.external_locker, 
-    0, NULL,
-    N_("Use external locker program."),
-    N_("prog") },
-  { NULL, }
-};
-
-DCL_CFG_CAPA (locking);
-
-
-/* ************************************************************************* */
-/* Address                                                                   */
-/* ************************************************************************* */
-     
-static struct mu_cfg_param mu_address_param[] = {
-  { "email-addr", mu_c_string, &address_settings.address, 0, NULL,
-    N_("Set the current user email address (default is "
-       "address@hidden)."),
-    N_("email") },
-  { "email-domain", mu_c_string, &address_settings.domain, 0, NULL,
-    N_("Set e-mail domain for unqualified user names (default is this host)"),
-    N_("domain") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (address);
-
-     
-/* ************************************************************************* */
-/* Mailer                                                                    */
-/* ************************************************************************* */
-     
-static struct mu_cfg_param mu_mailer_param[] = {
-  { "url", mu_c_string, &mailer_settings.mailer, 0, NULL,
-    N_("Use this URL as the default mailer"),
-    N_("url") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (mailer);
-
-
-/* ************************************************************************* */
-/* Logging                                                                   */
-/* ************************************************************************* */
-
-static int
-cb_facility (void *data, mu_config_value_t *val)
-{
-  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
-    return 1;
-  
-  if (mu_string_to_syslog_facility (val->v.string, &mu_log_facility))
-    {
-      mu_error (_("unknown syslog facility `%s'"), val->v.string);
-      return 1;
-    }
-   return 0;
-}
-
-static int
-cb_severity (void *data, mu_config_value_t *val)
-{
-  unsigned n;
-  
-  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
-    return 1;
-  if (mu_severity_from_string (val->v.string, &n))
-    {
-      mu_error (_("unknown severity `%s'"), val->v.string);
-      return 1;
-    }
-  mu_log_severity_threshold = n;
-  return 0;
-}      
-
-static struct mu_cfg_param mu_logging_param[] = {
-  { "syslog", mu_c_bool, &mu_log_syslog, 0, NULL,
-    N_("Send diagnostics to syslog.") },
-  { "print-severity", mu_c_bool, &mu_log_print_severity, 0, NULL,
-    N_("Print message severity levels.") },
-  { "severity", mu_cfg_callback, NULL, 0, cb_severity,
-    N_("Output only messages with a severity equal to or greater than "
-       "this one.") },
-  { "facility", mu_cfg_callback, NULL, 0, cb_facility,
-    N_("Set syslog facility. Arg is one of the following: user, daemon, "
-       "auth, authpriv, mail, cron, local0 through local7 (case-insensitive), "
-       "or a facility number.") },
-  { "session-id", mu_c_bool, &mu_log_session_id, 0, NULL,
-    N_("Log session ID") },
-  { "tag", mu_c_string, &mu_log_tag, 0, NULL,
-    N_("Tag syslog messages with this string.") },
-  { NULL }
-};
-
-static int logging_settings; /* Dummy variable */
-DCL_CFG_CAPA (logging);
-
-
-/* ************************************************************************* */
-/* Debug                                                                     */
-/* ************************************************************************* */
-
-static int
-_cb2_debug_level (const char *arg, void *data MU_ARG_UNUSED)
-{
-  mu_debug_parse_spec (arg);
-  return 0;
-}
-
-static int
-cb_debug_level (void *data, mu_config_value_t *val)
-{
-  return mu_cfg_string_value_cb (val, _cb2_debug_level, NULL);
-}
-
-static struct mu_cfg_param mu_debug_param[] = {
-  { "level", mu_cfg_callback, NULL, 0, &cb_debug_level,
-    N_("Set Mailutils debugging level.  Argument is a colon-separated list "
-       "of debugging specifications in the form:\n"
-       "   <object: string>[[:]=<level: number>].") },
-  { "line-info", mu_c_bool, &debug_settings.line_info, 0, NULL,
-    N_("Prefix debug messages with Mailutils source locations.") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (debug);
-
diff --git a/libmu_cfg/gsasl.c b/libmu_cfg/gsasl.c
deleted file mode 100644
index 539f8b9..0000000
--- a/libmu_cfg/gsasl.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation,
-   Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-#include <mailutils/gsasl.h>
-
-static struct mu_gsasl_module_data gsasl_settings;
-
-static struct mu_cfg_param mu_gsasl_param[] = {
-  { "enable", mu_c_bool, &gsasl_settings.enable, 0, NULL,
-    N_("Enable GSASL (default)") },
-  { "cram-passwd", mu_c_string, &gsasl_settings.cram_md5_pwd, 0, NULL,
-    N_("Name of GSASL password file."),
-    N_("file") },
-  { "service", mu_c_string, &gsasl_settings.service, 0, NULL,
-    N_("SASL service name."),
-    N_("name") },
-  { "realm", mu_c_string, &gsasl_settings.realm, 0, NULL,
-    N_("SASL realm name."),
-    N_("name") },
-  { "hostname", mu_c_string, &gsasl_settings.hostname, 0, NULL,
-    N_("SASL host name."),
-    N_("name") },
-  { "anonymous-user", mu_c_string, &gsasl_settings.anon_user, 0, NULL,
-    N_("Anonymous user name."),
-    N_("name") },
-
-  { NULL }
-};
-
-DCL_CFG_CAPA (gsasl);
-     
-     
diff --git a/libmu_cfg/init.c b/libmu_cfg/init.c
deleted file mode 100644
index 5d28567..0000000
--- a/libmu_cfg/init.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
-#include "mailutils/libcfg.h"
-#include <string.h>
-#include <stdlib.h>
-
-#define CFG_CAPA_MAX 512
-static struct mu_cfg_capa *cfg_capa_table[CFG_CAPA_MAX] = {
-#define S(c) &__mu_common_cat3__(mu_,c,_cfg_capa)
-  S (auth),
-  S (mailbox),
-  S (locking),
-  S (address),
-  S (mailer),
-  S (logging),
-  S (gsasl),
-  S (pam),
-  S (radius),
-  S (sql),
-  S (tls),
-  S (virtdomain),
-  S (sieve),
-  S (ldap),
-  S (debug),
-  NULL
-};
-
-static int cfg_capa_index = MU_ARRAY_SIZE(cfg_capa_table) - 1;
-
-static struct mu_cfg_capa *
-find_cfg_capa (const char *name)
-{
-  int i;
-
-  for (i = 0; cfg_capa_table[i]; i++)
-    if (strcmp (cfg_capa_table[i]->name, name) == 0)
-      return cfg_capa_table[i];
-  return NULL;
-}
-
-static int
-reserved_name (const char *name)
-{
-  static char *reserved[] = { "common", NULL };
-  char **p;
-
-  if (name[0] == '.')
-    return 1;
-  
-  for (p = reserved; *p; p++)
-    if (strcmp (name, *p) == 0)
-      return 1;
-  return 0;
-}
-
-int
-mu_libcfg_register_capa (struct mu_cfg_capa *capa)
-{
-  if (cfg_capa_index == CFG_CAPA_MAX)
-    return MU_ERR_NOENT;
-  cfg_capa_table[cfg_capa_index++] = capa;
-  return 0;
-}
-
-void
-mu_libcfg_init (char **cnames)
-{
-  int i;
-  for (i = 0; cnames[i]; i++)
-    {
-      if (!reserved_name (cnames[i]))
-       {
-         struct mu_cfg_capa *cp = find_cfg_capa (cnames[i]);
-         if (cp)
-           mu_config_root_register_section (NULL, cp->name, NULL,
-                                            cp->parser, cp->cfgparam);
-#if 0
-         else
-           mu_error (_("unknown configuration group requested `%s'"),
-                     cnames[i]);
-#endif
-       }
-    }
-}
-
-int
-mu_libcfg_parse_config (mu_cfg_tree_t **ptree)
-{
-  struct mu_cfg_parse_hints hints;
-
-  memset (&hints, 0, sizeof (hints));
-  
-  if (mu_cfg_parser_verbose)
-    hints.flags |= MU_PARSE_CONFIG_VERBOSE;
-  if (mu_cfg_parser_verbose > 1)
-    hints.flags |= MU_PARSE_CONFIG_DUMP;
-  
-  if (mu_load_site_rcfile)
-    {
-      hints.flags |= MU_CFG_PARSE_SITE_RCFILE;
-      hints.site_rcfile = mu_site_rcfile;
-    }
-  
-  if (mu_load_user_rcfile && mu_program_name)
-    {
-      hints.flags |= MU_CFG_PARSE_PROGRAM;
-      hints.program = (char*) mu_program_name;
-    }
-  
-  if (mu_load_rcfile)
-    {
-      hints.flags |= MU_CFG_PARSE_CUSTOM_RCFILE;
-      hints.custom_rcfile = mu_load_rcfile;
-    }
-
-  return mu_cfg_parse_config (ptree, &hints);
-}
-
-
-
-/* FIXME: Deprecated */
-int
-mu_parse_config_files (struct mu_cfg_param *param, void *target)
-{
-  int flags = 0;
-  int rc;
-  
-  if (mu_cfg_parser_verbose)
-    flags |= MU_PARSE_CONFIG_VERBOSE;
-  if (mu_cfg_parser_verbose > 1)
-    flags |= MU_PARSE_CONFIG_DUMP;
-  
-  if (mu_load_site_rcfile)
-    {
-      rc = mu_parse_config (mu_site_rcfile, mu_program_name, param,
-                           flags | MU_PARSE_CONFIG_GLOBAL, target);
-      if (rc == ENOMEM)
-       {
-         mu_error ("%s", mu_strerror (rc));
-         return rc;
-       }
-    }
-
-  if (mu_load_user_rcfile && mu_program_name)
-    {
-      size_t size = 3 + strlen (mu_program_name) + 1;
-      char *file_name = malloc (size);
-      if (file_name)
-       {
-         strcpy (file_name, "~/.");
-         strcat (file_name, mu_program_name);
-
-         rc = mu_parse_config (file_name, mu_program_name, param, flags,
-                               target);
-         if (rc == ENOMEM)
-           {
-             mu_error ("%s", mu_strerror (rc));
-             return rc;
-           }
-
-         free (file_name);
-       }
-    }
-
-  if (mu_load_rcfile)
-    {
-      rc = mu_parse_config (mu_load_rcfile, mu_program_name, param,
-                           flags, target);
-      if (rc)
-       {
-         mu_error (_("errors parsing file %s: %s"), mu_load_rcfile,
-                   mu_strerror (rc));
-         return rc;
-       }
-    }
-       
-  return 0;
-}
diff --git a/libmu_cfg/ldap.c b/libmu_cfg/ldap.c
deleted file mode 100644
index ec47165..0000000
--- a/libmu_cfg/ldap.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-#include "mailutils/util.h"
-#include "mailutils/ldap.h"
-
-static struct mu_ldap_module_config ldap_settings;
-
-static int
-_cb2_field_map (const char *arg, void *data)
-{
-  int err;
-  int rc = mutil_parse_field_map (arg, &ldap_settings.field_map, &err);
-  if (rc)
-    /* FIXME: this message can be misleading */
-    mu_error (_("error near element %d: %s"), err, mu_strerror (rc));
-  return 0;
-}
-
-static int
-cb_field_map (void *data, mu_config_value_t *val)
-{
-  return mu_cfg_string_value_cb (val, _cb2_field_map, NULL);
-}
-
-static struct mu_cfg_param mu_ldap_param[] = {
-  { "enable", mu_c_bool, &ldap_settings.enable, 0, NULL,
-    N_("Enable LDAP lookups.") },
-  { "url", mu_c_string, &ldap_settings.url, 0, NULL,
-    N_("Set URL of the LDAP server."),
-    N_("url") },
-  { "base", mu_c_string, &ldap_settings.base, 0, NULL,
-    N_("Base DN for LDAP lookups."),
-    N_("dn") },
-  { "binddn", mu_c_string, &ldap_settings.binddn, 0, NULL,
-    N_("DN for accessing LDAP database."),
-    N_("dn") },
-  { "passwd", mu_c_string, &ldap_settings.passwd, 0, NULL,
-    N_("Password for use with binddn.") },
-  { "tls", mu_c_bool, &ldap_settings.tls, 0, NULL,
-    N_("Use TLS encryption.") },
-  { "debug", mu_c_int, &ldap_settings.debug, 0, NULL,
-    N_("Set LDAP debugging level.") },
-  { "field-map", mu_cfg_callback, NULL, 0, cb_field_map,
-    N_("Set a field-map for parsing LDAP replies.  The map is a "
-       "column-separated list of definitions.  Each definition has the "
-       "following form:\n"
-       "   <name: string>=<attr: string>\n"
-       "where <name> is one of the following: name, passwd, uid, gid, "
-       "gecos, dir, shell, mailbox, quota, and <attr> is the name of "
-       "the corresponding LDAP attribute."),
-    N_("map") },
-  { "getpwnam", mu_c_string, &ldap_settings.getpwnam_filter, 0, NULL,
-    N_("LDAP filter to use for getpwnam requests."),
-    N_("filter") },
-  { "getpwuid", mu_c_string, &ldap_settings.getpwuid_filter, 0, NULL,
-    N_("LDAP filter to use for getpwuid requests."),
-    N_("filter") },
-  { NULL }
-};
-
-int                                                                          
-mu_ldap_section_parser
-   (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node,              
-    const char *section_label, void **section_data,
-    void *call_data, mu_cfg_tree_t *tree)
-{                                                                            
-  switch (stage)                                                             
-    {                                                                        
-    case mu_cfg_section_start:
-      ldap_settings.enable = 1;
-      break;                                                                 
-                                                                             
-    case mu_cfg_section_end:                                                 
-      mu_gocs_store ("ldap", &ldap_settings);        
-    }                                                                        
-  return 0;                                                                  
-}
-
-struct mu_cfg_capa mu_ldap_cfg_capa = {                
-  "ldap",  mu_ldap_param, mu_ldap_section_parser
-};
diff --git a/libmu_cfg/pam.c b/libmu_cfg/pam.c
deleted file mode 100644
index ec8c9cc..0000000
--- a/libmu_cfg/pam.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation,
-   Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-
-static char *pam_settings;
-
-static struct mu_cfg_param mu_pam_param[] = {
-  { "service", mu_c_string, &pam_settings, 0, NULL,
-    N_("Set PAM service name."),
-    N_("name") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (pam);
-
diff --git a/libmu_cfg/radius.c b/libmu_cfg/radius.c
deleted file mode 100644
index fb874a6..0000000
--- a/libmu_cfg/radius.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation,
-   Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-#include <mailutils/radius.h>
-
-static struct mu_radius_module_data radius_settings;
-
-static struct mu_cfg_param mu_radius_param[] = {
-  { "auth", mu_c_string, &radius_settings.auth_request, 0, NULL,
-    N_("Radius request for authorization."),
-    N_("request") },
-  { "getpwnam", mu_c_string, &radius_settings.getpwnam_request, 0, NULL,
-    N_("Radius request for getpwnam."),
-    N_("request") },
-  { "getpwuid", mu_c_string, &radius_settings.getpwuid_request, 0, NULL,
-    N_("Radius request for getpwuid."),
-    N_("request") },
-  { "directory", mu_c_string, &radius_settings.config_dir, 0, NULL,
-    N_("Set radius configuration directory.") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (radius);
diff --git a/libmu_cfg/sieve.c b/libmu_cfg/sieve.c
deleted file mode 100644
index fb4f106..0000000
--- a/libmu_cfg/sieve.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2008, 2010-2012, 2014-2016 Free Software
-   Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-#include <mailutils/sieve.h>
-
-static struct mu_gocs_sieve sieve_settings;
-
-static int
-cb_clear_library_path (void *data, mu_config_value_t *val)
-{
-  int flag;
-
-  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
-    return 1;
-  if (mu_str_to_c (val->v.string, mu_c_bool, &flag, NULL))
-    {
-      mu_error (_("not a boolean"));
-      return 1;
-    }
-  if (flag)
-    sieve_settings.clearflags |= MU_SIEVE_CLEAR_LIBRARY_PATH;
-  return 0;
-}
-
-static int
-cb_clear_include_path (void *data, mu_config_value_t *val)
-{
-  int flag;
-  
-  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
-    return 1;
-  if (mu_str_to_c (val->v.string, mu_c_bool, &flag, NULL))
-    {
-      mu_error (_("not a boolean"));
-      return 1;
-    }
-  if (flag)
-    sieve_settings.clearflags |= MU_SIEVE_CLEAR_INCLUDE_PATH;
-  return 0;
-}
-
-static int
-_add_path (const char *arg, void *data)
-{
-  mu_list_t *plist = data;
-    
-  if (!*plist)
-    {
-      int rc = mu_list_create (plist);
-      if (rc)
-       {
-         mu_error (_("cannot create list: %s"), mu_strerror (rc));
-         exit (1);
-       }
-      mu_list_set_destroy_item (*plist, mu_list_free_item);
-    }
-  return mu_string_split (arg, ":", *plist);
-}
-
-static int
-cb_include_path (void *data, mu_config_value_t *val)
-{
-  return mu_cfg_string_value_cb (val, _add_path,
-                                &sieve_settings.include_path);
-}  
-
-static int
-cb_library_path (void *data, mu_config_value_t *val)
-{
-  return mu_cfg_string_value_cb (val, _add_path,
-                                &sieve_settings.library_path);
-}
-
-static int
-cb_library_path_prefix (void *data, mu_config_value_t *val)
-{
-  return mu_cfg_string_value_cb (val, _add_path,
-                                &sieve_settings.library_path_prefix);
-}
-
-static struct mu_cfg_param mu_sieve_param[] = {
-  { "clear-library-path", mu_cfg_callback, NULL, 0, cb_clear_library_path,
-     N_("Clear library search path.") },
-  { "clear-include-path", mu_cfg_callback, NULL, 0, cb_clear_include_path,
-     N_("Clear include search path.") },
-  { "library-path", mu_cfg_callback, NULL, 0, cb_library_path,
-    N_("Add directories to the library search path.  Argument is a "
-       "colon-separated list of directories."),
-    N_("list") },
-  { "library-path-prefix", mu_cfg_callback, NULL, 0, cb_library_path_prefix,
-    N_("Add directories to the beginning of the library search path.  "
-       "Argument is a colon-separated list of directories."),
-    N_("list") },
-  { "include-path", mu_cfg_callback, NULL, 0, cb_include_path,
-    N_("Add directories to the include search path.  Argument is a "
-       "colon-separated list of directories."),
-    N_("list") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (sieve);
diff --git a/libmu_cfg/sql.c b/libmu_cfg/sql.c
deleted file mode 100644
index af60300..0000000
--- a/libmu_cfg/sql.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2012, 2014-2016 Free Software Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-#include <mailutils/sql.h>
-#include <mailutils/util.h>
-
-static struct mu_sql_module_config sql_settings;
-
-
-
-/* Resource file configuration */
-static int
-cb_password_type (void *data, mu_config_value_t *val)
-{
-  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
-    return 1;
-  
-  if (mu_sql_decode_password_type (val->v.string, &sql_settings.password_type))
-    mu_error (_("unknown password type `%s'"), val->v.string);
-  return 0;
-}
-
-static int
-_cb2_field_map (const char *arg, void *data)
-{
-  int err;
-  int rc = mutil_parse_field_map (arg, &sql_settings.field_map, &err);
-  if (rc)
-    /* FIXME: this message may be misleading */
-    mu_error (_("error near element %d: %s"), err, mu_strerror (rc));
-  return 0;
-}
-
-static int
-cb_field_map (void *data, mu_config_value_t *val)
-{
-  return mu_cfg_string_value_cb (val, _cb2_field_map, NULL);
-}
-
-static struct mu_cfg_param mu_sql_param[] = {
-  { "interface", mu_c_string, &sql_settings.interface, 0, NULL,
-    N_("Set SQL interface to use (one of: mysql, odbc, or postgres).") },
-  { "getpwnam", mu_c_string, &sql_settings.getpwnam_query, 0, NULL,
-    N_("SQL query to use for getpwnam requests."),
-    N_("query") },
-  { "getpwuid", mu_c_string, &sql_settings.getpwuid_query, 0, NULL,
-    N_("SQL query to use for getpwuid requests."),
-    N_("query") },
-  { "getpass", mu_c_string, &sql_settings.getpass_query, 0, NULL,
-    N_("SQL query returning the user's password."),
-    N_("query") },
-  { "host", mu_c_string, &sql_settings.host, 0, NULL,
-    N_("SQL server host name.") },
-  { "user", mu_c_string, &sql_settings.user, 0, NULL,
-    N_("SQL user name.") },
-  { "passwd", mu_c_string, &sql_settings.passwd, 0, NULL,
-    N_("Password for the SQL user.") },
-  { "port", mu_c_int, &sql_settings.port, 0, NULL,
-    N_("SQL server port.") },
-  { "db", mu_c_string, &sql_settings.db, 0, NULL,
-    N_("Database name.") },
-  { "password-type", mu_cfg_callback, NULL, 0, cb_password_type,
-    N_("Type of password returned by getpass query (one of: plain, hash, "
-       "scrambled).") },
-  { "positional", mu_c_bool, &sql_settings.positional, 0, NULL,
-    N_("Use positional (v1.0 compatible) field interface.") },
-  { "field-map", mu_cfg_callback, NULL, 0, cb_field_map,
-    N_("Set a field-map for parsing SQL replies.  The map is a "
-       "column-separated list of definitions.  Each definition has the "
-       "following form:\n"
-       "   <name: string>=<column: string>\n"
-       "where <name> is one of the following: name, passwd, uid, gid, "
-       "gecos, dir, shell, mailbox, quota, and <column> is the name of "
-       "the corresponding SQL column."),
-    N_("map") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (sql);
-
-     
diff --git a/libmu_cfg/tls.c b/libmu_cfg/tls.c
deleted file mode 100644
index 3d568ef..0000000
--- a/libmu_cfg/tls.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007-2008, 2010-2012, 2014-2016 Free Software
-   Foundation, Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-#include <mailutils/tls.h>
-#include <mailutils/util.h>
-#include <mailutils/kwd.h>
-
-#define SSL_CERT_FILE_CHECKS  (MU_FILE_SAFETY_GROUP_WRITABLE |         \
-                              MU_FILE_SAFETY_GROUP_WRITABLE |          \
-                              MU_FILE_SAFETY_LINKED_WRDIR)
-
-#define SSL_KEY_FILE_CHECKS   (MU_FILE_SAFETY_ALL & 
~MU_FILE_SAFETY_OWNER_MISMATCH)
-
-#define SSL_CA_FILE_CHECKS    (MU_FILE_SAFETY_GROUP_WRITABLE |         \
-                              MU_FILE_SAFETY_GROUP_WRITABLE |          \
-                              MU_FILE_SAFETY_LINKED_WRDIR)
-
-static struct mu_tls_module_config tls_settings = {
-    1,                   /* enabled by default */
-
-    NULL,                /* Certificate file */
-    SSL_CERT_FILE_CHECKS,
-
-    NULL,                /* Key file */ 
-    SSL_KEY_FILE_CHECKS, /* Stringent safety checks for keys */
-
-    NULL,                /* CA file */
-    SSL_CA_FILE_CHECKS
-};
-
-static int
-cb2_safety_checks (const char *name, void *data)
-{
-  int defval;
-  
-  if (data == &tls_settings.ssl_key_safety_checks)
-    defval = SSL_KEY_FILE_CHECKS;
-  else if (data == &tls_settings.ssl_cert_safety_checks)
-    defval = SSL_CERT_FILE_CHECKS;
-  else if (data == &tls_settings.ssl_cafile_safety_checks)
-    defval = SSL_CA_FILE_CHECKS;
-  else
-    {
-      mu_error (_("INTERNAL ERROR at %s:%d: unknown default value?"),
-               __FILE__, __LINE__);
-      defval = MU_FILE_SAFETY_ALL;
-    }
-  if (mu_file_safety_compose (data, name, defval))
-    mu_error (_("unknown keyword: %s"), name);
-  return 0;
-}
-
-static int
-cb_safety_checks (void *data, mu_config_value_t *arg)
-{
-  return mu_cfg_string_value_cb (arg, cb2_safety_checks, data);
-}
-
-static struct mu_cfg_param mu_tls_param[] = {
-  { "enable", mu_c_bool, &tls_settings.enable, 0, NULL,
-    N_("Enable TLS encryption.") },
-  { "ssl-cert", mu_c_string, &tls_settings.ssl_cert, 0, NULL,
-    N_("Specify SSL certificate file."),
-    N_("file") },
-  { "ssl-key", mu_c_string, &tls_settings.ssl_key, 0, NULL,
-    N_("Specify SSL certificate key file."),
-    N_("file") },
-  { "ssl-cafile", mu_c_string, &tls_settings.ssl_cafile, 0, NULL,
-    N_("Specify trusted CAs file."),
-    N_("file") },
-  { "ssl-priorities", mu_c_string, &tls_settings.priorities, 0, NULL,
-    N_("Set the priorities to use on the ciphers, key exchange methods, "
-       "macs and compression methods."),
-    NULL },
-  { "key-file-safety-checks", mu_cfg_callback,
-    &tls_settings.ssl_key_safety_checks, 0,
-    cb_safety_checks,
-    N_("Configure safety checks for SSL key file.  Argument is a list or "
-       "sequence of check names optionally prefixed with '+' to enable or "
-       "'-' to disable the corresponding check.  Valid check names are:\n"
-       "\n"
-       "  none          disable all checks\n"
-       "  all           enable all checks\n"
-       "  gwrfil        forbid group writable files\n"
-       "  awrfil        forbid world writable files\n"
-       "  grdfil        forbid group readable files\n"
-       "  ardfil        forbid world writable files\n"
-       "  linkwrdir     forbid symbolic links in group or world writable 
directories\n"
-       "  gwrdir        forbid files in group writable directories\n"
-       "  awrdir        forbid files in world writable directories\n"),
-    N_("arg: list") },  
-  { "cert-file-safety-checks", mu_cfg_callback,
-    &tls_settings.ssl_cert_safety_checks, 0,
-    cb_safety_checks,
-    N_("Configure safety checks for SSL certificate.  See above for a 
description of <arg>."),
-    N_("arg: list") },  
-  { "ca-file-safety-checks", mu_cfg_callback,
-    &tls_settings.ssl_cafile_safety_checks, 0,
-    cb_safety_checks,
-    N_("Configure safety checks for SSL certificate authority file.  See above 
for a description of <arg>."),
-    N_("arg: list") },  
-  { NULL }
-}; 
-
-DCL_CFG_CAPA (tls);
-
diff --git a/libmu_cfg/virtdomain.c b/libmu_cfg/virtdomain.c
deleted file mode 100644
index d4e2d1e..0000000
--- a/libmu_cfg/virtdomain.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* This file is part of GNU Mailutils
-   Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation,
-   Inc.
-
-   GNU Mailutils is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 3, or (at
-   your option) any later version.
-
-   GNU Mailutils is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include "mailutils/libcfg.h"
-
-static struct mu_gocs_virtual virtdomain_settings;
-
-static struct mu_cfg_param mu_virtdomain_param[] = {
-  { "passwd-dir", mu_c_string, &virtdomain_settings, 0, NULL,
-    N_("Name of the directory where virtual domain password files are "
-       "located."),
-    N_("dir") },
-  { NULL }
-};
-
-DCL_CFG_CAPA (virtdomain);
-     
diff --git a/libmu_sieve/conf.c b/libmu_sieve/conf.c
index 15b33aa..7b9102f 100644
--- a/libmu_sieve/conf.c
+++ b/libmu_sieve/conf.c
@@ -29,9 +29,6 @@ mu_list_t mu_sieve_library_path = NULL;
 mu_list_t mu_sieve_library_path_prefix = NULL;
 mu_debug_handle_t mu_sieve_debug_handle;
 
-//FIXME: provide definition (from gocs.h)
-static struct mu_gocs_sieve sieve_settings;
-
 void
 mu_sieve_debug_init (void)
 {
@@ -39,6 +36,15 @@ mu_sieve_debug_init (void)
     mu_sieve_debug_handle = mu_debug_register_category ("sieve");
 }
 
+struct sieve_settings
+{
+  int clearflags;
+  mu_list_t include_path;
+  mu_list_t library_path_prefix;
+  mu_list_t library_path;
+};
+static struct sieve_settings sieve_settings;
+
 /*FIXME: REMOVE BEGIN */
 static int
 _path_append (void *item, void *data)
@@ -61,33 +67,6 @@ _path_append (void *item, void *data)
   return mu_list_append (*plist, p);
 }
 
-int
-mu_sieve_module_init (enum mu_gocs_op op, void *data)
-{
-  struct mu_gocs_sieve *p;
-  if (!(op == mu_gocs_op_set && data))
-    return 0;
-  p = data;
-
-  if (p->clearflags & MU_SIEVE_CLEAR_INCLUDE_PATH)
-    mu_list_destroy (&mu_sieve_include_path);
-  mu_list_foreach (p->include_path, _path_append, &mu_sieve_include_path);
-  if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH)
-    {
-      mu_list_destroy (&mu_sieve_library_path);
-      mu_list_destroy (&mu_sieve_library_path_prefix);
-    }
-  mu_list_foreach (p->library_path_prefix, _path_append,
-                  &mu_sieve_library_path_prefix);
-  mu_list_foreach (p->library_path, _path_append, &mu_sieve_library_path);
-  mu_list_destroy (&p->library_path);
-  mu_list_destroy (&p->library_path_prefix);
-  mu_list_destroy (&p->include_path);
-  mu_sieve_debug_init ();
-  return 0;
-}
-/* FIXME: REMOVE END */
-
 static int
 cb_clear_library_path (void *data, mu_config_value_t *val)
 {
@@ -238,9 +217,30 @@ static struct mu_option sieve_option[] = {
   MU_OPTION_END
 };
 
+static void
+sieve_commit (void *ptr)
+{
+  if (sieve_settings.clearflags & MU_SIEVE_CLEAR_INCLUDE_PATH)
+    mu_list_destroy (&mu_sieve_include_path);
+  mu_list_foreach (sieve_settings.include_path, _path_append, 
&mu_sieve_include_path);
+  if (sieve_settings.clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH)
+    {
+      mu_list_destroy (&mu_sieve_library_path);
+      mu_list_destroy (&mu_sieve_library_path_prefix);
+    }
+  mu_list_foreach (sieve_settings.library_path_prefix, _path_append,
+                  &mu_sieve_library_path_prefix);
+  mu_list_foreach (sieve_settings.library_path, _path_append, 
&mu_sieve_library_path);
+  mu_list_destroy (&sieve_settings.library_path);
+  mu_list_destroy (&sieve_settings.library_path_prefix);
+  mu_list_destroy (&sieve_settings.include_path);
+  mu_sieve_debug_init ();
+}
+
 struct mu_cli_capa mu_cli_capa_sieve = {
   "sieve",
   sieve_option,
   mu_sieve_param,
-  NULL, NULL
+  NULL,
+  sieve_commit
 };
diff --git a/maidag/Makefile.am b/maidag/Makefile.am
index 008713e..53c887e 100644
--- a/maidag/Makefile.am
+++ b/maidag/Makefile.am
@@ -36,7 +36,7 @@ maidag_LDADD = \
  @LIBMU_SCM@ @address@hidden
  @address@hidden
  @MU_LIB_PY@ @address@hidden
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_SIEVE}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
diff --git a/maidag/maidag.c b/maidag/maidag.c
index ddca3ee..9b1c37e 100644
--- a/maidag/maidag.c
+++ b/maidag/maidag.c
@@ -270,7 +270,6 @@ static char *capa[] = {
   "locking",
   "mailer",
   "sieve",
-  "tls",
   NULL
 };
 
@@ -553,7 +552,7 @@ main (int argc, char *argv[])
   mu_log_print_severity = 1;
   
   /* Parse command line */
-  mu_cli_capa_register (&mu_cli_capa_tls);
+
   mu_cli_capa_register (&mu_cli_capa_sieve);
   mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
 
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 7af953a..7134b5a 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -25,7 +25,7 @@ address@hidden@
 mailbin_PROGRAMS = mail
 
 mail_LDADD = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
  ${MU_LIB_POP}\
diff --git a/mail/mail.c b/mail/mail.c
index a10d061..cd8c466 100644
--- a/mail/mail.c
+++ b/mail/mail.c
@@ -17,6 +17,7 @@
 
 #include "mail.h"
 #include "mailutils/cli.h"
+#include "mailutils/mu_auth.h"
 
 /* Global variables and constants*/
 mu_mailbox_t mbox;            /* Mailbox being operated upon */
@@ -240,7 +241,6 @@ static char *mail_capa[] = {
   "debug",
   "mailbox",
   "locking",
-  "tls",
   NULL 
 };
                             
@@ -368,6 +368,8 @@ main (int argc, char **argv)
   /* Register the desired formats.  */
   mu_register_all_formats ();
 
+  mu_auth_register_module (&mu_auth_tls_module);  
+  
   interactive = isatty (fileno (stdin));
 #ifdef HAVE_SIGACTION
   {
@@ -417,7 +419,6 @@ main (int argc, char **argv)
               MOPTF_OVERWRITE);
 
   /* argument parsing */
-  mu_cli_capa_register (&mu_cli_capa_tls);
   mu_cli (argc, argv, &cli, mail_capa, NULL, &argc, &argv);
 
   if ((hint & (HINT_SEND_MODE|HINT_FILE_OPTION)) ==
diff --git a/messages/Makefile.am b/messages/Makefile.am
index 56ff5e7..d611b2c 100644
--- a/messages/Makefile.am
+++ b/messages/Makefile.am
@@ -22,7 +22,7 @@ SUBDIRS = . tests
 bin_PROGRAMS = messages
 messages_SOURCES = messages.c
 messages_LDADD =\
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
  ${MU_LIB_POP}\
diff --git a/messages/messages.c b/messages/messages.c
index 84cf4bf..c0c2c4a 100644
--- a/messages/messages.c
+++ b/messages/messages.c
@@ -41,7 +41,6 @@ static char *capa[] = {
   "debug",
   "mailbox",
   "locking",
-  "tls",
   NULL
 };
 
@@ -65,7 +64,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 == 0 && messages_count (NULL) < 0)
diff --git a/mimeview/Makefile.am b/mimeview/Makefile.am
index d85eebb..b4c9108 100644
--- a/mimeview/Makefile.am
+++ b/mimeview/Makefile.am
@@ -47,7 +47,7 @@ mimetypes-lex.c: $(srcdir)/mimetypes.l mimetypes-decl.h
 BUILT_SOURCES = mimetypes-gram.c mimetypes-lex.c mimetypes-decl.h
 
 mimeview_LDADD = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MAILUTILS}\
  @LTLIBINTL@
  
diff --git a/movemail/Makefile.am b/movemail/Makefile.am
index 5d0b5c6..e166b81 100644
--- a/movemail/Makefile.am
+++ b/movemail/Makefile.am
@@ -19,7 +19,7 @@ AM_CPPFLAGS = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@
 bin_PROGRAMS = movemail
 
 movemail_LDADD = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
  ${MU_LIB_POP}\
diff --git a/movemail/movemail.c b/movemail/movemail.c
index 8fdaf90..1352578 100644
--- a/movemail/movemail.c
+++ b/movemail/movemail.c
@@ -381,7 +381,6 @@ static char *movemail_capa[] = {
   "locking",
   "mailbox",
   "auth",
-  "tls",
   NULL 
 };
 
@@ -843,10 +842,10 @@ main (int argc, char **argv)
   
   /* Register the desired "mailbox" formats.  */
   mu_register_all_formats ();
-
-  /* argument parsing */
+  /* Register authentication modules */
+  mu_auth_register_module (&mu_auth_tls_module);
   
-  mu_cli_capa_register (&mu_cli_capa_tls);
+  /* argument parsing */
   mu_cli (argc, argv, &cli, movemail_capa, NULL, &argc, &argv);
 
   if (argc < 2 || argc > 3)
diff --git a/mu/acl.c b/mu/acl.c
index 749ba28..e7d2de7 100644
--- a/mu/acl.c
+++ b/mu/acl.c
@@ -14,63 +14,24 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/un.h>
-#include <arpa/inet.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/libcfg.h>
-#include "argp.h"
 #include "mu.h"
 
-static char acl_doc[] = N_("mu acl - test access control lists.");
 char acl_docstring[] = N_("test access control lists");
 static char acl_args_doc[] = N_("ADDRESS [ADDRESS...]");
 
-static struct argp_option acl_options[] = {
-  { "file", 'f', N_("FILE"), 0, N_("read ACLs from FILE") },
-  { "path", 'p', N_("PATH"), 0,
-    N_("path to the ACL in the configuration tree") },
-  { NULL }
-};
-
 static char *input_file_name;
 static struct mu_sockaddr *target_sa;
 static mu_acl_t acl;
 static const char *path = "acl";
 
-static error_t
-acl_parse_opt (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    case 'f':
-      input_file_name = arg;
-      break;
-
-    case 'p':
-      path = arg;
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp acl_argp = {
-  acl_options,
-  acl_parse_opt,
-  acl_args_doc,
-  acl_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option acl_options[] = {
+  { "file", 'f', N_("FILE"), MU_OPTION_DEFAULT,
+    N_("read ACLs from FILE"),
+    mu_c_string, &input_file_name },
+  { "path", 'p', N_("PATH"), MU_OPTION_DEFAULT,
+    N_("path to the ACL in the configuration tree"),
+    mu_c_string, &path },
+  { NULL }
 };
 
 
@@ -82,16 +43,13 @@ static struct mu_cfg_param acl_cfg_param[] = {
 int
 mutool_acl (int argc, char **argv)
 {
-  int rc, index;
+  int rc;
   mu_acl_result_t result;
   mu_cfg_tree_t *tree = NULL, *temp_tree = NULL;
   mu_cfg_node_t *node;
-  
-  if (argp_parse (&acl_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
+  struct mu_cfg_parse_hints hints;
 
-  argc -= index;
-  argv += index;
+  mu_action_getopt (&argc, &argv, acl_options, acl_docstring, acl_args_doc);
 
   if (argc == 0)
     {
@@ -99,16 +57,13 @@ mutool_acl (int argc, char **argv)
       return 1;
     }
 
-  if (input_file_name)
-    {
-      mu_load_site_rcfile = 0;
-      mu_load_user_rcfile = 0;
-      mu_load_rcfile = input_file_name;
-    }
+  memset (&hints, 0, sizeof (hints));
+  hints.flags = MU_CFG_PARSE_CUSTOM_RCFILE;
+  hints.custom_rcfile = input_file_name;
 
   mu_acl_cfg_init ();
-  if (mu_libcfg_parse_config (&tree))
-    return 1;
+  if (mu_cfg_parse_config (&tree, &hints))
+    exit (EX_CONFIG);
   if (!tree)
     return 0;
   
diff --git a/mu/cflags.c b/mu/cflags.c
index 1ecadb5..dd549e6 100644
--- a/mu/cflags.c
+++ b/mu/cflags.c
@@ -14,32 +14,19 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/libcfg.h>
-#include <argp.h>
-
-static char cflags_doc[] = N_("mu cflags - show compiler options");
-char cflags_docstring[] = N_("show compiler options");
+#include "mu.h"
 
-static struct argp cflags_argp = {
-  NULL,
-  NULL,
-  NULL,
-  cflags_doc,
-  NULL,
-  NULL,
-  NULL
-};
+char cflags_docstring[] = N_("show compiler options");
 
 int
 mutool_cflags (int argc, char **argv)
 {
-  if (argp_parse (&cflags_argp, argc, argv, ARGP_IN_ORDER, NULL, NULL))
-    return 1;
+  mu_action_getopt (&argc, &argv, NULL, cflags_docstring, NULL);
+  if (argc)
+    {
+      mu_error (_("too many arguments"));
+      return EX_USAGE;
+    }
   mu_printf ("%s\n", COMPILE_FLAGS);
   return 0;
 }
diff --git a/mu/dbm.c b/mu/dbm.c
index 4c0e4d2..531a3cf 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -14,21 +14,12 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <string.h>
-#include <grp.h>
-#include <sysexits.h>
+#include "mu.h"
+#include <mailutils/dbm.h>
 #include <fnmatch.h>
 #include <regex.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/dbm.h>
-#include "argp.h"
-#include "mu.h"
+#include <sys/stat.h>
+#include <grp.h>
 
 static char dbm_doc[] = N_("mu dbm - DBM management tool\n"
 "Valid COMMANDs are:\n"
@@ -39,6 +30,7 @@ static char dbm_doc[] = N_("mu dbm - DBM management tool\n"
 "  delete         - delete specified keys from the database\n"
 "  add            - add records to the database\n"
 "  replace        - add records replacing ones with matching keys\n");
+
 char dbm_docstring[] = N_("DBM management tool");
 static char dbm_args_doc[] = N_("COMMAND FILE [KEY...]");
 
@@ -1603,154 +1595,161 @@ delete_database (int argc, char **argv)
   mu dbm --replace a.db < input
  */
 
-static struct argp_option dbm_options[] = {
-  { NULL, 0, NULL, 0, N_("Create Options"), 0},
-  { "file",   'f', N_("FILE"), 0,
-    N_("read input from FILE (with create, delete, add and replace)") },
-  { "permissions", 'p', N_("NUM"), 0,
-    N_("set permissions on the created database") },
-  { "user",        'u', N_("USER"), 0,
-    N_("set database owner name") },
-  { "group",       'g', N_("GROUP"), 0,
-    N_("set database owner group") },
-  { "copy-permissions", 'P', NULL, 0,
-    N_("copy database permissions and ownership from the input file") },
-  { "ignore-meta",      'm', NULL, 0,
-    N_("ignore meta-information from input file headers") },
-  { "ignore-directives", 'I', N_("NAMES"), 0,
-    N_("ignore the listed directives") },
-  { NULL, 0, NULL, 0, N_("List and Dump Options"), 0},
-  { "format",           'H', N_("TYPE"), 0,
-    N_("select output format") },
-  { "no-header",        'q', NULL, 0,
-    N_("suppress format header") },
-  { NULL, 0, NULL, 0, N_("List, Dump and Delete Options"), 0},
-  { "glob",        'G', NULL, 0,
-    N_("treat keys as globbing patterns") },
-  { "regex",       'R', NULL, 0,
-    N_("treat keys as regular expressions") },
-  { "ignore-case", 'i', NULL, 0,
-    N_("case-insensitive matches") },
-  { NULL, 0, NULL, 0, N_("Options for Use with Format 0.0"), 0 },
-  { "count-null",  'N', NULL, 0,
-    N_("data length accounts for terminating zero") },
-  { "no-count-null", 'n', NULL, 0,
-    N_("data length does not account for terminating zero") },
-  { NULL }
-};
-
-static error_t
-dbm_parse_opt (int key, char *arg, struct argp_state *state)
+static void
+set_permissions (struct mu_parseopt *po, struct mu_option *opt, char const 
*arg)
 {
-  switch (key)
+  char *p;
+  unsigned long d = strtoul (arg, &p, 8);
+  if (*p || (d & ~0777))
     {
-    case 'f':
-      input_file = arg;
-      break;
-
-    case 'H':
-      select_format (arg);
-      break;
-      
-    case 'p':
-      {
-       char *p;
-       unsigned long d = strtoul (arg, &p, 8);
-       if (*p || (d & ~0777))
-         argp_error (state, _("invalid file mode: %s"), arg);
-       file_mode = d;
-       known_meta_data |= META_FILE_MODE;
-      }
-      break;
+      mu_parseopt_error (po, _("invalid file mode: %s"), arg);
+      exit (po->po_exit_error);
+    }
+  file_mode = d;
+  known_meta_data |= META_FILE_MODE;
+}
 
-    case 'P':
-      copy_permissions = 1;
-      break;
+static void
+set_user (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+  auth = mu_get_auth_by_name (arg);
+  if (auth)
+    known_meta_data |= META_AUTH;
+  else
+    {
+      char *p;
+      unsigned long n = strtoul (arg, &p, 0);
+      if (*p == 0)
+       {
+         owner_uid = n;
+         known_meta_data |= META_UID;
+       }
+      else
+       {
+         mu_parseopt_error (po, _("no such user: %s"), arg);
+         exit (po->po_exit_error);
+       }
+    }
+  ignore_directives ("user,uid");
+}
 
-    case 'q':
-      suppress_header = 1;
-      break;
-      
-    case 'u':
-      auth = mu_get_auth_by_name (arg);
-      if (auth)
-       known_meta_data |= META_AUTH;
+static void
+set_group (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+  struct group *gr = getgrnam (arg);
+  if (!gr)
+    {
+      char *p;
+      unsigned long n = strtoul (arg, &p, 0);
+      if (*p == 0)
+       owner_gid = n;
       else
        {
-         char *p;
-         unsigned long n = strtoul (arg, &p, 0);
-         if (*p == 0)
-           {
-             owner_uid = n;
-             known_meta_data |= META_UID;
-           }
-         else
-           argp_error (state, _("no such user: %s"), arg);
+         mu_parseopt_error (po, _("no such group: %s"), arg);
+         exit (po->po_exit_error);
        }
-      ignore_directives ("user,uid");
-      break;
+    }
+  else
+    owner_gid = gr->gr_gid;
+  known_meta_data |= META_GID;
+  ignore_directives ("group,gid");
+}
 
-    case 'g':
-      {
-       struct group *gr = getgrnam (arg);
-       if (!gr)
-         {
-           char *p;
-           unsigned long n = strtoul (arg, &p, 0);
-           if (*p == 0)
-             owner_gid = n;
-           else
-             argp_error (state, _("no such group: %s"), arg);
-         }
-       else
-         owner_gid = gr->gr_gid;
-       known_meta_data |= META_GID;
-       ignore_directives ("group,gid");
-      }
-      break;
+static void
+set_ignore_meta (struct mu_parseopt *po, struct mu_option *opt, char const 
*arg)
+{
+  ignore_flagged_directives (DF_META);
+}
 
-    case 'G':
-      key_type = key_glob;
-      break;
+static void
+set_ignore_directives (struct mu_parseopt *po, struct mu_option *opt,
+                      char const *arg)
+{
+  ignore_directives (arg);
+}
 
-    case 'R':
-      key_type = key_regex;
-      break;
+static void
+set_format (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+  select_format (arg);
+}
 
-    case 'm':/* FIXME: Why m? */
-      ignore_flagged_directives (DF_META);
-      break;
+static void
+set_glob (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+  key_type = key_glob;
+}
 
-    case 'I':
-      ignore_directives (arg);
-      break;
-      
-    case 'i':
-      case_sensitive = 0;
-      break;
+static void
+set_regex (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+  key_type = key_regex;
+}
 
-    case 'N':
-      include_zero = 1;
-      break;
+static void
+set_ignore_case (struct mu_parseopt *po, struct mu_option *opt, char const 
*arg)
+{
+  case_sensitive = 0;
+}
 
-    case 'n':
-      include_zero = 0;
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
+static void
+clear_include_zero (struct mu_parseopt *po, struct mu_option *opt,
+                   char const *arg)
+{
+  include_zero = 0;
 }
 
-static struct argp dbm_argp = {
-  dbm_options,
-  dbm_parse_opt,
-  dbm_args_doc,
-  dbm_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option dbm_options[] = {
+  MU_OPTION_GROUP (N_("Create Options")),
+  { "file",   'f', N_("FILE"), MU_OPTION_DEFAULT,
+    N_("read input from FILE (with create, delete, add and replace)"),
+    mu_c_string, &input_file },
+  { "permissions", 'p', N_("NUM"), MU_OPTION_DEFAULT,
+    N_("set permissions on the created database"),
+    mu_c_string, NULL, set_permissions },
+  { "user",        'u', N_("USER"), MU_OPTION_DEFAULT,
+    N_("set database owner name"),
+    mu_c_string, NULL, set_user },
+  { "group",       'g', N_("GROUP"), MU_OPTION_DEFAULT,
+    N_("set database owner group"),
+    mu_c_string, NULL, set_group },
+  { "copy-permissions", 'P', NULL, MU_OPTION_DEFAULT,
+    N_("copy database permissions and ownership from the input file"),
+    mu_c_bool, &copy_permissions },
+  { "ignore-meta",      'm', NULL, MU_OPTION_DEFAULT,
+    N_("ignore meta-information from input file headers"),
+    mu_c_string, NULL, set_ignore_meta },
+  { "ignore-directives", 'I', N_("NAMES"), MU_OPTION_DEFAULT,
+    N_("ignore the listed directives"),
+    mu_c_string, NULL, set_ignore_directives },
+  
+  MU_OPTION_GROUP (N_("List and Dump Options")),
+  { "format",           'H', N_("TYPE"), MU_OPTION_DEFAULT,
+    N_("select output format"),
+    mu_c_string, NULL, set_format },
+  { "no-header",        'q', NULL, MU_OPTION_DEFAULT,
+    N_("suppress format header"),
+    mu_c_bool, &suppress_header },
+  
+  MU_OPTION_GROUP (N_("List, Dump and Delete Options")),
+  { "glob",        'G', NULL, MU_OPTION_DEFAULT,
+    N_("treat keys as globbing patterns"),
+    mu_c_string, NULL, set_glob },
+  { "regex",       'R', NULL, MU_OPTION_DEFAULT,
+    N_("treat keys as regular expressions"),
+    mu_c_string, NULL, set_regex },
+  { "ignore-case", 'i', NULL, MU_OPTION_DEFAULT,
+    N_("case-insensitive matches"),
+    mu_c_string, NULL, set_ignore_case },
+  
+  MU_OPTION_GROUP (N_("Options for Use with Format 0.0")),
+  { "count-null",  'N', NULL, MU_OPTION_DEFAULT,
+    N_("data length accounts for terminating zero"),
+    mu_c_bool, &include_zero },
+  { "no-count-null", 'n', NULL, MU_OPTION_DEFAULT,
+    N_("data length does not account for terminating zero"),
+    mu_c_string, NULL, clear_include_zero },
+  MU_OPTION_END
 };
 
 struct mu_kwd mode_tab[] =
@@ -1769,12 +1768,8 @@ int
 mutool_dbm (int argc, char **argv)
 {
   int index;
-
-  if (argp_parse (&dbm_argp, argc, argv, 0, &index, NULL))
-    return 1;
-
-  argc -= index;
-  argv += index;
+    
+  mu_action_getopt (&argc, &argv, dbm_options, dbm_doc, dbm_args_doc);
 
   if (argc == 0)
     {
diff --git a/mu/dispatch.c b/mu/dispatch.c
index 05ffeec..cd27a66 100644
--- a/mu/dispatch.c
+++ b/mu/dispatch.c
@@ -49,33 +49,34 @@ dispatch_find_action (const char *name)
   return NULL;
 }
 
-char *
-dispatch_docstring (const char *text)
+void
+subcommand_help (mu_stream_t str)
 {
-  mu_stream_t str;
   struct mutool_action_tab *p;
-  mu_off_t size;
-  size_t n;
-  char *ret;
+  unsigned margin;
   
-  mu_memory_stream_create (&str, MU_STREAM_RDWR);
-  mu_stream_printf (str, "%s\n%s\n\n", text, _("Commands are:"));
+  mu_stream_printf (str, "%s\n\n", _("Commands are:"));
   for (p = mutool_action_tab; p->name; p++)
-    mu_stream_printf (str, "  %s %-16s - %s\n",
-                     mu_program_name,
-                     p->name, gettext (p->docstring));
+    {
+      margin = 2;
+      mu_stream_ioctl (str, MU_IOCTL_WORDWRAPSTREAM,
+                      MU_IOCTL_WORDWRAP_SET_MARGIN,
+                      &margin);
+      mu_stream_printf (str, "%s %s",  mu_program_name, p->name);
+      margin = 29;
+      mu_stream_ioctl (str, MU_IOCTL_WORDWRAPSTREAM,
+                      MU_IOCTL_WORDWRAP_SET_MARGIN,
+                      &margin);
+      mu_stream_printf (str, "%s", gettext (p->docstring));
+    }
+  margin = 0;
+  mu_stream_ioctl (str, MU_IOCTL_WORDWRAPSTREAM,
+                  MU_IOCTL_WORDWRAP_SET_MARGIN,
+                  &margin);
   mu_stream_printf (str,
                      _("\nTry `%s COMMAND --help' to get help on a particular "
                      "COMMAND.\n\n"),
                      mu_program_name);
-  mu_stream_printf (str, "%s\n", _("Options are:"));
-  mu_stream_flush (str);
-  mu_stream_size (str, &size);
-  ret = mu_alloc (size + 1);
-  mu_stream_seek (str, 0, MU_SEEK_SET, NULL);
-  mu_stream_read (str, ret, size, &n);
-  ret[n] = 0;
-  mu_stream_destroy (&str);
-  return ret;
+  mu_stream_printf (str, "%s\n", _("OPTIONs are:"));
 }
     
diff --git a/mu/filter.c b/mu/filter.c
index 33a5588..ea23979 100644
--- a/mu/filter.c
+++ b/mu/filter.c
@@ -23,57 +23,41 @@
 #include "argp.h"
 #include "mu.h"
 
-static char filter_doc[] = N_("mu filter - apply a chain of filters to the 
input");
 char filter_docstring[] = N_("apply a chain of filters to the input");
 static char filter_args_doc[] = N_("[~]NAME [ARGS] [+ [~]NAME [ARGS]...]");
 
-static struct argp_option filter_options[] = {
-  { "encode", 'e', NULL, 0, N_("encode the input (default)") },
-  { "decode", 'd', NULL, 0, N_("decode the input") },
-  { "newline", 'n', NULL, 0, N_("print additional newline") },
-  { "list", 'L', NULL, 0, N_("list supported filters") },
-  { NULL }
-};
-
 static int filter_mode = MU_FILTER_ENCODE;
 static int newline_option = 0;
 static int list_option;
 
-static error_t
-filter_parse_opt (int key, char *arg, struct argp_state *state)
+static void
+set_encode_mode (struct mu_parseopt *po, struct mu_option *opt,
+                char const *arg)
 {
-  switch (key)
-    {
-    case 'e':
-      filter_mode = MU_FILTER_ENCODE;
-      break;
-
-    case 'd':
-      filter_mode = MU_FILTER_DECODE;
-      break;
-
-    case 'n':
-      newline_option = 1;
-      break;
+  filter_mode = MU_FILTER_ENCODE;
+}
 
-    case 'L':
-      list_option = 1;
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
+static void
+set_decode_mode (struct mu_parseopt *po, struct mu_option *opt,
+                char const *arg)
+{
+  filter_mode = MU_FILTER_DECODE;
 }
 
-static struct argp filter_argp = {
-  filter_options,
-  filter_parse_opt,
-  filter_args_doc,
-  filter_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option filter_options[] = {
+  { "encode", 'e', NULL, MU_OPTION_DEFAULT,
+    N_("encode the input (default)"),
+    mu_c_string, NULL, set_encode_mode },
+  { "decode", 'd', NULL, MU_OPTION_DEFAULT,
+    N_("decode the input"),
+    mu_c_string, NULL, set_decode_mode },
+  { "newline", 'n', NULL, MU_OPTION_DEFAULT,
+    N_("print additional newline"),
+    mu_c_bool, &newline_option },
+  { "list", 'L', NULL, MU_OPTION_DEFAULT,
+    N_("list supported filters"),
+    mu_c_bool, &list_option },
+  MU_OPTION_END
 };
 
 static int
@@ -85,7 +69,7 @@ filter_printer (void *item, void *data)
 }
 
 static int
-list_filters ()
+list_filters (void)
 {
   mu_list_t list;
   int rc = mu_filter_get_list (&list);
@@ -111,17 +95,14 @@ negate_filter_mode (int mode)
 int
 mutool_filter (int argc, char **argv)
 {
-  int rc, index;
+  int rc;
   mu_stream_t flt, prev_stream;
   const char *fltname;
   int mode;
-  
-  if (argp_parse (&filter_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
-
-  argc -= index;
-  argv += index;
 
+  mu_action_getopt (&argc, &argv, filter_options, filter_docstring,
+                   filter_args_doc);
+  
   if (list_option)
     {
       if (argc)
diff --git a/mu/flt2047.c b/mu/flt2047.c
index df02409..eb99b7b 100644
--- a/mu/flt2047.c
+++ b/mu/flt2047.c
@@ -14,87 +14,50 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <mailutils/mailutils.h>
-#include "argp.h"
 #include "mu.h"
 
-static char flt2047_doc[] = N_("mu 2047 - decode/encode message headers.");
 char flt2047_docstring[] = N_("decode/encode email message headers");
 static char flt2047_args_doc[] = N_("[text]");
 
-static struct argp_option flt2047_options[] = {
-  { "encode", 'e', NULL, 0, N_("encode the input (default)") },
-  { "decode", 'd', NULL, 0, N_("decode the input") },
-  { "newline", 'n', NULL, 0, N_("print additional newline") },
-  { "charset", 'c', N_("NAME"), 0,
-    N_("set charset (default: iso-8859-1)") },
-  { "encoding", 'E', N_("NAME"), 0,
-    N_("set encoding (default: quoted-printable)") },
-  { NULL }
-};
-  
 static int decode_mode = 0;
 static int newline_option = 0;
 static const char *charset = "iso-8859-1";
 static const char *encoding = "quoted-printable";
 
-static error_t
-flt2047_parse_opt (int key, char *arg, struct argp_state *state)
+static void
+set_encode_mode (struct mu_parseopt *po, struct mu_option *opt,
+                char const *arg)
 {
-  switch (key)
-    {
-    case 'c':
-      charset = arg;
-      break;
-      
-    case 'e':
-      decode_mode = 0;
-      break;
-
-    case 'E':
-      encoding = arg;
-      break;
-
-    case 'd':
-      decode_mode = 1;
-      break;
-
-    case 'n':
-      newline_option = 0;
-      break;
-
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
+  decode_mode = 0;
 }
 
-static struct argp flt2047_argp = {
-  flt2047_options,
-  flt2047_parse_opt,
-  flt2047_args_doc,
-  flt2047_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option flt2047_options[] = {
+  { "encode", 'e', NULL, MU_OPTION_DEFAULT,
+    N_("encode the input (default)"),
+    mu_c_string, NULL, set_encode_mode },
+  { "decode", 'd', NULL, MU_OPTION_DEFAULT,
+    N_("decode the input"),
+    mu_c_bool, &decode_mode },
+  { "newline", 'n', NULL, MU_OPTION_DEFAULT,
+    N_("print additional newline"),
+    mu_c_bool, &newline_option },  
+  { "charset", 'c', N_("NAME"), MU_OPTION_DEFAULT,
+    N_("set charset (default: iso-8859-1)"),
+    mu_c_string, &charset },
+  { "encoding", 'E', N_("NAME"), MU_OPTION_DEFAULT,
+    N_("set encoding (default: quoted-printable)"),
+    mu_c_string, &encoding },
+  MU_OPTION_END
 };
-
+  
 int
 mutool_flt2047 (int argc, char **argv)
 {
-  int rc, index;
+  int rc;
   char *p;
-  
-  if (argp_parse (&flt2047_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
 
-  argc -= index;
-  argv += index;
+  mu_action_getopt (&argc, &argv, flt2047_options, flt2047_docstring,
+                   flt2047_args_doc);
 
   if (argc)
     {
diff --git a/mu/getans.c b/mu/getans.c
index dc59401..529aca4 100644
--- a/mu/getans.c
+++ b/mu/getans.c
@@ -14,10 +14,6 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <mailutils/mailutils.h>
 #include "mu.h"
 
 int
diff --git a/mu/getarg.c b/mu/getarg.c
index f7197df..6a084ed 100644
--- a/mu/getarg.c
+++ b/mu/getarg.c
@@ -14,16 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <mailutils/mailutils.h>
 #include "mu.h"
+#include <netdb.h>
 
 int
 get_bool (const char *str, int *pb)
diff --git a/mu/getyn.c b/mu/getyn.c
index eb36492..d721f96 100644
--- a/mu/getyn.c
+++ b/mu/getyn.c
@@ -14,10 +14,6 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <mailutils/mailutils.h>
 #include "mu.h"
 
 int
diff --git a/mu/help.c b/mu/help.c
index 9889cab..3334417 100644
--- a/mu/help.c
+++ b/mu/help.c
@@ -29,37 +29,24 @@ static char help_doc[] = N_("mu help - display a terse help 
summary");
 char help_docstring[] = N_("display a terse help summary");
 static char help_args_doc[] = N_("[COMMAND]");
 
-static struct argp help_argp = {
-  NULL,
-  NULL,
-  help_args_doc,
-  help_doc,
-  NULL,
-  NULL,
-  NULL
-};
-
 int
 mutool_help (int argc, char **argv)
 {
-  int index;
-
-  if (argp_parse (&help_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
+  mu_action_getopt (&argc, &argv, NULL, help_doc, help_args_doc);
 
-  if (index == argc - 1)
+  if (argc == 1)
     {
-      mutool_action_t action = dispatch_find_action (argv[index]);
+      mutool_action_t action = dispatch_find_action (argv[0]);
       if (!action)
        {
-         mu_error (_("don't know what %s is"), argv[index]);
+         mu_error (_("don't know what %s is"), argv[0]);
          exit (1);
        }
-      mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[index]);
+      mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[0]);
       argv[1] = "--help";
       return action (2, argv);
     }
-  else if (argc != index)
+  else if (argc > 1)
     {
       mu_error (_("too many arguments"));
       exit (1);
diff --git a/mu/imap.c b/mu/imap.c
index 3aee4fb..3f64817 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -31,35 +31,7 @@
 #include "mu.h"
 #include "argp.h"
 
-static char imap_doc[] = N_("mu imap - IMAP4 client shell.");
 char imap_docstring[] = N_("IMAP4 client shell");
-static char imap_args_doc[] = "";
-
-static struct argp_option imap_options[] = {
-  { NULL }
-};
-
-static error_t
-imap_parse_opt (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp imap_argp = {
-  imap_options,
-  imap_parse_opt,
-  imap_args_doc,
-  imap_doc,
-  NULL,
-  NULL,
-  NULL
-};
-
 
 static mu_imap_t imap;
 static int uid_mode;
@@ -1336,13 +1308,7 @@ struct mutool_command imap_comtab[] = {
 int
 mutool_imap (int argc, char **argv)
 {
-  int index;
-
-  if (argp_parse (&imap_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
-
-  argc -= index;
-  argv += index;
+  mu_action_getopt (&argc, &argv, NULL, imap_docstring, NULL);
 
   if (argc)
     {
diff --git a/mu/info.c b/mu/info.c
index c44e7e1..dfbb2df 100644
--- a/mu/info.c
+++ b/mu/info.c
@@ -14,13 +14,6 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <mailutils/mailutils.h>
-#include "argp.h"
 #include "mu.h"
 
 static char info_doc[] = N_("mu info - print a list of configuration\
@@ -29,49 +22,19 @@ static char info_doc[] = N_("mu info - print a list of 
configuration\
 char info_docstring[] = N_("show Mailutils configuration");
 static char info_args_doc[] = N_("[capa...]");
 
-static struct argp_option info_options[] = {
-  { "verbose", 'v', NULL, 0,
-    N_("increase output verbosity"), 0},
-  { NULL }
-};
-
 static int verbose;
 
-static error_t
-info_parse_opt (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    case 'v':
-      verbose++;
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp info_argp = {
-  info_options,
-  info_parse_opt,
-  info_args_doc,
-  info_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option info_options[] = {
+  { "verbose", 'v', NULL, MU_OPTION_DEFAULT,
+    N_("increase output verbosity"),
+    mu_c_bool, &verbose },
+  MU_OPTION_END
 };
 
 int
 mutool_info (int argc, char **argv)
 {
-  int index;
-  
-  if (argp_parse (&info_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
-
-  argc -= index;
-  argv += index;
+  mu_action_getopt (&argc, &argv, info_options, info_doc, info_args_doc);
 
   if (argc == 0)
     mu_format_options (mu_strout, verbose);
diff --git a/mu/ldflags.c b/mu/ldflags.c
index 71f80a6..7f52bf2 100644
--- a/mu/ldflags.c
+++ b/mu/ldflags.c
@@ -14,28 +14,11 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/libcfg.h>
-#include <argp.h>
+#include "mu.h"
 
-static char ldflags_doc[] = N_("mu ldflags - list libraries required to link");
 char ldflags_docstring[] = N_("list libraries required to link");
 static char ldflags_args_doc[] = N_("KEYWORD [KEYWORD...]");
 
-static struct argp ldflags_argp = {
-  NULL,
-  NULL,
-  ldflags_args_doc,
-  ldflags_doc,
-  NULL,
-  NULL,
-  NULL
-};
-
 
 #ifdef WITH_TLS
 # define NEEDAUTH "-lmu_auth " AUTHLIBS
@@ -140,13 +123,9 @@ sort_entries ()
 int
 mutool_ldflags (int argc, char **argv)
 {
-  int i, j;
-  
-  if (argp_parse (&ldflags_argp, argc, argv, ARGP_IN_ORDER, &i, NULL))
-    return 1;
+  int j;
 
-  argc -= i;
-  argv += i;
+  mu_action_getopt (&argc, &argv, NULL, ldflags_docstring, ldflags_args_doc);
   
   add_entry (-100, LINK_FLAGS);
   add_entry (100, LINK_POSTFLAGS);
diff --git a/mu/logger.c b/mu/logger.c
index 37520dd..18a425a 100644
--- a/mu/logger.c
+++ b/mu/logger.c
@@ -14,35 +14,11 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <mailutils/mailutils.h>
-#include "argp.h"
 #include "mu.h"
 
-static char logger_doc[] = N_("mu logger - log data using Mailutils log 
facility");
 char logger_docstring[] = N_("log data using Mailutils log facility");
 static char logger_args_doc[] = N_("[TEXT]");
 
-#define OPT_SYSLOG 256
-#define OPT_STDERR 257
-
-static struct argp_option logger_options[] = {
-  { "file", 'f', N_("FILE"), 0, N_("read message from FILE") },
-  { "priority", 'p', N_("FACILITY[.LEVEL]"), 0,
-    N_("log at the specified syslog priority (implies --syslog)") },
-  { "syslog", OPT_SYSLOG, NULL, 0, N_("log via syslog") },
-  { "stderr", OPT_STDERR, NULL, 0, N_("log to the standard error") },
-  { "severity", 's', N_("SEV"), 0,
-    N_("log at Mailutils severity level SEV") },
-  { "locus", 'l', N_("FILE:LINE[:COL]"), 0,
-    N_("set locus for logging") },
-  { "tag", 't', N_("syslog tag"), 0,
-    N_("set syslog tag") },
-  { NULL }
-};
-
 static char *input_file = NULL;
 static int logger_type = MU_STRERR_STDERR;
 static int log_severity = MU_LOG_ERROR;
@@ -51,104 +27,119 @@ static int syslog_facility = LOG_USER;
 static int syslog_priority = LOG_ERR;
 static char *syslog_tag = NULL;
 
-static error_t
-logger_parse_opt (int key, char *arg, struct argp_state *state)
+static void
+set_priority (struct mu_parseopt *po, struct mu_option *opt,
+             char const *arg)
 {
-  switch (key)
+  char *s = strchr (arg, '.');
+  if (s)
+    *s++ = 0;
+  if (mu_string_to_syslog_facility (arg, &syslog_facility))
     {
-    case 'f':
-      input_file = arg;
-      break;
+      mu_parseopt_error (po, _("unknown facility: %s"), arg);
+      exit (po->po_exit_error);
+    }
+  if (s && mu_string_to_syslog_priority (s, &syslog_priority))
+    {
+      mu_parseopt_error (po, _("unknown priority: %s"), s);
+      exit (po->po_exit_error);
+    }
+  
+  logger_type = MU_STRERR_SYSLOG;
+}
 
-    case OPT_SYSLOG:
-      logger_type = MU_STRERR_SYSLOG;
-      break;
+static void
+set_syslog (struct mu_parseopt *po, struct mu_option *opt,
+           char const *arg)
+{
+  logger_type = MU_STRERR_SYSLOG;
+}
 
-    case OPT_STDERR:
-      logger_type = MU_STRERR_STDERR;
-      break;
+static void
+set_stderr (struct mu_parseopt *po, struct mu_option *opt,
+           char const *arg)
+{
+  logger_type = MU_STRERR_STDERR;
+}
 
-    case 's':
+static void
+set_severity (struct mu_parseopt *po, struct mu_option *opt,
+             char const *arg)
+{
+  int i;
+  
+  for (i = 0; i < _mu_severity_num; i++)
+    if (mu_c_strcasecmp (_mu_severity_str[i], arg) == 0)
       {
-       int i;
+       log_severity = i;
+       return;
+      }
+  mu_parseopt_error (po, _("unknown severity: %s"), arg);
+  exit (po->po_exit_error);
+}
 
-       for (i = 0; i < _mu_severity_num; i++)
-         if (mu_c_strcasecmp (_mu_severity_str[i], arg) == 0)
+static void
+set_locus (struct mu_parseopt *po, struct mu_option *opt,
+          char const *arg)
+{
+  char *s;
+  
+  locus.mu_file = mu_strdup (arg);
+  s = strchr (arg, ':');
+  if (s)
+    {
+      *s++ = 0;
+      locus.mu_line = strtoul (s, &s, 10);
+      if (*s == ':')
+       {
+         locus.mu_col = strtoul (s + 1, &s, 10);
+         if (*s)
            {
-             log_severity = i;
-             return 0;
+             mu_parseopt_error (po, _("bad column number: %s"), arg);
+             exit (po->po_exit_error);
            }
-       argp_error (state, _("unknown severity: %s"), arg);
-       break;
-      }
-
-    case 't':
-      syslog_tag = arg;
-      break;
-      
-    case 'p':
-      {
-       char *s = strchr (arg, '.');
-       if (s)
-         *s++ = 0;
-       if (mu_string_to_syslog_facility (arg, &syslog_facility))
-         argp_error (state, _("unknown facility: %s"), arg);
-       if (s &&
-           mu_string_to_syslog_priority (s, &syslog_priority))
-         argp_error (state, _("unknown priority: %s"), s);
-       logger_type = MU_STRERR_SYSLOG;
-       break;
-      }
-      
-    case 'l':
-      {
-       char *s;
-       
-       locus.mu_file = arg;
-       s = strchr (arg, ':');
-       if (s)
-         {
-           *s++ = 0;
-           locus.mu_line = strtoul (s, &s, 10);
-           if (*s == ':')
-             {
-               locus.mu_col = strtoul (s + 1, &s, 10);
-               if (*s)
-                 argp_error (state, _("bad column number: %s"), arg);
-             }
-           else if (*s)
-             argp_error (state, _("bad line number: %s"), arg);
-         }
-       break;
-      }
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
+       }
+      else if (*s)
+       {
+         mu_parseopt_error (po, _("bad line number: %s"), arg);
+         exit (po->po_exit_error);
+       }
     }
-  return 0;
 }
 
-static struct argp logger_argp = {
-  logger_options,
-  logger_parse_opt,
-  logger_args_doc,
-  logger_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option logger_options[] = {
+  { "file", 'f', N_("FILE"), MU_OPTION_DEFAULT,
+    N_("read message from FILE"),
+    mu_c_string, &input_file },
+  { "priority", 'p', N_("FACILITY[.LEVEL]"), MU_OPTION_DEFAULT,
+    N_("log at the specified syslog priority (implies --syslog)"),
+    mu_c_string, NULL, set_priority },
+  { "syslog", 0, NULL, MU_OPTION_DEFAULT,
+    N_("log via syslog"),
+    mu_c_string, NULL, set_syslog },
+  { "stderr", 0, NULL, MU_OPTION_DEFAULT,
+    N_("log to the standard error"),
+    mu_c_string, NULL, set_stderr },  
+  { "severity", 's', N_("SEV"), MU_OPTION_DEFAULT,
+    N_("log at Mailutils severity level SEV"),
+    mu_c_string, NULL, set_severity },
+  { "locus", 'l', N_("FILE:LINE[:COL]"), MU_OPTION_DEFAULT,
+    N_("set locus for logging"),
+    mu_c_string, NULL, set_locus },
+  { "tag", 't', N_("TAG"), MU_OPTION_DEFAULT,
+    N_("set syslog tag"),
+    mu_c_string, &syslog_tag },
+  MU_OPTION_END
 };
 
 int
 mutool_logger (int argc, char **argv)
 {
-  int index;
   mu_stream_t logger, input;
   int rc, mode;
-  
-  if (argp_parse (&logger_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
-  argc -= index;
-  argv += index;
+
+  mu_action_getopt (&argc, &argv, logger_options, logger_docstring,
+                   logger_args_doc);
 
   if (argc && input_file)
     {
diff --git a/mu/mu.c b/mu/mu.c
index 6334414..0b471aa 100644
--- a/mu/mu.c
+++ b/mu/mu.c
@@ -21,58 +21,17 @@
 #include <string.h>
 #include <mailutils/mailutils.h>
 #include <mailutils/tls.h>
-#include "mailutils/libargp.h"
+#include "mailutils/cli.h"
 #include "mu.h"
 
-static char args_doc[] = N_("COMMAND [CMDOPTS]");
-static char doc[] = N_("GNU Mailutils multi-purpose tool.");
-
-static struct argp_option options[] = {
-  { NULL }
+struct mu_cli_setup cli = {
+  .prog_doc = N_("GNU Mailutils multi-purpose tool."),
+  .prog_args = N_("COMMAND [CMDOPTS]"),
+  .inorder = 1,
+  .prog_doc_hook = subcommand_help
 };
 
-static error_t
-parse_opt (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static char *
-mu_help_filter (int key, const char *text, void *input)
-{
-  char *s;
-  
-  switch (key)
-    {
-    case ARGP_KEY_HELP_PRE_DOC:
-      s = dispatch_docstring (text);
-      break;
-
-    default:
-      s = (char*) text;
-    }
-  return s;
-}
-
-
-static struct argp argp = {
-  options,
-  parse_opt,
-  args_doc,
-  doc,
-  NULL,
-  mu_help_filter,
-  NULL
-};
-
-static const char *mu_tool_capa[] = {
-  "mailutils",
-  "common",
+static char *capa[] = {
   "debug",
   "locking",
   "mailbox",
@@ -80,26 +39,9 @@ static const char *mu_tool_capa[] = {
   NULL 
 };
 
-struct mu_cfg_param mu_tool_param[] = {
-  { NULL }
-};
-
-int
-mu_help ()
-{
-  char *x_argv[3];
-    
-  x_argv[0] = (char*) mu_program_name;
-  x_argv[1] = "--help";
-  x_argv[2] = NULL;
-  return mu_app_init (&argp, mu_tool_capa, mu_tool_param, 
-                     2, x_argv, 0, NULL, NULL);
-}
-
 int
 main (int argc, char **argv)
 {
-  int index;
   mutool_action_t action;
   
   /* Native Language Support */
@@ -109,16 +51,7 @@ main (int argc, char **argv)
   /* Register the desired mailbox formats.  */
   mu_register_all_mbox_formats ();
 
-#ifdef WITH_TLS
-  mu_gocs_register ("tls", mu_tls_module_init);
-#endif
-  mu_argp_init (NULL, NULL);
-  if (mu_app_init (&argp, mu_tool_capa, mu_tool_param, 
-                  argc, argv, ARGP_IN_ORDER, &index, NULL))
-    exit (1);
-
-  argc -= index;
-  argv += index;
+  mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
 
   if (argc < 1)
     {
@@ -133,16 +66,60 @@ main (int argc, char **argv)
       exit (1);
     }
 
-  /* Disable --version option in action. */
-  argp_program_version = NULL;
-  argp_program_version_hook = NULL;
-
-  /* Reset argv[0] for diagnostic purposes */
-  mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[0]);
-  
   /* Run the action. */
   exit (action (argc, argv));
 }
+
+int
+mu_help (void)
+{
+  char *argv[3];
+  argv[0] = mu_full_program_name;
+  argv[1] = "--help";
+  argv[2] = NULL;
+  mu_cli (2, argv, &cli, capa, NULL, NULL, NULL);
+  return 0;
+} 
+
+void
+mu_action_getopt (int *pargc, char ***pargv, struct mu_option *opt,
+                 char const *docstring, char const *argdoc)
+{
+  struct mu_parseopt po;
+  int flags = MU_PARSEOPT_IMMEDIATE;
+  struct mu_option *options[2];
+  char const *prog_args[2];
+  char *progname;
+  
+  options[0] = opt;
+  options[1] = NULL;
+
+  mu_asprintf (&progname, "%s %s", mu_program_name, (*pargv)[0]);
+  po.po_prog_name = progname;
+  flags |= MU_PARSEOPT_PROG_NAME;
+  
+  po.po_prog_doc = docstring;
+  flags |= MU_PARSEOPT_PROG_DOC;
+
+  if (argdoc)
+    {
+      prog_args[0] = argdoc;
+      prog_args[1] = NULL;
+      po.po_prog_args = prog_args;
+      flags |= MU_PARSEOPT_PROG_ARGS;
+    }
+  
+  po.po_bug_address = PACKAGE_BUGREPORT;
+  flags |= MU_PARSEOPT_BUG_ADDRESS;
+
+  if (mu_parseopt (&po, *pargc, *pargv, options, flags))
+    exit (po.po_exit_error);
+
+  *pargc -= po.po_arg_start;
+  *pargv += po.po_arg_start;
+  
+  mu_parseopt_free (&po);  
+}
 
   
   
diff --git a/mu/mu.h b/mu/mu.h
index 51f1463..c6771c2 100644
--- a/mu/mu.h
+++ b/mu/mu.h
@@ -14,7 +14,17 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include <mailutils/types.h>
+#if defined(HAVE_CONFIG_H)
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include <sysexits.h>
+#include <mailutils/mailutils.h>
 
 typedef int (*mutool_action_t) (int argc, char **argv);
 
@@ -40,7 +50,7 @@ mu_stream_t mutool_open_pager (void);
 
 int mu_help (void);
 mutool_action_t dispatch_find_action (const char *name);
-char *dispatch_docstring (const char *text);
+void subcommand_help (mu_stream_t str);
 
 int port_from_sa (struct mu_sockaddr *sa);
 
@@ -64,3 +74,6 @@ int get_port (const char *port_str, int *pn);
 
 int mu_getans (const char *variants, const char *fmt, ...);
 
+void mu_action_getopt (int *pargc, char ***pargv, struct mu_option *opt,
+                      char const *docstring, char const *argdoc);
+
diff --git a/mu/pop.c b/mu/pop.c
index 0ae586f..7a24011 100644
--- a/mu/pop.c
+++ b/mu/pop.c
@@ -14,48 +14,9 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <mailutils/mailutils.h>
 #include "mu.h"
-#include "argp.h"
 
-static char pop_doc[] = N_("mu pop - POP3 client shell.");
 char pop_docstring[] = N_("POP3 client shell");
-static char pop_args_doc[] = "";
-
-static struct argp_option pop_options[] = {
-  { NULL }
-};
-
-static error_t
-pop_parse_opt (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp pop_argp = {
-  pop_options,
-  pop_parse_opt,
-  pop_args_doc,
-  pop_doc,
-  NULL,
-  NULL,
-  NULL
-};
 
 /* Global handle for pop3.  */
 static mu_pop3_t pop3;
@@ -656,13 +617,7 @@ struct mutool_command pop_comtab[] = {
 int
 mutool_pop (int argc, char **argv)
 {
-  int index;
-
-  if (argp_parse (&pop_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
-  
-  argc -= index;
-  argv += index;
+  mu_action_getopt (&argc, &argv, NULL, pop_docstring, NULL);
 
   if (argc)
     {
diff --git a/mu/query.c b/mu/query.c
index 6223293..d0016da 100644
--- a/mu/query.c
+++ b/mu/query.c
@@ -14,98 +14,44 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/libcfg.h>
-#include "argp.h"
 #include "mu.h"
 
-static char query_doc[] = N_("mu query - query configuration values.");
 char query_docstring[] = N_("query configuration values");
 static char query_args_doc[] = N_("path [path...]");
 
 static char *file_name;
-static struct mu_cfg_parse_hints hints;
+int value_option;
+int path_option;
+int verbose_option;
+char *progname;
 
-enum {
-  VALUE_OPTION = 256,
-  PATH_OPTION
-};
-
-static struct argp_option query_options[] = {
-  { "file", 'f', N_("FILE"), 0,
+static struct mu_option query_options[] = {
+  { "file", 'f', N_("FILE"), MU_OPTION_DEFAULT,
     N_("query configuration values from FILE (default mailutils.rc)"),
-    0 },
-  { "value", VALUE_OPTION, NULL, 0,
+    mu_c_string, &file_name },
+  { "value", 0, NULL, MU_OPTION_DEFAULT,
     N_("display parameter values only"),
-    0 },
-  { "program", 'p', N_("NAME"), 0,
+    mu_c_bool, &value_option },
+  { "program", 'p', N_("NAME"), MU_OPTION_DEFAULT,
     N_("set program name for configuration lookup"),
-    0 },
-  { "path", PATH_OPTION, NULL, 0,
-    N_("display parameters as paths") },
-  { "verbose", 'v', NULL, 0,
-    N_("increase output verbosity"), 0},
-  { NULL }
-};
-
-static error_t
-query_parse_opt (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    case 'f':
-      file_name = arg;
-      break;
-
-    case 'p':
-      hints.flags |= MU_CFG_PARSE_PROGRAM;
-      hints.program = arg;
-      break;
-      
-    case 'v':
-      hints.flags |= MU_CFG_FMT_LOCUS;
-      break;
-
-    case VALUE_OPTION:
-      hints.flags |= MU_CFG_FMT_VALUE_ONLY;
-      break;
-      
-    case PATH_OPTION:
-      hints.flags |= MU_CFG_FMT_PARAM_PATH;
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp query_argp = {
-  query_options,
-  query_parse_opt,
-  query_args_doc,
-  query_doc,
-  NULL,
-  NULL,
-  NULL
+    mu_c_string, &progname },
+  { "path", 0, NULL, MU_OPTION_DEFAULT,
+    N_("display parameters as paths"),
+    mu_c_bool, &path_option },
+  { "verbose", 'v', NULL, MU_OPTION_DEFAULT,
+    N_("increase output verbosity"),
+    mu_c_bool, &verbose_option },
+  MU_OPTION_END
 };
 
 int
 mutool_query (int argc, char **argv)
 {
-  int index;
+  static struct mu_cfg_parse_hints hints;
   mu_cfg_tree_t *tree = NULL;
-  
-  if (argp_parse (&query_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
-    return 1;
 
-  argc -= index;
-  argv += index;
+  mu_action_getopt (&argc, &argv, query_options, query_docstring,
+                   query_args_doc);
 
   if (argc == 0)
     {
@@ -113,8 +59,21 @@ mutool_query (int argc, char **argv)
       return 1;
     }
 
-  hints.flags |= MU_CFG_PARSE_SITE_RCFILE | MU_PARSE_CONFIG_GLOBAL;
-  hints.site_rcfile = file_name ? file_name : mu_site_rcfile;
+  hints.flags = MU_CFG_PARSE_SITE_RCFILE | MU_PARSE_CONFIG_GLOBAL;
+  hints.site_rcfile = file_name ? file_name : mu_site_config_file ();
+
+  if (progname)
+    {
+      hints.flags |= MU_CFG_PARSE_PROGRAM;
+      hints.program = progname;
+    }
+
+  if (verbose_option)
+    hints.flags |= MU_CFG_FMT_LOCUS;
+  if (value_option)
+    hints.flags |= MU_CFG_FMT_VALUE_ONLY;
+  if (path_option)
+    hints.flags |= MU_CFG_FMT_PARAM_PATH;
   
   if (mu_cfg_parse_config (&tree, &hints))
     return 1;
diff --git a/mu/send.c b/mu/send.c
index a069df0..9a82f20 100644
--- a/mu/send.c
+++ b/mu/send.c
@@ -14,17 +14,6 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <mailutils/cctype.h>
-#include <mailutils/mailutils.h>
-#include <argp.h>
 #include "mu.h"
 
 static int read_recipients;
@@ -46,59 +35,41 @@ send_address_add (mu_address_t *paddr, const char *value)
   MU_ASSERT (mu_address_union (paddr, addr));
   mu_address_destroy (&addr);
 }
-
-static char send_doc[] = N_("mu send - send a message.");
+
 char send_docstring[] = N_("send a message");
 static char send_args_doc[] = "URL-or-HOST [FILE]";
 
-static struct argp_option send_options[] = {
-  { "from",  'F', N_("ADDRESS"), 0,
-    N_("send mail from this ADDRESS") },
-  { "rcpt",  'T', N_("ADDRESS"), 0,
-    N_("send mail to this ADDRESS") },
-  { "read-recipients", 't', NULL, 0,
-    N_("read recipients from the message") },
-  { NULL }
-};
-
-static error_t
-send_parse_opt (int key, char *arg, struct argp_state *state)
+static void
+set_from_address (struct mu_parseopt *po, struct mu_option *opt,
+                 char const *arg)
 {
-  switch (key)
-    {
-    case 'F':
-      MU_ASSERT (mu_address_create_null (&from_addr));
-      send_address_add (&from_addr, arg);
-      break;
-
-    case 'T':
-      send_address_add (&rcpt_addr, arg);
-      break;
-
-    case 't':
-      read_recipients = 1;
-      break;
+  MU_ASSERT (mu_address_create_null (&from_addr));
+  send_address_add (&from_addr, arg);
+}
 
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
+static void
+set_rcpt_address (struct mu_parseopt *po, struct mu_option *opt,
+                 char const *arg)
+{
+  send_address_add (&rcpt_addr, arg);
 }
 
-static struct argp send_argp = {
-  send_options,
-  send_parse_opt,
-  send_args_doc,
-  send_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option send_options[] = {
+  { "from",  'F', N_("ADDRESS"), MU_OPTION_DEFAULT,
+    N_("send mail from this ADDRESS"),
+    mu_c_string, NULL, set_from_address },
+  { "rcpt",  'T', N_("ADDRESS"), MU_OPTION_DEFAULT,
+    N_("send mail to this ADDRESS"),
+    mu_c_string, NULL, set_rcpt_address },
+  { "read-recipients", 't', NULL, MU_OPTION_DEFAULT,
+    N_("read recipients from the message"),
+    mu_c_bool, &read_recipients },
+  MU_OPTION_END
 };
 
 int
 mutool_send (int argc, char **argv)
 {
-  int index;
   char *infile;
   mu_stream_t instr;
   mu_message_t msg;
@@ -108,12 +79,8 @@ mutool_send (int argc, char **argv)
   
   MU_ASSERT (mu_address_create_null (&rcpt_addr));
   mu_register_all_mailer_formats ();
-  
-  if (argp_parse (&send_argp, argc, argv, 0, &index, NULL))
-    return 1;
 
-  argc -= index;
-  argv += index;
+  mu_action_getopt (&argc, &argv, send_options, send_docstring, send_args_doc);
 
   if (argc < 1)
     {
diff --git a/mu/shell.c b/mu/shell.c
index 30966d9..ff4bd05 100644
--- a/mu/shell.c
+++ b/mu/shell.c
@@ -14,17 +14,9 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
+#include "mu.h"
 #include <signal.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/tls.h>
-#include "mailutils/libargp.h"
 #include "muaux.h"
-#include "mu.h"
 
 #ifdef WITH_READLINE
 # include <readline/readline.h>
diff --git a/mu/smtp.c b/mu/smtp.c
index d9ac79b..bc6d292 100644
--- a/mu/smtp.c
+++ b/mu/smtp.c
@@ -28,34 +28,7 @@
 #include <argp.h>
 #include "mu.h"
 
-static char smtp_doc[] = N_("mu smtp - run a SMTP session.");
 char smtp_docstring[] = N_("run a SMTP session");
-static char smtp_args_doc[] = "";
-
-static struct argp_option smtp_options[] = {
-  { NULL }
-};
-
-static error_t
-smtp_parse_opt (int key, char *arg, struct argp_state *state)
-{
-  switch (key)
-    {
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp smtp_argp = {
-  smtp_options,
-  smtp_parse_opt,
-  smtp_args_doc,
-  smtp_doc,
-  NULL,
-  NULL,
-  NULL
-};
 
 enum smtp_session_status
   {
@@ -958,16 +931,10 @@ struct mutool_command smtp_comtab[] = {
 int
 mutool_smtp (int argc, char **argv)
 {
-  int index;
-  
   mu_registrar_record (mu_smtp_record);
   mu_registrar_record (mu_smtps_record);
-  
-  if (argp_parse (&smtp_argp, argc, argv, 0, &index, NULL))
-    return 1;
-
-  argc -= index;
 
+  mu_action_getopt (&argc, &argv, NULL, smtp_docstring, NULL);
   if (argc)
     {
       mu_error (_("bad arguments"));
diff --git a/mu/util.c b/mu/util.c
index c51243a..8ad5afe 100644
--- a/mu/util.c
+++ b/mu/util.c
@@ -14,14 +14,6 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <mailutils/mailutils.h>
 #include "mu.h"
 
 int
diff --git a/mu/verbose.c b/mu/verbose.c
index 070b049..53c979e 100644
--- a/mu/verbose.c
+++ b/mu/verbose.c
@@ -14,12 +14,6 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <mailutils/mailutils.h>
 #include "mu.h"
 
 /* Manipulations with verbosity flags, which are common for pop and imap. */
diff --git a/mu/wicket.c b/mu/wicket.c
index 2855175..7d46125 100644
--- a/mu/wicket.c
+++ b/mu/wicket.c
@@ -14,59 +14,32 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#if defined(HAVE_CONFIG_H)
-# include <config.h>
-#endif
-#include <stdlib.h>
-#include <mailutils/mailutils.h>
-#include <mailutils/libcfg.h>
-#include <argp.h>
-
-static char wicket_doc[] = N_("mu wicket - find matching URL in wicket");
+#include "mu.h"
+
 char wicket_docstring[] = N_("scan wickets for matching URLs");
 static char wicket_args_doc[] = N_("URL");
 
-static struct argp_option wicket_options[] = {
-  { "file",    'f', N_("FILE"), 0, N_("use FILE instead of ~/.mu-tickets") },
-  { "verbose", 'v', NULL,       0, N_("increase output verbosity") },
-  { "quiet",   'q', NULL,       0, N_("suppress any output") },
-  { NULL }
-};
-
 static char *wicket_file = "~/.mu-tickets";
 static int wicket_verbose = 1;
 
-static error_t
-wicket_parse_opt (int key, char *arg, struct argp_state *state)
+static void
+clear_wicket_verbose (struct mu_parseopt *po, struct mu_option *opt,
+                     char const *arg)
 {
-  switch (key)
-    {
-    case 'f':
-      wicket_file = arg;
-      break;
-
-    case 'v':
-      wicket_verbose++;
-      break;
-
-    case 'q':
-      wicket_verbose = 0;
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
+  wicket_verbose = 0;
 }
 
-static struct argp wicket_argp = {
-  wicket_options,
-  wicket_parse_opt,
-  wicket_args_doc,
-  wicket_doc,
-  NULL,
-  NULL,
-  NULL
+static struct mu_option wicket_options[] = {
+  { "file",    'f', N_("FILE"), MU_OPTION_DEFAULT,
+    N_("use FILE instead of ~/.mu-tickets"),
+    mu_c_string, &wicket_file },
+  { "verbose", 'v', NULL,       MU_OPTION_DEFAULT,
+    N_("increase output verbosity"),
+    mu_c_string, &wicket_verbose },
+  { "quiet",   'q', NULL,       MU_OPTION_DEFAULT,
+    N_("suppress any output"),
+    mu_c_string, NULL, clear_wicket_verbose },
+  { NULL }
 };
 
 
@@ -129,12 +102,8 @@ mutool_wicket (int argc, char **argv)
   mu_stream_t stream;
   int rc, i, exit_code;
   
-  if (argp_parse (&wicket_argp, argc, argv, ARGP_IN_ORDER, &i, NULL))
-    return 1;
-
-  argc -= i;
-  argv += i;
-
+  mu_action_getopt (&argc, &argv, wicket_options, wicket_docstring,
+                   wicket_args_doc);
   if (argc == 0)
     {
       mu_error (_("not enough arguments"));
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 135171c..d62e071 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,37 +25,16 @@ imap4d/signal.c
 imap4d/starttls.c
 imap4d/util.c
 
-lib/gnu/argp-help.c
-lib/gnu/argp-parse.c
-lib/gnu/getopt.c
 lib/mailcap.c
 lib/tcpwrap.c
 lib/strexit.c
 lib/manlock.c
 
-libmu_argp/cmdline.c
-libmu_argp/common.c
-libmu_argp/mu_argp.c
-libmu_argp/sieve.c
-
 libmu_auth/ldap.c
 libmu_auth/radius.c
 libmu_auth/sql.c
 libmu_auth/tls.c
 
-libmu_cfg/acl.c
-libmu_cfg/auth.c
-libmu_cfg/common.c
-libmu_cfg/gsasl.c
-libmu_cfg/init.c
-libmu_cfg/ldap.c
-libmu_cfg/pam.c
-libmu_cfg/radius.c
-libmu_cfg/sieve.c
-libmu_cfg/sql.c
-libmu_cfg/tls.c
-libmu_cfg/virtdomain.c
-
 libmu_sieve/actions.c
 libmu_sieve/comparator.c
 libmu_sieve/conf.c
@@ -117,7 +96,6 @@ libmailutils/cfg/driver.c
 libmailutils/cfg/format.c
 libmailutils/cfg/lexer.l
 libmailutils/cfg/parser.y
-libmailutils/cfg/gocs.c
 
 libmailutils/diag/debug.c
 libmailutils/diag/diag.c
diff --git a/pop3d/Makefile.am b/pop3d/Makefile.am
index 7fea649..792acd4 100644
--- a/pop3d/Makefile.am
+++ b/pop3d/Makefile.am
@@ -51,7 +51,7 @@ if MU_COND_DBM
 endif
 
 pop3d_LDADD = \
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_MH}\
  ${MU_LIB_MAILDIR}\
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 9329725..adf1a5c 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -104,8 +104,7 @@ static struct mu_option pop3d_options[] = {
   { "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 },
-
-  {NULL, 0, NULL, 0, NULL, 0}
+  MU_OPTION_END
 }, *options[] = { pop3d_options, NULL };
 
 static int
@@ -308,7 +307,6 @@ static char *capa[] = {
   "mailbox",
   "locking",
   "logging",
-  "tls",
   NULL
 };
 
@@ -585,7 +583,6 @@ main (int argc, char **argv)
 #ifdef ENABLE_DBM
   set_dbm_safety ();
 #endif
-  mu_cli_capa_register (&mu_cli_capa_tls);
 
   mu_cli (argc, argv, &cli, capa, server, &argc, &argv);
   if (argc)
diff --git a/pop3d/pop3d.h b/pop3d/pop3d.h
index 2765690..6a04976 100644
--- a/pop3d/pop3d.h
+++ b/pop3d/pop3d.h
@@ -121,6 +121,7 @@ extern int expire_on_exit;
 #include <mailutils/filter.h>
 #include <mailutils/stdstream.h>
 #include <mailutils/stream.h>
+#include "mailutils/syslog.h"
 
 /* For Berkley DB2 APOP password file */
 #ifdef HAVE_DB_H
diff --git a/readmsg/Makefile.am b/readmsg/Makefile.am
index 57c9dc3..66ffef6 100644
--- a/readmsg/Makefile.am
+++ b/readmsg/Makefile.am
@@ -23,7 +23,7 @@ bin_PROGRAMS = readmsg
 readmsg_SOURCES = readmsg.c msglist.c readmsg.h
 
 readmsg_LDADD =\
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
  ${MU_LIB_POP}\
diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c
index bbbabf5..a405452 100644
--- a/readmsg/readmsg.c
+++ b/readmsg/readmsg.c
@@ -21,6 +21,7 @@
 
 #include "readmsg.h"
 #include "mailutils/cli.h"
+#include "mailutils/mu_auth.h"
 #include "mu_umaxtostr.h"
 
 #define WEEDLIST_SEPARATOR " :,"
@@ -94,7 +95,6 @@ static char *readmsg_argp_capa[] = {
   "debug",
   "mailbox",
   "locking",
-  "tls",
   NULL
 };
 
@@ -242,7 +242,7 @@ main (int argc, char **argv)
   mu_register_all_mbox_formats ();
   mu_register_extra_formats ();
 
-  mu_cli_capa_register (&mu_cli_capa_tls);
+  mu_auth_register_module (&mu_auth_tls_module);
 
   mu_cli (argc, argv, &cli, readmsg_argp_capa, NULL, &argc, &argv);
 
diff --git a/sieve/Makefile.am b/sieve/Makefile.am
index 2a294ba..d51db0c 100644
--- a/sieve/Makefile.am
+++ b/sieve/Makefile.am
@@ -22,7 +22,7 @@ EXTRA_DIST = examples
 bin_PROGRAMS = sieve
 sieve_SOURCES = sieve.c
 sieve_LDADD =\
- ${MU_APP_NEW_LIBRARIES}\
+ ${MU_APP_LIBRARIES}\
  ${MU_LIB_SIEVE}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
diff --git a/sieve/sieve.c b/sieve/sieve.c
index d3738df..8642fc0 100644
--- a/sieve/sieve.c
+++ b/sieve/sieve.c
@@ -44,6 +44,7 @@
 #include <mailutils/nls.h>
 #include <mailutils/tls.h>
 #include <mailutils/cli.h>
+#include <mailutils/mu_auth.h>
 
 #define D_DEFAULT "TPt"
 
@@ -238,7 +239,6 @@ static char *sieve_argp_capa[] = {
   "locking",
   "logging",
   "mailer",
-  "tls",
   "sieve",
   NULL
 };
@@ -394,7 +394,7 @@ main (int argc, char *argv[])
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mu_cli_capa_register (&mu_cli_capa_tls);
+  mu_auth_register_module (&mu_auth_tls_module);
   mu_cli_capa_register (&mu_cli_capa_sieve);
   mu_sieve_debug_init ();
   
diff --git a/sql/sql.c b/sql/sql.c
index 7510592..dddab6f 100644
--- a/sql/sql.c
+++ b/sql/sql.c
@@ -69,7 +69,7 @@ add_disptab (mu_sql_dispatch_t *tab)
 #endif
 
 int
-mu_sql_interface_index (char *name)
+mu_sql_interface_index (char const *name)
 {
   int i;
   //mu_sql_dispatch_t *tab;


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]