From MAILER-DAEMON Sat May 01 12:59:22 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O8G2E-0005Hj-Fj
	for mharc-commit-mailutils@gnu.org; Sat, 01 May 2010 12:59:22 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O8G2D-0005FI-38
	for commit-mailutils@gnu.org; Sat, 01 May 2010 12:59:21 -0400
Received: from [140.186.70.92] (port=57629 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O8G2A-0005AQ-Ix
	for commit-mailutils@gnu.org; Sat, 01 May 2010 12:59:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8G27-00038W-At
	for commit-mailutils@gnu.org; Sat, 01 May 2010 12:59:17 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:48580
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8G27-00038R-6c
	for commit-mailutils@gnu.org; Sat, 01 May 2010 12:59: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 1O8G26-0001il-MH
	for commit-mailutils@gnu.org; Sat, 01 May 2010 16:59:14 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8G26-0005w8-68
	for commit-mailutils@gnu.org; Sat, 01 May 2010 16:59:14 +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: fd5cc1028e705b1c5fc350361e3a10a0b23f6b23
X-Git-Newrev: 17e7050b820314f268996c7f06ae9344a5f4f5c2
Message-Id: <E1O8G26-0005w8-68@vcs-noshell.in.savannah.gnu.org>
Date: Sat, 01 May 2010 16:59:14 +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-85-g17e7050
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, 01 May 2010 16:59:21 -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=17e7050b820314f268996c7f06ae9344a5f4f5c2

The branch, stream-cleanup has been updated
       via  17e7050b820314f268996c7f06ae9344a5f4f5c2 (commit)
       via  d223d743be22bc5dae7aa42b12e529f6c5f03858 (commit)
       via  55187d77a5aece6b16c1a6091f9704bd159fda73 (commit)
       via  e745b7a0a24f3f29f1737d9bb52a0c2683384ffb (commit)
       via  1ec505ce98996b4633faf3961692becf0a711bd9 (commit)
      from  fd5cc1028e705b1c5fc350361e3a10a0b23f6b23 (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 17e7050b820314f268996c7f06ae9344a5f4f5c2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 19:58:33 2010 +0300

    Optimize readline/readdelim/getdelim calls.
    
    This speeds up common reading operations by factor of 4-6.
    
    * include/mailutils/stream.h (mu_stream_readdelim): New proto.
    * include/mailutils/sys/stream.h (_mu_stream) <readdelim>: New method.
    * mailbox/stream.c (_stream_scandelim, _stream_readdelim): New functions.
    (mu_stream_readdelim): New function.
    (mu_stream_readline): Rewrite using mu_stream_readdelim.
    (mu_stream_getdelim): Optimize.
    
    * mailbox/amd.c (amd_body_stream_readdelim): New function.
    (_amd_attach_message): Set the readdelim method.
    * mailbox/header.c: Add a placeholder for readdelim method.
    * mailbox/message.c (_message_stream_readdelim): New function.
    (_message_stream_create): Set the readdelim method.
    * mailbox/streamref.c (_streamref_readdelim): New function.
    (mu_streamref_create_abridged): Set the readdelim method.

commit d223d743be22bc5dae7aa42b12e529f6c5f03858
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 17:44:07 2010 +0300

    Fix amd
    
    * mailbox/amd.c (_amd_attach_message): Store body.
    (amd_scan_message): Scan the message only if it has been modified
    after the last scan.
    Fix loop condition.
    Store mhm->mtime on success.
    (amd_message_stream_open): Enforce full buffering.
    (amd_body_stream_read): Fix.
    (amd_body_stream_seek): Don't call mu_stream_seek on mhm->stream.

commit 55187d77a5aece6b16c1a6091f9704bd159fda73
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 17:43:48 2010 +0300

    Bugfixes
    
    * mailbox/message.c (_check_stream_state): Bugfix.
    (_message_stream_seek): Bugfix.
    (_message_stream_read): Always try to fill out the buffer.
    (_message_stream_create): Set MU_STREAM_SEEK flag bit.

commit e745b7a0a24f3f29f1737d9bb52a0c2683384ffb
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 17:42:52 2010 +0300

    Bugfix in filter_iconv.
    
    * mailbox/filter_iconv.c (mu_filter_iconv_create): Return
    the created stream in *s.

commit 1ec505ce98996b4633faf3961692becf0a711bd9
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 17:42:13 2010 +0300

    Keep track of the current offset in the _mu_stream structure.
    
    * include/mailutils/sys/stream.h (_mu_stream)<offset>: New member.
    * mailbox/stream.c (_stream_fill_buffer): Propagate return value
    from mu_stream_read_unbuffered.
    (_stream_flush_buffer): Use stream->offset. Honor the `all' argument.
    (mu_stream_seek): Rewrite using the `offset' member.
    (mu_stream_read_unbuffered)
    (mu_stream_write_unbuffered): Update offset.
    (mu_stream_readline): Return EINVAL if size is 0.

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

Summary of changes:
 include/mailutils/stream.h     |    2 +
 include/mailutils/sys/stream.h |    2 +
 mailbox/amd.c                  |  114 +++++++++++++++++++++++------
 mailbox/filter_iconv.c         |    1 +
 mailbox/header.c               |   53 +++++++++++++
 mailbox/message.c              |   67 +++++++++++++----
 mailbox/stream.c               |  158 ++++++++++++++++++++++++++++------------
 mailbox/streamref.c            |   11 +++
 8 files changed, 324 insertions(+), 84 deletions(-)

diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index 0197fcd..cdc55e7 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -74,6 +74,8 @@ int mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
 int mu_stream_set_buffer (mu_stream_t stream, enum mu_buffer_type type,
 			  size_t size);
 int mu_stream_read (mu_stream_t stream, void *buf, size_t size, size_t *pread);
+int mu_stream_readdelim (mu_stream_t stream, char *buf, size_t size,
+			 int delim, size_t *pread);
 int mu_stream_readline (mu_stream_t stream, char *buf, size_t size, size_t *pread);
 int mu_stream_getdelim (mu_stream_t stream, char **pbuf, size_t *psize,
 			int delim, size_t *pread);
diff --git a/include/mailutils/sys/stream.h b/include/mailutils/sys/stream.h
index 2800341..e63d60d 100644
--- a/include/mailutils/sys/stream.h
+++ b/include/mailutils/sys/stream.h
@@ -35,11 +35,13 @@ struct _mu_stream
   char *cur;
 
   int flags;
+  mu_off_t offset;
   mu_off_t bytes_in, bytes_out;
   
   int last_err;
 
   int (*read) (struct _mu_stream *, char *, size_t, size_t *);
+  int (*readdelim) (struct _mu_stream *, char *, size_t, int, size_t *);
   int (*write) (struct _mu_stream *, const char *, size_t, size_t *);
   int (*flush) (struct _mu_stream *);
   int (*open) (struct _mu_stream *);
diff --git a/mailbox/amd.c b/mailbox/amd.c
index befe43e..d5ff6d5 100644
--- a/mailbox/amd.c
+++ b/mailbox/amd.c
@@ -117,6 +117,10 @@ static int amd_envelope_sender (mu_envelope_t envelope, char *buf, size_t len,
 static int amd_body_stream_read (mu_stream_t str, char *buffer,
 				 size_t buflen,
 				 size_t *pnread);
+static int amd_body_stream_readdelim (mu_stream_t is,
+				      char *buffer, size_t buflen,
+				      int delim,
+				      size_t *pnread);
 static int amd_body_stream_size (mu_stream_t str, mu_off_t *psize);
 static int amd_body_stream_seek (mu_stream_t str, mu_off_t off, int whence,
 				 mu_off_t *presult);
@@ -487,6 +491,7 @@ _amd_attach_message (mu_mailbox_t mailbox, struct _amd_message *mhm,
 	return ENOMEM;
       }
     str->stream.read = amd_body_stream_read;
+    str->stream.readdelim = amd_body_stream_readdelim;
     str->stream.size = amd_body_stream_size;
     str->stream.seek = amd_body_stream_seek;
     mu_body_set_stream (body, (mu_stream_t) str, msg);
@@ -494,6 +499,7 @@ _amd_attach_message (mu_mailbox_t mailbox, struct _amd_message *mhm,
     mu_body_set_size (body, amd_body_size, msg);
     mu_body_set_lines (body, amd_body_lines, msg);
     mu_message_set_body (msg, body, mhm);
+    str->body = body;
   }
 
   /* Set the envelope.  */
@@ -1341,30 +1347,26 @@ amd_scan_message (struct _amd_message *mhm)
   size_t hlines = 0;
   size_t blines = 0;
   size_t body_start = 0;
+  struct stat st;
+  char *msg_name;
 
   /* Check if the message was modified after the last scan */
-  if (mhm->mtime)
-    {
-      struct stat st;
-      char *msg_name;
-
-      status = mhm->amd->cur_msg_file_name (mhm, &msg_name);
-      if (status)
-	return status;
+  status = mhm->amd->cur_msg_file_name (mhm, &msg_name);
+  if (status)
+    return status;
 
-      if (stat (msg_name, &st) == 0 && st.st_mtime == mhm->mtime)
-	{
-	  /* Nothing to do */
-	  free (msg_name);
-	  return 0;
-	}
+  if (stat (msg_name, &st) == 0 && st.st_mtime == mhm->mtime)
+    {
+      /* Nothing to do */
       free (msg_name);
+      return 0;
     }
+  free (msg_name);
 
   off = 0;
   status = mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   if (status == 0)
-    while ((status = mu_stream_readline (stream, buf, sizeof (buf), &n) == 0)
+    while ((status = mu_stream_readline (stream, buf, sizeof (buf), &n)) == 0
 	   && n != 0)
       {
 	if (in_header)
@@ -1401,6 +1403,7 @@ amd_scan_message (struct _amd_message *mhm)
 
   if (status == 0)
     {
+      mhm->mtime = st.st_mtime;
       if (!body_start)
 	body_start = off;
       mhm->header_lines = hlines;
@@ -1552,6 +1555,9 @@ amd_message_stream_open (struct _amd_message *mhm)
   if (status != 0)
     return status;
 
+  /* FIXME: Select buffer size dynamically */
+  mu_stream_set_buffer (mhm->stream, mu_buffer_full, 16384);
+  
   status = mu_stream_open (mhm->stream);
 
   if (status != 0)
@@ -1614,9 +1620,15 @@ amd_body_stream_read (mu_stream_t is, char *buffer, size_t buflen,
   if (ln > 0)
     {
       nread = ((size_t)ln < buflen) ? (size_t)ln : buflen;
-      status = mu_stream_read (mhm->stream, buffer, nread, pnread);
+      status = mu_stream_seek (mhm->stream, mhm->body_start + amdstr->off,
+			       MU_SEEK_SET, NULL);
       if (status == 0)
-	amdstr->off += pnread ? *pnread : nread;
+	{
+	  status = mu_stream_read (mhm->stream, buffer, nread, &nread);
+	  amdstr->off += nread;
+	  if (pnread)
+	    *pnread = nread;
+	}
     }
 
   mu_monitor_unlock (mhm->amd->mailbox->monitor);
@@ -1628,14 +1640,75 @@ amd_body_stream_read (mu_stream_t is, char *buffer, size_t buflen,
 }
 
 static int
+amd_body_stream_readdelim (mu_stream_t is, char *buffer, size_t buflen,
+			   int delim,
+			   size_t *pnread)
+{
+  struct _amd_body_stream *amdstr = (struct _amd_body_stream *)is;
+  mu_body_t body = amdstr->body;
+  mu_message_t msg = mu_body_get_owner (body);
+  struct _amd_message *mhm = mu_message_get_owner (msg);
+  size_t nread = 0;
+  int status = 0;
+
+  amd_pool_open (mhm);
+
+  if (buffer == NULL || buflen == 0)
+    {
+      if (pnread)
+	*pnread = nread;
+      return 0;
+    }
+
+  mu_monitor_rdlock (mhm->amd->mailbox->monitor);
+#ifdef WITH_PTHREAD
+  /* read() is cancellation point since we're doing a potentially
+     long operation.  Lets make sure we clean the state.  */
+  pthread_cleanup_push (amd_cleanup, (void *)mhm->amd->mailbox);
+#endif
+
+  status = mu_stream_seek (mhm->stream, mhm->body_start + amdstr->off,
+			   MU_SEEK_SET, NULL);
+  if (status)
+    {
+      buflen--;
+      while (buflen)
+	{
+	  size_t ln, rdsize;
+	  
+	  ln = mhm->body_end - (mhm->body_start + amdstr->off);
+	  if (ln > 0)
+	    {
+	      rdsize = ((size_t)ln < buflen) ? (size_t)ln : buflen;
+	      status = mu_stream_readdelim (mhm->stream, buffer, rdsize,
+					    delim, &rdsize);
+	      amdstr->off += nread;
+	      nread += rdsize;
+	      if (status)
+		break;
+	      buflen -= rdsize;
+	      buffer += rdsize;
+	    }
+	}
+    }
+
+  mu_monitor_unlock (mhm->amd->mailbox->monitor);
+#ifdef WITH_PTHREAD
+  pthread_cleanup_pop (0);
+#endif
+
+  if (pnread)
+    *pnread = nread;
+  return status;
+}
+
+static int
 amd_body_stream_seek (mu_stream_t str, mu_off_t off, int whence,
 		      mu_off_t *presult)
 {
-  int rc;
   size_t size;
   struct _amd_body_stream *amdstr = (struct _amd_body_stream *)str;
   mu_message_t msg = mu_body_get_owner (amdstr->body);
-  struct _amd_message *mhm = mu_message_get_owner (msg);
   
   amd_body_size (amdstr->body, &size);
   switch (whence)
@@ -1655,9 +1728,6 @@ amd_body_stream_seek (mu_stream_t str, mu_off_t off, int whence,
   if (off < 0 || off >= size)
     return ESPIPE;
 
-  rc = mu_stream_seek (mhm->stream, mhm->body_start + off, MU_SEEK_SET, NULL);
-  if (rc)
-    return rc;
   amdstr->off = off;
   if (presult)
     *presult = off;
diff --git a/mailbox/filter_iconv.c b/mailbox/filter_iconv.c
index 3831b96..802c35d 100644
--- a/mailbox/filter_iconv.c
+++ b/mailbox/filter_iconv.c
@@ -462,5 +462,6 @@ mu_filter_iconv_create (mu_stream_t *s, mu_stream_t transport,
   iptr->stream.ctl = _icvt_ioctl;
   iptr->stream.wait = _icvt_wait;
   iptr->stream.seek = _icvt_seek;
+  *s = iptr;
   return 0;
 }
diff --git a/mailbox/header.c b/mailbox/header.c
index 224915f..4ad57ec 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -999,6 +999,59 @@ header_read (mu_stream_t is, char *buffer, size_t buflen, size_t *pnread)
   return 0;
 }
 
+#if 0
+/* FIXME: Implement header_readdelim based on this: */
+static int
+_header_readline (mu_stream_t is, char *buffer, size_t buflen, size_t *pnread)
+{
+  struct _mu_header_stream *hstr = (struct _mu_header_stream *) is;
+  mu_header_t header = hstr->hdr;
+  struct mu_hdrent *ent;
+  size_t ent_off;
+  int status;
+  size_t strsize;
+  char *start, *end;
+
+  if (buflen == 0)
+    return EINVAL;
+
+  header = mu_stream_get_owner (is);
+  status = mu_header_fill (header);
+  if (status)
+    return status;
+  if (mu_hdrent_find_stream_pos (header, hstr->off, &ent, &ent_off))
+    {
+      if (pnread)
+	*pnread = 0;
+      return 0;
+    }
+
+  buflen--; /* Account for the terminating nul */
+
+  mu_hdrent_fixup (header, ent);
+  strsize = MU_STR_SIZE (ent->nlen, ent->vlen) - ent_off;
+  start = MU_HDRENT_NAME (header, ent) + ent_off;
+  end = strchr (start, '\n');
+  if (end)
+    {
+      size_t len = end - start + 1;
+      if (len < strsize)
+	strsize = len;
+    }
+
+  if (strsize < buflen)
+    buflen = strsize;
+
+  memcpy (buffer, start, buflen);
+  buffer[buflen] = 0;
+  hstr->off += buflen;
+  mu_hdrent_unroll_fixup (header, ent);
+  if (pnread)
+    *pnread = buflen;
+  return 0;
+}
+#endif
+
 static int
 header_write (mu_stream_t os, const char *buf, size_t buflen, size_t *pnwrite)
 {
diff --git a/mailbox/message.c b/mailbox/message.c
index d23677c..4f93fa3 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -104,7 +104,7 @@ _check_stream_state (struct _mu_message_stream *str)
 	  rc = mu_body_get_streamref (str->msg->body, &str->transport);
 	  if (rc == 0)
 	    {
-	      str->state = _mss_header;
+	      str->state = _mss_body;
 	      rc = mu_stream_seek (str->transport, 0, MU_SEEK_SET, NULL);
 	    }
 	}
@@ -194,13 +194,12 @@ _message_stream_seek (struct _mu_stream *str, mu_off_t off, int whence,
 	return rc;
       /* fall through */
     case _mss_header:
-      if (off > hsize)
-	{
-	  mu_stream_destroy (&sp->transport);
-	  rc = _check_stream_state (sp);
-	  if (rc)
-	    return rc;
-	}
+      if (off < hsize)
+	break;
+      mu_stream_destroy (&sp->transport);
+      rc = _check_stream_state (sp);
+      if (rc)
+	return rc;
       /* fall through */
     case _mss_body:
       off -= hsize;
@@ -224,17 +223,51 @@ _message_stream_read (struct _mu_stream *str, char *buf, size_t bufsize,
 		      size_t *pnread)
 {
   struct _mu_message_stream *sp = (struct _mu_message_stream *)str;
-  int rc = _check_stream_state (sp);
-  if (rc)
-    return rc;
-  if (sp->state == _mss_eof)
+  size_t nread = 0;
+  int rc;
+  
+  while (bufsize)
     {
-      *pnread = 0;
-      return 0;
+      size_t n;
+      rc = _check_stream_state (sp);
+      if (rc)
+	break;
+      if (sp->state == _mss_eof)
+	break;
+      rc = mu_stream_read (sp->transport, buf, bufsize, &n);
+      nread += n;
+      buf += n;
+      bufsize -= n;
     }
-  return mu_stream_read (sp->transport, buf, bufsize, pnread);
+  *pnread = nread;
+  return rc;
 }
 
+static int
+_message_stream_readdelim (struct _mu_stream *str, char *buf, size_t bufsize,
+			   int delim, size_t *pnread)
+{
+  struct _mu_message_stream *sp = (struct _mu_message_stream *)str;
+  size_t nread = 0;
+  int rc;
+  
+  while (bufsize)
+    {
+      size_t n;
+      rc = _check_stream_state (sp);
+      if (rc)
+	break;
+      if (sp->state == _mss_eof)
+	break;
+      rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &n);
+      nread += n;
+      buf += n;
+      bufsize -= n;
+    }
+  *pnread = nread;
+  return rc;
+}  
+
 #if 0
 static int
 _message_stream_write (struct _mu_stream *str,
@@ -252,11 +285,13 @@ _message_stream_create (mu_stream_t *pmsg, mu_message_t msg, int flags)
 {
   struct _mu_message_stream *sp;
 
-  sp = (struct _mu_message_stream *) _mu_stream_create (sizeof (*sp), flags);
+  sp = (struct _mu_message_stream *) _mu_stream_create (sizeof (*sp),
+							flags | MU_STREAM_SEEK);
   if (!sp)
     return ENOMEM;
 
   sp->stream.read = _message_stream_read;
+  sp->stream.readdelim = _message_stream_readdelim;
   /* FIXME: Write is not defined */
   /*  sp->stream.write = _message_stream_write;*/
   sp->stream.done = _message_stream_done;
diff --git a/mailbox/stream.c b/mailbox/stream.c
index 0ea5c01..21e4fec 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -69,11 +69,10 @@ _stream_fill_buffer (struct _mu_stream *stream)
       return 0;
 	
     case mu_buffer_full:
-      if (mu_stream_read_unbuffered (stream,
-				     stream->buffer, stream->bufsize,
-				     0,
-				     &stream->level))
-	return 1;
+      rc = mu_stream_read_unbuffered (stream,
+				      stream->buffer, stream->bufsize,
+				      0,
+				      &stream->level);
       break;
 	
     case mu_buffer_line:
@@ -124,9 +123,7 @@ _stream_flush_buffer (struct _mu_stream *stream, int all)
   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)))
+	  && (rc = mu_stream_seek (stream, stream->offset, MU_SEEK_SET, NULL)))
 	return rc;
 
       switch (stream->buftype)
@@ -138,6 +135,8 @@ _stream_flush_buffer (struct _mu_stream *stream, int all)
 	  if ((rc = mu_stream_write_unbuffered (stream, stream->cur,
 						stream->level, 1, NULL)))
 	    return rc;
+	  if (all)
+	    _stream_advance_buffer (stream, stream->level);
 	  break;
 	    
 	case mu_buffer_line:
@@ -167,6 +166,9 @@ _stream_flush_buffer (struct _mu_stream *stream, int all)
 	    }
 	}
     }
+  else if (all)
+    _stream_advance_buffer (stream, stream->level);
+  
   if (stream->level)
     {
       if (stream->cur > stream->buffer)
@@ -280,11 +282,10 @@ mu_stream_eof (mu_stream_t stream)
 int
 mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
 		mu_off_t *pres)
-{
+{    
   int rc;
-  mu_off_t res;
-  size_t bpos;
-    
+  mu_off_t size;
+  
   if (!stream->seek)
     return _stream_seterror (stream, ENOSYS, 0);
 
@@ -297,35 +298,39 @@ mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
       break;
 
     case MU_SEEK_CUR:
-      break;
-
-    case MU_SEEK_END: 
-      bpos = _stream_buffer_offset (stream);
-      if (bpos + offset >= 0 && bpos + offset < _stream_orig_level (stream))
+      if (offset == 0)
 	{
-	  if ((rc = stream->seek (stream, offset, whence, &res)))
-	    return _stream_seterror (stream, rc, 1);
-	  offset -= bpos;
-	  _stream_advance_buffer (stream, offset);
-	  _stream_cleareof (stream);
-	  if (pres)
-	    *pres = res - stream->level;
+	  *pres = stream->offset + _stream_buffer_offset (stream);
 	  return 0;
 	}
+      offset += stream->offset;
+      break;
+
+    case MU_SEEK_END:
+      rc = mu_stream_size (stream, &size);
+      if (rc)
+	return _stream_seterror (stream, rc, 1);
+      offset += size;
       break;
 
     default:
       return _stream_seterror (stream, EINVAL, 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);
-  _stream_cleareof (stream);
+  if (stream->buftype == mu_buffer_none
+      || offset < stream->offset
+      || offset > stream->offset + _stream_buffer_offset (stream))
+    {
+      if ((rc = _stream_flush_buffer (stream, 1)))
+	return rc;
+      rc = stream->seek (stream, offset, MU_SEEK_SET, &stream->offset);
+      if (rc)
+	return _stream_seterror (stream, rc, 1);
+      _stream_cleareof (stream);
+    }
+  
   if (pres)
-    *pres = res - stream->level;
+    *pres = stream->offset + _stream_buffer_offset (stream);
   return 0;
 }
 
@@ -419,6 +424,7 @@ mu_stream_read_unbuffered (mu_stream_t stream, void *buf, size_t size,
 	  }
 	_stream_seterror (stream, rc, rc != 0);
       }
+    stream->offset += nread;
     if (pnread)
       *pnread = nread;
     
@@ -478,6 +484,7 @@ mu_stream_write_unbuffered (mu_stream_t stream,
 	stream->bytes_out += nwritten;
     }
   stream->flags |= _MU_STR_WRT;
+  stream->offset += nwritten;
   if (pnwritten)
     *pnwritten = nwritten;
   _stream_seterror (stream, rc, rc != 0);
@@ -524,29 +531,59 @@ mu_stream_read (mu_stream_t stream, void *buf, size_t size, size_t *pread)
       
       if (pread)
 	*pread = nbytes;
-      else if (size) 
-	return _stream_seterror (stream, EIO, 1);
     }
   return 0;
 }
 
 int
-mu_stream_readline (mu_stream_t stream, char *buf, size_t size, size_t *pread)
+_stream_scandelim (mu_stream_t stream, char *buf, size_t size, int delim,
+		   size_t *pnread)
+{
+  int rc = 0;
+  size_t nread = 0;
+  
+  size--;
+  while (size)
+    {
+      char *p;
+      size_t len;
+      
+      if (stream->level == 0)
+	{
+	  if ((rc = _stream_fill_buffer (stream)) || stream->level == 0)
+	    break;
+	}
+      
+      p = memchr (stream->cur, delim, stream->level);
+      len = p ? p - stream->cur + 1 : stream->level;
+      if (len > size)
+	len = size;
+      memcpy (buf, stream->cur, len);
+      _stream_advance_buffer (stream, len);
+      buf += len;
+      size -= len;
+      nread += len;
+    }
+  *buf = 0;
+  *pnread = nread;
+  return rc;
+}
+
+static int
+_stream_readdelim (mu_stream_t stream, char *buf, size_t size,
+		   int delim, size_t *pread)
 {
   int rc;
   char c;
   size_t n = 0, rdn;
     
-  if (size == 0)
-    return EIO;
-    
   size--;
   for (n = 0;
        n < size && (rc = mu_stream_read (stream, &c, 1, &rdn)) == 0 && rdn;)
     {
       *buf++ = c;
       n++;
-      if (c == '\n')
+      if (c == delim)
 	break;
     }
   *buf = 0;
@@ -556,6 +593,30 @@ mu_stream_readline (mu_stream_t stream, char *buf, size_t size, size_t *pread)
 }
 
 int
+mu_stream_readdelim (mu_stream_t stream, char *buf, size_t size,
+		     int delim, size_t *pread)
+{
+  int rc;
+  
+  if (size == 0)
+    return EINVAL;
+    
+  if (stream->readdelim)
+    rc = stream->readdelim (stream, buf, size, delim, pread);
+  else if (stream->buftype != mu_buffer_none)
+    rc = _stream_scandelim (stream, buf, size, delim, pread);
+  else
+    rc = _stream_readdelim (stream, buf, size, delim, pread);
+  return rc;
+}
+
+int
+mu_stream_readline (mu_stream_t stream, char *buf, size_t size, size_t *pread)
+{
+  return mu_stream_readdelim (stream, buf, size, '\n', pread);
+}
+
+int
 mu_stream_getdelim (mu_stream_t stream, char **pbuf, size_t *psize,
 		    int delim, size_t *pread)
 {
@@ -576,13 +637,8 @@ 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, &rdn);
-      if (rc || rdn == 0)
-	break;
-	
       /* Make enough space for len+1 (for final NUL) bytes.  */
       if (cur_len + 1 >= n)
 	{
@@ -610,10 +666,20 @@ mu_stream_getdelim (mu_stream_t stream, char **pbuf, size_t *psize,
 	  n = needed;
 	}
 
-      lineptr[cur_len] = c;
-      cur_len++;
+      if (stream->readdelim)
+	rc = stream->readdelim (stream, lineptr + cur_len, n - cur_len, delim,
+				&rdn);
+      else if (stream->buftype != mu_buffer_none)
+	rc = _stream_scandelim (stream, lineptr + cur_len, n - cur_len, delim,
+				&rdn);
+      else
+	rc = mu_stream_read (stream, lineptr + cur_len, 1, &rdn);
+
+      if (rc || rdn == 0)
+	break;
+      cur_len += rdn;
       
-      if (c == delim)
+      if (lineptr[cur_len - 1] == delim)
 	break;
     }
   lineptr[cur_len] = '\0';
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index 7e9ff4f..0cad3fa 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -69,6 +69,16 @@ _streamref_read (struct _mu_stream *str, char *buf, size_t bufsize,
 }
 
 static int
+_streamref_readdelim (struct _mu_stream *str, char *buf, size_t bufsize,
+		      int delim, size_t *pnread)
+{
+  struct _mu_streamref *sp = (struct _mu_streamref *)str;
+  return streamref_return (sp, mu_stream_readdelim (sp->transport,
+						    buf, bufsize,
+						    delim, pnread));
+}
+
+static int
 _streamref_write (struct _mu_stream *str, const char *buf, size_t bufsize,
 		  size_t *pnwrite)
 {
@@ -264,6 +274,7 @@ mu_streamref_create_abridged (mu_stream_t *pref, mu_stream_t str,
   mu_stream_ref (str);
 
   sp->stream.read = _streamref_read; 
+  sp->stream.readdelim = _streamref_readdelim; 
   sp->stream.write = _streamref_write;
   sp->stream.flush = _streamref_flush;
   sp->stream.open = _streamref_open; 


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Sat May 01 13:52:42 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O8Grq-0006ts-9K
	for mharc-commit-mailutils@gnu.org; Sat, 01 May 2010 13:52:42 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O8Grn-0006pc-VN
	for commit-mailutils@gnu.org; Sat, 01 May 2010 13:52:40 -0400
Received: from [140.186.70.92] (port=59789 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O8Grm-0006mM-5i
	for commit-mailutils@gnu.org; Sat, 01 May 2010 13:52:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8Grk-0001Rq-OK
	for commit-mailutils@gnu.org; Sat, 01 May 2010 13:52:38 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:56616
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8Grk-0001Rm-Li
	for commit-mailutils@gnu.org; Sat, 01 May 2010 13:52:36 -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 1O8Grk-0002Nr-0b
	for commit-mailutils@gnu.org; Sat, 01 May 2010 17:52:36 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8Grj-0000Nb-Uj
	for commit-mailutils@gnu.org; Sat, 01 May 2010 17:52:35 +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: 17e7050b820314f268996c7f06ae9344a5f4f5c2
X-Git-Newrev: 62db89e3dca29f9b931c62b25014955a4ede36c0
Message-Id: <E1O8Grj-0000Nb-Uj@vcs-noshell.in.savannah.gnu.org>
Date: Sat, 01 May 2010 17:52:35 +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-86-g62db89e
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, 01 May 2010 17:52:40 -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=62db89e3dca29f9b931c62b25014955a4ede36c0

The branch, stream-cleanup has been updated
       via  62db89e3dca29f9b931c62b25014955a4ede36c0 (commit)
      from  17e7050b820314f268996c7f06ae9344a5f4f5c2 (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 62db89e3dca29f9b931c62b25014955a4ede36c0
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat May 1 20:51:57 2010 +0300

    Bugfixes.
    
    * mailbox/rfc2047.c (mu_rfc2047_decode): Rewind in_stream.
    * mailbox/stream.c (_stream_scandelim): Break the loop when
    the delimiter is found.
    * mailbox/streamref.c (_streamref_readdelim): Take into account
    the abridgement.

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

Summary of changes:
 mailbox/rfc2047.c   |    1 +
 mailbox/stream.c    |    2 ++
 mailbox/streamref.c |   30 +++++++++++++++++++++++++++---
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index a5f61b4..df19d9f 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -162,6 +162,7 @@ mu_rfc2047_decode (const char *tocode, const char *input, char **ptostr)
 
 	  mu_memory_stream_create (&in_stream, 0);
 	  mu_stream_write (in_stream, encoded_text, size, NULL);
+	  mu_stream_seek (in_stream, 0, MU_SEEK_SET, NULL);
 	  status = mu_decode_filter (&filter, in_stream, filter_type, fromcode,
 				     tocode);
 	  if (status != 0)
diff --git a/mailbox/stream.c b/mailbox/stream.c
index 21e4fec..4e74caf 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -563,6 +563,8 @@ _stream_scandelim (mu_stream_t stream, char *buf, size_t size, int delim,
       buf += len;
       size -= len;
       nread += len;
+      if (p) /* Delimiter found */
+	break;
     }
   *buf = 0;
   *pnread = nread;
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index 0cad3fa..de5fec8 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -73,9 +73,33 @@ _streamref_readdelim (struct _mu_stream *str, char *buf, size_t bufsize,
 		      int delim, size_t *pnread)
 {
   struct _mu_streamref *sp = (struct _mu_streamref *)str;
-  return streamref_return (sp, mu_stream_readdelim (sp->transport,
-						    buf, bufsize,
-						    delim, pnread));
+  int rc;
+  size_t nread;
+  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 + 2; /* extra 1 to account for \0 */
+	  if (size < bufsize)
+	    bufsize = size;
+	}
+      rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &nread);
+      if (rc == 0)
+	{
+	  sp->offset += nread;
+	  *pnread = nread;
+	}
+    }
+  else if (rc == ESPIPE)
+    {
+      *pnread = 0;
+      mu_stream_clearerr (sp->transport);
+      return 0;
+    }
+  return streamref_return (sp, rc);
 }
 
 static int


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Sun May 02 11:01:06 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O8afK-0001W9-60
	for mharc-commit-mailutils@gnu.org; Sun, 02 May 2010 11:01:06 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O8afI-0001W4-VP
	for commit-mailutils@gnu.org; Sun, 02 May 2010 11:01:05 -0400
Received: from [140.186.70.92] (port=57164 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O8afD-0001Vj-9A
	for commit-mailutils@gnu.org; Sun, 02 May 2010 11:01:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8af8-0003Pl-4i
	for commit-mailutils@gnu.org; Sun, 02 May 2010 11:00:59 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:35619
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8af8-0003Pe-02
	for commit-mailutils@gnu.org; Sun, 02 May 2010 11:00:54 -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 1O8af7-0000rH-8l
	for commit-mailutils@gnu.org; Sun, 02 May 2010 15:00:53 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8af5-0006RO-2Y
	for commit-mailutils@gnu.org; Sun, 02 May 2010 15:00:53 +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: 62db89e3dca29f9b931c62b25014955a4ede36c0
X-Git-Newrev: b000617bad12dc7d3b0ea5f4541cc66b64e2fb02
Message-Id: <E1O8af5-0006RO-2Y@vcs-noshell.in.savannah.gnu.org>
Date: Sun, 02 May 2010 15:00:51 +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-92-gb000617
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, 02 May 2010 15:01: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=b000617bad12dc7d3b0ea5f4541cc66b64e2fb02

The branch, stream-cleanup has been updated
       via  b000617bad12dc7d3b0ea5f4541cc66b64e2fb02 (commit)
       via  55e8650184dc3f03e98cd41714115dc9803610cc (commit)
       via  a5721d4bc037b7288722650cf8d6685d18c6cdfd (commit)
       via  82917550244d2e4d06f4450d58af7beaae51a0a7 (commit)
       via  14af0505bcf691efbeb8fb60ab5ea99b9836f061 (commit)
       via  7262235cbe6dc9426ad6e37c5fe0f4b023b324a9 (commit)
      from  62db89e3dca29f9b931c62b25014955a4ede36c0 (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 b000617bad12dc7d3b0ea5f4541cc66b64e2fb02
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 17:58:01 2010 +0300

    Implement seek on filters in read-only mode.
    
    * include/mailutils/stream.h (mu_stream_skip_input_bytes): New proto.
    * mailbox/stream.c (mu_stream_skip_input_bytes): New function.
    * mailbox/fltstream.c (filter_seek): Re-implement on top of
    mu_stream_skip_input_bytes.
    (mu_filter_stream_create): Fix flag validity checking.
    
    * examples/base64.c: Add new option (-s) for testing seek operations
    on filters.

commit 55e8650184dc3f03e98cd41714115dc9803610cc
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 17:00:23 2010 +0300

    Make version output of the MH utilities more informative.
    
    * mh/mh_argp.c [MU_ALPHA_RELEASE}: Include git-describe.h
    (mh_program_version_hook): New function.
    (mh_argp_init): Take no arguments. Set argp_program_version_hook.
    * mh/mh_getopt.h (ARG_LICENSE): Remove.
    (mh_argp_init): Change proto.
    
    All sources: Fix calls to mh_argp_init, remove --license option.

commit a5721d4bc037b7288722650cf8d6685d18c6cdfd
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 16:16:44 2010 +0300

    For alpha version, include git tag info in the version output.
    
    * include/mailutils/libargp.h (mu_program_version_hook): New proto.
    * libmu_argp/Makefile.am (libmu_argp_a_SOURCES): Remove mu_argp.h.
    * libmu_argp/mu_argp.h: Remove.
    * libmu_argp/muinit.c [MU_ALPHA_RELEASE]: Include git-describe.h
    (mu_program_version_hook): New function.
    (mu_argp_init): Set mu_program_version_hook, unless vers is given.
    
    * comsat/comsat.c (main): Call mu_argp_init with NULL arguments.
    * config/mailutils-config.c: Likewise.
    * dotlock/dotlock.c: Likewise.
    * examples/muauth.c: Likewise.
    * frm/frm.c: Likewise.
    * frm/from.c: Likewise.
    * guimb/main.c: Likewise.
    * imap4d/imap4d.c: Likewise.
    * maidag/maidag.c: Likewise.
    * mail/mail.c: Likewise.
    * messages/messages.c: Likewise.
    * mimeview/mimeview.c: Likewise.
    * movemail/movemail.c: Likewise.
    * pop3d/pop3d.c: Likewise.
    * pop3d/popauth.c: Likewise.
    * readmsg/readmsg.c: Likewise.
    * sieve/sieve.c: Likewise.

commit 82917550244d2e4d06f4450d58af7beaae51a0a7
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 15:40:02 2010 +0300

    Fix conditional compilation.
    
    * .gitignore: Add git-describe and git-describe.h.
    * Makefile.am (MU_COND_LIBMU_CPP): Replaced with MU_COND_SUPPORT_CXX
    (SUBDIRS): Begin with .
    (EXTRA_DIST, BUILT_SOURCES): Add git-describe and git-describe.h.
    (git-describe, git-describe.h): New rules.
    (alpha, alphacheck): Use git-describe to produce additional suffix.
    * enable.m4 (MU_ENABLE_SUPPORT): Create an Automake condition.
    * configure.ac: Fix MU_ENABLE_SUPPORT calls.
    (--without-python): Replace with --disable-python.
    * examples/Makefile.am: Disable components based on MU_COND conditions.
    * libproto/Makefile.am: Likewise.
    * include/mailutils/Makefile.am (MU_COND_LIBMU_CPP): Replace with
    MU_COND_SUPPORT_CXX.
    
    * mailbox/nullrec.c: New file.
    * mailbox/Makefile.am (libmailutils_la_SOURCES): Add nullrec.c.
    
    * mail/decode.c: Remove unused variable.
    * mailbox/streamref.c: Likewise.

commit 14af0505bcf691efbeb8fb60ab5ea99b9836f061
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 14:20:32 2010 +0300

    Simplify stream->seek.
    
    * include/mailutils/sys/stream.h (_mu_stream) <seek>: Remove the
    `whence' parameter.
    * mailbox/stream.c (mu_stream_seek): Update the seek method call.
    
    * mailbox/streamref.c (_streamref_seek): Fix the signature. Remove
    unnecessary code.
    * mailbox/amd.c (amd_body_stream_seek): Likewise.
    * mailbox/body.c (_body_seek): Likewise.
    * mailbox/file_stream.c (fd_seek): Likewise.
    * mailbox/filter_iconv.c (_icvt_seek): Likewise.
    * mailbox/fltstream.c (filter_seek): Likewise.
    * mailbox/header.c (header_seek): Likewise.
    * mailbox/mapfile_stream.c (_mapfile_seek): Likewise.
    * mailbox/memory_stream.c (_memory_seek): Likewise.
    * mailbox/message.c (_message_stream_seek): Likewise.
    * mailbox/message_stream.c (_message_stream_seek): Likewise.
    * mailbox/mime.c (_mime_body_seek): Likewise.
    * mailbox/stdio_stream.c (stdio_seek): Likewise.

commit 7262235cbe6dc9426ad6e37c5fe0f4b023b324a9
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 13:57:06 2010 +0300

    Improve CRLF filter.
    
    * include/mailutils/filter.h (mu_filter_new_data_t): Change prototype.
    * mailbox/filter.c (mu_filter_create): Reflect the above.
    * mailbox/crlfflt.c (crlf_state): New enum.
    (_crlf_encoder): Keep state info in xd. Do not modify eventual input
    CRLFs.
    (alloc_state): New function.
    (_rfc822_filter,_crlf_filter): Provide the `newdata' method.

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

Summary of changes:
 .gitignore                              |    2 +
 Makefile.am                             |   53 ++++++++++++++++++++-----
 am/enable.m4                            |    6 ++-
 comsat/comsat.c                         |    2 +-
 config/mailutils-config.c               |    3 +-
 configure.ac                            |   51 +++++++++++++----------
 dotlock/dotlock.c                       |    3 +-
 examples/Makefile.am                    |   20 ++++++++-
 examples/base64.c                       |   18 ++++++--
 examples/muauth.c                       |    3 +-
 frm/frm.c                               |    3 +-
 frm/from.c                              |    3 +-
 guimb/main.c                            |    3 +-
 imap4d/imap4d.c                         |    2 +-
 include/mailutils/Makefile.am           |    2 +-
 include/mailutils/filter.h              |    2 +-
 include/mailutils/libargp.h             |    1 +
 include/mailutils/stream.h              |    3 +
 include/mailutils/sys/stream.h          |    2 +-
 libmu_argp/Makefile.am                  |    1 -
 libmu_argp/mu_argp.h                    |   46 ---------------------
 libmu_argp/muinit.c                     |   39 +++++++++++++++++-
 libproto/Makefile.am                    |   22 ++++++++++-
 maidag/maidag.c                         |    2 +-
 mail/decode.c                           |    1 -
 mail/mail.c                             |    2 +-
 mailbox/Makefile.am                     |    1 +
 mailbox/amd.c                           |   19 +--------
 mailbox/body.c                          |    6 +-
 mailbox/crlfflt.c                       |   60 ++++++++++++++++++++++------
 mailbox/file_stream.c                   |    4 +-
 mailbox/filter.c                        |    6 ++-
 mailbox/filter_iconv.c                  |    7 ++-
 mailbox/fltstream.c                     |   13 ++++--
 mailbox/header.c                        |   16 +-------
 mailbox/mapfile_stream.c                |   17 +-------
 mailbox/memory_stream.c                 |   17 +-------
 mailbox/message.c                       |   22 +----------
 mailbox/message_stream.c                |   17 +-------
 mailbox/mime.c                          |   15 +------
 mailbox/{stream_vprintf.c => nullrec.c} |   51 +++++++++++++----------
 mailbox/stdio_stream.c                  |   16 +-------
 mailbox/stream.c                        |   67 ++++++++++++++++++++++++++++++-
 mailbox/streamref.c                     |   23 +----------
 messages/messages.c                     |    3 +-
 mh/ali.c                                |    9 +----
 mh/anno.c                               |    9 +----
 mh/burst.c                              |    9 +----
 mh/comp.c                               |    9 +----
 mh/fmtcheck.c                           |    9 +----
 mh/folder.c                             |   10 +----
 mh/forw.c                               |   10 +----
 mh/inc.c                                |    9 +----
 mh/install-mh.c                         |    9 +----
 mh/mark.c                               |    9 +----
 mh/mh_argp.c                            |   45 ++++++++++++++++++++-
 mh/mh_getopt.h                          |    3 +-
 mh/mhl.c                                |    9 +----
 mh/mhn.c                                |    9 +----
 mh/mhparam.c                            |    9 +----
 mh/mhpath.c                             |    9 +----
 mh/pick.c                               |    9 +----
 mh/refile.c                             |    9 +----
 mh/repl.c                               |    9 +----
 mh/rmf.c                                |    9 +----
 mh/rmm.c                                |    9 +----
 mh/scan.c                               |   10 +----
 mh/send.c                               |    9 +----
 mh/sortm.c                              |   10 +----
 mh/whatnow.c                            |   10 +----
 mh/whom.c                               |   10 +----
 mimeview/mimeview.c                     |    3 +-
 movemail/movemail.c                     |    3 +-
 pop3d/pop3d.c                           |    2 +-
 pop3d/popauth.c                         |    8 +--
 readmsg/readmsg.c                       |    3 +-
 sieve/sieve.c                           |    4 +-
 77 files changed, 439 insertions(+), 529 deletions(-)
 delete mode 100644 libmu_argp/mu_argp.h
 copy mailbox/{stream_vprintf.c => nullrec.c} (54%)

diff --git a/.gitignore b/.gitignore
index 3f3f74e..a142bc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,8 @@ config.h.in
 config.log
 config.status
 configure
+git-describe
+git-describe.h
 libtool
 m4
 pathdefs.h
diff --git a/Makefile.am b/Makefile.am
index f6f53a9..81aefd2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -85,11 +85,11 @@ if MU_COND_LIBMU_SCM
   LIBMU_SCM_DIR = libmu_scm
 endif
 
-if MU_COND_LIBMU_CPP
+if MU_COND_SUPPORT_CXX
   LIBMU_CPP_DIR = libmu_cpp
 endif
 
-SUBDIRS = \
+SUBDIRS = . \
  mu-aux\
  include\
  po\
@@ -124,8 +124,8 @@ SUBDIRS = \
  $(MOVEMAIL_DIR)\
  $(MIMEVIEW_DIR)
 
-EXTRA_DIST = COPYING.LESSER paths
-
+EXTRA_DIST = COPYING.LESSER paths git-describe git-describe.h
+BUILT_SOURCES = git-describe git-describe.h
 DISTCLEANFILES = pathdefs.h
 
 gen_start_date = "2008-12-08"
@@ -155,12 +155,45 @@ ChangeLog:
 	  mv cl-t ChangeLog;                                               \
 	fi
 
-alpha:
-	$(MAKE) dist distdir=$(PACKAGE)-$(VERSION)-`date +"%Y%m%d"`
+.PHONY: git-describe
+git-describe:
+	$(AM_V_GEN)if test -d .git; then \
+		dirty=`git diff-index --name-only HEAD 2>/dev/null` || dirty=;\
+		test -n "$$dirty" && dirty="-dirty"; \
+		descr=`git describe`; \
+		echo $${descr}$$dirty > git-describe; \
+	fi
 
-alphacheck:
-	$(MAKE) distcheck distdir=$(PACKAGE)-$(VERSION)-`date +"%Y%m%d"`
+dist-hook: ChangeLog git-describe
+	@PATCHLEV=`echo "$(PACKAGE_VERSION)" | \
+                   sed -r "s/[0-9]+\.[0-9]+\.?//"`; \
+	if test $${PATCHLEV:-0} -lt 50; then \
+		if grep -q FIXME NEWS; then \
+			echo >&2 "NEWS file contains FIXMEs"; \
+			exit 1; \
+		fi; \
+	fi
+
+git-describe.h: git-describe
+	$(AM_V_GEN)if test -f $(srcdir)/git-describe; then \
+	  sed '1s/.*/#define GIT_DESCRIBE "&"/' $(srcdir)/git-describe; \
+	else \
+          echo "/* No git tag */"; \
+	fi > git-describe.h
+
+alpha: git-describe
+	$(AM_V_GEN)if test -f $(srcdir)/git-describe; then \
+	  tag=`head -n 1 $(srcdir)/git-describe`; \
+	else \
+	  tag=`date +"%Y%m%d"`; \
+	fi; \
+	$(MAKE) dist distdir=$(PACKAGE)-$(VERSION)-$$tag
 
-rpm: dist
-	rpm -ta --clean mailutils-$(VERSION).tar.gz
+alphacheck:
+	$(AM_V_GEN)if test -f $(srcdir)/git-describe; then \
+	  tag=`head -n 1 $(srcdir)/git-describe`; \
+	else \
+	  tag=`date +"%Y%m%d"`; \
+	fi; \
+	$(MAKE) distcheck distdir=$(PACKAGE)-$(VERSION)-$$tag
 
diff --git a/am/enable.m4 b/am/enable.m4
index faf3a31..e531c98 100644
--- a/am/enable.m4
+++ b/am/enable.m4
@@ -23,6 +23,7 @@ dnl                   [default-value])
 AC_DEFUN([MU_ENABLE_SUPPORT], [
 	pushdef([mu_upcase],translit($1,[a-z+-],[A-ZX_]))
 	pushdef([mu_cache_var],[mu_cv_enable_]translit($1,[+-],[x_]))
+	pushdef([mu_cond],[MU_COND_SUPPORT_]mu_upcase)
 
 	AC_ARG_ENABLE($1, 
 	              AC_HELP_STRING([--disable-]$1,
@@ -43,8 +44,11 @@ AC_DEFUN([MU_ENABLE_SUPPORT], [
 	if test x"[$]mu_cache_var" = x"yes"; then
 		AC_DEFINE([ENABLE_]mu_upcase,1,[Define this if you enable $1 support])
         fi
-	popdef([mu_upcase])
+	AM_CONDITIONAL(mu_cond,
+	               [test x"[$]mu_cache_var" = x"yes" ifelse($4,,,[&& $4])])
+	popdef([mu_cond])
 	popdef([mu_cache_var])
+	popdef([mu_upcase])
 ])
 
 dnl MU_ENABLE_BUILD(feature, [action-if-true], [action-if-false],
diff --git a/comsat/comsat.c b/comsat/comsat.c
index 82e8056..ca11efe 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -570,7 +570,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   comsat_init ();
   mu_acl_cfg_init ();
   mu_m_server_cfg_init ();
diff --git a/config/mailutils-config.c b/config/mailutils-config.c
index a5aeb4f..ccf55ab 100644
--- a/config/mailutils-config.c
+++ b/config/mailutils-config.c
@@ -25,7 +25,6 @@
 #include <mu_asprintf.h>
 #include "mailutils/libargp.h"
 
-const char *program_version = "mailutils-config (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU mailutils-config -- display compiler and loader options needed for building a program with mailutils.");
 static char args_doc[] = N_("[arg...]");
 
@@ -188,7 +187,7 @@ main (int argc, char **argv)
   mu_stream_t stream;
   int fmtflags = 0;
   
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
 
   mu_set_program_name (argv[0]);
   mu_libargp_init ();
diff --git a/configure.ac b/configure.ac
index ad31075..832b332 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,16 +40,16 @@ dnl Library paths
 AC_SUBST(MU_LIB_AUTH,'${top_builddir}/libmu_auth/libmu_auth.la')
 AC_SUBST(MU_LIB_MAILUTILS,'${top_builddir}/mailbox/libmailutils.la')
 AC_SUBST(MU_LIB_SQL,'${top_builddir}/sql/libsql.la')
-AC_SUBST(MU_LIB_IMAP,'${top_builddir}/libproto/imap/libmu_imap.la')
-AC_SUBST(MU_LIB_MAILDIR,'${top_builddir}/libproto/maildir/libmu_maildir.la')
+AC_SUBST(MU_LIB_IMAP)
+AC_SUBST(MU_LIB_MAILDIR)
 AC_SUBST(MU_LIB_MAILER,'${top_builddir}/libproto/mailer/libmu_mailer.la')
 AC_SUBST(MU_LIB_MBOX,'${top_builddir}/libproto/mbox/libmu_mbox.la')
-AC_SUBST(MU_LIB_MH,'${top_builddir}/libproto/mh/libmu_mh.la')
-AC_SUBST(MU_LIB_NNTP,'${top_builddir}/libproto/nntp/libmu_nntp.la')
-AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la')
+AC_SUBST(MU_LIB_MH)
+AC_SUBST(MU_LIB_NNTP)
+AC_SUBST(MU_LIB_POP)
 AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libmu_sieve/libmu_sieve.la')
-AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la')
-AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la')
+AC_SUBST(MU_LIB_SCM)
+AC_SUBST(MU_LIB_CPP)
 AC_SUBST(MU_LIB_ARGP,'${top_builddir}/libmu_argp/libmu_argp.la')
 AC_SUBST(MU_LIB_PY)
 
@@ -815,9 +815,17 @@ AC_ARG_WITH([virtual-pwddir],
 		*)  SITE_VIRTUAL_PWDDIR="\$(sysconfdir)/${withval}";;
 	     esac],
              [SITE_VIRTUAL_PWDDIR="\$(sysconfdir)/domain"])
-MU_ENABLE_SUPPORT(imap)
-MU_ENABLE_SUPPORT(pop)
-MU_ENABLE_SUPPORT(nntp)
+	     
+MU_ENABLE_SUPPORT([imap],
+         [MU_LIB_IMAP='${top_builddir}/libproto/imap/libmu_imap.la'])
+MU_ENABLE_SUPPORT([pop],
+         [MU_LIB_POP='${top_builddir}/libproto/pop/libmu_pop.la'])
+MU_ENABLE_SUPPORT([nntp],
+         [MU_LIB_NNTP='${top_builddir}/libproto/nntp/libmu_nntp.la'])
+MU_ENABLE_SUPPORT([mh],
+         [MU_LIB_MH='${top_builddir}/libproto/mh/libmu_mh.la'])
+MU_ENABLE_SUPPORT([maildir],
+         [MU_LIB_MAILDIR='${top_builddir}/libproto/maildir/libmu_maildir.la'])
 
 AC_SUBST(MU_SMTP_PROGRAMS_BUILD)
 AC_SUBST(MU_SMTP_DEJATOOL)
@@ -829,9 +837,6 @@ MU_ENABLE_SUPPORT(sendmail)
 
 MU_ENABLE_SUPPORT(prog)
 
-MU_ENABLE_SUPPORT(mh)
-
-MU_ENABLE_SUPPORT(maildir)
 
 # FIXME: Should be --with-radius 
 MU_ENABLE_SUPPORT(radius,
@@ -1083,6 +1088,7 @@ if test "$useguile" != "no"; then
 	    [useguile=yes
    	     AC_DEFINE([WITH_GUILE],1,[Enable Guile support])
              GUILE_BINDIR=`guile-config info bindir`
+	     MU_LIB_SCM='${top_builddir}/libmu_scm/libmu_scm.la'
              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'
@@ -1103,14 +1109,14 @@ fi
 AC_SUBST(lisp_LISP)
 
 # Check for Python
-AC_ARG_WITH([python],
-            AC_HELP_STRING([--without-python],
-                           [do not build Python interface]),
-            [
-case "${withval}" in
+AC_ARG_ENABLE([python],
+              AC_HELP_STRING([--disable-python],
+                             [do not build Python interface]),
+              [
+case "${enableval}" in
   yes) status_python=yes ;;
   no)  status_python=no ;;
-  *)   AC_MSG_ERROR(bad value ${withval} for --without-python) ;;
+  *)   AC_MSG_ERROR(bad value ${enableval} for --enable-python) ;;
 esac],[status_python=yes])
 
 AC_SUBST(PYTHON_LIBS)
@@ -1150,8 +1156,8 @@ AM_CONDITIONAL([MU_COND_PYTHON], [test "$status_python" = yes])
 
 AC_SUBST(MU_CXX_EXAMPLES_BUILD)
 MU_ENABLE_SUPPORT(cxx,
-  	          [MU_CXX_EXAMPLES_BUILD='$(MU_CXX_EXAMPLES_LIST)'])
-AM_CONDITIONAL([MU_COND_LIBMU_CPP], [test "$mu_cv_enable_cxx" = yes])
+  	          [MU_CXX_EXAMPLES_BUILD='$(MU_CXX_EXAMPLES_LIST)'
+                   MU_LIB_CPP='${top_builddir}/libmu_cpp/libmu_cpp.la'])
 
 # Default mailbox record
 # Note: 1. Support for mbox type is always enabled.
@@ -1236,12 +1242,13 @@ case `echo $VERSION|sed  's/[[^.]]//g'` in
 "..")  if test `echo $VERSION | sed  's/.*\.//'` -lt 50; then
 	 RENDITION=DISTRIB
        else
+         AC_DEFINE_UNQUOTED([MU_ALPHA_RELEASE], 1,
+	                    [Define if this is an alpha release])
          RENDITION=PROOF
        fi;;
 *)     RENDITION=PROOF;;
 esac
 
-
 AC_CONFIG_COMMANDS([status],[
 cat <<EOF
 
diff --git a/dotlock/dotlock.c b/dotlock/dotlock.c
index 6315b2d..d561d18 100644
--- a/dotlock/dotlock.c
+++ b/dotlock/dotlock.c
@@ -33,7 +33,6 @@
 
 #include "mailutils/libargp.h"
 
-const char *program_version = "GNU dotlock (" PACKAGE_STRING ")";
 static char doc[] =
 N_("GNU dotlock -- lock mail spool files.")
 "\v"
@@ -161,7 +160,7 @@ main (int argc, char *argv[])
 
   argp_err_exit_status = MU_DL_EX_ERROR;
   
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, dotlock_capa, dotlock_cfg_param, 
 		   argc, argv, 0, NULL, NULL))
     exit (1);
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 1e189a1..1ba0b87 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -18,7 +18,19 @@
 ##   Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
 ##   02110-1301 USA
 
-SUBDIRS = config cpp python scheme
+if MU_COND_SUPPORT_POP
+  POP3CLIENT = pop3client
+endif
+
+if MU_COND_SUPPORT_NNTP
+  NNTPCLIENT = nntpclient
+endif
+
+if MU_COND_SUPPORT_CXX
+  CPP_DIR = cpp
+endif
+
+SUBDIRS = config $(CPP_DIR) python scheme
 
 noinst_PROGRAMS = \
  aclck\
@@ -40,11 +52,13 @@ noinst_PROGRAMS = \
  muauth\
  muemail\
  murun\
- nntpclient\
- pop3client \
+ $(NNTPCLIENT)\
+ $(POP3CLIENT)\
  sfrom\
  url-parse
 
+EXTRA_PROGRAMS = pop3client nntpclient
+
 ## NOTE: Numaddr must be an installable target, otherwise libtool
 ## will not create a shared library and `make check' will fail in
 ## sieve. Pity.
diff --git a/examples/base64.c b/examples/base64.c
index 26e8795..3785a6a 100644
--- a/examples/base64.c
+++ b/examples/base64.c
@@ -53,8 +53,9 @@ main (int argc, char * argv [])
   int flags = MU_STREAM_READ;
   char *input = NULL, *output = NULL;
   char *encoding = "base64";
-    
-  while ((c = getopt (argc, argv, "deE:hi:o:pvw")) != EOF)
+  mu_off_t shift = 0;
+  
+  while ((c = getopt (argc, argv, "deE:hi:o:ps:vw")) != EOF)
     switch (c)
       {
       case 'i':
@@ -80,6 +81,10 @@ main (int argc, char * argv [])
       case 'p':
  	printable = 1; /* FIXME: Not implemented */
 	break;
+
+      case 's':
+	shift = strtoul (optarg, NULL, 0); 
+	break;
 	
       case 'v':
 	verbose = 1;
@@ -98,7 +103,7 @@ main (int argc, char * argv [])
       }
 
   if (input)
-    MU_ASSERT (mu_file_stream_create (&in, input, MU_STREAM_READ));
+    MU_ASSERT (mu_file_stream_create (&in, input, MU_STREAM_READ|MU_STREAM_SEEK));
   else
     MU_ASSERT (mu_stdio_stream_create (&in, MU_STDIN_FD, 0));
   MU_ASSERT (mu_stream_open (in));
@@ -112,13 +117,18 @@ main (int argc, char * argv [])
 
   if (flags == MU_STREAM_READ)
     {
-      MU_ASSERT (mu_filter_create (&flt, in, encoding, mode, MU_STREAM_READ));
+      MU_ASSERT (mu_filter_create (&flt, in, encoding, mode,
+				   MU_STREAM_READ|MU_STREAM_SEEK));
+      if (shift)
+	MU_ASSERT (mu_stream_seek (flt, shift, MU_SEEK_SET, NULL));
       c_copy (out, flt);
     }
   else
     {
       MU_ASSERT (mu_filter_create (&flt, out, encoding, mode,
 				   MU_STREAM_WRITE));
+      if (shift)
+	MU_ASSERT (mu_stream_seek (in, shift, MU_SEEK_SET, NULL));
       c_copy (flt, in);
     }
       
diff --git a/examples/muauth.c b/examples/muauth.c
index 23ba521..c771ebf 100644
--- a/examples/muauth.c
+++ b/examples/muauth.c
@@ -27,7 +27,6 @@
 #include <mailutils/mailutils.h>
 #include "mailutils/libargp.h"
 
-const char *program_version = "muauth (" PACKAGE_STRING ")";
 static char doc[] =
 "muauth -- test mailutils authentication and authorization schemes";
 static char args_doc[] = "key";
@@ -91,7 +90,7 @@ main (int argc, char * argv [])
   uid_t uid;
   
   MU_AUTH_REGISTER_ALL_MODULES ();
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &index, NULL))
     exit (1);
 
diff --git a/frm/frm.c b/frm/frm.c
index b56bff2..f978560 100644
--- a/frm/frm.c
+++ b/frm/frm.c
@@ -31,7 +31,6 @@ static int align = 0;      /* Tidy mode. -t option. */
 #define IS_NEW  0x100
 static int select_attribute;
 
-const char *program_version = "frm (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU frm -- display From: lines.");
 
 static struct attr_tab {
@@ -358,7 +357,7 @@ main (int argc, char **argv)
   mu_gocs_register ("tls", mu_tls_module_init);
 #endif
   
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, frm_argp_capa, NULL, argc, argv, 0, &c, NULL))
     exit (1);
 
