From MAILER-DAEMON Thu Apr 01 06:35:33 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NxHkL-0001W9-8I
	for mharc-commit-mailutils@gnu.org; Thu, 01 Apr 2010 06:35:33 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NxHkI-0001W2-Ny
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 06:35:30 -0400
Received: from [140.186.70.92] (port=48063 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NxHkF-0001VI-Ko
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 06:35:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxHkD-0007mn-GH
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 06:35:27 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:38790
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxHkD-0007mj-Dg
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 06:35:25 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxHkD-0004uK-0S
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 10:35:25 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxHkB-00037i-R6
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 10:35:24 +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: c3378d59ccc7cf6d57d6b07ed8923a169c7923cd
X-Git-Newrev: 43a43a758881ae1294b73696175bc066e9257aa2
Message-Id: <E1NxHkB-00037i-R6@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 01 Apr 2010 10:35:24 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-53-g43a43a7
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: Thu, 01 Apr 2010 10:35:30 -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=43a43a758881ae1294b73696175bc066e9257aa2

The branch, master has been updated
       via  43a43a758881ae1294b73696175bc066e9257aa2 (commit)
       via  ee08a14e8d73482297fa603938e0ba04475c092c (commit)
       via  36226fa2c08235807a34ca448788f6cdaa9cff02 (commit)
      from  c3378d59ccc7cf6d57d6b07ed8923a169c7923cd (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 43a43a758881ae1294b73696175bc066e9257aa2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 13:25:41 2010 +0300

    Fix SCM syslog interface.
    
    * libmu_scm/mu_logger.c (log_tag): New static.
    (mu-openlog): Preserve log tag in log_tag, because
    openlog stores its first argument as-is.
    Simplify argument handling.
    (mu-logger): Simplify argument handling.
    (mu-closelog): Free log_tag.

commit ee08a14e8d73482297fa603938e0ba04475c092c
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 13:15:01 2010 +0300

    Remove the uses of deprecated Guile functions.
    
    * am/guile.m4 (MU_CHECK_GUILE): Check for scm_t_off.
    * include/mailutils/guile.h (mu_scm_makenum)
    (mu_set_variable): Remove prototypes.
    * libmu_scm/mu_address.c: Remove calls to deprecated Guile functions.
    * libmu_scm/mu_body.c: Likewise.
    * libmu_scm/mu_guile.c: Likewise.
    * libmu_scm/mu_mailbox.c: Likewise.
    * libmu_scm/mu_message.c: Likewise.
    * libmu_scm/mu_mime.c: Likewise.
    * libmu_scm/mu_util.c: Likewise.
    * libmu_scm/mu_scm.c (mu_scm_makenum): Remove.
    (mu_set_variable): Remove. Use scm_c_define instead.

commit 36226fa2c08235807a34ca448788f6cdaa9cff02
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 13:13:28 2010 +0300

    Add missing include.
    
    * mailutils/mutil.h: Include mailutils/mutil.h

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

Summary of changes:
 am/guile.m4               |    3 +-
 include/mailutils/guile.h |    3 +-
 libmu_scm/mu_address.c    |    6 ++--
 libmu_scm/mu_body.c       |    4 +-
 libmu_scm/mu_guile.c      |    2 +-
 libmu_scm/mu_logger.c     |   51 ++++++++++++++---------------------------
 libmu_scm/mu_mailbox.c    |   12 +++++-----
 libmu_scm/mu_message.c    |   55 +++++++++++++++++++-------------------------
 libmu_scm/mu_mime.c       |    6 ++--
 libmu_scm/mu_scm.c        |   53 +++++++++++-------------------------------
 libmu_scm/mu_util.c       |   22 ++++++-----------
 mailbox/cfg_lexer.l       |    3 +-
 12 files changed, 83 insertions(+), 137 deletions(-)

diff --git a/am/guile.m4 b/am/guile.m4
index ff0a544..f049037 100644
--- a/am/guile.m4
+++ b/am/guile.m4
@@ -62,7 +62,8 @@ AC_DEFUN([MU_CHECK_GUILE],
     GUILE_VERSION=
     GUILE_VERSION_NUMBER=
     m4_if($3,,[AC_MSG_ERROR(required library libguile not found)], [$3])
-  else    
+  else
+    AC_CHECK_TYPES([scm_t_off],[],[],[#include <libguile.h>])
     AC_DEFINE_UNQUOTED(GUILE_VERSION, "$GUILE_VERSION",
                        [Guile version number])
     AC_DEFINE_UNQUOTED(GUILE_VERSION_NUMBER, $GUILE_VERSION_NUMBER,
diff --git a/include/mailutils/guile.h b/include/mailutils/guile.h
index 1c0e6e2..1db5b8a 100644
--- a/include/mailutils/guile.h
+++ b/include/mailutils/guile.h
@@ -43,8 +43,7 @@ extern "C" {
 
 void mu_scm_error (const char *func_name, int status,
 		   const char *fmt, SCM args);
-extern SCM mu_scm_makenum (unsigned long val);
-extern void mu_set_variable (const char *name, SCM value);
+
 extern void mu_scm_init (void);
 
 extern void mu_scm_mailbox_init (void);
diff --git a/libmu_scm/mu_address.c b/libmu_scm/mu_address.c
index ace89c2..a357170 100644
--- a/libmu_scm/mu_address.c
+++ b/libmu_scm/mu_address.c
@@ -66,7 +66,7 @@ _get_address_part (const char *func_name, address_get_fp fun,
   mu_address_destroy (&addr);
 
   if (status == 0)
-    ret = scm_makfrom0str (str);
+    ret = scm_from_locale_string (str);
   else
     {
       free (str);
@@ -150,7 +150,7 @@ SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0,
 
   mu_address_get_count (addr, &count);
   mu_address_destroy (&addr);
-  return mu_scm_makenum (count);
+  return scm_from_size_t (count);
 }
 #undef FUNC_NAME
 
@@ -179,7 +179,7 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0,
 		  "Cannot get user email for ~A",
 		  scm_list_1 (NAME));
 
-  ret = scm_makfrom0str (email);
+  ret = scm_from_locale_string (email);
   free (email);
   return ret;
 }
diff --git a/libmu_scm/mu_body.c b/libmu_scm/mu_body.c
index 435e2c2..43ee30b 100644
--- a/libmu_scm/mu_body.c
+++ b/libmu_scm/mu_body.c
@@ -19,7 +19,7 @@
 
 #include "mu_scm.h"
 
-long body_tag;
+static scm_t_bits body_tag;
 
 struct mu_body
 {
@@ -159,7 +159,7 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
   if (nread == 0)
     return SCM_EOF_VAL;
 
-  return scm_makfrom0str (mbp->buffer);
+  return scm_from_locale_string (mbp->buffer);
 }
 #undef FUNC_NAME
 
diff --git a/libmu_scm/mu_guile.c b/libmu_scm/mu_guile.c
index c2fb89c..b5cd261 100644
--- a/libmu_scm/mu_guile.c
+++ b/libmu_scm/mu_guile.c
@@ -131,7 +131,7 @@ load_path_handler (void *data)
   struct load_closure *lp = data;
 
   scm_set_program_arguments (lp->argc, lp->argv, (char*)lp->filename);
-  scm_primitive_load (scm_makfrom0str (lp->filename));
+  scm_primitive_load (scm_from_locale_string (lp->filename));
   return SCM_UNDEFINED;
 }
 
diff --git a/libmu_scm/mu_logger.c b/libmu_scm/mu_logger.c
index 5b6d0f4..4dc7841 100644
--- a/libmu_scm/mu_logger.c
+++ b/libmu_scm/mu_logger.c
@@ -21,39 +21,22 @@
 
 #include <syslog.h>
 
+static char *log_tag;
+
 SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0,
 	   (SCM IDENT, SCM OPTION, SCM FACILITY),
 "Opens a connection to the system logger for Guile program.\n"
 "IDENT, OPTION and FACILITY have the same meaning as in openlog(3)")
 #define FUNC_NAME s_scm_mu_openlog
 {
-  char *ident, *ident_mem = NULL;
-  int option, facility;
-
-  if (IDENT == SCM_BOOL_F)
-    ident = "libmu_scm";
-  else
-    {
-      SCM_ASSERT (scm_is_string (IDENT), IDENT, SCM_ARG1, FUNC_NAME);
-      ident = ident_mem = scm_to_locale_string (IDENT);
-    }
+  SCM_ASSERT (scm_is_string (IDENT), IDENT, SCM_ARG1, FUNC_NAME);
+  if (log_tag)
+    free (log_tag);
+  log_tag = scm_to_locale_string(IDENT);
 	
-  if (scm_is_integer (OPTION))
-    option = scm_to_int32 (OPTION);
-  else if (SCM_BIGP (OPTION)) 
-    option = (int) scm_i_big2dbl (OPTION);
-  else 
-    SCM_ASSERT (0, OPTION, SCM_ARG2, FUNC_NAME);
-
-  if (scm_is_integer (FACILITY)) 
-    facility = scm_to_int32 (FACILITY);
-  else if (SCM_BIGP (FACILITY)) 
-    facility = (int) scm_i_big2dbl (FACILITY);
-  else
-    SCM_ASSERT (0, FACILITY, SCM_ARG3, FUNC_NAME);
-
-  openlog (ident, option, facility);
-  free (ident_mem);
+  SCM_ASSERT (scm_is_integer (OPTION), OPTION, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_integer (FACILITY), FACILITY, SCM_ARG3, FUNC_NAME);
+  openlog (log_tag, scm_to_int (OPTION), scm_to_int (FACILITY));
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
@@ -66,18 +49,13 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0,
   int prio;
   char *str;
 
-  if (PRIO == SCM_BOOL_F) 
-    prio = LOG_INFO;
-  else if (scm_is_integer (PRIO)) 
-    prio = scm_to_int32 (PRIO);
-  else if (SCM_BIGP (PRIO)) 
-    prio = (int) scm_i_big2dbl (PRIO);
-  else
-    SCM_ASSERT (0, PRIO, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_integer (PRIO), PRIO, SCM_ARG1, FUNC_NAME);
+  prio = scm_to_int (PRIO);
   
   SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME);
   str = scm_to_locale_string (TEXT);
   syslog (prio, "%s", str);
+  free (str);
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
@@ -88,6 +66,11 @@ SCM_DEFINE (scm_mu_closelog, "mu-closelog", 0, 0, 0,
 #define FUNC_NAME s_scm_mu_closelog
 {
   closelog ();
+  if (log_tag)
+    {
+      free (log_tag);
+      log_tag = NULL;
+    }
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index 4d4eb55..8a54fda 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -19,7 +19,7 @@
 
 #include "mu_scm.h"
 
-long mailbox_tag;
+static scm_t_bits mailbox_tag;
 
 /* NOTE: Maybe will have to add some more members. That's why it is a
    struct, not just a typedef mu_mailbox_t */
@@ -160,7 +160,7 @@ SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0,
     mu_scm_error (FUNC_NAME, rc,
 		  "Cannot construct mailbox URL for ~A",
 		  scm_list_1 (USER));
-  ret = scm_makfrom0str (p);
+  ret = scm_from_locale_string (p);
   free (p);
   return ret;
 }
@@ -175,13 +175,13 @@ SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0,
   if (!SCM_UNBNDP (URL))
     {
       char *s;
-      
+
       SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME);
       s = scm_to_locale_string (URL);
       mu_set_folder_directory (s);
       free (s);
     }
-  return scm_makfrom0str (mu_folder_directory ());
+  return scm_from_locale_string (mu_folder_directory ());
 }
 #undef FUNC_NAME 
 
@@ -288,7 +288,7 @@ SCM_DEFINE (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0,
                   "Cannot get mailbox url",
                   SCM_BOOL_F);
 
-  return scm_makfrom0str (mu_url_to_string (url));
+  return scm_from_locale_string (mu_url_to_string (url));
 }
 #undef FUNC_NAME
 
@@ -364,7 +364,7 @@ SCM_DEFINE (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0,
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot count messages in mailbox ~A",
 		  scm_list_1 (MBOX));
-  return mu_scm_makenum (nmesg);
+  return scm_from_size_t (nmesg);
 }
 #undef FUNC_NAME
 
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index 61d4c78..4167f96 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -19,7 +19,7 @@
 
 #include "mu_scm.h"
 
-long message_tag;
+static scm_t_bits message_tag;
 
 struct mu_message
 {
@@ -147,13 +147,13 @@ mu_scm_message_add_owner (SCM MESG, SCM owner)
   struct mu_message *mum = (struct mu_message *) SCM_CDR (MESG);
   SCM cell;
 
-  if (SCM_IMP (mum->mbox) && SCM_BOOLP (mum->mbox))
+  if (scm_is_bool (mum->mbox))
     {
       mum->mbox = owner;
       return;
     }
   
-  if (SCM_NIMP (mum->mbox) && SCM_CONSP (mum->mbox))
+  if (scm_is_pair (mum->mbox))
     cell = scm_cons (owner, mum->mbox);
   else
     cell = scm_cons (owner, scm_cons (mum->mbox, SCM_EOL));
@@ -281,7 +281,7 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0,
   msg = mu_scm_message_get (MESG);
   SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME);
 
-  if (SCM_IMP (VALUE) && SCM_BOOLP (VALUE))
+  if (scm_is_bool (VALUE))
     return SCM_UNSPECIFIED;
   
   SCM_ASSERT (scm_is_string (VALUE), VALUE, SCM_ARG2, FUNC_NAME);
@@ -317,10 +317,11 @@ SCM_DEFINE (scm_mu_message_get_size, "mu-message-get-size", 1, 0, 0,
 {
   mu_message_t msg;
   size_t size;
+  
   SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
   msg = mu_scm_message_get (MESG);
   mu_message_size (msg, &size);
-  return mu_scm_makenum (size);
+  return scm_from_size_t (size);
 }
 #undef FUNC_NAME
 
@@ -341,7 +342,7 @@ SCM_DEFINE (scm_mu_message_get_lines, "mu-message-get-lines", 1, 0, 0,
 		  "Cannot get number of lines in message ~A",
 		  scm_list_1 (MESG));
 
-  return mu_scm_makenum (lines);
+  return scm_from_size_t (lines);
 }
 #undef FUNC_NAME
 
@@ -426,7 +427,7 @@ SCM_DEFINE (scm_mu_message_get_envelope_date, "mu-message-get-envelope-date", 1,
   status = mu_parse_ctime_date_time (&sdate, &tm, &tz);
   if (status)
     mu_scm_error (FUNC_NAME, status, "invalid envelope date",
-		  scm_list_1 (scm_makfrom0str (sdate)));
+		  scm_list_1 (scm_from_locale_string (sdate)));
   return filltime (&tm, tz.utc_offset, tz.tz_name);  
 }
 #undef FUNC_NAME
@@ -447,7 +448,7 @@ SCM_DEFINE (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
   if (status == 0)
     {
       char *p = _get_envelope_sender (env);
-      ret = scm_makfrom0str (p);
+      ret = scm_from_locale_string (p);
       free (p);
     }
   else
@@ -484,7 +485,7 @@ SCM_DEFINE (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0,
   switch (status)
     {
     case 0:
-      ret = scm_makfrom0str (value);
+      ret = scm_from_locale_string (value);
       free (value);
       break;
       
@@ -533,8 +534,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1,
   msg = mu_scm_message_get (MESG);
   if (!SCM_UNBNDP (HEADERS))
     {
-      SCM_ASSERT (SCM_NIMP (HEADERS) && SCM_CONSP (HEADERS),
-		  HEADERS, SCM_ARG2, FUNC_NAME);
+      SCM_ASSERT (scm_is_pair (HEADERS), HEADERS, SCM_ARG2, FUNC_NAME);
       headers = HEADERS;
     }
 
@@ -558,7 +558,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1,
 		      "Cannot get header field ~A, message ~A",
 		      scm_list_2 (scm_from_size_t (i), MESG));
       
-      if (headers != SCM_EOL && string_sloppy_member (headers, name) == 0)
+      if (!scm_is_null (headers) && string_sloppy_member (headers, name) == 0)
 	continue;
       status = mu_header_aget_field_value (hdr, i, &value);
       if (status)
@@ -566,12 +566,12 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1,
 		      "Cannot get header value ~A, message ~A",
 		      scm_list_2 (scm_from_size_t (i), MESG));
 
-      scm_name = scm_makfrom0str (name);
-      scm_value = scm_makfrom0str (value);
+      scm_name = scm_from_locale_string (name);
+      scm_value = scm_from_locale_string (value);
 
       scm_new = scm_cons (scm_cons (scm_name, scm_value), SCM_EOL);
       
-      if (scm_first == SCM_EOL)
+      if (scm_is_null (scm_first))
 	scm_first = scm_last = scm_new;
       else
 	{
@@ -601,13 +601,11 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2,
   
   SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
   msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (((SCM_IMP (LIST) && SCM_EOL == LIST) ||
-	       (SCM_NIMP (LIST) && SCM_CONSP (LIST))),
+  SCM_ASSERT (scm_is_null (LIST) || scm_is_pair (LIST),
 	      LIST, SCM_ARG2, FUNC_NAME);
   if (!SCM_UNBNDP (REPLACE))
     {
-      SCM_ASSERT (SCM_IMP (REPLACE) && SCM_BOOLP (REPLACE),
-		  REPLACE, SCM_ARG3, FUNC_NAME);
+      SCM_ASSERT (scm_is_bool (REPLACE), REPLACE, SCM_ARG3, FUNC_NAME);
       replace = REPLACE == SCM_BOOL_T;
     }
 
@@ -616,14 +614,13 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2,
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message headers", SCM_BOOL_F);
 
-  for (list = LIST; list != SCM_EOL; list = SCM_CDR (list))
+  for (list = LIST; !scm_is_null (list); list = SCM_CDR (list))
     {
       SCM cell = SCM_CAR (list);
       SCM car, cdr;
       char *hdr_c, *val_c;
       
-      SCM_ASSERT (SCM_NIMP (cell) && SCM_CONSP (cell),
-		  cell, SCM_ARGn, FUNC_NAME);
+      SCM_ASSERT (scm_is_pair (cell), cell, SCM_ARGn, FUNC_NAME);
       car = SCM_CAR (cell);
       cdr = SCM_CDR (cell);
       SCM_ASSERT (scm_is_string (car), car, SCM_ARGn, FUNC_NAME);
@@ -659,8 +656,7 @@ SCM_DEFINE (scm_mu_message_delete, "mu-message-delete", 1, 1, 0,
   msg = mu_scm_message_get (MESG);
   if (!SCM_UNBNDP (FLAG))
     {
-      SCM_ASSERT (SCM_IMP (FLAG) && SCM_BOOLP (FLAG),
-		  FLAG, SCM_ARG2, FUNC_NAME);
+      SCM_ASSERT (scm_is_bool (FLAG), FLAG, SCM_ARG2, FUNC_NAME);
       delete = FLAG == SCM_BOOL_T;
     }
   status = mu_message_get_attribute (msg, &attr);
@@ -759,8 +755,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0,
 
   if (!SCM_UNBNDP (VALUE))
     {
-      SCM_ASSERT (SCM_IMP (VALUE) && SCM_BOOLP (VALUE),
-		  VALUE, SCM_ARG3, FUNC_NAME);
+      SCM_ASSERT (scm_is_bool (VALUE), VALUE, SCM_ARG3, FUNC_NAME);
       value = VALUE == SCM_BOOL_T;
     }
   
@@ -880,8 +875,7 @@ SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0,
 
   if (!SCM_UNBNDP (VALUE))
     {
-      SCM_ASSERT (SCM_IMP (VALUE) && SCM_BOOLP (VALUE),
-		  VALUE, SCM_ARG3, FUNC_NAME);
+      SCM_ASSERT (scm_is_bool (VALUE), VALUE, SCM_ARG3, FUNC_NAME);
       set = VALUE == SCM_BOOL_T;
     }
   
@@ -922,8 +916,7 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
 
   if (!SCM_UNBNDP (FULL))
     {
-      SCM_ASSERT (SCM_IMP (FULL) && SCM_BOOLP (FULL),
-		  FULL, SCM_ARG3, FUNC_NAME);
+      SCM_ASSERT (scm_is_bool (FULL), FULL, SCM_ARG3, FUNC_NAME);
       if (FULL == SCM_BOOL_T)
 	{
 	  status = mu_message_get_stream (msg, &stream);
@@ -1010,7 +1003,7 @@ SCM_DEFINE (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1, 0, 0,
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get number of parts in the message ~A",
 		  scm_list_1 (MESG));
-  return mu_scm_makenum (nparts);
+  return scm_from_size_t (nparts);
 }
 #undef FUNC_NAME
 
diff --git a/libmu_scm/mu_mime.c b/libmu_scm/mu_mime.c
index de889ed..ca9f799 100644
--- a/libmu_scm/mu_mime.c
+++ b/libmu_scm/mu_mime.c
@@ -19,7 +19,7 @@
 
 #include "mu_scm.h"
 
-long mime_tag;
+static scm_t_bits mime_tag;
 
 struct mu_mime
 {
@@ -101,7 +101,7 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0,
   int flags;
   int status;
   
-  if (SCM_IMP (FLAGS) && SCM_BOOLP (FLAGS))
+  if (scm_is_bool (FLAGS))
     {
       /*if (FLAGS == SCM_BOOL_F)*/
       flags = 0;
@@ -152,7 +152,7 @@ SCM_DEFINE (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0,
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot count MIME parts", SCM_BOOL_F);
-  return mu_scm_makenum (nparts);
+  return scm_from_size_t (nparts);
 }
 #undef FUNC_NAME
 
diff --git a/libmu_scm/mu_scm.c b/libmu_scm/mu_scm.c
index 3b02a86..9df9551 100644
--- a/libmu_scm/mu_scm.c
+++ b/libmu_scm/mu_scm.c
@@ -29,36 +29,11 @@ mu_scm_error (const char *func_name, int status,
 {
   scm_error_scm (scm_from_locale_symbol ("mailutils-error"),
 		 func_name ? scm_from_locale_string (func_name) : SCM_BOOL_F,
-		 scm_makfrom0str (fmt),
+		 scm_from_locale_string (fmt),
 		 args,
 		 scm_list_1 (scm_from_int (status)));
 }
 
-SCM
-mu_scm_makenum (unsigned long val)
-#ifndef HAVE_SCM_LONG2NUM
-{
-  if (SCM_FIXABLE ((long) val))
-    return scm_from_int (val);
-
-#ifdef SCM_BIGDIG
-  return scm_long2big (val);
-#else /* SCM_BIGDIG */
-  return scm_make_real ((double) val);
-#endif /* SCM_BIGDIG */
-}
-#else
-{
-  return scm_long2num (val);
-}
-#endif
-
-void
-mu_set_variable (const char *name, SCM value)
-{
-  scm_c_define (name, value);
-}
-
 SCM _mu_scm_package_string; /* STRING: PACKAGE_STRING */
 SCM _mu_scm_package;        /* STRING: PACKAGE */
 SCM _mu_scm_version;        /* STRING: VERSION */
@@ -133,7 +108,7 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1,
 {
   int status;
 
-  if (REST == SCM_EOL)
+  if (scm_is_null (REST))
     {
       status = register_format (NULL);
       if (status)
@@ -143,7 +118,7 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1,
     }
   else
     {
-      for (; REST != SCM_EOL; REST = SCM_CDR (REST))
+      for (; !scm_is_null (REST); REST = SCM_CDR (REST))
 	{
 	  char *s;
 	  SCM scm = SCM_CAR (REST);
@@ -168,7 +143,7 @@ SCM_DEFINE (scm_mu_strerror, "mu-strerror", 1, 0, 0,
 #define FUNC_NAME s_scm_mu_strerror
 {
   SCM_ASSERT (scm_is_integer (ERR), ERR, SCM_ARG1, FUNC_NAME);
-  return scm_makfrom0str (mu_strerror (scm_to_int (ERR)));
+  return scm_from_locale_string (mu_strerror (scm_to_int (ERR)));
 }
 #undef FUNC_NAME
 
@@ -194,20 +169,20 @@ mu_scm_init ()
 {
   int i;
 
-  _mu_scm_mailer = scm_makfrom0str ("sendmail:" PATH_SENDMAIL);
-  mu_set_variable ("mu-mailer", _mu_scm_mailer);
+  _mu_scm_mailer = scm_from_locale_string ("sendmail:" PATH_SENDMAIL);
+  scm_c_define ("mu-mailer", _mu_scm_mailer);
 
-  _mu_scm_debug = mu_scm_makenum(0);
-  mu_set_variable ("mu-debug", _mu_scm_debug);
+  _mu_scm_debug = scm_from_int (0);
+  scm_c_define ("mu-debug", _mu_scm_debug);
 
-  _mu_scm_package = scm_makfrom0str (PACKAGE);
-  mu_set_variable ("mu-package", _mu_scm_package);
+  _mu_scm_package = scm_from_locale_string (PACKAGE);
+  scm_c_define ("mu-package", _mu_scm_package);
 
-  _mu_scm_version = scm_makfrom0str (VERSION);
-  mu_set_variable ("mu-version", _mu_scm_version);
+  _mu_scm_version = scm_from_locale_string (VERSION);
+  scm_c_define ("mu-version", _mu_scm_version);
 
-  _mu_scm_package_string = scm_makfrom0str (PACKAGE_STRING);
-  mu_set_variable ("mu-package-string", _mu_scm_package_string);
+  _mu_scm_package_string = scm_from_locale_string (PACKAGE_STRING);
+  scm_c_define ("mu-package-string", _mu_scm_package_string);
 
   /* Create MU- attribute names */
   for (i = 0; attr_kw[i].name; i++)
diff --git a/libmu_scm/mu_util.c b/libmu_scm/mu_util.c
index 2668a76..22fedc5 100644
--- a/libmu_scm/mu_util.c
+++ b/libmu_scm/mu_util.c
@@ -56,20 +56,14 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0,
     mu_scm_error (FUNC_NAME, errno,
 		  "Cannot get user credentials", SCM_BOOL_F);
 
-  ve[0] = scm_makfrom0str (entry->name);
-  ve[1] = scm_makfrom0str (entry->passwd);
-  ve[2] = scm_ulong2num ((unsigned long) entry->uid);
-  ve[3] = scm_ulong2num ((unsigned long) entry->gid);
-  ve[4] = scm_makfrom0str (entry->gecos);
-  if (!entry->dir)
-    ve[5] = scm_makfrom0str ("");
-  else
-    ve[5] = scm_makfrom0str (entry->dir);
-  if (!entry->shell)
-    ve[6] = scm_makfrom0str ("");
-  else
-    ve[6] = scm_makfrom0str (entry->shell);
-  ve[7] = scm_makfrom0str (entry->mailbox);
+  ve[0] = scm_from_locale_string (entry->name);
+  ve[1] = scm_from_locale_string (entry->passwd);
+  ve[2] = scm_from_ulong ((unsigned long) entry->uid);
+  ve[3] = scm_from_ulong ((unsigned long) entry->gid);
+  ve[4] = scm_from_locale_string (entry->gecos);
+  ve[5] = scm_from_locale_string (entry->dir ? entry->dir : "");
+  ve[6] = scm_from_locale_string (entry->shell ? entry->shell : "");
+  ve[7] = scm_from_locale_string (entry->mailbox);
 
   scm_array_handle_release (&handle);
   
diff --git a/mailbox/cfg_lexer.l b/mailbox/cfg_lexer.l
index 47faca2..f530ca2 100644
--- a/mailbox/cfg_lexer.l
+++ b/mailbox/cfg_lexer.l
@@ -37,7 +37,8 @@
 #include <mailutils/nls.h>
 #include <mailutils/cfg.h>
 #include <mailutils/list.h>
-
+#include <mailutils/mutil.h>
+  
 #include "cfg_parser.h"
 
 void _mu_line_begin (void);


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 01 09:39:22 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NxKcD-0007Pk-WD
	for mharc-commit-mailutils@gnu.org; Thu, 01 Apr 2010 09:39:22 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NxKcC-0007Pe-60
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 09:39:20 -0400
Received: from [140.186.70.92] (port=53048 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NxKc9-0007PW-T6
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 09:39:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxKc8-0000Vv-MC
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 09:39:17 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:34021
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxKc8-0000Vq-KN
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 09:39:16 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxKc8-000787-7h
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 13:39:16 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxKc7-00024T-Eq
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 13:39:16 +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: 43a43a758881ae1294b73696175bc066e9257aa2
X-Git-Newrev: 42f9e9d0e3c73059048934e385074d78a023e6e4
Message-Id: <E1NxKc7-00024T-Eq@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 01 Apr 2010 13:39:15 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-54-g42f9e9d
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: Thu, 01 Apr 2010 13:39:20 -0000

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

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=42f9e9d0e3c73059048934e385074d78a023e6e4

The branch, master has been updated
       via  42f9e9d0e3c73059048934e385074d78a023e6e4 (commit)
      from  43a43a758881ae1294b73696175bc066e9257aa2 (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 42f9e9d0e3c73059048934e385074d78a023e6e4
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 16:37:28 2010 +0300

    Fix the use of deprecated Guile interfaces in port code.
    
    * am/guile.m4 (MU_CHECK_GUILE): Check for SCM_DEVAL_P et al.
    * libmu_scm/mu_guile.c (mu_guile_init): Protect calls to
    SCM_DEVAL_P &c. by #ifdef GUILE_DEBUG_MACROS
    * libmu_scm/mu_port.c [!HAVE_SCM_T_OFF](scm_t_off): New typedef.
    (mu_port_make_from_stream): Use scm_new_port_table_entry instead
    of the deprecated scm_add_to_port_table

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

Summary of changes:
 am/guile.m4          |   11 +++++++++++
 libmu_scm/mu_guile.c |    2 ++
 libmu_scm/mu_port.c  |   15 ++++++++-------
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/am/guile.m4 b/am/guile.m4
index f049037..64b5cac 100644
--- a/am/guile.m4
+++ b/am/guile.m4
@@ -63,6 +63,17 @@ AC_DEFUN([MU_CHECK_GUILE],
     GUILE_VERSION_NUMBER=
     m4_if($3,,[AC_MSG_ERROR(required library libguile not found)], [$3])
   else
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libguile.h>]],
+                      [SCM_DEVAL_P = 1;
+                       SCM_BACKTRACE_P = 1;
+                       SCM_RECORD_POSITIONS_P = 1;
+                       SCM_RESET_DEBUG_MODE;])],
+                      [mu_cv_guile_debug=yes],
+                      [mu_cv_guile_debug=no])
+    if test $mu_cv_guile_debug = yes; then
+      AC_DEFINE_UNQUOTED(GUILE_DEBUG_MACROS, 1,
+                         [Define to 1 if SCM_DEVAL_P, SCM_BACKTRACE_P, SCM_RECORD_POSITIONS_P and SCM_RESET_DEBUG_MODE are defined])
+    fi
     AC_CHECK_TYPES([scm_t_off],[],[],[#include <libguile.h>])
     AC_DEFINE_UNQUOTED(GUILE_VERSION, "$GUILE_VERSION",
                        [Guile version number])
diff --git a/libmu_scm/mu_guile.c b/libmu_scm/mu_guile.c
index b5cd261..26dc2a7 100644
--- a/libmu_scm/mu_guile.c
+++ b/libmu_scm/mu_guile.c
@@ -109,10 +109,12 @@ mu_guile_init (int debug)
 
   if (debug)
     {
+#ifdef GUILE_DEBUG_MACROS
       SCM_DEVAL_P = 1;
       SCM_BACKTRACE_P = 1;
       SCM_RECORD_POSITIONS_P = 1;
       SCM_RESET_DEBUG_MODE;
+#endif
     }
   mu_scm_init ();
 }
diff --git a/libmu_scm/mu_port.c b/libmu_scm/mu_port.c
index 8b2906c..6f3e452 100644
--- a/libmu_scm/mu_port.c
+++ b/libmu_scm/mu_port.c
@@ -20,6 +20,10 @@
 #include "mu_scm.h"
 #include <mailutils/io.h>
 
+#ifndef HAVE_SCM_T_OFF
+typedef off_t scm_t_off;
+#endif
+
 struct mu_port
 {
   mu_stream_t stream;         /* Associated stream */
@@ -87,16 +91,13 @@ mu_port_make_from_stream (SCM msg, mu_stream_t stream, long mode)
   mp->stream = stream;
   mp->offset = 0;
 
-  port = scm_cell (scm_tc16_smuport | mode, 0);
-
-  pt = scm_add_to_port_table (port);
-  SCM_SETPTAB_ENTRY (port, pt);
+  port = scm_new_port_table_entry (scm_tc16_smuport | mode);
+  pt = SCM_PTAB_ENTRY (port);
   pt->rw_random = mu_stream_is_seekable (stream);
-
   SCM_SETSTREAM (port, mp);
   mu_port_alloc_buffer (port, 0, 0);
-
-  /*  SCM_PTAB_ENTRY (port)->file_name = "name";FIXME*/
+  /* FIXME:
+     SCM_PTAB_ENTRY (port)->file_name = "name";*/
   return port;
 }
 


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 01 12:49:32 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NxNaG-0007Bs-Ml
	for mharc-commit-mailutils@gnu.org; Thu, 01 Apr 2010 12:49:32 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NxNaF-0007Be-Fi
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 12:49:31 -0400
Received: from [140.186.70.92] (port=43157 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NxNaD-0007Ax-4o
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 12:49:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxNaA-00053m-E5
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 12:49:29 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:48272
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxNaA-00053g-BE
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 12:49:26 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxNa9-0000xb-Q5
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 16:49:25 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxNa9-0007ka-ES
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 16:49:25 +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: 42f9e9d0e3c73059048934e385074d78a023e6e4
X-Git-Newrev: 832dad5395744b45ed705d8b9bab6432cdbf7d0e
Message-Id: <E1NxNa9-0007ka-ES@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 01 Apr 2010 16:49:25 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-56-g832dad5
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: Thu, 01 Apr 2010 16:49:32 -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=832dad5395744b45ed705d8b9bab6432cdbf7d0e

The branch, master has been updated
       via  832dad5395744b45ed705d8b9bab6432cdbf7d0e (commit)
       via  85bc741c0fb1adace8527a7da8c91efa6432a4c6 (commit)
      from  42f9e9d0e3c73059048934e385074d78a023e6e4 (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 832dad5395744b45ed705d8b9bab6432cdbf7d0e
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 19:49:20 2010 +0300

    Bugfix.
    
    * mailbox/attachment.c (_ISSPECIAL): Fix definition.

commit 85bc741c0fb1adace8527a7da8c91efa6432a4c6
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 19:32:09 2010 +0300

    Style fix.
    
    * mailbox/attachment.c: Fix indentation.

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

Summary of changes:
 mailbox/attachment.c |  137 ++++++++++++++++++++++++++------------------------
 1 files changed, 71 insertions(+), 66 deletions(-)

diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 34332d4..55e546f 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -66,7 +66,7 @@ struct _msg_info
 
 int
 mu_message_create_attachment (const char *content_type, const char *encoding,
-			      const char *filename, mu_message_t * newmsg)
+			      const char *filename, mu_message_t *newmsg)
 {
   mu_header_t hdr;
   mu_body_t body;
@@ -75,7 +75,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
   int ret;
 
   if (newmsg == NULL)
-    return MU_ERR_OUT_PTR_NULL;	
+    return MU_ERR_OUT_PTR_NULL;
   if (filename == NULL)
     return EINVAL;
 
@@ -101,19 +101,19 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
 	      sprintf (header, MSG_HDR, content_type, name, encoding, name);
 	      if ((ret =
 		   mu_header_create (&hdr, header, strlen (header),
-				  *newmsg)) == 0)
+				     *newmsg)) == 0)
 		{
 		  mu_message_get_body (*newmsg, &body);
 		  if ((ret =
 		       mu_file_stream_create (&fstream, filename,
-					   MU_STREAM_READ)) == 0)
+					      MU_STREAM_READ)) == 0)
 		    {
 		      if ((ret = mu_stream_open (fstream)) == 0)
 			{
 			  if ((ret =
 			       mu_filter_create (&tstream, fstream, encoding,
-					      MU_FILTER_ENCODE,
-					      MU_STREAM_READ)) == 0)
+						 MU_FILTER_ENCODE,
+						 MU_STREAM_READ)) == 0)
 			    {
 			      mu_body_set_stream (body, tstream, *newmsg);
 			      mu_message_set_header (*newmsg, hdr, NULL);
@@ -121,7 +121,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
 			}
 		    }
 		}
-              free (header);
+	      free (header);
 	    }
 	}
     }
@@ -142,7 +142,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
 
 static int
 _attachment_setup (struct _msg_info **info, mu_message_t msg,
-		   mu_stream_t * stream, void **data)
+		   mu_stream_t *stream, void **data)
 {
   int sfl, ret;
   mu_body_t body;
@@ -185,14 +185,11 @@ _attachment_free (struct _msg_info *info, int free_message)
   free (info);
 }
 
-#define _ISSPECIAL(c) ( \
-    ((c) == '(') || ((c) == ')') || ((c) == '<') || ((c) == '>') \
-    || ((c) == '@') || ((c) == ',') || ((c) == ';') || ((c) == ':') \
-    || ((c) == '\\') || ((c) == '.') || ((c) == '[') \
-    || ((c) == ']') )
+/* See RFC 2045, 5.1.  Syntax of the Content-Type Header Field */
+#define _ISSPECIAL(c) !!strchr ("()<>@,;:\\\"/[]?=", c)
 
 static char *
-_header_get_param (char *field_body, const char *param, size_t * len)
+_header_get_param (char *field_body, const char *param, size_t *len)
 {
   char *str, *p, *v, *e;
   int quoted = 0, was_quoted = 0;
@@ -230,7 +227,7 @@ _header_get_param (char *field_body, const char *param, size_t * len)
 }
 
 int
-mu_message_aget_attachment_name(mu_message_t msg, char **name)
+mu_message_aget_attachment_name (mu_message_t msg, char **name)
 {
   size_t sz = 0;
   int ret = 0;
@@ -238,16 +235,18 @@ mu_message_aget_attachment_name(mu_message_t msg, char **name)
   if (name == NULL)
     return MU_ERR_OUT_PTR_NULL;
 
-  if((ret = mu_message_get_attachment_name(msg, NULL, 0, &sz)) != 0)
+  if ((ret = mu_message_get_attachment_name (msg, NULL, 0, &sz)) != 0)
     return ret;
 
-  *name = malloc(sz + 1);
-
-  if((ret = mu_message_get_attachment_name(msg, *name, sz + 1, NULL)) != 0)
-  {
-    free(*name);
-    *name = NULL;
-  }
+  *name = malloc (sz + 1);
+  if (!*name)
+    return ENOMEM;
+  
+  if ((ret = mu_message_get_attachment_name (msg, *name, sz + 1, NULL)) != 0)
+    {
+      free (*name);
+      *name = NULL;
+    }
 
   return ret;
 }
@@ -262,7 +261,7 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
   char *name = NULL;
   size_t namesz = 0;
 
-  if(!msg)
+  if (!msg)
     return ret;
 
   if ((ret = mu_message_get_header (msg, &hdr)) != 0)
@@ -272,25 +271,25 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
 
   /* If the header wasn't there, we'll fall back to Content-Type, but
      other errors are fatal. */
-  if(ret != 0 && ret != MU_ERR_NOENT)
+  if (ret != 0 && ret != MU_ERR_NOENT)
     return ret;
 
-  if(ret == 0 && value != NULL)
-  {
-    /* FIXME: this is cheezy, it should check the value of the
-       Content-Disposition field, not strstr it. */
+  if (ret == 0 && value != NULL)
+    {
+      /* FIXME: this is cheezy, it should check the value of the
+         Content-Disposition field, not strstr it. */
 
       if (strstr (value, "attachment") != NULL)
 	name = _header_get_param (value, "filename", &namesz);
-  }
+    }
 
   /* If we didn't get the name, we fall back on the Content-Type name
      parameter. */
 
   if (name == NULL)
     {
-      if(value)
-	free(value);
+      if (value)
+	free (value);
 
       ret = mu_header_aget_value (hdr, "Content-Type", &value);
       name = _header_get_param (value, "name", &namesz);
@@ -302,11 +301,11 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
 
       name[namesz] = '\0';
 
-      if(sz)
+      if (sz)
 	*sz = namesz;
 
-      if(buf)
-	strncpy(buf, name, bufsz);
+      if (buf)
+	strncpy (buf, name, bufsz);
     }
   else
     ret = MU_ERR_NOENT;
@@ -336,40 +335,40 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
   if (ret == 0 && (ret = mu_message_get_header (msg, &hdr)) == 0)
     {
       if (filename == NULL)
-      {
-	ret = mu_message_aget_attachment_name (msg, &partname);
-	if(partname)
-	  fname = partname;
-      }
+	{
+	  ret = mu_message_aget_attachment_name (msg, &partname);
+	  if (partname)
+	    fname = partname;
+	}
       else
 	fname = filename;
       if (fname
 	  && (ret =
 	      mu_file_stream_create (&info->fstream, fname,
-				  MU_STREAM_WRITE | MU_STREAM_CREAT)) == 0)
+				     MU_STREAM_WRITE | MU_STREAM_CREAT)) == 0)
 	{
 	  if ((ret = mu_stream_open (info->fstream)) == 0)
 	    {
-              char *content_encoding;
+	      char *content_encoding;
 	      char *content_encoding_mem = NULL;
 
 	      mu_header_get_value (hdr, "Content-Transfer-Encoding", NULL, 0,
-				&size);
+				   &size);
 	      if (size)
 		{
 		  content_encoding_mem = malloc (size + 1);
 		  if (content_encoding_mem == NULL)
 		    ret = ENOMEM;
-                  content_encoding = content_encoding_mem;
+		  content_encoding = content_encoding_mem;
 		  mu_header_get_value (hdr, "Content-Transfer-Encoding",
-				    content_encoding, size + 1, 0);
+				       content_encoding, size + 1, 0);
 		}
 	      else
 		content_encoding = "7bit";
 	      ret =
 		mu_filter_create (&info->stream, istream, content_encoding,
-			       MU_FILTER_DECODE, MU_STREAM_READ);
-              free (content_encoding_mem);
+				  MU_FILTER_DECODE, MU_STREAM_READ);
+	      free (content_encoding_mem);
 	    }
 	}
     }
@@ -381,15 +380,16 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
       while ((ret == 0 && info->nbytes)
 	     ||
 	     ((ret =
-	       mu_stream_read (info->stream, info->buf, BUF_SIZE, info->ioffset,
-			    &info->nbytes)) == 0 && info->nbytes))
+	       mu_stream_read (info->stream, info->buf, BUF_SIZE,
+			       info->ioffset, &info->nbytes)) == 0
+	      && info->nbytes))
 	{
 	  info->ioffset += info->nbytes;
 	  while (info->nbytes)
 	    {
 	      if ((ret =
 		   mu_stream_write (info->fstream, info->buf, info->nbytes,
-				 info->ooffset, &nbytes)) != 0)
+				    info->ooffset, &nbytes)) != 0)
 		break;
 	      info->nbytes -= nbytes;
 	      info->ooffset += nbytes;
@@ -412,7 +412,7 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
 }
 
 int
-mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
+mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg, void **data)
 {
   mu_stream_t istream, ostream;
   const char *header;
@@ -429,12 +429,14 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
   if ((ret = _attachment_setup (&info, msg, &ostream, data)) != 0)
     return ret;
 
-  if (info->msg == NULL && (ret = mu_message_create (&(info->msg), NULL)) == 0)
+  if (info->msg == NULL
+      && (ret = mu_message_create (&(info->msg), NULL)) == 0)
     {
       header =
 	"Content-Type: message/rfc822\nContent-Transfer-Encoding: 7bit\n\n";
       if ((ret =
-	   mu_header_create (&(info->hdr), header, strlen (header), msg)) == 0)
+	   mu_header_create (&(info->hdr), header, strlen (header),
+			     msg)) == 0)
 	ret = mu_message_set_header (info->msg, info->hdr, NULL);
     }
   if (ret == 0 && (ret = mu_message_get_stream (msg, &istream)) == 0)
@@ -448,15 +450,16 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
 	  while ((ret == 0 && info->nbytes)
 		 ||
 		 ((ret =
-		   mu_stream_read (istream, info->buf, BUF_SIZE, info->ioffset,
-				&info->nbytes)) == 0 && info->nbytes))
+		   mu_stream_read (istream, info->buf, BUF_SIZE,
+				   info->ioffset, &info->nbytes)) == 0
+		  && info->nbytes))
 	    {
 	      info->ioffset += info->nbytes;
 	      while (info->nbytes)
 		{
 		  if ((ret =
 		       mu_stream_write (ostream, info->buf, info->nbytes,
-				     info->ooffset, &nbytes)) != 0)
+					info->ooffset, &nbytes)) != 0)
 		    break;
 		  info->nbytes -= nbytes;
 		  info->ooffset += nbytes;
@@ -472,7 +475,8 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
 }
 
 int
-mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
+mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
+			  void **data)
 {
   size_t size, nbytes;
   int ret = 0;
@@ -491,14 +495,16 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
       mu_header_get_value (hdr, "Content-Type", NULL, 0, &size);
       if (size)
 	{
-          char *content_type;
+	  char *content_type;
 	  if ((content_type = malloc (size + 1)) == NULL)
 	    return ENOMEM;
-	  mu_header_get_value (hdr, "Content-Type", content_type, size + 1, 0);
-	  ret = mu_c_strncasecmp (content_type, "message/rfc822",
-	                          strlen ("message/rfc822"));
-          free (content_type);
-          if (ret != 0)
+	  mu_header_get_value (hdr, "Content-Type", content_type, size + 1,
+			       0);
+	  ret =
+	    mu_c_strncasecmp (content_type, "message/rfc822",
+			      strlen ("message/rfc822"));
+	  free (content_type);
+	  if (ret != 0)
 	    return EINVAL;
 	}
       else
@@ -518,14 +524,14 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
 	     ||
 	     ((ret =
 	       mu_stream_read (istream, info->buf, BUF_SIZE, info->ioffset,
-			    &info->nbytes)) == 0 && info->nbytes))
+			       &info->nbytes)) == 0 && info->nbytes))
 	{
 	  info->ioffset += info->nbytes;
 	  while (info->nbytes)
 	    {
 	      if ((ret =
 		   mu_stream_write (ostream, info->buf, info->nbytes,
-				 info->ooffset, &nbytes)) != 0)
+				    info->ooffset, &nbytes)) != 0)
 		break;
 	      info->nbytes -= nbytes;
 	      info->ooffset += nbytes;
@@ -538,4 +544,3 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
     _attachment_free (info, ret);
   return ret;
 }
-


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 01 16:14:51 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NxQmx-0007vp-4H
	for mharc-commit-mailutils@gnu.org; Thu, 01 Apr 2010 16:14:51 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NxQmu-0007vA-VO
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 16:14:49 -0400
Received: from [140.186.70.92] (port=41969 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NxQmt-0007ut-4X
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 16:14:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxQmq-0003fM-KT
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 16:14:47 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:42776
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxQmq-0003fA-6f
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 16:14:44 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxQmp-0003SJ-Hr
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 20:14:43 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxQmm-0006Ud-9W
	for commit-mailutils@gnu.org; Thu, 01 Apr 2010 20:14:43 +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: 832dad5395744b45ed705d8b9bab6432cdbf7d0e
X-Git-Newrev: 52fffebc9d359125c21130d93a67b225b4778457
Message-Id: <E1NxQmm-0006Ud-9W@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 01 Apr 2010 20:14:41 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-58-g52fffeb
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: Thu, 01 Apr 2010 20:14:49 -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=52fffebc9d359125c21130d93a67b225b4778457

The branch, master has been updated
       via  52fffebc9d359125c21130d93a67b225b4778457 (commit)
       via  c73e770c70d3e358e65759130d7fdff047750a69 (commit)
      from  832dad5395744b45ed705d8b9bab6432cdbf7d0e (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 52fffebc9d359125c21130d93a67b225b4778457
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 23:12:33 2010 +0300

    Implement mailbox iterators in Scheme.
    
    * libmu_scm/mu_mailbox.c (struct mu_mailbox)<itr>: New member.
    (mu_scm_mailbox_free): Destroy the iterator.
    (mu_scm_mailbox_create0): Initialize itr to NULL.
    (mu-mailbox-first-message, mu-mailbox-next-message)
    (mu-mailbox-more-messages?): New function.
    * guimb/scm/sieve-core.scm (sieve-run): Rewrite
    main loop in the True Schemish Way.

commit c73e770c70d3e358e65759130d7fdff047750a69
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 1 21:39:24 2010 +0300

    Implement mailbox iterators.
    
    * include/mailutils/mailbox.h (mu_mailbox_get_iterator): New function.
    * libproto/include/mailbox0.h (struct _mu_mailbox)<iterator>: New
    member.
    * mailbox/mbxitr.c: New file.
    * mailbox/Makefile.am (libmailutils_la_SOURCES): Add mbxitr.c

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

Summary of changes:
 guimb/scm/sieve-core.scm    |   17 +++--
 include/mailutils/mailbox.h |    3 +
 libmu_scm/mu_mailbox.c      |  109 +++++++++++++++++++++++++++++
 libproto/include/mailbox0.h |    4 +-
 mailbox/Makefile.am         |    1 +
 mailbox/mbxitr.c            |  160 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 285 insertions(+), 9 deletions(-)
 create mode 100644 mailbox/mbxitr.c

diff --git a/guimb/scm/sieve-core.scm b/guimb/scm/sieve-core.scm
index 5a11c65..f5f335c 100644
--- a/guimb/scm/sieve-core.scm
+++ b/guimb/scm/sieve-core.scm
@@ -472,14 +472,15 @@
   (if (not sieve-my-email)
       (set! sieve-my-email (mu-username->email)))
 ;  (DEBUG 1 "Mailbox: " sieve-mailbox)
-  
-  (let ((count (mu-mailbox-messages-count sieve-mailbox)))
-    (do ((n 1 (1+ n)))
-	((> n count) #f)
-	(set! sieve-current-message
-	      (mu-mailbox-get-message sieve-mailbox n))
-	(sieve-run-current-message thunk))
-    (sieve-close-mailboxes)))
+
+  (let msg-loop ((msg (mu-mailbox-first-message sieve-mailbox)))
+    (if (not (eof-object? msg))
+	(begin
+	  (set! sieve-current-message msg)
+	  (sieve-run-current-message thunk)
+	  (msg-loop (mu-mailbox-next-message sieve-mailbox)))))
+
+  (sieve-close-mailboxes))
 
 (define (sieve-command-line)
   (catch #t
diff --git a/include/mailutils/mailbox.h b/include/mailutils/mailbox.h
index d554c9b..d3aa895 100644
--- a/include/mailutils/mailbox.h
+++ b/include/mailutils/mailbox.h
@@ -107,6 +107,9 @@ extern int  mu_mailbox_get_observable  (mu_mailbox_t, mu_observable_t *);
 /* Locking */  
 extern int mu_mailbox_lock (mu_mailbox_t mbox);
 extern int mu_mailbox_unlock (mu_mailbox_t mbox);
+
+extern int mu_mailbox_get_iterator (mu_mailbox_t mbx,
+				    mu_iterator_t *piterator);
   
 #ifdef __cplusplus
 }
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index 8a54fda..663755e 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -18,6 +18,7 @@
    Boston, MA 02110-1301 USA */
 
 #include "mu_scm.h"
+#include <mailutils/iterator.h>
 
 static scm_t_bits mailbox_tag;
 
@@ -26,6 +27,7 @@ static scm_t_bits mailbox_tag;
 struct mu_mailbox
 {
   mu_mailbox_t mbox;       /* Mailbox */
+  mu_iterator_t itr;
   int noclose;
 };
 
@@ -40,6 +42,9 @@ static scm_sizet
 mu_scm_mailbox_free (SCM mailbox_smob)
 {
   struct mu_mailbox *mum = (struct mu_mailbox *) SCM_CDR (mailbox_smob);
+
+  mu_iterator_destroy (&mum->itr);
+  
   if (!mum->noclose)
     {
       mu_mailbox_close (mum->mbox);
@@ -112,6 +117,7 @@ mu_scm_mailbox_create0 (mu_mailbox_t mbox, int noclose)
 
   mum = scm_gc_malloc (sizeof (struct mu_mailbox), "mailbox");
   mum->mbox = mbox;
+  mum->itr = NULL;
   mum->noclose = noclose;
   SCM_RETURN_NEWSMOB (mailbox_tag, mum);
 }
@@ -409,6 +415,109 @@ SCM_DEFINE (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0,
 }
 #undef FUNC_NAME
 
+/* Iterations */
+#define ITROP(op, descr)			\
+  do						\
+    {						\
+      int status = op;				\
+      if (status == MU_ERR_NOENT)		\
+	return SCM_EOF_VAL;			\
+      if (status)				\
+	mu_scm_error (FUNC_NAME, status,	\
+		      "~A: " descr ": ~A",	\
+		      scm_list_2 (MBOX,		\
+				  scm_from_locale_string (mu_strerror (status)))); \
+    }									\
+  while (0)
+
+SCM_DEFINE (scm_mu_mailbox_first_message, "mu-mailbox-first-message", 1, 0, 0,
+	    (SCM MBOX),
+	    "Returns first message from the mailbox.")
+#define FUNC_NAME s_scm_mu_mailbox_first_message
+{
+  struct mu_mailbox *mum;
+  int status;
+  mu_message_t msg;
+  
+  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  if (!mum->itr)
+    {
+      status = mu_mailbox_get_iterator (mum->mbox, &mum->itr);
+      if (status)
+	mu_scm_error (FUNC_NAME, status,
+		      "~A: cannot create iterator: ~A",
+		      scm_list_2 (MBOX,
+				  scm_from_locale_string (mu_strerror (status))));
+    }
+  ITROP (mu_iterator_first (mum->itr), "moving to the first message");
+  ITROP (mu_iterator_current (mum->itr, (void**)&msg),
+	 "getting current message");
+  return mu_scm_message_create (MBOX, msg);
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0, 0,
+	    (SCM MBOX),
+	    "Returns next message from the mailbox.")
+#define FUNC_NAME s_scm_mu_mailbox_next_message
+{
+  struct mu_mailbox *mum;
+  int status;
+  mu_message_t msg;
+  
+  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  if (!mum->itr)
+    {
+      status = mu_mailbox_get_iterator (mum->mbox, &mum->itr);
+      if (status)
+	mu_scm_error (FUNC_NAME, status,
+		      "~A: cannot create iterator: ~A",
+		      scm_list_2 (MBOX,
+				  scm_from_locale_string (mu_strerror (status))));
+      ITROP (mu_iterator_first (mum->itr), "moving to the first message");
+    }
+  else
+    ITROP (mu_iterator_next (mum->itr), "advancing iterator");
+  
+  ITROP (mu_iterator_current (mum->itr, (void**)&msg),
+	 "getting current message");
+  return mu_scm_message_create (MBOX, msg);
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?", 1, 0, 0,
+	    (SCM MBOX),
+	    "Returns next message from the mailbox.")
+#define FUNC_NAME s_scm_mu_mailbox_more_messages_p
+{
+  struct mu_mailbox *mum;
+  int status;
+  
+  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  if (!mum->itr)
+    {
+      status = mu_mailbox_get_iterator (mum->mbox, &mum->itr);
+      if (status)
+	mu_scm_error (FUNC_NAME, status,
+		      "~A: cannot create iterator: ~A",
+		      scm_list_2 (MBOX,
+				  scm_from_locale_string (mu_strerror (status))));
+      status = mu_iterator_first (mum->itr);
+      if (status == MU_ERR_NOENT)
+	return SCM_BOOL_F;
+      if (status)
+	mu_scm_error (FUNC_NAME, status,
+		      "~A: cannot set iterator to the first message: ~A",
+		      scm_list_2 (MBOX,
+				  scm_from_locale_string (mu_strerror (status))));
+    }
+  return scm_from_bool (!!mu_iterator_is_done (mum->itr));
+}
+#undef FUNC_NAME
+
 /* Initialize the module */
 void
 mu_scm_mailbox_init ()
diff --git a/libproto/include/mailbox0.h b/libproto/include/mailbox0.h
index bbe25f1..a052e43 100644
--- a/libproto/include/mailbox0.h
+++ b/libproto/include/mailbox0.h
@@ -29,6 +29,7 @@
 
 #include <mailutils/monitor.h>
 #include <mailutils/mailbox.h>
+#include <mailutils/iterator.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -46,7 +47,8 @@ struct _mu_mailbox
   int flags;
   mu_folder_t folder;
   mu_monitor_t monitor;
-
+  mu_iterator_t iterator;
+  
   /* Back pointer to the specific mailbox */
   void *data;
 
diff --git a/mailbox/Makefile.am b/mailbox/Makefile.am
index 845bc58..5146528 100644
--- a/mailbox/Makefile.am
+++ b/mailbox/Makefile.am
@@ -95,6 +95,7 @@ libmailutils_la_SOURCES = \
  mailer.c\
  mapfile_stream.c\
  mbx_default.c\
+ mbxitr.c\
  md5.c\
  message.c\
  memory_stream.c\
diff --git a/mailbox/mbxitr.c b/mailbox/mbxitr.c
new file mode 100644
index 0000000..6137e12
--- /dev/null
+++ b/mailbox/mbxitr.c
@@ -0,0 +1,160 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2010 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 <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include <mailutils/debug.h>
+#include <mailutils/errno.h>
+#include <mailutils/error.h>
+#include <mailutils/iterator.h>
+
+#include <mailbox0.h>
+
+struct mailbox_iterator
+{
+  mu_mailbox_t mbx;
+  size_t idx;
+};
+
+static int
+mbx_first (void *owner)
+{
+  struct mailbox_iterator *itr = owner;
+  itr->idx = 1;
+  return 0;
+}
+
+static int
+mbx_next (void *owner)
+{
+  struct mailbox_iterator *itr = owner;
+  itr->idx++;
+  return 0;
+}
+
+static int
+mbx_getitem (void *owner, void **pret, const void **pkey)
+{
+  struct mailbox_iterator *itr = owner;
+  size_t count;
+  int rc;
+  
+  rc = mu_mailbox_messages_count (itr->mbx, &count);
+  if (rc)
+    return rc;
+  if (itr->idx > count)
+    return MU_ERR_NOENT;
+  rc = mu_mailbox_get_message (itr->mbx, itr->idx, (mu_message_t*)pret);
+  if (rc == 0 && pkey)
+    *pkey = NULL; /* FIXME: Perhaps return UIDL or other unique id? */
+  return rc;
+}
+
+static int
+mbx_finished_p (void *owner)
+{
+  struct mailbox_iterator *itr = owner;
+  size_t count;
+
+  if (mu_mailbox_messages_count (itr->mbx, &count))
+    return 1;
+  return itr->idx > count;
+}
+
+static int
+mbx_destroy (mu_iterator_t iterator, void *data)
+{
+  struct mailbox_iterator *itr = data;
+
+  mu_iterator_detach (&itr->mbx->iterator, iterator);
+  free (data);
+  return 0;
+}
+
+static int
+mbx_curitem_p (void *owner, void *item)
+{
+  void *ptr;
+
+  if (mbx_getitem (owner, &ptr, NULL))
+    return 0;
+  return ptr == item;/* FIXME: Is it ok? */
+}
+
+static int
+mbx_data_dup (void **ptr, void *owner)
+{
+  struct mailbox_iterator *itr = owner;
+
+  *ptr = malloc (sizeof (struct mailbox_iterator));
+  if (*ptr == NULL)
+    return ENOMEM;
+  memcpy (*ptr, owner, sizeof (struct mailbox_iterator));
+  mu_iterator_attach (&itr->mbx->iterator, *ptr);
+  return 0;
+}
+
+int
+mu_mailbox_get_iterator (mu_mailbox_t mbx, mu_iterator_t *piterator)
+{
+  mu_iterator_t iterator;
+  int status;
+  struct mailbox_iterator *itr;
+
+  if (!mbx)
+    return EINVAL;
+
+  itr = calloc (1, sizeof *itr);
+  if (!itr)
+    return ENOMEM;
+  itr->mbx = mbx;
+  itr->idx = 1;
+
+  status = mu_iterator_create (&iterator, itr);
+  if (status)
+    {
+      free (itr);
+      return status;
+    }
+
+  mu_iterator_set_first (iterator, mbx_first);
+  mu_iterator_set_next (iterator, mbx_next);
+  mu_iterator_set_getitem (iterator, mbx_getitem);
+  mu_iterator_set_finished_p (iterator, mbx_finished_p);
+  mu_iterator_set_curitem_p (iterator, mbx_curitem_p);
+  mu_iterator_set_destroy (iterator, mbx_destroy);
+  mu_iterator_set_dup (iterator, mbx_data_dup);
+
+  mu_iterator_attach (&mbx->iterator, iterator);
+
+  *piterator = iterator;
+  return 0;
+}
+
+
+
+
+
+  
+


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Sat Apr 03 04:17:07 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NxyXT-0008SJ-2m
	for mharc-commit-mailutils@gnu.org; Sat, 03 Apr 2010 04:17:07 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NxyXR-0008Rw-Js
	for commit-mailutils@gnu.org; Sat, 03 Apr 2010 04:17:05 -0400
Received: from [140.186.70.92] (port=39667 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NxyXO-0008RU-PU
	for commit-mailutils@gnu.org; Sat, 03 Apr 2010 04:17:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxyXN-0002Q7-1V
	for commit-mailutils@gnu.org; Sat, 03 Apr 2010 04:17:02 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:52371
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxyXM-0002Py-Vo
	for commit-mailutils@gnu.org; Sat, 03 Apr 2010 04:17:01 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxyXM-0004Dp-NZ
	for commit-mailutils@gnu.org; Sat, 03 Apr 2010 08:17:00 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NxyXM-0004pQ-Cw
	for commit-mailutils@gnu.org; Sat, 03 Apr 2010 08:17:00 +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: 52fffebc9d359125c21130d93a67b225b4778457
X-Git-Newrev: d5ae81e503facb6b39cebd5dbf6697dfa429ef07
Message-Id: <E1NxyXM-0004pQ-Cw@vcs-noshell.in.savannah.gnu.org>
Date: Sat, 03 Apr 2010 08:17:00 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-59-gd5ae81e
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: Sat, 03 Apr 2010 08:17:05 -0000

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

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

The branch, master has been updated
       via  d5ae81e503facb6b39cebd5dbf6697dfa429ef07 (commit)
      from  52fffebc9d359125c21130d93a67b225b4778457 (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 d5ae81e503facb6b39cebd5dbf6697dfa429ef07
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Apr 3 11:17:53 2010 +0300

    Make mu_message_(a?)get_attachment_name RFC-compatible.
    
    * mailbox/attachment.c (_header_get_param): Rewrite.
    (_get_attachment_name): New auxiliary function.
    (mu_message_aget_attachment_name)
    (mu_message_get_attachment_name): Rewrite using _get_attachment_name.
    * mh/mhn.c (store_handler): Use mu_message_aget_attachment_name.

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

Summary of changes:
 mailbox/attachment.c |  317 ++++++++++++++++++++++++++++++++++++++------------
 mh/mhn.c             |   53 +--------
 2 files changed, 243 insertions(+), 127 deletions(-)

diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 55e546f..39165e6 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -188,78 +188,243 @@ _attachment_free (struct _msg_info *info, int free_message)
 /* See RFC 2045, 5.1.  Syntax of the Content-Type Header Field */
 #define _ISSPECIAL(c) !!strchr ("()<>@,;:\\\"/[]?=", c)
 
-static char *
-_header_get_param (char *field_body, const char *param, size_t *len)
+/* _header_get_param - an auxiliary function to extract values from
+   Content-Type, Content-Disposition and similar headers.
+
+   Arguments:
+   
+   FIELD_BODY    Header value, complying to RFCs 2045, 2183, 2231.3;
+   DISP          Disposition.  Unless it is NULL, the disposition part
+                 of FIELD_BODY is compared with it.  If they differ,
+		 the function returns MU_ERR_NOENT.
+   PARAM         Name of the parameter to extract from FIELD_BODY;
+   BUF           Where to extract the value to;
+   BUFSZ         Size of BUF;
+   PRET          Pointer to the memory location for the return buffer (see
+                 below).
+   PLEN          Pointer to the return size.
+
+   The function parses FIELD_BODY and extracts the value of the parameter
+   PARAM.
+
+   If BUF is not NULL and BUFSZ is not 0, the extracted value is stored into
+   BUF.  At most BUFSZ-1 bytes are copied.
+
+   Otherwise, if PRET is not NULL, the function allocates enough memory to
+   hold the extracted value, copies there the result, and stores the
+   pointer to the allocated memory into the location pointed to by PRET.
+
+   If PLEN is not NULL, the size of the extracted value (without terminating
+   NUL character) is stored there.
+
+   If BUF==NULL *and* PRET==NULL, no memory is allocated, but PLEN is
+   honored anyway, i.e. unless it is NULL it receives size of the result.
+   This can be used to estimate the needed buffer size.
+
+   Return values:
+     0             on success.
+     MU_ERR_NOENT, requested parameter not found, or disposition does
+                   not match DISP.
+     MU_ERR_PARSE, if FIELD_BODY does not comply to any of the abovemntioned
+                   RFCs.
+     ENOMEM      , if unable to allocate memory.
+*/
+   
+int
+_header_get_param (char *field_body,
+		   const char *disp,
+		   const char *param,
+		   char *buf, size_t bufsz,
+		   char **pret, size_t *plen)
 {
-  char *str, *p, *v, *e;
-  int quoted = 0, was_quoted = 0;
-
-  if (len == NULL || (str = field_body) == NULL)
-    return NULL;
+  int res = MU_ERR_NOENT;            /* Return value, pessimistic default */
+  size_t param_len = strlen (param);
+  char *p;
+  char *mem = NULL;                  /* Allocated memory storage */
+  size_t retlen = 0;                 /* Total number of bytes copied */
+  unsigned long cind = 0;            /* Expected continued parameter index.
+					See RFC 2231, Section 3,
+					"Parameter Value Continuations" */
+  
+  if (field_body == NULL)
+    return EINVAL;
 
-  p = strchr (str, ';');
-  while (p)
+  if (bufsz == 0) /* Make sure buf value is meaningful */
+    buf = NULL;
+  
+  p = strchr (field_body, ';');
+  if (!p)
+    return MU_ERR_NOENT;
+  if (disp && mu_c_strncasecmp (field_body, disp, p - field_body))
+    return MU_ERR_NOENT;
+      
+  while (p && *p)
     {
-      p++;
-      while (mu_isspace (*p))	/* walk upto start of param */
-	p++;
+      char *v, *e;
+      size_t len, escaped_chars = 0;
+
+      if (*p != ';')
+	{
+	  res = MU_ERR_PARSE;
+	  break;
+	}
+      
+      /* walk upto start of param */      
+      p = mu_str_skip_class (p + 1, MU_CTYPE_SPACE);
       if ((v = strchr (p, '=')) == NULL)
 	break;
-      *len = 0;
-      v = e = v + 1;
-      while (*e && (quoted || (!_ISSPECIAL (*e) && !mu_isspace (*e))))
-	{			/* skip pass value and calc len */
-	  if (*e == '\"')
-	    quoted = ~quoted, was_quoted = 1;
-	  else
-	    (*len)++;
+      v++;
+      /* Find end of the parameter */
+      if (*v == '"')
+	{
+	  /* Quoted string */
+	  for (e = ++v; *e != '"'; e++)
+	    {
+	      if (*e == 0) /* Malformed header */
+		{
+		  res = MU_ERR_PARSE;
+		  break;
+		}
+	      if (*e == '\\')
+		{
+		  if (*++e == 0)
+		    {
+		      res = MU_ERR_PARSE;
+		      break;
+		    }
+		  escaped_chars++;
+		}
+	    }
+	  if (res == MU_ERR_PARSE)
+	    break;
+	  len = e - v;
 	  e++;
 	}
-      if (mu_c_strncasecmp (p, param, strlen (param)))
-	{			/* no match jump to next */
+      else
+	{
+	  for (e = v + 1; !(_ISSPECIAL (*e) || mu_isspace (*e)); e++)
+	    ;
+	  len = e - v;
+	}
+
+      /* Is it our parameter? */
+      if (mu_c_strncasecmp (p, param, param_len))
+	{			/* nope, jump to next */
 	  p = strchr (e, ';');
 	  continue;
 	}
-      else
-	return was_quoted ? v + 1 : v;	/* return unquoted value */
-    }
-  return NULL;
-}
+	
+      res = 0; /* Indicate success */
+      
+      if (p[param_len] == '*')
+	{
+	  /* Parameter value continuation (RFC 2231, Section 3).
+	     See if the index is OK */
+	  char *end;
+	  unsigned long n = strtoul (p + param_len + 1, &end, 10);
+	  if (*end != '=' || n != cind)
+	    {
+	      res = MU_ERR_PARSE;
+	      break;
+	    }
+	  /* Everything OK, increase the estimation */
+	  cind++; 
+	}
+      
+      /* Prepare P for the next iteration */
+      p = e;
 
-int
-mu_message_aget_attachment_name (mu_message_t msg, char **name)
-{
-  size_t sz = 0;
-  int ret = 0;
+      /* Escape characters that appear in quoted-pairs are
+	 semantically "invisible" (RFC 2822, Section 3.2.2,
+	 "Quoted characters") */
+      len -= escaped_chars;
 
-  if (name == NULL)
-    return MU_ERR_OUT_PTR_NULL;
+      /* Adjust len if nearing end of the buffer */
+      if (bufsz && len >= bufsz)
+	len = bufsz - 1;
 
-  if ((ret = mu_message_get_attachment_name (msg, NULL, 0, &sz)) != 0)
-    return ret;
+      if (pret)
+	{
+	  /* The caller wants us to allocate the memory */
+	  if (!buf && !mem)
+	    {
+	      mem = malloc (len + 1);
+	      if (!mem)
+		{
+		  res = ENOMEM;
+		  break;
+		}
+	      buf = mem;
+	    }
+	  else if (mem)
+	    {
+	      /* If we got here, it means we are iterating over
+		 a parameter value continuation, and cind=0 has
+		 already been passed.  Reallocate the memory to
+		 accomodate next chunk of data. */
+	      char *newmem = realloc (mem, retlen + len + 1);
+	      if (!newmem)
+		{
+		  res = ENOMEM;
+		  break;
+		}
+	      mem = newmem;
+	    }
+	}
 
-  *name = malloc (sz + 1);
-  if (!*name)
-    return ENOMEM;
-  
-  if ((ret = mu_message_get_attachment_name (msg, *name, sz + 1, NULL)) != 0)
-    {
-      free (*name);
-      *name = NULL;
+      if (buf)
+	{
+	  /* Actually copy the data.  Buf is not NULL either because
+	     the user passed it as an argument, or because we allocated
+	     memory for it. */
+	  if (escaped_chars)
+	    {
+	      int i;
+	      for (i = 0; i < len; i++)
+		{
+		  if (*v == '\\')
+		    ++v;
+		  buf[retlen + i] = *v++;
+		}
+	    }
+	  else
+	    memcpy (buf + retlen, v, len);
+	}
+      /* Adjust total result size ... */
+      retlen += len;
+      /* ... and remaining buffer size, if necessary */
+      if (bufsz)
+	{
+	  bufsz -= len;
+	  if (bufsz == 0)
+	    break;
+	}
     }
 
-  return ret;
+  if (res == 0)
+    {
+      /* Everything OK, prepare the returned data. */
+      if (buf)
+	buf[retlen] = 0;
+      if (plen)
+	*plen = retlen;
+      if (pret)
+	*pret = mem;
+    }
+  else if (mem)
+    free (mem);
+  return res;
 }
 
-int
-mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
-				size_t *sz)
+/* Get the attachment name from MSG.  See _header_get_param, for a
+   description of the rest of arguments. */
+static int
+_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
+		      char **pbuf, size_t *sz)
 {
   int ret = EINVAL;
   mu_header_t hdr;
   char *value = NULL;
-  char *name = NULL;
-  size_t namesz = 0;
 
   if (!msg)
     return ret;
@@ -276,41 +441,39 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
 
   if (ret == 0 && value != NULL)
     {
-      /* FIXME: this is cheezy, it should check the value of the
-         Content-Disposition field, not strstr it. */
-
-      if (strstr (value, "attachment") != NULL)
-	name = _header_get_param (value, "filename", &namesz);
+      ret = _header_get_param (value, "attachment",
+			       "filename", buf, bufsz, pbuf, sz);
+      free (value);
+      value = NULL;
+      if (ret == 0 || ret != MU_ERR_NOENT)
+	return ret;
     }
 
   /* If we didn't get the name, we fall back on the Content-Type name
      parameter. */
 
-  if (name == NULL)
-    {
-      if (value)
-	free (value);
-
-      ret = mu_header_aget_value (hdr, "Content-Type", &value);
-      name = _header_get_param (value, "name", &namesz);
-    }
-
-  if (name)
-    {
-      ret = 0;
-
-      name[namesz] = '\0';
+  free (value);
+  ret = mu_header_aget_value (hdr, "Content-Type", &value);
+  if (ret == 0)
+    ret = _header_get_param (value, NULL, "name", buf, bufsz, pbuf, sz);
+  free (value);
 
-      if (sz)
-	*sz = namesz;
+  return ret;
+}
 
-      if (buf)
-	strncpy (buf, name, bufsz);
-    }
-  else
-    ret = MU_ERR_NOENT;
+int
+mu_message_aget_attachment_name (mu_message_t msg, char **name)
+{
+  if (name == NULL)
+    return MU_ERR_OUT_PTR_NULL;
+  return _get_attachment_name (msg, NULL, 0, name, NULL);
+}
 
-  return ret;
+int
+mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
+				size_t *sz)
+{
+  return _get_attachment_name (msg, buf, bufsz, NULL, sz);
 }
 
 int
diff --git a/mh/mhn.c b/mh/mhn.c
index ac19f44..a6bc4ea 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -1588,59 +1588,12 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
   
   if (mode_options & OPT_AUTO)
     {
-      mu_header_t hdr;
       char *val;
 
-      if (mu_message_get_header (msg, &hdr) == 0)
+      if (mu_message_aget_attachment_name (msg, &val) == 0)
 	{
-	  int argc;
-	  char **argv;
-
-	  if (mu_header_aget_value (hdr, MU_HEADER_CONTENT_DISPOSITION, &val) == 0)
-	    {
-	      if (mu_argcv_get (val, "=", NULL, &argc, &argv) == 0)
-		{
-		  int i;
-
-		  for (i = 0; i < argc; i++)
-		    {
-		      if (strcmp (argv[i], "filename") == 0
-			  && ++i < argc
-			  && argv[i][0] == '='
-			  && ++i < argc)
-			{
-			  name = normalize_path (dir, argv[i]);
-			  break;
-			}
-		    }
-		  mu_argcv_free (argc, argv);
-		}
-	      free (val);
-	    }
-
-	  if (!name
-	      && mu_header_aget_value (hdr, MU_HEADER_CONTENT_TYPE, &val) == 0)
-	    {
-	      if (mu_argcv_get (val, "=", NULL, &argc, &argv) == 0)
-		{
-		  int i;
-		  
-		  for (i = 0; i < argc; i++)
-		    {
-		      if ((strcmp (argv[i], "filename") == 0
-			   || strcmp (argv[i], "name") == 0)
-			  && ++i < argc
-			  && argv[i][0] == '='
-			  && ++i < argc)
-			{
-			  name = normalize_path (dir, argv[i]);
-			  break;
-			}
-		    }
-		  mu_argcv_free (argc, argv);
-		}
-	      free (val);
-	    }
+	  name = normalize_path (dir, val);
+	  free (val);
 	}
     }
   


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Tue Apr 06 15:32:06 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NzEVK-0005JP-OH
	for mharc-commit-mailutils@gnu.org; Tue, 06 Apr 2010 15:32:06 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NzEVJ-0005HZ-1l
	for commit-mailutils@gnu.org; Tue, 06 Apr 2010 15:32:05 -0400
Received: from [140.186.70.92] (port=55200 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NzEVG-0005F8-6W
	for commit-mailutils@gnu.org; Tue, 06 Apr 2010 15:32:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NzEVD-00037Y-JX
	for commit-mailutils@gnu.org; Tue, 06 Apr 2010 15:32:02 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:53185
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NzEVD-00037T-H8
	for commit-mailutils@gnu.org; Tue, 06 Apr 2010 15:31:59 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NzEVD-0005g8-Dh
	for commit-mailutils@gnu.org; Tue, 06 Apr 2010 19:31:59 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NzEVB-0000q0-Jf
	for commit-mailutils@gnu.org; Tue, 06 Apr 2010 19:31:59 +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: d5ae81e503facb6b39cebd5dbf6697dfa429ef07
X-Git-Newrev: b2c1b1ff400a604fa41c168351630bac3238177e
Message-Id: <E1NzEVB-0000q0-Jf@vcs-noshell.in.savannah.gnu.org>
Date: Tue, 06 Apr 2010 19:31:57 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-60-gb2c1b1f
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, 06 Apr 2010 19:32:05 -0000

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

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

The branch, master has been updated
       via  b2c1b1ff400a604fa41c168351630bac3238177e (commit)
      from  d5ae81e503facb6b39cebd5dbf6697dfa429ef07 (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 b2c1b1ff400a604fa41c168351630bac3238177e
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Apr 6 21:55:15 2010 +0300

    Improve compatibility with RFC 2231 and RFC 2047.
    
    * mailbox/mimehdr.c: New file.
    * mailbox/Makefile.am (libmailutils_la_SOURCES): Add
    mailbox/mimehdr.c.
    * mailbox/attachment.c (_header_get_param)
    (_get_attachment_name, mu_message_aget_attachment_name)
    (mu_message_get_attachment_name: Move to mailbox/mimehdr.c (with
    edits).
    (mu_message_save_attachment): Add a FIXME comment.
    * include/mailutils/message.h (MU_MIMEHDR_MULTILINE)
    (MU_MIMEHDR_CSINFO): New defines.
    (mu_mimehdr_get_disp,mu_mimehdr_aget_disp)
    (mu_mimehdr_get_param,mu_mimehdr_aget_param)
    (mu_mimehdr_decode_param)
    (mu_mimehdr_aget_decoded_param): New prototypes.
    (mu_message_aget_attachment_name): Change signature.
    (mu_message_aget_decoded_attachment_name): New prototype.
    
    * mailbox/mutil.c (mu_hex2ul): Fix a silly bug (have
    anybody ever tried to use that function?!?)
    * mailbox/testsuite/Urls: Update.
    
    * examples/mimetest.c (message_display_parts): Add a FIXME comment.
    * libmu_cpp/message.cc (Message::get_attachment_name): Likewise.
    * mh/mhn.c (store_handler): Likewise.
    * python/libmu_py/message.c (api_message_get_attachment_name): Likewise.

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

Summary of changes:
 examples/mimetest.c         |    3 +-
 include/mailutils/message.h |   31 ++-
 libmu_cpp/message.cc        |    3 +-
 mailbox/Makefile.am         |    1 +
 mailbox/attachment.c        |  294 +--------------------
 mailbox/mimehdr.c           |  614 +++++++++++++++++++++++++++++++++++++++++++
 mailbox/mutil.c             |    4 +-
 mailbox/testsuite/Urls      |    2 +-
 mh/mhn.c                    |    4 +-
 python/libmu_py/message.c   |    3 +-
 10 files changed, 658 insertions(+), 301 deletions(-)
 create mode 100644 mailbox/mimehdr.c

diff --git a/examples/mimetest.c b/examples/mimetest.c
index 90a00a0..c42dc44 100644
--- a/examples/mimetest.c
+++ b/examples/mimetest.c
@@ -242,7 +242,8 @@ message_display_parts (mu_message_t msg, int indent)
         {
           /* Save the attachements.  */
           char *fname = NULL;
-          mu_message_aget_attachment_name (part, &fname);
+	  /* FIXME: CS/Lang info is ignored */
+          mu_message_aget_attachment_name (part, &fname, NULL);
           if (fname == NULL)
             fname = mu_tempname (NULL);
 
diff --git a/include/mailutils/message.h b/include/mailutils/message.h
index 724766a..3ff2588 100644
--- a/include/mailutils/message.h
+++ b/include/mailutils/message.h
@@ -119,9 +119,36 @@ extern int mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg,
 extern int mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
 				     void **data);
 
+/* Bit values for *pflags in functions below */
+#define MU_MIMEHDR_MULTILINE 0x01  /* Parameter was multiline */
+#define MU_MIMEHDR_CSINFO    0x02  /* Parameter contains charset/language
+				      info */
+
+extern int mu_mimehdr_get_disp (const char *str, const char *param,
+				char *buf, size_t bufsz, size_t *retsz);
+extern int mu_mimehdr_aget_disp (const char *str, const char *param,
+				char **pvalue);
+extern int mu_mimehdr_get_param (const char *str, const char *param,
+				 char *buf, size_t bufsz, size_t *retsz,
+				 int *pflags);
+extern int mu_mimehdr_aget_param (const char *str, const char *param,
+				  char **pval, int *pflags);
+extern int mu_mimehdr_decode_param (const char *value, int csinfo,
+				    const char *charset,
+				    char **pval, char **plang);
+extern int mu_mimehdr_aget_decoded_param (const char *str, const char *param,
+					  const char *charset, 
+					  char **pval, char **plang);
+  
 extern int mu_message_get_attachment_name (mu_message_t, char *name,
-					   size_t bufsz, size_t* sz);
-extern int mu_message_aget_attachment_name (mu_message_t, char **name);
+					   size_t bufsz, size_t* sz,
+					   int *pflags);
+extern int mu_message_aget_attachment_name (mu_message_t, char **name,
+					    int *pflags);
+extern int mu_message_aget_decoded_attachment_name (mu_message_t msg,
+						    const char *charset,
+						    char **name,
+						    char **plang);
 
 extern int mu_message_save_to_mailbox (mu_message_t msg, 
 				       mu_debug_t debug, const char *toname,
diff --git a/libmu_cpp/message.cc b/libmu_cpp/message.cc
index 55fdd38..21f3ec6 100644
--- a/libmu_cpp/message.cc
+++ b/libmu_cpp/message.cc
@@ -224,7 +224,8 @@ Message :: get_attachment_name ()
   char *c_name;
   std::string name;
 
-  int status = mu_message_aget_attachment_name (msg, &c_name);
+  /* FIXME: CS/Lang info is ignored */
+  int status = mu_message_aget_attachment_name (msg, &c_name, NULL);
   if (status)
     throw Exception ("Message::get_attachment_name", status);
   if (c_name) {
diff --git a/mailbox/Makefile.am b/mailbox/Makefile.am
index 5146528..96c203a 100644
--- a/mailbox/Makefile.am
+++ b/mailbox/Makefile.am
@@ -101,6 +101,7 @@ libmailutils_la_SOURCES = \
  memory_stream.c\
  message_stream.c\
  mime.c\
+ mimehdr.c\
  mkfilename.c\
  monitor.c\
  msrv.c\
diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 39165e6..9ef1455 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -185,297 +185,6 @@ _attachment_free (struct _msg_info *info, int free_message)
   free (info);
 }
 
-/* See RFC 2045, 5.1.  Syntax of the Content-Type Header Field */
-#define _ISSPECIAL(c) !!strchr ("()<>@,;:\\\"/[]?=", c)
-
-/* _header_get_param - an auxiliary function to extract values from
-   Content-Type, Content-Disposition and similar headers.
-
-   Arguments:
-   
-   FIELD_BODY    Header value, complying to RFCs 2045, 2183, 2231.3;
-   DISP          Disposition.  Unless it is NULL, the disposition part
-                 of FIELD_BODY is compared with it.  If they differ,
-		 the function returns MU_ERR_NOENT.
-   PARAM         Name of the parameter to extract from FIELD_BODY;
-   BUF           Where to extract the value to;
-   BUFSZ         Size of BUF;
-   PRET          Pointer to the memory location for the return buffer (see
-                 below).
-   PLEN          Pointer to the return size.
-
-   The function parses FIELD_BODY and extracts the value of the parameter
-   PARAM.
-
-   If BUF is not NULL and BUFSZ is not 0, the extracted value is stored into
-   BUF.  At most BUFSZ-1 bytes are copied.
-
-   Otherwise, if PRET is not NULL, the function allocates enough memory to
-   hold the extracted value, copies there the result, and stores the
-   pointer to the allocated memory into the location pointed to by PRET.
-
-   If PLEN is not NULL, the size of the extracted value (without terminating
-   NUL character) is stored there.
-
-   If BUF==NULL *and* PRET==NULL, no memory is allocated, but PLEN is
-   honored anyway, i.e. unless it is NULL it receives size of the result.
-   This can be used to estimate the needed buffer size.
-
-   Return values:
-     0             on success.
-     MU_ERR_NOENT, requested parameter not found, or disposition does
-                   not match DISP.
-     MU_ERR_PARSE, if FIELD_BODY does not comply to any of the abovemntioned
-                   RFCs.
-     ENOMEM      , if unable to allocate memory.
-*/
-   
-int
-_header_get_param (char *field_body,
-		   const char *disp,
-		   const char *param,
-		   char *buf, size_t bufsz,
-		   char **pret, size_t *plen)
-{
-  int res = MU_ERR_NOENT;            /* Return value, pessimistic default */
-  size_t param_len = strlen (param);
-  char *p;
-  char *mem = NULL;                  /* Allocated memory storage */
-  size_t retlen = 0;                 /* Total number of bytes copied */
-  unsigned long cind = 0;            /* Expected continued parameter index.
-					See RFC 2231, Section 3,
-					"Parameter Value Continuations" */
-  
-  if (field_body == NULL)
-    return EINVAL;
-
-  if (bufsz == 0) /* Make sure buf value is meaningful */
-    buf = NULL;
-  
-  p = strchr (field_body, ';');
-  if (!p)
-    return MU_ERR_NOENT;
-  if (disp && mu_c_strncasecmp (field_body, disp, p - field_body))
-    return MU_ERR_NOENT;
-      
-  while (p && *p)
-    {
-      char *v, *e;
-      size_t len, escaped_chars = 0;
-
-      if (*p != ';')
-	{
-	  res = MU_ERR_PARSE;
-	  break;
-	}
-      
-      /* walk upto start of param */      
-      p = mu_str_skip_class (p + 1, MU_CTYPE_SPACE);
-      if ((v = strchr (p, '=')) == NULL)
-	break;
-      v++;
-      /* Find end of the parameter */
-      if (*v == '"')
-	{
-	  /* Quoted string */
-	  for (e = ++v; *e != '"'; e++)
-	    {
-	      if (*e == 0) /* Malformed header */
-		{
-		  res = MU_ERR_PARSE;
-		  break;
-		}
-	      if (*e == '\\')
-		{
-		  if (*++e == 0)
-		    {
-		      res = MU_ERR_PARSE;
-		      break;
-		    }
-		  escaped_chars++;
-		}
-	    }
-	  if (res == MU_ERR_PARSE)
-	    break;
-	  len = e - v;
-	  e++;
-	}
-      else
-	{
-	  for (e = v + 1; !(_ISSPECIAL (*e) || mu_isspace (*e)); e++)
-	    ;
-	  len = e - v;
-	}
-
-      /* Is it our parameter? */
-      if (mu_c_strncasecmp (p, param, param_len))
-	{			/* nope, jump to next */
-	  p = strchr (e, ';');
-	  continue;
-	}
-	
-      res = 0; /* Indicate success */
-      
-      if (p[param_len] == '*')
-	{
-	  /* Parameter value continuation (RFC 2231, Section 3).
-	     See if the index is OK */
-	  char *end;
-	  unsigned long n = strtoul (p + param_len + 1, &end, 10);
-	  if (*end != '=' || n != cind)
-	    {
-	      res = MU_ERR_PARSE;
-	      break;
-	    }
-	  /* Everything OK, increase the estimation */
-	  cind++; 
-	}
-      
-      /* Prepare P for the next iteration */
-      p = e;
-
-      /* Escape characters that appear in quoted-pairs are
-	 semantically "invisible" (RFC 2822, Section 3.2.2,
-	 "Quoted characters") */
-      len -= escaped_chars;
-
-      /* Adjust len if nearing end of the buffer */
-      if (bufsz && len >= bufsz)
-	len = bufsz - 1;
-
-      if (pret)
-	{
-	  /* The caller wants us to allocate the memory */
-	  if (!buf && !mem)
-	    {
-	      mem = malloc (len + 1);
-	      if (!mem)
-		{
-		  res = ENOMEM;
-		  break;
-		}
-	      buf = mem;
-	    }
-	  else if (mem)
-	    {
-	      /* If we got here, it means we are iterating over
-		 a parameter value continuation, and cind=0 has
-		 already been passed.  Reallocate the memory to
-		 accomodate next chunk of data. */
-	      char *newmem = realloc (mem, retlen + len + 1);
-	      if (!newmem)
-		{
-		  res = ENOMEM;
-		  break;
-		}
-	      mem = newmem;
-	    }
-	}
-
-      if (buf)
-	{
-	  /* Actually copy the data.  Buf is not NULL either because
-	     the user passed it as an argument, or because we allocated
-	     memory for it. */
-	  if (escaped_chars)
-	    {
-	      int i;
-	      for (i = 0; i < len; i++)
-		{
-		  if (*v == '\\')
-		    ++v;
-		  buf[retlen + i] = *v++;
-		}
-	    }
-	  else
-	    memcpy (buf + retlen, v, len);
-	}
-      /* Adjust total result size ... */
-      retlen += len;
-      /* ... and remaining buffer size, if necessary */
-      if (bufsz)
-	{
-	  bufsz -= len;
-	  if (bufsz == 0)
-	    break;
-	}
-    }
-
-  if (res == 0)
-    {
-      /* Everything OK, prepare the returned data. */
-      if (buf)
-	buf[retlen] = 0;
-      if (plen)
-	*plen = retlen;
-      if (pret)
-	*pret = mem;
-    }
-  else if (mem)
-    free (mem);
-  return res;
-}
-
-/* Get the attachment name from MSG.  See _header_get_param, for a
-   description of the rest of arguments. */
-static int
-_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
-		      char **pbuf, size_t *sz)
-{
-  int ret = EINVAL;
-  mu_header_t hdr;
-  char *value = NULL;
-
-  if (!msg)
-    return ret;
-
-  if ((ret = mu_message_get_header (msg, &hdr)) != 0)
-    return ret;
-
-  ret = mu_header_aget_value (hdr, "Content-Disposition", &value);
-
-  /* If the header wasn't there, we'll fall back to Content-Type, but
-     other errors are fatal. */
-  if (ret != 0 && ret != MU_ERR_NOENT)
-    return ret;
-
-  if (ret == 0 && value != NULL)
-    {
-      ret = _header_get_param (value, "attachment",
-			       "filename", buf, bufsz, pbuf, sz);
-      free (value);
-      value = NULL;
-      if (ret == 0 || ret != MU_ERR_NOENT)
-	return ret;
-    }
-
-  /* If we didn't get the name, we fall back on the Content-Type name
-     parameter. */
-
-  free (value);
-  ret = mu_header_aget_value (hdr, "Content-Type", &value);
-  if (ret == 0)
-    ret = _header_get_param (value, NULL, "name", buf, bufsz, pbuf, sz);
-  free (value);
-
-  return ret;
-}
-
-int
-mu_message_aget_attachment_name (mu_message_t msg, char **name)
-{
-  if (name == NULL)
-    return MU_ERR_OUT_PTR_NULL;
-  return _get_attachment_name (msg, NULL, 0, name, NULL);
-}
-
-int
-mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
-				size_t *sz)
-{
-  return _get_attachment_name (msg, buf, bufsz, NULL, sz);
-}
-
 int
 mu_message_save_attachment (mu_message_t msg, const char *filename,
 			    void **data)
@@ -499,7 +208,8 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
     {
       if (filename == NULL)
 	{
-	  ret = mu_message_aget_attachment_name (msg, &partname);
+	  /* FIXME: Charset info is ignored */
+	  ret = mu_message_aget_attachment_name (msg, &partname, NULL);
 	  if (partname)
 	    fname = partname;
 	}
diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
new file mode 100644
index 0000000..848842b
--- /dev/null
+++ b/mailbox/mimehdr.c
@@ -0,0 +1,614 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2009, 2010 Free
+   Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not,
+   see <http://www.gnu.org/licenses/>. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
+#include <mailutils/errno.h>
+#include <mailutils/message.h>
+#include <mailutils/header.h>
+#include <mailutils/stream.h>
+#include <mailutils/url.h> /* FIXME: for mu_url_decode, which should
+			      be renamed! */
+#include <mailutils/mime.h>
+#include <mailutils/filter.h>
+#include <mailutils/mutil.h>
+
+/* See RFC 2045, 5.1.  Syntax of the Content-Type Header Field */
+#define _ISSPECIAL(c) !!strchr ("()<>@,;:\\\"/[]?=", c)
+
+/* _header_get_param - an auxiliary function to extract values from
+   Content-Type, Content-Disposition and similar headers.
+
+   Arguments:
+   
+   FIELD_BODY    Header value, complying to RFCs 2045, 2183, 2231.3;
+   DISP          Disposition.  Unless it is NULL, the disposition part
+                 of FIELD_BODY is compared with it.  If they differ,
+		 the function returns MU_ERR_NOENT.
+   PARAM         Name of the parameter to extract from FIELD_BODY;
+   BUF           Where to extract the value to;
+   BUFSZ         Size of BUF;
+   PRET          Pointer to the memory location for the return buffer (see
+                 below).
+   PLEN          Pointer to the return size.
+   PFLAGS        On return, flags describing the parameter are stored there.
+                 The MU_MIMEHDR_MULTILINE bit is set if the parameter value
+		 was multiline (RFC 2231.3).  The MU_MIMEHDR_CSINFO bit is set
+		 if the parameter value includes charset/language
+		 information (RFC 2231.4).
+
+   The function parses FIELD_BODY and extracts the value of the parameter
+   PARAM.
+
+   If BUF is not NULL and BUFSZ is not 0, the extracted value is stored into
+   BUF.  At most BUFSZ-1 bytes are copied.
+
+   Otherwise, if PRET is not NULL, the function allocates enough memory to
+   hold the extracted value, copies there the result, and stores the
+   pointer to the allocated memory into the location pointed to by PRET.
+
+   If PLEN is not NULL, the size of the extracted value (without terminating
+   NUL character) is stored there.
+
+   If BUF==NULL *and* PRET==NULL, no memory is allocated, but PLEN is
+   honored anyway, i.e. unless it is NULL it receives size of the result.
+   This can be used to estimate the needed buffer size.
+
+   Return values:
+     0             on success.
+     MU_ERR_NOENT, requested parameter not found, or disposition does
+                   not match DISP.
+     MU_ERR_PARSE, if FIELD_BODY does not comply to any of the abovemntioned
+                   RFCs.
+     ENOMEM      , if unable to allocate memory.
+*/
+   
+int
+_header_get_param (const char *field_body,
+		   const char *disp,
+		   const char *param,
+		   char *buf, size_t bufsz,
+		   char **pret, size_t *plen,
+		   int *pflags)
+{
+  int res = MU_ERR_NOENT;            /* Return value, pessimistic default */
+  size_t param_len = strlen (param);
+  char *p;
+  char *mem = NULL;                  /* Allocated memory storage */
+  size_t retlen = 0;                 /* Total number of bytes copied */
+  unsigned long cind = 0;            /* Expected continued parameter index.
+					See RFC 2231, Section 3,
+					"Parameter Value Continuations" */
+  int flags = 0;
+  
+  if (field_body == NULL)
+    return EINVAL;
+
+  if (bufsz == 0) /* Make sure buf value is meaningful */
+    buf = NULL;
+  
+  p = strchr (field_body, ';');
+  if (!p)
+    return MU_ERR_NOENT;
+  if (disp && mu_c_strncasecmp (field_body, disp, p - field_body))
+    return MU_ERR_NOENT;
+      
+  while (p && *p)
+    {
+      char *v, *e;
+      size_t len, escaped_chars = 0;
+      
+      if (*p != ';')
+	{
+	  res = MU_ERR_PARSE;
+	  break;
+	}
+      
+      /* walk upto start of param */      
+      p = mu_str_skip_class (p + 1, MU_CTYPE_SPACE);
+      if ((v = strchr (p, '=')) == NULL)
+	break;
+      v++;
+      /* Find end of the parameter */
+      if (*v == '"')
+	{
+	  /* Quoted string */
+	  for (e = ++v; *e != '"'; e++)
+	    {
+	      if (*e == 0) /* Malformed header */
+		{
+		  res = MU_ERR_PARSE;
+		  break;
+		}
+	      if (*e == '\\')
+		{
+		  if (*++e == 0)
+		    {
+		      res = MU_ERR_PARSE;
+		      break;
+		    }
+		  escaped_chars++;
+		}
+	    }
+	  if (res == MU_ERR_PARSE)
+	    break;
+	  len = e - v;
+	  e++;
+	}
+      else
+	{
+	  for (e = v + 1; !(_ISSPECIAL (*e) || mu_isspace (*e)); e++)
+	    ;
+	  len = e - v;
+	}
+
+      /* Is it our parameter? */
+      if (mu_c_strncasecmp (p, param, param_len))
+	{			/* nope, jump to next */
+	  p = strchr (e, ';');
+	  continue;
+	}
+
+      res = 0; /* Indicate success */
+      
+      if (p[param_len] == '*')
+	{
+	  char *cp = p + param_len + 1;
+	  
+	  /* It is a parameter value continuation (RFC 2231, Section 3)
+	     or parameter value character set and language information
+	     (ibid., Section 4). */
+	  if (*cp == '=')
+	    flags |= MU_MIMEHDR_CSINFO;
+	  else if (mu_isdigit (*cp))
+	    {
+	      /* See if the index is OK */
+	  
+	      char *end;
+	      unsigned long n = strtoul (cp, &end, 10);
+
+	      if (*end == '*')
+		{
+		  flags |= MU_MIMEHDR_CSINFO;
+		  end++;
+		}
+	      if (*end != '=' || n != cind)
+		{
+		  res = MU_ERR_PARSE;
+		  break;
+		}
+	      /* Everything OK, increase the estimation */
+	      flags |= MU_MIMEHDR_MULTILINE;
+	      cind++; 
+	    }
+	}
+      
+      /* Prepare P for the next iteration */
+      p = e;
+
+      /* Escape characters that appear in quoted-pairs are
+	 semantically "invisible" (RFC 2822, Section 3.2.2,
+	 "Quoted characters") */
+      len -= escaped_chars;
+
+      /* Adjust len if nearing end of the buffer */
+      if (bufsz && len >= bufsz)
+	len = bufsz - 1;
+
+      if (pret)
+	{
+	  /* The caller wants us to allocate the memory */
+	  if (!buf && !mem)
+	    {
+	      mem = malloc (len + 1);
+	      if (!mem)
+		{
+		  res = ENOMEM;
+		  break;
+		}
+	      buf = mem;
+	    }
+	  else if (mem)
+	    {
+	      /* If we got here, it means we are iterating over
+		 a parameter value continuation, and cind=0 has
+		 already been passed.  Reallocate the memory to
+		 accomodate next chunk of data. */
+	      char *newmem = realloc (mem, retlen + len + 1);
+	      if (!newmem)
+		{
+		  res = ENOMEM;
+		  break;
+		}
+	      mem = newmem;
+	    }
+	}
+
+      if (buf)
+	{
+	  /* Actually copy the data.  Buf is not NULL either because
+	     the user passed it as an argument, or because we allocated
+	     memory for it. */
+	  if (escaped_chars)
+	    {
+	      int i;
+	      for (i = 0; i < len; i++)
+		{
+		  if (*v == '\\')
+		    ++v;
+		  buf[retlen + i] = *v++;
+		}
+	    }
+	  else
+	    memcpy (buf + retlen, v, len);
+	}
+      /* Adjust total result size ... */
+      retlen += len;
+      /* ... and remaining buffer size, if necessary */
+      if (bufsz)
+	{
+	  bufsz -= len;
+	  if (bufsz == 0)
+	    break;
+	}
+    }
+
+  if (res == 0)
+    {
+      /* Everything OK, prepare the returned data. */
+      if (buf)
+	buf[retlen] = 0;
+      if (plen)
+	*plen = retlen;
+      if (pret)
+	*pret = mem;
+      if (pflags)
+	*pflags = flags;
+    }
+  else if (mem)
+    free (mem);
+  return res;
+}
+
+/* STR is a value of a structured MIME header, e.g. Content-Type.
+   This function returns the `disposition part' of it.  In other
+   words, it returns disposition, if STR is a Content-Disposition
+   value, and `type/subtype' part, if it is a Content-Type value.
+*/
+int
+mu_mimehdr_get_disp (const char *str, const char *param,
+		     char *buf, size_t bufsz, size_t *retsz)
+{
+  char *p = strchr (str, ';');
+  size_t size;
+  
+  if (!p)
+    return MU_ERR_NOENT;
+  size = p - str;
+  if (buf)
+    size = mu_cpystr (buf, str, size);
+  if (retsz)
+    *retsz = size;
+  return 0;
+}
+
+/* Same as mu_mimehdr_get_disp, but allocates memory */
+int
+mu_mimehdr_aget_disp (const char *str, const char *param, char **pvalue)
+{
+  char *p = strchr (str, ';');
+  size_t size;
+  
+  if (!p)
+    return MU_ERR_NOENT;
+  size = p - str;
+  p = malloc (size + 1);
+  if (!p)
+    return ENOMEM;
+  memcpy (p, str, size);
+  p[size] = 0;
+  return 0;
+}
+
+/* Get the value of the parameter PARAM from STR, which must be
+   a value of a structured MIME header.
+   At most BUFSZ-1 of data are stored in BUF.  A terminating NUL
+   character is appended to it.
+   
+   Unless NULL, RETSZ is filled with the actual length of the
+   returned data (not including the NUL terminator).
+
+   Unless PFLAGS is null it will contain, on return, the flags describing
+   the parameter.  The MU_MIMEHDR_MULTILINE bit is set if the parameter value
+   was multiline (RFC 2231.3).  The MU_MIMEHDR_CSINFO bit is set if the
+   parameter value includes charset/language information (RFC 2231.4).
+   
+   BUF may be NULL, in which case the function will only fill
+   RETSZ and PFLAGS, as described above. */
+int
+mu_mimehdr_get_param (const char *str, const char *param,
+		     char *buf, size_t bufsz, size_t *retsz,
+		     int *pflags)
+{
+  return _header_get_param (str, NULL, param, buf, bufsz, NULL, retsz,
+			    pflags);
+}
+
+/* Same as mu_mimehdr_get_param, but allocates memory. */
+int
+mu_mimehdr_aget_param (const char *str, const char *param,
+		      char **pval, int *pflags)
+{
+  return _header_get_param (str, NULL, param, NULL, 0, pval, NULL, pflags);
+}
+
+/* Decode a parameter value.  Arguments:
+
+   Input:
+   VALUE        Parameter value.
+   FLAGS        Flags obtained from a previous call to one of the functions
+                above.
+   CHARSET      Output charset.
+
+   Output:
+   PVAL         A pointer to the decoded value is stored there.
+                The memory is allocated using malloc.
+   PLANG        If language information was present in VALUE, its
+                malloc'ed copy is stored in the memory location pointed
+		to by this variable.  If there was no language information,
+		*PLANG is set to NULL. 
+
+   Both PVAL and PLANG may be NULL if that particular piece of information
+   is not needed. */
+int
+mu_mimehdr_decode_param (const char *value, int flags,
+			 const char *charset, char **pval, char **plang)
+{
+  char *decoded;
+  int rc;
+  char *lang = NULL;
+  char *data;
+
+  if (flags == 0)
+    {
+      rc = mu_rfc2047_decode (charset, value, &decoded);
+      if (rc)
+	return rc;
+    }
+  else
+    {
+      decoded = mu_url_decode (value);
+      if (!decoded)
+	return ENOMEM;
+  
+      if ((flags & MU_MIMEHDR_CSINFO)
+	  && (lang = strchr (decoded, '\''))
+	  && (data = strchr (lang + 1, '\'')))
+	{
+	  char *source_cs = decoded;
+
+	  *lang++ = 0;
+	  *data++ = 0;
+
+	  lang = lang[0] ? strdup (lang) : NULL;
+      
+	  if (source_cs[0] && charset && mu_c_strcasecmp (source_cs, charset))
+	    {
+	      char *outval = NULL;
+	      mu_stream_t instr = NULL;
+	      mu_stream_t outstr = NULL;
+	      mu_stream_t cvt = NULL;
+	      char iobuf[512];
+	  
+	      do
+		{
+		  size_t total = 0, pos;
+		  size_t nbytes;
+
+		  rc = mu_memory_stream_create (&instr, 0, 0);
+		  if (rc)
+		    break;
+		  rc = mu_stream_write (instr, data, strlen (data), 0, NULL);
+		  if (rc)
+		    break;
+
+		  rc = mu_memory_stream_create (&outstr, 0, 0);
+		  if (rc)
+		    break;
+		  
+		  rc = mu_filter_iconv_create (&cvt, instr, source_cs, charset,
+					       MU_STREAM_NO_CLOSE,
+					       mu_default_fallback_mode);
+		  if (rc)
+		    break;
+		  
+		  rc = mu_stream_open (cvt);
+		  if (rc)
+		    break;
+
+		  while (mu_stream_sequential_read (cvt, iobuf, sizeof (iobuf),
+						    &nbytes) == 0
+			 && nbytes)
+		    {
+		      rc = mu_stream_sequential_write (outstr, iobuf, nbytes);
+		      if (rc)
+			break;
+		      total += nbytes;
+		    }
+		  
+		  if (rc)
+		    break;
+		  
+		  outval = malloc (total + 1);
+		  if (!outval)
+		    {
+		      rc = ENOMEM;
+		      break;
+		    }
+
+		  mu_stream_seek (outstr, 0, SEEK_SET);
+		  pos = 0;
+		  while (mu_stream_sequential_read (outstr, outval + pos,
+						    total - pos, &nbytes) == 0
+			 && nbytes)
+		    pos += nbytes;
+		  outval[pos] = 0;
+		}
+	      while (0);
+	      
+	      mu_stream_close (cvt);
+	      mu_stream_destroy (&cvt, mu_stream_get_owner (cvt));
+	      mu_stream_close (instr);
+	      mu_stream_destroy (&instr, mu_stream_get_owner (instr));
+	      mu_stream_close (outstr);
+	      mu_stream_destroy (&outstr, mu_stream_get_owner (outstr));
+	      
+	      free (decoded);
+	  
+	      if (rc)
+		{
+		  /* Cleanup after an error. */
+		  free (lang);
+		  free (outval);
+		  return rc;
+		}
+	      decoded = outval;
+	    }
+	  else
+	    memmove (decoded, data, strlen (data) + 1);
+	}
+    }
+  
+  if (pval)
+    *pval = decoded;
+  else
+    free (decoded);
+  
+  if (plang)
+    *plang = lang;
+  return 0;
+}
+
+/* Similar to mu_mimehdr_aget_param, but the returned value is decoded
+   according to the CHARSET.  Unless PLANG is NULL, it receives malloc'ed
+   language name from STR.  If there was no language name, *PLANG is set
+   to NULL. 
+*/
+int
+mu_mimehdr_aget_decoded_param (const char *str, const char *param,
+			       const char *charset, 
+			       char **pval, char **plang)
+{
+  char *value;
+  int rc;
+  int flags;
+  
+  rc = mu_mimehdr_aget_param (str, param, &value, &flags);
+  if (rc == 0)
+    {
+      rc = mu_mimehdr_decode_param (value, flags, charset, pval, plang);
+      free (value);
+    }
+  return rc;
+}
+  
+/* Get the attachment name from MSG.  See _header_get_param, for a
+   description of the rest of arguments. */
+static int
+_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
+		      char **pbuf, size_t *sz, int *pflags)
+{
+  int ret = EINVAL;
+  mu_header_t hdr;
+  char *value = NULL;
+
+  if (!msg)
+    return ret;
+
+  if ((ret = mu_message_get_header (msg, &hdr)) != 0)
+    return ret;
+
+  ret = mu_header_aget_value_unfold (hdr, "Content-Disposition", &value);
+
+  /* If the header wasn't there, we'll fall back to Content-Type, but
+     other errors are fatal. */
+  if (ret != 0 && ret != MU_ERR_NOENT)
+    return ret;
+
+  if (ret == 0 && value != NULL)
+    {
+      ret = _header_get_param (value, "attachment",
+			       "filename", buf, bufsz, pbuf, sz, pflags);
+      free (value);
+      value = NULL;
+      if (ret == 0 || ret != MU_ERR_NOENT)
+	return ret;
+    }
+
+  /* If we didn't get the name, we fall back on the Content-Type name
+     parameter. */
+
+  free (value);
+  ret = mu_header_aget_value_unfold (hdr, "Content-Type", &value);
+  if (ret == 0)
+    ret = _header_get_param (value, NULL, "name", buf, bufsz, pbuf, sz,
+			     pflags);
+  free (value);
+
+  return ret;
+}
+
+int
+mu_message_aget_attachment_name (mu_message_t msg, char **name, int *pflags)
+{
+  if (name == NULL)
+    return MU_ERR_OUT_PTR_NULL;
+  return _get_attachment_name (msg, NULL, 0, name, NULL, pflags);
+}
+
+int
+mu_message_aget_decoded_attachment_name (mu_message_t msg,
+					 const char *charset,
+					 char **pval,
+					 char **plang)
+{
+  char *value;
+  int flags;
+  int rc = mu_message_aget_attachment_name (msg, &value, &flags);
+  if (rc == 0)
+    {
+      rc = mu_mimehdr_decode_param (value, flags, charset, pval, plang);
+      free (value);
+    }
+  return rc;
+}
+
+int
+mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
+				size_t *sz, int *pflags)
+{
+  return _get_attachment_name (msg, buf, bufsz, NULL, sz, pflags);
+}
+
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index ce53794..19dbcc1 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -75,10 +75,10 @@ mu_hex2ul (char hex)
    return hex - '0';
 
   if (hex >= 'a' && hex <= 'z')
-    return hex - 'a';
+    return hex - 'a' + 10;
 
   if (hex >= 'A' && hex <= 'Z')
-    return hex - 'A';
+    return hex - 'A' + 10;
 
   return -1;
 }
diff --git a/mailbox/testsuite/Urls b/mailbox/testsuite/Urls
index ee7479f..a6e565e 100644
--- a/mailbox/testsuite/Urls
+++ b/mailbox/testsuite/Urls
@@ -58,7 +58,7 @@ scheme://%75%73%65%72:%70%61%73%73@%68%6f%73%74 => SUCCESS
 	user <user>
 	passwd <pass>
 	auth <>
-	host <hest>
+	host <host>
 	port 0
 	path <>
 
diff --git a/mh/mhn.c b/mh/mhn.c
index a6bc4ea..db100f6 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -1590,7 +1590,9 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
     {
       char *val;
 
-      if (mu_message_aget_attachment_name (msg, &val) == 0)
+      /* FIXME: Take into account CS/Lang info and recode the value
+	 if necessary */
+      if (mu_message_aget_attachment_name (msg, &val, NULL) == 0)
 	{
 	  name = normalize_path (dir, val);
 	  free (val);
diff --git a/python/libmu_py/message.c b/python/libmu_py/message.c
index 49827c2..fc71cbf 100644
--- a/python/libmu_py/message.c
+++ b/python/libmu_py/message.c
@@ -287,7 +287,8 @@ api_message_get_attachment_name (PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple (args, "O!", &PyMessageType, &py_msg))
     return NULL;
 
-  status = mu_message_aget_attachment_name (py_msg->msg, &name);
+  /* FIXME: CS/Lang info is ignored */
+  status = mu_message_aget_attachment_name (py_msg->msg, &name, NULL);
   return status_object (status, PyString_FromString (name ? name : ""));
 }
 


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 08 04:47:17 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NznOP-0005f7-NZ
	for mharc-commit-mailutils@gnu.org; Thu, 08 Apr 2010 04:47:17 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NznON-0005ec-9O
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 04:47:15 -0400
Received: from [140.186.70.92] (port=33954 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NznOI-0005eR-RX
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 04:47:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NznOE-0007g7-Ix
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 04:47:10 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:42246
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NznOE-0007g2-H2
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 04:47:06 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NznOE-0007Ok-97
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 08:47:06 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1NznOC-0002p2-Rz
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 08:47:06 +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: b2c1b1ff400a604fa41c168351630bac3238177e
X-Git-Newrev: 7287e840118d680efe1795e053500c999a950ade
Message-Id: <E1NznOC-0002p2-Rz@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 08 Apr 2010 08:47:05 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-61-g7287e84
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: Thu, 08 Apr 2010 08:47:15 -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=7287e840118d680efe1795e053500c999a950ade

The branch, master has been updated
       via  7287e840118d680efe1795e053500c999a950ade (commit)
      from  b2c1b1ff400a604fa41c168351630bac3238177e (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 7287e840118d680efe1795e053500c999a950ade
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 8 11:45:06 2010 +0300

    Improve MIME parameter parsing.
    
    * mailbox/mimehdr.c (_header_get_param): Improve error checking.
    Allow for optional whitespace around the '='.
    * mailbox/rfc2047.c (mu_rfc2047_decode): tocode=NULL is OK.

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

Summary of changes:
 mailbox/mimehdr.c |   66 ++++++++++++++++++++++++++++++++++++++++-------------
 mailbox/rfc2047.c |    2 +-
 2 files changed, 51 insertions(+), 17 deletions(-)

diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
index 848842b..0c04c23 100644
--- a/mailbox/mimehdr.c
+++ b/mailbox/mimehdr.c
@@ -84,7 +84,11 @@
                    RFCs.
      ENOMEM      , if unable to allocate memory.
 */
-   
+
+/* Internal flag used by _header_get_param to delay increasing
+   estimated continuation index. */
+#define _MU_MIMEHDR_INCR_CIND 0x8000
+
 int
 _header_get_param (const char *field_body,
 		   const char *disp,
@@ -117,7 +121,7 @@ _header_get_param (const char *field_body,
       
   while (p && *p)
     {
-      char *v, *e;
+      char *v, *e, *ep, *cp;
       size_t len, escaped_chars = 0;
       
       if (*p != ';')
@@ -128,9 +132,10 @@ _header_get_param (const char *field_body,
       
       /* walk upto start of param */      
       p = mu_str_skip_class (p + 1, MU_CTYPE_SPACE);
-      if ((v = strchr (p, '=')) == NULL)
+      if ((ep = strchr (p, '=')) == NULL)
 	break;
-      v++;
+      /* Allow for optional whitespace after '=' */
+      v = mu_str_skip_class (ep + 1, MU_CTYPE_SPACE);
       /* Find end of the parameter */
       if (*v == '"')
 	{
@@ -171,18 +176,15 @@ _header_get_param (const char *field_body,
 	  continue;
 	}
 
-      res = 0; /* Indicate success */
-      
-      if (p[param_len] == '*')
+      cp = p + param_len;
+
+      if (*cp == '*')
 	{
-	  char *cp = p + param_len + 1;
-	  
+	  cp++;
 	  /* It is a parameter value continuation (RFC 2231, Section 3)
 	     or parameter value character set and language information
 	     (ibid., Section 4). */
-	  if (*cp == '=')
-	    flags |= MU_MIMEHDR_CSINFO;
-	  else if (mu_isdigit (*cp))
+	  if (mu_isdigit (*cp))
 	    {
 	      /* See if the index is OK */
 	  
@@ -194,16 +196,48 @@ _header_get_param (const char *field_body,
 		  flags |= MU_MIMEHDR_CSINFO;
 		  end++;
 		}
-	      if (*end != '=' || n != cind)
+	      if (n != cind)
 		{
 		  res = MU_ERR_PARSE;
 		  break;
 		}
-	      /* Everything OK, increase the estimation */
-	      flags |= MU_MIMEHDR_MULTILINE;
-	      cind++; 
+	      /* Everything OK, mark this as a multiline (continued)
+		 parameter. We also need to increment the estimation,
+		 but it cannot be done right now because its value is
+		 used below to decide whether to do flag cleanup
+		 on error. So we set _MU_MIMEHDR_INCR_CIND flag instead
+		 and increment cind later. */
+	      flags |= (MU_MIMEHDR_MULTILINE|_MU_MIMEHDR_INCR_CIND);
+	      /* And point cp to the last character: there are more
+		 checks ahead. */
+	      cp = end;
 	    }
+	  else
+	    flags |= MU_MIMEHDR_CSINFO;
 	}
+      /* Allow for optional whitespace before '=' */
+      cp = mu_str_skip_class (cp, MU_CTYPE_SPACE);
+      /* cp must now point to the equals sign */
+      if (cp != ep)
+	{
+	  /* Clean up everything, unless we're in the middle of a
+	     parameter continuation. */
+	  if (cind == 0)
+	    flags = 0;
+
+	  /* Try next parameter */
+	  p = strchr (e, ';');
+	  continue;
+	}
+
+      if (flags & _MU_MIMEHDR_INCR_CIND)
+	{
+	  /* Increase the estimation. */
+	  flags &= ~_MU_MIMEHDR_INCR_CIND;
+	  cind++;
+	}
+      
+      res = 0; /* Indicate success */
       
       /* Prepare P for the next iteration */
       p = e;
diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index bf23b7e..540f80e 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -92,7 +92,7 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
      }                                           \
  } while (0) 
   
-  if (!tocode || !input)
+  if (!input)
     return EINVAL;
   if (!ptostr)
     return MU_ERR_OUT_PTR_NULL;


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 08 06:30:25 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1Nzp0C-0001J1-VD
	for mharc-commit-mailutils@gnu.org; Thu, 08 Apr 2010 06:30:25 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1Nzp0B-0001IJ-9P
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 06:30:23 -0400
Received: from [140.186.70.92] (port=50749 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Nzp09-0001HK-O2
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 06:30:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzp06-0005Ed-I3
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 06:30:21 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:41567
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzp06-0005EZ-GI
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 06:30:18 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzp06-0000DM-46
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 10:30:18 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzp02-0004Wo-GU
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 10:30:17 +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: 7287e840118d680efe1795e053500c999a950ade
X-Git-Newrev: d1b1cba265616c7b48948c7f27d4a15f335fd6ae
Message-Id: <E1Nzp02-0004Wo-GU@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 08 Apr 2010 10:30:15 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-62-gd1b1cba
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: Thu, 08 Apr 2010 10:30:23 -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=d1b1cba265616c7b48948c7f27d4a15f335fd6ae

The branch, master has been updated
       via  d1b1cba265616c7b48948c7f27d4a15f335fd6ae (commit)
      from  7287e840118d680efe1795e053500c999a950ade (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 d1b1cba265616c7b48948c7f27d4a15f335fd6ae
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 8 13:29:31 2010 +0300

    Bugfixes.
    
    * mailbox/mimehdr.c (_header_get_param): If buf is NULL
    on entry, make sure it alwaus points to allocated memory
    afterwards.
    
    * examples/mimetest.c (charset): New variable.
    (main): New command line option -c.
    (message_display_parts): Use mu_message_aget_decoded_attachment_name.
    Pass fname to mu_message_save_attachment.

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

Summary of changes:
 examples/mimetest.c |   26 ++++++++++++++++++++++----
 mailbox/mimehdr.c   |    2 +-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/examples/mimetest.c b/examples/mimetest.c
index c42dc44..53ae377 100644
--- a/examples/mimetest.c
+++ b/examples/mimetest.c
@@ -35,6 +35,7 @@ void message_display_parts(mu_message_t msg, int indent);
 
 const char *from;
 const char *subject;
+const char *charset = "UTF-8";
 int print_attachments;
 int indent_level = 4;
 
@@ -72,7 +73,23 @@ main (int argc, char **argv)
       else if (strcmp (argv[i], "-p") == 0)
         print_attachments = 1;
       else if (strcmp (argv[i], "-i") == 0)
-        indent_level = strtoul (argv[++i], NULL, 0);
+	{
+	  if (++i == argc)
+	    {
+	      mu_error ("-i requires argument");
+	      exit (1);
+	    }
+	  indent_level = strtoul (argv[i], NULL, 0);
+	}
+      else if (strcmp (argv[i], "-c") == 0)
+	{
+	  if (++i == argc)
+	    {
+	      mu_error ("-c requires argument");
+	      exit (1);
+	    }
+	  charset = argv[i];
+	}
       else
         break;
     }
@@ -242,8 +259,9 @@ message_display_parts (mu_message_t msg, int indent)
         {
           /* Save the attachements.  */
           char *fname = NULL;
-	  /* FIXME: CS/Lang info is ignored */
-          mu_message_aget_attachment_name (part, &fname, NULL);
+
+          mu_message_aget_decoded_attachment_name (part, charset,
+						   &fname, NULL);
           if (fname == NULL)
             fname = mu_tempname (NULL);
 
@@ -251,7 +269,7 @@ message_display_parts (mu_message_t msg, int indent)
                   fname);
           printf ("%*.*sBegin\n", indent, indent, "");
           /*FIXME: What is the 'data' argument for? */
-          mu_message_save_attachment (part, NULL, NULL);
+          mu_message_save_attachment (part, fname, NULL);
           if (print_attachments)
             print_file (fname, indent);
           free (fname);
diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
index 0c04c23..2e09903 100644
--- a/mailbox/mimehdr.c
+++ b/mailbox/mimehdr.c
@@ -276,7 +276,7 @@ _header_get_param (const char *field_body,
 		  res = ENOMEM;
 		  break;
 		}
-	      mem = newmem;
+	      buf = mem = newmem;
 	    }
 	}
 


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 08 07:36:03 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1Nzq1i-0002kp-Tg
	for mharc-commit-mailutils@gnu.org; Thu, 08 Apr 2010 07:36:02 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1Nzq1h-0002kB-0x
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 07:36:01 -0400
Received: from [140.186.70.92] (port=56885 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Nzq1U-0002Um-Md
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 07:36:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzprh-0003lU-BM
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 07:25:46 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:43913
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzprh-0003lP-6c
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 07:25:41 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzprg-0000sE-Lq
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 11:25:40 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzprg-0000pB-4n
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 11:25:40 +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: d1b1cba265616c7b48948c7f27d4a15f335fd6ae
X-Git-Newrev: d8ab03b03566831cb5dfe8caf4a1e1b77106a342
Message-Id: <E1Nzprg-0000pB-4n@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 08 Apr 2010 11:25:40 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-63-gd8ab03b
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: Thu, 08 Apr 2010 11:36:01 -0000

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

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

The branch, master has been updated
       via  d8ab03b03566831cb5dfe8caf4a1e1b77106a342 (commit)
      from  d1b1cba265616c7b48948c7f27d4a15f335fd6ae (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 d8ab03b03566831cb5dfe8caf4a1e1b77106a342
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 8 14:25:20 2010 +0300

    Bugfix in mu_rfc2047_decode.
    
    * mailbox/rfc2047.c (mu_rfc2047_decode): Use temporary buffer
    for reading from the filter stream, to avoid preliminary breaking
    from the read loop when end of the buffer is reached. Realloc the
    buffer as neccessary.

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

Summary of changes:
 mailbox/rfc2047.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index 540f80e..77d02e5 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -117,7 +117,8 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
 	  const char *filter_type = NULL;
 	  size_t nbytes = 0, size;
 	  const char *sp = fromstr + 2;
-
+	  char tmp[128];
+	  
 	  fromcode = getword (&sp, '?');
 	  encoding_type = getword (&sp, '?');
 	  encoded_text = getword (&sp, '?');
@@ -164,11 +165,14 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
 	  if (status != 0)
 	    break;
 
-	  while (mu_stream_sequential_read (filter, buffer + bufpos,
-					 bufsize - bufpos,
-					 &nbytes) == 0
+	  while (mu_stream_sequential_read (filter, tmp, sizeof (tmp),
+					    &nbytes) == 0
 		 && nbytes)
-	    bufpos += nbytes;
+	    {
+	      CHKBUF (nbytes);
+	      memcpy (buffer + bufpos, tmp, nbytes);
+	      bufpos += nbytes;
+	    }
 
 	  mu_stream_close (filter);
 	  mu_stream_destroy (&filter, mu_stream_get_owner (filter));


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 08 11:40:25 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1NztqD-0006Gd-1P
	for mharc-commit-mailutils@gnu.org; Thu, 08 Apr 2010 11:40:25 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NztqB-0006Fr-9m
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 11:40:23 -0400
Received: from [140.186.70.92] (port=34314 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Nztq9-0006FS-Gn
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 11:40:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nztq8-0001Lz-8T
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 11:40:21 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:44403
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nztq8-0001Lt-5r
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 11:40:20 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nztq7-0003y8-KX
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 15:40:19 +0000
Received: from polak by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nztpw-0003mg-5Y
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 15:40:19 +0000
From: "Wojciech Polak" <polak@gnu.org>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d8ab03b03566831cb5dfe8caf4a1e1b77106a342
X-Git-Newrev: 1a374c8cbea21dabe2f7db123a559576531238db
Message-Id: <E1Nztpw-0003mg-5Y@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 08 Apr 2010 15:40:19 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-64-g1a374c8
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: Thu, 08 Apr 2010 15:40:23 -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=1a374c8cbea21dabe2f7db123a559576531238db

The branch, master has been updated
       via  1a374c8cbea21dabe2f7db123a559576531238db (commit)
      from  d8ab03b03566831cb5dfe8caf4a1e1b77106a342 (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 1a374c8cbea21dabe2f7db123a559576531238db
Author: Wojciech Polak <polak@gnu.org>
Date:   Thu Apr 8 17:34:49 2010 +0200

    Reflect recent RFC compatibility changes in Python/C++.
    
    * examples/python/mimetest.py: Update.
    * include/mailutils/cpp/message.h (get_attachment_name): Overload.
    * libmu_cpp/message.cc (Message::get_attachment_name): Overload.
    * python/libmu_py/message.c (api_message_get_attachment_name): Update.
    * python/mailutils/message.py (Message.get_attachment_name):
    Add optional charset parameter. Return (name, lang) tuple.

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

Summary of changes:
 examples/python/mimetest.py     |    2 +-
 include/mailutils/cpp/message.h |    2 ++
 libmu_cpp/message.cc            |   21 +++++++++++++++++++--
 python/libmu_py/message.c       |   20 +++++++++++++-------
 python/mailutils/message.py     |    6 +++---
 5 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/examples/python/mimetest.py b/examples/python/mimetest.py
index c14d727..471a052 100644
--- a/examples/python/mimetest.py
+++ b/examples/python/mimetest.py
@@ -90,7 +90,7 @@ def message_display_parts (msg, indent):
       else:
           # Save the attachements.
           try:
-              fname = part.get_attachment_name ()
+              fname, lang = part.get_attachment_name ()
 	  except:
               fname = util.tempname ()
 
diff --git a/include/mailutils/cpp/message.h b/include/mailutils/cpp/message.h
index 19f076d..bdd50af 100644
--- a/include/mailutils/cpp/message.h
+++ b/include/mailutils/cpp/message.h
@@ -68,6 +68,8 @@ class Message
   void save_attachment (const std::string& filename);
   Message& unencapsulate ();
   std::string get_attachment_name ();
+  std::string get_attachment_name (const std::string& charset,
+				   char* lang=NULL);
 };
 
 }
diff --git a/libmu_cpp/message.cc b/libmu_cpp/message.cc
index 21f3ec6..a023600 100644
--- a/libmu_cpp/message.cc
+++ b/libmu_cpp/message.cc
@@ -224,8 +224,25 @@ Message :: get_attachment_name ()
   char *c_name;
   std::string name;
 
-  /* FIXME: CS/Lang info is ignored */
-  int status = mu_message_aget_attachment_name (msg, &c_name, NULL);
+  int status = mu_message_aget_decoded_attachment_name (msg, NULL, &c_name,
+							NULL);
+  if (status)
+    throw Exception ("Message::get_attachment_name", status);
+  if (c_name) {
+    name = c_name;
+    free (c_name);
+  }
+  return name;
+}
+
+std::string
+Message :: get_attachment_name (const std::string& charset, char *lang)
+{
+  char *c_name;
+  std::string name;
+
+  int status = mu_message_aget_decoded_attachment_name (msg, charset.c_str (),
+							&c_name, &lang);
   if (status)
     throw Exception ("Message::get_attachment_name", status);
   if (c_name) {
diff --git a/python/libmu_py/message.c b/python/libmu_py/message.c
index fc71cbf..58f9c5b 100644
--- a/python/libmu_py/message.c
+++ b/python/libmu_py/message.c
@@ -282,14 +282,22 @@ api_message_get_attachment_name (PyObject *self, PyObject *args)
 {
   int status;
   char *name = NULL;
+  char *charset = NULL;
+  char *lang = NULL;
+  PyObject *py_ret;
   PyMessage *py_msg;
 
-  if (!PyArg_ParseTuple (args, "O!", &PyMessageType, &py_msg))
+  if (!PyArg_ParseTuple (args, "O!|z", &PyMessageType, &py_msg, &charset))
     return NULL;
 
-  /* FIXME: CS/Lang info is ignored */
-  status = mu_message_aget_attachment_name (py_msg->msg, &name, NULL);
-  return status_object (status, PyString_FromString (name ? name : ""));
+  status = mu_message_aget_decoded_attachment_name (py_msg->msg, charset,
+						    &name, &lang);
+
+  py_ret = PyTuple_New (3);
+  PyTuple_SetItem (py_ret, 0, PyInt_FromLong (status));
+  PyTuple_SetItem (py_ret, 1, PyString_FromString (name ? name : ""));
+  PyTuple_SetItem (py_ret, 2, lang ? PyString_FromString (lang) : Py_None);
+  return _ro (py_ret);
 }
 
 static PyObject *
@@ -314,12 +322,10 @@ static PyObject *
 api_message_unencapsulate (PyObject *self, PyObject *args)
 {
   int status;
-  char *filename = NULL;
   PyMessage *py_msg;
   PyMessage *py_unen = PyMessage_NEW ();
 
-  if (!PyArg_ParseTuple (args, "O!|s", &PyMessageType, &py_msg,
-			 &filename))
+  if (!PyArg_ParseTuple (args, "O!", &PyMessageType, &py_msg))
     return NULL;
 
   Py_INCREF (py_unen);
diff --git a/python/mailutils/message.py b/python/mailutils/message.py
index 0f4744a..89aa984 100644
--- a/python/mailutils/message.py
+++ b/python/mailutils/message.py
@@ -138,11 +138,11 @@ class Message:
             raise MessageError (status)
         return uidl
 
-    def get_attachment_name (self):
-        status, name = message.get_attachment_name (self.msg)
+    def get_attachment_name (self, charset=None):
+        status, name, lang = message.get_attachment_name (self.msg, charset)
         if status:
             raise MessageError (status)
-        return name
+        return name, lang
 
     def save_attachment (self, filename = ''):
         status = message.save_attachment (self.msg, filename)


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 08 16:13:56 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1Nzy6t-0007Fc-Vh
	for mharc-commit-mailutils@gnu.org; Thu, 08 Apr 2010 16:13:56 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1Nzy6r-0007F8-Po
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 16:13:53 -0400
Received: from [140.186.70.92] (port=43872 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Nzy6n-0007Ek-0p
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 16:13:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzy6k-0003vo-7b
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 16:13:48 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:46228
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzy6k-0003vU-53
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 16:13:46 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzy6j-0007J7-BC
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 20:13:45 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1Nzy6j-0004av-86
	for commit-mailutils@gnu.org; Thu, 08 Apr 2010 20:13:45 +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: 1a374c8cbea21dabe2f7db123a559576531238db
X-Git-Newrev: 787121995cef1f77d279df9b70a9eb1f4fb35325
Message-Id: <E1Nzy6j-0004av-86@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 08 Apr 2010 20:13:45 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-66-g7871219
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: Thu, 08 Apr 2010 20:13:54 -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=787121995cef1f77d279df9b70a9eb1f4fb35325

The branch, master has been updated
       via  787121995cef1f77d279df9b70a9eb1f4fb35325 (commit)
       via  d02e8bf4ee35f5b1f81208b56b545e1f2d6ac2a9 (commit)
      from  1a374c8cbea21dabe2f7db123a559576531238db (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 787121995cef1f77d279df9b70a9eb1f4fb35325
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 8 23:13:38 2010 +0300

    Fix all FIXMEs from b2c1b1ff.  Revise attachment API.
    
    * include/mailutils/message.h (mu_message_save_attachment)
    (mu_message_encapsulate, mu_message_unencapsulate): Change type
    of the last argument.
    (mu_mime_io_buffer_create,mu_mime_io_buffer_destroy)
    (mu_mime_io_buffer_set_size,mu_mime_io_buffer_get_size)
    (mu_mime_io_buffer_set_charset,mu_mime_io_buffer_sget_charset)
    (mu_mime_io_buffer_aget_charset): New prototypes.
    (mu_mimehdr_get_disp,mu_mimehdr_aget_disp): Remove unneeded
    parameter.
    * include/mailutils/types.hin (mu_mime_io_buffer_t): New type.
    * mailbox/attachment.c (_msg_info): Rename structure to
    _mu_mime_io_buffer.
    <header_buf,header_len,mu_header_size>: Remove unreferenced members.
    <refcnt,bufsize,charset>: New members.
    <ioffset,ooffset>: Change type to size_t.
    (mu_mime_io_buffer_create,mu_mime_io_buffer_destroy)
    (mu_mime_io_buffer_set_size,mu_mime_io_buffer_get_size)
    (mu_mime_io_buffer_set_charset,mu_mime_io_buffer_sget_charset)
    (mu_mime_io_buffer_aget_charset): New functions.
    (mu_message_save_attachment)
    (mu_message_encapsulate, mu_message_unencapsulate): Take
    mu_mime_io_buffer_t as the last argument.
    * mailbox/mimehdr.c (mu_mimehdr_get_disp): Remove unneeded
    parameter.
    (mu_mimehdr_aget_disp): Remove unneeded parameter. Store
    return value into pvalue.
    
    * examples/mimetest.c (message_display_parts): Use
    mu_mimehdr_aget_disp and mu_mime_io_buffer_* functions.
    * mailbox/testsuite/Mime: Update.
    
    * mh/mhn.c (options, opt_handler): New option --charset.
    (store_handler): Use mu_message_aget_decoded_attachment_name.

commit d02e8bf4ee35f5b1f81208b56b545e1f2d6ac2a9
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 8 14:37:40 2010 +0300

    Minor change.
    
    * mailbox/rfc2047.c: Minor style fix.

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

Summary of changes:
 examples/mimetest.c         |   59 ++++++++-----
 include/mailutils/message.h |   28 +++++--
 include/mailutils/types.hin |    1 +
 mailbox/attachment.c        |  203 +++++++++++++++++++++++++++++--------------
 mailbox/mimehdr.c           |    6 +-
 mailbox/rfc2047.c           |   14 ++--
 mailbox/testsuite/Mime      |   20 ++--
 mh/mh_getopt.h              |    3 +-
 mh/mhn.c                    |   31 +++++--
 9 files changed, 242 insertions(+), 123 deletions(-)

diff --git a/examples/mimetest.c b/examples/mimetest.c
index 53ae377..bca97af 100644
--- a/examples/mimetest.c
+++ b/examples/mimetest.c
@@ -35,7 +35,7 @@ void message_display_parts(mu_message_t msg, int indent);
 
 const char *from;
 const char *subject;
-const char *charset = "UTF-8";
+const char *charset;
 int print_attachments;
 int indent_level = 4;
 
@@ -180,8 +180,6 @@ message_display_parts (mu_message_t msg, int indent)
   size_t nparts, nsubparts;
   mu_message_t part;
   mu_header_t hdr;
-  const char *type;
-  const char *encoding;
   mu_stream_t str;
   mu_body_t body;
   int offset, ismulti;
@@ -200,24 +198,34 @@ message_display_parts (mu_message_t msg, int indent)
   for (j = 1; j <= nparts; j++)
     {
       int status;
+      const char *hvalue;
+      char *type = NULL;
+      const char *encoding = "";
+
       MU_ASSERT (mu_message_get_part (msg, j, &part));
       MU_ASSERT (mu_message_get_header (part, &hdr));
-      status = mu_header_sget_value (hdr, MU_HEADER_CONTENT_TYPE, &type);
+      status = mu_header_sget_value (hdr, MU_HEADER_CONTENT_TYPE,
+				     &hvalue);
       if (status == MU_ERR_NOENT)
-	type = "";
+	/* nothing */;
       else if (status != 0)
+	mu_error ("Cannot get header value: %s", mu_strerror (status));
+      else
 	{
-	  type = "";
-	  mu_error ("Cannot get header value: %s", mu_strerror (status));
+	  status = mu_mimehdr_aget_disp (hvalue, &type);
+	  if (status)
+	    mu_error ("Cannot extract content type field: %s",
+		      mu_strerror (status));
 	}
-      printf ("%*.*sType of part %d = %s\n", indent, indent, "", j, type);
+      printf ("%*.*sType of part %d = %s\n", indent, indent, "",
+	      j, type ? type : "");
       print_message_part_sizes (part, indent);
       if (mu_header_sget_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING,
 				&encoding))
 	encoding = "";
       ismulti = 0;
-      if ((type[0]
-           && mu_c_strncasecmp (type, "message/rfc822", strlen (type)) == 0)
+      if ((type
+           && mu_c_strcasecmp (type, "message/rfc822") == 0)
           || (mu_message_is_multipart (part, &ismulti) == 0 && ismulti))
         {
           if (!ismulti)
@@ -232,23 +240,21 @@ message_display_parts (mu_message_t msg, int indent)
                   indent, indent, "", from, subject);
           printf ("%*.*sBegin\n", indent, indent, "");
           MU_ASSERT (mu_message_get_num_parts (part, &nsubparts));
-          message_display_parts (part, indent+indent_level);
+          message_display_parts (part, indent + indent_level);
           mu_message_destroy (&part, NULL);
         }
-      else if (type[0] == '\0'
-               || (mu_c_strncasecmp (type, "text/plain", strlen ("text/plain")) ==
-                   0)
-               || (mu_c_strncasecmp (type, "text/html", strlen ("text/html")) ==
-                   0))
-        {
-          printf ("%*.*sText Message\n", indent, indent, "");
+      else if (!type
+               || (mu_c_strcasecmp (type, "text/plain") == 0)
+               || (mu_c_strcasecmp (type, "text/html")) == 0)
+	{
+	  printf ("%*.*sText Message\n", indent, indent, "");
           printf ("%*.*sBegin\n", indent, indent, "");
           mu_message_get_body (part, &body);
           mu_body_get_stream (body, &str);
           mu_filter_create (&str, str, encoding, 0, 0);
           offset = 0;
-          while (mu_stream_readline (str, buf, sizeof (buf), offset, &nbytes) ==
-                 0 && nbytes)
+          while (mu_stream_readline (str, buf, sizeof (buf),
+				     offset, &nbytes) == 0 && nbytes)
             {
               printf ("%*.*s%s", indent, indent, "", buf);
               offset += nbytes;
@@ -268,13 +274,22 @@ message_display_parts (mu_message_t msg, int indent)
           printf ("%*.*sAttachment - saving [%s]\n", indent, indent, "",
                   fname);
           printf ("%*.*sBegin\n", indent, indent, "");
-          /*FIXME: What is the 'data' argument for? */
-          mu_message_save_attachment (part, fname, NULL);
+          if (charset)
+	    {
+	      mu_mime_io_buffer_t info;
+	      mu_mime_io_buffer_create (&info);
+	      mu_mime_io_buffer_set_charset (info, charset);
+	      MU_ASSERT (mu_message_save_attachment (part, NULL, info));
+	      mu_mime_io_buffer_destroy (&info);
+	    }
+	  else
+	    MU_ASSERT (mu_message_save_attachment (part, fname, NULL));
           if (print_attachments)
             print_file (fname, indent);
           free (fname);
         }
       printf ("\n%*.*sEnd\n", indent, indent, "");
+      free (type);
     }
 }
 
diff --git a/include/mailutils/message.h b/include/mailutils/message.h
index 3ff2588..9ca5703 100644
--- a/include/mailutils/message.h
+++ b/include/mailutils/message.h
@@ -113,21 +113,35 @@ extern int mu_message_create_attachment (const char *content_type,
 					 const char *filename,
 					 mu_message_t *newmsg);
 extern int mu_message_save_attachment (mu_message_t msg,
-				       const char *filename, void **data);
+				       const char *filename,
+				       mu_mime_io_buffer_t buf);
 extern int mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg,
-				   void **data);
+				   mu_mime_io_buffer_t buf);
 extern int mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
-				     void **data);
+				     mu_mime_io_buffer_t buf);
 
+extern int mu_mime_io_buffer_create (mu_mime_io_buffer_t *pinfo);
+extern void mu_mime_io_buffer_destroy (mu_mime_io_buffer_t *pinfo);
+  
+extern void mu_mime_io_buffer_set_size (mu_mime_io_buffer_t info, size_t size);
+extern void mu_mime_io_buffer_get_size (mu_mime_io_buffer_t info,
+					size_t *psize);
+extern int mu_mime_io_buffer_set_charset (mu_mime_io_buffer_t info,
+					  const char *charset);
+extern void mu_mime_io_buffer_sget_charset (mu_mime_io_buffer_t info,
+					    const char **charset);
+extern int mu_mime_io_buffer_aget_charset (mu_mime_io_buffer_t info,
+					   const char **charset);
+
+  
 /* Bit values for *pflags in functions below */
 #define MU_MIMEHDR_MULTILINE 0x01  /* Parameter was multiline */
 #define MU_MIMEHDR_CSINFO    0x02  /* Parameter contains charset/language
 				      info */
 
-extern int mu_mimehdr_get_disp (const char *str, const char *param,
-				char *buf, size_t bufsz, size_t *retsz);
-extern int mu_mimehdr_aget_disp (const char *str, const char *param,
-				char **pvalue);
+extern int mu_mimehdr_get_disp (const char *str, char *buf, size_t bufsz,
+				size_t *retsz);
+extern int mu_mimehdr_aget_disp (const char *str, char **pvalue);
 extern int mu_mimehdr_get_param (const char *str, const char *param,
 				 char *buf, size_t bufsz, size_t *retsz,
 				 int *pflags);
diff --git a/include/mailutils/types.hin b/include/mailutils/types.hin
index 8fa1983..019e66f 100644
--- a/include/mailutils/types.hin
+++ b/include/mailutils/types.hin
@@ -113,6 +113,7 @@ typedef struct _mu_m_server *mu_m_server_t;
 typedef struct _mu_opool *mu_opool_t;
 typedef struct _mu_progmailer *mu_progmailer_t;
 typedef struct _mu_secret *mu_secret_t;
+typedef struct _mu_mime_io_buffer *mu_mime_io_buffer_t;
   
 #define MU_FOLDER_ATTRIBUTE_DIRECTORY 0x001
 #define MU_FOLDER_ATTRIBUTE_FILE      0x002
diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 9ef1455..26430fc 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -47,17 +47,17 @@
 
 #define BUF_SIZE	2048
 
-struct _msg_info
+struct _mu_mime_io_buffer
 {
+  unsigned int refcnt;
   char *buf;
+  size_t bufsize;
   size_t nbytes;
-  char *header_buf;
-  int header_len;
-  int mu_header_size;
+  char *charset;
   mu_header_t hdr;
   mu_message_t msg;
-  int ioffset;
-  int ooffset;
+  size_t ioffset;
+  size_t ooffset;
   mu_stream_t stream;	/* output file/decoding stream for saving attachment */
   mu_stream_t fstream;	/* output file stream for saving attachment */
 };
@@ -139,58 +139,131 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
   return ret;
 }
 
+int
+mu_mime_io_buffer_create (mu_mime_io_buffer_t *pinfo)
+{
+  mu_mime_io_buffer_t info;
+  
+  if ((info = calloc (1, sizeof (*info))) == NULL)
+    return ENOMEM;
+  info->refcnt = 1;
+  info->bufsize = BUF_SIZE;
+  *pinfo = info;
+  return 0;
+}
 
-static int
-_attachment_setup (struct _msg_info **info, mu_message_t msg,
-		   mu_stream_t *stream, void **data)
+void
+mu_mime_io_buffer_set_size (mu_mime_io_buffer_t info, size_t size)
 {
-  int sfl, ret;
-  mu_body_t body;
+  info->bufsize = size;
+}
 
-  if ((ret = mu_message_get_body (msg, &body)) != 0 ||
-      (ret = mu_body_get_stream (body, stream)) != 0)
-    return ret;
-  mu_stream_get_flags (*stream, &sfl);
-  if (data == NULL && (sfl & MU_STREAM_NONBLOCK))
-    return EINVAL;
-  if (data)
-    *info = *data;
-  if (*info == NULL)
-    {
-      if ((*info = calloc (1, sizeof (struct _msg_info))) == NULL)
-	return ENOMEM;
-    }
-  if (((*info)->buf = malloc (BUF_SIZE)) == NULL)
+void
+mu_mime_io_buffer_get_size (mu_mime_io_buffer_t info, size_t *psize)
+{
+  *psize = info->bufsize;
+}
+
+int
+mu_mime_io_buffer_set_charset (mu_mime_io_buffer_t info, const char *charset)
+{
+  char *cp = strdup (charset);
+  if (!cp)
+    return ENOMEM;
+  free (info->charset);
+  info->charset = cp;
+  return 0;
+}
+
+void
+mu_mime_io_buffer_sget_charset (mu_mime_io_buffer_t info, const char **charset)
+{
+  *charset = info->charset;
+}
+
+int
+mu_mime_io_buffer_aget_charset (mu_mime_io_buffer_t info, const char **charset)
+{
+  *charset = strdup (info->charset);
+  if (!charset)
+    return ENOMEM;
+  return 0;
+}
+
+void
+mu_mime_io_buffer_destroy (mu_mime_io_buffer_t *pinfo)
+{
+  if (pinfo && *pinfo)
     {
-      free (*info);
-      return ENOMEM;
+      mu_mime_io_buffer_t info = *pinfo;
+      free (info->charset);
+      free (info->buf);
+      free (info);
+      *pinfo = NULL;
     }
-  return 0;
 }
 
 static void
-_attachment_free (struct _msg_info *info, int free_message)
+_attachment_free (struct _mu_mime_io_buffer *info, int free_message)
 {
-  if (info->buf)
-    free (info->buf);
-  if (info->header_buf)
-    free (info->header_buf);
   if (free_message)
     {
       if (info->msg)
-	mu_message_destroy (&(info->msg), NULL);
+	mu_message_destroy (&info->msg, NULL);
       else if (info->hdr)
-	mu_header_destroy (&(info->hdr), NULL);
+	mu_header_destroy (&info->hdr, NULL);
+    }
+  info->msg = NULL;
+  info->hdr = NULL;
+  info->ioffset = 0;
+  info->ooffset = 0;
+  info->stream = NULL;
+  info->fstream = NULL;
+  if (--info->refcnt == 0)
+    {
+      free (info->charset);
+      free (info->buf);
+      free (info);
     }
-  free (info);
+}
+
+static int
+_attachment_setup (mu_mime_io_buffer_t *pinfo, mu_message_t msg,
+		   mu_stream_t *stream)
+{
+  int ret;
+  mu_body_t body;
+  mu_mime_io_buffer_t info;
+  
+  if ((ret = mu_message_get_body (msg, &body)) != 0 ||
+      (ret = mu_body_get_stream (body, stream)) != 0)
+    return ret;
+  if (*pinfo)
+    {
+      info = *pinfo;
+      info->refcnt++;
+    }
+  else
+    {
+      ret = mu_mime_io_buffer_create (&info);
+      if (ret)
+	return ret;
+    }
+  
+  if (!info->buf && ((info->buf = malloc (info->bufsize)) == NULL))
+    {
+      _attachment_free (info, 0);
+      return ENOMEM;
+    }
+  *pinfo = info;
+  return 0;
 }
 
 int
 mu_message_save_attachment (mu_message_t msg, const char *filename,
-			    void **data)
+			    mu_mime_io_buffer_t info)
 {
   mu_stream_t istream;
-  struct _msg_info *info = NULL;
   int ret;
   size_t size;
   size_t nbytes;
@@ -201,15 +274,15 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
   if (msg == NULL)
     return EINVAL;
 
-  if ((ret = _attachment_setup (&info, msg, &istream, data)) != 0)
+  if ((ret = _attachment_setup (&info, msg, &istream)) != 0)
     return ret;
 
   if (ret == 0 && (ret = mu_message_get_header (msg, &hdr)) == 0)
     {
       if (filename == NULL)
 	{
-	  /* FIXME: Charset info is ignored */
-	  ret = mu_message_aget_attachment_name (msg, &partname, NULL);
+	  ret = mu_message_aget_decoded_attachment_name (msg, info->charset,
+							 &partname, NULL);
 	  if (partname)
 	    fname = partname;
 	}
@@ -248,12 +321,12 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
   if (info->stream && istream)
     {
       if (info->nbytes)
-	memmove (info->buf, info->buf + (BUF_SIZE - info->nbytes),
+	memmove (info->buf, info->buf + (info->bufsize - info->nbytes),
 		 info->nbytes);
       while ((ret == 0 && info->nbytes)
 	     ||
 	     ((ret =
-	       mu_stream_read (info->stream, info->buf, BUF_SIZE,
+	       mu_stream_read (info->stream, info->buf, info->bufsize,
 			       info->ioffset, &info->nbytes)) == 0
 	      && info->nbytes))
 	{
@@ -274,9 +347,10 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
       mu_stream_close (info->fstream);
       mu_stream_destroy (&info->stream, NULL);
       mu_stream_destroy (&info->fstream, NULL);
-      _attachment_free (info, ret);
     }
 
+  _attachment_free (info, ret); /* FIXME: or 0? */
+  
   /* Free fname if we allocated it. */
   if (partname)
     free (partname);
@@ -285,11 +359,11 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
 }
 
 int
-mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg, void **data)
+mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg,
+			mu_mime_io_buffer_t info)
 {
   mu_stream_t istream, ostream;
   const char *header;
-  struct _msg_info *info = NULL;
   int ret = 0;
   size_t nbytes;
   mu_body_t body;
@@ -299,16 +373,16 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg, void **data)
   if (newmsg == NULL)
     return MU_ERR_OUT_PTR_NULL;
 
-  if ((ret = _attachment_setup (&info, msg, &ostream, data)) != 0)
+  if ((ret = _attachment_setup (&info, msg, &ostream)) != 0)
     return ret;
 
   if (info->msg == NULL
-      && (ret = mu_message_create (&(info->msg), NULL)) == 0)
+      && (ret = mu_message_create (&info->msg, NULL)) == 0)
     {
       header =
 	"Content-Type: message/rfc822\nContent-Transfer-Encoding: 7bit\n\n";
       if ((ret =
-	   mu_header_create (&(info->hdr), header, strlen (header),
+	   mu_header_create (&info->hdr, header, strlen (header),
 			     msg)) == 0)
 	ret = mu_message_set_header (info->msg, info->hdr, NULL);
     }
@@ -318,12 +392,12 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg, void **data)
 	  (ret = mu_body_get_stream (body, &ostream)) == 0)
 	{
 	  if (info->nbytes)
-	    memmove (info->buf, info->buf + (BUF_SIZE - info->nbytes),
+	    memmove (info->buf, info->buf + (info->bufsize - info->nbytes),
 		     info->nbytes);
 	  while ((ret == 0 && info->nbytes)
 		 ||
 		 ((ret =
-		   mu_stream_read (istream, info->buf, BUF_SIZE,
+		   mu_stream_read (istream, info->buf, info->bufsize,
 				   info->ioffset, &info->nbytes)) == 0
 		  && info->nbytes))
 	    {
@@ -342,27 +416,27 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg, void **data)
     }
   if (ret == 0)
     *newmsg = info->msg;
-  if (ret != EAGAIN && info)
-    _attachment_free (info, ret);
+  _attachment_free (info, ret && ret != EAGAIN);
   return ret;
 }
 
+#define MESSAGE_RFC822_STR "message/rfc822"
+
 int
 mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
-			  void **data)
+			  mu_mime_io_buffer_t info)
 {
   size_t size, nbytes;
   int ret = 0;
   mu_header_t hdr;
   mu_stream_t istream, ostream;
-  struct _msg_info *info = NULL;
 
   if (msg == NULL)
     return EINVAL;
   if (newmsg == NULL)
     return MU_ERR_OUT_PTR_NULL;
 
-  if ((data == NULL || *data == NULL)
+  if (info == NULL /* FIXME: not needed? */
       && (ret = mu_message_get_header (msg, &hdr)) == 0)
     {
       mu_header_get_value (hdr, "Content-Type", NULL, 0, &size);
@@ -373,9 +447,8 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
 	    return ENOMEM;
 	  mu_header_get_value (hdr, "Content-Type", content_type, size + 1,
 			       0);
-	  ret =
-	    mu_c_strncasecmp (content_type, "message/rfc822",
-			      strlen ("message/rfc822"));
+	  ret = mu_c_strncasecmp (content_type, MESSAGE_RFC822_STR,
+				  sizeof (MESSAGE_RFC822_STR) - 1);
 	  free (content_type);
 	  if (ret != 0)
 	    return EINVAL;
@@ -383,20 +456,21 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
       else
 	return EINVAL;
     }
-  if ((ret = _attachment_setup (&info, msg, &istream, data)) != 0)
+  if ((ret = _attachment_setup (&info, msg, &istream)) != 0)
     return ret;
   if (info->msg == NULL)
-    ret = mu_message_create (&(info->msg), NULL);
+    ret = mu_message_create (&info->msg, NULL);
   if (ret == 0)
     {
       mu_message_get_stream (info->msg, &ostream);
       if (info->nbytes)
-	memmove (info->buf, info->buf + (BUF_SIZE - info->nbytes),
+	memmove (info->buf, info->buf + (info->bufsize - info->nbytes),
 		 info->nbytes);
       while ((ret == 0 && info->nbytes)
 	     ||
 	     ((ret =
-	       mu_stream_read (istream, info->buf, BUF_SIZE, info->ioffset,
+	       mu_stream_read (istream, info->buf,
+			       info->bufsize, info->ioffset,
 			       &info->nbytes)) == 0 && info->nbytes))
 	{
 	  info->ioffset += info->nbytes;
@@ -413,7 +487,6 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
     }
   if (ret == 0)
     *newmsg = info->msg;
-  if (ret != EAGAIN && info)
-    _attachment_free (info, ret);
+  _attachment_free (info, ret && ret != EAGAIN);
   return ret;
 }
diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
index 2e09903..cd38332 100644
--- a/mailbox/mimehdr.c
+++ b/mailbox/mimehdr.c
@@ -332,8 +332,7 @@ _header_get_param (const char *field_body,
    value, and `type/subtype' part, if it is a Content-Type value.
 */
 int
-mu_mimehdr_get_disp (const char *str, const char *param,
-		     char *buf, size_t bufsz, size_t *retsz)
+mu_mimehdr_get_disp (const char *str, char *buf, size_t bufsz, size_t *retsz)
 {
   char *p = strchr (str, ';');
   size_t size;
@@ -350,7 +349,7 @@ mu_mimehdr_get_disp (const char *str, const char *param,
 
 /* Same as mu_mimehdr_get_disp, but allocates memory */
 int
-mu_mimehdr_aget_disp (const char *str, const char *param, char **pvalue)
+mu_mimehdr_aget_disp (const char *str, char **pvalue)
 {
   char *p = strchr (str, ';');
   size_t size;
@@ -363,6 +362,7 @@ mu_mimehdr_aget_disp (const char *str, const char *param, char **pvalue)
     return ENOMEM;
   memcpy (p, str, size);
   p[size] = 0;
+  *pvalue = p;
   return 0;
 }
 
diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index 77d02e5..ba11d58 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -192,18 +192,18 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
 	    {
 	      if (--run_count)
 		{
-		  CHKBUF(run_count);
+		  CHKBUF (run_count);
 		  memcpy (buffer + bufpos, fromstr - run_count, run_count);
 		  bufpos += run_count;
 		  run_count = 0;
 		}
-	      CHKBUF(1);
+	      CHKBUF (1);
 	      buffer[bufpos++] = *fromstr++;
 	    }
 	}
       else
 	{
-	  CHKBUF(1);
+	  CHKBUF (1);
 	  buffer[bufpos++] = *fromstr++;
 	}
     }
@@ -211,12 +211,12 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
   if (*fromstr)
     {
       size_t len = strlen (fromstr);
-      CHKBUF(len);
-      memcpy (buffer + bufpos, fromstr, strlen (fromstr));
-      bufpos += strlen (fromstr);
+      CHKBUF (len);
+      memcpy (buffer + bufpos, fromstr, len);
+      bufpos += len;
     }
 
-  CHKBUF(1);
+  CHKBUF (1);
   buffer[bufpos++] = 0;
   
   free (fromcode);
diff --git a/mailbox/testsuite/Mime b/mailbox/testsuite/Mime
index 07d046f..39cb238 100644
--- a/mailbox/testsuite/Mime
+++ b/mailbox/testsuite/Mime
@@ -83,7 +83,7 @@ From: Sergey Poznyakoff <gray@Mirddin.farlep.net>
 Subject: Simple MIME
 Number of parts in message - 2
 Total message size - 1626/42
-Type of part 1 = text/plain; name="msg.1"; charset="us-ascii"
+Type of part 1 = text/plain
 Message part size - 371/13: 141/4, 230/9
 Text Message
 Begin
@@ -98,7 +98,7 @@ And welcome little fishes in
 With gently smiling jaws!
 
 End
-Type of part 2 = application/octet-stream; name="msg.21"
+Type of part 2 = application/octet-stream
 Message part size - 645/11: 183/5, 462/6
 Attachment - saving [msg.21]
 Begin
@@ -119,7 +119,7 @@ From: Sergey Poznyakoff <gray@Mirddin.farlep.net>
 Subject: Nested MIME
 Number of parts in message - 2
 Total message size - 3484/84
-Type of part 1 = text/plain; name="msg.21"; charset="us-ascii"
+Type of part 1 = text/plain
 Message part size - 496/14: 155/4, 341/10
 Text Message
 Begin
@@ -135,11 +135,11 @@ Why, I do it again and again.'
 
 
 End
-Type of part 2 = multipart/mixed; boundary="----- =_aaaaaaaaaa1"
+Type of part 2 = multipart/mixed
 Message part size - 2378/52: 114/3, 2264/49
 Encapsulated message : 	
 Begin
-Type of part 1 = application/octet-stream; name="msg.22"
+Type of part 1 = application/octet-stream
 Message part size - 663/12: 184/5, 479/7
 Attachment - saving [msg.22]
 Begin
@@ -154,11 +154,11 @@ By the use of this ointment--one shilling the box--
 Allow me to sell you a couple?'
 
 End
-Type of part 2 = multipart/mixed; boundary="----- =_aaaaaaaaaa2"
+Type of part 2 = multipart/mixed
 Message part size - 1531/32: 114/3, 1417/29
 Encapsulated message : 	
 Begin
-Type of part 1 = application/octet-stream; name="msg.23"
+Type of part 1 = application/octet-stream
 Message part size - 668/12: 185/5, 483/7
 Attachment - saving [msg.23]
 Begin
@@ -173,7 +173,7 @@ And the muscular strength, which it gave to my jaw,
 Has lasted the rest of my life.'
 
 End
-Type of part 2 = application/octet-stream; name="msg.24"
+Type of part 2 = application/octet-stream
 Message part size - 679/12: 184/5, 495/7
 Attachment - saving [msg.24]
 Begin
@@ -197,13 +197,13 @@ From: Sergey Poznyakoff <gray@Mirddin.farlep.net>
 Subject: Empty MIME Parts
 Number of parts in message - 2
 Total message size - 914/27
-Type of part 1 = text/plain; name="empty"; charset="us-ascii"
+Type of part 1 = text/plain
 Message part size - 143/4: 143/4, 0/0
 Text Message
 Begin
 
 End
-Type of part 2 = text/plain; name="single.line"; charset="us-ascii"
+Type of part 2 = text/plain
 Message part size - 156/5: 155/4, 1/1
 Text Message
 Begin
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index 4815b12..bd26f83 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -55,7 +55,8 @@ enum mh_arg {
   ARG_BUILD,		
   ARG_CC,	        
   ARG_CFLAGS,		
-  ARG_CHANGECUR,		
+  ARG_CHANGECUR,
+  ARG_CHARSET,
   ARG_CHECK,
   ARG_CHUNKSIZE,
   ARG_CLEAR,		
diff --git a/mh/mhn.c b/mh/mhn.c
index db100f6..f37d63d 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -74,16 +74,18 @@ static struct argp_option options[] = {
   {"auto",         ARG_AUTO,         N_("BOOL"), OPTION_ARG_OPTIONAL,
    N_("use filenames from the content headers"), 31},
   {"noauto",       ARG_NOAUTO,       NULL, OPTION_HIDDEN, "", 31 },
-
+  {"charset",      ARG_CHARSET,      N_("NAME"), 0,
+   N_("use this charset to represent attachment file names"), 31},
+  
   {N_("Other options"),    0,  NULL, OPTION_DOC,  NULL, 40},
   {"part",         ARG_PART,         N_("PART"), 0,
    N_("limit the scope of the operation to the given part"), 41},
   {"type",         ARG_TYPE,         N_("CONTENT"), 0,
    N_("operate on message part with given multipart content"), 41 },
-  {"verbose",       ARG_VERBOSE,     N_("BOOL"), OPTION_ARG_OPTIONAL,
+  {"verbose",      ARG_VERBOSE,     N_("BOOL"), OPTION_ARG_OPTIONAL,
    N_("print additional information"), 41 },
-  {"noverbose",     ARG_NOVERBOSE,   NULL, OPTION_HIDDEN, "", 41 },
-  {"quiet",         ARG_QUIET, 0, 0,
+  {"noverbose",    ARG_NOVERBOSE,   NULL, OPTION_HIDDEN, "", 41 },
+  {"quiet",        ARG_QUIET, 0, 0,
    N_("be quiet")},
   {"license", ARG_LICENSE, 0,      0,
    N_("display software license"), -1},
@@ -144,6 +146,8 @@ static char *content_type;
 static char *content_subtype;
 static char *input_file;
 static int width = 80;
+static char *charset;  /* Charset for output file names.  NULL means
+			  no recoding is necessary. */
 
 static mh_msgset_t msgset;
 static mu_mailbox_t mbox;
@@ -397,6 +401,10 @@ opt_handler (int key, char *arg, struct argp_state *state)
       mh_license (argp_program_version);
       break;
 
+    case ARG_CHARSET:
+      charset = arg;
+      break;
+      
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -1589,14 +1597,21 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
   if (mode_options & OPT_AUTO)
     {
       char *val;
-
-      /* FIXME: Take into account CS/Lang info and recode the value
-	 if necessary */
-      if (mu_message_aget_attachment_name (msg, &val, NULL) == 0)
+      int rc = mu_message_aget_decoded_attachment_name (msg, charset,
+							&val, NULL);
+      if (rc == 0)
 	{
 	  name = normalize_path (dir, val);
 	  free (val);
 	}
+      else if (rc != MU_ERR_NOENT)
+	{
+	  char *pstr = msg_part_format (part);
+	  mu_diag_output (MU_DIAG_WARNING,
+			  _("%s: cannot decode attachment name: %s"),
+			  pstr, mu_strerror (rc));
+	  free (pstr);
+	}
     }
   
   if (!name)


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Mon Apr 12 09:28:27 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O1Jgh-0005qu-Hh
	for mharc-commit-mailutils@gnu.org; Mon, 12 Apr 2010 09:28:27 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O1Jgg-0005qi-Jq
	for commit-mailutils@gnu.org; Mon, 12 Apr 2010 09:28:26 -0400
Received: from [140.186.70.92] (port=38203 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O1Jgc-0005q0-SX
	for commit-mailutils@gnu.org; Mon, 12 Apr 2010 09:28:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1JgZ-00012B-Tx
	for commit-mailutils@gnu.org; Mon, 12 Apr 2010 09:28:22 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:54785
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1JgZ-000124-Qc
	for commit-mailutils@gnu.org; Mon, 12 Apr 2010 09:28:19 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1JgY-0004zD-W0
	for commit-mailutils@gnu.org; Mon, 12 Apr 2010 13:28:19 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1JgY-0002aL-2C
	for commit-mailutils@gnu.org; Mon, 12 Apr 2010 13:28:18 +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: 787121995cef1f77d279df9b70a9eb1f4fb35325
X-Git-Newrev: 49e121acc32a38b2d618cfd0544de349618c2bb1
Message-Id: <E1O1JgY-0002aL-2C@vcs-noshell.in.savannah.gnu.org>
Date: Mon, 12 Apr 2010 13:28:18 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-67-g49e121a
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: Mon, 12 Apr 2010 13:28:26 -0000

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

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=49e121acc32a38b2d618cfd0544de349618c2bb1

The branch, master has been updated
       via  49e121acc32a38b2d618cfd0544de349618c2bb1 (commit)
      from  787121995cef1f77d279df9b70a9eb1f4fb35325 (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 49e121acc32a38b2d618cfd0544de349618c2bb1
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Apr 12 16:28:41 2010 +0300

    Migrate Guile support to GINT.
    
    * gint: New module.
    * am/guile.m4: Remove.
    * mu-aux/guile-doc-snarf: Remove.
    * mu-aux/guile-doc-snarf.awk: Remove.
    * mu-aux/Makefile.am (EXTRA_DIST): Remove guile-doc-snarf,
    guile-doc-snarf.awk
    
    * Makefile.am: Add gint.
    * bootstrap.conf: Init gint submodule.
    * configure.ac: Rewrite Guile support using GINT_INIT.
    (AC_CONFIG_FILES): Add gint/Makefile.
    * guimb/scm/Makefile.am (sitedir): Change.
    * guimb/scm/Makefile.am: Likewise.
    * libmu_scm/Makefile.am: Include ../gint/gint.mk
    Adjust all variables.
    Remove unnecessary rules.
    * libmu_scm/mailutils.scm.in: Remove exports and includes.
    Remove obsolete code.
    * libmu_scm/mu_address.c: Use SCM_DEFINE_PUBLIC to declare public
    interfaces.
    * libmu_scm/mu_body.c: Likewise.
    * libmu_scm/mu_mailbox.c: Likewise.
    * libmu_scm/mu_message.c: Likewise.
    * libmu_scm/mu_mime.c: Likewise.
    * libmu_scm/mu_util.c: Likewise.
    * libmu_scm/mu_logger.c: Likewise.
    (mu_scm_logger_init): Make all constants public.
    * libmu_scm/mu_scm.c: Likewise.
    * libmu_scm/mu_guile.c: Use scm_c_catch instead of the
    obsolete scm_internal_lazy_catch.

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

Summary of changes:
 .gitmodules                |    3 +
 Makefile.am                |    4 +-
 am/guile.m4                |   85 ------------------------------------
 bootstrap.conf             |    3 +
 configure.ac               |   57 +++++++-----------------
 gint                       |    1 +
 guimb/scm/Makefile.am      |    2 +-
 libmu_scm/Makefile.am      |   54 +++--------------------
 libmu_scm/mailutils.scm.in |   64 +--------------------------
 libmu_scm/mu_address.c     |   14 +++---
 libmu_scm/mu_body.c        |    4 +-
 libmu_scm/mu_guile.c       |   14 +++---
 libmu_scm/mu_logger.c      |   11 +++--
 libmu_scm/mu_mailbox.c     |   28 ++++++------
 libmu_scm/mu_message.c     |   50 +++++++++++-----------
 libmu_scm/mu_mime.c        |   12 +++---
 libmu_scm/mu_scm.c         |   18 +++++---
 libmu_scm/mu_util.c        |    2 +-
 mu-aux/Makefile.am         |    2 -
 mu-aux/guile-doc-snarf     |   86 -------------------------------------
 mu-aux/guile-doc-snarf.awk |  102 --------------------------------------------
 21 files changed, 121 insertions(+), 495 deletions(-)
 create mode 100644 .gitmodules
 delete mode 100644 am/guile.m4
 create mode 160000 gint
 delete mode 100755 mu-aux/guile-doc-snarf
 delete mode 100644 mu-aux/guile-doc-snarf.awk

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..7c369d4
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "gint"]
+	path = gint
+	url = git://git.gnu.org.ua/gint.git
diff --git a/Makefile.am b/Makefile.am
index 0fc2e3c..f6f53a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,7 @@
 ##   Foundation, Inc.  51 Franklin Street, Fifth Floor, Boston, MA
 ##   02110-1301 USA
 
-ACLOCAL_AMFLAGS = -I m4 -I am
+ACLOCAL_AMFLAGS = -I m4 -I am -I gint
 
 if MU_COND_PYTHON
   PYTHON_DIR = python
@@ -81,6 +81,7 @@ if MU_COND_MIMEVIEW
 endif
 
 if MU_COND_LIBMU_SCM
+  GINT_DIR = gint
   LIBMU_SCM_DIR = libmu_scm
 endif
 
@@ -101,6 +102,7 @@ SUBDIRS = \
  libmu_argp\
  libmu_cfg\
  $(LIBMU_CPP_DIR)\
+ $(GINT_DIR)\
  $(LIBMU_SCM_DIR)\
  libmu_sieve\
  $(PYTHON_DIR)\
diff --git a/am/guile.m4 b/am/guile.m4
deleted file mode 100644
index 64b5cac..0000000
--- a/am/guile.m4
+++ /dev/null
@@ -1,85 +0,0 @@
-dnl This file is part of GNU mailutils.
-dnl Copyright (C) 2001, 2006, 2007, 2010 Free Software Foundation, Inc.
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 3 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software Foundation,
-dnl Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-dnl
-
-dnl MU_CHECK_GUILE(minversion, [act-if-found], [ac-if-not-found])
-dnl                    $1            $2               $3
-AC_DEFUN([MU_CHECK_GUILE],
-[
-  AS_VAR_SET([mu_cv_guile], [no])
-  AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $PATH)
-  if test "$GUILE_CONFIG" = no; then
-    m4_if($3,,[AC_MSG_ERROR(cannot find Guile)], [$3])
-  else
-    AC_SUBST(GUILE_INCLUDES)
-    AC_SUBST(GUILE_LIBS)
-    AC_SUBST(GUILE_VERSION)
-    AC_SUBST(GUILE_VERSION_NUMBER)
-  
-    GUILE_INCLUDES=`$GUILE_CONFIG compile`
-    GUILE_LIBS=`$GUILE_CONFIG link`
-    GUILE_VERSION=`($GUILE_CONFIG --version 2>&1; echo '')|sed 's/guile-config [[^0-9]]* \([[0-9]][[0-9.]]*\)$/\1/'`
-    VEX=`echo $GUILE_VERSION | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'`
-    GUILE_VERSION_NUMBER=`eval expr "$VEX"`
-
-    ifelse($1,,,[
-      VEX=`echo $1 | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'`
-      min=`eval expr "$VEX"`
-      if test $GUILE_VERSION_NUMBER -lt $min; then
-        m4_if($3,,
-	        [AC_MSG_ERROR([Guile version too old; required is at least ]$1)],
-	        [$3])
-      fi])
-
-    save_LIBS=$LIBS
-    save_CFLAGS=$CFLAGS
-    LIBS="$LIBS $GUILE_LIBS"
-    CFLAGS="$CFLAGS $GUILE_INCLUDES"
-    AC_TRY_LINK([#include <libguile.h>],
-                 m4_if([$1], , scm_shell(0, NULL);, [$1]),
-                [AS_VAR_SET([mu_cv_guile], $GUILE_VERSION)])
-    LIBS=$save_LIBS
-    CFLAGS=$save_CFLAGS
-  fi
-
-  if test $mu_cv_guile = no; then
-    GUILE_INCLUDES=
-    GUILE_LIBS=
-    GUILE_VERSION=
-    GUILE_VERSION_NUMBER=
-    m4_if($3,,[AC_MSG_ERROR(required library libguile not found)], [$3])
-  else
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libguile.h>]],
-                      [SCM_DEVAL_P = 1;
-                       SCM_BACKTRACE_P = 1;
-                       SCM_RECORD_POSITIONS_P = 1;
-                       SCM_RESET_DEBUG_MODE;])],
-                      [mu_cv_guile_debug=yes],
-                      [mu_cv_guile_debug=no])
-    if test $mu_cv_guile_debug = yes; then
-      AC_DEFINE_UNQUOTED(GUILE_DEBUG_MACROS, 1,
-                         [Define to 1 if SCM_DEVAL_P, SCM_BACKTRACE_P, SCM_RECORD_POSITIONS_P and SCM_RESET_DEBUG_MODE are defined])
-    fi
-    AC_CHECK_TYPES([scm_t_off],[],[],[#include <libguile.h>])
-    AC_DEFINE_UNQUOTED(GUILE_VERSION, "$GUILE_VERSION",
-                       [Guile version number])
-    AC_DEFINE_UNQUOTED(GUILE_VERSION_NUMBER, $GUILE_VERSION_NUMBER,
-                       [Guile version number: MAX*10 + MIN])
-    m4_if($2,,,[$2])
-  fi
-])     
-
diff --git a/bootstrap.conf b/bootstrap.conf
index f61b6d6..2537767 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -81,6 +81,9 @@ excluded_files='
     m4/visibility.m4
 '
 
+git submodule init || exit $?
+git submodule update || exit $?
+
 # Read local configuration file
 if [ -r .bootstrap ]; then
   echo "$0: Reading configuration file .bootstrap"
diff --git a/configure.ac b/configure.ac
index 29a7600..ad31075 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1073,51 +1073,27 @@ if test "$status_dbm" != no; then
 fi
 
 dnl Check for Guile
-AC_SUBST(GUILE_BINDIR)
-AC_SUBST(LIBMU_SCM)
-AC_SUBST(LIBMU_SCM_DEPS)
-AC_SUBST(MU_GUILE_SITE_DIR)
-AC_SUBST(MU_GUILE_SIEVE_MOD_DIR)
-AC_SUBST(MU_GUILE_SIEVE_MOD_DATA)
-
+AC_SUBST([GUILE_BINDIR])
+AC_SUBST([LIBMU_SCM])
+AC_SUBST([LIBMU_SCM_DEPS])
+AC_SUBST([MU_GUILE_SIEVE_MOD_DIR])
+AC_SUBST([MU_GUILE_SIEVE_MOD_DATA])
 if test "$useguile" != "no"; then
-  MU_CHECK_GUILE(1.8,
-         [useguile=yes
-   	  AC_DEFINE(WITH_GUILE,1,[Enable Guile support])
-          GUILE_BINDIR=`guile-config info bindir`
-          LIBMU_SCM=../libmu_scm/libmu_scm.la
-          LIBMU_SCM_DEPS='${MU_LIB_MBOX} ${MU_LIB_IMAP} ${MU_LIB_POP} ${MU_LIB_MH} ${MU_LIB_MAILDIR} ${MU_LIB_MAILER}'
-          MU_GUILE_SITE_DIR='$(GUILE_SITE)/$(PACKAGE)'
-          MU_GUILE_SIEVE_MOD_DIR='$(GUILE_SITE)/sieve-modules'
-          MU_GUILE_SIEVE_MOD_DATA='$(MU_GUILE_SIEVE_MOD_DATA_X)'
-  ],[useguile=no])
-
- if test "$useguile" = "yes"; then
-  AC_ARG_WITH([guiledir],
-           AC_HELP_STRING([--with-guiledir=DIR],
-                          [Specify the directory to install guile modules to]),
-           [case $withval in
-            /*)  GUILE_SITE=$withval;;
-            yes) GUILE_SITE=`$GUILE_CONFIG info pkgdatadir`/site;;
-            *)   AC_MSG_ERROR([Argument to --with-guiledir must be an absolute directory name]);;
-            esac],
-            [GUILE_SITE=`$GUILE_CONFIG info pkgdatadir`/site
-             pfx=$prefix
-             test "$pfx" = NONE && pfx=$ac_default_prefix
-             case $GUILE_SITE in
-             $pfx/*) ;; # OK
-             *)  AC_MSG_WARN([guile site directory "$GUILE_SITE" lies outside your current prefix ($pfx).])
-                 GUILE_SITE='$(pkgdatadir)/$(VERSION)/guile'
-                 AC_MSG_WARN([Falling back to ${GUILE_SITE} instead. Use --with-guiledir to force using site directory.])
-                 ;;
-             esac])
- fi 
+  GINT_INIT([gint],[1.8],
+	    [useguile=yes
+   	     AC_DEFINE([WITH_GUILE],1,[Enable Guile support])
+             GUILE_BINDIR=`guile-config info bindir`
+             LIBMU_SCM=../libmu_scm/libmu_scm.la
+             LIBMU_SCM_DEPS='${MU_LIB_MBOX} ${MU_LIB_IMAP} ${MU_LIB_POP} ${MU_LIB_MH} ${MU_LIB_MAILDIR} ${MU_LIB_MAILER}'
+             MU_GUILE_SIEVE_MOD_DIR='$(GUILE_SITE)/$(PACKAGE)/sieve-modules'
+             MU_GUILE_SIEVE_MOD_DATA='$(MU_GUILE_SIEVE_MOD_DATA_X)'
+             GINT_INCLUDES='${MU_APP_COMMON_INCLUDES}'
+             GINT_LDADD=../lib/libmuaux.la
+            ],[useguile=no])
 fi
 
 AM_CONDITIONAL([MU_COND_LIBMU_SCM],[test "$useguile" = "yes"])
 
-AC_SUBST(GUILE_SITE)
-
 dnl Check for Emacs site-lisp directory
 AM_PATH_LISPDIR
 
@@ -1353,6 +1329,7 @@ AC_CONFIG_FILES([
  examples/cpp/Makefile
  examples/python/Makefile
  examples/scheme/Makefile
+ gint/Makefile
  frm/Makefile
  frm/testsuite/Makefile
  guimb/Makefile
diff --git a/gint b/gint
new file mode 160000
index 0000000..c6a7620
--- /dev/null
+++ b/gint
@@ -0,0 +1 @@
+Subproject commit c6a7620deb7e3e139329e2daad31d4071f01b43b
diff --git a/guimb/scm/Makefile.am b/guimb/scm/Makefile.am
index bb014ff..68df43f 100644
--- a/guimb/scm/Makefile.am
+++ b/guimb/scm/Makefile.am
@@ -37,7 +37,7 @@ sieve.sed: Makefile
 
 CLEANFILES = sieve.scm sieve.sed
 
-sitedir=@MU_GUILE_SITE_DIR@
+sitedir=@GUILE_SITE@/$(PACKAGE)
 site_DATA=sieve-core.scm
 
 MU_GUILE_SIEVE_MOD_DATA_X=\
diff --git a/libmu_scm/Makefile.am b/libmu_scm/Makefile.am
index 92588ed..f317bba 100644
--- a/libmu_scm/Makefile.am
+++ b/libmu_scm/Makefile.am
@@ -18,7 +18,7 @@
 ##   Foundation, Inc.  51 Franklin Street, Fifth Floor, Boston, MA
 ##   02110-1301 USA
 
-INCLUDES = -I. @MU_LIB_COMMON_INCLUDES@ @GUILE_INCLUDES@ 
+INCLUDES = -I. @MU_LIB_COMMON_INCLUDES@
 
 lib_LTLIBRARIES=libmu_scm.la
 
@@ -51,10 +51,7 @@ libmu_scm_la_LIBADD = \
  ${MU_LIB_MAILUTILS}\
  @GUILE_LIBS@
 
-EXTRA_DIST=mailutils.scm mailutils.scm.in guile-procedures.texi guile-procedures.txt
-
-sitedir=@MU_GUILE_SITE_DIR@
-site_DATA=guile-procedures.txt mailutils.scm
+EXTRA_DIST=mailutils.scm mailutils.scm.in
 
 DOT_X_FILES=\
  mu_address.x\
@@ -78,55 +75,16 @@ DOT_DOC_FILES=\
  mu_scm.doc\
  mu_util.doc 
 
-BUILT_SOURCES=$(DOT_X_FILES) $(DOT_DOC_FILES) guile-procedures.texi
-
+CLEANFILES=
 DISTCLEANFILES=\
- $(DOT_X_FILES)\
- $(DOT_DOC_FILES)\
- guile-procedures.texi\
- guile-procedures.txt\
  mailutils.scm
 
-CLEANFILES=*.inc
-
-AM_CPPFLAGS=-DDATADIR=\"$(pkgdatadir)\"
-ETAGS_ARGS = --regex='/SCM_\(GLOBAL_\)?\(G?PROC\|G?PROC1\|SYMBOL\|VCELL\|CONST_LONG\).*\"\([^\"]\)*\"/\3/' \
-   --regex='/[ \t]*SCM_[G]?DEFINE1?[ \t]*(\([^,]*\),[^,]*/\1/'
-
-GUILE_DOC_SNARF=$(mu_aux_dir)/guile-doc-snarf
-
-SUFFIXES=.x .doc .inc .in
-
-.c.x:
-	$(AM_V_GEN)AWK=$(AWK) \
-	$(GUILE_DOC_SNARF) -o $@ \
-                           $< $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) 
-
-.c.doc:
-	$(AM_V_GEN)AWK=$(AWK) \
-	$(GUILE_DOC_SNARF) -d -o $@ \
-                           $< $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) 
-
-.c.inc:
-	$(AM_V_GEN)sed -n 's/SCM_DEFINE *(.[^,]*, *\"\([^"][^"]*\)\".*/[(export \1)]/p' $< > $@
-
-guile-procedures.texi: $(DOT_DOC_FILES)
-	$(AM_V_GEN)cat $(DOT_DOC_FILES) > $@
-
-guile-procedures.txt: guile-procedures.texi
-	$(AM_V_GEN) rm -f $@; \
-	  $(MAKEINFO) --force -o $@ guile-procedures.texi || test -f $@
-
-mailutils.scm: mailutils.scm.in $(C_SRCS:.c=.inc)
+mailutils.scm: mailutils.scm.in
 	$(AM_V_GEN)m4 -DVERSION=$(VERSION) -DLIBDIR=$(libdir) \
 	   -DSITEDIR=$(sitedir) \
            -DBUILDDIR=$(top_builddir)/libmu_scm \
             $(srcdir)/mailutils.scm.in > $@
 
-
-## Add -MG to make the .x magic work with auto-dep code.
-MKDEP = $(CC) -M -MG $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-
 install-data-hook:
 	 @here=`pwd`; \
 	 cd $(DESTDIR)$(libdir);\
@@ -137,3 +95,7 @@ install-data-hook:
 	 fi; \
 	 cd $$here
 
+sitedir   = @GUILE_SITE@/$(PACKAGE)
+site_DATA = mailutils.scm
+SUFFIXES=
+include ../gint/gint.mk
diff --git a/libmu_scm/mailutils.scm.in b/libmu_scm/mailutils.scm.in
index 66d773e..d78a753 100644
--- a/libmu_scm/mailutils.scm.in
+++ b/libmu_scm/mailutils.scm.in
@@ -20,7 +20,7 @@
 changequote([,])dnl
 
 (define-module (mailutils mailutils)
-               #:use-module (ice-9 documentation))
+  #:use-module (ice-9 documentation))
 
 (set! documentation-files (append documentation-files 
                                   (list "SITEDIR/guile-procedures.txt")))
@@ -38,65 +38,7 @@ changequote([,])dnl
    (lambda (lib)
 	   (dynamic-link (string-append lib-path lib)))
    mu-libs)
-  (cond
-   ((or (string=? (version) "1.4")
-	(string=? (version) "1.4.1"))
-    (dynamic-call "mu_scm_init"
-		  (dynamic-link (string-append
-				 lib-path
-				 "libguile-mailutils-v-VERSION"))))
-   (else
-    (load-extension (string-append
-		     lib-path "libguile-mailutils-v-VERSION") "mu_scm_init"))))
-
-(export mu-package)
-(export mu-package-string)
-(export mu-version)
-(export mu-mailer)
-(export mu-debug)
-(export mu-path-maildir)
-(export mu-path-folder-dir)
-
-(export MU-ATTRIBUTE-ANSWERED)
-(export MU-ATTRIBUTE-FLAGGED)
-(export MU-ATTRIBUTE-DELETED)
-(export MU-ATTRIBUTE-DRAFT)
-(export MU-ATTRIBUTE-SEEN)
-(export MU-ATTRIBUTE-READ)
-(export MU-ATTRIBUTE-MODIFIED)
-(export MU-ATTRIBUTE-RECENT)
-
-(export LOG_USER)   
-(export LOG_DAEMON)
-(export LOG_AUTH)  
-(export LOG_LOCAL0)
-(export LOG_LOCAL1)
-(export LOG_LOCAL2)
-(export LOG_LOCAL3)
-(export LOG_LOCAL4)
-(export LOG_LOCAL5)
-(export LOG_LOCAL6)
-(export LOG_LOCAL7)
-(export LOG_EMERG)    
-(export LOG_ALERT)   
-(export LOG_CRIT)    
-(export LOG_ERR)     
-(export LOG_WARNING) 
-(export LOG_NOTICE)  
-(export LOG_INFO)    
-(export LOG_DEBUG)   
-(export LOG_CONS)   
-(export LOG_NDELAY) 
-(export LOG_PID)
-
-include(BUILDDIR/mu_address.inc)
-include(BUILDDIR/mu_body.inc)
-include(BUILDDIR/mu_mailbox.inc)
-include(BUILDDIR/mu_message.inc)
-include(BUILDDIR/mu_mime.inc)
-include(BUILDDIR/mu_logger.inc)
-include(BUILDDIR/mu_port.inc)
-include(BUILDDIR/mu_scm.inc)
-include(BUILDDIR/mu_util.inc)
+  (load-extension (string-append
+		   lib-path "libguile-mailutils-v-VERSION") "mu_scm_init"))
 
 ;;;; End of mailutils.scm
diff --git a/libmu_scm/mu_address.c b/libmu_scm/mu_address.c
index a357170..9ced92c 100644
--- a/libmu_scm/mu_address.c
+++ b/libmu_scm/mu_address.c
@@ -78,7 +78,7 @@ _get_address_part (const char *func_name, address_get_fp fun,
   return ret;
 }
 
-SCM_DEFINE (scm_mu_address_get_personal, "mu-address-get-personal", 1, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_address_get_personal, "mu-address-get-personal", 1, 1, 0,
 	    (SCM ADDRESS, SCM NUM),
 	    "Return personal part of the NUMth email address from ADDRESS.\n")
 #define FUNC_NAME s_scm_mu_address_get_personal
@@ -88,7 +88,7 @@ SCM_DEFINE (scm_mu_address_get_personal, "mu-address-get-personal", 1, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_address_get_comments, "mu-address-get-comments", 1, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_address_get_comments, "mu-address-get-comments", 1, 1, 0,
 	    (SCM ADDRESS, SCM NUM),
 	    "Return comment part of the NUMth email address from ADDRESS.\n")
 #define FUNC_NAME s_scm_mu_address_get_comments
@@ -98,7 +98,7 @@ SCM_DEFINE (scm_mu_address_get_comments, "mu-address-get-comments", 1, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_address_get_email, "mu-address-get-email", 1, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_address_get_email, "mu-address-get-email", 1, 1, 0,
 	    (SCM ADDRESS, SCM NUM),
 	    "Return email part of the NUMth email address from ADDRESS.\n")
 #define FUNC_NAME s_scm_mu_address_get_email
@@ -108,7 +108,7 @@ SCM_DEFINE (scm_mu_address_get_email, "mu-address-get-email", 1, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_address_get_domain, "mu-address-get-domain", 1, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_address_get_domain, "mu-address-get-domain", 1, 1, 0,
 	    (SCM ADDRESS, SCM NUM),
 	    "Return domain part of the NUMth email address from ADDRESS.\n")
 #define FUNC_NAME s_scm_mu_address_get_domain
@@ -118,7 +118,7 @@ SCM_DEFINE (scm_mu_address_get_domain, "mu-address-get-domain", 1, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_address_get_local, "mu-address-get-local", 1, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_address_get_local, "mu-address-get-local", 1, 1, 0,
 	    (SCM ADDRESS, SCM NUM),
 	    "Return local part of the NUMth email address from ADDRESS.\n")
 #define FUNC_NAME s_scm_mu_address_get_local
@@ -128,7 +128,7 @@ SCM_DEFINE (scm_mu_address_get_local, "mu-address-get-local", 1, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0,
 	    (SCM ADDRESS),
 	    "Return number of parts in email address ADDRESS.\n")
 #define FUNC_NAME s_scm_mu_address_get_count
@@ -154,7 +154,7 @@ SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_username_to_email, "mu-username->email", 0, 1, 0,
 	    (SCM NAME),
 "Deduce user's email address from his username. If NAME is omitted, \n"
 "current username is assumed\n")
diff --git a/libmu_scm/mu_body.c b/libmu_scm/mu_body.c
index 43ee30b..a259717 100644
--- a/libmu_scm/mu_body.c
+++ b/libmu_scm/mu_body.c
@@ -102,7 +102,7 @@ mu_scm_body_create (SCM msg, mu_body_t body)
 /* ************************************************************************* */
 /* Guile primitives */
 
-SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
 	    (SCM BODY), 
 	    "Read next line from the BODY.")
 #define FUNC_NAME s_scm_mu_body_read_line
@@ -163,7 +163,7 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_body_write, "mu-body-write", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0,
 	    (SCM BODY, SCM TEXT),
 	    "Append TEXT to message BODY.")
 #define FUNC_NAME s_scm_mu_body_write
diff --git a/libmu_scm/mu_guile.c b/libmu_scm/mu_guile.c
index 26dc2a7..39e1916 100644
--- a/libmu_scm/mu_guile.c
+++ b/libmu_scm/mu_guile.c
@@ -57,9 +57,10 @@ mu_guile_safe_exec (SCM (*handler) (void *data), void *data, SCM *result)
     return 1;
   ed.handler = handler;
   ed.data = data;
-  scm_internal_lazy_catch (SCM_BOOL_T,
-			   scheme_safe_exec_body, (void*)&ed,
-			   eval_catch_handler, &jmp_env);
+  scm_c_catch (SCM_BOOL_T,
+	       scheme_safe_exec_body, (void*)&ed,
+	       eval_catch_handler, &jmp_env,
+	       NULL, NULL);
   if (result)
     *result = ed.result;
   return 0;
@@ -91,9 +92,10 @@ mu_guile_safe_proc_call (SCM proc, SCM arglist, SCM *presult)
     return 1;
 
   cell = scm_cons (proc, arglist);
-  result = scm_internal_lazy_catch (SCM_BOOL_T,
-				    eval_catch_body, cell,
-				    eval_catch_handler, &jmp_env);
+  result = scm_c_catch (SCM_BOOL_T,
+			eval_catch_body, cell,
+			eval_catch_handler, &jmp_env,
+			NULL, NULL);
   if (presult)
     *presult = result;
   return 0;
diff --git a/libmu_scm/mu_logger.c b/libmu_scm/mu_logger.c
index 4dc7841..ab6ee87 100644
--- a/libmu_scm/mu_logger.c
+++ b/libmu_scm/mu_logger.c
@@ -23,7 +23,7 @@
 
 static char *log_tag;
 
-SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_openlog, "mu-openlog", 3, 0, 0,
 	   (SCM IDENT, SCM OPTION, SCM FACILITY),
 "Opens a connection to the system logger for Guile program.\n"
 "IDENT, OPTION and FACILITY have the same meaning as in openlog(3)")
@@ -41,7 +41,7 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_logger, "mu-logger", 2, 0, 0,
 	   (SCM PRIO, SCM TEXT),
 	   "Distributes TEXT via syslogd priority PRIO.")
 #define FUNC_NAME s_scm_mu_logger
@@ -60,7 +60,7 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_closelog, "mu-closelog", 0, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_closelog, "mu-closelog", 0, 0, 0,
 	   (),
 	   "Closes the channel to the system logger opened by @code{mu-openlog}.")
 #define FUNC_NAME s_scm_mu_closelog
@@ -113,6 +113,9 @@ mu_scm_logger_init ()
   int i;
   
   for (i = 0; i < sizeof (syslog_kw)/sizeof (syslog_kw[0]); i++)
-    scm_c_define (syslog_kw[i].name, scm_from_int (syslog_kw[i].facility));
+    {
+      scm_c_define (syslog_kw[i].name, scm_from_int (syslog_kw[i].facility));
+      scm_c_export (syslog_kw[i].name, NULL);
+    }
 #include <mu_logger.x>
 }
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index 663755e..f58fbad 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -137,7 +137,7 @@ mu_scm_is_mailbox (SCM scm)
 /* ************************************************************************* */
 /* Guile primitives */
 
-SCM_DEFINE (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
 	    (SCM URL), 
 "Do not use this function. Use mu-user-mailbox-url instead.")
 #define FUNC_NAME s_scm_mu_mail_directory
@@ -149,7 +149,7 @@ SCM_DEFINE (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
 }
 #undef FUNC_NAME 
 
-SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, 
+SCM_DEFINE_PUBLIC (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, 
 	    (SCM USER),
 	    "")
 #define FUNC_NAME s_scm_mu_user_mailbox_url
@@ -172,7 +172,7 @@ SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0,
 }
 #undef FUNC_NAME 
 
-SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0,
 	    (SCM URL), 
 "If URL is given, sets it as a name of the user's folder directory.\n"
 "Returns the current value of the folder directory.")
@@ -191,7 +191,7 @@ SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0,
 }
 #undef FUNC_NAME 
 
-SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
 	    (SCM URL, SCM MODE), 
 "Opens the mailbox specified by URL. MODE is a string, consisting of\n"
 "the characters described below, giving the access mode for the mailbox\n"
@@ -263,7 +263,7 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_close, "mu-mailbox-close", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_close, "mu-mailbox-close", 1, 0, 0,
 	    (SCM MBOX), "Closes mailbox MBOX.")
 #define FUNC_NAME s_scm_mu_mailbox_close
 {
@@ -277,7 +277,7 @@ SCM_DEFINE (scm_mu_mailbox_close, "mu-mailbox-close", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0,
 	    (SCM MBOX), 
             "Returns url of the mailbox MBOX.")
 #define FUNC_NAME s_scm_mu_mailbox_get_url
@@ -298,7 +298,7 @@ SCM_DEFINE (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0,
 	    (SCM MBOX, SCM MODE),
 "Returns a port associated with the contents of the MBOX.\n"
 "MODE is a string defining operation mode of the stream. It may\n"
@@ -327,7 +327,7 @@ SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_get_message, "mu-mailbox-get-message", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_message, "mu-mailbox-get-message", 2, 0, 0,
             (SCM MBOX, SCM MSGNO), 
 "Retrieve from message #MSGNO from the mailbox MBOX.")
 #define FUNC_NAME s_scm_mu_mailbox_get_message
@@ -353,7 +353,7 @@ SCM_DEFINE (scm_mu_mailbox_get_message, "mu-mailbox-get-message", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0,
 	    (SCM MBOX), 
 "Returns number of messages in the mailbox MBOX.")
 #define FUNC_NAME s_scm_mu_mailbox_messages_count
@@ -374,7 +374,7 @@ SCM_DEFINE (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_expunge, "mu-mailbox-expunge", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_expunge, "mu-mailbox-expunge", 1, 0, 0,
 	    (SCM MBOX), 
 "Expunges deleted messages from the mailbox MBOX.")
 #define FUNC_NAME s_scm_mu_mailbox_expunge
@@ -393,7 +393,7 @@ SCM_DEFINE (scm_mu_mailbox_expunge, "mu-mailbox-expunge", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0,
 	    (SCM MBOX, SCM MESG),
 "Appends message MESG to the mailbox MBOX.")
 #define FUNC_NAME s_scm_mu_mailbox_append_message
@@ -430,7 +430,7 @@ SCM_DEFINE (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0,
     }									\
   while (0)
 
-SCM_DEFINE (scm_mu_mailbox_first_message, "mu-mailbox-first-message", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_first_message, "mu-mailbox-first-message", 1, 0, 0,
 	    (SCM MBOX),
 	    "Returns first message from the mailbox.")
 #define FUNC_NAME s_scm_mu_mailbox_first_message
@@ -457,7 +457,7 @@ SCM_DEFINE (scm_mu_mailbox_first_message, "mu-mailbox-first-message", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0, 0,
 	    (SCM MBOX),
 	    "Returns next message from the mailbox.")
 #define FUNC_NAME s_scm_mu_mailbox_next_message
@@ -487,7 +487,7 @@ SCM_DEFINE (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?", 1, 0, 0,
 	    (SCM MBOX),
 	    "Returns next message from the mailbox.")
 #define FUNC_NAME s_scm_mu_mailbox_more_messages_p
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index 4167f96..d9e3386 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -176,7 +176,7 @@ mu_scm_is_message (SCM scm)
 /* ************************************************************************* */
 /* Guile primitives */
 
-SCM_DEFINE (scm_mu_message_create, "mu-message-create", 0, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_create, "mu-message-create", 0, 0, 0,
 	    (),
 	    "Creates an empty message.\n")
 #define FUNC_NAME s_scm_mu_message_create
@@ -188,7 +188,7 @@ SCM_DEFINE (scm_mu_message_create, "mu-message-create", 0, 0, 0,
 #undef FUNC_NAME
 
 /* FIXME: This changes envelope date */
-SCM_DEFINE (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
 	    (SCM MESG),
 	    "Creates the copy of the message MESG.\n")
 #define FUNC_NAME s_scm_mu_message_copy
@@ -249,7 +249,7 @@ SCM_DEFINE (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_destroy, "mu-message-destroy", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_destroy, "mu-message-destroy", 1, 0, 0,
 	    (SCM MESG),
 	    "Destroys the message MESG.")
 #define FUNC_NAME s_scm_mu_message_destroy
@@ -263,7 +263,7 @@ SCM_DEFINE (scm_mu_message_destroy, "mu-message-destroy", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0,
 	    (SCM MESG, SCM HEADER, SCM VALUE, SCM REPLACE),
 "Sets new VALUE to the header HEADER of the message MESG.\n"
 "If HEADER is already present in the message its value\n"
@@ -284,7 +284,7 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0,
   if (scm_is_bool (VALUE))
     return SCM_UNSPECIFIED;
   
-  SCM_ASSERT (scm_is_string (VALUE), VALUE, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_string (VALUE), VALUE, SCM_ARG3, FUNC_NAME);
   if (!SCM_UNBNDP (REPLACE))
     {
       replace = REPLACE == SCM_BOOL_T;
@@ -310,7 +310,7 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_size, "mu-message-get-size", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_size, "mu-message-get-size", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns the size of the message MESG\n.")
 #define FUNC_NAME s_scm_mu_message_get_size
@@ -325,7 +325,7 @@ SCM_DEFINE (scm_mu_message_get_size, "mu-message-get-size", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_lines, "mu-message-get-lines", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_lines, "mu-message-get-lines", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns number of lines in the given message.\n")
 #define FUNC_NAME s_scm_mu_message_get_lines
@@ -367,7 +367,7 @@ filltime (struct tm *bd_time, int zoff, const char *zname)
   return result;
 }
 
-SCM_DEFINE (scm_mu_message_get_envelope, "mu-message-get-envelope", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope, "mu-message-get-envelope", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns envelope date of the message MESG.\n")
 #define FUNC_NAME s_scm_mu_message_get_envelope
@@ -402,7 +402,7 @@ SCM_DEFINE (scm_mu_message_get_envelope, "mu-message-get-envelope", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_envelope_date, "mu-message-get-envelope-date", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope_date, "mu-message-get-envelope-date", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns envelope date of the message MESG.\n")
 #define FUNC_NAME s_scm_mu_message_get_envelope_date
@@ -432,7 +432,7 @@ SCM_DEFINE (scm_mu_message_get_envelope_date, "mu-message-get-envelope-date", 1,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns email address of the sender of the message MESG.\n")
 #define FUNC_NAME s_scm_mu_message_get_sender
@@ -459,7 +459,7 @@ SCM_DEFINE (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0,
 	    (SCM MESG, SCM HEADER),
 	    "Returns value of the header HEADER from the message MESG.\n")
 #define FUNC_NAME s_scm_mu_message_get_header
@@ -517,7 +517,7 @@ string_sloppy_member (SCM lst, char *name)
   return 0;
 }
 
-SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, 1, 0,
 	    (SCM MESG, SCM HEADERS),
 "Returns the list of headers in the message MESG. Optional argument\n" 
 "HEADERS gives a list of header names to restrict return value to.\n")
@@ -583,7 +583,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1,
 }
 #undef FUNC_NAME
   
-SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, 1, 0,
 	    (SCM MESG, SCM LIST, SCM REPLACE),
 "Set the headers in the message MESG from LIST\n"
 "LIST is a list of conses (cons HEADER VALUE).  The function sets\n"
@@ -640,7 +640,7 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_delete, "mu-message-delete", 1, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_delete, "mu-message-delete", 1, 1, 0,
 	    (SCM MESG, SCM FLAG),
 "Mark the message MESG as deleted. Optional argument FLAG allows to toggle\n"
 "deletion mark. The message is deleted if it is @code{#t} and undeleted if\n"
@@ -677,7 +677,7 @@ SCM_DEFINE (scm_mu_message_delete, "mu-message-delete", 1, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0,
 	    (SCM MESG, SCM FLAG),
 "Return value of the attribute FLAG of the message MESG.")
 #define FUNC_NAME s_scm_mu_message_get_flag
@@ -738,7 +738,7 @@ SCM_DEFINE (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0,
 	    (SCM MESG, SCM FLAG, SCM VALUE),
 "Set the attribute FLAG of the message MESG. If optional VALUE is #f, the\n"
 "attribute is unset.")
@@ -836,7 +836,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_user_flag, "mu-message-get-user-flag", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_user_flag, "mu-message-get-user-flag", 2, 0, 0,
 	    (SCM MESG, SCM FLAG),
 "Return the value of the user attribute FLAG from the message MESG.")
 #define FUNC_NAME s_scm_mu_message_get_user_flag
@@ -858,7 +858,7 @@ SCM_DEFINE (scm_mu_message_get_user_flag, "mu-message-get-user-flag", 2, 0, 0,
 #undef FUNC_NAME
   
 
-SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0,
 	    (SCM MESG, SCM FLAG, SCM VALUE),
 "Set the given user attribute FLAG in the message MESG. If optional argumen\n"
 "VALUE is @samp{#f}, the attribute is unset.")
@@ -892,7 +892,7 @@ SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
 	    (SCM MESG, SCM MODE, SCM FULL),
 "Returns a port associated with the given MESG. MODE is a string\n"
 "defining operation mode of the stream. It may contain any of the\n"
@@ -948,7 +948,7 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
 #undef FUNC_NAME
   
 
-SCM_DEFINE (scm_mu_message_get_body, "mu-message-get-body", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_body, "mu-message-get-body", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns the message body for the message MESG.")
 #define FUNC_NAME s_scm_mu_message_get_body
@@ -966,7 +966,7 @@ SCM_DEFINE (scm_mu_message_get_body, "mu-message-get-body", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_multipart_p, "mu-message-multipart?", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_multipart_p, "mu-message-multipart?", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns @code{#t} if MESG is a multipart @acronym{MIME} message.")
 #define FUNC_NAME s_scm_mu_message_multipart_p
@@ -981,7 +981,7 @@ SCM_DEFINE (scm_mu_message_multipart_p, "mu-message-multipart?", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1, 0, 0,
 	    (SCM MESG),
 "Returns number of parts in a multipart @acronym{MIME} message. Returns\n"
 "@code{#f} if the argument is not a multipart message.")
@@ -1007,7 +1007,7 @@ SCM_DEFINE (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_part, "mu-message-get-part", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_part, "mu-message-get-part", 2, 0, 0,
 	    (SCM MESG, SCM PART),
 "Returns part #PART from a multipart @acronym{MIME} message MESG.")
 #define FUNC_NAME s_scm_mu_message_get_part
@@ -1034,7 +1034,7 @@ SCM_DEFINE (scm_mu_message_get_part, "mu-message-get-part", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_send, "mu-message-send", 1, 3, 0,
 	    (SCM MESG, SCM MAILER, SCM FROM, SCM TO),
 "Sends the message MESG. Optional MAILER overrides default mailer settings\n"
 "in mu-mailer. Optional FROM and TO give sender and recever addresses.\n")
@@ -1118,7 +1118,7 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_message_get_uid, "mu-message-get-uid", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_message_get_uid, "mu-message-get-uid", 1, 0, 0,
 	    (SCM MESG),
 	    "Returns uid of the message MESG\n")
 #define FUNC_NAME s_scm_mu_message_get_uid
diff --git a/libmu_scm/mu_mime.c b/libmu_scm/mu_mime.c
index ca9f799..c8f512b 100644
--- a/libmu_scm/mu_mime.c
+++ b/libmu_scm/mu_mime.c
@@ -89,7 +89,7 @@ mu_scm_is_mime (SCM scm)
 /* ************************************************************************* */
 /* Guile primitives */
 
-SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mime_create, "mu-mime-create", 0, 2, 0,
 	    (SCM FLAGS, SCM MESG),
 "Creates a new @acronym{MIME} object.  Both arguments are optional.\n"
 "FLAGS specifies the type of the object to create (@samp{0} is a reasonable\n"
@@ -127,7 +127,7 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mime_multipart_p, "mu-mime-multipart?", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mime_multipart_p, "mu-mime-multipart?", 1, 0, 0,
 	    (SCM MIME),
 "Returns @code{#t} if MIME is a multipart object.\n")
 #define FUNC_NAME s_scm_mu_mime_multipart_p
@@ -137,7 +137,7 @@ SCM_DEFINE (scm_mu_mime_multipart_p, "mu-mime-multipart?", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0,
 	    (SCM MIME),
 "Returns number of parts in the @sc{mime} object MIME.")
 #define FUNC_NAME s_scm_mu_mime_get_num_parts
@@ -156,7 +156,7 @@ SCM_DEFINE (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mime_get_part, "mu-mime-get-part", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mime_get_part, "mu-mime-get-part", 2, 0, 0,
 	    (SCM MIME, SCM NUM),
 	    "Returns NUMth part from the @sc{mime} object MIME.")
 #define FUNC_NAME s_scm_mu_mime_get_part
@@ -178,7 +178,7 @@ SCM_DEFINE (scm_mu_mime_get_part, "mu-mime-get-part", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mime_add_part, "mu-mime-add-part", 2, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mime_add_part, "mu-mime-add-part", 2, 0, 0,
 	    (SCM MIME, SCM MESG),
 	    "Adds MESG to the @sc{mime} object MIME.")
 #define FUNC_NAME s_scm_mu_mime_add_part
@@ -204,7 +204,7 @@ SCM_DEFINE (scm_mu_mime_add_part, "mu-mime-add-part", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_mime_get_message, "mu-mime-get-message", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_mime_get_message, "mu-mime-get-message", 1, 0, 0,
 	    (SCM MIME),
 	    "Converts @sc{mime} object MIME to a message.\n")
 #define FUNC_NAME s_scm_mu_mime_get_message
diff --git a/libmu_scm/mu_scm.c b/libmu_scm/mu_scm.c
index 9df9551..ddfa8d9 100644
--- a/libmu_scm/mu_scm.c
+++ b/libmu_scm/mu_scm.c
@@ -88,7 +88,7 @@ register_format (const char *name)
 }
     
 
-SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1,
+SCM_DEFINE_PUBLIC (scm_mu_register_format, "mu-register-format", 0, 0, 1,
 	    (SCM REST),
 "Registers desired mailutils formats.  Any number of arguments can be given.\n"
 "Each argument must be one of the following strings:\n\n"
@@ -136,7 +136,7 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_mu_strerror, "mu-strerror", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_strerror, "mu-strerror", 1, 0, 0,
 	    (SCM ERR),
 "Return the error message corresponding to ERR, which must be\n"
 "an integer value.\n")
@@ -177,16 +177,22 @@ mu_scm_init ()
 
   _mu_scm_package = scm_from_locale_string (PACKAGE);
   scm_c_define ("mu-package", _mu_scm_package);
-
+  scm_c_export ("mu-package", NULL);
+  
   _mu_scm_version = scm_from_locale_string (VERSION);
   scm_c_define ("mu-version", _mu_scm_version);
-
+  scm_c_export ("mu-version", NULL);
+  
   _mu_scm_package_string = scm_from_locale_string (PACKAGE_STRING);
   scm_c_define ("mu-package-string", _mu_scm_package_string);
-
+  scm_c_export ("mu-package-string", NULL);
+  
   /* Create MU- attribute names */
   for (i = 0; attr_kw[i].name; i++)
-    scm_c_define(attr_kw[i].name, scm_from_int(attr_kw[i].value));
+    {
+      scm_c_define (attr_kw[i].name, scm_from_int(attr_kw[i].value));
+      scm_c_export (attr_kw[i].name, NULL);
+    }
   
   mu_scm_mutil_init ();
   mu_scm_mailbox_init ();
diff --git a/libmu_scm/mu_util.c b/libmu_scm/mu_util.c
index 22fedc5..bdf3aca 100644
--- a/libmu_scm/mu_util.c
+++ b/libmu_scm/mu_util.c
@@ -19,7 +19,7 @@
 
 #include "mu_scm.h"
 
-SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0,
+SCM_DEFINE_PUBLIC (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0,
             (SCM USER),
 "Look up an entry in the user database. USER can be an integer,\n"
 "or a string, giving the behaviour of @code{mu_get_auth_by_uid} or\n"
diff --git a/mu-aux/Makefile.am b/mu-aux/Makefile.am
index e0ee233..28a299b 100644
--- a/mu-aux/Makefile.am
+++ b/mu-aux/Makefile.am
@@ -20,8 +20,6 @@
 
 EXTRA_DIST = \
  debugdef.m4\
- guile-doc-snarf\
- guile-doc-snarf.awk\
  gylwrap\
  mailutils.spec\
  mailutils.spec.in\
diff --git a/mu-aux/guile-doc-snarf b/mu-aux/guile-doc-snarf
deleted file mode 100755
index c25dd28..0000000
--- a/mu-aux/guile-doc-snarf
+++ /dev/null
@@ -1,86 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2002, 2006, 2007 Sergey Poznyakoff
-#
-# This is a snarfer for guile version 1.6
-# 
-#  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
-#  the Free Software Foundation; either version 3 of the License, or
-#  (at your option) any later version.
-# 
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#  
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 
-
-OUTFILE=/dev/tty
-DOCFILE=0
-BASEDIR=`dirname $0`
-test -n "${CPP+set}" || CPP="gcc -E"
-test -n "${AWK+set}" || AWK=awk
-temp=/tmp/snarf.$$
-trap "rm -f $temp" 0 1 2 15
-
-# process aruments
-while [ $# -gt 0 ];
-do
-    case $1 in
-    -o) OUTFILE=$2; shift 2;;
-    -d) DOCFILE=1; shift;;
-    *)  break;;
-    esac
-done
-
-INFILE=$1; shift
-
-cpp_exit=1
-
-snarf_x() {
-    echo "/* source: $INFILE */" ;
-    echo "/* cpp arguments: $@ */" ;
-    $CPP -DSCM_MAGIC_SNARF_INITS -DSCM_MAGIC_SNARFER "$@" > ${temp}
-    cpp_exit=$?
-    grep "^ *\^ *\^" ${temp} | sed -e "s/^ *\^ *\^//" -e "s/\^\ *:\ *\^.*/;/"
-}
-
-snarf_doc() {
-    $CPP -DSCM_MAGIC_SNARF_DOCS "$@" > ${temp}
-    cpp_exit=$?
-    sed -n '
-	/^ *^^ {.*/{
-	# First, remove the delimiting braces
-	s/^ *^^ {//
-	s/\^^ }/^^/
-	# Initialize the hold space
-	h
-	:beg
-	# Delete everything after the first ^^
-	s/\^^.*//
-	# Exchange spaces
-	x
-	# Delete up to the first ^^
-	s/[^^]*\^^//
-	# Append to the hold space and exchange
-	H
-	x
-	# Branch if the last substitution was successful
-	tbeg
-	# Otherwise, print the pattern space
-	p
-	}' $temp | \
-      $AWK -f $BASEDIR/guile-doc-snarf.awk 
-}
-
-case "$DOCFILE" in
-    0) snarf_x $INFILE "$@" > $OUTFILE;;
-    1) snarf_doc $INFILE "$@" > $OUTFILE;;
-esac
-
-if [ $cpp_exit -ne 0 ]; then
-    [ "$OUTFILE" != "/dev/tty" ] && rm $OUTFILE
-fi
-exit $cpp_exit
diff --git a/mu-aux/guile-doc-snarf.awk b/mu-aux/guile-doc-snarf.awk
deleted file mode 100644
index 4604faf..0000000
--- a/mu-aux/guile-doc-snarf.awk
+++ /dev/null
@@ -1,102 +0,0 @@
-# Copyright (C) 2002, 2006, 2007 Sergey Poznyakoff
-#
-# This is a snarfer for guile version 1.6
-# 
-#  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
-#  the Free Software Foundation; either version 3 of the License, or
-#  (at your option) any later version.
-# 
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#  
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software
-#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-#  02110-1301 USA.
-
-BEGIN {
-      cname = ""
-}
-
-function flush() {
-	 if (cname == "")
-	    return;
-	 if (arg_req + arg_opt + arg_var != numargs)
-	    error(cname " incorrectly defined as taking " numargs " arguments")
-
-	 print "\f" fname
-	 print "@c snarfed from " loc_source ":" loc_line
-	 printf "@deffn {Scheme procedure} %s", fname
-	 # All scheme primitives follow the same naming style:
-	 # SCM argument names are in upper case.
-	 # So, we convert them to lower case for @deffn line and
-	 # replace their occurrences in the docstring by appropriate
-	 # @var{} commands.
-         for (i = 1; i <= numargs; i++) {
-	    printf(" %s", tolower(arglist[i]))
-	    gsub(arglist[i], "@var{" tolower(arglist[i]) "}", docstring)
-         }
-	 print ""
-	 print docstring
-	 print "@end deffn\n"
-	     
-	 delete argpos
-	 delete arglist
-	 cname = ""
-}
-
-function error(s) {
-	 print loc_source ":" loc_line ": " s > "/dev/stderr"
-	 exit 1
-}
-
-#{print NR ": " state}
-
-state == 0 && NF != 0 { state = 1 }		
-
-state == 1 && $1 == "cname" { cname = $2; next }
-state == 1 && $1 == "fname" { fname = substr($2,2,length($2)-2); next }
-state == 1 && $1 == "type" { type = $2; next }
-state == 1 && $1 == "location" { loc_source = $2; loc_line = $3; next }
-state == 1 && $1 == "arglist" {
-	match($0, "\\(.*\\)")
-	s = substr($0,RSTART+1,RLENGTH-2)
-	numargs = split(s, a, ",")
-	for (i = 1; i <= numargs; i++) {
-	    m = split(a[i], b, "[ \t]*")
-	    if (b[1] == "") {
-	       t = b[2]
-	       n = b[3]
-	       m--
-	    } else {
-	       t = b[1]
-	       n = b[2]
-	    }   
-	    if (m > 2 || t != "SCM")
-	       error(cname ": wrong argument type for arg " i " " t)
-	    arglist[i] = n
-	}
-	next
-}
-
-state == 1 && $1 == "argsig" { arg_req = $2; arg_opt = $3; arg_var = $4; next }
-state == 1 && $1 == "argpos" { argpos[$2] = $3; next }
-
-state == 1 && / *\"/    {
-        # Concatenate strings. A very simplified version, but
-        # works for us
-	gsub("\\\\n\" *\"", "\n")
-        gsub("\"\"", "")
-	gsub("\\\\n", "\n")
-	match($0,"\".*\"")
-	docstring = substr($0,RSTART+1,RLENGTH-2)
-}
-
-state == 1 && NF==0 { flush(); state = 0; }
-
-END {
-	flush()
-}


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Wed Apr 14 05:02:55 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O1yUp-0004bA-I9
	for mharc-commit-mailutils@gnu.org; Wed, 14 Apr 2010 05:02:55 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O1yUn-0004aU-Mv
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 05:02:53 -0400
Received: from [140.186.70.92] (port=37781 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O1yUi-0004YH-Mt
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 05:02:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1yUc-0003iR-Vy
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 05:02:48 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:59278
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1yUc-0003iJ-Sf
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 05:02:42 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1yUc-0002ys-KJ
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 09:02:42 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O1yUb-0000CR-90
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 09:02:42 +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: 49e121acc32a38b2d618cfd0544de349618c2bb1
X-Git-Newrev: 94adc8f49244e0abfd3ac47e0cfb2af2a063adc5
Message-Id: <E1O1yUb-0000CR-90@vcs-noshell.in.savannah.gnu.org>
Date: Wed, 14 Apr 2010 09:02:42 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-68-g94adc8f
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, 14 Apr 2010 09:02:54 -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=94adc8f49244e0abfd3ac47e0cfb2af2a063adc5

The branch, master has been updated
       via  94adc8f49244e0abfd3ac47e0cfb2af2a063adc5 (commit)
      from  49e121acc32a38b2d618cfd0544de349618c2bb1 (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 94adc8f49244e0abfd3ac47e0cfb2af2a063adc5
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Apr 14 11:36:52 2010 +0300

    Further improvements in the Guile-related code.
    
    * gint: Upgrade.
    * libmu_scm/Makefile.am: Initialize BUILT_SOURCES.
    * libmu_scm/mu_address.c (address_get_fp): Change
    signature to match those of mu_address_aget family.
    (all functions): Use functions from mu_address_aget family.
    Downcase argument names. Refer to them in the docstring
    using @var notation.
    * libmu_scm/mu_body.c: Downcase argument names. Refer to them
    in the docstring using @var notation.
    * libmu_scm/mu_logger.c: Likewise.
    * libmu_scm/mu_mailbox.c: Likewise.
    * libmu_scm/mu_message.c: Likewise.
    * libmu_scm/mu_mime.c: Likewise.
    * libmu_scm/mu_scm.c: Likewise.
    * libmu_scm/mu_util.c: Likewise.

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

Summary of changes:
 gint                   |    2 +-
 libmu_scm/Makefile.am  |    1 +
 libmu_scm/mu_address.c |   89 +++++------
 libmu_scm/mu_body.c    |   21 ++-
 libmu_scm/mu_logger.c  |   30 ++--
 libmu_scm/mu_mailbox.c |  187 +++++++++++----------
 libmu_scm/mu_message.c |  427 ++++++++++++++++++++++++------------------------
 libmu_scm/mu_mime.c    |  101 ++++++------
 libmu_scm/mu_scm.c     |   16 +-
 libmu_scm/mu_util.c    |   12 +-
 10 files changed, 441 insertions(+), 445 deletions(-)

diff --git a/gint b/gint
index c6a7620..4254b05 160000
--- a/gint
+++ b/gint
@@ -1 +1 @@
-Subproject commit c6a7620deb7e3e139329e2daad31d4071f01b43b
+Subproject commit 4254b0590e609b82dac3d688ecb401c9eefb7e25
diff --git a/libmu_scm/Makefile.am b/libmu_scm/Makefile.am
index f317bba..a65df28 100644
--- a/libmu_scm/Makefile.am
+++ b/libmu_scm/Makefile.am
@@ -98,4 +98,5 @@ install-data-hook:
 sitedir   = @GUILE_SITE@/$(PACKAGE)
 site_DATA = mailutils.scm
 SUFFIXES=
+BUILT_SOURCES=
 include ../gint/gint.mk
diff --git a/libmu_scm/mu_address.c b/libmu_scm/mu_address.c
index 9ced92c..2df7dcb 100644
--- a/libmu_scm/mu_address.c
+++ b/libmu_scm/mu_address.c
@@ -19,30 +19,29 @@
 
 #include "mu_scm.h"
 
-typedef int (*address_get_fp) (mu_address_t, size_t, char *, size_t, size_t *);
+typedef int (*address_get_fp) (mu_address_t, size_t, char **);
 
 static SCM
 _get_address_part (const char *func_name, address_get_fp fun,
-		   SCM ADDRESS, SCM NUM)
+		   SCM address, SCM num)
 {
   mu_address_t addr;
-  int length;
   char *str;
   SCM ret;
-  int num;
+  int n;
   int status;
   
-  SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, func_name);
+  SCM_ASSERT (scm_is_string (address), address, SCM_ARG1, func_name);
 
-  if (!SCM_UNBNDP (NUM))
+  if (!SCM_UNBNDP (num))
     {
-      SCM_ASSERT (scm_is_integer (NUM), NUM, SCM_ARG1, func_name);
-      num = scm_to_int (NUM);
+      SCM_ASSERT (scm_is_integer (num), num, SCM_ARG1, func_name);
+      n = scm_to_int (num);
     }
   else
-    num = 1;
+    n = 1;
 
-  str = scm_to_locale_string (ADDRESS);
+  str = scm_to_locale_string (address);
   if (!str[0])
     {
       free (str);
@@ -54,15 +53,7 @@ _get_address_part (const char *func_name, address_get_fp fun,
   if (status)
     mu_scm_error (func_name, status, "Cannot create address", SCM_BOOL_F);
 
-  str = malloc (length + 1);
-  if (!str)
-    {
-      mu_address_destroy (&addr);
-      mu_scm_error (func_name, ENOMEM,
-		    "Cannot allocate memory", SCM_BOOL_F);
-    }
-
-  status = (*fun) (addr, num, str, length + 1, NULL);
+  status = (*fun) (addr, n, &str);
   mu_address_destroy (&addr);
 
   if (status == 0)
@@ -79,58 +70,58 @@ _get_address_part (const char *func_name, address_get_fp fun,
 }
 
 SCM_DEFINE_PUBLIC (scm_mu_address_get_personal, "mu-address-get-personal", 1, 1, 0,
-	    (SCM ADDRESS, SCM NUM),
-	    "Return personal part of the NUMth email address from ADDRESS.\n")
+	    (SCM address, SCM num),
+	    "Return personal part of the @var{num}th email address from @var{address}.\n")
 #define FUNC_NAME s_scm_mu_address_get_personal
 {
   return _get_address_part (FUNC_NAME, 
-			    mu_address_get_personal, ADDRESS, NUM);
+			    mu_address_aget_personal, address, num);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_address_get_comments, "mu-address-get-comments", 1, 1, 0,
-	    (SCM ADDRESS, SCM NUM),
-	    "Return comment part of the NUMth email address from ADDRESS.\n")
+	    (SCM address, SCM num),
+	    "Return comment part of the @var{num}th email address from @var{address}.\n")
 #define FUNC_NAME s_scm_mu_address_get_comments
 {
   return _get_address_part (FUNC_NAME, 
-			    mu_address_get_comments, ADDRESS, NUM);
+			    mu_address_aget_comments, address, num);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_address_get_email, "mu-address-get-email", 1, 1, 0,
-	    (SCM ADDRESS, SCM NUM),
-	    "Return email part of the NUMth email address from ADDRESS.\n")
+	    (SCM address, SCM num),
+	    "Return email part of the @var{num}th email address from @var{address}.\n")
 #define FUNC_NAME s_scm_mu_address_get_email
 {
   return _get_address_part (FUNC_NAME, 
-			    mu_address_get_email, ADDRESS, NUM);
+			    mu_address_aget_email, address, num);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_address_get_domain, "mu-address-get-domain", 1, 1, 0,
-	    (SCM ADDRESS, SCM NUM),
-	    "Return domain part of the NUMth email address from ADDRESS.\n")
+	    (SCM address, SCM num),
+	    "Return domain part of the @var{num}th email address from @var{address}.\n")
 #define FUNC_NAME s_scm_mu_address_get_domain
 {
   return _get_address_part (FUNC_NAME, 
-			    mu_address_get_domain, ADDRESS, NUM);
+			    mu_address_aget_domain, address, num);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_address_get_local, "mu-address-get-local", 1, 1, 0,
-	    (SCM ADDRESS, SCM NUM),
-	    "Return local part of the NUMth email address from ADDRESS.\n")
+	    (SCM address, SCM num),
+	    "Return local part of the @var{num}th email address from @var{address}.\n")
 #define FUNC_NAME s_scm_mu_address_get_local
 {
   return _get_address_part (FUNC_NAME, 
-			    mu_address_get_local_part, ADDRESS, NUM);
+			    mu_address_aget_local_part, address, num);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0,
-	    (SCM ADDRESS),
-	    "Return number of parts in email address ADDRESS.\n")
+	    (SCM address),
+	    "Return number of parts in email address @var{address}.\n")
 #define FUNC_NAME s_scm_mu_address_get_count
 {
   mu_address_t addr;
@@ -138,15 +129,15 @@ SCM_DEFINE_PUBLIC (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0,
   int status;
   char *str;
   
-  SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_string (address), address, SCM_ARG1, FUNC_NAME);
 
-  str = scm_to_locale_string (ADDRESS);
+  str = scm_to_locale_string (address);
   status = mu_address_create (&addr, str);
   free (str);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot create address for ~A",
-		  scm_list_1 (ADDRESS));
+		  scm_list_1 (address));
 
   mu_address_get_count (addr, &count);
   mu_address_destroy (&addr);
@@ -155,29 +146,29 @@ SCM_DEFINE_PUBLIC (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_username_to_email, "mu-username->email", 0, 1, 0,
-	    (SCM NAME),
-"Deduce user's email address from his username. If NAME is omitted, \n"
+	    (SCM name),
+"Deduce user's email address from his username. If @var{name} is omitted, \n"
 "current username is assumed\n")
 #define FUNC_NAME s_scm_mu_username_to_email
 {
-  char *name;
+  char *username;
   char *email;
   SCM ret;
   
-  if (SCM_UNBNDP (NAME))
-    name = NULL;
+  if (SCM_UNBNDP (name))
+    username = NULL;
   else
     {
-      SCM_ASSERT (scm_is_string (NAME), NAME, SCM_ARG1, FUNC_NAME);
-      name = scm_to_locale_string (NAME);
+      SCM_ASSERT (scm_is_string (name), name, SCM_ARG1, FUNC_NAME);
+      username = scm_to_locale_string (name);
     }
 
-  email = mu_get_user_email (name);
-  free (name);
+  email = mu_get_user_email (username);
+  free (username);
   if (!email)
     mu_scm_error (FUNC_NAME, 0,
 		  "Cannot get user email for ~A",
-		  scm_list_1 (NAME));
+		  scm_list_1 (name));
 
   ret = scm_from_locale_string (email);
   free (email);
diff --git a/libmu_scm/mu_body.c b/libmu_scm/mu_body.c
index a259717..ff88759 100644
--- a/libmu_scm/mu_body.c
+++ b/libmu_scm/mu_body.c
@@ -103,16 +103,16 @@ mu_scm_body_create (SCM msg, mu_body_t body)
 /* Guile primitives */
 
 SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
-	    (SCM BODY), 
-	    "Read next line from the BODY.")
+	    (SCM body), 
+	    "Read next line from the @var{body}.")
 #define FUNC_NAME s_scm_mu_body_read_line
 {
   struct mu_body *mbp;
   size_t n, nread;
   int status;
   
-  SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME);
-  mbp = (struct mu_body *) SCM_CDR (BODY);
+  SCM_ASSERT (mu_scm_is_body (body), body, SCM_ARG1, FUNC_NAME);
+  mbp = (struct mu_body *) SCM_CDR (body);
 
   if (!mbp->stream)
     {
@@ -164,8 +164,8 @@ SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0,
-	    (SCM BODY, SCM TEXT),
-	    "Append TEXT to message BODY.")
+	    (SCM body, SCM text),
+	    "Append @var{text} to message @var{body}.")
 #define FUNC_NAME s_scm_mu_body_write
 {
   char *ptr;
@@ -173,9 +173,9 @@ SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0,
   struct mu_body *mbp;
   int status;
   
-  SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME);
-  mbp = (struct mu_body *) SCM_CDR (BODY);
-  SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_body (body), body, SCM_ARG1, FUNC_NAME);
+  mbp = (struct mu_body *) SCM_CDR (body);
+  SCM_ASSERT (scm_is_string (text), text, SCM_ARG2, FUNC_NAME);
   
   if (!mbp->stream)
     {
@@ -185,9 +185,10 @@ SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0,
 		      "Cannot get body stream", SCM_BOOL_F);
     }
 
-  ptr = SCM_STRING_CHARS (TEXT);
+  ptr = scm_to_locale_string (text);
   len = strlen (ptr);
   status = mu_stream_write (mbp->stream, ptr, len, mbp->offset, &n);
+  free (ptr);
   mu_scm_error (FUNC_NAME, status,
 		"Error writing to stream", SCM_BOOL_F);
   mbp->offset += n;
diff --git a/libmu_scm/mu_logger.c b/libmu_scm/mu_logger.c
index ab6ee87..01ebe00 100644
--- a/libmu_scm/mu_logger.c
+++ b/libmu_scm/mu_logger.c
@@ -24,37 +24,37 @@
 static char *log_tag;
 
 SCM_DEFINE_PUBLIC (scm_mu_openlog, "mu-openlog", 3, 0, 0,
-	   (SCM IDENT, SCM OPTION, SCM FACILITY),
+	   (SCM ident, SCM option, SCM facility),
 "Opens a connection to the system logger for Guile program.\n"
-"IDENT, OPTION and FACILITY have the same meaning as in openlog(3)")
+"@var{ident}, @var{option} and @var{facility} have the same meaning as in openlog(3)")
 #define FUNC_NAME s_scm_mu_openlog
 {
-  SCM_ASSERT (scm_is_string (IDENT), IDENT, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_string (ident), ident, SCM_ARG1, FUNC_NAME);
   if (log_tag)
     free (log_tag);
-  log_tag = scm_to_locale_string(IDENT);
+  log_tag = scm_to_locale_string (ident);
 	
-  SCM_ASSERT (scm_is_integer (OPTION), OPTION, SCM_ARG2, FUNC_NAME);
-  SCM_ASSERT (scm_is_integer (FACILITY), FACILITY, SCM_ARG3, FUNC_NAME);
-  openlog (log_tag, scm_to_int (OPTION), scm_to_int (FACILITY));
+  SCM_ASSERT (scm_is_integer (option), option, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_integer (facility), facility, SCM_ARG3, FUNC_NAME);
+  openlog (log_tag, scm_to_int (option), scm_to_int (facility));
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_logger, "mu-logger", 2, 0, 0,
-	   (SCM PRIO, SCM TEXT),
-	   "Distributes TEXT via syslogd priority PRIO.")
+	   (SCM prio, SCM text),
+	   "Distributes @var{text} via the syslog priority @var{prio}.")
 #define FUNC_NAME s_scm_mu_logger
 {
-  int prio;
+  int nprio;
   char *str;
 
-  SCM_ASSERT (scm_is_integer (PRIO), PRIO, SCM_ARG1, FUNC_NAME);
-  prio = scm_to_int (PRIO);
+  SCM_ASSERT (scm_is_integer (prio), prio, SCM_ARG1, FUNC_NAME);
+  nprio = scm_to_int (prio);
   
-  SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME);
-  str = scm_to_locale_string (TEXT);
-  syslog (prio, "%s", str);
+  SCM_ASSERT (scm_is_string (text), text, SCM_ARG2, FUNC_NAME);
+  str = scm_to_locale_string (text);
+  syslog (nprio, "%s", str);
   free (str);
   return SCM_UNSPECIFIED;
 }
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index f58fbad..dce05e8 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -138,34 +138,34 @@ mu_scm_is_mailbox (SCM scm)
 /* Guile primitives */
 
 SCM_DEFINE_PUBLIC (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
-	    (SCM URL), 
+		   (SCM url), 
 "Do not use this function. Use mu-user-mailbox-url instead.")
 #define FUNC_NAME s_scm_mu_mail_directory
 {
   mu_scm_error (FUNC_NAME, ENOSYS,
 		"This function is deprecated. Use mu-user-mailbox-url instead.",
-		  scm_list_1 (URL));
+		  scm_list_1 (url));
   return SCM_EOL;
 }
 #undef FUNC_NAME 
 
 SCM_DEFINE_PUBLIC (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, 
-	    (SCM USER),
-	    "")
+		   (SCM user),
+		   "Return URL of the default mailbox for user @var{user}.")
 #define FUNC_NAME s_scm_mu_user_mailbox_url
 {
   int rc;
   char *p, *str;
   SCM ret;
   
-  SCM_ASSERT (scm_is_string (USER), USER, SCM_ARG1, FUNC_NAME);
-  str = scm_to_locale_string (USER);
+  SCM_ASSERT (scm_is_string (user), user, SCM_ARG1, FUNC_NAME);
+  str = scm_to_locale_string (user);
   rc = mu_construct_user_mailbox_url (&p, str);
   free (str);
   if (rc)
     mu_scm_error (FUNC_NAME, rc,
 		  "Cannot construct mailbox URL for ~A",
-		  scm_list_1 (USER));
+		  scm_list_1 (user));
   ret = scm_from_locale_string (p);
   free (p);
   return ret;
@@ -173,17 +173,17 @@ SCM_DEFINE_PUBLIC (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0,
 #undef FUNC_NAME 
 
 SCM_DEFINE_PUBLIC (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0,
-	    (SCM URL), 
-"If URL is given, sets it as a name of the user's folder directory.\n"
+		   (SCM url), 
+"If @var{url} is given, sets it as a name of the user's folder directory.\n"
 "Returns the current value of the folder directory.")
 #define FUNC_NAME s_scm_mu_folder_directory
 {
-  if (!SCM_UNBNDP (URL))
+  if (!SCM_UNBNDP (url))
     {
       char *s;
 
-      SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME);
-      s = scm_to_locale_string (URL);
+      SCM_ASSERT (scm_is_string (url), url, SCM_ARG1, FUNC_NAME);
+      s = scm_to_locale_string (url);
       mu_set_folder_directory (s);
       free (s);
     }
@@ -192,12 +192,12 @@ SCM_DEFINE_PUBLIC (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0,
 #undef FUNC_NAME 
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
-	    (SCM URL, SCM MODE), 
-"Opens the mailbox specified by URL. MODE is a string, consisting of\n"
+	    (SCM url, SCM mode), 
+"Opens the mailbox specified by @var{url}. @var{mode} is a string, consisting of\n"
 "the characters described below, giving the access mode for the mailbox\n"
 "\n"
 "@multitable @columnfractions 0.20 0.70\n"
-"@headitem MODE @tab Meaning\n"
+"@headitem @var{mode} @tab Meaning\n"
 "@item r @tab Open for reading.\n"
 "@item w @tab Open for writing.\n"
 "@item a @tab Open for appending to the end of the mailbox.\n"
@@ -208,54 +208,54 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
 {
   mu_mailbox_t mbox = NULL;
   char *mode_str;
-  int mode = 0;
+  int mode_bits = 0;
   int status;
   SCM ret;
   
-  SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (scm_is_string (url), url, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME);
   
   scm_dynwind_begin (0);
   
-  mode_str = scm_to_locale_string (MODE);
+  mode_str = scm_to_locale_string (mode);
   scm_dynwind_free (mode_str);
   for (; *mode_str; mode_str++)
     switch (*mode_str)
       {
       case 'r':
-	mode |= MU_STREAM_READ;
+	mode_bits |= MU_STREAM_READ;
 	break;
       case 'w':
-	mode |= MU_STREAM_WRITE;
+	mode_bits |= MU_STREAM_WRITE;
 	break;
       case 'a':
-	mode |= MU_STREAM_APPEND;
+	mode_bits |= MU_STREAM_APPEND;
 	break;
       case 'c':
-	mode |= MU_STREAM_CREAT;
+	mode_bits |= MU_STREAM_CREAT;
 	break;
       }
   
-  if (mode & MU_STREAM_READ && mode & MU_STREAM_WRITE)
-    mode = (mode & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR;
+  if (mode_bits & MU_STREAM_READ && mode_bits & MU_STREAM_WRITE)
+    mode_bits = (mode_bits & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR;
 
-  mode_str = scm_to_locale_string (URL);
+  mode_str = scm_to_locale_string (url);
   scm_dynwind_free (mode_str);
   
   status = mu_mailbox_create_default (&mbox, mode_str);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot create default mailbox ~A",
-		  scm_list_1 (URL));
+		  scm_list_1 (url));
 
 
-  status = mu_mailbox_open (mbox, mode);
+  status = mu_mailbox_open (mbox, mode_bits);
   if (status)
     {
       mu_mailbox_destroy (&mbox);
       mu_scm_error (FUNC_NAME, status,
 		    "Cannot open default mailbox ~A",
-		    scm_list_1 (URL));
+		    scm_list_1 (url));
     }
   ret = mu_scm_mailbox_create (mbox);
   scm_dynwind_end ();
@@ -264,13 +264,14 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_close, "mu-mailbox-close", 1, 0, 0,
-	    (SCM MBOX), "Closes mailbox MBOX.")
+		   (SCM mbox),
+		   "Closes mailbox @var{mbox}.")
 #define FUNC_NAME s_scm_mu_mailbox_close
 {
   struct mu_mailbox *mum;
 
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
   mu_mailbox_close (mum->mbox);
   mu_mailbox_destroy (&mum->mbox);
   return SCM_UNSPECIFIED;
@@ -278,16 +279,16 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_close, "mu-mailbox-close", 1, 0, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0,
-	    (SCM MBOX), 
-            "Returns url of the mailbox MBOX.")
+		   (SCM mbox), 
+		   "Returns URL of the mailbox @var{MBOX}.")
 #define FUNC_NAME s_scm_mu_mailbox_get_url
 {
   struct mu_mailbox *mum;
   mu_url_t url;
   int status;
  
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
   status = mu_mailbox_get_url (mum->mbox, &url);
   if (status)
     mu_scm_error (FUNC_NAME, status,
@@ -299,9 +300,9 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0,
-	    (SCM MBOX, SCM MODE),
-"Returns a port associated with the contents of the MBOX.\n"
-"MODE is a string defining operation mode of the stream. It may\n"
+		   (SCM mbox, SCM mode),
+"Returns a port associated with the contents of the @var{mbox},\n"
+"which is a string defining operation mode of the stream. It may\n"
 "contain any of the two characters: @samp{r} for reading, @samp{w} for\n"
 "writing.\n")
 #define FUNC_NAME s_scm_mu_mailbox_get_port
@@ -312,105 +313,105 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0,
   char *s;
   SCM ret;
   
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
   status = mu_mailbox_get_stream (mum->mbox, &stream);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get mailbox stream",
-		  scm_list_1 (MBOX));
-  s = scm_to_locale_string (MODE);
-  ret = mu_port_make_from_stream (MBOX, stream, scm_mode_bits (s));
+		  scm_list_1 (mbox));
+  s = scm_to_locale_string (mode);
+  ret = mu_port_make_from_stream (mbox, stream, scm_mode_bits (s));
   free (s);
   return ret;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_message, "mu-mailbox-get-message", 2, 0, 0,
-            (SCM MBOX, SCM MSGNO), 
-"Retrieve from message #MSGNO from the mailbox MBOX.")
+		   (SCM mbox, SCM msgno), 
+"Retrieve from message #@var{msgno} from the mailbox @var{mbox}.")
 #define FUNC_NAME s_scm_mu_mailbox_get_message
 {
-  size_t msgno;
+  size_t n;
   struct mu_mailbox *mum;
   mu_message_t msg;
   int status;
     
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (scm_is_integer (MSGNO), MSGNO, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_integer (msgno), msgno, SCM_ARG2, FUNC_NAME);
 
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
-  msgno = scm_to_int32 (MSGNO);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
+  n = scm_to_size_t (msgno);
 
-  status = mu_mailbox_get_message (mum->mbox, msgno, &msg);
+  status = mu_mailbox_get_message (mum->mbox, n, &msg);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message ~A from mailbox ~A",
-		  scm_list_2 (MSGNO, MBOX));
+		  scm_list_2 (msgno, mbox));
     
-  return mu_scm_message_create (MBOX, msg);
+  return mu_scm_message_create (mbox, msg);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0,
-	    (SCM MBOX), 
-"Returns number of messages in the mailbox MBOX.")
+		   (SCM mbox), 
+"Returns number of messages in the mailbox @var{mbox}.")
 #define FUNC_NAME s_scm_mu_mailbox_messages_count
 {
   struct mu_mailbox *mum;
   size_t nmesg;
   int status;
   
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
 
   status = mu_mailbox_messages_count (mum->mbox, &nmesg);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot count messages in mailbox ~A",
-		  scm_list_1 (MBOX));
+		  scm_list_1 (mbox));
   return scm_from_size_t (nmesg);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_expunge, "mu-mailbox-expunge", 1, 0, 0,
-	    (SCM MBOX), 
-"Expunges deleted messages from the mailbox MBOX.")
+		   (SCM mbox), 
+"Expunges deleted messages from the mailbox @var{mbox}.")
 #define FUNC_NAME s_scm_mu_mailbox_expunge
 {
   struct mu_mailbox *mum;
   int status;
     
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
   status = mu_mailbox_expunge (mum->mbox);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot expunge messages in mailbox ~A",
-		  scm_list_1 (MBOX));
+		  scm_list_1 (mbox));
   return SCM_BOOL_T;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0,
-	    (SCM MBOX, SCM MESG),
-"Appends message MESG to the mailbox MBOX.")
+		   (SCM mbox, SCM mesg),
+		   "Appends message @var{mesg} to the mailbox @var{mbox}.")
 #define FUNC_NAME s_scm_mu_mailbox_append_message
 {
   struct mu_mailbox *mum;
   mu_message_t msg;
   int status;
     
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG2, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
+  msg = mu_scm_message_get (mesg);
   status = mu_mailbox_append_message (mum->mbox, msg);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot append message ~A to mailbox ~A",
-		  scm_list_2 (MESG, MBOX));
+		  scm_list_2 (mesg, mbox));
   return SCM_BOOL_T;
 }
 #undef FUNC_NAME
@@ -425,56 +426,56 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2
       if (status)				\
 	mu_scm_error (FUNC_NAME, status,	\
 		      "~A: " descr ": ~A",	\
-		      scm_list_2 (MBOX,		\
+		      scm_list_2 (mbox,		\
 				  scm_from_locale_string (mu_strerror (status)))); \
     }									\
   while (0)
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_first_message, "mu-mailbox-first-message", 1, 0, 0,
-	    (SCM MBOX),
-	    "Returns first message from the mailbox.")
+	    (SCM mbox),
+	    "Returns first message from the mailbox @var{mbox}.")
 #define FUNC_NAME s_scm_mu_mailbox_first_message
 {
   struct mu_mailbox *mum;
   int status;
   mu_message_t msg;
   
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
   if (!mum->itr)
     {
       status = mu_mailbox_get_iterator (mum->mbox, &mum->itr);
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "~A: cannot create iterator: ~A",
-		      scm_list_2 (MBOX,
+		      scm_list_2 (mbox,
 				  scm_from_locale_string (mu_strerror (status))));
     }
   ITROP (mu_iterator_first (mum->itr), "moving to the first message");
   ITROP (mu_iterator_current (mum->itr, (void**)&msg),
 	 "getting current message");
-  return mu_scm_message_create (MBOX, msg);
+  return mu_scm_message_create (mbox, msg);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0, 0,
-	    (SCM MBOX),
-	    "Returns next message from the mailbox.")
+		   (SCM mbox),
+	    "Returns next message from the mailbox @var{mbox}.")
 #define FUNC_NAME s_scm_mu_mailbox_next_message
 {
   struct mu_mailbox *mum;
   int status;
   mu_message_t msg;
   
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
   if (!mum->itr)
     {
       status = mu_mailbox_get_iterator (mum->mbox, &mum->itr);
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "~A: cannot create iterator: ~A",
-		      scm_list_2 (MBOX,
+		      scm_list_2 (mbox,
 				  scm_from_locale_string (mu_strerror (status))));
       ITROP (mu_iterator_first (mum->itr), "moving to the first message");
     }
@@ -483,27 +484,31 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0,
   
   ITROP (mu_iterator_current (mum->itr, (void**)&msg),
 	 "getting current message");
-  return mu_scm_message_create (MBOX, msg);
+  return mu_scm_message_create (mbox, msg);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?", 1, 0, 0,
-	    (SCM MBOX),
-	    "Returns next message from the mailbox.")
+		   (SCM mbox),
+"Returns @samp{#t} if there are more messages in the mailbox @var{mbox}\n"
+"ahead of current iterator position.  Usually this function is used after\n"
+"a call to @samp{mu-mailbox-first-message} or @samp{mu-mailbox-next-message}.\n"
+"If not, it initializes the iterator and points it to the first message inn"
+"the mailbox.")
 #define FUNC_NAME s_scm_mu_mailbox_more_messages_p
 {
   struct mu_mailbox *mum;
   int status;
   
-  SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_mailbox *) SCM_CDR (MBOX);
+  SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_mailbox *) SCM_CDR (mbox);
   if (!mum->itr)
     {
       status = mu_mailbox_get_iterator (mum->mbox, &mum->itr);
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "~A: cannot create iterator: ~A",
-		      scm_list_2 (MBOX,
+		      scm_list_2 (mbox,
 				  scm_from_locale_string (mu_strerror (status))));
       status = mu_iterator_first (mum->itr);
       if (status == MU_ERR_NOENT)
@@ -511,7 +516,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?",
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "~A: cannot set iterator to the first message: ~A",
-		      scm_list_2 (MBOX,
+		      scm_list_2 (mbox,
 				  scm_from_locale_string (mu_strerror (status))));
     }
   return scm_from_bool (!!mu_iterator_is_done (mum->itr));
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index d9e3386..27c96be 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -177,8 +177,8 @@ mu_scm_is_message (SCM scm)
 /* Guile primitives */
 
 SCM_DEFINE_PUBLIC (scm_mu_message_create, "mu-message-create", 0, 0, 0,
-	    (),
-	    "Creates an empty message.\n")
+		   (),
+		   "Creates an empty message.\n")
 #define FUNC_NAME s_scm_mu_message_create
 {
   mu_message_t msg;
@@ -189,8 +189,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_create, "mu-message-create", 0, 0, 0,
 
 /* FIXME: This changes envelope date */
 SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
-	    (SCM MESG),
-	    "Creates the copy of the message MESG.\n")
+		   (SCM mesg),
+		   "Creates a copy of the message @var{mesg}.\n")
 #define FUNC_NAME s_scm_mu_message_copy
 {
   mu_message_t msg, newmsg;
@@ -199,14 +199,14 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
   size_t off, n;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
 
   status = mu_message_get_stream (msg, &in);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get input stream from message ~A",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   
   status = mu_message_create (&newmsg, NULL);
   if (status)
@@ -250,44 +250,44 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_destroy, "mu-message-destroy", 1, 0, 0,
-	    (SCM MESG),
-	    "Destroys the message MESG.")
+		   (SCM mesg),
+		   "Destroys the message @var{mesg}.")
 #define FUNC_NAME s_scm_mu_message_destroy
 {
   struct mu_message *mum;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  mum = (struct mu_message *) SCM_CDR (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  mum = (struct mu_message *) SCM_CDR (mesg);
   mu_message_destroy (&mum->msg, mu_message_get_owner (mum->msg));
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0,
-	    (SCM MESG, SCM HEADER, SCM VALUE, SCM REPLACE),
-"Sets new VALUE to the header HEADER of the message MESG.\n"
-"If HEADER is already present in the message its value\n"
-"is replaced with the suplied one iff the optional REPLACE is\n"
-"#t. Otherwise, a new header is created and appended.")
+		   (SCM mesg, SCM header, SCM value, SCM replace),
+"Sets header @var{header} of the message @var{mesg} to new @var{value}.\n"
+"If @var{header} is already present in the message, its value\n"
+"is replaced with the suplied one iff the optional @var{replace} is\n"
+"@code{#t}. Otherwise, a new header is created and appended.")
 #define FUNC_NAME s_scm_mu_message_set_header
 {
   mu_message_t msg;
   mu_header_t hdr;
-  int replace = 0;
+  int repl = 0;
   int status;
   char *hdr_c, *val_c;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  SCM_ASSERT (scm_is_string (header), header, SCM_ARG2, FUNC_NAME);
 
-  if (scm_is_bool (VALUE))
-    return SCM_UNSPECIFIED;
+  if (scm_is_bool (value))
+    return SCM_UNSPECIFIED;/*FIXME: Exception*/
   
-  SCM_ASSERT (scm_is_string (VALUE), VALUE, SCM_ARG3, FUNC_NAME);
-  if (!SCM_UNBNDP (REPLACE))
+  SCM_ASSERT (scm_is_string (value), value, SCM_ARG3, FUNC_NAME);
+  if (!SCM_UNBNDP (replace))
     {
-      replace = REPLACE == SCM_BOOL_T;
+      repl = replace == SCM_BOOL_T;
     }
   
   status = mu_message_get_header (msg, &hdr);
@@ -295,52 +295,52 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0,
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message headers", SCM_BOOL_F);
 
-  hdr_c = scm_to_locale_string (HEADER);
-  val_c = scm_to_locale_string (VALUE);
-  status = mu_header_set_value (hdr, hdr_c, val_c, replace);
+  hdr_c = scm_to_locale_string (header);
+  val_c = scm_to_locale_string (value);
+  status = mu_header_set_value (hdr, hdr_c, val_c, repl);
   free (hdr_c);
   free (val_c);
   
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot set header \"~A: ~A\" in message ~A",
-		  scm_list_3 (HEADER, VALUE, MESG));
+		  scm_list_3 (header, value, mesg));
   
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_size, "mu-message-get-size", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns the size of the message MESG\n.")
+		   (SCM mesg),
+		   "Returns size of the message @var{mesg}\n.")
 #define FUNC_NAME s_scm_mu_message_get_size
 {
   mu_message_t msg;
   size_t size;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   mu_message_size (msg, &size);
   return scm_from_size_t (size);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_lines, "mu-message-get-lines", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns number of lines in the given message.\n")
+		   (SCM mesg),
+		   "Returns number of lines in the message @var{msg}.\n")
 #define FUNC_NAME s_scm_mu_message_get_lines
 {
   mu_message_t msg;
   size_t lines;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   status = mu_message_lines (msg, &lines);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get number of lines in message ~A",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
 
   return scm_from_size_t (lines);
 }
@@ -368,8 +368,8 @@ filltime (struct tm *bd_time, int zoff, const char *zname)
 }
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope, "mu-message-get-envelope", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns envelope date of the message MESG.\n")
+		   (SCM mesg),
+		   "Returns envelope date of the message @var{mesg}.\n")
 #define FUNC_NAME s_scm_mu_message_get_envelope
 {
   mu_message_t msg;
@@ -379,20 +379,20 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope, "mu-message-get-envelope", 1, 0,
   const char *date;
   size_t dlen;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   status = mu_message_get_envelope (msg, &env);
   if (status)
     mu_scm_error (FUNC_NAME, status, "cannot get envelope",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   status = mu_envelope_sget_sender (env, &sender);
   if (status)
     mu_scm_error (FUNC_NAME, status, "cannot get envelope sender",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   status = mu_envelope_sget_date (env, &date);
   if (status)
     mu_scm_error (FUNC_NAME, status, "cannot get envelope date",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   dlen = strlen (date);
   if (date[dlen-1] == '\n')
     dlen--;
@@ -403,8 +403,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope, "mu-message-get-envelope", 1, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope_date, "mu-message-get-envelope-date", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns envelope date of the message MESG.\n")
+		   (SCM mesg),
+		   "Returns envelope date of the message @var{mesg}.\n")
 #define FUNC_NAME s_scm_mu_message_get_envelope_date
 {
   mu_message_t msg;
@@ -414,16 +414,16 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope_date, "mu-message-get-envelope-da
   struct tm tm;
   mu_timezone tz;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   status = mu_message_get_envelope (msg, &env);
   if (status)
     mu_scm_error (FUNC_NAME, status, "cannot get envelope",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   status = mu_envelope_sget_date (env, &sdate);
   if (status)
     mu_scm_error (FUNC_NAME, status, "cannot get envelope date",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   status = mu_parse_ctime_date_time (&sdate, &tm, &tz);
   if (status)
     mu_scm_error (FUNC_NAME, status, "invalid envelope date",
@@ -433,8 +433,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_envelope_date, "mu-message-get-envelope-da
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns email address of the sender of the message MESG.\n")
+		   (SCM mesg),
+	   "Returns email address of the sender of the message @var{mesg}.\n")
 #define FUNC_NAME s_scm_mu_message_get_sender
 {
   mu_message_t msg;
@@ -442,8 +442,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
   int status;
   SCM ret;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   status = mu_message_get_envelope (msg, &env);
   if (status == 0)
     {
@@ -454,14 +454,14 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
   else
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get envelope of message ~A",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   return ret;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0,
-	    (SCM MESG, SCM HEADER),
-	    "Returns value of the header HEADER from the message MESG.\n")
+		   (SCM mesg, SCM header),
+"Returns value of the header @var{header} from the message @var{mesg}.\n")
 #define FUNC_NAME s_scm_mu_message_get_header
 {
   mu_message_t msg;
@@ -471,15 +471,15 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0,
   SCM ret;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  SCM_ASSERT (scm_is_string (header), header, SCM_ARG2, FUNC_NAME);
   status = mu_message_get_header (msg, &hdr);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message headers", SCM_BOOL_F);
 
-  header_string = scm_to_locale_string (HEADER);
+  header_string = scm_to_locale_string (header);
   status = mu_header_aget_value (hdr, header_string, &value);
   free (header_string);
   switch (status)
@@ -496,7 +496,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0,
     default:
       mu_scm_error (FUNC_NAME, status,
 		    "Cannot get header ~A from message ~A",
-		    scm_list_2 (HEADER, MESG));
+		    scm_list_2 (header, mesg));
     }
 
   return ret;
@@ -518,25 +518,23 @@ string_sloppy_member (SCM lst, char *name)
 }
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, 1, 0,
-	    (SCM MESG, SCM HEADERS),
-"Returns the list of headers in the message MESG. Optional argument\n" 
-"HEADERS gives a list of header names to restrict return value to.\n")
+		   (SCM mesg, SCM headers),
+"Returns list of headers in the message @var{mesg}. optional argument\n" 
+"@var{headers} gives a list of header names to restrict return value to.\n")
 #define FUNC_NAME s_scm_mu_message_get_header_fields
 {
   size_t i, nfields = 0;
   mu_message_t msg;
   mu_header_t hdr = NULL;
   SCM scm_first = SCM_EOL, scm_last = SCM_EOL;
-  SCM headers = SCM_EOL;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  if (!SCM_UNBNDP (HEADERS))
-    {
-      SCM_ASSERT (scm_is_pair (HEADERS), HEADERS, SCM_ARG2, FUNC_NAME);
-      headers = HEADERS;
-    }
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  if (SCM_UNBNDP (headers))
+    headers = SCM_EOL;
+  else
+    SCM_ASSERT (scm_is_pair (headers), headers, SCM_ARG2, FUNC_NAME);
 
   status = mu_message_get_header (msg, &hdr);
   if (status)
@@ -556,7 +554,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_header_fields, "mu-message-get-header-fiel
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "Cannot get header field ~A, message ~A",
-		      scm_list_2 (scm_from_size_t (i), MESG));
+		      scm_list_2 (scm_from_size_t (i), mesg));
       
       if (!scm_is_null (headers) && string_sloppy_member (headers, name) == 0)
 	continue;
@@ -564,7 +562,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_header_fields, "mu-message-get-header-fiel
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "Cannot get header value ~A, message ~A",
-		      scm_list_2 (scm_from_size_t (i), MESG));
+		      scm_list_2 (scm_from_size_t (i), mesg));
 
       scm_name = scm_from_locale_string (name);
       scm_value = scm_from_locale_string (value);
@@ -584,29 +582,27 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_header_fields, "mu-message-get-header-fiel
 #undef FUNC_NAME
   
 SCM_DEFINE_PUBLIC (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, 1, 0,
-	    (SCM MESG, SCM LIST, SCM REPLACE),
-"Set the headers in the message MESG from LIST\n"
-"LIST is a list of conses (cons HEADER VALUE).  The function sets\n"
-"these headers in the message MESG.\n"
-"Optional parameter REPLACE specifies whether the new header\n"
+		   (SCM mesg, SCM list, SCM replace),
+"Set headers in the message @var{mesg} to those listed in @var{list},\n"
+"which is a list of conses @code{(cons @var{header} @var{value})}.\n\n"
+"Optional parameter @var{replace} specifies whether new header\n"
 "values should replace the headers already present in the\n"
 "message.")
 #define FUNC_NAME s_scm_mu_message_set_header_fields
 {
   mu_message_t msg;
   mu_header_t hdr;
-  SCM list;
-  int replace = 0;
+  int repl = 0;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (scm_is_null (LIST) || scm_is_pair (LIST),
-	      LIST, SCM_ARG2, FUNC_NAME);
-  if (!SCM_UNBNDP (REPLACE))
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  SCM_ASSERT (scm_is_null (list) || scm_is_pair (list),
+	      list, SCM_ARG2, FUNC_NAME);
+  if (!SCM_UNBNDP (replace))
     {
-      SCM_ASSERT (scm_is_bool (REPLACE), REPLACE, SCM_ARG3, FUNC_NAME);
-      replace = REPLACE == SCM_BOOL_T;
+      SCM_ASSERT (scm_is_bool (replace), replace, SCM_ARG3, FUNC_NAME);
+      repl = replace == SCM_BOOL_T;
     }
 
   status = mu_message_get_header (msg, &hdr);
@@ -614,7 +610,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_header_fields, "mu-message-set-header-fiel
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message headers", SCM_BOOL_F);
 
-  for (list = LIST; !scm_is_null (list); list = SCM_CDR (list))
+  for (; !scm_is_null (list); list = SCM_CDR (list))
     {
       SCM cell = SCM_CAR (list);
       SCM car, cdr;
@@ -627,13 +623,13 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_header_fields, "mu-message-set-header-fiel
       SCM_ASSERT (scm_is_string (cdr), cdr, SCM_ARGn, FUNC_NAME);
       hdr_c = scm_to_locale_string (car);
       val_c = scm_to_locale_string (cdr);
-      status = mu_header_set_value (hdr, hdr_c, val_c, replace);
+      status = mu_header_set_value (hdr, hdr_c, val_c, repl);
       free (hdr_c);
       free (val_c);
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "Cannot set header value: message ~A, header ~A, value ~A",
-		      scm_list_3 (MESG, car, cdr));
+		      scm_list_3 (mesg, car, cdr));
 
     }
   return SCM_UNSPECIFIED;
@@ -641,10 +637,10 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_header_fields, "mu-message-set-header-fiel
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_delete, "mu-message-delete", 1, 1, 0,
-	    (SCM MESG, SCM FLAG),
-"Mark the message MESG as deleted. Optional argument FLAG allows to toggle\n"
-"deletion mark. The message is deleted if it is @code{#t} and undeleted if\n"
-"it is @code{#f}")
+		   (SCM mesg, SCM flag),
+"Mark message @var{mesg} as deleted. Optional argument @var{flag} allows to\n"
+"toggle the deletion mark. The message is deleted if it is @code{#t} and\n"
+"undeleted if it is @code{#f}.")
 #define FUNC_NAME s_scm_mu_message_delete
 {
   mu_message_t msg;
@@ -652,12 +648,12 @@ SCM_DEFINE_PUBLIC (scm_mu_message_delete, "mu-message-delete", 1, 1, 0,
   int delete = 1;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  if (!SCM_UNBNDP (FLAG))
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  if (!SCM_UNBNDP (flag))
     {
-      SCM_ASSERT (scm_is_bool (FLAG), FLAG, SCM_ARG2, FUNC_NAME);
-      delete = FLAG == SCM_BOOL_T;
+      SCM_ASSERT (scm_is_bool (flag), flag, SCM_ARG2, FUNC_NAME);
+      delete = flag == SCM_BOOL_T;
     }
   status = mu_message_get_attribute (msg, &attr);
   if (status)
@@ -678,8 +674,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_delete, "mu-message-delete", 1, 1, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0,
-	    (SCM MESG, SCM FLAG),
-"Return value of the attribute FLAG of the message MESG.")
+		   (SCM mesg, SCM flag),
+"Return the value of the attribute @var{flag} of the message @var{mesg}.")
 #define FUNC_NAME s_scm_mu_message_get_flag
 {
   mu_message_t msg;
@@ -687,16 +683,16 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0,
   int ret = 0;
   int status;
     
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  SCM_ASSERT (scm_is_integer (flag), flag, SCM_ARG2, FUNC_NAME);
 
   status = mu_message_get_attribute (msg, &attr);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message attribute", SCM_BOOL_F);
   
-  switch (scm_to_int32 (FLAG))
+  switch (scm_to_int (flag))
     {
     case MU_ATTRIBUTE_ANSWERED:
       ret = mu_attribute_is_answered (attr);
@@ -732,31 +728,31 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0,
       
     default:
       mu_attribute_get_flags (attr, &ret);
-      ret &= scm_to_int32 (FLAG);
+      ret &= scm_to_int (flag);
     }
   return ret ? SCM_BOOL_T : SCM_BOOL_F;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0,
-	    (SCM MESG, SCM FLAG, SCM VALUE),
-"Set the attribute FLAG of the message MESG. If optional VALUE is #f, the\n"
-"attribute is unset.")
+		   (SCM mesg, SCM flag, SCM value),
+"Set the attribute @var{flag} in message @var{mesg}. If optional @var{value}\n"
+"is @samp{#f}, the attribute is unset.\n")
 #define FUNC_NAME s_scm_mu_message_set_flag
 {
   mu_message_t msg;
   mu_attribute_t attr;
-  int value = 1;
+  int val = 1;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  SCM_ASSERT (scm_is_integer (flag), flag, SCM_ARG2, FUNC_NAME);
 
-  if (!SCM_UNBNDP (VALUE))
+  if (!SCM_UNBNDP (value))
     {
-      SCM_ASSERT (scm_is_bool (VALUE), VALUE, SCM_ARG3, FUNC_NAME);
-      value = VALUE == SCM_BOOL_T;
+      SCM_ASSERT (scm_is_bool (value), value, SCM_ARG3, FUNC_NAME);
+      val = value == SCM_BOOL_T;
     }
   
   status = mu_message_get_attribute (msg, &attr);
@@ -765,67 +761,67 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0,
 		  "Cannot get message attribute", SCM_BOOL_F);
 
   status = 0;
-  switch (scm_to_int32 (FLAG))
+  switch (scm_to_int (flag))
     {
     case MU_ATTRIBUTE_ANSWERED:
-      if (value)
+      if (val)
 	status = mu_attribute_set_answered (attr);
       else
 	status = mu_attribute_unset_answered (attr);
       break;
       
     case MU_ATTRIBUTE_FLAGGED:
-      if (value)
+      if (val)
 	status = mu_attribute_set_flagged (attr);
       else
 	status = mu_attribute_unset_flagged (attr);
       break;
       
     case MU_ATTRIBUTE_DELETED:
-      if (value)
+      if (val)
 	status = mu_attribute_set_deleted (attr);
       else
 	status = mu_attribute_unset_deleted (attr);
       break;
       
     case MU_ATTRIBUTE_DRAFT:
-      if (value)
+      if (val)
 	status = mu_attribute_set_draft (attr);
       else
 	status = mu_attribute_unset_draft (attr);
       break;
       
     case MU_ATTRIBUTE_SEEN:
-      if (value)
+      if (val)
 	status = mu_attribute_set_seen (attr);
       else
 	status = mu_attribute_unset_seen (attr);
       break;
       
     case MU_ATTRIBUTE_READ:
-      if (value)
+      if (val)
 	status = mu_attribute_set_read (attr);
       else
 	status = mu_attribute_unset_read (attr);
       break;
       
     case MU_ATTRIBUTE_MODIFIED:
-      if (value)
+      if (val)
 	status = mu_attribute_set_modified (attr);
       else
 	status = mu_attribute_clear_modified (attr);
       break;
       
     case MU_ATTRIBUTE_RECENT:
-      if (value)
+      if (val)
 	status = mu_attribute_set_recent (attr);
       else
 	status = mu_attribute_unset_recent (attr);
       break;
       
     default:
-      if (value)
-	status = mu_attribute_set_flags (attr, scm_to_int32 (FLAG));
+      if (val)
+	status = mu_attribute_set_flags (attr, scm_to_int (flag));
     }
   
   if (status)
@@ -837,31 +833,31 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_user_flag, "mu-message-get-user-flag", 2, 0, 0,
-	    (SCM MESG, SCM FLAG),
-"Return the value of the user attribute FLAG from the message MESG.")
+		   (SCM mesg, SCM flag),
+"Return value of the user-defined attribute @var{flag} from the message @var{mesg}.")
 #define FUNC_NAME s_scm_mu_message_get_user_flag
 {
   mu_message_t msg;
   mu_attribute_t attr;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  SCM_ASSERT (scm_is_integer (flag), flag, SCM_ARG2, FUNC_NAME);
   status = mu_message_get_attribute (msg, &attr);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message attribute", SCM_BOOL_F);
-  return mu_attribute_is_userflag (attr, scm_to_int32 (FLAG)) ?
-                                SCM_BOOL_T : SCM_BOOL_F;
+  return mu_attribute_is_userflag (attr, scm_to_int (flag)) ?
+                                   SCM_BOOL_T : SCM_BOOL_F;
 }
 #undef FUNC_NAME
   
 
 SCM_DEFINE_PUBLIC (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0,
-	    (SCM MESG, SCM FLAG, SCM VALUE),
-"Set the given user attribute FLAG in the message MESG. If optional argumen\n"
-"VALUE is @samp{#f}, the attribute is unset.")
+		   (SCM mesg, SCM flag, SCM value),
+"Set user-defined attribute @var{flag} in the message @var{mesg}.\n"
+"If optional argumen @var{value} is @samp{#f}, the attribute is unset.")
 #define FUNC_NAME s_scm_mu_message_set_user_flag
 {
   mu_message_t msg;
@@ -869,14 +865,14 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2,
   int set = 1;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
-  SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
+  SCM_ASSERT (scm_is_integer (flag), flag, SCM_ARG2, FUNC_NAME);
 
-  if (!SCM_UNBNDP (VALUE))
+  if (!SCM_UNBNDP (value))
     {
-      SCM_ASSERT (scm_is_bool (VALUE), VALUE, SCM_ARG3, FUNC_NAME);
-      set = VALUE == SCM_BOOL_T;
+      SCM_ASSERT (scm_is_bool (value), value, SCM_ARG3, FUNC_NAME);
+      set = value == SCM_BOOL_T;
     }
   
   status = mu_message_get_attribute (msg, &attr);
@@ -885,19 +881,19 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2,
 		  "Cannot get message attribute", SCM_BOOL_F);
   
   if (set)
-    mu_attribute_set_userflag (attr, scm_to_int32 (FLAG));
+    mu_attribute_set_userflag (attr, scm_to_int (flag));
   else
-    mu_attribute_unset_userflag (attr, scm_to_int32 (FLAG));
+    mu_attribute_unset_userflag (attr, scm_to_int (flag));
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
-	    (SCM MESG, SCM MODE, SCM FULL),
-"Returns a port associated with the given MESG. MODE is a string\n"
-"defining operation mode of the stream. It may contain any of the\n"
+		   (SCM mesg, SCM mode, SCM full),
+"Returns a port associated with the message @var{mesg}. The @var{mode} is a\n"
+"string defining operation mode of the stream. It may contain any of the\n"
 "two characters: @samp{r} for reading, @samp{w} for writing.\n"
-"If optional argument FULL is specified, it should be a boolean value.\n"
+"If optional argument @var{full} is specified, it should be a boolean value.\n"
 "If it is @samp{#t} then the returned port will allow access to any\n"
 "part of the message (including headers). If it is @code{#f} then the port\n"
 "accesses only the message body (the default).\n")
@@ -909,15 +905,15 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
   char *str;
   SCM ret;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME);
 
-  msg = mu_scm_message_get (MESG);
+  msg = mu_scm_message_get (mesg);
 
-  if (!SCM_UNBNDP (FULL))
+  if (!SCM_UNBNDP (full))
     {
-      SCM_ASSERT (scm_is_bool (FULL), FULL, SCM_ARG3, FUNC_NAME);
-      if (FULL == SCM_BOOL_T)
+      SCM_ASSERT (scm_is_bool (full), full, SCM_ARG3, FUNC_NAME);
+      if (full == SCM_BOOL_T)
 	{
 	  status = mu_message_get_stream (msg, &stream);
 	  if (status)
@@ -940,8 +936,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
 		      SCM_BOOL_F);
     }
 
-  str = scm_to_locale_string (MODE);
-  ret = mu_port_make_from_stream (MESG, stream, scm_mode_bits (str));
+  str = scm_to_locale_string (mode);
+  ret = mu_port_make_from_stream (mesg, stream, scm_mode_bits (str));
   free (str);
   return ret;
 }
@@ -949,42 +945,42 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
   
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_body, "mu-message-get-body", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns the message body for the message MESG.")
+		   (SCM mesg),
+		   "Returns message body for the message @var{mesg}.")
 #define FUNC_NAME s_scm_mu_message_get_body
 {
   mu_message_t msg;
   mu_body_t body = NULL;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   status = mu_message_get_body (msg, &body);
   if (status)
     mu_scm_error (FUNC_NAME, status, "Cannot get message body", SCM_BOOL_F);
-  return mu_scm_body_create (MESG, body);
+  return mu_scm_body_create (mesg, body);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_multipart_p, "mu-message-multipart?", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns @code{#t} if MESG is a multipart @acronym{MIME} message.")
+		   (SCM mesg),
+"Returns @code{#t} if @var{mesg} is a multipart @acronym{MIME} message.")
 #define FUNC_NAME s_scm_mu_message_multipart_p
 {
   mu_message_t msg;
   int ismime = 0;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   mu_message_is_multipart (msg, &ismime);
   return ismime ? SCM_BOOL_T : SCM_BOOL_F;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1, 0, 0,
-	    (SCM MESG),
-"Returns number of parts in a multipart @acronym{MIME} message. Returns\n"
-"@code{#f} if the argument is not a multipart message.")
+		   (SCM mesg),
+"Returns number of parts in a multipart @acronym{MIME} message @var{mesg}.\n"
+"Returns @code{#f} if the argument is not a multipart message.")
 #define FUNC_NAME s_scm_mu_message_get_num_parts
 {
   mu_message_t msg;
@@ -992,8 +988,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1,
   size_t nparts = 0;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   mu_message_is_multipart (msg, &ismime);
   if (!ismime)
     return SCM_BOOL_F;
@@ -1002,58 +998,59 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1,
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get number of parts in the message ~A",
-		  scm_list_1 (MESG));
+		  scm_list_1 (mesg));
   return scm_from_size_t (nparts);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_part, "mu-message-get-part", 2, 0, 0,
-	    (SCM MESG, SCM PART),
-"Returns part #PART from a multipart @acronym{MIME} message MESG.")
+		   (SCM mesg, SCM part),
+"Returns part #@var{part} of a multipart @acronym{MIME} message @var{mesg}.")
 #define FUNC_NAME s_scm_mu_message_get_part
 {
   mu_message_t msg, submsg;
   int ismime = 0;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (scm_is_integer (PART), PART, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_integer (part), part, SCM_ARG2, FUNC_NAME);
 
-  msg = mu_scm_message_get (MESG);
+  msg = mu_scm_message_get (mesg);
   mu_message_is_multipart (msg, &ismime);
   if (!ismime)
     return SCM_BOOL_F;
 
-  status = mu_message_get_part (msg, scm_to_int32 (PART), &submsg);
+  status = mu_message_get_part (msg, scm_to_size_t (part), &submsg);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get number of part ~A from the message ~A",
-		  scm_list_2 (PART, MESG));
+		  scm_list_2 (part, mesg));
 
-  return mu_scm_message_create (MESG, submsg);
+  return mu_scm_message_create (mesg, submsg);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_send, "mu-message-send", 1, 3, 0,
-	    (SCM MESG, SCM MAILER, SCM FROM, SCM TO),
-"Sends the message MESG. Optional MAILER overrides default mailer settings\n"
-"in mu-mailer. Optional FROM and TO give sender and recever addresses.\n")
+		   (SCM mesg, SCM mailer, SCM from, SCM to),
+"Sends message @var{mesg}. Optional @var{mailer} overrides default mailer\n"
+"settings. Optional @var{from} and @var{to} give sender and recever\n"
+"addresses, respectively.\n")
 #define FUNC_NAME s_scm_mu_message_send
 {
   char *mailer_name;
-  mu_address_t from = NULL;
-  mu_address_t to = NULL;
-  mu_mailer_t mailer = NULL;
+  mu_address_t from_addr = NULL;
+  mu_address_t to_addr = NULL;
+  mu_mailer_t mailer_c = NULL;
   mu_message_t msg;
   int status;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   
-  if (!SCM_UNBNDP (MAILER) && MAILER != SCM_BOOL_F)
+  if (!SCM_UNBNDP (mailer) && mailer != SCM_BOOL_F)
     {
-      SCM_ASSERT (scm_is_string (MAILER), MAILER, SCM_ARG2, FUNC_NAME);
-      mailer_name = scm_to_locale_string (MAILER);
+      SCM_ASSERT (scm_is_string (mailer), mailer, SCM_ARG2, FUNC_NAME);
+      mailer_name = scm_to_locale_string (mailer);
     }
   else
     {
@@ -1061,74 +1058,74 @@ SCM_DEFINE_PUBLIC (scm_mu_message_send, "mu-message-send", 1, 3, 0,
       mailer_name = scm_to_locale_string (val);
     }
   
-  if (!SCM_UNBNDP (FROM) && FROM != SCM_BOOL_F)
+  if (!SCM_UNBNDP (from) && from != SCM_BOOL_F)
     {
       char *s;
       int rc;
       
-      SCM_ASSERT (scm_is_string (FROM), FROM, SCM_ARG3, FUNC_NAME);
-      s = scm_to_locale_string (FROM);
-      rc = mu_address_create (&from, s);
+      SCM_ASSERT (scm_is_string (from), from, SCM_ARG3, FUNC_NAME);
+      s = scm_to_locale_string (from);
+      rc = mu_address_create (&from_addr, s);
       free (s);
       if (rc)
 	mu_scm_error (FUNC_NAME, rc, "cannot create address",
-		      scm_list_1 (FROM));
+		      scm_list_1 (from));
     }
   
-  if (!SCM_UNBNDP (TO) && TO != SCM_BOOL_F)
+  if (!SCM_UNBNDP (to) && to != SCM_BOOL_F)
     {
       char *s;
       int rc;
       
-      SCM_ASSERT (scm_is_string (TO), TO, SCM_ARG4, FUNC_NAME);
-      s = scm_to_locale_string (TO);
-      rc = mu_address_create (&to, s);
+      SCM_ASSERT (scm_is_string (to), to, SCM_ARG4, FUNC_NAME);
+      s = scm_to_locale_string (to);
+      rc = mu_address_create (&to_addr, s);
       free (s);
       if (rc)
 	mu_scm_error (FUNC_NAME, rc, "cannot create address",
-		      scm_list_1 (TO));
+		      scm_list_1 (to));
     }
 
-  status = mu_mailer_create (&mailer, mailer_name);
+  status = mu_mailer_create (&mailer_c, mailer_name);
   free (mailer_name);
   if (status)
     mu_scm_error (FUNC_NAME, status, "Cannot get create mailer", SCM_BOOL_F);
 
-  if (scm_to_int32 (MU_SCM_SYMBOL_VALUE ("mu-debug")))
+  if (scm_to_int (MU_SCM_SYMBOL_VALUE ("mu-debug")))
     {
       mu_debug_t debug = NULL;
-      mu_mailer_get_debug (mailer, &debug);
+      mu_mailer_get_debug (mailer_c, &debug);
       mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
     }
 
-  status = mu_mailer_open (mailer, MU_STREAM_RDWR);
+  status = mu_mailer_open (mailer_c, MU_STREAM_RDWR);
   if (status == 0)
     {
-      status = mu_mailer_send_message (mailer, msg, from, to);
+      status = mu_mailer_send_message (mailer_c, msg, from_addr, to_addr);
       if (status)
 	mu_scm_error (FUNC_NAME, status, "Cannot send message", SCM_BOOL_F);
 
-      mu_mailer_close (mailer);
+      mu_mailer_close (mailer_c);
     }
   else
     mu_scm_error (FUNC_NAME, status, "Cannot open mailer", SCM_BOOL_F);
-  mu_mailer_destroy (&mailer);
+  mu_mailer_destroy (&mailer_c);
   
   return status == 0 ? SCM_BOOL_T : SCM_BOOL_F;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_message_get_uid, "mu-message-get-uid", 1, 0, 0,
-	    (SCM MESG),
-	    "Returns uid of the message MESG\n")
+		   (SCM mesg),
+	    "Returns UID of the message @var{mesg}\n")
 #define FUNC_NAME s_scm_mu_message_get_uid
 {
   mu_message_t msg;
   int status;
   size_t uid;
   
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
+  msg = mu_scm_message_get (mesg);
   status = mu_message_get_uid (msg, &uid);
   if (status)
     mu_scm_error (FUNC_NAME, status, "Cannot get message uid", SCM_BOOL_F);
diff --git a/libmu_scm/mu_mime.c b/libmu_scm/mu_mime.c
index c8f512b..2c90037 100644
--- a/libmu_scm/mu_mime.c
+++ b/libmu_scm/mu_mime.c
@@ -90,65 +90,66 @@ mu_scm_is_mime (SCM scm)
 /* Guile primitives */
 
 SCM_DEFINE_PUBLIC (scm_mu_mime_create, "mu-mime-create", 0, 2, 0,
-	    (SCM FLAGS, SCM MESG),
+		   (SCM flags, SCM mesg),
 "Creates a new @acronym{MIME} object.  Both arguments are optional.\n"
-"FLAGS specifies the type of the object to create (@samp{0} is a reasonable\n"
-"value).  MESG gives the message to create the @acronym{MIME} object from.")
+"@var{Flags} specifies the type of the object to create (@samp{0} is a\n"
+"reasonable value).  @var{mesg} gives the message to create the\n"
+"@acronym{MIME} object from.")
 #define FUNC_NAME s_scm_mu_mime_create
 {
   mu_message_t msg = NULL;
   mu_mime_t mime;
-  int flags;
+  int fl;
   int status;
   
-  if (scm_is_bool (FLAGS))
+  if (scm_is_bool (flags))
     {
-      /*if (FLAGS == SCM_BOOL_F)*/
-      flags = 0;
+      /*if (flags == SCM_BOOL_F)*/
+      fl = 0;
     }
   else
     {
-      SCM_ASSERT (scm_is_integer (FLAGS), FLAGS, SCM_ARG1, FUNC_NAME);
-      flags = scm_to_int32 (FLAGS);
+      SCM_ASSERT (scm_is_integer (flags), flags, SCM_ARG1, FUNC_NAME);
+      fl = scm_to_int (flags);
     }
   
-  if (!SCM_UNBNDP (MESG))
+  if (!SCM_UNBNDP (mesg))
     {
-      SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME);
-      msg = mu_scm_message_get (MESG);
+      SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG2, FUNC_NAME);
+      msg = mu_scm_message_get (mesg);
     }
   
-  status = mu_mime_create (&mime, msg, flags);
+  status = mu_mime_create (&mime, msg, fl);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot create MIME object", SCM_BOOL_F);
   
-  return mu_scm_mime_create (MESG, mime);
+  return mu_scm_mime_create (mesg, mime);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mime_multipart_p, "mu-mime-multipart?", 1, 0, 0,
-	    (SCM MIME),
-"Returns @code{#t} if MIME is a multipart object.\n")
+		   (SCM mime),
+"Returns @code{#t} if @var{mime} is a multipart object.\n")
 #define FUNC_NAME s_scm_mu_mime_multipart_p
 {
-  SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME);
-  return mu_mime_is_multipart (mu_scm_mime_get (MIME)) ? SCM_BOOL_T : SCM_BOOL_F;
+  SCM_ASSERT (mu_scm_is_mime (mime), mime, SCM_ARG1, FUNC_NAME);
+  return mu_mime_is_multipart (mu_scm_mime_get (mime)) ? SCM_BOOL_T : SCM_BOOL_F;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0,
-	    (SCM MIME),
-"Returns number of parts in the @sc{mime} object MIME.")
+		   (SCM mime),
+"Returns number of parts in the @acronym{MIME} object @var{mime}.")
 #define FUNC_NAME s_scm_mu_mime_get_num_parts
 {
-  mu_mime_t mime;
+  mu_mime_t mimeobj;
   size_t nparts;
   int status;
   
-  SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME);
-  mime = mu_scm_mime_get (MIME);
-  status = mu_mime_get_num_parts (mime, &nparts);
+  SCM_ASSERT (mu_scm_is_mime (mime), mime, SCM_ARG1, FUNC_NAME);
+  mimeobj = mu_scm_mime_get (mime);
+  status = mu_mime_get_num_parts (mimeobj, &nparts);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot count MIME parts", SCM_BOOL_F);
@@ -157,71 +158,71 @@ SCM_DEFINE_PUBLIC (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mime_get_part, "mu-mime-get-part", 2, 0, 0,
-	    (SCM MIME, SCM NUM),
-	    "Returns NUMth part from the @sc{mime} object MIME.")
+		   (SCM mime, SCM num),
+"Returns @var{num}th part from the @acronym{MIME} object @var{mime}.")
 #define FUNC_NAME s_scm_mu_mime_get_part
 {
   mu_message_t msg = NULL;
   int status;
   
-  SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (scm_is_integer (NUM), NUM, SCM_ARG2, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_mime (mime), mime, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (scm_is_integer (num), num, SCM_ARG2, FUNC_NAME);
   
-  status = mu_mime_get_part (mu_scm_mime_get (MIME),
-			     scm_to_int32 (NUM), &msg);
+  status = mu_mime_get_part (mu_scm_mime_get (mime),
+			     scm_to_int (num), &msg);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get part ~A from MIME object ~A",
-		  scm_list_2 (NUM, MIME));
+		  scm_list_2 (num, mime));
   
-  return mu_scm_message_create (MIME, msg);
+  return mu_scm_message_create (mime, msg);
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mime_add_part, "mu-mime-add-part", 2, 0, 0,
-	    (SCM MIME, SCM MESG),
-	    "Adds MESG to the @sc{mime} object MIME.")
+		   (SCM mime, SCM mesg),
+"Adds message @var{mesg} to the @acronym{MIME} object @var{mime}.")
 #define FUNC_NAME s_scm_mu_mime_add_part
 {
-  mu_mime_t mime;
+  mu_mime_t mimeobj;
   mu_message_t msg;
   int status;
   
-  SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME);
-  SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME);
-  mime = mu_scm_mime_get (MIME);
-  msg = mu_scm_message_get (MESG);
+  SCM_ASSERT (mu_scm_is_mime (mime), mime, SCM_ARG1, FUNC_NAME);
+  SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG2, FUNC_NAME);
+  mimeobj = mu_scm_mime_get (mime);
+  msg = mu_scm_message_get (mesg);
 
-  status = mu_mime_add_part (mime, msg);
+  status = mu_mime_add_part (mimeobj, msg);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot add new part to MIME object ~A",
-		  scm_list_1 (MIME));
+		  scm_list_1 (mime));
   
-  mu_scm_message_add_owner (MESG, MIME);
+  mu_scm_message_add_owner (mesg, mime);
   
   return SCM_BOOL_T;
 }
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_mime_get_message, "mu-mime-get-message", 1, 0, 0,
-	    (SCM MIME),
-	    "Converts @sc{mime} object MIME to a message.\n")
+		   (SCM mime),
+"Converts @acronym{MIME} object @var{mime} to a message.\n")
 #define FUNC_NAME s_scm_mu_mime_get_message
 {
-  mu_mime_t mime;
+  mu_mime_t mimeobj;
   mu_message_t msg;
   int status;
   
-  SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME);
-  mime = mu_scm_mime_get (MIME);
-  status = mu_mime_get_message (mime, &msg);
+  SCM_ASSERT (mu_scm_is_mime (mime), mime, SCM_ARG1, FUNC_NAME);
+  mimeobj = mu_scm_mime_get (mime);
+  status = mu_mime_get_message (mimeobj, &msg);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get message from MIME object ~A",
-		  scm_list_1 (MIME));
+		  scm_list_1 (mime));
 
-  return mu_scm_message_create (MIME, msg);
+  return mu_scm_message_create (mime, msg);
 }
 #undef FUNC_NAME
 
diff --git a/libmu_scm/mu_scm.c b/libmu_scm/mu_scm.c
index ddfa8d9..f5d3f4c 100644
--- a/libmu_scm/mu_scm.c
+++ b/libmu_scm/mu_scm.c
@@ -89,7 +89,7 @@ register_format (const char *name)
     
 
 SCM_DEFINE_PUBLIC (scm_mu_register_format, "mu-register-format", 0, 0, 1,
-	    (SCM REST),
+		   (SCM rest),
 "Registers desired mailutils formats.  Any number of arguments can be given.\n"
 "Each argument must be one of the following strings:\n\n"
 "@multitable @columnfractions 0.3 0.6\n"
@@ -108,7 +108,7 @@ SCM_DEFINE_PUBLIC (scm_mu_register_format, "mu-register-format", 0, 0, 1,
 {
   int status;
 
-  if (scm_is_null (REST))
+  if (scm_is_null (rest))
     {
       status = register_format (NULL);
       if (status)
@@ -118,10 +118,10 @@ SCM_DEFINE_PUBLIC (scm_mu_register_format, "mu-register-format", 0, 0, 1,
     }
   else
     {
-      for (; !scm_is_null (REST); REST = SCM_CDR (REST))
+      for (; !scm_is_null (rest); rest = SCM_CDR (rest))
 	{
 	  char *s;
-	  SCM scm = SCM_CAR (REST);
+	  SCM scm = SCM_CAR (rest);
 	  SCM_ASSERT (scm_is_string (scm), scm, SCM_ARGn, FUNC_NAME);
 	  s = scm_to_locale_string (scm);
 	  status = register_format (s);
@@ -137,13 +137,13 @@ SCM_DEFINE_PUBLIC (scm_mu_register_format, "mu-register-format", 0, 0, 1,
 #undef FUNC_NAME
 
 SCM_DEFINE_PUBLIC (scm_mu_strerror, "mu-strerror", 1, 0, 0,
-	    (SCM ERR),
-"Return the error message corresponding to ERR, which must be\n"
+		   (SCM err),
+"Return the error message corresponding to @var{err}, which must be\n"
 "an integer value.\n")
 #define FUNC_NAME s_scm_mu_strerror
 {
-  SCM_ASSERT (scm_is_integer (ERR), ERR, SCM_ARG1, FUNC_NAME);
-  return scm_from_locale_string (mu_strerror (scm_to_int (ERR)));
+  SCM_ASSERT (scm_is_integer (err), err, SCM_ARG1, FUNC_NAME);
+  return scm_from_locale_string (mu_strerror (scm_to_int (err)));
 }
 #undef FUNC_NAME
 
diff --git a/libmu_scm/mu_util.c b/libmu_scm/mu_util.c
index bdf3aca..8f3b232 100644
--- a/libmu_scm/mu_util.c
+++ b/libmu_scm/mu_util.c
@@ -20,8 +20,8 @@
 #include "mu_scm.h"
 
 SCM_DEFINE_PUBLIC (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0,
-            (SCM USER),
-"Look up an entry in the user database. USER can be an integer,\n"
+		   (SCM user),
+"Look up an entry in the user database. @var{User} can be an integer,\n"
 "or a string, giving the behaviour of @code{mu_get_auth_by_uid} or\n"
 "@code{mu_get_auth_by_name} respectively.\n"
 "\n"
@@ -39,16 +39,16 @@ SCM_DEFINE_PUBLIC (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0,
 				     &handle,
 				     NULL, NULL);
   
-  if (scm_is_integer (USER))
+  if (scm_is_integer (user))
     {
-      entry = mu_get_auth_by_uid (scm_to_int32 (USER));
+      entry = mu_get_auth_by_uid (scm_to_int (user));
     }
   else
     {
       char *s;
       
-      SCM_VALIDATE_STRING (1, USER);
-      s = scm_to_locale_string (USER);
+      SCM_VALIDATE_STRING (1, user);
+      s = scm_to_locale_string (user);
       entry = mu_get_auth_by_name (s);
       free (s);
     }


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Wed Apr 14 11:22:34 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O24QE-0002or-Aq
	for mharc-commit-mailutils@gnu.org; Wed, 14 Apr 2010 11:22:34 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O24QC-0002nf-1k
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 11:22:32 -0400
Received: from [140.186.70.92] (port=46792 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O24QA-0002nW-39
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 11:22:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O24Q8-0007ES-0f
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 11:22:29 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:44140
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O24Q7-0007EJ-U7
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 11:22:27 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O24Q7-0007cT-I1
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 15:22:27 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O24Q6-0000Dv-N0
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 15:22:27 +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: 94adc8f49244e0abfd3ac47e0cfb2af2a063adc5
X-Git-Newrev: dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2
Message-Id: <E1O24Q6-0000Dv-N0@vcs-noshell.in.savannah.gnu.org>
Date: Wed, 14 Apr 2010 15:22:27 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-70-gdbbf8da
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, 14 Apr 2010 15:22:32 -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=dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2

The branch, master has been updated
       via  dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2 (commit)
       via  77b116b12786c1f9520e87868528494db61ce8af (commit)
      from  94adc8f49244e0abfd3ac47e0cfb2af2a063adc5 (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 dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Apr 14 18:23:42 2010 +0300

    Fix memory leaks in filter and filter_iconv code.
    
    * mailbox/filter.c (filter_destroy): Destroy the underlying
    stream, unless flag is given.
    (mu_filter_create): Treat last argument as stream flags.
    * mailbox/filter_iconv.c (_icvt_destroy): Free the icvt_stream
    structure.
    
    * examples/mimetest.c (message_display_parts): Pass
    MU_STREAM_NO_CLOSE to the invocation of mu_filter_create.
    * mail/decode.c (display_submessage): Likewise.
    * mailbox/attachment.c (mu_message_save_attachment): Likewise.
    * mh/mh_list.c (eval_body): Likewise.
    * mh/mhn.c (mhn_message_size, show_internal): Likewise.
    (finish_text_msg): Likewise; call mu_stream_destroy
    
    * imap4d/preauth.c (decode64_buf): remove unnecessary
    call to mu_stream_destroy.
    * libmu_auth/ldap.c (chk_md5, chk_smd5)
    (chk_sha, chk_ssha): Likewise.
    
    * mailbox/mutil.c: Fix indentation.

commit 77b116b12786c1f9520e87868528494db61ce8af
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Apr 14 18:21:52 2010 +0300

    Fix memory leak in mu_rfc2047_decode.
    
    * mailbox/rfc2047.c (getword): Change signature; return error
    code.
    (mu_rfc2047_decode): Reflect the above change.

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

Summary of changes:
 examples/mimetest.c    |    5 ++++-
 imap4d/preauth.c       |    1 -
 libmu_auth/ldap.c      |    5 -----
 mail/decode.c          |    3 ++-
 mailbox/attachment.c   |    3 ++-
 mailbox/filter.c       |   16 ++++++++++------
 mailbox/filter_iconv.c |    1 +
 mailbox/mutil.c        |    4 ++--
 mailbox/rfc2047.c      |   33 +++++++++++++++++----------------
 mh/mh_list.c           |    3 ++-
 mh/mhn.c               |   13 ++++++++-----
 11 files changed, 48 insertions(+), 39 deletions(-)

diff --git a/examples/mimetest.c b/examples/mimetest.c
index bca97af..923e4d0 100644
--- a/examples/mimetest.c
+++ b/examples/mimetest.c
@@ -251,7 +251,10 @@ message_display_parts (mu_message_t msg, int indent)
           printf ("%*.*sBegin\n", indent, indent, "");
           mu_message_get_body (part, &body);
           mu_body_get_stream (body, &str);
-          mu_filter_create (&str, str, encoding, 0, 0);
+          /* Make sure the original body stream is not closed when
+             str gets destroyed */
+          mu_filter_create (&str, str, encoding, MU_FILTER_DECODE,
+			    MU_STREAM_READ | MU_STREAM_NO_CLOSE);
           offset = 0;
           while (mu_stream_readline (str, buf, sizeof (buf),
 				     offset, &nbytes) == 0 && nbytes)
diff --git a/imap4d/preauth.c b/imap4d/preauth.c
index a9a2a5c..203cb29 100644
--- a/imap4d/preauth.c
+++ b/imap4d/preauth.c
@@ -217,7 +217,6 @@ decode64_buf (const char *name, unsigned char **pbuf, size_t *psize)
   mu_stream_sequential_write (str, name, namelen);
   mu_stream_read (flt, (char*) buf, sizeof buf, 0, &size);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
   *pbuf = malloc (size);
   if (!*pbuf)
     return 1;
diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c
index 70d3e0f..3fdedfb 100644
--- a/libmu_auth/ldap.c
+++ b/libmu_auth/ldap.c
@@ -602,7 +602,6 @@ chk_md5 (const char *db_pass, const char *pass)
 
   mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
   
   return memcmp (md5digest, d1, sizeof md5digest) == 0 ?
                   0 : MU_ERR_AUTH_FAILURE;
@@ -629,13 +628,11 @@ chk_smd5 (const char *db_pass, const char *pass)
   if (!d1)
     {
       mu_stream_destroy (&flt, NULL);
-      mu_stream_destroy (&str, NULL);
       return ENOMEM;
     }
   
   mu_stream_read (flt, (char*) d1, size, 0, &size);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
 
   if (size <= 16)
     {
@@ -674,7 +671,6 @@ chk_sha (const char *db_pass, const char *pass)
 
   mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
   
   return memcmp (sha1digest, d1, sizeof sha1digest) == 0 ?
                   0 : MU_ERR_AUTH_FAILURE;
@@ -701,7 +697,6 @@ chk_ssha (const char *db_pass, const char *pass)
   if (!d1)
     {
       mu_stream_destroy (&flt, NULL);
-      mu_stream_destroy (&str, NULL);
       return ENOMEM;
     }
   
diff --git a/mail/decode.c b/mail/decode.c
index 2eb3a82..4beadc9 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -258,7 +258,8 @@ display_submessage (struct mime_descend_closure *closure, void *data)
 
       /* Can we decode.  */
       if (mu_filter_create(&d_stream, b_stream, closure->encoding,
-			   MU_FILTER_DECODE, MU_STREAM_READ) == 0)
+			   MU_FILTER_DECODE, 
+			   MU_STREAM_READ|MU_STREAM_NO_CLOSE) == 0)
 	stream = d_stream;
       else
 	stream = b_stream;
diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 26430fc..8f02b4f 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -313,7 +313,8 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
 		content_encoding = "7bit";
 	      ret =
 		mu_filter_create (&info->stream, istream, content_encoding,
-				  MU_FILTER_DECODE, MU_STREAM_READ);
+				  MU_FILTER_DECODE,
+				  MU_STREAM_READ | MU_STREAM_NO_CLOSE);
 	      free (content_encoding_mem);
 	    }
 	}
diff --git a/mailbox/filter.c b/mailbox/filter.c
index 6a2e4d1..e7ad3d2 100644
--- a/mailbox/filter.c
+++ b/mailbox/filter.c
@@ -46,6 +46,8 @@ static void
 filter_destroy (mu_stream_t stream)
 {
   mu_filter_t filter = mu_stream_get_owner (stream);
+  if (!(stream->flags & MU_STREAM_NO_CLOSE))
+    mu_stream_destroy (&filter->stream, mu_stream_get_owner (filter->stream));
   if (filter->_destroy)
     filter->_destroy (filter);
   if (filter->property)
@@ -165,7 +167,7 @@ mu_filter_get_list (mu_list_t *plist)
 
 int
 mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name,
-		  int type, int direction)
+		  int type, int flags)
 {
   mu_iterator_t iterator = NULL;
   mu_filter_record_t filter_record = NULL;
@@ -204,14 +206,12 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name,
 
   if (found)
     {
-      int flags = 0;
       mu_filter_t filter;
 
       filter = calloc (1, sizeof (*filter));
       if (filter == NULL)
 	return ENOMEM;
 
-      mu_stream_get_flags (stream, &flags);
       status = mu_stream_create (pstream, flags | MU_STREAM_NO_CHECK, filter);
       if (status != 0)
 	{
@@ -221,7 +221,11 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name,
 
       filter->stream = stream;
       filter->filter_stream = *pstream;
-      filter->direction = (direction == 0) ? MU_STREAM_READ : direction;
+      filter->direction = (flags == 0) ? MU_STREAM_READ
+	                      : (flags
+				 & (MU_STREAM_READ |
+				    MU_STREAM_WRITE |
+				    MU_STREAM_RDWR));
       filter->type = type;
 
       status = mu_property_create (&(filter->property), filter);
@@ -249,8 +253,8 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name,
 	    }
         }
 
-      mu_stream_set_open (*pstream, filter_open, filter );
-      mu_stream_set_close (*pstream, filter_close, filter );
+      mu_stream_set_open (*pstream, filter_open, filter);
+      mu_stream_set_close (*pstream, filter_close, filter);
       mu_stream_set_read (*pstream, filter_read, filter);
       mu_stream_set_readline (*pstream, filter_readline, filter);
       mu_stream_set_write (*pstream, filter_write, filter);
diff --git a/mailbox/filter_iconv.c b/mailbox/filter_iconv.c
index c09d463..e47c5db 100644
--- a/mailbox/filter_iconv.c
+++ b/mailbox/filter_iconv.c
@@ -114,6 +114,7 @@ _icvt_destroy (mu_stream_t stream)
   s->buf = NULL;
   if (s->cd != (iconv_t) -1)
     iconv_close (s->cd);
+  free (s);
 }
 
 static int _icvt_read (mu_stream_t stream, char *optr, size_t osize,
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index 19dbcc1..70bce58 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -1329,8 +1329,8 @@ mu_decode_filter (mu_stream_t *pfilter, mu_stream_t input,
     {
       mu_stream_t cvt;
       status = mu_filter_iconv_create (&cvt, filter, fromcode, tocode,
-				    MU_STREAM_NO_CLOSE,
-				    mu_default_fallback_mode);
+				       MU_STREAM_NO_CLOSE,
+				       mu_default_fallback_mode);
       if (status == 0)
 	{
 	  if (mu_stream_open (cvt))
diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index ba11d58..64327d9 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -42,23 +42,26 @@ realloc_buffer (char **bufp, size_t *bufsizep, size_t incr)
   return 0;
 }
 
-static char *
-getword (const char **pstr, int delim)
+int
+getword (char **pret, const char **pstr, int delim)
 {
   size_t len;
   char *ret;
   const char *start = *pstr;
   const char *end = strchr (start, delim);
+
+  free (*pret);
   if (!end)
-    return NULL;
+    return MU_ERR_BAD_2047_INPUT;
   len = end - start;
   ret = malloc (len + 1);
   if (!ret)
-    return NULL;
+    return ENOMEM;
   memcpy (ret, start, len);
   ret[len] = 0;
   *pstr = end + 1;
-  return ret;
+  *pret = ret;
+  return 0;
 }
     
 int
@@ -119,23 +122,21 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
 	  const char *sp = fromstr + 2;
 	  char tmp[128];
 	  
-	  fromcode = getword (&sp, '?');
-	  encoding_type = getword (&sp, '?');
-	  encoded_text = getword (&sp, '?');
+	  status = getword (&fromcode, &sp, '?');
+	  if (status)
+	    break;
+	  status = getword (&encoding_type, &sp, '?');
+	  if (status)
+	    break;
+	  status = getword (&encoded_text, &sp, '?');
+	  if (status)
+	    break;
 	  if (sp == NULL || sp[0] != '=')
 	    {
 	      status = MU_ERR_BAD_2047_INPUT;
 	      break;
 	    }
       
-	  if (fromcode == NULL
-	      || encoding_type == NULL
-	      || encoded_text == NULL)
-	    {
-	      status = MU_ERR_BAD_2047_INPUT;
-	      break;
-	    }
-
 	  size = strlen (encoded_text);
 
 	  switch (encoding_type[0])
diff --git a/mh/mh_list.c b/mh/mh_list.c
index 489d028..6d8c651 100644
--- a/mh/mh_list.c
+++ b/mh/mh_list.c
@@ -699,7 +699,8 @@ eval_body (struct eval_env *env)
       if (encoding)
 	{
 	  int rc = mu_filter_create(&dstr, input, encoding,
-				 MU_FILTER_DECODE, MU_STREAM_READ);
+				    MU_FILTER_DECODE, 
+				    MU_STREAM_READ | MU_STREAM_NO_CLOSE);
 	  if (rc == 0)
 	    input = dstr;
 	  free (encoding);
diff --git a/mh/mhn.c b/mh/mhn.c
index f37d63d..b54d109 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -1122,8 +1122,9 @@ mhn_message_size (mu_message_t msg, size_t *psize)
 	  mu_message_get_header (msg, &hdr);
 	  _get_content_encoding (hdr, &encoding);
 
-	  rc = mu_filter_create(&dstr, bstr, encoding,
-				MU_FILTER_DECODE, MU_STREAM_READ);
+	  rc = mu_filter_create (&dstr, bstr, encoding,
+			 	 MU_FILTER_DECODE, 
+				 MU_STREAM_READ | MU_STREAM_NO_CLOSE);
 	  free (encoding);
 	  if (rc == 0)
 	    {
@@ -1272,8 +1273,8 @@ show_internal (mu_message_t msg, msg_part_t part, char *encoding, mu_stream_t ou
       return 0;
     }
   mu_body_get_stream (body, &bstr);
-  rc = mu_filter_create(&dstr, bstr, encoding,
-		     MU_FILTER_DECODE, MU_STREAM_READ);
+  rc = mu_filter_create (&dstr, bstr, encoding,
+		         MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_NO_CLOSE);
   if (rc == 0)
     bstr = dstr;
   cat_message (out, bstr);
@@ -2052,10 +2053,12 @@ finish_text_msg (struct compose_env *env, mu_message_t *msg, int ascii)
       mu_message_get_body (*msg, &body);
       mu_body_get_stream (body, &input);
       rc = mu_filter_create (&fstr, input, "quoted-printable",
-			     MU_FILTER_ENCODE, MU_STREAM_READ);
+			     MU_FILTER_ENCODE, 
+			     MU_STREAM_READ | MU_STREAM_NO_CLOSE);
       if (rc == 0)
 	{
 	  cat_message (output, fstr);
+	  mu_stream_destroy (&fstr, NULL);
 	  mu_message_unref (*msg);
 	  *msg = newmsg;
 	}


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Wed Apr 14 13:34:20 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O26Tk-0006Nb-Oi
	for mharc-commit-mailutils@gnu.org; Wed, 14 Apr 2010 13:34:20 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O26Ti-0006N0-Uw
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 13:34:19 -0400
Received: from [140.186.70.92] (port=54884 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O26Th-0006MI-Es
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 13:34:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O26Tf-0006q2-TM
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 13:34:17 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:32872
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O26Tf-0006pu-PB
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 13:34:15 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O26Tf-0000jt-5u
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 17:34:15 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O26Te-0000uc-RJ
	for commit-mailutils@gnu.org; Wed, 14 Apr 2010 17:34:15 +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: dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2
X-Git-Newrev: 76c508f88d9026915072af5ebb4055dc121154d5
Message-Id: <E1O26Te-0000uc-RJ@vcs-noshell.in.savannah.gnu.org>
Date: Wed, 14 Apr 2010 17:34:14 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-72-g76c508f
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, 14 Apr 2010 17:34:19 -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=76c508f88d9026915072af5ebb4055dc121154d5

The branch, master has been updated
       via  76c508f88d9026915072af5ebb4055dc121154d5 (commit)
       via  16ea05b703d50a78dc017ebf0d9355257dc6e8a2 (commit)
      from  dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2 (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 76c508f88d9026915072af5ebb4055dc121154d5
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Apr 14 20:34:10 2010 +0300

    Fix indirect memory leak in mu_decode_filter.
    
    * include/mailutils/stream.h (mu_stream_clr_flags): New function.
    * mailbox/stream.c (mu_stream_clr_flags): New function.
    * mailbox/mapfile_stream.c (_mapfile_open): Avoid unnecessary
    boolean operation.
    * mailbox/mutil.c (mu_decode_filter): Use mu_stream_clr_flags
    to clear bits.

commit 16ea05b703d50a78dc017ebf0d9355257dc6e8a2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Apr 14 20:18:41 2010 +0300

    Improve mu_mimehdr_a?get_disp.
    
    * mailbox/mimehdr.c (mu_mimehdr_get_disp)
    (mu_mimehdr_aget_disp): Return disposition even if
    no parameters have been given.

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

Summary of changes:
 include/mailutils/stream.h |    1 +
 mailbox/mapfile_stream.c   |    2 +-
 mailbox/mimehdr.c          |   10 ++++++----
 mailbox/mutil.c            |    5 +----
 mailbox/stream.c           |   11 ++++++++++-
 5 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index 59c8b25..9625dae 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -129,6 +129,7 @@ extern void mu_stream_set_owner   (mu_stream_t, void* owner);
 
 extern int mu_stream_get_flags    (mu_stream_t, int *pflags);
 extern int mu_stream_set_flags    (mu_stream_t, int flags);
+extern int mu_stream_clr_flags    (mu_stream_t, int flags);
 
 extern int mu_stream_get_property (mu_stream_t, mu_property_t *);
 extern int mu_stream_set_property (mu_stream_t, mu_property_t, void *);
diff --git a/mailbox/mapfile_stream.c b/mailbox/mapfile_stream.c
index 29a6f06..e70d701 100644
--- a/mailbox/mapfile_stream.c
+++ b/mailbox/mapfile_stream.c
@@ -335,7 +335,7 @@ _mapfile_open (mu_stream_t stream)
   else
     mfs->ptr = NULL;
   mfs->flags = mflag;
-  mu_stream_set_flags (stream, flags |MU_STREAM_NO_CHECK);
+  mu_stream_set_flags (stream, MU_STREAM_NO_CHECK);
   return 0;
 }
 
diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
index cd38332..4c27358 100644
--- a/mailbox/mimehdr.c
+++ b/mailbox/mimehdr.c
@@ -338,8 +338,9 @@ mu_mimehdr_get_disp (const char *str, char *buf, size_t bufsz, size_t *retsz)
   size_t size;
   
   if (!p)
-    return MU_ERR_NOENT;
-  size = p - str;
+    size = strlen (str);
+  else
+    size = p - str;
   if (buf)
     size = mu_cpystr (buf, str, size);
   if (retsz)
@@ -355,8 +356,9 @@ mu_mimehdr_aget_disp (const char *str, char **pvalue)
   size_t size;
   
   if (!p)
-    return MU_ERR_NOENT;
-  size = p - str;
+    size = strlen (str);
+  else
+    size = p - str;
   p = malloc (size + 1);
   if (!p)
     return ENOMEM;
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index 70bce58..656a31f 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -1337,10 +1337,7 @@ mu_decode_filter (mu_stream_t *pfilter, mu_stream_t input,
 	    mu_stream_destroy (&cvt, mu_stream_get_owner (cvt));
 	  else
 	    {
-	      int flags;
-	      mu_stream_get_flags (cvt, &flags);
-	      flags &= ~MU_STREAM_NO_CLOSE;
-	      mu_stream_set_flags (cvt, flags);
+	      mu_stream_clr_flags (cvt, MU_STREAM_NO_CLOSE);
 	      filter = cvt;
 	    }
 	}
diff --git a/mailbox/stream.c b/mailbox/stream.c
index bdb44da..79a077a 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -80,7 +80,7 @@ mu_stream_destroy (mu_stream_t *pstream, void *owner)
       mu_stream_t stream = *pstream;
       if ((stream->flags & MU_STREAM_NO_CHECK) || stream->owner == owner)
 	{
-	  mu_stream_close(stream);
+	  mu_stream_close (stream);
 	  if (stream->rbuffer.base)
 	    free (stream->rbuffer.base);
 
@@ -815,6 +815,15 @@ mu_stream_set_flags (mu_stream_t stream, int fl)
 }
 
 int
+mu_stream_clr_flags (mu_stream_t stream, int fl)
+{
+  if (stream == NULL)
+    return EINVAL;
+  stream->flags &= ~fl;
+  return 0;
+}
+
+int
 mu_stream_set_strerror (mu_stream_t stream,
 			int (*fp) (mu_stream_t, const char **), void *owner)
 {


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Sun Apr 18 14:12:19 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O3Yyh-0001e9-8u
	for mharc-commit-mailutils@gnu.org; Sun, 18 Apr 2010 14:12:19 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O3Yyf-0001dT-Ay
	for commit-mailutils@gnu.org; Sun, 18 Apr 2010 14:12:17 -0400
Received: from [140.186.70.92] (port=41865 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O3Yye-0001cp-60
	for commit-mailutils@gnu.org; Sun, 18 Apr 2010 14:12:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O3Yyb-0007nF-UQ
	for commit-mailutils@gnu.org; Sun, 18 Apr 2010 14:12:16 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:57631
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O3Yyb-0007n8-Sa
	for commit-mailutils@gnu.org; Sun, 18 Apr 2010 14:12:13 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O3Yyb-0003hh-I9
	for commit-mailutils@gnu.org; Sun, 18 Apr 2010 18:12:13 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O3Yyb-0003aU-7D
	for commit-mailutils@gnu.org; Sun, 18 Apr 2010 18:12: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: 76c508f88d9026915072af5ebb4055dc121154d5
X-Git-Newrev: 5157bbc99fc7cd3c0ea904f70ab2ee1f595ac8fe
Message-Id: <E1O3Yyb-0003aU-7D@vcs-noshell.in.savannah.gnu.org>
Date: Sun, 18 Apr 2010 18:12:13 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-73-g5157bbc
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, 18 Apr 2010 18:12:18 -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=5157bbc99fc7cd3c0ea904f70ab2ee1f595ac8fe

The branch, master has been updated
       via  5157bbc99fc7cd3c0ea904f70ab2ee1f595ac8fe (commit)
      from  76c508f88d9026915072af5ebb4055dc121154d5 (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 5157bbc99fc7cd3c0ea904f70ab2ee1f595ac8fe
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Apr 18 21:10:10 2010 +0300

    Bugfix.
    
    * mailbox/cfg_lexer.l (mu_cfg_parse_file): Parse only
    regular files.

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

Summary of changes:
 mailbox/cfg_lexer.l |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/mailbox/cfg_lexer.l b/mailbox/cfg_lexer.l
index f530ca2..998d84d 100644
--- a/mailbox/cfg_lexer.l
+++ b/mailbox/cfg_lexer.l
@@ -333,6 +333,14 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags)
       free (full_name);
       return ENOENT;
     }
+  else if (!S_ISREG (st.st_mode))
+    {
+      if (flags & MU_PARSE_CONFIG_VERBOSE)
+	mu_diag_output (MU_DIAG_INFO, _("%s: not a regular file"), full_name);
+      free (full_name);
+      return ENOENT;
+    } 
+      
   fp = fopen (full_name, "r");
   if (!fp)
     {


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Mon Apr 26 16:11:02 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O6Udx-0004Cb-Um
	for mharc-commit-mailutils@gnu.org; Mon, 26 Apr 2010 16:11:01 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O6Udw-0004AW-4S
	for commit-mailutils@gnu.org; Mon, 26 Apr 2010 16:11:00 -0400
Received: from [140.186.70.92] (port=32779 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O6Udu-00048h-G6
	for commit-mailutils@gnu.org; Mon, 26 Apr 2010 16:10:59 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O6Uds-0004zW-JX
	for commit-mailutils@gnu.org; Mon, 26 Apr 2010 16:10:57 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:49553
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O6Uds-0004zS-Hd
	for commit-mailutils@gnu.org; Mon, 26 Apr 2010 16:10:56 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O6Uds-000188-E3
	for commit-mailutils@gnu.org; Mon, 26 Apr 2010 20:10:56 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O6Uds-0001Zc-34
	for commit-mailutils@gnu.org; Mon, 26 Apr 2010 20:10:56 +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: 5157bbc99fc7cd3c0ea904f70ab2ee1f595ac8fe
X-Git-Newrev: 1a771a60bf194a84f8e2df404a768ea71623fbf9
Message-Id: <E1O6Uds-0001Zc-34@vcs-noshell.in.savannah.gnu.org>
Date: Mon, 26 Apr 2010 20:10:56 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-74-g1a771a6
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: Mon, 26 Apr 2010 20:11:00 -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=1a771a60bf194a84f8e2df404a768ea71623fbf9

The branch, master has been updated
       via  1a771a60bf194a84f8e2df404a768ea71623fbf9 (commit)
      from  5157bbc99fc7cd3c0ea904f70ab2ee1f595ac8fe (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 1a771a60bf194a84f8e2df404a768ea71623fbf9
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Apr 26 22:48:29 2010 +0300

    Accept additional whitespace and quotes in the disposition part of MIME headers.
    
    * mailbox/mimehdr.c (disp_segment_len): New function.
    (mu_mimehdr_get_disp, mu_mimehdr_aget_disp): Use disp_segment_len.
    Unquote the returned string.
    (_header_get_param): Allow for whitespace before '"'. Unquote the
    string before comparison.

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

Summary of changes:
 mailbox/mimehdr.c |   57 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
index 4c27358..3391868 100644
--- a/mailbox/mimehdr.c
+++ b/mailbox/mimehdr.c
@@ -100,6 +100,7 @@ _header_get_param (const char *field_body,
   int res = MU_ERR_NOENT;            /* Return value, pessimistic default */
   size_t param_len = strlen (param);
   char *p;
+  size_t size;
   char *mem = NULL;                  /* Allocated memory storage */
   size_t retlen = 0;                 /* Total number of bytes copied */
   unsigned long cind = 0;            /* Expected continued parameter index.
@@ -116,7 +117,18 @@ _header_get_param (const char *field_body,
   p = strchr (field_body, ';');
   if (!p)
     return MU_ERR_NOENT;
-  if (disp && mu_c_strncasecmp (field_body, disp, p - field_body))
+  /* Allow for possible whitespace before the semicolon */
+  for (size = p - field_body;
+       size > 0 && mu_isblank (field_body[size-1]); size--)
+    ;
+  /* Remove surrounding quotes.
+     FIXME: unescape the quoted contents. */
+  if (field_body[0] == '"' && field_body[size-1] == '"')
+    {
+      field_body++;
+      size -= 2;
+    }
+  if (disp && mu_c_strncasecmp (field_body, disp, size))
     return MU_ERR_NOENT;
       
   while (p && *p)
@@ -326,6 +338,21 @@ _header_get_param (const char *field_body,
   return res;
 }
 
+static size_t
+disp_segment_len (const char *str)
+{
+  char *p = strchr (str, ';');
+  size_t size;
+  
+  if (!p)
+    size = strlen (str);
+  else
+    size = p - str;
+  while (size > 0 && mu_isblank (str[size-1]))
+    size--;
+  return size;
+}
+
 /* STR is a value of a structured MIME header, e.g. Content-Type.
    This function returns the `disposition part' of it.  In other
    words, it returns disposition, if STR is a Content-Disposition
@@ -334,13 +361,15 @@ _header_get_param (const char *field_body,
 int
 mu_mimehdr_get_disp (const char *str, char *buf, size_t bufsz, size_t *retsz)
 {
-  char *p = strchr (str, ';');
   size_t size;
-  
-  if (!p)
-    size = strlen (str);
-  else
-    size = p - str;
+
+  str = mu_str_skip_class (str, MU_CTYPE_BLANK);
+  size = disp_segment_len (str);
+  if (size > 2 && str[0] == '"' && str[size-1] == '"')
+    {
+      str++;
+      size -= 2;
+    }
   if (buf)
     size = mu_cpystr (buf, str, size);
   if (retsz)
@@ -352,13 +381,17 @@ mu_mimehdr_get_disp (const char *str, char *buf, size_t bufsz, size_t *retsz)
 int
 mu_mimehdr_aget_disp (const char *str, char **pvalue)
 {
-  char *p = strchr (str, ';');
+  char *p;
   size_t size;
   
-  if (!p)
-    size = strlen (str);
-  else
-    size = p - str;
+  str = mu_str_skip_class (str, MU_CTYPE_BLANK);
+  size = disp_segment_len (str);
+  if (size > 2 && str[0] == '"' && str[size-1] == '"')
+    {
+      str++;
+      size -= 2;
+    }
+
   p = malloc (size + 1);
   if (!p)
     return ENOMEM;


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Wed Apr 28 18:01:30 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O7FJx-0006TM-Kp
	for mharc-commit-mailutils@gnu.org; Wed, 28 Apr 2010 18:01:29 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O7FJw-0006S9-MD
	for commit-mailutils@gnu.org; Wed, 28 Apr 2010 18:01:28 -0400
Received: from [140.186.70.92] (port=53511 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O7FJu-0006P7-TM
	for commit-mailutils@gnu.org; Wed, 28 Apr 2010 18:01:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7FJt-0005s2-6f
	for commit-mailutils@gnu.org; Wed, 28 Apr 2010 18:01:26 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:50197
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7FJt-0005ry-4q
	for commit-mailutils@gnu.org; Wed, 28 Apr 2010 18:01:25 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7FJs-0003mZ-Rm
	for commit-mailutils@gnu.org; Wed, 28 Apr 2010 22:01:24 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7FJs-0004oZ-Hf
	for commit-mailutils@gnu.org; Wed, 28 Apr 2010 22:01:24 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/stream-cleanup
X-Git-Reftype: branch
X-Git-Oldrev: 0000000000000000000000000000000000000000
X-Git-Newrev: 9a6b436ab0a2f2567cdbd25ab15f037c178404c4
Message-Id: <E1O7FJs-0004oZ-Hf@vcs-noshell.in.savannah.gnu.org>
Date: Wed, 28 Apr 2010 22:01:24 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, stream-cleanup,
	created. rel-2_1-73-g9a6b436
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, 28 Apr 2010 22:01:29 -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=9a6b436ab0a2f2567cdbd25ab15f037c178404c4

The branch, stream-cleanup has been created
        at  9a6b436ab0a2f2567cdbd25ab15f037c178404c4 (commit)

- Log -----------------------------------------------------------------
commit 9a6b436ab0a2f2567cdbd25ab15f037c178404c4
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Apr 23 23:33:49 2010 +0300

    Stream support rewritten from scratch.
    
    Does not compile yet.
    
    New files:
    * mailbox/streamref.c
    * include/mailutils/sys/streamref.h
    * include/mailutils/sys/file_stream.h
    * include/mailutils/sys/header_stream.h
    * include/mailutils/sys/mapfile_stream.h
    * include/mailutils/sys/memory_stream.h
    * include/mailutils/sys/message_stream.h
    * include/mailutils/sys/prog_stream.h
    * include/mailutils/sys/socket_stream.h
    * include/mailutils/sys/stdio_stream.h
    * include/mailutils/sys/stream.h
    * include/mailutils/sys/streamtrans.h
    * mailbox/prog_stream.c
    * mailbox/stdio_stream.c
    * mailbox/stream_printf.c
    * mailbox/stream_vprintf.c
    * mailbox/temp_file_stream.c
    * mailbox/streamcpy.c
    * mailbox/binflt.c
    * mailbox/crlfflt.c
    * mailbox/fltstream.c
    * mailbox/qpflt.c
    * mailbox/linelenflt.c
    
    Removed files:
    * mailbox/filter_rfc822.c
    * mailbox/filter_trans.c
    
    Moved files (with edits):
    * libproto/include/filter0.h -> include/mailutils/sys/filter.h
    * libproto/include/header0.h -> include/mailutils/sys/header.h
    * libproto/include/message0.h -> include/mailutils/sys/message.h
    * libproto/include/mime0.h -> include/mailutils/sys/mime.h
    
    Modified files:
    * comsat/action.c
    * config/mailutils-config.c
    * examples/base64.c
    * examples/cpp/msg-send.cc
    * examples/header.c
    * examples/http.c
    * examples/iconv.c
    * examples/mimetest.c
    * examples/msg-send.c
    * examples/mta.c
    * examples/murun.c
    * examples/nntpclient.c
    * examples/pop3client.c
    * imap4d/append.c
    * imap4d/auth_gsasl.c
    * imap4d/fetch.c
    * imap4d/preauth.c
    * imap4d/search.c
    * imap4d/util.c
    * include/mailutils/body.h
    * include/mailutils/folder.h
    * include/mailutils/header.h
    * include/mailutils/mailbox.h
    * include/mailutils/mailer.h
    * include/mailutils/mailutils.h
    * include/mailutils/message.h
    * include/mailutils/stream.h
    * include/mailutils/sys/Makefile.am
    * include/mailutils/sys/filter.h
    * include/mailutils/sys/header.h
    * include/mailutils/sys/message.h
    * include/mailutils/sys/mime.h
    * include/mailutils/sys/nntp.h
    * include/mailutils/sys/pop3.h
    * include/mailutils/sys/stream.h
    * include/mailutils/types.hin
    * lib/mailcap.c
    * lib/mu_dbm.h
    * libmu_argp/muinit.c
    * libmu_auth/ldap.c
    * libmu_auth/tls.c
    * libmu_scm/Makefile.am
    * libmu_scm/mu_body.c
    * libmu_scm/mu_message.c
    * libmu_scm/mu_port.c
    * libmu_sieve/actions.c
    * libmu_sieve/extensions/pipe.c
    * libmu_sieve/extensions/spamd.c
    * libmu_sieve/extensions/vacation.c
    * libproto/mailer/smtp.c
    * libproto/mbox/mboxscan.c
    * libproto/mbox/mbox.c
    * libproto/mbox/mbox0.h
    * libproto/nntp/nntp_article.c
    * libproto/nntp/nntp_carrier.c
    * libproto/nntp/nntp_destroy.c
    * libproto/nntp/nntp_ihave.c
    * libproto/nntp/nntp_post.c
    * libproto/nntp/nntp_readline.c
    * libproto/nntp/nntp_sendline.c
    * libproto/pop/pop3_carrier.c
    * libproto/pop/pop3_destroy.c
    * libproto/pop/pop3_readline.c
    * libproto/pop/pop3_sendline.c
    * libproto/pop/pop3_stat.c
    * maidag/mailtmp.c
    * mail/decode.c
    * mail/escape.c
    * mail/msgset.y
    * mail/pipe.c
    * mail/print.c
    * mail/send.c
    * mail/top.c
    * mail/util.c
    * mail/write.c
    * mailbox/Makefile.am
    * mailbox/amd.c
    * mailbox/attachment.c
    * mailbox/body.c
    * mailbox/cfg_driver.c
    * mailbox/cfg_format.c
    * mailbox/debug.c
    * mailbox/file_stream.c
    * mailbox/folder.c
    * mailbox/hdritr.c
    * mailbox/header.c
    * mailbox/mailbox.c
    * mailbox/mailcap.c
    * mailbox/mailer.c
    * mailbox/mapfile_stream.c
    * mailbox/memory_stream.c
    * mailbox/message.c
    * mailbox/message_stream.c
    * mailbox/mime.c
    * mailbox/mimehdr.c
    * mailbox/mutil.c
    * mailbox/prog_stream.c
    * mailbox/progmailer.c
    * mailbox/rfc2047.c
    * mailbox/socket_stream.c
    * mailbox/stream.c
    * mailbox/stream_vprintf.c
    * mailbox/tcp.c
    * mailbox/vartab.c
    * mailbox/wicket.c
    * mh/burst.c
    * mh/comp.c
    * mh/compcommon.c
    * mh/forw.c
    * mh/mh_ctx.c
    * mh/mh_format.c
    * mh/mh_init.c
    * mh/mh_list.c
    * mh/mh_whatnow.c
    * mh/mhl.c
    * mh/mhn.c
    * mh/pick.y
    * mh/repl.c
    * mimeview/mimeview.c
    * mu-aux/generr.awk
    * pop3d/extra.c
    * pop3d/pop3d.h
    * pop3d/retr.c
    * pop3d/top.c
    * readmsg/msglist.c
    * readmsg/readmsg.c
    * sieve/sieve.c

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


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 29 07:08:55 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O7Rbz-0001Bf-25
	for mharc-commit-mailutils@gnu.org; Thu, 29 Apr 2010 07:08:55 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O7Rbx-0001BY-U4
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 07:08:53 -0400
Received: from [140.186.70.92] (port=37636 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O7Rbv-0001B8-An
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 07:08:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7Rbt-0001e1-PR
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 07:08:51 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:41389
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7Rbt-0001dv-MB
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 07:08:49 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7Rbt-0004po-0G
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 11:08:49 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7Rbs-0000H5-QR
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 11:08:48 +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: 1a771a60bf194a84f8e2df404a768ea71623fbf9
X-Git-Newrev: d31b2f980ff7e040103428d9cfb227df6e260c6e
Message-Id: <E1O7Rbs-0000H5-QR@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 29 Apr 2010 11:08:48 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-78-gd31b2f9
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: Thu, 29 Apr 2010 11:08:54 -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=d31b2f980ff7e040103428d9cfb227df6e260c6e

The branch, master has been updated
       via  d31b2f980ff7e040103428d9cfb227df6e260c6e (commit)
       via  37f87dce4a7b47cb4b61163b6f66ea6658eaf23b (commit)
       via  b4b8b6ec832014c02a51cdcf4ce84bd38cc3f05f (commit)
       via  21b82ef506c8be16a2022324cd3678a421b85a91 (commit)
      from  1a771a60bf194a84f8e2df404a768ea71623fbf9 (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 d31b2f980ff7e040103428d9cfb227df6e260c6e
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 29 14:08:01 2010 +0300

    Minor change
    
    * libproto/include/mime0.h (struct _mu_mime): Use size_t for
    offsets, ssize_t for line_ndx.

commit 37f87dce4a7b47cb4b61163b6f66ea6658eaf23b
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 29 13:59:30 2010 +0300

    Allow for a sequence of semicolons before kw/value pair in a structured header.
    
    * mailbox/mimehdr.c (_header_get_param): Skip superfluous semicolons.

commit b4b8b6ec832014c02a51cdcf4ce84bd38cc3f05f
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 29 13:38:32 2010 +0300

    Remove line length limitation in mime parser.
    
    * libproto/include/mime0.h (struct _mu_mime): New member line_size.
    * mailbox/mime.c (_mime_setup_buffers): Use line_size instead of
    MIME_MAX_HDR_LEN.
    (_mime_parse_mpart_message): Reallocate cur_line as necessary.
    (mu_mime_create): Initialize line_size.

commit 21b82ef506c8be16a2022324cd3678a421b85a91
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 29 13:34:30 2010 +0300

    Allow for certain class of broken headers.
    
    * mailbox/mimehdr.c (_header_get_param): Tolerate unquoted value parts
    which contain tspecials, except ';'.

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

Summary of changes:
 libproto/include/mime0.h |   31 ++++++++++++++++---------------
 mailbox/mime.c           |   16 ++++++++++++----
 mailbox/mimehdr.c        |   14 +++++++++++++-
 3 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/libproto/include/mime0.h b/libproto/include/mime0.h
index 145db33..c1bce64 100644
--- a/libproto/include/mime0.h
+++ b/libproto/include/mime0.h
@@ -58,27 +58,28 @@ struct _mu_mime
   int             flags;
   char           *content_type;
 
-  int             tparts;
-  int             nmtp_parts;
+  size_t          tparts;
+  size_t          nmtp_parts;
   struct _mime_part **mtp_parts;      /* list of parts in the msg */
   char           *boundary;
-  int             cur_offset;
-  int             cur_part;
-  int             part_offset;
-  int             boundary_len;
-  int             preamble;
-  int             postamble;
+  size_t          cur_offset;
+  size_t          cur_part;
+  size_t          part_offset;
+  size_t          boundary_len;
+  size_t          preamble;
+  size_t          postamble;
   /* parser state */
   char           *cur_line;
-  int             line_ndx;
+  ssize_t         line_ndx;
+  size_t          line_size;
   char           *cur_buf;
-  int             buf_size;
+  size_t          buf_size;
   char           *header_buf;
-  int             header_buf_size;
-  int             header_length;
-  int             body_offset;
-  int             body_length;
-  int             body_lines;
+  size_t          header_buf_size;
+  size_t          header_length;
+  size_t          body_offset;
+  size_t          body_length;
+  size_t          body_lines;
   int             parser_state;
 };
 
diff --git a/mailbox/mime.c b/mailbox/mime.c
index 421d686..33186d9 100644
--- a/mailbox/mime.c
+++ b/mailbox/mime.c
@@ -224,7 +224,7 @@ _mime_setup_buffers (mu_mime_t mime)
       return ENOMEM;
     }
   if (mime->cur_line == NULL
-      && (mime->cur_line = calloc (MIME_MAX_HDR_LEN, 1)) == NULL)
+      && (mime->cur_line = calloc (mime->line_size, 1)) == NULL)
     {
       free (mime->cur_buf);
       return ENOMEM;
@@ -380,10 +380,17 @@ _mime_parse_mpart_message (mu_mime_t mime)
 		}
 	    }
 	  mime->line_ndx++;
-	  if (mime->line_ndx >= MIME_MAX_HDR_LEN)
+	  if (mime->line_ndx >= mime->line_size)
 	    {
-	      mime->line_ndx = 0;
-	      mime->parser_state = MIME_STATE_BEGIN_LINE;
+	      size_t newsize = mime->line_size + MIME_MAX_HDR_LEN;
+	      char *p = realloc (mime->cur_line, newsize);
+	      if (!p)
+		{
+		  ret = ENOMEM;
+		  break;
+		}
+	      mime->cur_line = p;
+	      mime->line_size = newsize;
 	    }
 	  mime->cur_offset++;
 	  nbytes--;
@@ -806,6 +813,7 @@ mu_mime_create (mu_mime_t *pmime, mu_message_t msg, int flags)
 	    {
 	      mime->msg = msg;
 	      mime->buf_size = MIME_DFLT_BUF_SIZE;
+	      mime->line_size = MIME_MAX_HDR_LEN;
 	      mu_message_get_body (msg, &body);
 	      mu_body_get_stream (body, &(mime->stream));
 	    }
diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
index 3391868..731e485 100644
--- a/mailbox/mimehdr.c
+++ b/mailbox/mimehdr.c
@@ -144,6 +144,18 @@ _header_get_param (const char *field_body,
       
       /* walk upto start of param */      
       p = mu_str_skip_class (p + 1, MU_CTYPE_SPACE);
+
+      /* Reportedly, some MUAs insert several semicolons */
+      if (*p == ';')
+	continue;
+
+      /* Ignore stray characters */
+      if (_ISSPECIAL (*p))
+	{
+	  p = strchr (p, ';');
+	  continue;
+	}
+	
       if ((ep = strchr (p, '=')) == NULL)
 	break;
       /* Allow for optional whitespace after '=' */
@@ -176,7 +188,7 @@ _header_get_param (const char *field_body,
 	}
       else
 	{
-	  for (e = v + 1; !(_ISSPECIAL (*e) || mu_isspace (*e)); e++)
+	  for (e = v + 1; *e && !(*e == ';' || mu_isspace (*e)); e++)
 	    ;
 	  len = e - v;
 	}


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 29 17:57:35 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O7bjj-0008IM-Qf
	for mharc-commit-mailutils@gnu.org; Thu, 29 Apr 2010 17:57:35 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O7bjj-0008IF-0V
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 17:57:35 -0400
Received: from [140.186.70.92] (port=60823 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O7bjf-0008I7-CQ
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 17:57:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7bjd-0004dd-JX
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 17:57:31 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:33139
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7bjd-0004dT-HK
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 17:57:29 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7bjc-0004Ii-LR
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 21:57:28 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7bjc-0006pL-He
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 21:57:28 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/stream-cleanup
X-Git-Reftype: branch
X-Git-Oldrev: 9a6b436ab0a2f2567cdbd25ab15f037c178404c4
X-Git-Newrev: 2613500d4a50cf7d36e30eea6d7af915a38c8f7d
Message-Id: <E1O7bjc-0006pL-He@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 29 Apr 2010 21:57:28 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, stream-cleanup,
	updated. rel-2_1-74-g2613500
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: Thu, 29 Apr 2010 21:57:35 -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=2613500d4a50cf7d36e30eea6d7af915a38c8f7d

The branch, stream-cleanup has been updated
       via  2613500d4a50cf7d36e30eea6d7af915a38c8f7d (commit)
      from  9a6b436ab0a2f2567cdbd25ab15f037c178404c4 (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 2613500d4a50cf7d36e30eea6d7af915a38c8f7d
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Apr 29 23:24:12 2010 +0300

    Bugfixes.
    
    * examples/sfrom.c (main): Check return from mu_mailbox_messages_count.
    * include/mailutils/sys/stream.h (_MU_STR_WRT): New constant.
    * libproto/mbox/mbox.c (_msg_stream_setup): Fix 3rd argument to
    mu_streamref_create_abridged.
    * libproto/mbox/mboxscan.c (mbox_scan_internal): Don't use mailbox->stream
    directly, because its offsets may get shifted by observers. Use streamref
    instead.
    * mailbox/argcv.c (argcv_get): Do nothing if argc <= 0.
    * mailbox/mapfile_stream.c (_mapfile_seek): Fill the *presult.
    * mailbox/memory_stream.c (_memory_done): Remove leftover free.
    * mailbox/stream.c: Reorder functions.
    (_mu_stream_create): Increase reference count (i.e. set it to 1)
    before returning.
    (mu_stream_seek): Call _stream_flush_buffer instead of
    mu_stream_flush.
    (mu_stream_read_unbuffered): Return 0 on EOF.
    (mu_stream_write_unbuffered): Set _MU_STR_WRT bit.
    (mu_stream_readline, mu_stream_getdelim): Check the actual
    number of bytes read.
    (mu_stream_flush): Call flush method only if _MU_STR_WRT is set.
    Clear it.
    * mailbox/streamref.c (_streamref_seek): Optimization for off==0 and
    whence == MU_SEEK_CUR.
    (_streamref_seek): Return new offset in ppos.
    (mu_streamref_create_abridged): Set MU_STREAM_NO_CLOSE.
    * mailbox/memory_stream.c (_memory_seek) : Return new offset in presult.
    * mailbox/message_stream.c (_message_seek): Likewise.
    * mailbox/stdio_stream.c (stdio_seek): Fix prototype.

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

Summary of changes:
 examples/sfrom.c               |    7 +-
 include/mailutils/sys/stream.h |    5 +-
 libproto/mbox/mbox.c           |    2 +-
 libproto/mbox/mboxscan.c       |   10 +-
 mailbox/argcv.c                |    2 +
 mailbox/mapfile_stream.c       |    1 +
 mailbox/memory_stream.c        |    3 +-
 mailbox/message_stream.c       |    5 +-
 mailbox/stdio_stream.c         |    5 +-
 mailbox/stream.c               |  299 ++++++++++++++++++++--------------------
 mailbox/streamref.c            |   18 ++-
 11 files changed, 190 insertions(+), 167 deletions(-)

diff --git a/examples/sfrom.c b/examples/sfrom.c
index 3a79cef..8e6384c 100644
--- a/examples/sfrom.c
+++ b/examples/sfrom.c
@@ -53,7 +53,12 @@ main (int argc, const char **argv)
       exit (EXIT_FAILURE);
     }
 
-  mu_mailbox_messages_count (mbox, &total);
+  status = mu_mailbox_messages_count (mbox, &total);
+  if (status != 0)
+    {
+      mu_error ("mu_mailbox_messages_count: %s", mu_strerror (status));
+      exit (EXIT_FAILURE);
+    }
 
   for (msgno = 1; msgno <= total; msgno++)
     {
diff --git a/include/mailutils/sys/stream.h b/include/mailutils/sys/stream.h
index 07249aa..2800341 100644
--- a/include/mailutils/sys/stream.h
+++ b/include/mailutils/sys/stream.h
@@ -18,8 +18,9 @@
 #define _MAILUTILS_SYS_STREAM_H
 
 #define _MU_STR_DIRTY         0x1000    /* Buffer dirty */
-#define _MU_STR_ERR           0x2000    /* Permanent error state */
-#define _MU_STR_EOF           0x4000    /* EOF encountered */
+#define _MU_STR_WRT           0x2000    /* Unflushed write pending */
+#define _MU_STR_ERR           0x4000    /* Permanent error state */
+#define _MU_STR_EOF           0x8000    /* EOF encountered */
 
 #define _MU_STR_INTERN_MASK   0xf000
 
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c
index 7b167a0..7e16f4f 100644
--- a/libproto/mbox/mbox.c
+++ b/libproto/mbox/mbox.c
@@ -297,7 +297,7 @@ _msg_stream_setup (mu_message_t msg, mbox_message_t mum)
   
   status = mu_streamref_create_abridged (&stream,
 					 mum->mud->mailbox->stream,
-					 mum->header_from_end,
+					 mum->header_from_end + 1,
 					 mum->body);
   if (status == 0)
     status = mu_message_set_stream (msg, stream, mum);
diff --git a/libproto/mbox/mboxscan.c b/libproto/mbox/mboxscan.c
index dbbe316..127a360 100644
--- a/libproto/mbox/mboxscan.c
+++ b/libproto/mbox/mboxscan.c
@@ -302,7 +302,12 @@ mbox_scan_internal (mu_mailbox_t mailbox, mbox_message_t mum,
   newline = 1;
   errno = lines = inheader = inbody = 0;
 
-  stream = mailbox->stream;
+  status = mu_streamref_create (&stream, mailbox->stream);
+  if (status)
+    return status;
+  status = mu_stream_seek (stream, total, MU_SEEK_SET, NULL);
+  if (status)
+    return status;
   while ((status = mu_stream_readline (stream, buf, sizeof (buf), &n)) == 0
 	 && n != 0)
     {
@@ -396,7 +401,8 @@ mbox_scan_internal (mu_mailbox_t mailbox, mbox_message_t mum,
 	  DISPATCH_PROGRESS (mailbox, mud);
 
     } /* while */
-
+  mu_stream_destroy (&stream);
+  
   if (mum)
     {
       mum->body_end = total - newline;
diff --git a/mailbox/argcv.c b/mailbox/argcv.c
index c31836c..636b9af 100644
--- a/mailbox/argcv.c
+++ b/mailbox/argcv.c
@@ -447,6 +447,8 @@ argcv_get (const char *command, const char *delim, const char *cmnt,
 void
 argcv_free (int argc, char **argv)
 {
+  if (argc <= 0)
+    return;
   while (--argc >= 0)
     if (argv[argc])
       free (argv[argc]);
diff --git a/mailbox/mapfile_stream.c b/mailbox/mapfile_stream.c
index f0e18ce..66bcca4 100644
--- a/mailbox/mapfile_stream.c
+++ b/mailbox/mapfile_stream.c
@@ -334,6 +334,7 @@ _mapfile_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presu
   if (off < 0 || off > mfs->size)
     return EINVAL;
   mfs->offset = off;
+  *presult = off;
   return 0;
 }
 
diff --git a/mailbox/memory_stream.c b/mailbox/memory_stream.c
index dc83a55..1f388fb 100644
--- a/mailbox/memory_stream.c
+++ b/mailbox/memory_stream.c
@@ -38,7 +38,6 @@ _memory_done (mu_stream_t stream)
   struct _mu_memory_stream *mfs = (struct _mu_memory_stream *) stream;
   if (mfs && mfs->ptr != NULL)
     free (mfs->ptr);
-  free (mfs);
 }
 
 static int
@@ -189,7 +188,7 @@ _memory_seek (struct _mu_stream *stream, mu_off_t off, int whence,
   if (off < 0 || off > mfs->size)
     return EINVAL;
   mfs->offset = off;
-  
+  *presult = off;
   return 0;
 }
 
diff --git a/mailbox/message_stream.c b/mailbox/message_stream.c
index 93844ee..f5c3cc4 100644
--- a/mailbox/message_stream.c
+++ b/mailbox/message_stream.c
@@ -303,8 +303,8 @@ _message_done (mu_stream_t stream)
 }
 
 static int
-_message_seek (struct _mu_stream *stream, off_t off, int whence,
-	       off_t *presult)
+_message_seek (struct _mu_stream *stream, mu_off_t off, int whence,
+	       mu_off_t *presult)
 { 
   struct _mu_message_stream *s = (struct _mu_message_stream*) stream;
   mu_off_t size;
@@ -327,6 +327,7 @@ _message_seek (struct _mu_stream *stream, off_t off, int whence,
   if (off < 0 || off >= size)
     return s->stream.last_err = EINVAL;
   s->offset = off;
+  *presult = off;
   return 0;
 }
 
diff --git a/mailbox/stdio_stream.c b/mailbox/stdio_stream.c
index b35b796..d401270 100644
--- a/mailbox/stdio_stream.c
+++ b/mailbox/stdio_stream.c
@@ -128,7 +128,7 @@ stdio_size (struct _mu_stream *str, off_t *psize)
 }
 
 static int
-stdio_seek (struct _mu_stream *str, off_t off, int whence, off_t *presult)
+stdio_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presult)
 { 
   struct _mu_stdio_stream *fs = (struct _mu_stdio_stream *) str;
   /* FIXME */
@@ -150,8 +150,7 @@ stdio_seek (struct _mu_stream *str, off_t off, int whence, off_t *presult)
     return EINVAL;
 
   fs->offset = off;
-  if (presult)
-    *presult = fs->offset;
+  *presult = fs->offset;
   return 0;
 }
 
diff --git a/mailbox/stream.c b/mailbox/stream.c
index fdee5c4..8d9e1f9 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -50,6 +50,138 @@ _stream_seterror (struct _mu_stream *stream, int code, int perm)
   return code;
 }
 
+#define _stream_cleareof(s) ((s)->flags &= ~_MU_STR_EOF)
+#define _stream_advance_buffer(s,n) ((s)->cur += n, (s)->level -= n)
+#define _stream_buffer_offset(s) ((s)->cur - (s)->buffer)
+#define _stream_orig_level(s) ((s)->level + _stream_buffer_offset(s))
+
+static int
+_stream_fill_buffer (struct _mu_stream *stream)
+{
+  size_t n;
+  size_t rdn;
+  int rc = 0;
+  char c;
+    
+  switch (stream->buftype)
+    {
+    case mu_buffer_none:
+      return 0;
+	
+    case mu_buffer_full:
+      if (mu_stream_read_unbuffered (stream,
+				     stream->buffer, stream->bufsize,
+				     0,
+				     &stream->level))
+	return 1;
+      break;
+	
+    case mu_buffer_line:
+      for (n = 0;
+	   n < stream->bufsize
+	     && (rc = mu_stream_read_unbuffered (stream,
+						 &c, 1, 0, &rdn)) == 0
+	     && rdn; n++)
+	{
+	  stream->buffer[n] = c;
+	  if (c == '\n')
+	    break;
+	}
+      stream->level = n;
+      break;
+    }
+  stream->cur = stream->buffer;
+  return rc;
+}
+
+#define BUFFER_FULL_P(s) \
+  ((s)->cur + (s)->level == (s)->buffer + (s)->bufsize)
+
+static int
+_stream_buffer_full_p (struct _mu_stream *stream)
+{
+    switch (stream->buftype)
+      {
+      case mu_buffer_none:
+	break;
+	
+      case mu_buffer_line:
+	return BUFFER_FULL_P (stream)
+	       || memchr (stream->cur, '\n', stream->level) != NULL;
+
+      case mu_buffer_full:
+	return BUFFER_FULL_P (stream);
+      }
+    return 0;
+}
+
+static int
+_stream_flush_buffer (struct _mu_stream *stream, int all)
+{
+  int rc;
+  char *end;
+		  
+  if (stream->flags & _MU_STR_DIRTY)
+    {
+      if ((stream->flags & MU_STREAM_SEEK)
+	  && (rc = mu_stream_seek (stream,
+				   - _stream_orig_level (stream),
+				   MU_SEEK_CUR, NULL)))
+	return rc;
+
+      switch (stream->buftype)
+	{
+	case mu_buffer_none:
+	    abort(); /* should not happen */
+	    
+	case mu_buffer_full:
+	  if ((rc = mu_stream_write_unbuffered (stream, stream->cur,
+						stream->level, 1, NULL)))
+	    return rc;
+	  break;
+	    
+	case mu_buffer_line:
+	  if (stream->level == 0)
+	    break;
+	  for (end = memchr (stream->cur, '\n', stream->level);
+	       end;
+	       end = memchr (stream->cur, '\n', stream->level))
+	    {
+	      size_t size = end - stream->cur + 1;
+	      rc = mu_stream_write_unbuffered (stream,
+					       stream->cur,
+					       size, 1, NULL);
+	      if (rc)
+		return rc;
+	      _stream_advance_buffer (stream, size);
+	    }
+	  if ((all && stream->level) || BUFFER_FULL_P (stream))
+	    {
+	      rc = mu_stream_write_unbuffered (stream,
+					       stream->cur,
+					       stream->level,
+					       1, NULL);
+	      if (rc)
+		return rc;
+	      _stream_advance_buffer (stream, stream->level);
+	    }
+	}
+    }
+  if (stream->level)
+    {
+      if (stream->cur > stream->buffer)
+	memmove (stream->buffer, stream->cur, stream->level);
+    }
+  else
+    {
+      stream->flags &= ~_MU_STR_DIRTY;
+      stream->level = 0;
+    }
+  stream->cur = stream->buffer;
+  return 0;
+}
+
+
 mu_stream_t
 _mu_stream_create (size_t size, int flags)
 {
@@ -58,6 +190,7 @@ _mu_stream_create (size_t size, int flags)
     abort ();
   str = mu_zalloc (size);
   str->flags = flags;
+  mu_stream_ref (str);
   return str;
 }
 
@@ -137,11 +270,6 @@ mu_stream_eof (mu_stream_t stream)
   return stream->flags & _MU_STR_EOF;
 }
 
-#define _stream_cleareof(s) ((s)->flags &= ~_MU_STR_EOF)
-#define _stream_advance_buffer(s,n) ((s)->cur += n, (s)->level -= n)
-#define _stream_buffer_offset(s) ((s)->cur - (s)->buffer)
-#define _stream_orig_level(s) ((s)->level + _stream_buffer_offset(s))
-
 int
 mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
 		mu_off_t *pres)
@@ -162,7 +290,7 @@ mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
       break;
 
     case MU_SEEK_CUR:
-	break;
+      break;
 
     case MU_SEEK_END: 
       bpos = _stream_buffer_offset (stream);
@@ -183,8 +311,8 @@ mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
       return _stream_seterror (stream, EINVAL, 1);
     }
 
-  if (mu_stream_flush (stream))
-    return -1;
+  if ((rc = _stream_flush_buffer (stream, 1)))
+    return rc;
   rc = stream->seek (stream, offset, whence, &res);
   if (rc)
     return _stream_seterror (stream, rc, 1);
@@ -247,15 +375,8 @@ mu_stream_read_unbuffered (mu_stream_t stream, void *buf, size_t size,
   if ((stream->flags & _MU_STR_EOF) || size == 0)
     {
       if (pnread)
-	{
-	  *pnread = 0;
-	  return 0;
-       }
-      else
-	{
-	  _stream_seterror (stream, EIO, 0);
-	  return EIO;
-	}
+	*pnread = 0;
+      return 0;
     }
     
     if (full_read)
@@ -277,8 +398,8 @@ mu_stream_read_unbuffered (mu_stream_t stream, void *buf, size_t size,
 	    stream->bytes_in += rdbytes;
 	    
 	  }
-	if (size)
-	  rc = _stream_seterror (stream, EIO, 0);
+	if (size && rc)
+	  rc = _stream_seterror (stream, rc, 0);
       }
     else
       {
@@ -349,136 +470,13 @@ mu_stream_write_unbuffered (mu_stream_t stream,
       if (rc == 0)
 	stream->bytes_out += nwritten;
     }
+  stream->flags |= _MU_STR_WRT;
   if (pnwritten)
     *pnwritten = nwritten;
   _stream_seterror (stream, rc, rc != 0);
   return rc;
 }
 
-static int
-_stream_fill_buffer (struct _mu_stream *stream)
-{
-  size_t n;
-  int rc = 0;
-  char c;
-    
-  switch (stream->buftype)
-    {
-    case mu_buffer_none:
-      return 0;
-	
-    case mu_buffer_full:
-      if (mu_stream_read_unbuffered (stream,
-				     stream->buffer, stream->bufsize,
-				     0,
-				     &stream->level))
-	return 1;
-      break;
-	
-    case mu_buffer_line:
-      for (n = 0;
-	   n < stream->bufsize
-	     && (rc = mu_stream_read_unbuffered (stream,
-						 &c, 1, 0, NULL)) == 0; n++)
-	{
-	  stream->buffer[n] = c;
-	  if (c == '\n')
-	    break;
-	}
-      stream->level = n;
-      break;
-    }
-  stream->cur = stream->buffer;
-  return rc;
-}
-
-#define BUFFER_FULL_P(s) \
-  ((s)->cur + (s)->level == (s)->buffer + (s)->bufsize)
-
-static int
-_stream_buffer_full_p (struct _mu_stream *stream)
-{
-    switch (stream->buftype)
-      {
-      case mu_buffer_none:
-	break;
-	
-      case mu_buffer_line:
-	return BUFFER_FULL_P (stream)
-	       || memchr (stream->cur, '\n', stream->level) != NULL;
-
-      case mu_buffer_full:
-	return BUFFER_FULL_P (stream);
-      }
-    return 0;
-}
-
-static int
-_stream_flush_buffer (struct _mu_stream *stream, int all)
-{
-  int rc;
-  char *end;
-		  
-  if (stream->flags & _MU_STR_DIRTY)
-    {
-      if ((stream->flags & MU_STREAM_SEEK)
-	  && (rc = mu_stream_seek (stream,
-				   - _stream_orig_level (stream),
-				   MU_SEEK_CUR, NULL)))
-	return rc;
-
-      switch (stream->buftype)
-	{
-	case mu_buffer_none:
-	    abort(); /* should not happen */
-	    
-	case mu_buffer_full:
-	  if ((rc = mu_stream_write_unbuffered (stream, stream->cur,
-						stream->level, 1, NULL)))
-	    return rc;
-	  break;
-	    
-	case mu_buffer_line:
-	  if (stream->level == 0)
-	    break;
-	  for (end = memchr(stream->cur, '\n', stream->level);
-	       end;
-	       end = memchr(stream->cur, '\n', stream->level))
-	    {
-	      size_t size = end - stream->cur + 1;
-	      rc = mu_stream_write_unbuffered (stream,
-					       stream->cur,
-					       size, 1, NULL);
-	      if (rc)
-		return rc;
-	      _stream_advance_buffer (stream, size);
-	    }
-	  if ((all && stream->level) || BUFFER_FULL_P (stream))
-	    {
-	      rc = mu_stream_write_unbuffered (stream,
-					       stream->cur,
-					       stream->level,
-					       1, NULL);
-	      if (rc)
-		return rc;
-	      _stream_advance_buffer (stream, stream->level);
-	    }
-	}
-    }
-  if (stream->level)
-    {
-      if (stream->cur > stream->buffer)
-	memmove (stream->buffer, stream->cur, stream->level);
-    }
-  else
-    {
-      stream->flags &= ~_MU_STR_DIRTY;
-      stream->level = 0;
-    }
-  stream->cur = stream->buffer;
-  return 0;
-}
-
 int
 mu_stream_read (mu_stream_t stream, void *buf, size_t size, size_t *pread)
 {
@@ -530,16 +528,17 @@ mu_stream_readline (mu_stream_t stream, char *buf, size_t size, size_t *pread)
 {
   int rc;
   char c;
-  size_t n = 0;
+  size_t n = 0, rdn;
     
   if (size == 0)
     return EIO;
     
   size--;
-  for (n = 0; n < size && (rc = mu_stream_read (stream, &c, 1, NULL)) == 0;
-       n++)
+  for (n = 0;
+       n < size && (rc = mu_stream_read (stream, &c, 1, &rdn)) == 0 && rdn;)
     {
       *buf++ = c;
+      n++;
       if (c == '\n')
 	break;
     }
@@ -571,9 +570,10 @@ mu_stream_getdelim (mu_stream_t stream, char **pbuf, size_t *psize,
   for (;;)
     {
       char c;
+      size_t rdn;
 
-      rc = mu_stream_read (stream, &c, 1, NULL);
-      if (rc)
+      rc = mu_stream_read (stream, &c, 1, &rdn);
+      if (rc || rdn == 0)
 	break;
 	
       /* Make enough space for len+1 (for final NUL) bytes.  */
@@ -686,8 +686,9 @@ mu_stream_flush (mu_stream_t stream)
   rc = _stream_flush_buffer (stream, 1);
   if (rc)
     return rc;
-  if (stream->flush)
+  if ((stream->flags & _MU_STR_WRT) && stream->flush)
     return stream->flush (stream);
+  stream->flags &= ~_MU_STR_WRT;
   return 0;
 }
 
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index 6b9fad0..75d2209 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -129,6 +129,11 @@ _streamref_seek (struct _mu_stream *str, mu_off_t off, int whence,
       break;
 
     case MU_SEEK_CUR:
+      if (off == 0)
+	{
+	  *ppos = sp->offset - sp->start;
+	  return 0;
+	}
       off += cur;
       break;
 
@@ -139,10 +144,12 @@ _streamref_seek (struct _mu_stream *str, mu_off_t off, int whence,
 
   if (off < 0 || off >= size)
     return sp->stream.last_err = EINVAL;
-  return streamref_return (sp,
-			   mu_stream_seek (sp->transport,
-					   sp->start + off, MU_SEEK_SET,
-					   &sp->offset));
+  rc = mu_stream_seek (sp->transport, sp->start + off, MU_SEEK_SET,
+		       &sp->offset);
+  if (rc)
+    return streamref_return (sp, rc);
+  *ppos = sp->offset - sp->start;
+  return 0;
 }
 
 static int
@@ -223,7 +230,8 @@ mu_streamref_create_abridged (mu_stream_t *pref, mu_stream_t str,
   if (rc)
     return rc;
   mu_stream_get_flags (str, &flags);
-  sp = (struct _mu_streamref *) _mu_stream_create (sizeof (*sp), flags);
+  sp = (struct _mu_streamref *) _mu_stream_create (sizeof (*sp),
+						   flags | MU_STREAM_NO_CLOSE);
   if (!sp)
     return ENOMEM;
   mu_stream_ref (str);


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu Apr 29 20:00:58 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O7df8-0002oI-2R
	for mharc-commit-mailutils@gnu.org; Thu, 29 Apr 2010 20:00:58 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O7df6-0002o8-CX
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 20:00:56 -0400
Received: from [140.186.70.92] (port=51331 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O7df2-0002nz-2d
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 20:00:56 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7df0-0002ky-2h
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 20:00:51 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:40841
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7dez-0002kq-TX
	for commit-mailutils@gnu.org; Thu, 29 Apr 2010 20:00:50 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7dew-0005oO-49
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 00:00:48 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7deh-0002Sb-3v
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 00:00:36 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/stream-cleanup
X-Git-Reftype: branch
X-Git-Oldrev: 2613500d4a50cf7d36e30eea6d7af915a38c8f7d
X-Git-Newrev: 0ee00fd5861514e757aa73b1e62ca9896b2461ff
Message-Id: <E1O7deh-0002Sb-3v@vcs-noshell.in.savannah.gnu.org>
Date: Fri, 30 Apr 2010 00:00:31 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, stream-cleanup,
	updated. rel-2_1-75-g0ee00fd
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: Fri, 30 Apr 2010 00:00:56 -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=0ee00fd5861514e757aa73b1e62ca9896b2461ff

The branch, stream-cleanup has been updated
       via  0ee00fd5861514e757aa73b1e62ca9896b2461ff (commit)
      from  2613500d4a50cf7d36e30eea6d7af915a38c8f7d (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 0ee00fd5861514e757aa73b1e62ca9896b2461ff
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Apr 30 02:59:59 2010 +0300

    Bugfixes in stream code.
    
    * mailbox/amd.c (amd_body_stream_seek): Fix boundary checking.
    Return ESPIPE on boundary error.
    * mailbox/header.c (header_seek): Likewise.
    * mailbox/memory_stream.c (_memory_seek): Likewise.
    * mailbox/message.c (_message_stream_seek): Likewise.
    * mailbox/message_stream.c (_message_seek): Likewise.
    * mailbox/stdio_stream.c (stdio_seek): Likewise.
    
    * mailbox/file_stream.c (fd_open): Invert error condition.
    Fix computation of open flags.
    Return immediately if open returns -1.
    (fd_seek): Fix boundary checking.
    Return ESPIPE on boundary error.
    * mailbox/mapfile_stream.c (_mapfile_open): Fix flags calculation.
    (_mapfile_seek): Fix boundary checking.
    Return ESPIPE on boundary error.
    
    * mailbox/streamref.c (_streamref_read): Fix calculation of the
    top size boundary.
    Return 0 bytes if seek returns ESPIPE.
    (_streamref_seek): Return ESPIPE on boundary error.
    
    * mailbox/base64.c (_base64_decoder, _base64_encoder): Do
    not dereference iobuf if cmd is mu_filter_init or mu_filter_done.
    * mailbox/binflt.c (_copy_codec, _bit7_coder): Likewise.
    * mailbox/crlfflt.c (_crlf_encoder, _crlf_decoder): Likewise.
    * mailbox/linelenflt.c (_ll_encoder): Likewise.
    * mailbox/qpflt.c (_qp_decoder, _qp_encoder): Likewise.
    
    * mailbox/mailcap.c (mu_mailcap_parse): Fix loop condition.

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

Summary of changes:
 mailbox/amd.c            |    4 ++--
 mailbox/base64.c         |   25 +++++++++++++++++--------
 mailbox/binflt.c         |   25 ++++++++++++++-----------
 mailbox/crlfflt.c        |   32 +++++++++++++++++++++-----------
 mailbox/file_stream.c    |    9 ++++++---
 mailbox/header.c         |    4 ++--
 mailbox/linelenflt.c     |   13 +++++++++----
 mailbox/mailcap.c        |    7 ++++---
 mailbox/mapfile_stream.c |    6 +++---
 mailbox/memory_stream.c  |    4 ++--
 mailbox/message.c        |    2 +-
 mailbox/message_stream.c |    2 +-
 mailbox/qpflt.c          |   25 +++++++++++++++++--------
 mailbox/stdio_stream.c   |    2 +-
 mailbox/streamref.c      |   18 ++++++++++++++++--
 15 files changed, 116 insertions(+), 62 deletions(-)

diff --git a/mailbox/amd.c b/mailbox/amd.c
index 34e823f..befe43e 100644
--- a/mailbox/amd.c
+++ b/mailbox/amd.c
@@ -1652,8 +1652,8 @@ amd_body_stream_seek (mu_stream_t str, mu_off_t off, int whence,
       break;
     }
 
-  if (off < 0 || off > size)
-    return EINVAL;
+  if (off < 0 || off >= size)
+    return ESPIPE;
 
   rc = mu_stream_seek (mhm->stream, mhm->body_start + off, MU_SEEK_SET, NULL);
   if (rc)
diff --git a/mailbox/base64.c b/mailbox/base64.c
index 156c4a8..fd0131e 100644
--- a/mailbox/base64.c
+++ b/mailbox/base64.c
@@ -114,10 +114,10 @@ _base64_decoder (void *xd MU_ARG_UNUSED,
   size_t consumed = 0;
   unsigned char data[4];
   size_t nbytes = 0;
-  const char *iptr = iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  const char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
 
   switch (cmd)
     {
@@ -133,7 +133,12 @@ _base64_decoder (void *xd MU_ARG_UNUSED,
       iobuf->osize = 3;
       return mu_filter_moreoutput;
     }
-  
+
+  iptr = iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+ 
   while (consumed < isize && nbytes + 3 < osize)
     {
       while (i < 4 && consumed < isize)
@@ -179,9 +184,9 @@ _base64_encoder (void *xd MU_ARG_UNUSED,
   int pad = 0;
   const unsigned char *ptr = (const unsigned char*) iobuf->input;
   size_t nbytes = 0;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  size_t isize;
+  char *optr;
+  size_t osize;
   
   switch (cmd)
     {
@@ -208,6 +213,10 @@ _base64_encoder (void *xd MU_ARG_UNUSED,
       return mu_filter_moreoutput;
     }
       
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+
   while ((consumed + 3 <= isize && nbytes + 4 <= osize) || pad)
     {
       unsigned char c1 = 0, c2 = 0, x = '=', y = '=';
diff --git a/mailbox/binflt.c b/mailbox/binflt.c
index 003b665..d3de518 100644
--- a/mailbox/binflt.c
+++ b/mailbox/binflt.c
@@ -27,10 +27,7 @@ _copy_codec (void *xd MU_ARG_UNUSED,
 	     enum mu_filter_command cmd,
 	     struct mu_filter_io *iobuf)
 {
-  const char *iptr = iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  size_t osize;
 
   switch (cmd)
     {
@@ -41,9 +38,10 @@ _copy_codec (void *xd MU_ARG_UNUSED,
       break;
     }
   
-  if (osize > isize)
-    osize = isize;
-  memcpy (optr, iptr, osize);
+  osize = iobuf->osize;
+  if (osize > iobuf->isize)
+    osize = iobuf->isize;
+  memcpy (iobuf->output, iobuf->input, osize);
   iobuf->isize = osize;
   iobuf->osize = osize;
   return mu_filter_ok;
@@ -55,10 +53,10 @@ _bit7_coder (void *xd MU_ARG_UNUSED,
 	     struct mu_filter_io *iobuf)
 {
   size_t i;
-  const unsigned char *iptr = (const unsigned char *) iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  const unsigned char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
 
   switch (cmd)
     {
@@ -69,6 +67,11 @@ _bit7_coder (void *xd MU_ARG_UNUSED,
       break;
     }
   
+  iptr = (const unsigned char *) iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+
   if (osize > isize)
     osize = isize;
   for (i = 0; i < osize; i++)
diff --git a/mailbox/crlfflt.c b/mailbox/crlfflt.c
index a07e08d..3e9bab0 100644
--- a/mailbox/crlfflt.c
+++ b/mailbox/crlfflt.c
@@ -31,10 +31,10 @@ _crlf_encoder (void *xd MU_ARG_UNUSED,
 	       struct mu_filter_io *iobuf)
 {
   size_t i, j;
-  const char *iptr = iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  const unsigned char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
 
   switch (cmd)
     {
@@ -45,9 +45,14 @@ _crlf_encoder (void *xd MU_ARG_UNUSED,
       break;
     }
   
+  iptr = (const unsigned char *) iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+
   for (i = j = 0; i < isize && j < osize; i++)
     {
-      unsigned char c = *(unsigned char*)iptr++;
+      unsigned char c = *iptr++;
       if (c == '\n')
 	{
 	  if (j + 1 == osize)
@@ -80,10 +85,10 @@ _crlf_decoder (void *xd MU_ARG_UNUSED,
 	       struct mu_filter_io *iobuf)
 {
   size_t i, j;
-  const char *iptr = iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  const unsigned char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
 
   switch (cmd)
     {
@@ -94,14 +99,19 @@ _crlf_decoder (void *xd MU_ARG_UNUSED,
       break;
     }
   
+  iptr = (const unsigned char *) iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+
   for (i = j = 0; i < isize && j < osize; i++)
     {
-      unsigned char c = *(unsigned char*)iptr++;
+      unsigned char c = *iptr++;
       if (c == '\r')
 	{
 	  if (i + 1 == isize)
 	    break;
-	  if (*(unsigned char*)iptr == '\n')
+	  if (*iptr == '\n')
 	    continue;
 	}
       optr[j++] = c;
diff --git a/mailbox/file_stream.c b/mailbox/file_stream.c
index 69a5d6b..977004d 100644
--- a/mailbox/file_stream.c
+++ b/mailbox/file_stream.c
@@ -75,13 +75,13 @@ fd_open (struct _mu_stream *str)
   int oflg;
   int fd;
   
-  if (fstr->filename)
+  if (!fstr->filename)
     return EINVAL;
   if (fstr->fd != -1)
     fd_close (str);
 
   /* Map the flags to the system equivalent.  */
-  if (fstr->stream.flags & MU_STREAM_RDWR)
+  if ((fstr->stream.flags & MU_STREAM_RDWR) == MU_STREAM_RDWR)
     oflg = O_RDWR;
   else if (fstr->stream.flags & (MU_STREAM_WRITE|MU_STREAM_APPEND))
     oflg = O_WRONLY;
@@ -109,6 +109,9 @@ fd_open (struct _mu_stream *str)
   else
     fd = open (fstr->filename, oflg);
 
+  if (fd == -1)
+    return errno;
+  
   if (!(fstr->stream.flags & MU_STREAM_ALLOW_LINKS)
       && (fstr->stream.flags & (MU_STREAM_CREAT | MU_STREAM_RDWR |
 				MU_STREAM_APPEND)))
@@ -149,7 +152,7 @@ fd_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presult)
 { 
   struct _mu_file_stream *fstr = (struct _mu_file_stream *) str;
   off = lseek (fstr->fd, off, whence);
-  if (off <= 0)
+  if (off < 0)
     return errno;
   *presult = off;
   return 0;
diff --git a/mailbox/header.c b/mailbox/header.c
index 5d23a98..50ff83f 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -956,8 +956,8 @@ header_seek (mu_stream_t str, mu_off_t off, int whence, mu_off_t *presult)
       break;
     }
 
-  if (off < 0 || off > hstr->hdr->size)
-    return EINVAL;
+  if (off < 0 || off >= hstr->hdr->size)
+    return ESPIPE;
   hstr->off = off;
   return 0;
 }
diff --git a/mailbox/linelenflt.c b/mailbox/linelenflt.c
index b487553..e3817de 100644
--- a/mailbox/linelenflt.c
+++ b/mailbox/linelenflt.c
@@ -34,10 +34,10 @@ _ll_encoder (void *xd,
 	     struct mu_filter_io *iobuf)
 {
   struct _mu_linelen_filter *flt = xd;
-  const char *iptr = iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  const char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
   size_t consumed, written;
   
   switch (cmd)
@@ -50,6 +50,11 @@ _ll_encoder (void *xd,
       break;
     }
 
+  iptr = iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+
   for (consumed = written = 0; consumed < isize && written < osize; )
     {
       char *p;
diff --git a/mailbox/mailcap.c b/mailbox/mailcap.c
index d0815b0..d9e96f2 100644
--- a/mailbox/mailcap.c
+++ b/mailbox/mailcap.c
@@ -510,9 +510,9 @@ mu_mailcap_parse (mu_mailcap_t mailcap, mu_stream_t stream)
   size_t n;
   char *previous;
   char *buffer;
-  int buflen = 512;
+  size_t buflen = 512;
 
-  buffer = malloc (buflen * sizeof (*buffer));
+  buffer = malloc (buflen);
   if (buffer == NULL)
     {
       return ENOMEM;
@@ -532,7 +532,8 @@ mu_mailcap_parse (mu_mailcap_t mailcap, mu_stream_t stream)
   if (status)
     return status;
   previous = NULL;
-  while ((status = mu_stream_readline (stream, buffer, buflen, &n)) == 0)
+  while ((status = mu_stream_readline (stream, buffer, buflen, &n)) == 0
+	 && n > 0)
     {
       int len;
 
diff --git a/mailbox/mapfile_stream.c b/mailbox/mapfile_stream.c
index 66bcca4..a54c65c 100644
--- a/mailbox/mapfile_stream.c
+++ b/mailbox/mapfile_stream.c
@@ -266,7 +266,7 @@ _mapfile_open (mu_stream_t stream)
       mfs->fd = -1;
     }
   /* Map the flags to the system equivalent */
-  if (flags & MU_STREAM_RDWR)
+  if ((flags & MU_STREAM_RDWR) == MU_STREAM_RDWR)
     {
       mflag = PROT_READ | PROT_WRITE;
       flg = O_RDWR;
@@ -331,8 +331,8 @@ _mapfile_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presu
       break;
     }
 
-  if (off < 0 || off > mfs->size)
-    return EINVAL;
+  if (off < 0 || off >= mfs->size)
+    return ESPIPE;
   mfs->offset = off;
   *presult = off;
   return 0;
diff --git a/mailbox/memory_stream.c b/mailbox/memory_stream.c
index 1f388fb..8e93e7b 100644
--- a/mailbox/memory_stream.c
+++ b/mailbox/memory_stream.c
@@ -185,8 +185,8 @@ _memory_seek (struct _mu_stream *stream, mu_off_t off, int whence,
       break;
     }
 
-  if (off < 0 || off > mfs->size)
-    return EINVAL;
+  if (off < 0)
+    return ESPIPE;
   mfs->offset = off;
   *presult = off;
   return 0;
diff --git a/mailbox/message.c b/mailbox/message.c
index b92815e..5d9a505 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -183,7 +183,7 @@ _message_stream_seek (struct _mu_stream *str, mu_off_t off, int whence,
       break;
     }
   if (off < 0 || off >= size)
-    return EINVAL;
+    return ESPIPE;
 
   switch (sp->state)
     {
diff --git a/mailbox/message_stream.c b/mailbox/message_stream.c
index f5c3cc4..6b3cb7d 100644
--- a/mailbox/message_stream.c
+++ b/mailbox/message_stream.c
@@ -325,7 +325,7 @@ _message_seek (struct _mu_stream *stream, mu_off_t off, int whence,
     }
 
   if (off < 0 || off >= size)
-    return s->stream.last_err = EINVAL;
+    return ESPIPE;
   s->offset = off;
   *presult = off;
   return 0;
diff --git a/mailbox/qpflt.c b/mailbox/qpflt.c
index cde2688..4d8db53 100644
--- a/mailbox/qpflt.c
+++ b/mailbox/qpflt.c
@@ -33,10 +33,10 @@ _qp_decoder (void *xd MU_ARG_UNUSED,
   size_t consumed = 0;
   size_t wscount = 0;
   size_t nbytes = 0;
-  const char *iptr = iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  const char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
 
   switch (cmd)
     {
@@ -47,6 +47,11 @@ _qp_decoder (void *xd MU_ARG_UNUSED,
       break;
     }
   
+  iptr = iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+
   while (consumed < isize && nbytes < osize)
     {
       c = *iptr++;
@@ -159,10 +164,10 @@ _qp_encoder (void *xd MU_ARG_UNUSED,
   size_t consumed = 0;
   size_t nbytes = 0;
   static const char _hexdigits[] = "0123456789ABCDEF";
-  const char *iptr = iobuf->input;
-  size_t isize = iobuf->isize;
-  char *optr = iobuf->output;
-  size_t osize = iobuf->osize;
+  const char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
 
   switch (cmd)
     {
@@ -173,6 +178,10 @@ _qp_encoder (void *xd MU_ARG_UNUSED,
       break;
     }
 
+  iptr = iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
   nbytes = 0;
 
   /* Strategy: check if we have enough room in the output buffer only
diff --git a/mailbox/stdio_stream.c b/mailbox/stdio_stream.c
index d401270..dac196c 100644
--- a/mailbox/stdio_stream.c
+++ b/mailbox/stdio_stream.c
@@ -147,7 +147,7 @@ stdio_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presult)
     }
 
   if (off < 0)
-    return EINVAL;
+    return ESPIPE;
 
   fs->offset = off;
   *presult = fs->offset;
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index 75d2209..04c8450 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -41,9 +41,17 @@ _streamref_read (struct _mu_stream *str, char *buf, size_t bufsize,
   struct _mu_streamref *sp = (struct _mu_streamref *)str;
   int rc;
   size_t nread;
-  rc = mu_stream_seek (sp->transport, sp->offset, MU_SEEK_SET, NULL);
+  mu_off_t off;
+  
+  rc = mu_stream_seek (sp->transport, sp->offset, MU_SEEK_SET, &off);
   if (rc == 0)
     {
+      if (sp->end)
+	{
+	  size_t size = sp->end - off + 1;
+	  if (size < bufsize)
+	    bufsize = size;
+	}
       rc = mu_stream_read (sp->transport, buf, bufsize, &nread);
       if (rc == 0)
 	{
@@ -51,6 +59,12 @@ _streamref_read (struct _mu_stream *str, char *buf, size_t bufsize,
 	  *pnread = nread;
 	}
     }
+  else if (rc == ESPIPE)
+    {
+      *pnread = 0;
+      str->flags |= _MU_STR_EOF;
+      return 0;
+    }
   return streamref_return (sp, rc);
 }
 
@@ -143,7 +157,7 @@ _streamref_seek (struct _mu_stream *str, mu_off_t off, int whence,
     }
 
   if (off < 0 || off >= size)
-    return sp->stream.last_err = EINVAL;
+    return sp->stream.last_err = ESPIPE;
   rc = mu_stream_seek (sp->transport, sp->start + off, MU_SEEK_SET,
 		       &sp->offset);
   if (rc)


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Fri Apr 30 18:37:15 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O7ypf-0008F8-5n
	for mharc-commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:37:15 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O7ypd-0008Dr-J5
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:37:13 -0400
Received: from [140.186.70.92] (port=44789 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O7ypa-0008BM-6y
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:37:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7ypX-0007rB-BT
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:37:10 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:49876
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7ypX-0007r4-8I
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:37:07 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7ypW-0005FV-Ls
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 22:37:06 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7ypW-0002sl-F7
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 22:37:06 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/stream-cleanup
X-Git-Reftype: branch
X-Git-Oldrev: 0ee00fd5861514e757aa73b1e62ca9896b2461ff
X-Git-Newrev: 987ec1d4f1fda22924fc84531e76f02fe6a288b9
Message-Id: <E1O7ypW-0002sl-F7@vcs-noshell.in.savannah.gnu.org>
Date: Fri, 30 Apr 2010 22:37:06 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, stream-cleanup,
	updated. rel-2_1-79-g987ec1d
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: Fri, 30 Apr 2010 22:37:14 -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=987ec1d4f1fda22924fc84531e76f02fe6a288b9

The branch, stream-cleanup has been updated
       via  987ec1d4f1fda22924fc84531e76f02fe6a288b9 (commit)
       via  2076b7637d834f9fcb26144037f6985fee9bbe9b (commit)
       via  fc9d0ad4a67789490761459c6334bbf4dc689ce0 (commit)
       via  57168a550fc55eba4bed74721a042ec1de99c2e3 (commit)
      from  0ee00fd5861514e757aa73b1e62ca9896b2461ff (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 987ec1d4f1fda22924fc84531e76f02fe6a288b9
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 01:33:49 2010 +0300

    Fix compilation of libmu_scm.
    
    * libmu_scm/mu_body.c (mu_scm_body_free): Unref the stream.
    Return 0.
    (mu-body-read-line, mu-body-write): Use stringrefs.
    * libmu_scm/mu_mailbox.c (mu-mailbox-get-port): Use stringrefs.
    * libmu_scm/mu_message.c (mu-message-copy): Use stringrefs.
    Use mu_stream_copy instead of manually copying stream contents.
    (mu-message-get-port): Use stringrefs.
    * libmu_scm/mu_port.c (mu_port_free): Unref the stream.

commit 2076b7637d834f9fcb26144037f6985fee9bbe9b
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 01:31:16 2010 +0300

    Fix compilation of several example programs.
    
    * examples/header.c: Use streamrefs.
    * examples/mimetest.c: Likewise.
    * examples/mta.c: Likewise.
    * examples/nntpclient.c: Remove an unused variable.

commit fc9d0ad4a67789490761459c6334bbf4dc689ce0
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 01:29:39 2010 +0300

    Fix compilation of mimeview.
    
    * mimeview/mimeview.c (mimeview_fp): Restore the variable.

commit 57168a550fc55eba4bed74721a042ec1de99c2e3
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 01:28:47 2010 +0300

    Fix UNIX mbox driver and mail utility.
    
    The `mail' and `frm' utilities pass tests.
    
    * include/mailutils/stream.h (mu_stream_err): New proto.
    * libproto/mbox/mbox.c (_msg_stream_setup)
    (_msg_body_setup): Fix stream abridgement.
    (mbox_envelope_date, mbox_envelope_sender): Fix seek position.
    (uid_to_stream): Fix invocation of mu_stream_printf.
    (append_message_to_stream): Likewise.
    (mbox_expunge_unlocked): Rewind tempstr before copying its
    contents back to the mailbox.
    (mbox_expunge0): Open tempstr.
    * libproto/mbox/mbox0.h (_mbox_message)<header_from>: Rename to
    envel_from.
    <header_from_end>: Rename to envel_from_end. All uses changed.
    * libproto/mbox/mboxscan.c: Minor changes.
    
    * mail/decode.c: Use streamrefs.
    * mail/escape.c: Likewise.
    * mail/msgset.y: Likewise.
    * mail/pipe.c: Likewise.
    * mail/print.c: Likewise.
    * mail/top.c: Likewise.
    * mail/write.c: Likewise.
    
    * mail/send.c: Use streamrefs.
    (mail_send0): Reset env->header after assigning it to
    the message.
    
    * mailbox/body.c (_body_seek): Fix a typo which produced
    a recursive call.
    * mailbox/file_stream.c (fd_truncate): New function.
    (_mu_file_stream_create): Initialize str->stream.truncate.
    
    * mailbox/header.c (header_parse): Fix parsing of blurbs lacking
    terminating empty line.
    (header_seek): Fix boundary checks.
    Return new position in presult.
    * mailbox/message.c (string_find_eoh): Rewrite to handle \n\n
    split between two successive invocations.
    (_header_fill): Update the invocation of string_find_eoh.
    
    * mailbox/stream.c (mu_stream_destroy): Call mu_stream_close.
    (mu_stream_get_flags, mu_stream_set_flags)
    (mu_stream_clr_flags): Ignore internal
    bits.
    (mu_stream_err): New function.
    (mu_stream_close): Close the stream only if it is not used by anyone else.
    * mailbox/streamref.c (_streamref_read): Clear transport error if
    ESPIPE is returned.
    (_streamref_size): Take into account sp->end and sp->start.
    (mu_streamref_create_abridged): Set pointer to 0.

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

Summary of changes:
 examples/header.c          |    7 ++-
 examples/mimetest.c        |    4 +-
 examples/mta.c             |    5 +-
 examples/nntpclient.c      |    1 -
 include/mailutils/stream.h |    1 +
 libmu_scm/mu_body.c        |    7 ++-
 libmu_scm/mu_mailbox.c     |    2 +-
 libmu_scm/mu_message.c     |   28 +++++--------
 libmu_scm/mu_port.c        |    2 +
 libproto/mbox/mbox.c       |   98 ++++++++++++++++++++++++++------------------
 libproto/mbox/mbox0.h      |    4 +-
 libproto/mbox/mboxscan.c   |    9 ++--
 mail/decode.c              |   38 ++++++-----------
 mail/escape.c              |   19 +++++----
 mail/msgset.y              |    5 +-
 mail/pipe.c                |    5 +-
 mail/print.c               |   14 +++++-
 mail/send.c                |   27 +++++++-----
 mail/top.c                 |    5 +-
 mail/write.c               |    7 ++-
 mailbox/body.c             |    2 +-
 mailbox/file_stream.c      |   10 ++++
 mailbox/header.c           |   20 +++------
 mailbox/message.c          |   42 +++++++++++++------
 mailbox/stream.c           |   18 ++++++--
 mailbox/streamref.c        |   23 ++++++++--
 mimeview/mimeview.c        |   10 ++--
 27 files changed, 240 insertions(+), 173 deletions(-)

diff --git a/examples/header.c b/examples/header.c
index 742bc2b..90cce65 100644
--- a/examples/header.c
+++ b/examples/header.c
@@ -173,7 +173,7 @@ cmd_dump (int argc, char **argv)
   if (argc == 2)
     off = strtoul (argv[1], NULL, 0);
 
-  status = mu_header_get_stream (header, &stream);
+  status = mu_header_get_streamref (header, &stream);
   if (status)
     {
       mu_error ("%u: cannot get stream: %s", line_num, mu_strerror (status));
@@ -183,6 +183,7 @@ cmd_dump (int argc, char **argv)
   status = mu_stream_seek (stream, off, SEEK_SET, NULL);
   if (status)
     {
+      mu_stream_destroy (&stream);
       mu_error ("%u: cannot seek: %s", line_num, mu_strerror (status));
       return;
     }
@@ -192,6 +193,7 @@ cmd_dump (int argc, char **argv)
     {
       fwrite (buf, 1, n, stdout);
     }
+  mu_stream_destroy (&stream);
 }  
 
 void
@@ -272,7 +274,7 @@ cmd_write (int argc, char **argv)
   if (check_args (argv[0], argc, 1, 1))
     return;
 
-  status = mu_header_get_stream (header, &str);
+  status = mu_header_get_streamref (header, &str);
   if (status)
     {
       mu_error ("%u: cannot get stream: %s", line_num, mu_strerror (status));
@@ -286,6 +288,7 @@ cmd_write (int argc, char **argv)
       if (buf[0] == '\n')
 	break;
     }
+  mu_stream_destroy (&str);
 }
 
 void
diff --git a/examples/mimetest.c b/examples/mimetest.c
index ed527ba..8e38ca9 100644
--- a/examples/mimetest.c
+++ b/examples/mimetest.c
@@ -250,12 +250,12 @@ message_display_parts (mu_message_t msg, int indent)
 	  printf ("%*.*sText Message\n", indent, indent, "");
           printf ("%*.*sBegin\n", indent, indent, "");
           mu_message_get_body (part, &body);
-          mu_body_get_stream (body, &str);
+          mu_body_get_streamref (body, &str);
           /* Make sure the original body stream is not closed when
              str gets destroyed */
           mu_filter_create (&str, str, encoding, MU_FILTER_DECODE,
 			    MU_STREAM_READ | MU_STREAM_NO_CLOSE);
-
+	  
 	  while (mu_stream_readline (str, buf, sizeof (buf), &nbytes) == 0
 		 && nbytes)
             {
diff --git a/examples/mta.c b/examples/mta.c
index 6d10480..1604955 100644
--- a/examples/mta.c
+++ b/examples/mta.c
@@ -19,7 +19,7 @@
 
 /* This is a "fake" mta designed for testing purposes. It imitates
    sendmail sending and daemon modes. It does not actually send anything,
-   instead it just outputs the transcript of what would have been done.
+   instead it just outputs a transcript of what would have been done.
 
    Invocation:
    
@@ -326,7 +326,7 @@ mta_send (mu_message_t msg)
   fprintf (diag, "ENVELOPE TO: %s\n", value);
   free (value);
 
-  mu_message_get_stream (msg, &stream);
+  mu_message_get_streamref (msg, &stream);
   line = 0;
   fprintf (diag, "%4lu: ", (unsigned long) line);
   while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
@@ -344,6 +344,7 @@ mta_send (mu_message_t msg)
 	    }
 	}
     }
+  mu_stream_destroy (&stream);
   fprintf (diag, "\nEND OF MESSAGE\n");
   fflush (diag);
   return 0;
diff --git a/examples/nntpclient.c b/examples/nntpclient.c
index 2c652f1..4fac953 100644
--- a/examples/nntpclient.c
+++ b/examples/nntpclient.c
@@ -423,7 +423,6 @@ com_body (char *arg)
 
    if (status == 0 && stream != NULL)
     {
-      size_t n = 0;
       char buf[128];
       while (mu_stream_readline (stream, buf, sizeof buf, 0) == 0)
         printf ("%s", buf);
diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index e6b2f5e..0197fcd 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -65,6 +65,7 @@ void mu_stream_unref (mu_stream_t stream);
 void mu_stream_destroy (mu_stream_t *pstream);
 int mu_stream_open (mu_stream_t stream);
 const char *mu_stream_strerror (mu_stream_t stream, int rc);
+int mu_stream_err (mu_stream_t stream);
 int mu_stream_last_error (mu_stream_t stream);
 void mu_stream_clearerr (mu_stream_t stream);
 int mu_stream_eof (mu_stream_t stream);
diff --git a/libmu_scm/mu_body.c b/libmu_scm/mu_body.c
index 3a5db3f..a5c5cf5 100644
--- a/libmu_scm/mu_body.c
+++ b/libmu_scm/mu_body.c
@@ -47,8 +47,9 @@ mu_scm_body_free (SCM body_smob)
   struct mu_body *mbp = (struct mu_body *) SCM_CDR (body_smob);
   if (mbp->buffer)
     free (mbp->buffer);
+  mu_stream_unref (mbp->stream);
   free (mbp);
-  return sizeof (struct mu_body);
+  return 0;
 }
 
 static int
@@ -114,7 +115,7 @@ SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0,
 
   if (!mbp->stream)
     {
-      status = mu_body_get_stream (mbp->body, &mbp->stream);
+      status = mu_body_get_streamref (mbp->body, &mbp->stream);
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "Cannot get body stream",
@@ -158,7 +159,7 @@ SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0,
   
   if (!mbp->stream)
     {
-      status = mu_body_get_stream (mbp->body, &mbp->stream);
+      status = mu_body_get_streamref (mbp->body, &mbp->stream);
       if (status)
 	mu_scm_error (FUNC_NAME, status,
 		      "Cannot get body stream", SCM_BOOL_F);
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index dce05e8..4dec046 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -316,7 +316,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0,
   SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME);
   SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME);
   mum = (struct mu_mailbox *) SCM_CDR (mbox);
-  status = mu_mailbox_get_stream (mum->mbox, &stream);
+  status = mu_mailbox_get_streamref (mum->mbox, &stream);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get mailbox stream",
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index 127cfe7..ffcf9e3 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -195,14 +195,12 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
 {
   mu_message_t msg, newmsg;
   mu_stream_t in = NULL, out = NULL;
-  char buffer[512];
-  size_t n;
   int status;
   
   SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
   msg = mu_scm_message_get (mesg);
 
-  status = mu_message_get_stream (msg, &in);
+  status = mu_message_get_streamref (msg, &in);
   if (status)
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot get input stream from message ~A",
@@ -213,7 +211,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
     mu_scm_error (FUNC_NAME, status,
 		  "Cannot create message", SCM_BOOL_F);
   
-  status = mu_message_get_stream (newmsg, &out);
+  status = mu_message_get_streamref (newmsg, &out);
   if (status)
     {
       mu_message_destroy (&newmsg, NULL);
@@ -221,18 +219,14 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0,
 		    "Cannot get output stream", SCM_BOOL_F);
     }
 
-  mu_stream_seek (in, 0, MU_SEEK_SET, NULL);
-  while ((status = mu_stream_read (in, buffer, sizeof (buffer) - 1, &n))
-	 == 0
-	 && n != 0)
+  status = mu_stream_copy (out, in, 0);
+  mu_stream_destroy (&in);
+  mu_stream_destroy (&out);
+  if (status)
     {
-      status = mu_stream_write (out, buffer, n, NULL);
-      if (status)
-	{
-	  mu_message_destroy (&newmsg, NULL);
-	  mu_scm_error (FUNC_NAME, status,
-			"Error writing to stream", SCM_BOOL_F);
-	}
+      mu_message_destroy (&newmsg, NULL);
+      mu_scm_error (FUNC_NAME, status,
+		    "Error writing to stream", SCM_BOOL_F);
     }
   
   return mu_scm_message_create (SCM_BOOL_F, newmsg);
@@ -905,7 +899,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
       SCM_ASSERT (scm_is_bool (full), full, SCM_ARG3, FUNC_NAME);
       if (full == SCM_BOOL_T)
 	{
-	  status = mu_message_get_stream (msg, &stream);
+	  status = mu_message_get_streamref (msg, &stream);
 	  if (status)
 	    mu_scm_error (FUNC_NAME, status, "Cannot get message stream",
 			  SCM_BOOL_F);
@@ -920,7 +914,7 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0,
       if (status)
 	mu_scm_error (FUNC_NAME, status, "Cannot get message body",
 		      SCM_BOOL_F);
-      status = mu_body_get_stream (body, &stream);
+      status = mu_body_get_streamref (body, &stream);
       if (status)
 	mu_scm_error (FUNC_NAME, status, "Cannot get message body stream",
 		      SCM_BOOL_F);
diff --git a/libmu_scm/mu_port.c b/libmu_scm/mu_port.c
index 2214dd3..0efa5e7 100644
--- a/libmu_scm/mu_port.c
+++ b/libmu_scm/mu_port.c
@@ -151,6 +151,8 @@ mu_port_close (SCM port)
 static scm_sizet
 mu_port_free (SCM port)
 {
+  struct mu_port *mp = MU_PORT (port);
+  mu_stream_unref (mp->stream);
   mu_port_close (port);
   return 0;
 }
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c
index 7e16f4f..5bb043c 100644
--- a/libproto/mbox/mbox.c
+++ b/libproto/mbox/mbox.c
@@ -259,7 +259,7 @@ static int
 mbox_message_qid (mu_message_t msg, mu_message_qid_t *pqid)
 {
   mbox_message_t mum = mu_message_get_owner (msg);
-  return mu_asprintf (pqid, "%lu", (unsigned long) mum->header_from);
+  return mu_asprintf (pqid, "%lu", (unsigned long) mum->envel_from);
 }
 
 
@@ -297,8 +297,8 @@ _msg_stream_setup (mu_message_t msg, mbox_message_t mum)
   
   status = mu_streamref_create_abridged (&stream,
 					 mum->mud->mailbox->stream,
-					 mum->header_from_end + 1,
-					 mum->body);
+					 mum->envel_from_end,
+					 mum->body_end);
   if (status == 0)
     status = mu_message_set_stream (msg, stream, mum);
   return status;
@@ -343,7 +343,7 @@ _msg_body_setup (mu_message_t msg, mbox_message_t mum)
   status = mu_streamref_create_abridged (&stream,
 					 mum->mud->mailbox->stream,
 					 mum->body,
-					 mum->body_end);
+					 mum->body_end - 1);
   if (status)
     mu_body_destroy (&body, msg);
   else
@@ -373,7 +373,7 @@ mbox_envelope_date (mu_envelope_t envelope, char *buf, size_t len,
     return EINVAL;
 
   status = mu_stream_seek (mum->mud->mailbox->stream,
-			   mum->header_from, MU_SEEK_SET,
+			   mum->envel_from, MU_SEEK_SET,
 			   NULL);
   if (status)
     return status;
@@ -419,7 +419,7 @@ mbox_envelope_sender (mu_envelope_t envelope, char *buf, size_t len,
     return EINVAL;
 
   status = mu_stream_seek (mum->mud->mailbox->stream,
-			   mum->header_from, MU_SEEK_SET,
+			   mum->envel_from, MU_SEEK_SET,
 			   NULL);
   if (status)
     return status;
@@ -1022,8 +1022,10 @@ uid_to_stream (mu_stream_t ostr, mu_message_t msg, mbox_data_t mud, int flags)
   else
     uid = mud->uidnext++;
   
-  return mu_stream_printf (ostr, "%s: %u\n", MU_HEADER_X_UID,
-			   (unsigned) uid);
+  mu_stream_printf (ostr, "%s: %u\n", MU_HEADER_X_UID, (unsigned) uid);
+  if (mu_stream_err (ostr))
+    return mu_stream_last_error (ostr);
+  return 0;
 }
 
 /* Append MSG to stream OSTR in its current position */
@@ -1048,12 +1050,14 @@ append_message_to_stream (mu_stream_t ostr, mu_message_t msg,
 
       if (flags & MBOX_FIRSTMSG)
 	{
-	  status = mu_stream_printf (ostr, "%s: %lu %u\n",
-				     MU_HEADER_X_IMAPBASE,
-				     (unsigned long) mud->uidvalidity,
-				     (unsigned) mud->uidnext);
-	  if (status)
-	    return status;
+	  /* FIXME: Perhaps printf should return error code,
+	     like the rest of stream functions. */
+	  mu_stream_printf (ostr, "%s: %lu %u\n",
+			    MU_HEADER_X_IMAPBASE,
+			    (unsigned long) mud->uidvalidity,
+			    (unsigned) mud->uidnext);
+	  if (mu_stream_err (ostr))
+	    return mu_stream_last_error (ostr);
 	}
 
       status = msg_attr_to_stream (ostr, msg);
@@ -1165,7 +1169,7 @@ mbox_reset (mu_mailbox_t mailbox, size_t dirty, int remove_deleted)
 	  else
 	    memset (mum, 0, sizeof (*mum));
 	}
-      mum->header_from = mum->header_from_end = 0;
+      mum->envel_from = mum->envel_from_end = 0;
       mum->body = mum->body_end = 0;
       mum->header_lines = mum->body_lines = 0;
     }
@@ -1187,7 +1191,7 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted,
   mu_off_t size;
 
   /* Set the marker position.  */
-  start_off = mud->umessages[dirty]->header_from;
+  start_off = mud->umessages[dirty]->envel_from;
 
   for (i = dirty; i < mud->messages_count; i++)
     {
@@ -1226,8 +1230,8 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted,
 	      status = mbox_get_message (mailbox, i + 1, &msg);
 	      if (status != 0)
 		{
-		  mu_error (_("error expunging:%d: %s"), __LINE__,
-			    mu_strerror (status));
+		  mu_error (_("%s:%d: error expunging: %s"),	        
+			    __FILE__, __LINE__, mu_strerror (status));	
 		  return status;
 		}
 	    }
@@ -1235,8 +1239,8 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted,
 					     flags);
 	  if (status != 0)
 	    {
-	      mu_error (_("error expunging:%d: %s"), __LINE__,
-		        mu_strerror (status));
+	      mu_error (_("%s:%d: error expunging: %s"),	        
+			__FILE__, __LINE__, mu_strerror (status));	
 	      return status;
 	    }
 	  /* Clear the dirty bits.  */
@@ -1247,7 +1251,7 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted,
 	{
 	  /* Otherwise, copy bits from mailbox->stream as is. */
 	  
-	  status = mu_stream_seek (mailbox->stream, mum->header_from,
+	  status = mu_stream_seek (mailbox->stream, mum->envel_from,
 				   MU_SEEK_SET, NULL);
 	  if (status)
 	    {
@@ -1257,7 +1261,7 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted,
 	      return status;
 	    }
 	  status = mu_stream_copy (tempstr, mailbox->stream,
-				   mum->body_end - mum->header_from);
+				   mum->body_end - mum->envel_from);
 	  if (status)
 	    {
 	      mu_error (_("%s:%d: error copying: %s"),
@@ -1336,10 +1340,19 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t dirty, int remove_deleted,
       return status;
     }
   
+  status = mu_stream_seek (tempstr, 0, MU_SEEK_SET, NULL);
+  if (status)
+    {
+      mu_error (_("%s:%d: seek error: %s"),
+		__FILE__, __LINE__,
+		mu_stream_strerror (mailbox->stream, status));
+      return status;
+    }
+
   status = mu_stream_copy (mailbox->stream, tempstr, size);
   if (status)
     {
-      mu_error (_("%s:%d: error writing to temporary stream: %s"),
+      mu_error (_("%s:%d: copying from the temporary stream: %s"),
 		__FILE__, __LINE__,
 		mu_strerror (status));
       return status;
@@ -1395,30 +1408,35 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted)
   status = mu_temp_file_stream_create (&tempstr, NULL);
   if (status == 0)
     {
-      sigset_t signalset;
+      status = mu_stream_open (tempstr);
+      if (status == 0)
+	{
+	  sigset_t signalset;
 #ifdef WITH_PTHREAD
-      int state;
-      pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
+	  int state;
+	  pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
 #endif
-      sigemptyset (&signalset);
-      sigaddset (&signalset, SIGTERM);
-      sigaddset (&signalset, SIGHUP);
-      sigaddset (&signalset, SIGTSTP);
-      sigaddset (&signalset, SIGINT);
-      sigaddset (&signalset, SIGWINCH);
-      sigprocmask (SIG_BLOCK, &signalset, 0);
-
-      status = mbox_expunge_unlocked (mailbox, dirty, remove_deleted, tempstr);
+	  sigemptyset (&signalset);
+	  sigaddset (&signalset, SIGTERM);
+	  sigaddset (&signalset, SIGHUP);
+	  sigaddset (&signalset, SIGTSTP);
+	  sigaddset (&signalset, SIGINT);
+	  sigaddset (&signalset, SIGWINCH);
+	  sigprocmask (SIG_BLOCK, &signalset, 0);
+	  
+	  status = mbox_expunge_unlocked (mailbox, dirty, remove_deleted,
+					  tempstr);
 
 #ifdef WITH_PTHREAD
-      pthread_setcancelstate (state, &state);
+	  pthread_setcancelstate (state, &state);
 #endif
-      sigprocmask (SIG_UNBLOCK, &signalset, 0);
+	  sigprocmask (SIG_UNBLOCK, &signalset, 0);
       
-      mu_stream_destroy (&tempstr);
+	  mu_stream_destroy (&tempstr);
 
-      if (status == 0)
-	mbox_reset (mailbox, dirty, remove_deleted);
+	  if (status == 0)
+	    mbox_reset (mailbox, dirty, remove_deleted);
+	}
     }
   mu_locker_unlock (mailbox->locker);
   return status;
diff --git a/libproto/mbox/mbox0.h b/libproto/mbox/mbox0.h
index 4e1f201..b53aa65 100644
--- a/libproto/mbox/mbox0.h
+++ b/libproto/mbox/mbox0.h
@@ -71,8 +71,8 @@ typedef struct _mbox_message *mbox_message_t;
 struct _mbox_message
 {
   /* Offset of the messages in the mailbox.  */
-  mu_off_t header_from;        /* Start of envelope (^From ) */
-  mu_off_t header_from_end;    /* End of envelope (terminating \n) */
+  mu_off_t envel_from;         /* Start of envelope (^From ) */
+  mu_off_t envel_from_end;     /* End of envelope (terminating \n) */
   mu_off_t body;               /* Start of body */
   mu_off_t body_end;           /* End of body */
 
diff --git a/libproto/mbox/mboxscan.c b/libproto/mbox/mboxscan.c
index 127a360..db8a099 100644
--- a/libproto/mbox/mboxscan.c
+++ b/libproto/mbox/mboxscan.c
@@ -359,11 +359,10 @@ mbox_scan_internal (mu_mailbox_t mailbox, mbox_message_t mum,
 		}
 	      /* Allocate_msgs will initialize mum.  */
 	      ALLOCATE_MSGS (mailbox, mud);
-	      mud->messages_count++;
-	      mum = mud->umessages[mud->messages_count - 1];
+	      mum = mud->umessages[mud->messages_count++];
 	      mum->mud = mud;
-              mum->header_from = total - n;
-              mum->header_from_end = total;
+              mum->envel_from = total - n;
+              mum->envel_from_end = total;
 	      mum->body_end = mum->body = 0;
 	      mum->attr_flags = 0;
 	      lines = 0;
@@ -467,7 +466,7 @@ mbox_scan0 (mu_mailbox_t mailbox, size_t msgno, size_t *pcount, int do_notif)
     {
       mum = mud->umessages[msgno - 1];
       if (mum)
-	total = mum->header_from;
+	total = mum->envel_from;
       mud->messages_count = msgno - 1;
     }
   else
diff --git a/mail/decode.c b/mail/decode.c
index 3c4fe46..f0212cd 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -116,8 +116,11 @@ display_headers (FILE *out, mu_message_t mesg,
     {
       mu_stream_t stream = NULL;
       if (mu_message_get_header (mesg, &hdr) == 0
-	  && mu_header_get_stream (hdr, &stream) == 0)
-	print_stream (stream, out);
+	  && mu_header_get_streamref (hdr, &stream) == 0)
+	{
+	  print_stream (stream, out);
+	  mu_stream_destroy (&stream);
+	}
     }
 }
 
@@ -254,12 +257,12 @@ display_submessage (struct mime_descend_closure *closure, void *data)
       
       mu_message_get_body (closure->message, &body);
       mu_message_get_header (closure->message, &hdr);
-      mu_body_get_stream (body, &b_stream);
+      mu_body_get_streamref (body, &b_stream);
 
       /* Can we decode.  */
-      if (mu_filter_create(&d_stream, b_stream, closure->encoding,
-			   MU_FILTER_DECODE, 
-			   MU_STREAM_READ|MU_STREAM_NO_CLOSE) == 0)
+      if (mu_filter_create (&d_stream, b_stream, closure->encoding,
+			    MU_FILTER_DECODE, 
+			    MU_STREAM_READ|MU_STREAM_NO_CLOSE) == 0)
 	stream = d_stream;
       else
 	stream = b_stream;
@@ -303,13 +306,13 @@ display_submessage (struct mime_descend_closure *closure, void *data)
 	  if (out != ofile)
 	    pclose (out);
 	}
-      if (d_stream)
-	mu_stream_destroy (&d_stream);
+      mu_stream_destroy (&stream);
     }
   
   return 0;
 }
 
+/* FIXME: Try to use mu_stream_copy instead */
 static int
 print_stream (mu_stream_t stream, FILE *out)
 {
@@ -317,12 +320,6 @@ print_stream (mu_stream_t stream, FILE *out)
   size_t n = 0;
   int rc;
   
-  rc = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
-  if (rc)
-    {
-      util_error (_("seek error: %s"), mu_stream_strerror (stream, rc));
-      return rc;
-    }
   while (mu_stream_read (stream, buffer, sizeof (buffer) - 1, &n) == 0
 	 && n != 0)
     {
@@ -397,20 +394,18 @@ run_metamail (const char *mailcap_cmd, mu_message_t mesg)
     {
       /* Child process */
       int status;
-      mu_stream_t stream;
+      mu_stream_t stream = NULL;
 
       do /* Fake loop to avoid gotos */
 	{
 	  mu_stream_t pstr;
-	  char buffer[512];
-	  size_t n;
 	  char *no_ask;
 	  
 	  setenv ("METAMAIL_PAGER", getenv ("PAGER"), 0);
 	  if (mailvar_get (&no_ask, "mimenoask", mailvar_type_string, 0))
 	    setenv ("MM_NOASK", no_ask, 1);
 	  
-	  status = mu_message_get_stream (mesg, &stream);
+	  status = mu_message_get_streamref (mesg, &stream);
 	  if (status)
 	    {
 	      mu_error ("mu_message_get_stream: %s", mu_strerror (status));
@@ -430,12 +425,7 @@ run_metamail (const char *mailcap_cmd, mu_message_t mesg)
 	      mu_error ("mu_stream_open: %s", mu_strerror (status));
 	      break;
 	    }
-	  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
-	  while (mu_stream_read (stream, buffer, sizeof buffer - 1,
-				 &n) == 0
-		 && n > 0)
-	    mu_stream_write (pstr, buffer, n, NULL);
-
+	  mu_stream_copy (pstr, stream, 0);
 	  mu_stream_close (pstr);
 	  mu_stream_destroy (&pstr);
 	  exit (0);
diff --git a/mail/escape.c b/mail/escape.c
index c874514..0f3f57e 100644
--- a/mail/escape.c
+++ b/mail/escape.c
@@ -30,19 +30,21 @@ dump_headers (FILE *fp, compose_env_t *env)
   size_t n;
   int rc;
   
-  mu_header_get_stream (env->header, &stream);
-  rc = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+  rc = mu_header_get_streamref (env->header, &stream);
   if (rc)
     {
-      util_error (_("seek error: %s"), mu_stream_strerror (stream, rc));
+      util_error ("mu_header_get_streamref: %s",
+		  mu_stream_strerror (stream, rc));
       return;
     }
+  /* FIXME: Use mu_stream_copy */
   while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
 	 && n != 0)
     {
       buffer[n] = 0;
       fprintf (fp, "%s", buffer);
     }
+  mu_stream_destroy (&stream);
 }
 
 #define STATE_INIT 0
@@ -478,24 +480,25 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data)
 	}
       fprintf (ofile, "%s\n", prefix);
       mu_message_get_body (mesg, &body);
-      mu_body_get_stream (body, &stream);
+      rc = mu_body_get_streamref (body, &stream);
     }
   else
-    mu_message_get_stream (mesg, &stream);
+    rc = mu_message_get_streamref (mesg, &stream);
 
-  rc = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   if (rc)
     {
-      util_error (_("seek error: %s"), mu_stream_strerror (stream, rc));
+      util_error (_("get_streamref error: %s"), mu_strerror (rc));
       return rc;
     }
-  
+
+  /* FIXME: Use mu_stream_copy? */
   while (mu_stream_readline (stream, buffer, sizeof buffer - 1, &n) == 0
 	 && n != 0)
     {
       buffer[n] = '\0';
       fprintf (ofile, "%s%s", prefix, buffer);
     }
+  mu_stream_destroy (&stream);
   return 0;
 }
 
diff --git a/mail/msgset.y b/mail/msgset.y
index a076473..f2c2a52 100644
--- a/mail/msgset.y
+++ b/mail/msgset.y
@@ -629,8 +629,7 @@ select_body (mu_message_t msg, void *closure)
   mu_message_get_body (msg, &body);
   mu_body_size (body, &size);
   mu_body_lines (body, &lines);
-  mu_body_get_stream (body, &stream);
-  status = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+  status = mu_body_get_streamref (body, &stream);
   while (status == 0
 	 && mu_stream_readline (stream, buffer, sizeof(buffer)-1, &n) == 0
 	 && n > 0)
@@ -643,7 +642,7 @@ select_body (mu_message_t msg, void *closure)
       else
 	status = regexec (&re, buffer, 0, NULL, 0);
     }
-
+  mu_stream_destroy (&stream);
   if (!noregex)
     regfree (&re);
 
diff --git a/mail/pipe.c b/mail/pipe.c
index 681e405..bb7ab0a 100644
--- a/mail/pipe.c
+++ b/mail/pipe.c
@@ -49,14 +49,15 @@ mail_pipe (int argc, char **argv)
     {
       if (util_get_message (mbox, mp->msg_part[0], &msg) == 0)
 	{
-	  mu_message_get_stream (msg, &stream);
-	  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+	  mu_message_get_streamref (msg, &stream);
+	  /* FIXME: Use mu_stream_copy */
 	  while (mu_stream_read (stream, buffer, sizeof (buffer) - 1, &n) == 0
 		 && n != 0)
 	    {
 	      buffer[n] = '\0';
 	      fprintf (tube, "%s", buffer);
 	    }
+	  mu_stream_destroy (&stream);
 	  if (mailvar_get (NULL, "page", mailvar_type_boolean, 0) == 0)
 	    fprintf (tube, "\f\n");
 	}
diff --git a/mail/print.c b/mail/print.c
index c804e26..9f0e409 100644
--- a/mail/print.c
+++ b/mail/print.c
@@ -36,6 +36,7 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data)
   size_t n = 0, lines = 0;
   FILE *out = ofile;
   int pagelines = util_get_crt ();
+  int status;
   
   mu_message_lines (mesg, &lines);
   if (mailvar_get (NULL, "showenvelope", mailvar_type_boolean, 0) == 0)
@@ -89,12 +90,18 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data)
 	}
       fprintf (out, "\n");
       mu_message_get_body (mesg, &body);
-      mu_body_get_stream (body, &stream);
+      status = mu_body_get_streamref (body, &stream);
     }
   else
-    mu_message_get_stream (mesg, &stream);
+    status = mu_message_get_streamref (mesg, &stream);
 
-  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+  if (status)
+    {
+      mu_error (_("get_stream error: %s"), mu_strerror (status));
+      return 0;
+    }
+
+  /* FIXME: Use mu_stream_copy instead? */
   while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
 	 && n != 0)
     {
@@ -106,6 +113,7 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data)
       buffer[n] = '\0';
       fprintf (out, "%s", buffer);
     }
+  mu_stream_destroy (&stream);
   if (out != ofile)
     pclose (out);
   
diff --git a/mail/send.c b/mail/send.c
index 07a7b1a..88c358e 100644
--- a/mail/send.c
+++ b/mail/send.c
@@ -293,36 +293,37 @@ compose_header_get (compose_env_t * env, char *name, char *defval)
 }
 
 void
-compose_destroy (compose_env_t * env)
+compose_destroy (compose_env_t *env)
 {
   mu_header_destroy (&env->header);
   free (env->outfiles);
 }
 
+/* FIXME: Can we use mu_stream_t instead of FILE? If so,
+   replace the loop with a call to mu_stream_copy. */
 static int
 fill_body (mu_message_t msg, FILE *file)
 {
   mu_body_t body = NULL;
   mu_stream_t stream = NULL;
-  off_t offset = 0;
   char *buf = NULL;
   size_t n = 0;
   mu_message_get_body (msg, &body);
-  mu_body_get_stream (body, &stream);
-
-  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
-  offset = 0;
+  mu_body_get_streamref (body, &stream);
+  int nullbody = 1;
+  
   while (getline (&buf, &n, file) >= 0)
     {
       size_t len = strlen (buf);
+      if (len)
+	nullbody = 0;
       mu_stream_write (stream, buf, len, NULL);
-      offset += len;
     }
-	    
+  mu_stream_destroy (&stream);
   if (buf)
     free (buf);
 
-  if (offset == 0)
+  if (nullbody)
     {
       if (mailvar_get (NULL, "nullbody", mailvar_type_boolean, 0) == 0)
 	{
@@ -525,7 +526,6 @@ mail_send0 (compose_env_t * env, int save_to)
 	  int rc;
 	  
 	  mu_message_create (&msg, NULL);
-	  mu_message_set_header (msg, env->header, NULL);
 
 	  /* Fill the body.  */
 	  rc = fill_body (msg, file);
@@ -599,6 +599,8 @@ mail_send0 (compose_env_t * env, int save_to)
 		  if (mailvar_get (&sendmail, "sendmail",
 				   mailvar_type_string, 0) == 0)
 		    {
+		      mu_message_set_header (msg, env->header, NULL);
+		      env->header = NULL;
 		      if (sendmail[0] == '/')
 			msg_to_pipe (sendmail, msg);
 		      else
@@ -669,14 +671,15 @@ msg_to_pipe (const char *cmd, mu_message_t msg)
       mu_stream_t stream = NULL;
       char buffer[512];
       size_t n = 0;
-      mu_message_get_stream (msg, &stream);
-      mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+      /* FIXME: Use mu_stream_copy */
+      mu_message_get_streamref (msg, &stream);
       while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
 	     && n != 0)
 	{
 	  buffer[n] = '\0';
 	  fprintf (fp, "%s", buffer);
 	}
+      mu_stream_destroy (&stream);
       pclose (fp);
     }
   else
diff --git a/mail/top.c b/mail/top.c
index d287156..de030af 100644
--- a/mail/top.c
+++ b/mail/top.c
@@ -35,8 +35,8 @@ top0 (msgset_t *mspec, mu_message_t msg, void *data)
       || lines < 0)
     return 1;
 
-  mu_message_get_stream (msg, &stream);
-  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+  /* FIXME: Use mu_stream_copy */
+  mu_message_get_streamref (msg, &stream);
   for (; lines > 0; lines--)
     {
       int status = mu_stream_readline (stream, buf, sizeof (buf), &n);
@@ -44,6 +44,7 @@ top0 (msgset_t *mspec, mu_message_t msg, void *data)
 	break;
       fprintf (ofile, "%s", buf);
     }
+  mu_stream_destroy (&stream);
   set_cursor (mspec->msg_part[0]);
 
   util_mark_read (msg);
diff --git a/mail/write.c b/mail/write.c
index eb7c1ff..ffaa44f 100644
--- a/mail/write.c
+++ b/mail/write.c
@@ -98,8 +98,8 @@ mail_write (int argc, char **argv)
       mu_body_lines (bod, &size);
       total_lines += size;
 
-      mu_body_get_stream (bod, &stream);
-      mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+      /* FIXME: Use mu_stream_copy */
+      mu_body_get_streamref (bod, &stream);
       /* should there be a separator? */
       while (mu_stream_read (stream, buffer, sizeof (buffer) - 1, &n) == 0
 	     && n != 0)
@@ -107,7 +107,8 @@ mail_write (int argc, char **argv)
 	  buffer[n] = '\0';
 	  fprintf (output, "%s", buffer);
 	}
-
+      mu_stream_destroy (&stream);
+      
       /* mark as saved. */
 
       mu_message_get_attribute (msg, &attr);
diff --git a/mailbox/body.c b/mailbox/body.c
index 17e616a..01f14f0 100644
--- a/mailbox/body.c
+++ b/mailbox/body.c
@@ -285,7 +285,7 @@ _body_seek (mu_stream_t stream, mu_off_t off, int whence, mu_off_t *presult)
 {
   struct _mu_body_stream *str = (struct _mu_body_stream*) stream;
   mu_body_t body = str->body;
-  return mu_stream_seek (body->stream, off, whence, presult);
+  return mu_stream_seek (body->fstream, off, whence, presult);
 }
 
 static const char *
diff --git a/mailbox/file_stream.c b/mailbox/file_stream.c
index 977004d..abf63ac 100644
--- a/mailbox/file_stream.c
+++ b/mailbox/file_stream.c
@@ -221,6 +221,15 @@ fd_wait (mu_stream_t stream, int *pflags, struct timeval *tvp)
 }
 
 int
+fd_truncate (mu_stream_t stream, mu_off_t size)
+{
+  struct _mu_file_stream *fstr = (struct _mu_file_stream *) stream;
+  if (ftruncate (fstr->fd, size))
+    return errno;
+  return 0;
+}
+
+int
 _mu_file_stream_create (mu_stream_t *pstream, size_t size,
 			char *filename, int flags)
 {
@@ -239,6 +248,7 @@ _mu_file_stream_create (mu_stream_t *pstream, size_t size,
   str->stream.size = fd_size;
   str->stream.ctl = fd_ioctl;
   str->stream.wait = fd_wait;
+  str->stream.truncate = fd_truncate;
   str->stream.error_string = fd_error_string;
 
   str->filename = filename;
diff --git a/mailbox/header.c b/mailbox/header.c
index 50ff83f..224915f 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -329,7 +329,7 @@ header_parse (mu_header_t header, const char *blurb, int len)
        *[ (' ' | '\t') field-value '\r' '\n' ]
   */
   /* First loop goes through the blurb */
-  for (header_start = blurb;  ; header_start = ++header_end)
+  for (header_start = blurb; len > 0; header_start = ++header_end)
     {
       const char *fn, *fn_end, *fv, *fv_end;
       struct mu_hdrent *ent;
@@ -340,7 +340,7 @@ header_parse (mu_header_t header, const char *blurb, int len)
 	break;
 
       /* Second loop extract one header field. */
-      for (header_start2 = header_start;  ;header_start2 = ++header_end)
+      for (header_start2 = header_start; len; header_start2 = ++header_end)
 	{
 	  header_end = memchr (header_start2, '\n', len);
 	  if (header_end == NULL)
@@ -348,21 +348,14 @@ header_parse (mu_header_t header, const char *blurb, int len)
 	  else
 	    {
 	      len -= (header_end - header_start2 + 1);
-	      if (len < 0)
-		{
-		  header_end = NULL;
-		  break;
-		}
-	      if (header_end[1] != ' '
-		  && header_end[1] != '\t')
+	      if (!len
+		  || (header_end[1] != ' '
+		      && header_end[1] != '\t'))
 		break; /* New header break the inner for. */
 	    }
 	  /* *header_end = ' ';  smash LF ? NO */
 	}
 
-      if (header_end == NULL)
-	break; /* FIXME: Bail out.  */
-      
       /* Now save the header in the data structure.  */
 
       /* Treats unix "From " specially.  FIXME: Should we? */
@@ -956,9 +949,10 @@ header_seek (mu_stream_t str, mu_off_t off, int whence, mu_off_t *presult)
       break;
     }
 
-  if (off < 0 || off >= hstr->hdr->size)
+  if (off < 0 || off > hstr->hdr->size)
     return ESPIPE;
   hstr->off = off;
+  *presult = off;
   return 0;
 }
 
diff --git a/mailbox/message.c b/mailbox/message.c
index 5d9a505..d23677c 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -270,21 +270,35 @@ _message_stream_create (mu_stream_t *pmsg, mu_message_t msg, int flags)
 }
 
 
+enum eoh_state
+  {
+    eoh_no,
+    eoh_maybe,
+    eoh_yes
+  };
+
 /* Message header stuff */
-static int
-string_find_eoh (const char *str, size_t len, size_t *ppos)
+static enum eoh_state
+string_find_eoh (enum eoh_state eoh, const char *str, size_t len,
+		 size_t *ppos)
 {
   size_t pos;
-  int eoh = 0;
+
+  if (eoh == eoh_maybe && *str == '\n')
+    {
+      *ppos = 0;
+      return eoh_yes;
+    }
   
-  for (pos = 0; pos < len-1; pos++)
-    if (str[pos] == '\n' && str[pos+1] == '\n')
+  for (pos = 0; pos < len - 1; pos++)
+    if (str[pos] == '\n' && str[pos + 1] == '\n')
       {
-	eoh = 1;
-	break;
+	*ppos = pos + 1;
+	return eoh_yes;
       }
+  
   *ppos = pos + 1;
-  return eoh;
+  return str[pos] == '\n' ? eoh_maybe : eoh_no;
 }
 
 #define MIN_HEADER_BUF_SIZE 2048
@@ -297,17 +311,21 @@ _header_fill (mu_stream_t stream, char **pbuf, size_t *plen)
   size_t bufsize = 0;
   char inbuf[MIN_HEADER_BUF_SIZE];
   size_t nread;
+  enum eoh_state eoh = eoh_no;
   
   status = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   if (status)
     return status;
       
-  while ((status = mu_stream_read (stream, inbuf, sizeof (inbuf), &nread))
-	 == 0 && nread)
+  while (eoh != eoh_yes
+	 && (status = mu_stream_read (stream, inbuf, sizeof (inbuf), &nread))
+	    == 0
+	 && nread)
     {
       char *nbuf;
       size_t len;
-      int eoh = string_find_eoh (inbuf, nread, &len);
+
+      eoh = string_find_eoh (eoh, inbuf, nread, &len);
       
       nbuf = realloc (buffer, bufsize + len);
       if (!nbuf)
@@ -318,8 +336,6 @@ _header_fill (mu_stream_t stream, char **pbuf, size_t *plen)
       memcpy (nbuf + bufsize, inbuf, len);
       buffer = nbuf;
       bufsize += len;
-      if (eoh)
-	break;
     }
 
   if (status)
diff --git a/mailbox/stream.c b/mailbox/stream.c
index 8d9e1f9..0ea5c01 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -53,7 +53,7 @@ _stream_seterror (struct _mu_stream *stream, int code, int perm)
 #define _stream_cleareof(s) ((s)->flags &= ~_MU_STR_EOF)
 #define _stream_advance_buffer(s,n) ((s)->cur += n, (s)->level -= n)
 #define _stream_buffer_offset(s) ((s)->cur - (s)->buffer)
-#define _stream_orig_level(s) ((s)->level + _stream_buffer_offset(s))
+#define _stream_orig_level(s) ((s)->level + _stream_buffer_offset (s))
 
 static int
 _stream_fill_buffer (struct _mu_stream *stream)
@@ -202,6 +202,7 @@ mu_stream_destroy (mu_stream_t *pstream)
       mu_stream_t str = *pstream;
       if (str && (str->ref_count == 0 || --str->ref_count == 0))
 	{
+	  mu_stream_close (str);
 	  if (str->done)
 	    str->done (str);
 	  free (str);
@@ -213,7 +214,7 @@ mu_stream_destroy (mu_stream_t *pstream)
 void
 mu_stream_get_flags (mu_stream_t str, int *pflags)
 {
-  *pflags = str->flags;
+  *pflags = str->flags & ~_MU_STR_INTERN_MASK;
 }
   
 void
@@ -252,6 +253,12 @@ mu_stream_strerror (mu_stream_t stream, int rc)
 }
 
 int
+mu_stream_err (mu_stream_t stream)
+{
+  return stream->flags & _MU_STR_ERR;
+}
+
+int
 mu_stream_last_error (mu_stream_t stream)
 {
   return stream->last_err;
@@ -700,6 +707,9 @@ mu_stream_close (mu_stream_t stream)
   if (!stream)
     return EINVAL;
   mu_stream_flush (stream);
+  /* Do close the stream only if it is not used by anyone else */
+  if (stream->ref_count > 1)
+    return 0;
   if (stream->close)
     rc = stream->close (stream);
   return rc;
@@ -785,7 +795,7 @@ mu_stream_set_flags (mu_stream_t stream, int fl)
 {
   if (stream == NULL)
     return EINVAL;
-  stream->flags |= fl;
+  stream->flags |= (fl & ~_MU_STR_INTERN_MASK);
   return 0;
 }
 
@@ -794,7 +804,7 @@ mu_stream_clr_flags (mu_stream_t stream, int fl)
 {
   if (stream == NULL)
     return EINVAL;
-  stream->flags &= ~fl;
+  stream->flags &= ~(fl & ~_MU_STR_INTERN_MASK);
   return 0;
 }
 
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index 04c8450..7e9ff4f 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -62,7 +62,7 @@ _streamref_read (struct _mu_stream *str, char *buf, size_t bufsize,
   else if (rc == ESPIPE)
     {
       *pnread = 0;
-      str->flags |= _MU_STR_EOF;
+      mu_stream_clearerr (sp->transport);
       return 0;
     }
   return streamref_return (sp, rc);
@@ -170,7 +170,21 @@ static int
 _streamref_size (struct _mu_stream *str, mu_off_t *psize)
 {
   struct _mu_streamref *sp = (struct _mu_streamref *)str;
-  return streamref_return (sp, mu_stream_size (sp->transport, psize));
+  mu_off_t size;
+  int rc = 0;
+  
+  if (sp->end)
+    size = sp->end - sp->start + 1;
+  else
+    {
+      rc = mu_stream_size (sp->transport, &size);
+      if (rc)
+	return streamref_return (sp, rc);
+      size -= sp->start;
+    }
+  if (rc == 0)
+    *psize = size;
+  return rc;
 }
 
 static int
@@ -240,12 +254,11 @@ mu_streamref_create_abridged (mu_stream_t *pref, mu_stream_t str,
   int flags;
   struct _mu_streamref *sp;
 
-  rc = mu_stream_seek (str, 0, MU_SEEK_CUR, &off);
+  rc = mu_stream_seek (str, 0, MU_SEEK_SET, &off);
   if (rc)
     return rc;
   mu_stream_get_flags (str, &flags);
-  sp = (struct _mu_streamref *) _mu_stream_create (sizeof (*sp),
-						   flags | MU_STREAM_NO_CLOSE);
+  sp = (struct _mu_streamref *) _mu_stream_create (sizeof (*sp), flags);
   if (!sp)
     return ENOMEM;
   mu_stream_ref (str);
diff --git a/mimeview/mimeview.c b/mimeview/mimeview.c
index 40840d9..6192ede 100644
--- a/mimeview/mimeview.c
+++ b/mimeview/mimeview.c
@@ -69,7 +69,7 @@ static char *no_ask_types;  /* List of MIME types for which no questions
 			       should be asked */
 static int interactive = -1; 
 char *mimeview_file;       /* Name of the file to view */
-int mimeview_fd;     /* Its descriptor */
+FILE *mimeview_fp;     /* Its descriptor */
 
 static void
 set_debug_flags (mu_debug_t debug, const char *arg)
@@ -201,8 +201,8 @@ open_file (char *name)
     }
 
   mimeview_file = name;
-  mimeview_fd = open (name, O_RDONLY);
-  if (mimeview_fd == -1)
+  mimeview_fp = fopen (name, "r");
+  if (mimeview_fp == NULL)
     {
       mu_error (_("Cannot open `%s': %s"), name, mu_strerror (errno));
       return -1;
@@ -213,7 +213,7 @@ open_file (char *name)
 void
 close_file ()
 {
-  close (mimeview_fd);
+  fclose (mimeview_fp);
 }
 
 void
@@ -258,7 +258,7 @@ display_file (const char *type)
 	mu_error (_("cannot create header: %s"), mu_strerror (status));
       else
 	{
-	  mu_stdio_stream_create (&stream, mimeview_fd,
+	  mu_stdio_stream_create (&stream, fileno (mimeview_fp),
 				  MU_STREAM_READ|
 				  MU_STREAM_SEEK|MU_STREAM_NO_CLOSE);
 	  mu_stream_open (stream);


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Fri Apr 30 18:41:53 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O7yu9-0004P3-Bo
	for mharc-commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:41:53 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O7yu7-0004O7-6m
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:41:51 -0400
Received: from [140.186.70.92] (port=34934 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O7yu4-0004MZ-4r
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:41:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7yu2-0008Lp-8R
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:41:48 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:56279
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7yu2-0008Lj-1W
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 18:41:46 -0400
Received: from [10.1.0.108] (helo=vcs-noshell.in.savannah.gnu.org)
	by internal.in.savannah.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7yu1-0005Kk-SL
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 22:41:45 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O7yu1-00035b-PV
	for commit-mailutils@gnu.org; Fri, 30 Apr 2010 22:41:45 +0000
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
X-Git-Refname: refs/heads/stream-cleanup
X-Git-Reftype: branch
X-Git-Oldrev: 987ec1d4f1fda22924fc84531e76f02fe6a288b9
X-Git-Newrev: fd5cc1028e705b1c5fc350361e3a10a0b23f6b23
Message-Id: <E1O7yu1-00035b-PV@vcs-noshell.in.savannah.gnu.org>
Date: Fri, 30 Apr 2010 22:41:45 +0000
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
Subject: [SCM] GNU Mailutils branch, stream-cleanup,
	updated. rel-2_1-80-gfd5cc10
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: Fri, 30 Apr 2010 22:41:51 -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=fd5cc1028e705b1c5fc350361e3a10a0b23f6b23

The branch, stream-cleanup has been updated
       via  fd5cc1028e705b1c5fc350361e3a10a0b23f6b23 (commit)
      from  987ec1d4f1fda22924fc84531e76f02fe6a288b9 (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 fd5cc1028e705b1c5fc350361e3a10a0b23f6b23
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 01:39:49 2010 +0300

    Use stringrefs, add some guidelines for further editing.
    
    * comsat/action.c
    * imap4d/fetch.c
    * imap4d/search.c
    * mh/burst.c
    * mh/comp.c
    * mh/forw.c
    * mh/mh_ctx.c
    * mh/mh_format.c
    * mh/mh_list.c
    * mh/mhn.c
    * mh/pick.y
    * pop3d/retr.c
    * pop3d/top.c
    * readmsg/msglist.c
    * readmsg/readmsg.c

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

Summary of changes:
 comsat/action.c   |    3 +-
 imap4d/fetch.c    |   25 ++++++++++-----
 imap4d/search.c   |    3 +-
 mh/burst.c        |   31 ++++++++++--------
 mh/comp.c         |   41 +++++++------------------
 mh/forw.c         |    4 +-
 mh/mh_ctx.c       |    7 ++--
 mh/mh_format.c    |    8 +++--
 mh/mh_list.c      |    6 +--
 mh/mhn.c          |   87 +++++++++++++++++++++++++----------------------------
 mh/pick.y         |    4 +-
 pop3d/retr.c      |    1 +
 pop3d/top.c       |    2 +
 readmsg/msglist.c |    3 +-
 readmsg/readmsg.c |   10 ++++--
 15 files changed, 115 insertions(+), 120 deletions(-)

diff --git a/comsat/action.c b/comsat/action.c
index 638d03f..738521c 100644
--- a/comsat/action.c
+++ b/comsat/action.c
@@ -155,7 +155,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk)
       if (lncount == 0)
 	lncount = maxlines;
       if (mu_message_get_body (msg, &body) == 0
-	  && mu_body_get_stream (body, &stream) == 0)
+	  && mu_body_get_streamref (body, &stream) == 0)
 	{
 	  size_t nread;
 	  char *buf = malloc (size+1);
@@ -179,6 +179,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk)
 		}
 	      obstack_grow (stk, buf, size);
 	    }
+	  mu_stream_destroy (&stream);
 	  free (buf);
 	}
       *pp = p;
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 18452a2..a36a097 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -885,7 +885,8 @@ _frt_body (struct fetch_function_closure *ffc,
   mu_message_t msg;
   mu_stream_t stream = NULL;
   size_t size = 0, lines = 0;
-
+  int rc;
+  
   set_seen (ffc, frt);
   if (ffc->name)
     util_send ("%s", ffc->name);
@@ -897,10 +898,12 @@ _frt_body (struct fetch_function_closure *ffc,
       util_send (" \"\"");
       return RESP_OK;
     }
-  mu_message_get_stream (msg, &stream);
+  mu_message_get_streamref (msg, &stream);
   mu_message_size (msg, &size);
   mu_message_lines (msg, &lines);
-  return fetch_io (stream, ffc->start, ffc->size, size + lines);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  return rc;
 }
 
 static int
@@ -911,7 +914,8 @@ _frt_body_text (struct fetch_function_closure *ffc,
   mu_body_t body = NULL;
   mu_stream_t stream = NULL;
   size_t size = 0, lines = 0;
-
+  int rc;
+  
   set_seen (ffc, frt);
   if (ffc->name)
     util_send ("%s",  ffc->name);
@@ -927,8 +931,10 @@ _frt_body_text (struct fetch_function_closure *ffc,
   mu_message_get_body (msg, &body);
   mu_body_size (body, &size);
   mu_body_lines (body, &lines);
-  mu_body_get_stream (body, &stream);
-  return fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_body_get_streamref (body, &stream);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  return rc;
 }
 
 static int
@@ -953,6 +959,7 @@ _frt_header0 (struct fetch_function_closure *ffc,
   mu_header_t header = NULL;
   mu_stream_t stream = NULL;
   size_t size = 0, lines = 0;
+  int rc;
   
   set_seen (ffc, frt);
   if (ffc->name)
@@ -969,8 +976,10 @@ _frt_header0 (struct fetch_function_closure *ffc,
   mu_message_get_header (msg, &header);
   mu_header_size (header, &size);
   mu_header_lines (header, &lines);
-  mu_header_get_stream (header, &stream);
-  return fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_header_get_streamref (header, &stream);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  return rc;
 }
 
 static int
diff --git a/imap4d/search.c b/imap4d/search.c
index bdfca9e..33d2aa2 100644
--- a/imap4d/search.c
+++ b/imap4d/search.c
@@ -842,7 +842,7 @@ _scan_body (struct parsebuf *pb, char *text)
   mu_message_get_body (pb->msg, &body);
   mu_body_size (body, &size);
   mu_body_lines (body, &lines);
-  mu_body_get_stream (body, &stream);
+  mu_body_get_streamref (body, &stream);
   rc = 0;
   while (rc == 0
 	 && mu_stream_read (stream, buffer, sizeof(buffer)-1, &n) == 0
@@ -851,6 +851,7 @@ _scan_body (struct parsebuf *pb, char *text)
       buffer[n] = 0;
       rc = util_strcasestr (buffer, text) != NULL;
     }
+  mu_stream_destroy (&stream);
   return rc;
 }
 
diff --git a/mh/burst.c b/mh/burst.c
index 0dcb080..0647baa 100644
--- a/mh/burst.c
+++ b/mh/burst.c
@@ -286,8 +286,7 @@ burst_digest (mu_message_t msg)
       exit (1);
     }
 
-  mu_message_get_stream (msg, &is);
-  mu_stream_seek (is, 0, MU_SEEK_SET, NULL);
+  mu_message_get_streamref (msg, &is);
   while (mu_stream_read (is, buf, bufsize, &n) == 0
 	 && n > 0)
     {
@@ -339,7 +338,8 @@ burst_digest (mu_message_t msg)
 
       flush_stream (&os, buf + start, i - start);
     }
-
+  mu_stream_destroy (&is);
+  
   free (buf);
   if (os)
     {
@@ -390,8 +390,10 @@ burst_or_copy (mu_message_t msg, int recursive, int copy)
 	      mu_body_t body;
 	      
 	      mu_message_get_body (msg, &body);
-	      mu_body_get_stream (body, &str);
-
+	      mu_body_get_streamref (body, &str);
+	      /* FIXME: Check if str is actually destroyed.
+		 See mailbox/message_stream.c
+	      */
 	      msg = mh_stream_to_message (str);
 	    }
 	  free (value);
@@ -487,8 +489,6 @@ msg_copy (size_t num, const char *file)
   mu_attribute_t attr = NULL;
   mu_stream_t istream, ostream;
   int rc;
-  size_t n;
-  char buf[512];
   
   if ((rc = mu_file_stream_create (&ostream,
 				   file,
@@ -501,13 +501,16 @@ msg_copy (size_t num, const char *file)
     }
 
   mu_mailbox_get_message (tmpbox, num, &msg);
-  mu_message_get_stream (msg, &istream);
-  mu_stream_seek (istream, 0, MU_SEEK_SET, NULL);
-  while (rc == 0
-	 && mu_stream_read (istream, buf, sizeof buf, &n) == 0
-	 && n > 0)
-    /* FIXME: Implement RFC 934 FSA? */
-    rc = mu_stream_write (ostream, buf, n, NULL);
+  mu_message_get_streamref (msg, &istream);
+  /* FIXME: Implement RFC 934 FSA? */
+  rc = mu_stream_copy (ostream, istream, 0);
+  if (rc)
+    {
+      mu_error (_("copy stream error: %s"), mu_strerror (rc));
+      exit (1);
+    }
+  
+  mu_stream_destroy (&istream);
   
   mu_stream_close (ostream);
   mu_stream_destroy (&ostream);
diff --git a/mh/comp.c b/mh/comp.c
index c01dfd6..3ac0a41 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -160,49 +160,30 @@ copy_message (mu_mailbox_t mbox, size_t n, const char *file)
   mu_stream_t in;
   mu_stream_t out;
   int rc;
-  size_t size;
-  char *buffer;
-  size_t bufsize, rdsize;
   
   mu_mailbox_get_message (mbox, n, &msg);
-  mu_message_size (msg, &size);
-
-  for (bufsize = size; bufsize > 0 && (buffer = malloc (bufsize)) == 0;
-       bufsize /= 2)
-    ;
-
-  if (!bufsize)
-    mh_err_memory (1);
-
-  mu_message_get_stream (msg, &in);
+  mu_message_get_streamref (msg, &in);
   
   if ((rc = mu_file_stream_create (&out,
-				file, MU_STREAM_RDWR|MU_STREAM_CREAT)) != 0
+				   file, MU_STREAM_RDWR|MU_STREAM_CREAT)) != 0
       || (rc = mu_stream_open (out)))
     {
       mu_error (_("cannot open output file \"%s\": %s"),
 		file, mu_strerror (rc));
-      free (buffer);
-      return 1;
-    }
-
-  mu_stream_seek (in, 0, MU_SEEK_SET, NULL);
-  while (size > 0
-	 && (rc = mu_stream_read (in, buffer, bufsize, &rdsize)) == 0
-	 && rdsize > 0)
-    {
-      if ((rc = mu_stream_write (out, buffer, rdsize, NULL)) != 0)
-	{
-	  mu_error (_("error writing to \"%s\": %s"),
-		    file, mu_strerror (rc));
-	  break;
-	}
-      size -= rdsize;
+      mu_stream_destroy (&in);
+      return rc;
     }
 
+  rc = mu_stream_copy (out, in, 0);
+  mu_stream_destroy (&in);
   mu_stream_close (out);
   mu_stream_destroy (&out);
   
+  if (rc)
+    {
+      mu_error (_("error copying to \"%s\": %s"),
+		file, mu_strerror (rc));
+    }
   return rc;
 }
 
diff --git a/mh/forw.c b/mh/forw.c
index 390af21..8ec9fee 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -246,10 +246,9 @@ msg_copy (mu_message_t msg, mu_stream_t ostream)
   char buf[512];
   enum rfc934_state state = S1;
   
-  rc = mu_message_get_stream (msg, &istream);
+  rc = mu_message_get_streamref (msg, &istream);
   if (rc)
     return rc;
-  mu_stream_seek (istream, 0, SEEK_SET, NULL);
   while (rc == 0
 	 && mu_stream_read (istream, buf, sizeof buf, &n) == 0
 	 && n > 0)
@@ -283,6 +282,7 @@ msg_copy (mu_message_t msg, mu_stream_t ostream)
       if (i > start)
 	rc = mu_stream_write (ostream, buf + start, i  - start, NULL);
     }
+  mu_stream_destroy (&istream);
   return rc;
 }
 
diff --git a/mh/mh_ctx.c b/mh/mh_ctx.c
index 995bfa6..0b4795d 100644
--- a/mh/mh_ctx.c
+++ b/mh/mh_ctx.c
@@ -145,17 +145,16 @@ mh_context_write (mh_context_t *ctx)
 		ctx->name, strerror (errno));
       return MU_ERR_FAILURE;
     }
-  
-  mu_header_get_stream (ctx->header, &stream);
 
-  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+  /* FIXME: Use mu_stream+copy */
+  mu_header_get_streamref (ctx->header, &stream);
   while (mu_stream_read (stream, buffer, sizeof buffer - 1, &n) == 0
 	 && n != 0)
     {
       buffer[n] = '\0';
       fprintf (fp, "%s", buffer);
     }
-
+  mu_stream_destroy (&stream);
   fclose (fp);
   return 0;
 }
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 95d677b..7d548c0 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -609,8 +609,10 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	    strobj_free (&mach.arg_str);
 	    mu_message_get_body (mach.message, &body);
 	    mu_body_size (body, &size);
-	    mu_body_get_stream (body, &stream);
-	    if (size == 0 || !stream)
+	    if (size == 0)
+	      break;
+	    mu_body_get_streamref (body, &stream);
+	    if (!stream)
 	      break;
 	    if (size > rest)
 	      size = rest;
@@ -619,7 +621,6 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 	    mach.arg_str.size = size;
 	    
 	    str_off = 0;
-	    mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
 	    while (!mu_stream_read (stream, mach.arg_str.ptr + str_off,
 				    mach.arg_str.size - str_off, &nread)
 		   && nread != 0
@@ -629,6 +630,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
 		if (nread)
 		  str_off += nread;
 	      }
+	    mu_stream_destroy (&stream);
 	    mach.arg_str.ptr[str_off] = 0;
 	  }
 	  break;
diff --git a/mh/mh_list.c b/mh/mh_list.c
index 94743b9..026308e 100644
--- a/mh/mh_list.c
+++ b/mh/mh_list.c
@@ -687,7 +687,7 @@ eval_body (struct eval_env *env)
   env->prefix = env->svar[S_COMPONENT];
 
   mu_message_get_body (env->msg, &body);
-  mu_body_get_stream (body, &input);
+  mu_body_get_streamref (body, &input);
 
   if (env->bvar[B_DECODE])
     {
@@ -707,15 +707,13 @@ eval_body (struct eval_env *env)
 	}
     }
   
-  mu_stream_seek (input, 0, SEEK_SET, NULL);
   while (mu_stream_readline (input, buf, sizeof buf, &n) == 0
 	 && n > 0)
     {
       buf[n] = 0;
       print (env, buf, 0);
     }
-  if (dstr)
-    mu_stream_destroy (&dstr);
+  mu_stream_destroy (&input);
   return 0;
 }
 
diff --git a/mh/mhn.c b/mh/mhn.c
index 6204050..0824134 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -961,6 +961,7 @@ _free_env (char **env)
   free (env);
 }
 
+/* FIXME: Use mimehdr.c functions instead */
 int
 get_extbody_params (mu_message_t msg, char **content, char **descr)
 {
@@ -971,8 +972,7 @@ get_extbody_params (mu_message_t msg, char **content, char **descr)
   size_t n;
 	
   mu_message_get_body (msg, &body);
-  mu_body_get_stream (body, &stream);
-  mu_stream_seek (stream, 0, SEEK_SET, NULL);
+  mu_body_get_streamref (body, &stream);
 
   while (rc == 0
 	 && mu_stream_readline (stream, buf, sizeof buf, &n) == 0
@@ -1005,6 +1005,7 @@ get_extbody_params (mu_message_t msg, char **content, char **descr)
 	  *content = strdup (p);
 	}
     }
+  mu_stream_destroy (&stream);
   return 0;
 }
 
@@ -1112,7 +1113,7 @@ mhn_message_size (mu_message_t msg, size_t *psize)
     {
       mu_stream_t dstr = NULL, bstr = NULL;
 
-      if (mu_body_get_stream (body, &bstr) == 0)
+      if (mu_body_get_streamref (body, &bstr) == 0)
 	{
 	  mu_header_t hdr;
 	  char *encoding;
@@ -1131,7 +1132,6 @@ mhn_message_size (mu_message_t msg, size_t *psize)
 	      char buf[512];
 	      size_t n;
 
-	      mu_stream_seek (dstr, 0, MU_SEEK_SET, NULL);
 	      while (mu_stream_read (dstr, buf, sizeof buf, &n) == 0
 		     && n > 0)
 		size += n;
@@ -1140,6 +1140,7 @@ mhn_message_size (mu_message_t msg, size_t *psize)
 	      *psize = size;
 	      return 0;
 	    }
+	  mu_stream_destroy (&bstr);
 	}
     }
 
@@ -1245,20 +1246,6 @@ mhn_list ()
 
 static mu_list_t mhl_format;
 
-void
-cat_message (mu_stream_t out, mu_stream_t in)
-{
-  int rc = 0;
-  char buf[512];
-  size_t n;
-
-  mu_stream_seek (in, 0, SEEK_SET, NULL);
-  while (rc == 0
-	 && mu_stream_read (in, buf, sizeof buf, &n) == 0
-	 && n > 0)
-    rc = mu_stream_write (out, buf, n, NULL);
-}
-
 int
 show_internal (mu_message_t msg, msg_part_t part, char *encoding, mu_stream_t out)
 {
@@ -1273,15 +1260,14 @@ show_internal (mu_message_t msg, msg_part_t part, char *encoding, mu_stream_t ou
 		mu_strerror (rc));
       return 0;
     }
-  mu_body_get_stream (body, &bstr);
+  mu_body_get_streamref (body, &bstr);
   rc = mu_filter_create (&dstr, bstr, encoding,
 		         MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_NO_CLOSE);
   if (rc == 0)
     bstr = dstr;
-  cat_message (out, bstr);
-  if (dstr)
-    mu_stream_destroy (&dstr);
-  return 0;
+  rc = mu_stream_copy (out, bstr, 0);
+  mu_stream_destroy (&bstr);
+  return rc;
 }
   
 int
@@ -1964,14 +1950,15 @@ copy_header_to_stream (mu_message_t msg, mu_stream_t stream)
   size_t bufsize = 0, n = 0;
   
   mu_message_get_header (msg, &hdr);
-  mu_header_get_stream (hdr, &in);
-  mu_stream_seek (in, 0, SEEK_SET, NULL);
+  mu_header_get_streamref (hdr, &in);
+  /* FIXME: Use mu_stream_copy */
   while (mu_stream_getline (in, &buf, &bufsize, &n) == 0 && n > 0)
     {
       if (n == 1 && buf[0] == '\n')
 	break;
       mu_stream_write (stream, buf, n, NULL);
     }
+  mu_stream_destroy (&in);
   free (buf);
 }
 
@@ -2009,29 +1996,29 @@ finish_text_msg (struct compose_env *env, mu_message_t *msg, int ascii)
       
       mu_message_create (&newmsg, NULL);
       mu_message_get_header (newmsg, &hdr);
-      mu_header_get_stream (hdr, &output);
       copy_header (*msg, hdr);
       mu_header_set_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING,
 			   "quoted-printable", 0);
       
       mu_message_get_body (newmsg, &body);
-      mu_body_get_stream (body, &output);
-      mu_stream_seek (output, 0, SEEK_SET, NULL);
+      mu_body_get_streamref (body, &output);
 
       mu_message_get_body (*msg, &body);
-      mu_body_get_stream (body, &input);
+      mu_body_get_streamref (body, &input);
       rc = mu_filter_create (&fstr, input, "quoted-printable",
 			     MU_FILTER_ENCODE, 
 			     MU_STREAM_READ | MU_STREAM_NO_CLOSE);
       if (rc == 0)
 	{
-	  cat_message (output, fstr);
+	  mu_stream_copy (output, fstr, 0);
 	  mu_stream_destroy (&fstr);
 	  mu_message_unref (*msg);
 	  *msg = newmsg;
 	}
       else
 	mu_message_destroy (&newmsg, NULL);
+      mu_stream_destroy (&input);
+      mu_stream_destroy (&output);
     }
   finish_msg (env, msg);
 }
@@ -2075,18 +2062,19 @@ edit_extern (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
     return 1;
 
   mu_message_get_body (*msg, &body);
-  mu_body_get_stream (body, &out);
-  mu_stream_seek (out, 0, SEEK_SET, NULL);
+  mu_body_get_streamref (body, &out);
 
   if (!id)
     id = mh_create_message_id (env->subpart);
   mu_header_set_value (hdr2, MU_HEADER_CONTENT_ID, id, 1);
   free (id);
 
-  mu_header_get_stream (hdr2, &in);
-  mu_stream_seek (in, 0, SEEK_SET, NULL);
-  cat_message (out, in);
+  mu_header_get_streamref (hdr2, &in);
+  mu_stream_copy (out, in, 0);
+  mu_stream_destroy (&in);
   mu_stream_close (out);
+  mu_stream_destroy (&out);
+  
   mu_header_destroy (&hdr2);
 
   finish_msg (env, msg);
@@ -2311,11 +2299,11 @@ edit_mime (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
     }
   
   mu_message_get_body (*msg, &body);
-  mu_body_get_stream (body, &out);
-  cat_message (out, fstr);
+  mu_body_get_streamref (body, &out);
+  mu_stream_copy (out, fstr, 0);
 
   mu_stream_close (out);
-  
+  mu_stream_destroy (&out);
   mu_stream_destroy (&fstr);
   finish_msg (env, msg);
   return rc;
@@ -2338,7 +2326,7 @@ mhn_edit (struct compose_env *env, int level)
   char *buf = NULL;
   size_t bufsize = 0, n;
   mu_body_t body;
-  mu_stream_t output;
+  mu_stream_t output = NULL;
   mu_message_t msg = NULL;
   size_t line_count = 0;
   int ascii_buf;
@@ -2350,12 +2338,15 @@ mhn_edit (struct compose_env *env, int level)
       if (!msg)
 	{
 	  mu_header_t hdr;
+
+	  /* Destroy old stream */
+	  mu_stream_destroy (&output);
+	  
 	  /* Create new message */
 	  mu_message_create (&msg, NULL);
 	  mu_message_get_header (msg, &hdr);
 	  mu_message_get_body (msg, &body);
-	  mu_body_get_stream (body, &output);
-	  mu_stream_seek (output, 0, SEEK_SET, NULL);
+	  mu_body_get_streamref (body, &output);
 	  line_count = 0;
 	  ascii_buf = 1; /* Suppose it is ascii */
 	  env->subpart++;
@@ -2390,6 +2381,8 @@ mhn_edit (struct compose_env *env, int level)
 	      free (b2);
 
 	      mu_stream_close (output);
+	      mu_stream_destroy (&output);
+	      
 	      if (line_count)
 		/* Close and append the previous part */
 		finish_text_msg (env, &msg, ascii_buf);
@@ -2472,6 +2465,7 @@ mhn_edit (struct compose_env *env, int level)
       else
 	mu_message_unref (msg);
     }
+  mu_stream_destroy (&output);
   
   return status;
 }
@@ -2620,14 +2614,14 @@ mhn_compose ()
   mu_mime_create (&mime, NULL, 0);
 
   mu_message_get_body (message, &body);
-  mu_body_get_stream (body, &stream);
-  mu_stream_seek (stream, 0, SEEK_SET, NULL);
+  mu_body_get_streamref (body, &stream);
 
   env.mime = mime;
   env.input = stream;
   env.subpart = 0;
   env.line = 0;
   rc = mhn_edit (&env, 0);
+  mu_stream_destroy (&stream);
   if (rc)
     return rc;
 
@@ -2670,10 +2664,11 @@ mhn_compose ()
 
   mhn_header (message, msg);
   copy_header_to_stream (message, stream);
-  mu_message_get_stream (msg, &in);
-  cat_message (stream, in);
+  mu_message_get_streamref (msg, &in);
+  mu_stream_copy (stream, in, 0);
+  mu_stream_destroy (&in);
   mu_stream_destroy (&stream);
-
+  
   /* Preserve the backup copy and replace the draft */
   unlink (backup);
   rename (input_file, backup);
diff --git a/mh/pick.y b/mh/pick.y
index 152b7a5..64248ec 100644
--- a/mh/pick.y
+++ b/mh/pick.y
@@ -324,8 +324,7 @@ match_message (mu_message_t msg, regex_t *regex)
   char buf[128];
   size_t n;
   
-  mu_message_get_stream (msg, &str);
-  mu_stream_seek (str, 0, SEEK_SET, NULL);
+  mu_message_get_streamref (msg, &str);
   while (mu_stream_readline (str, buf, sizeof buf, &n) == 0
 	 && n > 0)
     {
@@ -333,6 +332,7 @@ match_message (mu_message_t msg, regex_t *regex)
       if (regexec (regex, buf, 0, NULL, 0) == 0)
 	return 1;
     }
+  mu_stream_destroy (&str);
   return 0;
 }
 
diff --git a/pop3d/retr.c b/pop3d/retr.c
index 137d53d..8d3030d 100644
--- a/pop3d/retr.c
+++ b/pop3d/retr.c
@@ -44,6 +44,7 @@ pop3d_retr (char *arg)
   if (pop3d_is_deleted (attr))
     return ERR_MESG_DELE;
 
+  /* FIXME: Use crlf filter + mu_stream_copy instead of the loop below */
   mu_message_get_stream (msg, &stream);
   pop3d_outf ("+OK\r\n");
 
diff --git a/pop3d/top.c b/pop3d/top.c
index d9d8614..0506a64 100644
--- a/pop3d/top.c
+++ b/pop3d/top.c
@@ -59,6 +59,7 @@ pop3d_top (char *arg)
 
   /* Header.  */
   mu_message_get_header (msg, &hdr);
+  /* FIXME: Use crlf filter + mu_stream_copy instead of the below loop */
   mu_header_get_stream (hdr, &stream);
   n = 0;
   while (mu_stream_readline (stream, buf, sizeof(buf), &n) == 0
@@ -80,6 +81,7 @@ pop3d_top (char *arg)
       int prev_nl = 1;
 
       mu_message_get_body (msg, &body);
+      /* FIXME: Use the crlf filter + mu_stream_copy */
       mu_body_get_stream (body, &stream);
       n = 0;
       while (mu_stream_readline (stream, buf, sizeof(buf), &n) == 0
diff --git a/readmsg/msglist.c b/readmsg/msglist.c
index 481993b..fb4ff99 100644
--- a/readmsg/msglist.c
+++ b/readmsg/msglist.c
@@ -124,8 +124,7 @@ msglist (mu_mailbox_t mbox, int show_all, int argc, char **argv,
 	      mu_stream_t stream = NULL;
 
 	      mu_mailbox_get_message (mbox, j, &msg);
-	      mu_message_get_stream (msg, &stream);
-	      mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+	      mu_message_get_streamref (msg, &stream);
 	      while (mu_stream_readline (stream, buf, sizeof buf, &len) == 0
 		     && len > 0)
 		{
diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c
index 0f2a0ed..0ea377e 100644
--- a/readmsg/readmsg.c
+++ b/readmsg/readmsg.c
@@ -211,14 +211,15 @@ print_header (mu_message_t message, int unix_header, int weedc, char **weedv)
       size_t len = 0;
       char buf[128];
 
-      mu_header_get_stream (header, &stream);
-      mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
+      /* FIXME: Use mu_stream_copy */
+      mu_header_get_streamref (header, &stream);
       while (mu_stream_read (stream, buf, sizeof (buf) - 1, &len) == 0
 	     && len != 0)
 	{
 	  buf[len] = '\0';
 	  printf ("%s", buf);
 	}
+      mu_stream_destroy (&stream);
     }
   else
     {
@@ -264,7 +265,9 @@ print_body (mu_message_t message)
   mu_stream_t stream = NULL;
   size_t len = 0;
   mu_message_get_body (message, &body);
-  mu_body_get_stream (body, &stream);
+
+  /* FIXME: Use mu_stream_copy */
+  mu_body_get_streamref (body, &stream);
 
   while (mu_stream_read (stream, buf, sizeof (buf) - 1, &len) == 0
 	 && len != 0)
@@ -272,6 +275,7 @@ print_body (mu_message_t message)
       buf[len] = '\0';
       printf ("%s", buf);
     }
+  mu_stream_destroy (&stream);
 }
 
 int


hooks/post-receive
-- 
GNU Mailutils



