From MAILER-DAEMON Tue Dec 01 08:22:19 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NFSgN-0002Bn-95
	for mharc-commit-mailutils@gnu.org; Tue, 01 Dec 2009 08:22:19 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NFSgK-00028b-Fe
	for commit-mailutils@gnu.org; Tue, 01 Dec 2009 08:22:16 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NFSgJ-000277-BI
	for commit-mailutils@gnu.org; Tue, 01 Dec 2009 08:22:15 -0500
Received: from [199.232.76.173] (port=40451 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NFSgJ-00026o-27
	for commit-mailutils@gnu.org; Tue, 01 Dec 2009 08:22:15 -0500
Received: from savannah.gnu.org ([199.232.41.3]:52209 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <INVALID.NOREPLY@gnu.org>)
	id 1NFSgI-0007jo-NZ
	for commit-mailutils@gnu.org; Tue, 01 Dec 2009 08:22:14 -0500
Received: from [10.1.0.109] (helo=cvs.savannah.gnu.org)
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NFSgH-0003bE-FN
	for commit-mailutils@gnu.org; Tue, 01 Dec 2009 13:22:13 +0000
Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NFSgG-0003ae-8y
	for commit-mailutils@gnu.org; Tue, 01 Dec 2009 13:22:13 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 8594f053df8ed4de9735f40355fd5608eab1cfb9
X-Git-Newrev: 34bbf3cc3526975957cc22345f63849c66742a75
Message-Id: <E1NFSgG-0003ae-8y@cvs.savannah.gnu.org>
Date: Tue, 01 Dec 2009 13:22:12 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-14-g34bbf3c
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Dec 2009 13:22: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=34bbf3cc3526975957cc22345f63849c66742a75

The branch, master has been updated
       via  34bbf3cc3526975957cc22345f63849c66742a75 (commit)
      from  8594f053df8ed4de9735f40355fd5608eab1cfb9 (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 34bbf3cc3526975957cc22345f63849c66742a75
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Dec 1 15:23:02 2009 +0200

    Fix reusability of smtp mailers.
    
    * libproto/mailer/smtp.c (_smtp_set_rcpt): Initialize smtp->ptr to
    smtp->buffer, not NULL.
    (smtp_close): Reset smtp->state.

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

Summary of changes:
 libproto/mailer/smtp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/libproto/mailer/smtp.c b/libproto/mailer/smtp.c
index 752198d..f78890a 100644
--- a/libproto/mailer/smtp.c
+++ b/libproto/mailer/smtp.c
@@ -200,7 +200,7 @@ static int      _smtp_set_rcpt (smtp_t, mu_message_t, mu_address_t);
 static void
 CLEAR_STATE (smtp_t smtp)
 {
-  smtp->ptr = NULL;
+  smtp->ptr = smtp->buffer;
   smtp->nl = NULL;
   smtp->s_offset = 0;
 
@@ -559,6 +559,7 @@ smtp_close (mu_mailer_t mailer)
     default:
       break;
     }
+  smtp->state = SMTP_NO_STATE;
   return mu_stream_close (mailer->stream);
 }
 


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Wed Dec 02 14:43:34 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NFv6s-0000r2-N0
	for mharc-commit-mailutils@gnu.org; Wed, 02 Dec 2009 14:43:34 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NFv6p-0000n8-CS
	for commit-mailutils@gnu.org; Wed, 02 Dec 2009 14:43:31 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NFv6o-0000lm-AY
	for commit-mailutils@gnu.org; Wed, 02 Dec 2009 14:43:30 -0500
Received: from [199.232.76.173] (port=38938 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NFv6o-0000lP-2Q
	for commit-mailutils@gnu.org; Wed, 02 Dec 2009 14:43:30 -0500
Received: from savannah.gnu.org ([199.232.41.3]:43720 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <INVALID.NOREPLY@gnu.org>)
	id 1NFv6n-0005GQ-Rk
	for commit-mailutils@gnu.org; Wed, 02 Dec 2009 14:43:29 -0500
Received: from [10.1.0.109] (helo=cvs.savannah.gnu.org)
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NFv6m-0007VO-Mo
	for commit-mailutils@gnu.org; Wed, 02 Dec 2009 19:43:28 +0000
Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NFv6m-0007Up-8B
	for commit-mailutils@gnu.org; Wed, 02 Dec 2009 19:43:28 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 34bbf3cc3526975957cc22345f63849c66742a75
X-Git-Newrev: b66ffedcecf7506efc8631dfe1047c0a1d28af80
Message-Id: <E1NFv6m-0007Up-8B@cvs.savannah.gnu.org>
Date: Wed, 02 Dec 2009 19:43:28 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-15-gb66ffed
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Dec 2009 19: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=b66ffedcecf7506efc8631dfe1047c0a1d28af80

The branch, master has been updated
       via  b66ffedcecf7506efc8631dfe1047c0a1d28af80 (commit)
      from  34bbf3cc3526975957cc22345f63849c66742a75 (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 b66ffedcecf7506efc8631dfe1047c0a1d28af80
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Dec 2 21:43:14 2009 +0200

    Bugfix.
    
    * libproto/mailer/smtp.c (smtp_open): Don't issue second
    EHLO if STARTTLS failed.

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

Summary of changes:
 libproto/mailer/smtp.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/libproto/mailer/smtp.c b/libproto/mailer/smtp.c
index f78890a..1573a65 100644
--- a/libproto/mailer/smtp.c
+++ b/libproto/mailer/smtp.c
@@ -488,12 +488,9 @@ smtp_open (mu_mailer_t mailer, int flags)
 
     case SMTP_STARTTLS:
     case SMTP_STARTTLS_ACK:
-      if (smtp->capa & CAPA_STARTTLS)
-	{
-	  smtp_starttls (smtp);
-	  goto ehlo;
-	}
-
+      if ((smtp->capa & CAPA_STARTTLS) && smtp_starttls (smtp) == 0)
+	goto ehlo;
+      
     case SMTP_AUTH:
     case SMTP_AUTH_ACK:
       if (smtp->capa & CAPA_AUTH)


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Tue Dec 15 17:01:08 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NKfS8-0006yW-1B
	for mharc-commit-mailutils@gnu.org; Tue, 15 Dec 2009 17:01:08 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NKfS6-0006xe-1J
	for commit-mailutils@gnu.org; Tue, 15 Dec 2009 17:01:06 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NKfS4-0006x2-Km
	for commit-mailutils@gnu.org; Tue, 15 Dec 2009 17:01:05 -0500
Received: from [199.232.76.173] (port=39218 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NKfS4-0006wu-Dy
	for commit-mailutils@gnu.org; Tue, 15 Dec 2009 17:01:04 -0500
Received: from savannah.gnu.org ([199.232.41.3]:34083 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <INVALID.NOREPLY@gnu.org>)
	id 1NKfS3-0005ro-Sv
	for commit-mailutils@gnu.org; Tue, 15 Dec 2009 17:01:04 -0500
Received: from [10.1.0.109] (helo=cvs.savannah.gnu.org)
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NKfS2-00068s-Fy
	for commit-mailutils@gnu.org; Tue, 15 Dec 2009 22:01:02 +0000
Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NKfS1-00068H-8X
	for commit-mailutils@gnu.org; Tue, 15 Dec 2009 22:01:02 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b66ffedcecf7506efc8631dfe1047c0a1d28af80
X-Git-Newrev: 96dc9ab99e9518f5f21a7710e396da8c3fd833b5
Message-Id: <E1NKfS1-00068H-8X@cvs.savannah.gnu.org>
Date: Tue, 15 Dec 2009 22:01:01 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-16-g96dc9ab
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 15 Dec 2009 22:01:06 -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=96dc9ab99e9518f5f21a7710e396da8c3fd833b5

The branch, master has been updated
       via  96dc9ab99e9518f5f21a7710e396da8c3fd833b5 (commit)
      from  b66ffedcecf7506efc8631dfe1047c0a1d28af80 (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 96dc9ab99e9518f5f21a7710e396da8c3fd833b5
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Dec 16 00:02:14 2009 +0200

    Add TLS to MH.  Handle --debug-level and --debug-line-info options.
    
    * mailbox/mbx_default.c (attach_auth_ticket): Do not
    proceed if auth is NULL.
    * mh/mh_getopt.h (struct mh_argp_data): Change return type
    and signature of handler.
    (mh_argp_parse): Likewise.
    * mh/mh_argp.c (parse_opt): Rewrite using new
    handler prototype.
    (mh_argp_parse): Use new hanlder type.
    Assign argp children.
    
    * mh/mh_init.c (mh_init): Call mu_init_tls_libs.
    
    * mh/ali.c: Update opt_handler
    * mh/anno.c: Update opt_handler
    * mh/burst.c: Update opt_handler
    * mh/comp.c: Update opt_handler
    * mh/fmtcheck.c: Update opt_handler
    * mh/folder.c: Update opt_handler
    * mh/forw.c: Update opt_handler
    * mh/inc.c: Update opt_handler
    * mh/install-mh.c: Update opt_handler
    * mh/mark.c: Update opt_handler
    * mh/mhl.c: Update opt_handler
    * mh/mhn.c: Update opt_handler
    * mh/mhparam.c: Update opt_handler
    * mh/mhpath.c: Update opt_handler
    * mh/pick.c: Update opt_handler
    * mh/refile.c: Update opt_handler
    * mh/repl.c: Update opt_handler
    * mh/rmf.c: Update opt_handler
    * mh/rmm.c: Update opt_handler
    * mh/scan.c: Update opt_handler
    * mh/send.c: Update opt_handler
    * mh/sortm.c: Update opt_handler
    * mh/whatnow.c: Update opt_handler
    * mh/whom.c: Update opt_handler

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

Summary of changes:
 mailbox/mbx_default.c |    3 +-
 mh/ali.c              |    6 ++--
 mh/anno.c             |    6 ++--
 mh/burst.c            |    6 ++--
 mh/comp.c             |    6 ++--
 mh/fmtcheck.c         |    6 ++--
 mh/folder.c           |    4 +-
 mh/forw.c             |    4 +-
 mh/inc.c              |    6 ++--
 mh/install-mh.c       |    6 ++--
 mh/mark.c             |    6 ++--
 mh/mh_argp.c          |   70 ++++++++++++++++++++++++++++++++++++++++--------
 mh/mh_getopt.h        |    5 ++-
 mh/mh_init.c          |    4 +++
 mh/mhl.c              |    6 ++--
 mh/mhn.c              |    6 ++--
 mh/mhparam.c          |    6 ++--
 mh/mhpath.c           |    6 ++--
 mh/pick.c             |    6 ++--
 mh/refile.c           |    4 +-
 mh/repl.c             |    6 ++--
 mh/rmf.c              |    6 ++--
 mh/rmm.c              |    6 ++--
 mh/scan.c             |    6 ++--
 mh/send.c             |    6 ++--
 mh/sortm.c            |    6 ++--
 mh/whatnow.c          |    6 ++--
 mh/whom.c             |    6 ++--
 28 files changed, 136 insertions(+), 84 deletions(-)

diff --git a/mailbox/mbx_default.c b/mailbox/mbx_default.c
index 50588f5..ef2089a 100644
--- a/mailbox/mbx_default.c
+++ b/mailbox/mbx_default.c
@@ -340,7 +340,8 @@ attach_auth_ticket (mu_mailbox_t mbox)
   mu_authority_t auth = NULL;
 
   if (mu_mailbox_get_folder (mbox, &folder) == 0
-      && mu_folder_get_authority (folder, &auth) == 0)
+      && mu_folder_get_authority (folder, &auth) == 0
+      && auth)
     {
       char *filename = mu_tilde_expansion (mu_ticket_file, "/", NULL);
       mu_wicket_t wicket;
diff --git a/mh/ali.c b/mh/ali.c
index ef8e81b..ed2709e 100644
--- a/mh/ali.c
+++ b/mh/ali.c
@@ -64,8 +64,8 @@ static int user_mode;
 static int normalize_mode;
 static int nolist_mode;
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -94,7 +94,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/anno.c b/mh/anno.c
index 8d0b7ff..397c0e8 100644
--- a/mh/anno.c
+++ b/mh/anno.c
@@ -58,8 +58,8 @@ static int anno_date = 1; /* Add date to the annotation */
 static char *component;   /* header field */
 static char *anno_text;   /* header field value */
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -96,7 +96,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/burst.c b/mh/burst.c
index e78f55c..4f93ed1 100644
--- a/mh/burst.c
+++ b/mh/burst.c
@@ -69,8 +69,8 @@ int eb_min_length = 1;  /* Minimal length of encapsulation boundary */
 
 #define VERBOSE(c) do { if (verbose) { printf c; putchar ('\n'); } } while (0)
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -121,7 +121,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
       
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/comp.c b/mh/comp.c
index c5f526d..f0a58e0 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -83,8 +83,8 @@ static int build_only = 0; /* --build flag */
 static int use_draft = 0;  /* --use flag */
 static char *draftmessage = "new";
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -148,7 +148,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/fmtcheck.c b/mh/fmtcheck.c
index ae8ea53..2a01440 100644
--- a/mh/fmtcheck.c
+++ b/mh/fmtcheck.c
@@ -68,8 +68,8 @@ action_dump ()
 
 static action_fp action = action_dump;
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -94,7 +94,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/folder.c b/mh/folder.c
index 1d51f52..a9fdf7a 100644
--- a/mh/folder.c
+++ b/mh/folder.c
@@ -136,7 +136,7 @@ size_t max_depth = 1;  /* Maximum recursion depth (0 means infinity) */
 #define OPTION_IS_SET(opt) ((opt) == -1 ? show_all : opt)
 
 static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -234,7 +234,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
       
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/forw.c b/mh/forw.c
index a33a8f0..7d5c395 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -117,7 +117,7 @@ static mh_msgset_t msgset;
 static mu_mailbox_t mbox;
 
 static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -214,7 +214,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/inc.c b/mh/inc.c
index d1c0c9e..841636c 100644
--- a/mh/inc.c
+++ b/mh/inc.c
@@ -79,8 +79,8 @@ static int truncate_source = -1;
 static int quiet = 0;
 static const char *append_folder;
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -147,7 +147,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/install-mh.c b/mh/install-mh.c
index 0104ea0..68d3c72 100644
--- a/mh/install-mh.c
+++ b/mh/install-mh.c
@@ -40,8 +40,8 @@ struct mh_option mh_option[] = {
 
 int automode;
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -57,7 +57,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/mark.c b/mh/mark.c
index 0f41020..5e2b3a8 100644
--- a/mh/mark.c
+++ b/mh/mark.c
@@ -75,8 +75,8 @@ add_sequence (char *name)
   mu_list_append (seq_list, name);
 }
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -121,7 +121,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/mh_argp.c b/mh/mh_argp.c
index 1144ed5..be989a2 100644
--- a/mh/mh_argp.c
+++ b/mh/mh_argp.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005,
-   2006, 2007 Free Software Foundation, Inc.
+   2006, 2007, 2009 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
@@ -33,26 +33,25 @@ static error_t
 parse_opt (int key, char *arg, struct argp_state *state)
 {
   struct mh_argp_data *data = state->input;
+  error_t ret = ARGP_ERR_UNKNOWN;
+  
   switch (key)
     {
     case ARGP_KEY_ARG:
       if (arg[0] == '+')
-	{
-	  data->handler (ARG_FOLDER, arg + 1, data->closure);
-	  break;
-	}
-      return ARGP_ERR_UNKNOWN;
-
+	ret = data->handler (ARG_FOLDER, arg + 1, state);
+      break;
+      
     default:
-      if (data->handler (key, arg, data->closure, state) == 0)
+      ret = data->handler (key, arg, state);
+      if (ret == 0)
 	{
 	  if (key == ARGP_KEY_ERROR)
 	    data->errind = state->next;
-	  break;
 	}
-      return ARGP_ERR_UNKNOWN;
     }
-  return 0;
+
+  return ret;
 }
 
 static int
@@ -101,13 +100,59 @@ mh_argp_init (const char *vers)
   argp_program_bug_address =  "<" PACKAGE_BUGREPORT ">";
 }
 
+
+enum
+  {
+    OPT_DEBUG_LEVEL = 256,
+    OPT_DEBUG_LINE_INFO,
+  };
+
+static struct argp_option mu_debug_argp_options[] = 
+{
+  { "debug-level", OPT_DEBUG_LEVEL, N_("LEVEL"), 0,
+    N_("set Mailutils debugging level"), 0 },
+  { "debug-line-info", OPT_DEBUG_LINE_INFO, NULL, 0,
+    N_("show source info with debugging messages"), 0 },
+  { NULL }
+};
+
+static error_t
+mu_debug_argp_parser (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+    case OPT_DEBUG_LEVEL:
+      mu_global_debug_from_string (arg, "command line");
+      break;
+
+    case OPT_DEBUG_LINE_INFO:
+      mu_debug_line_info = 1;
+      break;
+      
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+struct argp mu_debug_argp = {
+  mu_debug_argp_options,
+  mu_debug_argp_parser,
+};
+
+struct argp_child mh_argp_children[] = {
+  { &mu_debug_argp, 0, N_("Global debugging settings"), 0 },
+  { NULL }
+};
+
 int
 mh_argp_parse (int *pargc, char **pargv[],
 	       int flags,
 	       struct argp_option *option,
 	       struct mh_option *mh_option,
 	       char *argp_doc, char *doc,
-	       int (*handler)(), void *closure, int *pindex)
+	       argp_parser_t handler,
+	       void *closure, int *pindex)
 {
   struct argp argp;
   struct mh_argp_data data;
@@ -123,6 +168,7 @@ mh_argp_parse (int *pargc, char **pargv[],
   argp.parser = parse_opt;
   argp.args_doc = argp_doc;
   argp.doc = doc;
+  argp.children = mh_argp_children;
   data.mh_option = mh_option;
   data.closure = closure;
   data.handler = handler;
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index eabf983..710da5b 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -34,7 +34,7 @@ struct mh_option
 struct mh_argp_data
 {
   struct mh_option *mh_option;
-  int (*handler)();
+  argp_parser_t handler;
   int errind;
   void *closure;
   char *doc;
@@ -190,7 +190,8 @@ int mh_argp_parse (int *argc, char **argv[],
 		   struct argp_option *option,
 		   struct mh_option *mh_option,
 		   char *argp_doc, char *doc,
-		   int (*handler)(), void *closure, int *index);
+		   argp_parser_t handler,
+		   void *closure, int *index);
 
 void mh_help (struct mh_option *mh_option, const char *doc);
 void mh_license (const char *name);
diff --git a/mh/mh_init.c b/mh/mh_init.c
index 3cb48c8..3594374 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -21,6 +21,7 @@
 
 #include <mh.h>
 #include <mailutils/url.h>
+#include <mailutils/tls.h>
 #include <pwd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -46,6 +47,9 @@ mh_init ()
 {
   /* Register all mailbox and mailer formats */
   mu_register_all_formats ();
+#ifdef WITH_TLS
+  mu_init_tls_libs ();
+#endif
 
   /* Read user's profile */
   mh_read_profile ();
diff --git a/mh/mhl.c b/mh/mhl.c
index 8bc7bd5..5181c9c 100644
--- a/mh/mhl.c
+++ b/mh/mhl.c
@@ -75,8 +75,8 @@ static int nomoreproc;
 
 static mu_list_t format;
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -137,7 +137,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/mhn.c b/mh/mhn.c
index 8f8f102..766b8fc 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -242,8 +242,8 @@ _get_content_encoding (mu_header_t hdr, char **value)
   return 0;
 }
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -398,7 +398,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/mhparam.c b/mh/mhparam.c
index ad56c43..ff444f1 100644
--- a/mh/mhparam.c
+++ b/mh/mhparam.c
@@ -46,8 +46,8 @@ struct mh_option mh_option[] = {
 static int display_all;
 static int display_comp_name = -1;
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -64,7 +64,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/mhpath.c b/mh/mhpath.c
index 13d5b1d..483da34 100644
--- a/mh/mhpath.c
+++ b/mh/mhpath.c
@@ -39,8 +39,8 @@ struct mh_option mh_option[] = {
   { 0 }
 };
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -53,7 +53,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/pick.c b/mh/pick.c
index dc1ce76..b145dec 100644
--- a/mh/pick.c
+++ b/mh/pick.c
@@ -143,8 +143,8 @@ add_sequence (char *name)
   mu_list_append (seq_list, name);
 }
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   char *s, *p;
   
@@ -291,7 +291,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
 
   return 0;
diff --git a/mh/refile.c b/mh/refile.c
index b6d12db..26b66a5 100644
--- a/mh/refile.c
+++ b/mh/refile.c
@@ -151,7 +151,7 @@ close_folders ()
 }
 
 static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -184,7 +184,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/repl.c b/mh/repl.c
index e501fef..712595f 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -138,8 +138,8 @@ decode_cc_flag (const char *opt, const char *arg)
   return rc;
 }
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   char *s;
   
@@ -271,7 +271,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
       
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/rmf.c b/mh/rmf.c
index fea2b16..ed1dc90 100644
--- a/mh/rmf.c
+++ b/mh/rmf.c
@@ -64,8 +64,8 @@ static char *cur_folder_path; /* Full pathname of the current folder */
 static char *folder_name;     /* Name of the (topmost) folder to be
 				 deleted */
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -95,7 +95,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/rmm.c b/mh/rmm.c
index ad39d9b..665dbbd 100644
--- a/mh/rmm.c
+++ b/mh/rmm.c
@@ -39,8 +39,8 @@ struct mh_option mh_option[] = {
   { 0 }
 };
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -53,7 +53,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/scan.c b/mh/scan.c
index 825956e..238149c 100644
--- a/mh/scan.c
+++ b/mh/scan.c
@@ -87,8 +87,8 @@ void list_message (mu_mailbox_t mbox, mu_message_t msg, size_t num, void *data);
 void print_header (mu_mailbox_t mbox);
 void clear_screen (void);
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -142,7 +142,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
       
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/send.c b/mh/send.c
index 3088cff..e3331fb 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -131,8 +131,8 @@ static int keep_files;           /* Keep draft files */
     watch_printf c;\
 } while (0)
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   char *p;
   
@@ -257,7 +257,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/sortm.c b/mh/sortm.c
index 7649e2e..8f5d467 100644
--- a/mh/sortm.c
+++ b/mh/sortm.c
@@ -116,8 +116,8 @@ static int comp_text (void *a, void *b);
 static int comp_date (void *a, void *b);
 static int comp_number (void *a, void *b);
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -196,7 +196,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/whatnow.c b/mh/whatnow.c
index aa3f07a..e45161d 100644
--- a/mh/whatnow.c
+++ b/mh/whatnow.c
@@ -57,8 +57,8 @@ struct mh_whatnow_env wh_env = { 0 };
 static int initial_edit = 1;
 static char *draftmessage = "cur";
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -96,7 +96,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }
diff --git a/mh/whom.c b/mh/whom.c
index 689e91a..eabe2fe 100644
--- a/mh/whom.c
+++ b/mh/whom.c
@@ -60,8 +60,8 @@ static int check_recipients;
 static int use_draft;            /* Use the prepared draft */
 static const char *draft_folder; /* Use this draft folder */
 
-static int
-opt_handler (int key, char *arg, void *unused, struct argp_state *state)
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
@@ -100,7 +100,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
       break;
 
     default:
-      return 1;
+      return ARGP_ERR_UNKNOWN;
     }
   return 0;
 }


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Wed Dec 16 06:05:20 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NKrh1-0001Rt-T5
	for mharc-commit-mailutils@gnu.org; Wed, 16 Dec 2009 06:05:19 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NKrgz-0001Q5-5N
	for commit-mailutils@gnu.org; Wed, 16 Dec 2009 06:05:17 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NKrgv-0001Nb-QV
	for commit-mailutils@gnu.org; Wed, 16 Dec 2009 06:05:16 -0500
Received: from [199.232.76.173] (port=55027 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NKrgv-0001NJ-Ia
	for commit-mailutils@gnu.org; Wed, 16 Dec 2009 06:05:13 -0500
Received: from savannah.gnu.org ([199.232.41.3]:59021 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <INVALID.NOREPLY@gnu.org>)
	id 1NKrgu-0001uw-06
	for commit-mailutils@gnu.org; Wed, 16 Dec 2009 06:05:12 -0500
Received: from [10.1.0.109] (helo=cvs.savannah.gnu.org)
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NKrgt-0004qc-1o
	for commit-mailutils@gnu.org; Wed, 16 Dec 2009 11:05:11 +0000
Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NKrgs-0004pu-Am
	for commit-mailutils@gnu.org; Wed, 16 Dec 2009 11:05:10 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 96dc9ab99e9518f5f21a7710e396da8c3fd833b5
X-Git-Newrev: a600395e1fe66e0a116827f17f9bd864d4554585
Message-Id: <E1NKrgs-0004pu-Am@cvs.savannah.gnu.org>
Date: Wed, 16 Dec 2009 11:05:10 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-17-ga600395
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 16 Dec 2009 11:05:17 -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=a600395e1fe66e0a116827f17f9bd864d4554585

The branch, master has been updated
       via  a600395e1fe66e0a116827f17f9bd864d4554585 (commit)
      from  96dc9ab99e9518f5f21a7710e396da8c3fd833b5 (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 a600395e1fe66e0a116827f17f9bd864d4554585
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Dec 16 13:06:22 2009 +0200

    Fix format specifiers and usage of const char* arguments/variables.
    
    Affected files:
    
    * comsat/comsat.c
    * examples/header.c
    * examples/mailcap.c
    * examples/pop3client.c
    * examples/url-parse.c
    * imap4d/fetch.c
    * imap4d/id.c
    * imap4d/list.c
    * imap4d/select.c
    * imap4d/status.c
    * imap4d/store.c
    * imap4d/sync.c
    * imap4d/util.c
    * include/mailutils/sieve.h
    * libmu_argp/common.c
    * libmu_argp/muinit.c
    * libmu_sieve/actions.c
    * libmu_sieve/extensions/pipe.c
    * libmu_sieve/extensions/vacation.c
    * libmu_sieve/prog.c
    * libmu_sieve/require.c
    * libmu_sieve/runtime.c
    * libmu_sieve/sieve-priv.h
    * libmu_sieve/sieve.y
    * libproto/imap/folder.c
    * libproto/imap/mbox.c
    * libproto/mailer/sendmail.c
    * libproto/mbox/mbox.c
    * libproto/pop/pop3_list.c
    * libproto/pop/pop3_stat.c
    * maidag/lmtp.c
    * maidag/sieve.c
    * mail/copy.c
    * mail/decode.c
    * mail/envelope.c
    * mail/eq.c
    * mail/escape.c
    * mail/from.c
    * mail/mail.h
    * mail/mailline.c
    * mail/mailvar.c
    * mail/size.c
    * mail/util.c
    * mail/write.c
    * mailbox/cfg_format.c
    * mailbox/folder.c
    * mailbox/parse822.c
    * mailbox/system.c
    * messages/messages.c
    * mh/folder.c
    * mh/forw.c
    * mh/inc.c
    * mh/mh.h
    * mh/mh_alias.l
    * mh/mh_fmtgram.y
    * mh/mh_getopt.h
    * mh/mh_init.c
    * mh/mh_msgset.c
    * mh/mh_whatnow.c
    * mh/mhn.c
    * mh/pick.y
    * mimeview/mimetypes.y
    * python/libmu_py/debug.c
    * sieve/sieve.c

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

Summary of changes:
 comsat/comsat.c                   |    2 +-
 examples/header.c                 |    4 +-
 examples/mailcap.c                |    5 ++-
 examples/pop3client.c             |    9 +++---
 examples/url-parse.c              |    4 +-
 imap4d/fetch.c                    |    4 +-
 imap4d/id.c                       |    2 +-
 imap4d/list.c                     |    2 +-
 imap4d/select.c                   |    8 +++--
 imap4d/status.c                   |    8 +++---
 imap4d/store.c                    |    2 +-
 imap4d/sync.c                     |   12 +++++---
 imap4d/util.c                     |    2 +-
 include/mailutils/sieve.h         |    4 +-
 libmu_argp/common.c               |    1 +
 libmu_argp/muinit.c               |    4 ++-
 libmu_sieve/actions.c             |   51 +++++++++++++++++++------------------
 libmu_sieve/extensions/pipe.c     |   18 ++++++------
 libmu_sieve/extensions/vacation.c |   33 ++++++++++++-----------
 libmu_sieve/prog.c                |    6 ++--
 libmu_sieve/require.c             |    4 +-
 libmu_sieve/runtime.c             |    8 +++---
 libmu_sieve/sieve-priv.h          |    4 +-
 libmu_sieve/sieve.y               |    4 +-
 libproto/imap/folder.c            |   47 ++++++++++++++++++----------------
 libproto/imap/mbox.c              |    8 +++---
 libproto/mailer/sendmail.c        |    4 +-
 libproto/mbox/mbox.c              |    4 +-
 libproto/pop/pop3_list.c          |   10 ++++---
 libproto/pop/pop3_stat.c          |   10 ++++---
 maidag/lmtp.c                     |    2 +-
 maidag/sieve.c                    |    3 +-
 mail/copy.c                       |    3 +-
 mail/decode.c                     |    4 +-
 mail/envelope.c                   |    3 +-
 mail/eq.c                         |    6 ++--
 mail/escape.c                     |    3 +-
 mail/from.c                       |    4 +-
 mail/mail.h                       |    4 +-
 mail/mailline.c                   |    4 +-
 mail/mailvar.c                    |    7 +++--
 mail/size.c                       |    8 +++--
 mail/util.c                       |   14 +++++-----
 mail/write.c                      |    5 ++-
 mailbox/cfg_format.c              |    7 +++--
 mailbox/folder.c                  |    8 ++---
 mailbox/parse822.c                |    4 +-
 mailbox/system.c                  |    5 ++-
 messages/messages.c               |    4 +-
 mh/folder.c                       |    3 +-
 mh/forw.c                         |    8 +++---
 mh/inc.c                          |    8 +++---
 mh/mh.h                           |    2 +-
 mh/mh_alias.l                     |    7 +++--
 mh/mh_fmtgram.y                   |    4 +-
 mh/mh_getopt.h                    |    2 +-
 mh/mh_init.c                      |    3 +-
 mh/mh_msgset.c                    |    6 +++-
 mh/mh_whatnow.c                   |   12 ++++----
 mh/mhn.c                          |    4 +-
 mh/pick.y                         |    9 ++++--
 mimeview/mimetypes.y              |    4 +-
 python/libmu_py/debug.c           |    4 +-
 sieve/sieve.c                     |    3 +-
 64 files changed, 248 insertions(+), 213 deletions(-)

diff --git a/comsat/comsat.c b/comsat/comsat.c
index a6bbf03..de9c9cc 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -276,7 +276,7 @@ int
 comsat_main (int fd)
 {
   int rdlen;
-  int len;
+  socklen_t len;
   struct sockaddr fromaddr;
   char buffer[216]; /*FIXME: Arbitrary size */
 
diff --git a/examples/header.c b/examples/header.c
index 84e9454..d9b015a 100644
--- a/examples/header.c
+++ b/examples/header.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 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
@@ -350,7 +350,7 @@ cmd_readline (int argc, char **argv)
     abort ();
   mu_header_get_stream (header, &stream);
   mu_stream_readline (stream, buf, size, 0, &nbytes);
-  printf ("\"%*.*s\"", nbytes, nbytes, buf);
+  printf ("\"%*.*s\"", (int) nbytes, (int) nbytes, buf);
   free (buf);
 }
   
diff --git a/examples/mailcap.c b/examples/mailcap.c
index fb0a4f3..4f5c57c 100644
--- a/examples/mailcap.c
+++ b/examples/mailcap.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2004, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2004, 2007,
+   2009 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
@@ -90,7 +91,7 @@ main (int argc, char **argv)
 			    mu_strerror (status));
 		  break;
 		}