diff --git a/frm/from.c b/frm/from.c
index 080b548..6b9fdf8 100644
--- a/frm/from.c
+++ b/frm/from.c
@@ -23,7 +23,6 @@ int count_only;
 char *sender_option;
 char *mailbox_name;
 
-const char *program_version = "from (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU from -- display from and subject.");
 
 static struct argp_option options[] = {
@@ -120,7 +119,7 @@ main (int argc, char **argv)
   mu_gocs_register ("tls", mu_tls_module_init);
 #endif
 
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &c, NULL))
     exit (1);
 
diff --git a/guimb/main.c b/guimb/main.c
index 460c6bd..f08d450 100644
--- a/guimb/main.c
+++ b/guimb/main.c
@@ -122,7 +122,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
   return 0;
 }
 
-const char *program_version = "guimb (" PACKAGE_STRING ")";
 static char doc[] =
 N_("GNU guimb -- process contents of the specified mailboxes "
 "using a Scheme program or expression.");
@@ -161,7 +160,7 @@ main (int argc, char *argv[])
   /* Register the desired formats. */
   mu_register_all_formats ();
 
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c))
     exit (1);
 
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index 195c4af..b180206 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -503,7 +503,7 @@ main (int argc, char **argv)
   mu_acl_cfg_init ();
   mu_m_server_cfg_init ();
   
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
 
   mu_m_server_create (&server, program_version);
   mu_m_server_set_conn (server, imap4d_connection);
