From MAILER-DAEMON Tue Nov 01 06:33:48 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c1WO3-0003qR-R6
	for mharc-commit-mailutils@gnu.org; Tue, 01 Nov 2016 06:33:47 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33590)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1WO0-0003ng-RW
	for commit-mailutils@gnu.org; Tue, 01 Nov 2016 06:33:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1WNz-00022Q-24
	for commit-mailutils@gnu.org; Tue, 01 Nov 2016 06:33:44 -0400
Received: from vcs.savannah.gnu.org ([208.118.235.72]:43195)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1WNy-00022M-V3
	for commit-mailutils@gnu.org; Tue, 01 Nov 2016 06:33:42 -0400
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id BA9142201B7; Tue,  1 Nov 2016 10:33:42 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-804-gb4c787e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 2ffea3b6973afdfc0972e33ba99a1faa9c4165de
X-Git-Newrev: b4c787e6ea89ba0005845925cc33070a264d2a77
Message-Id: <20161101103342.BA9142201B7@vcs.savannah.gnu.org>
Date: Tue,  1 Nov 2016 10:33:42 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Nov 2016 10:33:46 -0000

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=b4c787e6ea89ba0005845925cc33070a264d2a77

The branch, master has been updated
       via  b4c787e6ea89ba0005845925cc33070a264d2a77 (commit)
       via  fd11c9136b9d862fa788ecb747cf5d1e9413a869 (commit)
      from  2ffea3b6973afdfc0972e33ba99a1faa9c4165de (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 b4c787e6ea89ba0005845925cc33070a264d2a77
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 1 12:29:46 2016 +0200

    Fix in logstream
    
    * libmailutils/stream/logstream.c (_log_write): Force MU_LOG_LOCUS
    mode if the locus is given explicitly.

commit fd11c9136b9d862fa788ecb747cf5d1e9413a869
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 1 12:27:20 2016 +0200

    Bugfixes in MH
    
    * mh/mh_getopt.c (mh_opt_notimpl_warning): For boolean options,
    don't emit warning if the value would be set to false.
    * mh/anno.c: Fix the type of boolean unimplemented options.
    * mh/refile.c: Likewise.
    * mh/repl.c: Likewise.
    * mh/send.c: Likewise.

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

Summary of changes:
 libmailutils/stream/logstream.c |    3 +++
 mh/anno.c                       |    2 +-
 mh/mh_getopt.c                  |    6 ++++++
 mh/refile.c                     |    2 +-
 mh/repl.c                       |    6 +++---
 mh/send.c                       |    8 ++++----
 6 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/libmailutils/stream/logstream.c b/libmailutils/stream/logstream.c
index d3893e0..019ba83 100644
--- a/libmailutils/stream/logstream.c
+++ b/libmailutils/stream/logstream.c
@@ -168,12 +168,14 @@ _log_write (struct _mu_stream *str, const char *buf, size_t size,
 	  /* Input line (decimal) */
 	  READNUM (n);
 	  _locus_set_line (&loc, n);
+	  logmode |= MU_LOGMODE_LOCUS;
 	  break;
 
 	case 'c':
 	  /* Column in input line (decimal) */
 	  READNUM (n);
 	  _locus_set_col (&loc, n);
+	  logmode |= MU_LOGMODE_LOCUS;
 	  break;
 	  
 	case 'f':
@@ -182,6 +184,7 @@ _log_write (struct _mu_stream *str, const char *buf, size_t size,
 	  fname = buf;
 	  buf += flen;
 	  size -= flen;
+	  logmode |= MU_LOGMODE_LOCUS;
 	  break;
 
 	default:
diff --git a/mh/anno.c b/mh/anno.c
index 604b9be..dab8bd2 100644
--- a/mh/anno.c
+++ b/mh/anno.c
@@ -30,7 +30,7 @@ static char *anno_text;   /* header field value */
 static struct mu_option options[] = {
   { "inplace", 0, NULL, MU_OPTION_HIDDEN,
     N_("annotate the message in place"),
-    mu_c_string, NULL, mh_opt_notimpl_warning },
+    mu_c_bool, NULL, mh_opt_notimpl_warning },
   { "date", 0, NULL, MU_OPTION_DEFAULT,
     N_("add FIELD: date header"),
     mu_c_bool, &anno_date },
diff --git a/mh/mh_getopt.c b/mh/mh_getopt.c
index 08c9001..0e7ec3c 100644
--- a/mh/mh_getopt.c
+++ b/mh/mh_getopt.c
@@ -293,6 +293,12 @@ void
 mh_opt_notimpl_warning (struct mu_parseopt *po, struct mu_option *opt,
 			char const *arg)
 {
+  if (opt->opt_type == mu_c_bool)
+    {
+      int val;
+      if (mu_str_to_c (arg, opt->opt_type, &val, NULL) == 0 && !val)
+	return;
+    }
   mu_error (_("ignoring not implemented option %s"), opt->opt_long);
 }
 
diff --git a/mh/refile.c b/mh/refile.c
index 8c7747d..32ed443 100644
--- a/mh/refile.c
+++ b/mh/refile.c
@@ -63,7 +63,7 @@ static struct mu_option options[] = {
   { "link",    0, NULL, MU_OPTION_ALIAS },
   { "preserve", 0, NULL, MU_OPTION_HIDDEN,
     N_("try to preserve message sequence numbers"),
-    mu_c_string, NULL, mh_opt_notimpl_warning },
+    mu_c_bool, NULL, mh_opt_notimpl_warning },
   { "source", 0, N_("FOLDER"), MU_OPTION_DEFAULT,
     N_("specify source folder; it will become the current folder after the program exits"),
     mu_c_string, NULL, mh_opt_set_folder },
diff --git a/mh/repl.c b/mh/repl.c
index fefa6a2..2d27ab5 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -129,7 +129,7 @@ static struct mu_option options[] = {
     mu_c_string, NULL, clr_cc },
   { "group", 0,  NULL, MU_OPTION_DEFAULT,
     N_("construct a group or followup reply"),
-    mu_c_string, NULL, set_group },
+    mu_c_bool, NULL, set_group },
   { "editor", 0, N_("PROG"), MU_OPTION_DEFAULT,
     N_("set the editor program to use"),
     mu_c_string, &wh_env.editor },
@@ -153,10 +153,10 @@ static struct mu_option options[] = {
     mu_c_string, &mhl_filter, mh_opt_clear_string },
   { "inplace",  0, NULL,   MU_OPTION_HIDDEN,
     N_("annotate the message in place"),
-    mu_c_string, NULL, mh_opt_notimpl_warning },
+    mu_c_bool, NULL, mh_opt_notimpl_warning },
   { "query",    0, NULL,   MU_OPTION_HIDDEN,
     N_("query for addresses to place in To: and Cc: lists"),
-    mu_c_string, NULL, mh_opt_notimpl_warning },
+    mu_c_bool, NULL, mh_opt_notimpl_warning },
   { "width",    0, N_("NUMBER"), MU_OPTION_DEFAULT,
     N_("set output width"),
     mu_c_int, &width },
diff --git a/mh/send.c b/mh/send.c
index 260b5c8..99dd570 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -118,14 +118,14 @@ static struct mu_option options[] = {
     mu_c_string, NULL, mh_opt_notimpl },
   { "nofilter",      0, NULL, MU_OPTION_HIDDEN,
     N_("undo the effect of the last --filter option"),
-    mu_c_string, NULL, mh_opt_notimpl },
+    mu_c_int, NULL, mh_opt_notimpl },
   { "format",        0, NULL, MU_OPTION_HIDDEN,
     N_("reformat To: and Cc: addresses"),
-    mu_c_string, NULL, mh_opt_notimpl_warning },
+    mu_c_bool, NULL, mh_opt_notimpl_warning },
   { "noformat",      0, NULL, MU_OPTION_HIDDEN },
   { "forward",       0, NULL, MU_OPTION_HIDDEN,
     N_("in case of failure forward the draft along with the failure notice to the sender"),
-    mu_c_string, NULL, mh_opt_notimpl_warning },
+    mu_c_bool, NULL, mh_opt_notimpl_warning },
   { "noforward",     0, NULL, MU_OPTION_HIDDEN, "" },
   { "mime",          0, NULL, MU_OPTION_HIDDEN,
     N_("use MIME encapsulation"),
@@ -154,7 +154,7 @@ static struct mu_option options[] = {
     mu_c_bool, &watch },
   { "width",         0, N_("NUMBER"), MU_OPTION_HIDDEN,
     N_("make header fields no longer than NUMBER columns"),
-    mu_c_string, NULL, mh_opt_notimpl_warning },
+    mu_c_uint, NULL, mh_opt_notimpl_warning },
 
   MU_OPTION_END
 };


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 02 09:25:17 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c1vXZ-00066B-Cx
	for mharc-commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:25:17 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:37965)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1vXR-00063k-GW
	for commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:25:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1vXI-0003GY-0y
	for commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:25:09 -0400
Received: from vcs.savannah.gnu.org ([208.118.235.72]:58045)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1vXH-0003G8-PB
	for commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:24:59 -0400
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 6A74C220149; Wed,  2 Nov 2016 13:24:59 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-806-gd434dd4
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b4c787e6ea89ba0005845925cc33070a264d2a77
X-Git-Newrev: d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad
Message-Id: <20161102132459.6A74C220149@vcs.savannah.gnu.org>
Date: Wed,  2 Nov 2016 13:24:59 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Nov 2016 13:25:16 -0000

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=d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad

The branch, master has been updated
       via  d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad (commit)
       via  dc62b3998f0fe8ce0f131e269b130831093264fb (commit)
      from  b4c787e6ea89ba0005845925cc33070a264d2a77 (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 d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 2 15:14:13 2016 +0200

    Rename default configuration file
    
    The default configuration file name is "mailutils.conf".  Legacy
    configuration file "mailutils.rc" is processed if necessary.
    
    * libmailutils/cli/cli.c: Rename main configuration file to mailutils.conf
    Remove 'rcfile' option aliases.
    (mu_cli_ext): Special handling for legacy configuration file.
    * NEWS: Update.
    * doc/texinfo/mailutils.texi: Update.
    * doc/texinfo/programs.texi: Update.

commit dc62b3998f0fe8ce0f131e269b130831093264fb
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 2 12:06:08 2016 +0200

    Improve configuration file handling.
    
    * include/mailutils/cfg.h (mu_cfg_parse_hints):
    Rename site_rcfile to site_file, custom_rcfile to custom_file.
    Remove append_tree and data fields.
    (MU_PARSE_CONFIG_GLOBAL,MU_CFG_PARSE_PROGRAM): Remove.
    (MU_PARSE_CONFIG_VERBOSE): Rename to MU_CF_VERBOSE.
    (MU_PARSE_CONFIG_DUMP): Rename to MU_CF_DUMP.
    (MU_CFG_FMT_LOCUS): Rename to MU_CF_FMT_LOCUS.
    (MU_CFG_FMT_VALUE_ONLY): Rename to MU_CF_FMT_VALUE_ONLY.
    (MU_CFG_FMT_PARAM_PATH): Rename to MU_CF_FMT_PARAM_PATH.
    
    (MU_CFG_COMPATIBILITY,MU_CFG_DEPRECATED): Remove.
    (mu_parse_config, mu_get_config): Remove deprecated functions.
    
    * libmailutils/cli/cli.c (mu_general_help_text): New global.
    (app_data): New struct.
    (init_options): Construct configuration option group depending on
    which configuration files are in use.
    (mu_cli_ext): Don't use per-user configuration files for servers.
    Pass pointer to app_data structure as po.po_data
    (mu_cli): Set MU_CFHINT_PER_USER_FILE flag by default.
    
    * mail/testsuite/lib/mail.exp: Rewrite invocation of the mu_init command.
    * include/mailutils/cli.h (mu_cli_setup) <server>: New field.
    
    * comsat/comsat.c (cli): Mark as server.
    (main): Bugfix: pass pointer to server to mu_cli.
    * imap4d/imap4d.c (cli): Mark as server.
    * pop3d/pop3d.c: Likewise.
    
    * comsat/tests/testsuite.at: Use the --no-site-config
    option.
    * imap4d/tests/testsuite.at: Likewise.
    
    * libmailutils/cfg/driver.c: Update.
    * libmailutils/cfg/format.c: Update.
    * libmailutils/cfg/lexer.l: Update.
    * libmailutils/cfg/parser.y: Update.
    * mu/acl.c: Update.
    
    * pop3d/testsuite/lib/pop3d.exp: Likewise.
    
    * mu/mu.c: Don't read configuration files.
    * mu/query.c: Fix args_doc
    
    * testsuite/lib/mailutils.exp (mu_init): Change option handling.
    Set --no-config option by default.

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

Summary of changes:
 NEWS                          |    4 +-
 comsat/comsat.c               |   12 +-
 comsat/tests/testsuite.at     |    2 +-
 doc/texinfo/mailutils.texi    |   32 ++---
 doc/texinfo/programs.texi     |  280 +++++++++++++++++++++++++++--------------
 imap4d/imap4d.c               |   11 +-
 imap4d/tests/testsuite.at     |    1 -
 include/mailutils/cfg.h       |   65 +++++-----
 include/mailutils/cli.h       |    5 +-
 libmailutils/cfg/driver.c     |   28 +----
 libmailutils/cfg/format.c     |   12 +-
 libmailutils/cfg/lexer.l      |   34 +----
 libmailutils/cfg/parser.y     |   43 +++----
 libmailutils/cli/cli.c        |  274 +++++++++++++++++++++++++++++++---------
 mail/testsuite/lib/mail.exp   |    2 +-
 mu/acl.c                      |    4 +-
 mu/mu.c                       |   17 ++-
 mu/query.c                    |   14 +--
 pop3d/pop3d.c                 |    7 +-
 pop3d/testsuite/lib/pop3d.exp |    3 +-
 sieve/tests/testsuite.at      |    2 +-
 testsuite/lib/mailutils.exp   |   23 +++-
 testsuite/testsuite.inc       |    3 +-
 23 files changed, 548 insertions(+), 330 deletions(-)

diff --git a/NEWS b/NEWS
index 4aa8610..a3190d4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2016-10-30
+GNU mailutils NEWS -- history of user-visible changes. 2016-11-02
 Copyright (C) 2002-2016 Free Software Foundation, Inc.
 See the end of file for copying conditions.
 
@@ -39,6 +39,8 @@ programmers which use or wish to use Mailutils in their projects.
  
 * Important changes
 
+** Main configuration file renamed to mailutils.conf
+
 ** IPv6 support.
 
 The core library as well as client and server utilities support
diff --git a/comsat/comsat.c b/comsat/comsat.c
index e16f91a..2a6d69f 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -194,11 +194,11 @@ struct mu_cfg_param comsat_cfg_param[] = {
 static char const *alt_args[] = { N_("--test MBOX-URL MSG-QID"), NULL };
 
 static struct mu_cli_setup cli = {
-  options,
-  comsat_cfg_param,
-  N_("GNU comsatd -- notify users about incoming mail"),
-  "",
-  alt_args,
+  .optv = options,
+  .cfg =comsat_cfg_param,
+  .prog_doc = N_("GNU comsatd -- notify users about incoming mail"),
+  .prog_alt_args = alt_args,
+  .server = 1
 };
 
 static char *capa[] = {
@@ -568,7 +568,7 @@ main (int argc, char **argv)
 
   save_argv = argv;
   
-  mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
+  mu_cli (argc, argv, &cli, capa, server, &argc, &argv);
 
   if (test_mode)
     {
diff --git a/comsat/tests/testsuite.at b/comsat/tests/testsuite.at
index 4c04223..a37ad5b 100644
--- a/comsat/tests/testsuite.at
+++ b/comsat/tests/testsuite.at
@@ -22,7 +22,7 @@ m4_pushdef([BIFF_MBOX],[`pwd`/mailbox])
 
 dnl ------------------------------------------------------------
 dnl comsatcmd
-m4_pushdef([comsatcmd],[comsatd --no-site --no-user --file ./biff.rc dnl
+m4_pushdef([comsatcmd],[comsatd --no-site-config --file ./biff.rc dnl
  --set logging.syslog=no --test])
 
 dnl ------------------------------------------------------------
diff --git a/doc/texinfo/mailutils.texi b/doc/texinfo/mailutils.texi
index 671aae4..c9fac62 100644
--- a/doc/texinfo/mailutils.texi
+++ b/doc/texinfo/mailutils.texi
@@ -154,23 +154,23 @@ Command Line
 Mailutils Configuration File
 
 * conf-syntax::         Configuration File Syntax
-* Include::             Include Statement
-* Logging Statement::
-* Debug Statement::
-* Mailbox Statement::
-* Locking Statement::
-* Mailer Statement::
-* ACL Statement::
-* Tcp-wrappers Statement::
+* include::             Include Statement
+* logging statement::
+* debug statement::
+* mailbox statement::
+* locking statement::
+* mailer statement::
+* acl statement::
+* tcp-wrappers statement::
 * Server Settings::
-* Auth Statement::
-* PAM Statement::
-* Virtdomain Statement::
-* Radius Statement::
-* SQL Statement::
-* LDAP Statement::
-* TLS Statement::
-* GSASL Statement::
+* auth statement::
+* pam statement::
+* virtdomain statement::
+* radius statement::
+* sql statement::
+* ldap statement::
+* tls statement::
+* gsasl statement::
 
 Configuration File Syntax
 
diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index a4edcf8..c087984 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -225,6 +225,10 @@ Do not load site-wide configuration file.
 @item --no-user-config
 Do not load user configuration file.
 
+@xopindex{no-config, introduced}
+@item --no-config
+Don't load site-wide and user configuration files.
+
 @xopindex{set, introduced}
 @item --set=@var{path}=@var{value}
 Set configuration variable.
@@ -233,7 +237,7 @@ Set configuration variable.
 @node configuration
 @section Mailutils Configuration File
 @cindex Mailutils configuration file
-@cindex mailutils.rc
+@cindex mailutils.conf
 
   Configuration files are the principal means of configuring any GNU
 Mailutils component.  When started, each utility tries to load its
@@ -242,9 +246,9 @@ configuration from the following locations, in that order:
 @enumerate 1
 @item Main site-wide configuration file.
 
-It is named @file{@var{sysconfdir}/mailutils.rc}, where @var{sysconfdir} stands
-for the system configuration directory set when compiling the package.
-You can obtain the value of @var{sysconfdir} by running
+It is named @file{@var{sysconfdir}/mailutils.conf}, where
+@var{sysconfdir} stands for the system configuration directory set
+when compiling the package. You can obtain the value of @var{sysconfdir} by running
 
 @example
 $ mailutils info sysconfdir
@@ -261,30 +265,58 @@ $ @var{prog} --show-config-options | grep SYSCONFDIR
 where @var{prog} stands for any GNU Mailutils utility.
 
 @xopindex{no-site-config, described}
-The site-wide configuration file is not read if the @option{--no-site-config}
-command line option was given.
+The site-wide configuration file is not read if any of
+@option{--no-site-config} or @option{--no-config} command line options
+was given.
+
+Older versions of GNU Mailutils read configuration from file
+@file{mailutils.rc}.  To facilitate transition, mailutils will look
+for that file as well.  If both the default site-wide configuration
+file and legacy configuration file are present you will get the
+following warning:
+
+@example
+legacy configuration file /etc/mailutils.rc ignored
+@end example
+
+Otherwise, if @file{mailutils.conf} does not exist and
+@file{mailutils.rc} is present, it will be used instead and the
+following warning will be issued:
+
+@example
+ using legacy configuration file /etc/mailutils.rc:
+ please rename it to /etc/mailutils.conf
+@end example
 
 @item Per-user configuration file.
 
-A per user configuration file is located in the user home directory
-and is named @samp{.@var{prog}}, where @var{prog} is the name of the
-utility.  For example, the per-user configuration file for
-@command{sieve} utility is named @file{.sieve}.
+Client utilities, such as @command{frm} or @command{sieve}, look in
+the user home directory for a file named @samp{.@var{prog}}, where
+@var{prog} is the name of the utility.  If it is present, it will be
+loaded after loading the site-wide configuration file.  This file
+allows users to customize such utilities.
 
-@xopindex{no-user-config, described}
-This configuration file is not read if the @option{--no-user-config}
-command line option was given.
+For example, the per-user configuration file for @command{sieve}
+utility is named @file{.sieve}. 
 
-@xopindex{config-file, described}
-@item Additional configuration file, if specified using the
-@option{--config-file} command line option.
+@xopindex{no-user-config, described}
+Loading of per-user configuration file is disabled by
+@option{--no-user-config} and @option{--no-config} options.
 @end enumerate
 
-The order in which configuration files are loaded defines the
-precedence of their settings.  Thus, settings from additional
-configuration file override those set in per-user configuration file.
-The latter, in their turn, take precedence over the settings from the
-site-wide configuration file.
+Server programs, such as @command{imap4d} don't use per-user
+configuration files.
+
+The @option{--no-config} option provides a shortcut for disabling
+loading of the default configuration files.  For servers, its effect
+is the same as of @option{--no-site-config}.  For client utilities, it
+is equivalent to @option{--no-site-config --no-user-config} used
+together.
+
+@xopindex{config-file, described}
+The @option{--config-file} command line option instructs the program
+to read configuration from the file supplied as its argument.  In that
+case, default configuration files are not used at all.
 
 @xopindex{config-verbose, described}
 Neither site-wide nor user configuration files are required to
@@ -342,11 +374,16 @@ $ imap4d --config-help > imap4d.rc
 @noindent
 and to edit the @file{imap4d.rc} file with your editor of choice.
 
+The order in which configuration files are loaded defines the
+precedence of their settings.  Thus, for client utilities, settings
+from the per-user configuration file override those from the site-wide
+configuration.
+
 @xopindex{set, described}
   It is also possible to set or override arbitrary configuration
 variables in the command line.  It can be done via the @option{--set}
 option.  Its argument is a @dfn{pathname} of the variable to be set,
-followed by an equals sign and value.  For example, to define the
+followed by an equals sign and a value.  For example, to define the
 variable @samp{syslog} in section @samp{logging} to @samp{no}, do the
 following: 
 
@@ -356,26 +393,30 @@ $ imap4d --set .logging.syslog=no
 
 Configuration pathnames are discussed in detail in @ref{Paths}.
 
+The @option{--set} options are processed after loading all
+configuration files.
+
 @menu
 * conf-syntax::         Configuration File Syntax
 * Variables::           Variable Expansion
-* Include::             Include Statement
-* Logging Statement::
-* Debug Statement::
-* Mailbox Statement::
-* Locking Statement::
-* Mailer Statement::
-* ACL Statement::
-* Tcp-wrappers Statement::
+* include::             Include Statement
+* program statement::
+* logging statement::
+* debug statement::
+* mailbox statement::
+* locking statement::
+* mailer statement::
+* acl statement::
+* tcp-wrappers statement::
 * Server Settings::
-* Auth Statement::
-* PAM Statement::
-* Virtdomain Statement::
-* Radius Statement::
-* SQL Statement::
-* LDAP Statement::
-* TLS Statement::
-* GSASL Statement::
+* auth statement::
+* pam statement::
+* virtdomain statement::
+* radius statement::
+* sql statement::
+* ldap statement::
+* tls statement::
+* gsasl statement::
 @end menu
 
 @node conf-syntax
@@ -611,8 +652,7 @@ this is not required.
 @command{Mailutils} configuration files have a distinct hierarchical
 structure.  Each statement in such files can therefore be identified
 by its name and the names of block statements containing it.  Such
-names form this statement @dfn{pathname}, similar to that used,
-e.g. by UNIX file system.
+names form the @dfn{pathname}, similar to that used by UNIX file system.
 
 For example, consider the following file:
 
@@ -650,9 +690,9 @@ Any other punctuation character can be used as a component separator,
 provided that it appears at the beginning of the pathname.  In other
 words, only absolute pathnames allow for a change in component separators.
 
-A block statement that has a tag is referred to by its name, followed
-by an equals sign, followed by the tag value.  For example, the
-statement @samp{A} in the file below:
+A block statement that has a tag is referred to by the statement's
+name, followed by an equals sign, followed by the tag value.  For
+example, the statement @samp{A} in the file below:
 
 @example
 program x @{
@@ -722,24 +762,27 @@ substituted, otherwise the expansion of @var{word} is substituted.
 The subsections below define variable names that are valid for use in
 each configuration statement.
 
-@node Include
-@subsection Include Statement 
+@node include
+@subsection The @code{include} Statement
+@anchor{Include} @c for backward-compatibility
 @cindex include statement, configuration file
 @kwindex include
   The @dfn{include statement} is a special statement that causes
-inclusion of a named file.  It has the following syntax:
+inclusion of the named file.  It has the following syntax:
 
 @example
 include @var{file};
 @end example
 
-If @var{file} names a regular file, the contents of this file is
-included in this point.  Otherwise, if @var{file} names a directory,
-Mailutils searches in that directory for a file whose name coincides
-with the name of utility being executed, and includes this file, if it
-exists.
+The effect of this statement is that the contents of this @var{file} is
+included in this point.
 
-It is a common approach to end the site-wide configuration file with
+In site-wide configuration file, @var{file} can be a directory name.
+In this case, Mailutils will search this directory for a file with the
+same name as the utility being executed.  If found, this file will be
+loaded.
+
+It is a common to end the site-wide configuration file with
 an include statement, e.g.:
 
 @example
@@ -747,11 +790,40 @@ include /etc/mailutils.d;
 @end example
 
 This allows each particular utility to have its own configuration
-file.  Thus.  @command{imap4d} will read
+file.  Thus, @command{imap4d} will read
 @file{/etc/mailutils.d/imap4d}, etc.
 
-@node Logging Statement
-@subsection Logging Statement
+@node program statement
+@subsection The @command{program} statement
+@kwindex program
+Another way to configure program-specific settings is by using the
+@command{program} statement.  The syntax is as follows:
+
+@example
+program @var{progname} @{
+   ...
+@}
+@end example
+
+The @command{program} statement is allowed only in the site-wide
+configuration file.  When encountered, its tag (@var{progname}) is
+compared with the name of the program being run.  If two strings are
+the same, the statements between curly braces are stored in a
+temporary memory, otherwise the statement is ignored.  When entire
+configuration file is loaded, the statements accumulated in the
+temporary storage are processed.
+
+Notice the difference between this statement and a per-program
+configuration file loaded via an @code{include} statement.  No matter
+where in the file the @command{program} statement is, it is always
+processed after the entire configuraion file is processed.  In the
+contrast, the per-program configuration file loaded via @code{include}
+with the directory name as its argument is processed right where it is
+encountered.
+
+@node logging statement
+@subsection The @code{logging} Statement
+@anchor{Logging Statement}
 @kwindex logging
 @subheading Syntax
 @example
@@ -822,8 +894,9 @@ programs that handle multiple user sessions simultaneously, such as
 @command{pop3d} and @command{imap4d}.
 @end deffn
 
-@node Debug Statement
-@subsection Debug Statement
+@node debug statement
+@subsection The @code{debug} Statement
+@anchor{Debug Statement}
 @kwindex debug
 @subheading Syntax
 @example
@@ -850,8 +923,9 @@ debugging messages to be prefixed with locations in Mailutils source
 files where they appear.  Normally, only Mailutils developers need
 this option. 
 
-@node Mailbox Statement
-@subsection Mailbox Statement
+@node mailbox statement
+@subsection The @code{mailbox} Statement
+@anchor{Mailbox Statement}
 @kwindex mailbox
 @subheading Syntax
 @example
@@ -1045,8 +1119,9 @@ The @var{dir} argument can contain mailbox type prefix, e.g
 The default folder name is @samp{Mail/}.
 @end deffn
 
-@node Locking Statement
-@subsection Locking Statement
+@node locking statement
+@subsection The @command{locking} Statement
+@anchor{Locking Statement}
 @kwindex locking
 @subheading Syntax
 @example
@@ -1121,8 +1196,9 @@ Set command line of an external locker program.  The @samp{E} flag
 must be set for this to take effect. 
 @end deffn
 
-@node Mailer Statement
-@subsection Mailer Statement
+@node mailer statement
+@subsection The @code{mailer} Statement
+@anchor{Mailer Statement}
 @kwindex mailer
 @subheading Syntax
 @example
@@ -1176,8 +1252,9 @@ mailer that allows to use arbitrary external programs as mailers.
 It is described in detain in @ref{Program Mailboxes,,prog}.
 @end table
 
-@node ACL Statement
-@subsection ACL Statement
+@node acl statement
+@subsection The @code{acl} Statement
+@anchor{ACL Statement}
 @kwindex acl
 @subheading Syntax
 @example
@@ -1321,8 +1398,9 @@ the given @var{program}.  Do not wait for it to terminate, and ignore
 its exit code.
 @end deffn
 
-@node Tcp-wrappers Statement
-@subsection Tcp-wrappers Statement
+@node tcp-wrappers statement
+@subsection The @code{tcp-wrappers} Statement
+@anchor{Tcp-wrappers Statement}
 @kwindex tcp-wrappers
 @subheading Syntax
 @example
@@ -1501,7 +1579,7 @@ requests during @var{time} seconds, the child process terminates.
 @end deffn
 
 @node Server Statement
-@subsubsection Server Statement
+@subsubsection The @code{server} Statement
 @cindex server statement
 @kwindex server
 @* Syntax:
@@ -1516,6 +1594,9 @@ server @var{ipaddr}[:@var{port}] @{
   # @r{Set idle timeout.}
   timeout @var{time};
 
+  # Size of the queue of pending connections
+  backlog <number: callback>;
+
   # @r{Kind of TLS encryption to use for this server.}
   tls @samp{no}|@samp{ondemand}|@samp{required}|@samp{connection};
     
@@ -1569,6 +1650,10 @@ Set idle timeout for this server.  This overrides global timeout
 settings (@pxref{General Server Configuration, timeout}).
 @end deffn
 
+@deffn {Configuration} backlog @var{number};
+Configures the size of the queue of pending connections
+@end deffn
+
 @deffn {Configuration} tls @var{mode};
 Configure the use of TLS encryption.  The @var{mode} argument is one
 of the following:
@@ -1602,9 +1687,9 @@ ACL are used, the connection is allowed only if both of them allow it,
 and is denied if any one of them denies it.
 @end deffn
 
-@node Auth Statement
-@subsection Auth Statement
-@UNREVISED
+@node auth statement
+@subsection The @code{auth} Statement
+@anchor{Auth Statement}
 @cindex authorization
 @cindex authentication
 @kwindex auth
@@ -1680,17 +1765,17 @@ User credentials are retrieved from the system user database
 @item sql
 User credentials are retrieved from a @acronym{SQL} database.
 A separate configuration statement, @code{sql}, is used to configure
-it (@pxref{SQL Statement}).
+it (@pxref{sql statement}).
 @item virtdomain
 User credentials are retrieved from a ``virtual domain'' user
 database.  Virtual domains are configured using @code{virtdomain}
-statement (@pxref{Virtdomain Statement}).
+statement (@pxref{virtdomain statement}).
 @item radius
-User credentials are retrieved using @acronym{RADIUS}.  @xref{Radius
-Statement}, for a detailed description on how to configure it.
+User credentials are retrieved using @acronym{RADIUS}.  @xref{radius
+statement}, for a detailed description on how to configure it.
 @item ldap
 User credentials are retrieved from an @acronym{LDAP}
-database.  @xref{LDAP Statement}, for an information on how to
+database.  @xref{ldap statement}, for an information on how to
 configure it.
 @end table
 
@@ -1719,16 +1804,16 @@ The hashed value of the user password is retrieved from
 @item sql
 The hashed value of the user password is retrieved from a
 @acronym{SQL} database using query supplied by @code{getpass}
-statement (@pxref{SQL Statement, getpass}).
+statement (@pxref{sql statement, getpass}).
 @item pam
 The user is authenticated via pluggable authentication module
 (@acronym{PAM}).  The @acronym{PAM} service name to be used is
-configured in @code{pam} statement (@pxref{PAM Statement}).
+configured in @code{pam} statement (@pxref{pam statement}).
 @item radius
 The user is authenticated on a remote @acronym{RADIUS}
-server.  @xref{Radius Statement}.
+server.  @xref{radius statement}.
 @item ldap
-The user is authenticated using @acronym{LDAP}.  @xref{LDAP Statement}.
+The user is authenticated using @acronym{LDAP}.  @xref{ldap statement}.
 @end table
 
 @FIXME{This list is inaccurate:}
@@ -1740,8 +1825,9 @@ the list of authentication modules is:
 @end example
 @end deffn
 
-@node PAM Statement
+@node pam statement
 @subsection PAM Statement
+@anchor{PAM Statement}
 @UNREVISED
 @kwindex pam
 @subheading Syntax
@@ -1762,10 +1848,11 @@ default, the base name of the Mailutils binary is used.
 @end deffn
 
 This statement takes effect only if @samp{pam} is listed in
-@code{authentication} statement (@pxref{Auth Statement}).
+@code{authentication} statement (@pxref{auth statement}).
 
-@node Virtdomain Statement
-@subsection Virtdomain Statement
+@node virtdomain statement
+@subsection The @code{virtdomain} Statement
+@anchor{Virtdomain Statement}
 @UNREVISED
 @kwindex virtdomain
 @subheading Syntax
@@ -1821,8 +1908,9 @@ the domain name corresponding to that address is looked up in the DNS
 system.  Finally, this domain name is used as a name of the password
 file.
 
-@node Radius Statement
-@subsection Radius Statement
+@node radius statement
+@subsection The @code{radius} Statement
+@anchor{Radius Statement}
 @UNREVISED
 @kwindex radius
 @subheading Syntax
@@ -1980,8 +2068,9 @@ The reply to @code{getpwuid} request is the same as to @code{getpwnam}
 request (see above).
 @end deffn
 
-@node SQL Statement
-@subsection SQL Statement
+@node sql statement
+@subsection The @code{sql} Statement
+@anchor{SQL Statement}
 @UNREVISED
 @kwindex sql
 @subheading Syntax
@@ -2066,8 +2155,9 @@ Name of the database.
 Password to access the database.
 @end deffn
 
-@node LDAP Statement
-@subsection LDAP Statement
+@node ldap statement
+@subsection The @code{ldap} Statement
+@anchor{LDAP Statement}
 @WRITEME
 @kwindex ldap
 @subheading Syntax
@@ -2096,8 +2186,9 @@ ldap @{
 @}
 @end example
 
-@node TLS Statement
-@subsection TLS Statement
+@node tls statement
+@subsection The @code{tls} Statement
+@anchor{TLS Statement}
 @WRITEME
 @kwindex tls
 @subheading Syntax
@@ -2114,8 +2205,9 @@ tls @{
 @}
 @end example
 
-@node GSASL Statement
-@subsection GSASL Statement
+@node gsasl statement
+@subsection The @code{gsasl} Statement
+@anchor{GSASL Statement}
 @WRITEME
 @kwindex gsasl
 @subheading Syntax
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index 031c3cc..df9cc7a 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -449,9 +449,10 @@ static struct mu_cfg_param imap4d_cfg_param[] = {
 };
 
 struct mu_cli_setup cli = {
-  options,
-  imap4d_cfg_param,
-  N_("GNU imap4d -- the IMAP4D daemon.")
+  .optv = options,
+  .cfg = imap4d_cfg_param,
+  .prog_doc = N_("GNU imap4d -- the IMAP4D daemon."),
+  .server = 1
 };
 
 int
@@ -659,7 +660,7 @@ get_client_address (int fd, struct sockaddr_in *pcs)
 }
 
 static int
-set_strerr_flt ()
+set_strerr_flt (void)
 {
   mu_stream_t flt, trans[2];
   int rc;
@@ -700,7 +701,7 @@ set_strerr_flt ()
 }
 
 static void
-clr_strerr_flt ()
+clr_strerr_flt (void)
 {
   mu_stream_t flt, trans[2];
   int rc;
diff --git a/imap4d/tests/testsuite.at b/imap4d/tests/testsuite.at
index 8b98295..c6e84cb 100644
--- a/imap4d/tests/testsuite.at
+++ b/imap4d/tests/testsuite.at
@@ -20,7 +20,6 @@ m4_define([IMAP4D_HOMEDIR])
 
 m4_define([IMAP4D_DEFAULT_OPTIONS],[dnl
 --no-site-config dnl
---no-user-config dnl
 --test dnl
 --set logging.syslog=0 dnl
 --set logging.severity=notice dnl
diff --git a/include/mailutils/cfg.h b/include/mailutils/cfg.h
index 1a69c82..9b8e951 100644
--- a/include/mailutils/cfg.h
+++ b/include/mailutils/cfg.h
@@ -72,17 +72,43 @@ struct mu_cfg_node
   mu_list_t nodes;   /* a list of mu_cfg_node_t */
   struct mu_cfg_node *parent; /* parent node */
 };
-
+
 struct mu_cfg_parse_hints
 {
   int flags;
-  char *site_rcfile;
-  char *custom_rcfile;
+  char *site_file;
+  char *custom_file;
   char *program;
-  struct mu_cfg_tree *append_tree;
-  void *data;
 };
 
+/* Bit constants for the flags field of struct mu_cfg_parse_hints */
+/* Parse site-wide configuration file hints.site_file */
+#define MU_CFHINT_SITE_FILE        0x0001
+/* Parse custom configuration file hints.custom_file */
+#define MU_CFHINT_CUSTOM_FILE      0x0002
+/* The hints.program field is set.  The "program PROGNAME" section
+   will be processed, if PROGNAME is the same as hints.program.
+   If include statement is used with the directory name DIR as its
+   argument, the file DIR/PROGNAME will be looked up and read in,
+   if it exists. */
+#define MU_CFHINT_PROGRAM          0x0004
+
+/* If MU_CFHINT_PROGRAM is set, look for the file ~/.PROGNAME after parsing
+   site-wide configuration */
+#define MU_CFHINT_PER_USER_FILE    0x0008
+  
+/* Verbosely log files being processed */
+#define MU_CF_VERBOSE              0x0010
+/* Dump the pare tree on stderr */
+#define MU_CF_DUMP                 0x0020
+
+/* Format location of the statement */
+#define MU_CF_FMT_LOCUS            0x0100
+/* Print only value */
+#define MU_CF_FMT_VALUE_ONLY       0x0200
+/* Print full parameter path */
+#define MU_CF_FMT_PARAM_PATH       0x0400
+  
 struct mu_cfg_tree
 {
   mu_list_t nodes;   /* a list of mu_cfg_node_t */
@@ -140,9 +166,6 @@ struct mu_cfg_param
   const char *argname;
 };
 
-#define MU_TARGET_REF(f) &f, 0
-#define MU_TARGET_OFF(s,f) NULL, mu_offsetof(s,f)
-
 enum mu_cfg_section_stage
   {
     mu_cfg_section_start,
@@ -230,29 +253,7 @@ int mu_config_register_plain_section (const char *parent_path,
 				      const char *ident,
 				      struct mu_cfg_param *params);
 
-#define MU_PARSE_CONFIG_GLOBAL     0x001
-#define MU_PARSE_CONFIG_VERBOSE    0x002
-#define MU_PARSE_CONFIG_DUMP       0x004
-#define MU_PARSE_CONFIG_PLAIN      0x008
-#define MU_CFG_PARSE_SITE_RCFILE   0x010
-#define MU_CFG_PARSE_CUSTOM_RCFILE 0x020
-#define MU_CFG_PARSE_PROGRAM       0x040
-#define MU_CFG_FMT_LOCUS           0x080
-#define MU_CFG_FMT_VALUE_ONLY      0x100
-#define MU_CFG_FMT_PARAM_PATH      0x200
-#define MU_PARSE_CONFIG_LINT       0x400
-#define MU_CFG_APPEND_TREE         0x800
   
-#ifdef MU_CFG_COMPATIBILITY
-# define MU_CFG_DEPRECATED
-#else
-# define MU_CFG_DEPRECATED MU_DEPRECATED
-#endif
-
-int mu_parse_config (const char *file, const char *progname,
-		     struct mu_cfg_param *progparam, int flags,
-		     void *target_ptr) MU_CFG_DEPRECATED;
-
 extern int mu_cfg_parser_verbose;
 extern size_t mu_cfg_error_count;
 
@@ -279,10 +280,6 @@ int mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file,
 		       int flags);
   
   
-int mu_get_config (const char *file, const char *progname,
-		   struct mu_cfg_param *progparam, int flags,
-		   void *target_ptr) MU_CFG_DEPRECATED;
-
 int mu_cfg_tree_create (struct mu_cfg_tree **ptree);
 mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
 					enum mu_cfg_node_type type,
diff --git a/include/mailutils/cli.h b/include/mailutils/cli.h
index eaf0f8d..b2ed7ce 100644
--- a/include/mailutils/cli.h
+++ b/include/mailutils/cli.h
@@ -50,11 +50,14 @@ 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;
+  int inorder:1;               /* Don't permute options and arguments */
+  int server:1;                /* This is a server: don't read per-user
+				  configuration files */
   void (*prog_doc_hook) (mu_stream_t);
 };
 
 extern const char mu_version_copyright[];
+extern const char mu_general_help_text[];
 
 void mu_version_hook (struct mu_parseopt *po, mu_stream_t stream);
 void mu_cli (int argc, char **argv, struct mu_cli_setup *setup,
diff --git a/libmailutils/cfg/driver.c b/libmailutils/cfg/driver.c
index f2a43a3..1b1ff05 100644
--- a/libmailutils/cfg/driver.c
+++ b/libmailutils/cfg/driver.c
@@ -27,7 +27,6 @@
 #include <ctype.h>
 #include <mailutils/argcv.h>
 #include <mailutils/nls.h>
-#define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
 #include <mailutils/cfg.h>
 #include <mailutils/errno.h>
 #include <mailutils/error.h>
@@ -466,14 +465,14 @@ mu_cfg_tree_reduce (mu_cfg_tree_t *parse_tree,
   struct mu_cfg_cont *cont;
   if (!parse_tree)
     return 0;
-  if (hints && (hints->flags & MU_PARSE_CONFIG_DUMP))
+  if (hints && (hints->flags & MU_CF_DUMP))
     {
       int yes = 1;
       mu_stream_t stream;
       
       mu_stdio_stream_create (&stream, MU_STDERR_FD, 0);
       mu_stream_ioctl (stream, MU_IOCTL_FD, MU_IOCTL_FD_SET_BORROW, &yes);
-      mu_cfg_format_parse_tree (stream, parse_tree, MU_CFG_FMT_LOCUS);
+      mu_cfg_format_parse_tree (stream, parse_tree, MU_CF_FMT_LOCUS);
       mu_stream_destroy (&stream);
     }
 
@@ -492,29 +491,6 @@ mu_format_config_tree (mu_stream_t stream, struct mu_cfg_param *progparam)
   mu_config_destroy_container (&cont);
 }
 
-int
-mu_parse_config (const char *file, const char *progname,
-		 struct mu_cfg_param *progparam, int flags,
-		 void *target_ptr)
-{
-  int rc;
-  char *full_name = mu_tilde_expansion (file, MU_HIERARCHY_DELIMITER, NULL);
-  if (full_name)
-    {
-      if (access (full_name, R_OK) == 0)
-	{
-	  rc = mu_get_config (full_name, progname, progparam, flags,
-			      target_ptr);
-	}
-      else
-	rc = ENOENT;
-      free (full_name);
-    }
-  else
-    rc = ENOMEM;
-  return rc;
-}
-
 static const char *
 _first_value_ptr (mu_config_value_t *val)
 {
diff --git a/libmailutils/cfg/format.c b/libmailutils/cfg/format.c
index d94c878..926c9d5 100644
--- a/libmailutils/cfg/format.c
+++ b/libmailutils/cfg/format.c
@@ -152,7 +152,7 @@ format_node (const mu_cfg_node_t *node, void *data)
 {
   struct tree_print *tp = data;
 
-  if ((tp->flags & MU_CFG_FMT_LOCUS) && node->locus.mu_file)
+  if ((tp->flags & MU_CF_FMT_LOCUS) && node->locus.mu_file)
     mu_stream_printf (tp->stream, "# %lu \"%s\"\n",
 		      (unsigned long) node->locus.mu_line, 
 		      node->locus.mu_file);
@@ -165,7 +165,7 @@ format_node (const mu_cfg_node_t *node, void *data)
       break;
 
     case mu_cfg_node_statement:
-      if (tp->flags & MU_CFG_FMT_PARAM_PATH)
+      if (tp->flags & MU_CF_FMT_PARAM_PATH)
 	return MU_CFG_ITER_OK;
       else
 	{
@@ -181,9 +181,9 @@ format_node (const mu_cfg_node_t *node, void *data)
       break;
 
     case mu_cfg_node_param:
-      if (tp->flags & MU_CFG_FMT_VALUE_ONLY)
+      if (tp->flags & MU_CF_FMT_VALUE_ONLY)
 	format_value (tp, node->label);
-      else if (tp->flags & MU_CFG_FMT_PARAM_PATH)
+      else if (tp->flags & MU_CF_FMT_PARAM_PATH)
 	{
 	  format_path (tp, node, ':');
 	  mu_stream_write (tp->stream, " ", 1, NULL);
@@ -209,7 +209,7 @@ static int
 format_node_end (const mu_cfg_node_t *node, void *data)
 {
   struct tree_print *tp = data;
-  if (!(tp->flags & MU_CFG_FMT_PARAM_PATH))
+  if (!(tp->flags & MU_CF_FMT_PARAM_PATH))
     {
       tp->level--;
       format_level (tp->stream, tp->level);
@@ -242,7 +242,7 @@ mu_cfg_format_node (mu_stream_t stream, const mu_cfg_node_t *node, int flags)
   struct tree_print t;
 
   if (node->type == mu_cfg_node_statement)
-    flags &= ~MU_CFG_FMT_VALUE_ONLY;
+    flags &= ~MU_CF_FMT_VALUE_ONLY;
   t.flags = flags;
   t.level = 0;
   t.stream = stream;
diff --git a/libmailutils/cfg/lexer.l b/libmailutils/cfg/lexer.l
index 2ecefce..5e8cbf5 100644
--- a/libmailutils/cfg/lexer.l
+++ b/libmailutils/cfg/lexer.l
@@ -330,14 +330,14 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags)
   int rc;
   char *full_name = mu_tilde_expansion (file, MU_HIERARCHY_DELIMITER, NULL);
 
-  if (flags & MU_PARSE_CONFIG_VERBOSE)
+  if (flags & MU_CF_VERBOSE)
     mu_diag_output (MU_DIAG_INFO, _("opening configuration file %s"),
 		    full_name);
   if (stat (full_name, &st))
     {
       if (errno != ENOENT)
 	mu_error (_("cannot stat `%s': %s"), full_name, mu_strerror (errno));
-      else if (flags & MU_PARSE_CONFIG_VERBOSE)
+      else if (flags & MU_CF_VERBOSE)
 	mu_diag_output (MU_DIAG_INFO, _("configuration file %s doesn't exist"),
 			full_name);
       free (full_name);
@@ -345,7 +345,7 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags)
     }
   else if (!S_ISREG (st.st_mode))
     {
-      if (flags & MU_PARSE_CONFIG_VERBOSE)
+      if (flags & MU_CF_VERBOSE)
 	mu_diag_output (MU_DIAG_INFO, _("%s: not a regular file"), full_name);
       free (full_name);
       return ENOENT;
@@ -360,7 +360,7 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags)
       return errno;
     }
 
-  if (flags & MU_PARSE_CONFIG_VERBOSE)
+  if (flags & MU_CF_VERBOSE)
     mu_diag_output (MU_DIAG_INFO, _("parsing file `%s'"), full_name);
 
   mu_cfg_set_lex_debug ();
@@ -379,37 +379,13 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags)
   yyrestart (fp);
   rc = mu_cfg_parse (return_tree);
   fclose (fp);
-  if (flags & MU_PARSE_CONFIG_VERBOSE)
+  if (flags & MU_CF_VERBOSE)
     mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"),
 		    mu_cfg_locus.mu_file);
 
   return rc == 0 ? 0 : MU_ERR_FAILURE;
 }
 
-/* FIXME: Deprecated interface */
-int
-mu_get_config (const char *file, const char *progname,
-               struct mu_cfg_param *progparam, int flags, void *target_ptr)
-{
-  mu_cfg_tree_t *parse_tree;
-  int rc = mu_cfg_parse_file (&parse_tree, file, flags);
-  if (rc == 0)
-    {
-      struct mu_cfg_parse_hints hints;
-
-      hints.flags = flags | MU_CFG_PARSE_PROGRAM;
-      hints.program = (char*)progname;
-      
-      rc = mu_cfg_tree_postprocess (parse_tree, &hints);
-      if (rc == 0)
-	rc = mu_cfg_tree_reduce (parse_tree, &hints, progparam, target_ptr);
-      mu_cfg_destroy_tree (&parse_tree);
-    }
-
-  return rc == 0 ? 0 : MU_ERR_FAILURE;
-}
-
-
 mu_opool_t 
 mu_cfg_lexer_pool ()
 {
diff --git a/libmailutils/cfg/parser.y b/libmailutils/cfg/parser.y
index 9ad8e8d..0b362a8 100644
--- a/libmailutils/cfg/parser.y
+++ b/libmailutils/cfg/parser.y
@@ -501,8 +501,7 @@ do_include (const char *name, struct mu_cfg_parse_hints *hints,
       
       if (S_ISDIR (sb.st_mode))
 	{
-	  if ((hints->flags & (MU_PARSE_CONFIG_GLOBAL|MU_CFG_PARSE_PROGRAM)) ==
-	      (MU_PARSE_CONFIG_GLOBAL|MU_CFG_PARSE_PROGRAM))
+	  if (hints->flags & MU_CFHINT_PROGRAM)
 	    {
 	      char *file = mu_make_file_name (name, hints->program);
 	      rc = mu_cfg_parse_file (&tree, file, hints->flags);
@@ -515,7 +514,7 @@ do_include (const char *name, struct mu_cfg_parse_hints *hints,
       if (rc == 0 && tree)
 	{
 	  struct mu_cfg_parse_hints xhints = *hints;
-	  xhints.flags &= ~MU_PARSE_CONFIG_GLOBAL;
+	  xhints.flags &= ~MU_CFHINT_PROGRAM;
 	  mu_cfg_tree_postprocess (tree, &xhints);
 	}
     }
@@ -538,8 +537,7 @@ do_include (const char *name, struct mu_cfg_parse_hints *hints,
 }
 
 int
-mu_cfg_tree_postprocess (mu_cfg_tree_t *tree,
-			 struct mu_cfg_parse_hints *hints)
+mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, struct mu_cfg_parse_hints *hints)
 {
   int rc;
   mu_iterator_t itr;
@@ -558,13 +556,12 @@ mu_cfg_tree_postprocess (mu_cfg_tree_t *tree,
       
       if (node->type == mu_cfg_node_statement)
 	{
-	  if ((hints->flags & MU_PARSE_CONFIG_GLOBAL) &&
+	  if ((hints->flags & MU_CFHINT_PROGRAM) &&
 	      strcmp (node->tag, "program") == 0)
 	    {
 	      if (node->label->type == MU_CFG_STRING)
 		{
-		  if ((hints->flags & MU_CFG_PARSE_PROGRAM)
-		      && strcmp (node->label->v.string, hints->program) == 0)
+		  if (strcmp (node->label->v.string, hints->program) == 0)
 		    {
 		      /* Reset the parent node */
 		      mu_list_foreach (node->nodes, _node_set_parent,
@@ -1527,10 +1524,11 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints)
 {
   int rc = 0;
   mu_cfg_tree_t *tree = NULL, *tmp;
+  struct mu_cfg_parse_hints xhints;
   
-  if ((hints->flags & MU_CFG_PARSE_SITE_RCFILE) && hints->site_rcfile)
+  if ((hints->flags & MU_CFHINT_SITE_FILE) && hints->site_file)
     {
-      rc = mu_cfg_parse_file (&tmp, hints->site_rcfile, hints->flags);
+      rc = mu_cfg_parse_file (&tmp, hints->site_file, hints->flags);
       
       if (rc == ENOMEM)
 	{
@@ -1539,14 +1537,16 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints)
 	}
       else if (rc == 0)
 	{
-	  struct mu_cfg_parse_hints xhints = *hints;
-	  xhints.flags |= MU_PARSE_CONFIG_GLOBAL;
-	  mu_cfg_tree_postprocess (tmp, &xhints);
+	  mu_cfg_tree_postprocess (tmp, hints);
 	  mu_cfg_tree_union (&tree, &tmp);
 	}
     }
+
+  xhints = *hints;
+  xhints.flags &= ~MU_CFHINT_PROGRAM;
   
-  if ((hints->flags & MU_CFG_PARSE_PROGRAM) && hints->program)
+  if ((hints->flags & MU_CFHINT_PER_USER_FILE)
+      && (hints->flags & MU_CFHINT_PROGRAM))
     {
       size_t size = 3 + strlen (hints->program) + 1;
       char *file_name = malloc (size);
@@ -1555,7 +1555,7 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints)
 	  strcpy (file_name, "~/.");
 	  strcat (file_name, hints->program);
 	  
-	  rc = mu_cfg_parse_file (&tmp, file_name, hints->flags);
+	  rc = mu_cfg_parse_file (&tmp, file_name, xhints.flags);
 	  if (rc == ENOMEM)
 	    {
 	      mu_error ("%s", mu_strerror (rc));
@@ -1564,7 +1564,7 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints)
 	    }
 	  else if (rc == 0)
 	    {
-	      mu_cfg_tree_postprocess (tmp, hints);
+	      mu_cfg_tree_postprocess (tmp, &xhints);
 	      mu_cfg_tree_union (&tree, &tmp);
 	    }
 	  else if (rc == ENOENT)
@@ -1573,26 +1573,23 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints)
 	}
     }
   
-  if ((hints->flags & MU_CFG_PARSE_CUSTOM_RCFILE) && hints->custom_rcfile)
+  if ((hints->flags & MU_CFHINT_CUSTOM_FILE) && hints->custom_file)
     {
-      rc = mu_cfg_parse_file (&tmp, hints->custom_rcfile, hints->flags);
+      rc = mu_cfg_parse_file (&tmp, hints->custom_file, xhints.flags);
       if (rc)
 	{
-	  mu_error (_("errors parsing file %s: %s"), hints->custom_rcfile,
+	  mu_error (_("errors parsing file %s: %s"), hints->custom_file,
 		    mu_strerror (rc));
 	  mu_cfg_destroy_tree (&tree);
 	  return rc;
 	}
       else
 	{
-	  mu_cfg_tree_postprocess (tmp, hints);
+	  mu_cfg_tree_postprocess (tmp, &xhints);
 	  mu_cfg_tree_union (&tree, &tmp);
 	}
     }
 
-  if (hints->flags & MU_CFG_APPEND_TREE)
-    mu_cfg_tree_union (&tree, &hints->append_tree);
-
   *ptree = tree;
   return rc;
 }
diff --git a/libmailutils/cli/cli.c b/libmailutils/cli/cli.c
index 793a3e2..557a9a6 100644
--- a/libmailutils/cli/cli.c
+++ b/libmailutils/cli/cli.c
@@ -18,6 +18,7 @@
 # include <config.h>
 #endif
 #include <stdlib.h>
+#include <unistd.h>
 #include <sysexits.h>
 #include <mailutils/cfg.h>
 #include <mailutils/opt.h>
@@ -33,8 +34,10 @@
 #include <mailutils/syslog.h>
 #include <mailutils/mu_auth.h>
 
+#define MU_LEGACY_CONFIG_FILE SYSCONFDIR "/mailutils.rc"
+
 #ifndef MU_SITE_CONFIG_FILE
-# define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.rc"
+# define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.conf"
 #endif
 
 char *
@@ -76,23 +79,29 @@ There is NO WARRANTY, to the extent permitted by law.\n\
 "));
 }
 
-static char gnu_general_help_url[] =
+const char mu_general_help_text[] =
   N_("General help using GNU software: <http://www.gnu.org/gethelp/>");
 
+struct app_data
+{
+  struct mu_cli_setup *setup;
+  struct mu_cfg_parse_hints *hints;
+  struct mu_cfg_tree *append_tree;
+  int lint;
+};
+
 static void
 extra_help_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;
-  mu_stream_printf (stream, "%s\n", _(setup->prog_extra_doc));
+  struct app_data *dp = po->po_data;
+  mu_stream_printf (stream, "%s\n", gettext (dp->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);
+  struct app_data *dp = po->po_data;
+  dp->setup->prog_doc_hook (stream);
 }
 
 static void
@@ -100,106 +109,151 @@ change_progname (struct mu_parseopt *po, struct mu_option *opt,
 		 char const *arg)
 {
   po->po_prog_name = mu_strdup (arg);
+  free (mu_program_name);
+  mu_program_name = mu_strdup (arg);  
 }
 
 static void
 no_user_config (struct mu_parseopt *po, struct mu_option *opt,
 		char const *arg)
 {
-  struct mu_cfg_parse_hints *hints = po->po_data;
-  hints->flags &= ~MU_CFG_PARSE_PROGRAM;
+  struct app_data *dp = po->po_data;
+  dp->hints->flags &= ~MU_CFHINT_PER_USER_FILE;
 }
 
 static void
 no_site_config (struct mu_parseopt *po, struct mu_option *opt,
 		char const *arg)
 {
-  struct mu_cfg_parse_hints *hints = po->po_data;
-  hints->flags &= ~MU_CFG_PARSE_SITE_RCFILE;
+  struct app_data *dp = po->po_data;
+  dp->hints->flags &= ~MU_CFHINT_SITE_FILE;
+}
+
+static void
+no_config (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+  struct app_data *dp = po->po_data;
+  dp->hints->flags &= ~(MU_CFHINT_SITE_FILE|MU_CFHINT_PER_USER_FILE);
 }
 
 static void
 config_file (struct mu_parseopt *po, struct mu_option *opt,
 	     char const *arg)
 {
-  struct mu_cfg_parse_hints *hints = po->po_data;
-  hints->flags |= MU_CFG_PARSE_CUSTOM_RCFILE;
-  hints->custom_rcfile = mu_strdup (arg);
+  struct app_data *dp = po->po_data;
+  dp->hints->flags = (dp->hints->flags
+		        & ~(MU_CFHINT_SITE_FILE|MU_CFHINT_PROGRAM))
+                      | MU_CFHINT_CUSTOM_FILE;
+  dp->hints->custom_file = mu_strdup (arg);
 }
 
 static void
 config_verbose (struct mu_parseopt *po, struct mu_option *opt,
 		char const *arg)
 {
-  struct mu_cfg_parse_hints *hints = po->po_data;
-  if (hints->flags & MU_PARSE_CONFIG_VERBOSE)
-    hints->flags |= MU_PARSE_CONFIG_DUMP;
+  struct app_data *dp = po->po_data;
+  if (dp->hints->flags & MU_CF_VERBOSE)
+    dp->hints->flags |= MU_CF_DUMP;
   else
-    hints->flags |= MU_PARSE_CONFIG_VERBOSE;
+    dp->hints->flags |= MU_CF_VERBOSE;
 }
 
 static void
 config_lint (struct mu_parseopt *po, struct mu_option *opt,
 		char const *arg)
 {
-  struct mu_cfg_parse_hints *hints = po->po_data;
-  hints->flags |= MU_PARSE_CONFIG_VERBOSE|MU_PARSE_CONFIG_LINT;
+  struct app_data *dp = po->po_data;
+  dp->lint = 1;
+  dp->hints->flags |= MU_CF_VERBOSE;
 }
 
 static void
 param_set (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
 {
-  struct mu_cfg_parse_hints *hints = po->po_data;
+  struct app_data *dp = po->po_data;
   mu_cfg_node_t *node;
   int rc = mu_cfg_create_subtree (arg, &node);
   if (rc)
     mu_parseopt_error (po, "%s: cannot create node: %s",
 		       arg, mu_strerror (rc));
-  if (!(hints->flags & MU_CFG_APPEND_TREE))
+  if (!dp->append_tree)
     {
-      mu_cfg_tree_create (&hints->append_tree);
-      hints->flags |= MU_CFG_APPEND_TREE;
+      mu_cfg_tree_create (&dp->append_tree);
     }
-  mu_cfg_tree_add_node (hints->append_tree, node);
+  mu_cfg_tree_add_node (dp->append_tree, node);
 }
 
 struct mu_option mu_common_options[] = {
-  MU_OPTION_GROUP(N_("Common options")),
+  /*  MU_OPTION_GROUP(N_("Common options")),*/
   { "program-name",   0,  N_("NAME"),  MU_OPTION_IMMEDIATE|MU_OPTION_HIDDEN,
     N_("set program name"),
     mu_c_string, NULL, change_progname },
+  MU_OPTION_END
+};
+
+/* This varibales are used to construct the set of configuration
+   handling options.
+*/
 
-  { "no-user-config", 0,  NULL,        MU_OPTION_IMMEDIATE,
-    N_("do not load user configuration file"),
-    mu_c_string, NULL, no_user_config },
-  { "no-user-rcfile", 0,  NULL,        MU_OPTION_ALIAS },
-  
+/* Option group header */
+static struct mu_option mu_config_option_header =
+  MU_OPTION_GROUP (N_("Configuration handling"));
+
+/* Disables site-wide configuration file */
+static struct mu_option mu_site_config_options[] = {
   { "no-site-config", 0,  NULL,        MU_OPTION_IMMEDIATE,
     N_("do not load site-wide configuration file"),
     mu_c_string, NULL, no_site_config },
-  { "no-site-rcfile", 0,  NULL,        MU_OPTION_ALIAS },
-  
+  MU_OPTION_END
+};  
+
+/* Disables per-user configuration file */
+static struct mu_option mu_user_config_options[] = {
+  { "no-user-config", 0,  NULL,        MU_OPTION_IMMEDIATE,
+    N_("do not load user configuration file"),
+    mu_c_string, NULL, no_user_config },
+  MU_OPTION_END
+};
+
+/* 1. If both site-wide and per-user configuration files are used,
+      this option is equivalent to --no-site-config --no-user-config
+      used together.
+   2. If only site-wide configuration is used, this option is an alias
+      to --no-site-config
+   3. If only per-user configuration is used, this option is an alias
+      to --no-user-config
+
+   Thus, --no-config-option always disables parsing of the default
+   configuration files.
+ */
+static struct mu_option mu_no_config_option = {
+  "no-config", 0,  NULL,        MU_OPTION_IMMEDIATE,
+  N_("do not load site and user configuration files"),
+  mu_c_string, NULL, no_config
+};
+
+/* These options are always available for utilities that use at least
+   one of default configuration files */
+static struct mu_option mu_config_options[] = {
   { "config-file",    0,  N_("FILE"),  MU_OPTION_IMMEDIATE,
-    N_("load this configuration file"),
+    N_("load this configuration file; implies --no-config"),
     mu_c_string, NULL, config_file },
-  { "rcfile",         0,  NULL,        MU_OPTION_ALIAS },
   
   { "config-verbose", 0,  NULL,        MU_OPTION_IMMEDIATE,
     N_("verbosely log parsing of the configuration files"),
     mu_c_string, NULL, config_verbose },
-  { "rcfile-verbose", 0,  NULL,        MU_OPTION_ALIAS },
   
   { "config-lint",    0,  NULL,        MU_OPTION_IMMEDIATE,
     N_("check configuration file syntax and exit"),
     mu_c_string, NULL, config_lint },
-  { "rcfile-lint",    0,  NULL,        MU_OPTION_ALIAS },
 
   { "set",            0,  N_("PARAM=VALUE"), MU_OPTION_IMMEDIATE,
     N_("set configuration parameter"),
     mu_c_string, NULL, param_set },
-  
-  MU_OPTION_END
+
+  MU_OPTION_END  
 };
+
 
 static void
 show_comp_defaults (struct mu_parseopt *po, struct mu_option *opt,
@@ -213,7 +267,7 @@ static void
 show_config_help (struct mu_parseopt *po, struct mu_option *opt,
 		  char const *unused)
 {
-  struct mu_cfg_parse_hints *hints = po->po_data;
+  struct app_data *dp = po->po_data;
 
   char *comment;
   mu_stream_t stream;
@@ -253,11 +307,10 @@ show_config_help (struct mu_parseopt *po, struct mu_option *opt,
   cont = mu_config_clone_root_container ();
   mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL,
 					dummy_include_param, NULL);
-  if (hints->data)
+  if (dp->setup)
     {
-      struct mu_cli_setup *setup = hints->data;
       mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL,
-					    setup->cfg, NULL);
+					    dp->setup->cfg, NULL);
     }
   
   mu_cfg_format_container (stream, cont);
@@ -267,11 +320,15 @@ show_config_help (struct mu_parseopt *po, struct mu_option *opt,
   exit (0);
 }  
 
-struct mu_option mu_extra_help_options[] = {
+static struct mu_option mu_extra_help_options[] = {
   MU_OPTION_GROUP (N_("Informational options")),
   { "show-config-options",   0,  NULL,  MU_OPTION_IMMEDIATE,
     N_("show compilation options"),
     mu_c_string, NULL, show_comp_defaults },
+  MU_OPTION_END
+};
+
+static struct mu_option mu_config_help_options[] = {
   { "config-help",           0,  NULL,  MU_OPTION_IMMEDIATE,
     N_("show configuration file summary"),
     mu_c_string, NULL, show_config_help },
@@ -288,9 +345,38 @@ add_opt_group (void *item, void *data)
   return 0;
 }
 
+#define CONFIG_ENABLED \
+  (MU_CFHINT_SITE_FILE | MU_CFHINT_CUSTOM_FILE | MU_CFHINT_PER_USER_FILE)
+
+static void
+opool_add_option (mu_opool_t pool, struct mu_option *opt)
+{
+  mu_opool_append (pool, opt, sizeof *opt);
+}
+
+static void
+opool_add_options (mu_opool_t pool, struct mu_option *opt)
+{
+  while (!MU_OPTION_IS_END (opt))
+    {
+      opool_add_option (pool, opt);
+      opt++;
+    }
+}
+
+static struct mu_option *
+opool_end_option (mu_opool_t pool)
+{
+  struct mu_option end = MU_OPTION_END;
+  opool_add_option (pool, &end);
+  return mu_opool_finish (pool, NULL);
+}
+
 /* Build the list of option groups and configuration sections */
 static struct mu_option **
-init_options (char **capa, struct mu_cli_setup *setup,
+init_options (mu_opool_t pool,
+	      char **capa, struct mu_cli_setup *setup,
+	      struct mu_cfg_parse_hints const *hints,
 	      mu_list_t *ret_comlist)
 {
   size_t i, s;
@@ -316,8 +402,41 @@ init_options (char **capa, struct mu_cli_setup *setup,
   *ret_comlist = comlist;
   
   mu_list_append (oplist, mu_common_options);
-  mu_list_append (oplist, mu_extra_help_options);
+
+  /* Construct configuration option section */
+  if (hints->flags & CONFIG_ENABLED)
+    {
+      opool_add_option (pool, &mu_config_option_header);
+      opool_add_options (pool, mu_config_options);
+      if (hints->flags & MU_CFHINT_SITE_FILE)
+	{
+	  opool_add_options (pool, mu_site_config_options);
+	  if (hints->flags & MU_CFHINT_PER_USER_FILE)
+	    {
+	      opool_add_options (pool, mu_user_config_options);
+	      opool_add_option (pool, &mu_no_config_option);
+	    }
+	  else
+	    {
+	      struct mu_option opt = mu_no_config_option;
+	      opt.opt_flags = MU_OPTION_ALIAS;
+	      opool_add_option (pool, &opt);
+	    }
+	}
+      else if (hints->flags & MU_CFHINT_PER_USER_FILE)
+	{
+	  struct mu_option opt = mu_no_config_option;
+	  opool_add_options (pool, mu_user_config_options);
+	  opt.opt_flags = MU_OPTION_ALIAS;
+	  opool_add_option (pool, &opt);
+	}
+      mu_list_append (oplist, opool_end_option (pool));
+    }
   
+  mu_list_append (oplist, mu_extra_help_options);
+  if (hints->flags & CONFIG_ENABLED)
+    mu_list_append (oplist, mu_config_help_options);
+		    
   mu_list_count (oplist, &s);
 
   po.po_optv = mu_calloc (s + 1, sizeof (po.po_optv[0]));
@@ -367,6 +486,8 @@ mu_cli_ext (int argc, char **argv,
   char const *dfl_args[DFLARGC];
   char **args = NULL;
   size_t argcnt;
+  struct app_data appd;
+  mu_opool_t pool;
   
   /* Set up defaults */
   if (setup->ex_usage == 0)
@@ -375,10 +496,11 @@ mu_cli_ext (int argc, char **argv,
     setup->ex_config = EX_CONFIG;
 
   hints = *cfhint;
-  hints.data = setup;
+  if (setup->server)
+    hints.flags &= ~MU_CFHINT_PER_USER_FILE;
   
   /* Set program name */
-  if (hints.flags & MU_CFG_PARSE_PROGRAM)
+  if (hints.flags & MU_CFHINT_PROGRAM)
     {
       if (!mu_log_tag)
 	mu_log_tag = (char*)hints.program;
@@ -389,7 +511,7 @@ mu_cli_ext (int argc, char **argv,
       if (!mu_log_tag)
 	mu_log_tag = (char*)mu_program_name;
       hints.program = (char*) mu_program_name;
-      hints.flags |= MU_CFG_PARSE_PROGRAM;
+      hints.flags |= MU_CFHINT_PROGRAM;
     }
 
   /* Initialize standard streams */
@@ -478,12 +600,17 @@ mu_cli_ext (int argc, char **argv,
   if (flags & MU_PARSEOPT_NEGATION)
     po.po_negation = pohint->po_negation;
 
-  po.po_data = &hints;
+  appd.setup = setup;
+  appd.hints = &hints;
+  appd.append_tree = NULL;
+  appd.lint = 0;
+  po.po_data = &appd;
   flags |= MU_PARSEOPT_DATA;
 
   po.po_exit_error = setup->ex_usage;
 
-  optv = init_options (capa, setup, &com_list);
+  mu_opool_create (&pool, MU_OPOOL_ENOMEMABRT);
+  optv = init_options (pool, capa, setup, &hints, &com_list);
 
   if (mu_parseopt (&po, argc, argv, optv, flags))
     exit (po.po_exit_error);
@@ -499,9 +626,35 @@ mu_cli_ext (int argc, char **argv,
   else if (argc)
     mu_parseopt_error (&po, "%s", _("unexpected arguments"));
 
+#if defined(MU_LEGACY_CONFIG_FILE)
+  if ((hints.flags & MU_CFHINT_SITE_FILE)
+      && strcmp (hints.site_file, MU_SITE_CONFIG_FILE) == 0)
+    {
+      if (access (MU_LEGACY_CONFIG_FILE, F_OK) == 0)
+	{
+	  if (access (hints.site_file, F_OK) == 0)
+	    {
+	      mu_diag_output (MU_DIAG_WARNING,
+			      _("legacy configuration file %s ignored"),
+			      MU_LEGACY_CONFIG_FILE);
+	    }
+	  else
+	    {
+	      mu_diag_output (MU_DIAG_WARNING,
+			      _("using legacy configuration file %s: please rename it to %s"),
+		              MU_LEGACY_CONFIG_FILE, MU_SITE_CONFIG_FILE);
+	      hints.site_file = MU_LEGACY_CONFIG_FILE;
+	    }
+	}
+    }  
+#endif
+  
   if (mu_cfg_parse_config (&parse_tree, &hints))
     exit (setup->ex_config);
 
+  if (appd.append_tree)
+    mu_cfg_tree_union (&parse_tree, &appd.append_tree);
+  
   if (mu_cfg_tree_reduce (parse_tree, &hints, setup->cfg, data))
     exit (setup->ex_config);
 
@@ -513,15 +666,14 @@ mu_cli_ext (int argc, char **argv,
   mu_list_foreach (com_list, run_commit, NULL);
   mu_list_destroy (&com_list);
 
-  if (hints.flags & MU_PARSE_CONFIG_LINT)
-    exit (0);
-
   mu_cfg_destroy_tree (&parse_tree);
   free (optv);
-  
   free (args);
-
-  mu_parseopt_free (&po);  
+  mu_parseopt_free (&po);
+  mu_opool_destroy (&pool);
+  
+  if (appd.lint)
+    exit (0);
 }
 
 void
@@ -543,14 +695,14 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa,
   pohint.po_bug_address = PACKAGE_BUGREPORT;
   pohint.po_flags |= MU_PARSEOPT_BUG_ADDRESS;
 
-  pohint.po_extra_info = gnu_general_help_url;
+  pohint.po_extra_info = mu_general_help_text;
   pohint.po_flags |= MU_PARSEOPT_EXTRA_INFO;
 
   pohint.po_version_hook = mu_version_hook;
   pohint.po_flags |= MU_PARSEOPT_VERSION_HOOK;
 
-  cfhint.site_rcfile = mu_site_config_file ();
-  cfhint.flags = MU_CFG_PARSE_SITE_RCFILE;
+  cfhint.site_file = mu_site_config_file ();
+  cfhint.flags = MU_CFHINT_SITE_FILE | MU_CFHINT_PER_USER_FILE;
   
   mu_cli_ext (argc, argv, setup, &pohint, &cfhint, capa, data,
 	      ret_argc, ret_argv);
diff --git a/mail/testsuite/lib/mail.exp b/mail/testsuite/lib/mail.exp
index ddebb2b..ad8a85b 100644
--- a/mail/testsuite/lib/mail.exp
+++ b/mail/testsuite/lib/mail.exp
@@ -18,7 +18,7 @@
 
 source $top_srcdir/testsuite/lib/mailutils.exp
 
-mu_init "--nosum --norc"
+mu_init --nosum --norc
 
 #FIXME: this doesn't work with remote testing
 set env(MAILRC) $MU_RC_DIR/mail.rc
diff --git a/mu/acl.c b/mu/acl.c
index e7d2de7..2a6acc4 100644
--- a/mu/acl.c
+++ b/mu/acl.c
@@ -58,8 +58,8 @@ mutool_acl (int argc, char **argv)
     }
 
   memset (&hints, 0, sizeof (hints));
-  hints.flags = MU_CFG_PARSE_CUSTOM_RCFILE;
-  hints.custom_rcfile = input_file_name;
+  hints.flags = MU_CFHINT_CUSTOM_FILE;
+  hints.custom_file = input_file_name;
 
   mu_acl_cfg_init ();
   if (mu_cfg_parse_config (&tree, &hints))
diff --git a/mu/mu.c b/mu/mu.c
index 0b471aa..03e1f56 100644
--- a/mu/mu.c
+++ b/mu/mu.c
@@ -43,7 +43,20 @@ int
 main (int argc, char **argv)
 {
   mutool_action_t action;
-  
+  static struct mu_parseopt pohint = {
+    .po_flags = MU_PARSEOPT_PACKAGE_NAME
+                | MU_PARSEOPT_PACKAGE_URL
+                | MU_PARSEOPT_BUG_ADDRESS
+                | MU_PARSEOPT_EXTRA_INFO
+                | MU_PARSEOPT_VERSION_HOOK,
+    .po_package_name = PACKAGE_NAME,
+    .po_package_url = PACKAGE_URL,
+    .po_bug_address = PACKAGE_BUGREPORT,
+    .po_extra_info = mu_general_help_text,
+    .po_version_hook = mu_version_hook,
+  };
+  struct mu_cfg_parse_hints cfhint = { .flags = 0 };
+
   /* Native Language Support */
   MU_APP_INIT_NLS ();
   MU_AUTH_REGISTER_ALL_MODULES ();
@@ -51,7 +64,7 @@ main (int argc, char **argv)
   /* Register the desired mailbox formats.  */
   mu_register_all_mbox_formats ();
 
-  mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
+  mu_cli_ext (argc, argv, &cli, &pohint, &cfhint, capa, NULL, &argc, &argv);
 
   if (argc < 1)
     {
diff --git a/mu/query.c b/mu/query.c
index d0016da..3440637 100644
--- a/mu/query.c
+++ b/mu/query.c
@@ -17,7 +17,7 @@
 #include "mu.h"
 
 char query_docstring[] = N_("query configuration values");
-static char query_args_doc[] = N_("path [path...]");
+static char query_args_doc[] = N_("PATH [PATH...]");
 
 static char *file_name;
 int value_option;
@@ -59,21 +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_config_file ();
+  hints.flags = MU_CFHINT_SITE_FILE;
+  hints.site_file = file_name ? file_name : mu_site_config_file ();
 
   if (progname)
     {
-      hints.flags |= MU_CFG_PARSE_PROGRAM;
+      hints.flags |= MU_CFHINT_PROGRAM;
       hints.program = progname;
     }
 
   if (verbose_option)
-    hints.flags |= MU_CFG_FMT_LOCUS;
+    hints.flags |= MU_CF_FMT_LOCUS;
   if (value_option)
-    hints.flags |= MU_CFG_FMT_VALUE_ONLY;
+    hints.flags |= MU_CF_FMT_VALUE_ONLY;
   if (path_option)
-    hints.flags |= MU_CFG_FMT_PARAM_PATH;
+    hints.flags |= MU_CF_FMT_PARAM_PATH;
   
   if (mu_cfg_parse_config (&tree, &hints))
     return 1;
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 39e47fc..de16fbd 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -317,9 +317,10 @@ static char *capa[] = {
 };
 
 struct mu_cli_setup cli = {
-  options,
-  pop3d_cfg_param,
-  N_("GNU pop3d -- the POP3 daemon."),
+  .optv = options,
+  .cfg = pop3d_cfg_param,
+  .prog_doc = N_("GNU pop3d -- the POP3 daemon."),
+  .server = 1
 };
 
 int
diff --git a/pop3d/testsuite/lib/pop3d.exp b/pop3d/testsuite/lib/pop3d.exp
index fa5fc8a..fd7f389 100644
--- a/pop3d/testsuite/lib/pop3d.exp
+++ b/pop3d/testsuite/lib/pop3d.exp
@@ -17,9 +17,8 @@
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. 
 
 source $top_srcdir/testsuite/lib/mailutils.exp
-
     
-mu_init "--rcfile=$objdir/pop3d.rc"
+mu_init "--config-file=$objdir/pop3d.rc"
 mu_version
 if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] {
     clone_output "WARNING: Support for virtual domains not compiled in"
diff --git a/sieve/tests/testsuite.at b/sieve/tests/testsuite.at
index 68cb747..189bab8 100644
--- a/sieve/tests/testsuite.at
+++ b/sieve/tests/testsuite.at
@@ -21,7 +21,7 @@ dnl testcompile(SCRIPT) -- test compilation of the Sieve SCRIPT
 dnl
 m4_define([testcompile],[
 AT_SETUP([compile $1])
-AT_CHECK([sieve -c $abs_top_srcdir/sieve/examples/$1],
+AT_CHECK([sieve MUT_SIEVE_DEFAULT_OPTIONS -c $abs_top_srcdir/sieve/examples/$1],
 [0])
 AT_CLEANUP
 ])
diff --git a/testsuite/lib/mailutils.exp b/testsuite/lib/mailutils.exp
index e47e426..2520f08 100644
--- a/testsuite/lib/mailutils.exp
+++ b/testsuite/lib/mailutils.exp
@@ -148,14 +148,25 @@ proc mu_init {args} {
         set MU_SPOOL_DIR "$MU_DATA_DIR/spool"
 	set MU_FOLDER_DIR "$MU_DATA_DIR/folder"
 
-	if {[llength $args] == 1 && [lindex $args 0] == "-noflags"} {
-	    set MU_TOOL_FLAGS "--no-site-rcfile --no-user-rcfile"
-	} else {
-	    set MU_TOOL_FLAGS "--set mailbox.mail-spool=\"'$MU_SPOOL_DIR'\" --no-site-rcfile --no-user-rcfile"
-	    for {set i 0} {$i < [llength $args]} {incr i} {
-		append MU_TOOL_FLAGS " [lindex $args $i]"
+	lappend flags "--no-config" "--set mailbox.mail-spool=\"'$MU_SPOOL_DIR'\""
+	set i 0
+	for {} {$i < [llength $args]} {incr i} {
+	    switch -- [lindex $args $i] {
+		-noflags  {
+		    unset flags 
+		}
+		--        {
+		    incr i
+		    break
+		}
+		default   {
+		    
+		    break
+		}
 	    }
 	}
+	lappend flags {*}[lrange $args $i end]
+	set MU_TOOL_FLAGS [join $flags { }]
     }
 }
     
diff --git a/testsuite/testsuite.inc b/testsuite/testsuite.inc
index 09cb1c3..aa3cf18 100644
--- a/testsuite/testsuite.inc
+++ b/testsuite/testsuite.inc
@@ -24,8 +24,7 @@ dnl ------------------------------------------------------------
 dnl MUT_DEFAULT_OPTIONS -- produce default command line options
 dnl ------------------------------------------------------------
 m4_define([MUT_DEFAULT_OPTIONS],[dnl
- --no-site-config dnl
- --no-user-config dnl
+ --no-config dnl
  --set '.mailbox.mailbox-type=mbox' dnl
 ])
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 02 09:46:46 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c1vsM-0006gy-4Z
	for mharc-commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:46:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42902)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1vsI-0006fb-7t
	for commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:46:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1vsC-0005Hd-U9
	for commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:46:42 -0400
Received: from vcs.savannah.gnu.org ([208.118.235.72]:58253)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c1vsC-0005HS-Qd
	for commit-mailutils@gnu.org; Wed, 02 Nov 2016 09:46:36 -0400
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 6BA6A220149; Wed,  2 Nov 2016 13:46:36 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-807-gd644964
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad
X-Git-Newrev: d644964e497147d7a3ee0e0693f37ec917a6c738
Message-Id: <20161102134636.6BA6A220149@vcs.savannah.gnu.org>
Date: Wed,  2 Nov 2016 13:46:36 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Nov 2016 13:46:43 -0000

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=d644964e497147d7a3ee0e0693f37ec917a6c738

The branch, master has been updated
       via  d644964e497147d7a3ee0e0693f37ec917a6c738 (commit)
      from  d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad (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 d644964e497147d7a3ee0e0693f37ec917a6c738
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 2 15:38:41 2016 +0200

    Bugfix
    
    * libmailutils/cfg/parser.y (mu_cfg_parse_config): Silently ignore
    ENOENT

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

Summary of changes:
 libmailutils/cfg/parser.y |   35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/libmailutils/cfg/parser.y b/libmailutils/cfg/parser.y
index 0b362a8..48f94d9 100644
--- a/libmailutils/cfg/parser.y
+++ b/libmailutils/cfg/parser.y
@@ -1530,15 +1530,19 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints)
     {
       rc = mu_cfg_parse_file (&tmp, hints->site_file, hints->flags);
       
-      if (rc == ENOMEM)
-	{
-	  mu_error ("%s", mu_strerror (rc));
-	  return rc;
-	}
-      else if (rc == 0)
+      switch (rc)
 	{
+	case 0:
 	  mu_cfg_tree_postprocess (tmp, hints);
 	  mu_cfg_tree_union (&tree, &tmp);
+	  
+	case ENOENT:
+	  rc = 0;
+	  break;
+
+	default:
+	  mu_error ("%s", mu_strerror (rc));
+	  return rc;
 	}
     }
 
@@ -1556,19 +1560,22 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints)
 	  strcat (file_name, hints->program);
 	  
 	  rc = mu_cfg_parse_file (&tmp, file_name, xhints.flags);
-	  if (rc == ENOMEM)
+	  switch (rc)
 	    {
+	    case 0:
+	      mu_cfg_tree_postprocess (tmp, &xhints);
+	      mu_cfg_tree_union (&tree, &tmp);
+	      break;
+
+	    case ENOENT:
+	      rc = 0;
+	      break;
+	      
+	    default:
 	      mu_error ("%s", mu_strerror (rc));
 	      mu_cfg_destroy_tree (&tree);
 	      return rc;
 	    }
-	  else if (rc == 0)
-	    {
-	      mu_cfg_tree_postprocess (tmp, &xhints);
-	      mu_cfg_tree_union (&tree, &tmp);
-	    }
-	  else if (rc == ENOENT)
-	    rc = 0;
 	  free (file_name);
 	}
     }


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 03 12:12:41 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c2Kd6-0004Yu-TR
	for mharc-commit-mailutils@gnu.org; Thu, 03 Nov 2016 12:12:40 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35822)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c2Kd0-0004YK-GU
	for commit-mailutils@gnu.org; Thu, 03 Nov 2016 12:12:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c2Kcs-0001NW-UH
	for commit-mailutils@gnu.org; Thu, 03 Nov 2016 12:12:34 -0400
Received: from vcs.savannah.gnu.org ([208.118.235.72]:44301)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c2Kcs-0001NP-P1
	for commit-mailutils@gnu.org; Thu, 03 Nov 2016 12:12:26 -0400
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 8236F22017C; Thu,  3 Nov 2016 16:12:26 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-808-gedb0514
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d644964e497147d7a3ee0e0693f37ec917a6c738
X-Git-Newrev: edb05144ade1984e28d88cfaea7c2fb0ec675f5b
Message-Id: <20161103161226.8236F22017C@vcs.savannah.gnu.org>
Date: Thu,  3 Nov 2016 16:12:26 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 03 Nov 2016 16:12:39 -0000

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=edb05144ade1984e28d88cfaea7c2fb0ec675f5b

The branch, master has been updated
       via  edb05144ade1984e28d88cfaea7c2fb0ec675f5b (commit)
      from  d644964e497147d7a3ee0e0693f37ec917a6c738 (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 edb05144ade1984e28d88cfaea7c2fb0ec675f5b
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 3 17:59:06 2016 +0200

    Fix docs. Change argument of the field-map configuration statement
    
    The field-map statement (.ldap.field-map & .sql.field-map) takes a
    list of mappings as argument.  For compatibility and for internal purposes,
    a string is still allowed.
    
    * doc/texinfo/programs.texi: Update.
    * include/mailutils/cfg.h (mu_cfg_field_map): New proto.
    * include/mailutils/sql.h (mu_password_type): Rename.
    (mu_sql_module_config) <positional>: Remove.
    (mu_sql_decode_password_type): Remove prototype.
    * libmailutils/base/mutil.c (mu_sql_decode_password_type): Remove
    function.
    * libmailutils/cfg/driver.c (mu_cfg_field_map): New function.
    * libmu_auth/ldap.c (cb_field_map): Use mu_cfg_field_map.
    (module_init): Fix default filter.
    * libmu_auth/sql.c (cb_field_map): Use mu_cfg_field_map.
    (mu_sql_param): Rename "password-type" statement to "password-encryption".
    Remove the "positional" statement.

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

Summary of changes:
 doc/texinfo/programs.texi |  478 +++++++++++++++++++++++++++++++++++++--------
 imap4d/auth_gsasl.c       |    2 +-
 include/mailutils/cfg.h   |    4 +
 include/mailutils/sql.h   |   13 +-
 libmailutils/base/mutil.c |   15 --
 libmailutils/cfg/driver.c |   91 ++++++++-
 libmu_auth/gsasl.c        |   10 +-
 libmu_auth/ldap.c         |   36 ++--
 libmu_auth/sql.c          |  130 ++++--------
 9 files changed, 561 insertions(+), 218 deletions(-)

diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index c087984..c3612b4 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -231,7 +231,7 @@ Don't load site-wide and user configuration files.
 
 @xopindex{set, introduced}
 @item --set=@var{path}=@var{value}
-Set configuration variable.
+Set configuration variable.  @xref{the --set option}.
 @end table
 
 @node configuration
@@ -292,12 +292,10 @@ following warning will be issued:
 
 Client utilities, such as @command{frm} or @command{sieve}, look in
 the user home directory for a file named @samp{.@var{prog}}, where
-@var{prog} is the name of the utility.  If it is present, it will be
-loaded after loading the site-wide configuration file.  This file
-allows users to customize such utilities.
-
-For example, the per-user configuration file for @command{sieve}
-utility is named @file{.sieve}. 
+@var{prog} is the name of the utility.  If present, this file will be
+loaded after loading the site-wide configuration file.  For example,
+the per-user configuration file for @command{sieve} utility is named
+@file{.sieve}.
 
 @xopindex{no-user-config, described}
 Loading of per-user configuration file is disabled by
@@ -320,40 +318,42 @@ case, default configuration files are not used at all.
 
 @xopindex{config-verbose, described}
 Neither site-wide nor user configuration files are required to
-exist.  If any or both of them are absent, GNU Mailutils does not
-complain, and the utility falls back to its default settings.  To make
-configuration processing more verbose, use the
+exist.  If any or both of them are absent, GNU Mailutils won't
+complain -- the utility will silently fall back to its default
+settings.
+
+To make configuration processing more verbose, use the
 @option{--config-verbose} command line option.  Here is an example of
 what you might get using this option:
 
 @example
-imap4d: Info: parsing file `/etc/mailutils.rc'
-imap4d: Info: finished parsing file `/etc/mailutils.rc'
+imap4d: parsing file `/etc/mailutils.conf'
+imap4d: finished parsing file `/etc/mailutils.conf'
 @end example
 
 Specifying this option more than once adds more verbosity to this
 output.  If this option is given two times, GNU Mailutils will print
-any configuration file statement it parsed, along with the exact
+each configuration file statement it parsed, along with the exact
 location where it occurred (the exact meaning of each statement will
 be described later in this chapter):
 
 @example
-imap4d: Info: parsing file `/etc/mailutils.rc'
-@hashchar{} 1 "/etc/mailutils.rc"
+imap4d: parsing file `/etc/mailutils.conf'
+@hashchar{} 1 "/etc/mailutils.conf"
 mailbox @{
-@hashchar{} 2 "/etc/mailutils.rc"
+@hashchar{} 2 "/etc/mailutils.conf"
   mailbox-pattern maildir:/var/spool/mail;type=index;param=2;user=$@{user@};
-@hashchar{} 3 "/etc/mailutils.rc"
+@hashchar{} 3 "/etc/mailutils.conf"
   mailbox-type maildir;
 @};
-@hashchar{} 6 "/etc/mailutils.rc"
+@hashchar{} 6 "/etc/mailutils.conf"
 include /etc/mailutils.d;
-imap4d: Info: parsing file `/etc/mailutils.d/imap4d'
+imap4d: parsing file `/etc/mailutils.d/imap4d'
 ...
 @end example
 
 @xopindex{config-lint, described}
-  To test configuration file without actually starting the utility,
+  To test configuration file without actually running the utility,
 use the @option{--config-lint} command line option.  With this option,
 any Mailutils utility exits after finishing parsing of the
 configuration files.  Any errors occurred during parsing are displayed
@@ -368,11 +368,11 @@ configuration file.  For example, the simplest way to write a
 configuration file for, say, @command{imap4d} is to run
 
 @example
-$ imap4d --config-help > imap4d.rc
+$ imap4d --config-help > imap4d.conf
 @end example
 
 @noindent
-and to edit the @file{imap4d.rc} file with your editor of choice.
+and to edit the @file{imap4d.conf} file with your editor of choice.
 
 The order in which configuration files are loaded defines the
 precedence of their settings.  Thus, for client utilities, settings
@@ -391,7 +391,8 @@ following:
 $ imap4d --set .logging.syslog=no
 @end example
 
-Configuration pathnames are discussed in detail in @ref{Paths}.
+Configuration pathnames are discussed in detail in @ref{Paths}.  For a
+detailed description of this option, @ref{the --set option}.
 
 The @option{--set} options are processed after loading all
 configuration files.
@@ -716,6 +717,76 @@ component separator, e.g.:
 .program="a.out".bar.baz
 @end example
 
+@anchor{the --set option}
+The @option{--set} command line option allows you to set configuration
+variables from the command line.  Its argument consists of the
+statement path and value, separated by a single equals sign (no
+whitespace is permitted at either side of it).  For example, the
+following option:
+
+@example
+--set .logging.facility=mail
+@end example
+
+@noindent
+has the same effect as the following statement in the configuration
+file:
+
+@example
+logging @{
+    facility mail;
+@}
+@end example
+
+Values set using this option override those set in the configuration
+files.  This provides a convenient way for temporarily changing
+configuration without altering configuration files.
+
+Notice, that when using @option{--set}, the @samp{=} sign has two
+purposes: first it separates statement path from the value, thus
+forming an assignment, and secondly it can be used within the path
+itself to introduce a tag.  To illustrate this, let's assume you have
+the following statement in your configuration file:
+
+@example
+@group
+program pop3d @{
+    logging @{
+       facility mail;
+    @}
+    server 0.0.0.0 @{
+       transcript no;
+    @}
+@}
+@end group
+@end example
+
+Now assume you wish to temporarily change logging facility to
+@samp{local1}.  The following option will do this:
+
+@example
+--set .program=pop3d.logging.facility=local1
+@end example
+
+When splitting the argument to @option{--set}, the option parser
+always looks for the rightmost equals sign.  Everything to the right
+of it is the value, and everything to the left of it - the path.
+
+If the tag contains dots (as the @code{server} statement in the
+example above), you should either escape them with slashes or change
+the pathname separator to some other character, e.g.:
+
+@example
+--set .program=pop3d.server='0\.0\.0\.0'.transcript=yes
+@end example
+
+@noindent
+or
+
+@example
+--set /program=pop3d/server="0.0.0.0"/transcript=yes
+@end example
+
 @node Variables
 @subsection Configuration Variables
 @cindex variable expansion
@@ -767,15 +838,16 @@ each configuration statement.
 @anchor{Include} @c for backward-compatibility
 @cindex include statement, configuration file
 @kwindex include
-  The @dfn{include statement} is a special statement that causes
-inclusion of the named file.  It has the following syntax:
+  A special statement is provided that causes inclusion of the named
+file.  It has the following syntax: 
 
 @example
 include @var{file};
 @end example
 
-The effect of this statement is that the contents of this @var{file} is
-included in this point.
+When reading the configuration file, this statement is effectively
+replaced with the content of @var{file}.  It is an error if @var{file}
+does not exist.
 
 In site-wide configuration file, @var{file} can be a directory name.
 In this case, Mailutils will search this directory for a file with the
@@ -815,11 +887,10 @@ temporary storage are processed.
 
 Notice the difference between this statement and a per-program
 configuration file loaded via an @code{include} statement.  No matter
-where in the file the @command{program} statement is, it is always
-processed after the entire configuraion file is processed.  In the
+where in the file the @command{program} statement is, its content will
+be processed after the content of the enclosing file.  In the
 contrast, the per-program configuration file loaded via @code{include}
-with the directory name as its argument is processed right where it is
-encountered.
+is processed right where it is encountered.
 
 @node logging statement
 @subsection The @code{logging} Statement
@@ -966,19 +1037,16 @@ favor of @code{mailbox-pattern} statement.
 The @code{mailbox-pattern} statement is a preferred way of configuring
 mailbox locations.  It supersedes @code{mail-spool} statement.
 
-The @var{url} is valid mailbox URL (@pxref{Mailbox}), which 
+The @var{url} must be a valid mailbox URL (@pxref{Mailbox}), which 
 may contain references to the @samp{user} variable
 (@pxref{Variables}).  This variable will be expanded to the actual
 user name.
 
 @anchor{local URL parameters}
-Optional URL parameters can be used to configure indexed directory
-structure.
-
 @cindex directory indexing
-An @dfn{indexed directory structure} is a special way of storing
-mailboxes, which allows for faster access in case of very large
-number of users. 
+Optional URL parameters can be used to configure @dfn{indexed directory
+structure}.  Such structure is a special way of storing mailboxes,
+which allows for faster access in case of very large number of users. 
 
 By default, all user mailboxes are stored in a single directory and
 are named after user login names.  To find the mailbox for a given
@@ -999,7 +1067,8 @@ user mailbox is determined using the following algorithm:
 @enumerate 1
 @item Take the first letter of the user name.
 @item Map it to a lower-case letter using @dfn{index mapping}
-table.  The result gives sub-directory name.
+table.  The result gives the name of a sub-directory where the mailbox
+is located.
 @item Descend into this directory.
 @end enumerate
 
@@ -1041,7 +1110,7 @@ arguments:
 @table @asis
 @kwindex type
 @item type=@var{value}
-Specifies type of indexing.  Valid values are @samp{index}, for direct
+Specifies the type of indexing.  Valid values are @samp{index}, for direct
 indexed structure, @samp{rev-index} for reverse indexing, and
 @samp{hash} for hashed structure.
 
@@ -1085,22 +1154,22 @@ If neither @code{mailbox-pattern} nor @code{mail-spool} are given, the
 mailbox names are determined using the following algorithm:
 
 @enumerate 1
-@item If environment variable @env{FOLDER} its value is used.
-@item Otherwise, if environment variable @env{MAIL} is set, its value
-is used.
-@item If neither of these is set, the mailbox name is constructed by
+@item If environment variable @env{FOLDER} is set, use its value.
+@item Otherwise, if environment variable @env{MAIL} is set, use its
+value.
+@item If neither of these is set, construct the mailbox name by 
 concatenating the built-in mail spool directory name, a directory
 separator, and the user name.
 
 The built-in mail spool directory name is determined at compile
-time, using @samp{_PATH_MAILDIR} define from the include file
+time, using the @samp{_PATH_MAILDIR} define from the include file
 @file{paths.h}.  If this value is not defined, @file{/var/mail} or
 @file{/usr/spool/mail} is used.
 @end enumerate
 
 @deffn {Configuration} mailbox-type @var{type}
 @vrindex MU_DEFAULT_SCHEME
-Specifies type of mailboxes.  By default, @samp{mbox} (UNIX mailbox)
+Specifies the type of mailboxes.  By default, @samp{mbox} (UNIX mailbox)
 is assumed.  This can be changed while configuring the package by
 setting @code{MU_DEFAULT_SCHEME} configuration variable.  The default
 value can be verified by running @command{mailutils info scheme}.
@@ -1157,7 +1226,7 @@ the following letters:
 
 @table @asis
 @item E
-Use an external program to manage locks.  The program is given by
+Use an external program to manage locks.  The program is given by the
 @code{external-locker} statement (see below).
 
 @item R
@@ -1192,8 +1261,9 @@ seconds ago.  The @samp{T} flag must be set for this to take effect.
 @end deffn
 
 @deffn {Configuration} external-locker @var{string}
-Set command line of an external locker program.  The @samp{E} flag
-must be set for this to take effect. 
+Determines the external locker program to use.  The @var{string}
+argument is the valid command line, starting with the full program
+name.  The @samp{E} flag must be set for this to take effect. 
 @end deffn
 
 @node mailer statement
@@ -1429,15 +1499,15 @@ Access control using TCP wrappers is based on two files, called
 @dfn{tables}, containing access rules.  There are two tables: the
 @dfn{allow table}, usually stored in file @file{/etc/hosts.allow}, and
 the @dfn{deny table}, kept in file @file{/etc/hosts.deny}.  The rules
-in each table begin with an identifier called @dfn{daemon name}.  Each
-utility wishing to verify a connection, select the entries having
+in each table begin with an identifier called @dfn{daemon name}.  A
+utility that wishes to verify a connection, selects the entries having
 its daemon name from the allow table.  A connection is allowed if it
 matches any of these entries.  Otherwise, the utility retrieves all
 entries with its daemon name from the deny table.  If any of these
 matches the connection, then it is refused.  Otherwise, if neither
 table contains matching entries, the connection is allowed.
 
-Description of a TCP wrapper table format lies outside the scope of
+The description of a TCP wrapper table format lies outside the scope of
 this document.  Please, see @ref{ACCESS CONTROL FILES,,ACCESS CONTROL FILES,
 hosts_access(5), hosts_access(5) man page}, for details.
 
@@ -1562,7 +1632,7 @@ After startup, store the PID of the main server process in
 @var{file}.  When the process terminates, the file is removed.  As of
 version @value{VERSION}, GNU Mailutils servers make no further use of
 this file.  It is intended for use by automated startup scripts and
-controlling programs (@FIXME-pxref{mention pies}).
+controlling programs (e.g. @pxref{Top, GNU pies,, pies, GNU Pies Manual}).
 @end deffn
 
 @deffn {Configuration} port @var{portspec};
@@ -1646,7 +1716,7 @@ in debugging.  They should be turned off on most production servers.
 @end deffn
 
 @deffn {Configuration} timeout @var{time};
-Set idle timeout for this server.  This overrides global timeout
+Set idle timeout for this server.  This overrides the global timeout
 settings (@pxref{General Server Configuration, timeout}).
 @end deffn
 
@@ -1779,13 +1849,18 @@ database.  @xref{ldap statement}, for an information on how to
 configure it.
 @end table
 
-@FIXME{This may be inaccurate:}
 Unless overridden by @code{authorization} statement,
 the default list of authorization modules is:
 
-@example
-  (system, sql, virtdomains)
-@end example
+@enumerate 1
+@item generic
+@item system
+@item pam
+@item sql
+@item virtual
+@item radius
+@item ldap
+@end enumerate
 @end deffn
 
 @deffn {Configuration} authentication @var{module-list}
@@ -1816,19 +1891,24 @@ server.  @xref{radius statement}.
 The user is authenticated using @acronym{LDAP}.  @xref{ldap statement}.
 @end table
 
-@FIXME{This list is inaccurate:}
 Unless overridden by @code{authentication} statement,
-the list of authentication modules is:
+the list of authentication modules is the same as for
+@code{authorization}, i.e.:
 
-@example
-  (generic, system, pam, sql)
-@end example
+@enumerate 1
+@item generic
+@item system
+@item pam
+@item sql
+@item virtual
+@item radius
+@item ldap
+@end enumerate
 @end deffn
 
 @node pam statement
 @subsection PAM Statement
 @anchor{PAM Statement}
-@UNREVISED
 @kwindex pam
 @subheading Syntax
 @example
@@ -1853,7 +1933,6 @@ This statement takes effect only if @samp{pam} is listed in
 @node virtdomain statement
 @subsection The @code{virtdomain} Statement
 @anchor{Virtdomain Statement}
-@UNREVISED
 @kwindex virtdomain
 @subheading Syntax
 @example
@@ -1880,8 +1959,8 @@ latter is set using @code{passwd-dir} statement.
 Set virtual domain password directory.
 @end deffn
 
-For example, when authenticating user @samp{smith@@domain.tld},
-the server will use password file named @file{@var{dir}/domain.tld}.
+For example, when authenticating user @samp{smith@@example.com},
+the server will use password file named @file{@var{dir}/example.com}.
 This file must be in UNIX passwd format (@pxref{password
 file,,,passwd(5), passwd(5) man page}), with encrypted passwords
 stored in it (as of GNU Mailutils version @value{VERSION}, there is no
@@ -1911,7 +1990,6 @@ file.
 @node radius statement
 @subsection The @code{radius} Statement
 @anchor{Radius Statement}
-@UNREVISED
 @kwindex radius
 @subheading Syntax
 @example
@@ -2043,7 +2121,7 @@ The attributes @code{GNU-MU-Mailbox} and @code{GNU-MU-Quota} are
 optional.
 
 If @code{GNU-MU-Mailbox} is present, it must contain a
-valid mailbox @acronym{URL} (@FIXME-pxref{urls}).  If
+valid mailbox @acronym{URL} (@pxref{Mailbox, URL}).  If
 @code{GNU-MU-Mailbox} is not present, Mailutils constructs the
 mailbox name using the settings from the @code{mailbox} configuration
 statement (@pxref{Mailbox Statement}), or built-in defaults, if it is
@@ -2071,7 +2149,6 @@ request (see above).
 @node sql statement
 @subsection The @code{sql} Statement
 @anchor{SQL Statement}
-@UNREVISED
 @kwindex sql
 @subheading Syntax
 @example
@@ -2091,7 +2168,7 @@ sql @{
   # @r{Type of password returned by getpass query.}
   password-type @samp{plain | hash | scrambled};
   # @r{Set a field-map for parsing SQL replies.}
-  field-map @var{map};
+  field-map @var{list};
   # @r{SQL query returning the user's password.}
   getpass @var{query};
   # @r{SQL query to use for getpwnam requests.}
@@ -2155,10 +2232,101 @@ Name of the database.
 Password to access the database.
 @end deffn
 
+@deffn {Configuration} password-encryption @var{arg};
+Defines type of encryption used by the password returned by
+@code{getpass} query (see below).  Possible arguments are:
+
+@table @asis
+@item plain
+Password is in plain text.
+
+@item crypt
+@itemx hash
+Password is encrypted by system @code{crypt} function
+(@pxref{crypt,,,crypt(3), crypt(3) man page}).
+
+@item scrambled
+Password is encrypted by MySQL @code{password} function.
+@end table
+@end deffn
+
+@deffn {Configuration} getpwnam @var{query}
+Defines SQL query that returns information about the given user.  The
+@var{query} is subject to variable expansion (@pxref{Variables}).  The
+only variable defined is @samp{$user}, which expands to the user name.
+
+@anchor{getpw column names}
+The query should return a single row with the following columns:
+
+@table @asis
+@item name
+User name.
+@item passwd
+User password.
+@item uid
+UID of the user.
+@item gid
+GID of the primary group.
+@item gecos
+Textual description of the user.
+@item dir
+User's home directory
+@item shell
+User's shell program.
+@end table
+
+The following columns are optional:
+
+@table @asis
+@item mailbox
+Full pathname of the user's mailbox.  If not returned or NULL, the
+mailbox is determined using the default algorithm (@pxref{Mailbox}).
+@item quota
+Upper limit on the size of the mailbox.  The value is either an
+integer number optionally followed by one of the usual size suffixes:
+@samp{K}, @samp{M}, @samp{G}, or @samp{T} (case-insensitive).
+@end table
+@end deffn
+
+@deffn {Configuration} getpwuid @var{query}
+Defines SQL query that returns information about the given UID.  The
+@var{query} is subject to variable expansion (@pxref{Variables}).  The
+only variable defined is @samp{$user}, which expands to the UID.
+
+The query should return a single row, as described for @code{getpwnam}.
+@end deffn
+
+@deffn {Configuration} getpass @var{query}
+Defines SQL query that returns the password of the given user.  The
+@var{query} is subject to variable expansion (@pxref{Variables}).  The
+only variable defined is @samp{$user}, which expands to the user name.
+
+The query should return a row with a single column, which gives the
+password.  The password can be encrypted as specified by the
+@code{password-encryption} statement.
+@end deffn
+
+@deffn {Configuration} field-map @var{list}
+Defines a translation map for column names.   The @var{list} is a
+list of mappings.  Each mapping is a string
+@samp{@var{name}=@var{column}}, where @var{name} is one of the names
+described in @ref{getpw column names}, and @var{column} is the name of
+the column in the returned row that should be used instead.  The effect of
+this statement is similar to that of SQL @code{AS} keyword.  E.g. the
+statement
+
+@example
+field-map (uid=user_id);
+@end example
+
+@noindent
+has the same effect as using @samp{SELECT user_id AS uid} in the SQL
+statement.
+@end deffn
+
 @node ldap statement
 @subsection The @code{ldap} Statement
 @anchor{LDAP Statement}
-@WRITEME
 @kwindex ldap
 @subheading Syntax
 @example
@@ -2178,18 +2346,107 @@ ldap @{
   # @r{Set LDAP debugging level.}
   debug @var{number};
   # @r{Set a field-map for parsing LDAP replies.}
-  field-map @var{map};
+  field-map @var{list};
   # @r{LDAP filter to use for getpwnam requests.}
   getpwnam @var{string};
   # @r{LDAP filter to use for getpwuid requests.}
   getpwuid @var{filter};
 @}
 @end example
+@subheading Description
+The @code{ldap} statement configures the use of LDAP for authentication.
+
+@deffn {Configuration} enable @var{bool}
+Enables LDAP lookups.  If absent, @samp{enable On} is assumed.
+@end deffn
+
+@deffn {Configuration} url @var{url}
+Sets the URL of the LDAP server.
+@end deffn
+
+@deffn {Configuration} base @var{string}
+Defines base DN for LDAP lookups.
+@end deffn
+
+@deffn {Configuration} binddn @var{string}
+Defines the DN for accessing LDAP database.
+@end deffn
+
+@deffn {Configuration} passwd @var{string}
+Password for use when binding to the database.
+@end deffn
+
+@deffn {Configuration} tls @var{bool}
+Enable the use of TLS when connecting to the server.
+@end deffn
+
+@deffn {Configuration} debug @var{number}
+Set LDAP debug level.  Please refer to the OpenLDAP documentation, for
+allowed @var{number} values and their meaning.
+@end deffn
+
+@deffn {Configuration} field-map @var{map} 
+Defines a map for parsing LDAP replies.  The @var{map} is a list
+of mappings@footnote{For backward compatibility, @var{map} can be a
+string containing colon-delimited list of mappings.  Such usage is,
+however, deprecated.}.  Each mapping is @samp{@var{field}=@var{attr}}, where
+@var{attr} is the name of the LDAP attribute and @var{field} is a
+field name that declares what information that attribute carries.
+Available values for @var{field} are:
+
+@table @asis
+@item name
+User name.
+@item passwd
+User password.
+@item uid
+UID of the user.
+@item gid
+GID of the primary group.
+@item gecos
+Textual description of the user.
+@item dir
+User's home directory
+@item shell
+User's shell program.
+@end table
+
+The default mapping is
+
+@example
+@group
+  ("name=uid",
+   "passwd=userPassword",
+   "uid=uidNumber",
+   "gid=gidNumber",
+   "gecos=gecos",
+   "dir=homeDirectory",
+   "shell=loginShell")
+@end group
+@end example
+@end deffn
+
+@deffn {Configuration} getpwnam @var{string}
+Defines the LDAP filter to use for @samp{getpwnam} requests.  The
+default is:
+
+@example
+  (&(objectClass=posixAccount) (uid=$user))
+@end example
+@end deffn
+
+@deffn {Configuration} getpwuid @var{string}
+Defines the LDAP filter to use for @samp{getpwuid} requests.  The
+default filter is:
+
+@example
+  (&(objectClass=posixAccount) (uidNumber=$user))
+@end example
+@end deffn
 
 @node tls statement
 @subsection The @code{tls} Statement
 @anchor{TLS Statement}
-@WRITEME
 @kwindex tls
 @subheading Syntax
 @example
@@ -2197,13 +2454,80 @@ tls @{
   # @r{Enable TLS support.}
   enable @var{bool};
   # @r{Specify SSL certificate file.}
-  ssl-cert @var{bool};
+  ssl-cert @var{string};
   # @r{Specify SSL certificate key file.}
   ssl-key @var{file};
   # @r{Specify trusted CAs file.}
   ssl-cafile @var{file};
+  # @r{Set the priorities to use on the ciphers, methods, etc.}
+  ssl-priorities @var{string};
+  # @r{Configure safety checks for SSL key file.}
+  key-file-safety-checks @var{list};
+  # @r{Configure safety checks for SSL certificate.}
+  cert-file-safety-checks @var{list};
+  # @r{Configure safety checks for SSL CA file.}
+  ca-file-safety-checks @var{list};
 @}
 @end example
+@subheading Description
+
+@deffn {Configuration} enable @var{bool}
+Enable TLS support.  If absent, @samp{enable On} is assumed.
+@end deffn
+
+@deffn {Configuration} ssl-cert @var{string}
+Specify SSL certificate file.
+@end deffn
+
+@deffn {Configuration} ssl-key @var{file}
+Specify SSL certificate key file.
+@end deffn
+
+@deffn {Configuration} ssl-cafile @var{file}
+Specify the trusted certificate authorities file.
+@end deffn
+
+@deffn {Configuration} ssl-priorities @var{string}
+Set the priorities to use on the ciphers, key exchange methods, MACs
+and compression methods.
+@end deffn
+
+@deffn {Configuration} key-file-safety-checks @var{list}
+Configure safety checks for SSL key file.  Elements of the @var{list} are
+names of individual checks, optionally prefixed with @samp{+} to enable or 
+@samp{-} to disable the corresponding check.  Valid check names are:
+
+@table @asis
+@item none
+Disable all checks.
+@item all
+Enable all checks.
+@item gwrfil
+Forbid group writable files.
+@item awrfil
+Forbid world writable files.
+@item grdfil
+Forbid group readable files.
+@item ardfil
+Forbid world writable files.
+@item linkwrdir
+Forbid symbolic links in group or world writable directories.
+@item gwrdir
+Forbid files in group writable directories.
+@item awrdir
+Forbid files in world writable directories,
+@end table
+@end deffn
+
+@deffn {Configuration} cert-file-safety-checks @var{list}
+Configure safety checks for SSL certificate.  See
+@code{key-file-safety-checks} for a description of @var{list}.
+@end deffn
+
+@deffn {Configuration} ca-file-safety-checks @var{list}
+Configure safety checks for SSL CA file.  See
+@code{key-file-safety-checks} for a description of @var{list}.
+@end deffn
 
 @node gsasl statement
 @subsection The @code{gsasl} Statement
@@ -8226,13 +8550,13 @@ optional @var{col} is the column number in that file.
 For example, the following invocation:
 
 @example
-mailutils logger --locus mailutils.rc:34 Suspicious statement
+mailutils logger --locus mailutils.conf:34 Suspicious statement
 @end example
 
 will send the following to the log:
 
 @example
-mu-logger: mailutils.rc:34: Suspicious statement
+mu-logger: mailutils.conf:34: Suspicious statement
 @end example
 
 @node mailutils pop
diff --git a/imap4d/auth_gsasl.c b/imap4d/auth_gsasl.c
index dbcdbd3..10f2aa6 100644
--- a/imap4d/auth_gsasl.c
+++ b/imap4d/auth_gsasl.c
@@ -243,7 +243,7 @@ retrieve_password (Gsasl *ctx, Gsasl_session *sctx)
     }
   
 #ifdef USE_SQL
-  if (mu_sql_module_config.password_type == password_plaintext)
+  if (mu_sql_module_config.password_encryption == mu_sql_password_plaintext)
     {
       char *passwd;
       int status = mu_sql_getpass (*username, &passwd);
diff --git a/include/mailutils/cfg.h b/include/mailutils/cfg.h
index 9b8e951..63b6d3b 100644
--- a/include/mailutils/cfg.h
+++ b/include/mailutils/cfg.h
@@ -297,6 +297,10 @@ int mu_cfg_create_subtree (const char *path, mu_cfg_node_t **pnode);
 int mu_cfg_parse_config (mu_cfg_tree_t **ptree,
 			 struct mu_cfg_parse_hints *hints);
 
+int mu_cfg_field_map (struct mu_config_value const *val, mu_assoc_t *passoc,
+		      char **err_term);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/sql.h b/include/mailutils/sql.h
index ff3a16e..5df8506 100644
--- a/include/mailutils/sql.h
+++ b/include/mailutils/sql.h
@@ -20,11 +20,11 @@
 #define _MAILUTILS_SQL_H
 
 /* Configuration */
-enum mu_password_type
+enum mu_sql_password_encryption
   {
-    password_plaintext,       /* Plaintext passwords */
-    password_scrambled,       /* Scrambled MySQL (>=3.21) password */
-    password_hash,            /* MD5 (or DES or whatever) hash */
+    mu_sql_password_plaintext,       /* Plaintext passwords */
+    mu_sql_password_scrambled,       /* Scrambled MySQL (>=3.21) password */
+    mu_sql_password_hash,            /* MD5 (or DES or whatever) hash */
   };
 
 struct mu_sql_module_config
@@ -38,8 +38,7 @@ struct mu_sql_module_config
   char *passwd;
   char *db;
   int port;
-  enum mu_password_type password_type;
-  int positional;
+  enum mu_sql_password_encryption password_encryption;
   mu_assoc_t field_map;
 };
 
@@ -143,6 +142,4 @@ extern int mu_sql_getpass (const char *username, char **passwd);
 extern int mu_check_mysql_scrambled_password (const char *scrambled,
 					      const char *message);
 
-int mu_sql_decode_password_type (const char *arg, enum mu_password_type *t);
-
 #endif
diff --git a/libmailutils/base/mutil.c b/libmailutils/base/mutil.c
index 4cd1660..be5821a 100644
--- a/libmailutils/base/mutil.c
+++ b/libmailutils/base/mutil.c
@@ -118,21 +118,6 @@ mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, int *perr)
   return rc;
 }
 
-/* FIXME: should it be here? */
-int
-mu_sql_decode_password_type (const char *arg, enum mu_password_type *t)
-{
-  if (strcmp (arg, "plain") == 0)
-    *t = password_plaintext;
-  else if (strcmp (arg, "hash") == 0)
-    *t = password_hash;
-  else if (strcmp (arg, "scrambled") == 0)
-    *t = password_scrambled;
-  else
-    return 1;
-  return 0;
-}
-
 int
 mu_stream_flags_to_mode (int flags, int isdir)
 {
diff --git a/libmailutils/cfg/driver.c b/libmailutils/cfg/driver.c
index 1b1ff05..4f0e875 100644
--- a/libmailutils/cfg/driver.c
+++ b/libmailutils/cfg/driver.c
@@ -38,7 +38,7 @@
 #include <mailutils/stream.h>
 #include <mailutils/assoc.h>
 #include <mailutils/alloc.h>
-
+#include <mailutils/cstr.h>
 
 static mu_assoc_t section_tab;
 
@@ -587,3 +587,92 @@ mu_cfg_string_value_cb (mu_config_value_t *val,
     }
   return rc;
 }
+
+struct mapping_closure
+{
+  mu_assoc_t assoc;
+  char *err_term;
+  int err;
+};
+
+static int
+parse_mapping (void *item, void *data)
+{
+  struct mapping_closure *clos = data;
+  char *str = item;
+  size_t len;
+  char *key, *val;
+  
+  len = strcspn (str, "=");
+  if (str[len] == 0)
+    {
+      clos->err_term = mu_strdup (str);
+      return MU_ERR_PARSE;
+    }
+  key = mu_alloc (len + 1);
+  memcpy (key, str, len);
+  key[len] = 0;
+  val = mu_strdup (str + len + 1);
+  if (!val)
+    return ENOMEM;
+  clos->err = mu_assoc_install (clos->assoc, key, &val);
+  free (key);
+  if (clos->err)
+    return 1;
+  return 0;
+}
+
+static void
+assoc_str_free (void *data)
+{
+  free (data);
+}
+
+int
+mu_cfg_field_map (struct mu_config_value const *val, mu_assoc_t *passoc,
+		  char **err_term)
+{
+  int rc;
+  struct mapping_closure clos;
+  mu_list_t list = NULL;
+  
+  rc = mu_assoc_create (&clos.assoc, sizeof(char*), 0);
+  if (rc)
+    return rc;
+  mu_assoc_set_free (clos.assoc, assoc_str_free);
+  clos.err_term = NULL;
+  
+  switch (val->type)
+    {
+    case MU_CFG_STRING:
+      mu_list_create (&list);
+      mu_list_set_destroy_item (list, mu_list_free_item);
+      rc = mu_string_split (val->v.string, ":", list);
+      if (rc == 0)
+	rc = mu_list_foreach (list, parse_mapping, &clos);
+      mu_list_destroy (&list);
+      break;
+
+    case MU_CFG_LIST:
+      rc = mu_list_foreach (val->v.list, parse_mapping, &clos);
+      break;
+
+    case MU_CFG_ARRAY:
+      rc = EINVAL;
+    }
+
+  if (rc)
+    {
+      if (err_term)
+	*err_term = clos.err_term;
+      else
+	free (clos.err_term);
+      mu_assoc_destroy (&clos.assoc);
+    }
+  else
+    *passoc = clos.assoc;
+  
+  return rc;
+}
+
+
diff --git a/libmu_auth/gsasl.c b/libmu_auth/gsasl.c
index d1f3b54..1e5ce20 100644
--- a/libmu_auth/gsasl.c
+++ b/libmu_auth/gsasl.c
@@ -39,12 +39,8 @@
 #include <gsasl.h>
 
 struct mu_gsasl_module_data mu_gsasl_module_data = {
-  1,
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-  SITE_CRAM_MD5_PWD
+  .enable = 1,
+  .cram_md5_pwd = SITE_CRAM_MD5_PWD
 };
 
 static struct mu_cfg_param mu_gsasl_param[] = {
@@ -65,7 +61,7 @@ static struct mu_cfg_param mu_gsasl_param[] = {
   { "anonymous-user", mu_c_string, &mu_gsasl_module_data.anon_user, 0, NULL,
     N_("Anonymous user name."),
     N_("name") },
-
+  
   { NULL }
 };
 
diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c
index ac39558..4798b56 100644
--- a/libmu_auth/ldap.c
+++ b/libmu_auth/ldap.c
@@ -60,24 +60,22 @@ const char *default_field_map =
 "shell=loginShell";
 
 static struct mu_ldap_module_config ldap_param;
-
-
 
 static int
-_cb2_field_map (const char *arg, void *data)
+cb_field_map (void *data, mu_config_value_t *val)
 {
-  int err;
-  int rc = mutil_parse_field_map (arg, &ldap_param.field_map, &err);
+  char *err_term;
+  int rc = mu_cfg_field_map (val, &ldap_param.field_map, &err_term);
+
   if (rc)
-    /* FIXME: this message can be misleading */
-    mu_error (_("error near element %d: %s"), err, mu_strerror (rc));
-  return 0;
-}
+    {
+      if (err_term)
+	mu_error (_("error near %s: %s"), err_term, mu_strerror (rc));
+      else
+	mu_error ("%s", mu_strerror (rc));
+    }
 
-static int
-cb_field_map (void *data, mu_config_value_t *val)
-{
-  return mu_cfg_string_value_cb (val, _cb2_field_map, NULL);
+  return rc;
 }
 
 static struct mu_cfg_param mu_ldap_param[] = {
@@ -140,14 +138,18 @@ module_init (void *ptr)
   if (ldap_param.enable)
     {
       if (!ldap_param.getpwnam_filter)
-	ldap_param.getpwnam_filter = "(&(objectClass=posixAccount) (uid=%u))";
+	ldap_param.getpwnam_filter =
+	  "(&(objectClass=posixAccount) (uid=$user))";
       if (!ldap_param.getpwuid_filter)
 	ldap_param.getpwuid_filter =
-	  "&(objectClass=posixAccount) (uidNumber=%u))";
+	  "(&(objectClass=posixAccount) (uidNumber=$user))";
       if (!ldap_param.field_map)
 	{
-	  int d;
-	  mutil_parse_field_map (default_field_map, &ldap_param.field_map, &d);
+	  struct mu_config_value val;
+	  val.type = MU_CFG_STRING;
+	  val.v.string = default_field_map;
+	  if (mu_cfg_field_map (&val, &ldap_param.field_map, NULL))
+	    abort ();
 	}
     }
 }
diff --git a/libmu_auth/sql.c b/libmu_auth/sql.c
index e40b710..6dbe664 100644
--- a/libmu_auth/sql.c
+++ b/libmu_auth/sql.c
@@ -51,38 +51,53 @@
 #include <mailutils/cstr.h>
 #include <mailutils/wordsplit.h>
 #include <mailutils/cli.h>
+#include <mailutils/kwd.h>
 #include "sql.h"
 
 #ifdef USE_SQL
 
 struct mu_sql_module_config mu_sql_module_config;
+
 /* Resource file configuration */
+
+static struct mu_kwd password_encryption[] = {
+  { "plain", mu_sql_password_plaintext },
+  { "scrambled", mu_sql_password_scrambled },
+  { "hash", mu_sql_password_hash },
+  { "crypt", mu_sql_password_hash },
+  { NULL }
+};
+
 static int
-cb_password_type (void *data, mu_config_value_t *val)
+cb_password_encryption (void *data, mu_config_value_t *val)
 {
+  int res;
+  
   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));
+  if (mu_kwd_xlat_name (password_encryption, val->v.string, &res))
+    mu_error ("%s", _("unrecognized password encryption"));
+  else
+    mu_sql_module_config.password_encryption = res;
   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);
+  char *err_term;
+  int rc = mu_cfg_field_map (val, &mu_sql_module_config.field_map, &err_term);
+
+  if (rc)
+    {
+      if (err_term)
+	mu_error (_("error near %s: %s"), err_term, mu_strerror (rc));
+      else
+	mu_error ("%s", mu_strerror (rc));
+    }
+
+  return rc;
 }
 
 static int
@@ -124,12 +139,10 @@ static struct mu_cfg_param mu_sql_param[] = {
     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,
+  { "password-encryption", mu_cfg_callback, NULL, 0, cb_password_encryption,
     N_("Type of password returned by getpass query."),
     /* TRANSLATORS: Words to the right of : are keywords - do not translate */
-    N_("arg: plain|hash|scrambled") },
-  { "positional", mu_c_bool, &mu_sql_module_config.positional, 0, NULL,
-    N_("Use positional (v1.0 compatible) field interface.") },
+    N_("arg: plain|hash|crypt|scrambled") },
   { "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 "
@@ -207,65 +220,8 @@ mu_sql_expand_query (const char *query, const char *ustr)
   free (esc_ustr);
   return res;
 }
-
 
 static int
-decode_tuple_v1_0 (mu_sql_connection_t conn, int n,
-		   struct mu_auth_data **return_data)
-{
-  int rc;
-  char *mailbox_name = NULL;
-  char *name;
-      
-  if (mu_sql_get_column (conn, 0, 0, &name))
-    return MU_ERR_FAILURE;
-
-  if (n == 7)
-    {
-      char *tmp;
-      if (mu_sql_get_column (conn, 0, 6, &tmp))
-	return MU_ERR_FAILURE;
-      if (tmp && (mailbox_name = strdup (tmp)) == NULL)
-	return ENOMEM;
-    }
-  else if (mu_construct_user_mailbox_url (&mailbox_name, name))
-    return MU_ERR_FAILURE;
-      
-  if (mailbox_name)
-    {
-      char *passwd, *suid, *sgid, *dir, *shell;
-	  
-      if (mu_sql_get_column (conn, 0, 1, &passwd)
-	  || !passwd
-	  || mu_sql_get_column (conn, 0, 2, &suid)
-	  || !suid
-	  || mu_sql_get_column (conn, 0, 3, &sgid)
-	  || !sgid
-	  || mu_sql_get_column (conn, 0, 4, &dir)
-	  || !dir
-	  || mu_sql_get_column (conn, 0, 5, &shell)
-	  || !shell)
-	return MU_ERR_FAILURE;
-      
-      rc = mu_auth_data_alloc (return_data,
-			       name,
-			       passwd,
-			       atoi (suid),
-			       atoi (sgid),
-			       "SQL User",
-			       dir,
-			       shell,
-			       mailbox_name,
-			       1);
-    }
-  else
-    rc = MU_ERR_AUTH_FAILURE;
-  
-  free (mailbox_name);
-  return rc;
-}
-
-static int
 get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory)
 {
   const char **name = mu_assoc_ref (mu_sql_module_config.field_map, id);
@@ -292,8 +248,8 @@ get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory)
 }
 
 static int
-decode_tuple_new (mu_sql_connection_t conn, int n,
-		  struct mu_auth_data **return_data)
+decode_tuple (mu_sql_connection_t conn, int n,
+	      struct mu_auth_data **return_data)
 {
   int rc;
   char *mailbox_name = NULL;
@@ -403,16 +359,6 @@ decode_tuple_new (mu_sql_connection_t conn, int n,
 }  
 
 static int
-decode_tuple (mu_sql_connection_t conn, int n,
-	      struct mu_auth_data **return_data)
-{
-  if (mu_sql_module_config.field_map || !mu_sql_module_config.positional)
-    return decode_tuple_new (conn, n, return_data);
-  else
-    return decode_tuple_v1_0 (conn, n, return_data);
-}
- 
-static int
 mu_auth_sql_by_name (struct mu_auth_data **return_data,
 		     const void *key,
 		     void *func_data MU_ARG_UNUSED,
@@ -723,9 +669,9 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
   if ((rc = mu_sql_getpass (auth_data->name, &sql_pass)))
     return rc;
 
-  switch (mu_sql_module_config.password_type)
+  switch (mu_sql_module_config.password_encryption)
     {
-    case password_hash:
+    case mu_sql_password_hash:
       crypt_pass = crypt (pass, sql_pass);
       if (!crypt_pass)
         rc = 1;
@@ -733,7 +679,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
         rc = strcmp (sql_pass, crypt_pass);
       break;
 
-    case password_scrambled:
+    case mu_sql_password_scrambled:
       /* FIXME: Should this call be implementation-independent? I mean,
          should we have mu_sql_check_scrambled() that will match the
 	 password depending on the exact type of the underlying database,
@@ -745,7 +691,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
 #endif
       break;
 
-    case password_plaintext:
+    case mu_sql_password_plaintext:
       rc = strcmp (sql_pass, pass);
       break;
     }


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 04 12:08:46 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c2h2s-00052W-L4
	for mharc-commit-mailutils@gnu.org; Fri, 04 Nov 2016 12:08:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55071)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c2h2m-0004y1-5t
	for commit-mailutils@gnu.org; Fri, 04 Nov 2016 12:08:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c2h2h-00081L-M1
	for commit-mailutils@gnu.org; Fri, 04 Nov 2016 12:08:40 -0400
Received: from vcs.savannah.gnu.org ([208.118.235.72]:56972)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c2h2h-00080x-G5
	for commit-mailutils@gnu.org; Fri, 04 Nov 2016 12:08:35 -0400
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 4896122012D; Fri,  4 Nov 2016 16:08:35 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-809-gaf20212
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: edb05144ade1984e28d88cfaea7c2fb0ec675f5b
X-Git-Newrev: af20212718728b315449ff35685772302883fc3d
Message-Id: <20161104160835.4896122012D@vcs.savannah.gnu.org>
Date: Fri,  4 Nov 2016 16:08:35 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 04 Nov 2016 16:08:44 -0000

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=af20212718728b315449ff35685772302883fc3d

The branch, master has been updated
       via  af20212718728b315449ff35685772302883fc3d (commit)
      from  edb05144ade1984e28d88cfaea7c2fb0ec675f5b (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 af20212718728b315449ff35685772302883fc3d
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 4 18:00:14 2016 +0200

    Fix operation of mail -t; some other minor fixes
    
    * mail/escape.c (parse_headers): Moved to send.c
    (check_headers): New function.
    (escape_continue): Use check_headers.
    * mail/mail.c (read_recipients): New variable.
    The -t option sets read_recipients and editheaders
    * mail/mail.h (parse_headers): New proto.
    * mail/send.c: Special handling for -t option.
    (parse_headers): New function.
    * movemail/movemail.c (onerror statement): Accept a list as
    argument.
    
    * doc/texinfo/mailutils.texi: Update.
    * doc/texinfo/programs.texi: Update.

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

Summary of changes:
 doc/texinfo/mailutils.texi |    1 -
 doc/texinfo/programs.texi  |  377 +++++++++++++++++++++++++++++---------------
 mail/escape.c              |  121 ++------------
 mail/mail.c                |   13 +-
 mail/mail.h                |    9 ++
 mail/send.c                |  166 +++++++++++++++++--
 mail/table.c               |    4 +-
 movemail/movemail.c        |   90 ++++++-----
 8 files changed, 490 insertions(+), 291 deletions(-)

diff --git a/doc/texinfo/mailutils.texi b/doc/texinfo/mailutils.texi
index c9fac62..636b973 100644
--- a/doc/texinfo/mailutils.texi
+++ b/doc/texinfo/mailutils.texi
@@ -236,7 +236,6 @@ Reading Mail
 @command{movemail} --- Moves Mail from the User Maildrop to the Local File
 
 * Movemail Configuration::
-* Movemail Options::     Description of the Available Options
 * Ownership::            Setting Destination Mailbox Ownership
 * Summary::              Short Movemail Invocation Summary
 
diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index c3612b4..d116fcc 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -2742,7 +2742,7 @@ is being sent, etc.
 @item trace6
 When used together with @samp{prot}, displays security-sensitive
 information (such as passwords, user keys, etc). in plaintext.  By
-default, such information is replaced with asteriscs to reduce the
+default, such information is replaced with asterisks to reduce the
 possibility of security compromise.
 @item trace7
 When used together with @samp{prot}, displays the @dfn{payload}
@@ -2795,10 +2795,10 @@ configuration file statements:
 
 @multitable @columnfractions 0.3 0.6
 @headitem Statement @tab Reference
-@item debug   @tab @xref{Debug Statement}.
-@item tls     @tab @xref{TLS Statement}.
-@item mailbox @tab @xref{Mailbox Statement}.
-@item locking @tab @xref{Locking Statement}.
+@item debug   @tab @xref{debug statement}.
+@item tls     @tab @xref{tls statement}.
+@item mailbox @tab @xref{mailbox statement}.
+@item locking @tab @xref{locking statement}.
 @end multitable
 
 @subheading @command{frm}
@@ -2907,10 +2907,9 @@ contents of the user system mailbox.  The @option{--file} (@option{-f})
 command line option allows to specify another mailbox name.  For more
 detail, see @ref{Reading Mail}.
 
-In contrast to other GNU Mailutils programs, @command{mail} does not
-use the Mailutils configuration file.  Instead, it uses the traditional
-@samp{mailrc}-style configuration.  @xref{Mail Configuration Files},
-for a detailed description of its format.
+In addition to the Mailutils configuration file, @command{mail} loads
+the traditional @samp{mailrc}-style configuration files.  @xref{Mail
+Configuration Files}, for a detailed description of their format.
 
 @menu
 * Invoking Mail::            Command Line Options.
@@ -2934,49 +2933,72 @@ General usage of @command{mail} program is:
 If [@var{address}...] part is present, @command{mail} switches to
 mail sending mode, otherwise it operates in mail reading mode.
 
-The program uses following option groups: @FIXME-xref{mailbox}.
-
-@command{Mail} understands following command line options:
+@command{Mail} understands the following command line options:
 
 @table @option
-@item -e
-@itemx --exist
-Return true if the mailbox contains some messages.  Return false
-otherwise.
-This is useful for writing shell scripts.
+@item -A @var{file}
+@itemx --attach=@var{file}
+Attach @var{file} to the composed message.  The encoding and content
+type are controlled by the @option{--encoding} and
+@option{--content-type} options, correspondingly.
+
+@item -a @var{header}:@var{value}
+@itemx --append=@var{header}:@var{value}
+Append the given header to the composed message.
+
+@item --content-type=@var{type}
+This options sets the content type to be used by all subsequent
+@option{--attach} options.
+
 @item -E @var{command}
 @itemx --exec=@var{command}
 Execute @var{command} before opening the mailbox.  Any number of
 @option{--exec} options can be given.  The commands will be executed
 after sourcing configuration files (@pxref{Mail Configuration Files}),
 but before opening the mailbox. 
-@item -f
-@itemx --file
-Operate on the mailbox given by the first non-optional command line
-argument.  If there is no such argument, read messages from the
-user's @file{mbox} file.  @xref{Reading Mail}, for more details about
-using this option.
+
+@item -e
+@itemx --exist
+Return true if the mailbox contains some messages.  Return false
+otherwise.
+
+This is useful for writing shell scripts.
+
+@item --encoding=@var{enc}
+Sets content transfer encoding for use by the subsequent
+@option{--attach} options.
+
 @item -F
 @itemx --byname
 Record outgoing messages in a file named after the first recipient.
 The name is the login-name portion of the address found first on the
 @samp{To:} line in the mail header.  This option sets the @samp{byname}
 variable, which see (@pxref{byname}).
+
+@item -f
+@itemx --file
+Operate on the mailbox given by the first non-optional command line
+argument.  If there is no such argument, read messages from the
+user's @file{mbox} file.  @xref{Reading Mail}, for more details about
+using this option.
+
 @item -H
 @itemx --headers
 Print header summary to stdout and exit.
+
 @item -i
 @itemx --ignore
-Ignore interrupts.
-@item -m @var{path}
-@itemx --mail-spool=@var{path}
-Set path to the mailspool directory
-@item -n
-@itemx --norc
-Do not read the system-wide mailrc file.  @xref{Mail Configuration Files}.
+Ignore interrupts when composing the message.
+
 @item -N
 @itemx --nosum
 Do not display initial header summary.
+
+@item -n
+@itemx --norc
+Do not read the system-wide mailrc file.  @xref{Mail Configuration
+Files}.
+
 @item -p
 @itemx --print
 @itemx --read
@@ -2990,18 +3012,26 @@ quit
 @end example
 @noindent
 except that @command{mail --print} does not change status of the messages.
-@item -r @var{address}
-@itemx --return-address=@var{address}
-Sets the return email address for outgoing mail.  @xref{return-address}.
+
 @item -q
 @itemx --quit
 Cause interrupts to terminate program.
+
+@item -r @var{address}
+@itemx --return-address=@var{address}
+Sets the return email address for outgoing mail.
+@xref{return-address}.
+
 @item -s @var{subj}
 @itemx --subject=@var{subj}
-Send a message with a Subject of @var{subj}.  Valid only in sending mode.
+Send a message with a Subject of @var{subj}.  Valid only in sending
+mode.
+
 @item -t
 @itemx --to
-Switch to sending mode.
+Read recipients from the message header.  Ignore addresses listed in
+the command line.
+
 @item -u @var{user}
 @itemx --user=@var{user}
 Operate on @var{user}'s mailbox.  This is equivalent to:
@@ -3013,16 +3043,11 @@ mail -f/@var{spool_path}/@var{user}
 @noindent
 with @var{spool_path} being the full path to your mailspool directory
 @*(@file{/var/spool/mail} or @file{/var/mail} on most systems).
-@item -?
-@itemx --help
-Display a help message.
-@item --usage
-Display a short usage summary.
-@item -V
-@itemx --version
-Print program version and exit.
 @end table
 
+The program also understands the common mailutils options
+(@pxref{Common Options}. 
+
 @node Specifying Messages
 @subsection How to Specify Message Sets
 
@@ -3136,6 +3161,7 @@ The actual escape character may be changed by setting the value of
 * Modifying the Headers::
 * Enclosing Another Message::
 * Adding a File to the Message::
+* Attaching a File to the Message::
 * Printing And Saving the Message::
 * Signing the Message::
 * Printing Another Message::
@@ -3194,6 +3220,7 @@ the headers as well.
 @node Modifying the Headers
 @subsubsection Modifying the Headers: ~h, ~t, ~c, ~b, ~s
 
+@cindex ~t, mail escape
 To add new addresses to the list of message recipients, use @samp{~t}
 command, e.g.:
 
@@ -3201,15 +3228,19 @@ command, e.g.:
 ~t name1@@domain.net name2
 @end example
 
+@cindex ~c, mail escape
+@cindex ~b, mail escape
 To add addresses to @code{Cc} or @code{Bcc}, use @samp{~c} or @samp{~b}
 escapes respectively.
 
+@cindex ~s, mail escape
 To change the @code{Subject} header, use @samp{~s} escape, e.g.:
 
 @example
 ~s "Re: your message"
 @end example
 
+@cindex ~h, mail escape
 Finally, to edit all headers, type @samp{~h} escape.  This will present
 you with the values of @code{To}, @code{Cc}, @code{Bcc}, and
 @code{Subject} headers allowing to edit them with normal text editing
@@ -3235,6 +3266,8 @@ prepended to each line enclosed.
 @node Adding a File to the Message
 @subsubsection Adding a File to the Message: ~r and ~d
 
+@cindex ~r, mail escape
+@cindex ~<, mail escape
 To append the contents of file @var{filename} to the message, type
 
 @example
@@ -3248,12 +3281,56 @@ or
 @end example
 @noindent
 
+@cindex ~d, mail escape
 The @samp{~d} escape is a shorthand for
 
 @example
 ~r dead.letter
 @end example
 
+@node Attaching a File to the Message
+@subsubsection Attaching a File to the Message
+@cindex ~+, mail escape
+The @samp{~+} escape attaches a file to the message.  It takes one to
+three arguments.  The first argument supplies the name of the file to
+attach:
+
+@example
+~+ myfile.txt
+@end example
+
+The file will be attached with default content-type
+@samp{application/octet-stream}, and encoding @samp{base64}
+(these can be altered by the @option{--content-type} and
+@option{--encoding} command line options, correspondingly).
+
+Optional second argument defines the content type to be used instead
+of the default one.  Optional third argument defines the encoding,
+e.g.:
+
+@example
+~+ myfile.html text/html base64
+@end example
+
+@cindex ~l, mail escape
+To list the files attached so far, use the @samp{~l} escape:
+
+@example
+~l
+   1 myfile.html text/html base64
+@end example
+
+Each line of the listing contains the ordinal number of the attachment,
+the name of the file, content-type and transfer encoding used.
+
+@cindex ~^, mail escape
+The @samp{~^} escape removes attachments.  Its argument is the number
+of the attachment to remove, e.g.:
+
+@example
+~^ 1
+@end example
+
 @node Printing And Saving the Message
 @subsubsection Printing And Saving the Message
 @kyindex ~p, mail escape
@@ -4692,7 +4769,7 @@ The program is started with the @option{--print} (@option{-p}) command
 line option (@pxref{Invoking Mail}).
 
 @item read
-The progran operates in read mode.  This is the default.
+The program operates in read mode.  This is the default.
 
 @item send
 The program operates in send mode.  This means it was given one or more
@@ -4992,7 +5069,7 @@ variables.  Also, if the user is trying to set an unknown variable,
 @*Type: Boolean.
 @*Default: False.
 
-If this variable is set, the listing ouput by @command{set} contains short
+If this variable is set, the listing output by @command{set} contains short
 descriptions before each variable.  @xref{Setting and Unsetting the Variables}. 
 
 @kwindex verbose
@@ -5021,8 +5098,9 @@ X-Mailer: mail (GNU Mailutils @value{VERSION})
 @node Mail Configuration Files
 @subsection Personal and System-wide Configuration Files
 
-Upon startup, @command{mail} reads the contents of the two command files:
-the system-wide configuration file, and the user's configuration
+After processing the usual Mailutils configuration files
+(@pxref{configuration}), @command{mail} reads the contents of the two
+command files: the system-wide command file, and the user's command
 file.  Each line read from these files is processed like a usual
 @command{mail} command.
 
@@ -5040,7 +5118,6 @@ package via @option{--with-mail-rc} option.  It defaults to
 @node messages
 @section @command{messages} --- Count the Number of Messages in a Mailbox
 @pindex messages
-@UNREVISED
 
 @command{Messages} prints on standard output the number of messages
 contained in each folder specified in command line.  If no folders
@@ -5055,18 +5132,19 @@ Number of messages in @var{folder}: @var{number}
 where @var{folder} represents the folder name, @var{number} represents
 the number of messages.
 
-Following configuration file statements affect the behaviour of 
+The following configuration file statements affect the behaviour of 
 @command{messages}:
 
 @multitable @columnfractions 0.3 0.6
 @headitem Statement @tab Reference
-@item debug         @tab @xref{Debug Statement}.
-@item tls           @tab @xref{TLS Statement}.
-@item mailbox       @tab @xref{Mailbox Statement}.
-@item locking       @tab @xref{Locking Statement}.
+@item debug         @tab @xref{debug statement}.
+@item tls           @tab @xref{tls statement}.
+@item mailbox       @tab @xref{mailbox statement}.
+@item locking       @tab @xref{locking statement}.
 @end multitable
 
-The program accepts following command line options:
+In addition to the common mailutils options (@pxref{Common Options}),
+the program accepts the following command line options:
 
 @table @option
 @item -q
@@ -5074,22 +5152,12 @@ The program accepts following command line options:
 @itemx -s
 @itemx --silent
 Be quiet.  Display only number of messages per mailbox, without leading text.
-@item -?
-@itemx --help
-Output help message and exit.
-@item --usage
-Output short usage summary and exit.
-@item -V
-@itemx --version
-Output program version and exit.
 @end table
 
 @page
 @node movemail
 @section @command{movemail} --- Moves Mail from the User Maildrop to the Local File
 @pindex movemail
-@UNREVISED
-
 The purpose of @command{movemail}, as its name implies, is to move mail
 from one location to another.  For example, the following invocation:
 
@@ -5100,11 +5168,10 @@ movemail /var/mail/smith INBOX
 @noindent
 moves messages from file @file{/var/mail/smith} to file @file{INBOX}.
 
-You will probably never have to run this program manually.  It is
-intended as a replacement for @command{movemail} from GNU Emacs.  The
-@command{movemail} program is run by Emacs @code{Rmail}
-module.  @xref{Rmail,,,emacs,Reading Mail with Rmail}, for detailed
-description of @code{Rmail} interface.
+The program was initially intended as a replacement for
+@command{movemail} from GNU Emacs.  The @command{movemail} program is
+run by Emacs @code{Rmail} module.  @xref{Rmail,,,emacs,Reading Mail
+with Rmail}, for detailed description of @code{Rmail} interface.
 
 Mailutils version of @command{movemail} is fully
 backward-compatible with its Emacs predecessor, so it should run
@@ -5113,18 +5180,21 @@ starting from 22.1 contain improved @code{Rmail} interface and
 are able to take advantage of all new features mailutils
 @command{movemail} provides.
 
+Apart from that use, @command{movemail} proved to be a useful tool for
+incorporating mail from remote mailboxes into the local one.  See
+@uref{http://mailutils.org/wiki/Fetching_Mail_with_Movemail, Fetching
+Mail with Movemail}, for a detailed discussion with usage recipes.
+
 @menu
 * Movemail Configuration::
-* Movemail Options::     Description of the Available Options
 * Ownership::            Setting Destination Mailbox Ownership
 * Summary::              Short Movemail Invocation Summary
 @end menu
 
 @node Movemail Configuration
 @subsection Movemail Configuration
-@UNREVISED
-
-Following configuration file statements affect the behavior of
+@cindex movemail, configuration
+The following configuration file statements affect the behavior of
 @command{movemail}:
 
 @deffn {Movemail Config} preserve @var{bool}
@@ -5139,7 +5209,7 @@ If @var{bool} is @samp{true}, reverse message sorting order.
 If @var{bool} is @samp{true}, output information used by Emacs rmail interface.
 @end deffn
 
-@deffn {Movemail Config} ignore-erros @var{bool}
+@deffn {Movemail Config} ignore-errors @var{bool}
 Continue moving messages after errors.  By default,
 @command{mailfromd} exits immediately if it cannot copy a message.
 @end deffn
@@ -5149,6 +5219,7 @@ Set program identifier, i.e. a string which will prefix all
 diagnostic messages issued by the program.  By default, program
 name is used.
 
+@anchor{movemail-program-id}
 The @var{fmt} is a format string that may contain references to the
 following variables (@pxref{Variables}):
 
@@ -5224,101 +5295,145 @@ Make destination mailbox owned by @var{user}.
 @end table
 @end deffn
 
-@multitable @columnfractions 0.3 0.6
-@headitem Statement @tab Reference
-@item debug         @tab @xref{Debug Statement}.
-@item tls           @tab @xref{TLS Statement}.
-@item mailbox       @tab @xref{Mailbox Statement}.
-@item locking       @tab @xref{Locking Statement}.
-@item pam           @tab @xref{PAM Statement}.
-@item sql           @tab @xref{SQL Statement}.
-@item virtdomain    @tab @xref{Virtdomain Statement}.
-@item radius        @tab @xref{Radius Statement}.
-@item ldap          @tab @xref{LDAP Statement}.
-@item auth          @tab @xref{Auth Statement}.
-@end multitable
+@deffn {Movemail Config} max-messages @var{count}
+Defines upper limit on the number of moved messages.  Movemail will
+stop after transferring @var{count} messages.
 
-@node Movemail Options
-@subsection Movemail Options
-@UNREVISED
+By default, the number of messages is not limited.
+@end deffn
 
-This subsection discusses @command{movemail} options from the point of
-view of an Emacs @code{Rmail} user.
+@anchor{movemail-onerror}
+@deffn {Movemail Config} onerror @var{actions}
+Defines what to do if an error occurs when transferring a message.
+@var{actions} is a list of one or more of the following keywords:
 
-To set various options to @command{movemail} from @code{Rmail}, use
-@code{rmail-movemail-flags} variable, or @samp{Rmail Movemail Flags}
-section from the menu. 
+@table @asis
+@item abort
+Abort the transfer and terminate the program.  This is the default
+action.
 
-Some POP servers return messages in reversed order.  To fix the
-order, use @option{-p} option or its synonym @option{--reverse}.
+@item skip
+Skip to the next message.
 
-If the remote server supports @acronym{TLS} encryption, use
-@option{--tls} to instruct @command{movemail} to initiate encrypted
-connection.
+@item delete
+Delete the affected message.
+
+@item count
+Count this message as processed.
+@end table
+
+Each keyword can be prefixed with @samp{no} to reverse its meaning.
+@end deffn
+
+The following standard Mailutils statements are supported:
+
+@multitable @columnfractions 0.3 0.6
+@headitem Statement @tab Reference
+@item debug         @tab @xref{debug statement}.
+@item tls           @tab @xref{tls statement}.
+@item mailbox       @tab @xref{mailbox statement}.
+@item locking       @tab @xref{locking statement}.
+@item pam           @tab @xref{pam statement}.
+@item sql           @tab @xref{sql statement}.
+@item virtdomain    @tab @xref{virtdomain statement}.
+@item radius        @tab @xref{radius statement}.
+@item ldap          @tab @xref{ldap statement}.
+@item auth          @tab @xref{auth statement}.
+@end multitable
 
 @node Ownership
 @subsection Setting Destination Mailbox Ownership
 @UNREVISED
 
-
 @node Summary
 @subsection Movemail Usage Summary
 
 @example
-movemail [@var{option}...] @var{inbox} @var{destfile} [@var{remote-password}]
+movemail [@var{option}...] @var{inbox} @var{destfile} [@var{password}]
 @end example
 
-The first argument, @var{inbox}, is the @acronym{url} (@FIXME-pxref{URL}) of
+The first argument, @var{inbox}, is the @acronym{url} (@pxref{Mailbox}) of
 the source mailbox.  The second argument, @var{destfile}, traditionally
 means destination file, i.e. the UNIX mailbox to copy messages
 to.  However, mailutils @command{movemail} extends the meaning of this
-parameter.  You may actually specify any valid @acronym{URL} as
+parameter.  You may actually specify any valid @acronym{url} as
 @var{destfile} parameter.@footnote{Rmail does not use this
-feature}.  Finally, optional third argument is a traditional way of
-specifying user passwords for remote (@acronym{POP} or @acronym{IMAP})
-mailboxes.
+feature}.
+
+For compatibility with older implementations of @command{movemail},
+the @var{source} argument can also have the form:
+
+@example
+po:@var{username}[:@var{pop-server}]
+@end example
+
+@noindent
+where @var{pop-server} is the IP address or hostname of a POP3 server
+to connect to and @var{username} is the name of the user on that
+server.  The password is then supplied by the third argument.
 
-Following is the summary of available command line options:
+It is equivalent to the following URL:
+
+@example
+pop://@var{username}[:@var{password}]@@@var{pop-server}
+@end example
+
+In fact, whenever @var{source} refers to a remote mailbox, the
+@var{password} argument can be used to pass the password.  However,
+the safer @dfn{ticket} method is of course preferred.
+
+Options are one or more of the following:
 
 @table @option
 @item --emacs
-Output information used by Emacs rmail interface
+Output information used by Emacs @code{rmail} interface.
 
 @item --ignore-errors
-Continue moving messages after an error occurs.
+Try to continue after errors.
+
+@item --max-messages=@var{count}
+Process at most @var{count} messages.
+
+@item --notify
+Enable biff notification.
+
+@item --onerror=@var{kw}[,@var{kw}...]
+What to do on errors.  @xref{movemail-onerror, onerror statement}, for
+a description of @var{kw}.
+
+@item -P @var{modelist}
+@itemx --owner=@var{modelist}
+Control mailbox ownership.  @var{modelist} is a comma-separated list
+of one or more ownership change methods.
+@xref{mailbox-ownership-methods}, for a description of available
+methods.
+
+This option is useful only when running @command{movemail} as root.
 
 @item -p
 @itemx --preserve
 @itemx --keep-messages
-Preserve the source mailbox
+Don't remove transferred messages from the source mailbox.
 
 @item --program-id=@var{fmt}
-Set program identifier for diagnostic purposes.  See @ref{Movemail
-Configuration,program-id}, for a detailed discussion of this feature. 
+Set program identifier for diagnostics (default: the program name).
+@xref{movemail-program-id}, for a description of its argument.
 
 @item -r
 @itemx --reverse
-Reverse the sorting order
-
-@item --tls[=@var{bool}]
-Enable (default) or disable TLS support
+Reverse the order of retrieved messages.
 
 @item -u
-@item --uidl
+@itemx --uidl
 Use UIDLs to avoid downloading the same message twice.
 
-@item -P @var{method-list}
-@itemx --owner=@var{method-list}
-Define list of methods for setting ownership of the destination
-mailbox.  @xref{mailbox-ownership-methods}, for a description of
-@var{method-list}.  This option is useful only when running
-@command{movemail} as root.
-
 @item -v
-@item --verbose
+@itemx --verbose
 Increase verbosity level.
 @end table
 
+The common options are also understood (@pxref{Common Options}).
+
 @page
 @node readmsg
 @section @command{readmsg} --- Extract Messages from a Folder
@@ -5398,6 +5513,8 @@ A whitespace or coma separated list of header names to show per message.
 Default is @option{--weedlist="From Subject Date To CC Apparently-"}.
 @end table
 
+See also @ref{Common Options}.
+
 @node Conf-readmsg
 @subsection Configuration of @command{readmsg}.
 
@@ -7997,7 +8114,7 @@ run:
 mailutils filter --list
 @end example
 
-Filters are applied in the order of their appearence, from left to
+Filters are applied in the order of their appearance, from left to
 right and operate in encode mode.  The plus sign has the same meaning
 as pipe in shell.  The default mode can be changed using the
 @option{--decode} (@option{-d}) and @option{--encode} (@option{-e}) options.
@@ -8050,7 +8167,7 @@ configuration file processing.
 @node mailutils acl
 @subsection mailutils acl
 The @command{mailutils acl} command tests Mailutils Access Control Lists.  By
-default it reads ACL from the Mailutils configiration file section
+default it reads ACL from the Mailutils configuration file section
 @samp{acl}.  The command takes a list of IP addresses as its
 arguments, applies the ACL to each of them in turn and prints the result.
 
@@ -8166,7 +8283,7 @@ smtp://bar@@gnu.org: /home/@var{user}/.mu-tickets:2: smtp://bar:***@@gnu.org
 @end example
 
 As you see, even in that case the tool hides the actual password part
-by replacing it with three asteriscs.  If you are working in a secure
+by replacing it with three asterisks.  If you are working in a secure
 environment, you can tell @command{mu wicket} to show passwords as
 well, by supplying the @option{-v} option twice.
 
@@ -8395,7 +8512,7 @@ As of version @value{VERSION}, @command{mailutils dbm} supports two formats
 for dumping DBM databases.  Both formats are line-oriented.  Comments
 are introduced with a sharp (@samp{#}) sign in the column 0 of a line,
 followed by at least one white space character (space or tab).  Sharp
-sign followed by a colon (@samp{#:}) introduces a @dfn{paragmatic
+sign followed by a colon (@samp{#:}) introduces a @dfn{pragmatic
 comment}, which carries some additional information to the loader. 
 
 @anchor{dump version 0.0}
diff --git a/mail/escape.c b/mail/escape.c
index c07d29a..4c337e0 100644
--- a/mail/escape.c
+++ b/mail/escape.c
@@ -37,119 +37,26 @@ dump_headers (mu_stream_t out, compose_env_t *env)
   mu_stream_destroy (&stream);
 }
 
-#define STATE_INIT 0
-#define STATE_READ 1
-#define STATE_BODY 2
-
 static int
-parse_headers (mu_stream_t input, compose_env_t *env)
+check_headers (mu_stream_t input, compose_env_t *env)
 {
-  int status;
-  mu_header_t header;
-  char *name = NULL;
-  char *value = NULL;
-  int state = STATE_INIT;
-  char *buf = NULL;
-  size_t size = 0, n;
-  int errcnt = 0, line = 0;
+  char *p;
   
-  if ((status = mu_header_create (&header, NULL, 0)) != 0)
-    {
-      mu_error (_("Cannot create header: %s"), mu_strerror (status));
-      return 1;
-    }
-
   mu_stream_seek (input, 0, MU_SEEK_SET, NULL);
-  while (state != STATE_BODY &&
-	 errcnt == 0 &&
-	 mu_stream_getline (input, &buf, &size, &n) == 0 && n > 0)
+  switch (parse_headers (input, env))
     {
-      mu_rtrim_class (buf, MU_CTYPE_SPACE);
-
-      line++;
-      switch (state)
-	{
-	case STATE_INIT:
-	  if (!buf[0] || mu_isspace (buf[0]))
-	    continue;
-	  else
-	    state = STATE_READ;
-	  /*FALLTHRU*/
-	  
-	case STATE_READ:
-	  if (buf[0] == 0)
-	    state = STATE_BODY;
-	  else if (mu_isspace (buf[0]))
-	    {
-	      /* A continuation line */
-	      if (name)
-		{
-		  char *p = NULL;
-		  mu_asprintf (&p, "%s\n%s", value, buf);
-		  free (value);
-		  value = p;
-		}
-	      else
-		{
-		  mu_error (_("%d: not a header line"), line);
-		  errcnt++;
-		}
-	    }
-	  else
-	    {
-	      char *p;
-	      
-	      if (name)
-		{
-		  mu_header_set_value (header, name, value[0] ? value : NULL, 0);
-		  free (name);
-		  free (value);
-		  name = value = NULL;
-		}
-	      p = strchr (buf, ':');
-	      if (p)
-		{
-		  *p++ = 0;
-		  while (*p && mu_isspace (*p))
-		    p++;
-		  value = mu_strdup (p);
-		  name = mu_strdup (buf);
-		}
-	      else
-		{
-		  mu_error (_("%d: not a header line"), line);
-		  errcnt++;
-		}
-	    }
-	  break;
-	}
+    case parse_headers_ok:
+      return 0;
+    case parse_headers_fatal:
+      return -1;
+    case parse_headers_error:
+      break;
     }
   
-  free (buf);
-  if (name)
-    {
-      mu_header_set_value (header, name, value, 0);
-      free (name);
-      free (value);
-    }     
-
-  if (errcnt)
-    {
-      char *p;
-      
-      mu_header_destroy (&header);
-      p = ml_readline (_("Edit again?"));
-      if (mu_true_answer_p (p) == 1)
-	return -1;
-      else
-	return 1;
-    }
-
-  mu_header_destroy (&env->header);
-  env->header = header;
-  return 0;
-}
-
+  p = ml_readline (_("Edit again?"));
+  return mu_true_answer_p (p);
+}  
+
 static void
 escape_continue (void)
 {
@@ -386,7 +293,7 @@ escape_run_editor (char *ed, int argc, char **argv, compose_env_t *env)
 	      return rc;
 	    }
 	}
-      while ((rc = parse_headers (tempstream, env)) < 0);
+      while (check_headers (tempstream, env));
     }
   else
     {
diff --git a/mail/mail.c b/mail/mail.c
index cd8c466..6a80425 100644
--- a/mail/mail.c
+++ b/mail/mail.c
@@ -23,6 +23,7 @@
 mu_mailbox_t mbox;            /* Mailbox being operated upon */
 size_t total;                 /* Total number of messages in the mailbox */
 int interactive;              /* Is the session interactive */  
+int read_recipients;          /* Read recipients from the message (mail -t) */
 
 static mu_list_t command_list;/* List of commands to be executed after parsing
 				 command line */
@@ -72,6 +73,8 @@ cli_command_option (struct mu_parseopt *po, struct mu_option *opt,
       break;
       
     case 't':
+      read_recipients = 1;
+      util_cache_command (&command_list, "set editheaders");
       util_cache_command (&command_list, "setq mode=send");
       break;
       
@@ -186,7 +189,7 @@ static struct mu_option mail_options[] = {
     mu_c_string, NULL, cli_subject },
   
   { "to",      't', NULL,       MU_OPTION_DEFAULT,
-    N_("precede message by a list of addresses"),
+    N_("read recipients from the message header"),
     mu_c_string, NULL, cli_command_option },
     
   { "user",    'u', N_("USER"), MU_OPTION_DEFAULT,
@@ -227,7 +230,7 @@ static struct mu_cli_setup cli = {
   options,
   NULL,
   N_("GNU mail -- process mail messages.\n"
-"If -f or --file is given, mail operates on the mailbox named "
+     "If -f or --file is given, mail operates on the mailbox named "
      "by the first argument, or the user's mbox, if no argument given."),
   N_("[address...]"),
   alt_args,
@@ -421,6 +424,12 @@ main (int argc, char **argv)
   /* argument parsing */
   mu_cli (argc, argv, &cli, mail_capa, NULL, &argc, &argv);
 
+  if (read_recipients)
+    {
+      argv += argc;
+      argc = 0;
+    }
+  
   if ((hint & (HINT_SEND_MODE|HINT_FILE_OPTION)) ==
       (HINT_SEND_MODE|HINT_FILE_OPTION))
     {
diff --git a/mail/mail.h b/mail/mail.h
index b589d3e..0c4465f 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -288,6 +288,15 @@ extern int escape_attach (int argc, char **argv, compose_env_t *env);
 extern int escape_remove_attachment (int argc, char **argv,
 				     compose_env_t *env);
 
+enum
+  {
+    parse_headers_ok,
+    parse_headers_error,
+    parse_headers_fatal
+  };
+
+extern int parse_headers (mu_stream_t input, compose_env_t *env);
+
 /* Cursor */
 extern void set_cursor (unsigned value);
 extern size_t get_cursor (void);
diff --git a/mail/send.c b/mail/send.c
index c2ed4e4..8a39d08 100644
--- a/mail/send.c
+++ b/mail/send.c
@@ -488,8 +488,42 @@ mail_send (int argc, char **argv)
   compose_init (&env);
 
   if (argc < 2)
-    compose_header_set (&env, MU_HEADER_TO, ml_readline_with_intr ("To: "),
-			COMPOSE_REPLACE);
+    {
+      if (interactive)
+	compose_header_set (&env, MU_HEADER_TO, ml_readline_with_intr ("To: "),
+			    COMPOSE_REPLACE);
+      else if (!mailvar_get (NULL, "editheaders", mailvar_type_boolean, 0))
+	{
+	  if (parse_headers (mu_strin, &env) != parse_headers_ok)
+	    {
+	      mu_error ("%s", _("Errors parsing message"));
+	      exit (EXIT_FAILURE);
+	    }
+	  if (add_header_list)
+	    {
+	      mu_iterator_t itr;
+	      mu_list_get_iterator (add_header_list, &itr);
+	      for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
+		   mu_iterator_next (itr))
+		{
+		  struct add_header *hp;
+		  int mode;
+		  if (mu_iterator_current (itr, (void**) &hp))
+		    break; 
+		  mode = hp->mode;
+		  if (mu_header_sget_value (env.header, hp->name, NULL) == 0)
+		    mode = COMPOSE_REPLACE;
+		  compose_header_set (&env, hp->name, hp->value, hp->mode);
+		}
+	      mu_iterator_destroy (&itr);
+	    }
+	}
+      else
+	{
+	  mu_error ("%s", _("No recipients specified"));
+	  exit (EXIT_FAILURE);
+	}
+    }
   else
     {
       while (--argc)
@@ -511,27 +545,137 @@ mail_send (int argc, char **argv)
 	}
     }
 
-  if (mailvar_get (NULL, "mailx", mailvar_type_boolean, 0))
-    read_cc_bcc (&env);
-
-  if (mailvar_get (NULL, "asksub", mailvar_type_boolean, 0) == 0)
-    compose_header_set (&env, MU_HEADER_SUBJECT,
-			ml_readline_with_intr ("Subject: "), COMPOSE_REPLACE);
+  if (interactive)
+    {
+      if (mailvar_get (NULL, "mailx", mailvar_type_boolean, 0))
+	read_cc_bcc (&env);
 
+      if (mailvar_get (NULL, "asksub", mailvar_type_boolean, 0) == 0)
+	compose_header_set (&env, MU_HEADER_SUBJECT,
+			    ml_readline_with_intr ("Subject: "),
+			    COMPOSE_REPLACE);
+    }
+  
   status = mail_send0 (&env, save_to);
   compose_destroy (&env);
   return status;
 }
+
+int
+parse_headers (mu_stream_t input, compose_env_t *env)
+{
+  int status;
+  mu_header_t header;
+  char *name = NULL;
+  char *value = NULL;
+  enum { STATE_INIT, STATE_READ, STATE_BODY } state = STATE_INIT;
+  char *buf = NULL;
+  size_t size = 0, n;
+  int errcnt = 0, line = 0;
+  
+  if ((status = mu_header_create (&header, NULL, 0)) != 0)
+    {
+      mu_error (_("Cannot create header: %s"), mu_strerror (status));
+      return parse_headers_fatal;
+    }
+  
+  while (state != STATE_BODY &&
+	 errcnt == 0 &&
+	 mu_stream_getline (input, &buf, &size, &n) == 0 && n > 0)
+    {
+      mu_rtrim_class (buf, MU_CTYPE_SPACE);
+
+      line++;
+      switch (state)
+	{
+	case STATE_INIT:
+	  if (!buf[0] || mu_isspace (buf[0]))
+	    continue;
+	  else
+	    state = STATE_READ;
+	  /*FALLTHRU*/
+	  
+	case STATE_READ:
+	  if (buf[0] == 0)
+	    state = STATE_BODY;
+	  else if (mu_isspace (buf[0]))
+	    {
+	      /* A continuation line */
+	      if (name)
+		{
+		  char *p = NULL;
+		  mu_asprintf (&p, "%s\n%s", value, buf);
+		  free (value);
+		  value = p;
+		}
+	      else
+		{
+		  mu_error (_("%d: not a header line"), line);
+		  errcnt++;
+		}
+	    }
+	  else
+	    {
+	      char *p;
+	      
+	      if (name)
+		{
+		  mu_header_set_value (header, name, value[0] ? value : NULL, 0);
+		  free (name);
+		  free (value);
+		  name = value = NULL;
+		}
+	      p = strchr (buf, ':');
+	      if (p)
+		{
+		  *p++ = 0;
+		  while (*p && mu_isspace (*p))
+		    p++;
+		  value = mu_strdup (p);
+		  name = mu_strdup (buf);
+		}
+	      else
+		{
+		  mu_error (_("%d: not a header line"), line);
+		  errcnt++;
+		}
+	    }
+	  break;
+	  
+	default:
+	  abort ();
+	}
+    }
+  
+  free (buf);
+  if (name)
+    {
+      mu_header_set_value (header, name, value, 0);
+      free (name);
+      free (value);
+    }     
+
+  if (errcnt)
+    {
+      mu_header_destroy (&header);
+      return parse_headers_error;
+    }
+
+  mu_header_destroy (&env->header);
+  env->header = header;
+  return parse_headers_ok;
+}
+
 
 void
-compose_init (compose_env_t * env)
+compose_init (compose_env_t *env)
 {
   memset (env, 0, sizeof (*env));
   mu_list_foreach (add_header_list, seed_headers, env);
 }
 
 int
-compose_header_set (compose_env_t * env, const char *name,
+compose_header_set (compose_env_t *env, const char *name,
 		    const char *value, int mode)
 {
   int status;
@@ -601,7 +745,7 @@ compose_header_set (compose_env_t * env, const char *name,
 }
 
 char *
-compose_header_get (compose_env_t * env, char *name, char *defval)
+compose_header_get (compose_env_t *env, char *name, char *defval)
 {
   char *p;
 
diff --git a/mail/table.c b/mail/table.c
index b5ffa03..4c3f4f7 100644
--- a/mail/table.c
+++ b/mail/table.c
@@ -226,8 +226,8 @@ static const struct mail_escape_entry mail_escape_table[] = {
   {"!",	"!",	"![shell-command]", escape_shell },
   {":",	":",	":[mail-command]",  escape_command },
   {"-",	"-",	"-[mail-command]",  escape_command },
-  {"+",	"+",	"+[name [content-type [encoding]]]", escape_attach },
-  {"^",	"^",	"^[N]",             escape_remove_attachment },
+  {"+",	"+",	"+name [content-type [encoding]]", escape_attach },
+  {"^",	"^",	"^N",               escape_remove_attachment },
   {"?",	"?",	"?",		    escape_help },
   {"A",	"A",	"A",		    escape_sign },
   {"a",	"a",	"a",		    escape_sign },
diff --git a/movemail/movemail.c b/movemail/movemail.c
index 6935763..7037ce9 100644
--- a/movemail/movemail.c
+++ b/movemail/movemail.c
@@ -194,51 +194,54 @@ set_mailbox_ownership_list (char const *str)
 }
 
 static int
-set_onerror_action (char const *str)
+set_onerror_action (void *item, void *data)
 {
-  struct mu_wordsplit ws;
-  static struct mu_kwd onerror_kw[] = {
-    { "skip", ONERROR_SKIP },
-    { "delete", ONERROR_DELETE },
-    { "count", ONERROR_COUNT },
-    { NULL }
-  };
-  int i, flag;
-  
+  char *str = item;
+
   if (strcmp (str, "abort") == 0)
+    onerror_flags = 0;
+  else
     {
-      onerror_flags = 0;
-      return 0;
-    }
-  ws.ws_delim = ",";
-  if (mu_wordsplit (str, &ws,
-		    MU_WRDSF_NOVAR | MU_WRDSF_NOCMD |
-		    MU_WRDSF_DELIM | MU_WRDSF_WS))
-    {
-      mu_error (_("cannot split argument: %s"), mu_wordsplit_strerror (&ws));
-      return 1;
-    }
-  for (i = 0; i < ws.ws_wordc; i++)
-    {
-      int clr = 0;
-      char *name = ws.ws_wordv[i];
-      
-      if (strncmp (name, "no", 2) == 0)
+      static struct mu_kwd onerror_kw[] = {
+	{ "skip", ONERROR_SKIP },
+	{ "delete", ONERROR_DELETE },
+	{ "count", ONERROR_COUNT },
+	{ NULL }
+      };
+      int flag, clr = 0;
+
+      if (strncmp (str, "no", 2) == 0)
 	{
 	  clr = 1;
-	  name += 2;
+	  str += 2;
+	}
+      if (mu_kwd_xlat_name (onerror_kw, str, &flag))
+	{
+	  mu_error (_("unknown keyword: %s"), str);
+	  return 1;
 	}
-      if (mu_kwd_xlat_name (onerror_kw, name, &flag))
-	mu_error (_("unknown keyword: %s"), ws.ws_wordv[i]);
       if (clr)
 	onerror_flags &= ~flag;
       else
 	onerror_flags |= flag;
     }
-  mu_wordsplit_free (&ws);
   return 0;
 }
 
+static int
+set_onerror_actions (char const *str)
+{
+  mu_list_t list;
+  int rc;
+  
+  mu_list_create (&list);
+  mu_list_set_destroy_item (list, mu_list_free_item);
+  mu_string_split (str, ",", list);
+  rc = mu_list_foreach (list, set_onerror_action, NULL);
+  mu_list_destroy (&list);
+  return rc;
+}
+
 static void
 cli_mailbox_ownership (struct mu_parseopt *po, struct mu_option *opt,
 		       char const *arg)
@@ -250,7 +253,7 @@ cli_mailbox_ownership (struct mu_parseopt *po, struct mu_option *opt,
 static void
 cli_onerror (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
 {
-  if (set_onerror_action (arg))
+  if (set_onerror_actions (arg))
     exit (po->po_exit_error);
 }
 
@@ -327,9 +330,20 @@ cb_mailbox_ownership (void *data, mu_config_value_t *val)
 static int
 cb_onerror (void *data, mu_config_value_t *val)
 {
-  if (mu_cfg_assert_value_type (val, MU_CFG_STRING))
-    return 1;
-  return set_onerror_action (val->v.string);
+  switch (val->type)
+    {
+    case MU_CFG_LIST:
+      mu_list_foreach (val->v.list, set_onerror_action, NULL);
+      break;
+
+    case MU_CFG_STRING:
+      set_onerror_actions (val->v.string);
+      break;
+
+    default:
+      mu_error ("%s", _("too many arguments"));
+    }
+  return 0;
 }
   
 struct mu_cfg_param movemail_cfg_param[] = {
@@ -360,12 +374,12 @@ struct mu_cfg_param movemail_cfg_param[] = {
   { "ignore-errors", mu_c_bool, &ignore_errors, 0, NULL,
     N_("Continue after an error.") },
   { "onerror", mu_cfg_callback, NULL, 0, cb_onerror,
-    N_("What to do after an error. Argument is a comma-separated list of:\n"
+    N_("What to do after an error. Argument is a list of:\n"
+       " abort  -  terminate the program (the default)\n"
        " skip   -  skip to the next message\n"
        " delete -  delete this one and to the next message\n"
        " count  -  count this message as processed\n"
-       "Each keyword can be prefixed with \"no\" to reverse its meaning\n"
-       "Setting onerror=abort reverts to the default behavior."),
+       "Each keyword can be prefixed with \"no\" to reverse its meaning."),
     N_("arg: list") },
   { NULL }
 };


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 05 14:27:28 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c35ge-0006At-GA
	for mharc-commit-mailutils@gnu.org; Sat, 05 Nov 2016 14:27:28 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39745)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c35gX-0006AW-Fl
	for commit-mailutils@gnu.org; Sat, 05 Nov 2016 14:27:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c35gR-0004ym-QR
	for commit-mailutils@gnu.org; Sat, 05 Nov 2016 14:27:21 -0400
Received: from vcs.savannah.gnu.org ([208.118.235.72]:42598)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c35gR-0004yD-HN
	for commit-mailutils@gnu.org; Sat, 05 Nov 2016 14:27:15 -0400
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 3E362220145; Sat,  5 Nov 2016 18:27:15 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-812-gfd19deb
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: af20212718728b315449ff35685772302883fc3d
X-Git-Newrev: fd19deb4391f18e1a752ae5cfe4a9d3155e97705
Message-Id: <20161105182715.3E362220145@vcs.savannah.gnu.org>
Date: Sat,  5 Nov 2016 18:27:15 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Nov 2016 18:27:27 -0000

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=fd19deb4391f18e1a752ae5cfe4a9d3155e97705

The branch, master has been updated
       via  fd19deb4391f18e1a752ae5cfe4a9d3155e97705 (commit)
       via  e8f82804806e94f9b6e4fc072d785e29ea099827 (commit)
       via  c8ae650738984896d1893bb570868f717410444d (commit)
      from  af20212718728b315449ff35685772302883fc3d (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 fd19deb4391f18e1a752ae5cfe4a9d3155e97705
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Sat Nov 5 20:18:05 2016 +0200

    Fix option sorting.
    
    * libmailutils/opt/opt.c (sort_group): Don't assume stability of the sort.
    Use auxiliary data structure to sort array of options that contain aliases.
    * libmailutils/tests/parseopt.c (set_prog_args): Fix delimiter.
    * libmailutils/tests/strtoc.c (v_cidr_format): Error checking.
    * maidag/Makefile.am (maidag_LDADD): Reorder libraries to make sure maidag
    uses freshly built libraries (not the ones already installed in the system).
    * mh/pick.c (options): Bugfix.

commit e8f82804806e94f9b6e4fc072d785e29ea099827
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Sat Nov 5 12:07:39 2016 +0200

    Add missing documentation

commit c8ae650738984896d1893bb570868f717410444d
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Sat Nov 5 12:07:24 2016 +0200

    Minor changes

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

Summary of changes:
 doc/texinfo/mailutils.texi    |   44 ++-
 doc/texinfo/programs.texi     |  690 ++++++++++++++++++++++++++++++-----------
 doc/texinfo/sieve.texi        |   14 +-
 gint                          |    2 +-
 libmailutils/opt/opt.c        |   76 ++++-
 libmailutils/tests/parseopt.c |    2 +-
 libmailutils/tests/strtoc.c   |   18 +-
 libmu_scm/mu_mailbox.c        |   18 +-
 libmu_scm/mu_scm.c            |    1 +
 maidag/Makefile.am            |    8 +-
 mail/send.c                   |    2 +-
 mh/pick.c                     |    2 +-
 scheme/guimb.scmi             |   20 +-
 13 files changed, 655 insertions(+), 242 deletions(-)

diff --git a/doc/texinfo/mailutils.texi b/doc/texinfo/mailutils.texi
index 636b973..0da2fab 100644
--- a/doc/texinfo/mailutils.texi
+++ b/doc/texinfo/mailutils.texi
@@ -119,6 +119,13 @@ Introduction
 * Book Contents::               What this Book Contains
 * History::                     A bit of History
 
+Mailbox
+
+* Local Mailboxes::      Mailboxes stored on the local file system.
+* Remote Mailboxes::     Mailboxes stored on remote hosts.
+* SMTP Mailboxes::       Mailboxes that send mail.
+* Program Mailboxes::
+
 Mailutils Programs
 
 * command line::      Command Line Syntax.  
@@ -154,7 +161,9 @@ Command Line
 Mailutils Configuration File
 
 * conf-syntax::         Configuration File Syntax
+* Variables::           Variable Expansion
 * include::             Include Statement
+* program statement::
 * logging statement::
 * debug statement::
 * mailbox statement::
@@ -207,6 +216,7 @@ Composing Mail
 * Modifying the Headers::
 * Enclosing Another Message::
 * Adding a File to the Message::
+* Attaching a File to the Message::
 * Printing And Saving the Message::
 * Signing the Message::
 * Printing Another Message::
@@ -247,7 +257,7 @@ Reading Mail
 @command{sieve}
 
 * sieve interpreter::   A Sieve Interpreter
-* sieve.scm::           A Sieve to Scheme Translator and Filter
+* sieve2scm::           A Sieve to Scheme Translator and Filter
 
 A Sieve Interpreter
 
@@ -327,24 +337,24 @@ Major differences between Mailutils MH and other MH implementations
 * Profile Variable Diffs::
 * Program Diffs::
 
-MU
+mailutils
 
 * mailutils invocation syntax::
-* mailutils help::
-* mailutils info::
-* mailutils cflags::
-* mailutils ldflags::
-* mailutils query::
-* mailutils 2047::
-* mailutils filter::
-* mailutils acl::
-* mailutils wicket::
-* mailutils dbm::
-* mailutils logger::
-* mailutils pop::
-* mailutils imap::
-* mailutils send::
-* mailutils smtp::
+* mailutils help::                Display a terse help summary.
+* mailutils info::                Show Mailutils configuration.
+* mailutils cflags::              Show compiler options.
+* mailutils ldflags::             List libraries required to link.
+* mailutils query::               Query configuration values.
+* mailutils 2047::                Decode/encode email message headers.
+* mailutils filter::              Apply a chain of filters to the input.
+* mailutils acl::                 Test access control lists.
+* mailutils wicket::              Scan wickets for matching URLs.
+* mailutils dbm::                 DBM management tool.
+* mailutils logger::              Log data using Mailutils log facility.
+* mailutils pop::                 POP3 client shell.
+* mailutils imap::                IMAP4 client shell.
+* mailutils send::                Send a message.
+* mailutils smtp::                Run a SMTP session.
 
 mailutils dbm
 
diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index d116fcc..2e4db32 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -5571,7 +5571,7 @@ utilities in detail.
 
 @menu
 * sieve interpreter::   A Sieve Interpreter
-* sieve.scm::           A Sieve to Scheme Translator and Filter
+* sieve2scm::           A Sieve to Scheme Translator and Filter
 @end menu
 
 @node sieve interpreter
@@ -5663,10 +5663,22 @@ Keep on going if execution fails on a message.  See also
 Append directory @var{dir} to the list of directories searched for
 library files.  See also @ref{Sieve Configuration, library-path}.
 
+@item --libdir-prefix=@var{dir}
+Add @var{dir} to the beginning of the list of directories searched for
+library files.
+
+@item -M @var{url}
+@itemx --mailer=@var{url}
+Define the URL of the default mailer.
+
 @item -n
 @itemx --no-actions
+@itemx --dry-run
 Dry run: do not execute any actions, just print what would be done.
 
+@item --no-program-name
+Do not prefix diagnostic messages with the program name.
+
 @item -t @var{ticket}
 @itemx --ticket=@var{ticket}
 Ticket file for mailbox authentication.  See also
@@ -5677,6 +5689,8 @@ Ticket file for mailbox authentication.  See also
 Log all actions executed.  See also @ref{Sieve Configuration, verbose}.
 @end table
 
+See also @ref{Common Options}.
+
 @node Sieve Configuration
 @subsubsection Sieve Configuration
 
@@ -5685,12 +5699,12 @@ configuration statements:
 
 @multitable @columnfractions 0.3 0.6
 @headitem Statement @tab Reference
-@item debug         @tab @xref{Debug Statement}.
-@item tls           @tab @xref{TLS Statement}.
-@item mailbox       @tab @xref{Mailbox Statement}.
-@item locking       @tab @xref{Locking Statement}.
-@item logging       @tab @xref{Logging Statement}.
-@item mailer        @tab @xref{Mailer Statement}.
+@item debug         @tab @xref{debug statement}.
+@item tls           @tab @xref{tls statement}.
+@item mailbox       @tab @xref{mailbox statement}.
+@item locking       @tab @xref{locking statement}.
+@item logging       @tab @xref{logging statement}.
+@item mailer        @tab @xref{mailer statement}.
 @end multitable
 
 The following statements configure sieve-specific features:
@@ -5698,38 +5712,33 @@ The following statements configure sieve-specific features:
 @deffn {Sieve Conf} sieve @{ ...  @}
 This block statement configures search paths @command{sieve} uses to
 locate its loadable modules.  @xref{Require Statement}, for a detailed
-information of this feature.
+information about loadable modules.
 
 This statement may contain the following sub-statements:
-@code{clear-library-path}, @code{clear-include-path},
-@code{library-path}, @code{include-path}, which are described below.
-@end deffn
 
 @deffn {Sieve Conf} clear-library-path @var{bool}
-Used within the @code{sieve} block statement.
-
 If @var{bool} is @samp{true}, clear library search path.
 @end deffn
 
 @deffn {Sieve Conf} clear-include-path @var{bool}
-Used within the @code{sieve} block statement.
-
 If @var{bool} is @samp{true}, clear include search path.
 @end deffn
 
 @deffn {Sieve Conf} library-path @var{path}
-Used within the @code{sieve} block statement.
-
 Add directories to @command{sieve} library search path.  Argument is a
 string containing a colon-separated list of directories.
 @end deffn
 
-@deffn {Sieve Conf} include-path @var{path}
-Used within the @code{sieve} block statement.
+@deffn {Sieve Conf} library-path-prefix @var{path}
+Add directories to the beginning if the library search path.  Argument
+is a string containing a colon-separated list of directories.
+@end deffn
 
+@deffn {Sieve Conf} include-path @var{path}
 Add directories to the include search path.  Argument is a
 string containing a colon-separated list of directories.
 @end deffn
+@end deffn
 
 @deffn {Sieve Conf} keep-going @var{bool}
 If @var{bool} is @samp{true}, do not abort if execution of a Sieve
@@ -5781,21 +5790,21 @@ debugging level to be enabled.  The argument can consist of the
 following letters:
 
 @table @samp
-@item @samp{t}
+@item t
 This flag enables sieve tracing.  It means that every test will be logged
 when executed.
 
-@item @samp{T}
+@item T
 This flag enables debugging of underlying @code{mailutils} library.
 
-@item @samp{P}
+@item P
 Trace network protocols: produces log of network transactions executed
 while running the script.
 
-@item @samp{g}
+@item g
 Enable main parser traces.  This is useful for debugging the sieve grammar.
 
-@item @samp{i}
+@item i
 Trace the program instructions.  It is the most extensive debugging
 level.  It produces the full execution log of a sieve program, showing
 each instruction and states of the sieve machine.  It is only useful
@@ -5813,7 +5822,7 @@ If the argument to @option{--debug} is omitted, it defaults to
 Option @option{--dump} produces the disassembled dump of the compiled
 sieve program. 
 
-By default @command{sieve} output all diagnostics on standard error and verbose
+By default @command{sieve} outputs all diagnostics on standard error and verbose
 logs on standard output.  This behaviour is changed when
 @option{--log-facility} is given in the command line (@FIXME-pxref{logging}).
 This option causes @command{sieve} to output its diagnostics to
@@ -5823,7 +5832,7 @@ the given syslog facility.
 @subsubsection Extending @command{sieve}
 
 The basic set of sieve actions, tests and comparators may be extended
-using loadable extensions.  Usual @code{require} mechanism is used for
+using loadable extensions.  The usual @code{require} mechanism is used for
 that.
 
 When processing arguments for @code{require} statement, @command{sieve}
@@ -5832,7 +5841,7 @@ uses the following algorithm:
 @enumerate 1
 @item Look up the name in a symbol table.  If the name begins with
 @samp{comparator-} it is looked up in the comparator table.  If it
-begins with @samp{test-}, the test table is used instead.  Otherwise
+begins with @samp{test-}, the test table is searched instead.  Otherwise
 the name is looked up in the action table.
 
 @item If the name is found, the search is terminated.
@@ -5852,12 +5861,17 @@ following search paths (in the order given):
 
 @item The value of the environment variable @env{LTDL_LIBRARY_PATH}.
 
+@item Additional search directories specified with the.
+@option{--libdir-prefix} command line option (@pxref{Invoking Sieve,
+libdir-prefix}), or the @code{library-path-prefix} configuration
+statement (@pxref{Sieve Configuration,library-path-prefix}).
+
 @item Additional search directories specified with the
 @code{library-path} statement (@pxref{Sieve Configuration,
 library-path}) in Sieve configuration file.
 
 @item Additional search directories specified with the.
-@option{--libdir} command line option (@FIXME-pxref{libdir}).
+@option{--libdir} command line option (@pxref{Invoking Sieve,libdir}).
 
 @item Additional search directories specified with the
 @code{#searchpath} Sieve directive (@pxref{#searchpath}).
@@ -5900,11 +5914,11 @@ source for the required action NAME is not available
 @c ***********************************************************************
 
 @page
-@node sieve.scm
+@node sieve2scm
 @subsection A Sieve to Scheme Translator and Filter
 @UNREVISED
 
-A Sieve to Scheme Translator @command{sieve.scm} translates a given
+A Sieve to Scheme Translator @command{sieve2scm} translates a given
 Sieve script into an equivalent Scheme program and optionally executes
 it.  The program itself is written in Scheme and requires presence of
 Guile version 1.8 or newer on the system.  For more information on
@@ -5928,7 +5942,7 @@ Set sieve library directory name
 Set debugging level
 @end table            
 
-The Scheme programs produced by @command{sieve.scm} can be used with
+The Scheme programs produced by @command{sieve2scm} can be used with
 @command{guimb} or @command{maidag}.
 
 @c ***********************************************************************
@@ -5937,22 +5951,64 @@ The Scheme programs produced by @command{sieve.scm} can be used with
 @node guimb
 @section @command{guimb} --- A Mailbox Scanning and Processing Language
 @pindex guimb
-@UNREVISED
 
-@command{Guimb} is for mailboxes what @command{awk} is for text files.
-It processes mailboxes, applying the user-supplied scheme procedures
-to each of them in turn and saves the resulting output in mailbox
-format.
+@command{Guimb} is an experimental tool that iterates over messages in
+a mailbox (or several mailboxes), applying a Scheme function to each
+of them.
 
-The following configuration statements affect the behavior of
-@command{guimb}:
+A user-defined @dfn{scheme module} that supplies the function to apply
+is specified using the @option{--source} or @option{--file} option.
+The module must define at least the following function:
 
-@multitable @columnfractions 0.3 0.6
-@headitem Statement @tab Reference
-@item debug         @tab @xref{Debug Statement}.
-@item mailbox       @tab @xref{Mailbox Statement}.
-@item locking       @tab @xref{Locking Statement}.
-@end multitable
+@deffn {User function} guimb-message @var{msg}
+Processes message @var{msg}.  This function can alter the message
+using Guile primitives supplied by mailutils.
+@end deffn
+
+The following function definitions are optional:
+
+@deffn {User function} guimb-getopt @var{args}
+If defined, this function is called after @command{guimb} has finished
+processing the command line.  @var{args} is a list of unconsumed
+command line arguments.
+
+The function is intended to provide a way of configuring the module
+from the command line.
+@end deffn
+
+@deffn {User function} guimb-end
+If defined, this function is called after all mailboxes have been processed.
+@end deffn
+
+In the following example we define a module that prints
+information about each message is the input mailbox, in a way similar
+to @code{frm} utility:
+
+@example
+@group
+(define-module (frm)
+  :export (guimb-message))
+
+(use-modules (mailutils mailutils))
+             
+(define (guimb-message msg)
+  (display (mu-message-get-sender msg))
+  (display " ")
+  (display (mu-message-get-header msg "subject"))
+  (newline))
+@end group
+@end example
+
+The modules are looked up in directories listed in the global variable
+@code{%load-path}.  New directories can be added to that variable on
+the fly using the @option{-L} (@option{--load-path}) option.  For
+example, if the sample module above was saved in a file
+@file{frm.scm} somewhere in the load path, it can be applied to the
+current user inbox by running the following command:
+
+@example
+guimb --file frm
+@end example
 
 @menu
 * Specifying Scheme Program to Execute::
@@ -5964,37 +6020,35 @@ The following configuration statements affect the behavior of
 @node Specifying Scheme Program to Execute
 @subheading Specifying Scheme Program to Execute
 
-The Scheme program or expression to be executed is passed to
-@command{guimb} via the following options:
+The Scheme module that defines message processing functions is given
+via the following options:
 
 @table @option
-@item -s @var{file}
-@itemx --source @var{file}
-Load Scheme source code from @var{file}.
-@item -c @var{expr}
-@itemx --code @var{expr}
-Execute given scheme expression.
+@item -s @var{module}
+@itemx --source @var{module}
+Load Scheme code from @var{module}.
+
+This option stops further argument processing, and passes all
+remaining arguments as the value of @var{args} argument to the
+@code{guimb-getopt} function, if it is defined.
+
+@item -f @var{module}
+@itemx --file @var{module}
+Load Scheme source code from @var{module}.  The remaining arguments
+are processed in the usual way.  When using this option, you can pass
+additional options and or arguments to the module by enclosing them in
+@option{-@{} and @option{-@}} options (@pxref{Passing Options to Scheme}).
 @end table
 
-The above switches stop further argument processing, and pass all
-remaining arguments as the value of @code{(command-line)}.
-
-If the remaining arguments must be processed by @command{guimb} itself,
-use following options:
+An experimental option is provided, that evaluates a supplied
+Scheme expression right after loading the module:
 
 @table @option
 @item -e @var{expr}
 @itemx --expression @var{expr}
-Execute scheme expression.
-@item -f @var{file}
-@itemx --file @var{file}
-Load Scheme source code from @var{file}.
+Evaluate scheme expression.
 @end table
 
-You can specify both of them.  In this case, the @var{file} is read
-first, then @var{expr} is executed.  You may still pass any additional
-arguments to the script using @option{--guile-arg} option.
-
 @node Specifying Mailboxes to Operate Upon
 @subheading Specifying Mailboxes to Operate Upon
 
@@ -6012,8 +6066,8 @@ The contents of specified mailboxes is processed, and the resulting
 mailbox contents is appended to @var{defmbox}.
 @item guimb [@var{options}] --user @var{username} [@var{mailbox}...]
 The contents of specified mailboxes is processed, and the resulting
-mailbox contents is appended to the user's system mailbox.  This allows
-to use @command{guimb} as a mail delivery agent.
+mailbox contents is appended to the user's system mailbox.  This makes
+it possible to use @command{guimb} as a mail delivery agent.
 @end table
 
 If no mailboxes are specified in the command line, @command{guimb} reads
@@ -6025,12 +6079,13 @@ and processes the system mailbox of the current user.
 Sometimes it is necessary to pass some command line options to the
 scheme procedure.  There are three ways of doing so.
 
-When using @option{--source} (@option{-s}) or @option{--code}
-(@option{-c}) options, all the rest of the command line following
-the option's argument is passed to Scheme program verbatim.  This
-allows for making guimb scripts executable by the shell.  If your system
-supports @samp{#!} magic at the start of scripts, add the following two
-lines to the beginning of your script to allow for its immediate execution:
+When using @option{--source} (@option{-s}) option, the rest of the
+command line following the option's argument is passed as the
+@var{args} argument to the @code{guimb-getopt} function, if such
+function is defined.  This allows for making guimb scripts executable
+by the shell.  If your system supports @samp{#!} magic at the start of
+scripts, add the following two lines to the beginning of your script
+to allow for its immediate execution: 
 
 @example
 #! /usr/local/bin/guimb -s
@@ -6040,18 +6095,19 @@ lines to the beginning of your script to allow for its immediate execution:
 @noindent
 (replace @samp{/usr/local/bin/} with the actual path to the @command{guimb}).
 
-Otherwise, if you use @option{--file} or @option{--expression} options,
-the additional arguments may be passed to the Scheme program @option{-g}
+Otherwise, if you use the @option{--file} option, the additional
+arguments can be passed to the Scheme program @option{-g} 
 (@option{--guile-arg}) command line option.  For example:
 
 @example
 guimb --guile-arg -opt --guile-arg 24 --file @var{progfile}
 @end example
 
-In this example, the scheme procedure will see the following command line:
+In this example, the @code{guimb-getopt} function will get the
+following argument
 
 @example
-@var{progfile} -opt 24
+( '-opt' 24 )
 @end example
 
 Finally, if there are many arguments to be passed to Scheme, it is more
@@ -6074,6 +6130,11 @@ Start with debugging evaluator and backtraces.
 @item -e @var{expr}
 @itemx --expression @var{expr}
 Execute given Scheme expression.
+@item -L @var{dir}
+@item --load-path @var{dir}
+Insert @var{dir} at the beginning of the @code{%load-path} list.  The
+argument is either a single directory name, or a list of such names,
+delimited by @samp{:} characters.
 @item -m @var{path}
 @itemx --mail-spool=@var{path}
 Set path to the mailspool directory
@@ -6111,8 +6172,8 @@ is a general-purpose @acronym{MDA} offering a rich set of
 features.  It can operate both in traditional mode, reading the message
 from its standard input, and in @acronym{LMTP} mode.  @command{Maidag}
 is able to deliver mail to any mailbox format, supported by GNU
-Mailutils.  These formats, among others, include @samp{remote+smtp},
-@samp{remote+prog} and @samp{remote+sendmail} which are
+Mailutils.  These formats, among others, include @samp{smtp://},
+@samp{prog://} and @samp{sendmail://} which are
 equivalent to forwarding a message over @acronym{SMTP} to a remote
 node.  Thus, @command{maidag} supersedes both @command{mail.local} and
 @command{mail.remote} utilities from GNU Mailutils versions prior to
@@ -6203,7 +6264,7 @@ maidag:
 MeTA1 (@uref{http://meta1.org}) communicates with the delivery agent
 using @acronym{LMTP}.
 
-LMTP mode is enabled in @command{maidag} by the @samp{lmpt yes}
+LMTP mode is enabled in @command{maidag} by the @samp{lmtp yes}
 statement.  The socket to listen on must be specified using
 @code{server} statement (@pxref{Server Settings}).  For the purposes of
 this section, let's suppose @command{maidag} will listen on a
@@ -6411,7 +6472,7 @@ Expands to the recipient home directory.
 Expands to the recipient user name.
 @end table
 
-By default, a filename extension decide which scripting language will
+By default, the filename extension decides which scripting language will
 be used.  User can alter the choice using @samp{language} configuration
 statement.  For example:
 
@@ -6592,25 +6653,25 @@ $ maidag --url maildir:///home/smith/Mail
 @node Remote Mailbox Delivery
 @subsection Remote Mailbox Delivery
 @command{Maidag} can be used to deliver mail to remote mailboxes, such
-as @samp{imap} or @samp{remote+smtp}.  If the mailbox @acronym{URL}
-is @samp{remote+smtp} or @samp{remote+sendmail}, the message is
+as @samp{imap} or @samp{smtp}.  If the mailbox @acronym{URL}
+is @samp{smtp} or @samp{sendmail}, the message is
 actually forwarded over @acronym{SMTP} to the remote node, so
 @command{maidag} acts as a message transfer agent.  For example:
 
 @example
-$ maidag --url remote+smtp://10.10.1.100:24
+$ maidag --url smtp://10.10.1.100:24
 @end example
 
 This command line will send the message to the machine
 @samp{10.10.1.100} using port @samp{24} (private mail system).
 
-The @samp{remote+prog} mailbox may be of special use.  Delivering to
+The @samp{prog} mailbox may be of special use.  Delivering to
 this mailbox results in invoking the specified command with the given
 arguments and passing the message to its standard input.  There are two
-ways to specify a @samp{remote+prog} mailbox:
+ways to specify a @samp{prog} mailbox:
 
 @table @asis
-@item remote+prog://@var{program}?@var{args}
+@item prog://@var{program}?@var{args}
 Here, @var{program} is the absolute pathname of the program binary,
 and @var{args} are its arguments, separated by @samp{&} signs.
 
@@ -6621,7 +6682,7 @@ white space.
 
 In both cases, @var{args} do not include @code{argv[0]}.
 
-The @samp{remote+prog} mailbox may be used, in particular, to implement
+The @samp{prog} mailbox may be used, in particular, to implement
 mailing lists with MeTA1.
 
 For example, suppose that the @command{maidag} configuration contains:
@@ -6672,20 +6733,20 @@ statements:
 
 @multitable @columnfractions 0.3 0.6
 @headitem Statement @tab Reference
-@item debug         @tab @xref{Debug Statement}.
-@item mailbox       @tab @xref{Mailbox Statement}.
-@item locking       @tab @xref{Locking Statement}.
-@item pam           @tab @xref{PAM Statement}.
-@item sql           @tab @xref{SQL Statement}.
-@item virtdomain    @tab @xref{Virtdomain Statement}.
-@item radius        @tab @xref{Radius Statement}.
-@item ldap          @tab @xref{LDAP Statement}.
-@item auth          @tab @xref{Auth Statement}.
-@item mailer        @tab @xref{Mailer Statement}.
+@item debug         @tab @xref{debug statement}.
+@item mailbox       @tab @xref{mailbox statement}.
+@item locking       @tab @xref{locking statement}.
+@item pam           @tab @xref{pam statement}.
+@item sql           @tab @xref{sql statement}.
+@item virtdomain    @tab @xref{virtdomain statement}.
+@item radius        @tab @xref{radius statement}.
+@item ldap          @tab @xref{ldap statement}.
+@item auth          @tab @xref{auth statement}.
+@item mailer        @tab @xref{mailer statement}.
 @item server        @tab @xref{Server Settings}.  Used only in
 @acronym{LMTP} mode.
-@item acl           @tab @xref{ACL Statement}.
-@item tcp-wrappers  @tab @xref{Tcp-wrappers Statement}.
+@item acl           @tab @xref{acl statement}.
+@item tcp-wrappers  @tab @xref{tcp-wrappers statement}.
 @end multitable
 
 @deffn {Maidag Config} ex-multiple-delivery-success @var{bool}
@@ -6940,7 +7001,6 @@ Use @var{program} to display files.
 @node pop3d
 @section POP3 Daemon
 @pindex pop3d
-@UNREVISED
 
 The @command{pop3d} daemon implements the Post Office Protocol
 Version 3 server.
@@ -7134,20 +7194,20 @@ The following configuration file statements affect the behavior of
 
 @multitable @columnfractions 0.3 0.6
 @headitem Statement @tab Reference
-@item debug         @tab @xref{Debug Statement}.
-@item tls           @tab @xref{TLS Statement}.
-@item mailbox       @tab @xref{Mailbox Statement}.
-@item locking       @tab @xref{Locking Statement}.
-@item logging       @tab @xref{Logging Statement}.
-@item pam           @tab @xref{PAM Statement}.
-@item sql           @tab @xref{SQL Statement}.
-@item virtdomain    @tab @xref{Virtdomain Statement}.
-@item radius        @tab @xref{Radius Statement}.
-@item ldap          @tab @xref{LDAP Statement}.
-@item auth          @tab @xref{Auth Statement}.
+@item debug         @tab @xref{debug statement}.
+@item tls           @tab @xref{tls statement}.
+@item mailbox       @tab @xref{mailbox statement}.
+@item locking       @tab @xref{locking statement}.
+@item logging       @tab @xref{logging statement}.
+@item pam           @tab @xref{pam statement}.
+@item sql           @tab @xref{sql statement}.
+@item virtdomain    @tab @xref{virtdomain statement}.
+@item radius        @tab @xref{radius statement}.
+@item ldap          @tab @xref{ldap statement}.
+@item auth          @tab @xref{auth statement}.
 @item server        @tab @xref{Server Settings}.
-@item acl           @tab @xref{ACL Statement}.
-@item tcp-wrappers  @tab @xref{Tcp-wrappers Statement}.
+@item acl           @tab @xref{acl statement}.
+@item tcp-wrappers  @tab @xref{tcp-wrappers statement}.
 @end multitable
 
 @deffn {Pop3d Conf} undelete @var{bool}
@@ -7207,26 +7267,15 @@ it defaults to 10 processes.
 @itemx --inetd
 Run in inetd mode.
 
-@item -h
-@itemx --help
-Display short help message and exit.
-
 @item --foreground
 Remain in foreground.
-
-@item --tls[=@var{bool}]
-Enable TLS.  If optional argument is supplied and is @samp{false}, then
-disable it.
-
-@item --debug-auth
-Enable debugging of authentication functions.
 @end table
 
+The Mailutils common options are also understood.  @xref{Common Options}.
 @page
 @node imap4d
 @section IMAP4 Daemon
 @pindex imap4d
-@UNREVISED
 
 GNU @command{imap4d} is a daemon implementing @sc{imap4} rev1 protocol
 for accessing and handling electronic mail messages on a server.  It can
@@ -7341,20 +7390,20 @@ configuration statements:
 
 @multitable @columnfractions 0.3 0.6
 @headitem Statement @tab Reference
-@item debug         @tab @xref{Debug Statement}.
-@item tls           @tab @xref{TLS Statement}.
-@item mailbox       @tab @xref{Mailbox Statement}.
-@item locking       @tab @xref{Locking Statement}.
-@item logging       @tab @xref{Logging Statement}.
-@item pam           @tab @xref{PAM Statement}.
-@item sql           @tab @xref{SQL Statement}.
-@item virtdomain    @tab @xref{Virtdomain Statement}.
-@item radius        @tab @xref{Radius Statement}.
-@item ldap          @tab @xref{LDAP Statement}.
-@item auth          @tab @xref{Auth Statement}.
+@item debug         @tab @xref{debug statement}.
+@item tls           @tab @xref{tls statement}.
+@item mailbox       @tab @xref{mailbox statement}.
+@item locking       @tab @xref{locking statement}.
+@item logging       @tab @xref{logging statement}.
+@item pam           @tab @xref{pam statement}.
+@item sql           @tab @xref{sql statement}.
+@item virtdomain    @tab @xref{virtdomain statement}.
+@item radius        @tab @xref{radius statement}.
+@item ldap          @tab @xref{ldap statement}.
+@item auth          @tab @xref{auth statement}.
 @item server        @tab @xref{Server Settings}.
-@item acl           @tab @xref{ACL Statement}.
-@item tcp-wrappers  @tab @xref{Tcp-wrappers Statement}.
+@item acl           @tab @xref{acl statement}.
+@item tcp-wrappers  @tab @xref{tcp-wrappers statement}.
 @end multitable
 
 @deffn {Imap4d Conf} shared-namespace @var{list}
@@ -7521,35 +7570,26 @@ it defaults to 20 processes.
 @emph{Please note}, that there should be no whitespace between the
 @option{-d} and its parameter.
 
-@item -h
-@itemx --help
-Display short help message and exit.
-
 @item -i
 @itemx --inetd
 Run in inetd mode.
+
 @item --foreground
 Run in foreground.
 
 @item --preauth
 Start in preauth mode
 
-@item --tls[=@var{bool}]
-Enable TLS support
-
-@item --debug-auth
-Debug authentication functions.
-
-@item -v
-@itemx --version
-Display program version and exit.
+@item --test
+Run in test mode.
 @end table
 
+See also @ref{Common Options}.
+
 @page
 @node comsatd
 @section Comsat Daemon
 @pindex comsatd
-@UNREVISED
 
 Comsatd is the server which receives reports of incoming mail and
 notifies users, wishing to get this service.  It can be started
@@ -7564,22 +7604,7 @@ either from @file{inetd.conf} or as a standalone daemon.
 @node Starting comsatd
 @subsection Starting @command{comsatd}
 
-@command{Comsatd} uses following option groups: @FIXME-xref{mailbox},
-@FIXME-xref{daemon}, @FIXME-xref{logging}.
-
 @table @option
-@item -C @var{file}
-@itemx --convert-config=@var{file}
-Convert the configuration file @var{file} to the new
-format.  @var{File} must be a @command{comsatd} configuration file in
-Mailutils v. 1.x format.  The converted file is printed on the standard
-output.  For example, the following command can be used to convert old
-@command{comsatd} configuration file to new format:
-
-@example
-$ comsatd --convert-config=/etc/comsatd.conf > /etc/mailutils.d/comsatd
-@end example
-
 @item -d
 @itemx --daemon
 Run as a standalone daemon.
@@ -7605,8 +7630,12 @@ mailbox, e.g.:
 $ comsatd --test /var/mail/root 34589
 @end example
 
+@item --foreground
+Don't detach from the controlling terminal, remain in foreground.
 @end table
 
+See also @ref{Common Options}.
+
 @node Configuring comsatd
 @subsection Configuring @command{comsatd}
 
@@ -7615,11 +7644,11 @@ Following configuration statements affect the behavior of
 
 @multitable @columnfractions 0.3 0.6
 @headitem Statement @tab Reference
-@item debug   @tab @xref{Debug Statement}.
-@item logging @tab @xref{Logging Statement}.
-@item mailbox @tab @xref{Mailbox Statement}.
-@item locking @tab @xref{Locking Statement}.
-@item acl     @tab @xref{ACL Statement}.
+@item debug   @tab @xref{debug statement}.
+@item logging @tab @xref{logging statement}.
+@item mailbox @tab @xref{mailbox statement}.
+@item locking @tab @xref{locking statement}.
+@item acl     @tab @xref{acl statement}.
 @end multitable
 
 @menu
@@ -7769,7 +7798,6 @@ $B(,5)\
 @page
 @node mh
 @section MH --- The MH Message Handling System
-@UNREVISED
 
 @include mu-mh.texi
 
@@ -8839,14 +8867,320 @@ Shows command history.
 
 @node mailutils imap
 @subsection mailutils imap
-The @command{mailutils imap} command is reserved for an interactive IMAP4
-client shell.  It does not do much now (as of version @value{VERSION}.
+The @command{mailutils imap} command invokes an interactive IMAP4 client
+shell.  It reads commands from the standard input, executes them and
+displays the results on the standard output.  The shell is similar to
+the @command{mailutils pop} (@pxref{mailutils pop}) shell.
+
+@subsubheading IMAP protocol commands
+
+Most commands in this group correspond (with minor differences) to
+IMAP commands described in RFC 3501@footnote{See
+@uref{http://www.faqs.org/rfcs/rfc3501.html}.}.
+
+@deffn {imap command} connect [-tls] @var{host} [@var{port}]
+Opens connection to the server @var{host}.  If the @option{-tls}
+option is given, TLS encryption (also known as IMAPS protocol) will be
+used.  If @var{port} argument is not supplied, the command uses port
+143 for a plain IMAP connection or 993 for IMAPS (if @option{-tls} is
+given).
+@end deffn
+
+@deffn {imap command} capability [-reread] [@var{name}...]
+Lists server capabilities.  Any number of @var{name}s is accepted.  If
+at least one is given, the shell will display only the named
+capabilities, otherwise it displays the entire list.  By default,
+@command{capability} reuses the response of its previous invocation
+(if there was any), instead of resending the CAPABILITY command to the
+server.  To force it do so, use the @option{-reread} option. 
+@end deffn
+
+@deffn {imap command} starttls
+Starts TLS negotiation.  This command is valid only after unencrypted
+connection has been successfully initiated using connect without the
+@option{-tls} option.
+@end deffn
+
+@deffn {imap command} login @var{user} [@var{password}] 
+Logs in to the server as @var{user} with optional @var{password}.  If
+the pass argument is omitted, the shell will ask you to enter it.
+While entering, both echoing and history recording will be disabled.
+Use this to avoid compromising your password.
+@end deffn
+
+@deffn {imap command} logout
+@deffnx {imap command} quit
+Quits the imap session.
+@end deffn
+
+@deffn {imap command} id [-test @var{kw}] [@var{arg}...]
+Sends IMAP ID command.  See RFC
+2971@footnote{@uref{http://www.faqs.org/rfcs/rfc2971.html}}, for a
+discussion of arguments.  By default, this command outputs entire ID
+list. If, however, the @option{-test} option is given, it will check whether
+the keyword @var{kw} is defined and display its value if so.  
+@end deffn
+
+@deffn {imap command} check
+Requests a server checkpoint.
+@end deffn
+
+@deffn {imap command} select [@var{mbox}]
+Selects the named mailbox. Without argument, selects @samp{INBOX}. 
+@end deffn
+
+@deffn {imap command} examine [@var{mbox}]
+Examines the named mailbox, i.e. selects it in read-only mode.  If
+@var{mbox} is not given, @samp{INBOX} is assumed.
+@end deffn
+
+@deffn {imap command} status @var{mbox} @var{kw} [@var{kw}...]
+Gets mailbox status.  Valid keywords (@var{kw} arguments) are:
+@samp{MESSAGES}, @samp{RECENT}, @samp{UIDNEXT}, @samp{UIDVALIDITY},
+and @samp{UNSEEN}.  Keywords are case-insensitive. 
+@end deffn
+
+@deffn {imap command} fetch @var{msgset} @var{items}
+Fetches message data.  See RFC 3501, section
+6.4.5@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.4.5}},
+for a discussion of its arguments.
+@end deffn
+
+@deffn {imap command} store @var{msgset} @var{items}
+Alters mailbox data.  See RFC 3501, section
+6.4.6@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.4.6}},
+for a discussion of its arguments. 
+@end deffn
+
+@deffn {imap command} close
+Closes the currently selected mailbox (with expunge). 
+@end deffn
+
+@deffn {imap command} unselect
+Closes the currently selected mailbox (without expunge). 
+@end deffn
+
+@deffn {imap command} delete @var{mbox}
+Deletes the mailbox @var{mbox}. 
+@end deffn
+
+@deffn {imap command} rename @var{old-name} @var{new-name}
+Renames existing mailbox @var{old-name} to @var{new-name}.
+@end deffn
+
+@deffn {imap command} expunge
+Permanently removes messages marked for deletion. 
+@end deffn
+
+@deffn {imap command} create @var{name}
+Creates new mailbox with the given @var{name}.
+@end deffn
+
+@deffn {imap command} append [-time @var{datetime}] [-flag @var{flag}] @var{mailbox} @var{file}
+Reads an RFC-822 message from @var{file} and appends it to the
+@var{mailbox}.  Use the @option{-time} option to supply envelope date
+for the message.  Use the @option{-flag} option to supply message
+flags.  For example:  
+
+@example
+append -time "25-Aug-2002 18:00:00 +0200" -flag \Seen INBOX input.msg
+@end example
+@end deffn
+
+@deffn {imap command} list @var{ref} @var{mbox}
+Lists matching mailboxes.  See RFC 3501, section
+6.3.8@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.3.8}},
+for a discussion of its arguments.
+@end deffn
+
+@deffn {imap command} lsub @var{ref} @var{mbox}
+Lists subscribed mailboxes (RFC 3501, section 6.3.9@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.3.9}}). 
+@end deffn
+
+@deffn {imap command} subscribe @var{mbox}
+Subscribes to a mailbox. 
+@end deffn
+
+@deffn {imap command} unsubscribe @var{mbox}
+Removes mailbox @var{mbox} from the subscription list. 
+@end deffn
+
+@deffn {imap command} noop
+Sends a @dfn{no operation} command. 
+@end deffn
+
+@deffn {imap command} disconnect
+Closes existing connection. 
+@end deffn
+
+@subsubheading Internal commands
+The @code{imap} shell implements the same set of internal commands as
+@code{pop} shell: @xref{mailutils pop, Internal commands}.  There is
+only one imap-specific internal command:
+
+@deffn {imap command} uid [on|off]
+Controls the UID mode.  When the UID mode is on, the commands
+@code{fetch} and @code{store} operate on and return message UIDs
+instead of their sequence numbers.  
+
+To examine the current state of the UID mode, issue the @code{uid}
+command without arguments.
+@end deffn
 
 @node mailutils send
 @subsection mailutils send
-@WRITEME
+Reads an RFC-822 message from a file and sends it over to a specified
+SMTP server.  The syntax is: 
+
+@example
+mailutils send [@var{options}] @var{host} @var{file}
+@end example
+
+@noindent
+where @var{host} defines the SMTP server through which to send the
+message, and @var{file} is the name of the input file containing the
+message.  For example, to send a message from file @file{input.msg}
+using SMTP service at localhost, one would write:
+
+@example
+$ mailutils send localhost input.msg
+@end example
+
+The @var{host} argument can be an IP address, hostname, or a
+valid SMTP URL. 
+
+The following command line options are understood:
 
+@table @option
+@item -F @var{address}
+@itemx --from=@var{address}
+Supplies envelope sender address.
+
+@item -T @var{address}
+@itemx --rcpt=@var{address}
+Supplies envelope recipient address.  It can be specified multiple
+times.
+
+@item -t
+@itemx --read-recipients
+Instructs the program to read recipient email addresses from the
+message @samp{To:}, @samp{Cc:}, and @samp{Bcc:} headers.
+@end table
+    
 @node mailutils smtp
 @subsection mailutils smtp
-@WRITEME
+The @code{mailutils smtp} command invokes an interactive SMTP client
+shell.  It reads commands from the standard input, executes them and
+displays the results on the standard output.  If the standard input is
+connected to a terminal, the readline and history facilities are
+enabled (provided that Mailutils is configured with GNU Readline).
+
+@subsubheading Initializing connection
+
+@deffn {smtp command} connect [-tls] @var{host} [@var{port}]
+Connects to SMTP server at @var{host} (IP address or host name).  If
+the @option{-tls} option is given, TLS encryption (also known as SMTPS
+protocol) will be used.  The default port number is 25 for plain SMTP
+and 465 for SMTPS.  Explicit @var{port} argument overrides the default
+value.  
+@end deffn
+
+@subsubheading Connection parameters
+
+A number of parameters is associated with an open connection:
+
+@table @asis
+@item domain
+Domain name used in EHLO statement.  Defaults to the current host name. 
+@end table
+
+The following parameters are used for ESMTP authentication:
+
+@table @asis
+@item username
+User name. 
+@item password
+User password. 
+@item service
+GSASL service name. 
+@item realm
+Realm name. 
+@item host
+Host name.
+@item url
+SMTP URL.  It can contain all of the above. Default is smtp:// 
+@end table
+
+These parameters are manipulated using the following statements:
+
+@deffn {smtp command} set @var{param} @var{value} [@var{param} @var{value}...]
+Sets parameter @var{param} to @var{value}.  Several parameters can be
+set with one @command{set} statement.  
+@end deffn
+
+@deffn {smtp command} clear [@var{param}...]
+Unset the supplied connection parameters.  If used without arguments,
+unsets all parameters.  
+@end deffn
+
+@deffn {smtp command} list [@var{param}...]
+Lists the values of the connection parameters.  If used without
+arguments, lists all parameters. 
+@end deffn
+
+@subsubheading SMTP commands
+@deffn {smtp command} ehlo [@var{domain}]
+Sends the ESMTP greeting.  Unless @var{domain} is supplied, the
+connection parameter @samp{domain} is used.  
+@end deffn
+
+@deffn {smtp command} capa [@var{name}...]
+Lists the server capabilities. 
+@end deffn
+
+@deffn {smtp command} starttls
+Initiates encrypted connection.  This command is disabled if the
+connection is opened with the @option{-tls} option.
+@end deffn
+
+@deffn {smtp command} auth @var{mech} [@var{mech}...]
+Authenticate using the supplied mechanisms.
+@end deffn
+
+@deffn {smtp command} rset
+Reset the session state.
+@end deffn
+
+@deffn {smtp command} from [@var{email}]
+Sets sender email address.  If used without arguments, prints the
+sender email address.
+@end deffn
+
+@deffn {smtp command} to [@var{email}]
+Sets recipient email address.  If used without arguments, prints all
+recepient names collected so far.
+@end deffn
+
+@deffn {smtp command} smtp @var{command} [@var{args}...]
+Sends the @var{command} with its arguments verbatim. 
+@end deffn
+
+@deffn {smtp command} quit
+Quits the SMTP session. 
+@end deffn
+
+@deffn {smtp command} send [@var{file}]
+Reads the message from @var{file} and sends it.  If @var{file} is not
+supplied, the action depends on whether a @code{send} command was used
+prevously within the same session.  If so, @command{mailutils} will
+first ask whether to reuse the already supplied message.  If not, it
+will start an editor, allowing you to enter the new message.  When you
+exit from the editor, you will be prompted what to do with the
+message: send, edit, or quit (discard) it.
+@end deffn
+
+@subsubheading Internal commands
+
+Internal commands are the same as in @code{pop} shell: @xref{mailutils
+pop, Internal commands}.
 
diff --git a/doc/texinfo/sieve.texi b/doc/texinfo/sieve.texi
index 7ea8b99..6722970 100644
--- a/doc/texinfo/sieve.texi
+++ b/doc/texinfo/sieve.texi
@@ -970,7 +970,7 @@ If the tagged argument is not given, @samp{:over} is assumed.
 
 @deftypefn Test {} pipe [:envelope] [:header] [:body] @
                         [:exit @var{code}(number)] @
-  	                [:signal @var{code}(number)] @
+                        [:signal @var{code}(number)] @
                         @var{command}(string)
 @*Synopsis:
 @smallexample
@@ -1489,14 +1489,14 @@ pipe "/usr/sbin/maidag --url smtp://gray@@mail.gnu.org"
                           [:noreply @var{noreply-address}(string-list)] @
                           [:reply_regex @var{expr}(string)] @
                           [:reply_prefix @var{prefix}(string)] @
- 		          [:sender @var{email}(string)] @
-		          [:database @var{path}(string)] @
-		          [:return_address @var{email}(string)] @
+                          [:sender @var{email}(string)] @
+                          [:database @var{path}(string)] @
+                          [:return_address @var{email}(string)] @
                           [:header @var{headers}(string-list)] @
-		          [:mime] @
-		          [:always_reply] @
+                          [:mime] @
+                          [:always_reply] @
                           [:rfc2822] @
-		          [:file] @
+                          [:file] @
                           @var{text}(string)
 @*Syntax:
 @smallexample
diff --git a/gint b/gint
index fd86bf7..42f4712 160000
--- a/gint
+++ b/gint
@@ -1 +1 @@
-Subproject commit fd86bf7d44b0c970771830692ae7491447ebe8b1
+Subproject commit 42f4712085b40173eaea58e14b1a579291a6fe3a
diff --git a/libmailutils/opt/opt.c b/libmailutils/opt/opt.c
index 0a436c5..7a992f2 100644
--- a/libmailutils/opt/opt.c
+++ b/libmailutils/opt/opt.c
@@ -29,6 +29,14 @@
 #define EXIT_SUCCESS 0
 #define EXIT_ERROR   1
 
+/* Option and its aliases form a contiguous array.  Option slot is used
+   to preserve contiguity during sorting. */
+struct opt_slot
+{
+  struct mu_option **opt;   /* Points to the option */
+  int count;                /* Number of options in opt */
+};
+
 /* Compare pointers to two option structs */
 static int
 optcmp (const void *a, const void *b)
@@ -36,11 +44,6 @@ optcmp (const void *a, const void *b)
   struct mu_option const *ap = *(struct mu_option const **)a;
   struct mu_option const *bp = *(struct mu_option const **)b;
   
-  while (ap->opt_flags & MU_OPTION_ALIAS)
-    ap--;
-  while (bp->opt_flags & MU_OPTION_ALIAS)
-    bp--;
-
   if (!MU_OPTION_IS_VALID_SHORT_OPTION (ap)
       && MU_OPTION_IS_VALID_LONG_OPTION (ap)
       && !MU_OPTION_IS_VALID_SHORT_OPTION (bp)
@@ -60,18 +63,67 @@ optcmp (const void *a, const void *b)
     }
 }
 
+/* Compare pointers to two option slots */
+static int
+slotcmp (const void *a, const void *b)
+{
+  struct opt_slot const *ap = (struct opt_slot const *)a;
+  struct opt_slot const *bp = (struct opt_slot const *)b;
+  return optcmp (ap->opt, bp->opt);
+} 
 /* Sort a group of options in OPTBUF, starting at index START (first
    option slot after a group header (if any).  The group spans up to
    next group header or end of options */
 static size_t
 sort_group (struct mu_option **optbuf, size_t start)
 {
-  size_t i;
-  
+  size_t i, count = 0;
+
+  /* Make sure the first option in group is not an alias. */
+  optbuf[start]->opt_flags &= ~MU_OPTION_ALIAS;
   for (i = start; optbuf[i] && !MU_OPTION_IS_GROUP_HEADER (optbuf[i]); i++)
-    ;
-  
-  qsort (&optbuf[start], i - start, sizeof (optbuf[0]), optcmp);
+    {
+      if (!(optbuf[i]->opt_flags & MU_OPTION_ALIAS))
+	count++;
+    }
+  if (count == i - start)
+    /* Inplace sort */
+    qsort (&optbuf[start], count, sizeof (optbuf[0]), optcmp);
+  else
+    {
+      /* Option group contains aliases. Split it into option slots. */
+      struct mu_option **tmp;
+      struct opt_slot *slots;
+      size_t j, k, l;
+      
+      slots = mu_calloc (count, sizeof (slots[0]));
+      j = 0;
+      slots[0].opt = optbuf + start;
+      slots[0].count = 1;
+      for (k = start + 1; k < i; k++)
+	{
+	  if (optbuf[k]->opt_flags & MU_OPTION_ALIAS)
+	    slots[j].count++;
+	  else
+	    {
+	      j++;
+	      slots[j].opt = optbuf + k;
+	      slots[j].count = 1;
+	    }
+	}
+      /* Sort the slots */
+      qsort (slots, count, sizeof (slots[0]), slotcmp);
+      /* Create ordered array of option pointers */
+      tmp = mu_calloc (i - start, sizeof (tmp[0]));
+      for (k = l = 0; k < count; k++)
+	for (j = 0; j < slots[k].count; j++)
+	  tmp[l++] = slots[k].opt[j];
+      /* Copy ordered pointers back and free temporary memory */
+      memcpy (optbuf + start, tmp, (i - start) * sizeof tmp[0]);
+      free (tmp);
+      free (slots);
+    }
+		     
   return i;
 }
 
@@ -648,9 +700,7 @@ parseopt_init (struct mu_parseopt *po, struct mu_option **options,
   
   po->po_optv[j] = NULL;
 
-  /* Ensure sane start of options.  This is necessary, in particular,
-     because optcmp backs up until it finds an element with cleared
-     MU_OPTION_ALIAS bit. */
+  /* Ensure sane start of options. */
   po->po_optv[0]->opt_flags &= ~MU_OPTION_ALIAS;
   if (!(flags & MU_PARSEOPT_NO_SORT))
     {
diff --git a/libmailutils/tests/parseopt.c b/libmailutils/tests/parseopt.c
index 7b2aade..cefffdd 100644
--- a/libmailutils/tests/parseopt.c
+++ b/libmailutils/tests/parseopt.c
@@ -90,7 +90,7 @@ set_prog_args (struct parseopt_param *param, char const *str, void *target)
 
   size = 1;
   for (i = 0; str[i]; i++)
-    if (str[i] == '\n')
+    if (str[i] == '|')
       size++;
 
   args = mu_calloc (size + 1, sizeof (args[0]));
diff --git a/libmailutils/tests/strtoc.c b/libmailutils/tests/strtoc.c
index 64c3cb4..8ac8637 100644
--- a/libmailutils/tests/strtoc.c
+++ b/libmailutils/tests/strtoc.c
@@ -161,10 +161,17 @@ static void
 v_cidr_format (union value *val, FILE *fp)
 {  
   char *buf;
-
-  mu_cidr_format (&val->v_cidr, 0, &buf);
-  fprintf (fp, "%s", buf);
-  free (buf);
+  int rc;
+  rc = mu_cidr_format (&val->v_cidr, 0, &buf);
+  if (rc)
+    {
+      fprintf (fp, "(can't convert value: %s)", mu_strerror (rc));
+    }
+  else
+    {
+      fprintf (fp, "%s", buf);
+      free (buf);
+    }
 }
 
 static int
@@ -259,6 +266,7 @@ struct testdata tests[] = {
 	.len = 4,
 	.address = { 127, 0, 0, 0 },
 	.netmask = { 255 } } } },
+#ifdef MAILUTILS_IPV6  
   { mu_c_cidr,   "fe80::4a5b:39ff:fe09:97f0/64", 0,  { .v_cidr = {
 	.family = 10,
 	.len = 16,
@@ -266,7 +274,7 @@ struct testdata tests[] = {
 		     0x4a, 0x5b, 0x39, 0xff, 0xfe, 0x9, 0x97, 0xf0 },
 	.netmask = { 255, 255, 255, 255, 255, 255, 255, 255,
 		     0,   0,   0,   0,   0,   0,   0,   0 } } } },
-  
+#endif  
   { mu_c_incr,   NULL,              0, { .v_int = 1 } },
   { mu_c_void }
 };
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index 6177b66..3b223a3 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -220,7 +220,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
   int status;
   SCM ret;
   
-  SCM_ASSERT (scm_is_string (url), url, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_bool (url) || scm_is_string (url), url, SCM_ARG1, FUNC_NAME);
   SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME);
   
   scm_dynwind_begin (0);
@@ -247,8 +247,20 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
   if (mode_bits & MU_STREAM_READ && mode_bits & MU_STREAM_WRITE)
     mode_bits = (mode_bits & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR;
 
-  mode_str = scm_to_locale_string (url);
-  scm_dynwind_free (mode_str);
+  if (scm_is_bool (url))
+    {
+      if (url == SCM_BOOL_F)
+	mode_str = NULL;
+      else
+	mu_scm_error (FUNC_NAME, EINVAL,
+		      "value #t for URL is reserved for future use",
+		      scm_list_1 (url));
+    }
+  else
+    {
+      mode_str = scm_to_locale_string (url);
+      scm_dynwind_free (mode_str);
+    }
   
   status = mu_mailbox_create_default (&mbox, mode_str);
   if (status)
diff --git a/libmu_scm/mu_scm.c b/libmu_scm/mu_scm.c
index f605776..98b4fb1 100644
--- a/libmu_scm/mu_scm.c
+++ b/libmu_scm/mu_scm.c
@@ -111,6 +111,7 @@ SCM_DEFINE_PUBLIC (scm_mu_register_format, "mu-register-format", 0, 0, 1,
 {
   int status;
 
+  SCM_VALIDATE_REST_ARGUMENT (rest);
   if (scm_is_null (rest))
     {
       status = register_format (NULL);
diff --git a/maidag/Makefile.am b/maidag/Makefile.am
index 53c887e..d684f41 100644
--- a/maidag/Makefile.am
+++ b/maidag/Makefile.am
@@ -33,9 +33,6 @@ endif
 
 maidag_LDADD = \
  ../lib/libmuscript.a\
- @LIBMU_SCM@ @GUILE_LIBS@\
- @LIBMU_SCM_DEPS@\
- @MU_LIB_PY@ @PYTHON_LIBS@\
  ${MU_APP_LIBRARIES}\
  ${MU_LIB_SIEVE}\
  ${MU_LIB_MBOX}\
@@ -49,7 +46,12 @@ maidag_LDADD = \
  @MU_AUTHLIBS@\
  ${MU_LIB_MAILUTILS} \
  @MU_COMMON_LIBRARIES@\
+ @LIBMU_SCM@\
+ @LIBMU_SCM_DEPS@\
+ @MU_LIB_PY@\
  $(LIBMU_DBM)\
+ @GUILE_LIBS@\
+ @PYTHON_LIBS@\
  @DBMLIBS@\
  @MU_TCPWRAP_LIBRARIES@
 
diff --git a/mail/send.c b/mail/send.c
index 8a39d08..c27b1db 100644
--- a/mail/send.c
+++ b/mail/send.c
@@ -513,7 +513,7 @@ mail_send (int argc, char **argv)
 		  mode = hp->mode;
 		  if (mu_header_sget_value (env.header, hp->name, NULL) == 0)
 		    mode = COMPOSE_REPLACE;
-		  compose_header_set (&env, hp->name, hp->value, hp->mode);
+		  compose_header_set (&env, hp->name, hp->value, mode);
 		}
 	      mu_iterator_destroy (&itr);
 	    }
diff --git a/mh/pick.c b/mh/pick.c
index 9a78866..53e9d83 100644
--- a/mh/pick.c
+++ b/mh/pick.c
@@ -192,7 +192,7 @@ static struct mu_option options[] = {
   { ")",         0, NULL, MU_OPTION_ALIAS },
 
   MU_OPTION_GROUP (N_("Operations over the selected messages")),
-  { "list",      0, NULL, MU_OPTION_ALIAS,
+  { "list",      0, NULL, MU_OPTION_DEFAULT,
     N_("list the numbers of the selected messages (default)"),
     mu_c_bool, &list },
   { "sequence",  0, N_("NAME"), MU_OPTION_DEFAULT,
diff --git a/scheme/guimb.scmi b/scheme/guimb.scmi
index 45453cf..8a93b09 100644
--- a/scheme/guimb.scmi
+++ b/scheme/guimb.scmi
@@ -27,6 +27,7 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (list (command-line)))" "$@"
 
 (use-modules (ice-9 getopt-long)
 	     (ice-9 rdelim)
+	     (ice-9 eval-string)
 	     (srfi srfi-1)
 	     (mailutils mailutils))
 
@@ -190,7 +191,7 @@ for any corresponding short options.
     guimb-module)
 
 (define-macro (bound? name)
-  `(and (module-defined? guimb-module ',name)
+  `(and (module-defined? (get-module) ',name)
 	(procedure? ,name)))
 
 (define (guimb-parse-command-line cmdline)
@@ -219,17 +220,12 @@ for any corresponding short options.
     (if (not output-mailbox-mode)
 	(set! output-mailbox-mode (if (null? input-mailbox-names) "wr" "a")))
     
-    (cond
-     (user-name
-      (set! output-mailbox
-	    (mu-mailbox-open
-	     (if (string? user-name)
-		 (string-append "%" user-name)
-		 "")
-	     output-mailbox-mode)))
-     (output-mailbox-name
-      (set! output-mailbox (mu-mailbox-open output-mailbox-name
-					    output-mailbox-mode))))
+    (if (and (not output-mailbox-name) user-name)
+	(set! output-mailbox-name (if (string? user-name)
+			 (string-append "%" user-name)
+			 #f)))
+    (set! output-mailbox (mu-mailbox-open output-mailbox-name
+						    output-mailbox-mode))
 ;    (write output-mailbox)(newline)
 
     (if source-file-name


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 07 01:20:03 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c3dHn-0001Eg-53
	for mharc-commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:20:03 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59136)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c3dHk-0001EQ-HH
	for commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:20:01 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c3dHi-0000Af-H3
	for commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:20:00 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:59671)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c3dHi-0000AR-Cw
	for commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:19:58 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 3471D22016E; Mon,  7 Nov 2016 06:19:58 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-813-gf93a4f1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: fd19deb4391f18e1a752ae5cfe4a9d3155e97705
X-Git-Newrev: f93a4f1be0672e9a728bf28585e1c11a2e3306b4
Message-Id: <20161107061958.3471D22016E@vcs.savannah.gnu.org>
Date: Mon,  7 Nov 2016 06:19:58 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 07 Nov 2016 06:20:02 -0000

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=f93a4f1be0672e9a728bf28585e1c11a2e3306b4

The branch, master has been updated
       via  f93a4f1be0672e9a728bf28585e1c11a2e3306b4 (commit)
      from  fd19deb4391f18e1a752ae5cfe4a9d3155e97705 (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 f93a4f1be0672e9a728bf28585e1c11a2e3306b4
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Mon Nov 7 08:14:15 2016 +0200

    Version 3.0

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

Summary of changes:
 NEWS         |   23 ++++++++++-------------
 configure.ac |    2 +-
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/NEWS b/NEWS
index a3190d4..fe4c9c3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,16 +1,15 @@
-GNU mailutils NEWS -- history of user-visible changes. 2016-11-02
+GNU mailutils NEWS -- history of user-visible changes. 2016-11-06
 Copyright (C) 2002-2016 Free Software Foundation, Inc.
 See the end of file for copying conditions.
 
 Please send mailutils bug reports to <bug-mailutils@gnu.org>.
 
 
-Version 2.99.993 (Git)
+Version 3.0 - 2016-11-06
 
 This version is a major rewrite of GNU Mailutils.  Quite a few parts
 of the basic framework were rewritten from scratch, while some others
-undergone a considerable revamping.  The user documentation at the
-moment is insufficient, and in some aspects even scarce.  It is being
+undergone considerable revamping.  The documentation is still being
 worked upon.  However, most of the utilities self-document themselves.  
 To obtain a summary of available configuration statements for a given
 program, run `program --config-help'.  For additional documentation,
@@ -136,7 +135,7 @@ example:
   mail -A prog --encoding quoted-printable --content-type text/c \
        -A main.c -A ext.h
 
-Here, the file "prog" will be attached witg the content type
+Here, the file "prog" will be attached with the content type
 "application/octet-stream" and encoding base64, while the files
 "main.c" and "ext.h" will be marked with content type "text/c" and
 encoded using "quoted-printable" algorithm.
@@ -168,7 +167,7 @@ to the `return-address' variable, e.g.:
     
 ** MH: improved compatibility with other implementations
 
-** MH inc: new option --moveto
+** MH inc: new option -moveto
 
 This option instructs the utility to move incorporated messages into
 another folder instead of deleting them. It is implemented only for
@@ -198,11 +197,11 @@ option:
 
   moveto=FOLDER
     Moves incorporated messages into FOLDER.  This is similar to the
-    `--moveto' option, but applies only to that particular mailbox.
+    `-moveto' option, but applies only to that particular mailbox.
     See the example above.
     
   nomoveto
-    Disables the previous `--moveto' option.
+    Disables the previous `-moveto' option.
 
   truncate[=BOOL]
     Controls source mailbox truncation.  If BOOL is not given or is
@@ -298,9 +297,9 @@ options for particular interfaces.  For example, to build only GDBM
 ** Link with GSASL by default
 
 GSASL is used by several Mailutils components (notably pop3d
-and imap4d as well as their client counterparts) for authentification.
+and imap4d as well as their client counterparts) for authentication.
 Since this version, it is enabled by default if configure detects the
-presense of GNU SASL version 0.2.3 or later.
+presence of GNU SASL version 0.2.3 or later.
 
 This can be disabled using the --without-gsasl option.
 
@@ -349,7 +348,7 @@ transaction.
 
 This method copies the requested set of messages into another
 mailbox. It is accessed using the `mu_mailbox_msgset_copy' or
-`mu_mailbox_message_copy' functions.  So far it is implememented
+`mu_mailbox_message_copy' functions.  So far it is implemented
 only for IMAP and IMAPS mailboxes.
 
 ** MIME support improved.
@@ -812,8 +811,6 @@ New diagnostics functions are available, among them:
 A new header file, mailutils/diag.h, provides declarations for these
 and other related functions.
   
-See documentation (FIXME: Chapter?) for more information.
-
 The functions mu_error and mu_verror are shortcuts for
 mu_diag_output (MU_DIAG_ERROR, ...)  and mu_diag_voutput (MU_DIAG_ERROR, ...),
 correspondingly.
diff --git a/configure.ac b/configure.ac
index 92ac4a1..ac6d567 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.993], [bug-mailutils@gnu.org], [mailutils],
+AC_INIT([GNU Mailutils], [3.0], [bug-mailutils@gnu.org], [mailutils],
         [http://mailutils.org])
 AC_CONFIG_SRCDIR([libmailutils/mailbox/mailbox.c])
 AC_CONFIG_AUX_DIR([build-aux])


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 07 01:20:43 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c3dIR-0001Lp-9g
	for mharc-commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:20:43 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59228)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c3dIN-0001LW-8m
	for commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:20:42 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c3dIJ-0000cz-SC
	for commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:20:39 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:59687)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c3dIJ-0000cp-MS
	for commit-mailutils@gnu.org; Mon, 07 Nov 2016 01:20:35 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 9724122016E; Mon,  7 Nov 2016 06:20:35 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils annotated tag, release-3.0, created. release-3.0
X-Git-Refname: refs/tags/release-3.0
X-Git-Reftype: annotated tag
X-Git-Oldrev: 0000000000000000000000000000000000000000
X-Git-Newrev: f0339fbe9108a2201c24f316356d4a508378b221
Message-Id: <20161107062035.9724122016E@vcs.savannah.gnu.org>
Date: Mon,  7 Nov 2016 06:20:35 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 07 Nov 2016 06:20:42 -0000

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=f0339fbe9108a2201c24f316356d4a508378b221

The annotated tag, release-3.0 has been created
        at  f0339fbe9108a2201c24f316356d4a508378b221 (tag)
   tagging  f93a4f1be0672e9a728bf28585e1c11a2e3306b4 (commit)
  replaces  release-2.2
 tagged by  Sergey Poznyakoff
        on  Mon Nov 7 08:19:15 2016 +0200

- Log -----------------------------------------------------------------
Version 3.0 released
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)

iEYEABECAAYFAlggHOsACgkQNgKwf1XQxzLBSgCfYXl+0uuNQ0NfXWeChEkqXQV6
5hgAn3HLtHsPIYqgju2ptO7rZxZ6CjHt
=dbda
-----END PGP SIGNATURE-----

Damien Diederen (1):
      maildir: Keep trailing comma even when no flags are set

Sergey Poznyakoff (801):
      Stream support rewritten from scratch.
      Bugfixes.
      Bugfixes in stream code.
      Fix UNIX mbox driver and mail utility.
      Fix compilation of mimeview.
      Fix compilation of several example programs.
      Fix compilation of libmu_scm.
      Use stringrefs, add some guidelines for further editing.
      Keep track of the current offset in the _mu_stream structure.
      Bugfix in filter_iconv.
      Bugfixes
      Fix amd
      Optimize readline/readdelim/getdelim calls.
      Bugfixes.
      Improve CRLF filter.
      Simplify stream->seek.
      Fix conditional compilation.
      For alpha version, include git tag info in the version output.
      Make version output of the MH utilities more informative.
      Implement seek on filters in read-only mode.
      Bugfixes in stream-related code.
      Fix for mbox read/write consistency.
      Various fixes in imap4d.
      Bugfixes
      Fix readmsg.
      Bugfixes
      Fix base64 test.
      Fix decode2047 test.
      Fix encode2047 test.
      pop3d: bugfixes.
      Fix mime test.
      Further bugfixes.
      Fix mime creation and Sieve reject/redirect actions.
      pop3d: cleanup
      libmu_sieve: cleanup
      Bugfix.
      amd, pop3d: bugfixes.
      Re-implement server TLS support.
      Add a framework for printing I/O transcripts; modify pop3d to use it.
      Redo the support for transport-based streams.
      Implement an ioctl for replace bottom-level transport layers in a stream chain.
      Minor change.
      Port the new I/O scheme from pop3d to imap4d.
      Re-implement GSASL support.
      pop3d: optimize apop support.
      pop3d: bugfixes.
      Remove unused constants.
      Reorganize directory tree.
      Re-implement pop3 client functions.
      Fix TLS support in smtp.
      Further fixes in pop3.
      Minor change in stream API.  Improve POP3 client interface.
      Begin rewriting pop3 mailbox support. Several bugfixes.
      Further improvements in pop3client: readline & history.
      Implement "read cache" streams. Rewrite stdio and socket streams.
      Finish pop3 mailbox implementation.
      Improve transcript stream.
      Rename XSCRIPT_ macros to MU_XSCRIPT.
      Remove leftovers of ARG_LICENSE option from MH.
      Bugfix
      Optimize I/O bufferization.
      Version 2.2.90.
      Improve filter framework. Implement a CRLFDOT filter.
      Reimplement POP3 I/O over the DOT and CRLFDOT filters.
      Bugfix
      amd: bugfix.
      movemail: bugfix.
      Mailbox quota support in imap4d: initial implementation.
      Optimize stream seeks and I/O.  Expand stream event handlers.  Rewrite xscript stream.
      Rewrite Sieve testssuite in Autotest.
      Remove files that are not necessary any more.
      Rewrite frm testsuite in Autotest.
      Rewrite readmsg testsuite in Autotest.
      Rename mailbox/ to libmailutils/.
      Rewrite libmailutils testsuite in Autotest.
      Rewrite testsuite for messages in Autotest.
      Bugfix.
      Optimize libmailutils testsuite.
      libmailutils/tests: test list and iterator operations.
      Implement `remove' method for mailboxes.
      Minor fix.
      Test mailbox deletion.
      Further improvement of the testsuite + some bugfixes.
      testsuite: recreate missing maildir entries
      Update for gnulib v0.0-4270-g18aae5b.
      Begin new implementation of the SMTP client.
      Bugfixes in the sieve testsuite.
      smtp client: implement more functions.
      Implement SMTP AUTH (via GSASL).
      * testsuite/smtpsend.c (main): Retry ehlo after successful authentication.
      Bugfix.
      Avoid unnecessary rebuilds of git-describe and git-describe.h
      Bugfixes.
      Improve authentication interface in SMTP client.
      Bugfix in message_stream.c
      Stream improvements.
      Improve smtp sending functions.
      Rewrite SMTP mailer.
      Various SMTP improvements.
      Minor changes.
      Fix hex (%XX) expansion in URLs.
      Add back testsuite/etc/DISTFILES.
      Finish switching to new gnulib (see 52d2552d23).
      Bugfixes.
      Cleanup in bufferization code.
      Remove unnecessary use of FILEs in imap4d and pop3d.
      Fix prog streams.
      Redo the code for installing tls/sasl transport streams.
      Disable installchecks for sieve.scm.
      Fix the SMTP SASL (client) without trace.
      Improve stream creation consistency.
      New utility: mu
      Bugfix.
      Bugfix.
      Fix docstrings in mu.
      Improve path parsing in mu_cfg_find_node.
      New mu submode: acl.  Supersedes examples/aclck.c
      Minor bugfixes.
      Remove the use of MAXHOSTNAMELEN macro.
      Implement pager in mu shell.
      Implement echo control on fd streams.  Implement mu_getpass function.
      Add a missing function.
      Minor bugfixes in pop client code.
      Improve mu shell interface.
      Minor changes.
      Improve scripting in mu pop shell.
      Fixes in stream subsystem.  Rewrite and optimize maidag lmtp mode using streams.
      Implement a filter for quoting ^From.  Use it for appending to UNIX mailboxes.
      Fix a silly copy-paste error.
      Improve maidag, add testsuite.
      Maidag cleanup
      maidag: remove `default' mode (superseded by --mda).
      maidag: optimize mda mode.
      Improve mta simulator output.
      maidag: improve forwarding capability, add a testcase for it.
      examples/mta.c: use streams instead of FILE; exit with codes from sysexits.h
      mu: compile pop support conditionally.
      Reorganize libmailutils directory structure.
      Fix copyleft notices to follow the GNU standards.
      Split the mess in mutil.c into logically separated units.
      Rename mu_strcasestr to mu_c_strcasestr.
      Minor fix
      Use mu_make_file_name where necessary.
      Improve mu_unroll_symlink interface.
      maidag/tests/forward.at: forgotten to add (see db1ee5e0a).
      movemail: accept "smtp://" and "sendmail://" as a destination mailbox.
      Improve the algorithm of obtaining sender name from messages.
      Provide an easy way of setting sender/recipient addresses in smtp URLs.
      Improve registrar/url interaction.  Fix SMTP URLs to comply to draft-earhart-url-smtp-00.  Minor fix in maidag (url mode).
      Allow for `notls' parameter in pop URLs.
      Improve SMTP client.
      Improve the algorithm for URL look up in wickets.
      New `mu' mode: wicket.
      Move `mailutils-config' functionality to `mu'.  Retain `mailutils-config' for backward compatibility.
      Improve URL matching code.
      Minor fix.
      Rewrite URL support.
      Version 2.9.90
      Remove tcp wrapper configuration keywords that did not actually change anything.
      Use mu_asprintf and mu_vasnprintf instead of asprintf and vasprintf.
      Fix allowed URL parts for local mailboxes.
      Add wordsplit module.
      Merge branch 'master' of ssh://git.savannah.gnu.org/srv/git/mailutils
      Fixes in wordsplit.  Use wordsplit instead of vartab in movemail.
      Implement a Key/Value environment.
      Use wordsplit to expand command prompt in mu.
      Remove all uses of vartab, replacing them with wordsplit.
      Minor changes.
      Use full buffering for streamrefs.
      Minor change.
      Remove the --license option.
      Improve command module system in mu.  Add a `help' command.
      Begin imap client implementation.
      Fix the "UNIX mailbox first message symptom".
      Make sure stream->offset points to the position in stream corresponding to the start of the buffer.
      imap client: implement login and id commands.
      filter subsystem: bugfixes.
      attachment.c: redesign/simplify using the new API.
      Improve stream statistics interface. Introduce "null stream".
      mhn: optimize using new API.
      Add MH testsuite.
      mhl: Improve backward compatibility.  Provide a test case.
      anno: Minor improvements.
      Document null streams
      Minor fix in the test suite.
      pick: improve compatibility.
      mh: improve traditional option parser and help output.
      mh: improve GNU option parser and help output.
      mh: Add new tests.
      mh: fix testsuite, add new tests.
      message_stream: Bugfix
      mh: fix burst, provide test cases.
      mh: rmm now saves state before returning
      mh: minor fix in traditional option handler
      mh: further fixes in burst testsuite.
      mh: Optimize for speed.
      Implement "inline-comment" filter.
      mh: implement prompter
      Minor fix.
      mh: Minor fixes.
      Rewrite property support.
      Re-implement MH sequences via mailbox properties.
      Move MH profile & context support to libproto.
      mh: improve component reading (profile, context and whom).
      mh: Fix compatibility issues in the draftfolder facility. Implement whatnowproc.
      mh: fix msgset parser and some more comp compatibility issues; provide testsuite for comp.
      Provide a library function for translating message UIDs to numbers and vice versa.
      mh: improve forw; add tests.
      mh: add repl tests.
      mh: implement rmmproc.
      Fix body start calculation in message_stream. Fix compose parser in mhn.
      New type of stream: static memory stream.
      mh: fix the use of mhl.forward in forw.
      wordsplit: fix whitespace trimming.
      mh: set a compatible search path for format files; other minor fixes.
      mh: move format files to a separate directory.
      mh: minor changes in forw and repl; provide a set of traditional scan formats.
      mh: add a forgotten file.
      mhn: minor changes.
      Rewrite temporary file handling.
      temp_file_stream: Use mu_tempfile_hints to control how the file name is created.
      Remove obsolete function.
      mhn: implement mhn-suffix-<type> profile component.
      mhn: minor improvements
      mh: improve mhn store mode.
      mh: further improvements in mnh & mh testsuite.
      mhn: compatibility fixes in show mode.
      Minor fixes.
      streams: fix mu_stream_wait operation for buffered streams
      mh: improve testsuite.
      mhn: minor fix in edit mode.
      mime creation: bugfixes.
      mhn: fixes in compose mode.
      Minor fix in libstring
      Bugfix in libstream
      send: fix draftfolder support; add testsuite
      sortm: update current message number; add testsuite.
      imap4d: rewrite subscription support from scratch.
      Minor fix.
      imap4d: various fixes.
      Revise TODO.
      sieve: rewrite lexer to use MU streams API.
      Fixes in message_stream.
      Avoid using strtok(_r)
      Minor change.
      Improve the inline-comment filter.
      mail: further improvements in quoting code.
      streams: introduce setbuf hooks.
      streams: introduce setbuf hooks.
      Initial implementation of log streams.
      Introduce stdstream module; move deprecated functions to libmu_compat.
      mu: use stdstream functions.
      Remove deprecated interfaces.
      Rewrite debugging and logging support.
      mh: testsuite fix.
      Merge branch 'master' of ssh://gray@git.sv.gnu.org/srv/git/mailutils
      Improve imap4d and pop3d testsuites.
      Merge branch 'master' of ssh://gray@git.sv.gnu.org/srv/git/mailutils
      Implement severity suppression in log streams; other minor fixes.
      Revise stream ioctl support.
      frm,messages,readmsg: Use MU streams instead of stdio.
      Implement a "line continuation" filter.
      comsat: minor changes
      file_stream: Bugfixes
      comsat: Use mu streams instead of stdio
      Rewrite prog stream support.
      comsat: add a way to specify alternative biffrc file name; new biffrc statement: tty
      comsat: improve tty handling, add testsuite.
      comsat: improve biffrc evaluation.
      Implement line number output in linecon and inline-comment filters.
      Test line info facility
      Minor improvements in logstream and related code.
      comsat: provide a fine-grained control over where biffrc errors are output
      Minor improvement
      Implement filter chains. Revamp filter output length support.
      Remove MU_STREAM_AUTOCLOSE flag.  Use mu_stream_unref, if necessary.
      Remove the MU_STREAM_FD_AUTOCLOSE stream flag.
      Implement mu_onexit functions; use MU stdstream in mh and mimeview.
      Minor change.
      mail: rewrite using MU streams.
      mail: use mu_strout; remove util_error in favor of mu_error.
      mh,maildir: Minor fix.
      Minor fixes.
      Remove an ugly debugging hack.
      Re-implement iconv convertor as a regular filter.
      Remove mu_filter_iconv_create.
      Remove the leftovers of mu_debug_t and obsoleted sieve interfaces.
      Mark unfinished interfaces as experimental so they're not built by default.
      Improve debugging in the category "auth".
      Minor change
      sieve: improve moderator extension.
      libmu_sieve: minor fix.
      sieve: improve "pipe" action, implement "pipe" test.
      Minor fixes.
      maildir: speed up mailbox scanning
      Update TODO
      Assorted changes
      Minor fixes.
      Pop3-client bugfixes (mostly).
      sieve: implement an option to add directory to the head of the library search path.
      Set library version to 4:0:0
      sieve: bugfixes
      filter stream: make sure all input data get processed.
      Minor fixes
      Bugfixes.
      Improve debugging; fix c522de119a.
      Improve debug parser and output functions.
      sieve: test "list" extension test.
      Bugfixes.
      Follow-up to the previous commit.
      mail: fix the "shell" ("!") command.
      Bugfixes
      Bugfixes.
      mailer: minor improvement
      movemail: various improvements.
      mailbox iterator: implement reverse direction and itrctl.
      Bugfix (complements 6bd92d3c07).
      movemail: minor improvements.
      Minor bugfix
      pop client and movemail: bugfixes
      Bugfixes.
      vacation: remove dependency on DBM; other minor fixes.
      Various fixes
      mh,maildir: speed up scanning.
      imap4d: speed up asynchronous mailbox notifications.
      frm: minor cleanup.
      Bugfixes.
      Make sure debugging calls don't dump core even if mu_strerr is not initialized.
      amd: bugfixes; speed up expunging.
      Provide a function for quick retrieval of message lines.
      imap4d: bugfixes.
      imap4d: further improvements.
      Remove guimb.
      Update copyright years.
      Minor changes in scheme-related code.
      Reincarnate guimb as a pure Scheme program.
      guimb: further improvements
      imap4d: complement 435f1918df.
      imap4d: don't issue spurious unsolicited responses after EXPUNGE.
      imap4d: redo signal handling
      libmailutils: bugfix
      Add useful debugging hooks.
      Bugfix
      Scheme: add primitives for manipulating the MU debug levels.
      Minor changes.
      Bugfixes
      mu: improve query interface.
      Introduce "parser hints", to provide better control over configuration parsing.
      Simplify mu_cfg_tree_reduce.
      New global variable mu_site_rcfile keeps the name of the site-wide configuration file.
      mail: bugfix
      message_stream: deduce default envelope address from the current user email
      Bugfixes.
      More bugfixes.
      New filter "c-escape".
      Minor fix
      Implement IPv6 support.
      Bugfix
      New configuration options to disable groups of utilities.
      Version 2.99.90
      cidr: Implement simplified IPv6 formats
      Bugfixes
      Bugfixes.
      Various minor fixes.
      imap4d: bugfix
      Minor fix.
      Fixes.
      Allow caller to set up custom in,out,err,progname,tag before calling mu_app_init.
      Bugfix.
      Implement optional mailbox-independent locking for pop3d and imap4d.
      Version 2.99.92
      Bugfixes.
      Minor change
      Fake commit to test whether git mail notification works.
      Various bugfixes.
      Bugfixes
      Improve mime support, introduce ref/unref functions for mu_message_t and mu_mime_t.
      Version 2.99.93
      Minor fix.
      Minor fix
      Make sure header reads always return the trailing \n, even for empty headers.
      Fix testsuite.
      Fix generation of the doc files.
      Minor fix.
      Minor changes.
      Bugfix
      imap4d: fix returned INTERNALDATE and date searches.
      Bugfixes.
      mh: open mailboxes in read-only mode unless the requested operation mandates otherwise.
      Minor changes, proposed by Jordi Mallach.
      Provide a mechanism for configurable file safety checking.
      File safety checks: Implement "default" keyword
      Bugfix.
      Change attribute handling in Maildir format.
      amd: report MU_EVT_MAILBOX_CORRUPT if unable to rename message file due to ENOENT
      Testsuite: add banners before groups of related tests.
      Fix locking in pop3 and imap4d.  This complements d0769b4f.
      Make all status flags permanent.
      Fixes in the testsuite & some minor fixes.
      Minor change.
      imap4d: fix reading multi-line literals
      Complement 1e33c774.
      Simplify mu_file_safety_check call.
      Reimplement DBM support.
      Use MU_CTYPE_ENDLN to trim \r\n.
      Add testcases for file safety checking functions.
      New interface for composing URLs from parts.
      pop3d: configurable APOP file and safety criteria.
      Reorganize error codes.
      Minor change
      inline-comment: bugfixes.
      cctype: bugfix.
      Introduce a better dbm dump format.
      mu dbm: improve command line interface.
      mu dbm: minor fix
      Minor changes.
      Fix TLS usage.
      Implement error_string method in TLS streams.
      Implement pop3s and imap4s in respective servers.
      Fix MU_EVT_MESSAGE_ADD in pop://
      Write NEWS article describing the recent changes.
      Update docs + minor changes.
      Minor fix.
      Version 2.99.94.
      Bugfix
      Minor changes in diagnostic messages.
      spamd sieve test: bugfix.
      Minor change
      Implement _dbm_get_fd in Kyoto cabinet.
      Merge branch 'master' of ssh://gray@git.sv.gnu.org/srv/git/mailutils
      Minor fix
      Minor change
      Minor changes.
      Import error codes directly from libmailutils to Python.
      Improve wordsplit.
      Implement IMAP I/O functions for client and server.
      Implement mu_imapio_reply_string function.
      Rewrite existing imap client support using imapio.
      Move list support into a separate convenience library.
      Implement list mapping.
      imap client: redo capability and id support via list mappers.
      imap client: implement select/examine.
      imap client: implement status command
      Rename mu_list_do to mu_list_foreach.  Add comments to mailutils/list.h
      Implement general-purpose processing of unsolicited responses in imap client.
      Imap client: fix status implementation.
      Implement list slicing functions.
      wordsplit: implement separate single- and double-quote parsing.
      libmu_dbm: Functions for DB creation take default safety flags in their last argument.
      Version 2.99.95
      Implement new DBM dump format.
      Bugfixes.
      Enable GSASL by default.
      tls: do not generate DH params.
      wordsplit: add incremental mode.
      wordsplit: minor fix in return_delims mode
      imapio: improve getline parser
      imap client: reflect changes to imapio parser.
      list: new operations: head and tail.
      Change callback handling in imap client.
      Process untagged responses synchronously.
      Minor change.
      imap client: implement noop.
      Minor change.
      Improve IMAP I/O module.  Add testcase.
      Add a test for non-synchronized imap literals.
      Change callback signature in imap client.
      imap4d: Fix the functionality of FETCH BODY sections HEADER, TEXT and MIME.
      imap4d: fix FETCH (BODYSTRUCTURE)
      imap4d: rewrite testsuite in Autotest.
      imap4d: reimplement append tests.
      Minor fix
      imap4d: reimplement fetch tests in Autotest.  Remove DejaGNU-based testsuite.
      Fix a bug in imap4d parser, add more tests.
      Update ignored file list.
      Imap4d: fix handling of nested message/rfc822 parts.
      Bugfix.
      imapio: fix payload tracing and handling of continuation responses
      Add a function for creating an empty email address object.
      imap client: initial implementation of fetch.
      Clean-up state changes in imap client.  Fix error handling in it and in pop3.
      Implement list folding functions.
      imap client: improve parsing of BODY[] items.
      Implement list sorting.
      MH: minor change in folder
      mail: Use new list functions to simplify vartab-related operations.
      Split ibmailutils/mailbox/message.c into logically separated and
      Implement locale-independent strftime function.
      Implement mu_scan_datetime.
      Bugfixes.
      Implement LIFO access functions for lists.
      Use list LIFO access where appropriate.
      Improve mu_scan_datetime
      Minor change
      imap4d: CLOSE should not send EXPUNGE responses. Fix error checking in STORE.
      imap client: implement STORE, DELETE, RENAME, CHECK, EXPUNGE, COPY, CLOSE and UNSELECT.
      Merge branch 'master' of ssh://git.savannah.gnu.org/srv/git/mailutils
      imap client: implement CREATE and APPEND. Fix APPEND in imap4d.
      Move date/time declarations into a separate header: mailutils/datetime.h
      Revamp date/time calculations.
      Bugfixes.
      Rename mu_tm2time to mu_datetime_to_utc.
      New function mu_datetime_tz_local.
      Use UTC in From_ separators in accordance with RFC 4155.
      Bugfix in mu_list_sort.
      Make sure mu_mailbox_get_message returns MU_ERR_NOENT if the requested message number is not found in the mailbox.
      Redo message set parser in imap4d
      imap4d: remove functions duplicated in the library
      Bugfix in libmu_sieve.
      Fix UID generation in mboxes (complements f9a034c7)
      Bugfix in imap4d.
      Initialize standard I/O streams statically.
      Fix declaration of mu_sieve_vlist_do in libmu_sieve.
      Fix possible output buffer overflow in base64 encoder.
      Minor changes.
      Bugfixes.
      Imap client: implement list.
      Imap client: quote command arguments as necessary.
      Imap client: Implement SUBSCRIBE and UNSUBSCRIBE.
      Imap client: implement LSUB.
      Imap client: implement starttls.
      Implement UID command in mu imap
      imap client: implement folder API.
      Minor cleanup in imap client.
      Share folder implementation between mbox, mh and maildir.  Fix mu_folder_delete.
      Add a test suite for folder delete method.
      Provisions for loading python modules from the source tree.
      Use IMAP-stile wildcards in folder matchers by default.
      Fix the use of the hierarchy delimiter.
      Move Python support from experimental to stable features.
      Re-implement parser for RFC-2231 header fields.
      Bugfix.
      imap4d: Fix fetch in case of message/rfc822
      Fix API for obtaining full email address.
      Implement imap (client) bodystructure and envelope.
      mu imap: implement copy command.
      Bugfixes in imap client.
      Implement imap mailbox (read-only, so far).
      Finish imap mailbox implementation.
      Minor fixes in imap.
      imap mbox: minor improvements.
      Add functions for operations on message sets.
      Bugfix.
      Use mu_msgset_t in imap client for FETCH, STORE and COPY.
      Use mu_msgset_t in imap4d.
      Update TODO.
      msgset: implement "foreach" calls.
      Improve msgset interface.  Use it in MH.
      Fix a bug in DOT decoder.
      Add SMTP test.
      Implement SMTPS.
      Happy GNU Year
      Bugfix in the testsuite.
      Restore extra quoting in test mhn-store-pipe of mh/tests/mhn.at
      Assorted fixes.
      Bugfix in the testsuite.
      Minor fix.
      Bugfix.
      Bugfixes.
      Fix parsing local URLs.
      Fix locking of Berkeley databases.
      Bugfix.
      Fix compilation of pop3d and maidag without DBM.
      Fix the use of struct utmp/utmpx in comsatd.
      mail: Implement folder completion in "save"
      Fix creation of Berkeley db files.
      Minor fix in smtp transport.
      Implement session ID for TCP/UDP servers.
      mh: minor fix in reply formats
      Add missing includes
      Bugfix.
      Improve conversion between file mode and safety criteria and vice versa.
      Minor fixes.
      Fix semantics of MU_IOCTL_SUBSTREAM.
      Minor changes.
      Revise some memory allocation routines.
      Fix SMTP test on machines with IPv6 enabled.
      Bugfixes.
      Avoid using expr in tests with ulong as its argument.
      Minor fix
      Implement a copy method in mailbox.
      Minor fix
      Remove get_stream methods from folder and mailbox.
      Fix quoted-printable and Q encodings.
      Fix handling of URL authentication credentials in SMTP AUTH.
      Fix SMTP STARTTLS and SMTPS
      Ninor change in bootstrap.
      Bugfix in imap4d testsuite.
      inc: accept mail from multiple source mailboxes.
      Update ignore lists.
      Fix typos in the generated ChangeLog.
      Update root ignore list.
      Bugfix
      Don't use disabled features in mailutils.scm
      Fix comsat testsuite.
      Implement two new Scheme functions.
      Fixes: port cfg statement, listen cfg statement in maidag, final dot recognition in maidag.
      Minor fix.
      Fix bug in mh testsuite.
      Fix in configuration reduction routines.
      Fix a typo.
      inc: bugfix
      Bugfix.
      Remove dependency on getline.
      Remove dependency on obstack. Use mu_opool_t instead.
      Improve configuration options.
      Upgrade imprimatur module.
      Spelling fixes.
      Implement --attach option in mail; fix dead.letter functionality
      mail: provide mechanism for listing and editing attachments from the shell
      Minor fix
      pop3d: make tls more configurable
      Minor changes in SMTP and URL code.
      Drop a superfluous dependency on libgcrypt.
      Implement SMTP shell in mu.
      Port 0b1e16bea to imap4d
      Ensure consisten stream state before calling its ctl method.
      mailutils-config: reflect eventual rename of mu, so that AM_GNU_MAILUTILS works.
      Fix a typo.
      mail: provide a way to set return address.
      Improve header stream write method.
      Implement editheader sieve extension (RFC 5293).
      Minor fixes.
      Bugfix.
      Make sure modifications to a message or its parts become visible in the message stream.
      ali: executable file inclusion.
      Raise version number
      Bugfix.
      Fix interaction with POP3 servers that do not support the CAPA command.
      Do not ask for ESMTP credentials if unable to handle them.
      Fix the use of localname and localdomain in ~/.mtstailor.
      Implement msgchk
      Implement IMAP SEARCH. New function mu_mailbox_access_time.
      Minor fixes.
      msgchk: assume -date by default
      Bugfix.
      MH: Synchronize sequences after removal of messages.
      Minor fix in docs
      Rewrite mu_utc_offset in a more portable (hopefully) way.
      MH send: improve compatibility with MH/nmh.
      Add support for Unseen-Sequence in inc.
      Fix MH sequence parser.
      Implement MH show utility.
      Minor fixes
      Bugfixes.
      One more fix.
      Support for RFC 3206
      Bugfix in LDAP code.
      Fix tls_required functionality in imap4d
      Bigfixes.
      Fix appending to IMAP[S] mailboxes
      Minor fix in mh/inc
      Fix bug in handling AUTHENTICATE command (imap4d). Add user/group ACLs.
      Issue a deprecation warning if tls-required is used in pop3d or imap4d config
      Fix coredump if crypt returns NULL.
      Use global TLS setting in inetd mode (bug #40891)
      Update copyright years.
      Move biff notification to the library.  Implement it in inc and movemail.
      Accept single-dash notify option to inc
      Use AM_CPPFLAGS instead of INCLUDES; upgrade gint
      Clean up unused variables.
      Improve tls support
      imap client: fix handling of ID response without untagged part
      Fix compilation without gnutls
      frm: fix counters when given multiple mailboxes.
      Bugfixes.
      New filter: htmlent
      Implement the xml filter.
      Fix memory overrun in iconv filter.
      New example: mboxidx
      Push missing files.
      Bugfix.
      Bugfixes.
      Move gnulib into a subdir.
      Add scripting capability to mh/inc.
      imap-related bugfixes.
      Fix possible coredump in stream library.
      Fix eventual memory overrun
      Fix the use of erad-only maildir folders. Imap4d improvements.
      Improve diagnostics in maildir
      New function mu_fgetpwent_r.
      Fix alignment issues in fgetpwent_r
      Update copyright years
      Switch to Texinfo 5.0
      Bugfixes.
      Honor MAIL and FOLDER envars if _mu_mailbox_pattern is not set.
      mail: honor columns/screen variables
      Fix doc generation.
      readmsg: minor fix
      Minor change.
      mail: the "copy" command operates on files by default.
      mail: add tests in a non-interactive mode
      Minor fix
      Fix improper padding in B encoding
      Minor fixes in Scheme scripts
      Make libmuaux installable shared library.
      Add gnulib as a module
      Bigfixes.
      Fix segfault when destroying mu_body_t under certain conditions
      Minor fix
      Fix double-inclusion of config.h in some sources
      python: fix passing size_t values on 64-bit architectures
      python: fix returning size_t values.
      python: cleanup
      Fix compilation warnings
      Bugfix
      Minor fix
      Version 2.99.99
      Bugfix
      Minor changes
      Compatibility fix.
      Fix make check if MU_DEFAULT_SCHEME value is other than mbox
      Fix TLS streams
      Minor fixes
      Log ciphersuite info after successful initiation of TLS connection
      Update NEWS
      Bugfix
      Spelling fixes in ChangeLog
      Fix typos
      Port wordsplit from grecs 20616b88
      Complement f160ca75
      Document mailbox types, variable extension, etc.
      Fixes in sieve vacation extension
      Vacation: improve compatibility with the Sendmail utility.
      Minor fixes in Makefiles.
      Bugfix
      Improve debugging
      Maidag: avoid using auth_by_uid when delivering message.
      Minor fixes.
      User-defined headers in vacation extension
      vacation: read message body from the file
      Document Sieve extensions
      Fix linking
      Minor changes.
      Minor fix
      Bugfix in wordsplit test program
      Update copyright years
      Fix build without tcpwrappers
      Minor fix
      Gracefully handle empty mailboxes in mu_msgset_parse_imap
      Revert changes to msgset test utility.
      Fix memory allocation in libmu_imap
      mh: fix the -nowhatnowproc option
      Fix docstrings for -nowhatnowproc
      Force using gnu-mh in Emacs after loading mailutils-mh
      Minor fixes
      Allow to configure the length of the backlog queue for TCP servers
      Bugfixes
      Add generic library for option parsing.
      Use mu_c_type_t throughout the code.  Get rid of mu_cfg_param_data_type.
      Fix mu_parseopt. Add testsuite for it.
      Fix help output.  Test it.
      Add missing test
      Raise shared library version number
      Introduce new CLI/configuration code for mailutils applications.
      Bugfix
      Convert to mu_cli: frm, from, messages, mimeview, movemail, readmsg, sieve
      Fix some incompatibilities in the previous commit.
      Bugfixes in libmailutils/opt/opt.c
      Implement simple word-wrapping stream
      Rewrite parseopt help routines using wordwrap streams
      Allow for multiple argument sets in help output.
      Convert mail to mu_cli
      Minor fix in help output.
      Convert examples to mu_cli
      Convert comsat to mu_cli
      Convert maidag to mu_cli
      Convert popauth to mu_cli
      Convert pop3d to mu_cli
      Convert remaining utilities (except mh) to mu_cli.
      Rename MU_APP_NEW_LIBRARIES back to MU_APP_LIBRARIES. Version 2.99.991.
      Minor fix
      Minor fix
      Minor fix in wordwrapper stream
      Support for single-dash long options (as in MH) and negation for boolean options.
      Begin rewriting MH to get rid of argp stuff.
      Finish conversion of MH utilities to mh_parseopt
      MH: Fix MH-E compatibility
      Bugfixes
      Provide extended interface to mu_cli.
      Bugfixes
      Bugfix
      Improve program usage output.
      Bugfix
      Bugfix
      Remove left over references to argp; other bugfixes
      Minor changes
      Remove old compatibility quirks
      Improve opool API
      Minor fix
      Bugfixes in MH
      Fix in logstream
      Improve configuration file handling.
      Rename default configuration file
      Bugfix
      Fix docs. Change argument of the field-map configuration statement
      Fix operation of mail -t; some other minor fixes
      Minor changes
      Add missing documentation
      Fix option sorting.
      Version 3.0

Wojciech Polak (11):
      Update C++ API and the examples.
      Update Python API and the examples.
      Minor PEP 8 changes in Python API.
      Remove more old debug leftovers from the Python interface.
      Re-add Tokyo Cabinet DBM support.
      Fix typos.
      Add Kyoto Cabinet DBM support.
      Update Python interface.
      Improve Python API. Add MemoryStream class.
      Update the NEWS file.
      Update C++ and Python interfaces.

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


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 10 00:47:08 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c4iCa-0002GT-FS
	for mharc-commit-mailutils@gnu.org; Thu, 10 Nov 2016 00:47:08 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38177)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c4iCX-0002GK-T9
	for commit-mailutils@gnu.org; Thu, 10 Nov 2016 00:47:06 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c4iCW-0007r6-Qy
	for commit-mailutils@gnu.org; Thu, 10 Nov 2016 00:47:05 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:39033)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c4iCW-0007r2-N8
	for commit-mailutils@gnu.org; Thu, 10 Nov 2016 00:47:04 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 43F90220170; Thu, 10 Nov 2016 05:47:04 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-1-gf674702
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f93a4f1be0672e9a728bf28585e1c11a2e3306b4
X-Git-Newrev: f674702867f09a3e2b8ebe3281a29cd9f660f29a
Message-Id: <20161110054704.43F90220170@vcs.savannah.gnu.org>
Date: Thu, 10 Nov 2016 05:47:04 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Nov 2016 05:47:07 -0000

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=f674702867f09a3e2b8ebe3281a29cd9f660f29a

The branch, master has been updated
       via  f674702867f09a3e2b8ebe3281a29cd9f660f29a (commit)
      from  f93a4f1be0672e9a728bf28585e1c11a2e3306b4 (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 f674702867f09a3e2b8ebe3281a29cd9f660f29a
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Thu Nov 10 07:45:08 2016 +0200

    Fix program name duplicate in the output of "mailutils help COMMAND"

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

Summary of changes:
 mu/help.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mu/help.c b/mu/help.c
index c2dcf1a..14fae20 100644
--- a/mu/help.c
+++ b/mu/help.c
@@ -35,15 +35,17 @@ mutool_help (int argc, char **argv)
 
   if (argc == 1)
     {
+      char *hargv[3];
       mutool_action_t action = dispatch_find_action (argv[0]);
       if (!action)
 	{
 	  mu_error (_("don't know what %s is"), argv[0]);
 	  exit (1);
 	}
-      mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[0]);
-      argv[1] = "--help";
-      return action (2, argv);
+      hargv[0] = argv[0];
+      hargv[1] = "--help";
+      hargv[2] = NULL;
+      return action (3, hargv);
     }
   else if (argc > 1)
     {


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 11 04:00:37 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c57hN-0000Ws-FU
	for mharc-commit-mailutils@gnu.org; Fri, 11 Nov 2016 04:00:37 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42166)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c57hI-0000WZ-1Y
	for commit-mailutils@gnu.org; Fri, 11 Nov 2016 04:00:36 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c57hH-00054f-1r
	for commit-mailutils@gnu.org; Fri, 11 Nov 2016 04:00:32 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:53855)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c57hG-00054Z-Uz
	for commit-mailutils@gnu.org; Fri, 11 Nov 2016 04:00:30 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 9B0B3220170; Fri, 11 Nov 2016 09:00:30 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-2-gaba91e5
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f674702867f09a3e2b8ebe3281a29cd9f660f29a
X-Git-Newrev: aba91e51a9d91c0abef4db78ac4a52c543432bee
Message-Id: <20161111090030.9B0B3220170@vcs.savannah.gnu.org>
Date: Fri, 11 Nov 2016 09:00:30 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Nov 2016 09:00:36 -0000

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=aba91e51a9d91c0abef4db78ac4a52c543432bee

The branch, master has been updated
       via  aba91e51a9d91c0abef4db78ac4a52c543432bee (commit)
      from  f674702867f09a3e2b8ebe3281a29cd9f660f29a (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 aba91e51a9d91c0abef4db78ac4a52c543432bee
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 11 10:57:36 2016 +0200

    mhn: restore -compose mode as default

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

Summary of changes:
 gint     |    2 +-
 mh/mhn.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gint b/gint
index 42f4712..fd86bf7 160000
--- a/gint
+++ b/gint
@@ -1 +1 @@
-Subproject commit 42f4712085b40173eaea58e14b1a579291a6fe3a
+Subproject commit fd86bf7d44b0c970771830692ae7491447ebe8b1
diff --git a/mh/mhn.c b/mh/mhn.c
index 2ebd8c3..9fcb83d 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -2766,7 +2766,7 @@ main (int argc, char **argv)
     pause_option = 0;
 
   if (!compose_option && !list_option && !show_option && !store_option)
-    show_option = 1;
+    compose_option = 1;
   
   signal (SIGPIPE, SIG_IGN);
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 14 08:54:47 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c6Hih-0002Kb-6j
	for mharc-commit-mailutils@gnu.org; Mon, 14 Nov 2016 08:54:47 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34259)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c6Hic-0002Ht-7K
	for commit-mailutils@gnu.org; Mon, 14 Nov 2016 08:54:45 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c6HiZ-0003kN-27
	for commit-mailutils@gnu.org; Mon, 14 Nov 2016 08:54:42 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:37325)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c6HiY-0003kF-T3
	for commit-mailutils@gnu.org; Mon, 14 Nov 2016 08:54:38 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 8E22C220179; Mon, 14 Nov 2016 13:54:38 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-3-ga04c6fe
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: aba91e51a9d91c0abef4db78ac4a52c543432bee
X-Git-Newrev: a04c6feb5007aeeb133b15558f13733743dee3e8
Message-Id: <20161114135438.8E22C220179@vcs.savannah.gnu.org>
Date: Mon, 14 Nov 2016 13:54:38 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 14 Nov 2016 13:54:45 -0000

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=a04c6feb5007aeeb133b15558f13733743dee3e8

The branch, master has been updated
       via  a04c6feb5007aeeb133b15558f13733743dee3e8 (commit)
      from  aba91e51a9d91c0abef4db78ac4a52c543432bee (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 a04c6feb5007aeeb133b15558f13733743dee3e8
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Mon Nov 14 09:34:57 2016 +0200

    Fix expansion of #, &, %, etc. in mail copy and file commands.
    
    This was accidentally broken by commit eea2c4aa.
    
    * include/mailutils/mailbox.h (mu_mailbox_expand_name): New proto.
    * libmailutils/mailbox/mbx_default.c (mu_mailbox_expand_name): New function.
    (mu_mailbox_create_default): Use it.
    (mu_set_folder_directory): Accept NULL as argument.
    (mu_folder_directory): Reset default value after assiging it.  This way
    the folder directory still defaults to the same value as earlier, but
    can be reset to NULL, if so desired.
    (plus_expand): Return a copy of the input string if folder is NULL.
    
    * mail/copy.c (append_to_mailbox): Use mu_mailbox_create, as the mailbox
    name has already been expanded.
    * mail/file.c (mail_expand_name): Use mu_mailbox_expand_name.
    (mail_file): Use mu_mailbox_create, as the mailbox
    name has already been expanded.
    * mail/mailvar.c (mailvar_cmd): New enum.
    (mailvar_symbol) <handler>: Change signature and return type.
    (mailvar_set): Rewrite. Take care not to modify the variable
    if the handler (if any) returns non-null or if the memory can't
    be allocated.
    (set_folder): Handler for the "folder" variable.
    
    * mail/tests/copy01.at: New testcase.
    * mail/tests/copy02.at: New testcase.
    * mail/tests/copy03.at: New testcase.
    * mail/tests/copy04.at: New testcase.
    * mail/tests/Makefile.am: Add new tests.
    * mail/tests/testsuite.at (MUT_MAIL_CMD): Set MAILRC to /dev/null.
    Add new tests.

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

Summary of changes:
 include/mailutils/mailbox.h         |    2 +
 libmailutils/mailbox/mbx_default.c  |  201 ++++++++++++++++++++---------------
 mail/copy.c                         |    4 +-
 mail/file.c                         |   47 ++++----
 mail/from.c                         |    4 +-
 mail/mail.c                         |    1 +
 mail/mail.h                         |    2 +-
 mail/mailvar.c                      |  183 +++++++++++++++++++++++--------
 mail/tests/Makefile.am              |    4 +
 mail/tests/cols00.at                |    1 -
 mail/tests/cols01.at                |    1 -
 mail/tests/copy00.at                |    1 -
 mail/tests/{cols01.at => copy01.at} |   26 ++---
 mail/tests/{cols00.at => copy02.at} |   28 ++---
 mail/tests/{cols00.at => copy03.at} |   29 ++---
 mail/tests/{cols00.at => copy04.at} |   35 +++---
 mail/tests/nohome.at                |    1 -
 mail/tests/testsuite.at             |    8 +-
 18 files changed, 362 insertions(+), 216 deletions(-)
 copy mail/tests/{cols01.at => copy01.at} (64%)
 copy mail/tests/{cols00.at => copy02.at} (61%)
 copy mail/tests/{cols00.at => copy03.at} (62%)
 copy mail/tests/{cols00.at => copy04.at} (56%)

diff --git a/include/mailutils/mailbox.h b/include/mailutils/mailbox.h
index 5cfb89d..9b9e43f 100644
--- a/include/mailutils/mailbox.h
+++ b/include/mailutils/mailbox.h
@@ -36,6 +36,8 @@ const char *mu_mailbox_url (void);
 const char *mu_folder_directory (void);
 int mu_construct_user_mailbox_url (char **pout, const char *name);
 
+int mu_mailbox_expand_name (const char *name, char **expansion);
+  
 /* Constructor/destructor and possible types.  */
 extern int  mu_mailbox_create          (mu_mailbox_t *, const char *);
 extern int  mu_mailbox_create_from_url (mu_mailbox_t *, mu_url_t);
diff --git a/libmailutils/mailbox/mbx_default.c b/libmailutils/mailbox/mbx_default.c
index 3b9c3e3..ea7e807 100644
--- a/libmailutils/mailbox/mbx_default.c
+++ b/libmailutils/mailbox/mbx_default.c
@@ -117,9 +117,17 @@ mu_set_mailbox_pattern (const char *pat)
 int
 mu_set_folder_directory (const char *p)
 {
-  char *fdir = strdup (p);
-  if (!fdir)
-    return ENOMEM;
+  char *fdir;
+
+  if (p)
+    {
+      fdir = strdup (p);
+      if (!fdir)
+	return ENOMEM;
+    }
+  else
+    fdir = NULL;
+  
   if (_mu_folder_dir != _default_folder_dir)
     free (_mu_folder_dir);
   _mu_folder_dir = fdir;
@@ -127,7 +135,7 @@ mu_set_folder_directory (const char *p)
 }
 
 const char *
-mu_mailbox_url ()
+mu_mailbox_url (void)
 {
   if (_mu_mailbox_pattern)
     return _mu_mailbox_pattern;
@@ -135,10 +143,13 @@ mu_mailbox_url ()
 }
 
 const char *
-mu_folder_directory ()
+mu_folder_directory (void)
 {
-  if (!_mu_folder_dir)
-    _mu_folder_dir = _default_folder_dir;
+  if (!_mu_folder_dir && _default_folder_dir)
+    {
+      mu_set_folder_directory (_default_folder_dir);
+      _default_folder_dir = NULL;
+    }
   return _mu_folder_dir;
 }
 
@@ -286,30 +297,40 @@ user_mailbox_name (const char *user, char **mailbox_name)
 static int
 plus_expand (const char *file, char **buf)
 {
-  char *home;
+  int rc = 0;
   const char *folder_dir = mu_folder_directory ();
 
-  home = get_homedir (NULL);
-  if (!home)
-    return ENOENT;
-  
-  file++;
-  
-  if (folder_dir[0] == '/' || mu_is_proto (folder_dir))
+  if (!folder_dir)
     {
-      *buf = mu_make_file_name (folder_dir, file);
-      if (!*buf)
-	return errno;
+      char *p = strdup (file);
+      if (!p)
+	return ENOMEM;
+      *buf = p;
     }
   else
     {
-      int rc = mu_asprintf (buf, "%s/%s/%s", home, folder_dir, file);
-      if (rc)
-	return rc;
+      file++;
+  
+      if (folder_dir[0] == '/' || mu_is_proto (folder_dir))
+	{
+	  char *p = mu_make_file_name (folder_dir, file);
+	  if (!p)
+	    return errno;
+	  *buf = p;
+	}
+      else
+	{
+	  char *home = get_homedir (NULL);
+      
+	  if (!home)
+	    return ENOENT;
+      
+	  rc = mu_asprintf (buf, "%s/%s/%s", home, folder_dir, file);
+	  free (home);
+	}
     }
   
-  free (home);
-  return 0;
+  return rc;
 }
 
 static int
@@ -374,21 +395,75 @@ attach_auth_ticket (mu_mailbox_t mbox)
     }
 }
 
-/* We are trying to be smart about the location of the mail.
-   mu_mailbox_create() is not doing this.
-   %           --> system mailbox for the real uid
-   %user       --> system mailbox for the given user
-   ~/file      --> /home/user/file
-   ~user/file  --> /home/user/file
-   +file       --> /home/user/Mail/file
-   =file       --> /home/user/Mail/file
-*/
+/* Expand mailbox name according to the following rules:
+
+   NAME            Expands to
+   -------------+------------------------------------
+   %            -> system mailbox for the real uid
+   %user        -> system mailbox for the given user
+   ~/file       -> /home/user/file
+   ~user/file   -> /home/user/file
+   +file        -> /home/user/Mail/file
+   =file        -> /home/user/Mail/file
+ */
 int
-mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail)
+mu_mailbox_expand_name (const char *name, char **expansion)
 {
-  char *mbox = NULL;
-  char *tmp_mbox = NULL;
+  int status = 0;
   char *p;
+  char *mbox = NULL;
+  
+  if (!name)
+    return EINVAL;
+  if (!expansion)
+    return MU_ERR_OUT_PTR_NULL;
+
+  p = mu_tilde_expansion (name, MU_HIERARCHY_DELIMITER, NULL);
+  if (!p)
+    return errno;
+  switch (p[0])
+    {
+    case '%':
+      status = percent_expand (p, &mbox);
+      break;
+      
+    case '+':
+    case '=':
+      status = plus_expand (p, &mbox);
+      break;
+  
+    case '/':
+      mbox = p;
+      p = NULL;
+      break;
+      
+    default:
+      if (!mu_is_proto (p))
+	{
+	  char *dir = mu_getcwd();
+	  mbox = mu_make_file_name (dir, p);
+	  if (!mbox)
+	    status = errno;
+	  free (dir);  
+	}
+      else
+	{
+	  mbox = p;
+	  p = NULL;
+	}
+    }
+  free (p);
+  if (status == 0)
+    *expansion = mbox;
+  return status;
+}
+
+/* Expand mailbox name MAIL and create a mailbox structure for it. */
+int
+mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail)
+{
+  char *mboxname = NULL;
+  char *name_ptr = NULL;
   int status = 0;
 
   /* Sanity.  */
@@ -412,63 +487,19 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail)
 
       if (!mail)
 	{
-	  if ((status = user_mailbox_name (NULL, &tmp_mbox)))
+	  if ((status = user_mailbox_name (NULL, &name_ptr)))
 	    return status;
-	  mail = tmp_mbox;
-	}
-    }
-  
-  p = mu_tilde_expansion (mail, MU_HIERARCHY_DELIMITER, NULL);
-  if (tmp_mbox)
-    free (tmp_mbox);
-  tmp_mbox = p;
-  mail = tmp_mbox;
-  if (!mail)
-    return ENOMEM;
-
-  switch (mail[0])
-    {
-    case '%':
-      status = percent_expand (mail, &mbox);
-      break;
-      
-    case '+':
-    case '=':
-      status = plus_expand (mail, &mbox);
-      break;
-
-    case '/':
-      mbox = strdup (mail);
-      if (!mbox)
-	status = errno;
-      break;
-      
-    default:
-      if (!mu_is_proto (mail))
-	{
-	  p = mu_getcwd();
-	  mbox = mu_make_file_name (p, mail);
-	  if (!mbox)
-	    status = errno;
-	  free (p);  
-	}
-      else
-	{
-	  mbox = strdup (mail);
-	  if (!mbox)
-	    status = errno;
+	  mail = name_ptr;
 	}
-      break;
     }
 
-  if (tmp_mbox)
-    free (tmp_mbox);
-
+  status = mu_mailbox_expand_name (mail, &mboxname);
+  free (name_ptr);
   if (status)
     return status;
   
-  status = mu_mailbox_create (pmbox, mbox);
-  free (mbox);
+  status = mu_mailbox_create (pmbox, mboxname);
+  free (mboxname);
   if (status == 0)
     attach_auth_ticket (*pmbox);
       
diff --git a/mail/copy.c b/mail/copy.c
index 5f6599c..9a8b547 100644
--- a/mail/copy.c
+++ b/mail/copy.c
@@ -40,7 +40,7 @@ append_to_mailbox (char const *filename, msgset_t *msglist, int mark,
   size_t size;
   mu_message_t msg;
   
-  if ((status = mu_mailbox_create_default (&mbx, filename)) != 0)
+  if ((status = mu_mailbox_create (&mbx, filename)) != 0)
     {
       mu_error (_("Cannot create mailbox %s: %s"), filename, 
                    mu_strerror (status));
@@ -96,7 +96,7 @@ append_to_file (char const *filename, msgset_t *msglist, int mark,
   size_t lines;
   mu_message_t msg;
   mu_locker_t locker;
-  
+
   status = mu_file_stream_create (&ostr, filename,
 				  MU_STREAM_CREAT|MU_STREAM_APPEND);
   if (status)
diff --git a/mail/file.c b/mail/file.c
index 94bde91..b8cf81d 100644
--- a/mail/file.c
+++ b/mail/file.c
@@ -23,44 +23,43 @@ static char *prev_name;
  * #	    the previous file
  * &	    the current mbox
  * +file    the file named in the folder directory (set folder=foo)
- * Note 1) The followig notations are left intact, since they are
- * handled by mu_mailbox_create_default:
  * %	    system mailbox
- * %user    system mailbox of the user 
- * Note 2) Allocates memory
+ * %user    system mailbox of the user
  */
 char *
 mail_expand_name (const char *name)
 {
-  switch (name[0])
+  int status = 0;
+  char *exp = NULL;
+    
+  if (strcmp (name, "#") == 0)
     {
-    case '#':
       if (!prev_name)
 	{
 	  mu_error (_("No previous file"));
 	  return NULL;
 	}
       else
-	name = mu_strdup (prev_name);
-      break;
-	  
-    case '&':
+	return mu_strdup (prev_name);
+    }
+
+  if (strcmp (name, "&") == 0)
+    {
       name = getenv ("MBOX");
       if (!name)
-	mu_error (_("MBOX environment variable not set"));
-      else
-	name = mu_strdup (name);
-      break;
-	  
-    case '+':
-      name = util_folder_path (name);
-      break;
-
-    default:
-      name = mu_strdup (name);
-      break;
+	{
+	  mu_error (_("MBOX environment variable not set"));
+	  return NULL;
+	}
+      /* else fall through */
     }
-  return (char*) name;
+
+  status = mu_mailbox_expand_name (name, &exp);
+
+  if (status)
+    mu_error (_("Failed to expand %s: %s"), name, mu_strerror (status));
+
+  return (char*) exp;
 }
 
 /*
@@ -87,7 +86,7 @@ mail_file (int argc, char **argv)
       if (!name)
 	return 1;
       
-      if ((status = mu_mailbox_create_default (&newbox, name)) != 0 
+      if ((status = mu_mailbox_create (&newbox, name)) != 0 
 	  || (status = mu_mailbox_open (newbox, MU_STREAM_RDWR)) != 0)
 	{
 	  mu_mailbox_destroy (&newbox);
diff --git a/mail/from.c b/mail/from.c
index 99cd87e..66c802f 100644
--- a/mail/from.c
+++ b/mail/from.c
@@ -538,10 +538,10 @@ compile_headline (const char *str)
 static struct header_segm *mail_header_line;
 
 void
-mail_compile_headline (struct mailvar_variable *var)
+mail_compile_headline (char const *str)
 {
   free_headline (mail_header_line);
-  mail_header_line = compile_headline (var->value.string);
+  mail_header_line = compile_headline (str);
 }
 
 
diff --git a/mail/mail.c b/mail/mail.c
index 6a80425..b0adcd8 100644
--- a/mail/mail.c
+++ b/mail/mail.c
@@ -330,6 +330,7 @@ static char *default_setup[] = {
   "set noinplacealiases",
   "set fromfield",
   "set headline=\"%>%a%4m %18f %16d %3L/%-5o %s\"",
+  "unset folder",
   
   /* Start in mail reading mode */
   "setq mode=read",
diff --git a/mail/mail.h b/mail/mail.h
index 0c4465f..f966ca5 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -193,7 +193,7 @@ extern int mail_folders (int argc, char **argv);
 extern int mail_followup (int argc, char **argv);
 extern int mail_from (int argc, char **argv);
 extern int mail_from0 (msgset_t *mspec, mu_message_t msg, void *data);
-extern void mail_compile_headline (struct mailvar_variable *var);
+extern void mail_compile_headline (char const *str);
 
 extern int mail_headers (int argc, char **argv);
 extern int mail_hold (int argc, char **argv);
diff --git a/mail/mailvar.c b/mail/mailvar.c
index a839a73..803f32c 100644
--- a/mail/mailvar.c
+++ b/mail/mailvar.c
@@ -22,20 +22,34 @@
 
 #define MAILVAR_TYPEMASK(type) (1<<(8+(type)))
 
+enum mailvar_cmd
+  {
+    mailvar_cmd_set,
+    mailvar_cmd_unset
+  };
+
 struct mailvar_symbol
 {
   struct mailvar_variable var;
   int flags;
   char *descr;
-  void (*handler) (struct mailvar_variable *);
+  int (*handler) (enum mailvar_cmd, struct mailvar_variable *);
 };
 
 mu_list_t mailvar_list = NULL;
 
-static void set_decode_fallback (struct mailvar_variable *);
-static void set_replyregex (struct mailvar_variable *);
-static void set_screen (struct mailvar_variable *);
-static void set_debug (struct mailvar_variable *);
+static int set_decode_fallback (enum mailvar_cmd cmd,
+				struct mailvar_variable *);
+static int set_replyregex (enum mailvar_cmd cmd,
+			   struct mailvar_variable *);
+static int set_screen (enum mailvar_cmd cmd,
+		       struct mailvar_variable *);
+static int set_debug (enum mailvar_cmd cmd,
+		      struct mailvar_variable *);
+static int set_folder (enum mailvar_cmd cmd,
+		       struct mailvar_variable *);
+static int set_headline (enum mailvar_cmd,
+			 struct mailvar_variable *);
   
 struct mailvar_symbol mailvar_tab[] =
   {
@@ -119,7 +133,8 @@ struct mailvar_symbol mailvar_tab[] =
       N_("swap the meaning of reply and Reply commands") },
     { { "folder", },
       MAILVAR_TYPEMASK (mailvar_type_string), 
-      N_("folder directory name") },
+      N_("folder directory name"),
+      set_folder },
     { { "fromfield", },
       MAILVAR_TYPEMASK (mailvar_type_boolean),
       N_("get sender address from the `From:' header, instead of "
@@ -133,7 +148,7 @@ struct mailvar_symbol mailvar_tab[] =
     { { "headline", },
       MAILVAR_TYPEMASK (mailvar_type_string),
       N_("format string to use for the header summary"),
-      mail_compile_headline },
+      set_headline },
     { { "hold", },
       MAILVAR_TYPEMASK (mailvar_type_boolean),
       N_("hold the read or saved messages in the system mailbox") },
@@ -471,9 +486,10 @@ int
 mailvar_set (const char *variable, void *value, enum mailvar_type type,
 	     int flags)
 {
-  struct mailvar_variable *var;
+  struct mailvar_variable *var, newvar;
   const struct mailvar_symbol *sym = find_mailvar_symbol (variable);
-  int unset = flags & MOPTF_UNSET;
+  enum mailvar_cmd cmd =
+    (flags & MOPTF_UNSET) ? mailvar_cmd_unset : mailvar_cmd_set;
   
   if (!(flags & MOPTF_QUIET)
       && mailvar_get (NULL, "variable-strict", mailvar_type_boolean, 0) == 0)
@@ -488,95 +504,174 @@ mailvar_set (const char *variable, void *value, enum mailvar_type type,
 	  return 1;
 	}
       else if (!(sym->flags & MAILVAR_TYPEMASK (type))
-	       && !unset)
+	       && cmd == mailvar_cmd_set)
 	{
 	  mu_error (_("Wrong type for %s"), variable);
 	  return 1;
 	}
     }
 
-  var = mailvar_find_variable (variable, !unset);
+  var = mailvar_find_variable (variable, cmd == mailvar_cmd_set);
 
   if (!var || (var->set && !(flags & MOPTF_OVERWRITE)))
     return 0;
 
-  mailvar_variable_reset (var);
-  if (!unset)
+  newvar.name = var->name;
+  newvar.type = var->type;
+  newvar.set = 0;
+  memset (&newvar.value, 0, sizeof (newvar.value));
+  
+  switch (cmd)
     {
-      var->type = type;
+    case mailvar_cmd_set:
       if (value)
 	{
-	  var->set = 1;
 	  switch (type)
 	    {
 	    case mailvar_type_number:
-	      var->value.number = *(int*)value;
+	      newvar.value.number = *(int*)value;
 	      break;
 	  
 	    case mailvar_type_string:
-	      var->value.string = strdup (value);
+	      {
+		char *p = strdup (value);
+		if (!p)
+		  {
+		    mu_error ("%s", _("Not enough memory"));
+		    return 1;
+		  }
+		newvar.value.string = p;
+	      }
 	      break;
 	  
 	    case mailvar_type_boolean:
-	      var->value.bool = *(int*)value;
+	      newvar.value.bool = *(int*)value;
 	      break;
 		  
 	    default:
 	      abort();
 	    }
+	  newvar.set = 1;
+	}
+      newvar.type = type;
+      if (sym
+	  && sym->handler
+	  && sym->flags & MAILVAR_TYPEMASK (type)
+	  && sym->handler (cmd, &newvar))
+	{
+	  mailvar_variable_reset (&newvar);
+	  return 1;
 	}
+      mailvar_variable_reset (var);
+      *var = newvar;
+      break;
+
+    case mailvar_cmd_unset:
+      if (sym
+	  && sym->handler
+	  && sym->handler (cmd, var))
+	return 1;
+      mailvar_variable_reset (var);
     }
-    
-  /* Special handling for some variables */
-  if (sym && sym->flags & MAILVAR_TYPEMASK (type) && sym->handler)
-    sym->handler (var);
+
+  return 0;
+}
+
+static int
+set_folder (enum mailvar_cmd cmd, struct mailvar_variable *var)
+{
+  int rc = mu_set_folder_directory (var->value.string);
+  if (rc)
+    mu_diag_funcall (MU_DIAG_ERROR, "mu_set_folder_directory",
+		     var->value.string, rc);
+  return rc;
+}
+		   
+
+static int
+set_headline (enum mailvar_cmd cmd, struct mailvar_variable *var)
+{
+  if (cmd == mailvar_cmd_unset)
+    return 1;
   
+  mail_compile_headline (var->value.string);
   return 0;
 }
 
-
-static void
-set_decode_fallback (struct mailvar_variable *var)
+static int
+set_decode_fallback (enum mailvar_cmd cmd, struct mailvar_variable *var)
 {
-  if (mu_set_default_fallback (var->value.string))
+  char *value;
+  int rc;
+  
+  switch (cmd)
+    {
+    case mailvar_cmd_set:
+      value = var->value.string;
+      break;
+
+    case mailvar_cmd_unset:
+      value = "none";
+    }
+  
+  rc = mu_set_default_fallback (value);
+  if (rc)
     mu_error (_("Incorrect value for decode-fallback"));
+  return rc;
 }
 
-static void
-set_replyregex (struct mailvar_variable *var)
+static int
+set_replyregex (enum mailvar_cmd cmd, struct mailvar_variable *var)
 {
   int rc;
   char *err;
-  
-  if ((rc = mu_unre_set_regex (var->value.string, 0, &err)))
+
+  switch (cmd)
     {
-      if (err)
-	mu_error ("%s: %s", mu_strerror (rc), err);
-      else
-	mu_error ("%s", mu_strerror (rc));
+    case mailvar_cmd_set:
+      if ((rc = mu_unre_set_regex (var->value.string, 0, &err)))
+	{
+	  if (err)
+	    mu_error ("%s: %s", mu_strerror (rc), err);
+	  else
+	    mu_error ("%s", mu_strerror (rc));
+	  return 1;
+	}
+      break;
+
+    case mailvar_cmd_unset:
+      return 1;
     }
+
+  return 0;
 }
 
-static void
-set_screen (struct mailvar_variable *var)
+static int
+set_screen (enum mailvar_cmd cmd, struct mailvar_variable *var)
 {
-  page_invalidate (1);
+  if (cmd == mailvar_cmd_set)
+    page_invalidate (1);
+  return 0;
 }
 
 #define DEFAULT_DEBUG_LEVEL  MU_DEBUG_LEVEL_UPTO (MU_DEBUG_TRACE7)
 
-static void
-set_debug (struct mailvar_variable *var)
+static int
+set_debug (enum mailvar_cmd cmd, struct mailvar_variable *var)
 {
   mu_debug_clear_all ();
 
-  if (var->type == mailvar_type_boolean)
+  if (cmd == mailvar_cmd_set)
     {
-      if (var->set)
-        mu_debug_set_category_level (MU_DEBCAT_ALL, DEFAULT_DEBUG_LEVEL);
-      return;
+      if (var->type == mailvar_type_boolean)
+	{
+	  if (var->set)
+	    mu_debug_set_category_level (MU_DEBCAT_ALL, DEFAULT_DEBUG_LEVEL);
+	  return 0;
+	}
+      mu_debug_parse_spec (var->value.string);
     }
-  mu_debug_parse_spec (var->value.string); 
+  return 0;
 }
 
 
diff --git a/mail/tests/Makefile.am b/mail/tests/Makefile.am
index 3d89b9b..4a9d54a 100644
--- a/mail/tests/Makefile.am
+++ b/mail/tests/Makefile.am
@@ -42,6 +42,10 @@ TESTSUITE_AT =\
  cols00.at\
  cols01.at\
  copy00.at\
+ copy01.at\
+ copy02.at\
+ copy03.at\
+ copy04.at\
  nohome.at\
  testsuite.at\
  version.at
diff --git a/mail/tests/cols00.at b/mail/tests/cols00.at
index b6ab9cf..295bdbd 100644
--- a/mail/tests/cols00.at
+++ b/mail/tests/cols00.at
@@ -24,7 +24,6 @@ AT_KEYWORDS([columns cols00])
 
 AT_CHECK([
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
 COLUMNS=26 MUT_MAIL_CMD -nH -E 'set columns=26' -f ./mbox
 COLUMNS=31 MUT_MAIL_CMD -nH -f ./mbox
 ],
diff --git a/mail/tests/cols01.at b/mail/tests/cols01.at
index d4d5625..2edc2f7 100644
--- a/mail/tests/cols01.at
+++ b/mail/tests/cols01.at
@@ -24,7 +24,6 @@ AT_KEYWORDS([columns cols01])
 
 AT_CHECK([
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
 MUT_MAIL_CMD -nH -E 'set columns=26' -f ./mbox
 MUT_MAIL_CMD -nH -E 'set columns=31' -f ./mbox
 ],
diff --git a/mail/tests/copy00.at b/mail/tests/copy00.at
index e3fc9b9..d054853 100644
--- a/mail/tests/copy00.at
+++ b/mail/tests/copy00.at
@@ -25,7 +25,6 @@ AT_KEYWORDS([copy copy00])
 AT_CHECK([
 test -f /dev/stdout || AT_SKIP_TEST
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
 echo 'copy 1 /dev/stdout' | MUT_MAIL_CMD -N -E 'set readonly' -f ./mbox | sed 's/  *$//;/^Held 1 message/d';
 ],
 [0],
diff --git a/mail/tests/cols01.at b/mail/tests/copy01.at
similarity index 64%
copy from mail/tests/cols01.at
copy to mail/tests/copy01.at
index d4d5625..858ba22 100644
--- a/mail/tests/cols01.at
+++ b/mail/tests/copy01.at
@@ -14,25 +14,25 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([setting columns])
-AT_KEYWORDS([columns cols01])
+AT_SETUP([copy: % expansion])
+AT_KEYWORDS([copy copy01])
 
-# Description: Mailutils 2.99.98 ignored columns setting
-# Reported-By: Dan Jacobson <jidanni@jidanni.org>
-# References: <87pp6rumzl.fsf@jidanni.org>,
-#   http://lists.gnu.org/archive/html/bug-mailutils/2015-04/msg00000.html
+# Description: Check whether special mailbox notations are correctly expanded
+# in copy command.  This was broken by commit eea2c4aa.
+#
+# This testcase checks for expansion of "%".
 
 AT_CHECK([
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
-MUT_MAIL_CMD -nH -E 'set columns=26' -f ./mbox
-MUT_MAIL_CMD -nH -E 'set columns=31' -f ./mbox
+mbox=`pwd`/user
+echo 'copy 1 %' | dnl
+ MUT_MAIL_CMD -N -f ./mbox --set '|mailbox|mailbox-pattern'=$mbox | dnl
+ sed 's/  *$//;/^Held 1 message/d;s|'$mbox'|MBOX|'
+cmp user $abs_top_srcdir/testsuite/spool/mbox
 ],
 [0],
-[>N   1 Sergey Poznyakoff
->N   1 Sergey Poznyakoff  Tue
+["MBOX"  14/438
+
 ])
 
 AT_CLEANUP
-
-
diff --git a/mail/tests/cols00.at b/mail/tests/copy02.at
similarity index 61%
copy from mail/tests/cols00.at
copy to mail/tests/copy02.at
index b6ab9cf..a0c5175 100644
--- a/mail/tests/cols00.at
+++ b/mail/tests/copy02.at
@@ -14,25 +14,27 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([setting columns from environment])
-AT_KEYWORDS([columns cols00])
+AT_SETUP([copy: + expansion])
+AT_KEYWORDS([copy copy02])
 
-# Description: Check if COLUMNS setting is honored.
-# Reported-By: Dan Jacobson <jidanni@jidanni.org>
-# References: <87vbgemcc7.fsf@jidanni.org>,
-#    http://lists.gnu.org/archive/html/bug-mailutils/2015-04/msg00002.html
+# Description: Check whether special mailbox notations are correctly expanded
+# in copy command.  This was broken by commit eea2c4aa.
+#
+# This testcase checks for expansion of "+".
 
 AT_CHECK([
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
-COLUMNS=26 MUT_MAIL_CMD -nH -E 'set columns=26' -f ./mbox
-COLUMNS=31 MUT_MAIL_CMD -nH -f ./mbox
+mkdir folder
+folder=`pwd`/folder
+echo 'copy 1 +saved' | dnl
+ MUT_MAIL_CMD -N -E "set folder=\"$folder\"" -f ./mbox | dnl
+ sed 's/  *$//;/^Held 1 message/d;s|'$folder/saved'|MBOX|'
+test -f $folder/saved || exit 1 
+cmp $folder/saved $abs_top_srcdir/testsuite/spool/mbox
 ],
 [0],
-[>N   1 Sergey Poznyakoff
->N   1 Sergey Poznyakoff  Tue
+["MBOX"  14/438
+
 ])
 
 AT_CLEANUP
-
-
diff --git a/mail/tests/cols00.at b/mail/tests/copy03.at
similarity index 62%
copy from mail/tests/cols00.at
copy to mail/tests/copy03.at
index b6ab9cf..f498ddb 100644
--- a/mail/tests/cols00.at
+++ b/mail/tests/copy03.at
@@ -14,25 +14,28 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([setting columns from environment])
-AT_KEYWORDS([columns cols00])
+AT_SETUP([copy: & expansion])
+AT_KEYWORDS([copy copy03])
 
-# Description: Check if COLUMNS setting is honored.
-# Reported-By: Dan Jacobson <jidanni@jidanni.org>
-# References: <87vbgemcc7.fsf@jidanni.org>,
-#    http://lists.gnu.org/archive/html/bug-mailutils/2015-04/msg00002.html
+# Description: Check whether special mailbox notations are correctly expanded
+# in copy command.  This was broken by commit eea2c4aa.
+#
+# This testcase checks for expansion of "&".
 
 AT_CHECK([
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
-COLUMNS=26 MUT_MAIL_CMD -nH -E 'set columns=26' -f ./mbox
-COLUMNS=31 MUT_MAIL_CMD -nH -f ./mbox
+mkdir folder
+MBOX=`pwd`/MBOX
+export MBOX
+echo 'copy 1 &' | dnl
+ MUT_MAIL_CMD -N -E "set folder=\"$folder\"" -f ./mbox  | dnl
+ sed 's/  *$//;/^Held 1 message/d;s|'$MBOX'|MBOX|'
+test -f $MBOX || exit 1 
+cmp $MBOX $abs_top_srcdir/testsuite/spool/mbox
 ],
 [0],
-[>N   1 Sergey Poznyakoff
->N   1 Sergey Poznyakoff  Tue
+["MBOX"  14/438
+
 ])
 
 AT_CLEANUP
-
-
diff --git a/mail/tests/cols00.at b/mail/tests/copy04.at
similarity index 56%
copy from mail/tests/cols00.at
copy to mail/tests/copy04.at
index b6ab9cf..5867474 100644
--- a/mail/tests/cols00.at
+++ b/mail/tests/copy04.at
@@ -14,25 +14,34 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([setting columns from environment])
-AT_KEYWORDS([columns cols00])
+AT_SETUP([copy: # expansion])
+AT_KEYWORDS([copy copy04])
 
-# Description: Check if COLUMNS setting is honored.
-# Reported-By: Dan Jacobson <jidanni@jidanni.org>
-# References: <87vbgemcc7.fsf@jidanni.org>,
-#    http://lists.gnu.org/archive/html/bug-mailutils/2015-04/msg00002.html
+# Description: Check whether special mailbox notations are correctly expanded
+# in copy command.  This was broken by commit eea2c4aa.
+#
+# This testcase checks for expansion of "#".
 
 AT_CHECK([
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
-COLUMNS=26 MUT_MAIL_CMD -nH -E 'set columns=26' -f ./mbox
-COLUMNS=31 MUT_MAIL_CMD -nH -f ./mbox
+folder=`pwd`
+MBOX=$folder/mbox
+NEW=$folder/new
+>$NEW
+AT_DATA([script],[file +new
+file +mbox
+copy 1 #
+])
+MUT_MAIL_CMD -N -E "set folder=\"$folder\"" -f $MBOX < script  | dnl
+ sed 's/  *$//;s|'$NEW'|NEW|;s|'$MBOX'|MBOX|'
+sed '/^X-IMAPbase:/d;/^Status:/d;/^X-UID/d' $NEW | diff - $abs_top_srcdir/testsuite/spool/mbox 
 ],
 [0],
-[>N   1 Sergey Poznyakoff
->N   1 Sergey Poznyakoff  Tue
+[Held 1 message in MBOX
+Held 0 messages in NEW
+"NEW"  17/482
+
+Held 1 message in MBOX
 ])
 
 AT_CLEANUP
-
-
diff --git a/mail/tests/nohome.at b/mail/tests/nohome.at
index b4b03f7..7189373 100644
--- a/mail/tests/nohome.at
+++ b/mail/tests/nohome.at
@@ -24,7 +24,6 @@ AT_KEYWORDS([nohome])
 
 AT_CHECK([
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox)
-unset MAILRC
 unset HOME
 MAIL=./mbox MUT_MAIL_CMD -nH
 ],
diff --git a/mail/tests/testsuite.at b/mail/tests/testsuite.at
index d3b2905..12ae2b1 100644
--- a/mail/tests/testsuite.at
+++ b/mail/tests/testsuite.at
@@ -16,7 +16,7 @@
 
 m4_include([testsuite.inc])
 
-m4_define([MUT_MAIL_CMD],[mail MUT_DEFAULT_OPTIONS])
+m4_define([MUT_MAIL_CMD],[MAILRC=/dev/null mail MUT_DEFAULT_OPTIONS])
 
 AT_INIT
 AT_TESTED([mail])
@@ -25,4 +25,8 @@ m4_include([version.at])
 m4_include([nohome.at])
 m4_include([cols00.at])
 m4_include([cols01.at])
-m4_include([copy00.at])
\ No newline at end of file
+m4_include([copy00.at])
+m4_include([copy01.at])
+m4_include([copy02.at])
+m4_include([copy03.at])
+m4_include([copy04.at])


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 23 11:43:05 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c9adV-0007mO-JW
	for mharc-commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:43:05 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55081)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9adK-0007ld-Pw
	for commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:43:04 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9adA-00078n-Lz
	for commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:42:54 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:49268)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9adA-00078d-EW
	for commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:42:44 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 4102A2201C5; Wed, 23 Nov 2016 16:42:44 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-6-gf2980e5
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a04c6feb5007aeeb133b15558f13733743dee3e8
X-Git-Newrev: f2980e5a1a7495e31f75b979b258bd0fffdb310e
Message-Id: <20161123164244.4102A2201C5@vcs.savannah.gnu.org>
Date: Wed, 23 Nov 2016 16:42:44 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Nov 2016 16:43:05 -0000

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=f2980e5a1a7495e31f75b979b258bd0fffdb310e

The branch, master has been updated
       via  f2980e5a1a7495e31f75b979b258bd0fffdb310e (commit)
       via  4e162e9bb1a48269ce57a739a07d8c933a17bd57 (commit)
       via  15404d914aec7e80c884fc63dbfa5d3e347b32cb (commit)
      from  a04c6feb5007aeeb133b15558f13733743dee3e8 (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 f2980e5a1a7495e31f75b979b258bd0fffdb310e
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 23 18:28:08 2016 +0200

    Redo sieve debugging support
    
    Instead of keeping individual debug flags for each Sieve machine,
    use global debugging mechanism, category "sieve".  The following
    levels are defined:
    
      trace1  -  print parse tree before optimization
      trace2  -  print parse tree after optimization
      trace3  -  print parser traces
      trace4  -  print tests and actions being executed
      trace8  -  print disassembled code, don't run
      trace9  -  print each Sieve instruction being executed
    
    * include/mailutils/sieve.h (mu_sieve_get_debug_level)
    (mu_sieve_set_debug_level): Remove.
    (mu_sieve_is_dry_run,mu_sieve_set_dry_run
    * lib/script.c (mu_script_debug_flags): Redo.
    * lib/sieve.c (sieve_init): Remove call to obsoleted
    mu_sieve_set_debug_level.
    
    * examples/numaddr.c: Use mu_sieve_trace
    * libmu_sieve/extensions/list.c: Likewise.
    * libmu_sieve/extensions/moderator.c: Likewise.
    * libmu_sieve/extensions/pipe.c: Likewise.
    * libmu_sieve/extensions/spamd.c: Likewise.
    * libmu_sieve/extensions/timestamp.c: Likewise.
    * libmu_sieve/extensions/vacation.c: Likewise.
    * libmu_sieve/tests.c: Likewise.
    
    * libmu_sieve/runtime.c (INSTR_DEBUG,INSTR_DISASS): Rewrite.
    (mu_sieve_get_debug_level): Remove.
    (mu_sieve_is_dry_run_: Rewrite.
    (mu_sieve_set_dry_run): New function.
    (mu_sieve_disass): Rewrite.
    * libmu_sieve/sieve-priv.h (mu_sieve_machine) <debug_level>: Remove.
    <dry_run>: New field.
    * libmu_sieve/sieve.y (mu_sieve_set_debug_level): Remove.
    * libmu_sieve/util.c (mu_sieve_trace): New function.
    * sieve/sieve.c: Rewrite support for --dry-run and --debug.
    
    * sieve/tests/ext.at: Use --libdir-prefix instead of -L

commit 4e162e9bb1a48269ce57a739a07d8c933a17bd57
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 23 13:46:43 2016 +0200

    Further cleanup of sieve namespace
    
    Prefix internal function names with mu_i_

commit 15404d914aec7e80c884fc63dbfa5d3e347b32cb
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 23 13:26:23 2016 +0200

    Rewrite sieve parser.
    
    Three objectives:
    
    1. Simplify code.
    2. Produce optimized sieve code.
    3. Improve error reporting.
    4. Prepare for further extensions
    
    * include/mailutils/sieve.h (mu_sieve_tag_checker_t): Change
    signature (take mu_sieve_machine_t as the first arg).  All
    uses changed.
    (mu_sieve_require): Likewise.
    (mu_sieve_yydebug): Remove global.
    
    * libmu_sieve/sieve-priv.h (mu_locus_range): New struct.
    (YYLTYPE): New define
    (mu_sieve_state): New enum.
    (mu_sieve_machine): New members: string_pool, state.
    (mu_sieve_node_type): New enum.
    (mu_sieve_node): New struct.
    Remove unused prototypes.
    
    * libmu_sieve/sieve.l: Keep track of code locations.  Use opool
    for constructing string values.
    * libmu_sieve/sieve.y: Rewrite.  First build the parse tree.  Then
    optimize it.  Finally, generate code.
    * libmu_sieve/tests.c (sieve_test_true,sieve_test_false): Remove.
    True and false tests are always optimized away.
    * libmu_sieve/util.c (mu_sv_compile_error): Remove.
    
    * libmu_sieve/actions.c: Use mu_diag_at_locus to report errors
    and mu_i_sv_error to mark sieve machine as being in error state.
    * libmu_sieve/comparator.c: Likewise.
    * libmu_sieve/prog.c (mu_sv_code): Replace with mu_i_sv_code.
    (mu_sv_code_instr,mu_sv_code_handler)
    (mu_sv_code_list,mu_sv_code_number)
    (mu_sv_code_string,mu_sv_code_source)
    (mu_sv_code_line,mu_sv_change_source)
    (mu_sv_code_action,mu_sv_code_test)
    (mu_sv_code_anyof,mu_sv_code_allof): Remove.
    (mu_i_sv_locus,mu_i_sv_code_action)
    (mu_i_sv_code_test): New function.
    (mu_sv_code_command): Replace with a static function.
    * libmu_sieve/require.c (mu_sieve_require): Take ptr to machine
    as the first arg.
    * libmu_sieve/runtime.c (mu_sieve_mailbox)
    (mu_sieve_message): Refuse to run if the machine is in error state.
    
    * sieve/sieve.c: Update.
    * sieve/tests/i-numeric.at: Update expected error message.
    
    * libmailutils/diag/diag.c (mu_diag_at_locus): Don't pass locus
    if mu_file is NULL.
    * libmu_auth/ldap.c (_mu_entry_to_auth_data): Remove leftover
    mu_error.

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

Summary of changes:
 examples/numaddr.c                 |    5 +-
 include/mailutils/sieve.h          |   19 +-
 lib/script.c                       |   10 +-
 lib/sieve.c                        |    1 -
 libmailutils/diag/diag.c           |    9 +-
 libmu_auth/ldap.c                  |    2 -
 libmu_sieve/Makefile.am            |    1 +
 libmu_sieve/actions.c              |   10 +-
 libmu_sieve/comparator.c           |   68 ++-
 libmu_sieve/extensions/list.c      |    5 +-
 libmu_sieve/extensions/moderator.c |    7 +-
 libmu_sieve/extensions/pipe.c      |    5 +-
 libmu_sieve/extensions/spamd.c     |    7 +-
 libmu_sieve/extensions/timestamp.c |    5 +-
 libmu_sieve/extensions/vacation.c  |    5 +-
 libmu_sieve/load.c                 |    4 +-
 libmu_sieve/prog.c                 |  296 ++++------
 libmu_sieve/require.c              |   19 +-
 libmu_sieve/runtime.c              |   68 ++-
 libmu_sieve/sieve-priv.h           |  149 +++--
 libmu_sieve/sieve.l                |  238 ++++----
 libmu_sieve/sieve.y                | 1091 +++++++++++++++++++++++++++++-------
 libmu_sieve/tests.c                |   33 +-
 libmu_sieve/util.c                 |   45 +-
 sieve/sieve.c                      |   52 +-
 sieve/tests/ext.at                 |    2 +-
 sieve/tests/i-numeric.at           |    2 +-
 27 files changed, 1412 insertions(+), 746 deletions(-)

diff --git a/examples/numaddr.c b/examples/numaddr.c
index aa5990f..578bddc 100644
--- a/examples/numaddr.c
+++ b/examples/numaddr.c
@@ -84,10 +84,7 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   struct val_ctr vc;
   int rc;
   
-  if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE)
-    {
-      mu_sieve_debug (mach, "NUMADDR");
-    }
+  mu_sieve_trace (mach, "NUMADDR");
 
   /* Retrieve required arguments: */
   /* First argument: list of header names */
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 9aab6c6..74fa7c5 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -47,7 +47,8 @@ typedef int (*mu_sieve_comparator_t) (const char *, const char *);
 typedef int (*mu_sieve_retrieve_t) (void *item, void *data, int idx,
 				    char **pval);
 typedef void (*mu_sieve_destructor_t) (void *data);
-typedef int (*mu_sieve_tag_checker_t) (const char *name,
+typedef int (*mu_sieve_tag_checker_t) (mu_sieve_machine_t mach,
+				       const char *name,
 				       mu_list_t tags, mu_list_t args);
 
 typedef enum
@@ -121,7 +122,6 @@ typedef struct
 #define MU_SIEVE_DEBUG_DISAS  0x0004
 #define MU_SIEVE_DRY_RUN      0x0008
 
-extern int mu_sieve_yydebug;
 extern mu_debug_handle_t mu_sieve_debug_handle;
 extern mu_list_t mu_sieve_include_path;
 extern mu_list_t mu_sieve_library_path;
@@ -190,13 +190,16 @@ int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t * test,
 mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach,
 				       mu_list_t tags);
 
-void mu_sieve_require (mu_list_t slist);
+void mu_sieve_require (mu_sieve_machine_t mach, mu_list_t slist);
+
 int mu_sieve_tag_lookup (mu_list_t taglist, char *name,
 			 mu_sieve_value_t ** arg);
 int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name);
-int mu_sieve_match_part_checker (const char *name, mu_list_t tags,
+int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
+				 const char *name, mu_list_t tags,
 				 mu_list_t args);
-int mu_sieve_match_part_checker (const char *name, mu_list_t tags,
+int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
+				 const char *name, mu_list_t tags,
 				 mu_list_t args);
 /* Operations in value lists */
 mu_sieve_value_t *mu_sieve_value_get (mu_list_t vlist, size_t index);
@@ -228,13 +231,15 @@ void *mu_sieve_get_data (mu_sieve_machine_t mach);
 void mu_sieve_set_data (mu_sieve_machine_t mach, void *);
 mu_message_t mu_sieve_get_message (mu_sieve_machine_t mach);
 size_t mu_sieve_get_message_num (mu_sieve_machine_t mach);
-int mu_sieve_get_debug_level (mu_sieve_machine_t mach);
+
+int mu_sieve_is_dry_run (mu_sieve_machine_t mach);
+int mu_sieve_set_dry_run (mu_sieve_machine_t mach, int val);
+
 mu_mailer_t mu_sieve_get_mailer (mu_sieve_machine_t mach);
 int mu_sieve_get_locus (mu_sieve_machine_t mach, struct mu_locus *);
 char *mu_sieve_get_daemon_email (mu_sieve_machine_t mach);
 const char *mu_sieve_get_identifier (mu_sieve_machine_t mach);
 
-void mu_sieve_set_debug_level (mu_sieve_machine_t mach, int level);
 void mu_sieve_set_logger (mu_sieve_machine_t mach,
 			  mu_sieve_action_log_t logger);
 void mu_sieve_set_mailer (mu_sieve_machine_t mach, mu_mailer_t mailer);
diff --git a/lib/script.c b/lib/script.c
index 5993897..2ac5378 100644
--- a/lib/script.c
+++ b/lib/script.c
@@ -39,6 +39,8 @@ struct mu_script_fun *script_tab[] = {
 int
 mu_script_debug_flags (const char *arg, char **endp)
 {
+  mu_debug_level_t lev;
+    
   for (; *arg; arg++)
     {
       switch (*arg)
@@ -48,11 +50,15 @@ mu_script_debug_flags (const char *arg, char **endp)
 	  break;
 
 	case 't':
-	  mu_script_debug_sieve |= MU_SIEVE_DEBUG_TRACE;
+	  mu_debug_get_category_level (mu_sieve_debug_handle, &lev);
+	  mu_debug_set_category_level (mu_sieve_debug_handle,
+			       lev | MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE4));
 	  break;
 	  
 	case 'i':
-	  mu_script_debug_sieve |= MU_SIEVE_DEBUG_INSTR;
+	  mu_debug_get_category_level (mu_sieve_debug_handle, &lev);
+	  mu_debug_set_category_level (mu_sieve_debug_handle,
+			       lev | MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE9));
 	  break;
 	  
 	case 'l':
diff --git a/lib/sieve.c b/lib/sieve.c
index c5f7846..a7450c1 100644
--- a/lib/sieve.c
+++ b/lib/sieve.c
@@ -81,7 +81,6 @@ sieve_init (const char *prog, mu_script_descr_t *pdescr)
   rc = mu_sieve_machine_init (&mach);
   if (rc == 0)
     {
-      mu_sieve_set_debug_level (mach, mu_script_debug_sieve);
       if (mu_script_sieve_log)
 	mu_sieve_set_logger (mach, _sieve_action_log);
       rc = mu_sieve_compile (mach, prog);
diff --git a/libmailutils/diag/diag.c b/libmailutils/diag/diag.c
index 3f10356..50b8aa9 100644
--- a/libmailutils/diag/diag.c
+++ b/libmailutils/diag/diag.c
@@ -61,10 +61,11 @@ mu_diag_at_locus (int level, struct mu_locus const *loc, const char *fmt, ...)
   va_list ap;
 
   va_start (ap, fmt);
-  mu_stream_printf (mu_strerr, "\033f<%d>%s\033l<%u>\033c<%u>",
-		    (unsigned) strlen (loc->mu_file), loc->mu_file,
-		    loc->mu_line,
-		    loc->mu_col);
+  if (loc && loc->mu_file)
+    mu_stream_printf (mu_strerr, "\033f<%d>%s\033l<%u>\033c<%u>",
+		      (unsigned) strlen (loc->mu_file), loc->mu_file,
+		      loc->mu_line,
+		      loc->mu_col);
   mu_diag_voutput (level, fmt, ap);
   va_end (ap);
 }
diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c
index 4798b56..37fb0c3 100644
--- a/libmu_auth/ldap.c
+++ b/libmu_auth/ldap.c
@@ -538,8 +538,6 @@ _mu_entry_to_auth_data (LDAP *ld, LDAPMessage *msg,
   
   rc = ldap_get_dn_ber (ld, msg, &ber, &bv);
   ufn = ldap_dn2ufn (bv.bv_val);
-  /* FIXME: Use debug or diag functions */
-  mu_error ("INFO: %s", ufn);
   ldap_memfree (ufn);
   
   mu_assoc_get_iterator (ldap_param.field_map, &itr);
diff --git a/libmu_sieve/Makefile.am b/libmu_sieve/Makefile.am
index d9025a9..63a21c7 100644
--- a/libmu_sieve/Makefile.am
+++ b/libmu_sieve/Makefile.am
@@ -17,6 +17,7 @@
 
 YLWRAP = $(SHELL) $(mu_aux_dir)/gylwrap
 AM_YFLAGS = -dtv
+#AM_LEXFLAGS=-dvp
 AM_CPPFLAGS =\
  @MU_LIB_COMMON_INCLUDES@\
  -DMU_SIEVE_MODDIR=\"@MU_SIEVE_MODDIR@\"
diff --git a/libmu_sieve/actions.c b/libmu_sieve/actions.c
index 335748a..84bd368 100644
--- a/libmu_sieve/actions.c
+++ b/libmu_sieve/actions.c
@@ -522,7 +522,8 @@ mu_sieve_data_type fileinto_args[] = {
 };
 
 static int
-perms_tag_checker (const char *name, mu_list_t tags, mu_list_t args)
+perms_tag_checker (mu_sieve_machine_t mach,
+		   const char *name, mu_list_t tags, mu_list_t args)
 {
   mu_iterator_t itr;
   int err = 0;
@@ -540,8 +541,9 @@ perms_tag_checker (const char *name, mu_list_t tags, mu_list_t args)
 	{
 	  if (mu_parse_stream_perm_string (&flag, t->arg->v.string, &p))
 	    {
-	      mu_sv_compile_error (&mu_sieve_locus, 
-				   _("invalid permissions (near %s)"), p);
+	      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus,
+				_("invalid permissions (near %s)"), p);
+	      mu_i_sv_error (mach);
 	      err = 1;
 	    }
 	}
@@ -561,7 +563,7 @@ static mu_sieve_tag_group_t fileinto_tag_groups[] = {
 };
   
 void
-mu_sv_register_standard_actions (mu_sieve_machine_t mach)
+mu_i_sv_register_standard_actions (mu_sieve_machine_t mach)
 {
   mu_sieve_register_action (mach, "stop", sieve_action_stop, NULL, NULL, 1);
   mu_sieve_register_action (mach, "keep", sieve_action_keep, NULL, NULL, 1);
diff --git a/libmu_sieve/comparator.c b/libmu_sieve/comparator.c
index 184936d..d7be199 100644
--- a/libmu_sieve/comparator.c
+++ b/libmu_sieve/comparator.c
@@ -139,7 +139,9 @@ mu_sieve_get_comparator (mu_sieve_machine_t mach, mu_list_t tags)
 
 /* Compile time support */
 
-struct regex_data {
+struct regex_data
+{
+  mu_sieve_machine_t mach;
   int flags;
   mu_list_t list;
 };
@@ -158,7 +160,7 @@ _regex_compile (void *item, void *data)
 {
   struct regex_data *rd = data;
   int rc;
-  regex_t *preg = mu_sieve_malloc (mu_sieve_machine, sizeof (*preg));
+  regex_t *preg = mu_sieve_malloc (rd->mach, sizeof (*preg));
   
   rc = regcomp (preg, (char*)item, rd->flags);
   if (rc)
@@ -168,11 +170,13 @@ _regex_compile (void *item, void *data)
       if (errbuf)
 	{
 	  regerror (rc, preg, errbuf, size);
-	  mu_sv_compile_error (&mu_sieve_locus, _("regex error: %s"), errbuf);
+	  mu_diag_at_locus (MU_LOG_ERROR, &rd->mach->locus,
+			    _("regex error: %s"), errbuf);
 	  free (errbuf);
 	}
       else
-	mu_sv_compile_error (&mu_sieve_locus, _("regex error"));
+	mu_diag_at_locus (MU_LOG_ERROR, &rd->mach->locus, _("regex error"));
+      mu_i_sv_error (rd->mach);
       return rc;
     }
 
@@ -203,7 +207,8 @@ comp_false (const char *pattern, const char *text)
 }
 
 int
-mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
+mu_sieve_match_part_checker (mu_sieve_machine_t mach,
+			     const char *name, mu_list_t tags, mu_list_t args)
 {
   mu_iterator_t itr;
   mu_sieve_runtime_tag_t *match = NULL;
@@ -233,9 +238,10 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
 	{
 	  if (match)
 	    {
-	      mu_sv_compile_error (&mu_sieve_locus, 
-			     _("match type specified twice in call to `%s'"),
-				   name);
+	      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+				_("match type specified twice in call to `%s'"),
+				name);
+	      mu_i_sv_error (mach);
 	      err = 1;
 	    }
 	  else
@@ -269,13 +275,14 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
 	  
 	  if (comp && strcmp (comp->arg->v.string, "i;ascii-numeric"))
 	    {
-	      mu_sv_compile_error (&mu_sieve_locus, 
-				   /* TRANSLATORS: Do not translate ':count'.
-				      It is the name of a Sieve tag */
-				   _("comparator %s is incompatible with "
-				     ":count in call to `%s'"),
-				   comp->arg->v.string,
-				   name);
+	      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus,
+				/* TRANSLATORS: Do not translate ':count'.
+				   It is the name of a Sieve tag */
+				_("comparator %s is incompatible with "
+				  ":count in call to `%s'"),
+				comp->arg->v.string,
+				name);
+	      mu_i_sv_error (mach);
 	      return 1;
 	    }
 
@@ -288,16 +295,18 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
 	  mu_list_count (val->v.list, &count);
 	  if (count > 1)
 	    {
-	      mu_sv_compile_error (&mu_sieve_locus, 
+	      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
 			_("second argument must be a list of one element"));
+	      mu_i_sv_error (mach);
 	      return 1;
 	    }
 	  mu_list_get (val->v.list, 0, (void **) &str);
 	  count = strtoul (str, &str, 10);
 	  if (*str)
 	    {
-	      mu_sv_compile_error (&mu_sieve_locus, 
+	      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
 			   _("second argument cannot be converted to number"));
+	      mu_i_sv_error (mach);
 	      return 1;
 	    }
 	}
@@ -306,9 +315,10 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
 
       if (mu_sieve_str_to_relcmp (str, NULL, NULL))
 	{
-	  mu_sv_compile_error (&mu_sieve_locus, 
-			       _("invalid relational match `%s' in call to `%s'"),
-			       str, name);
+	  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+			    _("invalid relational match `%s' in call to `%s'"),
+			    str, name);
+	  mu_i_sv_error (mach);
 	  return 1;
 	}
     }
@@ -316,18 +326,18 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
   if (!compfun)
     {
       compname = comp ? comp->arg->v.string : "i;ascii-casemap";
-      compfun = mu_sieve_comparator_lookup (mu_sieve_machine, compname, 
-                                            matchtype);
+      compfun = mu_sieve_comparator_lookup (mach, compname, matchtype);
       if (!compfun)
 	{
-	  mu_sv_compile_error (&mu_sieve_locus, 
-			   _("comparator `%s' is incompatible with match type `%s' in call to `%s'"),
-			       compname, match ? match->tag : "is", name);
+	  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+			    _("comparator `%s' is incompatible with match type `%s' in call to `%s'"),
+			    compname, match ? match->tag : "is", name);
+	  mu_i_sv_error (mach);
 	  return 1;
 	}
     }
 
-  tmp = mu_sieve_malloc (mu_sieve_machine, sizeof (*tmp));
+  tmp = mu_sieve_malloc (mach, sizeof (*tmp));
   tmp->tag = TAG_COMPFUN;
   tmp->arg = mu_sieve_value_create (SVT_POINTER, compfun);
   mu_list_append (tags, tmp);
@@ -343,6 +353,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
       if (mu_list_get (args, 1, (void**)&val))
 	return 0;
 
+      rd.mach = mach;
       rd.flags = REG_EXTENDED;
       if (strcmp (compname, "i;ascii-casemap") == 0)
 	rd.flags |= REG_ICASE;
@@ -351,8 +362,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
       
       rc = mu_sieve_vlist_do (val, _regex_compile, &rd);
 
-      mu_sieve_machine_add_destructor (mu_sieve_machine, _free_reglist, 
-                                       rd.list);
+      mu_sieve_machine_add_destructor (rd.mach, _free_reglist, rd.list);
 
       if (rc)
 	return rc;
@@ -492,7 +502,7 @@ i_ascii_numeric_eq (const char *pattern, const char *text)
 }
 
 void
-mu_sv_register_standard_comparators (mu_sieve_machine_t mach)
+mu_i_sv_register_standard_comparators (mu_sieve_machine_t mach)
 {
   mu_sieve_register_comparator (mach,
 			     "i;octet",
diff --git a/libmu_sieve/extensions/list.c b/libmu_sieve/extensions/list.c
index caef14f..46b7a25 100644
--- a/libmu_sieve/extensions/list.c
+++ b/libmu_sieve/extensions/list.c
@@ -152,10 +152,7 @@ list_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   struct header_closure clos;
   int result;
 
-  if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE)
-    {
-      mu_sieve_debug (mach, "LIST");
-    }
+  mu_sieve_trace (mach, "LIST");
   
   memset (&clos, 0, sizeof clos);
   if (mu_sieve_tag_lookup (tags, "delim", &arg))
diff --git a/libmu_sieve/extensions/moderator.c b/libmu_sieve/extensions/moderator.c
index d889725..00b1de4 100644
--- a/libmu_sieve/extensions/moderator.c
+++ b/libmu_sieve/extensions/moderator.c
@@ -273,11 +273,8 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int discard = 0;
   int ismime;
   
-  if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE)
-    {
-      mu_sieve_debug (mach, "moderator_test %lu",
-		      (unsigned long) mu_sieve_get_message_num (mach));
-    }
+  mu_sieve_trace (mach, "moderator_test %lu",
+		  (unsigned long) mu_sieve_get_message_num (mach));
 
   msg = mu_sieve_get_message (mach);
   mu_message_is_multipart (msg, &ismime);
diff --git a/libmu_sieve/extensions/pipe.c b/libmu_sieve/extensions/pipe.c
index cb2e78a..783950b 100644
--- a/libmu_sieve/extensions/pipe.c
+++ b/libmu_sieve/extensions/pipe.c
@@ -105,10 +105,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
     }
   cmd = val->v.string;
 
-  if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE)
-    {
-      mu_sieve_debug (mach, test ? "PIPE (test)" : "PIPE (action)");
-    }
+  mu_sieve_trace (mach, test ? "PIPE (test)" : "PIPE (action)");
 
   if (mu_sieve_is_dry_run (mach))
     return 0;
diff --git a/libmu_sieve/extensions/spamd.c b/libmu_sieve/extensions/spamd.c
index 6689328..1fd8837 100644
--- a/libmu_sieve/extensions/spamd.c
+++ b/libmu_sieve/extensions/spamd.c
@@ -368,11 +368,8 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_header_t hdr;
   mu_debug_handle_t lev = 0;
   
-  if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE)
-    {
-      mu_sieve_debug (mach, "spamd_test %lu",
-		      (unsigned long) mu_sieve_get_message_num (mach));
-    }
+  mu_sieve_trace (mach, "spamd_test %lu",
+		  (unsigned long) mu_sieve_get_message_num (mach));
   
   if (mu_sieve_is_dry_run (mach))
     return 0;
diff --git a/libmu_sieve/extensions/timestamp.c b/libmu_sieve/extensions/timestamp.c
index 7fdcf14..67fceb0 100644
--- a/libmu_sieve/extensions/timestamp.c
+++ b/libmu_sieve/extensions/timestamp.c
@@ -57,10 +57,7 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   time_t tlimit, tval;
   int rc;
   
-  if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE)
-    {
-      mu_sieve_debug (mach, "TIMESTAMP");
-    }
+  mu_sieve_trace (mach, "TIMESTAMP");
 
   /* Retrieve required arguments: */
   /* First argument: header name */
diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c
index d6b6a2e..863fe15 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -136,10 +136,7 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
 static int
 diag (mu_sieve_machine_t mach)
 {
-  if (mu_sieve_get_debug_level (mach) & MU_SIEVE_DEBUG_TRACE)
-    {
-      mu_sieve_debug (mach, "VACATION");
-    }
+  mu_sieve_trace (mach, "VACATION");
 
   mu_sieve_log_action (mach, "VACATION", NULL);
   return mu_sieve_is_dry_run (mach);
diff --git a/libmu_sieve/load.c b/libmu_sieve/load.c
index 341aa9f..c164c27 100644
--- a/libmu_sieve/load.c
+++ b/libmu_sieve/load.c
@@ -136,7 +136,7 @@ _add_load_dir (void *item, void *unused)
 }
 
 int
-mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
+mu_i_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
 {
   if (sieve_init_load_path ())
     return 1;
@@ -155,7 +155,7 @@ mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name)
 }
 
 int
-mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
+mu_i_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
 {
   return 1;
 }
diff --git a/libmu_sieve/prog.c b/libmu_sieve/prog.c
index 5b0140e..50af4c9 100644
--- a/libmu_sieve/prog.c
+++ b/libmu_sieve/prog.c
@@ -25,72 +25,55 @@
 #include <sieve-priv.h>
 
 int
-mu_sv_code (sieve_op_t *op)
+mu_i_sv_code (struct mu_sieve_machine *mach, sieve_op_t op)
 {
-  if (mu_sieve_machine->pc >= mu_sieve_machine->progsize)
+  if (mach->pc >= mach->progsize)
     {
-      size_t newsize = mu_sieve_machine->progsize + SIEVE_CODE_INCR;
-      sieve_op_t *newprog = mu_sieve_mrealloc (mu_sieve_machine, 
-                                               mu_sieve_machine->prog,
-					       newsize *
-					     sizeof mu_sieve_machine->prog[0]);
+      size_t newsize = mach->progsize + SIEVE_CODE_INCR;
+      sieve_op_t *newprog =
+	mu_sieve_mrealloc (mach, mach->prog, newsize * sizeof mach->prog[0]);
       if (!newprog)
 	{
-	  mu_sv_compile_error (&mu_sieve_locus, _("not enough memory"));
+	  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, _("not enough memory"));
+	  mu_i_sv_error (mach);
 	  return 1;
 	}
-      mu_sieve_machine->prog = newprog;
-      mu_sieve_machine->progsize = newsize;
+      mach->prog = newprog;
+      mach->progsize = newsize;
     }
-  mu_sieve_machine->prog[mu_sieve_machine->pc++] = *op;
+  mach->prog[mach->pc++] = op;
   return 0;
 }
-
-int
-mu_sv_code_instr (sieve_instr_t instr)
-{
-  sieve_op_t op;
-
-  op.instr = instr;
-  return mu_sv_code (&op);
-}
-
-int
-mu_sv_code_handler (mu_sieve_handler_t handler)
-{
-  sieve_op_t op;
-
-  op.handler = handler;
-  return mu_sv_code (&op);
-}
-
-int
-mu_sv_code_list (mu_list_t list)
-{
-  sieve_op_t op;
-
-  op.list = list;
-  return mu_sv_code (&op);
-}
-
-int
-mu_sv_code_number (long num)
+
+static int
+file_eq (char const *a, char const *b)
 {
-  sieve_op_t op;
-
-  op.number = num;
-  return mu_sv_code (&op);
+  if (a)
+    return b ? (strcmp (a, b) == 0) : 1;
+  return b ? 0 : 1;
 }
-
+      
+/* FIXME: 1. Only beg is stored
+          2. mu_col is not used
+ */
 int
-mu_sv_code_string (const char *string)
+mu_i_sv_locus (struct mu_sieve_machine *mach, struct mu_locus_range *lr)
 {
-  sieve_op_t op;
+  if (!file_eq (mach->locus.mu_file, lr->beg.mu_file))
+    {
+      mu_i_sv_code (mach, (sieve_op_t) _mu_i_sv_instr_source);
+      mu_i_sv_code (mach, (sieve_op_t) lr->beg.mu_file);
+    }
+  if (mach->locus.mu_line != lr->beg.mu_line)
+    {
+      mu_i_sv_code (mach, (sieve_op_t) _mu_i_sv_instr_line);
+      mu_i_sv_code (mach, (sieve_op_t) lr->beg.mu_line);
+    }
 
-  op.string = string;
-  return mu_sv_code (&op);
+  mach->locus = lr->beg;
+  return 0;
 }
-
+
 mu_sieve_tag_def_t *
 find_tag (mu_sieve_tag_group_t *taglist, char *tagname,
 	  mu_sieve_tag_checker_t *checker)
@@ -119,7 +102,9 @@ _compare_ptr (void *item, void *data)
   return item == data;
 }
 
-struct check_arg {
+struct check_arg
+{
+  struct mu_sieve_machine *mach;
   const char *name;
   mu_list_t args;
   mu_list_t tags;
@@ -129,11 +114,13 @@ static int
 _run_checker (void *item, void *data)
 {
   struct check_arg *arg = data;
-  return (*(mu_sieve_tag_checker_t)item) (arg->name, arg->tags, arg->args);
+  return (*(mu_sieve_tag_checker_t)item) (arg->mach, arg->name,
+					  arg->tags, arg->args);
 }
 
-int
-mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
+static int
+sv_code_command (struct mu_sieve_machine *mach,
+		 mu_sieve_register_t *reg, mu_list_t arglist)
 {
   mu_iterator_t itr;
   mu_list_t arg_list = NULL;
@@ -144,7 +131,7 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
   int rc, err = 0;
   static mu_sieve_data_type empty[] = { SVT_VOID };
   
-  if (mu_sv_code_handler (reg->handler))
+  if (mu_i_sv_code (mach, (sieve_op_t) reg->handler))
     return 1;
 
   exp_arg = reg->req_args ? reg->req_args : empty;
@@ -155,13 +142,15 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 
       if (rc)
 	{
-	  mu_sv_compile_error (&mu_sieve_locus, 
-                               _("cannot create iterator: %s"),
-  		               mu_strerror (rc));
+	  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus,
+			    _("cannot create iterator: %s"),
+			    mu_strerror (rc));
+	  mu_i_sv_error (mach);
 	  return 1;
 	}
   
-      for (mu_iterator_first (itr); !mu_iterator_is_done (itr); mu_iterator_next (itr))
+      for (mu_iterator_first (itr);
+	   !mu_iterator_is_done (itr); mu_iterator_next (itr))
 	{
 	  mu_sieve_value_t *val;
 	  mu_sieve_runtime_tag_t tagrec, *tagptr;
@@ -171,21 +160,24 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 	  if (val->type == SVT_TAG)
 	    {
 	      mu_sieve_tag_checker_t cf;
-	      mu_sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string, &cf);
+	      mu_sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string,
+						  &cf);
 	      if (!tag)
 		{
-		  mu_sv_compile_error (&mu_sieve_locus, 
-				       _("invalid tag name `%s' for `%s'"),
-				       val->v.string, reg->name);
+		  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+				    _("invalid tag name `%s' for `%s'"),
+				    val->v.string, reg->name);
+		  mu_i_sv_error (mach);
 		  err = 1;
 		  break;
 		}
 	      
 	      if (!tag_list && (rc = mu_list_create (&tag_list)))
 		{
-		  mu_sv_compile_error (&mu_sieve_locus, 
-                                       _("cannot create tag list: %s"),
-			               mu_strerror (rc));
+		  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+				    _("cannot create tag list: %s"),
+				    mu_strerror (rc));
+		  mu_i_sv_error (mach);
 		  err = 1;
 		  break;
 		}
@@ -196,24 +188,25 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 		  mu_iterator_next (itr);
 		  if (mu_iterator_is_done (itr))
 		    {
-		      mu_sv_compile_error (&mu_sieve_locus, 
+		      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
 			   _("required argument for tag %s is missing"),
-					   tag->name);
+					tag->name);
+		      mu_i_sv_error (mach);
 		      err = 1;
 		      break;
 		    }
 		  mu_iterator_current (itr, (void **)&tagrec.arg);
 		  if (tagrec.arg->type != tag->argtype)
 		    {
-		      mu_sv_compile_error (&mu_sieve_locus, 
-					   _("type mismatch in argument to "
-					     "tag `%s'"),
-					   tag->name);
-		      mu_sv_compile_error (&mu_sieve_locus, 
-					   _("expected %s but passed %s"),
-					   mu_sieve_type_str (tag->argtype),
-					   mu_sieve_type_str
-					                 (tagrec.arg->type));
+		      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+					     _("type mismatch in argument to "
+					       "tag `%s'"),
+					     tag->name);
+		      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+					     _("expected %s but passed %s"),
+					     mu_sieve_type_str (tag->argtype),
+					     mu_sieve_type_str (tagrec.arg->type));
+		      mu_i_sv_error (mach);
 		      err = 1;
 		      break;
 		    }
@@ -221,7 +214,7 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 	      else
 		tagrec.arg = NULL;
 	      
-	      tagptr = mu_sieve_malloc (mu_sieve_machine, sizeof (*tagptr));
+	      tagptr = mu_sieve_malloc (mach, sizeof (*tagptr));
 	      *tagptr = tagrec;
 	      mu_list_append (tag_list, tagptr);
 
@@ -229,9 +222,10 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 		{
 		  if (!chk_list && (rc = mu_list_create (&chk_list)))
 		    {
-		      mu_sv_compile_error (&mu_sieve_locus, 
- 			  	         _("cannot create check list: %s"),
-					   mu_strerror (rc));
+		      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+					_("cannot create check list: %s"),
+					mu_strerror (rc));
+		      mu_i_sv_error (mach);
 		      err = 1;
 		      break;
 		    }
@@ -250,9 +244,10 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 		    }
 		  else
 		    {
-		      mu_sv_compile_error (&mu_sieve_locus, 
-				      _("too many arguments in call to `%s'"),
-					   reg->name);
+		      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+					_("too many arguments in call to `%s'"),
+					reg->name);
+		      mu_i_sv_error (mach);
 		      err = 1;
 		      break;
 		    }
@@ -266,19 +261,20 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 
 		      mu_list_create (&list);
 		      mu_list_append (list, val->v.string);
-		      mu_sieve_mfree (mu_sieve_machine, val);
+		      mu_sieve_mfree (mach, val);
 		      val = mu_sieve_value_create (SVT_STRING_LIST, list);
 		    }
 		  else
 		    {
-		      mu_sv_compile_error (&mu_sieve_locus, 
+		      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
                                    _("type mismatch in argument %lu to `%s'"),
 				   (unsigned long) (exp_arg - reg->req_args + 1),
-					   reg->name);
-		      mu_sv_compile_error (&mu_sieve_locus, 
-					   _("expected %s but passed %s"),
-					   mu_sieve_type_str (*exp_arg),
-					   mu_sieve_type_str (val->type));
+					     reg->name);
+		      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+					_("expected %s but passed %s"),
+					mu_sieve_type_str (*exp_arg),
+					mu_sieve_type_str (val->type));
+		      mu_i_sv_error (mach);
 		      err = 1;
 		      break;
 		    }
@@ -286,9 +282,10 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 
 	      if (!arg_list && (rc = mu_list_create (&arg_list)))
 		{
-		  mu_sv_compile_error (&mu_sieve_locus, 
-                                       _("cannot create arg list: %s"),
-			               mu_strerror (rc));
+		  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+				    _("cannot create arg list: %s"),
+				    mu_strerror (rc));
+		  mu_i_sv_error (mach);
 		  err = 1;
 		  break;
 		}
@@ -304,16 +301,18 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
     {
       if (!opt_args && *exp_arg != SVT_VOID)
 	{
-	  mu_sv_compile_error (&mu_sieve_locus, 
-                               _("too few arguments in call to `%s'"),
-			       reg->name);
+	  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus, 
+			    _("too few arguments in call to `%s'"),
+			    reg->name);
+	  mu_i_sv_error (mach);
 	  err = 1;
 	}
 
       if (chk_list)
 	{
 	  struct check_arg chk_arg;
-      
+
+	  chk_arg.mach = mach;
 	  chk_arg.name = reg->name;
 	  chk_arg.tags = tag_list;
 	  chk_arg.args = arg_list;
@@ -322,9 +321,9 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
     }
   
   if (!err)
-    err = mu_sv_code_list (arg_list)
-          || mu_sv_code_list (tag_list)
-          || mu_sv_code_string (reg->name);
+    err = mu_i_sv_code (mach, (sieve_op_t) arg_list)
+      || mu_i_sv_code (mach, (sieve_op_t) tag_list)
+      || mu_i_sv_code (mach, (sieve_op_t) (char*) reg->name);
 
   if (err)
     {
@@ -337,95 +336,18 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 }
 
 int
-mu_sv_code_source (const char *name)
-{
-  char *s;
-  
-  if (mu_list_locate (mu_sieve_machine->source_list, 
-                      (void*) name, (void **) &s))
-    {
-      s = mu_sieve_mstrdup (mu_sieve_machine, name);
-      mu_list_append (mu_sieve_machine->source_list, s);
-    }
-  
-  return mu_sv_code_instr (_mu_sv_instr_source)
-	 || mu_sv_code_string (s);
-}
-
-int
-mu_sv_code_line (size_t line)
+mu_i_sv_code_action (struct mu_sieve_machine *mach,
+		     mu_sieve_register_t *reg, mu_list_t arglist)
 {
-  sieve_op_t op;
-
-  op.line = line;
-  return mu_sv_code_instr (_mu_sv_instr_line)
-	 || mu_sv_code (&op);
-}
-
-static int sieve_source_changed;
-
-void
-mu_sv_change_source ()
-{
-  sieve_source_changed = 1;
-}
-
-static int
-sieve_check_source_changed ()
-{
-  if (sieve_source_changed)
-    {
-      sieve_source_changed = 0;
-      return mu_sv_code_source (mu_sieve_locus.mu_file);
-    }
-  return 0;
-}
-
-int
-mu_sv_code_action (mu_sieve_register_t *reg, mu_list_t arglist)
-{
-  return sieve_check_source_changed ()
-         || mu_sv_code_line (mu_sieve_locus.mu_line)
-         || mu_sv_code_instr (_mu_sv_instr_action)
-         || mu_sv_code_command (reg, arglist);
+  return mu_i_sv_code (mach, (sieve_op_t) _mu_i_sv_instr_action)
+         || sv_code_command (mach, reg, arglist);
 }
 
 int
-mu_sv_code_test (mu_sieve_register_t *reg, mu_list_t arglist)
-{
-  return sieve_check_source_changed ()
-         || mu_sv_code_line (mu_sieve_locus.mu_line)
-         || mu_sv_code_instr (_mu_sv_instr_test)
-         || mu_sv_code_command (reg, arglist);
-}
-
-void
-mu_sv_code_anyof (size_t start)
+mu_i_sv_code_test (struct mu_sieve_machine *mach,
+		   mu_sieve_register_t *reg, mu_list_t arglist)
 {
-  size_t end = mu_sieve_machine->pc;
-  while (mu_sieve_machine->prog[start+1].pc != 0)
-    {
-      size_t next = mu_sieve_machine->prog[start+1].pc;
-      mu_sieve_machine->prog[start].instr = _mu_sv_instr_brnz;
-      mu_sieve_machine->prog[start+1].pc = end - start - 2;
-      start = next;
-    }
-  mu_sieve_machine->prog[start].instr = _mu_sv_instr_nop;
-  mu_sieve_machine->prog[start+1].instr = _mu_sv_instr_nop;
+  return mu_i_sv_code (mach, (sieve_op_t) _mu_i_sv_instr_test)
+         || sv_code_command (mach, reg, arglist);
 }
 
-void
-mu_sv_code_allof (size_t start)
-{
-  size_t end = mu_sieve_machine->pc;
-  
-  while (mu_sieve_machine->prog[start+1].pc != 0)
-    {
-      size_t next = mu_sieve_machine->prog[start+1].pc;
-      mu_sieve_machine->prog[start+1].pc = end - start - 2;
-      start = next;
-    }
-  mu_sieve_machine->prog[start].instr = _mu_sv_instr_nop;
-  mu_sieve_machine->prog[start+1].instr = _mu_sv_instr_nop;
-}
-		
diff --git a/libmu_sieve/require.c b/libmu_sieve/require.c
index de6ac00..18c348e 100644
--- a/libmu_sieve/require.c
+++ b/libmu_sieve/require.c
@@ -27,7 +27,7 @@
 #include <sieve-priv.h>
 
 void
-mu_sieve_require (mu_list_t slist)
+mu_sieve_require (mu_sieve_machine_t mach, mu_list_t slist)
 {
   int status;
   mu_iterator_t itr;
@@ -35,9 +35,10 @@ mu_sieve_require (mu_list_t slist)
   status = mu_list_get_iterator (slist, &itr);
   if (status)
     {
-      mu_sv_compile_error (&mu_sieve_locus,
-			   _("cannot create iterator: %s"),
-			   mu_strerror (status));
+      mu_diag_at_locus (MU_LOG_ERROR, &mach->locus,
+			_("cannot create iterator: %s"),
+			mu_strerror (status));
+      mu_i_sv_error (mach);
       return;
     }
 
@@ -73,12 +74,12 @@ mu_sieve_require (mu_list_t slist)
 	  text = _("required action");
 	}
 
-      if (reqfn (mu_sieve_machine, name))
+      if (reqfn (mach, name))
 	{
-	  mu_sv_compile_error (&mu_sieve_locus,
-			       _("source for the %s %s is not available"),
-			       text,
-			       name);
+	  mu_diag_at_locus (MU_LOG_ERROR, &mach->locus,
+			    _("source for the %s %s is not available"),
+			    text, name);
+	  mu_i_sv_error (mach);
 	}
     }
   mu_iterator_destroy (&itr);
diff --git a/libmu_sieve/runtime.c b/libmu_sieve/runtime.c
index 60bdecc..2778739 100644
--- a/libmu_sieve/runtime.c
+++ b/libmu_sieve/runtime.c
@@ -28,18 +28,19 @@
 #define SIEVE_ADJUST(m,n) (m)->pc+=(n)
 
 #define INSTR_DEBUG(m) \
-  ((m)->debug_level & (MU_SIEVE_DEBUG_INSTR|MU_SIEVE_DEBUG_DISAS))
-#define INSTR_DISASS(m) ((m)->debug_level & MU_SIEVE_DEBUG_DISAS)
+  (mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE9)) 
+#define INSTR_DISASS(m) \
+  (mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE8)) 
 
 void
-_mu_sv_instr_nop (mu_sieve_machine_t mach)
+_mu_i_sv_instr_nop (mu_sieve_machine_t mach)
 {
   if (INSTR_DEBUG (mach))
     mu_sieve_debug (mach, "%4lu: NOP", (unsigned long) (mach->pc - 1));
 }
 
 void
-_mu_sv_instr_source (mu_sieve_machine_t mach)
+_mu_i_sv_instr_source (mu_sieve_machine_t mach)
 {
   mach->locus.mu_file = (char*) SIEVE_ARG (mach, 0, string);
   mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
@@ -53,7 +54,7 @@ _mu_sv_instr_source (mu_sieve_machine_t mach)
 }
 		 
 void
-_mu_sv_instr_line (mu_sieve_machine_t mach)
+_mu_i_sv_instr_line (mu_sieve_machine_t mach)
 {
   mach->locus.mu_line = SIEVE_ARG (mach, 0, line);
   mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
@@ -80,9 +81,9 @@ instr_run (mu_sieve_machine_t mach)
     {
       mu_stream_printf (mach->errstream,
 			"\033s<%d>Arguments: ", MU_LOG_DEBUG);
-      mu_sv_print_value_list (arg_list, mach->errstream);
+      mu_i_sv_print_value_list (arg_list, mach->errstream);
       mu_stream_printf (mach->errstream, "\n\033s<%d>Tags: ", MU_LOG_DEBUG);
-      mu_sv_print_tag_list (tag_list, mach->errstream);
+      mu_i_sv_print_tag_list (tag_list, mach->errstream);
       mu_stream_printf (mach->errstream, "\n");
     }
 
@@ -92,7 +93,7 @@ instr_run (mu_sieve_machine_t mach)
 }
 
 void
-_mu_sv_instr_action (mu_sieve_machine_t mach)
+_mu_i_sv_instr_action (mu_sieve_machine_t mach)
 {
   mach->identifier = SIEVE_ARG (mach, 3, string);
   if (INSTR_DEBUG (mach))
@@ -105,7 +106,7 @@ _mu_sv_instr_action (mu_sieve_machine_t mach)
 }
 
 void
-_mu_sv_instr_test (mu_sieve_machine_t mach)
+_mu_i_sv_instr_test (mu_sieve_machine_t mach)
 {
   mach->identifier = SIEVE_ARG (mach, 3, string);
   if (INSTR_DEBUG (mach))
@@ -117,7 +118,7 @@ _mu_sv_instr_test (mu_sieve_machine_t mach)
 }
 
 void
-_mu_sv_instr_push (mu_sieve_machine_t mach)
+_mu_i_sv_instr_push (mu_sieve_machine_t mach)
 {
   if (INSTR_DEBUG (mach))
     {
@@ -135,7 +136,7 @@ _mu_sv_instr_push (mu_sieve_machine_t mach)
 }
 
 void
-_mu_sv_instr_pop (mu_sieve_machine_t mach)
+_mu_i_sv_instr_pop (mu_sieve_machine_t mach)
 {
   if (INSTR_DEBUG (mach))
     {
@@ -153,7 +154,7 @@ _mu_sv_instr_pop (mu_sieve_machine_t mach)
 }
 
 void
-_mu_sv_instr_not (mu_sieve_machine_t mach)
+_mu_i_sv_instr_not (mu_sieve_machine_t mach)
 {
   if (INSTR_DEBUG (mach))
     {
@@ -165,7 +166,7 @@ _mu_sv_instr_not (mu_sieve_machine_t mach)
 }
 
 void
-_mu_sv_instr_branch (mu_sieve_machine_t mach)
+_mu_i_sv_instr_branch (mu_sieve_machine_t mach)
 {
   long num = SIEVE_ARG (mach, 0, number);
 
@@ -183,7 +184,7 @@ _mu_sv_instr_branch (mu_sieve_machine_t mach)
 }
 
 void
-_mu_sv_instr_brz (mu_sieve_machine_t mach)
+_mu_i_sv_instr_brz (mu_sieve_machine_t mach)
 {
   long num = SIEVE_ARG (mach, 0, number);
   SIEVE_ADJUST (mach, 1);
@@ -202,7 +203,7 @@ _mu_sv_instr_brz (mu_sieve_machine_t mach)
 }
   
 void
-_mu_sv_instr_brnz (mu_sieve_machine_t mach)
+_mu_i_sv_instr_brnz (mu_sieve_machine_t mach)
 {
   long num = SIEVE_ARG (mach, 0, number);
   SIEVE_ADJUST (mach, 1);
@@ -263,12 +264,6 @@ mu_sieve_get_message_num (mu_sieve_machine_t mach)
   return mach->msgno;
 }
 
-int
-mu_sieve_get_debug_level (mu_sieve_machine_t mach)
-{
-  return mach->debug_level;
-}
-
 const char *
 mu_sieve_get_identifier (mu_sieve_machine_t mach)
 {
@@ -278,7 +273,15 @@ mu_sieve_get_identifier (mu_sieve_machine_t mach)
 int
 mu_sieve_is_dry_run (mu_sieve_machine_t mach)
 {
-  return mach->debug_level & MU_SIEVE_DRY_RUN;
+  return mach->dry_run;
+}
+
+int
+mu_sieve_set_dry_run (mu_sieve_machine_t mach, int val)
+{
+  if (mach->state != mu_sieve_state_compiled)
+    return EINVAL; //FIXME: another error code
+  return mach->dry_run = val;
 }
 
 int
@@ -304,12 +307,15 @@ sieve_run (mu_sieve_machine_t mach)
 int
 mu_sieve_disass (mu_sieve_machine_t mach)
 {
-  int level = mach->debug_level;
+  mu_debug_level_t lev;
   int rc;
-
-  mach->debug_level = MU_SIEVE_DEBUG_INSTR | MU_SIEVE_DEBUG_DISAS;
+  
+  mu_debug_get_category_level (mu_sieve_debug_handle, &lev);
+  mu_debug_set_category_level (mu_sieve_debug_handle,
+			       MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE8)
+			       | MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE9));
   rc = sieve_run (mach);
-  mach->debug_level = level;
+  mu_debug_set_category_level (mu_sieve_debug_handle, lev);
   return rc;
 }
   
@@ -339,6 +345,10 @@ mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox)
   if (!mach || !mbox)
     return EINVAL;
 
+  if (mach->state != mu_sieve_state_compiled)
+    return EINVAL; /* FIXME: Error code */
+  mach->state = mu_sieve_state_running;
+  
   mu_observer_create (&observer, mach);
   mu_observer_set_action (observer, _sieve_action, mach);
   mu_mailbox_get_observable (mbox, &observable);
@@ -353,6 +363,7 @@ mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox)
   mu_observable_detach (observable, observer);
   mu_observer_destroy (&observer, mach);
 
+  mach->state = mu_sieve_state_compiled;
   mach->mailbox = NULL;
   
   return rc;
@@ -366,10 +377,15 @@ mu_sieve_message (mu_sieve_machine_t mach, mu_message_t msg)
   if (!mach || !msg)
     return EINVAL;
 
+  if (mach->state != mu_sieve_state_compiled)
+    return EINVAL; /* FIXME: Error code */
+  mach->state = mu_sieve_state_running;
+
   mach->msgno = 1;
   mach->msg = msg;
   mach->mailbox = NULL;
   rc = sieve_run (mach);
+  mach->state = mu_sieve_state_compiled;
   mach->msg = NULL;
   
   return rc;
diff --git a/libmu_sieve/sieve-priv.h b/libmu_sieve/sieve-priv.h
index 894e19d..1ff62d9 100644
--- a/libmu_sieve/sieve-priv.h
+++ b/libmu_sieve/sieve-priv.h
@@ -31,20 +31,38 @@ typedef union
   mu_sieve_value_t *val;
   mu_list_t list;
   long number;
-  const char *string;
   size_t pc;
   size_t line;
+  int inum;
+  char *string;
 } sieve_op_t;
 
+struct mu_locus_range
+{
+  struct mu_locus beg;
+  struct mu_locus end;
+};
+  
+#define YYLTYPE struct mu_locus_range
+
+enum mu_sieve_state
+  {
+    mu_sieve_state_init,
+    mu_sieve_state_error,
+    mu_sieve_state_compiled,
+    mu_sieve_state_running
+  };
+
 struct mu_sieve_machine
 {
   /* Static data */
-  struct mu_locus locus;    /* Approximate location in the code */
+  struct mu_locus locus;     /* Approximate location in the code */
 
   mu_list_t memory_pool;     /* Pool of allocated memory objects */
   mu_list_t destr_list;      /* List of destructor functions */
 
   /* Symbol space: */
+  mu_opool_t string_pool;    /* String constants */
   mu_list_t test_list;       /* Tests */
   mu_list_t action_list;     /* Actions */
   mu_list_t comp_list;       /* Comparators */
@@ -54,11 +72,12 @@ struct mu_sieve_machine
   sieve_op_t *prog;          /* Compiled program */
 
   /* Runtime data */
+  enum mu_sieve_state state;
   size_t pc;                 /* Current program counter */
   long reg;                  /* Numeric register */
   mu_list_t stack;           /* Runtime stack */
 
-  int debug_level;           /* Debugging level */
+  int dry_run;               /* Dry-run mode */
   jmp_buf errbuf;            /* Target location for non-local exits */
   const char *identifier;    /* Name of action or test being executed */
   
@@ -76,54 +95,88 @@ struct mu_sieve_machine
   char *daemon_email;
   void *data;
 };
+
+enum mu_sieve_node_type
+  {
+    mu_sieve_node_noop,
+    mu_sieve_node_false,
+    mu_sieve_node_true,
+    mu_sieve_node_test,
+    mu_sieve_node_action,
+    mu_sieve_node_cond,
+    mu_sieve_node_anyof,
+    mu_sieve_node_allof,
+    mu_sieve_node_not,
+  };
+
+struct mu_sieve_node
+{
+  struct mu_sieve_node *prev, *next;
+  enum mu_sieve_node_type type;
+  struct mu_locus_range locus;
+  union
+  {
+    mu_sieve_value_t *value;
+    mu_list_t list;
+    struct mu_sieve_node *node;
+    struct
+    {
+      struct mu_sieve_node *expr;
+      struct mu_sieve_node *iftrue;
+      struct mu_sieve_node *iffalse;
+    } cond;
+    struct
+    {
+      mu_sieve_register_t *reg;
+      mu_list_t arg;
+    } command;
+  } v;
+};
+
+int mu_sieve_yyerror (const char *s);
+int mu_sieve_yylex (void);
 
-extern struct mu_locus mu_sieve_locus;
+int mu_i_sv_lex_begin (const char *name);
+int mu_i_sv_lex_begin_string (const char *buf, int bufsize,
+			      const char *fname, int line);
+void mu_i_sv_lex_finish (struct mu_sieve_machine *mach);
+
 extern mu_sieve_machine_t mu_sieve_machine;
-extern int mu_sieve_error_count; 
 
 #define TAG_COMPFUN "__compfun__"
-#define TAG_RELFUN  "__relfun__"
 
-void mu_sv_compile_error (struct mu_locus *locus,
-			  const char *fmt, ...) MU_PRINTFLIKE(2,3);
-void mu_sv_print_value_list (mu_list_t list, mu_stream_t str);
-void mu_sv_print_tag_list (mu_list_t list, mu_stream_t str);
+int mu_i_sv_code (struct mu_sieve_machine *mach, sieve_op_t op);
+
+void mu_i_sv_compile_error (struct mu_sieve_machine *mach,
+			    const char *fmt, ...) MU_PRINTFLIKE(2,3);
+
+int mu_i_sv_locus (struct mu_sieve_machine *mach, struct mu_locus_range *lr);
+int mu_i_sv_code_action (struct mu_sieve_machine *mach,
+			 mu_sieve_register_t *reg, mu_list_t arglist);
+int mu_i_sv_code_test (struct mu_sieve_machine *mach,
+		       mu_sieve_register_t *reg, mu_list_t arglist);
+
+/* Opcodes */
+void _mu_i_sv_instr_action (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_test (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_push (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_pop (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_not (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_branch (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_brz (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_brnz (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_nop (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_source (mu_sieve_machine_t mach);
+void _mu_i_sv_instr_line (mu_sieve_machine_t mach);
+
+int mu_i_sv_load_add_dir (mu_sieve_machine_t mach, const char *name);
+
+void mu_i_sv_register_standard_actions (mu_sieve_machine_t mach);
+void mu_i_sv_register_standard_tests (mu_sieve_machine_t mach);
+void mu_i_sv_register_standard_comparators (mu_sieve_machine_t mach);
+
+void mu_i_sv_print_value_list (mu_list_t list, mu_stream_t str);
+void mu_i_sv_print_tag_list (mu_list_t list, mu_stream_t str);
+
+void mu_i_sv_error (mu_sieve_machine_t mach);
 
-int mu_sv_lex_begin (const char *name);
-int mu_sv_lex_begin_string (const char *buf, int bufsize,
-			    const char *fname, int line);
-void mu_sv_lex_finish (void);
-int mu_sieve_yyerror (const char *s);
-int mu_sieve_yylex (); 
-
-void mu_sv_register_standard_actions (mu_sieve_machine_t mach);
-void mu_sv_register_standard_tests (mu_sieve_machine_t mach);
-void mu_sv_register_standard_comparators (mu_sieve_machine_t mach);
-
-int mu_sv_code (sieve_op_t *op);
-int mu_sv_code_instr (sieve_instr_t instr);
-int mu_sv_code_handler (mu_sieve_handler_t handler);
-int mu_sv_code_list (mu_list_t list);
-int mu_sv_code_number (long num);
-int mu_sv_code_test (mu_sieve_register_t *reg, mu_list_t arglist);
-int mu_sv_code_action (mu_sieve_register_t *reg, mu_list_t arglist);
-void mu_sv_code_anyof (size_t start);
-void mu_sv_code_allof (size_t start);
-int mu_sv_code_source (const char *name);
-int mu_sv_code_line (size_t line);
-void mu_sv_change_source (void);
-
-void _mu_sv_instr_action (mu_sieve_machine_t mach);
-void _mu_sv_instr_test (mu_sieve_machine_t mach);
-void _mu_sv_instr_push (mu_sieve_machine_t mach);
-void _mu_sv_instr_pop (mu_sieve_machine_t mach);
-void _mu_sv_instr_not (mu_sieve_machine_t mach);
-void _mu_sv_instr_branch (mu_sieve_machine_t mach);
-void _mu_sv_instr_brz (mu_sieve_machine_t mach);
-void _mu_sv_instr_brnz (mu_sieve_machine_t mach);
-void _mu_sv_instr_nop (mu_sieve_machine_t mach);
-void _mu_sv_instr_source (mu_sieve_machine_t mach);
-void _mu_sv_instr_line (mu_sieve_machine_t mach);
-
-int mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name);
-  
diff --git a/libmu_sieve/sieve.l b/libmu_sieve/sieve.l
index 7b478ee..1bbb2a0 100644
--- a/libmu_sieve/sieve.l
+++ b/libmu_sieve/sieve.l
@@ -35,10 +35,6 @@
 #include <sieve-priv.h>
 #include <sieve-gram.h>
   
-struct mu_locus mu_sieve_locus;
-ino_t sieve_source_inode;
-
-static mu_list_t string_list;
 static char *multiline_delimiter;
 static int strip_tabs; 
 
@@ -57,6 +53,11 @@ static void sieve_searchpath (void);
 static char *str_unescape (char *text, size_t len);
 static int isemptystr (char *text);
 
+static ino_t sieve_source_inode;
+struct mu_locus mu_sieve_locus;
+static int newline;
+static mu_list_t file_names;
+
 static mu_stream_t input_stream;
  
 static int
@@ -89,6 +90,61 @@ fillbuf (char *buf, size_t max_size)
         yy_switch_to_buffer (s); \
 } while (0)
 
+static int
+file_name_cmp (const void *a, const void *b)  
+{
+  return strcmp (a, b);
+}
+
+static void
+init_locus (char const *name, ino_t ino)
+{
+  mu_sieve_locus.mu_file = NULL;
+  if (name)
+    {
+      if (!file_names)
+	{
+	  mu_list_create (&file_names);
+	  mu_list_set_comparator (file_names, file_name_cmp);
+	  mu_list_set_destroy_item (file_names, mu_list_free_item);
+	}
+      else
+	{
+	  mu_list_locate (file_names, (void*) name,
+			  (void**) &mu_sieve_locus.mu_file);
+	}
+      if (!mu_sieve_locus.mu_file)
+	{
+	  mu_sieve_locus.mu_file = strdup (name);//FIXME: Error checking
+	  mu_list_append (file_names, mu_sieve_locus.mu_file);
+	}
+    }
+  mu_sieve_locus.mu_line = 1;
+  mu_sieve_locus.mu_col = 0;
+  newline = 0;
+  sieve_source_inode = ino;
+}
+ 
+static void
+advance_locus (void)
+{
+  if (newline)
+    {
+      mu_sieve_locus.mu_line++;
+      mu_sieve_locus.mu_col = 0;
+      yylloc.beg = yylloc.end = mu_sieve_locus;                        
+    }
+  else
+    {
+      mu_sieve_locus.mu_col += yyleng;
+      yylloc.beg = yylloc.end = mu_sieve_locus;                        
+      yylloc.beg.mu_col -= yyleng;                             
+    }
+  newline = yytext[yyleng-1] == '\n';
+}
+ 
+#define YY_USER_ACTION advance_locus ();
+   
 struct buffer_ctx
 {
   struct buffer_ctx *prev;
@@ -125,8 +181,9 @@ push_source (const char *name)
         
   if (stat (name, &st))
     {
-      mu_sv_compile_error (&mu_sieve_locus,
-                           _("cannot stat `%s': %s"), name, strerror (errno));
+      mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
+			_("cannot stat `%s': %s"), name, strerror (errno));
+      mu_i_sv_error (mu_sieve_machine);
       return 1;
     }
 
@@ -139,28 +196,36 @@ push_source (const char *name)
     {
       yyerror (_("recursive inclusion"));
       if (ctx->prev)
-	mu_sv_compile_error (&ctx->prev->locus,
-                             _("`%s' already included here"),
-                             name);
+	{
+	  mu_diag_at_locus (MU_LOG_ERROR, &ctx->prev->locus,
+			    _("`%s' already included here"),
+			    name);
+	  mu_i_sv_error (mu_sieve_machine);
+	}
       else
-	mu_sv_compile_error (&mu_sieve_locus, 
-                             _("`%s' already included at top level"),
-		             name);
+	{
+	  mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
+			    _("`%s' already included at top level"),
+			    name);
+	  mu_i_sv_error (mu_sieve_machine);
+	}	  
       return 1;
     }
 
   rc = mu_file_stream_create (&stream, name, MU_STREAM_READ);
   if (rc)
     {
-      mu_sv_compile_error (&mu_sieve_locus, 
-                           _("cannot open file `%s': %s"),
-			   name, mu_strerror (rc));
+      mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
+			_("cannot open file `%s': %s"),
+			name, mu_strerror (rc));
+      mu_i_sv_error (mu_sieve_machine);
       return 1;
     }
 
   /* Push current context */
   if (mu_sieve_locus.mu_file)
     {
+      advance_locus ();
       ctx = mu_sieve_alloc (sizeof (*ctx));
       ctx->locus = mu_sieve_locus;
       ctx->i_node = sieve_source_inode;
@@ -172,14 +237,9 @@ push_source (const char *name)
       SET_BUFFER_STATE (ctx->state);
     }
   input_stream = stream;
-  
-  mu_sieve_locus.mu_file = strdup (name);
-  mu_sieve_locus.mu_line = 1;
-  mu_sieve_locus.mu_col = 0; /* FIXME: not used */
-  sieve_source_inode = st.st_ino;
 
-  mu_sv_change_source ();
-  
+  init_locus (name, st.st_ino);
+
   return 0;
 }
 
@@ -190,26 +250,21 @@ pop_source ()
 
   mu_stream_destroy (&input_stream);
 
-  if (mu_sieve_locus.mu_file)
-    free (mu_sieve_locus.mu_file);
   if (!context_stack)
     {
       input_stream = NULL;
-      mu_sieve_locus.mu_file = NULL;
+      init_locus (NULL, 0);
       return 1;
     }
   /* Restore previous context */
   input_stream = context_stack->input;
   mu_sieve_locus = context_stack->locus;
-  mu_sieve_locus.mu_line++; /* #include rule did not increment it */
   sieve_source_inode = context_stack->i_node;
   RESTORE_BUFFER_STATE (context_stack->state);
   ctx = context_stack->prev;
   free (context_stack);
   context_stack = ctx;
 
-  mu_sv_change_source ();
-
   return 0;
 }
 %}
@@ -225,16 +280,16 @@ SIZESUF [kKmMgG]
 
 %%
          /* C-style comments */
-"/*"         BEGIN(COMMENT);
+"/*"                    { BEGIN(COMMENT); }
 <COMMENT>[^*\n]*        /* eat anything that's not a '*' */
 <COMMENT>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
-<COMMENT>\n             ++mu_sieve_locus.mu_line;
-<COMMENT>"*"+"/"        BEGIN(INITIAL);
+<COMMENT>\n             ;
+<COMMENT>"*"+"/"        { BEGIN (INITIAL); }
          /* Preprocessor directives (an extension) */
 #[ \t]*include.*\n      { sieve_include (); }
-#[ \t]*searchpath.*\n          { sieve_searchpath (); } 
+#[ \t]*searchpath.*\n   { sieve_searchpath (); } 
          /* End-of-line comments */
-#.*\n   { mu_sieve_locus.mu_line++; }
+#.*\n   ;
 #.*     /* end-of-file comment */;
          /* Reserved words */
 require return REQUIRE; 
@@ -244,6 +299,8 @@ else	return ELSE;
 anyof	return ANYOF;   
 allof	return ALLOF;   
 not     return NOT;
+false   return FALSE;
+true    return TRUE;
          /* Identifiers */
 {IDENT}  { ident (yytext); return IDENT; } 
 :{IDENT} { ident (yytext + 1); return TAG; }
@@ -254,34 +311,28 @@ not     return NOT;
          /* Quoted strings */
 \"[^\\"\n]*\"                 { return string (); }
 \"[^\\"\n]*\\.    { BEGIN(STR);
-                   line_begin ();
-		   line_add (str_unescape (yytext + 1, yyleng - 1), 0); }
+                    line_begin ();
+  		    line_add (str_unescape (yytext + 1, yyleng - 1), 0); }
 <STR>[^\\"\n]*\\. { line_add (str_unescape (yytext, yyleng), 0); }
 <STR>[^\\"\n]*\" { BEGIN(INITIAL);
-                   if (yyleng > 1) 
+                  if (yyleng > 1) 
                      line_add (yytext, yyleng - 1); 
                    line_finish ();
 		   return STRING; }
          /* Multiline strings */
 text:-?[ \t]*#.*\n       { BEGIN(ML);
-                           multiline_begin ();
-			   mu_sieve_locus.mu_line++; }
+                           multiline_begin (); }
 text:-?[ \t]*\n          { BEGIN(ML);
-                           multiline_begin ();
-			   mu_sieve_locus.mu_line++; }
-text:-?\\?{IDENT}[ \t]*#.*\n { BEGIN(ML); multiline_begin ();
-                               mu_sieve_locus.mu_line++; }
-text:-?\\?{IDENT}[ \t]*\n    { BEGIN(ML); multiline_begin ();
-                               mu_sieve_locus.mu_line++; }
+                           multiline_begin (); }
+text:-?\\?{IDENT}[ \t]*#.*\n { BEGIN(ML);
+                               multiline_begin (); }
+text:-?\\?{IDENT}[ \t]*\n    { BEGIN(ML);
+                               multiline_begin (); }
 <ML>#[ \t]*include.*\n    { if (multiline_delimiter[0] == '\\')
-                              {
-				mu_sieve_locus.mu_line++;
-                                multiline_add (NULL);
-			      }
+                              multiline_add (NULL);
                             else
                               sieve_include (); }
 <ML>.*\n { char *p = multiline_strip_tabs (yytext);
-           mu_sieve_locus.mu_line++;
 	   
            if (strncmp (p, multiline_delimiter, strlen (multiline_delimiter))
 	        == 0
@@ -296,7 +347,7 @@ text:-?\\?{IDENT}[ \t]*\n    { BEGIN(ML); multiline_begin ();
 	    multiline_add (NULL); } 
 {WS}     ;
          /* Other tokens */
-\n { mu_sieve_locus.mu_line++; } 
+\n       ;
 . return yytext[0];
 
 %%
@@ -400,7 +451,7 @@ sieve_include ()
 }
 
 static void
-sieve_searchpath ()
+sieve_searchpath (void)
 {
   char *p, *endp = yytext + yyleng, *name;
   
@@ -410,20 +461,20 @@ sieve_searchpath ()
   name = get_file_name (p, endp, NULL);
   if (name)
     {
-      mu_sv_load_add_dir (mu_sieve_machine, name);
+      mu_i_sv_load_add_dir (mu_sieve_machine, name);
       free (name);
     }
 }
 
 int
-mu_sv_lex_begin (const char *name)
+mu_i_sv_lex_begin (const char *name)
 {
   return push_source (name);
 }
 
 int
-mu_sv_lex_begin_string (const char *buf, int bufsize,
-			const char *fname, int line)
+mu_i_sv_lex_begin_string (const char *buf, int bufsize,
+			  const char *fname, int line)
 {
   int rc;
   
@@ -439,19 +490,18 @@ mu_sv_lex_begin_string (const char *buf, int bufsize,
       return 1;
     }
 
-  mu_sieve_locus.mu_file = strdup (fname);
-  mu_sieve_locus.mu_line = line;
-  sieve_source_inode = 0;
+  init_locus (fname, 0);
 
-  mu_sv_change_source ();
   return 0;
 }
 
 void
-mu_sv_lex_finish ()
+mu_i_sv_lex_finish (struct mu_sieve_machine *mach)
 {
   while (pop_source () == 0)
     ;
+  mach->source_list = file_names;
+  file_names = NULL;
 }
   
 static int
@@ -507,19 +557,7 @@ multiline_strip_tabs (char *text)
 static void
 line_add (char *text, size_t len)
 {
-  char *s;
-  
-  if (len == 0)
-    len = strlen (text);
-  s = malloc (len + 1);
-  if (!s)
-    {
-      yyerror (_("not enough memory"));
-      exit (1);
-    }
-  memcpy (s, text, len);
-  s[len] = 0;
-  mu_list_append (string_list, s);
+  mu_opool_append (mu_sieve_machine->string_pool, text, len);
 }
 
 static void
@@ -527,27 +565,17 @@ multiline_add (char *s)
 {
   if (!s)
     s = multiline_strip_tabs (yytext);
-  line_add (s, 0);
+  mu_opool_appendz (mu_sieve_machine->string_pool, s);
 }
 
 static void
-line_begin ()
+line_begin (void)
 {
-  int status;
-
-  if (string_list)
-    mu_sieve_slist_destroy (&string_list);
-  status = mu_list_create (&string_list);
-  if (status)
-    {
-      mu_sv_compile_error (&mu_sieve_locus,
-                           "mu_list_create: %s", mu_strerror (status));
-      exit (1);
-    }
+  /* nothing */
 }
 
 static void
-multiline_begin ()
+multiline_begin (void)
 {
   char *p = yytext + 5; /* past the text: keyword */
 
@@ -587,42 +615,14 @@ multiline_begin ()
 }
 
 static void
-line_finish ()
+line_finish (void)
 {
-  mu_iterator_t itr;
-  int length = 0;
-  char *p;
-  
-  if (!string_list || mu_list_get_iterator (string_list, &itr))
-    return;
-
-  /* Count number of characters in the multiline */
-  for (mu_iterator_first (itr); !mu_iterator_is_done (itr); mu_iterator_next (itr))
-    {
-      char *s;
-      mu_iterator_current (itr, (void **)&s);
-      length += strlen (s);
-    }
-
-  /* Copy the contents */
-  yylval.string = mu_sieve_malloc (mu_sieve_machine, length + 1);
-  p = yylval.string;
-  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
-       mu_iterator_next (itr))
-    {
-      char *s;
-      mu_iterator_current (itr, (void **)&s);
-      strcpy (p, s);
-      p += strlen (s);
-      free (s);
-    }
-  *p = 0;
-  mu_iterator_destroy (&itr);
-  mu_list_destroy (&string_list);
+  mu_opool_append_char (mu_sieve_machine->string_pool, 0);
+  yylval.string = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
 }
 
 static void
-multiline_finish ()
+multiline_finish (void)
 {
   line_finish ();
 }
diff --git a/libmu_sieve/sieve.y b/libmu_sieve/sieve.y
index ce6fa4d..86fb962 100644
--- a/libmu_sieve/sieve.y
+++ b/libmu_sieve/sieve.y
@@ -24,220 +24,256 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <sieve-priv.h>
+#include <mailutils/stdstream.h>
 
 mu_sieve_machine_t mu_sieve_machine;
 int mu_sieve_error_count;
-
-static void branch_fixup (size_t start, size_t end);
+static struct mu_sieve_node *sieve_tree;
+
+static struct mu_sieve_node *node_alloc (enum mu_sieve_node_type,
+					 struct mu_locus_range *);
+static void cond_join (struct mu_sieve_node *node);
+
+#define YYLLOC_DEFAULT(Current, Rhs, N)                         \
+  do								\
+    {								\
+      if (N)							\
+	{							\
+	  (Current).beg = YYRHSLOC(Rhs, 1).beg;			\
+	  (Current).end = YYRHSLOC(Rhs, N).end;			\
+	}							\
+      else							\
+	{							\
+	  (Current).beg = YYRHSLOC(Rhs, 0).end;			\
+	  (Current).end = (Current).beg;			\
+	}							\
+    } while (0)
+
+#define LOCUS_EQ(a,b) \
+  ((((a)->mu_file == (b)->mu_file)                                      \
+          || ((a)->mu_file && (b)->mu_file				\
+	      && strcmp((a)->mu_file, (b)->mu_file) == 0))		\
+   && (a)->mu_line == (b)->mu_line)
+	 
+#define YY_LOCATION_PRINT(File, Loc)				    \
+  do								    \
+    {								    \
+      if (LOCUS_EQ(&(Loc).beg, &(Loc).end))			    \
+	fprintf(File, "%s:%u.%u-%u.%u",				    \
+		(Loc).beg.mu_file,				    \
+		(Loc).beg.mu_line, (Loc).beg.mu_col,		    \
+		(Loc).end.mu_line, (Loc).end.mu_col);		    \
+      else							    \
+	fprintf(File, "%s:%u.%u-%s:%u.%u",			    \
+		(Loc).beg.mu_file,				    \
+		(Loc).beg.mu_line, (Loc).beg.mu_col,		    \
+		(Loc).end.mu_file,				    \
+		(Loc).end.mu_line, (Loc).end.mu_col);		    \
+    }								    \
+  while (0)
 %}
 
+%error-verbose
+%locations
+
 %union {
   char *string;
   size_t number;
-  sieve_instr_t instr;
   mu_sieve_value_t *value;
   mu_list_t list;
-  size_t pc;
-  struct {
-    size_t start;
-    size_t end;
-  } pclist;
-  struct {
+  struct
+  {
     char *ident;
     mu_list_t args;
   } command;
-  struct {
-    size_t begin;
-    size_t cond;
-    size_t branch;
-  } branch;
+  struct node_list
+  {
+    struct mu_sieve_node *head, *tail;
+  } node_list;
+  struct mu_sieve_node *node;
 }
 
 %token <string> IDENT TAG
 %token <number> NUMBER
 %token <string> STRING MULTILINE
-%token REQUIRE IF ELSIF ELSE ANYOF ALLOF NOT
+%token REQUIRE IF ELSIF ELSE ANYOF ALLOF NOT FALSE TRUE
 
 %type <value> arg
 %type <list> slist stringlist stringorlist arglist maybe_arglist
 %type <command> command
-%type <pclist> testlist
-%type <pc> action test statement list elsif else cond begin if block
-%type <branch> elsif_branch maybe_elsif else_part
+%type <node> action test statement block cond
+%type <node> else_part
+%type <node_list> list testlist elsif_branch maybe_elsif 
 
 %%
 
 input        : /* empty */
+               {
+		 sieve_tree = NULL;
+	       }
              | list
-               { /* to placate bison */ }
+               {
+		 sieve_tree = $1.head;
+	       }
              ;
 
 list         : statement
+               {
+		 $$.head = $$.tail = $1;
+	       }
              | list statement
+               {
+		 if ($2)
+		   {
+		     $2->prev = $1.tail;
+		     if ($1.tail)
+		       $1.tail->next = $2;
+		     else
+		       $1.head = $2;
+		     $1.tail = $2;
+		   }
+		 $$ = $1;
+	       }
              ;
 
 statement    : REQUIRE stringorlist ';'
                {
-		 mu_sieve_require ($2);
+		 mu_sieve_require (mu_sieve_machine, $2);
 		 /*  All the items in $2 are registered in memory_pool,
 		     so we don't free them */
 		 mu_list_destroy (&$2);
-		 $$ = mu_sieve_machine->pc;
+		 $$ = NULL;
 	       }
              | action ';'
 	     /* 1  2     3       4    */ 
-             | if cond block else_part
+             | IF cond block else_part
                {
-		 mu_sieve_machine->prog[$2].pc = $4.begin - $2 - 1;
-		 if ($4.branch)
-		   branch_fixup ($4.branch, mu_sieve_machine->pc);
+		 $$ = node_alloc (mu_sieve_node_cond, &@1);
+		 $$->v.cond.expr = $2;
+		 $$->v.cond.iftrue = $3;
+		 $$->v.cond.iffalse = $4;
 	       }		 
              ;
 
-if           : IF
-               {
-		 $$ = mu_sieve_machine->pc;
-	       }
-             ;
-
 else_part    : maybe_elsif
                {
-		 if ($1.begin)
-		   mu_sieve_machine->prog[$1.cond].pc =
-		                  mu_sieve_machine->pc - $1.cond - 1;
-		 else
-		   {
-		     $$.begin = mu_sieve_machine->pc;
-		     $$.branch = 0;
-		   }
+		 cond_join ($1.head);
+		 $$ = $1.head;
 	       }
-             | maybe_elsif else block
+             | maybe_elsif ELSE block
                {
-		 if ($1.begin)
+		 $3->prev = $1.tail;
+		 if ($1.head)
 		   {
-		     mu_sieve_machine->prog[$1.cond].pc = $3 - $1.cond - 1;
-		     mu_sieve_machine->prog[$2].pc = $1.branch;
-		     $$.begin = $1.begin;
-		     $$.branch = $2;
+		     $1.tail->next = $3;
+		     $1.tail = $3;
+		     cond_join ($1.head);
+		     $$ = $1.head;
 		   }
 		 else
-		   {
-		     $$.begin = $3;
-		     $$.branch = $2;
-		   }
+		   $$ = $3;
 	       }
              ;
 
 maybe_elsif  : /* empty */
                {
-		 $$.begin = 0;
+		 $$.head = $$.tail = NULL;
 	       }
              | elsif_branch
              ;
 
-elsif_branch : elsif begin cond block
+elsif_branch : ELSIF cond block
                {
-		 $$.begin = $2; 
-		 $$.branch = $1;
-		 $$.cond = $3;
+		 struct mu_sieve_node *node =
+		   node_alloc (mu_sieve_node_cond, &@1);
+		 node->v.cond.expr = $2;
+		 node->v.cond.iftrue = $3;
+		 node->v.cond.iffalse = NULL;
+		 $$.head = $$.tail = node;
 	       }
-             | elsif_branch elsif begin cond block
+             | elsif_branch ELSIF cond block
                {
-		 mu_sieve_machine->prog[$1.cond].pc = $3 - $1.cond - 1;
-		 mu_sieve_machine->prog[$2].pc = $1.branch;
-		 $$.begin = $1.begin;
-		 $$.branch = $2;
-		 $$.cond = $4;
-	       }
-             ;
-
-elsif        : ELSIF
-               {
-		 mu_sv_code_instr (_mu_sv_instr_branch);
-		 $$ = mu_sieve_machine->pc;
-		 mu_sv_code_number (0);
-	       }
-             ;
-
-else         : ELSE
-               {
-		 mu_sv_code_instr (_mu_sv_instr_branch);
-		 $$ = mu_sieve_machine->pc;
-		 mu_sv_code_number (0);
+		 struct mu_sieve_node *node =
+		   node_alloc (mu_sieve_node_cond, &@2);
+		 node->v.cond.expr = $3;
+		 node->v.cond.iftrue = $4;
+		 node->v.cond.iffalse = NULL;
+
+		 node->prev = $1.tail;
+		 $1.tail->next = node;
+		 $1.tail = node;
+		 $$ = $1;
 	       }
              ;
 
 block        : '{' list '}'
                {
-		 $$ = $2;
+		 $$ = $2.head;
 	       }
              ;
 
-testlist     : cond_expr
-               {
-		 $$.start = $$.end = mu_sieve_machine->pc;
-		 if (mu_sv_code_instr (_mu_sv_instr_brz)
-		     || mu_sv_code_number (0))
-		   YYERROR;
-	       }
-             | testlist ',' cond_expr
+testlist     : cond
                {
-		 mu_sieve_machine->prog[$1.end+1].pc = mu_sieve_machine->pc;
-		 $1.end = mu_sieve_machine->pc;
-		 if (mu_sv_code_instr (_mu_sv_instr_brz)
-		     || mu_sv_code_number (0))
-		   YYERROR;
-		 $$ = $1;
+		 $$.head = $$.tail = $1;
 	       }
-             ;
-
-cond         : cond_expr
+             | testlist ',' cond
                {
-		 mu_sv_code_instr (_mu_sv_instr_brz);
-		 $$ = mu_sieve_machine->pc;
-		 mu_sv_code_number (0);
+		 $3->prev = $1.tail;
+		 $1.tail->next = $3;
+		 $1.tail = $3;
 	       }
              ;
 
-cond_expr    : test
-               { /* to placate bison */ }
+cond         : test
              | ANYOF '(' testlist ')'
                {
-		 mu_sv_code_anyof ($3.start);
+		 $$ = node_alloc (mu_sieve_node_anyof, &@1);
+		 $$->v.node = $3.head;
 	       }
              | ALLOF '(' testlist ')'
                {
-		 mu_sv_code_allof ($3.start);
+		 $$ = node_alloc (mu_sieve_node_allof, &@1);
+		 $$->v.node = $3.head;
 	       }
-             | NOT cond_expr
+             | NOT cond
                {
-		 if (mu_sv_code_instr (_mu_sv_instr_not))
-		   YYERROR;
+		 $$ = node_alloc (mu_sieve_node_not, &@1);
+		 $$->v.node = $2;
 	       }
              ;
 
-begin        : /* empty */
-               {
-		 $$ = mu_sieve_machine->pc;
-	       }
-             ; 
-
 test         : command
                {
-		 mu_sieve_register_t *reg = 
-		        mu_sieve_test_lookup (mu_sieve_machine, $1.ident);
-		 $$ = mu_sieve_machine->pc;
+		 mu_sieve_register_t *reg;
 
+		 mu_sieve_machine->locus = @1.beg;
+		 reg = mu_sieve_test_lookup (mu_sieve_machine, $1.ident);
 		 if (!reg)
-		   mu_sv_compile_error (&mu_sieve_locus,
-					_("unknown test: %s"),
-					$1.ident);
+		   {
+		     mu_diag_at_locus (MU_LOG_ERROR, &@1.beg,
+				       _("unknown test: %s"),
+				       $1.ident);
+		     mu_i_sv_error (mu_sieve_machine);
+		   }
 		 else if (!reg->required)
-		   mu_sv_compile_error (&mu_sieve_locus,
-					_("test `%s' has not been required"),
-					$1.ident);
-		 else if (mu_sv_code_test (reg, $1.args))
-		   YYERROR;
+		   {
+		     mu_diag_at_locus (MU_LOG_ERROR, &@1.beg,
+				       _("test `%s' has not been required"),
+				       $1.ident);
+		     mu_i_sv_error (mu_sieve_machine);
+		   }
+		 
+		 $$ = node_alloc (mu_sieve_node_test, &@1);
+		 $$->v.command.reg = reg;
+		 $$->v.command.arg = $1.args;
+	       }
+             | TRUE
+	       {
+		 $$ = node_alloc (mu_sieve_node_true, &@1);
+	       }
+             | FALSE
+	       {
+		 $$ = node_alloc (mu_sieve_node_false, &@1);
 	       }
              ;
 
@@ -250,20 +286,29 @@ command      : IDENT maybe_arglist
 
 action       : command
                {
-		 mu_sieve_register_t *reg = 
-		        mu_sieve_action_lookup (mu_sieve_machine, $1.ident);
+		 mu_sieve_register_t *reg;
+
+		 mu_sieve_machine->locus = @1.beg;
+		 reg = mu_sieve_action_lookup (mu_sieve_machine, $1.ident);
 		 
-		 $$ = mu_sieve_machine->pc;
 		 if (!reg)
-		   mu_sv_compile_error (&mu_sieve_locus,
-					_("unknown action: %s"),
-					$1.ident);
+		   {
+		     mu_diag_at_locus (MU_LOG_ERROR, &@1.beg,
+				       _("unknown action: %s"),
+				       $1.ident);
+		     mu_i_sv_error (mu_sieve_machine);
+		   }
 		 else if (!reg->required)
-		   mu_sv_compile_error (&mu_sieve_locus,
-					_("action `%s' has not been required"),
-					$1.ident);
-		 else if (mu_sv_code_action (reg, $1.args))
-		   YYERROR;
+		   {
+		     mu_diag_at_locus (MU_LOG_ERROR, &@1.beg,
+				       _("action `%s' has not been required"),
+				       $1.ident);
+		     mu_i_sv_error (mu_sieve_machine);
+		   }
+		 
+		 $$ = node_alloc(mu_sieve_node_action, &@1);
+		 $$->v.command.reg = reg;
+		 $$->v.command.arg = $1.args;
 	       }
              ;
 
@@ -287,7 +332,7 @@ arglist      : arg
              ;
 
 arg          : stringlist
-               {
+               {		 
 		 $$ = mu_sieve_value_create (SVT_STRING_LIST, $1);
 	       }
              | STRING
@@ -339,10 +384,604 @@ slist        : STRING
 int
 yyerror (const char *s)
 {
-  mu_sv_compile_error (&mu_sieve_locus, "%s", s);
+  extern struct mu_locus mu_sieve_locus;
+
+  mu_sieve_machine->locus = mu_sieve_locus;
+  mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus, "%s", s);
+  mu_i_sv_error (mu_sieve_machine);
+  return 0;
+}
+
+static void
+cond_join (struct mu_sieve_node *node)
+{
+  while (node)
+    {
+      struct mu_sieve_node *next = node->next;
+      node->prev = node->next = NULL;
+      node->v.cond.iffalse = next;
+      node = next;
+    }
+}
+
+static struct mu_sieve_node *
+node_alloc (enum mu_sieve_node_type type, struct mu_locus_range *lr)
+{
+  struct mu_sieve_node *node = malloc (sizeof (*node));
+  if (node)
+    {
+      node->prev = node->next = NULL;
+      node->type = type;
+      node->locus = *lr;
+    }
+  return node;
+}
+
+static void node_optimize (struct mu_sieve_node *node);
+static void node_free (struct mu_sieve_node *node);
+static void node_replace (struct mu_sieve_node *node,
+			  struct mu_sieve_node *repl);
+static int node_code (struct mu_sieve_machine *mach,
+		      struct mu_sieve_node *node);
+static void node_dump (mu_stream_t str, struct mu_sieve_node *node,
+		       unsigned level);
+
+static void tree_free (struct mu_sieve_node **tree);
+static void tree_optimize (struct mu_sieve_node *tree);
+static int tree_code (struct mu_sieve_machine *mach,
+		      struct mu_sieve_node *tree);
+static void tree_dump (mu_stream_t str, struct mu_sieve_node *tree, unsigned level);
+
+static void
+indent (mu_stream_t str, unsigned level)
+{
+#define tab "  "
+#define tablen (sizeof (tab) - 1)
+  while (level--)
+    mu_stream_write (str, tab, tablen, NULL);
+}
+
+/* mu_sieve_node_noop */
+static void
+dump_node_noop (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  indent (str, level);
+  mu_stream_printf (str, "NOOP\n");  
+}
+
+/* mu_sieve_node_false */
+static void
+dump_node_false (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  indent (str, level);
+  mu_stream_printf (str, "FALSE\n");
+}
+
+/* mu_sieve_node_true */
+static void
+dump_node_true (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  indent (str, level);
+  mu_stream_printf (str, "TRUE\n");
+}
+
+/* mu_sieve_node_test & mu_sieve_node_action */
+static void
+free_node_command (struct mu_sieve_node *node)
+{
+  mu_list_destroy (&node->v.command.arg);
+}
+
+static int
+code_node_test (struct mu_sieve_machine *mach, struct mu_sieve_node *node)
+{
+  return mu_i_sv_code_test (mach, node->v.command.reg, node->v.command.arg);
+}
+
+static int
+code_node_action (struct mu_sieve_machine *mach, struct mu_sieve_node *node)
+{
+  return mu_i_sv_code_action (mach, node->v.command.reg, node->v.command.arg);
+}
+
+struct string_dumper_data
+{
+  int init;
+  mu_stream_t stream;
+};
+
+static int
+string_dumper (void *item, void *data)
+{
+  struct string_dumper_data *dp = data;
+  if (dp->init == 0)
+    dp->init = 1;
+  else
+    mu_stream_printf (dp->stream, ", ");
+  mu_stream_printf (dp->stream, "\"%s\"", (char*)item);
+  return 0;
+}
+
+static int
+dump_val (void *item, void *data)
+{
+  mu_sieve_value_t *val = item;
+  mu_stream_t str = data;
+
+  mu_stream_printf (str, " ");
+  switch (val->type)
+    {
+    case SVT_VOID:
+      mu_stream_printf (str, "(void)");
+      break;
+      
+    case SVT_NUMBER:
+      mu_stream_printf (str, "%zu", val->v.number);
+      break;
+      
+    case SVT_STRING:
+      mu_stream_printf (str, "\"%s\"", val->v.string);
+      break;
+      
+    case SVT_STRING_LIST:
+      {
+	struct string_dumper_data d;
+	d.init = 0;
+	d.stream = str;
+	mu_stream_printf (str, "[");
+	mu_list_foreach (val->v.list, string_dumper, &d);
+	mu_stream_printf (str, "]");
+      }
+      break;
+      
+    case SVT_TAG:
+      mu_stream_printf (str, ":%s", val->v.string);
+      break;
+      
+    case SVT_IDENT:
+      mu_stream_printf (str, "%s", val->v.string);
+      break;
+	
+    case SVT_VALUE_LIST:
+      mu_stream_printf (str, "[");
+      mu_list_foreach (val->v.list, dump_val, str);
+      mu_stream_printf (str, "]");
+      break;
+      
+    case SVT_POINTER:
+      mu_stream_printf (str, "%p", val->v.ptr);
+      break;
+
+    default:
+      abort ();
+    }
+  return 0;
+}
+  
+static void
+dump_node_command (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  indent (str, level);
+  mu_stream_printf (str, "COMMAND %s", node->v.command.reg->name);
+  mu_list_foreach (node->v.command.arg, dump_val, str);
+  mu_stream_printf (str, "\n");
+}
+
+/* mu_sieve_node_cond */
+static void
+free_node_cond (struct mu_sieve_node *node)
+{
+  tree_free (&node->v.cond.expr);
+  tree_free (&node->v.cond.iftrue);
+  tree_free (&node->v.cond.iffalse);	     
+}
+
+static void
+optimize_node_cond (struct mu_sieve_node *node)
+{
+  tree_optimize (node->v.cond.expr);
+  switch (node->v.cond.expr->type)
+    {
+    case mu_sieve_node_true:
+      tree_optimize (node->v.cond.iftrue);
+      node_replace (node, node->v.cond.iftrue);
+      break;
+
+    case mu_sieve_node_false:
+      tree_optimize (node->v.cond.iffalse);
+      node_replace (node, node->v.cond.iffalse);
+      break;
+
+    default:
+      tree_optimize (node->v.cond.iftrue);
+      tree_optimize (node->v.cond.iffalse);
+    }
+}
+
+static int
+code_node_cond (struct mu_sieve_machine *mach, struct mu_sieve_node *node)
+{
+  size_t br1;
+  
+  tree_code (mach, node->v.cond.expr);
+  mu_i_sv_code (mach, (sieve_op_t) _mu_i_sv_instr_brz);
+  br1 = mach->pc;
+  mu_i_sv_code (mach, (sieve_op_t) 0);
+  tree_code (mach, node->v.cond.iftrue);
+  
+  if (node->v.cond.iffalse)
+    {
+      size_t br2;
+
+      mu_i_sv_code (mach, (sieve_op_t) _mu_i_sv_instr_branch);
+      br2 = mach->pc;
+      mu_i_sv_code (mach, (sieve_op_t) 0);
+      
+      mach->prog[br1].pc = mach->pc - br1 - 1;
+
+      tree_code (mach, node->v.cond.iffalse);
+      mach->prog[br2].pc = mach->pc - br2 - 1;
+    }
+  else
+    mach->prog[br1].pc = mach->pc - br1 - 1;
+  return 0;
+}
+  
+static void
+dump_node_cond (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  indent (str, level);
+  mu_stream_printf (str, "COND\n");
+
+  ++level;
+
+  indent (str, level);
+  mu_stream_printf (str, "EXPR:\n");
+  tree_dump (str, node->v.cond.expr, level + 1);
+
+  indent (str, level);
+  mu_stream_printf (str, "IFTRUE:\n");
+  tree_dump (str, node->v.cond.iftrue, level + 1);
+
+  indent (str, level);
+  mu_stream_printf (str, "IFFALSE:\n");
+  tree_dump (str, node->v.cond.iffalse, level + 1);
+}
+
+/* mu_sieve_node_anyof & mu_sieve_node_allof */
+static void
+free_node_x_of (struct mu_sieve_node *node)
+{
+  tree_free (&node->v.node);
+}
+
+static void
+optimize_x_of (struct mu_sieve_node *node, enum mu_sieve_node_type solve)
+{
+  struct mu_sieve_node *cur;
+  tree_optimize (node->v.node);
+  cur = node->v.node;
+  while (cur)
+    {
+      struct mu_sieve_node *next = cur->next;
+      switch (cur->type)
+	{
+	case mu_sieve_node_false:
+	case mu_sieve_node_true:
+	  if (cur->type == solve)
+	    {
+	      tree_free (&node->v.node);
+	      node->type = solve;
+	      return;
+	    }
+	  else
+	    {
+	      if (cur->prev)
+		cur->prev->next = next;
+	      else
+		node->v.node = next;
+	      if (next)
+		next->prev = cur->prev;
+	      node_free (cur);
+	    }
+	  break;
+
+	default:
+	  break;
+	}
+      
+      cur = next;
+    }
+  
+  if (!node->v.node)
+    node->type = solve == mu_sieve_node_false ? mu_sieve_node_true : mu_sieve_node_false;
+}
+
+static int
+code_node_x_of (struct mu_sieve_machine *mach, struct mu_sieve_node *node,
+		sieve_op_t op)
+{
+  struct mu_sieve_node *cur = node->v.node;
+  size_t pc = 0;
+  size_t end;
+  
+  while (cur)
+    {
+      node_code (mach, cur);
+      if (cur->next)
+	{
+	  mu_i_sv_code (mach, op);
+	  mu_i_sv_code (mach, (sieve_op_t) pc);
+	  pc = mach->pc - 1;
+	}
+      cur = cur->next;
+    }
+
+  /* Fix-up locations */
+  end = mach->pc;
+  while (pc != 0)
+    {
+      size_t prev = mach->prog[pc].pc;
+      mach->prog[pc].pc = end - pc - 1;
+      pc = prev;
+    }
+
+  return 0;
+}
+
+static void
+dump_node_x_of (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  indent (str, level);
+  mu_stream_printf (str, "%s:\n",
+		    node->type == mu_sieve_node_allof ? "ALLOF" : "ANYOF");
+
+  ++level;
+  node = node->v.node;
+  while (node)
+    {
+      node_dump (str, node, level + 1);
+      node = node->next;
+      if (node)
+	{
+	  indent (str, level);
+	  mu_stream_printf (str, "%s:\n",
+			    node->type == mu_sieve_node_allof ? "AND" : "OR");
+	}
+    }
+}
+  
+/* mu_sieve_node_anyof */
+static void
+optimize_node_anyof (struct mu_sieve_node *node)
+{
+  optimize_x_of (node, mu_sieve_node_true);
+}
+
+static int
+code_node_anyof (struct mu_sieve_machine *mach, struct mu_sieve_node *node)
+{
+  return code_node_x_of (mach, node, (sieve_op_t) _mu_i_sv_instr_brnz);
+}
+
+/* mu_sieve_node_allof */
+static void
+optimize_node_allof (struct mu_sieve_node *node)
+{
+  return optimize_x_of (node, mu_sieve_node_false);
+}
+
+static int
+code_node_allof (struct mu_sieve_machine *mach, struct mu_sieve_node *node)
+{
+  return code_node_x_of (mach, node, (sieve_op_t) _mu_i_sv_instr_brz);
+}
+
+/* mu_sieve_node_not */
+static void
+free_node_not (struct mu_sieve_node *node)
+{
+  tree_free (&node->v.node);
+}
+
+static void
+optimize_node_not (struct mu_sieve_node *node)
+{
+  tree_optimize (node->v.node);
+  switch (node->v.node->type)
+    {
+    case mu_sieve_node_false:
+      tree_free (&node->v.node);
+      node->type = mu_sieve_node_true;
+      break;
+      
+    case mu_sieve_node_true:
+      tree_free (&node->v.node);
+      node->type = mu_sieve_node_false;
+      break;
+
+    default:
+      break;
+    }
+}
+
+static int
+code_node_not (struct mu_sieve_machine *mach, struct mu_sieve_node *node)
+{
+  node_code (mach, node->v.node);
+  return mu_i_sv_code (mach, (sieve_op_t) _mu_i_sv_instr_not);
+}
+
+static void
+dump_node_not (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  indent (str, level);
+  mu_stream_printf (str, "NOT\n");
+  node_dump (str, node->v.node, level + 1);
+}
+
+struct node_descr
+{
+  int (*code_fn) (struct mu_sieve_machine *mach, struct mu_sieve_node *node);
+  void (*optimize_fn) (struct mu_sieve_node *node);
+  void (*free_fn) (struct mu_sieve_node *node);
+  void (*dump_fn) (mu_stream_t str, struct mu_sieve_node *node, unsigned level);
+
+};
+
+static struct node_descr node_descr[] = {
+  [mu_sieve_node_noop]  = { NULL, NULL, NULL, dump_node_noop },
+  [mu_sieve_node_false]  = { NULL, NULL, NULL, dump_node_false },
+  [mu_sieve_node_true]   = { NULL, NULL, NULL, dump_node_true },
+  [mu_sieve_node_test]   = { code_node_test, NULL,
+			     free_node_command, dump_node_command },
+  [mu_sieve_node_action] = { code_node_action, NULL,
+			     free_node_command, dump_node_command },
+  [mu_sieve_node_cond]   = { code_node_cond, optimize_node_cond,
+			     free_node_cond, dump_node_cond },
+  [mu_sieve_node_anyof]  = { code_node_anyof, optimize_node_anyof,
+			     free_node_x_of, dump_node_x_of },
+  [mu_sieve_node_allof]  = { code_node_allof, optimize_node_allof,
+			     free_node_x_of, dump_node_x_of },
+  [mu_sieve_node_not]    = { code_node_not, optimize_node_not,
+			     free_node_not, dump_node_not },
+};
+
+static void
+node_optimize (struct mu_sieve_node *node)
+{
+  if ((int)node->type >= MU_ARRAY_SIZE (node_descr))
+    abort ();
+  if (node_descr[node->type].optimize_fn)
+    node_descr[node->type].optimize_fn (node);
+}
+
+static void
+node_free (struct mu_sieve_node *node)
+{
+  if ((int)node->type >= MU_ARRAY_SIZE (node_descr))
+    abort ();
+  if (node_descr[node->type].free_fn)
+    node_descr[node->type].free_fn (node);
+  free (node);
+}
+
+static void
+node_replace (struct mu_sieve_node *node, struct mu_sieve_node *repl)
+{
+  struct mu_sieve_node copy;
+
+  if ((int)node->type >= MU_ARRAY_SIZE (node_descr))
+    abort ();
+  
+  copy = *node;
+  if (repl)
+    {
+      node->type = repl->type;
+      node->v = repl->v;
+
+      switch (copy.type)
+	{
+	case mu_sieve_node_cond:
+	  if (repl == copy.v.cond.expr)
+	    copy.v.cond.expr = NULL;
+	  else if (repl == copy.v.cond.iftrue)
+	    copy.v.cond.iftrue = NULL;
+	  else if (repl == copy.v.cond.iffalse)
+	    copy.v.cond.iffalse = NULL;
+	  break;
+	  
+	case mu_sieve_node_not:
+	  if (repl == copy.v.node)
+	    copy.v.node = NULL;
+	  break;
+
+	default:
+	  break;
+	}
+    }
+  else
+    node->type = mu_sieve_node_noop;
+
+  if (node_descr[node->type].free_fn)
+    node_descr[node->type].free_fn (&copy);
+}
+
+static int
+node_code (struct mu_sieve_machine *mach, struct mu_sieve_node *node)
+{
+  if ((int)node->type >= MU_ARRAY_SIZE (node_descr))
+    abort ();
+
+  if (!node_descr[node->type].code_fn)
+    return 0;
+
+  if (mu_i_sv_locus (mach, &node->locus))
+    return 1;
+
+  return node_descr[node->type].code_fn (mach, node);
+}
+
+static void
+node_dump (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
+{
+  if ((int)node->type >= MU_ARRAY_SIZE (node_descr)
+      || !node_descr[node->type].dump_fn) 
+    abort ();
+  node_descr[node->type].dump_fn (str, node, level);
+}
+
+
+static void
+tree_free (struct mu_sieve_node **tree)
+{
+  struct mu_sieve_node *cur = *tree;
+  while (cur)
+    {
+      struct mu_sieve_node *next = cur->next;
+      node_free (cur);
+      cur = next;
+    }
+}
+
+static void
+tree_optimize (struct mu_sieve_node *tree)
+{
+  while (tree)
+    {
+      node_optimize (tree);
+      tree = tree->next;
+    }
+}
+
+static int
+tree_code (struct mu_sieve_machine *mach, struct mu_sieve_node *tree)
+{
+  while (tree)
+    {
+      if (node_code (mach, tree))
+	return 1;
+      tree = tree->next;
+    }
   return 0;
 }
 
+static void
+tree_dump (mu_stream_t str, struct mu_sieve_node *tree, unsigned level)
+{
+  while (tree)
+    {
+      node_dump (str, tree, level);
+      tree = tree->next;
+    }
+}  
+
+void
+mu_i_sv_error (mu_sieve_machine_t mach)
+{
+  mach->state = mu_sieve_state_error;
+}
+
 int
 mu_sieve_machine_init_ex (mu_sieve_machine_t *pmach,
 			  void *data, mu_stream_t errstream)
@@ -362,6 +1001,16 @@ mu_sieve_machine_init_ex (mu_sieve_machine_t *pmach,
       return rc;
     }
 
+  rc = mu_opool_create (&mach->string_pool, MU_OPOOL_DEFAULT);
+  if (rc)
+    {
+      mu_list_destroy (&mach->memory_pool);
+      free (mach);
+      return rc;
+    }
+  
+  mach->source_list = NULL;
+
   mach->data = data;
   mach->errstream = errstream;
   mu_stream_ref (errstream);
@@ -388,7 +1037,7 @@ mu_sieve_machine_inherit (mu_sieve_machine_t const parent,
     return rc;
 
   child->logger = parent->logger;
-  child->debug_level = parent->debug_level;
+  child->dry_run = parent->dry_run;
   *pmach = child;
   return 0;
 }
@@ -417,11 +1066,12 @@ mu_sieve_machine_dup (mu_sieve_machine_t const in, mu_sieve_machine_t *out)
   mach->progsize = in->progsize;
   mach->prog = in->prog;
 
+  mach->state = in->state;
   mach->pc = 0;
   mach->reg = 0;
   mach->stack = NULL;
 
-  mach->debug_level = in->debug_level;
+  mach->dry_run = in->dry_run;
   
   mach->errstream = in->errstream;
   mu_stream_ref (mach->errstream);
@@ -450,12 +1100,6 @@ mu_sieve_set_diag_stream (mu_sieve_machine_t mach, mu_stream_t str)
 }
 
 void
-mu_sieve_set_debug_level (mu_sieve_machine_t mach, int level)
-{
-  mach->debug_level = level;
-}
-
-void
 mu_sieve_set_logger (mu_sieve_machine_t mach, mu_sieve_action_log_t logger)
 {
   mach->logger = logger;
@@ -571,97 +1215,146 @@ mu_sieve_machine_destroy (mu_sieve_machine_t *pmach)
   mu_list_destroy (&mach->test_list);
   mu_list_destroy (&mach->comp_list);
   mu_list_destroy (&mach->source_list);
+  mu_opool_destroy (&mach->string_pool);
   mu_sieve_slist_destroy (&mach->memory_pool);
   free (mach);
   *pmach = NULL;
 }
 
-static int
-string_comp (const void *item, const void *value)
-{
-  return strcmp (item, value);
-}
-
-void
-mu_sieve_machine_begin (mu_sieve_machine_t mach, const char *file)
+static void
+sieve_machine_begin (mu_sieve_machine_t mach, const char *file)
 {
+  mu_i_sv_register_standard_actions (mach);
+  mu_i_sv_register_standard_tests (mach);
+  mu_i_sv_register_standard_comparators (mach);
   mu_sieve_machine = mach;
-  mu_sieve_error_count = 0;
-  mu_sv_code_instr (NULL);
-
-  mu_list_create (&mach->source_list);
-  mu_list_set_comparator (mach->source_list, string_comp);
-  
-  mu_sv_register_standard_actions (mach);
-  mu_sv_register_standard_tests (mach);
-  mu_sv_register_standard_comparators (mach);
 }
 
-void
-mu_sieve_machine_finish (mu_sieve_machine_t mach)
+static void
+sieve_machine_finish (void)
 {
-  mu_sv_code_instr (NULL);
+  //nothing
 }
 
 int
-mu_sieve_compile (mu_sieve_machine_t mach, const char *name)
+with_machine (mu_sieve_machine_t mach, char const *name,
+	      int (*thunk) (void *), void *data)
 {
   int rc = 0;
+  mu_stream_t save_errstr = mu_strerr;
   
-  mu_sieve_machine_begin (mach, name);
+  mu_stream_ref (save_errstr);
+  mu_strerr = mach->errstream;
+  mu_stream_ref (mu_strerr);
+
+  sieve_machine_begin (mach, name);
+
+  rc = thunk (data);
+
+  sieve_machine_finish ();
+
+  mu_stream_unref (save_errstr);
+  mu_strerr = save_errstr;
+  mu_stream_unref (mu_strerr);
 
-  if (mu_sv_lex_begin (name) == 0)
-    {
-      if (yyparse () || mu_sieve_error_count)
-	rc = MU_ERR_PARSE;
-      mu_sv_lex_finish ();
-    }
-  else
-    rc = MU_ERR_FAILURE;
-  
-  mu_sieve_machine_finish (mach);
   return rc;
 }
 
-int
-mu_sieve_compile_buffer (mu_sieve_machine_t mach,
-			 const char *buf, int bufsize,
-			 const char *fname, int line)
+static int
+sieve_parse (void)
 {
   int rc;
-  
-  mu_sieve_machine_begin (mach, fname);
 
-  if (mu_sv_lex_begin_string (buf, bufsize, fname, line) == 0)
+  sieve_tree = NULL;
+  yydebug = mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE3);
+
+  rc = yyparse ();
+  mu_i_sv_lex_finish (mu_sieve_machine);
+  if (rc)
+    mu_i_sv_error (mu_sieve_machine);
+  if (mu_sieve_machine->state == mu_sieve_state_init)
     {
-      rc = yyparse ();
-      if (mu_sieve_error_count)
-	rc = 1;
-      mu_sv_lex_finish ();
+      if (mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE1))
+	{
+	  mu_error (_("Unoptimized parse tree"));
+	  tree_dump (mu_strerr, sieve_tree, 0);
+	}
+      tree_optimize (sieve_tree);
+      if (mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE2))
+	{
+	  mu_error (_("Optimized parse tree"));
+	  tree_dump (mu_strerr, sieve_tree, 0);
+	}
+      mu_i_sv_code (mu_sieve_machine, (sieve_op_t) 0);
+
+      /* Clear location, so that mu_i_sv_locus will do its job. */
+      mu_sieve_machine->locus.mu_file = NULL;
+      mu_sieve_machine->locus.mu_line = 0;
+      mu_sieve_machine->locus.mu_col = 0;
+      
+      rc = tree_code (mu_sieve_machine, sieve_tree);
+      if (rc)
+	mu_i_sv_error (mu_sieve_machine);
+      mu_i_sv_code (mu_sieve_machine, (sieve_op_t) 0);
     }
-  else
-    rc = 1;
   
-  mu_sieve_machine_finish (mach);
+  if (rc == 0)
+    {
+      if (mu_sieve_machine->state == mu_sieve_state_error)
+	rc = MU_ERR_PARSE;
+      else
+	mu_sieve_machine->state = mu_sieve_state_compiled;
+    }
+
+  tree_free (&sieve_tree);
   return rc;
 }
 
-static void
-_branch_fixup (size_t start, size_t end)
+static int
+sieve_compile_file (void *name)
 {
-  size_t prev = mu_sieve_machine->prog[start].pc;
-  if (!prev)
-    return;
-  branch_fixup (prev, end);
-  mu_sieve_machine->prog[prev].pc = end - prev - 1;
+  if (mu_i_sv_lex_begin (name) == 0)
+    return sieve_parse ();
+  return MU_ERR_FAILURE;
 }
 
-static void
-branch_fixup (size_t start, size_t end)
+int
+mu_sieve_compile (mu_sieve_machine_t mach, const char *name)
+{
+  return with_machine (mach, name, sieve_compile_file, (void *) name);
+}
+
+struct strbuf
+{
+  const char *ptr;
+  size_t size;
+  const char *file;
+  int line;
+};
+
+static int
+sieve_compile_strbuf (void *name)
 {
-  _branch_fixup (start, end);
-  mu_sieve_machine->prog[start].pc = end - start - 1;
+  struct strbuf *buf = name;
+  if (mu_i_sv_lex_begin_string (buf->ptr, buf->size, buf->file, buf->line) == 0)
+    return sieve_parse ();
+  return MU_ERR_FAILURE;
+} 
+
+//FIXME: The API is clumsy
+int
+mu_sieve_compile_buffer (mu_sieve_machine_t mach,
+			 const char *str, int strsize,
+			 const char *fname, int line)
+{
+  struct strbuf buf;
+  buf.ptr = str;
+  buf.size = strsize;
+  buf.file = fname;
+  buf.line = line;
+  return with_machine (mach, fname, sieve_compile_strbuf, &buf);
 }
 
 
 
+
diff --git a/libmu_sieve/tests.c b/libmu_sieve/tests.c
index f0f989e..5d3efee 100644
--- a/libmu_sieve/tests.c
+++ b/libmu_sieve/tests.c
@@ -119,8 +119,7 @@ sieve_test_address (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   size_t count;
   
-  if (mach->debug_level & MU_SIEVE_DEBUG_TRACE)
-    mu_sieve_debug (mach, "ADDRESS");
+  mu_sieve_trace (mach, "ADDRESS");
 
   h = mu_sieve_value_get (args, 0);
   if (!h)
@@ -183,8 +182,7 @@ sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   size_t count, mcount = 0;
   struct header_closure clos;
   
-  if (mach->debug_level & MU_SIEVE_DEBUG_TRACE)
-    mu_sieve_debug (mach, "HEADER");
+  mu_sieve_trace (mach, "HEADER");
 
   h = mu_sieve_value_get (args, 0);
   if (!h)
@@ -267,8 +265,7 @@ sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   size_t count;
   
-  if (mach->debug_level & MU_SIEVE_DEBUG_TRACE)
-    mu_sieve_debug (mach, "ENVELOPE");
+  mu_sieve_trace (mach, "ENVELOPE");
 
   h = mu_sieve_value_get (args, 0);
   if (!h)
@@ -320,22 +317,6 @@ sieve_test_size (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 }
 
 int
-sieve_test_true (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
-{
-  if (mach->debug_level & MU_SIEVE_DEBUG_TRACE)
-    mu_sieve_debug (mach, "TRUE");
-  return 1;
-}
-
-int
-sieve_test_false (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
-{
-  if (mach->debug_level & MU_SIEVE_DEBUG_TRACE)
-    mu_sieve_debug (mach, "FALSE");
-  return 0;
-}
-
-int
 _test_exists (void *item, void *data)
 {
   mu_header_t hdr = data;
@@ -350,8 +331,7 @@ sieve_test_exists (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_header_t header = NULL;
   mu_sieve_value_t *val;   
 
-  if (mach->debug_level & MU_SIEVE_DEBUG_TRACE)
-    mu_sieve_debug (mach, "EXISTS");
+  mu_sieve_trace (mach, "EXISTS");
 
   mu_message_get_header (mu_sieve_get_message (mach), &header);
   val = mu_sieve_value_get (args, 0);
@@ -444,10 +424,9 @@ mu_sieve_tag_group_t header_tag_groups[] = {
 };
 
 void
-mu_sv_register_standard_tests (mu_sieve_machine_t mach)
+mu_i_sv_register_standard_tests (mu_sieve_machine_t mach)
 {
-  mu_sieve_register_test (mach, "false", sieve_test_false, NULL, NULL, 1);
-  mu_sieve_register_test (mach, "true", sieve_test_true, NULL, NULL, 1);
+  /* true and false are built-ins */
   mu_sieve_register_test (mach, "address", sieve_test_address,
 		       address_req_args, address_tag_groups, 1);
   mu_sieve_register_test (mach, "size", sieve_test_size,
diff --git a/libmu_sieve/util.c b/libmu_sieve/util.c
index fa6c623..d0538b8 100644
--- a/libmu_sieve/util.c
+++ b/libmu_sieve/util.c
@@ -171,7 +171,7 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data)
       break;
 	
     default:
-      mu_sv_compile_error (&mu_sieve_locus, _("invalid data type"));
+      mu_error ("%s", _("invalid data type"));
       abort ();
     }
   return val;
@@ -186,24 +186,6 @@ mu_sieve_value_get (mu_list_t vlist, size_t index)
 }
 
 void
-mu_sv_compile_error (struct mu_locus *ploc, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  mu_sieve_error_count++;
-  mu_stream_ioctl (mu_sieve_machine->errstream,
-                   MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS,
-		   ploc);
-  mu_stream_printf (mu_sieve_machine->errstream,
-		    "\033s<%d>\033O<%d>",
-		    MU_LOG_ERROR, MU_LOGMODE_LOCUS);
-  mu_stream_vprintf (mu_sieve_machine->errstream, fmt, ap);
-  mu_stream_write (mu_sieve_machine->errstream, "\n", 1, NULL);
-  va_end (ap);
-}
-
-void
 mu_sieve_error (mu_sieve_machine_t mach, const char *fmt, ...)
 {
   va_list ap;
@@ -248,6 +230,27 @@ mu_sieve_debug (mu_sieve_machine_t mach, const char *fmt, ...)
 }
 
 void
+mu_sieve_trace (mu_sieve_machine_t mach, const char *fmt, ...)
+{
+  va_list ap;
+
+  if (!mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE4))
+    return;
+  
+  va_start (ap, fmt);
+  mu_stream_printf (mach->errstream, "\033s<%d>", MU_LOG_DEBUG);
+  if (mach->locus.mu_file)
+    mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
+		      MU_LOGMODE_LOCUS,
+		      (unsigned) strlen (mach->locus.mu_file),
+		      mach->locus.mu_file,
+		      mach->locus.mu_line);
+  mu_stream_vprintf (mach->errstream, fmt, ap);
+  mu_stream_write (mach->errstream, "\n", 1, NULL);
+  va_end (ap);
+}
+
+void
 mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
 		     const char *fmt, ...)
 {
@@ -357,7 +360,7 @@ sieve_print_value (mu_sieve_value_t *val, mu_stream_t str)
 } 
 
 void
-mu_sv_print_value_list (mu_list_t list, mu_stream_t str)
+mu_i_sv_print_value_list (mu_list_t list, mu_stream_t str)
 {
   mu_sieve_value_t val;
   
@@ -384,7 +387,7 @@ tag_printer (void *item, void *data)
 }
 
 void
-mu_sv_print_tag_list (mu_list_t list, mu_stream_t str)
+mu_i_sv_print_tag_list (mu_list_t list, mu_stream_t str)
 {
   mu_list_foreach (list, tag_printer, str);
 }
diff --git a/sieve/sieve.c b/sieve/sieve.c
index 2b7fb9e..0f7789a 100644
--- a/sieve/sieve.c
+++ b/sieve/sieve.c
@@ -55,43 +55,46 @@ int sieve_debug;
 int verbose;
 char *script;
 int expression_option;
+int dry_run;
 
 static int sieve_print_locus = 1; /* Should the log messages include the
 				     locus */
 
 static void
-set_debug_level (const char *arg)
+modify_debug_flags (mu_debug_level_t set, mu_debug_level_t clr)
 {
   mu_debug_level_t lev;
   
+  mu_debug_get_category_level (mu_sieve_debug_handle, &lev);
+  mu_debug_set_category_level (mu_sieve_debug_handle, (lev & ~clr) | set);
+}
+
+static void
+set_debug_level (const char *arg)
+{
   for (; *arg; arg++)
     {
       switch (*arg)
 	{
 	case 'T':
-	  mu_debug_get_category_level (mu_sieve_debug_handle, &lev);
-	  mu_debug_set_category_level (mu_sieve_debug_handle, 
-				       lev |
-				    (MU_DEBUG_LEVEL_UPTO(MU_DEBUG_TRACE9) &
-				     ~MU_DEBUG_LEVEL_MASK(MU_DEBUG_ERROR)));
+	  modify_debug_flags (MU_DEBUG_LEVEL_UPTO(MU_DEBUG_TRACE9),
+			      MU_DEBUG_LEVEL_MASK(MU_DEBUG_ERROR));
 	  break;
 
 	case 'P':
-	  mu_debug_get_category_level (mu_sieve_debug_handle, &lev);
-	  mu_debug_set_category_level (mu_sieve_debug_handle,
-				    lev | MU_DEBUG_LEVEL_MASK(MU_DEBUG_PROT));
+	  modify_debug_flags (MU_DEBUG_LEVEL_MASK(MU_DEBUG_PROT), 0);
 	  break;
 
 	case 'g':
-	  mu_sieve_yydebug = 1;
+	  modify_debug_flags (MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE1), 0);
 	  break;
 
 	case 't':
-	  sieve_debug |= MU_SIEVE_DEBUG_TRACE;
+	  modify_debug_flags (MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE4), 0);
 	  break;
 	  
 	case 'i':
-	  sieve_debug |= MU_SIEVE_DEBUG_INSTR;
+	  modify_debug_flags (MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE9), 0);
 	  break;
 	  
 	default:
@@ -101,13 +104,6 @@ set_debug_level (const char *arg)
 }
 
 static void
-cli_dry_run (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
-{
-  sieve_debug |= MU_SIEVE_DRY_RUN;
-  verbose = 1;
-}
-
-static void
 cli_compile_and_dump (struct mu_parseopt *po, struct mu_option *opt,
 		      char const *arg)
 {
@@ -136,10 +132,10 @@ cli_no_program_name (struct mu_parseopt *po, struct mu_option *opt,
 }
 
 static struct mu_option sieve_options[] = {
-  { "no-actions", 'n', NULL, MU_OPTION_DEFAULT,
+  { "dry-run", 'n', NULL, MU_OPTION_DEFAULT,
     N_("do not execute any actions, just print what would be done"),
-    mu_c_string, NULL, cli_dry_run },
-  { "dry-run", 0, NULL, MU_OPTION_ALIAS },
+    mu_c_bool, &dry_run },
+  { "no-actions", 0, NULL, MU_OPTION_ALIAS },
   { "keep-going", 'k', NULL, MU_OPTION_DEFAULT,
     N_("keep on going if execution fails on a message"),
     mu_c_bool, &keep_going },
@@ -157,7 +153,7 @@ static struct mu_option sieve_options[] = {
     mu_c_string, &mu_ticket_file },
   { "debug", 'd', N_("FLAGS"), MU_OPTION_ARG_OPTIONAL,
     N_("debug flags (defaults to \"" D_DEFAULT "\")"),
-    mu_c_string, NULL, cli_debug },
+    mu_c_string, NULL, cli_debug, D_DEFAULT },
   { "verbose", 'v', NULL, MU_OPTION_DEFAULT,
     N_("log all actions"), 
     mu_c_bool, &verbose },
@@ -332,7 +328,7 @@ sieve_mailbox (mu_sieve_machine_t mach)
     }
 
   /* Open the mailbox read-only if we aren't going to modify it. */
-  if (sieve_debug & MU_SIEVE_DRY_RUN)
+  if (mu_sieve_is_dry_run (mach))
     rc = mu_mailbox_open (mbox, MU_STREAM_READ);
   else
     rc = mu_mailbox_open (mbox, MU_STREAM_RDWR);
@@ -358,7 +354,7 @@ sieve_mailbox (mu_sieve_machine_t mach)
   rc = mu_sieve_mailbox (mach, mbox);
   
  cleanup:
-  if (mbox && !(sieve_debug & MU_SIEVE_DRY_RUN))
+  if (mbox && !dry_run)
     {
       int e;
       
@@ -403,7 +399,9 @@ main (int argc, char *argv[])
   mu_register_all_formats ();
 
   mu_cli (argc, argv, &cli, sieve_capa, NULL, &argc, &argv);
-
+  if (dry_run)
+    verbose++;
+  
   if (argc == 0)
     {
       mu_error (_("script must be specified"));
@@ -446,7 +444,7 @@ main (int argc, char *argv[])
       return EX_OK;
     }
 
-  mu_sieve_set_debug_level (mach, sieve_debug);
+  mu_sieve_set_dry_run (mach, dry_run);
 
   if (mbox_url && strcmp (mbox_url, "-") == 0)
     rc = sieve_message (mach);
diff --git a/sieve/tests/ext.at b/sieve/tests/ext.at
index 633b30e..4bfec67 100644
--- a/sieve/tests/ext.at
+++ b/sieve/tests/ext.at
@@ -32,7 +32,7 @@ if numaddr [[ "to", "cc" ]] :over 5
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/bigto.mbox)
 
 sieve MUT_SIEVE_CMDLINE dnl
- --clearpath -L "${abs_top_builddir}/examples" -f ./bigto.mbox prog
+ --clearpath --libdir-prefix= "${abs_top_builddir}/examples" -f ./bigto.mbox prog
 ],
 [0],
 [],
diff --git a/sieve/tests/i-numeric.at b/sieve/tests/i-numeric.at
index fe30de8..c6e494f 100644
--- a/sieve/tests/i-numeric.at
+++ b/sieve/tests/i-numeric.at
@@ -38,7 +38,7 @@ if header :comparator "i;ascii-numeric" :contains "X-Number" "15"
     discard;
   }
 ],[78],[],
-[sieve: prog:5: comparator `i;ascii-numeric' is incompatible with match type `contains' in call to `header'
+[sieve: prog:4:1: comparator `i;ascii-numeric' is incompatible with match type `contains' in call to `header'
 ])
 AT_CLEANUP
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 23 11:49:04 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c9ajI-0000wD-Fy
	for mharc-commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:49:04 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:58536)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9ajG-0000w2-0f
	for commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:49:03 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9ajE-0004a4-SZ
	for commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:49:02 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:49504)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9ajE-0004Zw-PH
	for commit-mailutils@gnu.org; Wed, 23 Nov 2016 11:49:00 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 806232201C5; Wed, 23 Nov 2016 16:49:00 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-7-gffa85e2
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f2980e5a1a7495e31f75b979b258bd0fffdb310e
X-Git-Newrev: ffa85e25b9c3598b9b37205585894ad7318063d5
Message-Id: <20161123164900.806232201C5@vcs.savannah.gnu.org>
Date: Wed, 23 Nov 2016 16:49:00 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Nov 2016 16:49:03 -0000

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=ffa85e25b9c3598b9b37205585894ad7318063d5

The branch, master has been updated
       via  ffa85e25b9c3598b9b37205585894ad7318063d5 (commit)
      from  f2980e5a1a7495e31f75b979b258bd0fffdb310e (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 ffa85e25b9c3598b9b37205585894ad7318063d5
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 23 18:46:24 2016 +0200

    Fix typo

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

Summary of changes:
 sieve/tests/ext.at |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sieve/tests/ext.at b/sieve/tests/ext.at
index 4bfec67..e3dd97d 100644
--- a/sieve/tests/ext.at
+++ b/sieve/tests/ext.at
@@ -32,7 +32,7 @@ if numaddr [[ "to", "cc" ]] :over 5
 MUT_MBCOPY($abs_top_srcdir/testsuite/spool/bigto.mbox)
 
 sieve MUT_SIEVE_CMDLINE dnl
- --clearpath --libdir-prefix= "${abs_top_builddir}/examples" -f ./bigto.mbox prog
+ --clearpath --libdir-prefix="${abs_top_builddir}/examples" -f ./bigto.mbox prog
 ],
 [0],
 [],


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 24 10:19:03 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1c9vnj-0003Wh-LY
	for mharc-commit-mailutils@gnu.org; Thu, 24 Nov 2016 10:19:03 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:44492)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9vnc-0003WT-Fw
	for commit-mailutils@gnu.org; Thu, 24 Nov 2016 10:19:02 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9vnT-0002ti-C3
	for commit-mailutils@gnu.org; Thu, 24 Nov 2016 10:18:56 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:34784)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1c9vnT-0002tc-6s
	for commit-mailutils@gnu.org; Thu, 24 Nov 2016 10:18:47 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id CEC6D2201C5; Thu, 24 Nov 2016 15:18:46 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-11-g05df35d
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ffa85e25b9c3598b9b37205585894ad7318063d5
X-Git-Newrev: 05df35d07a46f70e7d09a4da39fdd2d7a7d58ed0
Message-Id: <20161124151846.CEC6D2201C5@vcs.savannah.gnu.org>
Date: Thu, 24 Nov 2016 15:18:46 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 24 Nov 2016 15:19:02 -0000

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=05df35d07a46f70e7d09a4da39fdd2d7a7d58ed0

The branch, master has been updated
       via  05df35d07a46f70e7d09a4da39fdd2d7a7d58ed0 (commit)
       via  a4c1a0e88bdeb8372ae66e27da4009a49b0f8009 (commit)
       via  d282d8e74e30328586a7c8e9a72a47a8f1fbce79 (commit)
       via  f617dd5dfc51dad7766c62c0cb70e5fcf0baf1b1 (commit)
      from  ffa85e25b9c3598b9b37205585894ad7318063d5 (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 05df35d07a46f70e7d09a4da39fdd2d7a7d58ed0
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 15:25:07 2016 +0200

    sieve: simplify action logging API
    
    * include/mailutils/sieve.h (mu_sieve_action_log_t): Change proto.
    * lib/sieve.c (_sieve_action_log): Rewrite.
    * libmu_sieve/util.c (mu_sieve_log_action): Rewrite.
    * python/libmu_py/sieve.c (_sieve_action_printer): Rewrite.
    * sieve/sieve.c (_sieve_action_log): Rewrite.

commit a4c1a0e88bdeb8372ae66e27da4009a49b0f8009
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 14:20:54 2016 +0200

    sieve: provide a separate stream for debugging output
    
    * include/mailutils/sieve.h (MU_SIEVE_DEBUG_TRACE)
    (MU_SIEVE_DEBUG_INSTR,MU_SIEVE_DEBUG_DISAS)
    (MU_SIEVE_DRY_RUN): Remove.
    (mu_sieve_machine_init_ex): Remove proto.
    (mu_sieve_set_dbg_stream,mu_sieve_get_dbg_stream)
    (mu_sieve_stream_save)
    (mu_sieve_stream_restore): New protos.
    * libmu_sieve/runtime.c (INSTR_DISASS,INSTR_DEBUG): Reimplement.
    * libmu_sieve/sieve-priv.h (MU_SV_SAVED_ERR_STATE)
    (MU_SV_SAVED_DBG_STATE,MU_SV_SAVED_STATE): New bitflags.
    (mu_sieve_state_disass): New constant.
    (mu_sieve_machine)<state_flags, err_mode>
    <err_locus,dbg_mode,dbg_locus>: New members.
    <dbgstream>: New member.
    * libmu_sieve/sieve.y (mu_sieve_machine_init_ex): Remove.
    (mu_sieve_machine_dup, mu_sieve_machine_inherit): Fix.
    (mu_sieve_set_dbg_stream)
    (mu_sieve_get_dbg_stream): New functions.
    (mu_sieve_machine_destroy): Destroy dbgstream.
    (with_machine): Preserve stream state (mode & locus).
    * libmu_sieve/util.c (mu_i_sv_debug,mu_i_sv_debug_command): Use ioctl
    instead of format strings.
    (mu_sieve_stream_save, mu_sieve_stream_restore): New functions.
    * python/libmu_py/sieve.c (api_sieve_machine_init): Use
    mu_sieve_machine_init.
    * sieve/sieve.c: Improve help output.
    (main): Dump disassembled code to standard output.

commit d282d8e74e30328586a7c8e9a72a47a8f1fbce79
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 10:08:57 2016 +0200

    Sieve: remove unused opcode
    
    * libmu_sieve/runtime.c (_mu_i_sv_instr_nop): Remove.
    * libmu_sieve/sieve-priv.h: Likewise.

commit f617dd5dfc51dad7766c62c0cb70e5fcf0baf1b1
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 09:55:18 2016 +0200

    Revamp debugging/tracing support
    
    * bootstrap.conf (mu_sieve_debug, mu_sieve_trace): Remove.
    * include/mailutils/sieve.h (mu_sieve_debug): Remove.
    
    * examples/numaddr.c: Remove calls to mu_sieve_trace.
    * libmu_sieve/extensions/list.c: Likewise.
    * libmu_sieve/extensions/moderator.c: Likewise.
    * libmu_sieve/extensions/pipe.c: Likewise.
    * libmu_sieve/extensions/spamd.c: Likewise.
    * libmu_sieve/extensions/timestamp.c: Likewise.
    * libmu_sieve/extensions/vacation.c: Likewise.
    * libmu_sieve/tests.c: Likewise.
    
    * libmu_sieve/runtime.c: Use new debugging/tracing functions.
    * libmu_sieve/sieve-priv.h (mu_i_sv_debug, mu_i_sv_trace)
    (mu_i_sv_debug_command)
    (mu_i_sv_argf, mu_i_sv_valf): New prototypes.
    * libmu_sieve/sieve.y (mu_i_sv_valf, mu_i_sv_argf): New functions.
    * libmu_sieve/util.c (mu_sieve_debug): Remove.
    (mu_i_sv_print_value_list): Remove.
    (mu_i_sv_print_tag_list): Remove.
    (mu_sieve_trace): Remove.
    (mu_i_sv_tagf): New function.
    (mu_i_sv_debug): New function.
    (mu_i_sv_trace): New function.
    (mu_i_sv_debug_command): New function.

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

Summary of changes:
 bootstrap.conf                     |    1 -
 examples/numaddr.c                 |    2 -
 include/mailutils/sieve.h          |   22 ++-
 lib/sieve.c                        |   11 +-
 libmu_sieve/extensions/list.c      |    2 -
 libmu_sieve/extensions/moderator.c |    3 -
 libmu_sieve/extensions/pipe.c      |    2 -
 libmu_sieve/extensions/spamd.c     |    3 -
 libmu_sieve/extensions/timestamp.c |    2 -
 libmu_sieve/extensions/vacation.c  |    2 -
 libmu_sieve/runtime.c              |  145 ++++++++-----------
 libmu_sieve/sieve-priv.h           |   30 +++-
 libmu_sieve/sieve.y                |  140 ++++++++++++-------
 libmu_sieve/tests.c                |    8 --
 libmu_sieve/util.c                 |  272 +++++++++++++++++++-----------------
 mail/tests/atlocal.in              |    2 +
 python/libmu_py/sieve.c            |   21 +--
 sieve/sieve.c                      |   32 +++--
 18 files changed, 370 insertions(+), 330 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index d969396..6360a2c 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -47,7 +47,6 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
  --flag=mu_debug_print:3:c-format\\\
  --flag=mu_debug_printf:3:c-format\\\
  --flag=mu_sieve_error:2:c-format\\\
- --flag=mu_sieve_debug:2:c-format\\\
  --flag=mu_sieve_log_action:3:c-format\\\
  --flag=mu_nntp_writeline:2:c-format\\\
  --flag=mu_pop3_writeline:2:c-format\\\
diff --git a/examples/numaddr.c b/examples/numaddr.c
index 578bddc..66602ad 100644
--- a/examples/numaddr.c
+++ b/examples/numaddr.c
@@ -84,8 +84,6 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   struct val_ctr vc;
   int rc;
   
-  mu_sieve_trace (mach, "NUMADDR");
-
   /* Retrieve required arguments: */
   /* First argument: list of header names */
   h = mu_sieve_value_get (args, 0);
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 74fa7c5..364a71a 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -35,9 +35,7 @@ typedef struct mu_sieve_machine *mu_sieve_machine_t;
 
 typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach,
 				   mu_list_t args, mu_list_t tags);
-typedef void (*mu_sieve_action_log_t) (void *data,
-				       mu_stream_t stream,
-				       size_t msgno, mu_message_t msg,
+typedef void (*mu_sieve_action_log_t) (mu_sieve_machine_t mach,
 				       const char *action,
 				       const char *fmt, va_list ap);
 
@@ -116,12 +114,6 @@ typedef struct
 #define MU_SIEVE_MATCH_EQ        5
 #define MU_SIEVE_MATCH_LAST      6
 
-/* Debugging levels */
-#define MU_SIEVE_DEBUG_TRACE  0x0001
-#define MU_SIEVE_DEBUG_INSTR  0x0002
-#define MU_SIEVE_DEBUG_DISAS  0x0004
-#define MU_SIEVE_DRY_RUN      0x0008
-
 extern mu_debug_handle_t mu_sieve_debug_handle;
 extern mu_list_t mu_sieve_include_path;
 extern mu_list_t mu_sieve_library_path;
@@ -212,9 +204,6 @@ int mu_sieve_vlist_compare (mu_sieve_value_t * a, mu_sieve_value_t * b,
 
 /* Functions to create and destroy sieve machine */
 int mu_sieve_machine_init (mu_sieve_machine_t *mach);
-int mu_sieve_machine_init_ex (mu_sieve_machine_t *pmach,
-			      void *data,
-			      mu_stream_t errstream);
 int mu_sieve_machine_dup (mu_sieve_machine_t const in,
 			  mu_sieve_machine_t *out);
 int mu_sieve_machine_inherit (mu_sieve_machine_t const in,
@@ -227,6 +216,9 @@ int mu_sieve_machine_add_destructor (mu_sieve_machine_t mach,
 void mu_sieve_get_diag_stream (mu_sieve_machine_t mach, mu_stream_t *pstr);
 void mu_sieve_set_diag_stream (mu_sieve_machine_t mach, mu_stream_t str);
 
+void mu_sieve_set_dbg_stream (mu_sieve_machine_t mach, mu_stream_t str);
+void mu_sieve_get_dbg_stream (mu_sieve_machine_t mach, mu_stream_t *pstr);
+
 void *mu_sieve_get_data (mu_sieve_machine_t mach);
 void mu_sieve_set_data (mu_sieve_machine_t mach, void *);
 mu_message_t mu_sieve_get_message (mu_sieve_machine_t mach);
@@ -247,12 +239,14 @@ void mu_sieve_set_daemon_email (mu_sieve_machine_t mach, const char *email);
 
 int mu_sieve_get_message_sender (mu_message_t msg, char **ptext);
 
+/* Stream state saving & restoring */
+void mu_sieve_stream_save (mu_sieve_machine_t mach);
+void mu_sieve_stream_restore (mu_sieve_machine_t mach);
+  
 /* Logging and diagnostic functions */
 
 void mu_sieve_error (mu_sieve_machine_t mach, const char *fmt, ...) 
                      MU_PRINTFLIKE(2,3);
-void mu_sieve_debug (mu_sieve_machine_t mach, const char *fmt, ...)
-                     MU_PRINTFLIKE(2,3);
 void mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
 			  const char *fmt, ...)
 			  MU_PRINTFLIKE(3,4);
diff --git a/lib/sieve.c b/lib/sieve.c
index a7450c1..249b560 100644
--- a/lib/sieve.c
+++ b/lib/sieve.c
@@ -28,15 +28,17 @@ struct sieve_log_data
 };
 
 static void
-_sieve_action_log (void *data,
-		   mu_stream_t stream, size_t msgno,
-		   mu_message_t msg,
+_sieve_action_log (mu_sieve_machine_t mach,
 		   const char *action, const char *fmt, va_list ap)
 {
-  struct sieve_log_data *ldat = data;
+  struct sieve_log_data *ldat = mu_sieve_get_data (mach);
   int pfx = 0;
+  mu_stream_t stream;
+  mu_message_t msg = mu_sieve_get_message (mach);
 
+  mu_sieve_get_diag_stream (mach, &stream);
   mu_stream_printf (stream, "\033s<%d>", MU_LOG_NOTICE);
+
   if (ldat)
     {
       if (ldat->user)
@@ -70,6 +72,7 @@ _sieve_action_log (void *data,
       mu_stream_vprintf (stream, fmt, ap);
     }
   mu_stream_printf (stream, "\n");
+  mu_stream_unref (stream);
 }
 
 static int
diff --git a/libmu_sieve/extensions/list.c b/libmu_sieve/extensions/list.c
index 46b7a25..ccde22d 100644
--- a/libmu_sieve/extensions/list.c
+++ b/libmu_sieve/extensions/list.c
@@ -152,8 +152,6 @@ list_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   struct header_closure clos;
   int result;
 
-  mu_sieve_trace (mach, "LIST");
-  
   memset (&clos, 0, sizeof clos);
   if (mu_sieve_tag_lookup (tags, "delim", &arg))
     clos.delim = arg->v.string;
diff --git a/libmu_sieve/extensions/moderator.c b/libmu_sieve/extensions/moderator.c
index 00b1de4..b19d0ed 100644
--- a/libmu_sieve/extensions/moderator.c
+++ b/libmu_sieve/extensions/moderator.c
@@ -273,9 +273,6 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int discard = 0;
   int ismime;
   
-  mu_sieve_trace (mach, "moderator_test %lu",
-		  (unsigned long) mu_sieve_get_message_num (mach));
-
   msg = mu_sieve_get_message (mach);
   mu_message_is_multipart (msg, &ismime);
 
diff --git a/libmu_sieve/extensions/pipe.c b/libmu_sieve/extensions/pipe.c
index 783950b..045c5a8 100644
--- a/libmu_sieve/extensions/pipe.c
+++ b/libmu_sieve/extensions/pipe.c
@@ -105,8 +105,6 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
     }
   cmd = val->v.string;
 
-  mu_sieve_trace (mach, test ? "PIPE (test)" : "PIPE (action)");
-
   if (mu_sieve_is_dry_run (mach))
     return 0;
 
diff --git a/libmu_sieve/extensions/spamd.c b/libmu_sieve/extensions/spamd.c
index 1fd8837..290d8b8 100644
--- a/libmu_sieve/extensions/spamd.c
+++ b/libmu_sieve/extensions/spamd.c
@@ -368,9 +368,6 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_header_t hdr;
   mu_debug_handle_t lev = 0;
   
-  mu_sieve_trace (mach, "spamd_test %lu",
-		  (unsigned long) mu_sieve_get_message_num (mach));
-  
   if (mu_sieve_is_dry_run (mach))
     return 0;
   
diff --git a/libmu_sieve/extensions/timestamp.c b/libmu_sieve/extensions/timestamp.c
index 67fceb0..56c12f2 100644
--- a/libmu_sieve/extensions/timestamp.c
+++ b/libmu_sieve/extensions/timestamp.c
@@ -57,8 +57,6 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   time_t tlimit, tval;
   int rc;
   
-  mu_sieve_trace (mach, "TIMESTAMP");
-
   /* Retrieve required arguments: */
   /* First argument: header name */
   h = mu_sieve_value_get (args, 0);
diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c
index 863fe15..8b8fefc 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -136,8 +136,6 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
 static int
 diag (mu_sieve_machine_t mach)
 {
-  mu_sieve_trace (mach, "VACATION");
-
   mu_sieve_log_action (mach, "VACATION", NULL);
   return mu_sieve_is_dry_run (mach);
 }
diff --git a/libmu_sieve/runtime.c b/libmu_sieve/runtime.c
index 2778739..4648b9a 100644
--- a/libmu_sieve/runtime.c
+++ b/libmu_sieve/runtime.c
@@ -27,17 +27,9 @@
 #define SIEVE_ARG(m,n,t) ((m)->prog[(m)->pc+(n)].t)
 #define SIEVE_ADJUST(m,n) (m)->pc+=(n)
 
+#define INSTR_DISASS(m) ((m)->state == mu_sieve_state_disass)
 #define INSTR_DEBUG(m) \
-  (mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE9)) 
-#define INSTR_DISASS(m) \
-  (mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE8)) 
-
-void
-_mu_i_sv_instr_nop (mu_sieve_machine_t mach)
-{
-  if (INSTR_DEBUG (mach))
-    mu_sieve_debug (mach, "%4lu: NOP", (unsigned long) (mach->pc - 1));
-}
+  (INSTR_DISASS(m) || mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE9)) 
 
 void
 _mu_i_sv_instr_source (mu_sieve_machine_t mach)
@@ -47,9 +39,7 @@ _mu_i_sv_instr_source (mu_sieve_machine_t mach)
                    MU_IOCTL_LOGSTREAM_SET_LOCUS,
 		   &mach->locus);
   if (INSTR_DEBUG (mach))
-    mu_sieve_debug (mach, "%4lu: SOURCE %s",
-		    (unsigned long) (mach->pc - 1),
-		    mach->locus.mu_file);
+    mu_i_sv_debug (mach, mach->pc - 1, "SOURCE %s", mach->locus.mu_file);
   SIEVE_ADJUST (mach, 1);
 }
 		 
@@ -61,14 +51,13 @@ _mu_i_sv_instr_line (mu_sieve_machine_t mach)
                    MU_IOCTL_LOGSTREAM_SET_LOCUS,
 		   &mach->locus);
   if (INSTR_DEBUG (mach))
-    mu_sieve_debug (mach, "%4lu: LINE %u",
-		 (unsigned long) (mach->pc - 1),
-		 mach->locus.mu_line);
+    mu_i_sv_debug (mach, mach->pc - 1, "LINE %u",
+		   mach->locus.mu_line);
   SIEVE_ADJUST (mach, 1);
 }
 		 
 static int
-instr_run (mu_sieve_machine_t mach)
+instr_run (mu_sieve_machine_t mach, char const *what)
 {
   mu_sieve_handler_t han = SIEVE_ARG (mach, 0, handler);
   mu_list_t arg_list = SIEVE_ARG (mach, 1, list);
@@ -78,15 +67,11 @@ instr_run (mu_sieve_machine_t mach)
   SIEVE_ADJUST(mach, 4);
 
   if (INSTR_DEBUG (mach))
-    {
-      mu_stream_printf (mach->errstream,
-			"\033s<%d>Arguments: ", MU_LOG_DEBUG);
-      mu_i_sv_print_value_list (arg_list, mach->errstream);
-      mu_stream_printf (mach->errstream, "\n\033s<%d>Tags: ", MU_LOG_DEBUG);
-      mu_i_sv_print_tag_list (tag_list, mach->errstream);
-      mu_stream_printf (mach->errstream, "\n");
-    }
-
+    mu_i_sv_debug_command (mach, mach->pc - 1,
+			   what, tag_list, arg_list);
+  else
+    mu_i_sv_trace (mach, what, tag_list, arg_list);
+  
   if (!INSTR_DISASS(mach))
     rc = han (mach, arg_list, tag_list);
   return rc;
@@ -96,12 +81,8 @@ void
 _mu_i_sv_instr_action (mu_sieve_machine_t mach)
 {
   mach->identifier = SIEVE_ARG (mach, 3, string);
-  if (INSTR_DEBUG (mach))
-    mu_sieve_debug (mach, "%4lu: ACTION: %s",
-		    (unsigned long) (mach->pc - 1),
-		    mach->identifier);
   mach->action_count++;
-  instr_run (mach);
+  instr_run (mach, "ACTION");
   mach->identifier = NULL;
 }
 
@@ -109,11 +90,7 @@ void
 _mu_i_sv_instr_test (mu_sieve_machine_t mach)
 {
   mach->identifier = SIEVE_ARG (mach, 3, string);
-  if (INSTR_DEBUG (mach))
-    mu_sieve_debug (mach, "%4lu: TEST: %s",
-		    (unsigned long) (mach->pc - 1),
-		    mach->identifier);
-  mach->reg = instr_run (mach);
+  mach->reg = instr_run (mach, "TEST");
   mach->identifier = NULL;
 }
 
@@ -121,11 +98,9 @@ void
 _mu_i_sv_instr_push (mu_sieve_machine_t mach)
 {
   if (INSTR_DEBUG (mach))
-    {
-      mu_sieve_debug (mach, "%4lu: PUSH", (unsigned long)(mach->pc - 1));
-      if (INSTR_DISASS (mach))
-	return;
-    }
+    mu_i_sv_debug (mach, mach->pc - 1, "PUSH");
+  if (INSTR_DISASS (mach))
+    return;
   
   if (!mach->stack && mu_list_create (&mach->stack))
     {
@@ -139,11 +114,9 @@ void
 _mu_i_sv_instr_pop (mu_sieve_machine_t mach)
 {
   if (INSTR_DEBUG (mach))
-    {
-      mu_sieve_debug (mach, "%4lu: POP", (unsigned long)(mach->pc - 1));
-      if (INSTR_DISASS (mach))
-	return;
-    }
+    mu_i_sv_debug (mach, mach->pc - 1, "POP");
+  if (INSTR_DISASS (mach))
+    return;
 
   if (!mach->stack || mu_list_is_empty (mach->stack))
     {
@@ -157,11 +130,9 @@ void
 _mu_i_sv_instr_not (mu_sieve_machine_t mach)
 {
   if (INSTR_DEBUG (mach))
-    {
-      mu_sieve_debug (mach, "%4lu: NOT", (unsigned long)(mach->pc - 1));
-      if (INSTR_DISASS (mach))
-	return;
-    }
+    mu_i_sv_debug (mach, mach->pc - 1, "NOT");
+  if (INSTR_DISASS (mach))
+    return;
   mach->reg = !mach->reg;
 }
 
@@ -172,13 +143,10 @@ _mu_i_sv_instr_branch (mu_sieve_machine_t mach)
 
   SIEVE_ADJUST (mach, 1);
   if (INSTR_DEBUG (mach))
-    {
-      mu_sieve_debug (mach, "%4lu: BRANCH %lu",
-		      (unsigned long)(mach->pc-2),
-		      (unsigned long)(mach->pc + num));
-      if (INSTR_DISASS (mach))
-	return;
-    }
+    mu_i_sv_debug (mach, mach->pc - 2, "BRANCH %lu",
+		   (unsigned long)(mach->pc + num));
+  if (INSTR_DISASS (mach))
+    return;
 
   mach->pc += num;
 }
@@ -190,13 +158,10 @@ _mu_i_sv_instr_brz (mu_sieve_machine_t mach)
   SIEVE_ADJUST (mach, 1);
 
   if (INSTR_DEBUG (mach))
-    {
-      mu_sieve_debug (mach, "%4lu: BRZ %lu",
-		      (unsigned long)(mach->pc-2),
-		      (unsigned long)(mach->pc + num));
-      if (INSTR_DISASS (mach))
-	return;
-    }
+    mu_i_sv_debug (mach, mach->pc - 2, "BRZ %lu",
+		   (unsigned long)(mach->pc + num));
+  if (INSTR_DISASS (mach))
+    return;
   
   if (!mach->reg)
     mach->pc += num;
@@ -209,13 +174,10 @@ _mu_i_sv_instr_brnz (mu_sieve_machine_t mach)
   SIEVE_ADJUST (mach, 1);
 
   if (INSTR_DEBUG (mach))
-    {
-      mu_sieve_debug (mach, "%4lu: BRNZ %lu",
-		      (unsigned long)(mach->pc-2),
-		      (unsigned long)(mach->pc + num));
-      if (INSTR_DISASS (mach))
-	return;
-    }
+    mu_i_sv_debug (mach, mach->pc - 2, "BRNZ %lu",
+		   (unsigned long)(mach->pc + num));
+  if (INSTR_DISASS (mach))
+    return;
   
   if (mach->reg)
     mach->pc += num;
@@ -287,35 +249,40 @@ mu_sieve_set_dry_run (mu_sieve_machine_t mach, int val)
 int
 sieve_run (mu_sieve_machine_t mach)
 {
-  if (setjmp (mach->errbuf))
-    return 1;
+  int rc;
 
-  mach->action_count = 0;
+  mu_sieve_stream_save (mach);
+  
+  rc = setjmp (mach->errbuf);
+  if (rc == 0)
+    {
+      mach->action_count = 0;
   
-  for (mach->pc = 1; mach->prog[mach->pc].handler; )
-    (*mach->prog[mach->pc++].instr) (mach);
+      for (mach->pc = 1; mach->prog[mach->pc].handler; )
+	(*mach->prog[mach->pc++].instr) (mach);
 
-  if (mach->action_count == 0)
-    mu_sieve_log_action (mach, "IMPLICIT KEEP", NULL);
+      if (mach->action_count == 0)
+	mu_sieve_log_action (mach, "IMPLICIT KEEP", NULL);
   
-  if (INSTR_DEBUG (mach))
-    mu_sieve_debug (mach, "%4lu: STOP", (unsigned long) mach->pc);
+      if (INSTR_DEBUG (mach))
+	mu_i_sv_debug (mach, mach->pc, "STOP");
+    }
   
-  return 0;
+  mu_sieve_stream_restore (mach);
+  
+  return rc;
 }
 
 int
 mu_sieve_disass (mu_sieve_machine_t mach)
 {
-  mu_debug_level_t lev;
   int rc;
-  
-  mu_debug_get_category_level (mu_sieve_debug_handle, &lev);
-  mu_debug_set_category_level (mu_sieve_debug_handle,
-			       MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE8)
-			       | MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE9));
+
+  if (mach->state != mu_sieve_state_compiled)
+    return EINVAL; /* FIXME: Error code */
+  mach->state = mu_sieve_state_disass;
   rc = sieve_run (mach);
-  mu_debug_set_category_level (mu_sieve_debug_handle, lev);
+  mach->state = mu_sieve_state_compiled;
   return rc;
 }
   
diff --git a/libmu_sieve/sieve-priv.h b/libmu_sieve/sieve-priv.h
index 1ff62d9..12aafaa 100644
--- a/libmu_sieve/sieve-priv.h
+++ b/libmu_sieve/sieve-priv.h
@@ -45,12 +45,17 @@ struct mu_locus_range
   
 #define YYLTYPE struct mu_locus_range
 
+#define MU_SV_SAVED_ERR_STATE 0x01
+#define MU_SV_SAVED_DBG_STATE 0x02
+#define MU_SV_SAVED_STATE     0x80
+
 enum mu_sieve_state
   {
     mu_sieve_state_init,
     mu_sieve_state_error,
     mu_sieve_state_compiled,
-    mu_sieve_state_running
+    mu_sieve_state_running,
+    mu_sieve_state_disass
   };
 
 struct mu_sieve_machine
@@ -85,9 +90,17 @@ struct mu_sieve_machine
   size_t    msgno;           /* Current message number */
   mu_message_t msg;          /* Current message */
   int action_count;          /* Number of actions executed over this message */
-			    
+
+  /* Stream state info */
+  int state_flags;
+  int err_mode;
+  struct mu_locus err_locus;
+  int dbg_mode;
+  struct mu_locus dbg_locus;
+  
   /* User supplied data */
   mu_stream_t errstream;
+  mu_stream_t dbgstream;
   
   mu_sieve_action_log_t logger;
   
@@ -165,7 +178,6 @@ void _mu_i_sv_instr_not (mu_sieve_machine_t mach);
 void _mu_i_sv_instr_branch (mu_sieve_machine_t mach);
 void _mu_i_sv_instr_brz (mu_sieve_machine_t mach);
 void _mu_i_sv_instr_brnz (mu_sieve_machine_t mach);
-void _mu_i_sv_instr_nop (mu_sieve_machine_t mach);
 void _mu_i_sv_instr_source (mu_sieve_machine_t mach);
 void _mu_i_sv_instr_line (mu_sieve_machine_t mach);
 
@@ -180,3 +192,15 @@ void mu_i_sv_print_tag_list (mu_list_t list, mu_stream_t str);
 
 void mu_i_sv_error (mu_sieve_machine_t mach);
 
+void mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...)
+  MU_PRINTFLIKE(3,4);
+void mu_i_sv_debug_command (mu_sieve_machine_t mach,
+			    size_t pc,
+			    char const *what,
+			    mu_list_t taglist, mu_list_t arglist);
+void mu_i_sv_trace (mu_sieve_machine_t mach, const char *what,
+		    mu_list_t taglist, mu_list_t arglist);
+
+void mu_i_sv_argf (mu_stream_t str, mu_list_t list);
+void mu_i_sv_valf (mu_stream_t str, mu_sieve_value_t *val);
+
diff --git a/libmu_sieve/sieve.y b/libmu_sieve/sieve.y
index 86fb962..eaa1cfc 100644
--- a/libmu_sieve/sieve.y
+++ b/libmu_sieve/sieve.y
@@ -502,12 +502,9 @@ string_dumper (void *item, void *data)
   return 0;
 }
 
-static int
-dump_val (void *item, void *data)
+void
+mu_i_sv_valf (mu_stream_t str, mu_sieve_value_t *val)
 {
-  mu_sieve_value_t *val = item;
-  mu_stream_t str = data;
-
   mu_stream_printf (str, " ");
   switch (val->type)
     {
@@ -544,7 +541,7 @@ dump_val (void *item, void *data)
 	
     case SVT_VALUE_LIST:
       mu_stream_printf (str, "[");
-      mu_list_foreach (val->v.list, dump_val, str);
+      mu_i_sv_argf (str, val->v.list);
       mu_stream_printf (str, "]");
       break;
       
@@ -555,9 +552,23 @@ dump_val (void *item, void *data)
     default:
       abort ();
     }
-  return 0;
 }
   
+static int
+dump_val (void *item, void *data)
+{
+  mu_sieve_value_t *val = item;
+  mu_stream_t str = data;
+  mu_i_sv_valf (str, val);
+  return 0;
+}
+
+void
+mu_i_sv_argf (mu_stream_t str, mu_list_t list)
+{
+  mu_list_foreach (list, dump_val, str);
+}
+
 static void
 dump_node_command (mu_stream_t str, struct mu_sieve_node *node, unsigned level)
 {
@@ -983,8 +994,7 @@ mu_i_sv_error (mu_sieve_machine_t mach)
 }
 
 int
-mu_sieve_machine_init_ex (mu_sieve_machine_t *pmach,
-			  void *data, mu_stream_t errstream)
+mu_sieve_machine_init (mu_sieve_machine_t *pmach)
 {
   int rc;
   mu_sieve_machine_t mach;
@@ -1011,33 +1021,46 @@ mu_sieve_machine_init_ex (mu_sieve_machine_t *pmach,
   
   mach->source_list = NULL;
 
-  mach->data = data;
-  mach->errstream = errstream;
-  mu_stream_ref (errstream);
+  mach->data = NULL;
+
+  mu_sieve_set_diag_stream (mach, mu_strerr);
+  mu_sieve_set_dbg_stream (mach, mu_strerr);
   
   *pmach = mach;
   return 0;
 }
 
 int
-mu_sieve_machine_init (mu_sieve_machine_t *pmach)
-{
-  return mu_sieve_machine_init_ex (pmach, NULL, mu_strerr);
-}
-
-int
 mu_sieve_machine_inherit (mu_sieve_machine_t const parent,
 			  mu_sieve_machine_t *pmach)
 {
   mu_sieve_machine_t child;
   int rc;
   
-  rc = mu_sieve_machine_init_ex (&child, parent->data, parent->errstream);
+  if (!parent || parent->state == mu_sieve_state_error)
+    return EINVAL;
+  
+  rc = mu_sieve_machine_init (&child);
   if (rc)
     return rc;
 
+  child->dry_run     = parent->dry_run;
+
+  child->state_flags = parent->state_flags;
+  child->err_mode    = parent->err_mode;
+  child->err_locus   = parent->err_locus;
+  child->dbg_mode    = parent->dbg_mode;
+  child->dbg_locus   = parent->dbg_locus;  
+
+  child->errstream = parent->errstream;
+  mu_stream_ref (child->errstream);
+  child->dbgstream = parent->dbgstream;
+  mu_stream_ref (child->dbgstream);
+  
+  child->data = parent->data;
   child->logger = parent->logger;
-  child->dry_run = parent->dry_run;
+  child->daemon_email = parent->daemon_email;
+
   *pmach = child;
   return 0;
 }
@@ -1047,7 +1070,9 @@ mu_sieve_machine_dup (mu_sieve_machine_t const in, mu_sieve_machine_t *out)
 {
   int rc;
   mu_sieve_machine_t mach;
-  
+
+  if (!in || in->state == mu_sieve_state_error)
+    return EINVAL; 
   mach = malloc (sizeof (*mach));
   if (!mach)
     return ENOMEM;
@@ -1066,15 +1091,33 @@ mu_sieve_machine_dup (mu_sieve_machine_t const in, mu_sieve_machine_t *out)
   mach->progsize = in->progsize;
   mach->prog = in->prog;
 
-  mach->state = in->state;
+  switch (in->state)
+    {
+    case mu_sieve_state_running:
+    case mu_sieve_state_disass:
+      mach->state = mu_sieve_state_compiled;
+      break;
+
+    default:
+      mach->state = in->state;
+    }
+  
   mach->pc = 0;
   mach->reg = 0;
   mach->stack = NULL;
 
   mach->dry_run = in->dry_run;
-  
+
+  mach->state_flags = in->state_flags;
+  mach->err_mode    = in->err_mode;
+  mach->err_locus   = in->err_locus;
+  mach->dbg_mode    = in->dbg_mode;
+  mach->dbg_locus   = in->dbg_locus;  
+
   mach->errstream = in->errstream;
   mu_stream_ref (mach->errstream);
+  mach->dbgstream = in->dbgstream;
+  mu_stream_ref (mach->dbgstream);
   
   mach->data = in->data;
   mach->logger = in->logger;
@@ -1100,6 +1143,21 @@ mu_sieve_set_diag_stream (mu_sieve_machine_t mach, mu_stream_t str)
 }
 
 void
+mu_sieve_set_dbg_stream (mu_sieve_machine_t mach, mu_stream_t str)
+{
+  mu_stream_unref (mach->dbgstream);
+  mach->dbgstream = str;
+  mu_stream_ref (mach->dbgstream);
+}
+
+void
+mu_sieve_get_dbg_stream (mu_sieve_machine_t mach, mu_stream_t *pstr)
+{
+  *pstr = mach->dbgstream;
+  mu_stream_ref (*pstr);
+}
+
+void
 mu_sieve_set_logger (mu_sieve_machine_t mach, mu_sieve_action_log_t logger)
 {
   mach->logger = logger;
@@ -1204,10 +1262,9 @@ void
 mu_sieve_machine_destroy (mu_sieve_machine_t *pmach)
 {
   mu_sieve_machine_t mach = *pmach;
-  /* FIXME: Restore stream state (locus & mode) */
-  mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
-                   MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL);
+
   mu_stream_destroy (&mach->errstream);
+  mu_stream_destroy (&mach->dbgstream);
   mu_mailer_destroy (&mach->mailer);
   mu_list_foreach (mach->destr_list, _run_destructor, NULL);
   mu_list_destroy (&mach->destr_list);
@@ -1221,42 +1278,31 @@ mu_sieve_machine_destroy (mu_sieve_machine_t *pmach)
   *pmach = NULL;
 }
 
-static void
-sieve_machine_begin (mu_sieve_machine_t mach, const char *file)
-{
-  mu_i_sv_register_standard_actions (mach);
-  mu_i_sv_register_standard_tests (mach);
-  mu_i_sv_register_standard_comparators (mach);
-  mu_sieve_machine = mach;
-}
-
-static void
-sieve_machine_finish (void)
-{
-  //nothing
-}
-
 int
 with_machine (mu_sieve_machine_t mach, char const *name,
 	      int (*thunk) (void *), void *data)
 {
   int rc = 0;
-  mu_stream_t save_errstr = mu_strerr;
-  
+  mu_stream_t save_errstr;
+
+  save_errstr = mu_strerr;  
   mu_stream_ref (save_errstr);
   mu_strerr = mach->errstream;
   mu_stream_ref (mu_strerr);
 
-  sieve_machine_begin (mach, name);
+  mu_i_sv_register_standard_actions (mach);
+  mu_i_sv_register_standard_tests (mach);
+  mu_i_sv_register_standard_comparators (mach);
+  mu_sieve_machine = mach;
 
+  mu_sieve_stream_save (mach);
   rc = thunk (data);
-
-  sieve_machine_finish ();
+  mu_sieve_stream_restore (mach);
 
   mu_stream_unref (save_errstr);
   mu_strerr = save_errstr;
   mu_stream_unref (mu_strerr);
-
+  
   return rc;
 }
 
diff --git a/libmu_sieve/tests.c b/libmu_sieve/tests.c
index 5d3efee..88adbe6 100644
--- a/libmu_sieve/tests.c
+++ b/libmu_sieve/tests.c
@@ -119,8 +119,6 @@ sieve_test_address (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   size_t count;
   
-  mu_sieve_trace (mach, "ADDRESS");
-
   h = mu_sieve_value_get (args, 0);
   if (!h)
     {
@@ -182,8 +180,6 @@ sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   size_t count, mcount = 0;
   struct header_closure clos;
   
-  mu_sieve_trace (mach, "HEADER");
-
   h = mu_sieve_value_get (args, 0);
   if (!h)
     {
@@ -265,8 +261,6 @@ sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   size_t count;
   
-  mu_sieve_trace (mach, "ENVELOPE");
-
   h = mu_sieve_value_get (args, 0);
   if (!h)
     {
@@ -331,8 +325,6 @@ sieve_test_exists (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_header_t header = NULL;
   mu_sieve_value_t *val;   
 
-  mu_sieve_trace (mach, "EXISTS");
-
   mu_message_get_header (mu_sieve_get_message (mach), &header);
   val = mu_sieve_value_get (args, 0);
   if (!val)
diff --git a/libmu_sieve/util.c b/libmu_sieve/util.c
index d0538b8..8b437c7 100644
--- a/libmu_sieve/util.c
+++ b/libmu_sieve/util.c
@@ -210,67 +210,7 @@ mu_sieve_arg_error (mu_sieve_machine_t mach, int n)
 {
   mu_sieve_error (mach, _("cannot retrieve argument %d"), n);
 }
-
-void
-mu_sieve_debug (mu_sieve_machine_t mach, const char *fmt, ...)
-{
-  va_list ap;
-
-  va_start (ap, fmt);
-  mu_stream_printf (mach->errstream, "\033s<%d>", MU_LOG_DEBUG);
-  if (mach->locus.mu_file)
-    mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
-		      MU_LOGMODE_LOCUS,
-		      (unsigned) strlen (mach->locus.mu_file),
-		      mach->locus.mu_file,
-		      mach->locus.mu_line);
-  mu_stream_vprintf (mach->errstream, fmt, ap);
-  mu_stream_write (mach->errstream, "\n", 1, NULL);
-  va_end (ap);
-}
-
-void
-mu_sieve_trace (mu_sieve_machine_t mach, const char *fmt, ...)
-{
-  va_list ap;
-
-  if (!mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE4))
-    return;
-  
-  va_start (ap, fmt);
-  mu_stream_printf (mach->errstream, "\033s<%d>", MU_LOG_DEBUG);
-  if (mach->locus.mu_file)
-    mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
-		      MU_LOGMODE_LOCUS,
-		      (unsigned) strlen (mach->locus.mu_file),
-		      mach->locus.mu_file,
-		      mach->locus.mu_line);
-  mu_stream_vprintf (mach->errstream, fmt, ap);
-  mu_stream_write (mach->errstream, "\n", 1, NULL);
-  va_end (ap);
-}
-
-void
-mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
-		     const char *fmt, ...)
-{
-  va_list ap;
-  
-  if (!mach->logger)
-    return;
-  va_start (ap, fmt);
-  mu_stream_printf (mach->errstream, "\033s<%d>", MU_LOG_INFO);
-  if (mach->locus.mu_file)
-    mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
-		      MU_LOGMODE_LOCUS,
-		      (unsigned) strlen (mach->locus.mu_file),
-		      mach->locus.mu_file,
-		      mach->locus.mu_line);
-  mach->logger (mach->data, mach->errstream, mach->msgno, mach->msg,
-		action, fmt, ap);
-  va_end (ap);
-}
-  
+
 const char *
 mu_sieve_type_str (mu_sieve_data_type type)
 {
@@ -303,95 +243,115 @@ mu_sieve_type_str (mu_sieve_data_type type)
 
   return "unknown";
 }
-
+
 static int
-string_printer (void *item, void *data)
+tag_printer (void *item, void *data)
 {
-  char *s = item;
+  mu_sieve_runtime_tag_t *val = item;
   mu_stream_t str = data;
-
-  mu_stream_printf (str, "\"%s\" ", s);
+  
+  mu_stream_printf (str, " :%s", val->tag);
+  if (val->arg)
+    mu_i_sv_valf (str, val->arg);
   return 0;
 }
 
-static void sieve_print_value (mu_sieve_value_t *, mu_stream_t str);
-
-static int
-value_printer (void *item, void *data)
+void
+mu_i_sv_tagf (mu_stream_t str, mu_list_t taglist)
 {
-  mu_sieve_value_t *val = item;
-  mu_stream_t str = data;
-  
-  sieve_print_value (val, str);
-  mu_stream_printf (str, " ");
-  return 0;
+  mu_list_foreach (taglist, tag_printer, str);
 }
 
-static void
-sieve_print_value (mu_sieve_value_t *val, mu_stream_t str)
+void
+mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...)
 {
-  mu_stream_printf (str, "%s(", mu_sieve_type_str (val->type));
-  switch (val->type)
-    {
-    case SVT_VOID:
-      break;
-      
-    case SVT_NUMBER:
-      mu_stream_printf (str, "%lu", (unsigned long) val->v.number);
-      break;
-      
-    case SVT_TAG:
-    case SVT_IDENT:
-    case SVT_STRING:
-      mu_stream_printf (str, "%s", val->v.string);
-      break;
-      
-    case SVT_STRING_LIST:
-      mu_list_foreach (val->v.list, string_printer, str);
-      break;
-
-    case SVT_VALUE_LIST:
-      mu_list_foreach (val->v.list, value_printer, str);
+  va_list ap;
 
-    case SVT_POINTER:
-      mu_stream_printf (str, "%p", val->v.ptr);
+  if (mach->state_flags & MU_SV_SAVED_DBG_STATE)
+    {
+      unsigned severity = MU_LOG_DEBUG;
+      mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_SET_SEVERITY, &severity);
+      if (mach->locus.mu_file)
+	{
+	  int mode = mach->dbg_mode | MU_LOGMODE_LOCUS;
+	  mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+			   MU_IOCTL_LOGSTREAM_SET_LOCUS, &mach->locus);
+	  mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+			   MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
+	}
     }
-  mu_stream_printf (str, ")");
-} 
+  va_start (ap, fmt);
+  mu_stream_printf (mach->dbgstream, "%4zu: ", pc);
+  mu_stream_vprintf (mach->dbgstream, fmt, ap);
+  mu_stream_write (mach->dbgstream, "\n", 1, NULL);
+  va_end (ap);
+}
 
 void
-mu_i_sv_print_value_list (mu_list_t list, mu_stream_t str)
+mu_i_sv_debug_command (mu_sieve_machine_t mach,
+		       size_t pc,
+		       char const *what,
+		       mu_list_t taglist, mu_list_t arglist)
 {
-  mu_sieve_value_t val;
-  
-  val.type = SVT_VALUE_LIST;
-  val.v.list = list;
-  sieve_print_value (&val, str);
+  if (mach->state_flags & MU_SV_SAVED_DBG_STATE)
+    {
+      unsigned severity = MU_LOG_DEBUG;
+      mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_SET_SEVERITY, &severity);
+      if (mach->locus.mu_file)
+	{
+	  int mode = mach->dbg_mode | MU_LOGMODE_LOCUS;
+	  mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+			   MU_IOCTL_LOGSTREAM_SET_LOCUS, &mach->locus);
+	  mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+			   MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
+	}
+    }
+  mu_stream_printf (mach->dbgstream, "%4zu: %s: %s",
+		    pc, what, mach->identifier);  
+  mu_i_sv_tagf (mach->dbgstream, taglist);
+  mu_i_sv_argf (mach->dbgstream, arglist);
+  mu_stream_write (mach->dbgstream, "\n", 1, NULL);
 }
 
-static int
-tag_printer (void *item, void *data)
+void
+mu_i_sv_trace (mu_sieve_machine_t mach, const char *what,
+	       mu_list_t taglist, mu_list_t arglist)
 {
-  mu_sieve_runtime_tag_t *val = item;
-  mu_stream_t str = data;
+  if (!mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE4))
+    return;
   
-  mu_stream_printf (str, "%s", val->tag);
-  if (val->arg)
-    {
-      mu_stream_printf (str, "(");
-      sieve_print_value (val->arg, str);
-      mu_stream_printf (str, ")");
-    }
-  mu_stream_printf (str, " ");
-  return 0;
+  mu_stream_printf (mach->errstream, "\033s<%d>", MU_LOG_DEBUG);
+  if (mach->locus.mu_file)
+    mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
+		      MU_LOGMODE_LOCUS,
+		      (unsigned) strlen (mach->locus.mu_file),
+		      mach->locus.mu_file,
+		      mach->locus.mu_line);
+  mu_stream_printf (mach->errstream, "%zu: %s %s", mach->msgno, what,
+		    mach->identifier);
+  mu_i_sv_tagf (mach->errstream, taglist);
+  mu_i_sv_argf (mach->errstream, arglist);
+  mu_stream_printf (mach->errstream, "\n");
 }
 
 void
-mu_i_sv_print_tag_list (mu_list_t list, mu_stream_t str)
+mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
+		     const char *fmt, ...)
 {
-  mu_list_foreach (list, tag_printer, str);
+  va_list ap;
+  
+  if (!mach->logger)
+    return;
+  
+  mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
+		   MU_IOCTL_LOGSTREAM_SET_LOCUS, &mach->locus);
+  va_start (ap, fmt);
+  mach->logger (mach, action, fmt, ap);
+  va_end (ap);
 }
-
+  
 static int
 tag_finder (void *item, void *data)
 {
@@ -437,7 +397,8 @@ mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t ac, void *data)
     }
 }
 
-struct comp_data {
+struct comp_data
+{
   mu_sieve_value_t *val;
   mu_sieve_comparator_t comp;
   mu_sieve_relcmp_t test;
@@ -446,7 +407,8 @@ struct comp_data {
   size_t count;
 };
 
-struct comp_data2 {
+struct comp_data2
+{
   char *sample;
   mu_sieve_comparator_t comp;
   mu_sieve_relcmp_t test;
@@ -481,9 +443,9 @@ _comp_action (void *item, void *data)
 
 int
 mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b,
-		     mu_sieve_comparator_t comp, mu_sieve_relcmp_t test,
-		     mu_sieve_retrieve_t retr,
-		     void *data, size_t *count)
+			mu_sieve_comparator_t comp, mu_sieve_relcmp_t test,
+			mu_sieve_retrieve_t retr,
+			void *data, size_t *count)
 {
   struct comp_data d;
   int rc;
@@ -499,3 +461,51 @@ mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b,
     *count = d.count;
   return rc;
 }
+
+
+void
+mu_sieve_stream_save (mu_sieve_machine_t mach)
+{
+  if (mach->state_flags & MU_SV_SAVED_STATE)
+    return;
+  
+  if (mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_GET_MODE, &mach->err_mode) == 0
+      && mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
+			  MU_IOCTL_LOGSTREAM_SET_LOCUS, &mach->err_locus) == 0)
+      mach->state_flags |= MU_SV_SAVED_ERR_STATE;
+
+  if (mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_GET_MODE, &mach->dbg_mode) == 0
+      && mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+			  MU_IOCTL_LOGSTREAM_SET_LOCUS, &mach->dbg_locus) == 0)
+    mach->state_flags |= MU_SV_SAVED_DBG_STATE;
+  
+  mach->state_flags |= MU_SV_SAVED_STATE;
+}
+
+void
+mu_sieve_stream_restore (mu_sieve_machine_t mach)
+{
+  if (!(mach->state_flags & MU_SV_SAVED_STATE))
+    return;
+
+  if (mach->state_flags & MU_SV_SAVED_ERR_STATE)
+    {
+      mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_SET_MODE, &mach->err_mode);
+      mu_stream_ioctl (mach->errstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_SET_LOCUS, &mach->err_locus);
+    }
+  
+  if (mach->dbgstream != mach->errstream
+      && (mach->state_flags & MU_SV_SAVED_DBG_STATE))
+    {
+      mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_SET_MODE, &mach->dbg_mode);
+      mu_stream_ioctl (mach->dbgstream, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_SET_LOCUS, &mach->dbg_locus);
+    }
+  
+  mach->state_flags = 0;
+}
diff --git a/mail/tests/atlocal.in b/mail/tests/atlocal.in
index 2516e66..73cd349 100644
--- a/mail/tests/atlocal.in
+++ b/mail/tests/atlocal.in
@@ -5,3 +5,5 @@
 
 PATH=@abs_builddir@:@abs_top_builddir@/mail:$top_srcdir:$srcdir:$PATH
 testsuitedir=@abs_top_srcdir@/testsuite
+MALLOC_CHECK_=2
+export MALLOC_CHECK_
diff --git a/python/libmu_py/sieve.c b/python/libmu_py/sieve.c
index d025fe6..baa3fb0 100644
--- a/python/libmu_py/sieve.c
+++ b/python/libmu_py/sieve.c
@@ -107,7 +107,9 @@ api_sieve_machine_init (PyObject *self, PyObject *args)
   if (status)
     return _ro (PyInt_FromLong (status));
   
-  status = mu_sieve_machine_init_ex (&py_mach->mach, NULL, estr);
+  status = mu_sieve_machine_init (&py_mach->mach);
+  if (status == 0)
+    mu_sieve_set_diag_stream (py_mach->mach, estr);
   mu_stream_unref (estr);
   return _ro (PyInt_FromLong (status));
 }
@@ -234,8 +236,7 @@ api_sieve_message (PyObject *self, PyObject *args)
 }
 
 static void
-_sieve_action_printer (void *data, mu_stream_t stream,
-		       size_t msgno, mu_message_t msg,
+_sieve_action_printer (mu_sieve_machine_t mach,
 		       const char *action, const char *fmt, va_list ap)
 {
   PyObject *py_args;
@@ -256,10 +257,12 @@ _sieve_action_printer (void *data, mu_stream_t stream,
 	  PyStream *py_stm = PyStream_NEW ();
 	  if (py_stm)
 	    {
-	      py_stm->stm = stream;
-	      mu_stream_ref (stream);
-	  
-	      py_msg->msg = msg;
+	      size_t msgno;
+	      
+	      mu_sieve_get_diag_stream (mach, &py_stm->stm);
+	      msgno = mu_sieve_get_message_num (mach);
+	      
+	      py_msg->msg = mu_sieve_get_message (mach);
 	      Py_INCREF (py_msg);
 
 	      PyDict_SetItemString (py_dict, "msgno",
@@ -270,7 +273,7 @@ _sieve_action_printer (void *data, mu_stream_t stream,
 
 	      if (mu_vasnprintf (&buf, &buflen, fmt, ap))
 		{
-		  mu_stream_unref (stream);
+		  mu_stream_destroy (&py_stm->stm);
 		  return;
 		}
 	      PyDict_SetItemString (py_dict, "text",
@@ -280,7 +283,7 @@ _sieve_action_printer (void *data, mu_stream_t stream,
 	      py_args = PyTuple_New (1);
 	      if (py_args)
 		{
-		  struct _mu_py_sieve_logger *s = data;
+		  struct _mu_py_sieve_logger *s = mu_sieve_get_data (mach);
 		  PyObject *py_fnc = s->py_action_printer;
 
 		  Py_INCREF (py_dict);
diff --git a/sieve/sieve.c b/sieve/sieve.c
index 0f7789a..e5e066c 100644
--- a/sieve/sieve.c
+++ b/sieve/sieve.c
@@ -247,27 +247,38 @@ static struct mu_cli_setup cli = {
   N_("GNU sieve -- a mail filtering tool."),
   "SCRIPT",
   NULL,
-  N_("Debug flags:\n\
+  N_("Sieve-specific debug levels:\n\
+\n\
+  trace1  -  print parse tree before optimization\n\
+  trace2  -  print parse tree after optimization\n\
+  trace3  -  print parser traces\n\
+  trace4  -  print tests and actions being executed\n\
+  trace9  -  print each Sieve instruction being executed\n\
+\n\
+Compatibility debug flags:\n\
   g - main parser traces\n\
   T - mailutils traces (same as --debug-level=sieve.trace0-trace1)\n\
   P - network protocols (same as --debug-level=sieve.=prot)\n\
-  t - sieve trace (MU_SIEVE_DEBUG_TRACE)\n\
-  i - sieve instructions trace (MU_SIEVE_DEBUG_INSTR)\n")
+  t - sieve trace (same as --debug-level=sieve.=trace4)\n\
+  i - sieve instructions trace (same as --debug-level=sieve.=trace9)\n")
 };
 
 static void
-_sieve_action_log (void *unused,
-		   mu_stream_t stream, size_t msgno,
-		   mu_message_t msg,
+_sieve_action_log (mu_sieve_machine_t mach,
 		   const char *action, const char *fmt, va_list ap)
 {
   size_t uid = 0;
+  mu_message_t msg;
+  mu_stream_t stream;
+
+  mu_sieve_get_diag_stream (mach, &stream);
+  msg = mu_sieve_get_message (mach);
   
   mu_message_get_uid (msg, &uid);
   mu_stream_printf (stream, "\033s<%d>\033%c<%d>", MU_LOG_NOTICE,
 		    sieve_print_locus ? 'O' : 'X', MU_LOGMODE_LOCUS);
   mu_stream_printf (stream, _("%s on msg uid %lu"),
-		  action, (unsigned long) uid);
+		    action, (unsigned long) uid);
   
   if (fmt && strlen (fmt))
     {
@@ -275,6 +286,8 @@ _sieve_action_log (void *unused,
       mu_stream_vprintf (stream, fmt, ap);
     }
   mu_stream_printf (stream, "\n");
+
+  mu_stream_unref (stream);
 }
 
 static int
@@ -440,7 +453,10 @@ main (int argc, char *argv[])
   if (compile_only)
     {
       if (compile_only == 2)
-	mu_sieve_disass (mach);
+	{
+	  mu_sieve_set_dbg_stream (mach, mu_strout);
+	  mu_sieve_disass (mach);
+	}
       return EX_OK;
     }
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 26 00:53:02 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cAVv4-0001Sl-JB
	for mharc-commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:53:02 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40491)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cAVv0-0001QU-GF
	for commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:53:01 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cAVux-00018R-Jz
	for commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:52:58 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:55312)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cAVux-00018C-FQ
	for commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:52:55 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 3419D2201C5; Sat, 26 Nov 2016 05:52:55 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-12-g1e6dc07
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 05df35d07a46f70e7d09a4da39fdd2d7a7d58ed0
X-Git-Newrev: 1e6dc073c8b89d740c7eeba747965dfb76be5f2a
Message-Id: <20161126055255.3419D2201C5@vcs.savannah.gnu.org>
Date: Sat, 26 Nov 2016 05:52:54 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 26 Nov 2016 05:53:01 -0000

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=1e6dc073c8b89d740c7eeba747965dfb76be5f2a

The branch, master has been updated
       via  1e6dc073c8b89d740c7eeba747965dfb76be5f2a (commit)
      from  05df35d07a46f70e7d09a4da39fdd2d7a7d58ed0 (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 1e6dc073c8b89d740c7eeba747965dfb76be5f2a
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 13:37:47 2016 +0200

    Implement RFC 5228, 2.4.2.4 (Encoding Characters Using "encoded-character")
    
    * libmu_sieve/encoded.c: New file.
    * libmu_sieve/strexp.c: New file.
    * libmu_sieve/Makefile.am: Add new files.
    * libmu_sieve/require.c (mu_sieve_require): Understand "encoded-character".
    * libmu_sieve/sieve-priv.h (mu_i_sv_interp_t): New typedef.
    (mu_i_sv_expand_encoded_char): New proto.
    (mu_sieve_require_encoded_character): New proto.
    * libmu_sieve/sieve.l (string): Rewrite via line_.* functions.  This
    fixes memory leaks on mu_sieve_machine_destroy.
    (line_finish): Expand ${} sequences before returning.
    (mu_sieve_require_encoded_character): New function.
    * sieve/tests/enc-char.at: New file.
    * sieve/tests/Makefile.am: Add enc-char.at
    * sieve/tests/testsuite.at: Likewise.

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

Summary of changes:
 include/mailutils/sieve.h |   30 +++---
 libmu_sieve/Makefile.am   |    2 +
 libmu_sieve/encoded.c     |  215 ++++++++++++++++++++++++++++++++++++++
 libmu_sieve/require.c     |    5 +
 libmu_sieve/sieve-priv.h  |   11 ++
 libmu_sieve/sieve.l       |   68 ++++++++++--
 libmu_sieve/strexp.c      |  250 +++++++++++++++++++++++++++++++++++++++++++++
 sieve/tests/Makefile.am   |    1 +
 sieve/tests/enc-char.at   |   62 +++++++++++
 sieve/tests/testsuite.at  |    1 +
 10 files changed, 619 insertions(+), 26 deletions(-)
 create mode 100644 libmu_sieve/encoded.c
 create mode 100644 libmu_sieve/strexp.c
 create mode 100644 sieve/tests/enc-char.at

diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 364a71a..019ee61 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -123,10 +123,10 @@ void mu_sieve_debug_init (void);
   
 /* Memory allocation functions */
 void *mu_sieve_alloc (size_t size);
-void *mu_sieve_palloc (mu_list_t * pool, size_t size);
-void *mu_sieve_prealloc (mu_list_t * pool, void *ptr, size_t size);
-void mu_sieve_pfree (mu_list_t * pool, void *ptr);
-char *mu_sieve_pstrdup (mu_list_t * pool, const char *str);
+void *mu_sieve_palloc (mu_list_t *pool, size_t size);
+void *mu_sieve_prealloc (mu_list_t *pool, void *ptr, size_t size);
+void mu_sieve_pfree (mu_list_t *pool, void *ptr);
+char *mu_sieve_pstrdup (mu_list_t *pool, const char *str);
 
 void *mu_sieve_malloc (mu_sieve_machine_t mach, size_t size);
 char *mu_sieve_mstrdup (mu_sieve_machine_t mach, const char *str);
@@ -134,7 +134,7 @@ void *mu_sieve_mrealloc (mu_sieve_machine_t mach, void *ptr, size_t size);
 void mu_sieve_mfree (mu_sieve_machine_t mach, void *ptr);
 
 mu_sieve_value_t *mu_sieve_value_create (mu_sieve_data_type type, void *data);
-void mu_sieve_slist_destroy (mu_list_t * plist);
+void mu_sieve_slist_destroy (mu_list_t *plist);
 
 /* Symbol space functions */
 mu_sieve_register_t *mu_sieve_test_lookup (mu_sieve_machine_t mach,
@@ -148,8 +148,8 @@ int mu_sieve_register_test_ext (mu_sieve_machine_t mach,
 				mu_sieve_tag_group_t *tags, int required);
 int mu_sieve_register_test (mu_sieve_machine_t mach,
 			    const char *name, mu_sieve_handler_t handler,
-			    mu_sieve_data_type * arg_types,
-			    mu_sieve_tag_group_t * tags, int required);
+			    mu_sieve_data_type *arg_types,
+			    mu_sieve_tag_group_t *tags, int required);
 
 int mu_sieve_register_action_ext (mu_sieve_machine_t mach,
 				  const char *name, mu_sieve_handler_t handler,
@@ -158,8 +158,8 @@ int mu_sieve_register_action_ext (mu_sieve_machine_t mach,
 				  mu_sieve_tag_group_t *tags, int required);
 int mu_sieve_register_action (mu_sieve_machine_t mach,
 			      const char *name, mu_sieve_handler_t handler,
-			      mu_sieve_data_type * arg_types,
-			      mu_sieve_tag_group_t * tags, int required);
+			      mu_sieve_data_type *arg_types,
+			      mu_sieve_tag_group_t *tags, int required);
 int mu_sieve_register_comparator (mu_sieve_machine_t mach, const char *name,
 				  int required, mu_sieve_comparator_t is,
 				  mu_sieve_comparator_t contains,
@@ -177,8 +177,8 @@ mu_sieve_comparator_t mu_sieve_comparator_lookup (mu_sieve_machine_t mach,
 
 mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach,
 					       mu_list_t tags);
-int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t * test,
-			    mu_sieve_relcmpn_t * stest);
+int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t *test,
+			    mu_sieve_relcmpn_t *stest);
 mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach,
 				       mu_list_t tags);
 
@@ -195,12 +195,12 @@ int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
 				 mu_list_t args);
 /* Operations in value lists */
 mu_sieve_value_t *mu_sieve_value_get (mu_list_t vlist, size_t index);
-int mu_sieve_vlist_do (mu_sieve_value_t * val, mu_list_action_t ac,
+int mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t ac,
 		       void *data);
-int mu_sieve_vlist_compare (mu_sieve_value_t * a, mu_sieve_value_t * b,
+int mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b,
 			    mu_sieve_comparator_t comp,
 			    mu_sieve_relcmp_t test, mu_sieve_retrieve_t ac,
-			    void *data, size_t * count);
+			    void *data, size_t *count);
 
 /* Functions to create and destroy sieve machine */
 int mu_sieve_machine_init (mu_sieve_machine_t *mach);
@@ -208,7 +208,7 @@ int mu_sieve_machine_dup (mu_sieve_machine_t const in,
 			  mu_sieve_machine_t *out);
 int mu_sieve_machine_inherit (mu_sieve_machine_t const in,
 			      mu_sieve_machine_t *out);
-void mu_sieve_machine_destroy (mu_sieve_machine_t * pmach);
+void mu_sieve_machine_destroy (mu_sieve_machine_t *pmach);
 int mu_sieve_machine_add_destructor (mu_sieve_machine_t mach,
 				     mu_sieve_destructor_t destr, void *ptr);
 
diff --git a/libmu_sieve/Makefile.am b/libmu_sieve/Makefile.am
index 63a21c7..1bed327 100644
--- a/libmu_sieve/Makefile.am
+++ b/libmu_sieve/Makefile.am
@@ -30,6 +30,7 @@ libmu_sieve_la_SOURCES = \
  actions.c\
  conf.c\
  comparator.c\
+ encoded.c\
  load.c\
  prog.c\
  register.c\
@@ -39,6 +40,7 @@ libmu_sieve_la_SOURCES = \
  sieve-gram.c\
  sieve-gram.h\
  sieve-lex.c\
+ strexp.c\
  tests.c\
  util.c
 libmu_sieve_la_LIBADD = ${MU_LIB_MAILUTILS} @LTDL_LIB@
diff --git a/libmu_sieve/encoded.c b/libmu_sieve/encoded.c
new file mode 100644
index 0000000..bba56c6
--- /dev/null
+++ b/libmu_sieve/encoded.c
@@ -0,0 +1,215 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 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/>. */
+
+/* The enchoded-character extension for Sieve (RFC 5228, 2.4.2.4) */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif  
+#include <sieve-priv.h>
+#include <mailutils/cctype.h>
+
+typedef int (*convfun) (char const *str, size_t len, size_t *ncons, mu_opool_t pool);
+
+static int hexconv (char const *str, size_t len, size_t *ncons, mu_opool_t pool);
+static int uniconv (char const *str, size_t len, size_t *ncons, mu_opool_t pool);
+
+struct convertor
+{
+  char const *pfx;
+  size_t len;
+  convfun fun;
+};
+
+static struct convertor conv[] = {
+  { "hex",     3, hexconv },
+  { "unicode", 7, uniconv },
+  { NULL }
+};
+
+static convfun
+findconv (char const **pstr, size_t *plen)
+{
+  struct convertor *cp;
+  char const *str = *pstr;
+  size_t len = *plen;
+  
+  for (cp = conv; cp->pfx; cp++)
+    {
+      if (len > cp->len && strncasecmp (str, cp->pfx, cp->len) == 0 &&
+	  str[cp->len] == ':')
+	{
+	  *pstr += cp->len + 1;
+	  *plen -= cp->len + 1;
+	  return cp->fun;
+	}
+    }
+  return NULL;
+}
+
+int
+mu_i_sv_expand_encoded_char (char const *input, size_t len,
+			     char **exp, void *data)
+{
+  int rc;
+  convfun fn;
+  mu_opool_t pool;
+  
+  fn = findconv (&input, &len);
+  if (!fn)
+    return MU_ERR_NOENT;
+
+  rc = mu_opool_create (&pool, MU_OPOOL_DEFAULT);
+  if (rc)
+    return rc;
+
+  while (rc == 0 && len > 0)
+    {
+      if (mu_isblank (*input))
+	{
+	  ++input;
+	  --len;
+	}
+      else if (mu_isxdigit (*input))
+	{
+	  size_t n;
+	  rc = fn (input, len, &n, pool);
+	  if (rc)
+	    break;
+	  input += n;
+	  len -= n;
+	}
+      else
+	{
+	  rc = EILSEQ;
+	  break;
+	}
+    }
+
+  if (rc == 0)
+    {
+      size_t len;
+      char *p = mu_opool_finish (pool, &len);
+      char *res;
+
+      res = malloc (len + 1);
+      if (!res)
+	rc = errno;
+      else
+	{
+	  memcpy (res, p, len);
+	  res[len] = 0;
+	  *exp = res;
+	}
+    }
+  mu_opool_destroy (&pool);
+  return rc;
+}
+
+static int
+hexconv (char const *str, size_t len, size_t *ncons, mu_opool_t pool)
+{
+  char c;
+  
+  if (len < 2)
+    return EILSEQ;
+  else 
+    {
+      c = mu_hex2ul (*str);
+      ++str;
+      if (!mu_isxdigit (*str))
+	return EILSEQ;
+      c = (c << 4) + mu_hex2ul (*str);
+      mu_opool_append_char (pool, c);
+    }
+  *ncons = 2;
+  return 0;
+}
+
+static int
+utf8_wctomb (unsigned int wc, mu_opool_t pool)
+{
+  int count;
+  char r[6];
+
+  /* FIXME: This implementation allows for full UTF-8 range.  RFC 5228
+     states on page 10, that "It is an error for a script to use a hexadecimal
+     value that isn't in either the range 0 to D7FF or the range E000 to
+     10FFFF".  I'm not sure that this limitation should be honored */
+     
+  if (wc < 0x80)
+    count = 1;
+  else if (wc < 0x800)
+    count = 2;
+  else if (wc < 0x10000)
+    count = 3;
+  else if (wc < 0x200000)
+    count = 4;
+  else if (wc < 0x4000000)
+    count = 5;
+  else if (wc <= 0x7fffffff)
+    count = 6;
+  else
+    return EILSEQ;
+
+  switch (count)
+    {
+      /* Note: code falls through cases! */
+    case 6:
+      r[5] = 0x80 | (wc & 0x3f);
+      wc = wc >> 6;
+      wc |= 0x4000000;
+    case 5:
+      r[4] = 0x80 | (wc & 0x3f);
+      wc = wc >> 6;
+      wc |= 0x200000;
+    case 4:
+      r[3] = 0x80 | (wc & 0x3f);
+      wc = wc >> 6;
+      wc |= 0x10000;
+    case 3:
+      r[2] = 0x80 | (wc & 0x3f);
+      wc = wc >> 6;
+      wc |= 0x800;
+    case 2:
+      r[1] = 0x80 | (wc & 0x3f);
+      wc = wc >> 6;
+      wc |= 0xc0;
+    case 1:
+      r[0] = wc;
+    }
+  mu_opool_append (pool, r, count);
+  return 0;
+}
+
+static int
+uniconv (char const *str, size_t len, size_t *ncons, mu_opool_t pool)
+{
+  unsigned int wc = 0;
+  size_t i;
+  
+  for (i = 0; i < len; i++)
+    {
+      if (i >= 12)
+	return EILSEQ;
+      if (!mu_isxdigit (str[i]))
+	break;
+      wc = (wc << 4) + mu_hex2ul (str[i]);
+    }
+  *ncons = i;
+  return utf8_wctomb (wc, pool);
+}
+
diff --git a/libmu_sieve/require.c b/libmu_sieve/require.c
index 18c348e..2f76d05 100644
--- a/libmu_sieve/require.c
+++ b/libmu_sieve/require.c
@@ -68,6 +68,11 @@ mu_sieve_require (mu_sieve_machine_t mach, mu_list_t slist)
 	  reqfn = mu_sieve_require_relational;
 	  text = "";
 	}
+      else if (strcmp (name, "encoded-character") == 0) /* RFC 5228, 2.4.2.4 */
+	{
+	  reqfn = mu_sieve_require_encoded_character;
+	  text = "";
+	}
       else
 	{
 	  reqfn = mu_sieve_require_action;
diff --git a/libmu_sieve/sieve-priv.h b/libmu_sieve/sieve-priv.h
index 12aafaa..8aa4030 100644
--- a/libmu_sieve/sieve-priv.h
+++ b/libmu_sieve/sieve-priv.h
@@ -203,4 +203,15 @@ void mu_i_sv_trace (mu_sieve_machine_t mach, const char *what,
 
 void mu_i_sv_argf (mu_stream_t str, mu_list_t list);
 void mu_i_sv_valf (mu_stream_t str, mu_sieve_value_t *val);
+
+typedef int (*mu_i_sv_interp_t) (char const *, size_t, char **, void *);
+
+int mu_i_sv_string_expand (char const *input,
+			   mu_i_sv_interp_t interp, void *data, char **ret);
+
+int mu_i_sv_expand_encoded_char (char const *input, size_t len, char **exp, void *data);
+
+int mu_sieve_require_encoded_character (mu_sieve_machine_t mach,
+					const char *name);
+
 
diff --git a/libmu_sieve/sieve.l b/libmu_sieve/sieve.l
index 1bbb2a0..f04d219 100644
--- a/libmu_sieve/sieve.l
+++ b/libmu_sieve/sieve.l
@@ -529,11 +529,11 @@ number ()
 }
 
 static int
-string ()
+string (void)
 {
-  yylval.string = mu_sieve_malloc (mu_sieve_machine, yyleng - 1);
-  memcpy (yylval.string, yytext + 1, yyleng - 2);
-  yylval.string[yyleng - 2] = 0;
+  line_begin ();
+  line_add (yytext + 1, yyleng - 2);
+  line_finish ();
   return STRING; 
 }
 
@@ -615,13 +615,6 @@ multiline_begin (void)
 }
 
 static void
-line_finish (void)
-{
-  mu_opool_append_char (mu_sieve_machine->string_pool, 0);
-  yylval.string = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
-}
-
-static void
 multiline_finish (void)
 {
   line_finish ();
@@ -648,3 +641,56 @@ str_unescape (char *text, size_t len)
   str[len - 1] = 0;
   return str;
 }
+
+enum
+  {
+    interp_encoded_character,
+    interp_variable
+  };
+
+#define MAXINTERP (interp_variable+1)
+mu_i_sv_interp_t interpreter[MAXINTERP];
+
+static void
+line_finish (void)
+{
+  int i;
+  char *str;
+  
+  mu_opool_append_char (mu_sieve_machine->string_pool, 0);
+  str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
+  for (i = 0; i < MAXINTERP; i++)
+    {
+      if (interpreter[i])
+	{
+	  char *exp;
+	  int rc = mu_i_sv_string_expand (str, interpreter[i], NULL, &exp);
+	  if (rc == 0)
+	    {
+	      mu_opool_free (mu_sieve_machine->string_pool, str);
+	      mu_opool_appendz (mu_sieve_machine->string_pool, exp);
+	      mu_opool_append_char (mu_sieve_machine->string_pool, 0);
+	      free (exp);
+	      str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
+	    }
+	  else if (rc == MU_ERR_CANCELED)
+	    continue;
+	  else
+	    {
+	      mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
+				_("error expandind string: %s"),
+				mu_strerror (rc));
+	      break;
+	    }
+	}
+    }
+  yylval.string = str;
+}
+
+int
+mu_sieve_require_encoded_character (mu_sieve_machine_t mach,
+				    const char *name)
+{
+  interpreter[interp_encoded_character] = mu_i_sv_expand_encoded_char;
+  return 0;
+}
diff --git a/libmu_sieve/strexp.c b/libmu_sieve/strexp.c
new file mode 100644
index 0000000..b4f31e3
--- /dev/null
+++ b/libmu_sieve/strexp.c
@@ -0,0 +1,250 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 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/>. */
+
+/* String expander */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif  
+#include <sieve-priv.h>
+
+enum segm_type
+  {
+    segm_copy,       /* reference to a fragment of the source string */
+    segm_repl        /* replacement */
+  };
+
+struct string_segment
+{
+  enum segm_type type;  /* Segment type */
+  size_t beg;           /* Beginning of the source string fragmen */
+  size_t end;           /* End of it */
+  char *repl;           /* Replacement, if type == segm_repl */
+};
+
+struct stringbuf
+{
+  char const *string;   /* Source string */
+  size_t length;        /* Length of the source */
+  size_t pos;           /* Offset of the current character */
+  
+  mu_list_t seglist;    /* List of segments */
+  jmp_buf errbuf;       /* Return location on failure */
+
+  char *expansion;      /* Expanded string */
+  char *endptr;         /* Used when assembling expansion */
+  
+  mu_i_sv_interp_t interp;
+  void *data;
+};
+
+static struct string_segment *
+segment_alloc (struct stringbuf *buf, size_t beg, enum segm_type type)
+{
+  int rc;
+  struct string_segment *segm;
+
+  segm = malloc (sizeof *segm);
+  if (!segm)
+    longjmp (buf->errbuf, ENOMEM);
+  segm->type = type;
+  segm->beg = beg;
+  segm->end = buf->pos - 1;
+  rc = mu_list_append (buf->seglist, segm);
+  if (rc)
+    longjmp (buf->errbuf, rc);
+  return segm;
+}
+
+static void
+segm_free (void *data)
+{
+  struct string_segment *segm = data;
+  if (segm->type == segm_repl)
+    free (segm->repl);
+  free (segm);
+}
+
+static void
+string_next_fragment (struct stringbuf *buf)
+{
+  size_t beg;
+  struct string_segment *segm;
+  char *exp;
+  
+  beg = buf->pos;
+  while (buf->pos < buf->length)
+    {
+      if (buf->string[buf->pos] == '$' && buf->pos + 1 < buf->length
+	  && buf->string[buf->pos + 1] == '{')
+	break;
+      buf->pos++;
+    }
+  segm = segment_alloc (buf, beg, segm_copy);
+  if (buf->pos == buf->length)
+    return;
+
+  beg = buf->pos;
+  buf->pos += 2;
+  /* Look for closing brace */
+  while (buf->pos < buf->length)
+    {
+      if (buf->string[buf->pos] == '$' && buf->pos + 1 < buf->length
+	  && buf->string[buf->pos + 1] == '{')
+	{
+	  /* Found nested reference.  Update verbatim segment and restart */
+	  segm->end = buf->pos - 1;
+	  beg = buf->pos;
+	  buf->pos++;
+	}
+      else if (buf->string[buf->pos] == '}')
+	break;
+      buf->pos++;
+    }
+
+  if (buf->pos == buf->length)
+    {
+      /* No references found */
+      segm->end = buf->pos - 1;
+      return;
+    }
+
+  if (buf->interp (buf->string + beg + 2, buf->pos - beg - 2, &exp,
+		   buf->data) == 0)
+    {
+      segm = segment_alloc (buf, beg, segm_repl);
+      segm->repl = exp;
+    }
+  else
+    segm->end = buf->pos;
+
+  buf->pos++;
+}
+
+struct segm_stat
+{
+  size_t end;
+  size_t len;
+};
+
+static int
+update_len (void *item, void *data)
+{
+  struct string_segment *segm = item;
+  struct segm_stat *st = data;
+
+  switch (segm->type)
+    {
+    case segm_copy:
+      if (segm->beg == st->end)
+	st->end = segm->end;
+      st->len += segm->end - segm->beg + 1;
+      break;
+
+    case segm_repl:
+      st->len += strlen (segm->repl);
+      break;
+    }
+  return 0;
+}
+
+static int
+append_segm (void *item, void *data)
+{
+  struct string_segment *segm = item;
+  struct stringbuf *buf = data;
+  size_t len;
+  
+  switch (segm->type)
+    {
+    case segm_copy:
+      len = segm->end - segm->beg + 1;
+      memcpy (buf->endptr, buf->string + segm->beg, len);
+      break;
+
+    case segm_repl:
+      len = strlen (segm->repl);
+      memcpy (buf->endptr, segm->repl, len);
+    }
+  
+  buf->endptr += len;
+  return 0;
+}
+
+static void
+string_split (struct stringbuf *buf)
+{
+  while (buf->pos < buf->length)
+    string_next_fragment (buf);
+}
+
+static int
+string_assemble (struct stringbuf *buf)
+{
+  struct segm_stat st;  
+  st.len = 0;
+  st.end = 0;
+  
+  mu_list_foreach (buf->seglist, update_len, &st);
+  if (st.end == buf->length - 1)
+    return MU_ERR_CANCELED;
+
+  buf->expansion = malloc (st.len + 1);
+  if (!buf->expansion)
+    longjmp (buf->errbuf, ENOMEM);
+  buf->endptr = buf->expansion; 
+  mu_list_foreach (buf->seglist, append_segm, buf);
+  *buf->endptr = 0;
+
+  return 0;
+}
+
+int
+mu_i_sv_string_expand (char const *input,
+		       mu_i_sv_interp_t interp, void *data, char **ret)
+{
+  struct stringbuf sb;
+  int rc;
+  
+  sb.string = input;
+  sb.length = strlen (input);
+  sb.pos = 0;
+
+  rc = mu_list_create (&sb.seglist);
+  if (rc)
+    return rc;
+  mu_list_set_destroy_item (sb.seglist, segm_free);
+  
+  sb.expansion = NULL;
+  sb.endptr = NULL;
+
+  sb.interp = interp;
+  sb.data = data;
+  
+  rc = setjmp (sb.errbuf);
+  if (rc == 0)
+    {
+      string_split (&sb);
+      rc = string_assemble (&sb);
+      if (rc == 0)
+	*ret = sb.expansion;
+    }
+  mu_list_destroy (&sb.seglist);
+  return rc;
+}
+
+  
+  
diff --git a/sieve/tests/Makefile.am b/sieve/tests/Makefile.am
index 7e0606e..dbf983e 100644
--- a/sieve/tests/Makefile.am
+++ b/sieve/tests/Makefile.am
@@ -47,6 +47,7 @@ TESTSUITE_AT = \
   anyof.at\
   delheader.at\
   compile.at\
+  enc-char.at\
   envelope.at\
   exists.at\
   ext.at\
diff --git a/sieve/tests/enc-char.at b/sieve/tests/enc-char.at
new file mode 100644
index 0000000..9d82525
--- /dev/null
+++ b/sieve/tests/enc-char.at
@@ -0,0 +1,62 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 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/>.
+
+AT_SETUP([encoded-character])
+AT_KEYWORDS([encoded-character enc-char])
+
+AT_CHECK([
+AT_DATA([prog],[[require ["reject", "encoded-character"];
+
+reject "$${hex:40}";
+reject "${hex: 40 }";
+reject "${HEX: 40}";
+reject "${hex:40";
+reject "${hex:400}";
+reject "${hex:4${hex:30}}";
+reject "${unicode:40}";
+reject "${ unicode:40}";
+reject "${UNICODE:40}";
+reject "${UnICoDE:0000040}";
+reject "${Unicode:40}";
+reject "${Unicode:Cool}";
+reject "Now ${hex: 69 73 20}the${unicode:20 74}${hex:69 6d}e";
+reject "Unbalanced ${hex: 73 65 71 uence";
+reject "Nested ${hex: 73 65 71 ${hex: 75 65 6E}}ce";
+reject "Invalid ${hex: 73 RE}";
+]])
+
+sieve MUT_SIEVE_CMDLINE MUT_SIEVE_OPTIONS -D prog | grep ACTION
+],
+[0],
+[   9: ACTION: reject "$@"
+  16: ACTION: reject "@"
+  23: ACTION: reject "@"
+  30: ACTION: reject "${hex:40"
+  37: ACTION: reject "${hex:400}"
+  44: ACTION: reject "${hex:40}"
+  51: ACTION: reject "@"
+  58: ACTION: reject "${ unicode:40}"
+  65: ACTION: reject "@"
+  72: ACTION: reject "@"
+  79: ACTION: reject "@"
+  86: ACTION: reject "${Unicode:Cool}"
+  93: ACTION: reject "Now is the time"
+ 100: ACTION: reject "Unbalanced ${hex: 73 65 71 uence"
+ 107: ACTION: reject "Nested ${hex: 73 65 71 uen}ce"
+ 114: ACTION: reject "Invalid ${hex: 73 RE}"
+])
+
+AT_CLEANUP
diff --git a/sieve/tests/testsuite.at b/sieve/tests/testsuite.at
index 189bab8..87b6ff1 100644
--- a/sieve/tests/testsuite.at
+++ b/sieve/tests/testsuite.at
@@ -113,6 +113,7 @@ m4_include([version.at])
 
 AT_BANNER(Compilation)
 m4_include([compile.at])
+m4_include([enc-char.at])
 
 AT_BANNER(Actions)
 m4_include([false.at])


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 26 00:55:28 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cAVxP-000203-UX
	for mharc-commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:55:27 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40692)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cAVxN-0001zv-HP
	for commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:55:26 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cAVxM-00029X-DT
	for commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:55:25 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:55342)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cAVxM-00029J-8U
	for commit-mailutils@gnu.org; Sat, 26 Nov 2016 00:55:24 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id EDE672201C5; Sat, 26 Nov 2016 05:55:23 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-13-gf5a1ff9
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 1e6dc073c8b89d740c7eeba747965dfb76be5f2a
X-Git-Newrev: f5a1ff9b5a2caa67c1bee2cbf4a00dc4f7946bb4
Message-Id: <20161126055523.EDE672201C5@vcs.savannah.gnu.org>
Date: Sat, 26 Nov 2016 05:55:23 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 26 Nov 2016 05:55:26 -0000

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=f5a1ff9b5a2caa67c1bee2cbf4a00dc4f7946bb4

The branch, master has been updated
       via  f5a1ff9b5a2caa67c1bee2cbf4a00dc4f7946bb4 (commit)
      from  1e6dc073c8b89d740c7eeba747965dfb76be5f2a (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 f5a1ff9b5a2caa67c1bee2cbf4a00dc4f7946bb4
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 26 07:51:38 2016 +0200

    Improve list sorting API
    
    * libmailutils/list/sort.c (mu_list_sort_r): New function.
    * include/mailutils/list.h: Provide prototype.

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

Summary of changes:
 include/mailutils/list.h |    3 +++
 libmailutils/list/sort.c |   31 ++++++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/include/mailutils/list.h b/include/mailutils/list.h
index adf61b4..7da3c29 100644
--- a/include/mailutils/list.h
+++ b/include/mailutils/list.h
@@ -345,6 +345,9 @@ int mu_list_rfold (mu_list_t _list, mu_list_folder_t _fold, void *_data,
      first of them is less than the second, and +1 otherwise.
   */
 void mu_list_sort (mu_list_t _list, mu_list_comparator_t _comp);
+void mu_list_sort_r (mu_list_t _list,
+		     int (*_comp) (const void *, const void *, void *),
+		     void *_data);
   
 #ifdef __cplusplus
 }
diff --git a/libmailutils/list/sort.c b/libmailutils/list/sort.c
index 0950d36..92d9183 100644
--- a/libmailutils/list/sort.c
+++ b/libmailutils/list/sort.c
@@ -37,7 +37,8 @@ _list_append_entry (struct _mu_list *list, struct list_data *ent)
 }
 
 static void
-_list_qsort (mu_list_t list, mu_list_comparator_t cmp)
+_list_qsort (mu_list_t list, int cmp (const void *, const void *, void *),
+	     void *data)
 {
   struct list_data *cur, *middle;
   struct _mu_list high_list, low_list;
@@ -47,7 +48,7 @@ _list_qsort (mu_list_t list, mu_list_comparator_t cmp)
     return;
   if (list->count == 2)
     {
-      if (cmp (list->head.prev->item, list->head.next->item) < 0)
+      if (cmp (list->head.prev->item, list->head.next->item, data) < 0)
 	{
 	  cur = list->head.prev;
 	  list->head.prev = list->head.next;
@@ -67,7 +68,7 @@ _list_qsort (mu_list_t list, mu_list_comparator_t cmp)
     cur = cur->next;
     if (cur == &list->head)
       return;
-  } while ((rc = cmp (list->head.next->item, cur->item)) == 0);
+  } while ((rc = cmp (list->head.next->item, cur->item, data)) == 0);
 
   /* Select the lower of the two as the middle value */
   middle = (rc > 0) ? cur : list->head.next;
@@ -81,7 +82,7 @@ _list_qsort (mu_list_t list, mu_list_comparator_t cmp)
       struct list_data *next = cur->next;
       cur->next = NULL;
 
-      if (cmp (middle->item, cur->item) < 0)
+      if (cmp (middle->item, cur->item, data) < 0)
 	_list_append_entry (&high_list, cur);
       else
 	_list_append_entry (&low_list, cur);
@@ -89,8 +90,8 @@ _list_qsort (mu_list_t list, mu_list_comparator_t cmp)
     }
 
   /* Sort both sublists recursively */
-  _list_qsort (&low_list, cmp);
-  _list_qsort (&high_list, cmp);
+  _list_qsort (&low_list, cmp, data);
+  _list_qsort (&high_list, cmp, data);
 
   /* Join both lists in order */
   if (low_list.head.prev)
@@ -114,8 +115,24 @@ _list_qsort (mu_list_t list, mu_list_comparator_t cmp)
 }
 
 void
+mu_list_sort_r (mu_list_t list,
+		int (*comp) (const void *, const void *, void *), void *data)
+{
+  if (list)
+    _list_qsort (list, comp, data);
+}
+
+static int
+callcomp (const void *a, const void *b, void *data)
+{
+  mu_list_comparator_t comp = data;
+  return comp (a, b);
+}
+
+void
 mu_list_sort (mu_list_t list, mu_list_comparator_t comp)
 {
   if (list)
-    _list_qsort (list, comp ? comp : list->comp);
+    _list_qsort (list, callcomp, comp ? comp : list->comp);
 }
+


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sun Nov 27 13:43:32 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cB4QF-0006eK-Ui
	for mharc-commit-mailutils@gnu.org; Sun, 27 Nov 2016 13:43:31 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49120)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cB4QA-0006eD-O0
	for commit-mailutils@gnu.org; Sun, 27 Nov 2016 13:43:30 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cB4Q6-0004LG-KT
	for commit-mailutils@gnu.org; Sun, 27 Nov 2016 13:43:26 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:46539)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cB4Q6-0004Ku-FL
	for commit-mailutils@gnu.org; Sun, 27 Nov 2016 13:43:22 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 2237D2201BD; Sun, 27 Nov 2016 18:43:22 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-15-g1528dfd
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f5a1ff9b5a2caa67c1bee2cbf4a00dc4f7946bb4
X-Git-Newrev: 1528dfded819e3c8ccba459425b0dc18b1f3a722
Message-Id: <20161127184322.2237D2201BD@vcs.savannah.gnu.org>
Date: Sun, 27 Nov 2016 18:43:21 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 27 Nov 2016 18:43:31 -0000

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=1528dfded819e3c8ccba459425b0dc18b1f3a722

The branch, master has been updated
       via  1528dfded819e3c8ccba459425b0dc18b1f3a722 (commit)
       via  56217f1e53ebd0527b0fa1457c0b214d0ea76fd6 (commit)
      from  f5a1ff9b5a2caa67c1bee2cbf4a00dc4f7946bb4 (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 1528dfded819e3c8ccba459425b0dc18b1f3a722
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Sat Nov 26 10:54:48 2016 +0200

    sieve: improve argument/tag runtime access API
    
    * include/mailutils/sieve.h (mu_sieve_data_type): Remove SVT_VALUE_LIST.
    (mu_sieve_value_storage): Named union for use in mu_sieve_value_t; remove
    the tag field.
    (mu_sieve_tag_lookup): Change prototype.
    (mu_sieve_value_get): Change prototype.
    (mu_sieve_value_get_optional)
    (mu_sieve_value_get_untyped): New functions.
    (mu_sieve_arg_error): Removed proto.
    
    * libmu_sieve/sieve.y: Remove SVT_VALUE_LIST support.
    * libmu_sieve/util.c (mu_sieve_value_create)
    (mu_sieve_type_str,mu_sieve_vlist_do): Remove SVT_VALUE_LIST support.
    (mu_sieve_value_get): Rewrite.
    (mu_sieve_value_get_untyped)
    (mu_sieve_value_get_optional): New functions.
    (mu_sieve_arg_error): Remove.
    (mu_sieve_tag_lookup): Rewrite.
    (mu_sieve_tag_lookup_untyped): New function.
    
    * doc/texinfo/libmu_sieve.texi: Update.
    
    libmu_sieve/tests.c
    libmu_sieve/actions.c
    libmu_sieve/extensions/editheader.c
    libmu_sieve/extensions/list.c
    libmu_sieve/extensions/moderator.c
    libmu_sieve/extensions/pipe.c
    libmu_sieve/extensions/spamd.c
    libmu_sieve/extensions/timestamp.c
    libmu_sieve/extensions/vacation.c
    libmu_sieve/relational.c
    
    examples/numaddr.c

commit 56217f1e53ebd0527b0fa1457c0b214d0ea76fd6
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Sat Nov 26 08:01:13 2016 +0200

    Minor fixes
    
    * libmu_sieve/sieve-priv.h (sieve_op_t) <unum>: New field.
    * libmu_sieve/sieve.l: Leave one string interpreter slot.

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

Summary of changes:
 doc/texinfo/libmu_sieve.texi        |    4 --
 examples/numaddr.c                  |   19 ++-----
 gint                                |    2 +-
 include/mailutils/sieve.h           |   39 +++++++++------
 libmu_sieve/actions.c               |   45 +++++++----------
 libmu_sieve/comparator.c            |    3 +-
 libmu_sieve/extensions/editheader.c |   44 +++-------------
 libmu_sieve/extensions/list.c       |   21 ++------
 libmu_sieve/extensions/moderator.c  |   18 +++----
 libmu_sieve/extensions/pipe.c       |   27 ++++------
 libmu_sieve/extensions/spamd.c      |   27 +++++-----
 libmu_sieve/extensions/timestamp.c  |   25 +++-------
 libmu_sieve/extensions/vacation.c   |   60 +++++++++-------------
 libmu_sieve/relational.c            |    6 +--
 libmu_sieve/sieve-priv.h            |    1 +
 libmu_sieve/sieve.l                 |   48 +++++++-----------
 libmu_sieve/sieve.y                 |    6 ---
 libmu_sieve/tests.c                 |   94 +++++++++++------------------------
 libmu_sieve/util.c                  |   94 +++++++++++++++++++++++++++++------
 19 files changed, 249 insertions(+), 334 deletions(-)

diff --git a/doc/texinfo/libmu_sieve.texi b/doc/texinfo/libmu_sieve.texi
index d4c4451..1d673a8 100644
--- a/doc/texinfo/libmu_sieve.texi
+++ b/doc/texinfo/libmu_sieve.texi
@@ -85,9 +85,6 @@ A sieve tag. See @code{mu_sieve_runtime_tag_t} below.
 @item SVT_IDENT
 A character string representing an identifier. 
 
-@item SVT_VALUE_LIST
-A @code{mu_list_t}. Each item in this list is of @code{mu_sieve_value_t} type.
-
 @item SVT_POINTER
 An opaque pointer.
 @end table
@@ -128,7 +125,6 @@ The numeric value is kept in @code{number} member.
 The string is kept in @code{string} member.
 
 @item SVT_STRING_LIST
-@itemx SVT_VALUE_LIST
 The list itself is pointed to by @code{list} member
 
 @item SVT_TAG
diff --git a/examples/numaddr.c b/examples/numaddr.c
index 66602ad..b073793 100644
--- a/examples/numaddr.c
+++ b/examples/numaddr.c
@@ -80,37 +80,26 @@ _count_items (void *item, void *data)
 static int
 numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 {
-  mu_sieve_value_t *h, *v;
+  mu_sieve_value_t *h;
   struct val_ctr vc;
   int rc;
   
   /* Retrieve required arguments: */
   /* First argument: list of header names */
-  h = mu_sieve_value_get (args, 0);
-  if (!h)
-    {
-      mu_sieve_error (mach, "numaddr: can't get argument 1");
-      mu_sieve_abort (mach);
-    }
+  h = mu_sieve_value_get_untyped (mach, args, 0);
   /* Second argument: Limit on the number of addresses */
-  v = mu_sieve_value_get (args, 1);
-  if (!v)
-    {
-      mu_sieve_error (mach, "numaddr: can't get argument 2");
-      mu_sieve_abort (mach);
-    }
+  mu_sieve_value_get (mach, args, 1, SVT_NUMBER, &vc.limit);
 
   /* Fill in the val_ctr structure */
   mu_message_get_header (mu_sieve_get_message (mach), &vc.hdr);
   vc.count = 0;
-  vc.limit = v->v.number;
 
   /* Count the addresses */
   rc = mu_sieve_vlist_do (h, _count_items, &vc);
 
   /* Here rc >= 1 iff the counted number of addresses is greater or equal
      to vc.limit. If `:under' tag was given we reverse the return value */
-  if (mu_sieve_tag_lookup (tags, "under", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "under", SVT_VOID, NULL))
     rc = !rc;
 
   return rc;
diff --git a/gint b/gint
index fd86bf7..42f4712 160000
--- a/gint
+++ b/gint
@@ -1 +1 @@
-Subproject commit fd86bf7d44b0c970771830692ae7491447ebe8b1
+Subproject commit 42f4712085b40173eaea58e14b1a579291a6fe3a
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 019ee61..4fc91c2 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -57,24 +57,24 @@ typedef enum
   SVT_STRING_LIST,
   SVT_TAG,
   SVT_IDENT,
-  SVT_VALUE_LIST,
   SVT_POINTER
 }
 mu_sieve_data_type;
 
 typedef struct mu_sieve_runtime_tag mu_sieve_runtime_tag_t;
 
+union mu_sieve_value_storage
+{
+  char *string;
+  size_t number;
+  mu_list_t list;
+  void *ptr;
+};
+
 typedef struct
 {
   mu_sieve_data_type type;
-  union
-  {
-    char *string;
-    size_t number;
-    mu_list_t list;
-    mu_sieve_runtime_tag_t *tag;
-    void *ptr;
-  } v;
+  union mu_sieve_value_storage v;
 } mu_sieve_value_t;
 
 typedef struct
@@ -184,8 +184,12 @@ mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach,
 
 void mu_sieve_require (mu_sieve_machine_t mach, mu_list_t slist);
 
-int mu_sieve_tag_lookup (mu_list_t taglist, char *name,
-			 mu_sieve_value_t ** arg);
+int mu_sieve_tag_lookup (mu_sieve_machine_t mach,
+			 mu_list_t taglist, char *name,
+			 mu_sieve_data_type type, void *ret);
+int mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist,
+				 char *name, mu_sieve_value_t **ret);
+  
 int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name);
 int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
 				 const char *name, mu_list_t tags,
@@ -193,8 +197,16 @@ int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
 int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
 				 const char *name, mu_list_t tags,
 				 mu_list_t args);
-/* Operations in value lists */
-mu_sieve_value_t *mu_sieve_value_get (mu_list_t vlist, size_t index);
+/* Operations on value lists */
+mu_sieve_value_t *mu_sieve_value_get_optional (mu_sieve_machine_t mach,
+					       mu_list_t vlist,
+					       size_t index);
+mu_sieve_value_t *mu_sieve_value_get_untyped (mu_sieve_machine_t mach,
+					      mu_list_t vlist,
+					      size_t index);
+int mu_sieve_value_get (mu_sieve_machine_t mach, mu_list_t vlist,
+			size_t index,
+			mu_sieve_data_type type, void *ret);
 int mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t ac,
 		       void *data);
 int mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b,
@@ -251,7 +263,6 @@ void mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
 			  const char *fmt, ...)
 			  MU_PRINTFLIKE(3,4);
 void mu_sieve_abort (mu_sieve_machine_t mach);
-void mu_sieve_arg_error (mu_sieve_machine_t mach, int n);
 
 int mu_sieve_is_dry_run (mu_sieve_machine_t mach);
 const char *mu_sieve_type_str (mu_sieve_data_type type);
diff --git a/libmu_sieve/actions.c b/libmu_sieve/actions.c
index 84bd368..f6c37f7 100644
--- a/libmu_sieve/actions.c
+++ b/libmu_sieve/actions.c
@@ -79,32 +79,29 @@ sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 {
   int rc;
   int mbflags = 0;
-  mu_sieve_value_t *opt;
-  mu_sieve_value_t *val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_error (mach, _("cannot get filename!"));
-      mu_sieve_abort (mach);
-    }
+  char *filename;
+  char *perms;
 
-  if (mu_sieve_tag_lookup (tags, "permissions", &opt))
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &filename);
+
+  if (mu_sieve_tag_lookup (mach, tags, "permissions", SVT_STRING, &perms))
     {
       const char *p;
       
-      if (mu_parse_stream_perm_string (&mbflags, opt->v.string, &p))
+      if (mu_parse_stream_perm_string (&mbflags, perms, &p))
 	{
 	  /* Should not happen, but anyway... */
 	  mu_sieve_error (mach, _("invalid permissions (near %s)"), p);
-	  return 1;
+	  mu_sieve_abort (mach);
 	}
     }
   
   mu_sieve_log_action (mach, "FILEINTO",
-		       _("delivering into %s"), val->v.string);
+		       _("delivering into %s"), filename);
   if (mu_sieve_is_dry_run (mach))
     return 0;
 
-  rc = mu_message_save_to_mailbox (mach->msg, val->v.string, mbflags);
+  rc = mu_message_save_to_mailbox (mach->msg, filename, mbflags);
   if (rc)
     mu_sieve_error (mach, _("cannot save to mailbox: %s"),
 		    mu_strerror (rc));
@@ -293,18 +290,14 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   char *addrtext;
   mu_address_t from, to;
   mu_header_t hdr;
+  char *text;
   
-  mu_sieve_value_t *val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_error (mach, _("reject: cannot get text!"));
-      mu_sieve_abort (mach);
-    }
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &text);
   mu_sieve_log_action (mach, "REJECT", NULL);  
   if (mu_sieve_is_dry_run (mach))
     return 0;
 
-  rc = build_mime (&mime, mach->msg, val->v.string);
+  rc = build_mime (&mime, mach->msg, text);
 
   mu_mime_get_message (mime, &newmsg);
   mu_message_unref (newmsg);
@@ -413,25 +406,21 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   char *fromaddr, *p;
   mu_mailer_t mailer = mu_sieve_get_mailer (mach);
+  char *addrstr;
   
-  mu_sieve_value_t *val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_error (mach, _("cannot get address!"));
-      mu_sieve_abort (mach);
-    }
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &addrstr);
 
-  rc = mu_address_create (&addr, val->v.string);
+  rc = mu_address_create (&addr, addrstr);
   if (rc)
     {
       mu_sieve_error (mach,
 		      _("%lu: parsing recipient address `%s' failed: %s"),
 		      (unsigned long) mu_sieve_get_message_num (mach),
-		      val->v.string, mu_strerror (rc));
+		      addrstr, mu_strerror (rc));
       return 1;
     }
   
-  mu_sieve_log_action (mach, "REDIRECT", _("to %s"), val->v.string);
+  mu_sieve_log_action (mach, "REDIRECT", _("to %s"), addrstr);
   if (mu_sieve_is_dry_run (mach))
     return 0;
 
diff --git a/libmu_sieve/comparator.c b/libmu_sieve/comparator.c
index d7be199..03fe403 100644
--- a/libmu_sieve/comparator.c
+++ b/libmu_sieve/comparator.c
@@ -288,8 +288,7 @@ mu_sieve_match_part_checker (mu_sieve_machine_t mach,
 
           matchtype = MU_SIEVE_MATCH_LAST; /* to not leave it undefined */
 	  compfun = comp_false;
-	  val = mu_sieve_value_get (args, 1);
-	  if (!val)
+	  if (mu_list_get (args, 1, (void**) &val))
 	    return 1; /* shouldn't happen */
 	  /* NOTE: Type of v is always SVT_STRING_LIST */
 	  mu_list_count (val->v.list, &count);
diff --git a/libmu_sieve/extensions/editheader.c b/libmu_sieve/extensions/editheader.c
index ba4d0c0..4ec7c1d 100644
--- a/libmu_sieve/extensions/editheader.c
+++ b/libmu_sieve/extensions/editheader.c
@@ -33,32 +33,14 @@
 int
 sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 {
-  mu_sieve_value_t *val;
   const char *field_name;
   const char *field_value;
   mu_message_t msg;
   mu_header_t hdr;
   int rc;
   
-  val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_error (mach, "%lu: %s",
-		      (unsigned long) mu_sieve_get_message_num (mach),
-		      _("cannot get field name"));
-      mu_sieve_abort (mach);
-    }
-  field_name = val->v.string;
-
-  val = mu_sieve_value_get (args, 1);
-  if (!val)
-    {
-      mu_sieve_error (mach, "%lu: %s",
-		      (unsigned long) mu_sieve_get_message_num (mach),
-		      _("cannot get field value"));
-      mu_sieve_abort (mach);
-    }
-  field_value = val->v.string;
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &field_name);
+  mu_sieve_value_get (mach, args, 1, SVT_STRING, &field_value);
 
   mu_sieve_log_action (mach, "ADDHEADER", "%s: %s", field_name, field_value);
 
@@ -76,7 +58,7 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       mu_sieve_abort (mach);
     }
 
-  rc = (mu_sieve_tag_lookup (tags, "last", NULL) ?
+  rc = (mu_sieve_tag_lookup (mach, tags, "last", SVT_VOID, NULL) ?
 	mu_header_append : mu_header_prepend) (hdr, field_name, field_value);
   if (rc)
     {
@@ -105,19 +87,10 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   mu_sieve_comparator_t comp;
   mu_iterator_t itr;
-  unsigned long i, idx = 0;
+  size_t i, idx = 0;
   
-  val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_error (mach, "%lu: %s",
-		      (unsigned long) mu_sieve_get_message_num (mach),
-		      _("cannot get field name"));
-      mu_sieve_abort (mach);
-    }
-  field_name = val->v.string;
-
-  val = mu_sieve_value_get (args, 1);
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &field_name);
+  val = mu_sieve_value_get_optional (mach, args, 1);
   if (!val)
     {
       field_pattern = NULL;
@@ -169,15 +142,14 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
     }
 
   mu_header_get_iterator (hdr, &itr);
-  if (mu_sieve_tag_lookup (tags, "last", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "last", SVT_VOID, NULL))
     {
       int backwards = 1;
       mu_iterator_ctl (itr, mu_itrctl_set_direction, &backwards);
     }
   comp = mu_sieve_get_comparator (mach, tags);
 
-  if (mu_sieve_tag_lookup (tags, "index", &val))
-    idx = val->v.number;
+  mu_sieve_tag_lookup (mach, tags, "index", SVT_NUMBER, &idx);
   
   for (i = 0, mu_iterator_first (itr); !mu_iterator_is_done (itr);
        mu_iterator_next (itr))
diff --git a/libmu_sieve/extensions/list.c b/libmu_sieve/extensions/list.c
index ccde22d..fd18660 100644
--- a/libmu_sieve/extensions/list.c
+++ b/libmu_sieve/extensions/list.c
@@ -147,30 +147,17 @@ list_retrieve_header (void *item, void *data, int idx, char **pval)
 static int
 list_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 {
-  mu_sieve_value_t *h, *v, *arg;
+  mu_sieve_value_t *h, *v;
   mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags);
   struct header_closure clos;
   int result;
 
   memset (&clos, 0, sizeof clos);
-  if (mu_sieve_tag_lookup (tags, "delim", &arg))
-    clos.delim = arg->v.string;
-  else
+  if (!mu_sieve_tag_lookup (mach, tags, "delim", SVT_STRING, &clos.delim))
     clos.delim = ",";
   
-  h = mu_sieve_value_get (args, 0);
-  if (!h)
-    {
-      mu_sieve_arg_error (mach, 1);
-      mu_sieve_abort (mach);
-    }
-  v = mu_sieve_value_get (args, 1);
-  if (!v)
-    {
-      mu_sieve_arg_error (mach, 2);
-      mu_sieve_abort (mach);
-    }
-
+  h = mu_sieve_value_get_untyped (mach, args, 0);
+  v = mu_sieve_value_get_untyped (mach, args, 1);
   mu_message_get_header (mu_sieve_get_message (mach), &clos.header);
   result = mu_sieve_vlist_compare (h, v, comp,
 				   mu_sieve_get_relcmp (mach, tags),
diff --git a/libmu_sieve/extensions/moderator.c b/libmu_sieve/extensions/moderator.c
index b19d0ed..7d16cef 100644
--- a/libmu_sieve/extensions/moderator.c
+++ b/libmu_sieve/extensions/moderator.c
@@ -80,9 +80,9 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags,
   int rc;
   mu_sieve_machine_t newmach;
   mu_attribute_t attr;
-  mu_sieve_value_t *arg;
+  char *arg;
   
-  if (mu_sieve_tag_lookup (tags, "source", &arg))
+  if (mu_sieve_tag_lookup (mach, tags, "source", SVT_STRING, &arg))
     {
       rc = mu_sieve_machine_inherit (mach, &newmach);
       if (rc)
@@ -97,11 +97,11 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags,
 	   ...
       */
       
-      rc = mu_sieve_compile (newmach, arg->v.string);
+      rc = mu_sieve_compile (newmach, arg);
       if (rc)
-	mu_sieve_error (mach, _("cannot compile source `%s'"), arg->v.string);
+	mu_sieve_error (mach, _("cannot compile source `%s'"), arg);
     }
-  else if (mu_sieve_tag_lookup (tags, "program", &arg))
+  else if (mu_sieve_tag_lookup (mach, tags, "program", SVT_STRING, &arg))
     {
       struct mu_locus locus;
       
@@ -114,7 +114,7 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags,
 	}
       mu_sieve_get_locus (mach, &locus);
       rc = mu_sieve_compile_buffer (newmach,
-				    arg->v.string, strlen (arg->v.string),
+				    arg, strlen (arg),
 				    locus.mu_file, locus.mu_line);
       if (rc)
 	mu_sieve_error (mach, _("cannot compile subprogram"));
@@ -303,7 +303,6 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
     {
       mu_message_t request;
       char *from = NULL;
-      mu_sieve_value_t *arg;
       
       if ((rc = moderator_message_get_part (mach, msg, 3, &request)))
 	{
@@ -312,14 +311,13 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 	  mu_sieve_abort (mach);
 	}
 
-      if (mu_sieve_tag_lookup (tags, "address", &arg))
-	from = arg->v.string;
+      mu_sieve_tag_lookup (mach, tags, "address", SVT_STRING, &from);
       
       if (moderator_discard_message (mach, request, from))
 	discard = 0;
       else
 	{
-	  if (!mu_sieve_tag_lookup (tags, "keep", NULL))
+	  if (!mu_sieve_tag_lookup (mach, tags, "keep", SVT_VOID, NULL))
 	    {
 	      mu_attribute_t attr = 0;
 
diff --git a/libmu_sieve/extensions/pipe.c b/libmu_sieve/extensions/pipe.c
index 045c5a8..d7eaadd 100644
--- a/libmu_sieve/extensions/pipe.c
+++ b/libmu_sieve/extensions/pipe.c
@@ -87,7 +87,6 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
   int retval = 0;
   int rc, result;
   mu_message_t msg;
-  mu_sieve_value_t *val;
   char *cmd;
   mu_stream_t pstr;
   mu_envelope_t env;
@@ -95,15 +94,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
   const char *error_arg = NULL;
   int pipe_mask = 0;
   
-  val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_error (mach, "%lu: %s",
-		      (unsigned long) mu_sieve_get_message_num (mach),
-		      _("cannot get command!"));
-      mu_sieve_abort (mach);
-    }
-  cmd = val->v.string;
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &cmd);
 
   if (mu_sieve_is_dry_run (mach))
     return 0;
@@ -111,11 +102,11 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
   msg = mu_sieve_get_message (mach);
   mu_message_get_envelope (msg, &env);
 
-  if (mu_sieve_tag_lookup (tags, "envelope", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "envelope", SVT_VOID, NULL))
     pipe_mask |= PIPE_ENVELOPE;
-  if (mu_sieve_tag_lookup (tags, "header", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "header", SVT_VOID, NULL))
     pipe_mask |= PIPE_HEADERS;
-  if (mu_sieve_tag_lookup (tags, "body", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "body", SVT_VOID, NULL))
     pipe_mask |= PIPE_BODY;
   if (pipe_mask == 0)
     pipe_mask = PIPE_ALL;
@@ -193,6 +184,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
     {
       int code = 0;
       int status;
+      size_t n;
       
       rc = mu_stream_ioctl (pstr, MU_IOCTL_PROGSTREAM,
 			    MU_IOCTL_PROG_STATUS, &status);
@@ -202,8 +194,8 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
 	  mu_sieve_abort (mach);
 	}
 
-      if (mu_sieve_tag_lookup (tags, "exit", &val))
-	code = val->v.number;
+      if (mu_sieve_tag_lookup (mach, tags, "exit", SVT_NUMBER, &n))
+	code = n;
       if (result == 0)
 	retval = code == 0;
       else if (result == MU_ERR_PROCESS_EXITED)
@@ -211,8 +203,9 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
       else if (result == MU_ERR_PROCESS_SIGNALED)
 	{
 	  int signo = WTERMSIG (status);
-	  if (mu_sieve_tag_lookup (tags, "signal", &val))
-	    retval = signo == val->v.number;
+	  size_t n;
+	  if (mu_sieve_tag_lookup (mach, tags, "signal", SVT_NUMBER, &n))
+	    retval = signo == n;
 	  else
 	    {
 	      mu_stream_destroy (&pstr);
diff --git a/libmu_sieve/extensions/spamd.c b/libmu_sieve/extensions/spamd.c
index 290d8b8..4e5fea1 100644
--- a/libmu_sieve/extensions/spamd.c
+++ b/libmu_sieve/extensions/spamd.c
@@ -362,9 +362,10 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int result;
   long score, threshold, limit;
   mu_stream_t stream = NULL, null;
-  mu_sieve_value_t *arg;
   mu_message_t msg;
   char *host;
+  size_t num;
+  char *str;
   mu_header_t hdr;
   mu_debug_handle_t lev = 0;
   
@@ -380,15 +381,13 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       mu_sieve_abort (mach);
     }
   
-  if (mu_sieve_tag_lookup (tags, "host", &arg))
-    host = arg->v.string;
-  else
+  if (!mu_sieve_tag_lookup (mach, tags, "host", SVT_STRING, &host))
     host = "127.0.0.1";
   
-  if (mu_sieve_tag_lookup (tags, "port", &arg))
-    result = spamd_connect_tcp (mach, &stream, host, arg->v.number);
-  else if (mu_sieve_tag_lookup (tags, "socket", &arg))
-    result = spamd_connect_socket (mach, &stream, arg->v.string);
+  if (mu_sieve_tag_lookup (mach, tags, "port", SVT_NUMBER, &num))
+    result = spamd_connect_tcp (mach, &stream, host, num);
+  else if (mu_sieve_tag_lookup (mach, tags, "socket", SVT_STRING, &str))
+    result = spamd_connect_socket (mach, &stream, str);
   else
     result = spamd_connect_tcp (mach, &stream, host, DEFAULT_SPAMD_PORT);
   if (result) /* spamd_connect_ already reported error */
@@ -422,8 +421,8 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   spamd_send_command (stream, "SYMBOLS SPAMC/1.2");
   
   spamd_send_command (stream, "Content-length: %lu", (u_long) size);
-  if (mu_sieve_tag_lookup (tags, "user", &arg))
-    spamd_send_command (stream, "User: %s", arg);
+  if (mu_sieve_tag_lookup (mach, tags, "user", SVT_STRING, &str))
+    spamd_send_command (stream, "User: %s", str);
   else
     {
       struct mu_auth_data *auth = mu_get_auth_by_uid (geteuid ());
@@ -465,14 +464,14 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 
   if (!result)
     {
-      if (mu_sieve_tag_lookup (tags, "over", &arg))
+      if (mu_sieve_tag_lookup (mach, tags, "over", SVT_STRING, &str))
 	{
-	  decode_float (&limit, arg->v.string, 3, NULL);
+	  decode_float (&limit, str, 3, NULL);
 	  result = score >= limit;
 	}
-      else if (mu_sieve_tag_lookup (tags, "under", &arg))
+      else if (mu_sieve_tag_lookup (mach, tags, "under", SVT_STRING, &str))
 	{
-	  decode_float (&limit, arg->v.string, 3, NULL);
+	  decode_float (&limit, str, 3, NULL);
 	  result = score <= limit;	  
 	}
     }
diff --git a/libmu_sieve/extensions/timestamp.c b/libmu_sieve/extensions/timestamp.c
index 56c12f2..dd29d1f 100644
--- a/libmu_sieve/extensions/timestamp.c
+++ b/libmu_sieve/extensions/timestamp.c
@@ -50,7 +50,8 @@
 static int
 timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 {
-  mu_sieve_value_t *h, *v;
+  char const *hname;
+  char const *date;
   mu_header_t hdr;
   char *val;
   time_t now = time (NULL);
@@ -59,24 +60,14 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   
   /* Retrieve required arguments: */
   /* First argument: header name */
-  h = mu_sieve_value_get (args, 0);
-  if (!h)
-    {
-      mu_sieve_arg_error (mach, 1);
-      mu_sieve_abort (mach);
-    }
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &hname);
   /* Second argument: date displacement */
-  v = mu_sieve_value_get (args, 1);
-  if (!v)
-    {
-      mu_sieve_arg_error (mach, 2);
-      mu_sieve_abort (mach);
-    }
+  mu_sieve_value_get (mach, args, 1, SVT_STRING, &date);
 
-  if (mu_parse_date (v->v.string, &tlimit, &now))
+  if (mu_parse_date (date, &tlimit, &now))
     {
       mu_sieve_error (mach, _("cannot parse date specification (%s)"),
-		   v->v.string);
+		      date);
       mu_sieve_abort (mach);
     }
 
@@ -87,7 +78,7 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       mu_sieve_abort (mach);
     }
   
-  if (mu_header_aget_value (hdr, h->v.string, &val))
+  if (mu_header_aget_value (hdr, hname, &val))
     return 0;
 
   if (mu_parse_date (val, &tval, &now))
@@ -102,7 +93,7 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 
   rc = tval > tlimit;
     
-  if (mu_sieve_tag_lookup (tags, "before", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "before", SVT_VOID, NULL))
     rc = !rc;  
 
   return rc;
diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c
index 8b8fefc..a3a1fc3 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -78,7 +78,7 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
       return 1;
     }
 
-  if (mu_sieve_tag_lookup (tags, "mime", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "mime", SVT_VOID, NULL))
     {
       mu_stream_t fstr;
       rc = mu_filter_create (&fstr, input, "base64",
@@ -249,7 +249,7 @@ noreply_address_p (mu_sieve_machine_t mach, mu_list_t tags, char *email)
   for (i = 0; rc == 0 && noreply_sender[i]; i++)
     rc = regex_comparator (noreply_sender[i], &rd);
 
-  if (!rc && mu_sieve_tag_lookup (tags, "noreply", &arg))
+  if (!rc && mu_sieve_tag_lookup_untyped (mach, tags, "noreply", &arg))
     rc = mu_sieve_vlist_do (arg, regex_comparator, &rd);
   
   return rc;
@@ -341,24 +341,23 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
 {
   mu_property_t prop;
   char *file;
-  mu_sieve_value_t *arg;
   unsigned int days;
   int rc;
   mu_stream_t str;
   mu_locker_t locker;
   const char *dbfile = "~/.vacation";
+  size_t n;
   
-  if (mu_sieve_tag_lookup (tags, "days", &arg))
+  if (mu_sieve_tag_lookup (mach, tags, "days", SVT_NUMBER, &n))
     {
-      days = arg->v.number;
+      days = n;
       if (days > DAYS_MAX)
 	days = DAYS_MAX;
     }
   else
     days = DAYS_DEFAULT;
 
-  if (mu_sieve_tag_lookup (tags, "database", &arg))
-    dbfile = arg->v.string;
+  mu_sieve_tag_lookup (mach, tags, "database", SVT_STRING, &dbfile);
   
   file = mu_tilde_expansion (dbfile, MU_HIERARCHY_DELIMITER, NULL);
   if (!file)
@@ -433,13 +432,9 @@ static void
 re_subject (mu_sieve_machine_t mach, mu_list_t tags, char **psubject)
 {
   char *subject;
-  mu_sieve_value_t *arg;
   char *prefix = "Re";
   
-  if (mu_sieve_tag_lookup (tags, "reply_prefix", &arg))
-    {
-      prefix = arg->v.string;
-    }
+  mu_sieve_tag_lookup (mach, tags, "reply_prefix", SVT_STRING, &prefix);
 
   subject = malloc (strlen (*psubject) + strlen (prefix) + 3);
   if (!subject)
@@ -467,20 +462,19 @@ static void
 vacation_subject (mu_sieve_machine_t mach, mu_list_t tags,
 		  mu_message_t msg, mu_header_t newhdr)
 {
-  mu_sieve_value_t *arg;
   char *value;
   char *subject;
   int subject_allocated = 0;
   mu_header_t hdr;
   
-  if (mu_sieve_tag_lookup (tags, "subject", &arg))
-    subject = arg->v.string;
+  if (mu_sieve_tag_lookup (mach, tags, "subject", SVT_STRING, &subject))
+    /* nothing */;
   else if (mu_message_get_header (msg, &hdr) == 0
 	   && mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT,
 					   &value) == 0)
     {
       char *p;
-      
+
       int rc = mu_rfc2047_decode (MU_SIEVE_CHARSET, value, &p);
 
       subject_allocated = 1;
@@ -494,11 +488,11 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags,
 	  subject = p;
 	}
 
-      if (mu_sieve_tag_lookup (tags, "reply_regex", &arg))
+      if (mu_sieve_tag_lookup (mach, tags, "reply_regex", SVT_STRING, &p))
 	{
 	  char *err = NULL;
 	  
-	  rc = mu_unre_set_regex (arg->v.string, 0, &err);
+	  rc = mu_unre_set_regex (p, 0, &err);
 	  if (rc)
 	    {
 	      mu_sieve_error (mach,
@@ -619,7 +613,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
   int rc;
   mu_sieve_value_t *val;
 
-  if (mu_sieve_tag_lookup (tags, "file", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "file", SVT_VOID, NULL))
     {
       mu_stream_t instr;
       
@@ -634,7 +628,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
 	  return -1;
 	}
       
-      if (mu_sieve_tag_lookup (tags, "rfc2822", NULL))
+      if (mu_sieve_tag_lookup (mach, tags, "rfc2822", SVT_VOID, NULL))
 	{
 	  rc = mu_stream_to_message (instr, &newmsg);
 	  mu_stream_unref (instr);
@@ -722,7 +716,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
     {
       mu_header_set_value (newhdr, MU_HEADER_TO, to, 0);
 
-      if (mu_sieve_tag_lookup (tags, "header", &val))
+      if (mu_sieve_tag_lookup_untyped (mach, tags, "header", &val))
 	{
 	  struct header_closure hc;
 	  hc.mach = mach;
@@ -774,7 +768,6 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   char *text, *from = NULL;
   char const *return_address;
-  mu_sieve_value_t *val;
   mu_message_t msg;
   mu_header_t hdr;
   char *my_address;
@@ -782,22 +775,15 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (diag (mach))
     return 0;
   
-  val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_error (mach, _("cannot get text!"));
-      mu_sieve_abort (mach);
-    }
-  else
-    text = val->v.string;
+  mu_sieve_value_get (mach, args, 0, SVT_STRING, &text);
 
   msg = mu_sieve_get_message (mach);
   mu_message_get_header (msg, &hdr);
 
-  if (mu_sieve_tag_lookup (tags, "sender", &val))
+  if (mu_sieve_tag_lookup (mach, tags, "sender", SVT_STRING, &from))
     {
       /* Debugging hook: :sender sets fake reply address */
-      from = strdup (val->v.string);
+      from = strdup (from);
       if (!from)
         {
           mu_sieve_error (mach, "%lu: %s",
@@ -817,12 +803,12 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 
   my_address = mu_get_user_email (NULL);
 
-  if (mu_sieve_tag_lookup (tags, "always_reply", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "always_reply", SVT_VOID, NULL))
     return_address = my_address;
   else
     {
-      val = NULL;
-      mu_sieve_tag_lookup (tags, "aliases", &val);
+      mu_sieve_value_t *val = NULL;
+      mu_sieve_tag_lookup_untyped (mach, tags, "aliases", &val);
       if (match_addresses (hdr, my_address, val, &return_address) == 0)
 	{
 	  free (my_address);
@@ -839,8 +825,8 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       return 0;
     }
 
-  if (mu_sieve_tag_lookup (tags, "return_address", &val))
-    return_address = val->v.string;
+  mu_sieve_tag_lookup (mach, tags, "return_address", SVT_STRING,
+		       &return_address);
 
   rc = vacation_reply (mach, tags, msg, text, from, return_address);
   free (from);
diff --git a/libmu_sieve/relational.c b/libmu_sieve/relational.c
index 871d8e9..19c9eec 100644
--- a/libmu_sieve/relational.c
+++ b/libmu_sieve/relational.c
@@ -83,12 +83,12 @@ mu_sieve_str_to_relcmp (const char *str,
 mu_sieve_relcmp_t
 mu_sieve_get_relcmp (mu_sieve_machine_t mach, mu_list_t tags)
 {
-  mu_sieve_value_t *arg;
+  char *str;
   mu_sieve_relcmp_t test = NULL;
   
-  if (mu_sieve_tag_lookup (tags, "value", &arg) == 0)
+  if (mu_sieve_tag_lookup (mach, tags, "value", SVT_STRING, &str) == 0)
     return op_ne;
-  mu_sieve_str_to_relcmp (arg->v.string, &test, NULL);
+  mu_sieve_str_to_relcmp (str, &test, NULL);
   return test;
 }
 
diff --git a/libmu_sieve/sieve-priv.h b/libmu_sieve/sieve-priv.h
index 8aa4030..6c62255 100644
--- a/libmu_sieve/sieve-priv.h
+++ b/libmu_sieve/sieve-priv.h
@@ -35,6 +35,7 @@ typedef union
   size_t line;
   int inum;
   char *string;
+  unsigned unum;
 } sieve_op_t;
 
 struct mu_locus_range
diff --git a/libmu_sieve/sieve.l b/libmu_sieve/sieve.l
index f04d219..43edd6a 100644
--- a/libmu_sieve/sieve.l
+++ b/libmu_sieve/sieve.l
@@ -642,46 +642,32 @@ str_unescape (char *text, size_t len)
   return str;
 }
 
-enum
-  {
-    interp_encoded_character,
-    interp_variable
-  };
-
-#define MAXINTERP (interp_variable+1)
-mu_i_sv_interp_t interpreter[MAXINTERP];
+static mu_i_sv_interp_t string_interpreter;
 
 static void
 line_finish (void)
 {
-  int i;
   char *str;
   
   mu_opool_append_char (mu_sieve_machine->string_pool, 0);
   str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
-  for (i = 0; i < MAXINTERP; i++)
+  if (string_interpreter)
     {
-      if (interpreter[i])
+      char *exp;
+      int rc = mu_i_sv_string_expand (str, string_interpreter, NULL, &exp);
+      if (rc == 0)
+	{
+	  mu_opool_free (mu_sieve_machine->string_pool, str);
+	  mu_opool_appendz (mu_sieve_machine->string_pool, exp);
+	  mu_opool_append_char (mu_sieve_machine->string_pool, 0);
+	  free (exp);
+	  str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
+	}
+      else if (rc != MU_ERR_CANCELED)
 	{
-	  char *exp;
-	  int rc = mu_i_sv_string_expand (str, interpreter[i], NULL, &exp);
-	  if (rc == 0)
-	    {
-	      mu_opool_free (mu_sieve_machine->string_pool, str);
-	      mu_opool_appendz (mu_sieve_machine->string_pool, exp);
-	      mu_opool_append_char (mu_sieve_machine->string_pool, 0);
-	      free (exp);
-	      str = mu_opool_finish (mu_sieve_machine->string_pool, NULL);
-	    }
-	  else if (rc == MU_ERR_CANCELED)
-	    continue;
-	  else
-	    {
-	      mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
-				_("error expandind string: %s"),
-				mu_strerror (rc));
-	      break;
-	    }
+	  mu_diag_at_locus (MU_LOG_ERROR, &mu_sieve_locus,
+			    _("error expandind string: %s"),
+			    mu_strerror (rc));
 	}
     }
   yylval.string = str;
@@ -691,6 +677,6 @@ int
 mu_sieve_require_encoded_character (mu_sieve_machine_t mach,
 				    const char *name)
 {
-  interpreter[interp_encoded_character] = mu_i_sv_expand_encoded_char;
+  string_interpreter = mu_i_sv_expand_encoded_char;
   return 0;
 }
diff --git a/libmu_sieve/sieve.y b/libmu_sieve/sieve.y
index eaa1cfc..22f0f20 100644
--- a/libmu_sieve/sieve.y
+++ b/libmu_sieve/sieve.y
@@ -539,12 +539,6 @@ mu_i_sv_valf (mu_stream_t str, mu_sieve_value_t *val)
       mu_stream_printf (str, "%s", val->v.string);
       break;
 	
-    case SVT_VALUE_LIST:
-      mu_stream_printf (str, "[");
-      mu_i_sv_argf (str, val->v.list);
-      mu_stream_printf (str, "]");
-      break;
-      
     case SVT_POINTER:
       mu_stream_printf (str, "%p", val->v.ptr);
       break;
diff --git a/libmu_sieve/tests.c b/libmu_sieve/tests.c
index 88adbe6..03b40d7 100644
--- a/libmu_sieve/tests.c
+++ b/libmu_sieve/tests.c
@@ -64,22 +64,23 @@ struct address_closure
 };  
 
 static int
-do_count (mu_list_t args, mu_list_t tags, size_t count, int retval)
+do_count (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags,
+	  size_t count, int retval)
 {
-  mu_sieve_value_t *arg;
+  char *relcmp;
   
-  if (mu_sieve_tag_lookup (tags, "count", &arg))
+  if (mu_sieve_tag_lookup (mach, tags, "count", SVT_STRING, &relcmp))
     {
       size_t limit;
       char *str;
-      mu_sieve_value_t *val;
+      mu_list_t list;
       mu_sieve_relcmpn_t stest;
       
-      val = mu_sieve_value_get (args, 1);
-      mu_list_get (val->v.list, 0, (void **) &str);
+      mu_sieve_value_get (mach, args, 1, SVT_STRING_LIST, &list);
+      mu_list_get (list, 0, (void **) &str);
       limit = strtoul (str, &str, 10);
 
-      mu_sieve_str_to_relcmp (arg->v.string, NULL, &stest);
+      mu_sieve_str_to_relcmp (relcmp, NULL, &stest);
       return stest (count, limit);
     }
   return retval;
@@ -119,18 +120,8 @@ sieve_test_address (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   size_t count;
   
-  h = mu_sieve_value_get (args, 0);
-  if (!h)
-    {
-      mu_sieve_arg_error (mach, 1);
-      mu_sieve_abort (mach);
-    }
-  v = mu_sieve_value_get (args, 1);
-  if (!v)
-    {
-      mu_sieve_arg_error (mach, 2);
-      mu_sieve_abort (mach);
-    }
+  h = mu_sieve_value_get_untyped (mach, args, 0);
+  v = mu_sieve_value_get_untyped (mach, args, 1);
 
   mu_message_get_header (mu_sieve_get_message (mach), &header);
   clos.data = header;
@@ -139,10 +130,11 @@ sieve_test_address (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_address, &clos, &count);
   mu_address_destroy (&clos.addr);
   
-  return do_count (args, tags, count, rc);
+  return do_count (mach, args, tags, count, rc);
 }
 
-struct header_closure {
+struct header_closure
+{
   mu_header_t header;
   int index;
 };
@@ -180,20 +172,10 @@ sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   size_t count, mcount = 0;
   struct header_closure clos;
   
-  h = mu_sieve_value_get (args, 0);
-  if (!h)
-    {
-      mu_sieve_arg_error (mach, 1);
-      mu_sieve_abort (mach);
-    }
-  v = mu_sieve_value_get (args, 1);
-  if (!v)
-    {
-      mu_sieve_arg_error (mach, 2);
-      mu_sieve_abort (mach);
-    }
+  h = mu_sieve_value_get_untyped (mach, args, 0);
+  v = mu_sieve_value_get_untyped (mach, args, 1);
 
-  if (mu_sieve_tag_lookup (tags, "mime", NULL))
+  if (mu_sieve_tag_lookup (mach, tags, "mime", SVT_VOID, NULL))
     {
       int ismime = 0;
 
@@ -218,10 +200,11 @@ sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 	}
     }
   mu_message_get_header (mach->msg, &clos.header);
-  if (mu_sieve_vlist_compare (h, v, comp, test, retrieve_header, &clos, &count))
+  if (mu_sieve_vlist_compare (h, v, comp, test, retrieve_header, &clos,
+			      &count))
     return 1;
 
-  return do_count (args, tags, count + mcount, 0);
+  return do_count (mach, args, tags, count + mcount, 0);
 }
 
 int
@@ -261,18 +244,8 @@ sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc;
   size_t count;
   
-  h = mu_sieve_value_get (args, 0);
-  if (!h)
-    {
-      mu_sieve_arg_error (mach, 1);
-      mu_sieve_abort (mach);
-    }
-  v = mu_sieve_value_get (args, 1);
-  if (!v)
-    {
-      mu_sieve_arg_error (mach, 2);
-      mu_sieve_abort (mach);
-    }
+  h = mu_sieve_value_get_untyped (mach, args, 0);
+  v = mu_sieve_value_get_untyped (mach, args, 1);
 
   mu_message_get_envelope (mu_sieve_get_message (mach), 
                            (mu_envelope_t*)&clos.data);
@@ -281,7 +254,7 @@ sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_envelope, &clos,
 			    &count);
   mu_address_destroy (&clos.addr);
-  return do_count (args, tags, count, rc);
+  return do_count (mach, args, tags, count, rc);
 }
 
 int
@@ -290,22 +263,17 @@ sieve_test_size (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   int rc = 1;
   mu_sieve_runtime_tag_t *tag = NULL;
   size_t size;
+  size_t arg;
   
-  mu_sieve_value_t *val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_arg_error (mach, 1);
-      mu_sieve_abort (mach);
-    }
-
+  mu_sieve_value_get (mach, args, 0, SVT_NUMBER, &arg);
   mu_message_size (mu_sieve_get_message (mach), &size);
   mu_list_get (tags, 0, (void **)&tag);
   if (!tag)
-    rc = size == val->v.number;
+    rc = size == arg;
   else if (strcmp (tag->tag, "over") == 0)
-    rc = size > val->v.number;
+    rc = size > arg;
   else if (strcmp (tag->tag, "under") == 0)
-    rc = size < val->v.number;
+    rc = size < arg;
 
   return rc;
 }
@@ -326,13 +294,7 @@ sieve_test_exists (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_sieve_value_t *val;   
 
   mu_message_get_header (mu_sieve_get_message (mach), &header);
-  val = mu_sieve_value_get (args, 0);
-  if (!val)
-    {
-      mu_sieve_arg_error (mach, 1);
-      mu_sieve_abort (mach);
-    }
-
+  val = mu_sieve_value_get_untyped (mach, args, 0);
   return mu_sieve_vlist_do (val, _test_exists, header) == 0;
 }
 
diff --git a/libmu_sieve/util.c b/libmu_sieve/util.c
index 8b437c7..adc737e 100644
--- a/libmu_sieve/util.c
+++ b/libmu_sieve/util.c
@@ -156,7 +156,6 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data)
       val->v.string = data;
       break;
       
-    case SVT_VALUE_LIST:
     case SVT_STRING_LIST:
       val->v.list = data;
       break;
@@ -178,13 +177,57 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data)
 }
 
 mu_sieve_value_t *
-mu_sieve_value_get (mu_list_t vlist, size_t index)
+mu_sieve_value_get_untyped (mu_sieve_machine_t mach, mu_list_t vlist,
+			    size_t index)
 {
   mu_sieve_value_t *val = NULL;
-  mu_list_get (vlist, index, (void **)&val);
+  int rc = mu_list_get (vlist, index, (void **)&val);
+  if (rc)
+    {
+      mu_sieve_error (mach, _("can't get argument %zu: %s"),
+		      index, mu_strerror (rc));
+      mu_sieve_abort (mach);
+    }
   return val;
 }
 
+mu_sieve_value_t *
+mu_sieve_value_get_optional (mu_sieve_machine_t mach, mu_list_t vlist,
+			     size_t index)
+{
+  mu_sieve_value_t *val = NULL;
+  int rc = mu_list_get (vlist, index, (void **)&val);
+  if (rc == MU_ERR_NOENT)
+    return NULL;
+  else if (rc)
+    {
+      mu_sieve_error (mach, _("can't get argument %zu: %s"),
+		      index, mu_strerror (rc));
+      mu_sieve_abort (mach);
+    }
+  return val;
+}  
+
+int
+mu_sieve_value_get (mu_sieve_machine_t mach, mu_list_t vlist,
+		    size_t index,
+		    mu_sieve_data_type type, void *ret)
+{
+  mu_sieve_value_t *val = mu_sieve_value_get_untyped (mach, vlist, index);
+  if (val->type != type)
+    {
+      mu_sieve_error (mach,
+		    _("bad type for argument %zu: %s, instead of expected %s"),
+		      index,
+		      mu_sieve_type_str (val->type),
+		      mu_sieve_type_str (type));
+      mu_sieve_abort (mach);
+    }
+
+  *(union mu_sieve_value_storage *)ret = val->v;
+  return 0;
+}
+
 void
 mu_sieve_error (mu_sieve_machine_t mach, const char *fmt, ...)
 {
@@ -204,12 +247,6 @@ mu_sieve_error (mu_sieve_machine_t mach, const char *fmt, ...)
   mu_stream_write (mach->errstream, "\n", 1, NULL);
   va_end (ap);
 }
-
-void
-mu_sieve_arg_error (mu_sieve_machine_t mach, int n)
-{
-  mu_sieve_error (mach, _("cannot retrieve argument %d"), n);
-}
 
 const char *
 mu_sieve_type_str (mu_sieve_data_type type)
@@ -234,9 +271,6 @@ mu_sieve_type_str (mu_sieve_data_type type)
     case SVT_IDENT:
       return "ident";
 
-    case SVT_VALUE_LIST:
-      return "value-list";
-
     case SVT_POINTER:
       return "pointer";
     }
@@ -367,26 +401,54 @@ tag_finder (void *item, void *data)
 }
 
 int
-mu_sieve_tag_lookup (mu_list_t taglist, char *name, mu_sieve_value_t **arg)
+mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist,
+			     char *name, mu_sieve_value_t **ret)
 {
   mu_sieve_runtime_tag_t t;
 
   t.tag = name;
   if (taglist && mu_list_foreach (taglist, tag_finder, &t))
     {
-      if (arg)
-	*arg = t.arg;
+      if (ret)
+	*ret = t.arg;
       return 1;
     }
   return 0;
 }
 
 int
+mu_sieve_tag_lookup (mu_sieve_machine_t mach, mu_list_t taglist,
+		     char *name, mu_sieve_data_type type,
+		     void *ret)
+{
+  mu_sieve_value_t *val;
+  int found = mu_sieve_tag_lookup_untyped (mach, taglist, name, &val);
+
+  if (found)
+    {
+      if (ret)
+	{
+	  if (val->type != type)
+	    {
+	      mu_sieve_error (mach,
+			      _("bad type for tag %s: %s, instead of expected %s"),
+			      name,
+			      mu_sieve_type_str (val->type),
+			      mu_sieve_type_str (type));
+	      mu_sieve_abort (mach);
+	    }
+	  *(union mu_sieve_value_storage *)ret = val->v;
+	}
+    }
+
+  return found;
+}
+
+int
 mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t ac, void *data)
 {
   switch (val->type)
     {
-    case SVT_VALUE_LIST:
     case SVT_STRING_LIST:
       return mu_list_foreach (val->v.list, ac, data);
     case SVT_STRING:


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 29 02:20:20 2016
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cBciC-0005Gg-G5
	for mharc-commit-mailutils@gnu.org; Tue, 29 Nov 2016 02:20:20 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60437)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cBci6-0005GS-WA
	for commit-mailutils@gnu.org; Tue, 29 Nov 2016 02:20:19 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cBci2-0000T3-Sn
	for commit-mailutils@gnu.org; Tue, 29 Nov 2016 02:20:14 -0500
Received: from vcs.savannah.gnu.org ([208.118.235.72]:38117)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1cBci2-0000Sz-NU
	for commit-mailutils@gnu.org; Tue, 29 Nov 2016 02:20:10 -0500
Received: by vcs.savannah.gnu.org (Postfix, from userid 65697)
	id 7C86B2201BD; Tue, 29 Nov 2016 07:20:10 +0000 (UTC)
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-3.0-16-g6efafc3
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 1528dfded819e3c8ccba459425b0dc18b1f3a722
X-Git-Newrev: 6efafc3f28d24b6e31052263d1c8f154049e9f65
Message-Id: <20161129072010.7C86B2201BD@vcs.savannah.gnu.org>
Date: Tue, 29 Nov 2016 07:20:10 +0000 (UTC)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils/>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 29 Nov 2016 07:20:20 -0000

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=6efafc3f28d24b6e31052263d1c8f154049e9f65

The branch, master has been updated
       via  6efafc3f28d24b6e31052263d1c8f154049e9f65 (commit)
      from  1528dfded819e3c8ccba459425b0dc18b1f3a722 (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 6efafc3f28d24b6e31052263d1c8f154049e9f65
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 28 13:57:56 2016 +0200

    sieve: more improvements to the argument/tag runtime access API
    
    * include/mailutils/sieve.h (mu_sieve_handler_t): Change signature:
    remove args and tags arguments, they are contained in struct
    mu_sieve_machine now.
    (mu_sieve_get_comparator)
    (mu_sieve_relcmpn_t): Change signature.
    (mu_sieve_tag_lookup,mu_sieve_tag_lookup_untyped): Remove
    (mu_sieve_get_tag,mu_sieve_get_tag_untyped): New protos.
    (mu_sieve_value_get_optional): Replace by
    mu_sieve_get_arg_optional.
    (mu_sieve_value_get_untyped): Replace by
    mu_sieve_get_arg_untyped.
    (mu_sieve_value_get): Replace by
    mu_sieve_get_arg.
    All uses changed.
    * libmu_sieve/sieve-priv.h (mu_sieve_machine): New members:
    arg_list and tag_list
    * libmu_sieve/runtime.c (instr_run): Set up identifier, arg_list,
    and tag_list in mu_sieve_machine_t before calling the handler.
    Reset them afterward.
    * libmu_sieve/util.c (mu_sieve_value_get_optional): Replace by
    mu_sieve_get_arg_optional.
    (mu_sieve_value_get_untyped): Replace by
    mu_sieve_get_arg_untyped.
    (mu_sieve_value_get): Replace by
    mu_sieve_get_arg.
    (mu_sieve_tag_lookup): Replace by mu_sieve_get_tag
    (mu_sieve_tag_lookup_untyped): Replace by
    mu_sieve_get_tag_untyped

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

Summary of changes:
 examples/numaddr.c                  |    8 ++---
 gint                                |    2 +-
 include/mailutils/sieve.h           |   33 +++++++----------
 libmu_sieve/actions.c               |   20 +++++------
 libmu_sieve/comparator.c            |    8 ++---
 libmu_sieve/extensions/editheader.c |   20 +++++------
 libmu_sieve/extensions/list.c       |   12 +++----
 libmu_sieve/extensions/moderator.c  |   14 ++++----
 libmu_sieve/extensions/pipe.c       |   22 ++++++------
 libmu_sieve/extensions/spamd.c      |   14 ++++----
 libmu_sieve/extensions/timestamp.c  |    8 ++---
 libmu_sieve/extensions/vacation.c   |   58 +++++++++++++++---------------
 libmu_sieve/relational.c            |    4 +--
 libmu_sieve/runtime.c               |   27 +++++++-------
 libmu_sieve/sieve-priv.h            |   15 ++++----
 libmu_sieve/tests.c                 |   68 +++++++++++++++++------------------
 libmu_sieve/util.c                  |   45 +++++++++++------------
 17 files changed, 183 insertions(+), 195 deletions(-)

diff --git a/examples/numaddr.c b/examples/numaddr.c
index b073793..7981e0b 100644
--- a/examples/numaddr.c
+++ b/examples/numaddr.c
@@ -78,7 +78,7 @@ _count_items (void *item, void *data)
 
 /* Handler for the numaddr test */
 static int
-numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+numaddr_test (mu_sieve_machine_t mach)
 {
   mu_sieve_value_t *h;
   struct val_ctr vc;
@@ -86,9 +86,9 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   
   /* Retrieve required arguments: */
   /* First argument: list of header names */
-  h = mu_sieve_value_get_untyped (mach, args, 0);
+  h = mu_sieve_get_arg_untyped (mach, 0);
   /* Second argument: Limit on the number of addresses */
-  mu_sieve_value_get (mach, args, 1, SVT_NUMBER, &vc.limit);
+  mu_sieve_get_arg (mach, 1, SVT_NUMBER, &vc.limit);
 
   /* Fill in the val_ctr structure */
   mu_message_get_header (mu_sieve_get_message (mach), &vc.hdr);
@@ -99,7 +99,7 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 
   /* Here rc >= 1 iff the counted number of addresses is greater or equal
      to vc.limit. If `:under' tag was given we reverse the return value */
-  if (mu_sieve_tag_lookup (mach, tags, "under", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "under", SVT_VOID, NULL))
     rc = !rc;
 
   return rc;
diff --git a/gint b/gint
index 42f4712..fd86bf7 160000
--- a/gint
+++ b/gint
@@ -1 +1 @@
-Subproject commit 42f4712085b40173eaea58e14b1a579291a6fe3a
+Subproject commit fd86bf7d44b0c970771830692ae7491447ebe8b1
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 4fc91c2..8a89ca4 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -33,8 +33,7 @@ extern "C" {
 
 typedef struct mu_sieve_machine *mu_sieve_machine_t;
 
-typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach,
-				   mu_list_t args, mu_list_t tags);
+typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach);
 typedef void (*mu_sieve_action_log_t) (mu_sieve_machine_t mach,
 				       const char *action,
 				       const char *fmt, va_list ap);
@@ -175,20 +174,17 @@ mu_sieve_comparator_t mu_sieve_comparator_lookup (mu_sieve_machine_t mach,
 						  const char *name,
 						  int matchtype);
 
-mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach,
-					       mu_list_t tags);
+mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach);
 int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t *test,
 			    mu_sieve_relcmpn_t *stest);
-mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach,
-				       mu_list_t tags);
+mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach);
 
 void mu_sieve_require (mu_sieve_machine_t mach, mu_list_t slist);
 
-int mu_sieve_tag_lookup (mu_sieve_machine_t mach,
-			 mu_list_t taglist, char *name,
-			 mu_sieve_data_type type, void *ret);
-int mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist,
-				 char *name, mu_sieve_value_t **ret);
+int mu_sieve_get_tag (mu_sieve_machine_t mach, char *name,
+		      mu_sieve_data_type type, void *ret);
+int mu_sieve_get_tag_untyped (mu_sieve_machine_t mach, 
+			      char *name, mu_sieve_value_t **ret);
   
 int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name);
 int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
@@ -198,15 +194,12 @@ int mu_sieve_match_part_checker (mu_sieve_machine_t mach,
 				 const char *name, mu_list_t tags,
 				 mu_list_t args);
 /* Operations on value lists */
-mu_sieve_value_t *mu_sieve_value_get_optional (mu_sieve_machine_t mach,
-					       mu_list_t vlist,
-					       size_t index);
-mu_sieve_value_t *mu_sieve_value_get_untyped (mu_sieve_machine_t mach,
-					      mu_list_t vlist,
-					      size_t index);
-int mu_sieve_value_get (mu_sieve_machine_t mach, mu_list_t vlist,
-			size_t index,
-			mu_sieve_data_type type, void *ret);
+mu_sieve_value_t *mu_sieve_get_arg_optional (mu_sieve_machine_t mach,
+					     size_t index);
+mu_sieve_value_t *mu_sieve_get_arg_untyped (mu_sieve_machine_t mach,
+					    size_t index);
+int mu_sieve_get_arg (mu_sieve_machine_t mach, size_t index,
+		      mu_sieve_data_type type, void *ret);
 int mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t ac,
 		       void *data);
 int mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b,
diff --git a/libmu_sieve/actions.c b/libmu_sieve/actions.c
index f6c37f7..077b8cd 100644
--- a/libmu_sieve/actions.c
+++ b/libmu_sieve/actions.c
@@ -47,7 +47,7 @@ sieve_mark_deleted (mu_message_t msg, int deleted)
 
 
 static int
-sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_stop (mu_sieve_machine_t mach)
 {
   mu_sieve_log_action (mach, "STOP", NULL);
   mach->pc = 0;
@@ -55,7 +55,7 @@ sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 }
 
 static int
-sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_keep (mu_sieve_machine_t mach)
 {
   mu_sieve_log_action (mach, "KEEP", NULL);
   if (mu_sieve_is_dry_run (mach))
@@ -65,7 +65,7 @@ sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 }
 
 static int
-sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_discard (mu_sieve_machine_t mach)
 {
   mu_sieve_log_action (mach, "DISCARD", _("marking as deleted"));
   if (mu_sieve_is_dry_run (mach))
@@ -75,16 +75,16 @@ sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 }
 
 static int
-sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_fileinto (mu_sieve_machine_t mach)
 {
   int rc;
   int mbflags = 0;
   char *filename;
   char *perms;
 
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &filename);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &filename);
 
-  if (mu_sieve_tag_lookup (mach, tags, "permissions", SVT_STRING, &perms))
+  if (mu_sieve_get_tag (mach, "permissions", SVT_STRING, &perms))
     {
       const char *p;
       
@@ -281,7 +281,7 @@ build_mime (mu_mime_t *pmime, mu_message_t msg, const char *text)
 }
 
 static int
-sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_reject (mu_sieve_machine_t mach)
 {
   mu_mime_t mime = NULL;
   mu_mailer_t mailer = mu_sieve_get_mailer (mach);
@@ -292,7 +292,7 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_header_t hdr;
   char *text;
   
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &text);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &text);
   mu_sieve_log_action (mach, "REJECT", NULL);  
   if (mu_sieve_is_dry_run (mach))
     return 0;
@@ -398,7 +398,7 @@ check_redirect_loop (mu_message_t msg)
 }
 
 static int
-sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_redirect (mu_sieve_machine_t mach)
 {
   mu_message_t msg, newmsg = NULL;
   mu_address_t addr = NULL, from = NULL;
@@ -408,7 +408,7 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_mailer_t mailer = mu_sieve_get_mailer (mach);
   char *addrstr;
   
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &addrstr);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &addrstr);
 
   rc = mu_address_create (&addr, addrstr);
   if (rc)
diff --git a/libmu_sieve/comparator.c b/libmu_sieve/comparator.c
index 03fe403..2ef43cf 100644
--- a/libmu_sieve/comparator.c
+++ b/libmu_sieve/comparator.c
@@ -127,14 +127,14 @@ _find_comparator (void *item, void *data)
 }
 
 mu_sieve_comparator_t
-mu_sieve_get_comparator (mu_sieve_machine_t mach, mu_list_t tags)
+mu_sieve_get_comparator (mu_sieve_machine_t mach)
 {
   mu_sieve_comparator_t comp = NULL;
 
-  mu_list_foreach (tags, _find_comparator, &comp);
+  mu_list_foreach (mach->tag_list, _find_comparator, &comp);
   return comp ? comp : mu_sieve_comparator_lookup (mach,
-						"i;ascii-casemap",
-						MU_SIEVE_MATCH_IS);
+						   "i;ascii-casemap",
+						   MU_SIEVE_MATCH_IS);
 }
 
 /* Compile time support */
diff --git a/libmu_sieve/extensions/editheader.c b/libmu_sieve/extensions/editheader.c
index 4ec7c1d..52c745e 100644
--- a/libmu_sieve/extensions/editheader.c
+++ b/libmu_sieve/extensions/editheader.c
@@ -31,7 +31,7 @@
 /* Syntax: addheader [:last] <field-name: string> <value: string>
  */
 int
-sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_addheader (mu_sieve_machine_t mach)
 {
   const char *field_name;
   const char *field_value;
@@ -39,8 +39,8 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_header_t hdr;
   int rc;
   
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &field_name);
-  mu_sieve_value_get (mach, args, 1, SVT_STRING, &field_value);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &field_name);
+  mu_sieve_get_arg (mach, 1, SVT_STRING, &field_value);
 
   mu_sieve_log_action (mach, "ADDHEADER", "%s: %s", field_name, field_value);
 
@@ -58,7 +58,7 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       mu_sieve_abort (mach);
     }
 
-  rc = (mu_sieve_tag_lookup (mach, tags, "last", SVT_VOID, NULL) ?
+  rc = (mu_sieve_get_tag (mach, "last", SVT_VOID, NULL) ?
 	mu_header_append : mu_header_prepend) (hdr, field_name, field_value);
   if (rc)
     {
@@ -77,7 +77,7 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
                         [<value-patterns: string-list>]
  */
 int
-sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_deleteheader (mu_sieve_machine_t mach)
 {
   mu_sieve_value_t *val;
   const char *field_name;
@@ -89,8 +89,8 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_iterator_t itr;
   size_t i, idx = 0;
   
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &field_name);
-  val = mu_sieve_value_get_optional (mach, args, 1);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &field_name);
+  val = mu_sieve_get_arg_optional (mach, 1);
   if (!val)
     {
       field_pattern = NULL;
@@ -142,14 +142,14 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
     }
 
   mu_header_get_iterator (hdr, &itr);
-  if (mu_sieve_tag_lookup (mach, tags, "last", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "last", SVT_VOID, NULL))
     {
       int backwards = 1;
       mu_iterator_ctl (itr, mu_itrctl_set_direction, &backwards);
     }
-  comp = mu_sieve_get_comparator (mach, tags);
+  comp = mu_sieve_get_comparator (mach);
 
-  mu_sieve_tag_lookup (mach, tags, "index", SVT_NUMBER, &idx);
+  mu_sieve_get_tag (mach, "index", SVT_NUMBER, &idx);
   
   for (i = 0, mu_iterator_first (itr); !mu_iterator_is_done (itr);
        mu_iterator_next (itr))
diff --git a/libmu_sieve/extensions/list.c b/libmu_sieve/extensions/list.c
index fd18660..71696c6 100644
--- a/libmu_sieve/extensions/list.c
+++ b/libmu_sieve/extensions/list.c
@@ -145,22 +145,22 @@ list_retrieve_header (void *item, void *data, int idx, char **pval)
 */
 
 static int
-list_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+list_test (mu_sieve_machine_t mach)
 {
   mu_sieve_value_t *h, *v;
-  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags);
+  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach);
   struct header_closure clos;
   int result;
 
   memset (&clos, 0, sizeof clos);
-  if (!mu_sieve_tag_lookup (mach, tags, "delim", SVT_STRING, &clos.delim))
+  if (!mu_sieve_get_tag (mach, "delim", SVT_STRING, &clos.delim))
     clos.delim = ",";
   
-  h = mu_sieve_value_get_untyped (mach, args, 0);
-  v = mu_sieve_value_get_untyped (mach, args, 1);
+  h = mu_sieve_get_arg_untyped (mach, 0);
+  v = mu_sieve_get_arg_untyped (mach, 1);
   mu_message_get_header (mu_sieve_get_message (mach), &clos.header);
   result = mu_sieve_vlist_compare (h, v, comp,
-				   mu_sieve_get_relcmp (mach, tags),
+				   mu_sieve_get_relcmp (mach),
 				   list_retrieve_header,
 				   &clos, NULL) > 0;
   cleanup (&clos);
diff --git a/libmu_sieve/extensions/moderator.c b/libmu_sieve/extensions/moderator.c
index 7d16cef..249611c 100644
--- a/libmu_sieve/extensions/moderator.c
+++ b/libmu_sieve/extensions/moderator.c
@@ -74,7 +74,7 @@
 #include <stdlib.h>
 
 static int
-moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags,
+moderator_filter_message (mu_sieve_machine_t mach, 
 			  mu_message_t msg, int *pdiscard)
 {
   int rc;
@@ -82,7 +82,7 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags,
   mu_attribute_t attr;
   char *arg;
   
-  if (mu_sieve_tag_lookup (mach, tags, "source", SVT_STRING, &arg))
+  if (mu_sieve_get_tag (mach, "source", SVT_STRING, &arg))
     {
       rc = mu_sieve_machine_inherit (mach, &newmach);
       if (rc)
@@ -101,7 +101,7 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags,
       if (rc)
 	mu_sieve_error (mach, _("cannot compile source `%s'"), arg);
     }
-  else if (mu_sieve_tag_lookup (mach, tags, "program", SVT_STRING, &arg))
+  else if (mu_sieve_get_tag (mach, "program", SVT_STRING, &arg))
     {
       struct mu_locus locus;
       
@@ -265,7 +265,7 @@ moderator_message_get_part (mu_sieve_machine_t mach,
 }
 
 static int
-moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+moderator_action (mu_sieve_machine_t mach)
 {
   mu_message_t msg, orig;
   int rc;
@@ -294,7 +294,7 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if ((rc = moderator_message_get_part (mach, msg, 2, &orig)))
     mu_sieve_abort (mach);
 
-  rc = moderator_filter_message (mach, tags, orig, &discard);
+  rc = moderator_filter_message (mach, orig, &discard);
   mu_message_unref (orig);
   if (rc)
     mu_sieve_abort (mach);
@@ -311,13 +311,13 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 	  mu_sieve_abort (mach);
 	}
 
-      mu_sieve_tag_lookup (mach, tags, "address", SVT_STRING, &from);
+      mu_sieve_get_tag (mach, "address", SVT_STRING, &from);
       
       if (moderator_discard_message (mach, request, from))
 	discard = 0;
       else
 	{
-	  if (!mu_sieve_tag_lookup (mach, tags, "keep", SVT_VOID, NULL))
+	  if (!mu_sieve_get_tag (mach, "keep", SVT_VOID, NULL))
 	    {
 	      mu_attribute_t attr = 0;
 
diff --git a/libmu_sieve/extensions/pipe.c b/libmu_sieve/extensions/pipe.c
index d7eaadd..3aedf16 100644
--- a/libmu_sieve/extensions/pipe.c
+++ b/libmu_sieve/extensions/pipe.c
@@ -82,7 +82,7 @@
 #define PIPE_ALL (PIPE_ENVELOPE | PIPE_HEADERS | PIPE_BODY)
 
 int
-sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
+sieve_pipe (mu_sieve_machine_t mach, int test)
 {
   int retval = 0;
   int rc, result;
@@ -94,7 +94,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
   const char *error_arg = NULL;
   int pipe_mask = 0;
   
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &cmd);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &cmd);
 
   if (mu_sieve_is_dry_run (mach))
     return 0;
@@ -102,11 +102,11 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
   msg = mu_sieve_get_message (mach);
   mu_message_get_envelope (msg, &env);
 
-  if (mu_sieve_tag_lookup (mach, tags, "envelope", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "envelope", SVT_VOID, NULL))
     pipe_mask |= PIPE_ENVELOPE;
-  if (mu_sieve_tag_lookup (mach, tags, "header", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "header", SVT_VOID, NULL))
     pipe_mask |= PIPE_HEADERS;
-  if (mu_sieve_tag_lookup (mach, tags, "body", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "body", SVT_VOID, NULL))
     pipe_mask |= PIPE_BODY;
   if (pipe_mask == 0)
     pipe_mask = PIPE_ALL;
@@ -194,7 +194,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
 	  mu_sieve_abort (mach);
 	}
 
-      if (mu_sieve_tag_lookup (mach, tags, "exit", SVT_NUMBER, &n))
+      if (mu_sieve_get_tag (mach, "exit", SVT_NUMBER, &n))
 	code = n;
       if (result == 0)
 	retval = code == 0;
@@ -204,7 +204,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
 	{
 	  int signo = WTERMSIG (status);
 	  size_t n;
-	  if (mu_sieve_tag_lookup (mach, tags, "signal", SVT_NUMBER, &n))
+	  if (mu_sieve_get_tag (mach, "signal", SVT_NUMBER, &n))
 	    retval = signo == n;
 	  else
 	    {
@@ -228,16 +228,16 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test)
 }
 
 int
-sieve_action_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_pipe (mu_sieve_machine_t mach)
 {
   mu_sieve_log_action (mach, "PIPE", NULL);
-  return sieve_pipe (mach, args, tags, 0);
+  return sieve_pipe (mach, 0);
 }
 
 int
-sieve_test_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_test_pipe (mu_sieve_machine_t mach)
 {
-  return sieve_pipe (mach, args, tags, 1);
+  return sieve_pipe (mach, 1);
 }
 
 
diff --git a/libmu_sieve/extensions/spamd.c b/libmu_sieve/extensions/spamd.c
index 4e5fea1..692f49a 100644
--- a/libmu_sieve/extensions/spamd.c
+++ b/libmu_sieve/extensions/spamd.c
@@ -353,7 +353,7 @@ get_real_message_size (mu_message_t msg, size_t *psize)
 */
 
 static int
-spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+spamd_test (mu_sieve_machine_t mach)
 {
   char *buffer = NULL;
   size_t size;
@@ -381,12 +381,12 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       mu_sieve_abort (mach);
     }
   
-  if (!mu_sieve_tag_lookup (mach, tags, "host", SVT_STRING, &host))
+  if (!mu_sieve_get_tag (mach, "host", SVT_STRING, &host))
     host = "127.0.0.1";
   
-  if (mu_sieve_tag_lookup (mach, tags, "port", SVT_NUMBER, &num))
+  if (mu_sieve_get_tag (mach, "port", SVT_NUMBER, &num))
     result = spamd_connect_tcp (mach, &stream, host, num);
-  else if (mu_sieve_tag_lookup (mach, tags, "socket", SVT_STRING, &str))
+  else if (mu_sieve_get_tag (mach, "socket", SVT_STRING, &str))
     result = spamd_connect_socket (mach, &stream, str);
   else
     result = spamd_connect_tcp (mach, &stream, host, DEFAULT_SPAMD_PORT);
@@ -421,7 +421,7 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   spamd_send_command (stream, "SYMBOLS SPAMC/1.2");
   
   spamd_send_command (stream, "Content-length: %lu", (u_long) size);
-  if (mu_sieve_tag_lookup (mach, tags, "user", SVT_STRING, &str))
+  if (mu_sieve_get_tag (mach, "user", SVT_STRING, &str))
     spamd_send_command (stream, "User: %s", str);
   else
     {
@@ -464,12 +464,12 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 
   if (!result)
     {
-      if (mu_sieve_tag_lookup (mach, tags, "over", SVT_STRING, &str))
+      if (mu_sieve_get_tag (mach, "over", SVT_STRING, &str))
 	{
 	  decode_float (&limit, str, 3, NULL);
 	  result = score >= limit;
 	}
-      else if (mu_sieve_tag_lookup (mach, tags, "under", SVT_STRING, &str))
+      else if (mu_sieve_get_tag (mach, "under", SVT_STRING, &str))
 	{
 	  decode_float (&limit, str, 3, NULL);
 	  result = score <= limit;	  
diff --git a/libmu_sieve/extensions/timestamp.c b/libmu_sieve/extensions/timestamp.c
index dd29d1f..e96f4dd 100644
--- a/libmu_sieve/extensions/timestamp.c
+++ b/libmu_sieve/extensions/timestamp.c
@@ -48,7 +48,7 @@
 
 /* Handler for the timestamp test */
 static int
-timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+timestamp_test (mu_sieve_machine_t mach)
 {
   char const *hname;
   char const *date;
@@ -60,9 +60,9 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   
   /* Retrieve required arguments: */
   /* First argument: header name */
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &hname);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &hname);
   /* Second argument: date displacement */
-  mu_sieve_value_get (mach, args, 1, SVT_STRING, &date);
+  mu_sieve_get_arg (mach, 1, SVT_STRING, &date);
 
   if (mu_parse_date (date, &tlimit, &now))
     {
@@ -93,7 +93,7 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 
   rc = tval > tlimit;
     
-  if (mu_sieve_tag_lookup (mach, tags, "before", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "before", SVT_VOID, NULL))
     rc = !rc;  
 
   return rc;
diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c
index a3a1fc3..989a87a 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -51,7 +51,7 @@
    is the message text.
 */
 static int
-build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
+build_mime (mu_sieve_machine_t mach, mu_mime_t *pmime,
 	    mu_message_t msg, const char *text)
 {
   mu_mime_t mime = NULL;
@@ -78,7 +78,7 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime,
       return 1;
     }
 
-  if (mu_sieve_tag_lookup (mach, tags, "mime", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "mime", SVT_VOID, NULL))
     {
       mu_stream_t fstr;
       rc = mu_filter_create (&fstr, input, "base64",
@@ -227,7 +227,7 @@ regex_comparator (void *item, void *data)
 /* Decide whether EMAIL address should not be responded to.
  */
 static int
-noreply_address_p (mu_sieve_machine_t mach, mu_list_t tags, char *email)
+noreply_address_p (mu_sieve_machine_t mach, char *email)
 {
   int i, rc = 0;
   mu_sieve_value_t *arg;
@@ -249,7 +249,7 @@ noreply_address_p (mu_sieve_machine_t mach, mu_list_t tags, char *email)
   for (i = 0; rc == 0 && noreply_sender[i]; i++)
     rc = regex_comparator (noreply_sender[i], &rd);
 
-  if (!rc && mu_sieve_tag_lookup_untyped (mach, tags, "noreply", &arg))
+  if (!rc && mu_sieve_get_tag_untyped (mach, "noreply", &arg))
     rc = mu_sieve_vlist_do (arg, regex_comparator, &rd);
   
   return rc;
@@ -337,7 +337,7 @@ test_and_update_prop (mu_property_t prop, const char *from,
    be answered, 0 if it should not, and throw exception if an error
    occurs. */
 static int
-check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
+check_db (mu_sieve_machine_t mach, char *from)
 {
   mu_property_t prop;
   char *file;
@@ -348,7 +348,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
   const char *dbfile = "~/.vacation";
   size_t n;
   
-  if (mu_sieve_tag_lookup (mach, tags, "days", SVT_NUMBER, &n))
+  if (mu_sieve_get_tag (mach, "days", SVT_NUMBER, &n))
     {
       days = n;
       if (days > DAYS_MAX)
@@ -357,7 +357,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
   else
     days = DAYS_DEFAULT;
 
-  mu_sieve_tag_lookup (mach, tags, "database", SVT_STRING, &dbfile);
+  mu_sieve_get_tag (mach, "database", SVT_STRING, &dbfile);
   
   file = mu_tilde_expansion (dbfile, MU_HIERARCHY_DELIMITER, NULL);
   if (!file)
@@ -429,12 +429,12 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
    "reply_prefix" tag.
  */
 static void
-re_subject (mu_sieve_machine_t mach, mu_list_t tags, char **psubject)
+re_subject (mu_sieve_machine_t mach, char **psubject)
 {
   char *subject;
   char *prefix = "Re";
   
-  mu_sieve_tag_lookup (mach, tags, "reply_prefix", SVT_STRING, &prefix);
+  mu_sieve_get_tag (mach, "reply_prefix", SVT_STRING, &prefix);
 
   subject = malloc (strlen (*psubject) + strlen (prefix) + 3);
   if (!subject)
@@ -459,7 +459,7 @@ re_subject (mu_sieve_machine_t mach, mu_list_t tags, char **psubject)
    Otherwise, reply_prefix is prepended to it. */
 
 static void
-vacation_subject (mu_sieve_machine_t mach, mu_list_t tags,
+vacation_subject (mu_sieve_machine_t mach,
 		  mu_message_t msg, mu_header_t newhdr)
 {
   char *value;
@@ -467,7 +467,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags,
   int subject_allocated = 0;
   mu_header_t hdr;
   
-  if (mu_sieve_tag_lookup (mach, tags, "subject", SVT_STRING, &subject))
+  if (mu_sieve_get_tag (mach, "subject", SVT_STRING, &subject))
     /* nothing */;
   else if (mu_message_get_header (msg, &hdr) == 0
 	   && mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT,
@@ -488,7 +488,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags,
 	  subject = p;
 	}
 
-      if (mu_sieve_tag_lookup (mach, tags, "reply_regex", SVT_STRING, &p))
+      if (mu_sieve_get_tag (mach, "reply_regex", SVT_STRING, &p))
 	{
 	  char *err = NULL;
 	  
@@ -504,7 +504,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags,
 	}
 	  
       if (mu_unre_subject (subject, NULL))
-	re_subject (mach, tags, &subject);
+	re_subject (mach, &subject);
       
       free (value);
     }
@@ -601,7 +601,7 @@ add_header (void *item, void *data)
 
 /* Generate and send the reply message */
 static int
-vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
+vacation_reply (mu_sieve_machine_t mach, mu_message_t msg,
 		char const *text, char const *to, char const *from)
 {
   mu_mime_t mime = NULL;
@@ -613,7 +613,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
   int rc;
   mu_sieve_value_t *val;
 
-  if (mu_sieve_tag_lookup (mach, tags, "file", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "file", SVT_VOID, NULL))
     {
       mu_stream_t instr;
       
@@ -628,7 +628,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
 	  return -1;
 	}
       
-      if (mu_sieve_tag_lookup (mach, tags, "rfc2822", SVT_VOID, NULL))
+      if (mu_sieve_get_tag (mach, "rfc2822", SVT_VOID, NULL))
 	{
 	  rc = mu_stream_to_message (instr, &newmsg);
 	  mu_stream_unref (instr);
@@ -684,7 +684,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
 	      return -1;
 	    }
 
-	  if (build_mime (mach, tags, &mime, msg, (char const *) trans[0]))
+	  if (build_mime (mach, &mime, msg, (char const *) trans[0]))
 	    {
 	      mu_stream_unref (text_stream);
 	      return -1;
@@ -696,7 +696,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
     }
   else
     {
-      if (build_mime (mach, tags, &mime, msg, text))
+      if (build_mime (mach, &mime, msg, text))
 	return -1;
       mu_mime_get_message (mime, &newmsg);
       mu_message_unref (newmsg);
@@ -716,7 +716,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
     {
       mu_header_set_value (newhdr, MU_HEADER_TO, to, 0);
 
-      if (mu_sieve_tag_lookup_untyped (mach, tags, "header", &val))
+      if (mu_sieve_get_tag_untyped (mach, "header", &val))
 	{
 	  struct header_closure hc;
 	  hc.mach = mach;
@@ -724,7 +724,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
 	  mu_sieve_vlist_do (val, add_header, &hc);
 	}
       
-      vacation_subject (mach, tags, msg, newhdr);
+      vacation_subject (mach, msg, newhdr);
       
       if (from)
         {
@@ -763,7 +763,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
 }
 
 int
-sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_action_vacation (mu_sieve_machine_t mach)
 {
   int rc;
   char *text, *from = NULL;
@@ -775,12 +775,12 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (diag (mach))
     return 0;
   
-  mu_sieve_value_get (mach, args, 0, SVT_STRING, &text);
+  mu_sieve_get_arg (mach, 0, SVT_STRING, &text);
 
   msg = mu_sieve_get_message (mach);
   mu_message_get_header (msg, &hdr);
 
-  if (mu_sieve_tag_lookup (mach, tags, "sender", SVT_STRING, &from))
+  if (mu_sieve_get_tag (mach, "sender", SVT_STRING, &from))
     {
       /* Debugging hook: :sender sets fake reply address */
       from = strdup (from);
@@ -803,12 +803,12 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 
   my_address = mu_get_user_email (NULL);
 
-  if (mu_sieve_tag_lookup (mach, tags, "always_reply", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "always_reply", SVT_VOID, NULL))
     return_address = my_address;
   else
     {
       mu_sieve_value_t *val = NULL;
-      mu_sieve_tag_lookup_untyped (mach, tags, "aliases", &val);
+      mu_sieve_get_tag_untyped (mach, "aliases", &val);
       if (match_addresses (hdr, my_address, val, &return_address) == 0)
 	{
 	  free (my_address);
@@ -816,19 +816,19 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 	}
     }
 
-  if (noreply_address_p (mach, tags, from)
+  if (noreply_address_p (mach, from)
       || bulk_precedence_p (hdr)
-      || check_db (mach, tags, from))
+      || check_db (mach, from))
     {
       free (from);
       free (my_address);
       return 0;
     }
 
-  mu_sieve_tag_lookup (mach, tags, "return_address", SVT_STRING,
+  mu_sieve_get_tag (mach, "return_address", SVT_STRING,
 		       &return_address);
 
-  rc = vacation_reply (mach, tags, msg, text, from, return_address);
+  rc = vacation_reply (mach, msg, text, from, return_address);
   free (from);
   free (my_address);
   if (rc == -1)
diff --git a/libmu_sieve/relational.c b/libmu_sieve/relational.c
index 19c9eec..7d18ea8 100644
--- a/libmu_sieve/relational.c
+++ b/libmu_sieve/relational.c
@@ -81,12 +81,12 @@ mu_sieve_str_to_relcmp (const char *str,
 }
 
 mu_sieve_relcmp_t
-mu_sieve_get_relcmp (mu_sieve_machine_t mach, mu_list_t tags)
+mu_sieve_get_relcmp (mu_sieve_machine_t mach)
 {
   char *str;
   mu_sieve_relcmp_t test = NULL;
   
-  if (mu_sieve_tag_lookup (mach, tags, "value", SVT_STRING, &str) == 0)
+  if (mu_sieve_get_tag (mach, "value", SVT_STRING, &str) == 0)
     return op_ne;
   mu_sieve_str_to_relcmp (str, &test, NULL);
   return test;
diff --git a/libmu_sieve/runtime.c b/libmu_sieve/runtime.c
index 4648b9a..1c0e38b 100644
--- a/libmu_sieve/runtime.c
+++ b/libmu_sieve/runtime.c
@@ -30,7 +30,7 @@
 #define INSTR_DISASS(m) ((m)->state == mu_sieve_state_disass)
 #define INSTR_DEBUG(m) \
   (INSTR_DISASS(m) || mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE9)) 
-
+
 void
 _mu_i_sv_instr_source (mu_sieve_machine_t mach)
 {
@@ -59,39 +59,38 @@ _mu_i_sv_instr_line (mu_sieve_machine_t mach)
 static int
 instr_run (mu_sieve_machine_t mach, char const *what)
 {
-  mu_sieve_handler_t han = SIEVE_ARG (mach, 0, handler);
-  mu_list_t arg_list = SIEVE_ARG (mach, 1, list);
-  mu_list_t tag_list = SIEVE_ARG (mach, 2, list);
   int rc = 0;
+  mu_sieve_handler_t han = SIEVE_ARG (mach, 0, handler);
+  mach->arg_list = SIEVE_ARG (mach, 1, list);
+  mach->tag_list = SIEVE_ARG (mach, 2, list);
+  mach->identifier = SIEVE_ARG (mach, 3, string);
   
-  SIEVE_ADJUST(mach, 4);
+  SIEVE_ADJUST (mach, 4);
 
   if (INSTR_DEBUG (mach))
-    mu_i_sv_debug_command (mach, mach->pc - 1,
-			   what, tag_list, arg_list);
+    mu_i_sv_debug_command (mach, mach->pc - 1, what);
   else
-    mu_i_sv_trace (mach, what, tag_list, arg_list);
+    mu_i_sv_trace (mach, what);
   
-  if (!INSTR_DISASS(mach))
-    rc = han (mach, arg_list, tag_list);
+  if (!INSTR_DISASS (mach))
+    rc = han (mach);
+  mach->arg_list = NULL;
+  mach->tag_list = NULL;
+  mach->identifier = NULL;
   return rc;
 }
 
 void
 _mu_i_sv_instr_action (mu_sieve_machine_t mach)
 {
-  mach->identifier = SIEVE_ARG (mach, 3, string);
   mach->action_count++;
   instr_run (mach, "ACTION");
-  mach->identifier = NULL;
 }
 
 void
 _mu_i_sv_instr_test (mu_sieve_machine_t mach)
 {
-  mach->identifier = SIEVE_ARG (mach, 3, string);
   mach->reg = instr_run (mach, "TEST");
-  mach->identifier = NULL;
 }
 
 void
diff --git a/libmu_sieve/sieve-priv.h b/libmu_sieve/sieve-priv.h
index 6c62255..d7b389b 100644
--- a/libmu_sieve/sieve-priv.h
+++ b/libmu_sieve/sieve-priv.h
@@ -83,9 +83,13 @@ struct mu_sieve_machine
   long reg;                  /* Numeric register */
   mu_list_t stack;           /* Runtime stack */
 
+  /* Call environment */
+  const char *identifier;    /* Name of action or test being executed */
+  mu_list_t arg_list;        /* Positional arguments */
+  mu_list_t tag_list;        /* Tagged arguments */
+  
   int dry_run;               /* Dry-run mode */
   jmp_buf errbuf;            /* Target location for non-local exits */
-  const char *identifier;    /* Name of action or test being executed */
   
   mu_mailbox_t mailbox;      /* Mailbox to operate upon */
   size_t    msgno;           /* Current message number */
@@ -195,12 +199,9 @@ void mu_i_sv_error (mu_sieve_machine_t mach);
 
 void mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...)
   MU_PRINTFLIKE(3,4);
-void mu_i_sv_debug_command (mu_sieve_machine_t mach,
-			    size_t pc,
-			    char const *what,
-			    mu_list_t taglist, mu_list_t arglist);
-void mu_i_sv_trace (mu_sieve_machine_t mach, const char *what,
-		    mu_list_t taglist, mu_list_t arglist);
+void mu_i_sv_debug_command (mu_sieve_machine_t mach, size_t pc,
+			    char const *what);
+void mu_i_sv_trace (mu_sieve_machine_t mach, const char *what);
 
 void mu_i_sv_argf (mu_stream_t str, mu_list_t list);
 void mu_i_sv_valf (mu_stream_t str, mu_sieve_value_t *val);
diff --git a/libmu_sieve/tests.c b/libmu_sieve/tests.c
index 03b40d7..0713373 100644
--- a/libmu_sieve/tests.c
+++ b/libmu_sieve/tests.c
@@ -64,19 +64,18 @@ struct address_closure
 };  
 
 static int
-do_count (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags,
-	  size_t count, int retval)
+do_count (mu_sieve_machine_t mach, size_t count, int retval)
 {
   char *relcmp;
   
-  if (mu_sieve_tag_lookup (mach, tags, "count", SVT_STRING, &relcmp))
+  if (mu_sieve_get_tag (mach, "count", SVT_STRING, &relcmp))
     {
       size_t limit;
       char *str;
       mu_list_t list;
       mu_sieve_relcmpn_t stest;
       
-      mu_sieve_value_get (mach, args, 1, SVT_STRING_LIST, &list);
+      mu_sieve_get_arg (mach, 1, SVT_STRING_LIST, &list);
       mu_list_get (list, 0, (void **) &str);
       limit = strtoul (str, &str, 10);
 
@@ -110,27 +109,28 @@ retrieve_address (void *item, void *data, int idx, char **pval)
 }
 
 int
-sieve_test_address (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_test_address (mu_sieve_machine_t mach)
 {
   mu_sieve_value_t *h, *v;
   mu_header_t header = NULL;
-  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags);
-  mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach, tags);
+  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach);
+  mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach);
   struct address_closure clos;
   int rc;
   size_t count;
   
-  h = mu_sieve_value_get_untyped (mach, args, 0);
-  v = mu_sieve_value_get_untyped (mach, args, 1);
+  h = mu_sieve_get_arg_untyped (mach, 0);
+  v = mu_sieve_get_arg_untyped (mach, 1);
 
   mu_message_get_header (mu_sieve_get_message (mach), &header);
   clos.data = header;
-  clos.aget = sieve_get_address_part (tags);
+  clos.aget = sieve_get_address_part (mach->tag_list);
   clos.addr = NULL;
-  rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_address, &clos, &count);
+  rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_address, &clos,
+			       &count);
   mu_address_destroy (&clos.addr);
   
-  return do_count (mach, args, tags, count, rc);
+  return do_count (mach, count, rc);
 }
 
 struct header_closure
@@ -164,18 +164,18 @@ retrieve_header (void *item, void *data, int idx, char **pval)
 }
 
 int
-sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_test_header (mu_sieve_machine_t mach)
 {
   mu_sieve_value_t *h, *v;
-  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags);
-  mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach, tags);
+  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach);
+  mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach);
   size_t count, mcount = 0;
   struct header_closure clos;
   
-  h = mu_sieve_value_get_untyped (mach, args, 0);
-  v = mu_sieve_value_get_untyped (mach, args, 1);
+  h = mu_sieve_get_arg_untyped (mach, 0);
+  v = mu_sieve_get_arg_untyped (mach, 1);
 
-  if (mu_sieve_tag_lookup (mach, tags, "mime", SVT_VOID, NULL))
+  if (mu_sieve_get_tag (mach, "mime", SVT_VOID, NULL))
     {
       int ismime = 0;
 
@@ -204,7 +204,7 @@ sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 			      &count))
     return 1;
 
-  return do_count (mach, args, tags, count + mcount, 0);
+  return do_count (mach, count + mcount, 0);
 }
 
 int
@@ -235,39 +235,39 @@ retrieve_envelope (void *item, void *data, int idx, char **pval)
 }
 
 int
-sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_test_envelope (mu_sieve_machine_t mach)
 {
   mu_sieve_value_t *h, *v;
-  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags);
-  mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach, tags);
+  mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach);
+  mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach);
   struct address_closure clos;
   int rc;
   size_t count;
   
-  h = mu_sieve_value_get_untyped (mach, args, 0);
-  v = mu_sieve_value_get_untyped (mach, args, 1);
+  h = mu_sieve_get_arg_untyped (mach, 0);
+  v = mu_sieve_get_arg_untyped (mach, 1);
 
-  mu_message_get_envelope (mu_sieve_get_message (mach), 
-                           (mu_envelope_t*)&clos.data);
-  clos.aget = sieve_get_address_part (tags);
+  mu_message_get_envelope (mu_sieve_get_message (mach),
+			   (mu_envelope_t*)&clos.data);
+  clos.aget = sieve_get_address_part (mach->tag_list);
   clos.addr = NULL;
   rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_envelope, &clos,
-			    &count);
+			       &count);
   mu_address_destroy (&clos.addr);
-  return do_count (mach, args, tags, count, rc);
+  return do_count (mach, count, rc);
 }
 
 int
-sieve_test_size (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_test_size (mu_sieve_machine_t mach)
 {
   int rc = 1;
   mu_sieve_runtime_tag_t *tag = NULL;
   size_t size;
   size_t arg;
   
-  mu_sieve_value_get (mach, args, 0, SVT_NUMBER, &arg);
+  mu_sieve_get_arg (mach, 0, SVT_NUMBER, &arg);
   mu_message_size (mu_sieve_get_message (mach), &size);
-  mu_list_get (tags, 0, (void **)&tag);
+  mu_list_get (mach->tag_list, 0, (void **)&tag);
   if (!tag)
     rc = size == arg;
   else if (strcmp (tag->tag, "over") == 0)
@@ -288,13 +288,13 @@ _test_exists (void *item, void *data)
 }
   
 int
-sieve_test_exists (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
+sieve_test_exists (mu_sieve_machine_t mach)
 {
   mu_header_t header = NULL;
   mu_sieve_value_t *val;   
 
   mu_message_get_header (mu_sieve_get_message (mach), &header);
-  val = mu_sieve_value_get_untyped (mach, args, 0);
+  val = mu_sieve_get_arg_untyped (mach, 0);
   return mu_sieve_vlist_do (val, _test_exists, header) == 0;
 }
 
diff --git a/libmu_sieve/util.c b/libmu_sieve/util.c
index adc737e..27c7d70 100644
--- a/libmu_sieve/util.c
+++ b/libmu_sieve/util.c
@@ -177,11 +177,10 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data)
 }
 
 mu_sieve_value_t *
-mu_sieve_value_get_untyped (mu_sieve_machine_t mach, mu_list_t vlist,
-			    size_t index)
+mu_sieve_get_arg_untyped (mu_sieve_machine_t mach, size_t index)
 {
   mu_sieve_value_t *val = NULL;
-  int rc = mu_list_get (vlist, index, (void **)&val);
+  int rc = mu_list_get (mach->arg_list, index, (void **)&val);
   if (rc)
     {
       mu_sieve_error (mach, _("can't get argument %zu: %s"),
@@ -192,11 +191,10 @@ mu_sieve_value_get_untyped (mu_sieve_machine_t mach, mu_list_t vlist,
 }
 
 mu_sieve_value_t *
-mu_sieve_value_get_optional (mu_sieve_machine_t mach, mu_list_t vlist,
-			     size_t index)
+mu_sieve_get_arg_optional (mu_sieve_machine_t mach, size_t index)
 {
   mu_sieve_value_t *val = NULL;
-  int rc = mu_list_get (vlist, index, (void **)&val);
+  int rc = mu_list_get (mach->arg_list, index, (void **)&val);
   if (rc == MU_ERR_NOENT)
     return NULL;
   else if (rc)
@@ -209,11 +207,10 @@ mu_sieve_value_get_optional (mu_sieve_machine_t mach, mu_list_t vlist,
 }  
 
 int
-mu_sieve_value_get (mu_sieve_machine_t mach, mu_list_t vlist,
-		    size_t index,
-		    mu_sieve_data_type type, void *ret)
+mu_sieve_get_arg (mu_sieve_machine_t mach, size_t index,
+		  mu_sieve_data_type type, void *ret)
 {
-  mu_sieve_value_t *val = mu_sieve_value_get_untyped (mach, vlist, index);
+  mu_sieve_value_t *val = mu_sieve_get_arg_untyped (mach, index);
   if (val->type != type)
     {
       mu_sieve_error (mach,
@@ -325,8 +322,7 @@ mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...)
 void
 mu_i_sv_debug_command (mu_sieve_machine_t mach,
 		       size_t pc,
-		       char const *what,
-		       mu_list_t taglist, mu_list_t arglist)
+		       char const *what)
 {
   if (mach->state_flags & MU_SV_SAVED_DBG_STATE)
     {
@@ -344,14 +340,13 @@ mu_i_sv_debug_command (mu_sieve_machine_t mach,
     }
   mu_stream_printf (mach->dbgstream, "%4zu: %s: %s",
 		    pc, what, mach->identifier);  
-  mu_i_sv_tagf (mach->dbgstream, taglist);
-  mu_i_sv_argf (mach->dbgstream, arglist);
+  mu_i_sv_tagf (mach->dbgstream, mach->tag_list);
+  mu_i_sv_argf (mach->dbgstream, mach->arg_list);
   mu_stream_write (mach->dbgstream, "\n", 1, NULL);
 }
 
 void
-mu_i_sv_trace (mu_sieve_machine_t mach, const char *what,
-	       mu_list_t taglist, mu_list_t arglist)
+mu_i_sv_trace (mu_sieve_machine_t mach, const char *what)
 {
   if (!mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE4))
     return;
@@ -365,8 +360,8 @@ mu_i_sv_trace (mu_sieve_machine_t mach, const char *what,
 		      mach->locus.mu_line);
   mu_stream_printf (mach->errstream, "%zu: %s %s", mach->msgno, what,
 		    mach->identifier);
-  mu_i_sv_tagf (mach->errstream, taglist);
-  mu_i_sv_argf (mach->errstream, arglist);
+  mu_i_sv_tagf (mach->errstream, mach->tag_list);
+  mu_i_sv_argf (mach->errstream, mach->arg_list);
   mu_stream_printf (mach->errstream, "\n");
 }
 
@@ -401,13 +396,13 @@ tag_finder (void *item, void *data)
 }
 
 int
-mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist,
-			     char *name, mu_sieve_value_t **ret)
+mu_sieve_get_tag_untyped (mu_sieve_machine_t mach, 
+			  char *name, mu_sieve_value_t **ret)
 {
   mu_sieve_runtime_tag_t t;
 
   t.tag = name;
-  if (taglist && mu_list_foreach (taglist, tag_finder, &t))
+  if (mach->tag_list && mu_list_foreach (mach->tag_list, tag_finder, &t))
     {
       if (ret)
 	*ret = t.arg;
@@ -417,12 +412,12 @@ mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist,
 }
 
 int
-mu_sieve_tag_lookup (mu_sieve_machine_t mach, mu_list_t taglist,
-		     char *name, mu_sieve_data_type type,
-		     void *ret)
+mu_sieve_get_tag (mu_sieve_machine_t mach, 
+		  char *name, mu_sieve_data_type type,
+		  void *ret)
 {
   mu_sieve_value_t *val;
-  int found = mu_sieve_tag_lookup_untyped (mach, taglist, name, &val);
+  int found = mu_sieve_get_tag_untyped (mach, name, &val);
 
   if (found)
     {


hooks/post-receive
-- 
GNU Mailutils