-	      printf ("\tfields[%d]: %s\n", j, buffer);
+	      printf ("\tfields[%lu]: %s\n", (unsigned long) j, buffer);
 	    }
 	  printf ("\n");
 	}
diff --git a/examples/pop3client.c b/examples/pop3client.c
index a404038..2c2199e 100644
--- a/examples/pop3client.c
+++ b/examples/pop3client.c
@@ -520,7 +520,7 @@ com_list (char *arg)
       unsigned int msgno = strtoul (arg, NULL, 10);
       status = mu_pop3_list (pop3, msgno, &size);
       if (status == 0)
-	printf ("Msg: %d Size: %d\n", msgno, size);
+	printf ("Msg: %u Size: %lu\n", msgno, (unsigned long) size);
     }
   return status;
 }
@@ -597,12 +597,13 @@ com_pass (char *arg)
 int
 com_stat (char *arg MU_ARG_UNUSED)
 {
-  unsigned count, size;
+  unsigned count = 0;
+  size_t size = 0;
   int status = 0;
 
-  count = size = 0;
   status = mu_pop3_stat (pop3, &count, &size);
-  printf ("Mesgs: %d Size %d\n", count, size);
+  printf ("Mesgs: %lu Size %lu\n",
+	  (unsigned long) count, (unsigned long) size);
   return status;
 }
 
diff --git a/examples/url-parse.c b/examples/url-parse.c
index d1a35c4..efddda6 100644
--- a/examples/url-parse.c
+++ b/examples/url-parse.c
@@ -54,7 +54,7 @@ print_fvpairs (mu_url_t url)
   if (fvc == 0)
     return;
   for (i = 0; i < fvc; i++)
-    printf ("\tparam[%d] <%s>\n", i, fvp[i]);
+    printf ("\tparam[%lu] <%s>\n", (unsigned long) i, fvp[i]);
 }
 
 static void
@@ -71,7 +71,7 @@ print_query (mu_url_t url)
   if (qargc == 0)
     return;
   for (i = 0; i < qargc; i++)
-    printf ("\tquery[%d] <%s>\n", i, qargv[i]);
+    printf ("\tquery[%lu] <%s>\n", (unsigned long) i, qargv[i]);
 }
 
 int
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 16caf33..faca25e 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -930,7 +930,7 @@ _frt_size (struct fetch_function_closure *ffc,
   
   mu_message_size (frt->msg, &size);
   mu_message_lines (frt->msg, &lines);
-  util_send ("%s %u", ffc->name, size + lines);
+  util_send ("%s %lu", ffc->name, (unsigned long) (size + lines));
   return RESP_OK;
 }
 
@@ -1312,7 +1312,7 @@ static size_t
 parsebuf_get_number (imap4d_parsebuf_t p)
 {
   char *cp;
-  unsigned n = strtoul (p->token, &cp, 10);
+  unsigned long n = strtoul (p->token, &cp, 10);
 
   if (*cp)
     imap4d_parsebuf_exit (p, "Syntax error: expected number");
diff --git a/imap4d/id.c b/imap4d/id.c
index 201f9bd..4715baa 100644
--- a/imap4d/id.c
+++ b/imap4d/id.c
@@ -197,7 +197,7 @@ imap4d_id (struct imap4d_command *command, imap4d_tokbuf_t tok)
 		util_send ("* ID (");
 	      else
 		util_send (" ");
-	      util_send ("\"%*.*s\" \"%s\"", len, len, p, q);
+	      util_send ("\"%*.*s\" \"%s\"", (int) len, (int) len, p, q);
 	    }
 	}
       mu_iterator_destroy (&itr);
diff --git a/imap4d/list.c b/imap4d/list.c
index f7049b4..ecb54f2 100644
--- a/imap4d/list.c
+++ b/imap4d/list.c
@@ -97,7 +97,7 @@ list_fun (mu_folder_t folder, struct mu_list_response *resp, void *data)
   name = refinfo->buf;
   
   if (strpbrk (name, "\"{}"))
-    util_send ("{%d}\r\n%s\r\n", strlen (name), name);
+    util_send ("{%lu}\r\n%s\r\n", (unsigned long) strlen (name), name);
   else if (is_atom (name))
     util_send ("%s\r\n", name);
   else
diff --git a/imap4d/select.c b/imap4d/select.c
index 0a7f39d..6b4949d 100644
--- a/imap4d/select.c
+++ b/imap4d/select.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2003, 2005, 2006,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 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
@@ -110,9 +110,11 @@ imap4d_select_status ()
   /* This outputs EXISTS and RECENT responses */
   imap4d_sync();
   util_out (RESP_OK, "[UIDVALIDITY %lu] UID valididy status", uidvalidity);
-  util_out (RESP_OK, "[UIDNEXT %d] Predicted next uid", uidnext);
+  util_out (RESP_OK, "[UIDNEXT %lu] Predicted next uid",
+	    (unsigned long) uidnext);
   if (unseen)
-    util_out (RESP_OK, "[UNSEEN %d] first unseen messsage ", unseen);
+    util_out (RESP_OK, "[UNSEEN %lu] first unseen messsage ",
+	      (unsigned long) unseen);
   util_out (RESP_NONE, "FLAGS (%s)", mflags);
   /* FIXME:
      - '\*' can be supported if we use the attribute_set userflag()
diff --git a/imap4d/status.c b/imap4d/status.c
index 2f1c0b1..6568c65 100644
--- a/imap4d/status.c
+++ b/imap4d/status.c
@@ -160,7 +160,7 @@ status_messages (mu_mailbox_t smbox)
 {
   size_t total = 0;
   mu_mailbox_messages_count (smbox, &total);
-  util_send ("MESSAGES %u", total);
+  util_send ("MESSAGES %lu", (unsigned long) total);
   return 0;
 }
 
@@ -169,7 +169,7 @@ status_recent (mu_mailbox_t smbox)
 {
   size_t recent = 0;
   mu_mailbox_messages_recent (smbox, &recent);
-  util_send ("RECENT %u", recent);
+  util_send ("RECENT %lu", (unsigned long) recent);
   return 0;
 }
 
@@ -178,7 +178,7 @@ status_uidnext (mu_mailbox_t smbox)
 {
   size_t uidnext = 1;
   mu_mailbox_uidnext (smbox, &uidnext);
-  util_send ("UIDNEXT %u", uidnext);
+  util_send ("UIDNEXT %lu", (unsigned long) uidnext);
   return 0;
 }
 
@@ -214,6 +214,6 @@ status_unseen (mu_mailbox_t smbox)
       if (!mu_attribute_is_read (attr))
 	unseen++;
     }
-  util_send ("UNSEEN %d", unseen);
+  util_send ("UNSEEN %lu", (unsigned long) unseen);
   return 0;
 }
diff --git a/imap4d/store.c b/imap4d/store.c
index 75c3023..147e800 100644
--- a/imap4d/store.c
+++ b/imap4d/store.c
@@ -151,7 +151,7 @@ imap4d_store0 (imap4d_tokbuf_t tok, int isuid, char **ptext)
 	  
 	  if (pclos.ack)
 	    {
-	      util_send ("* %d FETCH (", msgno);
+	      util_send ("* %lu FETCH (", (unsigned long) msgno);
 	      
 	      if (isuid)
 		util_send ("UID %lu ", (unsigned long) msgno);
diff --git a/imap4d/sync.c b/imap4d/sync.c
index 51d2aa8..7c70732 100644
--- a/imap4d/sync.c
+++ b/imap4d/sync.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2005, 2007, 2009 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
@@ -101,7 +101,8 @@ notify_flag (size_t msgno, mu_attribute_t oattr)
 	    add_flag (&abuf, "\\Recent");
 	  }
       if (*abuf)
-	util_out (RESP_NONE, "%d FETCH FLAGS (%s)", msgno, abuf);
+	util_out (RESP_NONE, "%lu FETCH FLAGS (%s)",
+		  (unsigned long) msgno, abuf);
       free (abuf);
     }
 }
@@ -123,7 +124,8 @@ notify_deleted (void)
 	{
 	  if (!(uid_table[i].notify))
 	    {
-	      util_out (RESP_NONE, "%d EXPUNGED", uid_table[i].msgno-decr);
+	      util_out (RESP_NONE, "%lu EXPUNGED",
+			(unsigned long) uid_table[i].msgno-decr);
 	      uid_table[i].notify = 1;
 	      decr++;
 	    }
@@ -237,8 +239,8 @@ notify (void)
       mu_mailbox_messages_recent (mbox, &recent);
     }
 
-  util_out (RESP_NONE, "%d EXISTS", total);
-  util_out (RESP_NONE, "%d RECENT", recent);
+  util_out (RESP_NONE, "%lu EXISTS", (unsigned long) total);
+  util_out (RESP_NONE, "%lu RECENT", (unsigned long) recent);
 
   if (!reset)
     reset_uids ();
diff --git a/imap4d/util.c b/imap4d/util.c
index ff222ab..b5f0fa0 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -325,7 +325,7 @@ util_send_qstring (const char *buffer)
 int
 util_send_literal (const char *buffer)
 {
-  return util_send ("{%u}\r\n%s", strlen (buffer), buffer);
+  return util_send ("{%lu}\r\n%s", (unsigned long) strlen (buffer), buffer);
 }
 
 /* Send an unsolicited response.  */
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 1ee1cdb..ac36534 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005, 
-   2006, 2007, 2008 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009 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
@@ -35,7 +35,7 @@ typedef struct mu_sieve_machine *mu_sieve_machine_t;
 
 typedef struct
 {
-  const char *source_file;
+  char *source_file;
   size_t source_line;
 }
 mu_sieve_locus_t;
diff --git a/libmu_argp/common.c b/libmu_argp/common.c
index a9d9e7d..cb17690 100644
--- a/libmu_argp/common.c
+++ b/libmu_argp/common.c
@@ -20,6 +20,7 @@
 # include <config.h>
 #endif
 #include "cmdline.h"
+#include <unistd.h>
 #include <string.h>
 #include <mailutils/syslog.h>
 #include <mailutils/mailbox.h>
diff --git a/libmu_argp/muinit.c b/libmu_argp/muinit.c
index 575a329..ad82bfb 100644
--- a/libmu_argp/muinit.c
+++ b/libmu_argp/muinit.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 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
@@ -20,6 +20,8 @@
 # include <config.h>
 #endif
 #include "cmdline.h"
+#include <unistd.h>
+#include <stdlib.h>
 #include <mailutils/stream.h>
 #include "xalloc.h"
 #include <string.h>
diff --git a/libmu_sieve/actions.c b/libmu_sieve/actions.c
index b3e56d8..bce1a7e 100644
--- a/libmu_sieve/actions.c
+++ b/libmu_sieve/actions.c
@@ -317,9 +317,9 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (rc)
     {
       mu_sieve_error (mach,
-		   _("%d: cannot create recipient address <%s>: %s"),
-		   mu_sieve_get_message_num (mach),
-		   addrtext, mu_strerror (rc));
+		      _("%lu: cannot create recipient address <%s>: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
+		      addrtext, mu_strerror (rc));
       free (addrtext);
       goto end;
     }