diff --git a/include/mailutils/Makefile.am b/include/mailutils/Makefile.am
index d1261d2..098a9fa 100644
--- a/include/mailutils/Makefile.am
+++ b/include/mailutils/Makefile.am
@@ -98,7 +98,7 @@ pkginclude_HEADERS = \
  vartab.h\
  version.h
 
-if MU_COND_LIBMU_CPP
+if MU_COND_SUPPORT_CXX
   CPP_DIR = cpp
 endif
 
diff --git a/include/mailutils/filter.h b/include/mailutils/filter.h
index 01a80cd..03c43c2 100644
--- a/include/mailutils/filter.h
+++ b/include/mailutils/filter.h
@@ -60,7 +60,7 @@ enum mu_filter_result
     mu_filter_moreoutput,
   };
   
-typedef void *(*mu_filter_new_data_t) (void *);
+typedef int (*mu_filter_new_data_t) (void **, int, void *);
 typedef enum mu_filter_result (*mu_filter_xcode_t) (void *data,
 						    enum mu_filter_command cmd,
 						    struct mu_filter_io *iobuf);
diff --git a/include/mailutils/libargp.h b/include/mailutils/libargp.h
index e96df3a..c0317be 100644
--- a/include/mailutils/libargp.h
+++ b/include/mailutils/libargp.h
@@ -75,6 +75,7 @@ void mu_argp_init (const char *vers, const char *bugaddr);
 int mu_app_init (struct argp *myargp, const char **capa,
 		 struct mu_cfg_param *cfg_param, 
 		 int argc, char **argv, int flags, int *pindex, void *data);
+extern void mu_program_version_hook (FILE *stream, struct argp_state *state);
 
 error_t mu_argp_parse (const struct argp *myargp, 
 		       int *pargc, char **pargv[],  
diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index cdc55e7..1aee884 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -71,6 +71,9 @@ void mu_stream_clearerr (mu_stream_t stream);
 int mu_stream_eof (mu_stream_t stream);
 int mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
 		    mu_off_t *pres);
+int mu_stream_skip_input_bytes (mu_stream_t stream, mu_off_t count,
+				mu_off_t *pres);
+
 int mu_stream_set_buffer (mu_stream_t stream, enum mu_buffer_type type,
 			  size_t size);
 int mu_stream_read (mu_stream_t stream, void *buf, size_t size, size_t *pread);
diff --git a/include/mailutils/sys/stream.h b/include/mailutils/sys/stream.h
index e63d60d..90de02f 100644
--- a/include/mailutils/sys/stream.h
+++ b/include/mailutils/sys/stream.h
@@ -47,7 +47,7 @@ struct _mu_stream
   int (*open) (struct _mu_stream *);
   int (*close) (struct _mu_stream *);
   void (*done) (struct _mu_stream *);
-  int (*seek) (struct _mu_stream *, mu_off_t, int, mu_off_t *);
+  int (*seek) (struct _mu_stream *, mu_off_t, mu_off_t *);
   int (*size) (struct _mu_stream *, mu_off_t *);
   int (*ctl) (struct _mu_stream *, int, void *);
   int (*wait) (struct _mu_stream *, int *, struct timeval *);
diff --git a/libmu_argp/Makefile.am b/libmu_argp/Makefile.am
index 3106f5c..87fd420 100644
--- a/libmu_argp/Makefile.am
+++ b/libmu_argp/Makefile.am
@@ -32,7 +32,6 @@ libmu_argp_a_SOURCES =\
  cmdline.h\
  common.c\
  compat.c\
- mu_argp.h\
  mu_argp.c\
  muinit.c\
  sieve.c\
diff --git a/libmu_argp/mu_argp.h b/libmu_argp/mu_argp.h
deleted file mode 100644
index 804f46c..0000000
--- a/libmu_argp/mu_argp.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* 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, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
-
-#ifndef _MAILUTILS_ARGP_H
-#define _MAILUTILS_ARGP_H
-
-#include <mailutils/types.h>
-#include <argp.h>
-#include <errno.h> /* May declare program_invocation_name */
-
-extern char *mu_license_text;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void mu_argp_init (struct argp *argp, const char *vers,
-			  const char *bugaddr, const char *capa[]);
-extern void mu_argp_done (struct argp *argp);
-  
-extern int mu_register_argp_capa (const char *name, struct argp_child *child);
-
-extern void mu_print_options (void);
-  
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/libmu_argp/muinit.c b/libmu_argp/muinit.c
index 6ed95d5..805fc30 100644
--- a/libmu_argp/muinit.c
+++ b/libmu_argp/muinit.c
@@ -25,13 +25,48 @@
 #include <mailutils/stream.h>
 #include "xalloc.h"
 #include <string.h>
-
+#ifdef MU_ALPHA_RELEASE
+# include <git-describe.h>
+#endif
 struct mu_cfg_tree *mu_argp_tree;
 
+const char version_etc_copyright[] =
+  /* Do *not* mark this string for translation.  %s is a copyright
+     symbol suitable for this locale, and %d is the copyright
+     year.  */
+  "Copyright %s 2010 Free Software Foundation, inc.";
+
+void
+mu_program_version_hook (FILE *stream, struct argp_state *state)
+{
+#ifdef GIT_DESCRIBE
+  fprintf (stream, "%s (%s) %s [%s]\n",
+	   mu_program_name, PACKAGE_NAME, PACKAGE_VERSION, GIT_DESCRIBE);
+#else
+  fprintf (stream, "%s (%s) %s\n", mu_program_name,
+	   PACKAGE_NAME, PACKAGE_VERSION);
+#endif
+  /* TRANSLATORS: Translate "(C)" to the copyright symbol
+     (C-in-a-circle), if this symbol is available in the user's
+     locale.  Otherwise, do not translate "(C)"; leave it as-is.  */
+  fprintf (stream, version_etc_copyright, _("(C)"));
+
+  fputs (_("\
+\n\
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\n\
+There is NO WARRANTY, to the extent permitted by law.\n\
+\n\
+"),
+	 stream);
+}
+
 void
 mu_argp_init (const char *vers, const char *bugaddr)
 {
-  argp_program_version = vers ? vers : PACKAGE_STRING;
+  if (vers)
+    argp_program_version = vers;
+  else
+    argp_program_version_hook = mu_program_version_hook;
   argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">";
 }
 
diff --git a/libproto/Makefile.am b/libproto/Makefile.am
index 314cfb7..30a423d 100644
--- a/libproto/Makefile.am
+++ b/libproto/Makefile.am
@@ -17,5 +17,25 @@
 ##   Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
 ##   02110-1301 USA
 
-SUBDIRS = include mbox pop nntp imap mh maildir mailer
+if MU_COND_SUPPORT_POP
+  POP_DIR = pop
+endif
+
+if MU_COND_SUPPORT_IMAP
+  IMAP_DIR = imap
+endif
+
+if MU_COND_SUPPORT_NNTP
+  NNTP_DIR = nntp
+endif
+
+if MU_COND_SUPPORT_MH
+  MH_DIR = mh
+endif
+
+if MU_COND_SUPPORT_MAILDIR
+  MAILDIR_DIR = maildir
+endif
+
+SUBDIRS = include mbox $(POP_DIR) $(NNTP_DIR) $(IMAP_DIR) $(MH_DIR) $(MAILDIR_DIR) mailer
 
diff --git a/maidag/maidag.c b/maidag/maidag.c
index ea04f07..894fa61 100644
--- a/maidag/maidag.c
+++ b/maidag/maidag.c
@@ -518,7 +518,7 @@ main (int argc, char *argv[])
   maidag_cfg_init ();
   
   /* Parse command line */
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
 
   mu_m_server_create (&server, program_version);
   mu_m_server_set_conn (server, lmtp_connection);
diff --git a/mail/decode.c b/mail/decode.c
index f0212cd..0acceaf 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -318,7 +318,6 @@ print_stream (mu_stream_t stream, FILE *out)
 {
   char buffer[512];
   size_t n = 0;
-  int rc;
   
   while (mu_stream_read (stream, buffer, sizeof (buffer) - 1, &n) == 0
 	 && n != 0)
diff --git a/mail/mail.c b/mail/mail.c
index afeb4e1..dba26a2 100644
--- a/mail/mail.c
+++ b/mail/mail.c
@@ -394,7 +394,7 @@ main (int argc, char **argv)
 #ifdef WITH_TLS
   mu_gocs_register ("tls", mu_tls_module_init);
 #endif
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, mail_capa, NULL, argc, argv, 0, NULL, &args))
     exit (1);
   
diff --git a/mailbox/Makefile.am b/mailbox/Makefile.am
index 1946fda..0d04930 100644
--- a/mailbox/Makefile.am
+++ b/mailbox/Makefile.am
@@ -114,6 +114,7 @@ libmailutils_la_SOURCES = \
  muerror.c\
  muerrno.c\
  nls.c\
+ nullrec.c\
  observer.c\
  opool.c\
  parse822.c\
diff --git a/mailbox/amd.c b/mailbox/amd.c
index d5ff6d5..450c7c0 100644
--- a/mailbox/amd.c
+++ b/mailbox/amd.c
@@ -122,7 +122,7 @@ static int amd_body_stream_readdelim (mu_stream_t is,
 				      int delim,
 				      size_t *pnread);
 static int amd_body_stream_size (mu_stream_t str, mu_off_t *psize);
-static int amd_body_stream_seek (mu_stream_t str, mu_off_t off, int whence,
+static int amd_body_stream_seek (mu_stream_t str, mu_off_t off, 
 				 mu_off_t *presult);
 
 struct _amd_body_stream
@@ -1703,27 +1703,12 @@ amd_body_stream_readdelim (mu_stream_t is, char *buffer, size_t buflen,
 }
 
 static int
-amd_body_stream_seek (mu_stream_t str, mu_off_t off, int whence,
-		      mu_off_t *presult)
+amd_body_stream_seek (mu_stream_t str, mu_off_t off, mu_off_t *presult)
 {
   size_t size;
   struct _amd_body_stream *amdstr = (struct _amd_body_stream *)str;
-  mu_message_t msg = mu_body_get_owner (amdstr->body);
   
   amd_body_size (amdstr->body, &size);
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      off += amdstr->off;
-      break;
-
-    case MU_SEEK_END:
-      off += size;
-      break;
-    }
 
   if (off < 0 || off >= size)
     return ESPIPE;
diff --git a/mailbox/body.c b/mailbox/body.c
index 01f14f0..8c5dba1 100644
--- a/mailbox/body.c
+++ b/mailbox/body.c
@@ -44,7 +44,7 @@ static int _body_truncate (mu_stream_t, mu_off_t);
 static int _body_size     (mu_stream_t, mu_off_t *);
 static int _body_write    (mu_stream_t, const char *, size_t, size_t *);
 static int _body_ioctl    (mu_stream_t, int, void *);
-static int _body_seek     (mu_stream_t, mu_off_t, int, mu_off_t *);
+static int _body_seek     (mu_stream_t, mu_off_t, mu_off_t *);
 static const char *_body_error_string (mu_stream_t, int);
 
 /* Our own defaults for the body.  */
@@ -281,11 +281,11 @@ mu_body_set_size (mu_body_t body, int (*_size)(mu_body_t, size_t*) , void *owner
 /* Stub function for the body stream.  */
 
 static int
-_body_seek (mu_stream_t stream, mu_off_t off, int whence, mu_off_t *presult)
+_body_seek (mu_stream_t stream, mu_off_t off, 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->fstream, off, whence, presult);
+  return mu_stream_seek (body->fstream, off, MU_SEEK_SET, presult);
 }
 
 static const char *
diff --git a/mailbox/crlfflt.c b/mailbox/crlfflt.c
index 3e9bab0..9dc147c 100644
--- a/mailbox/crlfflt.c
+++ b/mailbox/crlfflt.c
@@ -22,11 +22,16 @@
 #include <mailutils/errno.h>
 #include <mailutils/filter.h>
 
+enum crlf_state
+{
+  state_init,
+  state_cr
+};
+  
 /* Move min(isize,osize) bytes from iptr to optr, replacing each \n
-   with \r\n.  Store number of bytes written to optr in *pnbytes.
-   Return number of bytes read from iptr. */
+   with \r\n.  Any input \r\n sequences remain untouched. */
 static enum mu_filter_result
-_crlf_encoder (void *xd MU_ARG_UNUSED,
+_crlf_encoder (void *xd,
 	       enum mu_filter_command cmd,
 	       struct mu_filter_io *iobuf)
 {
@@ -35,10 +40,12 @@ _crlf_encoder (void *xd MU_ARG_UNUSED,
   size_t isize;
   char *optr;
   size_t osize;
-
+  enum crlf_state *state = xd;
+  
   switch (cmd)
     {
     case mu_filter_init:
+      *state = state_init;
     case mu_filter_done:
       return mu_filter_ok;
     default:
@@ -55,7 +62,12 @@ _crlf_encoder (void *xd MU_ARG_UNUSED,
       unsigned char c = *iptr++;
       if (c == '\n')
 	{
-	  if (j + 1 == osize)
+	  if (*state == state_cr)
+	    {
+	      *state = state_init;
+	      optr[j++] = c;
+	    }
+	  else if (j + 1 == osize)
 	    {
 	      if (i == 0)
 		{
@@ -64,10 +76,17 @@ _crlf_encoder (void *xd MU_ARG_UNUSED,
 		}
 	      break;
 	    }
-	  optr[j++] = '\r';
-	  optr[j++] = '\n';
+	  else
+	    {
+	      optr[j++] = '\r';
+	      optr[j++] = '\n';
+	    }
+	}
+      else if (c == '\r')
+	{
+	  *state = state_cr;
+	  optr[j++] = c;
 	}
-      /*else if (c == '\r')*/
       else
 	optr[j++] = c;
     }
@@ -77,8 +96,7 @@ _crlf_encoder (void *xd MU_ARG_UNUSED,
 }
 
 /* Move min(isize,osize) bytes from iptr to optr, replacing each \r\n
-   with \n.  Store number of bytes written to optr in *pnbytes.
-   Return number of bytes read from iptr. */
+   with \n. */
 static enum mu_filter_result
 _crlf_decoder (void *xd MU_ARG_UNUSED,
 	       enum mu_filter_command cmd,
@@ -121,10 +139,28 @@ _crlf_decoder (void *xd MU_ARG_UNUSED,
   return mu_filter_ok;
 }
 
+static int
+alloc_state (void **pret, int mode, void *data MU_ARG_UNUSED)
+{
+  switch (mode)
+    {
+    case MU_FILTER_ENCODE:
+      *pret = malloc (sizeof (int));
+      if (!*pret)
+	return ENOMEM;
+      break;
+
+    case MU_FILTER_DECODE:
+      *pret = NULL;
+    }
+  return 0;
+}
+  
+
 static struct _mu_filter_record _crlf_filter = {
   "CRLF",
   0,
-  NULL,
+  alloc_state,
   _crlf_encoder,
   _crlf_decoder
 };
@@ -136,7 +172,7 @@ mu_filter_record_t mu_crlf_filter = &_crlf_filter;
 static struct _mu_filter_record _rfc822_filter = {
   "RFC822",
   0,
-  NULL,
+  alloc_state,
   _crlf_encoder,
   _crlf_decoder
 };
diff --git a/mailbox/file_stream.c b/mailbox/file_stream.c
index abf63ac..c97075f 100644
--- a/mailbox/file_stream.c
+++ b/mailbox/file_stream.c
@@ -148,10 +148,10 @@ fd_open (struct _mu_stream *str)
 }
 
 int
-fd_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presult)
+fd_seek (struct _mu_stream *str, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_file_stream *fstr = (struct _mu_file_stream *) str;
-  off = lseek (fstr->fd, off, whence);
+  off = lseek (fstr->fd, off, SEEK_SET);
   if (off < 0)
     return errno;
   *presult = off;
diff --git a/mailbox/filter.c b/mailbox/filter.c
index ddefb95..3a12b56 100644
--- a/mailbox/filter.c
+++ b/mailbox/filter.c
@@ -169,7 +169,11 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name,
     return status;
 
   if (frec->newdata)
-    xdata = frec->newdata (NULL);
+    {
+      status = frec->newdata (&xdata, mode, NULL);
+      if (status)
+	return status;
+    }
 
   status = ((flags & MU_STREAM_WRITE) ? filter_create_wr : filter_create_rd)
                    (pstream, stream,
diff --git a/mailbox/filter_iconv.c b/mailbox/filter_iconv.c
index 802c35d..8d34285 100644
--- a/mailbox/filter_iconv.c
+++ b/mailbox/filter_iconv.c
@@ -415,11 +415,12 @@ _icvt_wait (mu_stream_t stream, int *pflags, struct timeval *tvp)
   return mu_stream_wait (s->transport, pflags, tvp);
 }
 
+/* FIXME: Seeks in the *transport* stream. */
 int
-_icvt_seek (mu_stream_t stream, mu_off_t off, int whence, mu_off_t *presult)
+_icvt_seek (mu_stream_t stream, mu_off_t off, mu_off_t *presult)
 {
   struct icvt_stream *s = (struct icvt_stream *)stream;
-  return mu_stream_seek (s->transport, off, whence, presult);
+  return mu_stream_seek (s->transport, off, MU_SEEK_SET, presult);
 }
 
 int
@@ -462,6 +463,6 @@ mu_filter_iconv_create (mu_stream_t *s, mu_stream_t transport,
   iptr->stream.ctl = _icvt_ioctl;
   iptr->stream.wait = _icvt_wait;
   iptr->stream.seek = _icvt_seek;
-  *s = iptr;
+  *s = (mu_stream_t)iptr;
   return 0;
 }
diff --git a/mailbox/fltstream.c b/mailbox/fltstream.c
index 858928b..99b5a47 100644
--- a/mailbox/fltstream.c
+++ b/mailbox/fltstream.c
@@ -314,11 +314,16 @@ filter_wr_flush (mu_stream_t stream)
 }
 
 static int
-filter_seek (struct _mu_stream *stream, mu_off_t off, int whence,
-	     mu_off_t *ppos)
+filter_seek (struct _mu_stream *stream, mu_off_t off, mu_off_t *ppos)
 {
   struct _mu_filter_stream *fs = (struct _mu_filter_stream *)stream;
-  return mu_stream_seek (fs->transport, off, whence, ppos);
+  int status;
+
+  status = mu_stream_seek (fs->transport, 0, MU_SEEK_SET, NULL);
+  if (status)
+    return status;
+  stream->offset = 0;
+  return mu_stream_skip_input_bytes (stream, off, ppos);
 }
 
 static int
@@ -392,7 +397,7 @@ mu_filter_stream_create (mu_stream_t *pflt,
 
   if ((flags & MU_STREAM_RDWR) == MU_STREAM_RDWR
       || !(flags & MU_STREAM_RDWR)
-      || (flags & MU_STREAM_SEEK))
+      || (flags & (MU_STREAM_WRITE|MU_STREAM_SEEK)) == (MU_STREAM_WRITE|MU_STREAM_SEEK))
     return EINVAL;
  
   fs = (struct _mu_filter_stream *) _mu_stream_create (sizeof (*fs), flags);
diff --git a/mailbox/header.c b/mailbox/header.c
index 4ad57ec..9c8fb9f 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -931,24 +931,10 @@ mu_hdrent_unroll_fixup (mu_header_t hdr, struct mu_hdrent *ent)
 }
 
 int
-header_seek (mu_stream_t str, mu_off_t off, int whence, mu_off_t *presult)
+header_seek (mu_stream_t str, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_header_stream *hstr = (struct _mu_header_stream *) str;
 
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      off += hstr->off;
-      break;
-
-    case MU_SEEK_END:
-      off += hstr->hdr->size;
-      break;
-    }
-
   if (off < 0 || off > hstr->hdr->size)
     return ESPIPE;
   hstr->off = off;
diff --git a/mailbox/mapfile_stream.c b/mailbox/mapfile_stream.c
index a54c65c..94d3f52 100644
--- a/mailbox/mapfile_stream.c
+++ b/mailbox/mapfile_stream.c
@@ -312,25 +312,10 @@ _mapfile_open (mu_stream_t stream)
 }
 
 static int
-_mapfile_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presult)
+_mapfile_seek (struct _mu_stream *str, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_mapfile_stream *mfs = (struct _mu_mapfile_stream *) str;
   
-  /* FIXME */
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      off += mfs->offset;
-      break;
-
-    case MU_SEEK_END:
-      off += mfs->size;
-      break;
-    }
-
   if (off < 0 || off >= mfs->size)
     return ESPIPE;
   mfs->offset = off;
diff --git a/mailbox/memory_stream.c b/mailbox/memory_stream.c
index 8e93e7b..ecb091f 100644
--- a/mailbox/memory_stream.c
+++ b/mailbox/memory_stream.c
@@ -166,24 +166,9 @@ _memory_ioctl (struct _mu_stream *stream, int code, void *ptr)
 }
 
 static int
-_memory_seek (struct _mu_stream *stream, mu_off_t off, int whence,
-	      mu_off_t *presult)
+_memory_seek (struct _mu_stream *stream, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_memory_stream *mfs = (struct _mu_memory_stream *) stream;
-  
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      off += mfs->offset;
-      break;
-
-    case MU_SEEK_END:
-      off += mfs->size;
-      break;
-    }
 
   if (off < 0)
     return ESPIPE;
diff --git a/mailbox/message.c b/mailbox/message.c
index 4f93fa3..8111b48 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -149,8 +149,7 @@ _message_stream_size (struct _mu_stream *str, mu_off_t *psize)
 }
 
 static int
-_message_stream_seek (struct _mu_stream *str, mu_off_t off, int whence,
-		      mu_off_t *ppos)
+_message_stream_seek (struct _mu_stream *str, mu_off_t off, mu_off_t *ppos)
 {
   struct _mu_message_stream *sp = (struct _mu_message_stream *)str;
   size_t hsize, size;
@@ -163,25 +162,6 @@ _message_stream_seek (struct _mu_stream *str, mu_off_t off, int whence,
   mu_body_size (sp->msg->body, &size);
   size += hsize;
   
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      {
-	mu_off_t cur;
-	rc = mu_stream_seek (sp->transport, 0, MU_SEEK_CUR, &cur);
-	if (rc)
-	  return rc;
-	off += cur;
-      }
-      break;
-
-    case MU_SEEK_END:
-      off += size;
-      break;
-    }
   if (off < 0 || off >= size)
     return ESPIPE;
 
diff --git a/mailbox/message_stream.c b/mailbox/message_stream.c
index 6b3cb7d..cfcd2dd 100644
--- a/mailbox/message_stream.c
+++ b/mailbox/message_stream.c
@@ -303,27 +303,12 @@ _message_done (mu_stream_t stream)
 }
 
 static int
-_message_seek (struct _mu_stream *stream, mu_off_t off, int whence,
-	       mu_off_t *presult)
+_message_seek (struct _mu_stream *stream, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_message_stream *s = (struct _mu_message_stream*) stream;
   mu_off_t size;
 
   mu_stream_size (stream, &size);
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      off += s->offset;
-      break;
-
-    case MU_SEEK_END:
-      off += size;
-      break;
-    }
-
   if (off < 0 || off >= size)
     return ESPIPE;
   s->offset = off;
diff --git a/mailbox/mime.c b/mailbox/mime.c
index b5db70c..f6f6d75 100644
--- a/mailbox/mime.c
+++ b/mailbox/mime.c
@@ -537,24 +537,11 @@ struct _mime_body_stream
 
 /* FIXME: The seek method is defective */
 static int
-_mime_body_seek (mu_stream_t stream, mu_off_t off, int whence,
-		 mu_off_t *presult)
+_mime_body_seek (mu_stream_t stream, mu_off_t off, mu_off_t *presult)
 {
   struct _mime_body_stream *mstr = (struct _mime_body_stream *)stream;
   mu_mime_t mime = mstr->mime;
 
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      off += mime->cur_offset;
-
-    case MU_SEEK_END:
-      return ESPIPE;
-    }
-    
   if (off == 0)
     {				/* reset message */
       mime->cur_offset = 0;
diff --git a/mailbox/stream_vprintf.c b/mailbox/nullrec.c
similarity index 54%
copy from mailbox/stream_vprintf.c
copy to mailbox/nullrec.c
index db0bff3..9d080cd 100644
--- a/mailbox/stream_vprintf.c
+++ b/mailbox/nullrec.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2004, 
+   2005, 2006, 2007, 2008, 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
@@ -14,29 +15,35 @@
    You should have received a copy of the GNU Lesser General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
+/* This file provides replacement definitions for mu_record_t defined
+   in those MU libraries which are disabled at configure time. */
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-#include <mailutils/types.h>
-#include <mailutils/stream.h>
-#include <mailutils/io.h>
+
 #include <stdlib.h>
-#include <string.h>
-
-int
-mu_stream_vprintf (mu_stream_t str, const char *fmt, va_list ap)
-{
-  char *buf = NULL;
-  size_t buflen = 0;
-  size_t n;
-  int rc;
-
-  rc = mu_vasnprintf (&buf, &buflen, fmt, ap);
-  if (rc)
-    return rc;
-  n = strlen (buf);
-  rc = mu_stream_write (str, buf, n, NULL);
-  free (buf);
-  return rc == 0 ? n : -1;
-}
+#include <mailutils/types.h>
+#include <mailutils/registrar.h>
+
+#ifndef ENABLE_IMAP
+mu_record_t mu_imap_record = NULL;
+mu_record_t mu_imaps_record = NULL;
+#endif
+
+#ifndef ENABLE_POP
+mu_record_t mu_pop_record = NULL;
+mu_record_t mu_pops_record = NULL;
+#endif
+
+#ifndef ENABLE_NNTP
+mu_record_t mu_nntp_record = NULL;
+#endif
+
+#ifndef ENABLE_MH
+mu_record_t mu_mh_record = NULL;
+#endif
+
+#ifndef ENABLE_MAILDIR
+mu_record_t mu_maildir_record = NULL;
+#endif
 
diff --git a/mailbox/stdio_stream.c b/mailbox/stdio_stream.c
index dac196c..ae77d12 100644
--- a/mailbox/stdio_stream.c
+++ b/mailbox/stdio_stream.c
@@ -128,23 +128,9 @@ stdio_size (struct _mu_stream *str, off_t *psize)
 }
 
 static int
-stdio_seek (struct _mu_stream *str, mu_off_t off, int whence, mu_off_t *presult)
+stdio_seek (struct _mu_stream *str, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_stdio_stream *fs = (struct _mu_stdio_stream *) str;
-  /* FIXME */
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      off += fs->offset;
-      break;
-
-    case MU_SEEK_END:
-      off += fs->size;
-      break;
-    }
 
   if (off < 0)
     return ESPIPE;
diff --git a/mailbox/stream.c b/mailbox/stream.c
index 4e74caf..2bc2117 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -323,7 +323,7 @@ mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
     {
       if ((rc = _stream_flush_buffer (stream, 1)))
 	return rc;
-      rc = stream->seek (stream, offset, MU_SEEK_SET, &stream->offset);
+      rc = stream->seek (stream, offset, &stream->offset);
       if (rc)
 	return _stream_seterror (stream, rc, 1);
       _stream_cleareof (stream);
@@ -334,6 +334,71 @@ mu_stream_seek (mu_stream_t stream, mu_off_t offset, int whence,
   return 0;
 }
 
+/* Skip COUNT bytes from the current position in stream by reading from
+   it.  Return new offset in PRES.
+
+   Return 0 on success, EACCES if STREAM was not opened for reading.
+   Another non-zero exit codes are propagated from the underlying
+   input operations.
+   
+   This function is designed to help implement seek method in otherwise
+   unseekable streams (such as filters).  Do not use it if you absolutely
+   have to.  Using it on an unbuffered stream is a terrible waste of CPU. */
+int
+mu_stream_skip_input_bytes (mu_stream_t stream, mu_off_t count, mu_off_t *pres)
+{
+  mu_off_t pos;
+  int rc;
+
+  if (!(stream->flags & MU_STREAM_READ))
+    return _stream_seterror (stream, EACCES, 1);
+
+  if (stream->buftype == mu_buffer_none)
+    {
+      for (pos = 0; pos < count; pos++)
+	{
+	  char c;
+	  size_t nrd;
+	  rc = mu_stream_read (stream, &c, 1, &nrd);
+	  if (nrd == 0)
+	    rc = ESPIPE;
+	  if (rc)
+	    break;
+	}
+    }
+  else
+    {
+      if ((rc = _stream_flush_buffer (stream, 1)))
+	return rc;
+      for (pos = 0;;)
+	{
+	  if (stream->level == 0)
+	    {
+	      rc = _stream_fill_buffer (stream);
+	      if (rc)
+		break;
+	      if (stream->level == 0)
+		{
+		  rc = ESPIPE;
+		  break;
+		}
+	    }
+	  if (pos <= count && count < pos + stream->level)
+	    {
+	      rc = 0;
+	      stream->cur = stream->buffer + count - pos;
+	      pos = count;
+	      break;
+	    }
+	}
+    }
+  
+  stream->offset += pos;
+  if (pres)
+    *pres = stream->offset;
+  return rc;
+}
+
 int
 mu_stream_set_buffer (mu_stream_t stream, enum mu_buffer_type type,
 		      size_t size)
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index de5fec8..4949a85 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -153,11 +153,9 @@ _streamref_done (struct _mu_stream *str)
 }
 
 static int
-_streamref_seek (struct _mu_stream *str, mu_off_t off, int whence,
-		 mu_off_t *ppos)
+_streamref_seek (struct _mu_stream *str, mu_off_t off, mu_off_t *ppos)
 {
   struct _mu_streamref *sp = (struct _mu_streamref *)str;
-  mu_off_t cur = sp->offset - sp->start;
   mu_off_t size;
   int rc;
   
@@ -171,25 +169,6 @@ _streamref_seek (struct _mu_stream *str, mu_off_t off, int whence,
       size -= sp->start;
     }
   
-  switch (whence)
-    {
-    case MU_SEEK_SET:
-      break;
-
-    case MU_SEEK_CUR:
-      if (off == 0)
-	{
-	  *ppos = sp->offset - sp->start;
-	  return 0;
-	}
-      off += cur;
-      break;
-
-    case MU_SEEK_END:
-      off += size;
-      break;
-    }
-
   if (off < 0 || off >= size)
     return sp->stream.last_err = ESPIPE;
   rc = mu_stream_seek (sp->transport, sp->start + off, MU_SEEK_SET,
diff --git a/messages/messages.c b/messages/messages.c
index 292f59c..62c38b8 100644
--- a/messages/messages.c
+++ b/messages/messages.c
@@ -31,7 +31,6 @@
 
 static int messages_count (const char *);
 
-const char *program_version = "messages (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU messages -- count the number of messages in a mailbox");
 static char args_doc[] = N_("[mailbox...]");
 
@@ -112,7 +111,7 @@ main (int argc, char **argv)
 #ifdef WITH_TLS
   mu_gocs_register ("tls", mu_tls_module_init);
 #endif
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, NULL, &args))
     exit (1);
 
diff --git a/mh/ali.c b/mh/ali.c
index 851ee1a..7c6964a 100644
--- a/mh/ali.c
+++ b/mh/ali.c
@@ -26,7 +26,6 @@
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 
-const char *program_version = "ali (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH ali")"\v"
 N_("Options marked with `*' are not yet implemented.\n"
 "Use -help to obtain the list of traditional MH options.");
@@ -44,8 +43,6 @@ static struct argp_option options[] = {
    N_("try to determine the official hostname for each address") },
   {"user", ARG_USER, N_("BOOL"),  OPTION_ARG_OPTIONAL,
    N_("list the aliases that expand to given addresses") },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -69,10 +66,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     case ARG_ALIAS:
       mh_alias_read (arg, 1);
       break;
@@ -195,7 +188,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/anno.c b/mh/anno.c
index 83119c3..d2870ff 100644
--- a/mh/anno.c
+++ b/mh/anno.c
@@ -21,7 +21,6 @@
 
 #include <mh.h>
 
-const char *program_version = "anno (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH anno")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -41,8 +40,6 @@ static struct argp_option options[] = {
    N_("add this FIELD to the message header") },
   {"text", ARG_TEXT, N_("STRING"), 0,
    N_("field value for the component") },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { NULL }
 };
 
@@ -92,10 +89,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       mh_quote (arg, &anno_text);
       break;
 
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -119,7 +112,7 @@ main (int argc, char **argv)
   
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/burst.c b/mh/burst.c
index 0647baa..670ea79 100644
--- a/mh/burst.c
+++ b/mh/burst.c
@@ -24,7 +24,6 @@
 #define obstack_chunk_free free
 #include <obstack.h>
 
-const char *program_version = "burst (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH burst")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -48,8 +47,6 @@ static struct argp_option options[] = {
   {"norecursive",  ARG_NORECURSIVE,  0, OPTION_HIDDEN, ""},
   {"length",       ARG_LENGTH,       N_("NUMBER"), 0,
    N_("set minimal length of digest encapsulation boundary (default 1)") },
-  {"license",      ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { NULL }
 };
 
@@ -93,10 +90,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
 	eb_min_length = 1;
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     case ARG_VERBOSE:
       verbose = is_true (arg);
       break;
@@ -554,7 +547,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/comp.c b/mh/comp.c
index 3ac0a41..71095a6 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -23,7 +23,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-const char *program_version = "comp (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH comp")"\v"
 N_("Options marked with `*' are not yet implemented.\n"
 "Use -help to obtain the list of traditional MH options.");
@@ -56,8 +55,6 @@ static struct argp_option options[] = {
   {"use",           ARG_USE, N_("BOOL"), OPTION_ARG_OPTIONAL,
    N_("use draft file preserved after the last session") },
   {"nouse",         ARG_NOUSE, NULL, OPTION_HIDDEN, ""},
-  {"license",       ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -143,10 +140,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       argp_error (state, _("option is not yet implemented"));
       exit (1);
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -195,7 +188,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/fmtcheck.c b/mh/fmtcheck.c
index 3d50ae8..33c456a 100644
--- a/mh/fmtcheck.c
+++ b/mh/fmtcheck.c
@@ -21,7 +21,6 @@
 
 #include <mh.h>
 
-const char *program_version = "fmtcheck (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH fmtcheck")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = "";
@@ -36,8 +35,6 @@ static struct argp_option options[] = {
    N_("dump the listing of compiled format code")},
   { "debug",  ARG_DEBUG, NULL,     0,
     N_("enable parser debugging output"),},
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
 
   { 0 }
 };
@@ -89,10 +86,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       mh_format_debug (1);
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -105,7 +98,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, NULL);
 
diff --git a/mh/folder.c b/mh/folder.c
index b13e373..c2baf4c 100644
--- a/mh/folder.c
+++ b/mh/folder.c
@@ -34,7 +34,6 @@
 #define obstack_chunk_free free
 #include <obstack.h>
 
-const char *program_version = "folder (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH folder")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[action] [msg]");
@@ -81,9 +80,6 @@ static struct argp_option options[] = {
   {"dry-run", ARG_DRY_RUN, NULL, 0,
    N_("do nothing, print what would be done (with --pack)"), 3},
    
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
-
   {NULL},
 };
 
@@ -225,10 +221,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       mh_set_current_folder (arg);
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     case ARG_VERBOSE:
       verbose++;
       break;
@@ -939,7 +931,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/forw.c b/mh/forw.c
index 8ec9fee..7fbaddb 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -21,7 +21,6 @@
 
 #include <mh.h>
 
-const char *program_version = "forw (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH forw")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -70,9 +69,6 @@ static struct argp_option options[] = {
    N_("use draft file preserved after the last session") },
   {"nouse",         ARG_NOUSE,         N_("BOOL"), OPTION_HIDDEN, "" },
 
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
-
   {NULL},
 };
 
@@ -209,10 +205,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       argp_error (state, _("option is not yet implemented"));
       exit (1);
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -426,7 +418,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/inc.c b/mh/inc.c
index 4dc9117..184a056 100644
--- a/mh/inc.c
+++ b/mh/inc.c
@@ -21,7 +21,6 @@
 
 #include <mh.h>
 
-const char *program_version = "inc (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH inc")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[+folder]");
@@ -50,8 +49,6 @@ static struct argp_option options[] = {
    N_("set output width")},
   {"quiet",   ARG_QUIET, 0,        0,
    N_("be quiet")},
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -142,10 +139,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       quiet = 1;
       break;
 
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -181,7 +174,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, NULL);
 
diff --git a/mh/install-mh.c b/mh/install-mh.c
index fd88631..a563c5f 100644
--- a/mh/install-mh.c
+++ b/mh/install-mh.c
@@ -19,7 +19,6 @@
 
 #include <mh.h>
 
-const char *program_version = "install-mh (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH install-mh")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = "";
@@ -28,8 +27,6 @@ static char args_doc[] = "";
 static struct argp_option options[] = {
   {"auto",  ARG_AUTO, NULL, 0, N_("do not ask for anything")},
   {"compat", ARG_COMPAT, NULL, OPTION_HIDDEN, ""},
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   {NULL}
 };
 