@@ -329,8 +329,8 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (rc)
     {
       mu_sieve_error (mach,
-		      _("%d: cannot create sender address <%s>: %s"),
-		      mu_sieve_get_message_num (mach),
+		      _("%lu: cannot create sender address <%s>: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
 		      mu_sieve_get_daemon_email (mach),
 		      mu_strerror (rc));
       goto end;
@@ -343,8 +343,8 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       mu_mailer_get_url (mailer, &url);
 	
       mu_sieve_error (mach,
-		      _("%d: cannot open mailer %s: %s"),
-		      mu_sieve_get_message_num (mach),
+		      _("%lu: cannot open mailer %s: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
 		      mu_url_to_string (url),
 		      mu_strerror (rc));
       goto end;
@@ -426,9 +426,9 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (rc)
     {
       mu_sieve_error (mach,
-		   _("%d: parsing recipient address `%s' failed: %s"),
-		   mu_sieve_get_message_num (mach),
-		   val->v.string, mu_strerror (rc));
+		      _("%lu: parsing recipient address `%s' failed: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
+		      val->v.string, mu_strerror (rc));
       return 1;
     }
   
@@ -439,8 +439,8 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   msg = mu_sieve_get_message (mach);
   if (check_redirect_loop (msg))
     {
-      mu_sieve_error (mach, _("%d: redirection loop detected"),
-		   mu_sieve_get_message_num (mach));
+      mu_sieve_error (mach, _("%lu: redirection loop detected"),
+		      (unsigned long) mu_sieve_get_message_num (mach));
       goto end;
     }
 
@@ -448,8 +448,9 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (rc)
     {
       mu_sieve_error (mach,
-		   _("%d: cannot get envelope sender: %s"),
-		   mu_sieve_get_message_num (mach), mu_strerror (rc));
+		      _("%lu: cannot get envelope sender: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
+		      mu_strerror (rc));
       goto end;
     }
 
@@ -457,8 +458,8 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (rc)
     {
       mu_sieve_error (mach,
-		      _("%d: cannot create sender address <%s>: %s"),
-		      mu_sieve_get_message_num (mach),
+		      _("%lu: cannot create sender address <%s>: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
 		      fromaddr, mu_strerror (rc));
       free (fromaddr);
       goto end;
@@ -470,9 +471,9 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (rc)
     {
       mu_sieve_error (mach,
-		   _("%d: cannot copy message: %s"),
-		   mu_sieve_get_message_num (mach),
-		   mu_strerror (rc));
+		      _("%lu: cannot copy message: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
+		      mu_strerror (rc));
       goto end;
     }
   
@@ -485,8 +486,8 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
     }
   else
     {
-      mu_sieve_error (mach, _("%d: cannot get my email address"),
-		   mu_sieve_get_message_num (mach));
+      mu_sieve_error (mach, _("%lu: cannot get my email address"),
+		      (unsigned long) mu_sieve_get_message_num (mach));
       goto end;
     }
   
@@ -497,10 +498,10 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
       mu_mailer_get_url (mailer, &url);
 	
       mu_sieve_error (mach,
-		   _("%d: cannot open mailer %s: %s"),
-		   mu_sieve_get_message_num (mach),
-		   mu_url_to_string (url),
-		   mu_strerror (rc));
+		      _("%lu: cannot open mailer %s: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
+		      mu_url_to_string (url),
+		      mu_strerror (rc));
       goto end;
     }
   
diff --git a/libmu_sieve/extensions/pipe.c b/libmu_sieve/extensions/pipe.c
index 6990a4a..f20995a 100644
--- a/libmu_sieve/extensions/pipe.c
+++ b/libmu_sieve/extensions/pipe.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 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
@@ -45,13 +45,13 @@
  if (!(expr))                                                                 \
    {                                                                          \
      if (ec)                                                                  \
-       mu_sieve_error (mach, "%d: %s: %s",                                    \
-	 	       mu_sieve_get_message_num (mach),                       \
+       mu_sieve_error (mach, "%lu: %s: %s",                                   \
+	 	       (unsigned long) mu_sieve_get_message_num (mach),	      \
 		       diag,                                                  \
 		       mu_strerror (ec));                                     \
      else                                                                     \
-       mu_sieve_error (mach, "%d: %s",                                        \
-	 	       mu_sieve_get_message_num (mach),                       \
+       mu_sieve_error (mach, "%lu: %s",                                       \
+	 	       (unsigned long) mu_sieve_get_message_num (mach),	      \
 		       diag);                                                 \
      mu_sieve_abort (mach);                                                   \
    }
@@ -60,14 +60,14 @@
  if (!(expr))                                                                 \
    {                                                                          \
      if (ec)                                                                  \
-       mu_sieve_error (mach, "%d: `%s': %s: %s",                              \
-	 	       mu_sieve_get_message_num (mach),                       \
+       mu_sieve_error (mach, "%lu: `%s': %s: %s",                             \
+	 	       (unsigned long) mu_sieve_get_message_num (mach),	      \
 		       arg,                                                   \
 		       diag,                                                  \
 		       mu_strerror (ec));                                     \
      else                                                                     \
-       mu_sieve_error (mach, "%d: `%s': %s",                                  \
-		       mu_sieve_get_message_num (mach),                       \
+       mu_sieve_error (mach, "%lu: `%s': %s",                                 \
+		       (unsigned long) mu_sieve_get_message_num (mach),	      \
 		       arg,                                                   \
 		       diag);                                                 \
      mu_sieve_abort (mach);                                                   \
diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c
index e4a9cf1..ab0a7c9 100644
--- a/libmu_sieve/extensions/vacation.c
+++ b/libmu_sieve/extensions/vacation.c
@@ -202,8 +202,8 @@ regex_comparator (void *item, void *data)
 	       REG_EXTENDED | REG_NOSUB | REG_NEWLINE | REG_ICASE))
     {
       mu_sieve_error (d->mach,
-		      _("%d: cannot compile regular expression \"%s\""),
-		      mu_sieve_get_message_num (d->mach),
+		      _("%lu: cannot compile regular expression \"%s\""),
+		      (unsigned long) mu_sieve_get_message_num (d->mach),
 		      (char*) item);
       return 0;
     }
@@ -293,8 +293,8 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
 
   if (asprintf (&file, "%s/.vacation", (home ? home : ".")) == -1)
     {
-      mu_sieve_error (mach, _("%d: cannot build db file name"),
-		      mu_sieve_get_message_num (mach));
+      mu_sieve_error (mach, _("%lu: cannot build db file name"),
+		      (unsigned long) mu_sieve_get_message_num (mach));
       free (home);
       mu_sieve_abort (mach);
     }
@@ -304,8 +304,8 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from)
   if (rc)
     {
       mu_sieve_error (mach,
-		      _("%d: cannot open `%s': %s"),
-		      mu_sieve_get_message_num (mach), file,
+		      _("%lu: cannot open `%s': %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach), file,
 		      mu_strerror (rc));
       free (file);
       mu_sieve_abort (mach);
@@ -375,8 +375,8 @@ re_subject (mu_sieve_machine_t mach, mu_list_t tags, char **psubject)
   if (!subject)
     {
       mu_sieve_error (mach,
-		      _("%d: not enough memory"),
-		      mu_sieve_get_message_num (mach));
+		      _("%lu: not enough memory"),
+		      (unsigned long) mu_sieve_get_message_num (mach));
       return;
     }
   
@@ -433,8 +433,8 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags,
 	      mu_sieve_error (mach,
 			      /* TRANSLATORS: 'vacation' is the name of the
 				 Sieve action. Do not translate it! */
-			      _("%d: vacation - cannot compile reply prefix regexp: %s: %s"),
-			      mu_sieve_get_message_num (mach),
+			      _("%lu: vacation - cannot compile reply prefix regexp: %s: %s"),
+			      (unsigned long) mu_sieve_get_message_num (mach),
 			      mu_strerror (rc),
 			      err ? err : "");
 	    }
@@ -483,8 +483,9 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
   if (rc)
     {
       mu_sieve_error (mach,
-		      _("%d: cannot create recipient address <%s>: %s"),
-		      mu_sieve_get_message_num (mach), from, mu_strerror (rc));
+		      _("%lu: cannot create recipient address <%s>: %s"),
+		      (unsigned long) mu_sieve_get_message_num (mach),
+		      from, mu_strerror (rc));
     }
   else
     {
@@ -522,8 +523,8 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg,
 	  mu_mailer_get_url (mailer, &url);
       
 	  mu_sieve_error (mach,
-			  _("%d: cannot open mailer %s: %s"),
-			  mu_sieve_get_message_num (mach),
+			  _("%lu: cannot open mailer %s: %s"),
+			  (unsigned long) mu_sieve_get_message_num (mach),
 			  mu_url_to_string (url), mu_strerror (rc));
 	}
       else
@@ -572,8 +573,8 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   else if (mu_sieve_get_message_sender (msg, &from))
     {
       mu_sieve_error (mach,
-		      _("%d: cannot get sender address"),
-		      mu_sieve_get_message_num (mach));
+		      _("%lu: cannot get sender address"),
+		      (unsigned long) mu_sieve_get_message_num (mach));
       mu_sieve_abort (mach);
     }
 
diff --git a/libmu_sieve/prog.c b/libmu_sieve/prog.c
index 79141ae..99f68d8 100644
--- a/libmu_sieve/prog.c
+++ b/libmu_sieve/prog.c
@@ -263,9 +263,9 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 		  else
 		    {
 		      mu_sv_compile_error (&mu_sieve_locus, 
-                                      _("type mismatch in argument %d to `%s'"),
-				      exp_arg - reg->req_args + 1,
-				      reg->name);
+                                   _("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),
diff --git a/libmu_sieve/require.c b/libmu_sieve/require.c
index 06f382a..be9ddea 100644
--- a/libmu_sieve/require.c
+++ b/libmu_sieve/require.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2004, 
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009 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
@@ -47,7 +47,7 @@ mu_sieve_require (mu_list_t slist)
     {
       char *name;
       int (*reqfn) (mu_sieve_machine_t mach, const char *name) = NULL;
-      char *text = NULL;
+      const char *text = NULL;
       
       mu_iterator_current (itr, (void **)&name);
 
diff --git a/libmu_sieve/runtime.c b/libmu_sieve/runtime.c
index 9c7da4f..ceb97c0 100644
--- a/libmu_sieve/runtime.c
+++ b/libmu_sieve/runtime.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 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
@@ -44,11 +44,11 @@ _mu_sv_instr_nop (mu_sieve_machine_t mach)
 void
 _mu_sv_instr_source (mu_sieve_machine_t mach)
 {
-  mach->locus.source_file = SIEVE_ARG (mach, 0, string);
+  mach->locus.source_file = (char*) SIEVE_ARG (mach, 0, string);
   if (INSTR_DEBUG (mach))
     mu_sieve_debug (mach, "%4lu: SOURCE %s\n",
-		 (unsigned long) (mach->pc - 1),
-		 mach->locus.source_file);
+		    (unsigned long) (mach->pc - 1),
+		    mach->locus.source_file);
   SIEVE_ADJUST (mach, 1);
 }
 		 
diff --git a/libmu_sieve/sieve-priv.h b/libmu_sieve/sieve-priv.h
index ce65f67..ae99bb1 100644
--- a/libmu_sieve/sieve-priv.h
+++ b/libmu_sieve/sieve-priv.h
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 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
@@ -96,7 +96,7 @@ 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 (char *s);
+int mu_sieve_yyerror (const char *s);
 int mu_sieve_yylex (); 
 
 void mu_sv_register_standard_actions (mu_sieve_machine_t mach);
diff --git a/libmu_sieve/sieve.y b/libmu_sieve/sieve.y
index 3b25465..dd1334f 100644
--- a/libmu_sieve/sieve.y
+++ b/libmu_sieve/sieve.y
@@ -1,7 +1,7 @@
 %{
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2002, 2005,
-   2006, 2007, 2008 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009 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
@@ -341,7 +341,7 @@ slist        : STRING
 %%
 
 int
-yyerror (char *s)
+yyerror (const char *s)
 {
   mu_sv_compile_error (&mu_sieve_locus, "%s", s);
   return 0;
diff --git a/libproto/imap/folder.c b/libproto/imap/folder.c
index 56dac5d..c38b364 100644
--- a/libproto/imap/folder.c
+++ b/libproto/imap/folder.c
@@ -207,15 +207,15 @@ authenticate_imap_login (mu_authority_t auth)
 	else if (status)
 	  return status;
 	
-	status = imap_writeline (f_imap, "g%u LOGIN \"%s\" \"%s\"\r\n",
-				 f_imap->seq, f_imap->user,
+	status = imap_writeline (f_imap, "g%lu LOGIN \"%s\" \"%s\"\r\n",
+				 (unsigned long) f_imap->seq, f_imap->user,
 				 mu_secret_password (f_imap->secret));
 	mu_secret_password_unref (f_imap->secret);
 	mu_secret_unref (f_imap->secret);
 	f_imap->secret = NULL;
 	CHECK_ERROR_CLOSE (folder, f_imap, status);
-	MU_DEBUG2 (folder->debug, MU_DEBUG_TRACE, "g%u LOGIN %s *\n",
-		   f_imap->seq, f_imap->user);
+	MU_DEBUG2 (folder->debug, MU_DEBUG_TRACE, "g%lu LOGIN %s *\n",
+		   (unsigned long) f_imap->seq, f_imap->user);
 	f_imap->seq++;
 	free (f_imap->user);
 	f_imap->user = NULL;
@@ -311,10 +311,10 @@ authenticate_imap_sasl_anon (mu_authority_t auth)
     case IMAP_AUTH_ANON_REQ_WRITE:
       {
 	MU_DEBUG1 (folder->debug, MU_DEBUG_PROT, 
-                   "g%u AUTHENTICATE ANONYMOUS\n",
-		   f_imap->seq);
-	status = imap_writeline (f_imap, "g%u AUTHENTICATE ANONYMOUS\r\n",
-				 f_imap->seq);
+                   "g%lu AUTHENTICATE ANONYMOUS\n",
+		   (unsigned long) f_imap->seq);
+	status = imap_writeline (f_imap, "g%lu AUTHENTICATE ANONYMOUS\r\n",
+				 (unsigned long) f_imap->seq);
 	f_imap->seq++;
 	CHECK_ERROR_CLOSE (folder, f_imap, status);
 	f_imap->auth_state = IMAP_AUTH_ANON_REQ_SEND;
@@ -539,8 +539,8 @@ read_capa (f_imap_t f_imap, int force)
   
   if (!f_imap->capav)
     {
-      status = imap_writeline (f_imap, "g%u CAPABILITY\r\n",
-			       f_imap->seq++);
+      status = imap_writeline (f_imap, "g%lu CAPABILITY\r\n",
+			       (unsigned long) f_imap->seq++);
       status = imap_send (f_imap);
       status = imap_parse (f_imap);
     }
@@ -787,7 +787,8 @@ folder_imap_close (mu_folder_t folder)
   switch (f_imap->state)
     {
     case IMAP_NO_STATE:
-      status = imap_writeline (f_imap, "g%u LOGOUT\r\n", f_imap->seq++);
+      status = imap_writeline (f_imap, "g%lu LOGOUT\r\n",
+			       (unsigned long) f_imap->seq++);
       CHECK_ERROR (f_imap, status);
       MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
       f_imap->state = IMAP_LOGOUT;
@@ -831,7 +832,8 @@ folder_imap_delete (mu_folder_t folder, const char *name)
   switch (f_imap->state)
     {
     case IMAP_NO_STATE:
-      status = imap_writeline (f_imap, "g%u DELETE %s\r\n", f_imap->seq++,
+      status = imap_writeline (f_imap, "g%lu DELETE %s\r\n",
+			       (unsigned long) f_imap->seq++,
 			       name);
       CHECK_ERROR (f_imap, status);
       MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
@@ -1007,8 +1009,8 @@ folder_imap_list (mu_folder_t folder, const char *ref, void *name,
     {
     case IMAP_NO_STATE:
       path = glob_to_imap (name, max_level != 1);
-      status = imap_writeline (f_imap, "g%u LIST \"%s\" \"%s\"\r\n",
-			       f_imap->seq++, ref, path);
+      status = imap_writeline (f_imap, "g%lu LIST \"%s\" \"%s\"\r\n",
+			       (unsigned long) f_imap->seq++, ref, path);
       free (path);
       CHECK_ERROR (f_imap, status);
       MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
@@ -1063,8 +1065,8 @@ folder_imap_lsub (mu_folder_t folder, const char *ref, const char *name,
   switch (f_imap->state)
     {
     case IMAP_NO_STATE:
-      status = imap_writeline (f_imap, "g%u LSUB \"%s\" \"%s\"\r\n",
-			       f_imap->seq++, ref, name);
+      status = imap_writeline (f_imap, "g%lu LSUB \"%s\" \"%s\"\r\n",
+			       (unsigned long) f_imap->seq++, ref, name);
       CHECK_ERROR (f_imap, status);
       MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
       f_imap->state = IMAP_LSUB;
@@ -1108,8 +1110,9 @@ folder_imap_rename (mu_folder_t folder, const char *oldpath,
   switch (f_imap->state)
     {
     case IMAP_NO_STATE:
-      status = imap_writeline (f_imap, "g%u RENAME %s %s\r\n",
-			       f_imap->seq++, oldpath, newpath);
+      status = imap_writeline (f_imap, "g%lu RENAME %s %s\r\n",
+			       (unsigned long) f_imap->seq++,
+			       oldpath, newpath);
       CHECK_ERROR (f_imap, status);
       MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
       f_imap->state = IMAP_RENAME;
@@ -1146,8 +1149,8 @@ folder_imap_subscribe (mu_folder_t folder, const char *name)
   switch (f_imap->state)
     {
     case IMAP_NO_STATE:
-      status = imap_writeline (f_imap, "g%u SUBSCRIBE %s\r\n",
-			       f_imap->seq++, name);
+      status = imap_writeline (f_imap, "g%lu SUBSCRIBE %s\r\n",
+			       (unsigned long) f_imap->seq++, name);
       CHECK_ERROR (f_imap, status);
       MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
       f_imap->state = IMAP_SUBSCRIBE;
@@ -1184,8 +1187,8 @@ folder_imap_unsubscribe (mu_folder_t folder, const char *name)
   switch (f_imap->state)
     {
     case IMAP_NO_STATE:
-      status = imap_writeline (f_imap, "g%u UNSUBSCRIBE %s\r\n",
-			       f_imap->seq++, name);
+      status = imap_writeline (f_imap, "g%lu UNSUBSCRIBE %s\r\n",
+			       (unsigned long) f_imap->seq++, name);
       CHECK_ERROR (f_imap, status);
       MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
       f_imap->state = IMAP_UNSUBSCRIBE;
diff --git a/libproto/imap/mbox.c b/libproto/imap/mbox.c
index 8aada6c..5c561d6 100644
--- a/libproto/imap/mbox.c
+++ b/libproto/imap/mbox.c
@@ -315,10 +315,10 @@ mailbox_imap_open (mu_mailbox_t mailbox, int flags)
 	      return 0;
 	    else if (status)
 	      return status;
-	    status = imap_writeline (f_imap, "g%u CREATE %s\r\n",
-				     f_imap->seq, path);
-	    MU_DEBUG2 (folder->debug, MU_DEBUG_PROT, "g%u CREATE %s\n",
-		       f_imap->seq, path);
+	    status = imap_writeline (f_imap, "g%lu CREATE %s\r\n",
+				     (unsigned long) f_imap->seq, path);
+	    MU_DEBUG2 (folder->debug, MU_DEBUG_PROT, "g%lu CREATE %s\n",
+		       (unsigned long) f_imap->seq, path);
 	    f_imap->seq++;
 	    if (status != 0)
 	      {
diff --git a/libproto/mailer/sendmail.c b/libproto/mailer/sendmail.c
index beaf24d..0e112da 100644
--- a/libproto/mailer/sendmail.c
+++ b/libproto/mailer/sendmail.c
@@ -236,8 +236,8 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
 	    {
 	      free (argvec);
 	      MU_DEBUG2 (mailer->debug, MU_DEBUG_ERROR,
-			 "cannot get email of recipient #%d: %s\n",
-			 i, mu_strerror (status));
+			 "cannot get email of recipient #%lu: %s\n",
+			 (unsigned long) i, mu_strerror (status));
 	      return status;
 	    }
 	  
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c
index c129dc0..12a2558 100644
--- a/libproto/mbox/mbox.c
+++ b/libproto/mbox/mbox.c
@@ -1194,8 +1194,8 @@ mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg)
       return 0;
     }
 
-  MU_DEBUG2 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_get_message (%s, %d)\n",
-		  mud->name, msgno);
+  MU_DEBUG2 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_get_message (%s, %lu)\n",
+	     mud->name, (unsigned long) msgno);
 
   return new_message (mailbox, mum, pmsg);
 }
diff --git a/libproto/pop/pop3_list.c b/libproto/pop/pop3_list.c
index e5d411f..ed708a8 100644
--- a/libproto/pop/pop3_list.c
+++ b/libproto/pop/pop3_list.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2007, 2009 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
@@ -29,7 +29,8 @@ int
 mu_pop3_list (mu_pop3_t pop3, unsigned int msgno, size_t *psize)
 {
   int status;
-
+  unsigned long lv;
+  
   if (pop3 == NULL || msgno == 0)
     return EINVAL;
   if (psize == NULL)
@@ -57,8 +58,9 @@ mu_pop3_list (mu_pop3_t pop3, unsigned int msgno, size_t *psize)
       pop3->state = MU_POP3_NO_STATE;
 
       /* Parse the answer.  */
-      *psize = 0;
-      sscanf (pop3->ack.buf, "+OK %d %d", &msgno, psize);
+      lv = 0;
+      sscanf (pop3->ack.buf, "+OK %d %lu", &msgno, &lv);
+      *psize = lv;
       break;
 
       /* They must deal with the error first by reopening.  */
diff --git a/libproto/pop/pop3_stat.c b/libproto/pop/pop3_stat.c
index 05ab1af..682531b 100644
--- a/libproto/pop/pop3_stat.c
+++ b/libproto/pop/pop3_stat.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2007, 2009 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
@@ -28,7 +28,8 @@ int
 mu_pop3_stat (mu_pop3_t pop3, unsigned *msg_count, size_t *size)
 {
   int status;
-
+  unsigned long lv;
+  
   if (pop3 == NULL || msg_count == NULL)
     return EINVAL;
   if (size == NULL)
@@ -57,8 +58,9 @@ mu_pop3_stat (mu_pop3_t pop3, unsigned *msg_count, size_t *size)
 
       /* Parse the answer.  */
       *msg_count = 0;
-      *size = 0;
-      sscanf (pop3->ack.buf, "+OK %d %d", msg_count, size);
+      lv = 0;
+      sscanf (pop3->ack.buf, "+OK %d %lu", msg_count, &lv);
+      *size = lv;
       break;
 
       /* They must deal with the error first by reopening.  */
diff --git a/maidag/lmtp.c b/maidag/lmtp.c
index 6842f53..46b245d 100644
--- a/maidag/lmtp.c
+++ b/maidag/lmtp.c
@@ -62,7 +62,7 @@ lmtp_reply (FILE *fp, char *code, char *enh, char *fmt, ...)
 	  fprintf (fp, "%s-", code);
 	  if (enh)
 	    fprintf (fp, "%s ", enh);
-	  fprintf (fp, "%.*s\r\n", len, str);
+	  fprintf (fp, "%.*s\r\n", (int) len, str);
 	  for (str = end; *str && *str == '\n'; str++);
 	}
       else
diff --git a/maidag/sieve.c b/maidag/sieve.c
index 92d2443..e9c17c9 100644
--- a/maidag/sieve.c
+++ b/maidag/sieve.c
@@ -57,7 +57,8 @@ _sieve_action_log (void *user_name,
     {
       size_t uid = 0;
       mu_message_get_uid (msg, &uid);
-      mu_diag_printf (MU_DIAG_NOTICE, _("%s on msg uid %d"), action, uid);
+      mu_diag_printf (MU_DIAG_NOTICE, _("%s on msg uid %lu"), action,
+		      (unsigned long) uid);
     }
   
   if (fmt && strlen (fmt))
diff --git a/mail/copy.c b/mail/copy.c
index effba42..604d063 100644
--- a/mail/copy.c
+++ b/mail/copy.c
@@ -108,7 +108,8 @@ mail_copy0 (int argc, char **argv, int mark)
     }
 
   if (status == 0)
-    fprintf (ofile, "\"%s\" %3d/%-5d\n", filename, total_lines, total_size);
+    fprintf (ofile, "\"%s\" %3lu/%-5lu\n", filename,
+	     (unsigned long) total_lines, (unsigned long) total_size);
 
   mu_mailbox_close (mbx);
   mu_mailbox_destroy (&mbx);
diff --git a/mail/decode.c b/mail/decode.c
index 5de847c..6327456 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -127,9 +127,9 @@ fprint_msgset (FILE *fp, const msgset_t *msgset)
   int i;
   size_t n = 0;
   
-  n = fprintf (fp, "%d", msgset->msg_part[0]);
+  n = fprintf (fp, "%lu", (unsigned long) msgset->msg_part[0]);
   for (i = 1; i < msgset->npart; i++)
-    n += fprintf (fp, "[%d", msgset->msg_part[i]);
+    n += fprintf (fp, "[%lu", (unsigned long) msgset->msg_part[i]);
   for (i = 1; i < msgset->npart; i++)
     n += fprintf (fp, "]");
   return n;
diff --git a/mail/envelope.c b/mail/envelope.c
index 24d9391..8525ccc 100644
--- a/mail/envelope.c
+++ b/mail/envelope.c
@@ -30,7 +30,8 @@ print_envelope (msgset_t *mspec, mu_message_t msg, void *data)
   status = mu_message_get_envelope (msg, &env);
   if (status)
     {
-      mu_error (_("%d: Cannot get envelope"), mspec->msg_part[0]);
+      mu_error (_("%lu: Cannot get envelope"),
+		(unsigned long) mspec->msg_part[0]);
     }
   else
     {
diff --git a/mail/eq.c b/mail/eq.c
index 4d63411..26113a9 100644
--- a/mail/eq.c
+++ b/mail/eq.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2005, 
-   2007 Free Software Foundation, Inc.
+   2007, 2009 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
@@ -36,7 +36,7 @@ mail_eq (int argc, char **argv)
       if (n == 0)
         util_error (_("No applicable message"));
       else
-        fprintf (ofile, "%u\n", n);
+        fprintf (ofile, "%lu\n", (unsigned long) n);
       break;
 
     case 2:
@@ -45,7 +45,7 @@ mail_eq (int argc, char **argv)
 	  if (list->msg_part[0] <= total)
 	    {
 	      set_cursor (list->msg_part[0]);
-	      fprintf (ofile, "%u\n", list->msg_part[0]);
+	      fprintf (ofile, "%lu\n", (unsigned long) list->msg_part[0]);
 	    }
 	  else
 	    util_error_range (list->msg_part[0]);
diff --git a/mail/escape.c b/mail/escape.c
index e44283e..b2e016c 100644
--- a/mail/escape.c
+++ b/mail/escape.c
@@ -433,7 +433,8 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data)
   size_t n = 0;
   char *prefix = "\t";
   
-  fprintf (stdout, _("Interpolating: %d\n"), mspec->msg_part[0]);
+  fprintf (stdout, _("Interpolating: %lu\n"),
+	   (unsigned long) mspec->msg_part[0]);
 
   mailvar_get (&prefix, "indentprefix", mailvar_type_string, 0);
 
diff --git a/mail/from.c b/mail/from.c
index 31e2a92..75212e1 100644
--- a/mail/from.c
+++ b/mail/from.c
@@ -115,11 +115,11 @@ format_headline (struct header_segm *seg, msgset_t *mspec, mu_message_t msg)
       if (seg->align == ALIGN_RIGHT)
 	{
 	  format_pad (width - len);
-	  fprintf (ofile, "%*.*s", len, len, p);
+	  fprintf (ofile, "%*.*s", (int) len, (int) len, p);
 	}
       else
 	{
-	  fprintf (ofile, "%*.*s", len, len, p);
+	  fprintf (ofile, "%*.*s", (int) len, (int) len, p);
 	  format_pad (width - len);
 	}
       out_cols += width;
diff --git a/mail/mail.h b/mail/mail.h
index d9950b0..50d3e31 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -410,8 +410,8 @@ extern int ml_got_interrupt (void);
 extern void ml_clear_interrupt (void);
 extern void ml_readline_init (void);
 extern int ml_reread (const char *prompt, char **text);
-extern char *ml_readline (char *prompt);
-extern char *ml_readline_with_intr (char *prompt);
+extern char *ml_readline (const char *prompt);
+extern char *ml_readline_with_intr (const char *prompt);
 
 extern char *alias_expand (const char *name);
 extern void alias_destroy (const char *name);
diff --git a/mail/mailline.c b/mail/mailline.c
index 4ed1c3a..dabf66e 100644
--- a/mail/mailline.c
+++ b/mail/mailline.c
@@ -175,7 +175,7 @@ ml_readline_internal ()
 }
 
 char *
-ml_readline (char *prompt)
+ml_readline (const char *prompt)
 {
   if (interactive)
     return readline (prompt);
@@ -183,7 +183,7 @@ ml_readline (char *prompt)
 }
 
 char *
-ml_readline_with_intr (char *prompt)
+ml_readline_with_intr (const char *prompt)
 {
   char *str = ml_readline (prompt);
   if (_interrupted)
diff --git a/mail/mailvar.c b/mail/mailvar.c
index e5cc5ce..f948b1a 100644
--- a/mail/mailvar.c
+++ b/mail/mailvar.c
@@ -285,14 +285,15 @@ find_mailvar_symbol (const char *var)
 }
 
 static void
-print_descr (FILE *out, char *s, int n, int doc_col, int rmargin, char *pfx)
+print_descr (FILE *out, const char *s, int n,
+	     int doc_col, int rmargin, char *pfx)
 {
   if (!s)
     return;
   do
     {
-      char *p;
-      char *space = NULL;
+      const char *p;
+      const char *space = NULL;
 
       if (n == 1 && pfx)
 	n += fprintf (out, "%s", pfx);
diff --git a/mail/size.c b/mail/size.c
index 6f5a14c..dddf48d 100644
--- a/mail/size.c
+++ b/mail/size.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2005, 2007, 2009 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
@@ -30,9 +30,11 @@ size0 (msgset_t *mspec, mu_message_t msg, void *data)
   mu_message_size (msg, &size);
   mu_message_lines (msg, &lines);
   
-  fprintf (ofile, "%c%2d %3d/%-5d\n",
+  fprintf (ofile, "%c%2lu %3lu/%-5lu\n",
 	   is_current_message (mspec->msg_part[0]) ? '>' : ' ',
-	   mspec->msg_part[0], lines, size);
+	   (unsigned long) mspec->msg_part[0],
+	   (unsigned long) lines,
+	   (unsigned long) size);
   return 0;
 }
 
diff --git a/mail/util.c b/mail/util.c
index b6c3ba5..0e1e0b0 100644
--- a/mail/util.c
+++ b/mail/util.c
@@ -387,7 +387,7 @@ util_screen_lines ()
   if (mailvar_get (&screen, "screen", mailvar_type_number, 0) == 0)
     return screen;
   n = util_getlines();
-  util_do_command ("set screen=%d", n);
+  util_do_command ("set screen=%lu", (unsigned long) n);
   return n;
 }
 
@@ -400,7 +400,7 @@ util_screen_columns ()
   if (mailvar_get (&cols, "columns", mailvar_type_number, 0) == 0)
     return cols;
   n = util_getcols();
-  util_do_command ("set columns=%d", n);
+  util_do_command ("set columns=%lu", (unsigned long) n);
   return n;
 }
 
@@ -794,15 +794,15 @@ util_descend_subparts (mu_message_t mesg, msgset_t *msgset, mu_message_t *part)
       mu_message_get_num_parts (mesg, &nparts);
       if (nparts < msgset->msg_part[i])
 	{
-	  util_error (_("No such (sub)part in the message: %d"),
-		      msgset->msg_part[i]);
+	  util_error (_("No such (sub)part in the message: %lu"),
+		      (unsigned long) msgset->msg_part[i]);
 	  return 1;
 	}
 
       if (mu_message_get_part (mesg, msgset->msg_part[i], &submsg))
 	{
-	  util_error (_("Cannot get (sub)part from the message: %d"),
-		      msgset->msg_part[i]);
+	  util_error (_("Cannot get (sub)part from the message: %lu"),
+		      (unsigned long) msgset->msg_part[i]);
 	  return 1;
 	}
 
@@ -1039,7 +1039,7 @@ util_get_message (mu_mailbox_t mbox, size_t msgno, mu_message_t *msg)
 int
 util_error_range (size_t msgno)
 {
-  util_error (_("%d: invalid message number"), msgno);
+  util_error (_("%lu: invalid message number"), (unsigned long) msgno);
   return 1;
 }
 
diff --git a/mail/write.c b/mail/write.c
index 511b921..5c396fb 100644
--- a/mail/write.c
+++ b/mail/write.c
@@ -50,7 +50,7 @@ mail_write (int argc, char **argv)
           util_error (_("No applicable message"));
           return 1;
         }
-      asprintf (&p, "%u", n);
+      asprintf (&p, "%lu", (unsigned long) n);
       filename = util_outfolder_name (p);
       free (p);
     }
@@ -115,7 +115,8 @@ mail_write (int argc, char **argv)
       mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_SAVED);
     }
 
-  fprintf (ofile, "\"%s\" %3d/%-5d\n", filename, total_lines, total_size);
+  fprintf (ofile, "\"%s\" %3lu/%-5lu\n", filename,
+	   (unsigned long) total_lines, (unsigned long) total_size);
 
   free (filename);
   fclose (output);
diff --git a/mailbox/cfg_format.c b/mailbox/cfg_format.c
index a7f3d0f..6633bb1 100644
--- a/mailbox/cfg_format.c
+++ b/mailbox/cfg_format.c
@@ -1,5 +1,5 @@
 /* cfg_print.c -- convert configuration parse tree to human-readable format.
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 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
@@ -132,8 +132,9 @@ format_node (const mu_cfg_node_t *node, void *data)
   struct tree_print *tp = data;
 
   if (node->locus.file)
-    mu_stream_sequential_printf (tp->stream, "# %d \"%s\"\n",
-				 node->locus.line, node->locus.file);
+    mu_stream_sequential_printf (tp->stream, "# %lu \"%s\"\n",
+				 (unsigned long) node->locus.line, 
+                                 node->locus.file);
   format_level (tp->stream, tp->level);
   switch (node->type)
     {
diff --git a/mailbox/folder.c b/mailbox/folder.c
index d685733..fec5b43 100644
--- a/mailbox/folder.c
+++ b/mailbox/folder.c
@@ -181,11 +181,9 @@ mu_folder_destroy (mu_folder_t *pfolder)
       if (folder->ref <= 0)
 	mu_list_remove (known_folder_list, folder);
       /* If the list is empty we can safely remove it.  */
-      if (mu_list_is_empty)
-	{
-	  mu_list_destroy (&known_folder_list);
-	  known_folder_list = NULL;
-	}
+      if (mu_list_is_empty (known_folder_list))
+	mu_list_destroy (&known_folder_list);
+
       mu_monitor_unlock (&folder_lock);
 
       if (folder->ref <= 0)
diff --git a/mailbox/parse822.c b/mailbox/parse822.c
index 41d1bc0..6490ff9 100644
--- a/mailbox/parse822.c
+++ b/mailbox/parse822.c
@@ -1783,7 +1783,7 @@ struct tm
 
 int
 mu_parse822_date_time (const char **p, const char *e, struct tm *tm,
-		    struct mu_timezone *tz)
+		       struct mu_timezone *tz)
 {
   /* date-time = [ day "," ] date time */
 
@@ -1852,7 +1852,7 @@ mu_parse822_date_time (const char **p, const char *e, struct tm *tm,
       tm->tm_gmtoff = tzoffset;
 #endif
 #ifdef HAVE_STRUCT_TM_TM_ZONE
-      tm->tm_zone = tz_name;
+      tm->tm_zone = (char*) tz_name;
 #endif
     }
 
diff --git a/mailbox/system.c b/mailbox/system.c
index c842cff..bd16b4b 100644
--- a/mailbox/system.c
+++ b/mailbox/system.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2007, 2009 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
@@ -118,9 +118,10 @@ mu_authenticate_system (struct mu_auth_data **return_data MU_ARG_UNUSED,
 			void *call_data)
 {
   const struct mu_auth_data *auth_data = key;
-  char *pass = call_data;
 
 #ifdef HAVE_SHADOW_H
+  char *pass = call_data;
+  
   if (auth_data)
     {
       struct spwd *spw;
diff --git a/messages/messages.c b/messages/messages.c
index f894ae7..2b1bff1 100644
--- a/messages/messages.c
+++ b/messages/messages.c
@@ -170,9 +170,9 @@ messages_count (const char *box)
     }
 
   if (silent)
-    printf ("%d\n", count);
+    printf ("%lu\n", (unsigned long) count);
   else
-    printf (_("Number of messages in %s: %d\n"), box, count);
+    printf (_("Number of messages in %s: %lu\n"), box, (unsigned long) count);
 
   status = mu_mailbox_close (mbox);
   if (status != 0)
diff --git a/mh/folder.c b/mh/folder.c
index a9fdf7a..f13e9bc 100644
--- a/mh/folder.c
+++ b/mh/folder.c
@@ -863,7 +863,8 @@ action_pack ()
       status = mu_mailbox_get_message (mbox, i + 1, &msg);
       if (status)
 	{
-	  mu_error (_("%d: cannot get message: %s"), i, mu_strerror (status));
+	  mu_error (_("%lu: cannot get message: %s"),
+		    (unsigned long) i, mu_strerror (status));
 	  return 1;
 	}
       mh_message_number (msg, &pack_tab[i].orig);
diff --git a/mh/forw.c b/mh/forw.c
index 7d5c395..b302bec 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -389,12 +389,12 @@ finish_draft ()
       if (msgset.count == 1)
 	{
 	  fd.num = 0;
-	  str = _("Forwarded message\n");
+	  str = (char*) _("Forwarded message\n");
 	}
       else
 	{
 	  fd.num = 1;
-	  str = _("Forwarded messages\n");
+	  str = (char*) _("Forwarded messages\n");
 	}
   
       rc = mu_stream_sequential_write (stream, str, strlen (str));
@@ -406,9 +406,9 @@ finish_draft ()
       rc = mu_stream_sequential_write (stream, str, strlen (str));
       
       if (msgset.count == 1)
-	str = _("End of Forwarded message");
+	str = (char*) _("End of Forwarded message");
       else
-	str = _("End of Forwarded messages");
+	str = (char*) _("End of Forwarded messages");
       
       rc = mu_stream_sequential_write (stream, str, strlen (str));
     }
diff --git a/mh/inc.c b/mh/inc.c
index 841636c..bf89e41 100644
--- a/mh/inc.c
+++ b/mh/inc.c
@@ -250,15 +250,15 @@ main (int argc, char **argv)
       
       if ((rc = mu_mailbox_get_message (input, n, &imsg)) != 0)
 	{
-	  mu_error (_("%d: cannot get message: %s"),
-		    n, mu_strerror (rc));
+	  mu_error (_("%lu: cannot get message: %s"),
+		    (unsigned long) n, mu_strerror (rc));
 	  continue;
 	}
 
       if ((rc = mu_mailbox_append_message (output, imsg)) != 0)
 	{
-	  mu_error (_("%d: error appending message: %s"),
-		    n, mu_strerror (rc));
+	  mu_error (_("%lu: error appending message: %s"),
+		    (unsigned long) n, mu_strerror (rc));
 	  continue;
 	}
 
diff --git a/mh/mh.h b/mh/mh.h
index 8631626..cc580e2 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -365,6 +365,6 @@ void mh_comp_draft (const char *formfile, const char *defformfile,
 		    const char *draftfile);
 int check_draft_disposition (struct mh_whatnow_env *wh, int use_draft);
 
-void ali_parse_error (char *fmt, ...) MU_PRINTFLIKE(1,2); 
+void ali_parse_error (const char *fmt, ...) MU_PRINTFLIKE(1,2); 
 void ali_verbatim (int enable);
 
diff --git a/mh/mh_alias.l b/mh/mh_alias.l
index af1293d..e28da65 100644
--- a/mh/mh_alias.l
+++ b/mh/mh_alias.l
@@ -28,7 +28,8 @@ size_t ali_line_num;
 ino_t ali_source_inode;
 
 void
-va_ali_parse_error_loc (char *name, size_t line, char *fmt, va_list ap)
+va_ali_parse_error_loc (const char *name, size_t line,
+			      const char *fmt, va_list ap)
 {
   char *buf;
 
@@ -41,7 +42,7 @@ va_ali_parse_error_loc (char *name, size_t line, char *fmt, va_list ap)
 }
 
 void
-ali_parse_error_loc (char *name, size_t line, char *fmt, ...)
+ali_parse_error_loc (const char *name, size_t line, const char *fmt, ...)
 {
   va_list ap;
 
@@ -51,7 +52,7 @@ ali_parse_error_loc (char *name, size_t line, char *fmt, ...)
 }
 
 void
-ali_parse_error (char *fmt, ...)
+ali_parse_error (const char *fmt, ...)
 {
   va_list ap;
 
diff --git a/mh/mh_fmtgram.y b/mh/mh_fmtgram.y
index d1b0841..a1360cb 100644
--- a/mh/mh_fmtgram.y
+++ b/mh/mh_fmtgram.y
@@ -23,7 +23,7 @@
 #define obstack_chunk_free free
 #include <obstack.h>
 
-int yyerror (char *s);
+int yyerror (const char *s);
 int yylex ();
  
 static mh_format_t format;     /* Format structure being built */
@@ -355,7 +355,7 @@ static char *start;
 static char *curp;
 
 int
-yyerror (char *s)
+yyerror (const char *s)
 {
   int len;
   mu_error ("%s: %s", start, s);
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index 710da5b..45889a6 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2002, 2005, 2007  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005, 2007, 2009 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
diff --git a/mh/mh_init.c b/mh/mh_init.c
index 3594374..20cccda 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -529,7 +529,8 @@ mh_iterate (mu_mailbox_t mbox, mh_msgset_t *msgset,
       num = msgset->list[i];
       if ((rc = mu_mailbox_get_message (mbox, num, &msg)) != 0)
 	{
-	  mu_error (_("cannot get message %d: %s"), num, mu_strerror (rc));
+	  mu_error (_("cannot get message %lu: %s"),
+		    (unsigned long) num, mu_strerror (rc));
 	  return 1;
 	}
 
diff --git a/mh/mh_msgset.c b/mh/mh_msgset.c
index a5f3dfa..ab2ecfe 100644
--- a/mh/mh_msgset.c
+++ b/mh/mh_msgset.c
@@ -162,7 +162,8 @@ msgset_preproc_part (mu_mailbox_t mbox, char *arg, char **rest)
 	rc = mu_mailbox_get_message (mbox, num, &msg);
 	if (rc)
 	  {
-	    mu_error (_("cannot get message %d: %s"), num, mu_strerror (rc));
+	    mu_error (_("cannot get message %lu: %s"),
+		      (unsigned long) num, mu_strerror (rc));
 	    exit (1);
 	  }
 	*rest = arg + strlen (p->name);
@@ -349,7 +350,8 @@ _mh_msgset_parse (mu_mailbox_t mbox, mh_msgset_t *msgset, int argc, char **argv)
 	      n = mh_get_message (mbox, start, NULL);
 	      if (!n)
 		{
-		  mu_error (_("message %d does not exist"), start);
+		  mu_error (_("message %lu does not exist"),
+			    (unsigned long) start);
 		  exit (1);
 		}
 	      msglist[msgno++] = n;
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c
index 56551fa..d2bb3f0 100644
--- a/mh/mh_whatnow.c
+++ b/mh/mh_whatnow.c
@@ -73,7 +73,7 @@ static int
 print_short (const char *str)
 {
   int n;
-  char *s;
+  const char *s;
   
   for (n = 0; *str; str++, n++)
     {
@@ -113,12 +113,12 @@ print_short (const char *str)
 }
 
 static void
-print_descr (int n, char *s)
+print_descr (int n, const char *s)
 {
   do
     {
-      char *p;
-      char *space = NULL;
+      const char *p;
+      const char *space = NULL;
       
       for (; n < OPT_DOC_COL; n++)
 	putchar (' ');
@@ -562,7 +562,7 @@ mh_whatnow (struct mh_whatnow_env *wh, int initial_edit)
     mh_spawnp (wh->editor, wh->file);
 
   if (!wh->prompt)
-    wh->prompt = _("What now?");
+    wh->prompt = (char*) _("What now?");
   
   return _whatnow (wh, whatnow_tab);
 }
@@ -586,7 +586,7 @@ mh_disposition (const char *filename)
   int rc;
   memset (&wh, 0, sizeof (wh));
   wh.file = xstrdup (filename);
-  wh.prompt = _("Disposition?");
+  wh.prompt = (char*) _("Disposition?");
   rc = _whatnow (&wh, disp_tab);
   free (wh.file);
   return rc;
diff --git a/mh/mhn.c b/mh/mhn.c
index 766b8fc..e763271 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -1064,7 +1064,7 @@ handle_message (mu_message_t msg, msg_part_t part, msg_handler_t fun, void *data
   mu_message_is_multipart (msg, &ismime);
   if (ismime)
     {
-      unsigned int i, nparts;
+      size_t i, nparts;
 
       mu_message_get_num_parts (msg, &nparts);
 
@@ -1391,7 +1391,7 @@ show_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
       const char *p;
       size_t size = 0;
 
-      str = _("part ");
+      str = (char*) _("part ");
       mu_stream_sequential_write (out, str, strlen (str));
       str = msg_part_format (part);
       mu_stream_sequential_write (out, str, strlen (str));
diff --git a/mh/pick.y b/mh/pick.y
index 0553371..b13afcc 100644
--- a/mh/pick.y
+++ b/mh/pick.y
@@ -33,13 +33,16 @@ regex_dup (regex_t *re)
   return rp;
 }
 
+int yyerror (const char *s);
+int yylex (void); 
+ 
 static node_t *parse_tree;
 static int nesting_level;
 static int reg_flags = REG_EXTENDED|REG_ICASE;
 %}
 
 %token <string> T_COMP T_DATEFIELD  T_STRING T_CFLAGS
-%token T_LBRACE T_RBRACE T_BEFORE T_AFTER T_CFLAGS
+%token T_LBRACE T_RBRACE T_BEFORE T_AFTER 
 %left T_OR
 %left T_AND
 %left T_NOT
@@ -215,10 +218,10 @@ tokname (int tok)
 }
 
 int
-yyerror (char *s)
+yyerror (const char *s)
 {
   int tok = yylex ();
-  char *str;
+  const char *str;
   
   if (!tok)
     str = _("end of input");
diff --git a/mimeview/mimetypes.y b/mimeview/mimetypes.y
index 7e0a934..24e6ab8 100644
--- a/mimeview/mimetypes.y
+++ b/mimeview/mimetypes.y
@@ -607,8 +607,8 @@ make_functional_node (char *ident, mu_list_t list)
   {
     char *s;
     asprintf (&s,
-	      _("argument %d has wrong type in call to `%s'"),
-	      i, ident);
+	      _("argument %lu has wrong type in call to `%s'"),
+	      (unsigned long) i, ident);
     yyerror (s);
     free (s);
     return NULL;
diff --git a/python/libmu_py/debug.c b/python/libmu_py/debug.c
index aacf1de..78b5056 100644
--- a/python/libmu_py/debug.c
+++ b/python/libmu_py/debug.c
@@ -111,7 +111,7 @@ _capture_stdout (PyObject *self, PyObject *args)
     return NULL;
   if (_mu_prog_debug_stdout)
     mu_debug_printf (_mu_prog_debug_stdout, MU_DIAG_INFO, "%.*s",
-		     strlen (buf), buf);
+		     (int) strlen (buf), buf);
   return _ro (Py_None);
 }
 
@@ -123,7 +123,7 @@ _capture_stderr (PyObject *self, PyObject *args)
     return NULL;
   if (_mu_prog_debug_stderr)
     mu_debug_printf (_mu_prog_debug_stderr, MU_DIAG_ERROR, "%.*s",
-		     strlen (buf), buf);
+		     (int) strlen (buf), buf);
   return _ro (Py_None);
 }
 
diff --git a/sieve/sieve.c b/sieve/sieve.c
index e96a675..76b7c6c 100644
--- a/sieve/sieve.c
+++ b/sieve/sieve.c
@@ -342,7 +342,8 @@ _sieve_action_log (void *unused,
     }
   
   mu_message_get_uid (msg, &uid);
-  mu_diag_printf (MU_DIAG_NOTICE, _("%s on msg uid %d"), action, uid);
+  mu_diag_printf (MU_DIAG_NOTICE, _("%s on msg uid %lu"),
+		  action, (unsigned long) uid);
   
   if (fmt && strlen (fmt))
     {


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Sun Dec 27 17:59:17 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NP24z-0004S2-2p
	for mharc-commit-mailutils@gnu.org; Sun, 27 Dec 2009 17:59:17 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NP24x-0004Qz-WD
	for commit-mailutils@gnu.org; Sun, 27 Dec 2009 17:59:16 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NP24u-0004OR-V7
	for commit-mailutils@gnu.org; Sun, 27 Dec 2009 17:59:15 -0500
Received: from [199.232.76.173] (port=40153 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NP24u-0004Nx-NK
	for commit-mailutils@gnu.org; Sun, 27 Dec 2009 17:59:12 -0500
Received: from savannah.gnu.org ([199.232.41.3]:60446 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <INVALID.NOREPLY@gnu.org>)
	id 1NP24t-0007H2-Kb
	for commit-mailutils@gnu.org; Sun, 27 Dec 2009 17:59:12 -0500
Received: from [10.1.0.109] (helo=cvs.savannah.gnu.org)
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NP24s-0008Eu-KG
	for commit-mailutils@gnu.org; Sun, 27 Dec 2009 22:59:10 +0000
Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NP24r-0008EN-C7
	for commit-mailutils@gnu.org; Sun, 27 Dec 2009 22:59:10 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a600395e1fe66e0a116827f17f9bd864d4554585
X-Git-Newrev: d39f4c2db3ea8bc387cde7dcc2825598aa166ff6
Message-Id: <E1NP24r-0008EN-C7@cvs.savannah.gnu.org>
Date: Sun, 27 Dec 2009 22:59:09 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-19-gd39f4c2
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 27 Dec 2009 22:59: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=d39f4c2db3ea8bc387cde7dcc2825598aa166ff6

The branch, master has been updated
       via  d39f4c2db3ea8bc387cde7dcc2825598aa166ff6 (commit)
       via  6dad17fe877fde4f17d87bc5a0327417936dbbd8 (commit)
      from  a600395e1fe66e0a116827f17f9bd864d4554585 (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 d39f4c2db3ea8bc387cde7dcc2825598aa166ff6
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Dec 28 00:59:50 2009 +0200

    Improve configuration parsing (step 1).
    
    Remove obsolete options (these have been made hidden in
    v. 2.0).  Handle "include" and "program" after parsing
    the sources, not while reducing the tree, as was
    previously.  Retain, however, old functions for compatibility,
    making them deprecated.  Add "query" mode to mailutils-config.
    
    * include/mailutils/cfg.h (mu_cfg_node_tag): Remove
    (mu_cfg_statement): Rename to mu_cfg_node_statement.
    (mu_cfg_tree): New member: tail.
    (mu_cfg_perror): Change signature.
    (mu_cfg_vperror, mu_cfg_parse_error): New protos.
    (MU_CFG_PATH_DELIM, MU_CFG_PATH_DELIM_STR): New defines.
    (MU_PARSE_CONFIG_PLAIN,MU_CFG_FMT_LOCUS): New constant.
    (MU_CFG_DEPRECATED): New macro.
    (mu_parse_config,mu_get_config): Deprecated.
    (mu_cfg_format_parse_tree): Change signature.
    (mu_cfg_format_node, mu_cfg_parse_file): New protos.
    (mu_cfg_tree_free): Remove stale proto.
    (mu_cfg_find_node, mu_cfg_create_subtree): New protos.
    * include/mailutils/libcfg.h (mu_libcfg_parse_config): New proto.
    (mu_parse_config_files): Deprecated.
    
    * include/mailutils/mutil.h (mu_make_file_name): New proto.
    (mu_retrieve_fp, mu_register_retriever)
    (mu_retrieve): Remove unused prototypes.
    * include/mailutils/opool.h (mu_opool_union): New proto.
    
    * libmu_argp/Makefile.am (libmu_argp_a_SOURCES): Remove
    sources (see below):
    * po/POTFILES.in: Likewise.
    * libmu_argp/gsasl.c: Remove.
    * libmu_argp/pam.c: Remove.
    * libmu_argp/radius.c: Remove.
    * libmu_argp/sql.c: Remove.
    * libmu_argp/tls.c: Remove.
    * libmu_argp/virtdomain.c: Remove.
    
    * config/mailutils-config.c: New option --query (-q)
    (main): Handle query mode.
    
    * comsat/comsat.c: Define MU_CFG_COMPATIBILITY to suppress
    deprecation warnings.
    
    * bootstrap.conf (XGETTEXT_OPTIONS): Add mu_cfg
    error reporting functions.
    
    * mailbox/Makefile.am (libmailutils_la_SOURCES): Add
    mkfilename.c
    * mailbox/mkfilename.c: New file.
    
    * imap4d/imap4d.c: Remove obsolete option (hidden since 2.0)
    * libmu_argp/auth.c: Likewise.
    * libmu_argp/cmdline.c: Likewise.
    * libmu_argp/tls.c: Likewise.
    * pop3d/pop3d.c: Likewise.
    * libmu_argp/common.c: Likewise.
    (mu_common_argp_options): New option --set.
    
    * libmu_argp/muinit.c (mu_app_init): Rewrite using parse
    tree as a principal entity.
    * libmu_cfg/init.c (mu_libcfg_parse_config): New function.
    * mailbox/cfg_driver.c (make_file_name): Remove.
    (_cb_include): Use mu_make_file_name.
    (mu_build_container): Use deprecated code only unless MU_PARSE_CONFIG_PLAIN
    flag is set.
    (mu_cfg_tree_reduce): Do nothing if the tree is NULL.
    * mailbox/cfg_format.c (format_node): Print locus optionally.
    (mu_cfg_format_parse_tree): Take additional argument.
    (mu_cfg_format_node): New function.
    * mailbox/cfg_lexer.l: Update calls to diagnostic functions.
    (mu_cfg_parse_file): New function.
    (mu_get_config): Rewrite.
    * mailbox/cfg_parser.y (parse_tree): Replace with
    parse_head, parse_tail. All usages updated.
    (mu_cfg_free_node): New function.
    (mu_cfg_vperror): New function.
    (mu_cfg_perror,mu_cfg_parse_error): New function.
    (mu_cfg_tree_union): New function.
    (mu_cfg_tree_postprocess): New function.
    (mu_cfg_find_section): Use MU_CFG_PATH_DELIM instead
    of hardcoded slash.
    (mu_cfg_value_eq): New function.
    (mu_cfg_find_node): New function. Redesign of an old idea.
    (mu_cfg_create_subtree): New function.
    * mailbox/opool.c (mu_opool_union): New function.
    
    * frm/testsuite/frm/test.exp: use --set option instead of
    the obsolete --mail-folder.
    * messages/testsuite/messages/test.exp: Likewise.
    * sieve/testsuite/sieve/action.exp: Likewise.
    * mail/testsuite/lib/mail.exp: use --set option instead of
    the obsolete --mail-spool.
    * mailbox/testsuite/lib/mailbox.exp: Likewise.
    * testsuite/lib/mailutils.exp: Likewise.
    * mailbox/mutil.c (mu_register_retriever)
    (mu_retrieve): Remove unused functions.
    
    Minor fix:
    
    * frm/common.c (frm_abort): Initialize URL
    before usage.
    (frm_scan): Don't call frm_abort on a mailbox
    that was not opened successfully.

commit 6dad17fe877fde4f17d87bc5a0327417936dbbd8
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Dec 26 11:05:48 2009 +0200

    Disable whitespace compression in MH formatting code.
    
    Whitespace compression in its current form interacts badly
    with wide-character encodings. To prevent it from spoiling
    wide charater text, it is disabled by default. The user may
    turn it back on by setting "Compress-WS: yes" in his .mh_profile.
    
    * mh/mh.h (MH_FMT_COMPWS): New format flag.
    * mh/mh_format.c (COMPRESS_WS): New macro.
    (reset_fmt_defaults): Set MH_FMT_COMPWS flag
    if Compress-WS global parameter is set to true.
    (mh_format, builtin_concat): Call COMPRESS_WS.

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

Summary of changes:
 bootstrap.conf                       |    3 +
 comsat/comsat.c                      |    2 +
 config/mailutils-config.c            |   72 ++++-
 frm/common.c                         |    5 +-
 frm/testsuite/frm/test.exp           |    4 +-
 imap4d/imap4d.c                      |   41 +---
 include/mailutils/cfg.h              |   48 +++-
 include/mailutils/libcfg.h           |    4 +-
 include/mailutils/mutil.h            |    5 +-
 include/mailutils/opool.h            |    6 +-
 libmu_argp/Makefile.am               |    7 +-
 libmu_argp/auth.c                    |   30 +--
 libmu_argp/cmdline.c                 |   13 +-
 libmu_argp/common.c                  |  240 ++-------------
 libmu_argp/gsasl.c                   |   74 -----
 libmu_argp/muinit.c                  |   26 +-
 libmu_argp/pam.c                     |   73 -----
 libmu_argp/radius.c                  |   96 ------
 libmu_argp/sql.c                     |  145 ---------
 libmu_argp/tls.c                     |   21 --
 libmu_argp/virtdomain.c              |   72 ----
 libmu_cfg/init.c                     |   78 +++++
 mail/testsuite/lib/mail.exp          |    4 +-
 mailbox/Makefile.am                  |    1 +
 mailbox/cfg_driver.c                 |  123 ++++----
 mailbox/cfg_format.c                 |   28 ++-
 mailbox/cfg_lexer.l                  |   32 ++-
 mailbox/cfg_parser.y                 |  595 +++++++++++++++++++++++++++++-----
 mailbox/{asprintf.c => mkfilename.c} |   42 ++--
 mailbox/mutil.c                      |   31 --
 mailbox/opool.c                      |   45 +++-
 mailbox/testsuite/lib/mailbox.exp    |    4 +-
 messages/testsuite/messages/test.exp |    4 +-
 mh/mh.h                              |    3 +-
 mh/mh_format.c                       |   20 +-
 po/POTFILES.in                       |    5 -
 pop3d/pop3d.c                        |   81 +-----
 sieve/testsuite/sieve/action.exp     |    4 +-
 testsuite/lib/mailutils.exp          |    8 +-
 39 files changed, 970 insertions(+), 1125 deletions(-)
 delete mode 100644 libmu_argp/gsasl.c
 delete mode 100644 libmu_argp/pam.c
 delete mode 100644 libmu_argp/radius.c
 delete mode 100644 libmu_argp/sql.c
 delete mode 100644 libmu_argp/virtdomain.c
 copy mailbox/{asprintf.c => mkfilename.c} (58%)

diff --git a/bootstrap.conf b/bootstrap.conf
index 42dc0c2..3774bf2 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -53,6 +53,9 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
  --flag=mh_getyn:1:c-format\\\
  --flag=mh_getyn_interactive:1:c-format\\\
  --flag=mh_error:1:c-format\\\
+ --flag=mu_cfg_perror:3:c-format\\\
+ --flag=mu_cfg_parse_error:1:c-format\\\
+ --flag=mu_cfg_format_error:3:c-format\\\
  --flag=ali_parse_error:1:c-format\\\
  --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\
  --flag=argp_error:2:c-format\\\
diff --git a/comsat/comsat.c b/comsat/comsat.c
index de9c9cc..a3abdae 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -18,6 +18,8 @@
    MA 02110-1301 USA */
 
 #include "comsat.h"
+#define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
+#include "mailutils/libcfg.h"
 #include "mailutils/libargp.h"
 
 #ifndef PATH_DEV
diff --git a/config/mailutils-config.c b/config/mailutils-config.c
index bc675f2..1a91a0e 100644
--- a/config/mailutils-config.c
+++ b/config/mailutils-config.c
@@ -39,6 +39,9 @@ static struct argp_option options[] = {
    N_("print a list of configuration options used to build mailutils; "
       "optional arguments are interpreted as a list of configuration "
       "options to check for"), 0},
+  {"query", 'q', N_("FILE"), OPTION_ARG_OPTIONAL,
+   N_("query configuration values from FILE (default mailutils.rc)"),
+   0 },
   {"verbose", 'v', NULL, 0,
    N_("increase output verbosity"), 0},
   {0, 0, 0, 0}
@@ -48,11 +51,13 @@ enum config_mode {
   MODE_VOID,
   MODE_COMPILE,
   MODE_LINK,
-  MODE_INFO
+  MODE_INFO,
+  MODE_QUERY
 };
 
 enum config_mode mode;
 int verbose;
+char *query_config_file;
 
 static error_t
 parse_opt (int key, char *arg, struct argp_state *state)
@@ -71,6 +76,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
       mode = MODE_INFO;
       break;
 
+    case 'q':
+      if (arg)
+	query_config_file = arg;
+      mode = MODE_QUERY;
+      break;
+      
     case 'v':
       verbose++;
       break;
@@ -170,14 +181,29 @@ int
 main (int argc, char **argv)
 {
   int index;
+  int i, rc;
+  struct argp *myargp;
+  char **excapa;
+  mu_cfg_tree_t *tree = NULL;
+  mu_stream_t stream;
+  int fmtflags = 0;
   
   mu_argp_init (program_version, NULL);
-  if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, &index, NULL))
+
+  mu_set_program_name (argv[0]);
+  mu_libargp_init ();
+  for (i = 0; argp_capa[i]; i++)
+    mu_gocs_register_std (argp_capa[i]); /*FIXME*/
+  myargp = mu_argp_build (&argp, &excapa);
+  
+  if (argp_parse (myargp, argc, argv, 0, &index, NULL))
     {
-      argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name);
+      argp_help (myargp, stdout, ARGP_HELP_SEE, program_invocation_short_name);
       return 1;
     }
-
+  mu_argp_done (myargp);
+  mu_set_program_name (program_invocation_name);
+  
   argc -= index;
   argv += index;
   
@@ -298,6 +324,44 @@ main (int argc, char **argv)
 	  return found == argc ? 0 : 1;
 	}
       return 0;
+
+    case MODE_QUERY:
+      if (argc == 0)
+	{
+	  mu_error (_("not enough arguments"));
+	  return 1;
+	}
+
+      if (query_config_file)
+	{
+	  mu_load_site_rcfile = 0;
+	  mu_load_user_rcfile = 0;
+	  mu_load_rcfile = query_config_file;
+	}
+
+      if (mu_libcfg_parse_config (&tree))
+	exit (1);
+      if (!tree)
+	exit (0);
+      rc = mu_stdio_stream_create (&stream, stdout, 0);
+      if (rc)
+	{
+	  mu_error ("mu_stdio_stream_create: %s", mu_strerror (rc));
+	  exit (1);
+	}
+      if (verbose)
+	fmtflags = MU_CFG_FMT_LOCUS;
+      for ( ; argc > 0; argc--, argv++)
+	{
+	  char *path = *argv;
+	  mu_cfg_node_t *node;
+
+	  if (mu_cfg_find_node (tree->head, path, &node) == 0)
+	    {
+	      mu_cfg_format_node (stream, node, fmtflags);
+	    }
+	}
+      exit (0);
     }
   
   argp_help (&argp, stdout, ARGP_HELP_USAGE, program_invocation_short_name);
diff --git a/frm/common.c b/frm/common.c
index 7e0ed3e..e1d2372 100644
--- a/frm/common.c
+++ b/frm/common.c
@@ -527,7 +527,7 @@ frm_abort (mu_mailbox_t *mbox)
   if ((status = mu_mailbox_close (*mbox)) != 0)
     {
       mu_url_t url;
-      
+      mu_mailbox_get_url (*mbox, &url);
       mu_error (_("could not close mailbox `%s': %s"),
 		mu_url_to_string (url), mu_strerror (status));
       exit (3);
@@ -580,7 +580,8 @@ frm_scan (char *mailbox_name, frm_select_t fun, size_t *total)
     {
       mu_error (_("could not open mailbox `%s': %s"),
 		mu_url_to_string (url), mu_strerror (status));
-      frm_abort (&mbox);
+      mu_mailbox_destroy (&mbox);
+      exit (3);
     }
   else
     {
diff --git a/frm/testsuite/frm/test.exp b/frm/testsuite/frm/test.exp
index 87a3737..72b8015 100644
--- a/frm/testsuite/frm/test.exp
+++ b/frm/testsuite/frm/test.exp
@@ -1,6 +1,6 @@
 # -*- tcl -*-
 # This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007 Free Software Foundation
+# Copyright (C) 2002, 2007, 2009 Free Software Foundation
 #  
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@ mu_exec -retcode 1 -message "frm -qS" -arg -qS \
 mu_exec -retcode 1 -arg -q -message "frm -q"  \
 "There are messages in that folder."
 
-mu_exec -retcode 1 -arg "--mail-folder=$MU_SPOOL_DIR" -arg +mbox -message "frm +mbox" \
+mu_exec -retcode 1 -arg "--set mailbox.folder=$MU_SPOOL_DIR" -arg +mbox -message "frm +mbox" \
 "Sergey Poznyakoff\tMBOX"
 
 mu_exec -arg -q -arg %nonexistent -retcode 2 -message "frm -q %nonexistent" \
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index 19e2e92..6f9e84d 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -57,9 +57,6 @@ int ident_encrypt_only;
 const char *program_version = "imap4d (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon.");
 
-#define OPT_LOGIN_DISABLED  256
-#define OPT_TLS_REQUIRED    257
-#define OPT_CREATE_HOME_DIR 258
 #define OPT_PREAUTH         259
 #define OPT_FOREGROUND      260
 
@@ -69,21 +66,9 @@ static struct argp_option options[] = {
   { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL,
     N_("runs in daemon mode with a maximum of NUMBER children"), 0 },
 
-  {"other-namespace", 'O', N_("PATHLIST"), OPTION_HIDDEN,
-   N_("set the `other' namespace"), 0},
-  {"shared-namespace", 'S', N_("PATHLIST"), OPTION_HIDDEN,
-   N_("set the `shared' namespace"), 0},
-  {"login-disabled", OPT_LOGIN_DISABLED, NULL, OPTION_HIDDEN,
-   N_("disable LOGIN command")},
-  {"create-home-dir", OPT_CREATE_HOME_DIR, N_("MODE"),
-   OPTION_ARG_OPTIONAL|OPTION_HIDDEN,
-   N_("create home directory, if it does not exist")},
   {"preauth", OPT_PREAUTH, NULL, 0,
    N_("start in preauth mode") },
-#ifdef WITH_TLS
-  {"tls-required", OPT_TLS_REQUIRED, NULL, OPTION_HIDDEN,
-   N_("always require STARTTLS before entering authentication phase")},
-#endif
+  
   {NULL, 0, NULL, 0, NULL, 0}
 };
 
@@ -134,30 +119,6 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state)
       mu_argp_node_list_new (&lst, "foreground", "yes");
       break;
       
-    case 'O':
-      mu_argp_node_list_new (&lst, "other-namespace", arg);
-      break;
-
-    case 'S':
-      mu_argp_node_list_new (&lst, "shared-namespace", arg);
-      break;
-
-    case OPT_LOGIN_DISABLED:
-      mu_argp_node_list_new (&lst, "login-disabled", "yes");
-      break;
-
-    case OPT_CREATE_HOME_DIR:
-      mu_argp_node_list_new (&lst, "create-home-dir", "yes");
-      if (arg)
-	mu_argp_node_list_new (&lst, "home-dir-mode", arg);
-      break;
-	
-#ifdef WITH_TLS
-    case OPT_TLS_REQUIRED:
-      mu_argp_node_list_new (&lst, "tls-required", "yes");
-      break;
-#endif
-
     case OPT_PREAUTH:
       preauth_mode = preauth_stdio;
       break;
diff --git a/include/mailutils/cfg.h b/include/mailutils/cfg.h
index 8994609..8141d12 100644
--- a/include/mailutils/cfg.h
+++ b/include/mailutils/cfg.h
@@ -1,5 +1,5 @@
 /* cfg.h -- general-purpose configuration file parser 
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 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
@@ -58,8 +58,7 @@ struct mu_config_value
 enum mu_cfg_node_type
   {
     mu_cfg_node_undefined,
-    mu_cfg_statement,
-    mu_cfg_node_tag=mu_cfg_statement, /* FIXME: remove */
+    mu_cfg_node_statement,
     mu_cfg_node_param
   };
 
@@ -81,19 +80,24 @@ struct mu_cfg_node
 
 struct mu_cfg_tree
 {
-  mu_cfg_node_t *node;
+  mu_cfg_node_t *head, *tail;
   mu_debug_t debug;
   mu_opool_t pool;
 };
 
 int mu_cfg_parse (mu_cfg_tree_t **ptree);
+int mu_cfg_tree_union (mu_cfg_tree_t **pa, mu_cfg_tree_t **pb);
+int mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, int flags);
 
 extern mu_cfg_locus_t mu_cfg_locus;
 
 mu_opool_t mu_cfg_lexer_pool (void);
 
-void mu_cfg_perror (const mu_cfg_locus_t *, const char *, ...)
-      MU_PRINTFLIKE(2,3);
+void mu_cfg_vperror (mu_debug_t, const mu_cfg_locus_t *,
+		     const char *fmt, va_list ap);
+void mu_cfg_perror (mu_debug_t debug, const mu_cfg_locus_t *,
+		    const char *, ...) MU_PRINTFLIKE(3,4);
+void mu_cfg_parse_error (const char *, ...) MU_PRINTFLIKE(1,2);
 void mu_cfg_format_error (mu_debug_t debug, size_t, const char *fmt, ...)
       MU_PRINTFLIKE(3,4);
 
@@ -205,6 +209,9 @@ struct mu_cfg_cidr
   unsigned long mask;
 };
 
+#define MU_CFG_PATH_DELIM '.'
+#define MU_CFG_PATH_DELIM_STR "."
+  
 int mu_config_create_container (struct mu_cfg_cont **pcont,
 				enum mu_cfg_cont_type type);
 int mu_config_clone_container (struct mu_cfg_cont *cont);
@@ -240,19 +247,32 @@ mu_debug_t mu_cfg_get_debug (void);
 #define MU_PARSE_CONFIG_GLOBAL  0x1
 #define MU_PARSE_CONFIG_VERBOSE 0x2
 #define MU_PARSE_CONFIG_DUMP    0x4
+#define MU_PARSE_CONFIG_PLAIN   0x8
+
+#ifdef MU_CFG_COMPATIBILITY
+# define MU_CFG_DEPRECATED
+#else
+# define MU_CFG_DEPRECATED __attribute__ ((deprecated))
+#endif
 
 int mu_parse_config (const char *file, const char *progname,
 		     struct mu_cfg_param *progparam, int flags,
-		     void *target_ptr);
+		     void *target_ptr) MU_CFG_DEPRECATED;
 
 int mu_cfg_parse_boolean (const char *str, int *res);
 
 extern int mu_cfg_parser_verbose;
 extern size_t mu_cfg_error_count;
 
+#define MU_CFG_FMT_LOCUS 0x01
+  
 void mu_cfg_format_docstring (mu_stream_t stream, const char *docstring,
 			      int level);
-void mu_cfg_format_parse_tree (mu_stream_t stream, struct mu_cfg_tree *tree);
+void mu_cfg_format_parse_tree (mu_stream_t stream, struct mu_cfg_tree *tree,
+			       int flags);
+void mu_cfg_format_node (mu_stream_t stream, const mu_cfg_node_t *node,
+			 int flags);
+  
 void mu_cfg_format_container (mu_stream_t stream, struct mu_cfg_cont *cont);
 void mu_format_config_tree (mu_stream_t stream, const char *progname,
 			    struct mu_cfg_param *progparam, int flags);
@@ -265,14 +285,16 @@ int mu_cfg_string_value_cb (mu_debug_t debug, mu_config_value_t *val,
 			    int (*fun) (mu_debug_t, const char *, void *),
 			    void *data);
 
+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);
-
+		   void *target_ptr) MU_CFG_DEPRECATED;
 
 int mu_cfg_tree_create (struct mu_cfg_tree **ptree);
 void mu_cfg_tree_set_debug (struct mu_cfg_tree *tree, mu_debug_t debug);
-void mu_cfg_tree_free (struct mu_cfg_tree *tree, void *mem);
 mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
 					enum mu_cfg_node_type type,
 					const mu_cfg_locus_t *loc,
@@ -281,6 +303,10 @@ mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
 					mu_cfg_node_t *node);
 void mu_cfg_tree_add_node (mu_cfg_tree_t *tree, mu_cfg_node_t *node);
 
+int mu_cfg_find_node (mu_cfg_node_t *tree, const char *path,
+		      mu_cfg_node_t **pnode);
+int mu_cfg_create_subtree (const char *path, mu_cfg_node_t **pnode);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/libcfg.h b/include/mailutils/libcfg.h
index 79dda00..20afa52 100644
--- a/include/mailutils/libcfg.h
+++ b/include/mailutils/libcfg.h
@@ -50,7 +50,9 @@ extern int mu_register_cfg_capa (const char *name,
 
 extern void mu_libcfg_init (char **cnames);
 extern int mu_parse_config_files (struct mu_cfg_param *param,
-				  void *target_ptr);
+				  void *target_ptr) MU_CFG_DEPRECATED;
+int mu_libcfg_parse_config (mu_cfg_tree_t **ptree);
+  
 extern void mu_acl_cfg_init (void);
 
 #define __mu_common_cat2__(a,b) a ## b
diff --git a/include/mailutils/mutil.h b/include/mailutils/mutil.h
index 7254f52..a610e23 100644
--- a/include/mailutils/mutil.h
+++ b/include/mailutils/mutil.h
@@ -99,6 +99,7 @@ extern int mu_aget_user_email_domain (char **pdomain);
  */
 extern char *mu_get_user_email (const char *name);
 
+extern char *mu_make_file_name (const char *dir, const char *file);  
 extern char *mu_normalize_path (char *path);
 extern int mu_tempfile (const char *tmpdir, char **namep);
 extern char *mu_tempname (const char *tmpdir);
@@ -108,10 +109,6 @@ extern char * mu_getcwd (void);
   
 extern int mu_spawnvp(const char *prog, char *av[], int *stat);
 
-typedef void *(*mu_retrieve_fp) (void *);
-extern void mu_register_retriever (mu_list_t *pflist, mu_retrieve_fp fun);
-extern void * mu_retrieve (mu_list_t flist, void *data);
-
 extern int mu_unroll_symlink (char *out, size_t outsz, const char *in);
 
 extern char * mu_expand_path_pattern (const char *pattern, const char *username);
diff --git a/include/mailutils/opool.h b/include/mailutils/opool.h
index 5cb16c1..25f6417 100644
--- a/include/mailutils/opool.h
+++ b/include/mailutils/opool.h
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 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
@@ -32,6 +32,10 @@ int mu_opool_create (mu_opool_t *pret, int memerr);
 int mu_opool_set_bucket_size (mu_opool_t opool, size_t size);
 int mu_opool_get_bucket_size (mu_opool_t opool, size_t *psize);
 
+/* Merge all data from *SRC into *DST.  If the latter is NULL, create
+   it.  On success, free *SRC and initialize it with NULL. */
+int mu_opool_union (mu_opool_t *dst, mu_opool_t *src);
+
 /* Clear all data from the pool, so next mu_opool_append* call will
    begin a new object. */
 void mu_opool_clear (mu_opool_t opool);
diff --git a/libmu_argp/Makefile.am b/libmu_argp/Makefile.am
index 435dcd8..03635aa 100644
--- a/libmu_argp/Makefile.am
+++ b/libmu_argp/Makefile.am
@@ -32,14 +32,9 @@ libmu_argp_a_SOURCES =\
  cmdline.h\
  common.c\
  compat.c\
- gsasl.c\
  mu_argp.h\
  mu_argp.c\
  muinit.c\
- pam.c\
- radius.c\
  sieve.c\
- sql.c\
- tls.c\
- virtdomain.c 
+ tls.c
 
diff --git a/libmu_argp/auth.c b/libmu_argp/auth.c
index fabacf7..e21ba1e 100644
--- a/libmu_argp/auth.c
+++ b/libmu_argp/auth.c
@@ -28,11 +28,7 @@
 /* ************************************************************************* */
 
 enum {
-  OPT_AUTHORIZATION=256,
-  OPT_AUTHENTICATION,
-  OPT_CLEAR_AUTHORIZATION,
-  OPT_CLEAR_AUTHENTICATION,
-  OPT_DEBUG_AUTH
+  OPT_DEBUG_AUTH=256
 };
 
 static error_t mu_auth_argp_parser (int key, char *arg,
@@ -40,14 +36,6 @@ static error_t mu_auth_argp_parser (int key, char *arg,
 
 /* Options used by programs that use extended authentication mechanisms. */
 static struct argp_option mu_auth_argp_option[] = {
-  { "authentication", OPT_AUTHENTICATION, N_("MODLIST"), OPTION_HIDDEN,
-    N_("set the list of modules to be used for authentication"), 0 },
-  { "authorization", OPT_AUTHORIZATION, N_("MODLIST"), OPTION_HIDDEN,
-    N_("set list of modules to be used for authorization"), 0 },
-  { "clear-authorization", OPT_CLEAR_AUTHORIZATION, NULL, OPTION_HIDDEN,
-    N_("clear the list of authorization modules"), 0 },
-  { "clear-authentication", OPT_CLEAR_AUTHENTICATION, NULL, OPTION_HIDDEN,
-    N_("clear the list of authentication modules"), 0 },
   { "debug-auth", OPT_DEBUG_AUTH, NULL, 0,
     N_("debug authentication functions") },
   { NULL,      0, NULL, 0, NULL, 0 }
@@ -92,22 +80,6 @@ mu_auth_argp_parser (int key, char *arg, struct argp_state *state)
       mu_argp_node_list_finish (&lst, "auth", NULL);
       break;
 
-    case OPT_AUTHORIZATION:
-      mu_argp_node_list_new (&lst, "authorization", arg);
-      break;
-      
-    case OPT_AUTHENTICATION:
-      mu_argp_node_list_new (&lst, "authentication", arg);
-      break;
-      
-    case OPT_CLEAR_AUTHENTICATION:
-      mu_argp_node_list_new (&lst, "authentication", "clear");
-      break;
-      
-    case OPT_CLEAR_AUTHORIZATION:
-      mu_argp_node_list_new (&lst, "authorization", "clear");
-      break;
-
     case OPT_DEBUG_AUTH:
       auth_set_debug ();
       break;
diff --git a/libmu_argp/cmdline.c b/libmu_argp/cmdline.c
index d5e835b..7504776 100644
--- a/libmu_argp/cmdline.c
+++ b/libmu_argp/cmdline.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 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
@@ -26,17 +26,9 @@ static struct mu_cmdline_capa *all_cmdline_capa[] = {
   &mu_common_cmdline,
   &mu_logging_cmdline,
   &mu_license_cmdline,
-  &mu_mailbox_cmdline,
-  &mu_locking_cmdline,
-  &mu_address_cmdline,
   &mu_mailer_cmdline,
   &mu_debug_cmdline,
-  &mu_pam_cmdline,
-  &mu_gsasl_cmdline,
   &mu_tls_cmdline,
-  &mu_radius_cmdline,
-  &mu_sql_cmdline,
-  &mu_virtdomain_cmdline,
   &mu_auth_cmdline,
   &mu_sieve_cmdline,
   NULL
@@ -104,7 +96,7 @@ mu_argp_node_list_finish (struct mu_argp_node_list *lst, char *tag,
     return;
   if (tag)
     node = mu_cfg_tree_create_node (mu_argp_tree,
-				    mu_cfg_node_tag,
+				    mu_cfg_node_statement,
 				    NULL,
 				    tag, label,
 				    lst->head);
@@ -113,3 +105,4 @@ mu_argp_node_list_finish (struct mu_argp_node_list *lst, char *tag,
   mu_cfg_tree_add_node (mu_argp_tree, node);
   mu_argp_node_list_init (lst);
 }
+
diff --git a/libmu_argp/common.c b/libmu_argp/common.c
index cb17690..aff478c 100644
--- a/libmu_argp/common.c
+++ b/libmu_argp/common.c
@@ -38,18 +38,11 @@ enum {
   OPT_RCFILE_LINT,
   OPT_RCFILE_VERBOSE,
   OPT_LOG_FACILITY,          
-  OPT_LOCK_FLAGS,            
-  OPT_LOCK_RETRY_COUNT,      
-  OPT_LOCK_RETRY_TIMEOUT,    
-  OPT_LOCK_EXPIRE_TIMEOUT,   
-  OPT_LOCK_EXTERNAL_PROGRAM, 
   OPT_LICENSE,
-  OPT_MAILBOX_PATTERN,
-  OPT_MAILBOX_TYPE,
-  OPT_MAIL_FOLDER,
   OPT_DEBUG_LEVEL,
   OPT_LINE_INFO,
-  OPT_HELP_CONFIG
+  OPT_HELP_CONFIG,
+  OPT_SET
 };
 
 static struct argp_option mu_common_argp_options[] = 
@@ -74,9 +67,21 @@ static struct argp_option mu_common_argp_options[] =
   { "config-lint", OPT_RCFILE_LINT, NULL, 0,
     N_("check configuration file syntax and exit"), 0 },
   { "rcfile-lint", 0, NULL, OPTION_ALIAS, NULL },
+  { "set", OPT_SET, N_("PARAM=VALUE"), 0,
+    N_("set configuration parameter"), 0 },
   { NULL, 0, NULL, 0, NULL, 0 }
 };
 
+static void
+set_config_param (const char *path, struct argp_state *state)
+{
+  mu_cfg_node_t *node;
+  int rc = mu_cfg_create_subtree (path, &node);
+  if (rc)
+    argp_error (state, "cannot create node: %s", mu_strerror (rc));
+  mu_cfg_tree_add_node (mu_argp_tree, node);
+}
+
 static error_t
 mu_common_argp_parser (int key, char *arg, struct argp_state *state)
 {
@@ -110,7 +115,11 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state)
     case OPT_HELP_CONFIG:
       mu_help_config_mode = 1;
       break;
-	
+
+    case OPT_SET:
+      set_config_param (arg, state);
+      break;
+      
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -231,215 +240,6 @@ struct mu_cmdline_capa mu_license_cmdline = {
 
 
 /* ************************************************************************* */
-/* Mailbox                                                                   */
-/* ************************************************************************* */
-
-/* Options used by programs that access mailboxes. */
-static struct argp_option mu_mailbox_argp_option[] = {
-  { "mail-spool", 'm', N_("URL"), OPTION_HIDDEN,
-    N_("use specified URL as a mailspool directory"), 0 },
-  { "mailbox-pattern", OPT_MAILBOX_PATTERN, N_("pat"), OPTION_HIDDEN,
-    "", 0 },
-  { "mailbox-type", OPT_MAILBOX_TYPE, N_("PROTO"), OPTION_HIDDEN,
-    N_("default mailbox type to use"), 0 },
-  { "mail-folder", OPT_MAIL_FOLDER, N_("DIR"), OPTION_HIDDEN,
-    N_("default user mail folder"), 0 },
-  { NULL }
-};
-
-static error_t
-mu_mailbox_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-  
-  switch (key)
-    {
-      /* mailbox */
-    case 'm':
-      mu_argp_node_list_new (&lst, "mail-spool", arg);
-      break;
-
-    case OPT_MAILBOX_PATTERN:
-      mu_argp_node_list_new (&lst, "mailbox-pattern", arg);
-      break;
-      
-    case OPT_MAILBOX_TYPE:
-      mu_argp_node_list_new (&lst, "mailbox-type", arg);
-      break;
-
-    case OPT_MAIL_FOLDER:
-      mu_argp_node_list_new (&lst, "folder", arg);
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "mailbox", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-struct argp mu_mailbox_argp = {
-  mu_mailbox_argp_option,
-  mu_mailbox_argp_parser,
-};
-
-struct argp_child mu_mailbox_argp_child = {
-  &mu_mailbox_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_mailbox_cmdline = {
-  "mailbox", &mu_mailbox_argp_child
-};
-
-
-/* ************************************************************************* */
-/* Locking                                                                   */
-/* ************************************************************************* */
-
-/* Options used by programs that access mailboxes. */
-static struct argp_option mu_locking_argp_option[] = {
-  {"lock-flags", OPT_LOCK_FLAGS, N_("FLAGS"), OPTION_HIDDEN,
-   N_("default locker flags (E=external, R=retry, T=time, P=pid)"), 0},
-  {"lock-retry-timeout", OPT_LOCK_RETRY_TIMEOUT, N_("SECONDS"), OPTION_HIDDEN,
-   N_("set timeout for acquiring the lockfile") },
-  {"lock-retry-count", OPT_LOCK_RETRY_COUNT, N_("NUMBER"), OPTION_HIDDEN,
-   N_("set the maximum number of times to retry acquiring the lockfile") },
-  {"lock-expire-timeout", OPT_LOCK_EXPIRE_TIMEOUT, N_("SECONDS"),
-   OPTION_HIDDEN,
-   N_("number of seconds after which the lock expires"), },
-  {"external-locker", OPT_LOCK_EXTERNAL_PROGRAM, N_("PATH"), OPTION_HIDDEN,
-   N_("set full path to the external locker program") },
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static error_t
-mu_locking_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-
-  switch (key)
-    {
-    case OPT_LOCK_FLAGS:
-      mu_argp_node_list_new (&lst, "flags", arg);
-      break;
-
-    case OPT_LOCK_RETRY_COUNT:
-      mu_argp_node_list_new (&lst, "retry-count", arg);
-      break;
-	  
-    case OPT_LOCK_RETRY_TIMEOUT:
-      mu_argp_node_list_new (&lst, "retry-timeout", arg);
-      break;
-
-    case OPT_LOCK_EXPIRE_TIMEOUT:
-      mu_argp_node_list_new (&lst, "expire-timeout", arg);
-      break;
-
-    case OPT_LOCK_EXTERNAL_PROGRAM:
-      mu_argp_node_list_new (&lst, "external-locker", arg);
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "locking", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-struct argp mu_locking_argp = {
-  mu_locking_argp_option,
-  mu_locking_argp_parser,
-};
-
-struct argp_child mu_locking_argp_child = {
-  &mu_locking_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_locking_cmdline = {
-  "locking", &mu_locking_argp_child
-};
-  
-
-/* ************************************************************************* */
-/* Address                                                                   */
-/* ************************************************************************* */
-
-/* Options used by programs that do address mapping. */
-static struct argp_option mu_address_argp_option[] = {
-  {"email-addr", 'E', N_("EMAIL"), OPTION_HIDDEN,
-   N_("set current user's email address (default is loginname@defaultdomain)"), 0},
-  {"email-domain", 'D', N_("DOMAIN"), OPTION_HIDDEN,
-   N_("set domain for unqualified user names (default is this host)"), 0},
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static error_t
-mu_address_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-
-  switch (key)
-    {
-    case 'E':
-      mu_argp_node_list_new (&lst, "email-addr", arg);
-      break;
-
-    case 'D':
-      mu_argp_node_list_new (&lst, "email-domain", arg);
-      break;
-
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "address", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-  
-struct argp mu_address_argp = {
-  mu_address_argp_option,
-  mu_address_argp_parser,
-};
-
-struct argp_child mu_address_argp_child = {
-  &mu_address_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_address_cmdline = {
-  "address", &mu_address_argp_child
-};
-
-
-/* ************************************************************************* */
 /* Mailer                                                                    */
 /* ************************************************************************* */
 
@@ -511,7 +311,7 @@ mu_debug_argp_parser (int key, char *arg, struct argp_state *state)
     {
     case OPT_DEBUG_LEVEL:
       mu_global_debug_from_string (arg, "command line");
-      //mu_argp_node_list_new (&lst, "level", arg);
+      /*mu_argp_node_list_new (&lst, "level", arg);*/
       break;
 
     case OPT_LINE_INFO:
diff --git a/libmu_argp/gsasl.c b/libmu_argp/gsasl.c
deleted file mode 100644
index e7d6996..0000000
--- a/libmu_argp/gsasl.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2009 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, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "cmdline.h"
-#include <mailutils/gsasl.h>
-
-#define OPT_CRAM_PASSWD 256
-
-static struct argp_option _gsasl_argp_options[] = {
-  {"cram-passwd", OPT_CRAM_PASSWD, N_("FILE"), OPTION_HIDDEN,
-   N_("specify password file for CRAM-MD5 authentication"), 0},
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static error_t
-_gsasl_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-
-  switch (key)
-    {
-    case OPT_CRAM_PASSWD:
-      mu_argp_node_list_new (&lst, "cram-passwd", arg);
-      break;
-
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "gsasl", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp _gsasl_argp = {
-  _gsasl_argp_options,
-  _gsasl_argp_parser
-};
-
-struct argp_child mu_gsasl_argp_child = {
-  &_gsasl_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_gsasl_cmdline = {
-  "gsasl", &mu_gsasl_argp_child
-};
-
-
diff --git a/libmu_argp/muinit.c b/libmu_argp/muinit.c
index ad82bfb..6607b07 100644
--- a/libmu_argp/muinit.c
+++ b/libmu_argp/muinit.c
@@ -66,7 +66,7 @@ mu_app_init (struct argp *myargp, const char **capa,
   struct argp *argp;
   struct argp argpnull = { 0 };
   char **excapa;
-  int cfgflags = 0;
+  struct mu_cfg_tree *parse_tree = NULL;
   
   mu_set_program_name (argv[0]);
   mu_libargp_init ();
@@ -119,16 +119,22 @@ mu_app_init (struct argp *myargp, const char **capa,
       mu_stream_destroy (&stream, NULL);
       exit (0);
     }
-  else
-    mu_parse_config_files (cfg_param, data);
-
-  if (mu_cfg_parser_verbose)
-    cfgflags |= MU_PARSE_CONFIG_VERBOSE;
-  if (mu_cfg_parser_verbose > 1)
-    cfgflags |= MU_PARSE_CONFIG_DUMP;
-  rc = mu_cfg_tree_reduce (mu_argp_tree, mu_program_name, cfg_param,
-			   cfgflags, data);
 
+  rc = mu_libcfg_parse_config (&parse_tree);
+  if (rc == 0)
+    {
+      int cfgflags = MU_PARSE_CONFIG_PLAIN;
+
+      if (mu_cfg_parser_verbose)
+	cfgflags |= MU_PARSE_CONFIG_VERBOSE;
+      if (mu_cfg_parser_verbose > 1)
+	cfgflags |= MU_PARSE_CONFIG_DUMP;
+      mu_cfg_tree_postprocess (mu_argp_tree, cfgflags);
+      mu_cfg_tree_union (&parse_tree, &mu_argp_tree);
+      rc = mu_cfg_tree_reduce (parse_tree, mu_program_name, cfg_param,
+			       cfgflags, data);
+    }
+  
   if (mu_rcfile_lint)
     {
       if (rc || mu_cfg_error_count)
diff --git a/libmu_argp/pam.c b/libmu_argp/pam.c
deleted file mode 100644
index d53a37d..0000000
--- a/libmu_argp/pam.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2009 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, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "cmdline.h"
-#include <mailutils/pam.h>
-
-#define OPT_PAM_SERVICE 256
-
-static error_t
-mu_pam_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-
-  switch (key)
-    {
-    case OPT_PAM_SERVICE:
-      mu_argp_node_list_new (&lst, "service", arg);
-      break;
-
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "pam", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp_option mu_pam_argp_option[] = {
-  { "pam-service", OPT_PAM_SERVICE, N_("STRING"), OPTION_HIDDEN,
-    N_("use STRING as PAM service name"), 0},
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static struct argp mu_pam_argp = {
-  mu_pam_argp_option,
-  mu_pam_argp_parser,
-};
-
-struct argp_child mu_pam_argp_child = {
-  &mu_pam_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_pam_cmdline = {
-  "pam", &mu_pam_argp_child
-};
diff --git a/libmu_argp/radius.c b/libmu_argp/radius.c
deleted file mode 100644
index b0f186a..0000000
--- a/libmu_argp/radius.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2009 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, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "cmdline.h"
-#include <mailutils/radius.h>
-
-enum {
-  OPT_AUTH_REQUEST = 256,
-  OPT_GETPWNAM_REQUEST,
-  OPT_GETPWUID_REQUEST, 
-  OPT_RADIUS_DIR
-};
-
-static struct argp_option mu_radius_argp_option[] = {
-  { "radius-auth-request", OPT_AUTH_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
-    N_("radius request to authenticate the user"), 0 },
-  { "radius-getpwnam-request", OPT_GETPWNAM_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
-    N_("radius request to retrieve a passwd entry based on username"), 0 },
-  { "radius-getpwuid-request", OPT_GETPWUID_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
-    N_("radius request to retrieve a passwd entry based on UID"), 0 },
-  { "radius-directory", OPT_RADIUS_DIR, N_("DIR"), OPTION_HIDDEN,
-    N_("set name of the radius configuration directory"), 0 },
-  { NULL }
-};
-
-static error_t
-mu_radius_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-
-  switch (key)
-    {
-    case OPT_AUTH_REQUEST:
-      mu_argp_node_list_new (&lst, "auth-request", arg);
-      break;
-      
-    case OPT_GETPWNAM_REQUEST:
-      mu_argp_node_list_new (&lst, "getwnam-request", arg);
-      break;
-      
-    case OPT_GETPWUID_REQUEST:
-      mu_argp_node_list_new (&lst, "getwuid-request", arg);
-      break;
-      
-    case OPT_RADIUS_DIR:
-      mu_argp_node_list_new (&lst, "directory", arg);
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "radius", NULL);
-      break;
-
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp mu_radius_argp = {
-  mu_radius_argp_option,
-  mu_radius_argp_parser,
-};
-
-struct argp_child mu_radius_argp_child = {
-  &mu_radius_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_radius_cmdline = {
-  "radius", &mu_radius_argp_child
-};
diff --git a/libmu_argp/sql.c b/libmu_argp/sql.c
deleted file mode 100644
index d009653..0000000
--- a/libmu_argp/sql.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2009 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, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "cmdline.h"
-
-enum {
-  OPT_SQL_INTERFACE = 256,        
-  OPT_SQL_GETPWNAM,         
-  OPT_SQL_GETPWUID,         
-  OPT_SQL_GETPASS,          
-  OPT_SQL_HOST,             
-  OPT_SQL_USER,             
-  OPT_SQL_PASSWD,           
-  OPT_SQL_DB,               
-  OPT_SQL_PORT,             
-  OPT_SQL_MU_PASSWORD_TYPE, 
-  OPT_SQL_FIELD_MAP,        
-};
-
-static struct argp_option mu_sql_argp_option[] = {
-  {"sql-interface", OPT_SQL_INTERFACE, N_("NAME"), OPTION_HIDDEN,
-   N_("type of SQL interface to use"), },
-  {"sql-getpwnam", OPT_SQL_GETPWNAM, N_("QUERY"), OPTION_HIDDEN,
-   N_("SQL query to retrieve a passwd entry based on username"), 0},
-  {"sql-getpwuid", OPT_SQL_GETPWUID, N_("QUERY"), OPTION_HIDDEN,
-   N_("SQL query to retrieve a passwd entry based on UID"), 0},
-  {"sql-getpass", OPT_SQL_GETPASS, N_("QUERY"), OPTION_HIDDEN,
-   N_("SQL query to retrieve a password from the database"), 0},
-  {"sql-host", OPT_SQL_HOST, N_("HOSTNAME"), OPTION_HIDDEN,
-   N_("name or IP of MySQL server to connect to"), 0},
-  {"sql-user", OPT_SQL_USER, N_("NAME"), OPTION_HIDDEN,
-   N_("SQL user name"), 0},
-  {"sql-passwd", OPT_SQL_PASSWD, N_("STRING"), OPTION_HIDDEN,
-   N_("SQL connection password"), 0},
-  {"sql-db", OPT_SQL_DB, N_("STRING"), OPTION_HIDDEN,
-   N_("name of the database to connect to"), 0},
-  {"sql-port", OPT_SQL_PORT, N_("NUMBER"), OPTION_HIDDEN,
-   N_("port to use"), 0},
-  {"sql-password-type", OPT_SQL_MU_PASSWORD_TYPE, N_("STRING"), OPTION_HIDDEN,
-   N_("type of password returned by --sql-getpass query. STRING is one of: plain, hash, scrambled"), 0},
-  {"sql-field-map", OPT_SQL_FIELD_MAP, N_("MAP"), OPTION_HIDDEN,
-   N_("declare a name translation map for SQL fields in results of sql-getpwnam and "
-      "sql-getpwuid queries"), 0},
-  { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static error_t
-mu_sql_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-  
-  switch (key)
-    {
-    case OPT_SQL_INTERFACE:
-      mu_argp_node_list_new (&lst, "interface", arg);
-      break;
-      
-    case OPT_SQL_GETPWNAM:
-      mu_argp_node_list_new (&lst, "getpwnam", arg);
-      break;
-
-    case OPT_SQL_GETPWUID:
-      mu_argp_node_list_new (&lst, "getpwuid", arg);
-      break;
-
-    case OPT_SQL_GETPASS:
-      mu_argp_node_list_new (&lst, "getpass", arg);
-      break;
-
-    case OPT_SQL_HOST:
-      mu_argp_node_list_new (&lst, "host", arg);
-      break;
-
-    case OPT_SQL_USER:
-      mu_argp_node_list_new (&lst, "user", arg);
-      break;
-
-    case OPT_SQL_PASSWD:
-      mu_argp_node_list_new (&lst, "passwd", arg);
-      break;
-
-    case OPT_SQL_DB:
-      mu_argp_node_list_new (&lst, "db", arg);
-      break;
-
-    case OPT_SQL_PORT:
-      mu_argp_node_list_new (&lst, "port", arg);
-      break;
-
-    case OPT_SQL_MU_PASSWORD_TYPE:
-      mu_argp_node_list_new (&lst, "password-type", arg);
-      break;
-
-    case OPT_SQL_FIELD_MAP:
-      mu_argp_node_list_new (&lst, "field-map", arg);
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "sql", NULL);
-      break;
-
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp mu_sql_argp = {
-  mu_sql_argp_option,
-  mu_sql_argp_parser,
-};
-
-struct argp_child mu_sql_argp_child = {
-  &mu_sql_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_sql_cmdline = {
-  "sql", &mu_sql_argp_child
-};
diff --git a/libmu_argp/tls.c b/libmu_argp/tls.c
index 44d5e2b..a5f0cbe 100644
--- a/libmu_argp/tls.c
+++ b/libmu_argp/tls.c
@@ -24,18 +24,9 @@
 
 enum {
   OPT_TLS = 256,         
-  OPT_SSL_CERT,   
-  OPT_SSL_KEY,    
-  OPT_SSL_CAFILE
 };
   
 static struct argp_option _tls_argp_options[] = {
-  {"ssl-cert", OPT_SSL_CERT, N_("FILE"), OPTION_HIDDEN,
-   N_("specify SSL certificate file"), 0},
-  {"ssl-key", OPT_SSL_KEY, N_("FILE"), OPTION_HIDDEN,
-   N_("specify SSL certificate key"), },
-  {"ssl-cafile", OPT_SSL_CAFILE, N_("FILE"), OPTION_HIDDEN,
-   N_("specify trusted CAs file"), 0},
   {"tls", OPT_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL,
    N_("enable TLS support") },
   {NULL, 0, NULL, 0, NULL, 0}
@@ -52,18 +43,6 @@ _tls_argp_parser (int key, char *arg, struct argp_state *state)
       mu_argp_node_list_new (&lst, "enable", arg ? arg : "yes");
       break;
       
-    case OPT_SSL_CERT:
-      mu_argp_node_list_new (&lst, "ssl-cert", arg);
-      break;
-
-    case OPT_SSL_KEY:
-      mu_argp_node_list_new (&lst, "ssl-key", arg);
-      break;
-
-    case OPT_SSL_CAFILE:
-      mu_argp_node_list_new (&lst, "ssl-cafile", arg);
-      break;
-
     case ARGP_KEY_INIT:
       mu_argp_node_list_init (&lst);
       break;
diff --git a/libmu_argp/virtdomain.c b/libmu_argp/virtdomain.c
deleted file mode 100644
index bd39247..0000000
--- a/libmu_argp/virtdomain.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2009 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, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "cmdline.h"
-
-#define OPT_PWDDIR 256
-
-static error_t
-mu_virt_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static struct mu_argp_node_list lst;
-
-  switch (key)
-    {
-    case OPT_PWDDIR:
-      mu_argp_node_list_new (&lst, "passwd-dir", arg);
-      break;
-
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (&lst, "virtdomain", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp_option mu_virt_argp_option[] = {
-  { "virtual-passwd-dir", OPT_PWDDIR, N_("DIR"), OPTION_HIDDEN,
-    N_("search for virtual passwd file in DIR"), 0},
-    { NULL,      0, NULL, 0, NULL, 0 }
-};
-
-static struct argp mu_virt_argp = {
-  mu_virt_argp_option,
-  mu_virt_argp_parser,
-};
-
-struct argp_child mu_virt_argp_child = {
-  &mu_virt_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_virtdomain_cmdline = {
-  "virtdomain", &mu_virt_argp_child
-};
diff --git a/libmu_cfg/init.c b/libmu_cfg/init.c
index 5cd627b..e4b36ff 100644
--- a/libmu_cfg/init.c
+++ b/libmu_cfg/init.c
@@ -18,6 +18,7 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
+#define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
 #include "mailutils/libcfg.h"
 #include <string.h>
 #include <stdlib.h>
@@ -82,7 +83,84 @@ mu_libcfg_init (char **cnames)
 	}
     }
 }
+
+int
+mu_libcfg_parse_config (mu_cfg_tree_t **ptree)
+{
+  int flags = 0;
+  int rc = 0;
+  mu_cfg_tree_t *tree = NULL, *tmp;
+  
+  if (mu_cfg_parser_verbose)
+    flags |= MU_PARSE_CONFIG_VERBOSE;
+  if (mu_cfg_parser_verbose > 1)
+    flags |= MU_PARSE_CONFIG_DUMP;
   
+  if (mu_load_site_rcfile)
+    {
+      rc = mu_cfg_parse_file (&tmp, MU_CONFIG_FILE, flags);
+
+      if (rc == ENOMEM)
+	{
+	  mu_error ("%s", mu_strerror (rc));
+	  return rc;
+	}
+      else if (rc == 0)
+	{
+	  mu_cfg_tree_postprocess (tmp, flags | MU_PARSE_CONFIG_GLOBAL);
+	  mu_cfg_tree_union (&tree, &tmp);
+	}
+    }
+
+  if (mu_load_user_rcfile && mu_program_name)
+    {
+      size_t size = 3 + strlen (mu_program_name) + 1;
+      char *file_name = malloc (size);
+      if (file_name)
+	{
+	  strcpy (file_name, "~/.");
+	  strcat (file_name, mu_program_name);
+
+	  rc = mu_cfg_parse_file (&tmp, file_name, flags);
+	  if (rc == ENOMEM)
+	    {
+	      mu_error ("%s", mu_strerror (rc));
+	      mu_cfg_destroy_tree (&tree);
+	      return rc;
+	    }
+	  else if (rc == 0)
+	    {
+	      mu_cfg_tree_postprocess (tmp, flags);
+	      mu_cfg_tree_union (&tree, &tmp);
+	    }
+	  free (file_name);
+	}
+    }
+
+  if (mu_load_rcfile)
+    {
+      rc = mu_cfg_parse_file (&tmp, mu_load_rcfile, flags);
+      if (rc)
+	{
+	  mu_error (_("errors parsing file %s: %s"), mu_load_rcfile,
+		    mu_strerror (rc));
+	  mu_cfg_destroy_tree (&tree);
+	  return rc;
+	}
+      else
+	{
+	  mu_cfg_tree_postprocess (tmp, flags);
+	  mu_cfg_tree_union (&tree, &tmp);
+	}
+    }
+
+  *ptree = tree;
+  return rc;
+}
+
+
+
+/* FIXME: Deprecated */
 int
 mu_parse_config_files (struct mu_cfg_param *param, void *target)
 {
diff --git a/mail/testsuite/lib/mail.exp b/mail/testsuite/lib/mail.exp
index ab600d9..6990161 100644
--- a/mail/testsuite/lib/mail.exp
+++ b/mail/testsuite/lib/mail.exp
@@ -1,6 +1,6 @@
 # -*- tcl -*-
 # This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007 Free Software Foundation
+# Copyright (C) 2002, 2007, 2009 Free Software Foundation
 #  
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -64,7 +64,7 @@ proc default_mail_start {args} {
     
     if [info exists host_board] {
 	if [board_info $host_board exists top_srcdir] {
-	    append sw " --mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool"
+	    append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
 	}
     }
 
diff --git a/mailbox/Makefile.am b/mailbox/Makefile.am
index 461c946..d6f8332 100644
--- a/mailbox/Makefile.am
+++ b/mailbox/Makefile.am
@@ -98,6 +98,7 @@ libmailutils_la_SOURCES = \
  memory_stream.c\
  message_stream.c\
  mime.c\
+ mkfilename.c\
  monitor.c\
  msrv.c\
  mu_auth.c\
diff --git a/mailbox/cfg_driver.c b/mailbox/cfg_driver.c
index 88f1647..412aca5 100644
--- a/mailbox/cfg_driver.c
+++ b/mailbox/cfg_driver.c
@@ -1,5 +1,5 @@
 /* cfg_driver.c -- Main driver for Mailutils configuration files
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 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
@@ -27,6 +27,7 @@
 #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>
@@ -453,23 +454,6 @@ prog_parser (enum mu_cfg_section_stage stage,
   return 0;
 }
 
-static char *
-make_file_name (const char *dir, const char *file)
-{
-  char *tmp;
-  size_t len = strlen (dir) + 1 + strlen (file);
-  tmp = malloc (len + 1);
-  if (!tmp)
-    {
-      mu_error ("%s", mu_strerror (errno));
-      exit (1);
-    }
-  strcpy (tmp, dir);
-  strcat (tmp, "/");
-  strcat (tmp, file);
-  return tmp;
-}
-
 struct include_data
 {
   const char *progname;
@@ -492,13 +476,20 @@ _cb_include (mu_debug_t debug, void *data, mu_config_value_t *val)
 
   dirname = val->v.string;
   if (dirname[0] != '/')
-    dirname = tmp = make_file_name (SYSCONFDIR, dirname);
-  
+    {
+      dirname = tmp = mu_make_file_name (SYSCONFDIR, dirname);
+      if (!dirname)
+        {
+          mu_error ("%s", mu_strerror (errno));
+          return 1;
+        }
+    }
+    
   if (stat (dirname, &sb) == 0)
     {
       if (S_ISDIR (sb.st_mode))
 	{
-	  char *file = make_file_name (dirname, idp->progname);
+	  char *file = mu_make_file_name (dirname, idp->progname);
 	  ret = mu_get_config (file, idp->progname, idp->progparam,
 			       idp->flags & ~MU_PARSE_CONFIG_GLOBAL,
 			       idp->target);
@@ -528,51 +519,61 @@ struct mu_cfg_cont *
 mu_build_container (const char *progname, struct include_data *idp)
 {
   struct mu_cfg_cont *cont = root_container;
-  struct mu_cfg_param mu_include_param[] = {
-    { "include", mu_cfg_callback, NULL, 0, _cb_include,
-      N_("Include contents of the given file.  If a directory is given, "
-	 "include contents of the file <file>/<program>, where <program> is "
-	 "the name of the program.  This latter form is allowed only in "
-	 "the site-wide configuration file."),
-      N_("file-or-directory") },
-    { NULL }
-  };
-
-  mu_include_param[0].data = idp;
+
   mu_config_clone_container (cont);
-  _mu_config_register_section (&cont, NULL, NULL, NULL,
-			       (void*) progname, mu_include_param, NULL);
-  if (idp->flags & MU_PARSE_CONFIG_GLOBAL)
+  
+  if (idp->flags & MU_PARSE_CONFIG_PLAIN)
     {
-      mu_iterator_t iter;
-      struct mu_cfg_section *prog_sect;
-      struct mu_cfg_cont *old_root = root_container;
-      static struct mu_cfg_param empty_param = { NULL };
+      struct mu_cfg_param mu_include_param[] = {
+	{ "include", mu_cfg_callback, NULL, 0, _cb_include,
+	  N_("Include contents of the given file.  If a directory is given, "
+	     "include contents of the file <file>/<program>, where "
+	     "<program> is the name of the program.  This latter form is "
+	     "allowed only in the site-wide configuration file."),
+	  N_("file-or-directory") },
+	{ NULL }
+      };
+
+      mu_include_param[0].data = idp;
+      _mu_config_register_section (&cont, NULL, NULL, NULL,
+				   (void*) progname, mu_include_param, NULL);
       
-      _mu_config_register_section (&cont, NULL, "program", progname,
-				   prog_parser,
-				   idp->progparam ?
-				     idp->progparam : &empty_param,
-				   &prog_sect);
-      
-      if (old_root->v.section.children)
+      if (idp->flags & MU_PARSE_CONFIG_GLOBAL)
 	{
-	  if (!prog_sect->children)
-	    mu_list_create (&prog_sect->children);
-	  mu_list_get_iterator (old_root->v.section.children, &iter);
-	  for (mu_iterator_first (iter); !mu_iterator_is_done (iter);
-	       mu_iterator_next (iter))
+	  mu_iterator_t iter;
+	  struct mu_cfg_section *prog_sect;
+	  struct mu_cfg_cont *old_root = root_container;
+	  static struct mu_cfg_param empty_param = { NULL };
+	  
+	  _mu_config_register_section (&cont, NULL, "program", progname,
+				       prog_parser,
+				       idp->progparam ?
+				       idp->progparam : &empty_param,
+				       &prog_sect);
+      
+	  if (old_root->v.section.children)
 	    {
-	      struct mu_cfg_cont *c;
-	      mu_iterator_current (iter, (void**)&c);
-	      mu_list_append (prog_sect->children, c);
+	      if (!prog_sect->children)
+		mu_list_create (&prog_sect->children);
+	      mu_list_get_iterator (old_root->v.section.children, &iter);
+	      for (mu_iterator_first (iter); !mu_iterator_is_done (iter);
+		   mu_iterator_next (iter))
+		{
+		  struct mu_cfg_cont *c;
+		  mu_iterator_current (iter, (void**)&c);
+		  mu_list_append (prog_sect->children, c);
+		}
+	      mu_iterator_destroy (&iter);
 	    }
-	  mu_iterator_destroy (&iter);
 	}
+      else if (idp->progparam)
+	_mu_config_register_section (&cont, NULL, NULL, NULL, NULL,
+				     idp->progparam, NULL);
     }
   else if (idp->progparam)
     _mu_config_register_section (&cont, NULL, NULL, NULL, NULL,
 				 idp->progparam, NULL);
+  
   return cont;
 }
 
@@ -582,14 +583,16 @@ mu_cfg_tree_reduce (mu_cfg_tree_t *parse_tree, const char *progname,
 		    void *target_ptr)
 {
   int rc = 0;
-  
+
+  if (!parse_tree)
+    return 0;
   if (flags & MU_PARSE_CONFIG_DUMP)
     {
       mu_stream_t stream;
       mu_stdio_stream_create (&stream, stderr,
  			      MU_STREAM_NO_CHECK|MU_STREAM_NO_CLOSE);
       mu_stream_open (stream);
-      mu_cfg_format_parse_tree (stream, parse_tree);
+      mu_cfg_format_parse_tree (stream, parse_tree, MU_CFG_FMT_LOCUS);
       mu_stream_destroy (&stream, NULL);
     }
 
@@ -597,14 +600,14 @@ mu_cfg_tree_reduce (mu_cfg_tree_t *parse_tree, const char *progname,
     {
       struct include_data idata;
       struct mu_cfg_cont *cont;
-
+      
       idata.progname = progname;
       idata.progparam = progparam;
       idata.flags = flags;
       idata.target = target_ptr;
-
+      
       cont = mu_build_container (progname, &idata);
-
+      
       rc = mu_cfg_scan_tree (parse_tree, &cont->v.section, target_ptr,
 			     (void*) progname);
       mu_config_destroy_container (&cont);
diff --git a/mailbox/cfg_format.c b/mailbox/cfg_format.c
index 6633bb1..5e9b3cf 100644
--- a/mailbox/cfg_format.c
+++ b/mailbox/cfg_format.c
@@ -29,6 +29,7 @@
 
 struct tree_print
 {
+  int flags;
   unsigned level;
   mu_stream_t stream;
   char *buf;
@@ -131,7 +132,7 @@ format_node (const mu_cfg_node_t *node, void *data)
 {
   struct tree_print *tp = data;
 
-  if (node->locus.file)
+  if ((tp->flags & MU_CFG_FMT_LOCUS) && node->locus.file)
     mu_stream_sequential_printf (tp->stream, "# %lu \"%s\"\n",
 				 (unsigned long) node->locus.line, 
                                  node->locus.file);
@@ -143,7 +144,7 @@ format_node (const mu_cfg_node_t *node, void *data)
 				   _("ERROR: undefined statement"));
       break;
 
-    case mu_cfg_node_tag:
+    case mu_cfg_node_statement:
       {
 	mu_stream_sequential_write (tp->stream, node->tag,
 				    strlen (node->tag));
@@ -183,16 +184,35 @@ format_node_end (const mu_cfg_node_t *node, void *data)
 }
 
 void
-mu_cfg_format_parse_tree (mu_stream_t stream, mu_cfg_tree_t *tree)
+mu_cfg_format_parse_tree (mu_stream_t stream, mu_cfg_tree_t *tree, int flags)
 {
   struct tree_print t;
+  t.flags = flags;
   t.level = 0;
   t.stream = stream;
   t.buf = NULL;
   t.bufsize = 0;
-  mu_cfg_preorder (tree->node, format_node, format_node_end, &t);
+  mu_cfg_preorder (tree->head, format_node, format_node_end, &t);
   free (t.buf);
 }
+
+void
+mu_cfg_format_node (mu_stream_t stream, const mu_cfg_node_t *node, int flags)
+{
+  struct tree_print t;
+  t.flags = flags;
+  t.level = 0;
+  t.stream = stream;
+  t.buf = NULL;
+  t.bufsize = 0;
+  format_node (node, &t);
+  if (node->type == mu_cfg_node_statement)
+    {
+      mu_cfg_preorder (node->node, format_node, format_node_end, &t);
+      format_node_end (node, &t);
+    }
+}
+
 
 
 const char *
diff --git a/mailbox/cfg_lexer.l b/mailbox/cfg_lexer.l
index 7d87d7e..d15bce1 100644
--- a/mailbox/cfg_lexer.l
+++ b/mailbox/cfg_lexer.l
@@ -150,12 +150,10 @@ P [1-9][0-9]*
 \n       { mu_cfg_locus.line++; } 
 [,;{}()] return yytext[0];
 .        { if (mu_isprint (yytext[0]))
-              mu_cfg_perror (&mu_cfg_locus,
-			     _("stray character %c"), yytext[0]);
+              mu_cfg_parse_error (_("stray character %c"), yytext[0]);
            else 
-              mu_cfg_perror (&mu_cfg_locus,
-			     _("stray character \\%03o"),
-			     (unsigned char) yytext[0]);
+              mu_cfg_parse_error (_("stray character \\%03o"),
+				  (unsigned char) yytext[0]);
          }
 %%
 
@@ -172,7 +170,7 @@ unescape_to_line (int c)
     {
       char t = mu_argcv_unquote_char (c);
       if (t == c && t != '\\' && t != '\"')
-	mu_cfg_perror (&mu_cfg_locus, _("unknown escape sequence '\\%c'"), c);
+	mu_cfg_parse_error (_("unknown escape sequence '\\%c'"), c);
       mu_opool_append_char (pool, t);
     }
 }
@@ -317,13 +315,11 @@ multiline_finish ()
 
 
 int
-mu_get_config (const char *file, const char *progname,
-               struct mu_cfg_param *progparam, int flags, void *target_ptr)
+mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags)
 {
   struct stat st;
   FILE *fp;
   int rc;
-  mu_cfg_tree_t *parse_tree;
   
   if (stat (file, &st))
     {
@@ -348,20 +344,30 @@ mu_get_config (const char *file, const char *progname,
   mu_cfg_locus.file = (char*) file;
   mu_cfg_locus.line = 1;
   yyrestart (fp);
-  rc = mu_cfg_parse (&parse_tree);
+  rc = mu_cfg_parse (return_tree);
   fclose (fp);
+  if (flags & MU_PARSE_CONFIG_VERBOSE)
+    mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"), 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)
     rc = mu_cfg_tree_reduce (parse_tree, progname, progparam, flags,
 			     target_ptr);
 
   mu_cfg_destroy_tree (&parse_tree);
 
-  if (flags & MU_PARSE_CONFIG_VERBOSE)
-    mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"), file);
-  
   return rc == 0 ? 0 : MU_ERR_FAILURE;
 }
 
+
 mu_opool_t 
 mu_cfg_lexer_pool ()
 {
diff --git a/mailbox/cfg_parser.y b/mailbox/cfg_parser.y
index d552bcb..2710afd 100644
--- a/mailbox/cfg_parser.y
+++ b/mailbox/cfg_parser.y
@@ -18,12 +18,15 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <netdb.h>
 #include "intprops.h"
+#include <mailutils/argcv.h>
 #include <mailutils/nls.h>
 #include <mailutils/cfg.h>
 #include <mailutils/alloc.h>
@@ -32,9 +35,10 @@
 #include <mailutils/list.h>
 #include <mailutils/iterator.h>
 #include <mailutils/debug.h>
+#include <mailutils/mutil.h>  
 
 int mu_cfg_parser_verbose;
-static mu_cfg_node_t *parse_tree;
+static mu_cfg_node_t *parse_head, *parse_tail;
 mu_cfg_locus_t mu_cfg_locus;
 size_t mu_cfg_error_count;
 
@@ -50,7 +54,7 @@ char *_mu_line_finish (void);
 static int
 yyerror (char *s)
 {
-  mu_cfg_perror (&mu_cfg_locus, "%s", s);
+  mu_cfg_parse_error ("%s", s);
   return 0;
 }
 
@@ -89,6 +93,13 @@ mu_cfg_alloc_node (enum mu_cfg_node_type type, mu_cfg_locus_t *loc,
 }
 
 void
+mu_cfg_free_node (mu_cfg_node_t *node)
+{
+  free (node->label);
+  free (node);
+}
+
+void
 mu_cfg_format_error (mu_debug_t debug, size_t level, const char *fmt, ...)
 {
   va_list ap;
@@ -110,8 +121,8 @@ _mu_cfg_debug_set_locus (mu_debug_t debug, const mu_cfg_locus_t *loc)
 		      loc->line);
 }
 
-static void
-_mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc,
+void
+mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc,
 		 const char *fmt, va_list ap)
 {
   if (!debug)
@@ -123,28 +134,28 @@ _mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc,
   mu_cfg_error_count++;
 }
 
-static void
-_mu_cfg_perror (mu_debug_t debug, const mu_cfg_locus_t *loc,
-		const char *fmt, ...)
+void
+mu_cfg_perror (mu_debug_t debug, const mu_cfg_locus_t *loc,
+	       const char *fmt, ...)
 {
   va_list ap;
 
   va_start (ap, fmt);
-  _mu_cfg_vperror (debug, loc, fmt, ap);
+  mu_cfg_vperror (debug, loc, fmt, ap);
   va_end (ap);
 }
 
 void
-mu_cfg_perror (const mu_cfg_locus_t *loc, const char *fmt, ...)
+mu_cfg_parse_error (const char *fmt, ...)
 {
   va_list ap;
 
   va_start (ap, fmt);
-  _mu_cfg_vperror (_mu_cfg_debug, loc, fmt, ap);
+  mu_cfg_vperror (_mu_cfg_debug, &mu_cfg_locus, fmt, ap);
   va_end (ap);
 }
 
-#define node_type_str(t) (((t) == mu_cfg_node_tag) ? "tag" : "param")
+#define node_type_str(t) (((t) == mu_cfg_node_statement) ? "stmt" : "param")
 
 static void
 debug_print_node (mu_cfg_node_t *node)
@@ -194,7 +205,8 @@ debug_print_node (mu_cfg_node_t *node)
 
 input   : stmtlist
 	  {
-	    parse_tree = $1.head;
+	    parse_head = $1.head;
+	    parse_tail = $1.tail;
 	  }
 	;
 
@@ -226,14 +238,14 @@ simple  : ident vallist ';'
 
 block   : ident tag '{' '}' opt_sc
 	  {
-	    $$ = mu_cfg_alloc_node (mu_cfg_node_tag, &$1.locus,
+	    $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &$1.locus,
 				    $1.name, $2,
 				    NULL);
 
 	  }
 	| ident tag '{' stmtlist '}' opt_sc
 	  {
-	    $$ = mu_cfg_alloc_node (mu_cfg_node_tag, &$1.locus,
+	    $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &$1.locus,
 				    $1.name, $2,
 				    $4.head);
 
@@ -273,7 +285,7 @@ vallist : vlist
 		val.v.arg.v = mu_alloc (n * sizeof (val.v.arg.v[0]));
 		if (!val.v.arg.v)
 		  {
-		    mu_cfg_perror (&mu_cfg_locus, _("not enough memory"));
+		    mu_cfg_parse_error (_("not enough memory"));
 		    abort();
 		  }
 
@@ -294,8 +306,8 @@ vlist   : value
 	      int rc = mu_list_create (&$$);
 	      if (rc)
 		{
-		  mu_cfg_perror (&mu_cfg_locus, _("cannot create list: %s"),
-				 mu_strerror (rc));
+		  mu_cfg_parse_error (_("cannot create list: %s"),
+				      mu_strerror (rc));
 		  abort ();
 		}
 	      mu_list_append ($$, config_value_dup (&$1)); /* FIXME */
@@ -430,13 +442,184 @@ mu_cfg_parse (mu_cfg_tree_t **ptree)
 
   tree = mu_alloc (sizeof (*tree));
   tree->debug = _mu_cfg_debug;
-  tree->node = parse_tree;
+  tree->head = parse_head;
+  tree->tail = parse_tail;
   tree->pool = mu_cfg_lexer_pool ();
-  parse_tree = NULL;
+  parse_head = parse_tail = NULL;
   *ptree = tree;
   return rc;
 }
 
+int
+mu_cfg_tree_union (mu_cfg_tree_t **pa, mu_cfg_tree_t **pb)
+{
+  mu_cfg_tree_t *a, *b;
+  int rc;
+  
+  if (!pb)
+    return EINVAL;
+  if (!*pb)
+    return 0;
+  b = *pb;
+  if (!pa)
+    return EINVAL;
+  if (!*pa)
+    {
+      *pa = b;
+      *pb = NULL;
+      return 0;
+    }
+  else
+    a = *pa;
+  
+  /* Merge opools */
+  rc = mu_opool_union (&b->pool, &a->pool);
+  if (rc)
+    return rc;
+    
+  /* Link node lists */
+  if (a->tail)
+    a->tail->next = b->head;
+  else
+    a->head = b->head;
+  a->tail = b->tail;
+
+  mu_debug_destroy (&b->debug, mu_debug_get_owner (b->debug));
+  free (b);
+  *pb = NULL;
+  return 0;
+}
+
+static mu_cfg_tree_t *
+do_include (const char *name, int flags, mu_cfg_locus_t *loc)
+{
+  struct stat sb;
+  char *tmpname = NULL;
+  mu_cfg_tree_t *tree = NULL;
+  
+  if (name[0] != '/')
+    {
+      name = tmpname = mu_make_file_name (SYSCONFDIR, name);
+      if (!name)
+        {
+          mu_error ("%s", mu_strerror (errno));
+          return NULL;
+        }
+    }
+  if (stat (name, &sb) == 0)
+    {
+      int rc = 0;
+
+      if (S_ISDIR (sb.st_mode))
+	{
+	  if (flags & MU_PARSE_CONFIG_GLOBAL)
+	    {
+	      char *file = mu_make_file_name (name, mu_program_name);
+	      rc = mu_cfg_parse_file (&tree, file, flags);
+	    }
+	}
+      else
+	rc = mu_cfg_parse_file (&tree, name, flags);
+	      
+      if (rc == 0 && tree)
+	mu_cfg_tree_postprocess (tree, flags & ~MU_PARSE_CONFIG_GLOBAL);
+    }
+  else if (errno == ENOENT)
+    mu_cfg_perror (tree->debug, loc,
+		   _("include file or directory does not exist"));
+  else
+    mu_cfg_perror (tree->debug, loc,
+		   _("cannot stat include file or directory: %s"),
+		   mu_strerror (errno));
+  free (tmpname);
+  return tree;
+}
+    
+int
+mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, int flags)
+{
+  mu_cfg_node_t *prev, *node;
+
+  for (prev = NULL, node = tree->head; node; )
+    {
+      mu_cfg_node_t *next = node->next;
+
+      if (node->type == mu_cfg_node_statement)
+	{
+	  if ((flags & MU_PARSE_CONFIG_GLOBAL) &&
+	      strcmp (node->tag, "program") == 0)
+	    {
+	      if (node->label->type == MU_CFG_STRING)
+		{
+		  if (strcmp (node->label->v.string, mu_program_name) == 0)
+		    {
+		      mu_cfg_node_t *p;
+		      
+		      /* Move all nodes from this block to the topmost
+			 level */
+		      if (prev)
+			prev->next = node->node;
+		      else
+			tree->head = node->node;
+		      p = node->node;
+		      mu_cfg_free_node (node);
+		      for (node = prev->next; node->next; node = node->next)
+			;
+		      node->next = next;
+		    }
+		}
+	      else
+		{
+		  mu_cfg_perror (tree->debug, &node->locus,
+				 _("argument to `program' is not a string"));
+		  if (prev)
+		    prev->next = next;
+		  else
+		    tree->head = next;
+		  mu_cfg_free_node (node);
+		}
+	    }
+	}
+      else if (node->type == mu_cfg_node_param &&
+	       strcmp (node->tag, "include") == 0)
+	{
+	  /* Remove node from the list */
+	  if (prev)
+	    prev->next = next;
+	  else
+	    tree->head = next;
+	      
+	  if (node->label->type == MU_CFG_STRING)
+	    {
+	      mu_cfg_tree_t *t = do_include (node->label->v.string, flags,
+					     &node->locus);
+	      if (t)
+		{
+		  if (prev)
+		    prev->next = t->head;
+		  else
+		    tree->head = t->head;
+		  
+		  t->tail->next = next;
+		  
+		  /* FIXME: check return value */
+		  mu_opool_union (&tree->pool, &t->pool);
+		  mu_debug_destroy (&t->debug, NULL);
+		  free (t);
+		}		      
+	    }
+	  else
+	    mu_cfg_perror (tree->debug, &node->locus,
+			   _("argument to `include' is not a string"));
+	  mu_cfg_free_node (node);
+	}
+	  
+      prev = node;
+      node = next;
+    }
+  return 0;
+}
+
 static int
 _mu_cfg_preorder_recursive (mu_cfg_node_t *node,
 			    mu_cfg_iter_func_t beg, mu_cfg_iter_func_t end,
@@ -447,7 +630,7 @@ _mu_cfg_preorder_recursive (mu_cfg_node_t *node,
     case mu_cfg_node_undefined:
       abort ();
 
-    case mu_cfg_node_tag:
+    case mu_cfg_node_statement:
       switch (beg (node, data))
 	{
 	case MU_CFG_ITER_OK:
@@ -491,7 +674,7 @@ _mu_cfg_postorder_recursive(mu_cfg_node_t *node,
     case mu_cfg_node_undefined:
       abort ();
 
-    case mu_cfg_node_tag:
+    case mu_cfg_node_statement:
       switch (beg (node, data))
 	{
 	case MU_CFG_ITER_OK:
@@ -532,7 +715,7 @@ mu_cfg_postorder (mu_cfg_node_t *node,
 static int
 free_section (const mu_cfg_node_t *node, void *data)
 {
-  if (node->type == mu_cfg_node_tag)
+  if (node->type == mu_cfg_node_statement)
     free ((void *) node);
   return MU_CFG_ITER_OK;
 }
@@ -551,7 +734,7 @@ mu_cfg_destroy_tree (mu_cfg_tree_t **ptree)
   if (ptree && *ptree)
     {
       mu_cfg_tree_t *tree = *ptree;
-      mu_cfg_postorder (tree->node, free_param, free_section, NULL);
+      mu_cfg_postorder (tree->head, free_param, free_section, NULL);
       mu_opool_destroy (&tree->pool);
       *ptree = NULL;
     }
@@ -643,7 +826,7 @@ push_section (struct scan_tree_data *dat, struct mu_cfg_section *sec)
   struct mu_cfg_section_list *p = mu_alloc (sizeof *p);
   if (!p)
     {
-      _mu_cfg_perror (dat->tree->debug, NULL, _("not enough memory"));
+      mu_cfg_perror (dat->tree->debug, NULL, _("not enough memory"));
       return 1;
     }
   p->sec = sec;
@@ -680,12 +863,12 @@ pop_section (struct scan_tree_data *dat)
 	  break;							\
 	if (x <= sum)							\
 	  {								\
-	    _mu_cfg_perror (d, loc, _("numeric overflow"));		\
+	    mu_cfg_perror (d, loc, _("numeric overflow"));		\
 	    return 1;							\
 	  }								\
 	else if (limit && x > limit)					\
 	  {								\
-	    _mu_cfg_perror (d, loc,					\
+	    mu_cfg_perror (d, loc,					\
 			    _("value out of allowed range"));		\
 	    return 1;							\
 	  }								\
@@ -721,9 +904,9 @@ pop_section (struct scan_tree_data *dat)
     STRxTONUM (s, type, tmpres, 0, d, loc);				\
     if (*s)								\
       {									\
-	_mu_cfg_perror (d, loc,						\
-			_("not a number (stopped near `%s')"),		\
-			s);						\
+	mu_cfg_perror (d, loc,						\
+		       _("not a number (stopped near `%s')"),		\
+		       s);						\
 	return 1;							\
       }									\
     res = tmpres;							\
@@ -752,9 +935,9 @@ pop_section (struct scan_tree_data *dat)
     STRxTONUM (s, unsigned type, tmpres, limit, d, loc);		\
     if (*s)								\
       {									\
-	_mu_cfg_perror (d, loc,						\
-			_("not a number (stopped near `%s')"),		\
-			s);						\
+	mu_cfg_perror (d, loc,						\
+		       _("not a number (stopped near `%s')"),		\
+		       s);						\
 	return 1;							\
       }									\
     res = sign ? - tmpres : tmpres;					\
@@ -767,7 +950,7 @@ parse_ipv4 (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
   struct in_addr addr;
   if (inet_aton (str, &addr) == 0)
     {
-      _mu_cfg_perror (sdata->tree->debug, locus, _("not an IPv4"));
+      mu_cfg_perror (sdata->tree->debug, locus, _("not an IPv4"));
       return 1;
     }
   addr.s_addr = ntohl (addr.s_addr);
@@ -787,9 +970,9 @@ parse_host (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
     }
   else if (inet_aton (str, &addr) == 0)
     {
-      _mu_cfg_perror (sdata->tree->debug, locus,
-		      _("cannot resolve hostname `%s'"),
-		      str);
+      mu_cfg_perror (sdata->tree->debug, locus,
+		     _("cannot resolve hostname `%s'"),
+		     str);
       return 1;
     }
   addr.s_addr = ntohl (addr.s_addr);
@@ -811,16 +994,16 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
     {
       int len = p - str;
       if (len > sizeof astr - 1) {
-	_mu_cfg_perror (sdata->tree->debug, locus,
-			_("not a valid IPv4 address in CIDR"));
+	mu_cfg_perror (sdata->tree->debug, locus,
+		       _("not a valid IPv4 address in CIDR"));
 	return 1;
       }
       memcpy (astr, str, len);
       astr[len] = 0;
       if (inet_aton (astr, &addr) == 0)
 	{
-	  _mu_cfg_perror (sdata->tree->debug, locus,
-			  _("not a valid IPv4 address in CIDR"));
+	  mu_cfg_perror (sdata->tree->debug, locus,
+			 _("not a valid IPv4 address in CIDR"));
 	  return 1;
 	}
       addr.s_addr = ntohl (addr.s_addr);
@@ -833,8 +1016,8 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
 	  struct in_addr a;
 	  if (inet_aton (p, &a) == 0)
 	    {
-	      _mu_cfg_perror (sdata->tree->debug, locus,
-			      _("not a valid network in CIDR"));
+	      mu_cfg_perror (sdata->tree->debug, locus,
+			     _("not a valid network in CIDR"));
 	      return 1;
 	    }
 	  a.s_addr = ntohl (a.s_addr);
@@ -847,8 +1030,8 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
 	}
       else if (mask > 32)
 	{
-	  _mu_cfg_perror (sdata->tree->debug, locus,
-			  _("not a valid network mask in CIDR"));
+	  mu_cfg_perror (sdata->tree->debug, locus,
+			 _("not a valid network mask in CIDR"));
 	  return 1;
 	}
     }
@@ -869,9 +1052,9 @@ parse_cidr (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
 
       if (*p)
 	{
-	  _mu_cfg_perror (sdata->tree->debug, locus,
-			  _("not a CIDR (stopped near `%s')"),
-			  p);
+	  mu_cfg_perror (sdata->tree->debug, locus,
+			 _("not a CIDR (stopped near `%s')"),
+			 p);
 	  return 1;
 	}
 
@@ -911,7 +1094,7 @@ parse_bool (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
 {
   if (mu_cfg_parse_boolean (str, res))
     {
-      _mu_cfg_perror (sdata->tree->debug, locus, _("not a boolean"));
+      mu_cfg_perror (sdata->tree->debug, locus, _("not a boolean"));
       return 1;
     }
   return 0;
@@ -924,8 +1107,7 @@ valcvt (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
 {
   if (val->type != MU_CFG_STRING)
     {
-      _mu_cfg_perror (sdata->tree->debug, locus,
-		      _("expected string value"));
+      mu_cfg_perror (sdata->tree->debug, locus, _("expected string value"));
       return 1;
     }
   switch (type)
@@ -972,8 +1154,7 @@ valcvt (struct scan_tree_data *sdata, const mu_cfg_locus_t *locus,
       break;
 
     case mu_cfg_off:
-      _mu_cfg_perror (sdata->tree->debug, locus,
-		      _("not implemented yet"));
+      mu_cfg_perror (sdata->tree->debug, locus, _("not implemented yet"));
       /* GETSNUM(node->tag_label, off_t, *(off_t*)tgt); */
       return 1;
 
@@ -1046,17 +1227,17 @@ _set_fun (void *item, void *data)
   if (clos->type >= MU_ARRAY_SIZE(config_type_size)
       || (size = config_type_size[clos->type]) == 0)
     {
-    _mu_cfg_perror (clos->sdata->tree->debug, clos->locus,
-		    _("INTERNAL ERROR at %s:%d: unhandled data type %d"),
-		    __FILE__, __LINE__, clos->type);
+    mu_cfg_perror (clos->sdata->tree->debug, clos->locus,
+		   _("INTERNAL ERROR at %s:%d: unhandled data type %d"),
+		   __FILE__, __LINE__, clos->type);
     return 1;
     }
 
   tgt = mu_alloc (size);
   if (!tgt)
     {
-      _mu_cfg_perror (clos->sdata->tree->debug, clos->locus,
-		      _("not enough memory"));
+      mu_cfg_perror (clos->sdata->tree->debug, clos->locus,
+		     _("not enough memory"));
       return 1;
     }
 
@@ -1075,9 +1256,9 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
 
   if (!param)
     {
-      _mu_cfg_perror (sdata->tree->debug, &node->locus,
-		      _("unknown keyword `%s'"),
-		      node->tag);
+      mu_cfg_perror (sdata->tree->debug, &node->locus,
+		     _("unknown keyword `%s'"),
+		     node->tag);
       return 1;
     }
 
@@ -1091,9 +1272,9 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
     tgt = NULL;
   else
     {
-      _mu_cfg_perror (sdata->tree->debug, &node->locus,
-		      _("INTERNAL ERROR: cannot determine target offset for "
-			"%s"), param->ident);
+      mu_cfg_perror (sdata->tree->debug, &node->locus,
+		     _("INTERNAL ERROR: cannot determine target offset for "
+		       "%s"), param->ident);
       abort ();
     }
 
@@ -1119,8 +1300,8 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
 	  break;
 
 	case MU_CFG_ARRAY:
-	  _mu_cfg_perror (sdata->tree->debug, &node->locus,
-			  _("expected list, but found array"));
+	  mu_cfg_perror (sdata->tree->debug, &node->locus,
+			 _("expected list, but found array"));
 	  return 1;
 	}
 
@@ -1134,9 +1315,9 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
 			  node->locus.line);
       if (!param->callback)
 	{
-	  _mu_cfg_perror (sdata->tree->debug, &node->locus,
-			  _("INTERNAL ERROR: %s: callback not defined"),
-			  node->tag);
+	  mu_cfg_perror (sdata->tree->debug, &node->locus,
+			 _("INTERNAL ERROR: %s: callback not defined"),
+			 node->tag);
 	  abort ();
 	}
       if (param->callback (sdata->tree->debug, tgt, node->label))
@@ -1161,7 +1342,7 @@ _scan_tree_helper (const mu_cfg_node_t *node, void *data)
     case mu_cfg_node_undefined:
       abort ();
 
-    case mu_cfg_node_tag:
+    case mu_cfg_node_statement:
       sec = find_subsection (sdata->list->sec, node->tag, 0);
       if (!sec)
 	{
@@ -1219,7 +1400,7 @@ _scan_tree_end_helper (const mu_cfg_node_t *node, void *data)
     default:
       abort ();
 
-    case mu_cfg_node_tag:
+    case mu_cfg_node_statement:
       sec = pop_section (sdata);
       if (sec && sec->parser)
 	{
@@ -1253,7 +1434,7 @@ mu_cfg_scan_tree (mu_cfg_tree_t *tree, struct mu_cfg_section *sections,
     }
   if (push_section (&dat, sections))
     return 1;
-  mu_cfg_preorder (tree->node, _scan_tree_helper, _scan_tree_end_helper, &dat);
+  mu_cfg_preorder (tree->head, _scan_tree_helper, _scan_tree_end_helper, &dat);
   if (debug)
     {
       mu_debug_set_locus (debug, NULL, 0);
@@ -1273,13 +1454,13 @@ mu_cfg_find_section (struct mu_cfg_section *root_sec,
       size_t len;
       const char *p;
 
-      while (*path == '/')
+      while (*path == MU_CFG_PATH_DELIM)
 	path++;
 
       if (*path == 0)
 	return MU_ERR_NOENT;
 
-      p = strchr (path, '/');
+      p = strchr (path, MU_CFG_PATH_DELIM);
       if (p)
 	len = p - path;
       else
@@ -1354,13 +1535,275 @@ mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
 void
 mu_cfg_tree_add_node (mu_cfg_tree_t *tree, mu_cfg_node_t *node)
 {
-  if (!tree->node)
-    tree->node = node;
+  if (!tree->head)
+    tree->head = node;
   else
     {
       mu_cfg_node_t *p;
-      for (p = tree->node; p->next; p = p->next)
+      for (p = tree->head; p->next; p = p->next)
 	;
       p->next = node;
     }
 }
+
+/* Return 1 if configuration value A equals B */
+int
+mu_cfg_value_eq (mu_config_value_t *a, mu_config_value_t *b)
+{
+  if (a->type != b->type)
+    return 0;
+  switch (a->type)
+    {
+    case MU_CFG_STRING:
+      if (a->v.string == NULL)
+	return b->v.string == NULL;
+      return strcmp (a->v.string, b->v.string) == 0;
+		     
+    case MU_CFG_LIST:
+      {
+	int ret = 1;
+	size_t cnt;
+	size_t i;
+	mu_iterator_t aitr, bitr;
+	
+	mu_list_count (a->v.list, &cnt);
+	mu_list_count (b->v.list, &i);
+	if (i != cnt)
+	  return 1;
+
+	mu_list_get_iterator (a->v.list, &aitr);
+	mu_list_get_iterator (b->v.list, &bitr);
+	for (i = 0,
+	       mu_iterator_first (aitr),
+	       mu_iterator_first (bitr);
+	     !mu_iterator_is_done (aitr) && !mu_iterator_is_done (bitr);
+	     mu_iterator_next (aitr),
+	       mu_iterator_next (bitr),
+	       i++)
+	  {
+	    mu_config_value_t *ap, *bp;
+	    mu_iterator_current (aitr, (void**)&ap);
+	    mu_iterator_current (bitr, (void**)&bp);
+	    ret = mu_cfg_value_eq (ap, bp);
+	    if (!ret)
+	      break;
+	  }
+	mu_iterator_destroy (&aitr);
+	mu_iterator_destroy (&bitr);
+	return ret && i == cnt;
+      }
+	
+    case MU_CFG_ARRAY:
+      if (a->v.arg.c == b->v.arg.c)
+	{
+	  size_t i;
+	  for (i = 0; i < a->v.arg.c; i++)
+	    if (!mu_cfg_value_eq (&a->v.arg.v[i], &b->v.arg.v[i]))
+	      return 0;
+	  return 1;
+	}
+    }
+  return 0;
+}
+
+
+struct find_data
+{
+  int argc;
+  char **argv;
+  int tag;
+  mu_config_value_t *label;
+  const mu_cfg_node_t *node;
+};
+
+static void
+free_value_mem (mu_config_value_t *p)
+{
+  switch (p->type)
+    {
+    case MU_CFG_STRING:
+      free ((char*)p->v.string);
+      break;
+      
+    case MU_CFG_LIST:
+      /* FIXME */
+      break;
+      
+    case MU_CFG_ARRAY:
+      {
+	size_t i;
+	for (i = 0; i < p->v.arg.c; i++)
+	  free_value_mem (&p->v.arg.v[i]);
+      }
+    }
+}
+
+static void
+destroy_value (void *p)
+{
+  mu_config_value_t *val = p;
+  if (val)
+    {
+      free_value_mem (val);
+      free (val);
+    }
+}
+
+static mu_config_value_t *
+parse_label (const char *str)
+{
+  mu_config_value_t *val = NULL;
+  int count, i;
+  char **vect;
+  size_t len = strlen (str);
+  
+  if (len > 1 && str[0] == '(' && str[len-1] == ')')
+    {
+      mu_list_t lst;
+      mu_argcv_get_np (str + 1, len - 2,
+		       ", \t", NULL,
+		       0,
+		       &count, &vect, NULL);
+      mu_list_create (&lst);
+      mu_list_set_destroy_item (lst, destroy_value);
+      for (i = 0; i < count; i++)
+	{
+	  mu_config_value_t *p = mu_alloc (sizeof (*p));
+	  p->type = MU_CFG_STRING;
+	  p->v.string = vect[i];
+	  mu_list_append (lst, p);
+	}
+      free (vect);
+      val = mu_alloc (sizeof (*val));
+      val->type = MU_CFG_LIST;
+      val->v.list = lst;
+    }
+  else
+    {      
+      mu_argcv_get (str, NULL, NULL, &count, &vect);
+      val = mu_alloc (sizeof (*val));
+      if (count == 1)
+	{
+	  val->type = MU_CFG_STRING;
+	  val->v.string = vect[0];
+	  free (vect);
+	}
+      else
+	{
+	  val->type = MU_CFG_ARRAY;
+	  val->v.arg.c = count;
+	  val->v.arg.v = mu_alloc (count * sizeof (val->v.arg.v[0]));
+	  for (i = 0; i < count; i++)
+	    {
+	      val->v.arg.v[i].type = MU_CFG_STRING;
+	      val->v.arg.v[i].v.string = vect[i];
+	    }
+	  free (vect);
+	}
+    }
+  return val;
+}
+
+static void
+parse_tag (struct find_data *fptr)
+{
+  char *p = strchr (fptr->argv[fptr->tag], '=');
+  if (p)
+    {
+      *p++ = 0;
+      fptr->label = parse_label (p);
+    }
+  else
+    fptr->label = NULL;
+}
+
+static int
+node_finder (const mu_cfg_node_t *node, void *data)
+{
+  struct find_data *fdptr = data;
+  if (strcmp (fdptr->argv[fdptr->tag], node->tag) == 0
+      && (!fdptr->label || mu_cfg_value_eq (fdptr->label, node->label)))
+    {
+      fdptr->tag++;
+      if (fdptr->tag == fdptr->argc)
+	{
+	  fdptr->node = node;
+	  return MU_CFG_ITER_STOP;
+	}
+      parse_tag (fdptr);
+      return MU_CFG_ITER_OK;
+    }
+  
+  return node->type == mu_cfg_node_statement ?
+               MU_CFG_ITER_SKIP : MU_CFG_ITER_OK;
+}
+
+int	    
+mu_cfg_find_node (mu_cfg_node_t *tree, const char *path, mu_cfg_node_t **pval)
+{
+  int rc;
+  struct find_data data;
+
+  rc = mu_argcv_get_np (path, strlen (path),
+			MU_CFG_PATH_DELIM_STR, NULL,
+			0, &data.argc, &data.argv, NULL);
+  if (rc)
+    return rc;
+  data.tag = 0;
+  parse_tag (&data);
+  rc = mu_cfg_preorder (tree, node_finder, NULL, &data);
+  destroy_value (data.label);
+  if (rc)
+    {
+      *pval = (mu_cfg_node_t *) data.node;
+      return 0;
+    }
+  return MU_ERR_NOENT;
+}
+
+
+
+int
+mu_cfg_create_subtree (const char *path, mu_cfg_node_t **pnode)
+{
+  int rc;
+  int argc, i;
+  char **argv;
+  mu_cfg_locus_t locus;
+  enum mu_cfg_node_type type;
+  mu_cfg_node_t *node = NULL;
+  
+  locus.file = "<int>";
+  locus.line = 0;
+  
+  rc = mu_argcv_get_np (path, strlen (path), MU_CFG_PATH_DELIM_STR, NULL, 0,
+			&argc, &argv, NULL);
+  if (rc)
+    return rc;
+
+  for (i = argc - 1; i >= 0; i--)
+    {
+      char *p = strrchr (argv[i], '=');
+      mu_config_value_t *label = NULL;
+
+      type = mu_cfg_node_statement;
+      if (p)
+	{
+	  *p++ = 0;
+	  label = parse_label (p);
+	  if (i == argc - 1)
+	    type = mu_cfg_node_param;
+	}
+      
+      node = mu_cfg_alloc_node (type, &locus, argv[i], label, node);
+    }
+
+  mu_argcv_free (argc, argv);
+  *pnode = node;
+  return 0;
+}
+
+  
+	  
+        
+  
diff --git a/mailbox/asprintf.c b/mailbox/mkfilename.c
similarity index 58%
copy from mailbox/asprintf.c
copy to mailbox/mkfilename.c
index 2bcd61d..00e64bc 100644
--- a/mailbox/asprintf.c
+++ b/mailbox/mkfilename.c
@@ -12,31 +12,35 @@
    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, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
+   Public License along with this library.  If not,
+   see <http://www.gnu.org/licenses/>. */
 
 #if HAVE_CONFIG_H
 # include <config.h>
 #endif
-
-#include <stdlib.h>
-#include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/alloc.h>
+#include <mailutils/mutil.h>
 
-#include <mailutils/io.h>
-
-int
-mu_asprintf (char **pbuf, const char *fmt, ...)
+char *
+mu_make_file_name (const char *dir, const char *file)
 {
-  va_list ap;
-  size_t size;
-  int rc;
+  char *tmp;
+  size_t dirlen = strlen (dir);
+  size_t len;
+
+  while (dirlen > 0 && dir[dirlen-1] == '/')
+    dirlen--;
   
-  va_start (ap, fmt);
-  *pbuf = NULL;
-  size = 0;
-  rc = mu_vasnprintf (pbuf, &size, fmt, ap);
-  va_end (ap);
-  return rc;
+  len = dirlen + 1 + strlen (file);
+  tmp = mu_alloc (len + 1);
+  if (tmp)
+    {
+      memcpy (tmp, dir, dirlen);
+      tmp[dirlen++] = '/';
+      strcpy (tmp + dirlen, file);
+    }
+  return tmp;
 }
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index 67ff755..489e153 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -291,37 +291,6 @@ mu_cpystr (char *dst, const char *src, size_t size)
   return len;
 }
 
-/* General retrieve stack support: */
-
-void
-mu_register_retriever (mu_list_t *pflist, mu_retrieve_fp fun)
-{
-  if (!*pflist && mu_list_create (pflist))
-    return;
-  mu_list_append (*pflist, fun);
-}
-
-void *
-mu_retrieve (mu_list_t flist, void *data)
-{
-  void *p = NULL;
-  mu_iterator_t itr;
-
-  if (mu_list_get_iterator (flist, &itr) == 0)
-    {
-      mu_retrieve_fp fun;
-      for (mu_iterator_first (itr); !p && !mu_iterator_is_done (itr);
-	   mu_iterator_next (itr))
-	{
-	  mu_iterator_current (itr, (void **)&fun);
-	  p = (*fun) (data);
-	}
-
-      mu_iterator_destroy (&itr);
-    }
-  return p;
-}
-
 int
 mu_get_host_name (char **host)
 {
diff --git a/mailbox/opool.c b/mailbox/opool.c
index 06fa31a..c98dc66 100644
--- a/mailbox/opool.c
+++ b/mailbox/opool.c
@@ -1,5 +1,5 @@
 /* String-list functions for GNU Mailutils.
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
 
    Based on slist module from GNU Radius.  Written by Sergey Poznyakoff.
    
@@ -254,7 +254,50 @@ mu_opool_finish (mu_opool_t opool, size_t *psize)
   mu_opool_clear (opool);
   return opool->free->buf;
 }
+
+int
+mu_opool_union (mu_opool_t *pdst, mu_opool_t *psrc)
+{
+  mu_opool_t src, dst;
+  
+  if (!psrc)
+    return EINVAL;
+  if (!*psrc)
+    return 0;
+  src = *psrc;
   
+  if (!pdst)
+    return EINVAL;
+  if (!*pdst)
+    {
+      *pdst = src;
+      *psrc = NULL;
+      return 0;
+    }
+  else
+    dst = *pdst;
+
+  if (dst->tail)
+    dst->tail->next = src->head;
+  else
+    dst->head = src->head;
+  dst->tail = src->tail;
+
+  if (src->free)
+    {
+      struct mu_opool_bucket *p;
+
+      for (p = src->free; p->next; p = p->next)
+	;
+      p->next = dst->free;
+      dst->free = src->free;
+    }
+
+  free (src);
+  *psrc = NULL;
+  return 0;
+}
+
 
 /* Iterator support */
 struct opool_iterator
diff --git a/mailbox/testsuite/lib/mailbox.exp b/mailbox/testsuite/lib/mailbox.exp
index 188a0e4..2c23d16 100644
--- a/mailbox/testsuite/lib/mailbox.exp
+++ b/mailbox/testsuite/lib/mailbox.exp
@@ -1,6 +1,6 @@
 # -*- tcl -*-
 # This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007 Free Software Foundation
+# Copyright (C) 2002, 2007, 2009 Free Software Foundation
 #  
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ proc mailbox_run {args} {
 	if {"$a" == "-mail-spool"} {
 	    if [info exists host_board] {
 		if [board_info $host_board exists top_srcdir] {
-		    append sw "--mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool"
+		    append sw "--set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
 		}
 	    }
 	    if {![info exists init_spool]} {
diff --git a/messages/testsuite/messages/test.exp b/messages/testsuite/messages/test.exp
index 955cf9d..75758ea 100644
--- a/messages/testsuite/messages/test.exp
+++ b/messages/testsuite/messages/test.exp
@@ -1,6 +1,6 @@
 # -*- tcl -*-
 # This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007 Free Software Foundation
+# Copyright (C) 2002, 2007, 2009 Free Software Foundation
 #  
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ mu_exec -message "messages" \
 mu_exec -message "messages -q" -arg -q "5"
 
 mu_exec -message "messages +teaparty.mbox" \
-     -arg "--mail-folder=$MU_SPOOL_DIR" -arg +teaparty.mbox \
+     -arg "--set mailbox.folder=$MU_SPOOL_DIR" -arg +teaparty.mbox \
 "Number of messages in $MU_SPOOL_DIR/teaparty.mbox: 95"
 
 #end of test.exp
diff --git a/mh/mh.h b/mh/mh.h
index cc580e2..0ccaeac 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -63,8 +63,9 @@
 extern char *strchrnul (const char *s, int c_in);
 #endif
 
-#define MH_FMT_RALIGN 0x1000
+#define MH_FMT_RALIGN  0x1000
 #define MH_FMT_ZEROPAD 0x2000
+#define MH_FMT_COMPWS  0x4000
 #define MH_WIDTH_MASK  0x0fff
 
 #define MH_SEQUENCES_FILE ".mh_sequences"
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 04552ad..f7b18f1 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -133,6 +133,14 @@ compress_ws (char *str, size_t *size)
   *size = p - (unsigned char*) str;
 }
 
+#define COMPRESS_WS(mach, str, size)		\
+  do						\
+    {						\
+      if ((mach)->fmtflags & MH_FMT_COMPWS)	\
+	compress_ws (str, size);		\
+    }						\
+  while (0)
+
 static void
 put_string (struct mh_machine *mach, char *str, int len)
 {
@@ -282,7 +290,13 @@ print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str)
 static void
 reset_fmt_defaults (struct mh_machine *mach)
 {
+  const char *p;
+  
   mach->fmtflags = 0;
+  p = mh_global_profile_get ("Compress-WS", NULL);
+  if (p && (mu_c_strcasecmp (p, "yes") == 0
+	    || mu_c_strcasecmp (p, "true") == 0))
+    mach->fmtflags |= MH_FMT_COMPWS;
 }
 
 static void
@@ -475,7 +489,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	      {
 		size_t len = strlen (value);
 		mach.arg_str.size = len + 1;
-      		compress_ws (value, &len);
+      		COMPRESS_WS (&mach, value, &len);
 		mach.arg_str.ptr = value;
 		mach.arg_num = 1;
 	      }
@@ -511,7 +525,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 		   && str_off < size)
 	      {
 		off += nread;
-       		compress_ws (mach.arg_str.ptr + str_off, &nread);
+                COMPRESS_WS (&mach, mach.arg_str.ptr + str_off, &nread);
 		if (nread)
 		  str_off += nread;
 	      }
@@ -1827,7 +1841,7 @@ builtin_concat (struct mh_machine *mach)
 
   if (size == 0)
     return;
-  compress_ws (strobj_ptr (&mach->arg_str), &size);
+  COMPRESS_WS (mach, strobj_ptr (&mach->arg_str), &size);
   if (strobj_len (&mach->reg_str) == 0)
     strobj_copy (&mach->reg_str, &mach->arg_str);
   else
diff --git a/po/POTFILES.in b/po/POTFILES.in
index bc19f93..6b4a59e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -43,14 +43,9 @@ libmu_argp/auth.c
 libmu_argp/cmdline.c
 libmu_argp/common.c
 libmu_argp/compat.c
-libmu_argp/gsasl.c
 libmu_argp/mu_argp.c
-libmu_argp/pam.c
-libmu_argp/radius.c
 libmu_argp/sieve.c
-libmu_argp/sql.c
 libmu_argp/tls.c
-libmu_argp/virtdomain.c
 
 libmu_auth/ldap.c
 libmu_auth/radius.c
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 6c725cb..50621a2 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -49,21 +49,14 @@ char *login_stat_file = LOGIN_STAT_FILE;
 #endif
 
 unsigned expire = EXPIRE_NEVER; /* Expire messages after this number of days */
-int expire_on_exit = 0;       /* Delete expired messages on exit */
+int expire_on_exit = 0;         /* Delete expired messages on exit */
 
 static error_t pop3d_parse_opt  (int key, char *arg, struct argp_state *astate);
 
 const char *program_version = "pop3d (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU pop3d -- the POP3 daemon.");
 
-#define OPT_LOGIN_DELAY     257
-#define OPT_STAT_FILE       258
-#define OPT_EXPIRE          259
-#define OPT_EXPIRE_ON_EXIT  260
-#define OPT_TLS_REQUIRED    261
-#define OPT_BULLETIN_SOURCE 262
-#define OPT_BULLETIN_DB     263
-#define OPT_FOREGROUND      264
+#define OPT_FOREGROUND      256
 
 static struct argp_option options[] = {
 #define GRP 0
@@ -73,38 +66,6 @@ static struct argp_option options[] = {
     N_("runs in daemon mode with a maximum of NUMBER children"), GRP+1 },
 #undef GRP
 
-#define GRP 5
-  {"undelete", 'u', NULL, OPTION_HIDDEN,
-   N_("undelete all messages on startup"), GRP+1},
-  {"expire", OPT_EXPIRE, N_("DAYS"), OPTION_HIDDEN,
-   N_("expire read messages after the given number of days"), GRP+1},
-  {"delete-expired", OPT_EXPIRE_ON_EXIT, NULL, OPTION_HIDDEN,
-   N_("delete expired messages upon closing the mailbox"), GRP+1},
-#ifdef WITH_TLS
-  {"tls-required", OPT_TLS_REQUIRED, NULL, OPTION_HIDDEN,
-   N_("always require STLS before entering authentication phase")},
-#endif
-#undef GRP
-  
-#define GRP 10
-#ifdef ENABLE_LOGIN_DELAY
-  {"login-delay", OPT_LOGIN_DELAY, N_("SECONDS"), OPTION_HIDDEN,
-   N_("allowed delay between two successive logins"), GRP+1},
-  {"stat-file", OPT_STAT_FILE, N_("FILENAME"), OPTION_HIDDEN,
-   N_("name of login statistics file"), GRP+1},
-#endif
-  
-#undef GRP
-
-#define GRP 20
-  { "bulletin-source", OPT_BULLETIN_SOURCE, N_("MBOX"), OPTION_HIDDEN,
-    N_("set source mailbox to get bulletins from"), GRP+1 },
-#ifdef USE_DBM
-  { "bulletin-db", OPT_BULLETIN_DB, N_("FILE"), OPTION_HIDDEN,
-    N_("set the bulletin database file name"), GRP+1 },
-#endif
-#undef GRP
-  
   {NULL, 0, NULL, 0, NULL, 0}
 };
 
@@ -203,44 +164,6 @@ pop3d_parse_opt (int key, char *arg, struct argp_state *astate)
       mu_argp_node_list_new (&lst, "foreground", "yes");
       break;
       
-    case 'u':
-      mu_argp_node_list_new (&lst, "undelete", "yes");
-      break;
-
-#ifdef ENABLE_LOGIN_DELAY
-    case OPT_LOGIN_DELAY:
-      mu_argp_node_list_new (&lst, "login-delay", arg);
-      break;
-
-    case OPT_STAT_FILE:
-      mu_argp_node_list_new (&lst, "stat-file", arg);
-      break;
-#endif  
- 
-    case OPT_EXPIRE:
-      mu_argp_node_list_new (&lst, "expire", arg);
-      break;
-
-    case OPT_EXPIRE_ON_EXIT:
-      mu_argp_node_list_new (&lst, "delete-expired", "yes");
-      break;
-
-#ifdef WITH_TLS
-    case OPT_TLS_REQUIRED:
-      mu_argp_node_list_new (&lst, "tls-required", "yes");
-      break;
-#endif
-
-    case OPT_BULLETIN_SOURCE:
-      mu_argp_node_list_new (&lst, "bulletin-source", arg);
-      break;
-      
-#ifdef USE_DBM
-    case OPT_BULLETIN_DB:
-      mu_argp_node_list_new (&lst, "bulletin-db", arg);
-      break;
-#endif
-      
     case ARGP_KEY_INIT:
       mu_argp_node_list_init (&lst);
       break;
diff --git a/sieve/testsuite/sieve/action.exp b/sieve/testsuite/sieve/action.exp
index 3335204..faa82a3 100644
--- a/sieve/testsuite/sieve/action.exp
+++ b/sieve/testsuite/sieve/action.exp
@@ -1,6 +1,6 @@
 # -*- tcl -*-
 # This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007 Free Software Foundation
+# Copyright (C) 2002, 2007, 2009 Free Software Foundation
 #  
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ sieve_test discard.sv -pattern\
 "DISCARD on msg uid 2: marking as deleted"\
 "DISCARD on msg uid 3: marking as deleted"
 
-sieve_test --mail-folder='$MU_SPOOL_DIR' fileinto.sv -pattern\
+sieve_test --set "mailbox.folder='$MU_SPOOL_DIR'" fileinto.sv -pattern\
 "FILEINTO on msg uid 1: delivering into +file"\
 "FILEINTO on msg uid 2: delivering into +file"\
 "FILEINTO on msg uid 3: delivering into +file"
diff --git a/testsuite/lib/mailutils.exp b/testsuite/lib/mailutils.exp
index 5c3df94..d4101b2 100644
--- a/testsuite/lib/mailutils.exp
+++ b/testsuite/lib/mailutils.exp
@@ -1,6 +1,6 @@
 # -*- tcl -*-
 # This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2005, 2007, 2008 Free Software Foundation
+# Copyright (C) 2002, 2005, 2007, 2008, 2009 Free Software Foundation
 #  
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -152,7 +152,7 @@ proc mu_init {args} {
 	if {[llength $args] == 1 && [lindex $args 0] == "-noflags"} {
 	    set MU_TOOL_FLAGS "--no-site-rcfile --no-user-rcfile"
 	} else {
-	    set MU_TOOL_FLAGS "--mail-spool $MU_SPOOL_DIR --no-site-rcfile --no-user-rcfile"
+	    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]"
 	    }
@@ -181,7 +181,7 @@ proc mu_start {args} {
     
     if [info exists host_board] {
 	if [board_info $host_board exists top_srcdir] {
-	    append sw " --mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool"
+	    append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
 	}
     }
 
@@ -263,7 +263,7 @@ proc mu_exec {args} {
 
     if [info exists host_board] {
 	if [board_info $host_board exists top_srcdir] {
-	    append sw " --mail-spool [board_info $host_board top_srcdir]/mail/testsuite/spool"
+	    append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
 	}
     }
 


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Tue Dec 29 14:30:29 2009
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NPhm1-0006W7-04
	for mharc-commit-mailutils@gnu.org; Tue, 29 Dec 2009 14:30:29 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NPhlz-0006VZ-FF
	for commit-mailutils@gnu.org; Tue, 29 Dec 2009 14:30:27 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NPhlx-0006VF-BC
	for commit-mailutils@gnu.org; Tue, 29 Dec 2009 14:30:26 -0500
Received: from [199.232.76.173] (port=51649 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NPhlx-0006VC-65
	for commit-mailutils@gnu.org; Tue, 29 Dec 2009 14:30:25 -0500
Received: from savannah.gnu.org ([199.232.41.3]:50336 helo=sv.gnu.org)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <INVALID.NOREPLY@gnu.org>)
	id 1NPhlw-0008Au-HL
	for commit-mailutils@gnu.org; Tue, 29 Dec 2009 14:30:25 -0500
Received: from [10.1.0.109] (helo=cvs.savannah.gnu.org)
	by sv.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NPhlv-0005Ay-Ep
	for commit-mailutils@gnu.org; Tue, 29 Dec 2009 19:30:23 +0000
Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NPhlt-0005AE-Bd
	for commit-mailutils@gnu.org; Tue, 29 Dec 2009 19:30:23 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d39f4c2db3ea8bc387cde7dcc2825598aa166ff6
X-Git-Newrev: 08b3da3417d572cd3567196c8ccb04ec7f068d8d
Message-Id: <E1NPhlt-0005AE-Bd@cvs.savannah.gnu.org>
Date: Tue, 29 Dec 2009 19:30:22 +0000
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-21-g08b3da3
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 29 Dec 2009 19:30: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=08b3da3417d572cd3567196c8ccb04ec7f068d8d

The branch, master has been updated
       via  08b3da3417d572cd3567196c8ccb04ec7f068d8d (commit)
       via  1428bd4560d2e740c4941a0f8121c674c2ee7500 (commit)
      from  d39f4c2db3ea8bc387cde7dcc2825598aa166ff6 (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 08b3da3417d572cd3567196c8ccb04ec7f068d8d
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Dec 29 17:36:29 2009 +0200

    Version 2.1.90
    
    * configure.ac, NEWS: Set version number 2.1.90
    
    * testsuite/lib/mailutils.exp: Quote arguments to the --set option.
    (mu_exec): escape backslashes and double-quotes in $sw.
    * frm/testsuite/frm/test.exp: Quote arguments to the --set option.
    * mail/testsuite/lib/mail.exp: Likewise.
    * mailbox/testsuite/lib/mailbox.exp: Likewise.
    * messages/testsuite/messages/test.exp: Likewise.
    * sieve/testsuite/sieve/action.exp: Likewise.
    * readmsg/testsuite/readmsg/test.exp: Remove extra backslashes,
    not needed due to the changes in mu_exec

commit 1428bd4560d2e740c4941a0f8121c674c2ee7500
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Dec 29 17:34:59 2009 +0200

    Support for multibyte-encoding in MH.
    
    * gnulib.modules (mbchar, mbiter, mbslen): New modules.
    * mh/mh.h (mh_charset): New function.
    * mh/mh_format.c (DFLWIDTH): New macro.
    (mbsubstrlen, mbsnlen): New functions.
    (compress_ws): Handle multibyte strings.
    (put_string): Use number of characters, not
    octets, to update ind.
    (print_hdr_segment): Handle multibyte strings.
    (print_simple_segment, print_fmt_string): Likewise.
    (reset_fmt_defaults): Restore default WS compression.
    (mh_format): Set LC_TYPE based on the settings of
    profile variables Charset and LC_BASE (new variable).
    * mh/mh_init.c (mh_charset): New function.
    (mh_decode_2047): Use mh_charset.

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

Summary of changes:
 NEWS                                 |    7 +-
 configure.ac                         |    2 +-
 frm/testsuite/frm/test.exp           |    2 +-
 gnulib.modules                       |    3 +
 mail/testsuite/lib/mail.exp          |    2 +-
 mailbox/testsuite/lib/mailbox.exp    |    2 +-
 messages/testsuite/messages/test.exp |    2 +-
 mh/mh.h                              |    1 +
 mh/mh_format.c                       |  214 ++++++++++++++++++++++++----------
 mh/mh_init.c                         |   16 ++-
 readmsg/testsuite/readmsg/test.exp   |    4 +-
 sieve/testsuite/sieve/action.exp     |    2 +-
 testsuite/lib/mailutils.exp          |    8 +-
 13 files changed, 183 insertions(+), 82 deletions(-)

diff --git a/NEWS b/NEWS
index c25a1ef..a4d939c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2009-09-10
+GNU mailutils NEWS -- history of user-visible changes. 2009-12-29
 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 
 2008, 2009 Free Software Foundation, Inc.
 See the end of file for copying conditions.
@@ -6,6 +6,11 @@ See the end of file for copying conditions.
 Please send mailutils bug reports to <bug-mailutils@gnu.org>.
 
 
+Version 2.1.90 (Git)
+
+See git log.
+
+
 Version 2.1 "Ten Years Later" - 2009-09-10:
 
 This release marks the 10 years anniversary of GNU Mailutils.
diff --git a/configure.ac b/configure.ac
index e6151ce..fe84ac5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@ dnl with GNU Mailutils; if not, write to the Free Software Foundation,
 dnl Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 AC_PREREQ(2.63)
-AC_INIT([GNU Mailutils], [2.1], [bug-mailutils@gnu.org], [mailutils])
+AC_INIT([GNU Mailutils], [2.1.90], [bug-mailutils@gnu.org], [mailutils])
 AC_CONFIG_SRCDIR([mailbox/mailbox.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([gnits 1.11 dist-bzip2 dist-lzma dist-xz std-options silent-rules])
diff --git a/frm/testsuite/frm/test.exp b/frm/testsuite/frm/test.exp
index 72b8015..a12e4aa 100644
--- a/frm/testsuite/frm/test.exp
+++ b/frm/testsuite/frm/test.exp
@@ -51,7 +51,7 @@ mu_exec -retcode 1 -message "frm -qS" -arg -qS \
 mu_exec -retcode 1 -arg -q -message "frm -q"  \
 "There are messages in that folder."
 
-mu_exec -retcode 1 -arg "--set mailbox.folder=$MU_SPOOL_DIR" -arg +mbox -message "frm +mbox" \
+mu_exec -retcode 1 -arg "--set mailbox.folder=\"'$MU_SPOOL_DIR'\"" -arg +mbox -message "frm +mbox" \
 "Sergey Poznyakoff\tMBOX"
 
 mu_exec -arg -q -arg %nonexistent -retcode 2 -message "frm -q %nonexistent" \
diff --git a/gnulib.modules b/gnulib.modules
index 37093a7..4368cf7 100644
--- a/gnulib.modules
+++ b/gnulib.modules
@@ -14,6 +14,9 @@ gitlog-to-changelog
 intprops
 inttostr
 malloc
+mbchar
+mbiter
+mbslen
 mbswidth
 obstack
 realloc
diff --git a/mail/testsuite/lib/mail.exp b/mail/testsuite/lib/mail.exp
index 6990161..bdae899 100644
--- a/mail/testsuite/lib/mail.exp
+++ b/mail/testsuite/lib/mail.exp
@@ -64,7 +64,7 @@ proc default_mail_start {args} {
     
     if [info exists host_board] {
 	if [board_info $host_board exists top_srcdir] {
-	    append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
+	    append sw " --set \"mailbox.mail-spool='[board_info $host_board top_srcdir]/mail/testsuite/spool'\""
 	}
     }
 
diff --git a/mailbox/testsuite/lib/mailbox.exp b/mailbox/testsuite/lib/mailbox.exp
index 2c23d16..c836fa1 100644
--- a/mailbox/testsuite/lib/mailbox.exp
+++ b/mailbox/testsuite/lib/mailbox.exp
@@ -31,7 +31,7 @@ proc mailbox_run {args} {
 	if {"$a" == "-mail-spool"} {
 	    if [info exists host_board] {
 		if [board_info $host_board exists top_srcdir] {
-		    append sw "--set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
+		    append sw "--set mailbox.mail-spool=\"'[board_info $host_board top_srcdir]/mail/testsuite/spool'\""
 		}
 	    }
 	    if {![info exists init_spool]} {
diff --git a/messages/testsuite/messages/test.exp b/messages/testsuite/messages/test.exp
index 75758ea..89461ef 100644
--- a/messages/testsuite/messages/test.exp
+++ b/messages/testsuite/messages/test.exp
@@ -31,7 +31,7 @@ mu_exec -message "messages" \
 mu_exec -message "messages -q" -arg -q "5"
 
 mu_exec -message "messages +teaparty.mbox" \
-     -arg "--set mailbox.folder=$MU_SPOOL_DIR" -arg +teaparty.mbox \
+     -arg "--set mailbox.folder=\"'$MU_SPOOL_DIR'\"" -arg +teaparty.mbox \
 "Number of messages in $MU_SPOOL_DIR/teaparty.mbox: 95"
 
 #end of test.exp
diff --git a/mh/mh.h b/mh/mh.h
index 0ccaeac..0f9c600 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -334,6 +334,7 @@ char *mh_create_message_id (int);
 int mh_whom (const char *filename, int check);
 void mh_set_reply_regex (const char *str);
 int mh_decode_2047 (char *text, char **decoded_text);
+const char *mh_charset (const char *);
 
 int mh_alias_read (char *name, int fail);
 int mh_alias_get (const char *name, mu_list_t *return_list);
diff --git a/mh/mh_format.c b/mh/mh_format.c
index f7b18f1..f7980f4 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -26,9 +26,15 @@
 #ifdef HAVE_STRINGS_H
 # include <strings.h>
 #endif
+#include <string.h>
+#include "mbiter.h"
+#include "mbchar.h"
+#include "mbswidth.h"
 
 static char *_get_builtin_name (mh_builtin_fp ptr);
 
+#define DFLWIDTH(mach) ((mach)->width - (mach)->ind)
+
 /* Functions for handling string objects. */
 
 void
@@ -106,17 +112,53 @@ strobj_realloc (strobj_t *obj, size_t length)
     }
 }
 
-/* Compress whitespace in a string */
+/* Return the length (number of octets) of a substring of
+   string STR of length LEN, such that it contains NCOL
+   multibyte characters. */
+int
+mbsubstrlen (char *str, size_t len, size_t ncol)
+{
+  int ret = 0;
+  mbi_iterator_t iter;
+
+  if (ncol <= 0)
+    return 0;
+  
+  for (mbi_init (iter, str, len);
+       ncol && mbi_avail (iter);
+       ncol--, mbi_advance (iter))
+    ret += mb_len (mbi_cur (iter));
+  return ret;
+}
+
+/* Return the number of multibyte characters in the first LEN bytes
+   of character string STRING.  */
+size_t
+mbsnlen (char *str, size_t len)
+{
+  int ret = 0;
+  mbi_iterator_t iter;
+
+  for (mbi_init (iter, str, len); mbi_avail (iter); mbi_advance (iter))
+    ret++;
+  return ret;
+}
+
+/* Compress whitespace in a string (multi-byte) */
 static void
-compress_ws (char *str, size_t *size)
+compress_ws (char *str, size_t *psize)
 {
   unsigned char *p, *q;
-  size_t len = *size;
+  size_t size = *psize;
+  mbi_iterator_t iter;
   int space = 0;
-
-  for (p = q = (unsigned char*) str; len; len--, q++)
+  
+  for (p = q = (unsigned char*) str,
+	 mbi_init (iter, str, size);
+       mbi_avail (iter);
+       mbi_advance (iter))
     {
-      if (isspace (*q))
+      if (mb_isspace (mbi_cur (iter)))
 	{
 	  if (!space)
 	    *p++ = ' ';
@@ -126,11 +168,15 @@ compress_ws (char *str, size_t *size)
       else if (space)
 	space = 0;
 
-      if (isprint (*q))
-	*p++ = *q;
+      if (mb_isprint (mbi_cur (iter)))
+	{
+	  size_t len = mb_len (mbi_cur (iter));
+	  memcpy (p, mb_ptr (mbi_cur (iter)), len);
+	  p += len;
+	}
     }
   *p = 0;
-  *size = p - (unsigned char*) str;
+  *psize = p - (unsigned char*) str;
 }
 
 #define COMPRESS_WS(mach, str, size)		\
@@ -145,8 +191,9 @@ static void
 put_string (struct mh_machine *mach, char *str, int len)
 {
   if (len == 0)
-    len = strlen (str);
+    return;
   obstack_grow (&mach->stk, str, len);
+  len = mbsnwidth (str, len, 0);
   mach->ind += len;
 }
 
@@ -156,40 +203,46 @@ print_hdr_segment (struct mh_machine *mach, char *str, size_t len)
   if (!len)
     len = strlen (str);
 
-  if (len < mach->width)
+  if (mbsnlen (str, len) < mach->width)
     put_string (mach, str, len);
   else
     {
-      char *endp = str + len;
-      
-      while (str < endp)
+      while (1)
 	{
-	  size_t rest;
-	  char *p;
-	  size_t size;
+	  mbi_iterator_t iter;
+	  size_t rest = DFLWIDTH (mach);
+	  size_t width = mbsnlen (str, len);
+	  size_t off, size;
 	  
-	  size = endp - str;
-	  rest = mach->width - mach->ind;
-	  if (size < rest)
+	  if (width <= rest)
 	    {
-	      put_string (mach, str, size);
+	      put_string (mach, str, len);
 	      break;
 	    }
-	  
-	  for (p = str + rest - 1; p > str && !isspace (*p); p--)
-	    ;
 
-	  if (p > str)
+	  size = off = 0;
+	  for (mbi_init (iter, str, len);
+	       mbi_avail (iter);
+	       mbi_advance (iter))
 	    {
-	      put_string (mach, str, p - str);
-	      put_string (mach, "\n\t", 0);
+	      if (mb_isspace (mbi_cur (iter)))
+		off = size;
+	      size += mb_len (mbi_cur (iter));
+	    }
+
+	  if (off > 0)
+	    {
+	      put_string (mach, str, off);
+	      put_string (mach, "\n        ", 9);
 	      mach->ind = 8;
-	      str = p;
+	      str += off;
+	      len -= off;
 	    }
 	  else
 	    {
-	      put_string (mach, str, size);
-	      str += len;
+	      size = mbsubstrlen (str, len, rest);
+	      put_string (mach, str, len);
+	      break;
 	    }
 	}
     }
@@ -232,7 +285,7 @@ print_simple_segment (struct mh_machine *mach, size_t width,
   if (!width)
     width = mach->width;
 
-  rest = width - mach->ind;
+  rest = DFLWIDTH (mach);
   if (rest == 0)
     {
       if (len == 1 && str[0] == '\n')
@@ -240,10 +293,7 @@ print_simple_segment (struct mh_machine *mach, size_t width,
       return;
     }
   
-  if (len > rest)
-    len = rest;
-
-  put_string (mach, str, len);
+  put_string (mach, str, mbsubstrlen (str, len, rest));
 }
 
 static void
@@ -274,13 +324,21 @@ static void
 print_fmt_string (struct mh_machine *mach, size_t fmtwidth, char *str)
 {
   size_t len = strlen (str);
-  if (len > fmtwidth)
-    len = fmtwidth;
+  size_t width = mbslen (str);
+
+  if (fmtwidth && width > fmtwidth)
+    {
+      len = mbsubstrlen (str, len, fmtwidth);
+      width = fmtwidth;
+    }
+  else
+    len = mbsubstrlen (str, len, DFLWIDTH (mach));
+  
   put_string (mach, str, len);
 
-  if (fmtwidth > len)
+  if (fmtwidth > width)
     {
-      fmtwidth -= len;
+      fmtwidth -= width;
       mach->ind += fmtwidth;
       while (fmtwidth--)
 	obstack_1grow (&mach->stk, ' ');
@@ -293,7 +351,7 @@ reset_fmt_defaults (struct mh_machine *mach)
   const char *p;
   
   mach->fmtflags = 0;
-  p = mh_global_profile_get ("Compress-WS", NULL);
+  p = mh_global_profile_get ("Compress-WS", "yes");
   if (p && (mu_c_strcasecmp (p, "yes") == 0
 	    || mu_c_strcasecmp (p, "true") == 0))
     mach->fmtflags |= MH_FMT_COMPWS;
@@ -409,6 +467,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 {
   struct mh_machine mach;
   char buf[64];
+  const char *charset = mh_global_profile_get ("Charset", NULL);
   
   memset (&mach, 0, sizeof (mach));
   mach.progsize = fmt->progsize;
@@ -421,13 +480,40 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
   mach.pc = 1;
   obstack_init (&mach.stk);
   mu_list_create (&mach.addrlist);
-
+  
   reset_fmt_defaults (&mach);
+
+#if HAVE_SETLOCALE
+  if (charset && strcmp (charset, "auto"))
+    {
+      /* Try to set LC_CTYPE according to the value of Charset variable.
+	 If Charset is `auto', there's no need to do anything, since it
+	 is already set. Otherwise, we need to construct a valid locale
+	 value with Charset as its codeset part. The problem is, what
+	 language and territory to use for that locale.
+
+	 Neither LANG nor any other environment variable is of any use,
+	 because if it were, the user would have set "Charset: auto".
+	 It would be logical to use 'C' or 'POSIX', but these do not
+	 work with '.UTF-8'. So, in the absence of any viable alternative,
+	 'en_US' is selected. This choice may be overridden by setting
+	 the LC_BASE mh_profile variable to the desired base part.
+      */
+      const char *lc_base = mh_global_profile_get ("LC_BASE", "en_US");
+      char *locale = xmalloc (strlen (lc_base) + 1 + strlen (charset) + 1);
+      strcpy (locale, lc_base);
+      strcat (locale, ".");
+      strcat (locale, charset);
+      if (!setlocale (LC_CTYPE, locale))
+        mu_error (_("cannot set LC_CTYPE %s"), locale);
+      free (locale);
+    }
+#endif
   
-  while (!mach.stop)
+  while (!mach.stop && mach.ind < mach.width)
     {
       mh_opcode_t opcode;
-      switch (opcode = MHI_OPCODE(mach.prog[mach.pc++]))
+      switch (opcode = MHI_OPCODE (mach.prog[mach.pc++]))
 	{
 	case mhop_nop:
 	  break;
@@ -437,7 +523,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	  break;
 
 	case mhop_branch:
-	  mach.pc += MHI_NUM(mach.prog[mach.pc]);
+	  mach.pc += MHI_NUM (mach.prog[mach.pc]);
 	  break;
 
 	case mhop_num_asgn:
@@ -449,27 +535,27 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	  break;
 	  
 	case mhop_num_arg:
-	  mach.arg_num = MHI_NUM(mach.prog[mach.pc++]);
+	  mach.arg_num = MHI_NUM (mach.prog[mach.pc++]);
 	  break;
 	  
 	case mhop_str_arg:
 	  {
-	    size_t skip = MHI_NUM(mach.prog[mach.pc++]);
-	    strobj_set (&mach.arg_str, MHI_STR(mach.prog[mach.pc]));
+	    size_t skip = MHI_NUM (mach.prog[mach.pc++]);
+	    strobj_set (&mach.arg_str, MHI_STR (mach.prog[mach.pc]));
 	    mach.pc += skip;
 	  }
 	  break;
 
 	case mhop_num_branch:
 	  if (!mach.arg_num)
-	    mach.pc += MHI_NUM(mach.prog[mach.pc]);
+	    mach.pc += MHI_NUM (mach.prog[mach.pc]);
 	  else
 	    mach.pc++;
 	  break;
 
 	case mhop_str_branch:
 	  if (!*strobj_ptr (&mach.arg_str))
-	    mach.pc += MHI_NUM(mach.prog[mach.pc]);
+	    mach.pc += MHI_NUM (mach.prog[mach.pc]);
 	  else
 	    mach.pc++;
 	  break;
@@ -503,7 +589,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	    mu_body_t body = NULL;
 	    mu_stream_t stream = NULL;
 	    size_t size = 0, off, str_off, nread;
-	    size_t rest = mach.width - mach.ind;
+	    size_t rest = DFLWIDTH (&mach);
 
 	    strobj_free (&mach.arg_str);
 	    mu_message_get_body (mach.message, &body);
@@ -564,7 +650,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	  break;
 
 	case mhop_fmtspec:
-	  mach.fmtflags = MHI_NUM(mach.prog[mach.pc++]);
+	  mach.fmtflags = MHI_NUM (mach.prog[mach.pc++]);
 	  break;
 
 	default:
@@ -615,7 +701,7 @@ mh_format_dump (mh_format_t *fmt)
       int num;
       
       printf ("% 4.4ld: ", (long) pc);
-      switch (opcode = MHI_OPCODE(prog[pc++]))
+      switch (opcode = MHI_OPCODE (prog[pc++]))
 	{
 	case mhop_nop:
 	  printf ("nop");
@@ -627,7 +713,7 @@ mh_format_dump (mh_format_t *fmt)
 	  break;
 
 	case mhop_branch:
-	  num = MHI_NUM(prog[pc++]);
+	  num = MHI_NUM (prog[pc++]);
 	  printf ("branch %d, %lu",
 		  num, (unsigned long) pc + num - 1);
 	  break;
@@ -641,14 +727,14 @@ mh_format_dump (mh_format_t *fmt)
 	  break;
 	  
 	case mhop_num_arg:
-	  num = MHI_NUM(prog[pc++]);
+	  num = MHI_NUM (prog[pc++]);
 	  printf ("num_arg %d", num);
 	  break;
 	  
 	case mhop_str_arg:
 	  {
-	    size_t skip = MHI_NUM(prog[pc++]);
-	    char *s = MHI_STR(prog[pc]);
+	    size_t skip = MHI_NUM (prog[pc++]);
+	    char *s = MHI_STR (prog[pc]);
 	    printf ("str_arg \"");
 	    for (; *s; s++)
 	      {
@@ -696,13 +782,13 @@ mh_format_dump (mh_format_t *fmt)
 	  break;
 
 	case mhop_num_branch:
-	  num = MHI_NUM(prog[pc++]);
+	  num = MHI_NUM (prog[pc++]);
 	  printf ("num_branch %d, %lu",
 		  num, (unsigned long) (pc + num - 1));
 	  break;
 
 	case mhop_str_branch:
-	  num = MHI_NUM(prog[pc++]);
+	  num = MHI_NUM (prog[pc++]);
 	  printf ("str_branch %d, %lu",
 		  num, (unsigned long) (pc + num - 1));
 	  break;
@@ -753,7 +839,7 @@ mh_format_dump (mh_format_t *fmt)
 	  {
 	    int space = 0;
 	    
-	    num = MHI_NUM(prog[pc++]);
+	    num = MHI_NUM (prog[pc++]);
 	    printf ("fmtspec: %#x, ", num);
 	    if (num & MH_FMT_RALIGN)
 	      {
@@ -840,7 +926,7 @@ builtin_width (struct mh_machine *mach)
 static void
 builtin_charleft (struct mh_machine *mach)
 {
-  mach->arg_num = mach->width - mach->ind;
+  mach->arg_num = DFLWIDTH (mach);
 }
 
 static void
@@ -1961,10 +2047,10 @@ mh_builtin_t builtin_tab[] = {
   { "comp",     builtin_comp,     mhtype_num,  mhtype_str,  MHA_OPTARG },
   { "compval",  builtin_compval,  mhtype_num,  mhtype_str },	   
   { "trim",     builtin_trim,     mhtype_str,  mhtype_str,  MHA_OPTARG },
-  { "putstr",   builtin_putstr,   mhtype_none,  mhtype_str, MHA_OPTARG },
-  { "putstrf",  builtin_putstrf,  mhtype_none,  mhtype_str, MHA_OPTARG },
-  { "putnum",   builtin_putnum,   mhtype_none,  mhtype_num, MHA_OPTARG },
-  { "putnumf",  builtin_putnumf,  mhtype_none,  mhtype_num, MHA_OPTARG },
+  { "putstr",   builtin_putstr,   mhtype_none, mhtype_str,  MHA_OPTARG },
+  { "putstrf",  builtin_putstrf,  mhtype_none, mhtype_str,  MHA_OPTARG },
+  { "putnum",   builtin_putnum,   mhtype_none, mhtype_num,  MHA_OPTARG },
+  { "putnumf",  builtin_putnumf,  mhtype_none, mhtype_num,  MHA_OPTARG },
   { "sec",      builtin_sec,      mhtype_num,  mhtype_str },
   { "min",      builtin_min,      mhtype_num,  mhtype_str },
   { "hour",     builtin_hour,     mhtype_num,  mhtype_str },
diff --git a/mh/mh_init.c b/mh/mh_init.c
index 20cccda..eecae2c 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -870,17 +870,17 @@ mh_set_reply_regex (const char *str)
 	      err ? err : "");
 }
 
-int
-mh_decode_2047 (char *text, char **decoded_text)
+const char *
+mh_charset (const char *dfl)
 {
-  const char *charset = mh_global_profile_get ("Charset", NULL);
+  const char *charset = mh_global_profile_get ("Charset", dfl);
 
   if (!charset)
-    return 1;
+    return NULL;
   if (mu_c_strcasecmp (charset, "auto") == 0)
     {
       /* Try to deduce the charset from LC_ALL variable */
-
+      
       char *lc_all = getenv ("LC_ALL");
       if (lc_all)
 	{
@@ -899,7 +899,13 @@ mh_decode_2047 (char *text, char **decoded_text)
 	  free (tmp);
 	}
     }
+  return charset;
+}
 
+int
+mh_decode_2047 (char *text, char **decoded_text)
+{
+  const char *charset = mh_charset (NULL);
   if (!charset)
     return 1;
   
diff --git a/readmsg/testsuite/readmsg/test.exp b/readmsg/testsuite/readmsg/test.exp
index cc834d9..2492648 100644
--- a/readmsg/testsuite/readmsg/test.exp
+++ b/readmsg/testsuite/readmsg/test.exp
@@ -1,6 +1,6 @@
 # -*- tcl -*-
 # This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007 Free Software Foundation
+# Copyright (C) 2002, 2007, 2009 Free Software Foundation
 #  
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ set env(FOLDER) $env(MAIL)
 
 mu_prepare_spools
 
-mu_exec -message "readmsg *" -arg "\\\\*" \
+mu_exec -message "readmsg *" -arg "\\*" \
 "Date: Fri, 28 Dec 2001 22:18:08 +0200"\
 "From: Foo Bar <foobar@nonexistent.net>"\
 "To: Bar <bar@dontmailme.org>"\
diff --git a/sieve/testsuite/sieve/action.exp b/sieve/testsuite/sieve/action.exp
index faa82a3..dd6af96 100644
--- a/sieve/testsuite/sieve/action.exp
+++ b/sieve/testsuite/sieve/action.exp
@@ -37,7 +37,7 @@ sieve_test discard.sv -pattern\
 "DISCARD on msg uid 2: marking as deleted"\
 "DISCARD on msg uid 3: marking as deleted"
 
-sieve_test --set "mailbox.folder='$MU_SPOOL_DIR'" fileinto.sv -pattern\
+sieve_test --set "mailbox.folder=\"'$MU_SPOOL_DIR'\"" fileinto.sv -pattern\
 "FILEINTO on msg uid 1: delivering into +file"\
 "FILEINTO on msg uid 2: delivering into +file"\
 "FILEINTO on msg uid 3: delivering into +file"
diff --git a/testsuite/lib/mailutils.exp b/testsuite/lib/mailutils.exp
index d4101b2..10d8043 100644
--- a/testsuite/lib/mailutils.exp
+++ b/testsuite/lib/mailutils.exp
@@ -152,7 +152,7 @@ proc mu_init {args} {
 	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"
+	    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]"
 	    }
@@ -181,7 +181,7 @@ proc mu_start {args} {
     
     if [info exists host_board] {
 	if [board_info $host_board exists top_srcdir] {
-	    append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
+	    append sw " --set mailbox.mail-spool=\"'[board_info $host_board top_srcdir]/mail/testsuite/spool'\""
 	}
     }
 
@@ -263,14 +263,14 @@ proc mu_exec {args} {
 
     if [info exists host_board] {
 	if [board_info $host_board exists top_srcdir] {
-	    append sw " --set mailbox.mail-spool=[board_info $host_board top_srcdir]/mail/testsuite/spool"
+	    append sw " --set mailbox.mail-spool=\"'[board_info $host_board top_srcdir]/mail/testsuite/spool'""
 	}
     }
 
     # Pity, dejagnu provides no way to retrieve exit status of the process.
     # This ugly construction is used to work around this. Hopefully, it
     # should execute on any decent platform...
-    set cmd "sh -c \"$MU_TOOL $sw\; echo \$?\""
+    set cmd "sh -c \"$MU_TOOL [regsub -all {["\\]} $sw {\\&}]\; echo \$?\""
     verbose "Executing $cmd"
 
     set res [remote_exec host $cmd]


hooks/post-receive
-- 
GNU Mailutils