@@ -53,10 +50,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
     case ARG_COMPAT:
       break;
 
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -72,7 +65,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_auto_install = 0;
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, NULL);
diff --git a/mh/mark.c b/mh/mark.c
index f5c6cd3..5f67a63 100644
--- a/mh/mark.c
+++ b/mh/mark.c
@@ -19,7 +19,6 @@
 
 #include <mh.h>
 
-const char *program_version = "mark (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH mark")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = "[msgs...]";
@@ -42,8 +41,6 @@ static struct argp_option options[] = {
   {"zero", ARG_ZERO, N_("BOOL"), OPTION_ARG_OPTIONAL,
    N_("empty the sequence before adding messages")},
   {"nozero", ARG_NOZERO, NULL, OPTION_HIDDEN, "" },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   {NULL}
 };
 
@@ -116,10 +113,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       seq_flags &= ~SEQ_ZERO;
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -195,7 +188,7 @@ main (int argc, char **argv)
   mu_url_t url;
   
   MU_APP_INIT_NLS ();
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/mh_argp.c b/mh/mh_argp.c
index fa5e514..be7ed16 100644
--- a/mh/mh_argp.c
+++ b/mh/mh_argp.c
@@ -28,6 +28,9 @@
 #include <string.h>
 #include <mailutils/argcv.h>
 #include "argp.h"
+#ifdef MU_ALPHA_RELEASE
+# include <git-describe.h>
+#endif
 
 static error_t
 parse_opt (int key, char *arg, struct argp_state *state)
@@ -93,11 +96,49 @@ my_argp_parse (struct argp *argp, int argc, char **argv, int flags,
   return rc;
 }
 
+const char version_etc_copyright[] =
+  /* Do *not* mark this string for translation.  %s is a copyright
+     symbol suitable for this locale, and %d is the copyright
+     year.  */
+  "Copyright %s 2010 Free Software Foundation, inc.";
+
+/* This is almost the same as mu_program_version_hook from muinit.c,
+   except for different formatting of the first line. MH uses:
+
+      progname (GNU Mailutils X.Y.Z)
+
+   where X.Y.Z stands for the version number. Emacs MH-E uses this
+   to determine Mailutils presence and its version number (see
+   lisp/mh-e/mh-e.el, function mh-variant-mu-mh-info). */
+static void
+mh_program_version_hook (FILE *stream, struct argp_state *state)
+{
+#ifdef GIT_DESCRIBE
+  fprintf (stream, "%s (%s %s) [%s]\n",
+	   mu_program_name, PACKAGE_NAME, PACKAGE_VERSION, GIT_DESCRIBE);
+#else
+  fprintf (stream, "%s (%s %s)\n", mu_program_name,
+	   PACKAGE_NAME, PACKAGE_VERSION);
+#endif
+  /* TRANSLATORS: Translate "(C)" to the copyright symbol
+     (C-in-a-circle), if this symbol is available in the user's
+     locale.  Otherwise, do not translate "(C)"; leave it as-is.  */
+  fprintf (stream, version_etc_copyright, _("(C)"));
+
+  fputs (_("\
+\n\
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\n\
+There is NO WARRANTY, to the extent permitted by law.\n\
+\n\
+"),
+	 stream);
+}
+
 void
-mh_argp_init (const char *vers)
+mh_argp_init ()
 {
-  argp_program_version = vers ? vers : PACKAGE_STRING;
   argp_program_bug_address =  "<" PACKAGE_BUGREPORT ">";
+  argp_program_version_hook = mh_program_version_hook;
 }
 
 
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index bd26f83..767307f 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -89,7 +89,6 @@ enum mh_arg {
   ARG_INTERACTIVE,	
   ARG_LBRACE,		
   ARG_LENGTH,		
-  ARG_LICENSE,		
   ARG_LIMIT,		
   ARG_LINK,		
   ARG_LIST,		
@@ -184,7 +183,7 @@ enum mh_arg {
   ARG_ZERO
 };
 
-void mh_argp_init (const char *vers);
+void mh_argp_init (void);
 void mh_argv_preproc (int argc, char **argv, struct mh_argp_data *data);
 int mh_getopt (int argc, char **argv, struct mh_option *mh_opt, const char *doc);
 int mh_argp_parse (int *argc, char **argv[],
diff --git a/mh/mhl.c b/mh/mhl.c
index 999a3cb..6a7024d 100644
--- a/mh/mhl.c
+++ b/mh/mhl.c
@@ -23,7 +23,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-const char *program_version = "mhl (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH mhl")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[files]");
@@ -48,8 +47,6 @@ static struct argp_option options[] = {
    N_("use given PROG instead of the default") },
   {"nomoreproc", ARG_NOMOREPROC, NULL, 0,
    N_("disable use of moreproc program") },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { NULL }
 };
    
@@ -133,10 +130,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       nomoreproc = 1;
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -224,7 +217,7 @@ main (int argc, char **argv)
   interactive = isatty (1) && isatty (0);
   
   MU_APP_INIT_NLS ();
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/mhn.c b/mh/mhn.c
index 0824134..29fcd94 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -26,7 +26,6 @@
 #define obstack_chunk_free free
 #include <obstack.h>
 
-const char *program_version = "mhn (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH mhn")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -87,8 +86,6 @@ static struct argp_option options[] = {
   {"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},
   {NULL}
 };
 
@@ -397,10 +394,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       mode_options |= OPT_QUIET;
       break;
 	
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     case ARG_CHARSET:
       charset = arg;
       break;
@@ -2690,7 +2683,7 @@ main (int argc, char **argv)
   
   MU_APP_INIT_NLS ();
   
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/mhparam.c b/mh/mhparam.c
index 85a28b2..f9b7a23 100644
--- a/mh/mhparam.c
+++ b/mh/mhparam.c
@@ -21,7 +21,6 @@
 
 #include <mh.h>
 
-const char *program_version = "mhparam (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH mhparam")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[components]");
@@ -32,8 +31,6 @@ static struct argp_option options[] = {
    N_("display all components from the MH profile. All other arguments are ignored")},
   {"component", ARG_COMPONENT, N_("BOOL"),   OPTION_ARG_OPTIONAL,
    N_("always display the component name") },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -60,10 +57,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       display_comp_name = is_true (arg);
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -126,7 +119,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/mhpath.c b/mh/mhpath.c
index c222fc7..04d58f8 100644
--- a/mh/mhpath.c
+++ b/mh/mhpath.c
@@ -21,7 +21,6 @@
 
 #include <mh.h>
 
-const char *program_version = "mhpath (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH mhpath")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[+folder] [msgs]");
@@ -30,8 +29,6 @@ static char args_doc[] = N_("[+folder] [msgs]");
 static struct argp_option options[] = {
   {"folder",  ARG_FOLDER, N_("FOLDER"), 0,
    N_("specify folder to operate upon")},
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -49,10 +46,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       mh_set_current_folder (arg);
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -83,7 +76,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/pick.c b/mh/pick.c
index e88aec0..51c1366 100644
--- a/mh/pick.c
+++ b/mh/pick.c
@@ -27,7 +27,6 @@
 #define obstack_chunk_free free
 #include <obstack.h>
 
-const char *program_version = "pick (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH pick")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -91,8 +90,6 @@ static struct argp_option options[] = {
   {"zero",     ARG_ZERO,     N_("BOOL"), OPTION_ARG_OPTIONAL,
    N_("empty the sequence before adding messages"), 4},
   {"nozero", ARG_NOZERO, NULL, OPTION_HIDDEN, "", 4 },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   {NULL},
 };
 
@@ -286,10 +283,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       pick_add_token (&lexlist, T_STRING, p);
       break;
 
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -349,7 +342,7 @@ main (int argc, char **argv)
 
   flags = mh_interactive_mode_p () ? 0 : ARGP_NO_ERRS;
   MU_APP_INIT_NLS ();
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, flags, options, mh_option,
 		 args_doc, doc, opt_handler, NULL, &index);
   if (pick_parse (lexlist))
diff --git a/mh/refile.c b/mh/refile.c
index 9cade4c..8b5e82f 100644
--- a/mh/refile.c
+++ b/mh/refile.c
@@ -26,7 +26,6 @@
 #include <errno.h>
 #include <fcntl.h>
 
-const char *program_version = "refile (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH refile")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -47,8 +46,6 @@ static struct argp_option options[] = {
    N_("specify source folder; it will become the current folder after the program exits")},
   {"src", 0, NULL, OPTION_ALIAS, NULL},
   {"file", ARG_FILE, N_("FILE"), 0, N_("use FILE as the source message")},
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -179,10 +176,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       source_file = arg;
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -232,7 +225,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/repl.c b/mh/repl.c
index de6a125..e17e237 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -24,7 +24,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-const char *program_version = "reply (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH repl")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -68,8 +67,6 @@ static struct argp_option options[] = {
   {"nowhatnowproc", ARG_NOWHATNOWPROC, NULL, 0,
    N_("* ignore whatnowproc variable; use standard `whatnow' shell instead")},
   {"use", ARG_USE, N_("BOOL"), OPTION_ARG_OPTIONAL, N_("use draft file preserved after the last session") },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -261,10 +258,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       argp_error (state, _("Option is not yet implemented"));
       exit (1);
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     case ARGP_KEY_FINI:
       if (!format_str)
 	format_str = default_format_str;
@@ -406,7 +399,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
 
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
diff --git a/mh/rmf.c b/mh/rmf.c
index 3aa7c80..31fb44e 100644
--- a/mh/rmf.c
+++ b/mh/rmf.c
@@ -30,7 +30,6 @@
 
 #include <dirent.h>
 
-const char *program_version = "rmf (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH rmf")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[+folder]");
@@ -45,8 +44,6 @@ static struct argp_option options[] = {
   {"recursive", ARG_RECURSIVE, NULL, 0,
    N_("recursively delete all subfolders")},
   {"norecursive", ARG_NORECURSIVE, NULL, OPTION_HIDDEN, ""},
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -90,10 +87,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       recurse = 0;
       break;
 
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -195,7 +188,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, NULL);
 
diff --git a/mh/rmm.c b/mh/rmm.c
index 68562d6..e82ac79 100644
--- a/mh/rmm.c
+++ b/mh/rmm.c
@@ -21,7 +21,6 @@
 
 #include <mh.h>
 
-const char *program_version = "rmm (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH rmm")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[+folder] [msgs]");
@@ -30,8 +29,6 @@ static char args_doc[] = N_("[+folder] [msgs]");
 static struct argp_option options[] = {
   {"folder",  ARG_FOLDER, N_("FOLDER"), 0,
    N_("specify folder to operate upon")},
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -49,10 +46,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       mh_set_current_folder (arg);
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -78,7 +71,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/scan.c b/mh/scan.c
index cdffca0..5c98a5f 100644
--- a/mh/scan.c
+++ b/mh/scan.c
@@ -28,7 +28,6 @@
 #include <time.h>
 #include <mailutils/observer.h>
 
-const char *program_version = "scan (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH scan")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[+folder] [msgs]");
@@ -54,9 +53,6 @@ static struct argp_option options[] = {
   {"file",    ARG_FILE, N_("FILE"),   0,
    N_("[not yet implemented]")},
   
-  {"license", ARG_LICENSE, 0,        0,
-   N_("display software license"), -1},
-
   { 0 }
 };
 
@@ -137,10 +133,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       argp_error (state, _("Option is not yet implemented"));
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-      
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -178,7 +170,7 @@ main (int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/send.c b/mh/send.c
index 8118d7f..22361b5 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -25,7 +25,6 @@
 #include <stdarg.h>
 #include <pwd.h>
 
-const char *program_version = "send (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH send")"\v"
 N_("Options marked with `*' are not yet implemented.\n\
 Use -help to obtain the list of traditional MH options.");
@@ -77,8 +76,6 @@ static struct argp_option options[] = {
   {"nowatch",       ARG_NOWATCH,       NULL, OPTION_HIDDEN, "" },
   {"width",         ARG_WIDTH,         N_("NUMBER"), 0,
    N_("* make header fields no longer than NUMBER columns") },
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
   { 0 }
 };
 
@@ -252,10 +249,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
 	}
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -747,7 +740,7 @@ main (int argc, char **argv)
   
   MU_APP_INIT_NLS ();
   
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mh/sortm.c b/mh/sortm.c
index 68b95c3..cdea0bd 100644
--- a/mh/sortm.c
+++ b/mh/sortm.c
@@ -24,7 +24,6 @@
 #include <unistd.h>
 #include <signal.h>
 
-const char *program_version = "sortm (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH sortm")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[msgs]");
@@ -76,9 +75,6 @@ static struct argp_option options[] = {
   {"quicksort", ARG_QUICKSORT,  0, 0,
    N_("use quicksort algorithm (default)"), 40 },
 
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
-
   { NULL },
 };
 
@@ -191,10 +187,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       algorithm = key;
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -558,7 +550,7 @@ main (int argc, char **argv)
   mu_url_t url;
   
   MU_APP_INIT_NLS ();
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option,
 		 args_doc, doc, opt_handler, NULL, &index);
   if (!oplist)
diff --git a/mh/whatnow.c b/mh/whatnow.c
index 7b3e666..3075d5a 100644
--- a/mh/whatnow.c
+++ b/mh/whatnow.c
@@ -20,7 +20,6 @@
 
 #include <mh.h>
 
-const char *program_version = "whatnow (" PACKAGE_STRING ")";
 static char doc[] = "GNU MH whatnow";
 static char args_doc[] = N_("[FILE]");
 
@@ -36,9 +35,6 @@ static struct argp_option options[] = {
   {"noedit", ARG_NOEDIT, 0, 0, N_("suppress the initial edit")},
   {"prompt", ARG_PROMPT, N_("STRING"), 0, N_("set the prompt")},
 
-  {"license", ARG_LICENSE, 0,      0,
-   N_("display software license"), -1},
-
   { NULL }
 };
 
@@ -91,10 +87,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       wh_env.prompt = arg;
       break;
       
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -108,7 +100,7 @@ main (int argc, char **argv)
   
   MU_APP_INIT_NLS ();
 
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
   argc -= index;
diff --git a/mh/whom.c b/mh/whom.c
index 893fe8e..9db8446 100644
--- a/mh/whom.c
+++ b/mh/whom.c
@@ -19,7 +19,6 @@
 
 #include <mh.h>
 
-const char *program_version = "whom (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH whom")"\v"
 N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = "[file]";
@@ -40,9 +39,6 @@ static struct argp_option options[] = {
    N_("check if addresses are deliverable") },
   {"nocheck",       ARG_NOCHECK,       NULL, OPTION_HIDDEN, "" },
 
-  {"license",       ARG_LICENSE,       0,    0,
-   N_("display software license"), -1},
-
   {NULL}
 };
 
@@ -96,10 +92,6 @@ opt_handler (int key, char *arg, struct argp_state *state)
       check_recipients = 0;
       break;
 
-    case ARG_LICENSE:
-      mh_license (argp_program_version);
-      break;
-
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -114,7 +106,7 @@ main (int argc, char **argv)
   
   MU_APP_INIT_NLS ();
   
-  mh_argp_init (program_version);
+  mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
 
diff --git a/mimeview/mimeview.c b/mimeview/mimeview.c
index 6192ede..0c359cc 100644
--- a/mimeview/mimeview.c
+++ b/mimeview/mimeview.c
@@ -33,7 +33,6 @@
 
 #include "mailcap.h"
 
-const char *program_version = "mimeview (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU mimeview -- display files, using mailcap mechanism.")
 "\v"     
 N_("Default mime.types file is ") DEFAULT_CUPS_CONFDIR "/mime.types"
@@ -281,7 +280,7 @@ main (int argc, char **argv)
   int index;
   
   MU_APP_INIT_NLS ();
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, capa, mimeview_cfg_param, 
 		   argc, argv, 0, &index, NULL))
     exit (1);
diff --git a/movemail/movemail.c b/movemail/movemail.c
index a385173..2004c7e 100644
--- a/movemail/movemail.c
+++ b/movemail/movemail.c
@@ -33,7 +33,6 @@
 #include "mailutils/libargp.h"
 #include <muaux.h>
 
-const char *program_version = "movemail (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU movemail -- move messages across mailboxes.");
 static char args_doc[] = N_("inbox-url destfile [POP-password]");
 
@@ -677,7 +676,7 @@ main (int argc, char **argv)
 #ifdef WITH_TLS
   mu_gocs_register ("tls", mu_tls_module_init);
 #endif
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, movemail_capa, movemail_cfg_param, 
 		   argc, argv, 0, &index, NULL))
     exit (1);
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index d0e7b60..62c871b 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -338,7 +338,7 @@ main (int argc, char **argv)
   mu_acl_cfg_init ();
   mu_m_server_cfg_init ();
   
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   	
   mu_m_server_create (&server, program_version);
   mu_m_server_set_conn (server, pop3d_connection);
diff --git a/pop3d/popauth.c b/pop3d/popauth.c
index bc8c443..9f73d60 100644
--- a/pop3d/popauth.c
+++ b/pop3d/popauth.c
@@ -56,14 +56,11 @@ int (*ftab[]) (struct action_data *) = {
   action_chpass
 };
 
-const char *program_version = "popauth (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU popauth -- manage pop3 authentication database");
 static error_t popauth_parse_opt  (int key, char *arg,
 				   struct argp_state *astate);
 
 void popauth_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) =
-                                   popauth_version;
 
 static struct argp_option options[] = 
 {
@@ -202,7 +199,8 @@ main(int argc, char **argv)
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
+  argp_program_version_hook = popauth_version;
   if (mu_app_init (&argp, popauth_argp_capa, NULL,
 		   argc, argv, 0, NULL, &adata))
     exit (EX_USAGE);
@@ -600,7 +598,7 @@ popauth_version (FILE *stream, struct argp_state *state)
 #elif defined(WITH_TOKYOCABINET)
 # define FORMAT "Tokyo Cabinet"
 #endif
-  printf ("%s\n", argp_program_version);
+  mu_program_version_hook (stream, state);
   printf (_("Database format: %s\n"), FORMAT);
   printf (_("Database location: %s\n"), APOP_PASSFILE);
   exit (EX_OK);
diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c
index 0ea377e..52c7512 100644
--- a/readmsg/readmsg.c
+++ b/readmsg/readmsg.c
@@ -33,7 +33,6 @@ static void print_header (mu_message_t, int, int, char **);
 static void print_body (mu_message_t);
 static int  string_starts_with (const char * s1, const char *s2);
 
-const char *program_version = "readmsg (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU readmsg -- print messages.");
 static error_t readmsg_parse_opt  (int key, char *arg, struct argp_state *astate);
 
@@ -301,7 +300,7 @@ main (int argc, char **argv)
 #ifdef WITH_TLS
   mu_gocs_register ("tls", mu_tls_module_init);
 #endif
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
   if (mu_app_init (&argp, readmsg_argp_capa, readmsg_cfg_param, 
 		   argc, argv, 0, &index, NULL))
     exit (1);
diff --git a/sieve/sieve.c b/sieve/sieve.c
index 814be65..1e1d395 100644
--- a/sieve/sieve.c
+++ b/sieve/sieve.c
@@ -48,8 +48,6 @@
 
 #include "mailutils/libargp.h"
 
-const char *program_version = "sieve (" PACKAGE_STRING ")";
-
 static char doc[] =
 N_("GNU sieve -- a mail filtering tool.")
 "\v"
@@ -480,7 +478,7 @@ main (int argc, char *argv[])
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mu_argp_init (program_version, NULL);
+  mu_argp_init (NULL, NULL);
 #ifdef WITH_TLS
   mu_gocs_register ("tls", mu_tls_module_init);
 #endif


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Sun May 02 15:37:10 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O8eyU-00084b-K8
	for mharc-commit-mailutils@gnu.org; Sun, 02 May 2010 15:37:10 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O8eyS-00083l-N2
	for commit-mailutils@gnu.org; Sun, 02 May 2010 15:37:08 -0400
Received: from [140.186.70.92] (port=33259 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O8eyQ-00083N-6M
	for commit-mailutils@gnu.org; Sun, 02 May 2010 15:37:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8eyO-0006VU-1N
	for commit-mailutils@gnu.org; Sun, 02 May 2010 15:37:06 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:33315
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8eyN-0006VL-Ue
	for commit-mailutils@gnu.org; Sun, 02 May 2010 15:37:03 -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 1O8eyN-0004Bv-Bp
	for commit-mailutils@gnu.org; Sun, 02 May 2010 19:37:03 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8eyN-0001Ww-6j
	for commit-mailutils@gnu.org; Sun, 02 May 2010 19:37:03 +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: b000617bad12dc7d3b0ea5f4541cc66b64e2fb02
X-Git-Newrev: b4ed41dcc3d0617358b9497d93c675e786109c5c
Message-Id: <E1O8eyN-0001Ww-6j@vcs-noshell.in.savannah.gnu.org>
Date: Sun, 02 May 2010 19:37:03 +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-96-gb4ed41d
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, 02 May 2010 19:37:08 -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=b4ed41dcc3d0617358b9497d93c675e786109c5c

The branch, stream-cleanup has been updated
       via  b4ed41dcc3d0617358b9497d93c675e786109c5c (commit)
       via  9289484606db997acfff0f832049de9bae537a35 (commit)
       via  6f6681b1906430011403bceb36b992c44955ad50 (commit)
       via  b4a02de17f416199ce90f030f8b013f0a8651b90 (commit)
      from  b000617bad12dc7d3b0ea5f4541cc66b64e2fb02 (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 b4ed41dcc3d0617358b9497d93c675e786109c5c
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 22:38:06 2010 +0300

    Various fixes in imap4d.
    
    Imap4d successfully passes all tests.
    
    * imap4d/close.c (imap4d_close0): Fix improper use of MU_STREAM_READ
    (flags changed their semantics since then).
    * imap4d/fetch.c: Send \n terminated lines, rely on filters to recode
    line terminators to \r\n.
    (fetch_io): Rewrite using CRLF encoder and util_copy_out.
    (_frt_header_fields): Rewind memory stream before reading from it.
    
    * imap4d/auth_gsasl.c: Send \n terminated lines, rely on filters
    to recode line terminators to \r\n.
    * imap4d/auth_gss.c: Likewise.
    * imap4d/capability.c: Likewise.
    * imap4d/copy.c: Likewise.
    * imap4d/id.c: Likewise.
    * imap4d/idle.c: Likewise.
    * imap4d/list.c: Likewise.
    * imap4d/namespace.c: Likewise.
    * imap4d/preauth.c: Likewise.
    * imap4d/search.c: Likewise.
    * imap4d/status.c: Likewise.
    * imap4d/store.c: Likewise.
    * imap4d/select.c: Likewise.
    (imap4d_select_status): Fix improper use of MU_STREAM_READ.
    
    * imap4d/util.c: Send \n terminated lines, rely on filters
    to recode line terminators to \r\n.
    (util_setio): Apply CRLF filters to both input and output streams
    (in opposite directions).
    (util_copy_out): New function.
    (remove_cr): Remove.
    * imap4d/imap4d.h (util_copy_out): New prototype.

commit 9289484606db997acfff0f832049de9bae537a35
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 22:34:54 2010 +0300

    Fix mailbox corruption in imap4d.
    
    Delivery of a signal when a previous signal was being handled caused
    mailbox corruption.
    
    * imap4d/imap4d.c (imap4d_child_signal_setup): New function.
    (imap4d_mainloop): Call imap4d_child_signal_setup.
    * imap4d/signal.c (imap4d_child_signal): Reset all signal handlers
    before doing actual job.
    * lib/signal.c (mu_set_signals): Use sigaction.

commit 6f6681b1906430011403bceb36b992c44955ad50
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 22:33:08 2010 +0300

    Fix for mbox read/write consistency.
    
    * libproto/mbox/mbox.c (append_message_to_stream): Add \n after each
    message (scanner relies on this to determine message sizes).

commit b4a02de17f416199ce90f030f8b013f0a8651b90
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 22:32:11 2010 +0300

    Bugfixes in stream-related code.
    
    * mailbox/fltstream.c (filter_read): Do not try to get more input until
    the output buffer is drained.
    * mailbox/mapfile_stream.c (_mapfile_seek): Fix conditional.
    * mailbox/stream.c (_stream_fill_buffer): Fix increment.
    (mu_stream_skip_input_bytes): Bugfixes.

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

Summary of changes:
 imap4d/auth_gsasl.c      |    4 +-
 imap4d/auth_gss.c        |    8 ++--
 imap4d/capability.c      |    2 +-
 imap4d/close.c           |    2 +-
 imap4d/copy.c            |    2 +-
 imap4d/fetch.c           |   36 +++++++--------
 imap4d/id.c              |    2 +-
 imap4d/idle.c            |    2 +-
 imap4d/imap4d.c          |   14 ++++--
 imap4d/imap4d.h          |    4 +-
 imap4d/list.c            |    6 +-
 imap4d/namespace.c       |    2 +-
 imap4d/preauth.c         |    2 +-
 imap4d/search.c          |    2 +-
 imap4d/select.c          |    8 ++--
 imap4d/signal.c          |   18 ++++---
 imap4d/status.c          |    2 +-
 imap4d/store.c           |    2 +-
 imap4d/util.c            |   58 +++++++++--------------
 lib/signal.c             |   11 ++++-
 libproto/mbox/mbox.c     |    2 +
 mailbox/fltstream.c      |  115 ++++++++++++++++++++++++----------------------
 mailbox/mapfile_stream.c |    2 +-
 mailbox/stream.c         |   14 +++--
 24 files changed, 167 insertions(+), 153 deletions(-)

diff --git a/imap4d/auth_gsasl.c b/imap4d/auth_gsasl.c
index 8676c4f..15e55ce 100644
--- a/imap4d/auth_gsasl.c
+++ b/imap4d/auth_gsasl.c
@@ -95,7 +95,7 @@ auth_gsasl (struct imap4d_command *command, char *auth_type, char **username)
   while ((rc = gsasl_step64 (sess_ctx, input_str, &output))
 	   == GSASL_NEEDS_MORE)
     {
-      util_send ("+ %s\r\n", output);
+      util_send ("+ %s\n", output);
       imap4d_getline (&input_str, &input_size, &input_len);
     }
   
@@ -112,7 +112,7 @@ auth_gsasl (struct imap4d_command *command, char *auth_type, char **username)
      returned, and clients must respond with an empty response. */
   if (output[0])
     {
-      util_send ("+ %s\r\n", output);
+      util_send ("+ %s\n", output);
       imap4d_getline (&input_str, &input_size, &input_len);
       if (input_len != 0)
 	{
diff --git a/imap4d/auth_gss.c b/imap4d/auth_gss.c
index e85c258..1a7fd95 100644
--- a/imap4d/auth_gss.c
+++ b/imap4d/auth_gss.c
@@ -163,7 +163,7 @@ auth_gssapi (struct imap4d_command *command,
 
   /* Start the dialogue */
 
-  util_send ("+ \r\n");
+  util_send ("+ \n");
   util_flush_output ();
   
   context = GSS_C_NO_CONTEXT;
@@ -192,7 +192,7 @@ auth_gssapi (struct imap4d_command *command,
 	  if (outbuf.length)
 	    {
 	      mu_base64_encode (outbuf.value, outbuf.length, &tmp, &size);
-	      util_send ("+ %s\r\n", tmp);
+	      util_send ("+ %s\n", tmp);
 	      free (tmp);
 	      gss_release_buffer (&min_stat, &outbuf);
 	    }
@@ -212,7 +212,7 @@ auth_gssapi (struct imap4d_command *command,
   if (outbuf.length)
     {
       mu_base64_encode (outbuf.value, outbuf.length, &tmp, &size);
-      util_send ("+ %s\r\n", tmp);
+      util_send ("+ %s\n", tmp);
       free (tmp);
       gss_release_buffer (&min_stat, &outbuf);
       imap4d_getline (&token_str, &token_size, &token_len);
@@ -232,7 +232,7 @@ auth_gssapi (struct imap4d_command *command,
     }
   
   mu_base64_encode (outbuf.value, outbuf.length, &tmp, &size);
-  util_send ("+ %s\r\n", tmp);
+  util_send ("+ %s\n", tmp);
   free (tmp);
 
   imap4d_getline (&token_str, &token_size, &token_len);
diff --git a/imap4d/capability.c b/imap4d/capability.c
index c88bc60..b52d926 100644
--- a/imap4d/capability.c
+++ b/imap4d/capability.c
@@ -80,7 +80,7 @@ imap4d_capability (struct imap4d_command *command, imap4d_tokbuf_t tok)
   mu_list_do (capa_list, print_capa, NULL);
   
   imap4d_auth_capability ();
-  util_send ("\r\n");
+  util_send ("\n");
 
   return util_finish (command, RESP_OK, "Completed");
 }
diff --git a/imap4d/close.c b/imap4d/close.c
index 732e849..e730268 100644
--- a/imap4d/close.c
+++ b/imap4d/close.c
@@ -30,7 +30,7 @@ imap4d_close0 (struct imap4d_command *command, imap4d_tokbuf_t tok,
     return util_finish (command, RESP_BAD, "Invalid arguments");
   
   mu_mailbox_get_flags (mbox, &flags);
-  if ((flags & MU_STREAM_READ) == 0)
+  if (flags & MU_STREAM_WRITE)
     {
       status = mu_mailbox_flush (mbox, expunge);
       if (status)
diff --git a/imap4d/copy.c b/imap4d/copy.c
index b25e1ee..7f9acad 100644
--- a/imap4d/copy.c
+++ b/imap4d/copy.c
@@ -52,7 +52,7 @@ imap4d_copy (struct imap4d_command *command, imap4d_tokbuf_t tok)
       int new_state = (rc == RESP_OK) ? command->success : command->failure;
       if (new_state != STATE_NONE)
 	state = new_state;
-      return util_send ("%s %s\r\n", command->tag, text);
+      return util_send ("%s %s\n", command->tag, text);
     }
   return util_finish (command, rc, "%s", text);
 }
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index a36a097..ef8ae9a 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -689,39 +689,36 @@ static int
 fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
 {
   mu_stream_t rfc = NULL;
+  
   size_t n = 0;
 
   mu_filter_create (&rfc, stream, "rfc822", MU_FILTER_ENCODE,
-		    MU_STREAM_READ|MU_STREAM_NO_CHECK|MU_STREAM_NO_CLOSE);
-
+		    MU_STREAM_READ|MU_STREAM_SEEK|MU_STREAM_NO_CLOSE);
+  
   if (start == 0 && size == (size_t) -1)
     {
-      char *buffer;
-      size_t bufsize;
       int rc;
       
-      for (bufsize = max; (buffer = malloc (bufsize)) == NULL; bufsize /= 2)
-	if (bufsize < 512)
-  	  imap4d_bye (ERR_NO_MEM);
-
       rc = mu_stream_seek (rfc, 0, MU_SEEK_SET, NULL);
       if (rc)
 	{
-	  mu_error ("seek error: %s", mu_stream_strerror (rfc, rc));
+	  mu_error ("seek error: %s", mu_stream_strerror (stream, rc));
 	  return RESP_BAD;
 	}
       if (max)
 	{
-	  util_send (" {%lu}\r\n", (unsigned long) max);
-	  while (mu_stream_read (rfc, buffer, bufsize, &n) == 0 && n > 0)
-	    util_send_bytes (buffer, n);
-
+	  util_send (" {%lu}\n", (unsigned long) max);
+	  util_copy_out (rfc, max);
 	  /* FIXME: Make sure exactly max bytes were sent */
-          free (buffer); 
 	}
       else
 	util_send (" \"\"");
     }
+  else if (start > max)
+    {
+      util_send ("<%lu>", (unsigned long) start);
+      util_send (" \"\"");
+    }
   else if (size + 2 < size) /* Check for integer overflow */
     {
       mu_stream_destroy (&rfc);
@@ -737,16 +734,17 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
       if (!p)
 	imap4d_bye (ERR_NO_MEM);
 
-      rc = mu_stream_seek (stream, start, MU_SEEK_SET, NULL);
+      rc = mu_stream_seek (rfc, start, MU_SEEK_SET, NULL);
       if (rc)
 	{
 	  mu_error ("seek error: %s", mu_stream_strerror (rfc, rc));
 	  free (buffer);
+	  mu_stream_destroy (&rfc);
 	  return RESP_BAD;
 	}
 
       while (total < size
-	     && mu_stream_read (rfc, p, size - total + 1, &n) == 0
+	     && mu_stream_read (rfc, p, size - total, &n) == 0
 	     && n > 0)
 	{
 	  total += n;
@@ -756,7 +754,7 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
       util_send ("<%lu>", (unsigned long) start);
       if (total)
 	{
-	  util_send (" {%lu}\r\n", (unsigned long) total);
+	  util_send (" {%lu}\n", (unsigned long) total);
 	  util_send_bytes (buffer, total);
 	}
       else
@@ -1085,6 +1083,7 @@ _frt_header_fields (struct fetch_function_closure *ffc,
   
   /* Output collected data */
   mu_stream_size (stream, &size);
+  mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   status = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
   
@@ -1657,7 +1656,7 @@ imap4d_fetch0 (imap4d_tokbuf_t tok, int isuid, char **err_text)
 	      util_send ("* %lu FETCH (", (unsigned long) frc.msgno);
 	      frc.eltno = 0;
 	      rc = mu_list_do (pclos.fnlist, _do_fetch, &frc);
-	      util_send (")\r\n");
+	      util_send (")\n");
 	    }
 	}
       }
@@ -1693,4 +1692,3 @@ imap4d_fetch (struct imap4d_command *command, imap4d_tokbuf_t tok)
   rc = imap4d_fetch0 (tok, 0, &err_text);
   return util_finish (command, rc, "%s", err_text);
 }
-
diff --git a/imap4d/id.c b/imap4d/id.c
index f8c261c..353d3fe 100644
--- a/imap4d/id.c
+++ b/imap4d/id.c
@@ -202,7 +202,7 @@ imap4d_id (struct imap4d_command *command, imap4d_tokbuf_t tok)
 	}
       mu_iterator_destroy (&itr);
       if (outcnt)
-	util_send (")\r\n");
+	util_send (")\n");
     }
   return util_finish (command, RESP_OK, "Completed");
 }
diff --git a/imap4d/idle.c b/imap4d/idle.c
index e3ddd6c..e8e7b8c 100644
--- a/imap4d/idle.c
+++ b/imap4d/idle.c
@@ -32,7 +32,7 @@ imap4d_idle (struct imap4d_command *command, imap4d_tokbuf_t tok)
   if (util_wait_input (0) == -1)
     return util_finish (command, RESP_NO, "Cannot idle");
 
-  util_send ("+ idling\r\n");
+  util_send ("+ idling\n");
   util_flush_output ();
 
   start = time (NULL);
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index b180206..ea492a0 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -383,18 +383,22 @@ get_client_address (int fd, struct sockaddr_in *pcs)
   return 0;
 }
 
+void
+imap4d_child_signal_setup (RETSIGTYPE (*handler) (int signo))
+{
+  static int sigtab[] = { SIGILL, SIGBUS, SIGFPE, SIGSEGV, SIGSTOP, SIGPIPE,
+			  SIGABRT, SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGALRM };
+  mu_set_signals (handler, sigtab, MU_ARRAY_SIZE (sigtab));
+}
+
 static int
 imap4d_mainloop (int fd, FILE *infile, FILE *outfile)
 {
   imap4d_tokbuf_t tokp;
   char *text;
   int debug_mode = isatty (fd);
-  static int sigtab[] = { SIGILL, SIGBUS, SIGFPE, SIGSEGV, SIGSTOP, SIGPIPE,
-			  SIGABRT, SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGALRM };
 
-  /* Reset signals */
-  mu_set_signals (imap4d_child_signal, sigtab, MU_ARRAY_SIZE (sigtab));
-  
+  imap4d_child_signal_setup (imap4d_child_signal);
   util_setio (infile, outfile);
 
   if (imap4d_preauth_setup (fd) == 0)
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index 1d9378d..6a01e46 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -202,7 +202,7 @@ extern int imap4d_transcript;
 extern mu_list_t imap4d_id_list;
 extern int imap4d_argc;                 
 extern char **imap4d_argv;
-  
+
 #ifndef HAVE_STRTOK_R
 extern char *strtok_r (char *s, const char *delim, char **save_ptr);
 #endif
@@ -334,6 +334,8 @@ extern int  util_send (const char *, ...) MU_PRINTFLIKE(1,2);
 extern int  util_send_bytes (const char *buf, size_t size);
 extern int  util_send_qstring (const char *);
 extern int  util_send_literal (const char *);
+extern int  util_copy_out (mu_stream_t str, size_t size);
+
 extern int  util_start (char *);
 extern int  util_finish (struct imap4d_command *, int, const char *, ...) 
                          MU_PRINTFLIKE(3,4);
diff --git a/imap4d/list.c b/imap4d/list.c
index 7ee42be..c7f42e4 100644
--- a/imap4d/list.c
+++ b/imap4d/list.c
@@ -97,11 +97,11 @@ list_fun (mu_folder_t folder, struct mu_list_response *resp, void *data)
   name = refinfo->buf;
   
   if (strpbrk (name, "\"{}"))
-    util_send ("{%lu}\r\n%s\r\n", (unsigned long) strlen (name), name);
+    util_send ("{%lu}\n%s\n", (unsigned long) strlen (name), name);
   else if (is_atom (name))
-    util_send ("%s\r\n", name);
+    util_send ("%s\n", name);
   else
-    util_send ("\"%s\"\r\n", name);
+    util_send ("\"%s\"\n", name);
   return 0;
 }
 
diff --git a/imap4d/namespace.c b/imap4d/namespace.c
index abe21cd..5fd1408 100644
--- a/imap4d/namespace.c
+++ b/imap4d/namespace.c
@@ -126,7 +126,7 @@ imap4d_namespace (struct imap4d_command *command, imap4d_tokbuf_t tok)
   print_namespace (NS_OTHER);
   util_send (" ");
   print_namespace (NS_SHARED);
-  util_send ("\r\n");
+  util_send ("\n");
 
   return util_finish (command, RESP_OK, "Completed");
 }
diff --git a/imap4d/preauth.c b/imap4d/preauth.c
index 3168286..d26efc8 100644
--- a/imap4d/preauth.c
+++ b/imap4d/preauth.c
@@ -366,7 +366,7 @@ do_preauth_ident (struct sockaddr *clt_sa, struct sockaddr *srv_sa)
       return NULL;
     }
 
-  mu_stream_printf (stream, "%u , %u\r\n",
+  mu_stream_printf (stream, "%u , %u\n",
 		    ntohs (clt_addr->sin_port),
 		    ntohs (srv_addr->sin_port));
   mu_stream_shutdown (stream, MU_STREAM_WRITE);
diff --git a/imap4d/search.c b/imap4d/search.c
index 33d2aa2..1163ce9 100644
--- a/imap4d/search.c
+++ b/imap4d/search.c
@@ -363,7 +363,7 @@ do_search (struct parsebuf *pb)
 	    util_send (" %s", mu_umaxtostr (0, pb->msgno));
 	}
     }
-  util_send ("\r\n");
+  util_send ("\n");
 }
 
 /* Parse buffer functions */
diff --git a/imap4d/select.c b/imap4d/select.c
index dcf3fe0..2e2142b 100644
--- a/imap4d/select.c
+++ b/imap4d/select.c
@@ -74,9 +74,9 @@ imap4d_select0 (struct imap4d_command *command, const char *mboxname,
 	{
 	  free (mailbox_name);
 	  /* Need to set the state explicitely for select.  */
-	  return util_send ("%s OK [%s] %s Completed\r\n", command->tag,
-			    (flags & MU_STREAM_READ)  ?
-			    "READ-ONLY" : "READ-WRITE", command->name);
+	  return util_send ("%s OK [%s] %s Completed\n", command->tag,
+			    ((flags & MU_STREAM_RDWR) == MU_STREAM_RDWR) ?
+			    "READ-WRITE" : "READ-ONLY", command->name);
 	}
     }
   
@@ -119,7 +119,7 @@ imap4d_select_status ()
   /* FIXME:
      - '\*' can be supported if we use the attribute_set userflag()
      - Answered is still not set in the mailbox code.  */
-  if (select_flags & MU_STREAM_READ)
+  if (!(select_flags & MU_STREAM_WRITE))
     util_out (RESP_OK, "[PERMANENTFLAGS ()] No Permanent flags");
   else
     util_out (RESP_OK, "[PERMANENTFLAGS (%s)] Permanent flags", pflags);
diff --git a/imap4d/signal.c b/imap4d/signal.c
index c9dcfc5..d71138e 100644
--- a/imap4d/signal.c
+++ b/imap4d/signal.c
@@ -49,21 +49,25 @@ imap4d_master_signal (int signo)
 RETSIGTYPE
 imap4d_child_signal (int signo)
 {
+  imap4d_child_signal_setup (SIG_IGN);
   mu_diag_output (MU_DIAG_CRIT, _("got signal `%s'"), strsignal (signo));
-
   switch (signo)
     {
     case SIGTERM:
     case SIGHUP:
-      imap4d_bye (ERR_TERMINATE);
-
+      signo = ERR_TERMINATE;
+      break;
+      
     case SIGALRM:
-      imap4d_bye (ERR_TIMEOUT);
-
+      signo = ERR_TIMEOUT;
+      break;
+      
     case SIGPIPE:
-      imap4d_bye (ERR_NO_OFILE);
+      signo = ERR_NO_OFILE;
+      break;
       
     default:
-      imap4d_bye (ERR_SIGNAL);
+      signo = ERR_SIGNAL;
     }
+  imap4d_bye (signo);
 }
diff --git a/imap4d/status.c b/imap4d/status.c
index 3933a79..3622c47 100644
--- a/imap4d/status.c
+++ b/imap4d/status.c
@@ -136,7 +136,7 @@ imap4d_status (struct imap4d_command *command, imap4d_tokbuf_t tok)
 
 	  
 	  if (count > 0)
-	    util_send (")\r\n");
+	    util_send (")\n");
 	  mu_mailbox_close (smbox);
 	}
       mu_mailbox_destroy (&smbox);
diff --git a/imap4d/store.c b/imap4d/store.c
index ac06bdc..c043a3e 100644
--- a/imap4d/store.c
+++ b/imap4d/store.c
@@ -157,7 +157,7 @@ imap4d_store0 (imap4d_tokbuf_t tok, int isuid, char **ptext)
 		util_send ("UID %lu ", (unsigned long) msgno);
 	      util_send ("FLAGS (");
 	      util_print_flags (attr);
-	      util_send ("))\r\n");
+	      util_send ("))\n");
 	    }
 	  /* Update the flags of uid table.  */
 	  imap4d_sync_flags (pclos.set[i]);
diff --git a/imap4d/util.c b/imap4d/util.c
index 8487161..26a1a8d 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -270,6 +270,12 @@ util_msgset (char *s, size_t ** set, int *n, int isuid)
 }
 
 int
+util_copy_out (mu_stream_t str, size_t size)
+{
+  return mu_stream_copy (ostream, str, size);
+}
+
+int
 util_send_bytes (const char *buf, size_t size)
 {
   return mu_stream_write (ostream, buf, size, NULL);
@@ -325,7 +331,7 @@ util_send_qstring (const char *buffer)
 int
 util_send_literal (const char *buffer)
 {
-  return util_send ("{%lu}\r\n%s", (unsigned long) strlen (buffer), buffer);
+  return util_send ("{%lu}\n%s", (unsigned long) strlen (buffer), buffer);
 }
 
 /* Send an unsolicited response.  */
@@ -337,7 +343,7 @@ util_out (int rc, const char *format, ...)
   int status = 0;
   va_list ap;
 
-  asprintf (&tempbuf, "* %s%s\r\n", sc2string (rc), format);
+  asprintf (&tempbuf, "* %s%s\n", sc2string (rc), format);
   va_start (ap, format);
   vasprintf (&buf, tempbuf, ap);
   va_end (ap);
@@ -346,7 +352,7 @@ util_out (int rc, const char *format, ...)
 
   if (imap4d_transcript)
     {
-      int len = strcspn (buf, "\r\n");
+      int len = strcspn (buf, "\n");
       mu_diag_output (MU_DIAG_DEBUG, "sent: %*.*s", len, len, buf);
     }
 
@@ -393,7 +399,7 @@ util_finish (struct imap4d_command *command, int rc, const char *format, ...)
 
   mu_stream_write (ostream, buf, strlen (buf), NULL);
   free (buf);
-  mu_stream_write (ostream, "\r\n", 2, NULL);
+  mu_stream_write (ostream, "\n", 2, NULL);
 
   /* Reset the state.  */
   if (rc == RESP_OK)
@@ -800,16 +806,24 @@ util_uidvalidity (mu_mailbox_t smbox, unsigned long *uidvp)
 void
 util_setio (FILE *in, FILE *out)
 {
+  mu_stream_t tmp;
+  
   if (!in)
     imap4d_bye (ERR_NO_IFILE);
   if (!out)
     imap4d_bye (ERR_NO_OFILE);
 
-  if (mu_stdio_stream_create (&istream, fileno (in), MU_STREAM_NO_CLOSE))
+  if (mu_stdio_stream_create (&tmp, fileno (in), MU_STREAM_NO_CLOSE))
     imap4d_bye (ERR_NO_IFILE);
-  if (mu_stdio_stream_create (&ostream, fileno (out), MU_STREAM_NO_CLOSE))
-    imap4d_bye (ERR_NO_OFILE);
+  mu_stream_set_buffer (tmp, mu_buffer_line, 1024);
+  mu_filter_create (&istream, tmp, "rfc822", MU_FILTER_DECODE, MU_STREAM_READ);
   mu_stream_set_buffer (istream, mu_buffer_line, 1024);
+  
+  if (mu_stdio_stream_create (&tmp, fileno (out), MU_STREAM_NO_CLOSE))
+    imap4d_bye (ERR_NO_OFILE);
+  mu_stream_set_buffer (tmp, mu_buffer_line, 1024);
+  mu_filter_create (&ostream, tmp, "rfc822", MU_FILTER_ENCODE,
+		    MU_STREAM_WRITE);
   mu_stream_set_buffer (ostream, mu_buffer_line, 1024);
 }
 
@@ -917,7 +931,7 @@ void
 util_bye ()
 {
   int rc = istream != ostream;
-  
+
   mu_stream_close (istream);
   mu_stream_destroy (&istream);
 
@@ -926,7 +940,6 @@ util_bye ()
       mu_stream_close (ostream);
       mu_stream_destroy (&ostream);
     }
-      
   mu_list_do (atexit_list, atexit_run, 0);
 }
 
@@ -1021,30 +1034,6 @@ is_atom (const char *s)
      
 
 static size_t
-remove_cr (char *line, size_t len)
-{
-  char *prev = NULL;
-  size_t rlen = len;
-  char *p;
-  while ((p = memchr (line, '\r', len)))
-    {
-      if (prev)
-	{
-	  memmove (prev, line, p - line);
-	  prev += p - line;
-	}
-      else
-	prev = p;
-      rlen--;
-      len -= p - line + 1;
-      line = p + 1;
-    }
-  if (prev)
-    memmove (prev, line, len);
-  return rlen;
-}
-
-static size_t
 unquote (char *line, size_t len)
 {
   char *prev = NULL;
@@ -1318,7 +1307,7 @@ imap4d_readline (struct imap4d_tokbuf *tok)
 	  /* Client can ask for non-synchronised literal,
 	     if a '+' is appended to the octet count. */
 	  if (*sp == '}')
-	    util_send ("+ GO AHEAD\r\n");
+	    util_send ("+ GO AHEAD\n");
 	  else if (*sp != '+')
 	    break;
 	  imap4d_tokbuf_expand (tok, number + 1);
@@ -1334,7 +1323,6 @@ imap4d_readline (struct imap4d_tokbuf *tok)
                len += sz;
             }
 	  check_input_err (rc, len);
-	  len = remove_cr (buf, len);
 	  imap4d_tokbuf_unquote (tok, &off, &len);
 	  tok->level += len;
 	  tok->buffer[tok->level++] = 0;
diff --git a/lib/signal.c b/lib/signal.c
index 8f5b615..8ce2108 100644
--- a/lib/signal.c
+++ b/lib/signal.c
@@ -26,7 +26,16 @@ void
 mu_set_signals (RETSIGTYPE (*handler) (int signo), int *sigv, int sigc)
 {
   int i;
+  struct sigaction act;
 
+  act.sa_flags = 0;
+  sigemptyset (&act.sa_mask);
   for (i = 0; i < sigc; i++)
-    signal (sigv[i], handler);
+    sigaddset (&act.sa_mask, i);
+      
+  for (i = 0; i < sigc; i++)
+    {
+      act.sa_handler = handler;
+      sigaction (sigv[i], &act, NULL);
+    }
 }
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c
index 5bb043c..98d288d 100644
--- a/libproto/mbox/mbox.c
+++ b/libproto/mbox/mbox.c
@@ -1087,6 +1087,8 @@ append_message_to_stream (mu_stream_t ostr, mu_message_t msg,
     }
   status = mu_stream_copy (ostr, istr, 0);
   mu_stream_destroy (&istr);
+  if (status == 0)
+    status = mu_stream_write (ostr, "\n", 1, NULL);
   return status;
 }
 
diff --git a/mailbox/fltstream.c b/mailbox/fltstream.c
index 99b5a47..90575a4 100644
--- a/mailbox/fltstream.c
+++ b/mailbox/fltstream.c
@@ -117,73 +117,78 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret)
   
   while (total < size && cmd != mu_filter_lastbuf)
     {
-      enum mu_filter_result res;
-      int rc;
       size_t rdsize;
 
-      if (MFB_RDBYTES (fs->inbuf) < min_input_level)
+      if (MFB_RDBYTES (fs->outbuf) == 0)
 	{
-	  rc = MFB_require (&fs->inbuf, min_input_level);
-	  if (rc)
-	    return rc;
-	  rc = mu_stream_read (fs->transport,
-			       MFB_ENDPTR (fs->inbuf),
-			       MFB_FREESIZE (fs->inbuf),
-			       &rdsize);
+	  enum mu_filter_result res;
+	  int rc;
+	  
+	  if (MFB_RDBYTES (fs->inbuf) < min_input_level)
+	    {
+	      rc = MFB_require (&fs->inbuf, min_input_level);
+	      if (rc)
+		return rc;
+	      rc = mu_stream_read (fs->transport,
+				   MFB_ENDPTR (fs->inbuf),
+				   MFB_FREESIZE (fs->inbuf),
+				   &rdsize);
+	      if (rc)
+		return rc;
+	      if (rdsize == 0 &&
+		  MFB_RDBYTES (fs->outbuf) == 0
+		  && MFB_RDBYTES (fs->inbuf) == 0)
+		break;
+	      MFB_advance_level (&fs->inbuf, rdsize);
+	    }
+
+	  if (min_output_size < MFB_RDBYTES (fs->inbuf))
+	    min_output_size = MFB_RDBYTES (fs->inbuf);
+	  rc = MFB_require (&fs->outbuf, min_output_size);
 	  if (rc)
 	    return rc;
-	  if (rdsize == 0 &&
-	      MFB_RDBYTES (fs->outbuf) == 0 && MFB_RDBYTES (fs->inbuf) == 0)
-	    break;
-	  MFB_advance_level (&fs->inbuf, rdsize);
-	}
-
-      if (min_output_size < MFB_RDBYTES (fs->inbuf))
-	min_output_size = MFB_RDBYTES (fs->inbuf);
-      rc = MFB_require (&fs->outbuf, min_output_size);
-      if (rc)
-	return rc;
       
-      init_iobuf (&iobuf, fs);
+	  init_iobuf (&iobuf, fs);
 
-      cmd = mu_stream_eof (fs->transport) ?
-	       mu_filter_lastbuf : mu_filter_xcode;
-      res = fs->xcode (fs->xdata, cmd, &iobuf);
-      switch (res)
-	{
-	case mu_filter_ok:
-	  if (iobuf.isize == 0 || iobuf.osize == 0)
+	  cmd = mu_stream_eof (fs->transport) ?
+	    mu_filter_lastbuf : mu_filter_xcode;
+	  res = fs->xcode (fs->xdata, cmd, &iobuf);
+	  switch (res)
 	    {
-	      /* FIXME: Hack to handle eventual buggy filters */
-	      if (iobuf.isize == 0)
-		min_input_level++;
-	      if (iobuf.osize == 0)
-		min_output_size++;
+	    case mu_filter_ok:
+	      if (iobuf.isize == 0 || iobuf.osize == 0)
+		{
+		  /* FIXME: Hack to handle eventual buggy filters */
+		  if (iobuf.isize == 0)
+		    min_input_level++;
+		  if (iobuf.osize == 0)
+		    min_output_size++;
+		  continue;
+		}
+	      if (iobuf.isize > MFB_RDBYTES (fs->inbuf)
+		  || iobuf.osize > MFB_FREESIZE (fs->outbuf))
+		return MU_ERR_FAILURE; /* FIXME: special error code? */
+	      break;
+	  
+	    case mu_filter_falure:
+	      return iobuf.errcode;
+	      
+	    case mu_filter_moreinput:
+	      min_input_level = iobuf.isize;
+	      continue;
+	      
+	    case mu_filter_moreoutput:
+	      min_output_size = iobuf.osize;
 	      continue;
 	    }
-	  if (iobuf.isize > MFB_RDBYTES (fs->inbuf)
-	      || iobuf.osize > MFB_FREESIZE (fs->outbuf))
-	    return MU_ERR_FAILURE; /* FIXME: special error code? */
-	  break;
-	  
-	case mu_filter_falure:
-	  return iobuf.errcode;
-	  
-	case mu_filter_moreinput:
-	  min_input_level = iobuf.isize;
-	  continue;
+      
+	  /* iobuf.osize contains number of bytes written to output */
+	  MFB_advance_level (&fs->outbuf, iobuf.osize);
 	  
-	case mu_filter_moreoutput:
-	  min_output_size = iobuf.osize;
-	  continue;
+	  /* iobuf.isize contains number of bytes read from input */
+	  MFB_advance_pos (&fs->inbuf, iobuf.isize);
 	}
-      
-      /* iobuf.osize contains number of bytes written to output */
-      MFB_advance_level (&fs->outbuf, iobuf.osize);
-      
-      /* iobuf.isize contains number of bytes read from input */
-      MFB_advance_pos (&fs->inbuf, iobuf.isize);
-      
+
       rdsize = size - total;
       if (rdsize > MFB_RDBYTES (fs->outbuf))
 	rdsize = MFB_RDBYTES (fs->outbuf);
diff --git a/mailbox/mapfile_stream.c b/mailbox/mapfile_stream.c
index 94d3f52..0b60147 100644
--- a/mailbox/mapfile_stream.c
+++ b/mailbox/mapfile_stream.c
@@ -316,7 +316,7 @@ _mapfile_seek (struct _mu_stream *str, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_mapfile_stream *mfs = (struct _mu_mapfile_stream *) str;
   
-  if (off < 0 || off >= mfs->size)
+  if (off < 0 || off > mfs->size)
     return ESPIPE;
   mfs->offset = off;
   *presult = off;
diff --git a/mailbox/stream.c b/mailbox/stream.c
index 2bc2117..b064421 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -80,9 +80,9 @@ _stream_fill_buffer (struct _mu_stream *stream)
 	   n < stream->bufsize
 	     && (rc = mu_stream_read_unbuffered (stream,
 						 &c, 1, 0, &rdn)) == 0
-	     && rdn; n++)
+	     && rdn; )
 	{
-	  stream->buffer[n] = c;
+	  stream->buffer[n++] = c;
 	  if (c == '\n')
 	    break;
 	}
@@ -368,10 +368,10 @@ mu_stream_skip_input_bytes (mu_stream_t stream, mu_off_t count, mu_off_t *pres)
     }
   else
     {
-      if ((rc = _stream_flush_buffer (stream, 1)))
-	return rc;
       for (pos = 0;;)
 	{
+	  if ((rc = _stream_flush_buffer (stream, 1)))
+	    return rc;
 	  if (stream->level == 0)
 	    {
 	      rc = _stream_fill_buffer (stream);
@@ -385,11 +385,13 @@ mu_stream_skip_input_bytes (mu_stream_t stream, mu_off_t count, mu_off_t *pres)
 	    }
 	  if (pos <= count && count < pos + stream->level)
 	    {
-	      rc = 0;
-	      stream->cur = stream->buffer + count - pos;
+	      size_t delta = count - pos;
+	      _stream_advance_buffer (stream, delta);
 	      pos = count;
+	      rc = 0;
 	      break;
 	    }
+	  pos += stream->level;
 	}
     }
   


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Sun May 02 18:34:22 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1O8hjy-0008T6-Qx
	for mharc-commit-mailutils@gnu.org; Sun, 02 May 2010 18:34:22 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1O8hjy-0008T1-6h
	for commit-mailutils@gnu.org; Sun, 02 May 2010 18:34:22 -0400
Received: from [140.186.70.92] (port=52863 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1O8hjw-0008SY-VM
	for commit-mailutils@gnu.org; Sun, 02 May 2010 18:34:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8hjv-0000Zg-E6
	for commit-mailutils@gnu.org; Sun, 02 May 2010 18:34:20 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:51106
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8hjv-0000Zc-CT
	for commit-mailutils@gnu.org; Sun, 02 May 2010 18:34: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 1O8hjv-0006HG-1N
	for commit-mailutils@gnu.org; Sun, 02 May 2010 22:34:19 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1O8hju-00007a-RU
	for commit-mailutils@gnu.org; Sun, 02 May 2010 22:34:19 +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: b4ed41dcc3d0617358b9497d93c675e786109c5c
X-Git-Newrev: 19f93a88c9a2cd1bbe66472514db16c13a333984
Message-Id: <E1O8hju-00007a-RU@vcs-noshell.in.savannah.gnu.org>
Date: Sun, 02 May 2010 22:34:18 +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-98-g19f93a8
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, 02 May 2010 22:34:22 -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=19f93a88c9a2cd1bbe66472514db16c13a333984

The branch, stream-cleanup has been updated
       via  19f93a88c9a2cd1bbe66472514db16c13a333984 (commit)
       via  e8562195618922fa03c6e8ff2036238f1da7b0a4 (commit)
      from  b4ed41dcc3d0617358b9497d93c675e786109c5c (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 19f93a88c9a2cd1bbe66472514db16c13a333984
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 23:21:01 2010 +0300

    Fix readmsg.
    
    Readmsg passes all tests successfully.
    
    * readmsg/msglist.c (msglist): Check return from mu_message_get_streamref.
    * readmsg/readmsg.c (print_header, print_body): Check return values.

commit e8562195618922fa03c6e8ff2036238f1da7b0a4
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun May 2 23:20:39 2010 +0300

    Bugfixes
    
    * mailbox/header.c (header_seek): Do not dereference
    hstr->hdr->size directly, because it may not be initialized yet.
    Use mu_header_size instead.
    * mailbox/message.c (_message_stream_readdelim): Break the loop
    if mu_stream_readdelim returned error or EOF.

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

Summary of changes:
 mailbox/header.c  |   10 ++++++++--
 mailbox/message.c |    2 ++
 readmsg/msglist.c |   23 +++++++++++++++--------
 readmsg/readmsg.c |   19 ++++++++++++++++---
 4 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/mailbox/header.c b/mailbox/header.c
index 9c8fb9f..669093c 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -934,8 +934,14 @@ int
 header_seek (mu_stream_t str, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_header_stream *hstr = (struct _mu_header_stream *) str;
-
-  if (off < 0 || off > hstr->hdr->size)
+  size_t size;
+  int status;
+    
+  status = mu_header_size (hstr->hdr, &size);
+  if (status)
+    return status;
+  
+  if (off < 0 || off > size)
     return ESPIPE;
   hstr->off = off;
   *presult = off;
diff --git a/mailbox/message.c b/mailbox/message.c
index 8111b48..a792ebb 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -240,6 +240,8 @@ _message_stream_readdelim (struct _mu_stream *str, char *buf, size_t bufsize,
       if (sp->state == _mss_eof)
 	break;
       rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &n);
+      if (rc || n == 0)
+	break;
       nread += n;
       buf += n;
       bufsize -= n;
diff --git a/readmsg/msglist.c b/readmsg/msglist.c
index fb4ff99..b42e325 100644
--- a/readmsg/msglist.c
+++ b/readmsg/msglist.c
@@ -118,24 +118,31 @@ msglist (mu_mailbox_t mbox, int show_all, int argc, char **argv,
 	  int found = 0;
 	  for (j = 1; j <= total; j++)
 	    {
+	      int status;
 	      char buf[128];
 	      size_t len = 0;
 	      mu_message_t msg = NULL;
 	      mu_stream_t stream = NULL;
 
 	      mu_mailbox_get_message (mbox, j, &msg);
-	      mu_message_get_streamref (msg, &stream);
-	      while (mu_stream_readline (stream, buf, sizeof buf, &len) == 0
-		     && len > 0)
+	      status = mu_message_get_streamref (msg, &stream);
+	      if (status)
+		mu_error (_("cannot read message: %s"),
+			  mu_strerror (status));
+	      else
 		{
-		  if (strstr (buf, argv[i]) != NULL)
+		  while (mu_stream_readline (stream, buf, sizeof buf, &len) == 0
+			 && len > 0)
 		    {
-		      addset (set, n, j);
-		      found = 1;
-		      break;
+		      if (strstr (buf, argv[i]) != NULL)
+			{
+			  addset (set, n, j);
+			  found = 1;
+			  break;
+			}
 		    }
+		  mu_stream_destroy (&stream);
 		}
-	      mu_stream_destroy (&stream);
 	      if (found && !show_all)
 		break;
 	    }
diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c
index 52c7512..7fdc63b 100644
--- a/readmsg/readmsg.c
+++ b/readmsg/readmsg.c
@@ -222,11 +222,18 @@ print_header (mu_message_t message, int unix_header, int weedc, char **weedv)
     }
   else
     {
+      int status;
       size_t count;
       size_t i;
 
-      mu_header_get_field_count (header, &count);
-
+      status = mu_header_get_field_count (header, &count);
+      if (status)
+	{
+	  mu_error (_("cannot get number of headers: %s"),
+		    mu_strerror (status));
+	  return;
+	}
+      
       for (i = 1; i <= count; i++)
 	{
 	  int j;
@@ -259,6 +266,7 @@ print_header (mu_message_t message, int unix_header, int weedc, char **weedv)
 static void
 print_body (mu_message_t message)
 {
+  int status;
   char buf[128];
   mu_body_t body = NULL;
   mu_stream_t stream = NULL;
@@ -266,7 +274,12 @@ print_body (mu_message_t message)
   mu_message_get_body (message, &body);
 
   /* FIXME: Use mu_stream_copy */
-  mu_body_get_streamref (body, &stream);
+  status = mu_body_get_streamref (body, &stream);
+  if (status)
+    {
+      mu_error (_("cannot get body stream: %s"), mu_strerror (status));
+      return;
+    }
 
   while (mu_stream_read (stream, buf, sizeof (buf) - 1, &len) == 0
 	 && len != 0)


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Thu May 06 17:16:49 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1OA8R6-0006Er-Vt
	for mharc-commit-mailutils@gnu.org; Thu, 06 May 2010 17:16:49 -0400
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1OA8R5-0006Dx-NL
	for commit-mailutils@gnu.org; Thu, 06 May 2010 17:16:47 -0400
Received: from [140.186.70.92] (port=60937 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1OA8R4-0006Cn-8Z
	for commit-mailutils@gnu.org; Thu, 06 May 2010 17:16:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OA8R3-00037h-7d
	for commit-mailutils@gnu.org; Thu, 06 May 2010 17:16:46 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:54114
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OA8R3-00037Z-3G
	for commit-mailutils@gnu.org; Thu, 06 May 2010 17:16:45 -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 1OA8R2-0007Kh-PW
	for commit-mailutils@gnu.org; Thu, 06 May 2010 21:16:44 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OA8R2-0002VA-Kz
	for commit-mailutils@gnu.org; Thu, 06 May 2010 21:16:44 +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: d31b2f980ff7e040103428d9cfb227df6e260c6e
X-Git-Newrev: 622ccfa2e9a3d07b396aa25d08351147caba43ae
Message-Id: <E1OA8R2-0002VA-Kz@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 06 May 2010 21:16:44 +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-79-g622ccfa
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/archive/html/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, 06 May 2010 21:16:47 -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=622ccfa2e9a3d07b396aa25d08351147caba43ae

The branch, master has been updated
       via  622ccfa2e9a3d07b396aa25d08351147caba43ae (commit)
      from  d31b2f980ff7e040103428d9cfb227df6e260c6e (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 622ccfa2e9a3d07b396aa25d08351147caba43ae
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri May 7 00:15:56 2010 +0300

    Minor fix.
    
    * mailbox/rfc2047.c (getword): Initialize *pret to NULL after freeing
    it.

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

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

diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index 64327d9..bc6972b 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -51,6 +51,7 @@ getword (char **pret, const char **pstr, int delim)
   const char *end = strchr (start, delim);
 
   free (*pret);
+  *pret = NULL;
   if (!end)
     return MU_ERR_BAD_2047_INPUT;
   len = end - start;


hooks/post-receive
-- 
GNU Mailutils



From MAILER-DAEMON Tue May 11 07:38:23 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1OBnn5-0005z7-Ht
	for mharc-commit-mailutils@gnu.org; Tue, 11 May 2010 07:38:23 -0400
Received: from [140.186.70.92] (port=48475 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1OBnn2-0005wd-Hx
	for commit-mailutils@gnu.org; Tue, 11 May 2010 07:38:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OBnmx-0002FQ-MP
	for commit-mailutils@gnu.org; Tue, 11 May 2010 07:38:20 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:50627
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OBnmx-0002FM-Kl
	for commit-mailutils@gnu.org; Tue, 11 May 2010 07:38: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 1OBnmx-0002X0-47
	for commit-mailutils@gnu.org; Tue, 11 May 2010 11:38:15 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OBnmw-0005hL-Ua
	for commit-mailutils@gnu.org; Tue, 11 May 2010 11:38: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: 622ccfa2e9a3d07b396aa25d08351147caba43ae
X-Git-Newrev: 0f227206d9cfb38b7023ce60de75877130647dfe
Message-Id: <E1OBnmw-0005hL-Ua@vcs-noshell.in.savannah.gnu.org>
Date: Tue, 11 May 2010 11:38: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-80-g0f22720
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/archive/html/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, 11 May 2010 11:38:22 -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=0f227206d9cfb38b7023ce60de75877130647dfe

The branch, master has been updated
       via  0f227206d9cfb38b7023ce60de75877130647dfe (commit)
      from  622ccfa2e9a3d07b396aa25d08351147caba43ae (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 0f227206d9cfb38b7023ce60de75877130647dfe
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue May 11 14:37:23 2010 +0300

    Fix GINT_INIT usage.
    
    * gint: Update to 4e48677eee5a
    * configure.ac (--without-guile): Remove option. Handled by GINT_INIT.
    (GINT_INIT): Don't call it within a conditional.

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

Summary of changes:
 configure.ac |   34 +++++++++++-----------------------
 gint         |    2 +-
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/configure.ac b/configure.ac
index ad31075..aae7cd3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -306,16 +306,6 @@ if test "$WITH_GNUTLS" != "no"; then
   AC_DEFINE(WITH_TLS,1,[Define if mailutils is using TLS])
 fi
 
-AC_ARG_WITH([guile],
-            AC_HELP_STRING([--without-guile],
-                           [do not build guile interface]),
-            [
-case "${withval}" in
-  yes) useguile=yes ;;
-  no)  useguile=no ;;
-  *)   AC_MSG_ERROR(bad value ${withval} for --without-guile) ;;
-esac],[useguile=yes])
-
 AC_SUBST(SITE_MAIL_RC)
 AC_ARG_WITH([mail-rc],
             AC_HELP_STRING([--with-mail-rc=FILE],
@@ -1078,19 +1068,17 @@ 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
-  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
+GINT_INIT([gint],[1.8 with-guile],
+	  [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])
 
 AM_CONDITIONAL([MU_COND_LIBMU_SCM],[test "$useguile" = "yes"])
 
diff --git a/gint b/gint
index 4254b05..4e48677 160000
--- a/gint
+++ b/gint
@@ -1 +1 @@
-Subproject commit 4254b0590e609b82dac3d688ecb401c9eefb7e25
+Subproject commit 4e48677eee5abf6a7190fc200d3085cc43643322


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue May 11 09:35:38 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1OBpcY-0005Qs-OA
	for mharc-commit-mailutils@gnu.org; Tue, 11 May 2010 09:35:38 -0400
Received: from [140.186.70.92] (port=39373 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1OBpcS-0005Qc-5H
	for commit-mailutils@gnu.org; Tue, 11 May 2010 09:35:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OBpcQ-00061G-Mj
	for commit-mailutils@gnu.org; Tue, 11 May 2010 09:35:32 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:54445
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OBpcQ-000619-L3
	for commit-mailutils@gnu.org; Tue, 11 May 2010 09:35:30 -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 1OBpcP-0003x4-LF
	for commit-mailutils@gnu.org; Tue, 11 May 2010 13:35:29 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OBpcP-0004ep-Ff
	for commit-mailutils@gnu.org; Tue, 11 May 2010 13:35:29 +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: 0f227206d9cfb38b7023ce60de75877130647dfe
X-Git-Newrev: b2c1941415490c40ac146c7426d688a153f930d1
Message-Id: <E1OBpcP-0004ep-Ff@vcs-noshell.in.savannah.gnu.org>
Date: Tue, 11 May 2010 13:35:29 +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-81-gb2c1941
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/archive/html/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, 11 May 2010 13:35:36 -0000

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

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

The branch, master has been updated
       via  b2c1941415490c40ac146c7426d688a153f930d1 (commit)
      from  0f227206d9cfb38b7023ce60de75877130647dfe (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 b2c1941415490c40ac146c7426d688a153f930d1
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue May 11 16:31:27 2010 +0300

    Upgrade gint to a5774356.

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

Summary of changes:
 gint |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gint b/gint
index 4e48677..a577435 160000
--- a/gint
+++ b/gint
@@ -1 +1 @@
-Subproject commit 4e48677eee5abf6a7190fc200d3085cc43643322
+Subproject commit a5774356a1c12d1bcb55b6322710e347e1604fc9


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu May 13 10:25:18 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1OCZLh-00027d-Aj
	for mharc-commit-mailutils@gnu.org; Thu, 13 May 2010 10:25:17 -0400
Received: from [140.186.70.92] (port=39224 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1OCZLc-00024m-Om
	for commit-mailutils@gnu.org; Thu, 13 May 2010 10:25:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OCZLX-00075L-Va
	for commit-mailutils@gnu.org; Thu, 13 May 2010 10:25:09 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:54485
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OCZLX-00075E-Ri
	for commit-mailutils@gnu.org; Thu, 13 May 2010 10:25: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 1OCZLX-0005u0-Hw
	for commit-mailutils@gnu.org; Thu, 13 May 2010 14:25:07 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OCZLV-0004e9-NV
	for commit-mailutils@gnu.org; Thu, 13 May 2010 14:25: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: b2c1941415490c40ac146c7426d688a153f930d1
X-Git-Newrev: d6d78fad1073dc4b1da28696a5aec01b6460ad29
Message-Id: <E1OCZLV-0004e9-NV@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 13 May 2010 14:25: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-83-gd6d78fa
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/archive/html/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, 13 May 2010 14:25:16 -0000

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

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

The branch, master has been updated
       via  d6d78fad1073dc4b1da28696a5aec01b6460ad29 (commit)
       via  ae130d52fd03ccc49e1df6ef92ca0c841a071073 (commit)
      from  b2c1941415490c40ac146c7426d688a153f930d1 (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 d6d78fad1073dc4b1da28696a5aec01b6460ad29
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu May 13 16:54:03 2010 +0300

    MH: Improve handling of not implemented options.
    
    * mh/mh_getopt.c (mh_opt_notimpl, mh_opt_notimpl_warning): New
    functions.
    * mh/mh_getopt.h (mh_opt_notimpl, mh_opt_notimpl_warning): New
    protos.
    * mh/ali.c (doc): Remove 'not implemented' stanza.
    * mh/pick.c: Likewise.
    * mh/anno.c: Use mh_opt_notimpl and mh_opt_notimpl_warning
    for not implemented options.
    * mh/comp.c: Likewise.
    * mh/forw.c: Likewise.
    * mh/mhn.c: Likewise.
    * mh/refile.c: Likewise.
    * mh/repl.c: Likewise.
    * mh/scan.c: Likewise.
    * mh/send.c: Likewise.

commit ae130d52fd03ccc49e1df6ef92ca0c841a071073
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu May 13 16:14:51 2010 +0300

    MH: a bugfix.
    
    * mh/mh_global.c (mh_read_profile): Set MU folder directory to
    mh_get_dir.  This fixes the bug reported by Peter S Galbraith
    (Id. <15312.1273667793@mixed>, ref.
    http://sourceforge.net/mailarchive/forum.php?thread_name=15904.1273699954%40mixed&forum_name=mh-e-devel)

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

Summary of changes:
 mh/ali.c       |    3 +--
 mh/anno.c      |    2 ++
 mh/comp.c      |    6 +++---
 mh/forw.c      |    9 ++++++---
 mh/mh_getopt.c |   13 +++++++++++++
 mh/mh_getopt.h |    3 +++
 mh/mh_global.c |    3 ++-
 mh/mhn.c       |    1 +
 mh/pick.c      |    3 +--
 mh/refile.c    |    1 +
 mh/repl.c      |    9 ++++++---
 mh/scan.c      |    2 +-
 mh/send.c      |   15 +++++++++++++--
 13 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/mh/ali.c b/mh/ali.c
index 851ee1a..088bd35 100644
--- a/mh/ali.c
+++ b/mh/ali.c
@@ -28,8 +28,7 @@
 
 const char *program_version = "ali (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH ali")"\v"
-N_("Options marked with `*' are not yet implemented.\n"
-"Use -help to obtain the list of traditional MH options.");
+N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("aliases ...");
 
 /* GNU options */
diff --git a/mh/anno.c b/mh/anno.c
index 83119c3..8b3319a 100644
--- a/mh/anno.c
+++ b/mh/anno.c
@@ -69,10 +69,12 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
 
     case ARG_INPLACE:
+      mh_opt_notimpl_warning ("-inplace");
       inplace = is_true (arg);
       break;
 
     case ARG_NOINPLACE:
+      mh_opt_notimpl_warning ("-noinplace");
       inplace = 0;
       break;
 
diff --git a/mh/comp.c b/mh/comp.c
index fc13db5..bcc0067 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -140,9 +140,9 @@ opt_handler (int key, char *arg, struct argp_state *state)
       
     case ARG_WHATNOWPROC:
     case ARG_NOWHATNOWPROC:
-      argp_error (state, _("option is not yet implemented"));
-      exit (1);
-      
+      mh_opt_notimpl ("-[no]whatnowproc");
+      break;
+
     case ARG_LICENSE:
       mh_license (argp_program_version);
       break;
diff --git a/mh/forw.c b/mh/forw.c
index 196c794..9597cfb 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -204,11 +204,14 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
       
     case ARG_INPLACE:
+      mh_opt_notimpl_warning ("-inplace");
+      break;
+
     case ARG_WHATNOWPROC:
     case ARG_NOWHATNOWPROC:
-      argp_error (state, _("option is not yet implemented"));
-      exit (1);
-      
+      mh_opt_notimpl ("-[no]whatnowproc");
+      break;
+ 
     case ARG_LICENSE:
       mh_license (argp_program_version);
       break;
diff --git a/mh/mh_getopt.c b/mh/mh_getopt.c
index dbd385a..2a6c949 100644
--- a/mh/mh_getopt.c
+++ b/mh/mh_getopt.c
@@ -150,3 +150,16 @@ mh_help (struct mh_option *mh_opt, const char *doc)
             "Run %s --help for more info on these.\n"),
             mu_program_name);
 }
+
+void
+mh_opt_notimpl (const char *name)
+{
+  mu_error (_("option is not yet implemented: %s"), name);
+  exit (1);
+}
+
+void
+mh_opt_notimpl_warning (const char *name)
+{
+  mu_error (_("ignoring not implemented option %s"), name);
+}
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index bd26f83..b930cf3 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -197,3 +197,6 @@ int mh_argp_parse (int *argc, char **argv[],
 
 void mh_help (struct mh_option *mh_option, const char *doc);
 void mh_license (const char *name);
+
+void mh_opt_notimpl (const char *name);
+void mh_opt_notimpl_warning (const char *name);
diff --git a/mh/mh_global.c b/mh/mh_global.c
index 4cf567d..7b5c054 100644
--- a/mh/mh_global.c
+++ b/mh/mh_global.c
@@ -73,6 +73,8 @@ mh_read_profile ()
   profile = mh_context_create (p, 1);
   mh_context_read (profile);
 
+  mu_set_folder_directory (mh_get_dir ());
+
   mh_set_reply_regex (mh_global_profile_get ("Reply-Regex", NULL));
   fallback = mh_global_profile_get ("Decode-Fallback", NULL);
   if (fallback && mu_set_default_fallback (fallback))
@@ -88,7 +90,6 @@ _mh_init_global_context ()
   
   if (context)
     return;
-  mu_set_folder_directory (mh_get_dir ());
   p = getenv ("CONTEXT");
   if (!p)
     p = MH_CONTEXT_FILE;
diff --git a/mh/mhn.c b/mh/mhn.c
index b54d109..b764e97 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -334,6 +334,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
       /* Display options */
 
     case ARG_SERIALONLY:
+      mh_opt_notimpl_warning ("-[no]serialonly");
       if (is_true (arg))
 	{
 	  mode_options |= OPT_SERIALONLY;
diff --git a/mh/pick.c b/mh/pick.c
index e88aec0..ecf3f8a 100644
--- a/mh/pick.c
+++ b/mh/pick.c
@@ -29,8 +29,7 @@
 
 const char *program_version = "pick (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU MH pick")"\v"
-N_("Options marked with `*' are not yet implemented.\n\
-Use -help to obtain the list of traditional MH options.");
+N_("Use -help to obtain the list of traditional MH options.");
 static char args_doc[] = N_("[messages]");
 
 /* GNU options */
diff --git a/mh/refile.c b/mh/refile.c
index 9cade4c..5bf2faa 100644
--- a/mh/refile.c
+++ b/mh/refile.c
@@ -168,6 +168,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
       
     case ARG_PRESERVE:
+      mh_opt_notimpl_warning ("-preserve");
       preserve_flag = is_true(arg);
       break;
 	
diff --git a/mh/repl.c b/mh/repl.c
index af6b22d..73fba50 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -256,11 +256,14 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
 	  
     case ARG_INPLACE:
+      mh_opt_notimpl_warning ("-inplace");
+      break;
+      
     case ARG_WHATNOWPROC:
     case ARG_NOWHATNOWPROC:
-      argp_error (state, _("Option is not yet implemented"));
-      exit (1);
-      
+      mh_opt_notimpl ("-[no]whatnowproc");
+      break;
+
     case ARG_LICENSE:
       mh_license (argp_program_version);
       break;
diff --git a/mh/scan.c b/mh/scan.c
index cdffca0..36081a8 100644
--- a/mh/scan.c
+++ b/mh/scan.c
@@ -134,7 +134,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
       
     case ARG_FILE:
-      argp_error (state, _("Option is not yet implemented"));
+      mh_opt_notimpl ("-file");
       break;
       
     case ARG_LICENSE:
diff --git a/mh/send.c b/mh/send.c
index 8118d7f..3f92c9d 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -170,30 +170,40 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
       
     case ARG_FILTER:
+      mh_opt_notimpl ("-filter");
+      break;
+
     case ARG_NOFILTER:
-      return 1;
-      
+      mh_opt_notimpl ("-nofilter");
+      break;
+ 
     case ARG_FORMAT:
+      mh_opt_notimpl_warning ("-format"); 
       reformat_recipients = is_true (arg);
       break;
       
     case ARG_NOFORMAT:
+      mh_opt_notimpl_warning ("-noformat"); 
       reformat_recipients = 0;
       break;
       
     case ARG_FORWARD:
+      mh_opt_notimpl_warning ("-forward");
       forward_notice = is_true (arg);
       break;
       
     case ARG_NOFORWARD:
+      mh_opt_notimpl_warning ("-noforward");
       forward_notice = 0;
       break;
       
     case ARG_MIME:
+      mh_opt_notimpl_warning ("-mime");
       mime_encaps = is_true (arg);
       break;
       
     case ARG_NOMIME:
+      mh_opt_notimpl_warning ("-nomime");
       mime_encaps = 0;
       break;
       
@@ -244,6 +254,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
       
     case ARG_WIDTH:
+      mh_opt_notimpl_warning ("-width");
       width = strtoul (arg, &p, 10);
       if (*p)
 	{


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue May 18 07:07:01 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1OEKdZ-0004P8-Cq
	for mharc-commit-mailutils@gnu.org; Tue, 18 May 2010 07:07:01 -0400
Received: from [140.186.70.92] (port=45686 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1OEKdW-0004Oz-9v
	for commit-mailutils@gnu.org; Tue, 18 May 2010 07:06:59 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OEKdS-0002eB-PR
	for commit-mailutils@gnu.org; Tue, 18 May 2010 07:06:58 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:36922
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OEKdS-0002du-Eg
	for commit-mailutils@gnu.org; Tue, 18 May 2010 07:06:54 -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 1OEKdR-00065M-SG
	for commit-mailutils@gnu.org; Tue, 18 May 2010 11:06:53 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OEKdR-0005DI-LB
	for commit-mailutils@gnu.org; Tue, 18 May 2010 11:06:53 +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: d6d78fad1073dc4b1da28696a5aec01b6460ad29
X-Git-Newrev: f73a07073ac2c6b08315371a5b92352a81c0c3cc
Message-Id: <E1OEKdR-0005DI-LB@vcs-noshell.in.savannah.gnu.org>
Date: Tue, 18 May 2010 11:06:53 +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-84-gf73a070
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/archive/html/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, 18 May 2010 11:06:59 -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=f73a07073ac2c6b08315371a5b92352a81c0c3cc

The branch, master has been updated
       via  f73a07073ac2c6b08315371a5b92352a81c0c3cc (commit)
      from  d6d78fad1073dc4b1da28696a5aec01b6460ad29 (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 f73a07073ac2c6b08315371a5b92352a81c0c3cc
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue May 18 14:05:36 2010 +0300

    Bugfix.
    
    * mailbox/url.c (_url_path_default): Fix improper use of
    sizeof (a typo, probably).

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

Summary of changes:
 mailbox/url.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mailbox/url.c b/mailbox/url.c
index 5580f8c..1b833bf 100644
--- a/mailbox/url.c
+++ b/mailbox/url.c
@@ -952,7 +952,7 @@ mu_url_init (mu_url_t url, int port, const char *scheme)
 static char *
 _url_path_default (const char *spooldir, const char *user, int unused)
 {
-  char *mbox = malloc (sizeof(spooldir) + strlen(user) + 2);
+  char *mbox = malloc (strlen (spooldir) + strlen (user) + 2);
   if (!mbox)
     errno = ENOMEM;
   else


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu May 20 09:30:17 2010
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1OF5pJ-0005EY-Cm
	for mharc-commit-mailutils@gnu.org; Thu, 20 May 2010 09:30:17 -0400
Received: from [140.186.70.92] (port=56386 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1OF5p5-00054j-7J
	for commit-mailutils@gnu.org; Thu, 20 May 2010 09:30:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OF5ou-0002Up-9M
	for commit-mailutils@gnu.org; Thu, 20 May 2010 09:30:02 -0400
Received: from colonialone.fsf.org ([140.186.70.51]:35090
	helo=internal.in.savannah.gnu.org)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OF5ou-0002Ug-37
	for commit-mailutils@gnu.org; Thu, 20 May 2010 09:29:52 -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 1OF5ot-0000dJ-70
	for commit-mailutils@gnu.org; Thu, 20 May 2010 13:29:51 +0000
Received: from gray by vcs-noshell.in.savannah.gnu.org with local (Exim 4.69)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1OF5os-0007lT-S9
	for commit-mailutils@gnu.org; Thu, 20 May 2010 13:29:51 +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: f73a07073ac2c6b08315371a5b92352a81c0c3cc
X-Git-Newrev: 7cbbb4012d63c86e8e0726a5634bdd880ffe34b3
Message-Id: <E1OF5os-0007lT-S9@vcs-noshell.in.savannah.gnu.org>
Date: Thu, 20 May 2010 13:29:50 +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-86-g7cbbb40
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/archive/html/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, 20 May 2010 13:30:17 -0000

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

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

The branch, master has been updated
       via  7cbbb4012d63c86e8e0726a5634bdd880ffe34b3 (commit)
       via  7d8bee8e82f7f1bad91371caf511f6eadf13b2f9 (commit)
      from  f73a07073ac2c6b08315371a5b92352a81c0c3cc (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 7cbbb4012d63c86e8e0726a5634bdd880ffe34b3
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu May 20 16:29:36 2010 +0300

    Movemail improved.
    
    * movemail/movemail.c: New options: --ignore-errors and --program-id.
    (_compare_msgno): Remove now unneded static.
    (main): Handle --ignore-errors and --program-id settings.
    Optimize the main loop for the case when --uidls is given.
    Return 1 on errors.
    * doc/texinfo/programs.texi: Document new features.

commit 7d8bee8e82f7f1bad91371caf511f6eadf13b2f9
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu May 20 12:15:36 2010 +0300

    Allow to use `CALL proc' in MySQL queries.
    
    * sql/mysql.c (mu_mysql_connect): Set CLIENT_MULTI_RESULTS flag.

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

Summary of changes:
 doc/texinfo/programs.texi |   60 +++++++++++++++-
 movemail/movemail.c       |  176 ++++++++++++++++++++++++++++++++++-----------
 sql/mysql.c               |    2 +-
 3 files changed, 195 insertions(+), 43 deletions(-)

diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index 118f44b..fe50c7f 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -4369,7 +4369,7 @@ intended as a replacement for @command{movemail} from GNU Emacs. The
 module. @xref{Rmail,,,emacs,Reading Mail with Rmail}, for detailed
 description of @code{Rmail} interface.
 
-Mailutils version of @command{movemail} is completely
+Mailutils version of @command{movemail} is fully
 backward-compatible with its Emacs predecessor, so it should run
 flawlessly with older versions of Emacs. Emacs versions
 starting from 22.1 contain improved @code{Rmail} interface and
@@ -4401,6 +4401,57 @@ If @var{bool} is @samp{true}, reverse message sorting order.
 If @var{bool} is @samp{true}, output information used by Emacs rmail interface.
 @end deffn
 
+@deffn {Movemail Config} ignore-erros @var{bool}
+Continue moving messages after errors.  By default,
+@command{mailfromd} exits immediately if it cannot copy a message.
+@end deffn
+
+@deffn {Movemail Config} program-id @var{fmt}
+Set program identifier, i.e. a string which will prefix all
+diagnostic messages issued by the program.  By default, program
+name is used.
+
+The @var{fmt} is a format string that may contain references to the
+following macro variables (@FIXME-pxref{macro-variables}):
+
+@table @code
+@item progname
+The program name.
+
+@item source
+URL of the source mailbox.
+
+@item source:user
+User part of the source mailbox URL.
+
+@item source:host
+Host part of the source mailbox URL.
+
+@item source:path
+Path part of the source mailbox URL.
+
+@item dest
+URL of the destination mailbox
+
+@item dest:user
+User part of the destination mailbox URL.
+
+@item dest:host
+Host part of the destination mailbox URL.
+
+@item dest:path
+Path part of the destination mailbox URL.
+@end table
+
+Setting @code{program-id} may be necessary if several @code{movemail}
+instances are run simultaneously (e.g. invoked from a script) to
+discern between the instances.  For example:
+
+@smallexample
+program-id "$@{progname@}: $@{source@} => $@{dest@}"
+@end smallexample
+@end deffn
+
 @deffn {Movemail Config} uidl @var{bool}
 Avoid copying the message if a message with the same UIDL already
 exists in the destination mailbox.
@@ -4494,11 +4545,18 @@ Following is the summary of available command line options:
 @item --emacs
 Output information used by Emacs rmail interface
 
+@item --ignore-errors
+Continue moving messages after an error occurs.
+
 @item -p
 @itemx --preserve
 @itemx --keep-messages
 Preserve the source mailbox
 
+@item --program-id=@var{fmt}
+Set program identifier for diagnostic purposes.  See @ref{Movemail
+Configuration,program-id}, for a detailed discussion of this feature. 
+
 @item -r
 @itemx --reverse
 Reverse the sorting order
diff --git a/movemail/movemail.c b/movemail/movemail.c
index a385173..3c91093 100644
--- a/movemail/movemail.c
+++ b/movemail/movemail.c
@@ -37,13 +37,17 @@ const char *program_version = "movemail (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU movemail -- move messages across mailboxes.");
 static char args_doc[] = N_("inbox-url destfile [POP-password]");
 
-#define OPT_EMACS 256
+enum {
+  EMACS_OPTION=256,
+  IGNORE_ERRORS_OPTION,
+  PROGRAM_ID_OPTION
+};
 
 static struct argp_option options[] = {
   { "preserve", 'p', NULL, 0, N_("preserve the source mailbox") },
   { "keep-messages", 0, NULL, OPTION_ALIAS, NULL },
   { "reverse",  'r', NULL, 0, N_("reverse the sorting order") },
-  { "emacs", OPT_EMACS, NULL, 0,
+  { "emacs", EMACS_OPTION, NULL, 0,
     N_("output information used by Emacs rmail interface") },
   { "uidl", 'u', NULL, 0,
     N_("use UIDLs to avoid downloading the same message twice") },
@@ -51,6 +55,10 @@ static struct argp_option options[] = {
     N_("increase verbosity level") },
   { "owner", 'P', N_("MODELIST"), 0,
     N_("control mailbox ownership") },
+  { "ignore-errors", IGNORE_ERRORS_OPTION, NULL, 0,
+    N_("try to continue after errors") },
+  { "program-id", PROGRAM_ID_OPTION, N_("FMT"), 0,
+    N_("set program identifier for diagnostics (default: program name)") },
   { NULL,      0, NULL, 0, NULL, 0 }
 };
 
@@ -59,6 +67,8 @@ static int preserve_mail;
 static int emacs_mode;
 static int uidl_option;
 static int verbose_option;
+static int ignore_errors;
+static char *program_id_option;
 
 enum set_ownership_mode
   {
@@ -135,10 +145,18 @@ parse_opt (int key, char *arg, struct argp_state *state)
       verbose_option++;
       break;
       
-    case OPT_EMACS:
+    case EMACS_OPTION:
       mu_argp_node_list_new (lst, "emacs", "yes");
       break;
 
+    case IGNORE_ERRORS_OPTION:
+      mu_argp_node_list_new (lst, "ignore-errors", "yes");
+      break;
+
+    case PROGRAM_ID_OPTION:
+      mu_argp_node_list_new (lst, "program-id", arg);
+      break;
+      
     case ARGP_KEY_INIT:
       mu_argp_node_list_init (&lst);
       break;
@@ -298,6 +316,10 @@ struct mu_cfg_param movemail_cfg_param[] = {
     N_("Use UIDLs to avoid downloading the same message twice.") },
   { "verbose", mu_cfg_int, &verbose_option, 0, NULL,
     N_("Set verbosity level.") },
+  { "ignore-errors", mu_cfg_bool, &ignore_errors, 0, NULL,
+    N_("Continue after an error.") },
+  { "program-id", mu_cfg_string, &program_id_option, 0, NULL,
+    N_("Set program identifier string (default: program name)") },
   { "mailbox-ownership", mu_cfg_callback, NULL, 0,
     cb_mailbox_ownership,
     N_("Define a list of methods for setting mailbox ownership. Valid "
@@ -633,26 +655,70 @@ _compare_uidls (const void *item, const void *value)
   return strcmp (a->uidl, b->uidl);
 }
 
-static int
-_compare_msgno (const void *item, const void *value)
-{
-  const struct mu_uidl *a = item;
-  const struct mu_uidl *b = value;
-
-  if (a->msgno < b->msgno)
-    return -1;
-  if (a->msgno > b->msgno)
-    return 1;
-  return 0;
+#define __cat2__(a,b) a ## b
+#define DCL_VTX(what)						\
+static int							\
+ __cat2__(_vtx_,what) (const char *name, void *data, char **p)	\
+{								\
+  mu_url_t url = data;			                        \
+  int rc = __cat2__(mu_url_aget_,what) (url, p);                \
+  if (rc == MU_ERR_NOENT)	                                \
+    {                                                           \
+      *p = strdup ("");						\
+      return 0;                                                 \
+    }                                                           \
+  return rc;                                                    \
 }
 
-static int
-msgno_in_list (mu_list_t list, size_t num)
+DCL_VTX (host)
+DCL_VTX (user)
+DCL_VTX (path)
+
+static void
+set_program_id (const char *source_name, const char *dest_name)
 {
-  struct mu_uidl t;
-  t.msgno = num;
-  return mu_list_locate (list, &t, NULL) == 0;
-}  
+  int rc;
+  mu_vartab_t vtab;
+  char *id;
+  mu_url_t url;
+      
+  mu_vartab_create (&vtab);
+  mu_vartab_define (vtab, "progname", mu_program_name, 1);
+  mu_vartab_define (vtab, "source", source_name, 1);
+  rc = mu_mailbox_get_url (source, &url);
+  if (rc)
+    mu_diag_output (MU_DIAG_INFO,
+		    _("cannot obtain source mailbox URL: %s"),
+		    mu_strerror (rc));
+  else
+    {
+      mu_vartab_define_exp (vtab, "source:user", _vtx_user, NULL, url);
+      mu_vartab_define_exp (vtab, "source:host", _vtx_host, NULL, url);
+      mu_vartab_define_exp (vtab, "source:path", _vtx_path, NULL, url);
+    }
+      
+  mu_vartab_define (vtab, "dest", dest_name, 1);
+  rc = mu_mailbox_get_url (dest, &url);
+  if (rc)
+    mu_diag_output (MU_DIAG_INFO,
+		    _("cannot obtain destination mailbox URL: %s"),
+		    mu_strerror (rc));
+  else
+    {
+      mu_vartab_define_exp (vtab, "dest:user", _vtx_user, NULL, url);
+      mu_vartab_define_exp (vtab, "dest:host", _vtx_host, NULL, url);
+      mu_vartab_define_exp (vtab, "dest:path", _vtx_path, NULL, url);
+    }
+      
+  rc = mu_vartab_expand (vtab, program_id_option, &id);
+  mu_vartab_destroy (&vtab);
+  /*      asprintf (&id, "%s: %s", mu_program_name, s);
+	  free (s);*/
+  /* FIXME: Don't use mu_set_program_name here, because it
+     plays wise with its argument. We need a mu_set_diag_prefix
+     function. */
+  mu_program_name = id;
+}
 
 int
 main (int argc, char **argv)
@@ -660,6 +726,7 @@ main (int argc, char **argv)
   int index;
   size_t i, total;
   int rc = 0;
+  int errs = 0;
   char *source_name, *dest_name;
   int flags;
   mu_list_t src_uidl_list = NULL;
@@ -707,6 +774,9 @@ main (int argc, char **argv)
   
   open_mailbox (&dest, dest_name, MU_STREAM_RDWR | MU_STREAM_CREAT, NULL);
 
+  if (program_id_option)
+    set_program_id (source_name, dest_name);
+
   rc = mu_mailbox_messages_count (source, &total);
   if (rc)
     {
@@ -745,43 +815,67 @@ main (int argc, char **argv)
 	}
       mu_iterator_destroy (&itr);
       mu_list_destroy (&dst_uidl_list);
-      mu_list_set_comparator (src_uidl_list, _compare_msgno);
+      mu_list_set_comparator (src_uidl_list, NULL);
     }
-  
-  if (reverse_order)
+
+  /* FIXME: Implementing a mailbox iterator would allow to merge the three
+     branches of this conditional. */
+  if (src_uidl_list)
+    {
+      mu_iterator_t itr;
+
+      rc = mu_list_get_iterator (src_uidl_list, &itr);
+      if (rc)
+	{
+	  mu_error(_("cannot get iterator: %s"), mu_strerror (rc));
+	  exit (1);
+	}
+      rc = mu_iterator_ctl (itr, mu_itrctl_set_direction, &reverse_order);
+      if (rc)
+	{
+	  mu_error(_("cannot set iteration direction: %s"), mu_strerror (rc));
+	  exit (1);
+	}
+      for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
+	   mu_iterator_next (itr))
+	{
+	  struct mu_uidl *uidl;
+	      
+	  mu_iterator_current (itr, (void **)&uidl);
+	  rc = move_message (source, dest, uidl->msgno);
+	  if (rc == 0)
+	    msg_count++;
+	  else if (!ignore_errors)
+	    break;
+	  else
+	    errs = 1;
+	}
+      mu_iterator_destroy (&itr);
+    }
+  else if (reverse_order)
     {
       for (i = total; i > 0; i--)
 	{
-	  if (src_uidl_list && !msgno_in_list (src_uidl_list, i))
-	    {
-	      if (verbose_option > 1)
-		mu_diag_output (MU_DIAG_INFO, _("ignoring message %lu"),
-				(unsigned long) i);
-	      continue;
-	    }
 	  rc = move_message (source, dest, i);
 	  if (rc == 0)
 	    msg_count++;
-	  else
+	  else if (!ignore_errors)
 	    break;
+	  else
+	    errs = 1;
 	}
     }
   else
     {
       for (i = 1; i <= total; i++)
 	{
-	  if (src_uidl_list && !msgno_in_list (src_uidl_list, i))
-	    {
-	      if (verbose_option > 1)
-		mu_diag_output (MU_DIAG_INFO, _("ignoring message %lu"),
-				(unsigned long) i);
-	      continue;
-	    }
 	  rc = move_message (source, dest, i);
 	  if (rc == 0)
 	    msg_count++;
-	  else
+	  else if (!ignore_errors)
 	    break;
+	  else
+	    errs = 1;
 	}
     }
   
@@ -791,7 +885,7 @@ main (int argc, char **argv)
 		    (unsigned long) msg_count);
   
   if (rc)
-    return rc;
+    return !!rc;
   
   mu_mailbox_sync (dest);
   rc = mu_mailbox_close (dest);
@@ -804,5 +898,5 @@ main (int argc, char **argv)
   mu_mailbox_close (source);
   mu_mailbox_destroy (&source);
 
-  return rc;
+  return !(rc == 0 && errs == 0);
 }
diff --git a/sql/mysql.c b/sql/mysql.c
index fd919a7..c573303 100644
--- a/sql/mysql.c
+++ b/sql/mysql.c
@@ -109,7 +109,7 @@ mu_mysql_connect (mu_sql_connection_t conn)
 			  conn->dbname,
 			  conn->port,
 			  socket_name,
-			  0))
+			  CLIENT_MULTI_RESULTS))
     return MU_ERR_SQL;
   
   return 0;


hooks/post-receive
-- 
GNU Mailutils


