From MAILER-DAEMON Tue Nov 01 04:30:36 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RL9jw-0000VM-JN
	for mharc-commit-mailutils@gnu.org; Tue, 01 Nov 2011 04:30:36 -0400
Received: from eggs.gnu.org ([140.186.70.92]:51373)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RL9jn-0000V0-8n
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 04:30:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RL9jj-0000nS-R7
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 04:30:27 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:45067)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RL9jj-0000nN-OP
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 04:30:23 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RL9jh-000677-T3
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 08:30:23 +0000
Date: Tue, 01 Nov 2011 08:30:21 +0000
Message-Id: <E1RL9jh-000677-T3@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-417-g5454ed7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d96764ba829cea2bd2cbd8ff483a11101e74883b
X-Git-Newrev: 5454ed7909380a8fa934b1e1a89d59e62174ab64
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Nov 2011 08:30:34 -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=5454ed7909380a8fa934b1e1a89d59e62174ab64

The branch, master has been updated
       via  5454ed7909380a8fa934b1e1a89d59e62174ab64 (commit)
      from  d96764ba829cea2bd2cbd8ff483a11101e74883b (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 5454ed7909380a8fa934b1e1a89d59e62174ab64
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 1 10:10:34 2011 +0200

    Introduce a better dbm dump format.
    
    * include/mailutils/dbm.h (mu_dbm_get_name): New prototype.
    * libmu_dbm/name.c: New file.
    * libmu_dbm/Makefile.am (libmu_dbm_la_SOURCES): Add name.c
    * mu/dbm.c: New dump format.

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

Summary of changes:
 include/mailutils/dbm.h      |    1 +
 libmu_dbm/Makefile.am        |    1 +
 libmu_dbm/create.c           |    3 +-
 libmu_dbm/{open.c => name.c} |   16 +-
 mu/dbm.c                     | 1149 ++++++++++++++++++++++++++++++++++++++----
 5 files changed, 1051 insertions(+), 119 deletions(-)
 copy libmu_dbm/{open.c => name.c} (78%)

diff --git a/include/mailutils/dbm.h b/include/mailutils/dbm.h
index ab0d5c1..ad04359 100644
--- a/include/mailutils/dbm.h
+++ b/include/mailutils/dbm.h
@@ -73,6 +73,7 @@ int mu_dbm_safety_set_flags (mu_dbm_file_t db, int flags);
 int mu_dbm_safety_check (mu_dbm_file_t db);
 char const *mu_dbm_strerror (mu_dbm_file_t db);
 int mu_dbm_get_fd (mu_dbm_file_t db, int *pag, int *dir);
+int mu_dbm_get_name (mu_dbm_file_t db, const char **pname);
 
 int mu_dbm_impl_iterator (mu_iterator_t *itr);
 
diff --git a/libmu_dbm/Makefile.am b/libmu_dbm/Makefile.am
index 93335d7..548f46f 100644
--- a/libmu_dbm/Makefile.am
+++ b/libmu_dbm/Makefile.am
@@ -29,6 +29,7 @@ libmu_dbm_la_SOURCES = \
  fetch.c\
  firstkey.c\
  getfd.c\
+ name.c\
  nextkey.c\
  open.c\
  safety.c\
diff --git a/libmu_dbm/create.c b/libmu_dbm/create.c
index dec1801..b3e9340 100644
--- a/libmu_dbm/create.c
+++ b/libmu_dbm/create.c
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2011 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
diff --git a/libmu_dbm/open.c b/libmu_dbm/name.c
similarity index 78%
copy from libmu_dbm/open.c
copy to libmu_dbm/name.c
index 5dd4175..94aabae 100644
--- a/libmu_dbm/open.c
+++ b/libmu_dbm/name.c
@@ -18,19 +18,23 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
+#include <unistd.h>
+#include <stdlib.h>
 #include <mailutils/types.h>
+#include <mailutils/list.h>
+#include <mailutils/url.h>
 #include <mailutils/dbm.h>
 #include <mailutils/errno.h>
+#include <mailutils/util.h>
 #include "mudbm.h"
 
 int
-mu_dbm_open (mu_dbm_file_t db, int flags, int mode)
+mu_dbm_get_name (mu_dbm_file_t db, const char **pname)
 {
   if (!db)
     return EINVAL;
-  if (!db->db_sys || !db->db_sys->_dbm_open)
-    return ENOSYS;
-  return db->db_sys->_dbm_open (db, flags, mode);
+  if (!pname)
+    return MU_ERR_OUT_PTR_NULL;
+  *pname = db->db_name;
+  return 0;
 }
-
diff --git a/mu/dbm.c b/mu/dbm.c
index 7f1014f..a33d593 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -51,19 +51,34 @@ enum key_type
     key_regex
   };
 
-enum mode mode;
-char *db_name;
-char *input_file;
-int permissions = 0600;
-struct mu_auth_data *auth;
-uid_t owner_uid = -1;
-gid_t owner_gid = -1;
-int copy_permissions;
-enum key_type key_type = key_literal;
-int case_sensitive = 1;
-int include_zero = -1;
+static enum mode mode;
+static char *db_name;
+static char *input_file;
+static int file_mode = 0600;
+static struct mu_auth_data *auth;
+static uid_t owner_uid;
+static gid_t owner_gid;
+static char *owner_user;
+static char *owner_group;
+static int copy_permissions;
+
+#define META_FILE_MODE 0x0001
+#define META_UID       0x0002
+#define META_GID       0x0004
+#define META_USER      0x0008
+#define META_GROUP     0x0010
+#define META_AUTH      0x0020
+
+static int known_meta_data;
+
+static enum key_type key_type = key_literal;
+static int case_sensitive = 1;
+static int include_zero = -1;
+
+static int suppress_header;
+
 
-void
+static void
 init_datum (struct mu_dbm_datum *key, char *str)
 {
   memset (key, 0, sizeof *key);
@@ -71,11 +86,17 @@ init_datum (struct mu_dbm_datum *key, char *str)
   key->mu_dsize = strlen (str) + !!include_zero;
 }
 
-mu_dbm_file_t
+static mu_dbm_file_t
 open_db_file (int mode)
 {
   int rc;
   mu_dbm_file_t db;
+
+  if (!db_name)
+    {
+      mu_error (_("database name not given"));
+      exit (EX_USAGE);
+    }
   
   rc = mu_dbm_create (db_name, &db);
   if (rc)
@@ -85,56 +106,477 @@ open_db_file (int mode)
       exit (EX_SOFTWARE);
     }
 
-  rc = mu_dbm_open (db, mode, permissions);
+  rc = mu_dbm_open (db, mode, file_mode);
   if (rc)
     {
       mu_diag_funcall (MU_DIAG_ERROR, "mu_dbm_open", db_name, rc);
       exit (EX_SOFTWARE);
     }
 
-  if (mode == MU_STREAM_CREAT && (owner_uid != -1 || owner_gid != -1))
+  return db;
+}
+
+static void
+set_db_ownership (mu_dbm_file_t db)
+{
+  int rc, dirfd, pagfd;
+  struct stat st;
+  
+  rc = mu_dbm_get_fd (db, &pagfd, &dirfd);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_dbm_get_fd", db_name, rc);
+      exit (EX_SOFTWARE);
+    }
+  
+  if (known_meta_data & META_USER)
     {
-      int dirfd, pagfd;
+      struct mu_auth_data *ap;
       
-      rc = mu_dbm_get_fd (db, &pagfd, &dirfd);
-      if (rc)
+      ap = mu_get_auth_by_name (owner_user);
+      if (!ap)
 	{
-	  mu_diag_funcall (MU_DIAG_ERROR, "mu_dbm_get_fd", db_name, rc);
-	  exit (EX_SOFTWARE);
+	  if (!(known_meta_data & META_UID))
+	    {
+	      mu_error (_("no such user: %s"), owner_user);
+	      exit (EX_DATAERR);
+	    }
 	}
-      if (owner_uid == -1 || owner_gid == -1)
+      else
 	{
-	  struct stat st;
-	  
-	  if (fstat (dirfd, &st))
+	  owner_uid = ap->uid;
+	  known_meta_data |= META_UID;
+	  mu_auth_data_free (ap);
+	}
+    }
+  
+  if (known_meta_data & META_GROUP)
+    {
+      struct group *gr = getgrnam (owner_group);
+      if (!gr)
+	{
+	  if (!(known_meta_data & META_GID))
 	    {
-	      mu_diag_funcall (MU_DIAG_ERROR, "fstat", db_name, errno);
-	      exit (EX_SOFTWARE);
+	      mu_error (_("no such group: %s"), owner_group);
+	      exit (EX_DATAERR);
 	    }
-	  if (owner_uid == -1)
-	    owner_uid = st.st_uid;
-	  if (owner_gid == -1)
-	    owner_gid = st.st_gid;
 	}
-      if (fchown (pagfd, owner_uid, owner_gid))
+      else
 	{
-	  mu_diag_funcall (MU_DIAG_ERROR, "fchown", db_name, errno);
+	  owner_gid = gr->gr_gid;
+	  known_meta_data |= META_GID;
+	}
+    }
+  
+  if (fstat (dirfd, &st))
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "fstat", db_name, errno);
+      exit (EX_SOFTWARE);
+    }
+  
+  if (known_meta_data & META_FILE_MODE)
+    {
+      if (fchmod (pagfd, file_mode) ||
+	  (pagfd != dirfd && fchmod (dirfd, file_mode)))
+	{
+	  mu_diag_funcall (MU_DIAG_ERROR, "fchmod", db_name, errno);
 	  exit (EX_SOFTWARE);
 	}
-      if (pagfd != dirfd &&
-	  fchown (dirfd, owner_uid, owner_gid))
+    }	      
+  
+  if (known_meta_data & (META_UID|META_GID))
+    {
+      if (!(known_meta_data & META_UID))
+	owner_uid = st.st_uid;
+      else if (!(known_meta_data & META_GID))
+	owner_gid = st.st_gid;
+      
+      if (fchown (pagfd, owner_uid, owner_gid) ||
+	  (pagfd != dirfd && fchown (dirfd, owner_uid, owner_gid)))
 	{
 	  mu_diag_funcall (MU_DIAG_ERROR, "fchown", db_name, errno);
 	  exit (EX_SOFTWARE);
 	}
     }
-  return db;
 }
+
+
+struct iobuf
+{
+  mu_stream_t stream;
+  char *buffer;
+  size_t bufsize;
+  size_t length;
+  int read;
+};
+
+static int is_dbm_directive (struct iobuf *input);
+static int is_len_directive (struct iobuf *input);
+static int is_ignored_directive (const char *name);
+static int set_directive (char *val);
+static void print_header (const char *name, mu_stream_t str);
+
+static int
+input_getline (struct iobuf *inp)
+{
+  int rc;
+  size_t len;
+
+  if (inp->read)
+    {
+      inp->read = 0;
+      return 0;
+    }
+  
+  while (1)
+    {
+      rc = mu_stream_getline (inp->stream, &inp->buffer, &inp->bufsize, &len);
+      if (rc)
+	return rc;
+      if (len == 0)
+	{
+	  inp->length = 0;
+	  break;
+	}
+      mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
+		       MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
+      inp->length = mu_rtrim_class (inp->buffer, MU_CTYPE_ENDLN);
+      if (inp->buffer[0] == '#' && !is_dbm_directive (inp))
+	{
+	  struct mu_locus loc;
+	  mu_stream_ioctl (mu_strerr,
+			   MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_LOCUS,
+			   &loc);
+	  loc.mu_line = strtoul (inp->buffer + 1, NULL, 10);
+	  mu_stream_ioctl (mu_strerr,
+			   MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS,
+			   &loc);
+	  free (loc.mu_file);
+	  continue;
+	}
+      break;
+    }
+  return 0;
+}
+
+static void
+input_ungetline (struct iobuf *inp)
+{
+  inp->read = 1;
+}
+
+static size_t
+input_length (struct iobuf *inp)
+{
+  return inp->length;
+}
+
+struct xfer_format
+{
+  const char *name;
+  void (*init) (struct xfer_format *fmt, const char *version,
+		struct iobuf *iop, int wr);
+  int (*reader) (struct iobuf *, void *data, struct mu_dbm_datum *key,
+		 struct mu_dbm_datum *content);
+  int (*writer) (struct iobuf *, void *data, struct mu_dbm_datum const *key,
+		 struct mu_dbm_datum const *content);
+  void *data;
+};
+
+static int ascii_reader (struct iobuf *, void *data,
+			 struct mu_dbm_datum *key,
+			 struct mu_dbm_datum *content);
+static int ascii_writer (struct iobuf *, void *data,
+			 struct mu_dbm_datum const *key,
+			 struct mu_dbm_datum const *content);
+
+static void newfmt_init (struct xfer_format *fmt,
+			 const char *version, struct iobuf *iop, int wr);
+
+static int newfmt_reader (struct iobuf *, void *data,
+			  struct mu_dbm_datum *key,
+			  struct mu_dbm_datum *content);
+static int newfmt_writer (struct iobuf *, void *data,
+			  struct mu_dbm_datum const *key,
+			  struct mu_dbm_datum const *content);
+
+static struct xfer_format format_tab[] = {
+  { "0.0", NULL, ascii_reader, ascii_writer, NULL },
+  { "1.0", newfmt_init, newfmt_reader, newfmt_writer, NULL },
+  { NULL }
+};
+static int format_count = MU_ARRAY_SIZE (format_tab) - 1;
+
+static struct xfer_format *format = format_tab;
+static const char *dump_format_version;
+						     
+static int
+read_data (struct iobuf *inp, struct mu_dbm_datum *key,
+	   struct mu_dbm_datum *content)
+{
+  return format->reader (inp, format->data, key, content);
+}
+
+static int
+write_data (struct iobuf *iop, struct mu_dbm_datum const *key,
+	    struct mu_dbm_datum const *content)
+{
+  return format->writer (iop, format->data, key, content);
+}     
+						     
+static int
+select_format (const char *version)
+{
+  struct xfer_format *fmt;
+  char *p;
+  unsigned long n;
+
+  dump_format_version = version;
+  for (fmt = format_tab; fmt->name; fmt++)
+    if (strcmp (fmt->name, version) == 0)
+      {
+	format = fmt;
+	return 0;
+      }
+
+  /* Try version number */
+  errno = 0;
+  n = strtoul (version, &p, 10);
+  if ((*p == 0 || *p == '.') && errno == 0 && n < format_count)
+    {
+      format = format_tab + n;
+      return 0;
+    }
+  mu_error (_("unsupported format version: %s"), version);
+  return 1;
+}
+
+static void
+init_format (int wr, struct iobuf *iop)
+{
+  if (format->init)
+    format->init (format,
+		  dump_format_version ? dump_format_version : format->name,
+		  iop, wr);
+}
+
+
+static int
+ascii_writer (struct iobuf *iop, void *data,
+	      struct mu_dbm_datum const *key,
+	      struct mu_dbm_datum const *content)
+{
+  size_t len;
+
+  if (!data)
+    {
+      if (!suppress_header && include_zero == 1 &&
+	  !is_ignored_directive ("null"))
+	mu_stream_printf (iop->stream, "#:null\n");
+      data = ascii_writer;
+    }
+  
+  len = key->mu_dsize;
+  if (key->mu_dptr[len - 1] == 0)
+    len--;
+  mu_stream_write (iop->stream, key->mu_dptr, len, NULL);
+  mu_stream_write (iop->stream, "\t", 1, NULL);
+
+  len = content->mu_dsize;
+  if (content->mu_dptr[len - 1] == 0)
+    len--;
+  mu_stream_write (iop->stream, content->mu_dptr, len, NULL);
+  mu_stream_write (iop->stream, "\n", 1, NULL);
+  return 0;
+}
+
+static int
+ascii_reader (struct iobuf *inp, void *data MU_ARG_UNUSED,
+	      struct mu_dbm_datum *key,
+	      struct mu_dbm_datum *content)
+{
+  char *kstr, *val;
+  int rc;
+  
+  rc = input_getline (inp);
+  if (rc)
+    {
+      mu_error ("%s", mu_strerror (rc));
+      return -1;
+    }
+  if (input_length (inp) == 0)
+    return 1;
+  kstr = mu_str_stripws (inp->buffer);
+  val = mu_str_skip_class_comp (kstr, MU_CTYPE_SPACE);
+  *val++ = 0;
+  val = mu_str_skip_class (val, MU_CTYPE_SPACE);
+  if (*val == 0)
+    {
+      mu_error (_("malformed line"));
+      key->mu_dsize = 0;
+    }
+  else
+    {
+      init_datum (key, kstr);
+      init_datum (content, val);
+    }
+  return 0;
+}  
+
+static void
+newfmt_init (struct xfer_format *fmt, const char *version,
+	     struct iobuf *iop, int wr)
+{
+  int rc;
+
+  if (!wr)
+    {
+      mu_stream_t flt;
+	
+      rc = mu_linelen_filter_create (&flt, iop->stream, 76, MU_STREAM_WRITE);
+      if (rc)
+	{
+	  mu_diag_funcall (MU_DIAG_ERROR, "mu_linelen_filter_create",
+			   NULL, rc);
+	  exit (EX_SOFTWARE);
+	}
+      iop->stream = flt;
+    }
+  else
+    {
+      mu_opool_t pool;
+      rc = mu_opool_create (&pool, 0);
+      if (rc)
+	{
+	  mu_diag_funcall (MU_DIAG_ERROR, "mu_opool_create",
+			   NULL, rc);
+	  exit (EX_SOFTWARE);
+	}
+      fmt->data = pool;
+    }      
+}
+
+static int
+newfmt_read_datum (struct iobuf *iop, mu_opool_t pool,
+		   struct mu_dbm_datum *datum)
+{
+  int rc;
+  unsigned char *ptr, *out;
+  size_t len;
+
+  mu_dbm_datum_free (datum);
+  
+  rc = input_getline (iop);
+  if (rc)
+    {
+      mu_error ("%s", mu_strerror (rc));
+      exit (EX_UNAVAILABLE);
+    }
+  if (iop->length == 0)
+    return 1;
+  
+  if (!is_len_directive (iop))
+    {
+      mu_error (_("unrecognized input line"));
+      exit (EX_DATAERR);
+    }
+  else
+    {
+      char *p;
+      unsigned long n;
+  
+      errno = 0;
+      n = strtoul (iop->buffer + 6, &p, 10);
+      if (*p || errno)
+	{
+	  mu_error (_("invalid length"));
+	  exit (EX_DATAERR);
+	}
+      datum->mu_dsize = n;
+    }
+
+  mu_opool_clear (pool);
+  while (1)
+    {
+      rc = input_getline (iop);
+      if (rc)
+	{
+	  mu_error ("%s", mu_strerror (rc));
+	  exit (EX_UNAVAILABLE);
+	}
+      if (iop->length == 0)
+	break;
+      if (is_len_directive (iop))
+	{
+	  input_ungetline (iop);
+	  break;
+	}
+      mu_opool_append (pool, iop->buffer, iop->length);
+    }
+
+  ptr = mu_opool_finish (pool, &len);
+  
+  rc = mu_base64_decode (ptr, len, &out, &len);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_base64_decode", NULL, rc);
+      exit (EX_SOFTWARE);
+    }
+
+  mu_dbm_datum_free (datum);
+  
+  datum->mu_dptr = (void*) out;
+  return 0;
+}
+
+static int
+newfmt_reader (struct iobuf *input, void *data,
+	       struct mu_dbm_datum *key,
+	       struct mu_dbm_datum *content)
+{
+  mu_opool_t pool = data;
+  if (newfmt_read_datum (input, pool, key))
+    return 1;
+  if (newfmt_read_datum (input, pool, content))
+    return 1;
+  return 0;
+}
+
+static void
+newfmt_write_datum (struct iobuf *iop, struct mu_dbm_datum const *datum)
+{
+  int rc;
+  
+  mu_stream_printf (iop->stream, "#:len=%lu\n",
+		    (unsigned long) datum->mu_dsize);
+
+  rc = mu_base64_encode ((unsigned char*)datum->mu_dptr, datum->mu_dsize,
+			 (unsigned char **)&iop->buffer, &iop->bufsize);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_base64_encode", NULL, rc);
+      exit (EX_SOFTWARE);
+    }
+  mu_stream_write (iop->stream, iop->buffer, iop->bufsize, NULL);
+  free (iop->buffer); // FIXME
+  mu_stream_write (iop->stream, "\n", 1, NULL);
+}
+
+static int
+newfmt_writer (struct iobuf *iop, void *data,
+	       struct mu_dbm_datum const *key,
+	       struct mu_dbm_datum const *content)
+{
+  newfmt_write_datum (iop, key);
+  newfmt_write_datum (iop, content);
+  return 0;
+}
+
 
 struct print_data
 {
   mu_dbm_file_t db;
-  mu_stream_t stream;
+  struct iobuf iob;
 };
   
 static int
@@ -143,7 +585,69 @@ print_action (struct mu_dbm_datum const *key, void *data)
   int rc;
   struct mu_dbm_datum contents;
   struct print_data *pd = data;
-  size_t len;
+  
+  if (!suppress_header)
+    {
+      int fd;
+      struct stat st;
+      const char *name, *p;
+      rc = mu_dbm_get_fd (pd->db, &fd, NULL);
+      if (rc)
+	{
+	  mu_diag_funcall (MU_DIAG_ERROR, "mu_dbm_get_fd", db_name, rc);
+	  exit (EX_SOFTWARE);
+	}
+      if (fstat (fd, &st))
+	{
+	  mu_diag_funcall (MU_DIAG_ERROR, "fstat", db_name, errno);
+	  exit (EX_UNAVAILABLE);
+	}
+  
+      if (!(known_meta_data & META_UID))
+	{
+	  known_meta_data |= META_UID;
+	  owner_uid = st.st_uid;
+	}
+      if (!(known_meta_data & META_GID))
+	{
+	  known_meta_data |= META_GID;
+	  owner_gid = st.st_gid;
+	}
+      if (!(known_meta_data & META_FILE_MODE))
+	{
+	  known_meta_data |= META_FILE_MODE;
+	  file_mode = st.st_mode & 0777;
+	}
+      
+      if (!(known_meta_data & META_USER))
+	{
+	  struct mu_auth_data *ap = mu_get_auth_by_uid (owner_uid);
+	  if (ap)
+	    {
+	      owner_user = xstrdup (ap->name);
+	      known_meta_data |= META_USER;
+	      mu_auth_data_free (ap);
+	    }
+	}
+
+      if (!(known_meta_data & META_GROUP))
+	{
+	  struct group *gr = getgrgid (owner_gid);
+	  if (gr)
+	    {
+	      owner_group = xstrdup (gr->gr_name);
+	      known_meta_data |= META_GROUP;
+	    }
+	}
+      
+      mu_dbm_get_name (pd->db, &name);
+      p = strrchr (name, '/');
+      if (p)
+	p++;
+      else
+	p = name;
+      print_header (p, mu_strout);
+    }
   
   memset (&contents, 0, sizeof contents);
   rc = mu_dbm_fetch (pd->db, key, &contents);
@@ -152,20 +656,10 @@ print_action (struct mu_dbm_datum const *key, void *data)
       mu_error (_("database fetch error: %s"), mu_dbm_strerror (pd->db));
       exit (EX_UNAVAILABLE);
     }
-
-  len = key->mu_dsize;
-  if (key->mu_dptr[len - 1] == 0)
-    len--;
-  mu_stream_write (pd->stream, key->mu_dptr, len, NULL);
-  mu_stream_write (pd->stream, "\t", 1, NULL);
-
-  len = contents.mu_dsize;
-  if (contents.mu_dptr[len - 1] == 0)
-    len--;
-  mu_stream_write (pd->stream, contents.mu_dptr, len, NULL);
-  mu_stream_write (pd->stream, "\n", 1, NULL);
+  rc = write_data (&pd->iob, key, &contents);
   mu_dbm_datum_free (&contents);
-  return 0;
+  suppress_header = 1;
+  return rc;
 }
 
 static void
@@ -254,7 +748,7 @@ match_regex (const char *str, void *data)
   return 0;
 }
 
-void
+static void
 compile_regexes (int argc, char **argv, struct regmatch *match)
 {
   regex_t *regs = xcalloc (argc, sizeof (regs[0]));
@@ -293,10 +787,13 @@ list_database (int argc, char **argv)
 {
   mu_dbm_file_t db = open_db_file (MU_STREAM_READ);
   struct print_data pdata;
-
+  
+  memset (&pdata, 0, sizeof pdata);
   pdata.db = db;
-  pdata.stream = mu_strout;
+  pdata.iob.stream = mu_strout;
 
+  init_format (0, &pdata.iob);
+  
   if (argc == 0)
     iterate_database (db, NULL, NULL, print_action, &pdata);
   else
@@ -321,23 +818,359 @@ list_database (int argc, char **argv)
 	}
     }
   mu_dbm_destroy (&db);
+  mu_stream_close (pdata.iob.stream);
+}
+
+static int
+is_dbm_directive (struct iobuf *input)
+{
+  return input->length > 2 &&
+         input->buffer[0] == '#' &&
+         input->buffer[1] == ':';
+}
+
+static int
+is_len_directive (struct iobuf *input)
+{
+  return input->length > 6 && memcmp (input->buffer, "#:len=", 6) == 0;
+}
+
+/*
+  #:version=1.0                       # Version number
+  #:filename=S                        # Original database name (basename)
+  #:uid=N,user=S,gid=N,group=S,mode=N # File meta info
+  #:null[=0|1]                        # Null termination (v.0.0 only)
+  #:len=N                             # record length (v.1.0)
+*/
+
+static int
+_set_version (const char *val)
+{
+  if (select_format (val))
+    exit (EX_DATAERR);
+  return 0;
+}
+
+static int
+_set_file (const char *val)
+{
+  if (!db_name)
+    db_name = xstrdup (val);
+  return 0;
+}
+
+static int
+_set_null (const char *val)
+{
+  if (!val)
+    include_zero = 1;
+  else if (val[0] == '0' && val[1] == 0)
+    include_zero = 0;
+  else if (val[0] == '1' && val[1] == 0)
+    include_zero = 1;
+  else
+    {
+      mu_error (_("bad value for `null' directive: %s"), val);
+      exit (EX_DATAERR);
+    }
+  return 0;
+}
+
+static int
+_set_uid (const char *val)
+{
+  char *p;
+  unsigned long n;
+
+  if (known_meta_data & META_UID)
+    return 0;
+  errno = 0;
+  n = strtoul (val, &p, 8);
+  if (*p || errno)
+    {
+      mu_error (_("invalid UID"));
+      exit (EX_DATAERR);
+    }
+  owner_uid = n;
+  known_meta_data |= META_UID;
+  return 0;
+}
+
+static int
+_set_gid (const char *val)
+{
+  char *p;
+  unsigned long n;
+  
+  if (known_meta_data & META_GID)
+    return 0;
+  errno = 0;
+  n = strtoul (val, &p, 8);
+  if (*p || errno)
+    {
+      mu_error (_("invalid GID"));
+      exit (EX_DATAERR);
+    }
+  owner_gid = n;
+  known_meta_data |= META_GID;
+  return 0;
+}
+
+static int
+_set_user (const char *val)
+{
+  if (known_meta_data & META_USER)
+    return 0;
+  free (owner_user);
+  owner_user = xstrdup (val);
+  known_meta_data |= META_USER;
+  return 0;
+}
+
+static int
+_set_group (const char *val)
+{
+  if (known_meta_data & META_GROUP)
+    return 0;
+  free (owner_group);
+  owner_group = xstrdup (val);
+  known_meta_data |= META_GROUP;
+  return 0;
+}
+
+static int
+_set_mode (const char *val)
+{
+  char *p;
+  unsigned long n;
+  
+  if (known_meta_data & META_FILE_MODE)
+    return 0;
+  errno = 0;
+  n = strtoul (val, &p, 8);
+  if (*p || errno || n > 0777)
+    {
+      mu_error (_("invalid file mode"));
+      exit (EX_DATAERR);
+    }
+  file_mode = n;
+  known_meta_data |= META_FILE_MODE;
+  return 0;
+}
+
+struct dbm_directive
+{
+  const char *name;
+  size_t len;
+  int (*set) (const char *val);
+  int flags;
+};
+
+#define DF_VALUE   0x01  /* directive requires a value */
+#define DF_HEADER  0x02  /* can appear only in file header */
+#define DF_PROTECT 0x04  /* directive cannot be ignored */
+#define DF_META    0x08  /* directive keeps file meta-information */
+#define DF_SEEN    0x10  /* directive was already seen */
+#define DF_IGNORE  0x20  /* ignore this directive */
+
+static struct dbm_directive dbm_directive_table[] = {
+#define S(s) #s, sizeof #s - 1
+  { S(version), _set_version, DF_HEADER|DF_VALUE|DF_PROTECT },
+  { S(file),    _set_file,    DF_HEADER|DF_VALUE },
+  { S(uid),     _set_uid,     DF_HEADER|DF_META|DF_VALUE },
+  { S(user),    _set_user,    DF_HEADER|DF_META|DF_VALUE },
+  { S(gid),     _set_gid,     DF_HEADER|DF_META|DF_VALUE },
+  { S(group),   _set_group,   DF_HEADER|DF_META|DF_VALUE },
+  { S(mode),    _set_mode,    DF_HEADER|DF_META|DF_VALUE },
+  { S(null),    _set_null,    DF_HEADER|DF_VALUE },
+  { S(null),    _set_null,    DF_HEADER },
+#undef S
+  { NULL }
+};
+
+static void
+ignore_directives (const char *arg)
+{
+  struct mu_wordsplit ws;
+  size_t i;
+  
+  ws.ws_delim = ",";
+  if (mu_wordsplit (arg, &ws,
+		    MU_WRDSF_NOVAR | MU_WRDSF_NOCMD | MU_WRDSF_DELIM))
+    {
+      mu_error (_("cannot split input line: %s"), mu_wordsplit_strerror (&ws));
+      exit (EX_SOFTWARE);
+    }
+
+  for (i = 0; i < ws.ws_wordc; i++)
+    {
+      char *arg = ws.ws_wordv[i];
+      size_t len = strlen (arg);
+      struct dbm_directive *p;
+      int found = 0;
+      
+      for (p = dbm_directive_table; p->name; p++)
+	{
+	  if (p->len == len && memcmp (p->name, arg, len) == 0)
+	    {
+	      if (p->flags & DF_PROTECT)
+		mu_error (_("directive %s cannot be ignored"), p->name);
+	      else
+		p->flags |= DF_IGNORE;
+	      found = 1;
+	    }
+	}
+      if (!found)
+	mu_error (_("unknown directive: %s"), arg);
+    }
+  mu_wordsplit_free (&ws);
+}
+
+static int
+is_ignored_directive (const char *arg)
+{
+  size_t len = strlen (arg);
+  struct dbm_directive *p;
+      
+  for (p = dbm_directive_table; p->name; p++)
+    {
+      if (p->len == len && memcmp (p->name, arg, len) == 0)
+	return p->flags & DF_IGNORE;
+    }
+  return 0;
 }
+
+static void
+ignore_flagged_directives (int flag)
+{
+  struct dbm_directive *p;
+  
+  for (p = dbm_directive_table; p->name; p++)
+    if (!(p->flags & DF_PROTECT) && (p->flags & flag))
+      p->flags |= DF_IGNORE;
+}
+
+static int
+set_directive (char *val)
+{
+  size_t len;
+  struct dbm_directive *p, *match = NULL;
+
+  mu_ltrim_class (val, MU_CTYPE_BLANK);
+  mu_rtrim_class (val, MU_CTYPE_BLANK);
+  len = strcspn (val, "=");
+  for (p = dbm_directive_table; p->name; p++)
+    {
+      if (p->len == len && memcmp (p->name, val, len) == 0)
+	{
+	  int rc;
+	  
+	  match = p;
+	  if (val[len] == '=')
+	    {
+	      if (!(p->flags & DF_VALUE))
+		continue;
+	    }
+	  else if (p->flags & DF_VALUE)
+	    continue;
+		  
+	  if (p->flags & DF_IGNORE)
+	    return 0;
+	  
+	  if (p->flags & DF_SEEN)
+	    {
+	      mu_error (_("directive %s appeared twice"), val);
+	      return 1;
+	    }
+	  rc = p->set ((p->flags & DF_VALUE) ? val + len + 1 : NULL);
+	  if (p->flags & DF_HEADER)
+	    p->flags |= DF_SEEN;
+	  return rc;
+	}
+    }
+  if (match)
+    {
+      if (match->flags & DF_VALUE)
+	mu_error (_("directive requires argument: %s"), val);
+      else
+	mu_error (_("directive does not take argument: %s"), val);
+    }
+  else
+    mu_error (_("unknown or unsupported directive %s"), val);
+  return 1;
+}
+
+static void
+print_header (const char *name, mu_stream_t str)
+{
+  char *delim;
+  time_t t;
+
+  time (&t);
+  mu_stream_printf (str, "# ");
+  mu_stream_printf (str, _("Database dump file created by %s on %s"),
+		    PACKAGE_STRING,
+		    ctime (&t));
+  mu_stream_printf (str, "#:version=%s\n", format->name);
+  if (!is_ignored_directive ("file"))
+    mu_stream_printf (str, "#:file=%s\n", name);
+
+  delim = "#:";
+  if ((known_meta_data & META_UID) && !is_ignored_directive ("uid"))
+    {
+      mu_stream_printf (str, "%suid=%lu", delim, (unsigned long) owner_uid);
+      delim = ",";
+    }
+  if ((known_meta_data & META_USER) && !is_ignored_directive ("user"))
+    {
+      mu_stream_printf (str, "%suser=%s", delim, owner_user);
+      delim = ",";
+    }
+  
+  if ((known_meta_data & META_GID) && !is_ignored_directive ("gid"))
+    {
+      mu_stream_printf (str, "%sgid=%lu", delim, (unsigned long) owner_gid);
+      delim = ",";
+    }
+
+  if ((known_meta_data & META_GROUP) && !is_ignored_directive ("group"))
+    {
+      mu_stream_printf (str, "%sgroup=%s", delim, owner_group);
+      delim = ",";
+    }
+  
+  if ((known_meta_data & META_FILE_MODE) && !is_ignored_directive ("mode"))
+    mu_stream_printf (str, "%smode=%03o", delim, file_mode);
+
+  if (delim[0] == ',')
+    mu_stream_printf (str, "\n");
+}
+
 
-void
+static void
 add_records (int mode, int replace)
 {
   mu_dbm_file_t db;
-  mu_stream_t input, flt;
+  mu_stream_t instream, flt;
   const char *flt_argv[] = { "inline-comment", "#", "-S", "-i", "#", NULL };
-  char *buf = NULL;
-  size_t size = 0;
-  size_t len;
-  unsigned long line;
   int rc;
+  int save_log_mode = 0, log_mode;
+  struct mu_locus save_locus = { NULL, }, locus;
+  struct mu_dbm_datum key, contents;
+  struct iobuf input;
+  struct mu_wordsplit ws;
+  int wsflags = MU_WRDSF_NOVAR | MU_WRDSF_NOCMD | MU_WRDSF_DELIM;
+  
+  if (mode != MU_STREAM_CREAT)
+    {
+      ignore_flagged_directives (DF_META);
+      known_meta_data = 0;
+    }
   
+  /* Prepare input data */
   if (input_file)
     {
-      rc = mu_file_stream_create (&input, input_file, MU_STREAM_READ);
+      rc = mu_file_stream_create (&instream, input_file, MU_STREAM_READ);
       if (rc)
 	{
 	  mu_error (_("cannot open input file %s: %s"), input_file,
@@ -346,9 +1179,9 @@ add_records (int mode, int replace)
 	}
     }
   else
-    input = mu_strin;
+    instream = mu_strin;
   
-  rc = mu_filter_create_args (&flt, input, "inline-comment",
+  rc = mu_filter_create_args (&flt, instream, "inline-comment",
 			      MU_ARRAY_SIZE (flt_argv) - 1, flt_argv,
 			      MU_FILTER_DECODE, MU_STREAM_READ);
   if (rc)
@@ -356,56 +1189,103 @@ add_records (int mode, int replace)
       mu_diag_funcall (MU_DIAG_ERROR, "mu_filter_create_args", input_file, rc);
       exit (EX_UNAVAILABLE);
     }
-  mu_stream_unref (input);
-  input = flt;
+  mu_stream_unref (instream);
+  instream = flt;
 
-  db = open_db_file (mode);
+  /* Configure error stream to output input file location before each error
+     message */
+  locus.mu_file = input_file ? input_file : "<stdin>";
+  locus.mu_line = 0;
+  locus.mu_col = 0;
+  
+  mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_MODE,
+		   &save_log_mode);
+  mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_LOCUS,
+		   &save_locus);
+  log_mode = save_log_mode | MU_LOGMODE_LOCUS;
+  mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE,
+		   &log_mode);
+  mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS,
+		   &locus);
 
-  line = 1;
-  if (!input_file)
-    input_file = "<stdin>";
-  while ((rc = mu_stream_getline (input, &buf, &size, &len)) == 0
-	 && len > 0)
+  /* Initialize I/O data */
+  memset (&key, 0, sizeof key);
+  memset (&contents, 0, sizeof contents);
+
+  /* Initialize input buffer */
+  input.buffer = NULL;
+  input.bufsize = 0;
+  input.length = 0;
+  input.read = 0;
+  input.stream = instream;
+
+  /* Read directive header */
+  ws.ws_delim = ",";
+  while ((rc = input_getline (&input)) == 0 &&
+	 is_dbm_directive (&input) &&
+	 !is_len_directive (&input))
     {
-      struct mu_dbm_datum key, contents;
-      char *kstr, *val;
-      
-      mu_rtrim_class (buf, MU_CTYPE_ENDLN);
-      if (buf[0] == '#')
+      size_t i;
+
+      if (mu_wordsplit (input.buffer + 2, &ws, wsflags))
 	{
-	  line = strtoul (buf + 1, NULL, 10);
-	  continue;
+	  mu_error (_("cannot split input line: %s"),
+		    mu_wordsplit_strerror (&ws));
+	  exit (EX_SOFTWARE);
 	}
-      kstr = mu_str_stripws (buf);
-      val = mu_str_skip_class_comp (kstr, MU_CTYPE_SPACE);
-      *val++ = 0;
-      val = mu_str_skip_class (val, MU_CTYPE_SPACE);
-      if (*val == 0)
+      for (i = 0; i < ws.ws_wordc; i++)
 	{
-	  mu_error (_("%s:%lu: malformed line"), input_file, line);
-	  line++;
-	  continue;
+	  set_directive (ws.ws_wordv[i]);
 	}
+      wsflags |= MU_WRDSF_REUSE;
+    }
+  if (wsflags & MU_WRDSF_REUSE)
+    mu_wordsplit_free (&ws);
 
-      init_datum (&key, kstr);
-      init_datum (&contents, val);
+  init_format (1, &input);
+  
+  /* Open the database */
+  db = open_db_file (mode);
+  if (known_meta_data)
+    set_db_ownership (db);
+  
+  /* Read and store the actual data */
+  if (rc == 0 && input_length (&input) > 0)
+    {
+      ignore_flagged_directives (DF_HEADER);
+      input_ungetline (&input);
 
-      rc = mu_dbm_store (db, &key, &contents, replace);
-      if (rc)
-	mu_error (_("%s:%lu: cannot store datum: %s"),
-		  input_file, line,
-		  rc == MU_ERR_FAILURE ?
-		     mu_dbm_strerror (db) : mu_strerror (rc));
-      line++;
+      memset (&key, 0, sizeof key);
+      memset (&contents, 0, sizeof contents);
+      
+      while ((rc = read_data (&input, &key, &contents)) == 0)
+	{
+	  if (key.mu_dsize)
+	    {
+	      rc = mu_dbm_store (db, &key, &contents, replace);
+	      if (rc)
+		mu_error (_("cannot store datum: %s"),
+			  rc == MU_ERR_FAILURE ?
+			  mu_dbm_strerror (db) : mu_strerror (rc));
+	    }
+	}
     }
+  
+  mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE,
+		   &save_log_mode);
+  mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS,
+		   &save_locus);
+  
   mu_dbm_destroy (&db);
-
-  mu_stream_unref (input);
+  mu_stream_unref (instream);
 }
 
 static void
 create_database ()
 {
+  if (getuid() != 0)
+    ignore_flagged_directives (DF_META);
+  
   if (copy_permissions)
     {
       struct stat st;
@@ -422,14 +1302,21 @@ create_database ()
 	}
       owner_uid = st.st_uid;
       owner_gid = st.st_gid;
-      permissions = st.st_mode & 0777;
+      file_mode = st.st_mode & 0777;
+      known_meta_data |= META_UID | META_GID | META_FILE_MODE;
     }
   else if (auth)
     {
-      if (owner_uid == -1)
-	owner_uid = auth->uid;
-      if (owner_gid == -1)
-	owner_gid = auth->gid;
+      if (!(known_meta_data & META_UID))
+	{
+	  owner_uid = auth->uid;
+	  known_meta_data |= META_UID;
+	}
+      if (!(known_meta_data & META_GID))
+	{
+	  owner_gid = auth->gid;
+	  known_meta_data |= META_GID;
+	}
     }
   add_records (MU_STREAM_CREAT, 0);
 }
@@ -558,6 +1445,15 @@ static struct argp_option dbm_options[] = {
     N_("set database owner group") },
   { "copy-permissions", 'P', NULL, 0,
     N_("copy database permissions and ownership from the input file") },
+  { "ignore-meta",      'm', NULL, 0,
+    N_("ignore meta-information from input file headers") },
+  { "ignore-directives", 'I', N_("NAMES"), 0,
+    N_("ignore the listed directives") },
+  { NULL, 0, NULL, 0, N_("List modifiers"), 0},
+  { "format",           'H', N_("TYPE"), 0,
+    N_("select output format") },
+  { "no-header",        'q', NULL, 0,
+    N_("suppress format header") },
   { NULL, 0, NULL, 0, N_("List and Delete modifiers"), 0},
   { "glob",        'G', NULL, 0,
     N_("treat keys as globbing patterns") },
@@ -602,13 +1498,18 @@ dbm_parse_opt (int key, char *arg, struct argp_state *state)
       input_file = arg;
       break;
 
+    case 'H':
+      select_format (arg);
+      break;
+      
     case 'p':
       {
 	char *p;
 	unsigned long d = strtoul (arg, &p, 8);
 	if (*p || (d & ~0777))
 	  argp_error (state, _("invalid file mode: %s"), arg);
-	permissions = d;
+	file_mode = d;
+	known_meta_data |= META_FILE_MODE;
       }
       break;
 
@@ -616,17 +1517,27 @@ dbm_parse_opt (int key, char *arg, struct argp_state *state)
       copy_permissions = 1;
       break;
 
+    case 'q':
+      suppress_header = 1;
+      break;
+      
     case 'u':
       auth = mu_get_auth_by_name (arg);
-      if (!auth)
+      if (auth)
+	known_meta_data |= META_AUTH;
+      else
 	{
 	  char *p;
 	  unsigned long n = strtoul (arg, &p, 0);
 	  if (*p == 0)
-	    owner_uid = n;
+	    {
+	      owner_uid = n;
+	      known_meta_data |= META_UID;
+	    }
 	  else
 	    argp_error (state, _("no such user: %s"), arg);
 	}
+      ignore_directives ("user,uid");
       break;
 
     case 'g':
@@ -643,6 +1554,8 @@ dbm_parse_opt (int key, char *arg, struct argp_state *state)
 	  }
 	else
 	  owner_gid = gr->gr_gid;
+	known_meta_data |= META_GID;
+	ignore_directives ("group,gid");
       }
       break;
 
@@ -654,6 +1567,14 @@ dbm_parse_opt (int key, char *arg, struct argp_state *state)
       key_type = key_regex;
       break;
 
+    case 'm':/* FIXME: Why m? */
+      ignore_flagged_directives (DF_META);
+      break;
+
+    case 'I':
+      ignore_directives (arg);
+      break;
+      
     case 'i':
       case_sensitive = 0;
       break;
@@ -686,8 +1607,8 @@ int
 mutool_dbm (int argc, char **argv)
 {
   int index;
-  
-  if (argp_parse (&dbm_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
+
+  if (argp_parse (&dbm_argp, argc, argv, 0, &index, NULL))
     return 1;
 
   argc -= index;
@@ -695,12 +1616,18 @@ mutool_dbm (int argc, char **argv)
 
   if (argc == 0)
     {
-      mu_error (_("database name not given"));
-      exit (EX_USAGE);
+      if (mode != mode_create)
+	{
+	  mu_error (_("database name not given"));
+	  exit (EX_USAGE);
+	}
     }
-  db_name = *argv++;
-  --argc;
-
+  else
+    {
+      db_name = *argv++;
+      --argc;
+    }
+  
   switch (mode)
     {
     case mode_list:


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 01 06:24:50 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RLBWU-0005o3-7E
	for mharc-commit-mailutils@gnu.org; Tue, 01 Nov 2011 06:24:50 -0400
Received: from eggs.gnu.org ([140.186.70.92]:49337)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLBWP-0005ng-1w
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 06:24:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLBWI-00052v-FY
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 06:24:45 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:44430)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLBWI-00052p-Cb
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 06:24:38 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLBWH-00010s-Fr
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 10:24:38 +0000
Date: Tue, 01 Nov 2011 10:24:37 +0000
Message-Id: <E1RLBWH-00010s-Fr@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-418-gfc93493
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 5454ed7909380a8fa934b1e1a89d59e62174ab64
X-Git-Newrev: fc93493b146bd36a01cd689c08a4ddaf95231517
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Nov 2011 10:24:49 -0000

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

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

The branch, master has been updated
       via  fc93493b146bd36a01cd689c08a4ddaf95231517 (commit)
      from  5454ed7909380a8fa934b1e1a89d59e62174ab64 (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 fc93493b146bd36a01cd689c08a4ddaf95231517
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 1 12:20:29 2011 +0200

    mu dbm: improve command line interface.
    
    * mu/dbm.c: Use subcommand (not options) to select operation mode.
    New subcommand: dump.
    * mu/help.c (mutool_help): Make sure argv[0] contains program and
    command name.
    * mu/mu.c (main): Likewise.

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

Summary of changes:
 mu/dbm.c  |  110 ++++++++++++++++++++++++++++++++++--------------------------
 mu/help.c |    3 +-
 mu/mu.c   |    4 ++
 3 files changed, 68 insertions(+), 49 deletions(-)

diff --git a/mu/dbm.c b/mu/dbm.c
index a33d593..9cf3556 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -31,13 +31,22 @@
 #include "mu.h"
 #include "xalloc.h"
 
-static char dbm_doc[] = N_("mu dbm - DBM management tool");
+static char dbm_doc[] = N_("mu dbm - DBM management tool\n"
+"Valid COMMANDs are:\n"
+"\n"
+"  create or load - create the database\n"
+"  list           - list contents of the database\n"
+"  delete         - delete specified keys from the database\n"
+"  add            - add records to the database\n"
+"  replace        - add records replacing ones with matching keys\n");
 char dbm_docstring[] = N_("DBM management tool");
-static char dbm_args_doc[] = N_("FILE [KEY...]");
+static char dbm_args_doc[] = N_("COMMAND FILE [KEY...]");
 
 enum mode
   {
+    mode_unspecified,
     mode_list,
+    mode_dump,
     mode_create,
     mode_delete,
     mode_add,
@@ -75,7 +84,7 @@ static enum key_type key_type = key_literal;
 static int case_sensitive = 1;
 static int include_zero = -1;
 
-static int suppress_header;
+static int suppress_header = -1;
 
 
 static void
@@ -306,9 +315,13 @@ static struct xfer_format format_tab[] = {
   { NULL }
 };
 static int format_count = MU_ARRAY_SIZE (format_tab) - 1;
-
-static struct xfer_format *format = format_tab;
+						     
+#define DEFAULT_LIST_FORMAT (&format_tab[0])
+#define DEFAULT_DUMP_FORMAT (&format_tab[1])
+						     
+static struct xfer_format *format;
 static const char *dump_format_version;
+
 						     
 static int
 read_data (struct iobuf *inp, struct mu_dbm_datum *key,
@@ -328,8 +341,6 @@ static int
 select_format (const char *version)
 {
   struct xfer_format *fmt;
-  char *p;
-  unsigned long n;
 
   dump_format_version = version;
   for (fmt = format_tab; fmt->name; fmt++)
@@ -338,15 +349,6 @@ select_format (const char *version)
 	format = fmt;
 	return 0;
       }
-
-  /* Try version number */
-  errno = 0;
-  n = strtoul (version, &p, 10);
-  if ((*p == 0 || *p == '.') && errno == 0 && n < format_count)
-    {
-      format = format_tab + n;
-      return 0;
-    }
   mu_error (_("unsupported format version: %s"), version);
   return 1;
 }
@@ -1427,16 +1429,9 @@ delete_database (int argc, char **argv)
  */
 
 static struct argp_option dbm_options[] = {
-  { NULL, 0, NULL, 0, N_("Operation mode"), 0},
-  { "create", 'c', NULL, 0, N_("create the database") },
-  { "list",   'l', NULL, 0, N_("list contents of the database") },
-  { "delete", 'd', NULL, 0, N_("delete specified keys from the database") },
-  { "add",    'a', NULL, 0, N_("add records to the database") },
-  { "replace",'r', NULL, 0, N_("add records replacing ones with matching keys") },
-  
-  { NULL, 0, NULL, 0, N_("Create modifiers"), 0},
+  { NULL, 0, NULL, 0, N_("Create Options"), 0},
   { "file",   'f', N_("FILE"), 0,
-    N_("read input from FILE (with --create, --delete, --add and --replace)") },
+    N_("read input from FILE (with create, delete, add and replace)") },
   { "permissions", 'p', N_("NUM"), 0,
     N_("set permissions on the created database") },
   { "user",        'u', N_("USER"), 0,
@@ -1449,19 +1444,19 @@ static struct argp_option dbm_options[] = {
     N_("ignore meta-information from input file headers") },
   { "ignore-directives", 'I', N_("NAMES"), 0,
     N_("ignore the listed directives") },
-  { NULL, 0, NULL, 0, N_("List modifiers"), 0},
+  { NULL, 0, NULL, 0, N_("List and Dump Options"), 0},
   { "format",           'H', N_("TYPE"), 0,
     N_("select output format") },
   { "no-header",        'q', NULL, 0,
     N_("suppress format header") },
-  { NULL, 0, NULL, 0, N_("List and Delete modifiers"), 0},
+  { NULL, 0, NULL, 0, N_("List, Dump and Delete Options"), 0},
   { "glob",        'G', NULL, 0,
     N_("treat keys as globbing patterns") },
   { "regex",       'R', NULL, 0,
     N_("treat keys as regular expressions") },
   { "ignore-case", 'i', NULL, 0,
     N_("case-insensitive matches") },
-  { NULL, 0, NULL, 0, N_("Data length modifiers"), 0 },
+  { NULL, 0, NULL, 0, N_("Options for Use with Format 0.0"), 0 },
   { "count-null",  'N', NULL, 0,
     N_("data length accounts for terminating zero") },
   { "no-count-null", 'n', NULL, 0,
@@ -1474,26 +1469,6 @@ dbm_parse_opt (int key, char *arg, struct argp_state *state)
 {
   switch (key)
     {
-    case 'c':
-      mode = mode_create;
-      break;
-
-    case 'l':
-      mode = mode_list;
-      break;
-
-    case 'd':
-      mode = mode_delete;
-      break;
-
-    case 'a':
-      mode = mode_add;
-      break;
-
-    case 'r':
-      mode = mode_replace;
-      break;
-
     case 'f':
       input_file = arg;
       break;
@@ -1603,6 +1578,18 @@ static struct argp dbm_argp = {
   NULL
 };
 
+struct mu_kwd mode_tab[] =
+{
+  { "add",     mode_add },
+  { "create",  mode_create },
+  { "load",    mode_create },
+  { "list",    mode_list },
+  { "replace", mode_replace },
+  { "delete",  mode_delete },
+  { "dump",    mode_dump },
+  { NULL }
+};
+
 int
 mutool_dbm (int argc, char **argv)
 {
@@ -1616,6 +1603,21 @@ mutool_dbm (int argc, char **argv)
 
   if (argc == 0)
     {
+      mu_error (_("subcommand not given"));
+      exit (EX_USAGE);
+    }
+  
+  if (mu_kwd_xlat_name (mode_tab, argv[0], &index))
+    {
+      mu_error (_("unknown subcommand: %s"), argv[0]);
+      exit (EX_USAGE);
+    }
+  mode = index;
+  argc--;
+  argv++;
+  
+  if (argc == 0)
+    {
       if (mode != mode_create)
 	{
 	  mu_error (_("database name not given"));
@@ -1631,6 +1633,18 @@ mutool_dbm (int argc, char **argv)
   switch (mode)
     {
     case mode_list:
+      if (!format)
+	format = DEFAULT_LIST_FORMAT;
+      if (suppress_header == -1)
+	suppress_header = 1;
+      list_database (argc, argv);
+      break;
+
+    case mode_dump:
+      if (!format)
+	format = DEFAULT_DUMP_FORMAT;
+      if (suppress_header == -1)
+	suppress_header = 0;
       list_database (argc, argv);
       break;
       
diff --git a/mu/help.c b/mu/help.c
index 3162481..d3b6e3a 100644
--- a/mu/help.c
+++ b/mu/help.c
@@ -21,6 +21,7 @@
 #endif
 #include <stdlib.h>
 #include <mailutils/nls.h>
+#include <mailutils/io.h>
 #include "mailutils/libargp.h"
 #include "mu.h"
 
@@ -54,7 +55,7 @@ mutool_help (int argc, char **argv)
 	  mu_error (_("don't know what %s is"), argv[index]);
 	  exit (1);
 	}
-      argv[0] = argv[index];
+      mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[index]);
       argv[1] = "--help";
       return action (2, argv);
     }
diff --git a/mu/mu.c b/mu/mu.c
index 01674e2..19681d7 100644
--- a/mu/mu.c
+++ b/mu/mu.c
@@ -135,6 +135,10 @@ main (int argc, char **argv)
   /* Disable --version option in action. */
   argp_program_version = NULL;
   argp_program_version_hook = NULL;
+
+  /* Reset argv[0] for diagnostic purposes */
+  mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[0]);
+  
   /* Run the action. */
   exit (action (argc, argv));
 }


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 01 07:41:24 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RLCia-0003sZ-OL
	for mharc-commit-mailutils@gnu.org; Tue, 01 Nov 2011 07:41:24 -0400
Received: from eggs.gnu.org ([140.186.70.92]:50501)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLCiY-0003sO-F4
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 07:41:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLCiX-0007ya-9W
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 07:41:22 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:40907)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLCiX-0007yP-2m
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 07:41:21 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLCiV-0005ny-A7
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 11:41:20 +0000
Date: Tue, 01 Nov 2011 11:41:19 +0000
Message-Id: <E1RLCiV-0005ny-A7@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-419-g47f26fa
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: fc93493b146bd36a01cd689c08a4ddaf95231517
X-Git-Newrev: 47f26faaecf71ffc88640f5b139eaf87e59d68f2
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Nov 2011 11:41:23 -0000

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

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

The branch, master has been updated
       via  47f26faaecf71ffc88640f5b139eaf87e59d68f2 (commit)
      from  fc93493b146bd36a01cd689c08a4ddaf95231517 (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 47f26faaecf71ffc88640f5b139eaf87e59d68f2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 1 13:40:32 2011 +0200

    mu dbm: minor fix
    
    * mu/dbm.c (add_records): Initialize format.

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

Summary of changes:
 mu/dbm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mu/dbm.c b/mu/dbm.c
index 9cf3556..8a9995b 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -318,7 +318,8 @@ static int format_count = MU_ARRAY_SIZE (format_tab) - 1;
 						     
 #define DEFAULT_LIST_FORMAT (&format_tab[0])
 #define DEFAULT_DUMP_FORMAT (&format_tab[1])
-						     
+#define DEFAULT_LOAD_FORMAT (&format_tab[0])
+
 static struct xfer_format *format;
 static const char *dump_format_version;
 
@@ -1244,6 +1245,8 @@ add_records (int mode, int replace)
   if (wsflags & MU_WRDSF_REUSE)
     mu_wordsplit_free (&ws);
 
+  if (!format)
+    format = DEFAULT_LOAD_FORMAT;
   init_format (1, &input);
   
   /* Open the database */


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 01 10:43:41 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RLFYz-0000tN-AG
	for mharc-commit-mailutils@gnu.org; Tue, 01 Nov 2011 10:43:41 -0400
Received: from eggs.gnu.org ([140.186.70.92]:56839)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLFYs-0000qJ-PU
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 10:43:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLFYo-00006a-6H
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 10:43:34 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:59700)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLFYn-00006V-W5
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 10:43:30 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RLFYm-0001JM-BM
	for commit-mailutils@gnu.org; Tue, 01 Nov 2011 14:43:29 +0000
Date: Tue, 01 Nov 2011 14:43:28 +0000
Message-Id: <E1RLFYm-0001JM-BM@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-420-g4fe85f7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 47f26faaecf71ffc88640f5b139eaf87e59d68f2
X-Git-Newrev: 4fe85f71cba8d7063f30a4b45fc0cc2f557f8681
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Nov 2011 14:43:39 -0000

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

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

The branch, master has been updated
       via  4fe85f71cba8d7063f30a4b45fc0cc2f557f8681 (commit)
      from  47f26faaecf71ffc88640f5b139eaf87e59d68f2 (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 4fe85f71cba8d7063f30a4b45fc0cc2f557f8681
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 1 16:42:02 2011 +0200

    Minor changes.
    
    * mu/dbm.c: Remove unused variables.
    * mu/wicket.c (wicket_args_doc): Fix argument name.

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

Summary of changes:
 mu/dbm.c    |   12 +++++-------
 mu/wicket.c |    2 +-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/mu/dbm.c b/mu/dbm.c
index 8a9995b..7f275e2 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -44,7 +44,6 @@ static char dbm_args_doc[] = N_("COMMAND FILE [KEY...]");
 
 enum mode
   {
-    mode_unspecified,
     mode_list,
     mode_dump,
     mode_create,
@@ -148,7 +147,7 @@ set_db_ownership (mu_dbm_file_t db)
 	  if (!(known_meta_data & META_UID))
 	    {
 	      mu_error (_("no such user: %s"), owner_user);
-	      exit (EX_DATAERR);
+	      exit (EX_NOUSER);
 	    }
 	}
       else
@@ -314,7 +313,6 @@ static struct xfer_format format_tab[] = {
   { "1.0", newfmt_init, newfmt_reader, newfmt_writer, NULL },
   { NULL }
 };
-static int format_count = MU_ARRAY_SIZE (format_tab) - 1;
 						     
 #define DEFAULT_LIST_FORMAT (&format_tab[0])
 #define DEFAULT_DUMP_FORMAT (&format_tab[1])
@@ -473,7 +471,7 @@ newfmt_read_datum (struct iobuf *iop, mu_opool_t pool,
   if (rc)
     {
       mu_error ("%s", mu_strerror (rc));
-      exit (EX_UNAVAILABLE);
+      exit (EX_IOERR);
     }
   if (iop->length == 0)
     return 1;
@@ -505,7 +503,7 @@ newfmt_read_datum (struct iobuf *iop, mu_opool_t pool,
       if (rc)
 	{
 	  mu_error ("%s", mu_strerror (rc));
-	  exit (EX_UNAVAILABLE);
+	  exit (EX_IOERR);
 	}
       if (iop->length == 0)
 	break;
@@ -892,7 +890,7 @@ _set_uid (const char *val)
   if (*p || errno)
     {
       mu_error (_("invalid UID"));
-      exit (EX_DATAERR);
+      exit (EX_NOUSER);
     }
   owner_uid = n;
   known_meta_data |= META_UID;
@@ -1178,7 +1176,7 @@ add_records (int mode, int replace)
 	{
 	  mu_error (_("cannot open input file %s: %s"), input_file,
 		    mu_strerror (rc));
-	  exit (EX_UNAVAILABLE);
+	  exit (EX_NOINPUT);
 	}
     }
   else
diff --git a/mu/wicket.c b/mu/wicket.c
index 79437dc..f01b148 100644
--- a/mu/wicket.c
+++ b/mu/wicket.c
@@ -24,7 +24,7 @@
 
 static char wicket_doc[] = N_("mu wicket - find matching URL in wicket");
 char wicket_docstring[] = N_("scan wickets for matching URLs");
-static char wicket_args_doc[] = N_("NAME");
+static char wicket_args_doc[] = N_("URL");
 
 static struct argp_option wicket_options[] = {
   { "file",    'f', N_("FILE"), 0, N_("use FILE instead of ~/.mu-tickets") },


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 04 06:22:29 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RMGur-0003dZ-LE
	for mharc-commit-mailutils@gnu.org; Fri, 04 Nov 2011 06:22:29 -0400
Received: from eggs.gnu.org ([140.186.70.92]:55534)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMGuo-0003d4-GL
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 06:22:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMGum-0005mm-6n
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 06:22:26 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:52182)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMGum-0005mi-2p
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 06:22:24 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMGul-0000s6-09
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 10:22:23 +0000
Date: Fri, 04 Nov 2011 10:22:23 +0000
Message-Id: <E1RMGul-0000s6-09@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-422-gbad3c6c
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 4fe85f71cba8d7063f30a4b45fc0cc2f557f8681
X-Git-Newrev: bad3c6c3a982f65af0fe137d1e5b7a98d13bb9d5
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 04 Nov 2011 10:22:28 -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=bad3c6c3a982f65af0fe137d1e5b7a98d13bb9d5

The branch, master has been updated
       via  bad3c6c3a982f65af0fe137d1e5b7a98d13bb9d5 (commit)
       via  325c864eb1b88ac73c39ca3681a02f5194021806 (commit)
      from  4fe85f71cba8d7063f30a4b45fc0cc2f557f8681 (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 bad3c6c3a982f65af0fe137d1e5b7a98d13bb9d5
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 4 12:19:46 2011 +0200

    Implement error_string method in TLS streams.
    
    * include/mailutils/sys/tls-stream.h (_mu_tls_stream_s): Remove.
    * libmailutils/diag/errors (MU_ERR_BAD_RESUMPTION): Remove. Use EAGAIN
    instead.
    (MU_ERR_DISABLED): New error code.
    * libmu_auth/tls.c (_tls_server_open): Return MU_ERR_DISABLED
    when needed.
    (_mu_tls_stream_create): Implement error_string method.
    * libproto/maildir/mbox.c (maildir_msg_init): Fix return value.

commit 325c864eb1b88ac73c39ca3681a02f5194021806
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 4 11:40:20 2011 +0200

    Fix TLS usage.
    
    Remove --tls option.  Make TLS stream open methods call mu_init_tls_libs.
    It is now not necessary to call this function explicitly, unless the
    application wishes to ensure TLS is initialized (e.g. pop3d or imap4d).
    
    * include/mailutils/libargp.h (mu_tls_cmdline): Remove.
    * libmu_argp/tls.c
    * libmu_argp/Makefile.am (libmu_argp_a_SOURCES): Remove tls.c
    * libmu_argp/cmdline.c (all_cmdline_capa): Remove tls.c
    * libmu_auth/tls.c [WITH_TLS] (mu_tls_module_config): Enable by default.
    (mu_check_tls_environment): Return 0 if TLS is disabled.
    (mu_init_tls_libs): Always call gnutls_global_init, otherwise any call
    to TLS library (especially, handshake) can produce a coredump.
    * libmu_cfg/tls.c: Fix description string for tls.enable.
    * mh/mh_init.c (mh_init): Remove call to mu_init_tls_libs, now unnecessary.
    * python/libmu_py/registrar.c: Likewise.
    * testsuite/smtpsend.c: Likewise.

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

Summary of changes:
 include/mailutils/libargp.h        |    1 -
 include/mailutils/sys/tls-stream.h |    9 ----
 libmailutils/diag/errors           |    2 +-
 libmu_argp/Makefile.am             |    3 +-
 libmu_argp/cmdline.c               |    1 -
 libmu_argp/tls.c                   |   74 ------------------------------------
 libmu_auth/tls.c                   |   36 ++++++++++++++---
 libmu_cfg/tls.c                    |    2 +-
 libproto/maildir/mbox.c            |    2 +-
 mh/mh_init.c                       |    3 -
 mu/pop.c                           |    2 +-
 python/libmu_py/registrar.c        |    5 --
 testsuite/smtpsend.c               |    3 -
 13 files changed, 34 insertions(+), 109 deletions(-)
 delete mode 100644 libmu_argp/tls.c

diff --git a/include/mailutils/libargp.h b/include/mailutils/libargp.h
index 5412d27..00b56d0 100644
--- a/include/mailutils/libargp.h
+++ b/include/mailutils/libargp.h
@@ -56,7 +56,6 @@ extern struct mu_cmdline_capa mu_debug_cmdline;
   
 extern struct mu_cmdline_capa mu_pam_cmdline;
 extern struct mu_cmdline_capa mu_gsasl_cmdline;
-extern struct mu_cmdline_capa mu_tls_cmdline;
 extern struct mu_cmdline_capa mu_radius_cmdline;
 extern struct mu_cmdline_capa mu_sql_cmdline;
 extern struct mu_cmdline_capa mu_virtdomain_cmdline;
diff --git a/include/mailutils/sys/tls-stream.h b/include/mailutils/sys/tls-stream.h
index 4c4abc9..bc885e4 100644
--- a/include/mailutils/sys/tls-stream.h
+++ b/include/mailutils/sys/tls-stream.h
@@ -45,13 +45,4 @@ struct _mu_tls_stream
   mu_stream_t transport[2];
 };
 
-struct _mu_tls_stream_s
-{
-  struct _mu_stream stream;
-  enum _mu_tls_stream_state state;
-  gnutls_session session;
-  int tls_err;
-  mu_stream_t transport;
-};
-
 #endif
diff --git a/libmailutils/diag/errors b/libmailutils/diag/errors
index 5b88ef0..6e54fad 100644
--- a/libmailutils/diag/errors
+++ b/libmailutils/diag/errors
@@ -45,7 +45,6 @@ MU_ERR_LOCK_EXT_KILLED      _("External locker killed")
 MU_ERR_NO_SUCH_USER         _("No such user name")
 
 MU_ERR_GETHOSTBYNAME        _("DNS name resolution failed")
-MU_ERR_BAD_RESUMPTION       _("State busy must resume operation")
 MU_ERR_MAILER_BAD_FROM      _("Not a valid sender address")
 MU_ERR_MAILER_BAD_TO        _("Not a valid recipient address")
 MU_ERR_MAILER_NO_RCPT_TO    _("No recipient addresses found")
@@ -123,3 +122,4 @@ MU_ERR_PERM_LINKED_WRDIR    _("Linked file in a writable directory")
 MU_ERR_PERM_DIR_IWGRP       _("File in group writable directory")
 MU_ERR_PERM_DIR_IWOTH       _("File in world writable directory")
 
+MU_ERR_DISABLED             _("Requested feature disabled in configuration")
diff --git a/libmu_argp/Makefile.am b/libmu_argp/Makefile.am
index 0703993..6714949 100644
--- a/libmu_argp/Makefile.am
+++ b/libmu_argp/Makefile.am
@@ -30,6 +30,5 @@ libmu_argp_a_SOURCES =\
  common.c\
  mu_argp.c\
  muinit.c\
- sieve.c\
- tls.c
+ sieve.c
 
diff --git a/libmu_argp/cmdline.c b/libmu_argp/cmdline.c
index 410317a..d478007 100644
--- a/libmu_argp/cmdline.c
+++ b/libmu_argp/cmdline.c
@@ -27,7 +27,6 @@ static struct mu_cmdline_capa *all_cmdline_capa[] = {
   &mu_logging_cmdline,
   &mu_mailer_cmdline,
   &mu_debug_cmdline,
-  &mu_tls_cmdline,
   &mu_sieve_cmdline,
   NULL
 };
diff --git a/libmu_argp/tls.c b/libmu_argp/tls.c
deleted file mode 100644
index fdd1b3f..0000000
--- a/libmu_argp/tls.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see 
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "cmdline.h"
-
-enum {
-  OPT_TLS = 256,         
-};
-  
-static struct argp_option _tls_argp_options[] = {
-  {"tls", OPT_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL,
-   N_("enable TLS support") },
-  {NULL, 0, NULL, 0, NULL, 0}
-};
-
-static error_t
-_tls_argp_parser (int key, char *arg, struct argp_state *state)
-{
-  static mu_list_t lst;
-  
-  switch (key)
-    {
-    case OPT_TLS:
-      mu_argp_node_list_new (lst, "enable", arg ? arg : "yes");
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (lst, "tls", NULL);
-      break;
-      
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
-
-static struct argp _tls_argp = {
-  _tls_argp_options,
-  _tls_argp_parser
-};
-
-static struct argp_child _tls_argp_child = {
-  &_tls_argp,
-  0,
-  NULL,
-  0
-};
-
-struct mu_cmdline_capa mu_tls_cmdline = {
-  "tls", &_tls_argp_child
-};
-
diff --git a/libmu_auth/tls.c b/libmu_auth/tls.c
index b225921..054fb92 100644
--- a/libmu_auth/tls.c
+++ b/libmu_auth/tls.c
@@ -35,7 +35,13 @@
 #include <mailutils/errno.h>
 #include <mailutils/util.h>
 
-struct mu_tls_module_config mu_tls_module_config;
+struct mu_tls_module_config mu_tls_module_config = {
+#ifdef WITH_TLS
+  1 /* enable by default */
+#else
+  0
+#endif
+};
   
 int
 mu_tls_module_init (enum mu_gocs_op op, void *data)
@@ -70,6 +76,8 @@ static gnutls_certificate_server_credentials x509_cred;
 int
 mu_check_tls_environment (void)
 {
+  if (!mu_tls_module_config.enable)
+    return 0;
   if (mu_tls_module_config.ssl_cert && mu_tls_module_config.ssl_key)
     {
       int rc = mu_file_safety_check (mu_tls_module_config.ssl_cert,
@@ -120,7 +128,7 @@ _mu_gtls_logger(int level, const char *text)
 int
 mu_init_tls_libs (void)
 {
-  if (mu_tls_module_config.enable && !mu_tls_enable)
+  if (!mu_tls_enable)
     mu_tls_enable = !gnutls_global_init (); /* Returns 1 on success */
 #ifdef DEBUG_TLS
   gnutls_global_set_log_function (_mu_gtls_logger);
@@ -319,8 +327,6 @@ _mu_tls_io_stream_create (mu_stream_t *pstream,
   sp->stream.close = _tls_io_close;
   sp->stream.done = _tls_io_done; 
   sp->stream.ctl = _tls_io_ioctl;
-  /* FIXME:
-     sp->stream.error_string = _tls_error_string;*/
 
   mu_stream_ref (transport);
   sp->transport = transport;
@@ -354,7 +360,8 @@ _tls_stream_push (gnutls_transport_ptr fd, const void *buf, size_t size)
   rc = mu_stream_write (stream, buf, size, &size);
   if (rc)
     {
-      mu_error ("_tls_stream_push: %s", mu_strerror (rc)); /* FIXME */
+      mu_error ("_tls_stream_push: %s",
+		mu_stream_strerror (stream, rc)); /* FIXME */
       return -1;
     }
 
@@ -370,9 +377,13 @@ _tls_server_open (mu_stream_t stream)
   int rc = 0;
   mu_transport_t transport[2];
   
+  if (!mu_tls_module_config.enable)
+    return MU_ERR_DISABLED;
   if (!stream || sp->state != state_init)
     return EINVAL;
 
+  mu_init_tls_libs ();
+  
   gnutls_certificate_allocate_credentials (&x509_cred);
 
   if (mu_tls_module_config.ssl_cafile)
@@ -473,6 +484,7 @@ _tls_client_open (mu_stream_t stream)
       /* FALLTHROUGH */
       
     case state_init:
+      mu_init_tls_libs ();
       prepare_client_session (stream);
       rc = gnutls_handshake (sp->session);
       if (rc < 0)
@@ -630,6 +642,17 @@ _tls_done (struct _mu_stream *stream)
   mu_stream_destroy (&sp->transport[1]);
 }
 
+static const char *
+_tls_error_string (struct _mu_stream *stream, int rc)
+{
+  if (rc == EIO)
+    {
+      struct _mu_tls_stream *sp = (struct _mu_tls_stream *) stream;
+      return gnutls_strerror (sp->tls_err);
+    }
+  return mu_strerror (rc);
+}
+
 static int
 _mu_tls_stream_create (mu_stream_t *pstream,
 		       int (*openfn) (mu_stream_t stream),
@@ -652,8 +675,7 @@ _mu_tls_stream_create (mu_stream_t *pstream,
   sp->stream.done = _tls_done; 
   sp->stream.ctl = _tls_ioctl;
   sp->stream.wait = _tls_wait;
-  /* FIXME:
-     sp->stream.error_string = _tls_error_string;*/
+  sp->stream.error_string = _tls_error_string;
 
   mu_stream_set_buffer (strin, mu_buffer_none, 0);
   mu_stream_set_buffer (strout, mu_buffer_none, 0);
diff --git a/libmu_cfg/tls.c b/libmu_cfg/tls.c
index c40586b..d659189 100644
--- a/libmu_cfg/tls.c
+++ b/libmu_cfg/tls.c
@@ -77,7 +77,7 @@ cb_safety_checks (void *data, mu_config_value_t *arg)
 
 static struct mu_cfg_param mu_tls_param[] = {
   { "enable", mu_cfg_bool, &tls_settings.enable, 0, NULL,
-    N_("Enable client TLS encryption.") },
+    N_("Enable TLS encryption.") },
   { "ssl-cert", mu_cfg_string, &tls_settings.ssl_cert, 0, NULL,
     N_("Specify SSL certificate file."),
     N_("file") },
diff --git a/libproto/maildir/mbox.c b/libproto/maildir/mbox.c
index 298bdfd..cbdc099 100644
--- a/libproto/maildir/mbox.c
+++ b/libproto/maildir/mbox.c
@@ -478,7 +478,7 @@ maildir_msg_init (struct _amd_data *amd, struct _amd_message *amm)
     }
   free (fname);
   free (name);
-  return MU_ERR_BAD_RESUMPTION;
+  return EAGAIN;
 }
 
 static int
diff --git a/mh/mh_init.c b/mh/mh_init.c
index 7d44c90..d89a05d 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -47,9 +47,6 @@ mh_init ()
   
   /* Register all mailbox and mailer formats */
   mu_register_all_formats ();
-#ifdef WITH_TLS
-  mu_init_tls_libs ();
-#endif
 
   /* Read user's profile */
   mh_read_profile ();
diff --git a/mu/pop.c b/mu/pop.c
index b0d7128..088ebfe 100644
--- a/mu/pop.c
+++ b/mu/pop.c
@@ -677,7 +677,7 @@ mutool_pop (int argc, char **argv)
 
   if (argp_parse (&pop_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
     return 1;
-
+  
   argc -= index;
   argv += index;
 
diff --git a/python/libmu_py/registrar.c b/python/libmu_py/registrar.c
index 0e898bf..cc73646 100644
--- a/python/libmu_py/registrar.c
+++ b/python/libmu_py/registrar.c
@@ -131,9 +131,4 @@ _mu_py_attach_registrar ()
 
   mu_registrar_record (MU_DEFAULT_RECORD);
   mu_registrar_set_default_record (MU_DEFAULT_RECORD);
-
-#ifdef WITH_TLS
-  mu_init_tls_libs ();
-#endif /* WITH_TLS */
-
 }
diff --git a/testsuite/smtpsend.c b/testsuite/smtpsend.c
index 2b0d91a..7eaa670 100644
--- a/testsuite/smtpsend.c
+++ b/testsuite/smtpsend.c
@@ -103,9 +103,6 @@ main (int argc, char **argv)
   
   mu_set_program_name (argv[0]);
   mu_stdstream_setup (MU_STDSTREAM_RESET_NONE);
-#ifdef WITH_TLS
-  mu_init_tls_libs ();
-#endif  
   
   if (argc < 2)
     usage ();


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 04 15:45:23 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RMPhb-0005jl-DX
	for mharc-commit-mailutils@gnu.org; Fri, 04 Nov 2011 15:45:23 -0400
Received: from eggs.gnu.org ([140.186.70.92]:58458)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMPhW-0005jM-1E
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 15:45:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMPhS-0001EA-N3
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 15:45:18 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:57706)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMPhS-0001E5-JT
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 15:45:14 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMPhR-000769-Gy
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 19:45:14 +0000
Date: Fri, 04 Nov 2011 19:45:13 +0000
Message-Id: <E1RMPhR-000769-Gy@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-423-ge1233d5
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: bad3c6c3a982f65af0fe137d1e5b7a98d13bb9d5
X-Git-Newrev: e1233d5516f48cd7d786a69d4eebd40e73d95d45
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 04 Nov 2011 19:45: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=e1233d5516f48cd7d786a69d4eebd40e73d95d45

The branch, master has been updated
       via  e1233d5516f48cd7d786a69d4eebd40e73d95d45 (commit)
      from  bad3c6c3a982f65af0fe137d1e5b7a98d13bb9d5 (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 e1233d5516f48cd7d786a69d4eebd40e73d95d45
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 4 21:30:38 2011 +0200

    Implement pop3s and imap4s in respective servers.
    
    * comsat/comsat.c (comsat_prefork,comsat_connection): Change signatures.
    * imap4d/imap4d.c: Implement imaps.
    * imap4d/imap4d.h (io_setio): Change signature.
    (tls_encryption_on): New proto.
    * imap4d/io.c (io_setio): Change signature.  Initialize TLS stream if
    requested.
    * imap4d/starttls.c (tls_encryption_on): New function.
    * include/mailutils/server.h (mu_srv_config): New struct.
    (mu_m_server_conn_fp, mu_m_server_prefork_fp): Remove typedefs.
    (mu_m_server_handler_fp): New typedef.
    (mu_m_server_set_conn): Change signature.
    (mu_m_server_set_prefork): Change signature.
    (mu_m_server_set_app_data_size)
    (mu_m_server_set_config_size): New prototype.
    (mu_m_server_cfg_init): Change signature.
    * include/mailutils/tls.h (mu_init_tls_libs): Change signature.
    * lib/tcpwrap.c: Include tcpwrap.h
    (mu_tcp_wrapper_daemon): Fix declaration.
    (mu_tcp_wrapper_prefork): Change signature.
    * lib/tcpwrap.h (mu_tcp_wrapper_prefork): Change signature
    * libmailutils/server/msrv.c (_mu_m_server) <conn,prefork>: Change
    data type.  All uses updated.
    <app_data_size>: New member.
    (m_srv_config): Remove struct.  Replaced with mu_srv_config from tls.h
    (mu_m_server_set_conn): Change signature.
    (mu_m_server_set_prefork): Change signature.
    (mu_m_server_set_app_data_size)
    (mu_m_server_set_config_size): New functions.
    (add_server): Allocate app_data_size additional bytes of data.
    (mu_m_server_cfg_init): Take one argument.
    * libmu_auth/tls.c (mu_tls_module_init): Update call to mu_init_tls_libs.
    Don't call mu_file_safety_check with NULL argument.
    (mu_init_tls_libs): Rewrite.  Prepare x509 here, instead of
    doing it each time a TLS stream is created.
    (mu_deinit_tls_libs): Free x509, if exists.
    (_tls_server_open): Update call to mu_init_tls_libs.
    Remove x509 initialization.
    * libmu_cfg/tls.c (cb2_safety_checks): Fix typos.
    * maidag/lmtp.c (lmtp_connection): Change signature.
    * maidag/maidag.c (main): Update call to mu_m_server_cfg_init.
    * maidag/maidag.h (lmtp_connection): Change signature.
    * pop3d/extra.c (pop3d_setio): Initialize TLS stream, if requested.
    * pop3d/pop3d.c: Implement pops.
    * pop3d/pop3d.h (pop3d_setio): Change prototype.

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

Summary of changes:
 comsat/comsat.c                |   16 +++---
 imap4d/imap4d.c                |   38 ++++++++++++-----
 imap4d/imap4d.h                |    3 +-
 imap4d/io.c                    |   17 +++++++-
 imap4d/starttls.c              |   28 +++++++-----
 include/mailutils/server.h     |   30 +++++++++---
 include/mailutils/tls.h        |    2 +-
 lib/tcpwrap.c                  |    8 +++-
 lib/tcpwrap.h                  |    6 ++-
 libmailutils/base/filesafety.c |    4 +-
 libmailutils/server/msrv.c     |   74 +++++++++++++++++--------------
 libmu_auth/tls.c               |   93 +++++++++++++++++++++------------------
 libmu_cfg/tls.c                |    6 +-
 maidag/lmtp.c                  |    9 ++--
 maidag/maidag.c                |    2 +-
 maidag/maidag.h                |    5 +-
 pop3d/extra.c                  |   23 +++++++++-
 pop3d/pop3d.c                  |   43 +++++++++++++-----
 pop3d/pop3d.h                  |    2 +-
 19 files changed, 261 insertions(+), 148 deletions(-)

diff --git a/comsat/comsat.c b/comsat/comsat.c
index e9a5a22..ec73d52 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -320,7 +320,8 @@ static unsigned overflow_count = 0; /* Number of overflows detected during
 				       the current interval */
 
 int
-comsat_prefork (int fd, void *data, struct sockaddr *s, int size)
+comsat_prefork (int fd, struct sockaddr *s, int size,
+		struct mu_srv_config *pconf, void *data)
 {
   int retval = 0;
   time_t now;
@@ -367,15 +368,14 @@ comsat_prefork (int fd, void *data, struct sockaddr *s, int size)
 
 int
 comsat_connection (int fd, struct sockaddr *sa, int salen,
-		   void *data, mu_ip_server_t srv,
-		   time_t to, int transcript)
+		   struct mu_srv_config *pconf, void *data)
 {
   char *buffer;
   size_t rdlen, size;
 
-  if (mu_udp_server_get_rdata (srv, &buffer, &rdlen))
+  if (mu_udp_server_get_rdata (pconf->tcpsrv, &buffer, &rdlen))
     return 0;
-  if (transcript)
+  if (pconf->transcript)
     {
       char *p = mu_sockaddr_to_astr (sa, salen);
       mu_diag_output (MU_DIAG_INFO,
@@ -386,10 +386,10 @@ comsat_connection (int fd, struct sockaddr *sa, int salen,
       mu_diag_output (MU_DIAG_INFO, "string: %s", buffer);
       free (p);
     }
-  mu_udp_server_get_bufsize (srv, &size);
+  mu_udp_server_get_bufsize (pconf->tcpsrv, &size);
   if (size < rdlen + 1)
     {
-      int rc = mu_udp_server_set_bufsize (srv, rdlen + 1);
+      int rc = mu_udp_server_set_bufsize (pconf->tcpsrv, rdlen + 1);
       if (rc)
 	{
 	  mu_error (_("cannot resize buffer: %s"), mu_strerror (rc));
@@ -560,7 +560,7 @@ main (int argc, char **argv)
   mu_argp_init (NULL, NULL);
   comsat_init ();
   mu_acl_cfg_init ();
-  mu_m_server_cfg_init ();
+  mu_m_server_cfg_init (NULL);
   mu_m_server_create (&server, program_version);
   mu_m_server_set_type (server, MU_IP_UDP);
   mu_m_server_set_conn (server, comsat_connection);
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index 035690a..65d678c 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -93,7 +93,7 @@ static const char *imap4d_capa[] = {
   NULL
 };
 
-static int imap4d_mainloop (int, int);
+static int imap4d_mainloop (int, int, int);
 
 static error_t
 imap4d_parse_opt (int key, char *arg, struct argp_state *state)
@@ -242,6 +242,20 @@ cb_mailbox_mode (void *data, mu_config_value_t *val)
   return 0;
 }
 
+struct imap4d_srv_config
+{
+  struct mu_srv_config m_cfg;
+  int tls;
+};
+
+static struct mu_cfg_param imap4d_srv_param[] = {
+  { "tls", mu_cfg_bool, NULL, mu_offsetof (struct imap4d_srv_config, tls),
+    NULL,
+    N_("Use TLS encryption for this server")
+  },
+  { NULL }
+};
+
 static struct mu_cfg_param imap4d_cfg_param[] = {
   { "homedir", mu_cfg_string, &modify_homedir, 0, NULL,
     N_("Modify home directory.") },
@@ -396,7 +410,7 @@ imap4d_child_signal_setup (RETSIGTYPE (*handler) (int signo))
 }
 
 static int
-imap4d_mainloop (int ifd, int ofd)
+imap4d_mainloop (int ifd, int ofd, int tls)
 {
   imap4d_tokbuf_t tokp;
   char *text;
@@ -435,7 +449,7 @@ imap4d_mainloop (int ifd, int ofd)
       imap4d_child_signal_setup (imap4d_child_signal);
     }
   
-  io_setio (ifd, ofd);
+  io_setio (ifd, ofd, tls);
 
   if (imap4d_preauth_setup (ifd) == 0)
     {
@@ -478,13 +492,14 @@ imap4d_mainloop (int ifd, int ofd)
 }
 
 int
-imap4d_connection (int fd, struct sockaddr *sa, int salen, void *data,
-		   mu_ip_server_t srv, time_t timeout, int transcript)
+imap4d_connection (int fd, struct sockaddr *sa, int salen,
+		   struct mu_srv_config *pconf, void *data)
 {
-  idle_timeout = timeout;
-  if (imap4d_transcript != transcript)
-    imap4d_transcript = transcript;
-  imap4d_mainloop (fd, fd);
+  struct imap4d_srv_config *cfg = (struct imap4d_srv_config *) pconf;
+
+  idle_timeout = pconf->timeout;
+  imap4d_transcript = pconf->transcript;
+  imap4d_mainloop (fd, fd, cfg->tls);
   return 0;
 }
 
@@ -559,11 +574,12 @@ main (int argc, char **argv)
   mu_tcpwrapper_cfg_init ();
   manlock_cfg_init ();
   mu_acl_cfg_init ();
-  mu_m_server_cfg_init ();
+  mu_m_server_cfg_init (imap4d_srv_param);
   
   mu_argp_init (NULL, NULL);
 
   mu_m_server_create (&server, program_version);
+  mu_m_server_set_config_size (server, sizeof (struct imap4d_srv_config));
   mu_m_server_set_conn (server, imap4d_connection);
   mu_m_server_set_prefork (server, mu_tcp_wrapper_prefork);
   mu_m_server_set_mode (server, MODE_INTERACTIVE);
@@ -669,7 +685,7 @@ main (int argc, char **argv)
     {
       /* Make sure we are in the root directory.  */
       chdir ("/");
-      status = imap4d_mainloop (MU_STDIN_FD, MU_STDOUT_FD);
+      status = imap4d_mainloop (MU_STDIN_FD, MU_STDOUT_FD, 0);
     }
 
   if (status)
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index 5245e2f..3ece140 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -220,7 +220,7 @@ extern int io_stream_completion_response (mu_stream_t str,
 					  const char *format, ...)
                                     MU_PRINTFLIKE(4,5);
 void io_getline (char **pbuf, size_t *psize, size_t *pnbytes);
-void io_setio (int, int);
+void io_setio (int, int, int);
 void io_flush (void);
 int io_wait_input (int);
   
@@ -297,6 +297,7 @@ extern int  imap4d_select_status (void);
 #ifdef WITH_TLS
 extern int  imap4d_starttls (struct imap4d_command *, imap4d_tokbuf_t);
 extern void starttls_init (void);
+void tls_encryption_on (void);
 #endif /* WITH_TLS */
 extern int  imap4d_status (struct imap4d_command *, imap4d_tokbuf_t);
 extern int  imap4d_store (struct imap4d_command *, imap4d_tokbuf_t);
diff --git a/imap4d/io.c b/imap4d/io.c
index 2033638..c0535fd 100644
--- a/imap4d/io.c
+++ b/imap4d/io.c
@@ -20,7 +20,7 @@
 mu_stream_t iostream;
 
 void
-io_setio (int ifd, int ofd)
+io_setio (int ifd, int ofd, int tls)
 {
   mu_stream_t str, istream, ostream;
   
@@ -38,6 +38,21 @@ io_setio (int ifd, int ofd)
   mu_stream_set_buffer (ostream, mu_buffer_line, 0);
   
   /* Combine the two streams into an I/O one. */
+#ifdef WITH_TLS
+  if (tls)
+    {
+      int rc = mu_tls_server_stream_create (&str, istream, ostream, 0);
+      if (rc)
+	{
+	  mu_stream_unref (istream);
+	  mu_stream_unref (ostream);
+	  mu_error (_("failed to create TLS stream: %s"), mu_strerror (rc));
+	  imap4d_bye (ERR_STREAM_CREATE);
+	}
+      tls_encryption_on ();
+    }
+  else
+#endif
   if (mu_iostream_create (&str, istream, ostream))
     imap4d_bye (ERR_STREAM_CREATE);
 
diff --git a/imap4d/starttls.c b/imap4d/starttls.c
index 5bceb1d..5539903 100644
--- a/imap4d/starttls.c
+++ b/imap4d/starttls.c
@@ -47,18 +47,9 @@ imap4d_starttls (struct imap4d_command *command, imap4d_tokbuf_t tok)
 
   status = io_completion_response (command, RESP_OK, "Begin TLS negotiation");
   io_flush ();
-  tls_done = imap4d_init_tls_server () == 0;
 
-  if (tls_done)
-    {
-      imap4d_capability_remove (IMAP_CAPA_STARTTLS);
-      
-      login_disabled = 0;
-      imap4d_capability_remove (IMAP_CAPA_LOGINDISABLED);
-
-      tls_required = 0;
-      imap4d_capability_remove (IMAP_CAPA_XTLSREQUIRED);
-    }
+  if (imap4d_init_tls_server () == 0)
+    tls_encryption_on ();
   else
     {
       mu_diag_output (MU_DIAG_ERROR, _("session terminated"));
@@ -70,11 +61,24 @@ imap4d_starttls (struct imap4d_command *command, imap4d_tokbuf_t tok)
 }
 
 void
+tls_encryption_on ()
+{
+  tls_done = 1;
+  imap4d_capability_remove (IMAP_CAPA_STARTTLS);
+      
+  login_disabled = 0;
+  imap4d_capability_remove (IMAP_CAPA_LOGINDISABLED);
+
+  tls_required = 0;
+  imap4d_capability_remove (IMAP_CAPA_XTLSREQUIRED);
+}
+
+void
 starttls_init ()
 {
   tls_available = mu_check_tls_environment ();
   if (tls_available)
-    tls_available = mu_init_tls_libs ();
+    tls_available = mu_init_tls_libs (1);
   if (tls_available)
     imap4d_capability_add (IMAP_CAPA_STARTTLS);
 }
diff --git a/include/mailutils/server.h b/include/mailutils/server.h
index c5da97e..896ebee 100644
--- a/include/mailutils/server.h
+++ b/include/mailutils/server.h
@@ -80,20 +80,31 @@ int mu_udp_server_get_rdata (mu_ip_server_t srv, char **pbuf,
 
 
 /* m-server */
+
+struct mu_srv_config       /* Configuration data for a single TCP server. */
+{
+  mu_m_server_t msrv;      /* Parent m-server. */  
+  mu_ip_server_t tcpsrv;   /* TCP server these data are for. */
+  mu_acl_t acl;            /* Access control list for this server. */ 
+  int single_process;      /* Should it run as a single process? */
+  int transcript;          /* Enable session transcript. */
+  time_t timeout;          /* Idle timeout for this server. */
+    /* Application-dependent data may follow */
+};
+
+
 typedef struct mu_m_server_connect_data mu_m_server_connect_data_t;
-typedef int (*mu_m_server_conn_fp) (int fd, struct sockaddr *sa, int salen,
-				    void *data, mu_ip_server_t srv,
-				    time_t timeout, int transcript);
-typedef int (*mu_m_server_prefork_fp) (int, void *,
-				       struct sockaddr *s, int size);
+typedef int (*mu_m_server_handler_fp) (int fd, struct sockaddr *sa, int salen,
+				       struct mu_srv_config *pconf,
+				       void *data);
 
 void mu_m_server_create (mu_m_server_t *psrv, const char *ident);
 void mu_m_server_destroy (mu_m_server_t *pmsrv);
 void mu_m_server_set_mode (mu_m_server_t srv, int mode);
 void mu_m_server_set_type (mu_m_server_t srv, int type);
 void mu_m_server_get_type (mu_m_server_t srv, int *ptype);
-void mu_m_server_set_conn (mu_m_server_t srv, mu_m_server_conn_fp f);
-void mu_m_server_set_prefork (mu_m_server_t srv, mu_m_server_prefork_fp fun);
+void mu_m_server_set_conn (mu_m_server_t srv, mu_m_server_handler_fp f);
+void mu_m_server_set_prefork (mu_m_server_t srv, mu_m_server_handler_fp fun);
 void mu_m_server_set_data (mu_m_server_t srv, void *data);
 void mu_m_server_set_max_children (mu_m_server_t srv, size_t num);
 int mu_m_server_set_pidfile (mu_m_server_t srv, const char *pidfile);
@@ -103,6 +114,8 @@ void mu_m_server_set_timeout (mu_m_server_t srv, time_t t);
 void mu_m_server_set_mode (mu_m_server_t srv, int mode);
 void mu_m_server_set_sigset (mu_m_server_t srv, sigset_t *sigset);
 void mu_m_server_set_strexit (mu_m_server_t srv, const char *(*fun) (int));
+void mu_m_server_set_app_data_size (mu_m_server_t srv, size_t size);
+int mu_m_server_set_config_size (mu_m_server_t srv, size_t size);
 
 int mu_m_server_mode (mu_m_server_t srv);
 int mu_m_server_foreground (mu_m_server_t srv);
@@ -120,7 +133,8 @@ void mu_m_server_end (mu_m_server_t msrv);
 void mu_m_server_stop (int code);
 int mu_m_server_check_acl (mu_m_server_t msrv, struct sockaddr *s, int salen);
 
-void mu_m_server_cfg_init (void);
+struct mu_cfg_param;
+void mu_m_server_cfg_init (struct mu_cfg_param *app_param);
 
 
 #endif
diff --git a/include/mailutils/tls.h b/include/mailutils/tls.h
index 6fdd49a..7fde4f9 100644
--- a/include/mailutils/tls.h
+++ b/include/mailutils/tls.h
@@ -49,7 +49,7 @@ extern int mu_tls_client_stream_create (mu_stream_t *stream,
 					int flags);
 
 extern int mu_check_tls_environment (void);
-extern int mu_init_tls_libs (void);
+extern int mu_init_tls_libs (int x509);
 extern void mu_deinit_tls_libs (void);
 
 extern int mu_tls_enable;
diff --git a/lib/tcpwrap.c b/lib/tcpwrap.c
index 6b8d2ca..6c97a23 100644
--- a/lib/tcpwrap.c
+++ b/lib/tcpwrap.c
@@ -27,9 +27,11 @@
 #include <mailutils/cfg.h>
 #include <mailutils/diag.h>
 #include <mailutils/error.h>
+#include <mailutils/server.h>
+#include "tcpwrap.h"
 
 int mu_tcp_wrapper_enable = 1;
-char *mu_tcp_wrapper_daemon;
+const char *mu_tcp_wrapper_daemon;
 
 #ifdef WITH_LIBWRAP
 # include <tcpd.h>
@@ -93,7 +95,9 @@ mu_tcpwrapper_access (int fd)
 #endif
 
 int
-mu_tcp_wrapper_prefork (int fd, void *data, struct sockaddr *sa, int salen)
+mu_tcp_wrapper_prefork (int fd, struct sockaddr *sa, int salen,
+			struct mu_srv_config *pconf,
+			void *data)
 {
   if (mu_tcp_wrapper_enable
       && sa->sa_family == AF_INET
diff --git a/lib/tcpwrap.h b/lib/tcpwrap.h
index 711bbb8..939889a 100644
--- a/lib/tcpwrap.h
+++ b/lib/tcpwrap.h
@@ -21,8 +21,10 @@ extern int mu_tcp_wrapper_enable;
 const char *mu_tcp_wrapper_daemon;
 extern int mu_tcpwrapper_access (int fd);
 extern void mu_tcpwrapper_cfg_init (void);
-extern int mu_tcp_wrapper_prefork (int fd, void *data,
-				   struct sockaddr *sa, int salen);
+extern int mu_tcp_wrapper_prefork (int fd, 
+				   struct sockaddr *sa, int salen,
+				   struct mu_srv_config *pconf,
+				   void *data);
 
 #ifdef WITH_LIBWRAP
 # define TCP_WRAPPERS_CONFIG { "tcp-wrappers", mu_cfg_section },
diff --git a/libmailutils/base/filesafety.c b/libmailutils/base/filesafety.c
index 6de1e9a..ca075b4 100644
--- a/libmailutils/base/filesafety.c
+++ b/libmailutils/base/filesafety.c
@@ -195,7 +195,9 @@ mu_file_safety_check (const char *filename, int mode,
 		      mu_list_t idlist)
 {
   struct file_check_buffer buf;
-  
+
+  if (!filename)
+    return EFAULT;
   memset (&buf, 0, sizeof (buf));
   if (stat (filename, &buf.filst) == 0)
     {
diff --git a/libmailutils/server/msrv.c b/libmailutils/server/msrv.c
index d5ceb8a..fca9322 100644
--- a/libmailutils/server/msrv.c
+++ b/libmailutils/server/msrv.c
@@ -76,9 +76,10 @@ struct _mu_m_server
 				    objects. It is cleared after the objects
 				    are opened and attached to the server. */
   
-  mu_m_server_conn_fp conn;      /* Connection handler function. */
-  mu_m_server_prefork_fp prefork;/* Pre-fork function. */
+  mu_m_server_handler_fp conn;   /* Connection handler function. */
+  mu_m_server_handler_fp prefork;/* Pre-fork function. */
   void *data;                    /* User-supplied data for conn and prefork. */
+  size_t app_data_size;
   
   int mode;                      /* Server mode: should be removed. */
   
@@ -98,16 +99,6 @@ struct _mu_m_server
 				    description. */
 };
 
-struct m_srv_config        /* Configuration data for a single TCP server. */
-{
-  mu_m_server_t msrv;      /* Parent m-server. */  
-  mu_ip_server_t tcpsrv;   /* TCP server these data are for. */
-  mu_acl_t acl;            /* Access control list for this server. */ 
-  int single_process;      /* Should it run as a single process? */
-  int transcript;          /* Enable session transcript. */
-  time_t timeout;          /* Idle timeout for this server. */
-};
-
 
 static int need_cleanup = 0;
 static int stop = 0; /* FIXME: Must be per-m-server */
@@ -326,13 +317,13 @@ mu_m_server_set_mode (mu_m_server_t srv, int mode)
 }
 
 void
-mu_m_server_set_conn (mu_m_server_t srv, mu_m_server_conn_fp conn)
+mu_m_server_set_conn (mu_m_server_t srv, mu_m_server_handler_fp conn)
 {
   srv->conn = conn;
 }
 
 void
-mu_m_server_set_prefork (mu_m_server_t srv, mu_m_server_prefork_fp fun)
+mu_m_server_set_prefork (mu_m_server_t srv, mu_m_server_handler_fp fun)
 {
   srv->prefork = fun;
 }
@@ -433,9 +424,24 @@ mu_m_server_foreground (mu_m_server_t srv)
 }
 
 void
-m_srv_config_free (void *data)
+mu_m_server_set_app_data_size (mu_m_server_t srv, size_t size)
+{
+  srv->app_data_size = size;
+}
+
+int
+mu_m_server_set_config_size (mu_m_server_t srv, size_t size)
+{
+  if (size < sizeof (struct mu_srv_config))
+    return EINVAL;
+  srv->app_data_size = size - sizeof (struct mu_srv_config);
+  return 0;
+}
+
+void
+mu_srv_config_free (void *data)
 {
-  struct m_srv_config *pconf = data;
+  struct mu_srv_config *pconf = data;
   /* FIXME */
   free (pconf);
 }
@@ -444,15 +450,15 @@ static int m_srv_conn (int fd, struct sockaddr *sa, int salen,
 		       void *server_data, void *call_data,
 		       mu_ip_server_t srv);
 
-static struct m_srv_config *
+static struct mu_srv_config *
 add_server (mu_m_server_t msrv, struct mu_sockaddr *s, int type)
 {
   mu_ip_server_t tcpsrv;
-  struct m_srv_config *pconf;
+  struct mu_srv_config *pconf;
 
   MU_ASSERT (mu_ip_server_create (&tcpsrv, s, type)); /* FIXME: type */
   MU_ASSERT (mu_ip_server_set_conn (tcpsrv, m_srv_conn));
-  pconf = calloc (1, sizeof (*pconf));
+  pconf = calloc (1, sizeof (*pconf) + msrv->app_data_size);
   if (!pconf)
     {
       mu_error ("%s", mu_strerror (ENOMEM));
@@ -462,7 +468,7 @@ add_server (mu_m_server_t msrv, struct mu_sockaddr *s, int type)
   pconf->tcpsrv = tcpsrv;
   pconf->single_process = 0;
   pconf->timeout = msrv->timeout;
-  MU_ASSERT (mu_ip_server_set_data (tcpsrv, pconf, m_srv_config_free));
+  MU_ASSERT (mu_ip_server_set_data (tcpsrv, pconf, mu_srv_config_free));
   if (!msrv->srvlist)
     MU_ASSERT (mu_list_create (&msrv->srvlist));
   MU_ASSERT (mu_list_append (msrv->srvlist, tcpsrv));
@@ -681,7 +687,7 @@ m_srv_conn (int fd, struct sockaddr *sa, int salen,
 	    mu_ip_server_t srv)
 {
   int status;
-  struct m_srv_config *pconf = server_data;
+  struct mu_srv_config *pconf = server_data;
   
   if (mu_m_server_check_acl (pconf->msrv, sa, salen))
     return 0;
@@ -701,7 +707,7 @@ m_srv_conn (int fd, struct sockaddr *sa, int salen,
           return 0;
         }
       if (pconf->msrv->prefork
-	  && pconf->msrv->prefork (fd, pconf->msrv->data, sa, salen))
+	  && pconf->msrv->prefork (fd, sa, salen, pconf, pconf->msrv->data))
 	return 0;
       
       pid = fork ();
@@ -711,8 +717,8 @@ m_srv_conn (int fd, struct sockaddr *sa, int salen,
 	{
 	  mu_ip_server_shutdown (srv); /* FIXME: does it harm for MU_IP_UDP? */
 	  mu_m_server_restore_signals (pconf->msrv);
-	  status = pconf->msrv->conn (fd, sa, salen, pconf->msrv->data, srv,
-				      pconf->timeout, pconf->transcript);
+	  status = pconf->msrv->conn (fd, sa, salen, pconf,
+				      pconf->msrv->data);
 	  closelog ();
 	  exit (status);
 	}
@@ -722,9 +728,9 @@ m_srv_conn (int fd, struct sockaddr *sa, int salen,
 	}
     }
   else if (!pconf->msrv->prefork
-	   || pconf->msrv->prefork (fd, pconf->msrv->data, sa, salen) == 0)
-    pconf->msrv->conn (fd, sa, salen, pconf->msrv->data, srv,
-		       pconf->timeout, pconf->transcript);
+	   || pconf->msrv->prefork (fd, sa, salen, pconf,
+				    pconf->msrv->data) == 0)
+    pconf->msrv->conn (fd, sa, salen, pconf, pconf->msrv->data);
   return 0;
 }
 
@@ -802,7 +808,7 @@ server_section_parser (enum mu_cfg_section_stage stage,
 
     case mu_cfg_section_end:
       {
-	struct m_srv_config *pconf = *section_data;
+	struct mu_srv_config *pconf = *section_data;
 	if (pconf->acl)
 	  mu_ip_server_set_acl (pconf->tcpsrv, pconf->acl);
       }
@@ -904,22 +910,22 @@ static struct mu_cfg_param dot_server_cfg_param[] = {
     
 static struct mu_cfg_param server_cfg_param[] = {
   { "single-process", mu_cfg_bool, 
-    NULL, mu_offsetof (struct m_srv_config, single_process), NULL,
+    NULL, mu_offsetof (struct mu_srv_config, single_process), NULL,
     N_("Run this server in foreground.") },
   { "transcript", mu_cfg_bool,
-    NULL, mu_offsetof (struct m_srv_config, transcript), NULL,
+    NULL, mu_offsetof (struct mu_srv_config, transcript), NULL,
     N_("Log the session transcript.") },
   { "timeout", mu_cfg_time,
-    NULL, mu_offsetof (struct m_srv_config, timeout), NULL,
+    NULL, mu_offsetof (struct mu_srv_config, timeout), NULL,
     N_("Set idle timeout.") },
   { "acl", mu_cfg_section,
-    NULL, mu_offsetof (struct m_srv_config, acl), NULL,
+    NULL, mu_offsetof (struct mu_srv_config, acl), NULL,
     N_("Global access control list.") },
   { NULL }
 };
 
 void
-mu_m_server_cfg_init ()
+mu_m_server_cfg_init (struct mu_cfg_param *app_param)
 {
   struct mu_cfg_section *section;
   if (mu_create_canned_section ("server", &section) == 0)
@@ -927,6 +933,8 @@ mu_m_server_cfg_init ()
       section->parser = server_section_parser;
       section->label = N_("ipaddr[:port]");
       mu_cfg_section_add_params (section, server_cfg_param);
+      if (app_param)
+	mu_cfg_section_add_params (section, app_param);
     }
   if (mu_create_canned_section (".server", &section) == 0)
     {
diff --git a/libmu_auth/tls.c b/libmu_auth/tls.c
index 054fb92..ef8df93 100644
--- a/libmu_auth/tls.c
+++ b/libmu_auth/tls.c
@@ -55,7 +55,7 @@ mu_tls_module_init (enum mu_gocs_op op, void *data)
       
     case mu_gocs_op_flush:
 #ifdef WITH_TLS
-      mu_init_tls_libs ();
+      mu_init_tls_libs (0);
 #endif    
       break;
     }
@@ -99,14 +99,17 @@ mu_check_tls_environment (void)
 	  return 0;
 	}
 
-      rc = mu_file_safety_check (mu_tls_module_config.ssl_cafile,
-				 mu_tls_module_config.ssl_cafile_safety_checks,
-				 -1, NULL);
-      if (rc)
+      if (mu_tls_module_config.ssl_cafile)
 	{
-	  mu_error ("%s: %s", mu_tls_module_config.ssl_cafile, 
-		    mu_strerror (rc));
-	  return 0;
+	  rc = mu_file_safety_check (mu_tls_module_config.ssl_cafile,
+			       mu_tls_module_config.ssl_cafile_safety_checks,
+				     -1, NULL);
+	  if (rc)
+	    {
+	      mu_error ("%s: %s", mu_tls_module_config.ssl_cafile, 
+			mu_strerror (rc));
+	      return 0;
+	    }
 	}
     }
   else
@@ -126,10 +129,40 @@ _mu_gtls_logger(int level, const char *text)
 #endif
 
 int
-mu_init_tls_libs (void)
+mu_init_tls_libs (int x509_setup)
 {
   if (!mu_tls_enable)
-    mu_tls_enable = !gnutls_global_init (); /* Returns 1 on success */
+    {
+      int rc;
+      if ((rc = gnutls_global_init ()) == GNUTLS_E_SUCCESS)
+	mu_tls_enable = 1;
+      else
+	{
+	  mu_error ("gnutls_global_init: %s", gnutls_strerror (rc));
+	  return 0;
+	}
+    }
+
+  if (x509_setup && !x509_cred)
+    {
+      mu_diag_output (MU_DIAG_INFO, _("initializing X509..."));
+      gnutls_certificate_allocate_credentials (&x509_cred);
+      if (mu_tls_module_config.ssl_cafile)
+	gnutls_certificate_set_x509_trust_file (x509_cred,
+						mu_tls_module_config.ssl_cafile,
+						GNUTLS_X509_FMT_PEM);
+  
+      gnutls_certificate_set_x509_key_file (x509_cred,
+					    mu_tls_module_config.ssl_cert, 
+					    mu_tls_module_config.ssl_key,
+					    GNUTLS_X509_FMT_PEM);
+      
+      gnutls_dh_params_init (&dh_params);
+      gnutls_dh_params_generate2 (dh_params, DH_BITS);
+      gnutls_certificate_set_dh_params (x509_cred, dh_params);
+      mu_diag_output (MU_DIAG_INFO, _("finished initializing X509"));
+    }
+  
 #ifdef DEBUG_TLS
   gnutls_global_set_log_function (_mu_gtls_logger);
   gnutls_global_set_log_level (110);
@@ -141,17 +174,14 @@ void
 mu_deinit_tls_libs (void)
 {
   if (mu_tls_enable)
-    gnutls_global_deinit ();
+    {
+      if (x509_cred)
+	gnutls_certificate_free_credentials (x509_cred);
+      gnutls_global_deinit ();
+    }
   mu_tls_enable = 0;
 }
 
-static void
-generate_dh_params (void)
-{
-  gnutls_dh_params_init (&dh_params);
-  gnutls_dh_params_generate2 (dh_params, DH_BITS);
-}
-
 static gnutls_session
 initialize_tls_session (void)
 {
@@ -382,28 +412,8 @@ _tls_server_open (mu_stream_t stream)
   if (!stream || sp->state != state_init)
     return EINVAL;
 
-  mu_init_tls_libs ();
+  mu_init_tls_libs (1);
   
-  gnutls_certificate_allocate_credentials (&x509_cred);
-
-  if (mu_tls_module_config.ssl_cafile)
-    gnutls_certificate_set_x509_trust_file (x509_cred,
-					    mu_tls_module_config.ssl_cafile,
-					    GNUTLS_X509_FMT_PEM);
-  
-  rc = gnutls_certificate_set_x509_key_file (x509_cred,
-					     mu_tls_module_config.ssl_cert, 
-					     mu_tls_module_config.ssl_key,
-					     GNUTLS_X509_FMT_PEM);
-  if (rc < 0)
-    {
-      sp->tls_err = rc;
-      return EIO;
-    }
-  
-  generate_dh_params ();
-  gnutls_certificate_set_dh_params (x509_cred, dh_params);
-
   sp->session = initialize_tls_session ();
   mu_stream_ioctl (stream, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, transport);
   gnutls_transport_set_ptr2 (sp->session,
@@ -478,13 +488,12 @@ _tls_client_open (mu_stream_t stream)
   switch (sp->state)
     {
     case state_closed:
-      gnutls_certificate_free_credentials (x509_cred);
       if (sp->session)
 	gnutls_deinit (sp->session);
       /* FALLTHROUGH */
       
     case state_init:
-      mu_init_tls_libs ();
+      mu_init_tls_libs (0);
       prepare_client_session (stream);
       rc = gnutls_handshake (sp->session);
       if (rc < 0)
@@ -630,8 +639,6 @@ _tls_done (struct _mu_stream *stream)
 {
   struct _mu_tls_stream *sp = (struct _mu_tls_stream *) stream;
   
-  if (x509_cred)
-    gnutls_certificate_free_credentials (x509_cred);
   if (sp->session && sp->state == state_closed)
     {
       gnutls_deinit (sp->session);
diff --git a/libmu_cfg/tls.c b/libmu_cfg/tls.c
index d659189..8bcc518 100644
--- a/libmu_cfg/tls.c
+++ b/libmu_cfg/tls.c
@@ -52,11 +52,11 @@ cb2_safety_checks (const char *name, void *data)
 {
   int defval;
   
-  if (data == &tls_settings.ssl_key)
+  if (data == &tls_settings.ssl_key_safety_checks)
     defval = SSL_KEY_FILE_CHECKS;
-  else if (data == &tls_settings.ssl_cert)
+  else if (data == &tls_settings.ssl_cert_safety_checks)
     defval = SSL_CERT_FILE_CHECKS;
-  else if (data == &tls_settings.ssl_cafile)
+  else if (data == &tls_settings.ssl_cafile_safety_checks)
     defval = SSL_CA_FILE_CHECKS;
   else
     {
diff --git a/maidag/lmtp.c b/maidag/lmtp.c
index f493b67..12f4214 100644
--- a/maidag/lmtp.c
+++ b/maidag/lmtp.c
@@ -574,8 +574,9 @@ typedef union
 } all_addr_t;
 
 int
-lmtp_connection (int fd, struct sockaddr *sa, int salen, void *data,
-		 mu_ip_server_t srv, time_t timeout, int transcript)
+lmtp_connection (int fd, struct sockaddr *sa, int salen,
+		 struct mu_srv_config *pconf,
+		 void *data)
 {
   mu_stream_t str;
   int rc;
@@ -588,9 +589,9 @@ lmtp_connection (int fd, struct sockaddr *sa, int salen, void *data,
     }
   mu_stream_set_buffer (str, mu_buffer_line, 0);
 
-  if (transcript || maidag_transcript)
+  if (pconf->transcript || maidag_transcript)
     str = lmtp_transcript (str);
-  lmtp_loop (str, timeout);
+  lmtp_loop (str, pconf->timeout);
   mu_stream_destroy (&str);
   return 0;
 }
diff --git a/maidag/maidag.c b/maidag/maidag.c
index eee6d83..decbe91 100644
--- a/maidag/maidag.c
+++ b/maidag/maidag.c
@@ -525,7 +525,7 @@ main (int argc, char *argv[])
 
   mu_tcpwrapper_cfg_init ();
   mu_acl_cfg_init ();
-  mu_m_server_cfg_init ();
+  mu_m_server_cfg_init (NULL);
   maidag_cfg_init ();
   
   /* Parse command line */
diff --git a/maidag/maidag.h b/maidag/maidag.h
index 5125fe7..1c59b19 100644
--- a/maidag/maidag.h
+++ b/maidag/maidag.h
@@ -150,8 +150,9 @@ int deliver_to_user (mu_message_t msg, char *dest_id, char **errp);
 
 int maidag_stdio_delivery (maidag_delivery_fn fun, int argc, char **argv);
 int maidag_lmtp_server (void);
-int lmtp_connection (int fd, struct sockaddr *sa, int salen, void *data,
-		     mu_ip_server_t srv, time_t timeout, int transcript);
+int lmtp_connection (int fd, struct sockaddr *sa, int salen,
+		     struct mu_srv_config *pconf,
+		     void *data);
 
 void maidag_error (const char *fmt, ...) MU_PRINTFLIKE(1, 2);
 void notify_biff (mu_mailbox_t mbox, char *name, size_t size);
diff --git a/pop3d/extra.c b/pop3d/extra.c
index c2d1c42..83f468a 100644
--- a/pop3d/extra.c
+++ b/pop3d/extra.c
@@ -93,6 +93,10 @@ pop3d_abquit (int reason)
       mu_diag_output (MU_DIAG_INFO, _("no socket to send to"));
       break;
 
+    case ERR_FILE:
+      code = EX_IOERR;
+      break;
+      
     case ERR_PROTO:
       code = EX_PROTOCOL;
       mu_diag_output (MU_DIAG_INFO, _("remote protocol error"));
@@ -125,7 +129,7 @@ pop3d_abquit (int reason)
 }
 
 void
-pop3d_setio (int ifd, int ofd)
+pop3d_setio (int ifd, int ofd, int tls)
 {
   mu_stream_t str, istream, ostream;
   
@@ -137,11 +141,26 @@ pop3d_setio (int ifd, int ofd)
   if (mu_stdio_stream_create (&istream, ifd, MU_STREAM_READ))
     pop3d_abquit (ERR_NO_IFILE);
   mu_stream_set_buffer (istream, mu_buffer_line, 0);
-  
+
   if (mu_stdio_stream_create (&ostream, ofd, MU_STREAM_WRITE))
     pop3d_abquit (ERR_NO_OFILE);
 
   /* Combine the two streams into an I/O one. */
+#ifdef WITH_TLS
+  if (tls)
+    {
+      int rc = mu_tls_server_stream_create (&str, istream, ostream, 0);
+      if (rc)
+	{
+	  mu_stream_unref (istream);
+	  mu_stream_unref (ostream);
+	  mu_error (_("failed to create TLS stream: %s"), mu_strerror (rc));
+	  pop3d_abquit (ERR_FILE);
+	}
+      tls_done = 1;
+    }
+  else
+#endif
   if (mu_iostream_create (&str, istream, ostream))
     pop3d_abquit (ERR_FILE);
 
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 4a15b38..3df0551 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -18,6 +18,7 @@
 #include "pop3d.h"
 #include "mailutils/pam.h"
 #include "mailutils/libargp.h"
+#include "mailutils/pop3.h"
 #include "tcpwrap.h"
 
 mu_mailbox_t mbox;
@@ -107,6 +108,19 @@ cb_bulletin_db (void *data, mu_config_value_t *val)
 }
 #endif
 
+struct pop3d_srv_config
+{
+  struct mu_srv_config m_cfg;
+  int tls;
+};
+
+static struct mu_cfg_param pop3d_srv_param[] = {
+  { "tls", mu_cfg_bool, NULL, mu_offsetof (struct pop3d_srv_config, tls), NULL,
+    N_("Use TLS encryption for this server")
+  },
+  { NULL }
+};
+    
 static struct mu_cfg_param pop3d_cfg_param[] = {
   { "undelete", mu_cfg_bool, &undelete_on_startup, 0, NULL,
     N_("On startup, clear deletion marks from all the messages.") },
@@ -247,9 +261,10 @@ pop3d_get_client_address (int fd, struct sockaddr_in *pcs)
    executes the proper functions. Also handles the bulk of error reporting.
    Arguments:
       ifd       --  input descriptor
-      ofd       --  output descriptor  */
+      ofd       --  output descriptor
+      tls       --  initiate encrypted connection */
 int
-pop3d_mainloop (int ifd, int ofd)
+pop3d_mainloop (int ifd, int ofd, int tls)
 {
   int status = OK;
   char buffer[512];
@@ -258,7 +273,7 @@ pop3d_mainloop (int ifd, int ofd)
 
   mu_set_signals (pop3d_child_signal, sigtab, MU_ARRAY_SIZE (sigtab));
 
-  pop3d_setio (ifd, ofd);
+  pop3d_setio (ifd, ofd, tls);
 
   state = initial_state;
 
@@ -324,13 +339,16 @@ pop3d_mainloop (int ifd, int ofd)
 }
 
 int
-pop3d_connection (int fd, struct sockaddr *sa, int salen, void *data,
-		  mu_ip_server_t srv, time_t timeout, int transcript)
+pop3d_connection (int fd, struct sockaddr *sa, int salen,
+		  struct mu_srv_config *pconf,
+		  void *data)
 {
-  idle_timeout = timeout;
-  if (pop3d_transcript != transcript)
-    pop3d_transcript = transcript;
-  pop3d_mainloop (fd, fd);
+  struct pop3d_srv_config *cfg = (struct pop3d_srv_config *) pconf;
+  
+  idle_timeout = pconf->timeout;
+  pop3d_transcript = pconf->transcript;
+
+  pop3d_mainloop (fd, fd, cfg->tls);
   return 0;
 }
 
@@ -370,11 +388,12 @@ main (int argc, char **argv)
   mu_tcpwrapper_cfg_init ();
   manlock_cfg_init ();
   mu_acl_cfg_init ();
-  mu_m_server_cfg_init ();
+  mu_m_server_cfg_init (pop3d_srv_param);
   
   mu_argp_init (NULL, NULL);
   	
   mu_m_server_create (&server, program_version);
+  mu_m_server_set_config_size (server, sizeof (struct pop3d_srv_config));
   mu_m_server_set_conn (server, pop3d_connection);
   mu_m_server_set_prefork (server, mu_tcp_wrapper_prefork);
   mu_m_server_set_mode (server, MODE_INTERACTIVE);
@@ -451,7 +470,7 @@ main (int argc, char **argv)
   tls_available = mu_check_tls_environment ();
   if (tls_available)
     {
-      tls_available = mu_init_tls_libs ();
+      tls_available = mu_init_tls_libs (1);
       if (tls_available)
 	enable_stls ();
     }
@@ -469,7 +488,7 @@ main (int argc, char **argv)
     {
       /* Make sure we are in the root directory.  */
       chdir ("/");
-      status = pop3d_mainloop (MU_STDIN_FD, MU_STDOUT_FD);
+      status = pop3d_mainloop (MU_STDIN_FD, MU_STDOUT_FD, 0);
     }
   
   if (status)
diff --git a/pop3d/pop3d.h b/pop3d/pop3d.h
index 0696c51..2ae6286 100644
--- a/pop3d/pop3d.h
+++ b/pop3d/pop3d.h
@@ -236,7 +236,7 @@ extern void enable_stls (void);
 #endif /* WITH_TLS */
 extern void pop3d_outf          (const char *fmt, ...) MU_PRINTFLIKE(1,2);
 
-extern void pop3d_setio         (int, int);
+extern void pop3d_setio         (int, int, int);
 extern char *pop3d_readline     (char *, size_t);
 extern void pop3d_flush_output  (void);
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 04 16:24:02 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RMQJ0-0001mq-E5
	for mharc-commit-mailutils@gnu.org; Fri, 04 Nov 2011 16:24:02 -0400
Received: from eggs.gnu.org ([140.186.70.92]:42214)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMQIx-0001mj-O7
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 16:24:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMQIw-0002Sc-0C
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 16:23:59 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:47858)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMQIv-0002SY-Ti
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 16:23:57 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMQIq-0001Vh-R3
	for commit-mailutils@gnu.org; Fri, 04 Nov 2011 20:23:56 +0000
Date: Fri, 04 Nov 2011 20:23:53 +0000
Message-Id: <E1RMQIq-0001Vh-R3@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-424-g397d794
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: e1233d5516f48cd7d786a69d4eebd40e73d95d45
X-Git-Newrev: 397d7942197ebc79d3bcb1dd92ab197e3f6aaf2d
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 04 Nov 2011 20:24:01 -0000

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

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

The branch, master has been updated
       via  397d7942197ebc79d3bcb1dd92ab197e3f6aaf2d (commit)
      from  e1233d5516f48cd7d786a69d4eebd40e73d95d45 (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 397d7942197ebc79d3bcb1dd92ab197e3f6aaf2d
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 4 22:22:44 2011 +0200

    Fix MU_EVT_MESSAGE_ADD in pop://
    
    * libproto/pop/mbox.c (pop_scan): Make sure MU_EVT_MESSAGE_ADD is delivered
    when it is already possible to retrieve the message.
    * mail/mail.c (default_setup) <headline>: Use %L instead of %l.
    
    * mu/logger.c (logger_options)<priority>: Minor fix.

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

Summary of changes:
 libproto/pop/mbox.c |   19 ++++++++++++++++---
 mail/mail.c         |    2 +-
 mu/logger.c         |    2 +-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/libproto/pop/mbox.c b/libproto/pop/mbox.c
index 9ce6603..ba03ef2 100644
--- a/libproto/pop/mbox.c
+++ b/libproto/pop/mbox.c
@@ -356,9 +356,6 @@ pop_scan (mu_mailbox_t mbox, size_t msgno, size_t *pcount)
 
 	  if (mbox->observable)
 	    {
-	      if (mu_observable_notify (mbox->observable, MU_EVT_MESSAGE_ADD,
-					&num) != 0)
-		break;
 	      if (((i + 1) % 10) == 0)
 		mu_observable_notify (mbox->observable,
 				      MU_EVT_MAILBOX_PROGRESS,
@@ -366,7 +363,23 @@ pop_scan (mu_mailbox_t mbox, size_t msgno, size_t *pcount)
 	    }
 	}
     }
+  
   mu_iterator_destroy (&itr);
+
+  if (mbox->observable)
+    {
+      /* MU_EVT_MESSAGE_ADD must be delivered only when it is already possible
+         to retrieve the message in question.  It could not be done in the
+         main loop because no other pop3d function can be called while LIST
+         is being handled.  Hence the extra loop. */
+      for (i = 0; i <= count; i++)
+	{
+	  if (mu_observable_notify (mbox->observable, MU_EVT_MESSAGE_ADD,
+				    &i) != 0)
+	    break;
+	}
+    }
+  
   return status;
 }
 
diff --git a/mail/mail.c b/mail/mail.c
index 33fac2c..d0643f9 100644
--- a/mail/mail.c
+++ b/mail/mail.c
@@ -289,7 +289,7 @@ static char *default_setup[] = {
   "set recursivealiases",
   "set noinplacealiases",
   "set fromfield",
-  "set headline=\"%>%a%4m %18f %16d %3l/%-5o %s\"",
+  "set headline=\"%>%a%4m %18f %16d %3L/%-5o %s\"",
   
   /* Start in mail reading mode */
   "setq mode=read",
diff --git a/mu/logger.c b/mu/logger.c
index f3bb738..e38616f 100644
--- a/mu/logger.c
+++ b/mu/logger.c
@@ -30,7 +30,7 @@ static char logger_args_doc[] = N_("[TEXT]");
 
 static struct argp_option logger_options[] = {
   { "file", 'f', N_("FILE"), 0, N_("read message from FILE") },
-  { "priority", 'p', N_("[FACILITY.LEVEL]"), 0,
+  { "priority", 'p', N_("FACILITY[.LEVEL]"), 0,
     N_("log at the specified syslog priority (implies --syslog)") },
   { "syslog", OPT_SYSLOG, NULL, 0, N_("log via syslog") },
   { "stderr", OPT_STDERR, NULL, 0, N_("log to the standard error") },


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 05 05:07:12 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RMcDY-0007xW-Ad
	for mharc-commit-mailutils@gnu.org; Sat, 05 Nov 2011 05:07:12 -0400
Received: from eggs.gnu.org ([140.186.70.92]:49567)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMcDV-0007xL-GC
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 05:07:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMcDT-0001Mr-Bj
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 05:07:09 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:41058)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMcDT-0001Mn-8k
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 05:07:07 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMcDS-0006lB-0f
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 09:07:06 +0000
Date: Sat, 05 Nov 2011 09:07:06 +0000
Message-Id: <E1RMcDS-0006lB-0f@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-425-g6d9c7d6
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 397d7942197ebc79d3bcb1dd92ab197e3f6aaf2d
X-Git-Newrev: 6d9c7d666f83da5d9f69d7e30b138d1a6e2e69da
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Nov 2011 09:07:11 -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=6d9c7d666f83da5d9f69d7e30b138d1a6e2e69da

The branch, master has been updated
       via  6d9c7d666f83da5d9f69d7e30b138d1a6e2e69da (commit)
      from  397d7942197ebc79d3bcb1dd92ab197e3f6aaf2d (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 6d9c7d666f83da5d9f69d7e30b138d1a6e2e69da
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 5 11:01:37 2011 +0200

    Write NEWS article describing the recent changes.

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

Summary of changes:
 NEWS |  197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 192 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index c96bda1..ab9643e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2011-07-27
+GNU mailutils NEWS -- history of user-visible changes. 2011-11-05
 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 Free Software Foundation, Inc.
 See the end of file for copying conditions.
@@ -8,10 +8,197 @@ Please send mailutils bug reports to <bug-mailutils@gnu.org>.
 
 Version 2.99.93 (Git)
 
-This version is highly experimental.  It features a rewrite from
-scratch of the stream subsystem and other vital parts of the
-framework.  No documentation is available so far, please use
-`git log' and the sources!
+This version is a major rewrite of GNU Mailutils.  Quite a few parts
+of the basic framework were rewritten from scratch, while some others
+undergone a considerable revamping.  The user documentation, at the
+moment, is insufficient, and in some aspects even scarce.  It is being
+worked upon.  However, most utilities self-document themselves.  To
+obtain a summary of available configuration statements for a given
+program, run `program --config-help'.  For additional documentation,
+please refer to http://mailutils.org/wiki.  If the piece of
+documentation you are looking for is not available there, don't
+hesitate to post your questions to <bug-mailutils@gnu.org>.
+
+Due to the global nature of these changes, the rewrite of some parts
+of the package is not yet finished, while some others are considered
+experimental.  Not currently implemented are:
+
+ - imap client
+ - nntp client
+ - Tokyocabinet support
+ 
+Experimental features are:
+
+ - C++ bindings
+ - Python bindings
+
+The discussion below lists the changes in this release.  It is divided
+in three major sections, each addressing a particular audience.  The
+section entitles "Important changes" is of particular interest to
+users.  This is perhaps the most visible part of this release.  The
+section "Configuration changes" addresses package installers.  It
+discusses the changes in configure script and related things.
+Finally, the section "Changes to the library" is of interest to
+programmers which use or wish to use Mailutils in their projects.
+ 
+* Important changes
+
+** IPv6 support.
+
+The core library as well as client and server utilities support
+AF_INET6 family of addresses.
+
+** Support for POP3S and IMAP4S in the respective servers.
+
+A single instance of pop3d is able to handle several subservers,
+supporting both plain POP3 and encrypted POP3S simultaneously.  The
+same holds true for imap4d.
+
+** DBM support reimplemented from scratch.
+
+The most important result of this change is that Mailutils is now able
+to handle databases of different formats (e.g. GDBM, Berkeley DB,
+NDBM) simultaneously, without need to reconfigure it.  The database
+flavor to use is selected at runtime, using `database URL'.  For
+example, "gdbm:///etc/mail/aliases.db" refers to a GDBM database.
+
+See http://mailutils.org/wiki/libmu_dbm
+
+** New utility `mu'
+
+`Mu' is a multi-purpose tool which can be of use to users, programmers
+and system administrators.  It allows you to retrieve information
+about Mailutils configuration, check ACLs and authentication tickets,
+list, create or modify DBM files, construct filters of arbitrary
+complexity and many more.
+
+See http://mailutils.org/wiki/mu
+
+** Configurable file safety checking
+
+Some files, such as SSL key files, need particular protection, while
+others (e.g. users' forward files) don't require it.  Mailutils
+configuration allows for configuring what safety checks are required
+for each group of files.  Files not meeting the configured criteria
+are not used to avoid compromising security.
+
+** Improved debugging and diagnostics
+
+See http://mailutils.org/wiki/debug_level.
+
+** Imap4d undergone a lot of changes to comply to existing RFCs
+
+** Pop3d and imap4d allow for mailbox-independent compulsory locking
+
+This feature is useful for those system administrators who don't wish
+to permit simultaneous access to mailboxes, even when the nature of the
+mailbox allows that (e.g. maildir).
+
+** Sieve: new extensions
+
+New extension action `pipe' invokes arbitrary external program and
+pipes the message (or any part thereof) to it.  
+
+See http://mailutils.org/wiki/Pipe
+
+A similar test uses the program exit code to decide what to do with
+the message
+
+See http://mailutils.org/wiki/Pipe_test
+
+New extension test `list' compares values of mail headers from a
+supplied list with a list of values.
+
+See http://mailutils.org/wiki/List_(Sieve_test)
+
+New extension test `timestamp' compares the value of a structured date
+header field with the given date.
+
+See http://mailutils.org/wiki/Timestamp_(Sieve_test)
+
+** MH: improved compatibility with other implementations
+
+** mailutils-config is deprecated.
+
+Use `mu cflags' and `mu ldflags' instead.  The mailutils-config is
+rewritten as a wrapper over these commands.
+
+See http://mailutils.org/wiki/mu for more information.
+
+** movemail functionality considerably improved
+
+See http://mailutils.org/wiki/Fetching_Mail_with_Movemail
+
+* Configuration changes
+
+These are of particular interest to installers.
+
+** New configuration options to disable particular groups of utilities.
+
+The `--enable-build-servers' options controls whether servers (such as
+imap4d, pop3d, comsat) will be built.  Its counterpart,
+`--enable-build-clients' controls whether client utilities will be
+built.
+
+** DBM options
+
+It is normally not needed to specify --with-gdbm, --with-berkeley-db
+or --with-ndbm explicitly.  Configuration will automatically pick up
+all available DBM libraries it can use.
+
+The Tokyocabinet support (--with-tokyocabinet) is temporarily not
+available.
+
+** Imap and nntp clients are not yet implemented
+
+** Experimental features
+
+The C++ and Python bindings are considered experimental and unstable.
+
+* Changes to the library
+
+** Stream support is rewritten from scratch
+
+Stream support is a cornerstone on which the rest of Mailutils is
+built.  The new implementation was developed with three main
+objectives in mind: reliability, speed and consistency.
+
+** URL support is rewritten from scratch
+
+New URL functions allow both for creating URLs from string
+representations and for building them from parts.
+
+** Filter support is rewritten from scratch
+
+Apart from the implementation itself, lots of new filters are
+provided.  See http://mailutils.org/wiki/Category:Filters for a
+list of those.
+
+A concept of `filter chains' was introduced, which allows for
+creating new filters using existing ones as their components.
+
+See http://mailutils.org/wiki/Mu#filter, for a description.
+
+** POP client library is rewritten from scratch
+
+The new library provides two APIs: a traditional mailbox API which
+hides the particularities of the POP protocol, and POP-specific API,
+which allows for writing applications directly accessing POP features.
+
+** SMTP client library is rewritten from scratch
+
+The new library provides a detailed control over the SMTP
+transaction.
+
+** Support for Maildir and MH formats considerably improved.
+
+** MIME support improved.
+
+** Debugging support considerably improved.
+
+See http://mailutils.org/wiki/debug_level.
+
+** Configuration file support (libmu_cfg) rewritten.
 
 
 Version 2.2 - 2010-09-08


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 05 19:51:08 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RMq0y-0007NB-4m
	for mharc-commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:51:08 -0400
Received: from eggs.gnu.org ([140.186.70.92]:57831)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq0V-0007MX-7x
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:51:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq03-0006hI-L2
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:50:39 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56322)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq03-0006hC-7P
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:50:11 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq02-0005aq-0V
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 23:50:10 +0000
Date: Sat, 05 Nov 2011 23:50:10 +0000
Message-Id: <E1RMq02-0005aq-0V@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-426-g3ec5d07
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 6d9c7d666f83da5d9f69d7e30b138d1a6e2e69da
X-Git-Newrev: 3ec5d07e67044b614b8beab0e34908b4eec23eab
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Nov 2011 23:51: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=3ec5d07e67044b614b8beab0e34908b4eec23eab

The branch, master has been updated
       via  3ec5d07e67044b614b8beab0e34908b4eec23eab (commit)
      from  6d9c7d666f83da5d9f69d7e30b138d1a6e2e69da (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 3ec5d07e67044b614b8beab0e34908b4eec23eab
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Nov 6 01:45:07 2011 +0200

    Update docs + minor changes.
    
    * .gitmodules: Add imprimatur.
    * Makefile.am: Likewise.
    * configure.ac: Likewise.
    * doc/Makefile.am: Likewise.
    * bootstrap.conf: Comment out make in doc/texinfo
    * doc/texinfo/Makefile.am: Rewrite.
    * doc/texinfo/fdl.texi: Minor change.
    * doc/texinfo/getdate.texi: Minor change.
    * doc/texinfo/mailutils.texi: begin rewrite.
    * doc/texinfo/mu-mh.texi: Minor change.
    * doc/texinfo/programs.texi: begin rewrite.
    * doc/texinfo/sieve.texi: Minor change.
    * doc/texinfo/usage.texi: Minor change.
    
    * libmailutils/cfg/lexer.l: Allow for @ in unquoted strings
    * pop3d/bulletin.c: Relax safety checks for bulletin.db
    * pop3d/logindelay.c: Relax safety checks for stat.sb
    * pop3d/pop3d.h (DEFAULT_GROUP_DB_SAFETY): New define.

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

Summary of changes:
 .gitmodules                |    3 +
 Makefile.am                |    2 +-
 bootstrap.conf             |    2 +-
 configure.ac               |   18 +-
 doc/Makefile.am            |    2 +-
 doc/imprimatur             |    1 +
 doc/texinfo/.gitignore     |    4 +
 doc/texinfo/Makefile.am    |  181 +--
 doc/texinfo/fdl.texi       |   85 +-
 doc/texinfo/getdate.texi   |  134 +-
 doc/texinfo/mailutils.texi |  436 ++----
 doc/texinfo/mu-mh.texi     |   74 +-
 doc/texinfo/programs.texi  | 3751 ++++++++++++++++++++++++++++----------------
 doc/texinfo/sieve.texi     |  270 ++--
 doc/texinfo/usage.texi     |   48 +-
 libmailutils/cfg/lexer.l   |    2 +-
 pop3d/bulletin.c           |    4 +
 pop3d/logindelay.c         |    4 +-
 pop3d/pop3d.h              |   11 +
 19 files changed, 2913 insertions(+), 2119 deletions(-)
 create mode 160000 doc/imprimatur

diff --git a/.gitmodules b/.gitmodules
index 7c369d4..f3199f7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
 [submodule "gint"]
 	path = gint
 	url = git://git.gnu.org.ua/gint.git
+[submodule "doc/imprimatur"]
+	path = doc/imprimatur
+	url = git://git.gnu.org.ua/imprimatur.git
diff --git a/Makefile.am b/Makefile.am
index 8d2f5ab..c97aa4d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@
 ## You should have received a copy of the GNU General Public License
 ## along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-ACLOCAL_AMFLAGS = -I m4 -I am -I gint
+ACLOCAL_AMFLAGS = -I m4 -I am -I gint -I doc/imprimatur
 
 if MU_COND_PYTHON
   PYTHON_DIR = python
diff --git a/bootstrap.conf b/bootstrap.conf
index 66621f2..0139225 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -100,5 +100,5 @@ done
 wget -P m4 http://git.savannah.gnu.org/cgit/radius.git/plain/scripts/radius.m4
 
 # Create included listings for texinfo docs.
-make -C doc/texinfo -f maint.mk
+#make -C doc/texinfo -f maint.mk
 
diff --git a/configure.ac b/configure.ac
index eaaea12..925a6e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1316,23 +1316,7 @@ dnl get sysconfdir expanded.
 CPPFLAGS="$CPPFLAGS -DSYSCONFDIR=\\\"\$(sysconfdir)\\\""
 
 # Doc hints.
-# Select a rendition level:
-#  DISTRIB for stable releases (at most one dot in the version number)
-#  and maintenance releases (two dots, patchlevel < 50)
-#  PROOF for alpha releases.
-#  PUBLISH can only be required manually when running make in doc/
-AC_SUBST(RENDITION)
-case `echo $VERSION|sed  's/[[^.]]//g'` in
-""|".")  RENDITION=DISTRIB;;
-"..")  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
+IMPRIMATUR_INIT([doc/imprimatur])
 
 AC_CONFIG_COMMANDS([status],[
 cat <<EOF
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 4be7763..9d4a172 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -15,5 +15,5 @@
 ## You should have received a copy of the GNU General Public License
 ## along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-SUBDIRS = texinfo man
+SUBDIRS = imprimatur texinfo man
 EXTRA_DIST = ChangeLog.CVS rfc/README
diff --git a/doc/imprimatur b/doc/imprimatur
new file mode 160000
index 0000000..f32ef19
--- /dev/null
+++ b/doc/imprimatur
@@ -0,0 +1 @@
+Subproject commit f32ef1983968e755cd580b06e369476d7e7f88b6
diff --git a/doc/texinfo/.gitignore b/doc/texinfo/.gitignore
index 9e5dd46..1a044fb 100644
--- a/doc/texinfo/.gitignore
+++ b/doc/texinfo/.gitignore
@@ -19,6 +19,10 @@ mailutils.tmp
 mailutils.toc
 mailutils.tp
 mailutils.vr
+mailutils.fl
+mailutils.kw
+mailutils.pdf
+mailutils.pr
 mdate-sh
 muint.info*
 stamp-1
diff --git a/doc/texinfo/Makefile.am b/doc/texinfo/Makefile.am
index dd28976..ec99299 100644
--- a/doc/texinfo/Makefile.am
+++ b/doc/texinfo/Makefile.am
@@ -17,174 +17,53 @@
 
 info_TEXINFOS = mailutils.texi 
 
-INCFILES = \
- addr.inc\
- http.inc\
- mailcap.inc\
- numaddr.inc\
- sfrom.inc\
- url-parse.inc
-
-RENDITION_TEXI=rendition.texi macros.texi
-
 mailutils_TEXINFOS = \
- address.texi\
- attribute.texi\
- auth.texi\
- body.texi\
- c-api.texi\
- encoding.texi\
- envelope.texi\
  fdl.texi\
- folder.texi\
- framework.texi\
  getdate.texi\
- headers.texi\
- imap4.texi\
- iterator.texi\
- libmu_scm.texi\
- libmu_auth.texi\
- libmu_sieve.texi\
- locker.texi\
- mailbox.texi\
- mailcap.texi\
- maildir.texi\
- mailer.texi\
- mbox.texi\
- message.texi\
- mh.texi\
+ macros.texi\
  mu-mh.texi\
- mu_address.texi\
- mu_body.texi\
- mu_logger.texi\
- mu_mailbox.texi\
- mu_message.texi\
- mu_mime.texi\
- mu_scm.texi\
- nntp.texi\
- parse822.texi\
- pop3.texi\
  programs.texi\
- sendmail.texi\
  sieve.texi\
- smtp.texi\
- stream.texi\
  usage.texi\
- url.texi\
- $(RENDITION_TEXI)\
- $(INCFILES)
+ version.texi
 
-DISTCLEANFILES=*.pgs *.kys *.vrs
 clean-local:
 	rm -rf manual
 
-# The rendering level is one of PUBLISH, DISTRIB or PROOF.
-# Just call `make RENDITION=PROOF [target]' if you want PROOF rendition.
-
-MAKEINFOFLAGS=-D$(RENDITION)
-GENDOCS=gendocs.sh
-TEXI2DVI=texi2dvi -t '@set $(RENDITION)' -E
-
-# Make sure you set TEXINPUTS.
-# TEXINPUTS=/usr/share/texmf/pdftex/plain/misc/ is ok for most distributions
-
-TEXINPUTS=$(srcdir):$(top_srcdir)/build-aux:$$TEXINPUTS
-
-manual:
-	TEXINPUTS=$(srcdir):$(top_srcdir)/build-aux:$(TEXINPUTS) \
-	 MAKEINFO="$(MAKEINFO) $(MAKEINFOFLAGS)" \
-	 TEXI2DVI="$(TEXI2DVI) -t @finalout" \
-	$(GENDOCS) --texi2html $(PACKAGE) '$(PACKAGE_NAME) manual'
+AM_MAKEINFOFLAGS = @IMPRIMATUR_MAKEINFOFLAGS@
+# Imprimatur setup
+imprimatur_INPUT=$(info_TEXINFOS) $(mailutils_TEXINFOS)
+include ../imprimatur/imprimatur.mk
+#CHECK_DOCS=$(top_srcdir)/@IMPRIMATUR_MODULE_DIR@/check-docs.sh
 
-
-EXTRA_DIST=gendocs_template mastermenu.el untabify.el
+# Checking
+all-check-docs: imprimatur-basic-checks
 
-master-menu:
-	emacs -batch -l mastermenu.el -f make-master-menu $(info_TEXINFOS)
+check-docs:
+	@$(MAKE) -k all-check-docs
 
-untabify:
-	emacs -batch -l untabify.el $(info_TEXINFOS) $(mailutils_TEXINFOS)
+#
 
-fix-sentence-spacing:
-	for file in $(info_TEXINFOS) $(mailutils_TEXINFOS); \
-	do \
-		if grep -q '\.  [@A-Z]' $$file; then \
-			mv $$file $${file}~; \
-			sed -r 's/\.  ([@A-Z])/. \1/g' $${file}~ > $$file; \
-		fi; \
-	done
+master-menu: imprimatur-master-menu
+untabify: imprimatur-untabify
+final: imprimatur-final
 
-final: untabify fix-sentence-spacing master-menu
+# Web manual
+#EXTRA_DIST = \
+# gendocs_template
 
-
-# Checks
-check-tabs:
-	@if test -n "`cat $(info_TEXINFOS) $(mailutils_TEXINFOS) |\
-             tr -d -c '\t'`"; then \
-		echo >&2 "Sources contain tabs; run make untabify"; \
-		false; \
-	fi
-
-check-sentence-spacing:
-	@if grep -q '\.  [@A-Z]' $(info_TEXINFOS) $(mailutils_TEXINFOS); then \
-		echo >&2 "Sources contain double-space sentence separators"; \
-		echo >&2 "Run make fix-sentence-spacing to fix"; \
-	fi
-
-check-format: check-tabs check-sentence-spacing
-
-check-refs:
-	@for file in $(info_TEXINFOS) $(mailutils_TEXINFOS); \
-	do \
-	  sed -e = $$file | \
-           sed -n 'N;/@FIXME-.*ref/{s/\(^[0-9][0-9]*\).*@FIXME-.*ref{\([^}]*\)}.*/'$$file':\1: \2/gp}'; \
-	done > $@-t; \
-	if [ -s $@-t ]; then \
-	  echo >&2 "Unresolved cross-references:"; \
-	  cat $@-t >&2;\
-	  rm $@-t; \
-	else \
-	  rm -f $@-t; \
-	fi
-
-check-fixmes:
-	@for file in $(info_TEXINFOS) $(mailutils_TEXINFOS); \
-	do \
-	  sed -e = $$file | \
-           sed -n 'N;/@FIXME{/{s/\(^[0-9][0-9]*\).*@FIXME{\([^}]*\).*/'$$file':\1: \2/gp}'; \
-	done > $@-t; \
-	if [ -s $@-t ]; then \
-	  echo >&2 "Unresolved FIXMEs:"; \
-	  cat $@-t >&2; \
-	  rm $@-t; \
-	  false; \
-	else \
-          rm -f $@-t; \
-	fi
-
-check-writeme:
-	@grep -Hn @WRITEME $(info_TEXINFOS) $(mailutils_TEXINFOS) > $@-t; \
-	if [ -s $@-t ]; then \
-	  echo "Empty nodes:"; \
-	  cat $@-t; \
-	  rm $@-t; \
-	  false;\
-	else \
-          rm $@-t; \
-	fi
+GENDOCS=gendocs.sh
+TEXI2DVI=texi2dvi -t '@set $(RENDITION)' -E
 
-check-unrevised:
-	@grep -Hn @UNREVISED $(info_TEXINFOS) $(mailutils_TEXINFOS) > $@-t; \
-	if [ -s $@-t ]; then \
-	  echo >&2 "Unrevised nodes:"; \
-	  cat $@-t >&2; \
-	  rm $@-t; \
-	  false;\
-	else \
-          rm $@-t; \
-	fi
+.PHONY: manual
+manual:
+	TEXINPUTS=$(srcdir):$(top_srcdir)/build-aux:$(TEXINPUTS) \
+	 MAKEINFO="$(MAKEINFO) $(MAKEINFOFLAGS) $(AM_MAKEINFOFLAGS)" \
+	 TEXI2DVI="$(TEXI2DVI)" \
+         TEXI2HTML="texi2html $(AM_MAKEINFOFLAGS)" \
+	$(GENDOCS) --texi2html $(PACKAGE) '$(PACKAGE_NAME) manual'
 
-all-check-docs: check-format check-writeme check-unrevised check-refs check-fixmes 
+manual.tar.bz2: manual
+	tar cfj manual.tar.bz2 manual
 
-check-docs: 
-	$(MAKE) -k all-check-docs
+man-tar: manual.tar.bz2
diff --git a/doc/texinfo/fdl.texi b/doc/texinfo/fdl.texi
index ab401d0..31cf840 100644
--- a/doc/texinfo/fdl.texi
+++ b/doc/texinfo/fdl.texi
@@ -1,6 +1,3 @@
-@setfilename fdl.info
-@node GNU FDL
-@appendix GNU Free Documentation License
 @cindex FDL, GNU Free Documentation License
 @center Version 1.2, November 2002
 
@@ -26,16 +23,16 @@ to get credit for their work, while not being considered responsible
 for modifications made by others.
 
 This License is a kind of ``copyleft'', which means that derivative
-works of the document must themselves be free in the same sense. It
+works of the document must themselves be free in the same sense.  It
 complements the GNU General Public License, which is a copyleft
 license designed for free software.
 
 We have designed this License in order to use it for manuals for free
 software, because free software needs free documentation: a free
 program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
+software does.  But this License is not limited to software manuals;
 it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
+whether it is published as a printed book.  We recommend this License
 principally for works whose purpose is instruction or reference.
 
 @item
@@ -43,11 +40,11 @@ APPLICABILITY AND DEFINITIONS
 
 This License applies to any manual or other work, in any medium, that
 contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
+distributed under the terms of this License.  Such a notice grants a
 world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The ``Document'', below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as ``you''. You accept the license if you
+work under the conditions stated herein.  The ``Document'', below,
+refers to any such manual or work.  Any member of the public is a
+licensee, and is addressed as ``you''.  You accept the license if you
 copy, modify or distribute the work in a way requiring permission
 under copyright law.
 
@@ -68,15 +65,15 @@ them.
 
 The ``Invariant Sections'' are certain Secondary Sections whose titles
 are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
+that says that the Document is released under this License.  If a
 section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
+allowed to be designated as Invariant.  The Document may contain zero
+Invariant Sections.  If the Document does not identify any Invariant
 Sections then there are none.
 
 The ``Cover Texts'' are certain short passages of text that are listed,
 as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
+the Document is released under this License.  A Front-Cover Text may
 be at most 5 words, and a Back-Cover Text may be at most 25 words.
 
 A ``Transparent'' copy of the Document means a machine-readable copy,
@@ -86,19 +83,19 @@ straightforwardly with generic text editors or (for images composed of
 pixels) generic paint programs or (for drawings) some widely available
 drawing editor, and that is suitable for input to text formatters or
 for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
+to text formatters.  A copy made in an otherwise Transparent file
 format whose markup, or absence of markup, has been arranged to thwart
 or discourage subsequent modification by readers is not Transparent.
 An image format is not Transparent if used for any substantial amount
-of text. A copy that is not ``Transparent'' is called ``Opaque''.
+of text.  A copy that is not ``Transparent'' is called ``Opaque''.
 
 Examples of suitable formats for Transparent copies include plain
 @sc{ascii} without markup, Texinfo input format, La@TeX{} input
 format, @acronym{SGML} or @acronym{XML} using a publicly available
 @acronym{DTD}, and standard-conforming simple @acronym{HTML},
-PostScript or @acronym{PDF} designed for human modification. Examples
+PostScript or @acronym{PDF} designed for human modification.  Examples
 of transparent image formats include @acronym{PNG}, @acronym{XCF} and
-@acronym{JPG}. Opaque formats include proprietary formats that can be
+@acronym{JPG}.  Opaque formats include proprietary formats that can be
 read and edited only by proprietary word processors, @acronym{SGML} or
 @acronym{XML} for which the @acronym{DTD} and/or processing tools are
 not generally available, and the machine-generated @acronym{HTML},
@@ -107,7 +104,7 @@ output purposes only.
 
 The ``Title Page'' means, for a printed book, the title page itself,
 plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
+this License requires to appear in the title page.  For works in
 formats which do not have any title page as such, ``Title Page'' means
 the text near the most prominent appearance of the work's title,
 preceding the beginning of the body of the text.
@@ -121,7 +118,7 @@ of such a section when you modify the Document means that it remains a
 section ``Entitled XYZ'' according to this definition.
 
 The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
+states that this License applies to the Document.  These Warranty
 Disclaimers are considered to be included by reference in this
 License, but only as regards disclaiming warranties: any other
 implication that these Warranty Disclaimers may have is void and has
@@ -134,10 +131,10 @@ You may copy and distribute the Document in any medium, either
 commercially or noncommercially, provided that this License, the
 copyright notices, and the license notice saying this License applies
 to the Document are reproduced in all copies, and that you add no other
-conditions whatsoever to those of this License. You may not use
+conditions whatsoever to those of this License.  You may not use
 technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
+copying of the copies you make or distribute.  However, you may accept
+compensation in exchange for copies.  If you distribute a large enough
 number of copies you must also follow the conditions in section 3.
 
 You may also lend copies, under the same conditions stated above, and
@@ -151,10 +148,10 @@ printed covers) of the Document, numbering more than 100, and the
 Document's license notice requires Cover Texts, you must enclose the
 copies in covers that carry, clearly and legibly, all these Cover
 Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
+the back cover.  Both covers must also clearly and legibly identify
+you as the publisher of these copies.  The front cover must present
 the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
+visible.  You may add other material on the covers in addition.
 Copying with changes limited to the covers, as long as they preserve
 the title of the Document and satisfy these conditions, can be treated
 as verbatim copying in other respects.
@@ -189,14 +186,14 @@ the conditions of sections 2 and 3 above, provided that you release
 the Modified Version under precisely this License, with the Modified
 Version filling the role of the Document, thus licensing distribution
 and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
+of it.  In addition, you must do these things in the Modified Version:
 
 @enumerate A
 @item
 Use in the Title Page (and on the covers, if any) a title distinct
 from that of the Document, and from those of previous versions
 (which should, if there were any, be listed in the History section
-of the Document). You may use the same title as a previous version
+of the Document).  You may use the same title as a previous version
 if the original publisher of that version gives permission.
 
 @item
@@ -232,7 +229,7 @@ Include an unaltered copy of this License.
 @item
 Preserve the section Entitled ``History'', Preserve its Title, and add
 to it an item stating at least the title, year, new authors, and
-publisher of the Modified Version as given on the Title Page. If
+publisher of the Modified Version as given on the Title Page.  If
 there is no section Entitled ``History'' in the Document, create one
 stating the title, year, authors, and publisher of the Document as
 given on its Title Page, then add an item describing the Modified
@@ -242,7 +239,7 @@ Version as stated in the previous sentence.
 Preserve the network location, if any, given in the Document for
 public access to a Transparent copy of the Document, and likewise
 the network locations given in the Document for previous versions
-it was based on. These may be placed in the ``History'' section.
+it was based on.  These may be placed in the ``History'' section.
 You may omit a network location for a work that was published at
 least four years before the Document itself, or if the original
 publisher of the version it refers to gives permission.
@@ -255,11 +252,11 @@ dedications given therein.
 
 @item
 Preserve all the Invariant Sections of the Document,
-unaltered in their text and in their titles. Section numbers
+unaltered in their text and in their titles.  Section numbers
 or the equivalent are not considered part of the section titles.
 
 @item
-Delete any section Entitled ``Endorsements''. Such a section
+Delete any section Entitled ``Endorsements''.  Such a section
 may not be included in the Modified Version.
 
 @item
@@ -273,7 +270,7 @@ Preserve any Warranty Disclaimers.
 If the Modified Version includes new front-matter sections or
 appendices that qualify as Secondary Sections and contain no material
 copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
+of these sections as invariant.  To do this, add their titles to the
 list of Invariant Sections in the Modified Version's license notice.
 These titles must be distinct from any other section titles.
 
@@ -285,9 +282,9 @@ standard.
 
 You may add a passage of up to five words as a Front-Cover Text, and a
 passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
+of Cover Texts in the Modified Version.  Only one passage of
 Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
+through arrangements made by) any one entity.  If the Document already
 includes a cover text for the same cover, previously added by you or
 by arrangement made by the same entity you are acting on behalf of,
 you may not add another; but you may replace the old one, on explicit
@@ -309,7 +306,7 @@ license notice, and that you preserve all their Warranty Disclaimers.
 
 The combined work need only contain one copy of this License, and
 multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
+copy.  If there are multiple Invariant Sections with the same name but
 different contents, make the title of each such section unique by
 adding at the end of it, in parentheses, the name of the original
 author or publisher of that section if known, or else a unique number.
@@ -319,7 +316,7 @@ Invariant Sections in the license notice of the combined work.
 In the combination, you must combine any sections Entitled ``History''
 in the various original documents, forming one section Entitled
 ``History''; likewise combine any sections Entitled ``Acknowledgements'',
-and any sections Entitled ``Dedications''. You must delete all
+and any sections Entitled ``Dedications''.  You must delete all
 sections Entitled ``Endorsements.''
 
 @item
@@ -364,11 +361,11 @@ distribute translations of the Document under the terms of section 4.
 Replacing Invariant Sections with translations requires special
 permission from their copyright holders, but you may include
 translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
+original versions of these Invariant Sections.  You may include a
 translation of this License, and all the license notices in the
 Document, and any Warranty Disclaimers, provided that you also include
 the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
+of those notices and disclaimers.  In case of a disagreement between
 the translation and the original version of this License or a notice
 or disclaimer, the original version will prevail.
 
@@ -381,9 +378,9 @@ title.
 TERMINATION
 
 You may not copy, modify, sublicense, or distribute the Document except
-as expressly provided for under this License. Any other attempt to
+as expressly provided for under this License.  Any other attempt to
 copy, modify, sublicense or distribute the Document is void, and will
-automatically terminate your rights under this License. However,
+automatically terminate your rights under this License.  However,
 parties who have received copies, or rights, from you under this
 License will not have their licenses terminated so long as such
 parties remain in full compliance.
@@ -392,9 +389,9 @@ parties remain in full compliance.
 FUTURE REVISIONS OF THIS LICENSE
 
 The Free Software Foundation may publish new, revised versions
-of the GNU Free Documentation License from time to time. Such new
+of the GNU Free Documentation License from time to time.  Such new
 versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns. See
+differ in detail to address new problems or concerns.  See
 @uref{http://www.gnu.org/copyleft/}.
 
 Each version of the License is given a distinguishing version number.
@@ -402,7 +399,7 @@ If the Document specifies that a particular numbered version of this
 License ``or any later version'' applies to it, you have the option of
 following the terms and conditions either of that specified version or
 of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
+Free Software Foundation.  If the Document does not specify a version
 number of this License, you may choose any version ever published (not
 as a draft) by the Free Software Foundation.
 @end enumerate
diff --git a/doc/texinfo/getdate.texi b/doc/texinfo/getdate.texi
index 741d449..0a816a7 100644
--- a/doc/texinfo/getdate.texi
+++ b/doc/texinfo/getdate.texi
@@ -7,7 +7,7 @@
 @c under the terms of the GNU Free Documentation License, Version 1.2 or
 @c any later version published by the Free Software Foundation; with no
 @c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
-@c Texts. A copy of the license is included in the ``GNU Free
+@c Texts.  A copy of the license is included in the ``GNU Free
 @c Documentation License'' file as part of this distribution.
 
 @cindex date input formats
@@ -18,30 +18,30 @@ First, a quote:
 @quotation
 Our units of temporal measurement, from seconds on up to months, are so
 complicated, asymmetrical and disjunctive so as to make coherent mental
-reckoning in time all but impossible. Indeed, had some tyrannical god
+reckoning in time all but impossible.  Indeed, had some tyrannical god
 contrived to enslave our minds to time, to make it all but impossible
 for us to escape subjection to sodden routines and unpleasant surprises,
 he could hardly have done better than handing down our present system.
 It is like a set of trapezoidal building blocks, with no vertical or
 horizontal surfaces, like a language in which the simplest thought
 demands ornate constructions, useless particles and lengthy
-circumlocutions. Unlike the more successful patterns of language and
+circumlocutions.  Unlike the more successful patterns of language and
 science, which enable us to face experience boldly or at least
 level-headedly, our system of temporal calculation silently and
 persistently encourages our terror of time.
 
 @dots{}  It is as though architects had to measure length in feet, width
 in meters and height in ells; as though basic instruction manuals
-demanded a knowledge of five different languages. It is no wonder then
+demanded a knowledge of five different languages.  It is no wonder then
 that we often look into our own immediate past or future, last Tuesday
-or a week from Sunday, with feelings of helpless confusion. @dots{}
+or a week from Sunday, with feelings of helpless confusion.  @dots{}
 
 --- Robert Grudin, @cite{Time and the Art of Living}.
 @end quotation
 
 This section describes the textual date representations that @sc{gnu}
-programs accept. These are the strings you, as a user, can supply as
-arguments to the various programs. The C interface (via the
+programs accept.  These are the strings you, as a user, can supply as
+arguments to the various programs.  The C interface (via the
 @code{get_date} function) is not described here.
 
 @menu
@@ -65,9 +65,9 @@ arguments to the various programs. The C interface (via the
 
 @cindex items in date strings
 A @dfn{date} is a string, possibly empty, containing many items
-separated by whitespace. The whitespace may be omitted when no
-ambiguity arises. The empty string means the beginning of today (i.e.,
-midnight). Order of the items is immaterial. A date string may contain
+separated by whitespace.  The whitespace may be omitted when no
+ambiguity arises.  The empty string means the beginning of today (i.e.,
+midnight).  Order of the items is immaterial.  A date string may contain
 many flavors of items:
 
 @itemize @bullet
@@ -86,11 +86,11 @@ many flavors of items:
 @findex first @r{in date strings}
 @findex next @r{in date strings}
 @findex last @r{in date strings}
-A few ordinal numbers may be written out in words in some contexts. This is
+A few ordinal numbers may be written out in words in some contexts.  This is
 most useful for specifying day of the week items or relative items (see
-below). Among the most commonly used ordinal numbers, the word
+below).  Among the most commonly used ordinal numbers, the word
 @samp{last} stands for @math{-1}, @samp{this} stands for 0, and
-@samp{first} and @samp{next} both stand for 1. Because the word
+@samp{first} and @samp{next} both stand for 1.  Because the word
 @samp{second} stands for the unit of time there is no way to write the
 ordinal number 2, but for convenience @samp{third} stands for 3,
 @samp{fourth} for 4, @samp{fifth} for 5,
@@ -113,10 +113,10 @@ abbreviations like @samp{AM}, @samp{DST}, @samp{EST}, @samp{first},
 The output of the @command{date} command
 is not always acceptable as a date string,
 not only because of the language problem, but also because there is no
-standard meaning for time zone items like @samp{IST}. When using
+standard meaning for time zone items like @samp{IST}.  When using
 @command{date} to generate a date string intended to be parsed later,
 specify a date format that is independent of language and that does not
-use time zone items other than @samp{UTC} and @samp{Z}. Here are some
+use time zone items other than @samp{UTC} and @samp{Z}.  Here are some
 ways to do this:
 
 @example
@@ -136,13 +136,13 @@ $ date +'@@%s.%N'  # %s and %N are GNU extensions.
 
 @cindex case, ignored in dates
 @cindex comments, in dates
-Alphabetic case is completely ignored in dates. Comments may be introduced
+Alphabetic case is completely ignored in dates.  Comments may be introduced
 between round parentheses, as long as included parentheses are properly
-nested. Hyphens not followed by a digit are currently ignored. Leading
+nested.  Hyphens not followed by a digit are currently ignored.  Leading
 zeros on numbers are ignored.
 
 Invalid dates like @samp{2005-02-29} or times like @samp{24:00} are
-rejected. In the typical case of a host that does not support leap
+rejected.  In the typical case of a host that does not support leap
 seconds, a time like @samp{23:59:60} is rejected even if it
 corresponds to a valid leap second.
 
@@ -152,9 +152,9 @@ corresponds to a valid leap second.
 
 @cindex calendar date item
 
-A @dfn{calendar date item} specifies a day of the year. It is
+A @dfn{calendar date item} specifies a day of the year.  It is
 specified differently, depending on whether the month is specified
-numerically or literally. All these strings specify the same calendar date:
+numerically or literally.  All these strings specify the same calendar date:
 
 @example
 1972-09-24     # @sc{iso} 8601.
@@ -170,8 +170,8 @@ Sep 24, 1972
 24sep72
 @end example
 
-The year can also be omitted. In this case, the last specified year is
-used, or the current year if none. For example:
+The year can also be omitted.  In this case, the last specified year is
+used, or the current year if none.  For example:
 
 @example
 9/24
@@ -185,19 +185,19 @@ Here are the rules.
 For numeric months, the @sc{iso} 8601 format
 @samp{@var{year}-@var{month}-@var{day}} is allowed, where @var{year} is
 any positive number, @var{month} is a number between 01 and 12, and
-@var{day} is a number between 01 and 31. A leading zero must be present
-if a number is less than ten. If @var{year} is 68 or smaller, then 2000
+@var{day} is a number between 01 and 31.  A leading zero must be present
+if a number is less than ten.  If @var{year} is 68 or smaller, then 2000
 is added to it; otherwise, if @var{year} is less than 100,
-then 1900 is added to it. The construct
+then 1900 is added to it.  The construct
 @samp{@var{month}/@var{day}/@var{year}}, popular in the United States,
-is accepted. Also @samp{@var{month}/@var{day}}, omitting the year.
+is accepted.  Also @samp{@var{month}/@var{day}}, omitting the year.
 
 @cindex month names in date strings
 @cindex abbreviations for months
 Literal months may be spelled out in full: @samp{January},
 @samp{February}, @samp{March}, @samp{April}, @samp{May}, @samp{June},
 @samp{July}, @samp{August}, @samp{September}, @samp{October},
-@samp{November} or @samp{December}. Literal months may be abbreviated
+@samp{November} or @samp{December}.  Literal months may be abbreviated
 to their first three letters, possibly followed by an abbreviating dot.
 It is also permitted to write @samp{Sept} instead of @samp{September}.
 
@@ -224,13 +224,13 @@ Or, omitting the year:
 @cindex time of day item
 
 A @dfn{time of day item} in date strings specifies the time on a given
-day. Here are some examples, all of which represent the same time:
+day.  Here are some examples, all of which represent the same time:
 
 @example
 20:02:00.000000
 20:02
 8:02pm
-20:02-0500      # In @sc{est} (U.S. Eastern Standard Time).
+20:02-0500      # In @sc{est} (U.S.  Eastern Standard Time).
 @end example
 
 More generally, the time of day may be given as
@@ -240,7 +240,7 @@ a number between 0 and 23, @var{minute} is a number between 0 and
 @samp{.} or @samp{,} and a fraction containing one or more digits.
 Alternatively,
 @samp{:@var{second}} can be omitted, in which case it is taken to
-be zero. On the rare hosts that support leap seconds, @var{second}
+be zero.  On the rare hosts that support leap seconds, @var{second}
 may be 60.
 
 @findex am @r{in date strings}
@@ -249,9 +249,9 @@ may be 60.
 @findex noon @r{in date strings}
 If the time is followed by @samp{am} or @samp{pm} (or @samp{a.m.}
 or @samp{p.m.}), @var{hour} is restricted to run from 1 to 12, and
-@samp{:@var{minute}} may be omitted (taken to be zero). @samp{am}
+@samp{:@var{minute}} may be omitted (taken to be zero).  @samp{am}
 indicates the first half of the day, @samp{pm} indicates the second
-half of the day. In this notation, 12 is the predecessor of 1:
+half of the day.  In this notation, 12 is the predecessor of 1:
 midnight is @samp{12am} while noon is @samp{12pm}.
 (This is the zero-oriented interpretation of @samp{12am} and @samp{12pm},
 as opposed to the old tradition derived from Latin
@@ -269,7 +269,7 @@ You can also separate @var{hh} from @var{mm} with a colon.
 When a time zone correction is given this way, it
 forces interpretation of the time relative to
 Coordinated Universal Time (@sc{utc}), overriding any previous
-specification for the time zone or the local time zone. For example,
+specification for the time zone or the local time zone.  For example,
 @samp{+0530} and @samp{+05:30} both stand for the time zone 5.5 hours
 ahead of @sc{utc} (e.g., India).
 This is the best way to
@@ -288,19 +288,19 @@ but not both.
 A @dfn{time zone item} specifies an international time zone, indicated
 by a small set of letters, e.g., @samp{UTC} or @samp{Z}
 for Coordinated Universal
-Time. Any included periods are ignored. By following a
+Time.  Any included periods are ignored.  By following a
 non-daylight-saving time zone by the string @samp{DST} in a separate
 word (that is, separated by some white space), the corresponding
 daylight saving time zone may be specified.
 Alternatively, a non-daylight-saving time zone can be followed by a
-time zone correction, to add the two values. This is normally done
+time zone correction, to add the two values.  This is normally done
 only for @samp{UTC}; for example, @samp{UTC+05:30} is equivalent to
 @samp{+05:30}.
 
 Time zone items other than @samp{UTC} and @samp{Z}
 are obsolescent and are not recommended, because they
 are ambiguous; for example, @samp{EST} has a different meaning in
-Australia than in the United States. Instead, it's better to use
+Australia than in the United States.  Instead, it's better to use
 unambiguous numeric time zone corrections like @samp{-0500}, as
 described in the previous section.
 
@@ -319,8 +319,8 @@ The explicit mention of a day of the week will forward the date
 
 Days of the week may be spelled out in full: @samp{Sunday},
 @samp{Monday}, @samp{Tuesday}, @samp{Wednesday}, @samp{Thursday},
-@samp{Friday} or @samp{Saturday}. Days may be abbreviated to their
-first three letters, optionally followed by a period. The special
+@samp{Friday} or @samp{Saturday}.  Days may be abbreviated to their
+first three letters, optionally followed by a period.  The special
 abbreviations @samp{Tues} for @samp{Tuesday}, @samp{Wednes} for
 @samp{Wednesday} and @samp{Thur} or @samp{Thurs} for @samp{Thursday} are
 also allowed.
@@ -328,8 +328,8 @@ also allowed.
 @findex next @var{day}
 @findex last @var{day}
 A number may precede a day of the week item to move forward
-supplementary weeks. It is best used in expression like @samp{third
-monday}. In this context, @samp{last @var{day}} or @samp{next
+supplementary weeks.  It is best used in expression like @samp{third
+monday}.  In this context, @samp{last @var{day}} or @samp{next
 @var{day}} is also acceptable; they move one week before or after
 the day that @var{day} by itself would represent.
 
@@ -343,7 +343,7 @@ A comma following a day of the week item is ignored.
 @cindex displacement of dates
 
 @dfn{Relative items} adjust a date (or the current date if none) forward
-or backward. The effects of relative items accumulate. Here are some
+or backward.  The effects of relative items accumulate.  Here are some
 examples:
 
 @example
@@ -361,18 +361,18 @@ examples:
 @findex hour @r{in date strings}
 @findex minute @r{in date strings}
 The unit of time displacement may be selected by the string @samp{year}
-or @samp{month} for moving by whole years or months. These are fuzzy
-units, as years and months are not all of equal duration. More precise
+or @samp{month} for moving by whole years or months.  These are fuzzy
+units, as years and months are not all of equal duration.  More precise
 units are @samp{fortnight} which is worth 14 days, @samp{week} worth 7
 days, @samp{day} worth 24 hours, @samp{hour} worth 60 minutes,
 @samp{minute} or @samp{min} worth 60 seconds, and @samp{second} or
-@samp{sec} worth one second. An @samp{s} suffix on these units is
+@samp{sec} worth one second.  An @samp{s} suffix on these units is
 accepted and ignored.
 
 @findex ago @r{in date strings}
 The unit of time may be preceded by a multiplier, given as an optionally
-signed number. Unsigned numbers are taken as positively signed. No
-number at all implies 1 for a multiplier. Following a relative item by
+signed number.  Unsigned numbers are taken as positively signed.  No
+number at all implies 1 for a multiplier.  Following a relative item by
 the string @samp{ago} is equivalent to preceding the unit by a
 multiplier with value @math{-1}.
 
@@ -389,8 +389,8 @@ one day in the past (equivalent to @samp{day ago}).
 The strings @samp{now} or @samp{today} are relative items corresponding
 to zero-valued time displacement, these strings come from the fact
 a zero-valued time displacement represents the current time when not
-otherwise changed by previous items. They may be used to stress other
-items, like in @samp{12:00 today}. The string @samp{this} also has
+otherwise changed by previous items.  They may be used to stress other
+items, like in @samp{12:00 today}.  The string @samp{this} also has
 the meaning of a zero-valued time displacement, but is preferred in
 date strings like @samp{this thursday}.
 
@@ -398,11 +398,11 @@ When a relative item causes the resulting date to cross a boundary
 where the clocks were adjusted, typically for daylight saving time,
 the resulting date and time are adjusted accordingly.
 
-The fuzz in units can cause problems with relative items. For
+The fuzz in units can cause problems with relative items.  For
 example, @samp{2003-07-31 -1 month} might evaluate to 2003-07-01,
-because 2003-06-31 is an invalid date. To determine the previous
+because 2003-06-31 is an invalid date.  To determine the previous
 month more reliably, you can ask for the month before the 15th of the
-current month. For example:
+current month.  For example:
 
 @example
 $ date -R
@@ -414,7 +414,7 @@ Last month was June!
 @end example
 
 Also, take care when manipulating dates around clock changes such as
-daylight saving leaps. In a few cases these have added or subtracted
+daylight saving leaps.  In a few cases these have added or subtracted
 as much as 24 hours from the clock, so it is often wise to adopt
 universal time by setting the @env{TZ} environment variable to
 @samp{UTC0} before embarking on calendrical calculations.
@@ -436,7 +436,7 @@ calendar date.
 If the decimal number is of the form @var{hh}@var{mm} and no other time
 of day item appears before it in the date string, then @var{hh} is read
 as the hour of the day and @var{mm} as the minute of the hour, for the
-specified time of day. @var{mm} can also be omitted.
+specified time of day.  @var{mm} can also be omitted.
 
 If both a calendar date and a time of day appear to the left of a number
 in the date string, but no relative item, then the number overrides the
@@ -447,26 +447,26 @@ year.
 @section Seconds since the Epoch
 
 If you precede a number with @samp{@@}, it represents an internal time
-stamp as a count of seconds. The number can contain an internal
+stamp as a count of seconds.  The number can contain an internal
 decimal point (either @samp{.} or @samp{,}); any excess precision not
 supported by the internal representation is truncated toward minus
-infinity. Such a number cannot be combined with any other date
+infinity.  Such a number cannot be combined with any other date
 item, as it specifies a complete time stamp.
 
 @cindex beginning of time, for @acronym{POSIX}
 @cindex epoch, for @acronym{POSIX}
 Internally, computer times are represented as a count of seconds since
-an epoch---a well-defined point of time. On @acronym{GNU} and
+an epoch---a well-defined point of time.  On @acronym{GNU} and
 @acronym{POSIX} systems, the epoch is 1970-01-01 00:00:00 @sc{utc}, so
 @samp{@@0} represents this time, @samp{@@1} represents 1970-01-01
-00:00:01 @sc{utc}, and so forth. @acronym{GNU} and most other
+00:00:01 @sc{utc}, and so forth.  @acronym{GNU} and most other
 @acronym{POSIX}-compliant systems support such times as an extension
 to @acronym{POSIX}, using negative counts, so that @samp{@@-1}
 represents 1969-12-31 23:59:59 @sc{utc}.
 
 Traditional Unix systems count seconds with 32-bit two's-complement
 integers and can represent times from 1901-12-13 20:45:52 through
-2038-01-19 03:14:07 @sc{utc}. More modern systems use 64-bit counts
+2038-01-19 03:14:07 @sc{utc}.  More modern systems use 64-bit counts
 of seconds with nanosecond subcounts, and can represent all the times
 in the known lifetime of the universe to a resolution of 1 nanosecond.
 
@@ -482,9 +482,9 @@ For example, on most hosts @samp{@@915148799} represents 1998-12-31
 @vindex TZ
 Normally, dates are interpreted using the rules of the current time
 zone, which in turn are specified by the @env{TZ} environment
-variable, or by a system default if @env{TZ} is not set. To specify a
+variable, or by a system default if @env{TZ} is not set.  To specify a
 different set of default time zone rules that apply just to one date,
-start the date with a string of the form @samp{TZ="@var{rule}"}. The
+start the date with a string of the form @samp{TZ="@var{rule}"}.  The
 two quote characters (@samp{"}) must be present in the date, and any
 quotes or backslashes within @var{rule} must be escaped by a
 backslash.
@@ -503,7 +503,7 @@ Sun Oct 31 01:30:00 EDT 2004
 In this example, the @option{--date} operand begins with its own
 @env{TZ} setting, so the rest of that operand is processed according
 to @samp{Europe/Paris} rules, treating the string @samp{2004-10-31
-06:30} as if it were in Paris. However, since the output of the
+06:30} as if it were in Paris.  However, since the output of the
 @command{date} command is processed according to the overall time zone
 rules, it uses New York time.  (Paris was normally six hours ahead of
 New York in 2004, but this example refers to a brief Halloween period
@@ -513,7 +513,7 @@ A @env{TZ} value is a rule that typically names a location in the
 @uref{http://www.twinsun.com/tz/tz-link.htm, @samp{tz} database}.
 A recent catalog of location names appears in the
 @uref{http://twiki.org/cgi-bin/xtra/tzdate, TWiki Date and Time
-Gateway}. A few non-@acronym{GNU} hosts require a colon before a
+Gateway}.  A few non-@acronym{GNU} hosts require a colon before a
 location name in a @env{TZ} setting, e.g.,
 @samp{TZ=":America/New_York"}.
 
@@ -521,10 +521,10 @@ The @samp{tz} database includes a wide variety of locations ranging
 from @samp{Arctic/Longyearbyen} to @samp{Antarctica/South_Pole}, but
 if you are at sea and have your own private time zone, or if you are
 using a non-@acronym{GNU} host that does not support the @samp{tz}
-database, you may need to use a @acronym{POSIX} rule instead. Simple
+database, you may need to use a @acronym{POSIX} rule instead.  Simple
 @acronym{POSIX} rules like @samp{UTC0} specify a time zone without
 daylight saving time; other rules can specify simple daylight saving
-regimes. @xref{TZ Variable,, Specifying the Time Zone with @code{TZ},
+regimes.  @xref{TZ Variable,, Specifying the Time Zone with @code{TZ},
 libc, The GNU C Library}.
 
 @node Authors of get_date
@@ -538,11 +538,11 @@ libc, The GNU C Library}.
 @cindex MacKenzie, David
 @cindex Meyering, Jim
 @cindex Eggert, Paul
-@code{get_date} was originally implemented by Steven M. Bellovin
+@code{get_date} was originally implemented by Steven M.  Bellovin
 (@email{smb@@research.att.com}) while at the University of North Carolina
-at Chapel Hill. The code was later tweaked by a couple of people on
+at Chapel Hill.  The code was later tweaked by a couple of people on
 Usenet, then completely overhauled by Rich $alz (@email{rsalz@@bbn.com})
-and Jim Berets (@email{jberets@@bbn.com}) in August, 1990. Various
+and Jim Berets (@email{jberets@@bbn.com}) in August, 1990.  Various
 revisions for the @sc{gnu} system were made by David MacKenzie, Jim Meyering,
 Paul Eggert and others.
 
diff --git a/doc/texinfo/mailutils.texi b/doc/texinfo/mailutils.texi
index 5e4ae5e..62faed0 100644
--- a/doc/texinfo/mailutils.texi
+++ b/doc/texinfo/mailutils.texi
@@ -3,12 +3,11 @@
 @setfilename mailutils.info
 @settitle GNU Mailutils Manual
 @setchapternewpage odd
-@finalout
 @c %**end of header
 
 @include version.texi
-@include macros.texi
 @include rendition.texi
+@include macros.texi
 
 @c Define indices
 @defcodeindex op
@@ -42,7 +41,7 @@
 * readmsg: (mailutils)readmsg.          Extract Messages from a Folder.
 * sieve: (mailutils)sieve.              Mail Filtering Utility.
 * mimeview: (mailutils)mimeview.        View MIME Messages.
-* mailutils-config: (mailutils)mailutils-config. List Information about Mailutils.
+* mu: (mailutils)mu.                    Mailutils Multi-Purpose Tool
 @end direntry
 @end ifinfo
 
@@ -57,13 +56,9 @@ Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009,
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.2 or
 any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
-and with the Back-Cover Texts as in (a) below. A copy of the license
-is included in the section entitled ``GNU Free Documentation License''.
-
-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
-this GNU Manual, like GNU software. Copies published by the Free
-Software Foundation raise funds for GNU development.''
+Invariant Sections, no Front-Cover, and no Back-Cover texts.
+A copy of the license is included in the section entitled ``GNU Free
+Documentation License''.
 @end copying
 
 @titlepage
@@ -75,9 +70,11 @@ Software Foundation raise funds for GNU development.''
 @insertcopying
 @end titlepage
 
+@ifnothtml
 @page
 @summarycontents
 @page
+@end ifnothtml
 @contents
 
 @ifnottex
@@ -125,6 +122,7 @@ Mailutils Programs
 
 * command line::      Command Line Syntax.  
 * configuration::     Common Configuration File.
+* debugging::
 
 * frm and from::      List Headers from a Mailbox.
 * mail::              Send and Receive Mail.
@@ -145,7 +143,7 @@ Mailutils Programs
 
 * mh::                The MH Message Handling System.
 
-* mailutils-config::  Get the Information about the Mailutils Build.
+* mu::                Mailutils Multi-Purpose Tool.
 
 Command Line
 
@@ -177,13 +175,19 @@ Configuration File Syntax
 
 * Comments::
 * Statements::
-* Block Statements::
+* Paths::
 
 Server Settings
 
 * General Server Configuration::
 * Server Statement::
 
+Debugging
+
+* Level Syntax::
+* Level BNF::
+* Debugging Categories::
+
 @command{mail} --- Send and Receive Mail
 
 * Invoking Mail::            Command Line Options.
@@ -232,6 +236,7 @@ Reading Mail
 
 * Movemail Configuration::
 * Movemail Options::     Description of the Available Options
+* Ownership::            Setting Destination Mailbox Ownership
 * Summary::              Short Movemail Invocation Summary
 
 @command{readmsg} --- Extract Messages from a Folder
@@ -260,7 +265,7 @@ A Sieve Interpreter
 
 maidag
 
-* Sendmail-maidag::          Using @command{maidag} with Sendmail.
+* Sendmail-maidag::         Using @command{maidag} with Sendmail.
 * Exim-maidag::             Using @command{maidag} with Exim.
 * MeTA1-maidag::            Using @command{maidag} with MeTA1.
 * Mailbox Quotas::
@@ -279,6 +284,7 @@ Maidag Scripting
 
 * Sieve Maidag Filters::
 * Scheme Maidag Filters::
+* Python Maidag Filters::
 
 mimeview
 
@@ -310,7 +316,7 @@ Configuring @command{comsatd}
 * General Settings::
 * Security Settings::
 
-@acronym{MH} --- The MH Message Handling System
+MH --- The MH Message Handling System
 
 * Diffs::      Major differences between Mailutils MH and other MH
                implementations.
@@ -321,70 +327,32 @@ Major differences between Mailutils MH and other MH implementations
 * Profile Variable Diffs::
 * Program Diffs::
 
-@command{mailutils-config} --- Get the Information about the Mailutils Build
-
-* Compiler Flags::      Getting Compiler Flags.
-* Loader Flags::        Getting Loader Flags.
-* General Information:: Obtaining General Build Information.
-
-Mailutils Libraries
-
-* libmailutils::    The Core Library.
-* libmu_auth::      Auxiliary Library for Authenticating Users.
-* libmu_scm::       Mailutils to Scheme Interface.
-* libmu_sieve::     GNU Implementation of Sieve Mail Filtering.
-
-Framework
-
-* Folder::             Folder.
-* Mailbox::            Mailbox.
-* Mailer::             Protocol Used to Send Mail.
-* Message::            Message.
-* Envelope::           Envelope.
-* Headers::            Headers.
-* Body::               Body.
-* Attribute::          Attribute.
-* Stream::             Stream.
-* Iterator::           Iterator.
-* Authenticator::      Authenticator.
-* Address::            Address.
-* Locker::             Locker.
-* URL::                Uniform Resource Locators.
-* Parse822::           Parsing RFC 822 headers.
-* Mailcap::            Parsing RFC 1524 file.
-
-Authentication Library
-
-* Data Types::
-* Initializing libmu_auth::
-* Module Creation and Destruction::
-* Obtaining Authorization Information::
-* Existing Modules::
-* Using libmu_auth in Your Programs::
-
-Mailutils to Scheme Interface
-
-* Address Functions::
-* Mailbox Functions::
-* Message Functions::
-* MIME Functions::
-* Logging Functions::
-* Other Functions::
-
-Using @file{libmu_scm}
-
-* Direct Linking::
-* Dynamic Linking::
-
-Sieve Library
-
-* Sieve Data Types::
-* Manipulating the Sieve Machine::
-* Logging and Diagnostic Functions::
-* Symbol Space Functions::
-* Memory Allocation::
-* Compiling and Executing the Script::
-* Writing Loadable Commands::
+MU
+
+* mu invocation syntax::
+* mu help::
+* mu info::
+* mu cflags::
+* mu ldflags::
+* mu query::
+* mu 2047::
+* mu filter::
+* mu acl::
+* mu wicket::
+* mu dbm::
+* mu logger::
+* mu pop::
+* mu imap::
+
+mu dbm
+
+* Create a Database::
+* Add Records to a Database::
+* Delete Records::
+* List the Database::
+* Dump the Database::
+* Dump Formats::
+* Dbm Exit Codes::
 
 Sieve Language
 
@@ -437,36 +405,58 @@ Date Input Formats
 
 @node Introduction
 @chapter Introduction
-
-GNU Mailutils is a rich and powerful protocol-independent mail
-framework.  It contains a series of useful mail libraries, clients,
-and servers.  These are the primary mail utilities for the GNU system.
-The central library is capable of handling electronic mail in various
-mailbox formats and protocols, both local and remote.  Specifically,
-this project contains a POP3 server, an IMAP4 server, and a Sieve mail
-filter. It also provides a POSIX `mailx' client, and a collection of
-other handy tools.
-
-The GNU Mailutils libraries supply an ample set of primitives for
-handling electronic mail in programs written in C, C++, Python or
-Scheme.
-
-At the core of Mailutils is libmailutils, a library which provides
-universal access to various mailboxes and protocols: UNIX mailbox,
-Maildir, MH, POP3, IMAP4, Sendmail, SMTP.  Mailutils offers functions
-for almost any mail-related task, such as parsing of messages, email
-addresses and URLs, handling MIME messages, listing mail folders,
-mailcap facilities, extensible Sieve filtering, access control lists.
-It supports various modern data security and authentication
-techniques: TLS encryption, SASL and GSSAPI, to name a few.
-The framework is able to work with a wide variety of authorization
-databases, ranging from traditional system password database up to
-RADIUS, SQL and LDAP.
-
-The utilities provided by Mailutils include imap4d and pop3d mail
-servers, mail reporting utility comsatd, general-purpose mail delivery
-agent maidag, mail filtering program sieve, and an implementation of
-MH message handling system.
+GNU Mailutils is a set of libraries and utilities for handling
+electronic mail.  It addresses a wide audience and can be of interest
+to application developers, casual users and system administrators alike.
+
+It provides programmers with a consistent API allowing them to
+handle a variety of different mailbox formats transparently and
+without having to delve into complexities of their internal structure.
+While doing so, it also provides interfaces that simplify common
+programming tasks, such as handling lists, parsing configuration
+files, etc.  The philosophy of Mailutils is to have a single and
+consistent programming interface for various objects designed to
+handle the same task.  It tries to use their similarities to create an
+interface that hides their differences and complexities.  This covers
+a wide variety of programming tasks: apart from mailbox handling,
+Mailutils also contains a unified iterface for work with various DBM
+databases and much more.
+
+The utilities built upon these libraries share that same distinctive
+feature: no matter what is the internal structure of an object, it is
+always handled the same way as other objects that do the same task.
+Again, the most common example of this approach are, of course,
+mailboxes.  Whatever Mailutils program you use, you can be sure it is
+able to handle various mailbox formats.  You even don't have to inform
+it about what type a mailbox is: it will do its best to discover it
+automatically.
+
+This approach sometimes covers entities which are seldom regarded as
+compatible.  For example, using Mailutils it is possible to treat an SMTP
+connection as a mailbox opened only for appending new messages.  This
+in turn, provides a way for extending the functionality of some
+utilities.  As an example, using this concept of mailboxes, the usual
+mail delivery agent becomes able to do things usually reserved for
+mail transport agents only!
+
+At the core of Mailutils is @file{libmailutils}, a library which
+provides an API for accessing a generalized mailbox.  A set of
+complementary libraries provide methods for handling particular
+mailbox implementations: UNIX mailbox, Maildir, MH, POP3, IMAP4,
+even SMTP.  Mailutils offers functions for almost any mail-related
+task, such as parsing of messages, email addresses and URLs, handling
+MIME messages, listing mail folders, mailcap facilities, extensible
+Sieve filtering, access control lists.  It supports various modern
+data security and authentication techniques: TLS encryption, SASL and
+GSSAPI, to name a few.  Mailutils is able to work with a wide
+variety of authorization databases, ranging from traditional system
+password database up to RADIUS, SQL and LDAP.
+
+The utilities provided by Mailutils include @command{imap4d} and
+@command{pop3d} mail servers, mail reporting utility
+@command{comsatd}, general-purpose mail delivery agent
+@command{maidag}, mail filtering program @command{sieve}, an implementation
+of MH message handling system and much more.
 
 All utilities share the same subset of command line options and use
 a unified configuration mechanism, which allows to easily configure
@@ -486,17 +476,17 @@ under the GNU FDL, and everything else is licensed under the GNU GPL.
 @section What this Book Contains
 
 @FIXME{This is more a plan on how the document should be structured,
-than a description of its actual structure. However it is:}
+than a description of its actual structure.  However it is:}
 
   This book addresses a wide audience of both system administrators
 and users that aim to use Mailutils programs, and programmers who wish
-to use Mailutils libraries in their programs. Given this audience,
+to use Mailutils libraries in their programs.  Given this audience,
 the book is divided in three major parts.
 
   The first part provides a detailed description of each Mailutils
-utility, and advices on how to use them in various situations. This
+utility, and advices on how to use them in various situations.  This
 part is intended for users and system administrators who are using
-Mailutils programs. If you are not interested in programming using
+Mailutils programs.  If you are not interested in programming using
 Mailutils, this is the only part you need to read.
 
   Subsequent parts address programmers.
@@ -508,67 +498,37 @@ Mailutils.
   Finally, the third part contains a complete Mailutils library
 reference. 
 
-  This version of the book is not finished. The places that may
+  This version of the book is not finished.  The places that may
 contain inaccurate information carry prominent notices stating so.
 For updated versions of the documentation, visit
-@uref{http://www.gnu.org/software/mailutils/manual}. If you have any
-questions, feel free to ask them at the mailing list
-@email{bug-mailutils@@gnu.org}. 
+@uref{http://mailutils.org/manual}.  All material that ends up in this
+document is first published in the Mailutils Wiki, available at
+@uref{http://mailutils.org/wiki}.  Be sure to visit it for latest
+updates.
+
+  If you have any questions that are not answered there, feel free to
+ask them at the mailing list @email{bug-mailutils@@gnu.org}. 
+
+@FIXME{Mailutils 3.0 introduced such amount of changes, most of which
+being a complete rewrite of the existing codebase, that the library
+tutorial and reference became hopelessly obsolete.  It is my deep
+conviction that using incorrect documentation is much worse than
+having no documentation at all, therefore I have withdrawn the
+obsolete parts from this edition of GNU Mailutils manual.  I am doing
+my best to document new Mailutils libraries and hope to be able to
+re-introduce these parts of the documentation soon.}
 
 @node History
 @section A bit of History, and why use this package?
 @UNREVISED
 
 This package started off to try and handle large mailbox files more
-gracefully then current POP3 servers did. While it handles this task,
-it also allows you to support a variety of different mailbox formats
-without any real effort on your part. Also, if a new format is added
-at a later date, your program will support that new format
-automatically as soon as it is compiled against the new library.
-
-@node Programs
-@chapter Mailutils Programs
-@cindex Programs
-@include programs.texi
-
-@node Libraries
-@chapter Mailutils Libraries
-@cindex Libraries
-
-@menu
-* libmailutils::    The Core Library.
-* libmu_auth::      Auxiliary Library for Authenticating Users.
-* libmu_scm::       Mailutils to Scheme Interface.
-* libmu_sieve::     GNU Implementation of Sieve Mail Filtering.
-@end menu
-
-@node libmailutils
-@section Framework
-@cindex Framework
-@include framework.texi
-
-@node libmu_auth
-@section Authentication Library
-@cindex Authentication Library
-@cindex libmu_auth
-@include libmu_auth.texi
-
-@node libmu_scm
-@section Mailutils to Scheme Interface
-@cindex Scheme
-@cindex libmu_scm
-@include libmu_scm.texi
-
-@node libmu_sieve
-@section Sieve Library
-@cindex Sieve Library
-@cindex libmu_sieve
-@include libmu_sieve.texi
-
-@node Sieve Language
-@chapter Sieve Language
-@cindex Sieve Language
-@include sieve.texi
+gracefully then available at that time POP3 servers did.  While it
+handles this task, it also allows you to support a variety of
+different mailbox formats without any real effort on your part. Also,
+if a new format is added at a later date, your program will support
+that new format automatically as soon as it is compiled against the
+new library. 
 
 @node Reporting Bugs
 @chapter Reporting Bugs
@@ -576,7 +536,7 @@ automatically as soon as it is compiled against the new library.
 Email bug reports to @email{bug-mailutils@@gnu.org}.
 
 As the purpose of bug reporting is to improve software, please be sure
-to include maximum information when reporting a bug. The information
+to include maximum information when reporting a bug.  The information
 needed is:
 
 @itemize
@@ -588,15 +548,33 @@ needed is:
 The archives of bug-mailutils mailing list are available from
 @url{http://mail.gnu.org/@/mailman/@/listinfo/@/bug-mailutils}.
 
+@node Programs
+@chapter Mailutils Programs
+@cindex Programs
+@include programs.texi
+
+@node Libraries
+@chapter Mailutils Libraries
+@cindex Libraries
+@WRITEME
+
+@node Sieve Language
+@chapter Sieve Language
+@cindex Sieve Language
+@include sieve.texi
+
 @node News
 @chapter Getting News About GNU Mailutils
 
 The two places to look for any news regarding GNU Mailutils are the
-Mailutils homepage at @url{http://www.gnu.org/@/software/@/mailutils}, and the
-project page at @url{http://savannah.gnu.org/@/projects/@/mailutils}.
+Mailutils homepage at @url{http://mailutils.org} or
+@url{http://www.gnu.org/@/software/@/mailutils}, and the project page
+at @url{http://savannah.gnu.org/@/projects/@/mailutils}. 
 
 The updated versions of this manual are available online from
-@url{http://www.gnu.org/@/software/@/mailutils/@/manual}.
+@uref{http://mailutils.org/manual}.  See also
+@uref{http://mailutils.org/wiki, Mailutils Wiki} for the latest
+updates.
 
 @node Acknowledgement
 @chapter Acknowledgement
@@ -630,128 +608,18 @@ Wojciech Polak @email{polak@@gnu.org}
 
 @node References
 @appendix References
-
-@itemize @bullet
-@item SMTP
-
-@itemize @minus
-@item
-@cite{RFC 2821: Simple Mail Transfer Protocol}
-
-@item
-@cite{RFC 2368: The mailto URL scheme}
-
-@item
-@cite{RFC 2487: SMTP Service Extension for Secure SMTP over TLS}
-@end itemize
-
-@item POP3
-
-@itemize @minus
-@item
-@cite{RFC 1939: Post Office Protocol - Version 3}
-
-@item
-@cite{RFC 1734: POP3 AUTHentication command}
-
-@item
-@cite{RFC 1957: Some Observations on Implementations of the Post Office
-Protocol (POP3)}
-
-@item
-@cite{RFC 2449: POP3 Extension Mechanism}
-
-@item
-@cite{RFC 2384: POP URL Scheme}
-
-@item
-@cite{RFC 2595: Using TLS with IMAP, POP3 and ACAP}
-@end itemize
-
-@item IMAP4
-
-@itemize @minus
-@item
-@cite{RFC 2060: INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1}
-
-@item
-@cite{RFC 2088: IMAP4 non-synchronizing literals}
-
-@item
-@cite{RFC 2193: IMAP4 Mailbox Referrals}
-
-@item
-@cite{RFC 2221: IMAP4 Login Referrals}
-
-@item
-@cite{RFC 2342: IMAP4 Namespace}
-
-@item
-@cite{RFC 2192: IMAP URL Scheme}
-
-@item
-@cite{RFC 1731: IMAP4 Authentication Mechanisms}
-
-@item
-@cite{RFC 2245: Anonymous SASL Mechanism}
-
-@item
-@cite{RFC 2595: Using TLS with IMAP, POP3 and ACAP}
-@end itemize
-
-@item message formats
-
-@itemize @minus
-@item
-@cite{RFC 2822: Internet Message Format}
-
-@item
-@cite{RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part One:
-Format of Internet Message Bodies}
-
-@item
-@cite{RFC 2046: Multipurpose Internet Mail Extensions (MIME) Part Two:
-Media Types}
-
-@item
-@cite{RFC 2047: Multipurpose Internet Mail Extensions (MIME) Part Three:
-Message Header Extensions for Non-ASCII Text}
-
-@item
-@cite{RFC 2049: Multipurpose Internet Mail Extensions (MIME) Part Five:
-Conformance Criteria and Examples}
-
-@item
-@cite{RFC 2111: Content-ID and Message-ID Uniform Resource Locators}
-@end itemize
-
-@item miscellaneous related topics
-
-@itemize @minus
-@item
-@cite{RFC 1738: Uniform Resource Locators (URL)}
-
-@item
-@cite{RFC 2298: An Extensible Message Format for Message Disposition
-Notifications}
-
-@item
-@cite{RFC 3028: Sieve: A Mail Filtering Language}
-
-@item
-@cite{RFC 3431: Sieve Extension: Relational Tests}
-
-@item
-@cite{Internet Email Protocols: A Developer's Guide, by Kevin Johnson}
-@end itemize
-@end itemize
+@WRITEME
 
 @node Date Input Formats
 @appendix Date Input Formats
 @include getdate.texi
 
+@node Usage Vars
+@appendix Configuring Help Summary
 @include usage.texi
 
+@node GNU FDL
+@appendix GNU Free Documentation License
 @include fdl.texi
 
 @node Function Index
diff --git a/doc/texinfo/mu-mh.texi b/doc/texinfo/mu-mh.texi
index 1442ebb..41cb9ed 100644
--- a/doc/texinfo/mu-mh.texi
+++ b/doc/texinfo/mu-mh.texi
@@ -16,7 +16,7 @@ For the information about the current state of Mailutils MH
 implementation please refer to file @file{mh/TODO} in the Mailutils
 distribution directory.
 
-[FIXME]
+@FIXME{This is perhaps not so important now.}
 
 @menu
 * Diffs::      Major differences between Mailutils MH and other MH
@@ -27,7 +27,7 @@ distribution directory.
 @subsection Major differences between Mailutils MH and other MH implementations
 
 @enumerate 1
-@item All programs use usual GNU long options. The support for MH single-dash
+@item All programs use usual GNU long options.  The support for MH single-dash
 options is provided for backward compatibility;
 
 @item UUCP addresses are not supported;
@@ -55,16 +55,16 @@ Diffs});
 @anchor{decode function}
 @deftypefn {MH Format} string decode (string @var{str})
 
-Decodes the input string @var{str} as per RFC 2047. Useful in printing
+Decodes the input string @var{str} as per RFC 2047.  Useful in printing
 @samp{From:}, @samp{To:} and @samp{Subject:} headers.
 
 Notice that, unlike the similar NMH function, @code{decode} checks the value
 of the global profile variable @code{Charset} (@pxref{Charset variable})
-to determine the charset to output the result in. If this variable is
-not set, @code{decode} returns its argument without any change. If
+to determine the charset to output the result in.  If this variable is
+not set, @code{decode} returns its argument without any change.  If
 this variable is set to @code{auto}, @code{decode} tries to determine
 the charset name from the setting of @env{LC_ALL} environment
-variable. Otherwise, the value of @code{Charset} is taken to be the
+variable.  Otherwise, the value of @code{Charset} is taken to be the
 name of the character set.
 @end deftypefn
 
@@ -75,7 +75,7 @@ Returns package name (string @samp{mailutils}).
 
 @deftypefn {MH Format} string package_string ()
 
-Returns full package string (e.g. @samp{GNU Mailutils 2.1})
+Returns full package string (e.g.  @samp{GNU Mailutils 2.1})
 @end deftypefn
 
 @deftypefn {MH Format} string version ()
@@ -86,7 +86,7 @@ Returns mailutils version.
 @deftypefn {MH Format} string unre (string @var{str})
 
 The function removes any leading whitespace and eventual @samp{Re:} prefix
-from its argument. Useful for creating subjects in reply messages:
+from its argument.  Useful for creating subjects in reply messages:
 
 @smallexample
   %<@{subject@}Subject: Re: %(unre@{subject@})\\n%>
@@ -96,7 +96,7 @@ from its argument. Useful for creating subjects in reply messages:
 @anchor{reply_regex function}
 @deftypefn {MH Format} void reply_regex (string @var{r})
 
-Sets the regular expression used to recognize reply messages. The
+Sets the regular expression used to recognize reply messages.  The
 argument @var{r} should be a POSIX extended regular expression. 
 Matching is case insensitive. 
 
@@ -109,7 +109,7 @@ For example, the following invocation
 @noindent
 corresponds to English @samp{Re}, Polish @samp{Odp}, Norwegian @samp{Aw} or
 German @samp{Ang}, optionally followed by a number in brackets, followed
-by colon and any amount of whitespace. Notice proper quoting of the
+by colon and any amount of whitespace.  Notice proper quoting of the
 regex metacharacters.
 
 See also @code{Reply-Regex} (@pxref{Reply-Regex variable}) and
@@ -123,12 +123,12 @@ See also @code{Reply-Regex} (@pxref{Reply-Regex variable}) and
 If @var{str} is not given, the value of @samp{Subject:} header is taken.
 
 The function returns true if its argument matches the ``reply subject''
-regular expression. This expression is set via the global profile variable
+regular expression.  This expression is set via the global profile variable
 @code{Reply-Regex} (@pxref{Reply-Regex variable}) or via the format
 function @code{reply_regex}. 
 
 This function is useful for creating @samp{Subject:} headers in reply
-messages. For example, consider the following construction:
+messages.  For example, consider the following construction:
 
 @smallexample
 @group
@@ -139,7 +139,7 @@ messages. For example, consider the following construction:
 @end smallexample
 
 If the @samp{Subject:} header already contained reply prefix, this construct
-leaves it unchanged. Otherwise it prepends to it the value of
+leaves it unchanged.  Otherwise it prepends to it the value of
 @code{Reply-Prefix} profile variable, or, if it is unset, the string
 @samp{Re:}. 
 
@@ -151,7 +151,7 @@ This expression is used in default @file{replcomps} and
 
 This function returns true if the given element is present in the
 recipient mask (as modified by @option{--cc} or @option{--nocc} options) and
-false otherwise. It is used in default formats for @command{repl} and
+false otherwise.  It is used in default formats for @command{repl} and
 @command{comp}, e.g.: 
 
 @smallexample
@@ -201,8 +201,8 @@ output.
 @anchor{Reply-Regex variable}
 @deftypevar {MH Variable} string Reply-Regex
 
-Keeps the regular expression used to recognize reply messages. The
-argument should be a POSIX extended regular expression. Matching
+Keeps the regular expression used to recognize reply messages.  The
+argument should be a POSIX extended regular expression.  Matching
 is case insensitive. 
 
 For more information, please see @xref{reply_regex function}.
@@ -225,21 +225,21 @@ RAND @command{anno} displays the prompt anyway.
 @item burst
 
 The utility is able to burst both RFC 934 digest messages and MIME
-multipart messages. It provides two additional command line options:
+multipart messages.  It provides two additional command line options:
 @option{--recurse} and @option{--length}.
 
 The @option{--recurse} option instructs the utility to recursively
 expand the digest.
 
 The @option{--length} option can be used to set the minimal encapsulation
-boundary length for RFC 934 digests. Default length is 1,
+boundary length for RFC 934 digests.  Default length is 1,
 i.e. encountering one dash immediately following a newline triggers
-digest decoding. It is OK for messages that follow RFC 934
-specification. However, many user agents do not precisely follow it,
+digest decoding.  It is OK for messages that follow RFC 934
+specification.  However, many user agents do not precisely follow it,
 in particular, they often do not escape lines starting with a dash by
-@samp{- } sequence. @command{Mailman} is one of such agents. To cope
+@samp{- } sequence.  @command{Mailman} is one of such agents.  To cope
 with such digests you can set encapsulation boundary length to a higher
-value. For example, @command{bounce --length=8} has been found to be
+value.  For example, @command{bounce --length=8} has been found to be
 sufficient for most Mailman-generated digests.
 
 @item comp
@@ -248,7 +248,7 @@ Understands @option{--build} option.
 
 @item fmtdump
 
-This command is not provided. Use @option{fmtcheck} instead.
+This command is not provided.  Use @option{fmtcheck} instead.
 
 @item mhl
 
@@ -280,8 +280,8 @@ The following format variables are silently ignored: @samp{center},
 @itemize @bullet
 
 @item New option
-New option @option{--compose} forces @command{mhn} editing mode. This
-is also the default mode. This differs from the standard
+New option @option{--compose} forces @command{mhn} editing mode.  This
+is also the default mode.  This differs from the standard
 @command{mhn}, which switches to the editing mode only if no other
 options were given and the input file name coincides with the value of
 @env{mhdraft} environment variable.  
@@ -289,22 +289,22 @@ options were given and the input file name coincides with the value of
 @item Show mode (@option{--show})
 If an appropriate mhn-show-type[/subtype] was not found, GNU @command{mhn}
 prints the decoded message content using @code{moreproc}
-variable. Standard @command{mhn} in this case used to print @samp{don't
+variable.  Standard @command{mhn} in this case used to print @samp{don't
 know how to display content} diagnostic. 
 
 The default behaviour is to pipe the content to the standard input
-of the mhn-show-type[/subtype] command. This is altered to using a
+of the mhn-show-type[/subtype] command.  This is altered to using a
 temporary file if the command contains @code{%f} or @code{%F} escapes.
 
 @item Store mode (@option{--store})
 If the @code{Content-Disposition} header contains @samp{filename=},
 and @command{mhn} is invoked with @option{--auto} switch, it
 transforms the file name into the absolute notation and uses it only
-if it lies below the current mhn-storage directory. Standard
+if it lies below the current mhn-storage directory.  Standard
 @command{mhn} only requires that the file name do not begin with @samp{/}.
 
 Before saving a message part, GNU @command{mhn} checks if the file already
-exists. If so, it asks whether the user wishes to rewrite it. This
+exists.  If so, it asks whether the user wishes to rewrite it.  This
 behaviour is disabled when @option{--quiet} option was given.
 @end itemize
 
@@ -319,7 +319,7 @@ recognized only if at least one of the following conditions is met:
 
 @itemize @bullet
 @item The word @var{component} contains at least one capital letter.
-E.g. @option{--User-Agent Mailutils}.
+E.g.  @option{--User-Agent Mailutils}.
 
 @item The word @var{component} ends with a colon, as in
 @option{user-agent: Mailutils}.
@@ -334,7 +334,7 @@ pick --component @var{field} --pattern @var{string}
 @end smallexample
 
 New command line option @option{--cflags} allows to control the type of 
-regular expressions used. The option must occur right before
+regular expressions used.  The option must occur right before
 @option{--pattern} or @option{--component} option (or one of its
 aliases, like @option{--cc}, @option{--from}, etc.)
 
@@ -401,11 +401,11 @@ will add it automatically.
 @item
 Linking messages between folders goes against the logic of Mailutils,
 so @command{refile} never makes links even if called with
-@option{--link} option. The latter is actually a synonym for @option{--copy},
+@option{--link} option.  The latter is actually a synonym for @option{--copy},
 which preserves the original message.
 
 @item
-The @option{--preserve} option is not implemented. It is retained for backward
+The @option{--preserve} option is not implemented.  It is retained for backward
 compatibility only.
 
 @item
@@ -414,7 +414,7 @@ Message specs and folder names may be interspersed.
 
 @item repl
 
-Understands @option{--use} option. Disposition shell provides
+Understands @option{--use} option.  Disposition shell provides
 @code{use} command. 
 
 @item rmm
@@ -423,7 +423,7 @@ Understands @option{--use} option. Disposition shell provides
 @item
 Different behaviour if one of the messages in the list does not exist:
 
-Mailutils @command{rmm} does not delete any messages. Standard
+Mailutils @command{rmm} does not delete any messages.  Standard
 @command{rmm} in this case deletes all messages preceding the
 non-existent one. 
 
@@ -445,7 +445,7 @@ Any number of @option{--datefield}, @option{--textfield} and
 @option{--numfield} options may be given, thus allowing to build sort
 criteria of arbitrary complexity. 
 
-The order of @option{--.*field} options sets the ordering priority. This
+The order of @option{--.*field} options sets the ordering priority.  This
 differs from the behaviour of the standard @command{sortm}, which
 always orders datefield-major, textfield-minor.
 
@@ -459,7 +459,7 @@ List the ordered messages using a format string given by
 
 @item --dry-run
 Do not actually sort messages, rather print what would have been
-done. This is useful for debugging purposes.
+done.  This is useful for debugging purposes.
 @end table
 
 @end table
diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index bcac978..84d9034 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -5,12 +5,12 @@
 @comment *******************************************************************
 
 GNU Mailutils provides a broad set of utilities for handling
-electronic mail. These utilities address the needs of both system
+electronic mail.  These utilities address the needs of both system
 administrators and users.
 
 All utilities are built around a single core subsystem and share many
-common aspects. All of them are able to work with almost any existing
-mailbox formats. They use a common configuration file syntax, and
+common aspects.  All of them are able to work with almost any existing
+mailbox formats.  They use a common configuration file syntax, and
 their configuration files are located in a single subdirectory.
 
 In this chapter we will discuss each utility, and give some advices on
@@ -22,6 +22,7 @@ syntax.
 @menu
 * command line::      Command Line Syntax.  
 * configuration::     Common Configuration File.
+* debugging::
 
 * frm and from::      List Headers from a Mailbox.
 * mail::              Send and Receive Mail.
@@ -42,7 +43,7 @@ syntax.
 
 * mh::                The MH Message Handling System.
 
-* mailutils-config::  Get the Information about the Mailutils Build.
+* mu::                Mailutils Multi-Purpose Tool.
 @end menu
 
 @node command line
@@ -57,55 +58,55 @@ syntax.
 @subsection Basic Notions About Command Line Options
 
   Many command line options have two forms, called short and long
-forms. Both forms are absolutely identical in function; they are
+forms.  Both forms are absolutely identical in function; they are
 interchangeable. 
 
   The @dfn{short} form is a traditional form for UNIX utilities.
 In this form, the option consists of a single dash, followed by a
-single letter, e.g. @option{-c}.
+single letter, e.g.  @option{-c}.
 
   Short options which require arguments take their arguments
 immediately following the option letter, optionally separated by white
-space. For example, you might write @option{-f name}, or @option{-fname}.
+space.  For example, you might write @option{-f name}, or @option{-fname}.
 Here, @option{-f} is the option, and @option{name} is its argument.
 
   Short options which allow optional arguments take their arguments
 immediately following the option letter, @emph{without any intervening
-white space characters}. This is important, so that the command line
+white space characters}.  This is important, so that the command line
 parser might discern that the text following option is its argument,
-not the next command line parameter. For example, if option @option{-d}
+not the next command line parameter.  For example, if option @option{-d}
 took an optional argument, then @option{-dname} would mean the option
 with its argument (@option{name} in this case), and @option{-d name} would
 mean the @option{-d} option without any argument, followed by command
 line argument @option{name}.
 
   Short options' letters may be clumped together, but you are not
-required to do this. When short options are clumped as a set, use one
-(single) dash for them all, e.g. @option{-cvl} is equivalent to @option{-c
--v -l}. However, only options that do not take arguments may be
-clustered this way. If an option takes an argument, it can only be
+required to do this.  When short options are clumped as a set, use one
+(single) dash for them all, e.g.  @option{-cvl} is equivalent to @option{-c
+-v -l}.  However, only options that do not take arguments may be
+clustered this way.  If an option takes an argument, it can only be
 the last option in such a cluster, otherwise it would be impossible to
-specify the argument for it. Anyway, it is much more readable to
+specify the argument for it.  Anyway, it is much more readable to
 specify such options separated.
 
   The @dfn{long} option names are probably easier to memorize than
-their short counterparts. They consist of two dashes, followed by a
+their short counterparts.  They consist of two dashes, followed by a
 multi-letter option name, which is usually selected to be a mnemonics
-for the operation it requests. For example, @option{--verbose} is a
-long option that increases the verbosity of a utility. In addition,
+for the operation it requests.  For example, @option{--verbose} is a
+long option that increases the verbosity of a utility.  In addition,
 long option names can abbreviated, provided that such an abbreviation
-is unique among the options understood by a given utility. For
+is unique among the options understood by a given utility.  For
 example, if a utility takes options @option{--foreground} and
 @option{--forward}, then the shortest possible abbreviations for these
-options are @option{--fore} and @option{--forw}, correspondingly. If
+options are @option{--fore} and @option{--forw}, correspondingly.  If
 you try to use @option{--for}, the utility will abort and inform you
 that the abbreviation you use is ambiguous, so it is not clear which
 of the options you intended to use.
 
   Long options which require arguments take those arguments following
-the option name. There are two ways of specifying a mandatory
-argument. It can be separated from the option name either by an equal
-sign, or by any amount of white space characters. For example, if the
+the option name.  There are two ways of specifying a mandatory
+argument.  It can be separated from the option name either by an equal
+sign, or by any amount of white space characters.  For example, if the
 @option{--file} option requires an argument, and you wish to supply
 @file{name} as its argument, then you can do so using any of the
 following notations: @option{--file=name} or @option{--file name}.
@@ -125,22 +126,22 @@ equal sign.
   Display a short summary of the command line options understood by
 this utilities, along with a terse description of each.
 
-  The output of this option consists of three major parts. First, a
-usage synopsis is displayed. For example:
+  The output of this option consists of three major parts.  First, a
+usage synopsis is displayed.  For example:
 
-@smallexample
+@example
 @group
 Usage: sieve [OPTION...] SCRIPT
 GNU sieve -- a mail filtering tool
 @end group
-@end smallexample
+@end example
 
   The first line tells that the @command{sieve} utility takes any
 number of options (brackets indicate optional part) and a single
-mandatory argument (@samp{SCRIPT}). The second lines summarizes the
+mandatory argument (@samp{SCRIPT}).  The second lines summarizes the
 purpose of the utility.
 
-  Following this header is an option summary. It consists of two
+  Following this header is an option summary.  It consists of two
 columns:
 
 @verbatim
@@ -151,10 +152,10 @@ columns:
 
 
 The leftmost column contains a comma-separated list of option
-names. Short options are listed first. The options are ordered
-alphabetically. Arguments, if any, are specified after the last
+names.  Short options are listed first.  The options are ordered
+alphabetically.  Arguments, if any, are specified after the last
 option name in the list, so that, e.g. the option @samp{-e} in the
-example above requires an argument: @samp{-e ADDRESS}. Optional
+example above requires an argument: @samp{-e ADDRESS}.  Optional
 arguments are enclosed in square brackets, as in @option{--debug}
 option in the example above.
 
@@ -166,20 +167,20 @@ notices and lists the email address for reporting bugs.
 
 @xopindex{usage, described}
 @item --usage
-Display a short summary of options. In the contrast to the
+Display a short summary of options.  In the contrast to the
 @option{--help} option, only option names and arguments
-are printed, without any textual description. For example:
+are printed, without any textual description.  For example:
 
-@smallexample
+@example
 @group
 Usage: sieve [-cv?V] [--compile-only] [--debug[=FLAGS]]
              [--email=ADDRESS] SCRIPT
 @end group
-@end smallexample
+@end example
 @end table
 
   The exact formatting of the output produced by these two options is
-configurable. @xref{Usage Vars}, for a detailed descriptions of it.
+configurable.  @xref{Usage Vars}, for a detailed descriptions of it.
 
 @table @option
 @xopindex{version, described}
@@ -189,15 +190,15 @@ Print program version and exit.
 
 @xopindex{show-config-options, described}
 @item --show-config-options
-Show configuration options used when compiling the package. You can
+Show configuration options used when compiling the package.  You can
 use this option to verify if support for a particular mailbox format
-or other functionality is compiled in the binary. The output of this
+or other functionality is compiled in the binary.  The output of this
 option is intended to be both machine-readable and understandable by
 humans.
 @end table
 
   The following command line options affect parsing of configuration
-files. Here we provide a short summary, the next section will
+files.  Here we provide a short summary, the next section will
 describe them in detail.
 
 @table @option
@@ -224,6 +225,10 @@ Do not load site-wide configuration file.
 @xopindex{no-user-config, introduced}
 @item --no-user-config
 Do not load user configuration file.
+
+@xopindex{set, introduced}
+@item --set=@var{path}
+Set configuration variable.
 @end table
 
 @node configuration
@@ -232,7 +237,7 @@ Do not load user configuration file.
 @cindex mailutils.rc
 
   Configuration files are the principal means of configuring any GNU
-Mailutils component. When started, each utility tries to load its
+Mailutils component.  When started, each utility tries to load its
 configuration from the following locations, in that order:
 
 @enumerate 1
@@ -242,16 +247,16 @@ It is named @file{@var{sysconfdir}/mailutils.rc}, where @var{sysconfdir} stands
 for the system configuration directory set when compiling the package.
 You can obtain the value of @var{sysconfdir} by running
 
-@smallexample
+@example
 $ mailutils-config --info sysconfdir
-@end smallexample
+@end example
 
 @noindent
 or
 
-@smallexample
+@example
 $ @var{prog} --show-config-options | grep SYSCONFDIR
-@end smallexample
+@end example
 
 @noindent
 where @var{prog} stands for any GNU Mailutils utility.
@@ -264,7 +269,7 @@ command line option was given.
 
 A per user configuration file is located in the user home directory
 and is named @samp{.@var{prog}}, where @var{prog} is the name of the
-utility. For example, the per-user configuration file for
+utility.  For example, the per-user configuration file for
 @command{sieve} utility is named @file{.sieve}.
 
 @xopindex{no-user-config, described}
@@ -277,31 +282,31 @@ command line option was given.
 @end enumerate
 
 The order in which configuration files are loaded defines the
-precedence of their settings. Thus, the settings from additional
+precedence of their settings.  Thus, the settings from additional
 configuration file override those set in per-user configuration file.
 The latter, in their turn, take precedence over the settings from the
 site-wide configuration file.
 
 @xopindex{config-verbose, described}
 Neither site-wide nor user configuration files are required to
-exist. If any or both of them are absent, GNU Mailutils does not
-complain, and the utility falls back to its default settings. To make
+exist.  If any or both of them are absent, GNU Mailutils does not
+complain, and the utility falls back to its default settings.  To make
 configuration processing more verbose, use the
-@option{--config-verbose} command line option. Here is an example of
+@option{--config-verbose} command line option.  Here is an example of
 what you might get using this option:
 
-@smallexample
+@example
 imap4d: Info: parsing file `/etc/mailutils.rc'
 imap4d: Info: finished parsing file `/etc/mailutils.rc'
-@end smallexample
+@end example
 
 Specifying this option more than once adds more verbosity to this
-output. If this option is given two times, GNU Mailutils will print
+output.  If this option is given two times, GNU Mailutils will print
 any configuration file statement it parsed, along with the exact
 location where it occurred (the exact meaning of each statement will
 be described later in this chapter):
 
-@smallexample
+@example
 imap4d: Info: parsing file `/etc/mailutils.rc'
 # 1 "/etc/mailutils.rc"
 mailbox @{
@@ -314,30 +319,43 @@ mailbox @{
 include /etc/mailutils.d;
 imap4d: Info: parsing file `/etc/mailutils.d/imap4d'
 ...
-@end smallexample
+@end example
 
 @xopindex{config-lint, described}
   To test configuration file without actually starting the utility,
-use the @option{--config-lint} command line option. With this option,
+use the @option{--config-lint} command line option.  With this option,
 any Mailutils utility exits after finishing parsing of the
-configuration files. Any errors occurred during parsing are displayed
-on the standard error output. This option can be combined with
+configuration files.  Any errors occurred during parsing are displayed
+on the standard error output.  This option can be combined with
 @option{--config-verbose} to obtain more detailed output.
 
 @xopindex{config-help, described}
   The @option{--config-help} command line option produces on the
 standard output the summary of all configuration statements understood
 by the utility, with detailed comments and in the form suitable for
-configuration file. For example, the simplest way to write a
+configuration file.  For example, the simplest way to write a
 configuration file for, say, @command{imap4d} is to run
 
-@smallexample
+@example
 $ imap4d --config-help > imap4d.rc
-@end smallexample
+@end example
 
 @noindent
 and to edit the @file{imap4d.rc} file with your editor of choice.
 
+@xopindex{set, described}
+  It is also possible to set or override arbitrary configuration
+variables in the command line.  It can be done via the @option{--set}
+option.  Its argument is a @dfn{pathname} of the variable to be set.
+For example, to define the variable @samp{syslog} in section
+@samp{logging} to @samp{no}, do the following:
+
+@example
+$ imap4d --set .logging.syslog=no
+@end example
+
+Configuration pathnames are discussed in detail in @ref{Paths}.
+
 @menu
 * conf-syntax::         Configuration File Syntax
 * Include::             Include Statement
@@ -361,40 +379,41 @@ and to edit the @file{imap4d.rc} file with your editor of choice.
 
 @node conf-syntax
 @subsection Configuration File Syntax
-  Configuration files consist of a series of statements. Blanks,
-tabs, newlines and comments, collectively called @dfn{white space} are
-ignored except as they serve to separate tokens. Some white space is
-required to separate otherwise adjacent keywords and values.
+  The configuration file consists of statements and comments.
+
+  There are three classes of lexical tokens: keywords, values, and
+separators.  Blanks, tabs, newlines and comments, collectively called
+@dfn{white space} are ignored except as they serve to separate
+tokens.  Some white space is required to separate otherwise adjacent 
+keywords and values.
 
 @menu
 * Comments::
 * Statements::
-* Block Statements::
+* Paths::
 @end menu
 
 @node Comments
 @subsubsection Comments
-@cindex comments, configuration file
-@cindex comments, single-line
+@cindex Comments in a configuration file
 @cindex single-line comments
   @dfn{Comments} may appear anywhere where white space may appear in the
-configuration file. There are two kinds of comments:
-single-line and multi-line comments. @dfn{Single-line} comments start
+configuration file.  There are two kinds of comments:
+single-line and multi-line comments.  @dfn{Single-line} comments start
 with @samp{#} or @samp{//} and continue to the end of the line:
 
-@smallexample
+@example
 # This is a comment
 // This too is a comment
-@end smallexample
+@end example
 
-@cindex comments, multi-line
 @cindex multi-line comments
   @dfn{Multi-line} or @dfn{C-style} comments start with the two
 characters @samp{/*} (slash, star) and continue until the first
 occurrence of @samp{*/} (star, slash).
 
-  Multi-line comments cannot be nested. However, single-line comments
-are allowed to appear within a multi-line one.
+  Multi-line comments cannot be nested.  However, single-line comments
+may well appear within multi-line ones.
 
 @node Statements
 @subsubsection Statements
@@ -402,21 +421,20 @@ are allowed to appear within a multi-line one.
 @cindex configuration file statements
 @cindex statement, simple
 @cindex simple statements
-  A @dfn{simple statement}, consists of a keyword and value 
-separated by any amount of whitespace. Simple statement is terminated
-with a semicolon (@samp{;}), unless it contains a @dfn{here-document}
-(see below), in which case semicolon is optional.
+  A @dfn{simple statement} consists of a keyword and value
+separated by any amount of whitespace.  Simple statement is terminated
+with a semicolon (@samp{;}).
 
-  Examples of simple statements:
+  The following is a simple statement:
 
-@smallexample
-pidfile /var/run/imap4d.pid;
-transcript yes;
-@end smallexample
+@example
+standalone yes;
+pidfile /var/run/pop3d.pid;
+@end example
 
   A @dfn{keyword} begins with a letter and may contain letters,
 decimal digits, underscores (@samp{_}) and dashes (@samp{-}).
-Examples of keywords are: @samp{group}, @samp{identity-check}.
+Examples of keywords are: @samp{expression}, @samp{output-file}.
 
   A @dfn{value} can be one of the following:
 
@@ -424,7 +442,7 @@ Examples of keywords are: @samp{group}, @samp{identity-check}.
 @item number
   A number is a sequence of decimal digits.
 
-@anchor{boolean value}
+@anchor{boolean value}  
 @item boolean
 @cindex boolean value
   A boolean value is one of the following: @samp{yes}, @samp{true},
@@ -435,14 +453,14 @@ Examples of keywords are: @samp{group}, @samp{identity-check}.
 @cindex string, unquoted
   An unquoted string may contain letters, digits, and any of the
 following characters: @samp{_}, @samp{-}, @samp{.}, @samp{/},
-@samp{:}.
+@samp{@@}, @samp{*}, @samp{:}.
 
 @item quoted string
 @cindex quoted string
 @cindex string, quoted
 @cindex escape sequence
   A quoted string is any sequence of characters enclosed in
-double-quotes (@samp{"}). A backslash appearing within a quoted
+double-quotes (@samp{"}).  A backslash appearing within a quoted
 string introduces an @dfn{escape sequence}, which is replaced
 with a single character according to the following rules:
 
@@ -456,142 +474,220 @@ with a single character according to the following rules:
 @item \n @tab Newline character (@acronym{ASCII} 10)
 @item \r @tab Carriage return character (@acronym{ASCII} 13)
 @item \t @tab Horizontal tabulation character (@acronym{ASCII} 9)
+@item \v @tab Vertical tabulation character (@acronym{ASCII} 11)
 @item \\ @tab A single backslash (@samp{\})
 @item \" @tab A double-quote.
 @end multitable
 @end float
 
   In addition, the sequence @samp{\@var{newline}} is removed from
-the string. This allows to split long strings over several
+the string.  This allows to split long strings over several
 physical lines, e.g.:
 
-@smallexample
+@example
 @group
 "a long string may be\
  split over several lines"
 @end group
-@end smallexample
+@end example
 
   If the character following a backslash is not one of those specified
 above, the backslash is ignored and a warning is issued.
 
   Two or more adjacent quoted strings are concatenated, which gives
 another way to split long strings over several lines to improve
-readability. The following fragment produces the same result as the
+readability.  The following fragment produces the same result as the
 example above:
 
-@smallexample
+@example
 @group
 "a long string may be"
 " split over several lines"
 @end group
-@end smallexample
+@end example
 
 @anchor{here-document}
 @item Here-document
 @cindex here-document
-  @dfn{Here-document} is a special construct that allows to introduce
+  A @dfn{here-document} is a special construct that allows to introduce
 strings of text containing embedded newlines.  
 
   The @code{<<@var{word}} construct instructs the parser to read all
-the lines that follow up to the line containing only @var{word}, with
-possible trailing blanks. Any lines thus read are concatenated
-together into a single string. For example:
+the following lines up to the line containing only @var{word}, with
+possible trailing blanks.  Any lines thus read are concatenated
+together into a single string.  For example:
 
-@smallexample
+@example
 @group
 <<EOT
 A multiline
 string
 EOT
 @end group
-@end smallexample
+@end example
 
-  Body of a here-document is interpreted the same way as
+  The body of a here-document is interpreted the same way as a
 double-quoted string, unless @var{word} is preceded by a backslash
-(e.g. @samp{<<\EOT}) or enclosed in double-quotes, in which case
+(e.g.  @samp{<<\EOT}) or enclosed in double-quotes, in which case
 the text is read as is, without interpretation of escape sequences.
 
   If @var{word} is prefixed with @code{-} (a dash), then all leading
 tab characters are stripped from input lines and the line containing
-@var{word}. Furthermore, if @code{-} is followed by a single space,
-all leading whitespace is stripped from them. This allows to indent
-here-documents in a natural fashion. For example:
+@var{word}.  Furthermore, if @code{-} is followed by a single space,
+all leading whitespace is stripped from them.  This allows to indent
+here-documents in a natural fashion.  For example:
 
-@smallexample
+@example
 @group
 <<- TEXT
-    All leading whitespace will be
+    The leading whitespace will be
     ignored when reading these lines.
 TEXT
 @end group
-@end smallexample
+@end example
 
   It is important that the terminating delimiter be the only token on
-its line. The only exception to this rule is allowed if a
-here-document appears as the last element of a statement. In this
+its line.  The only exception to this rule is allowed if a
+here-document appears as the last element of a statement.  In this
 case a semicolon can be placed on the same line with its terminating 
 delimiter, as in: 
 
-@smallexample
+@example
 help-text <<-EOT
         A sample help text.
 EOT;
-@end smallexample
-
-  However, terminated semicolon after a here-document is optional.
+@end example
 
 @anchor{list values}
 @item list
 @cindex list
-  A @dfn{list} is a comma-separated list of values. Lists are
-enclosed in parentheses. The following example shows a statement
+  A @dfn{list} is a comma-separated list of values.  Lists are
+enclosed in parentheses.  The following example shows a statement
 whose value is a list of strings:
 
-@smallexample
-shared-namespace ("/home", "/var/spool/common");
-@end smallexample
+@example
+alias (test,null);
+@end example
 
   In any case where a list is appropriate, a single value is allowed
 without being a member of a list: it is equivalent to a list with a
-single member. This means that, e.g. @samp{shared-namespace /home;} is
-equivalent to @samp{shared-namespace (/home);}.
+single member.  This means that, e.g.
+
+@example
+alias test;
+@end example
+
+@noindent
+is equivalent to
+
+@example
+alias (test);
+@end example
 @end table
 
-@node Block Statements
-@subsubsection Block Statements
-@cindex block statement, configuration file
-  A @dfn{block statement} introduces a logical group of another
-statements. It consists of a keyword, followed by an optional value,
+@cindex statement, block
+@cindex block statement
+  A @dfn{block statement} introduces a logical group of 
+statements.  It consists of a keyword, followed by an optional value,
 and a sequence of statements enclosed in curly braces, as shown in
-example below:
+the example below:
 
-@smallexample
+@example
 @group
-tcp-wrappers @{
-  enable yes;
-  allow-syslog-priority info;
-  deny-syslog-priority notice;
+server srv1 @{
+  host 10.0.0.1;
+  community "foo";
 @}
 @end group
-@end smallexample
+@end example
 
   The closing curly brace may be followed by a semicolon, although
 this is not required.
-  
+
+@node Paths
+@subsubsection Statement Path
+
+@command{Mailutils} configuration files have a distinct hierarchical
+structure.  Each statement in such files can therefore be identified
+by its name and the names of block statements containing it.  Such
+names form this statement @dfn{pathname}, similar to that used,
+e.g. by UNIX file system.
+
+For example, consider the following file:
+
+@example
+foo @{
+  bar @{
+    baz 45;   # @r{A.}
+  @}
+  baz 98;     # @r{B.}
+@}
+@end example
+
+The full pathname of the statement marked with @samp{A} can be written
+as:
+
+@example
+.foo.bar.baz
+@end example
+
+Similarly, the statement marked with @samp{B} has the following
+pathname:
+
+@example
+.foo.baz
+@end example
+
+The default path component separator is dot.  A pathname beginning with
+a component separator is called @dfn{absolute pathname}.  Absolute
+pathnames uniquely identify corresponding statements.  If the leading
+dot is omitted, the resulting pathname is called
+@dfn{relative}.  Relative pathnames identify statements in relation to 
+the current point of reference in the configuration file.
+
+Any other punctuation character can be used as a component separator,
+provided that it appears at the beginning of the pathname.  In other
+words, only absolute pathnames allow for a change in component separators.
+
+A block statement that has a tag is referred to by its name, followed
+by an equals sign, followed by the tag value.  For example, the
+statement @samp{A} in the file below:
+
+@example
+program x @{
+  bar @{
+    baz 45;   # @r{A.}
+  @}
+@}
+@end example
+
+is identified by the following pathname:
+
+@example
+.program=x.bar.baz
+@end example
+
+The tag can optionally be enclosed in a pair of double quotes.  Such a
+quoting becomes mandatory for tags that contain white space or path
+component separator, e.g.:
+
+@example
+.program="a.out".bar.baz
+@end example
+
 @node Include
 @subsection Include Statement 
 @cindex include statement, configuration file
 @kwindex include
-  An @dfn{include statement} is a special statement that causes
-inclusion of a named file. This statement has the following syntax:
+  The @dfn{include statement} is a special statement that causes
+inclusion of a named file.  It has the following syntax:
 
-@smallexample
+@example
 include @var{file};
-@end smallexample
+@end example
 
 If @var{file} names a regular file, the contents of this file is
-included in this point. Otherwise, if @var{file} names a directory,
+included in this point.  Otherwise, if @var{file} names a directory,
 Mailutils searches in that directory for a file whose name coincides
 with the name of utility being executed, and includes this file, if it
 exists.
@@ -599,215 +695,103 @@ exists.
 It is a common approach to end the site-wide configuration file with
 an include statement, e.g.:
 
-@smallexample
+@example
 include /etc/mailutils.d;
-@end smallexample
+@end example
 
 This allows each particular utility to have its own configuration
-file. Thus. @command{imap4d} will read
+file.  Thus.  @command{imap4d} will read
 @file{/etc/mailutils.d/imap4d}, etc.
 
 @node Logging Statement
 @subsection Logging Statement
 @kwindex logging
 @subheading Syntax
-@smallexample
+@example
 logging @{
+  # @r{Send diagnostics to syslog.}
+  syslog @var{boolean};
+  # @r{Print message severity levels.}
+  print-severity @var{boolean};
+  # @r{Output only messages with a severity equal to or}
+  # @r{greater than this one.}
+  severity @var{string};
   # @r{Set syslog facility.}
   facility @var{name};
   # @r{Tag syslog messages with this string.}
   tag @var{text};
 @}
-@end smallexample
+@end example
 
 @subheading Description
-  The @code{logging} block statement provides configuration for
-programs that use @command{syslog} for diagnostics. The default
-syslog facility is determined at compile time, it can be inspected
-using the following command:
+  The @code{logging} block statement configures where the diagnostic
+output goes and how verbose it is.
+
+@deffn {Configuration} syslog bool
+If @samp{syslog} is set to @samp{yes}, the diagnostics will go to
+syslog.  Otherwise, it goes to the standard error.
+@end deffn
 
-@smallexample
-$ mailutils-config --info log_facility
-@end smallexample
+The default syslog facility is determined at compile time, it can be inspected
+using the following command (@pxref{mu info}):
+
+@example
+$ mu info log_facility
+@end example
 
 @anchor{syslog facility}
 @deffn {Configuration} facility name
-Use syslog facility @var{name}. Valid argument values are: @samp{user},
+Use syslog facility @var{name}.  Valid argument values are: @samp{user},
 @samp{daemon}, @samp{auth}, @samp{authpriv}, @samp{mail}, @samp{cron},
 @samp{local0} through @samp{local7} (all names case-insensitive), or
 a facility number.
 @end deffn
 
 @deffn {Configuration} tag text
-Tag syslog messages with @var{text}. By default, program name is used
+Tag syslog messages with @var{text}.  By default, program name is used
 as syslog tag.
 @end deffn
 
+@deffn {Configuration} print-severity bool
+Print Mailutils severity name before each message.
+@end deffn
+
+@deffn {Configuration} severity name
+Output only messages with a severity equal to or greater than this
+one.  Valid arguments are: @samp{debug}, @samp{info}, @samp{notice},
+@samp{warning}, @samp{error}, @samp{crit}, @samp{alert}, @samp{emerg},
+@end deffn
+
 @node Debug Statement
 @subsection Debug Statement
 @kwindex debug
 @subheading Syntax
-@smallexample
+@example
 debug @{
   # @r{Set Mailutils debugging level.}
   level @var{spec};
   # @r{Prefix debug messages with Mailutils source locations.}
   line-info @var{bool};
 @}
-@end smallexample
+@end example
 
 @subheading Description
-The @code{debug} statement configures debugging output. Although it
-is mostly useful for Mailutils developers, it may be of interest for
-casual users as well. In particular, you may use it to obtain more
-information about Mailutils actions, which may help in configuring it,
-or in filling a bug report.
-
-Debugging output is controlled by a set of levels, each of which can be
-enabled or disabled independently of others. A @dfn{debugging
-level} consists of a module name, which defines a Mailutils module
-affected by this level, and a level number, which defines the
-verbosity of the debugging output. Valid debugging levels are:
-
-@float Table, debugging levels
-@caption{Debugging levels}
-@table @asis
-@item error
-Display only error messages.
-
-@item trace0 through trace7
-Eight levels of verbosity, @samp{trace0} producing less output,
-@samp{trace7} producing maximum possible output.
-
-@item prot
-Display network protocol interactions, where appropriate.
-@end table
-@end float
-
-The most important debugging modules are:
-
-@table @asis
-@item acl
-Debug access control lists. @FIXME-xref{Debugging ACLs}.
-
-@item config
-Debug configuration parser and/or lexical analyzer. The following
-levels are supported:
-
-@table @asis
-@item trace0
-Minimal information about configuration statements.
-
-@item trace2
-Trace lexical structure of the configuration files.
-
-@item trace7
-Trace execution of the configuration parser.
-@end table
-
-Due to its specific nature, this debugging module cannot be enabled
-using @code{level} statement below. The @option{--debug-level}
-command line option should be used instead
-(@FIXME-pxref{debug-level}). Alternatively, you may use the following
-hook, provided to facilitate debugging of the configuration parser: a
-@dfn{pragmatic comment} in form:
-
-@smallexample
-#debug=@var{level}
-@end smallexample
-
-is understood as a request to set debugging level of module
-@samp{config} to @var{level}.
-
-@item ip_server
-IP based servers, such as @command{imap4d} and @command{pop3d}. This
-module supports @samp{trace0} and @samp{error} levels. @xref{Server
-Settings}, for more information about servers.
-
-@item udp_server
-UDP based servers, such as @command{comsatd}. This module supports
-@samp{trace0} and @samp{error} levels. @xref{Server Settings}, for
-more information about servers. 
-
-@item mailbox
-Operations over mailboxes. This module supports the following levels:
-@samp{error}, @samp{trace0}, @samp{trace1}, and @samp{proto}. The
-latter is used by remote mailbox support libraries.
-
-@item sieve
-Debug Sieve parser and run-time evaluator. Currently supported levels
-are @samp{error}, @samp{trace1} and @samp{trace7}.
-@end table
-
-@deffn {Configuration} level spec
-This statement enables debugging levels given by @var{spec}. The
-argument is an list of debugging specifications or a string with
-specifications delimited by semicolons. The syntax of a specification
-is:
-
-@smallexample
-  @var{module}[[:]=@var{level}]
-@end smallexample
-
-@noindent
-where @var{module} is the name of a module, and @var{level} is the
-level to be set. The level may be optionally prefixed with the
-following symbols:
-
-@table @samp
-@item !
-All levels except this one. E.g. @samp{config=!trace7} means
-set all debugging levels, except @samp{trace7} for the @samp{config}
-module.
-
-@item <
-All levels up to and including this. The words @samp{up to} refer to
-the position of levels in @ref{debugging levels} table, so that, e.g.
-@samp{<trace2} means levels @samp{error}, @samp{trace0}, @samp{trace1}
-and @samp{trace2}.
-@end table
-
-Both prefixes can be used together, in this order: @samp{!<}. This
-means all levels except this one and ones listed before it in
-the table.
-
-A comma before equal sign, as in @samp{mailbox:=<trace7} means set
-this debugging levels in all modules, invoked by this one.
-
-The @var{level} in the level specification can also be a
-comma-separated list of valid levels, e.g.:
-
-@smallexample
-   mailbox=<trace2,!<trace4
-@end smallexample
-
-@noindent
-which means ``levels trace3 and trace4''.
-
-The following example illustrates two equivalent ways of setting
-debugging level in a configuration file:
-
-@smallexample
-  level ("mailbox=!proto", "acl=<trace7");
-  level "mailbox=!proto;acl=<trace7";
-@end smallexample
-
-The @option{--debug-level} command line option overrides the settings
-of the @code{level} configuration statement.
-@end deffn
-
-@deffn {Configuration} line-info @var{bool}
-If @var{bool} is @samp{true} (@pxref{boolean value}), each debugging
-message will be preceded by a corresponding source file location,
-i.e. the file name and line number where this message was generated.
-@end deffn
+The @samp{debug} statement controls the amount of additional debugging
+information output by Mailutils programs.  The @samp{level} statement
+enables additional debugging information.  Its argument (@var{spec})
+is a Mailutils debugging specification as described in
+@ref{debugging}.
 
+The @samp{line-info} statement, when set to @samp{true} causes
+debugging messages to be prefixed with locations in Mailutils source
+files where they appear.  Normally, only Mailutils developers need
+this option. 
 
 @node Mailbox Statement
 @subsection Mailbox Statement
 @kwindex mailbox
 @subheading Syntax
-@smallexample
+@example
 mailbox @{
   # @r{Use specified @var{url} as a mailspool.}
   mail-spool @var{url};
@@ -818,7 +802,7 @@ mailbox @{
   # @r{Default user mail folder.}
   folder @var{dir};
 @}
-@end smallexample
+@end example
 
 @subheading Description
 The @code{mailbox} statement configures the location, name and type of
@@ -829,7 +813,7 @@ The mailbox location can be specified using @code{mail-spool} or
 
 @deffn {Configuration} mail-spool @var{path}
 The @code{mail-spool} statement specifies directory that holds user
-mailboxes. Once this statement is given, the @command{libmailutils}
+mailboxes.  Once this statement is given, the @command{libmailutils}
 library will assume that the mailbox of user @var{login} is kept in
 file @file{@var{path}/@var{login}}.
 
@@ -840,25 +824,25 @@ favor of @code{mailbox-pattern} statement.
 
 @deffn {Configuration} mailbox-pattern @var{pattern}
 The @code{mailbox-pattern} statement is a modern way of configuring
-mailbox locations. It supersedes @code{mail-spool} statement.
+mailbox locations.  It supersedes @code{mail-spool} statement.
 
 The @var{pattern} is valid @dfn{mailbox URL}, which 
 may contain references to @samp{user} macro-variable
-(@FIXME-pxref{macro-variables}). This macro-variable will be expanded
-to the actual user name. The full syntax for @var{pattern} is:
+(@FIXME-pxref{macro-variables}).  This macro-variable will be expanded
+to the actual user name.  The full syntax for @var{pattern} is:
 
-@smallexample
+@example
   [@var{type}://]@var{path}[;@var{args}]
-@end smallexample
+@end example
 
 @noindent
 where:
 
 @table @var
 @item type
-Specifies the mailbox type. It must be one of mailbox types,
-supported by Mailutils. @FIXME-xref{Mailbox URLs}. By default,
-@samp{local} is assumed. @FIXME{Verify this}.
+Specifies the mailbox type.  It must be one of mailbox types,
+supported by Mailutils.  @FIXME-xref{Mailbox URLs}.  By default,
+@samp{local} is assumed.  @FIXME{Verify this}.
 
 @item path
 The path pattern.
@@ -873,9 +857,9 @@ mailboxes, which allows for faster access in case of very large
 number of users. 
 
 By default, all user mailboxes are stored in a single directory and
-are named after user login names. To find the mailbox for a given
+are named after user login names.  To find the mailbox for a given
 user, the system scans the directory for the corresponding
-file. This usually implies linear search, so the time needed to
+file.  This usually implies linear search, so the time needed to
 locate a mailbox is directly proportional to the ordinal number of
 the mailbox in the directory.
 
@@ -885,13 +869,13 @@ GNU Mailutils supports three types of indexed directories:
 @cindex direct indexing
 @cindex indexing, direct
 In direct indexed directory structure, @var{path} contains 26 subdirectories
-named with lower-case letters of Latin alphabet. The location of the
+named with lower-case letters of Latin alphabet.  The location of the
 user mailbox is determined using the following algorithm:
 
 @enumerate 1
 @item Take the first letter of the user name.
 @item Map it to a lower-case letter using @dfn{index mapping}
-table. The result gives sub-directory name.
+table.  The result gives sub-directory name.
 @item Descend into this directory.
 @end enumerate
 
@@ -899,7 +883,7 @@ For example, using this algorithm, the mailbox of the user
 @samp{smith} is stored in file @file{@var{path}/s/smith}.
 
 If each of single-letter subdirectories contains the
-indexed directory structure, we have second level of indexing. In
+indexed directory structure, we have second level of indexing.  In
 this case the file name of @samp{smith}'s mailbox is
 @file{@var{path}/s/m/smith}.
 
@@ -907,7 +891,7 @@ this case the file name of @samp{smith}'s mailbox is
 @cindex indexing, reverse
 The @dfn{reverse} indexed structure uses the same principles, but the
 indexing letters are taken from the @emph{end} of the user name,
-instead of from the beginning. For example, in the 2nd level reverse
+instead of from the beginning.  For example, in the 2nd level reverse
 indexed structure, the @samp{smith}'s mailbox is located in
 @file{@var{path}/h/t/smith}.
 
@@ -915,9 +899,9 @@ indexed structure, the @samp{smith}'s mailbox is located in
 @cindex indexing, hashed
 Finally, the @dfn{hashed} structure consists of 256 subdirectories
 under @var{path}, named by 2-letter hex codes from @samp{00} to
-@samp{FF}. Mailboxes are stored in these subdirectories. The name
+@samp{FF}.  Mailboxes are stored in these subdirectories.  The name
 of the subdirectory is computed by hashing first @var{level} letters
-of the user name. The hashing algorithm is:
+of the user name.  The hashing algorithm is:
 
 @enumerate 1
 @item Take next letter from the user name
@@ -933,7 +917,7 @@ arguments:
 @table @asis
 @kwindex type
 @item type=@var{value}
-Specifies type of indexing. Valid values are @samp{index}, for direct
+Specifies type of indexing.  Valid values are @samp{index}, for direct
 indexed structure, @samp{rev-index} for reverse indexing, and
 @samp{hash} for hashed structure.
 
@@ -943,7 +927,7 @@ Specifies indexing level.
 
 @kwindex user
 @item user=@var{string}
-Specifies indexing key. The only meaningful value, as of Mailutils
+Specifies indexing key.  The only meaningful value, as of Mailutils
 version @value{VERSION} is @samp{user=$@{user@}}.
 @end table
 
@@ -951,25 +935,25 @@ Let's assume the traditional mail layout, in which user incoming
 mails are stored in UNIX mailbox format in @file{/var/mail} directory.
 The @code{mailbox-pattern} for this case is:
 
-@smallexample
+@example
   mailbox-pattern "/var/mail/$@{user@}";
-@end smallexample
+@end example
 
 It is entirely equivalent to specifying @samp{mail-spool "/var/mail"}.
 
 Now, if the layout is the same, but mailboxes are kept in
 @samp{maildir} format, then the corresponding statement is:
 
-@smallexample
+@example
   mailbox-pattern "maildir:///var/mail/$@{user@}";
-@end smallexample
+@end example
 
 Finally, if the mailboxes are stored in a directly-indexed directory with
 two levels of indexing, than:
 
-@smallexample
+@example
   mailbox-pattern "maildir:///var/mail;type=index;param=2;user=$@{user@}";
-@end smallexample
+@end example
 @end table
 @end deffn
 
@@ -986,22 +970,22 @@ separator, and the user name.
 
 The built-in mail spool directory name is determined at compile
 time, using @samp{_PATH_MAILDIR} define from the include file
-@file{paths.h}. If this value is not defined, @file{/var/mail} or
+@file{paths.h}.  If this value is not defined, @file{/var/mail} or
 @file{/usr/spool/mail} is used.
 @end enumerate
 
 @deffn {Configuration} mailbox-type @var{type}
 @vrindex MU_DEFAULT_SCHEME
-Specifies type of mailboxes. By default, @samp{mbox} (UNIX mailbox)
-is assumed. This can be changed while configuring the package by
-setting @code{MU_DEFAULT_SCHEME} configuration variable. The default
+Specifies type of mailboxes.  By default, @samp{mbox} (UNIX mailbox)
+is assumed.  This can be changed while configuring the package by
+setting @code{MU_DEFAULT_SCHEME} configuration variable.  The default
 value can be verified by running @command{mailutils-config --info scheme}.
 @end deffn
 
 @deffn {Configuration} folder @var{dir}
 @cindex plus expansion
-Sets user mail folder directory. Its value is using when expanding
-@samp{plus-notation}, i.e. such mailbox names as @file{+inbox}. The
+Sets user mail folder directory.  Its value is using when expanding
+@samp{plus-notation}, i.e. such mailbox names as @file{+inbox}.  The
 @samp{+} sign is replaced by @var{dir}, followed by a directory
 separator (@samp{/}).
 
@@ -1015,7 +999,7 @@ The default folder name is @samp{Mail/}.
 @subsection Locking Statement
 @kwindex locking
 @subheading Syntax
-@smallexample
+@example
 locking @{
   # @r{Default locker flags.}
   flags @var{arg};
@@ -1028,33 +1012,33 @@ locking @{
   # @r{Use @var{prog} as external locker program.}
   external-locker @var{prog};
 @}
-@end smallexample
+@end example
 
 @subheading Description
 This block statement configures various parameters used when locking
 UNIX mailboxes in order to prevent simultaneous writes.
 
 It is important to note, that locking applies only to maildrops in
-UNIX mailbox format. All other mailbox types do not require locking.
+UNIX mailbox format.  All other mailbox types do not require locking.
 
 @deffn {Configuration} flags @var{string}
-Set locking flags. Argument is a string consisting of one or more of
+Set locking flags.  Argument is a string consisting of one or more of
 the following letters:
 
 @table @asis
 @item E
-Use an external program to manage locks. The program is given by
+Use an external program to manage locks.  The program is given by
 @code{external-locker} statement (see below).
 
 @item R
-If the locking attempt failed, retry it. This is the default. The
+If the locking attempt failed, retry it.  This is the default.  The
 number of retries, and time interval between the two successive
 attempts is given by @code{retry-count} and @code{retry-timeout}
 statements, correspondingly.
 
 @item T
 If a lock file exists, check its modification time and, if it is
-older than a predefined amount of time, remove the lock. The amount
+older than a predefined amount of time, remove the lock.  The amount
 of time is specified by @code{expire-timeout} statement.
 
 @item P
@@ -1063,22 +1047,22 @@ Store the PID of the locking process in a lock file.
 @end deffn
 
 @deffn {Configuration} retry-count @var{number}
-Number of locking attempts. The @samp{P} flag must be set for this to
+Number of locking attempts.  The @samp{P} flag must be set for this to
 take effect.
 @end deffn
 
 @deffn {Configuration} retry-timeout @var{seconds}
 Time interval, in seconds, between the two successive locking
-attempts. The @samp{P} flag must be set for this to take effect.
+attempts.  The @samp{P} flag must be set for this to take effect.
 @end deffn
 
 @deffn {Configuration} expire-timeout @var{seconds}
 Remove existing lock file, if it is created more than this number of
-seconds ago. The @samp{T} flag must be set for this to take effect.
+seconds ago.  The @samp{T} flag must be set for this to take effect.
 @end deffn
 
 @deffn {Configuration} external-locker @var{string}
-Set command line of an external locker program. The @samp{E} flag
+Set command line of an external locker program.  The @samp{E} flag
 must be set for this to take effect. 
 @end deffn
 
@@ -1086,16 +1070,16 @@ must be set for this to take effect.
 @subsection Mailer Statement
 @kwindex mailer
 @subheading Syntax
-@smallexample
+@example
 mailer @{
   url @var{url};
 @}
-@end smallexample
+@end example
 
 @subheading Description
 A @dfn{mailer} is a special logical entity GNU Mailutils uses for
-sending messages. Its internal representation is discussed in
-@ref{Mailer}. The @code{mailer} statement configures it.
+sending messages.  Its internal representation is discussed in
+@FIXME-ref{Mailer}.  The @code{mailer} statement configures it.
 
 The mailer statement contains a single sub-statement:
 
@@ -1104,20 +1088,20 @@ Set the mailer @acronym{URL}.
 @end deffn
 
 GNU Mailutils supports two types of mailer @acronym{URL}s, described
-in the table below. As usual, square brackets indicate optional parts:
+in the table below.  As usual, square brackets indicate optional parts:
 
 @table @asis
 @item smtp://@var{host}[:@var{port}]
-Use an SMTP server @var{host} to send messages. Optional @var{port}
+Use an SMTP server @var{host} to send messages.  Optional @var{port}
 specifies port number or symbolic name (as defined in
-@file{/etc/services}). It defaults to 25. The @var{host} can be
+@file{/etc/services}).  It defaults to 25.  The @var{host} can be
 specified as either an IP address in dotted-quad notation or as a
-symbolic host name. In the latter case, DNS system will be used to
+symbolic host name.  In the latter case, DNS system will be used to
 resolve it.
 
 @item sendmail://@var{progname}
 Use sendmail-compatible program
-@var{progname}. @dfn{Sendmail-compatible} means that the program must
+@var{progname}.  @dfn{Sendmail-compatible} means that the program must
 support following command line options:
 
 @table @option
@@ -1132,21 +1116,21 @@ Get recipient addresses from the message.
 @end table
 
 @item sendmail:
-This is a special form of the @samp{sendmail} mailer. It uses the
+This is a special form of the @samp{sendmail} mailer.  It uses the
 @command{sendmail} binary from the @code{_PATH_SENDMAIL} macro in your
-@file{/usr/include/paths.h}. It is the default mailer.
+@file{/usr/include/paths.h}.  It is the default mailer.
 
 @item prog://@var{progname}?@var{query}
-A @dfn{prog} mailer. This is a generalization of @samp{sendmail}
+A @dfn{prog} mailer.  This is a generalization of @samp{sendmail}
 mailer that allows to use arbitrary external programs as mailers.
 
-The @var{progname} must be a full pathname of the binary file. When
+The @var{progname} must be a full pathname of the binary file.  When
 sending message, Mailutils will invoke this file with the arguments
 specified by @var{query} and will pipe the message to be sent to its
 standard input.
 
 The @var{query} part is a list of arguments, separated by @samp{&}
-signs. Arguments may contain the following macro-substitutions:
+signs.  Arguments may contain the following macro-substitutions:
 
 @table @samp
 @item $@{sender@}
@@ -1161,7 +1145,7 @@ Expands to the recipient email addresses.
 @subsection ACL Statement
 @kwindex acl
 @subheading Syntax
-@smallexample
+@example
 acl @{
   # @r{Allow connections from this IP address.}
   allow [from] @var{ip};
@@ -1176,22 +1160,22 @@ acl @{
      from @var{ip}. */
   ifexec [from] @var{ip} @var{program};
 @}
-@end smallexample
+@end example
 
 @subheading Description
 The ACL statement defines an @dfn{Access Control List}, a special
 structure that controls who can access the given Mailutils resource.
 
-The @code{acl} block contains a list of access controls. Each control
+The @code{acl} block contains a list of access controls.  Each control
 can be regarded as a function that returns a tree-state value:
-@samp{True}, @samp{False} and @samp{Don't know}. When a
+@samp{True}, @samp{False} and @samp{Don't know}.  When a
 remote party connects to the server, each of controls is tried in
-turn. If a control returns @samp{False}, access is denied. If it
-returns @samp{True}, access is allowed. If it returns @samp{Don't
-know}, then the next control is tried. It is unclear whether to allow
-access if the last control in list returned @samp{Don't know}. GNU
+turn.  If a control returns @samp{False}, access is denied.  If it
+returns @samp{True}, access is allowed.  If it returns @samp{Don't
+know}, then the next control is tried.  It is unclear whether to allow
+access if the last control in list returned @samp{Don't know}.  GNU
 Mailutils @value{VERSION} issues a warning message and allows access.
-This default may change in future versions. Users are advised to
+This default may change in future versions.  Users are advised to
 write their ACLs so that the last control returns a definitive answer
 (either @code{True} or @code{False}).
 
@@ -1200,12 +1184,12 @@ can be replaced by any of:
 
 @itemize @bullet
 @item An IPv4 address in dotted-quad notation.
+@item An IPv6 address in numeric notation
 @item A CIDR in the form @samp{@var{ip}/@var{mask}}, where @var{ip} is
-an IPv4 address, and @var{mask} is a decimal number in the range
-@samp{0--32}.
+an IP address (either IPv4 or IPv6), and @var{mask} is the network mask.
 @item A symbolic host name.
 @kwindex any
-@item A word @samp{any}, that stands for @samp{0.0.0.0/0}.
+@item A word @samp{any}, which matches any IP address.
 @end itemize
 
 The following controls are understood:
@@ -1220,17 +1204,17 @@ Deny connections from IP addresses matching this @var{cidr} block.
 
 @deffn {Configuration} ifexec [from] @var{cidr} @var{program}
 When a connection from the @var{cidr} block is requested, execute
-the program @var{program}. If its exit code is @samp{0}, then allow
-connection. Otherwise, deny it.
+the program @var{program}.  If its exit code is @samp{0}, then allow
+connection.  Otherwise, deny it.
 @end deffn
 
 The following two controls are provided for logging purposes and as a
-means of extensions. They always return a @samp{Don't know} answer,
+means of extensions.  They always return a @samp{Don't know} answer,
 and therefore should not be used at the end of an ACL:
 
 @deffn {Configuration} log [from] @var{cidr} [@var{string}]
-Log connections from addresses in this @var{cidr}. The
-@code{MU_DIAG_INFO} channel is used. If the logging goes to syslog,
+Log connections from addresses in this @var{cidr}.  The
+@code{MU_DIAG_INFO} channel is used.  If the logging goes to syslog,
 it is translated to the @code{LOG_INFO} priority.
 
 If @var{string} is not given, the format of the log entry depends on
@@ -1238,30 +1222,30 @@ the connection family, as described in the table below:
 
 @table @asis
 @item @{AF_INET @var{ip}:@var{port}@}
-For inet IPv4 connections. The variables @var{ip} and @var{port} are
+For inet IPv4 connections.  The variables @var{ip} and @var{port} are
 replaced by the remote IP address and port number, correspondingly.
 
 @item @{AF_UNIX@}
-For connections over UNIX sockets. The socket name, if available, may
+For connections over UNIX sockets.  The socket name, if available, may
 be printed before the closing curly brace.
 @end table
 
 If the @var{string} is specified, it undergoes macro expansion and the
-result of it is used as the log entry. The following macro variables
+result of it is used as the log entry.  The following macro variables
 are expanded:
 
 @table @code
 @item aclno
-Ordinal number of the control in the ACL. Numbers begin from
+Ordinal number of the control in the ACL.  Numbers begin from
 @samp{0}.
 
 @item family
-Connection family. Mailutils version @value{VERSION} supports two
+Connection family.  Mailutils version @value{VERSION} supports two
 families: @samp{AF_INET} and @samp{AF_UNIX}.
 
 @item address
 Remote IP address (for @samp{AF_INET}) or socket name (for
-@samp{AF_UNIX}). Notice that most Unixes return empty string instead
+@samp{AF_UNIX}).  Notice that most Unixes return empty string instead
 of the @samp{AF_UNIX} socket name, so do not rely on it.
 
 @item port
@@ -1271,12 +1255,12 @@ Remote port number (for @samp{AF_INET}).
 For example, the following ACL makes a Mailutils server log every
 incoming connection:
 
-@smallexample
+@example
   acl @{
      log from any "Connect from $@{address@}";
      ...
   @}
-@end smallexample
+@end example
 
 This was the default behavior for the versions of Mailutils up to
 @samp{1.2}, so if you got used to its logs you might wish to add the
@@ -1285,15 +1269,16 @@ above in your configuration files.
 
 @deffn {Configuration} exec [from] @var{cidr} @var{program}
 If a connection from the @var{cidr} block is requested, execute
-the given @var{program}. Do not wait for it to terminate, and ignore
+the given @var{program}.  Do not wait for it to terminate, and ignore
 its exit code.
 @end deffn
 
 @node Tcp-wrappers Statement
 @subsection Tcp-wrappers Statement
+@UNREVISED
 @kwindex tcp-wrappers
 @subheading Syntax
-@smallexample
+@example
 tcp-wrappers @{
   # @r{Enable TCP wrapper access control.}
   enable @var{bool};
@@ -1308,47 +1293,47 @@ tcp-wrappers @{
   # @r{Log denied accesses at this syslog priority.}
   deny-syslog-priority @var{prio};
 @}
-@end smallexample
+@end example
 
 @subsection Description
 The @code{tcp-wrappers} statements provides an alternative way to
-control accesses to the resources served by GNU Mailutils. This
+control accesses to the resources served by GNU Mailutils.  This
 statement is enabled if Mailutils is compiled with TCP wrappers
 library @command{libwrap}.
 
 Access control using TCP wrappers is based on two files, called
-@dfn{tables}, containing access rules. There are two tables: the
+@dfn{tables}, containing access rules.  There are two tables: the
 @dfn{allow table}, usually stored in file @file{/etc/hosts.allow}, and
-the @dfn{deny table}, kept in file @file{/etc/hosts.deny}. The rules
-in each table begin with an identifier called @dfn{daemon name}. Each
+the @dfn{deny table}, kept in file @file{/etc/hosts.deny}.  The rules
+in each table begin with an identifier called @dfn{daemon name}.  Each
 utility wishing to verify a connection, select the entries having
-its daemon name from the allow table. A connection is allowed if it
-matches any of these entries. Otherwise, the utility retrieves all
-entries with its daemon name from the deny table. If any of these
-matches the connection, then it is refused. Otherwise, if neither
+its daemon name from the allow table.  A connection is allowed if it
+matches any of these entries.  Otherwise, the utility retrieves all
+entries with its daemon name from the deny table.  If any of these
+matches the connection, then it is refused.  Otherwise, if neither
 table contains matching entries, the connection is allowed.
 
 Description of a TCP wrapper table format lies outside the scope of
-this document. Please, see @ref{ACCESS CONTROL FILES,,ACCESS CONTROL FILES,
+this document.  Please, see @ref{ACCESS CONTROL FILES,,ACCESS CONTROL FILES,
 hosts_access(5), hosts_access(5) man page}, for details.
 
 @deffn {Configuration} enable @var{bool}
-Enable access control using TCP wrappers. It is on by default.
+Enable access control using TCP wrappers.  It is on by default.
 @end deffn
 
 @deffn {Configuration} daemon @var{name}
-Set daemon name for TCP wrapper lookups. By default, the name of the
-utility is used. E.g. @command{imap4d} uses @samp{imap4d} as the
+Set daemon name for TCP wrapper lookups.  By default, the name of the
+utility is used.  E.g.  @command{imap4d} uses @samp{imap4d} as the
 daemon name.
 @end deffn
 
 @deffn {Configuration} allow-table @var{file}
-Use @var{file} as allow table. By default, @file{/etc/hosts.allow} is
+Use @var{file} as allow table.  By default, @file{/etc/hosts.allow} is
 used. 
 @end deffn
   
 @deffn {Configuration} deny-table @var{file}
-Use @var{file} as negative table. By default, @file{/etc/hosts.deny}
+Use @var{file} as negative table.  By default, @file{/etc/hosts.deny}
 is used.
 @end deffn
 
@@ -1362,16 +1347,17 @@ Log denied accesses using syslog priority @var{prio}.
 
 @node Server Settings
 @subsection Server Settings
+@UNREVISED
 @cindex server settings, configuration
 @cindex configuring servers
   GNU Mailutils offers several server applications: @command{pop3d},
-@command{imap4d}, @command{comsatd}, to name a few. Being quite
+@command{imap4d}, @command{comsatd}, to name a few.  Being quite
 different in their purpose, they are very similar in some aspects of
-their architecture. First of all, they all support two operating
+their architecture.  First of all, they all support two operating
 mode: a @dfn{daemon} mode, where a program disconnects from the controlling
 terminal and works in background, and an @dfn{inetd} mode, where it
 remains in foreground and communicates with the remote party via
-standard input and output streams. Secondly, when operating as
+standard input and output streams.  Secondly, when operating as
 daemons, they listen to a preconfigured set of IP addresses and
 ports, reacting to requests that arrive.
 
@@ -1386,9 +1372,10 @@ subsection.
 
 @node General Server Configuration
 @subsubsection General Server Configuration
+@UNREVISED
 @cindex server configuration, general
 @* Syntax:
-@smallexample
+@example
 # @r{Set daemon mode.}
 mode @samp{inetd|daemon};
 # @r{Run in foreground.}
@@ -1401,23 +1388,23 @@ pidfile @var{file};
 port @var{portspec};
 # @r{Set idle timeout.}
 timeout @var{time};
-@end smallexample
+@end example
 
 @* Description:
 These statements configure general server-related issues.
 
 @deffn {Configuration} mode @var{string};
-Set operation mode of the server. Two operation modes are supported:
+Set operation mode of the server.  Two operation modes are supported:
 
 @anchor{server mode}
 @table @asis
 @cindex daemon, server mode
 @item daemon
 Run as a standalone daemon, disconnecting from the controlling
-terminal and continuing to run in the background. In this case, it is
+terminal and continuing to run in the background.  In this case, it is
 the server that controls what IP addresses and ports to listen on, who
 is allowed to connect and from where, how many clients are allowed to
-connect simultaneously, etc. Most remaining configuration statements
+connect simultaneously, etc.  Most remaining configuration statements
 are valid only in the daemon mode.
 
 This is the preferred mode of operation for GNU Mailutils servers.
@@ -1425,14 +1412,14 @@ This is the preferred mode of operation for GNU Mailutils servers.
 @cindex inetd, server mode
 @item inetd
 Operate as a subprocess of UNIX internet super-server program,
-@command{inetd}. @xref{Internet super-server,,,inetd(8), inetd(8) man
+@command{inetd}.  @xref{Internet super-server,,,inetd(8), inetd(8) man
 page}, for a detailed description of the operation of @command{inetd}
-and its configuration. In this case it is @command{inetd} that
+and its configuration.  In this case it is @command{inetd} that
 controls all major connectivity aspects, the Mailutils server itself
 communicates with it via standard input and output streams.
 
 For historical reasons, this mode is the default, if no @code{mode}
-statement is specified. This will change in the future.
+statement is specified.  This will change in the future.
 @end table
 @end deffn
 
@@ -1453,31 +1440,32 @@ The default is 20 clients.
 
 @deffn {Configuration} pidfile @var{file};
 After startup, store the PID of the main server process in
-@var{file}. When the process terminates, the file is removed. As of
+@var{file}.  When the process terminates, the file is removed.  As of
 version @value{VERSION}, GNU Mailutils servers make no further use of
-this file. It is intended for use by automated startup scripts and
+this file.  It is intended for use by automated startup scripts and
 controlling programs (@FIXME-pxref{mention pies}).
 @end deffn
 
 @deffn {Configuration} port @var{portspec};
 @*[daemon mode only]
-@*Set default port to listen to. The @var{portspec} argument is either
+@*Set default port to listen to.  The @var{portspec} argument is either
 a port number in decimal, or a symbolic service name, as listed in
 @file{/etc/services} (@pxref{Internet network services list,,,
 services(5), services(5) man page}).
 @end deffn
 
 @deffn {Configuration} timeout @var{time};
-Set maximum idle time out in seconds. If a client does not send any
+Set maximum idle time out in seconds.  If a client does not send any
 requests during @var{time} seconds, the child process terminates.
 @end deffn
 
 @node Server Statement
 @subsubsection Server Statement
+@UNREVISED
 @cindex server statement
 @kwindex server
 @* Syntax:
-@smallexample
+@example
 server @var{ipaddr}[:@var{port}] @{
   # @r{Run this server as a single process.}
   single-process @var{bool};
@@ -1488,20 +1476,20 @@ server @var{ipaddr}[:@var{port}] @{
   # @r{Set server specific ACLs.}
   acl @{ /* @xref{ACL Statement}. */ @};
 @}
-@end smallexample
+@end example
 
 @* Description:
 The @code{server} block statement configures a single TCP or UDP
-server. It takes effect only in daemon mode (@pxref{server mode}).
+server.  It takes effect only in daemon mode (@pxref{server mode}).
 The argument to this statement specifies the IP address, and,
-optionally, the port, to listen on for requests. The @var{ipaddr}
+optionally, the port, to listen on for requests.  The @var{ipaddr}
 part is either an IPv4 address in dotted-quad form, or a symbolic host
-name which can be resolved to such an address via DNS. Specifying
+name which can be resolved to such an address via DNS.  Specifying
 @samp{0.0.0.0} as the @var{ipaddr} means listen on all available
-network interfaces. The @var{port} argument is either a port number
+network interfaces.  The @var{port} argument is either a port number
 in decimal, or a symbolic service name, as listed in
 @file{/etc/services} (@pxref{Internet network services
-list,,,services(5), services(5) man page}). If @var{port} is omitted,
+list,,,services(5), services(5) man page}).  If @var{port} is omitted,
 Mailutils uses the port set by @code{port} statement (@pxref{General
 Server Configuration, port}), or, in its absence, the default port
 number, which depends on a server being used (e.g. 110, for
@@ -1515,28 +1503,28 @@ Statements within the @code{server} block statement configure this
 particular server.
 
 @deffn {Configuration} single-process @var{bool};
-If set to true, this server will operate in single-process mode. This
+If set to true, this server will operate in single-process mode.  This
 mode is intended for debugging only, do not use it on production
 servers.
 @end deffn
 
 @deffn {Configuration} transcript @var{bool};
-Enable transcript of the client-server interaction. This may generate
+Enable transcript of the client-server interaction.  This may generate
 excessive amounts of logging, which in turn may slow down the operation
 considerably.
 
 Session transcripts are useful in fine-tuning your configurations and
-in debugging. They should be turned off on most production servers.
+in debugging.  They should be turned off on most production servers.
 @end deffn
 
 @deffn {Configuration} timeout @var{time};
-Set idle timeout for this server. This overrides global timeout
+Set idle timeout for this server.  This overrides global timeout
 settings (@pxref{General Server Configuration, timeout}).
 @end deffn
 
 @deffn {Configuration} acl
-This statement defines a per-server Access Control List. Its syntax
-is as described in @ref{ACL Statement}. Per-server ACLs complement,
+This statement defines a per-server Access Control List.  Its syntax
+is as described in @ref{ACL Statement}.  Per-server ACLs complement,
 but not override, global ACLs, i.e. if both global ACL and per-server
 ACL are used, the connection is allowed only if both of them allow it,
 and is denied if any one of them denies it.
@@ -1544,59 +1532,60 @@ and is denied if any one of them denies it.
 
 @node Auth Statement
 @subsection Auth Statement
+@UNREVISED
 @cindex authorization
 @cindex authentication
 @kwindex auth
 @subheading Syntax
-@smallexample
+@example
 auth @{
   # @r{Set a list of modules for authentication.}
   authentication @var{module-list};
   # @r{Set a list of modules for authorization.}
   authorization @var{module-list};
 @}
-@end smallexample
+@end example
 
 @subheading Description
 Some mail utilities provide access to their services only after
 verifying that the user is actually the person he is claiming
-to be. Such programs are, for example, @command{pop3d} and
-@command{imap4d}. The process of the verification is broken
+to be.  Such programs are, for example, @command{pop3d} and
+@command{imap4d}.  The process of the verification is broken
 down into two stages: @dfn{authorization} and @dfn{authentication}.
 In @dfn{authorization} stage the program retrieves the information
-about a particular user. In @dfn{authentication} stage, this
-information is compared against the user-supplied credentials. Only if
+about a particular user.  In @dfn{authentication} stage, this
+information is compared against the user-supplied credentials.  Only if
 both stages succeed is the user allowed to use the service.
 
-A set of @dfn{modules} is involved in performing each stage. For
+A set of @dfn{modules} is involved in performing each stage.  For
 example, the authorization stage can retrieve the user description
 from various sources: system database, SQL database, virtual domain
-table, etc. Each module is responsible for retrieving the description
-from a particular source of information. The modules are arranged in
-a @dfn{module list}. The modules from the list are invoked in turn,
-until one of them succeeds or the list is exhausted. In the latter case 
-the authorization fails. Otherwise, the data returned by the succeeded
+table, etc.  Each module is responsible for retrieving the description
+from a particular source of information.  The modules are arranged in
+a @dfn{module list}.  The modules from the list are invoked in turn,
+until one of them succeeds or the list is exhausted.  In the latter case 
+the authorization fails.  Otherwise, the data returned by the succeeded
 module are used in authentication.
 
-Similarly, authentication may be performed in several ways. The
-authentication modules are also grouped in a list. Each module
+Similarly, authentication may be performed in several ways.  The
+authentication modules are also grouped in a list.  Each module
 is tried in turn until either a module succeeds, in which case the
 authentication succeeds, or the end of the list is reached.
 
 For example, the authorization list
 
-@smallexample
+@example
   (system, sql, virtdomains)
-@end smallexample
+@end example
 
 @noindent
 means that first the system user database (@file{/etc/password}) is
-searched for a description of a user in question. If the search fails,
-the @acronym{SQL} database is searched. Finally, if it also fails, the
+searched for a description of a user in question.  If the search fails,
+the @acronym{SQL} database is searched.  Finally, if it also fails, the
 search is performed in the virtual domain database.
 
 @emph{Note}, that some authentication and/or authorization modules may
-be disabled when configuring the package before compilation. The names
+be disabled when configuring the package before compilation.  The names
 of the disabled modules are nevertheless available for use in runtime
 configuration options, but they represent a ``fail-only'' functionality,
 e.g. if the package was compiled without @acronym{SQL} support then
@@ -1606,7 +1595,7 @@ passing the execution on to the next module.
 The @code{auth} statement configures authentication and authorization.
 
 @deffn {Configuration} authorization @var{module-list}
-Define a sequence of modules to use for authorization. Modules will
+Define a sequence of modules to use for authorization.  Modules will
 be tried in the same order as listed in @var{module-list}.
 
 The modules available for use in authorization list are:
@@ -1621,14 +1610,14 @@ A separate configuration statement, @code{sql}, is used to configure
 it (@pxref{SQL Statement}).
 @item virtdomain
 User credentials are retrieved from a ``virtual domain'' user
-database. Virtual domains are configured using @code{virtdomain}
+database.  Virtual domains are configured using @code{virtdomain}
 statement (@pxref{Virtdomain Statement}).
 @item radius
-User credentials are retrieved using @acronym{RADIUS}. @xref{Radius
+User credentials are retrieved using @acronym{RADIUS}.  @xref{Radius
 Statement}, for a detailed description on how to configure it.
 @item ldap
 User credentials are retrieved from an @acronym{LDAP}
-database. @xref{LDAP Statement}, for an information on how to
+database.  @xref{LDAP Statement}, for an information on how to
 configure it.
 @end table
 
@@ -1636,20 +1625,20 @@ configure it.
 Unless overridden by @code{authorization} statement,
 the default list of authorization modules is:
 
-@smallexample
+@example
   (system, sql, virtdomains)
-@end smallexample
+@end example
 @end deffn
 
 @deffn {Configuration} authentication @var{module-list}
-Define a sequence of modules to use for authentication. Modules will
+Define a sequence of modules to use for authentication.  Modules will
 be tried in the same order as listed in @var{module-list}.
 
 The following table lists modules available for use in @var{module-list}:
 
 @table @asis
 @item generic
-The generic authentication type. User password is hashed and compared
+The generic authentication type.  User password is hashed and compared
 against the hash value returned in authorization stage.
 @item system
 The hashed value of the user password is retrieved from
@@ -1660,41 +1649,42 @@ The hashed value of the user password is retrieved from a
 statement (@pxref{SQL Statement, getpass}).
 @item pam
 The user is authenticated via pluggable authentication module
-(@acronym{PAM}). The @acronym{PAM} service name to be used is
+(@acronym{PAM}).  The @acronym{PAM} service name to be used is
 configured in @code{pam} statement (@pxref{PAM Statement}).
 @item radius
 The user is authenticated on a remote @acronym{RADIUS}
-server. @xref{Radius Statement}.
+server.  @xref{Radius Statement}.
 @item ldap
-The user is authenticated using @acronym{LDAP}. @xref{LDAP Statement}.
+The user is authenticated using @acronym{LDAP}.  @xref{LDAP Statement}.
 @end table
 
 @FIXME{This list is inaccurate:}
 Unless overridden by @code{authentication} statement,
 the list of authentication modules is:
 
-@smallexample
+@example
   (generic, system, pam, sql)
-@end smallexample
+@end example
 @end deffn
 
 @node PAM Statement
 @subsection PAM Statement
+@UNREVISED
 @kwindex pam
 @subheading Syntax
-@smallexample
+@example
 pam @{
   # @r{Set PAM service name.}
   service @var{text};
 @}
-@end smallexample
+@end example
 
 @subheading Description
-The @code{pam} statement configures @acronym{PAM} authentication. It
+The @code{pam} statement configures @acronym{PAM} authentication.  It
 contains a single sub-statement:
 
 @deffn {Configuration} service @var{text}
-Define service name to look for in @acronym{PAM} configuration. By
+Define service name to look for in @acronym{PAM} configuration.  By
 default, the base name of the Mailutils binary is used.
 @end deffn
 
@@ -1703,14 +1693,15 @@ This statement takes effect only if @samp{pam} is listed in
 
 @node Virtdomain Statement
 @subsection Virtdomain Statement
+@UNREVISED
 @kwindex virtdomain
 @subheading Syntax
-@smallexample
+@example
 virtdomain @{
   # @r{Name of the virtdomain password directory.}
   passwd-dir @var{dir};
 @}
-@end smallexample
+@end example
 
 @subheading Description
 @dfn{Virtual mail domains} make it possible to handle several
@@ -1720,9 +1711,9 @@ user name can be present in several domains and represent different
 users.
 
 When authenticating to a server with virtual domain support enabled,
-users must supply their user names with domain parts. The server strips
+users must supply their user names with domain parts.  The server strips
 off the domain part and uses it as a name of UNIX-format password
-database file, located in the @dfn{domain password directory}. The
+database file, located in the @dfn{domain password directory}.  The
 latter is set using @code{passwd-dir} statement.
 
 @deffn {Configuration} passwd-dir @var{dir}
@@ -1735,33 +1726,34 @@ This file must be in UNIX passwd format (@pxref{password
 file,,,passwd(5), passwd(5) man page}), with encrypted passwords
 stored in it (as of GNU Mailutils version @value{VERSION}, there is no
 support for shadow files in virtual password directories, although
-this is planned for future versions). Here is an example record from
+this is planned for future versions).  Here is an example record from
 this file:
 
-@smallexample
+@example
 smith:Wbld/G2Q2Le2w:1000:1000:Email Account:/var/mail/domain/smith:/dev/null
-@end smallexample
+@end example
 
 Notice, that it must contain user names without domain parts.
 
 The @code{pw_dir} field (the 6th field) is used to determine the
-location of the maildrop for this user. It is defined as
-@file{@var{pw_dir}/INBOX}. In our example, the maildrop for user
+location of the maildrop for this user.  It is defined as
+@file{@var{pw_dir}/INBOX}.  In our example, the maildrop for user
 @samp{smith} will be located in file @file{/var/mail/domain/smith}.
 
 If user did not supply his domain name, or if no matching record was
 found in the password file, or if the file matching the domain name
 does not exist, then GNU Mailutils falls back to alternative method.
-First, it tries to determine the IP address of the remote party. Then
+First, it tries to determine the IP address of the remote party.  Then
 the domain name corresponding to that address is looked up in the DNS
-system. Finally, this domain name is used as a name of the password
+system.  Finally, this domain name is used as a name of the password
 file.
 
 @node Radius Statement
 @subsection Radius Statement
+@UNREVISED
 @kwindex radius
 @subheading Syntax
-@smallexample
+@example
 radius @{
   # Set radius configuration directory.
   directory @var{dir};
@@ -1772,17 +1764,17 @@ radius @{
   # Radius request for getpwuid.
   getpwuid @var{request};
 @}
-@end smallexample
+@end example
 @subheading Description
 The @code{radius} block statement configures @acronym{RADIUS
 authentication} and authorization.
 
 Mailutils uses GNU Radius library, which is configured via
 @file{raddb/client.conf} file (@pxref{client.conf, Client Configuration,
-Client Configuration, radius, GNU Radius Reference Manual}). Its exact
+Client Configuration, radius, GNU Radius Reference Manual}).  Its exact
 location depends on configuration settings that were used while
-compiling GNU Radius. Usually it is @file{/usr/local/etc}, or
-@file{/etc}. This default can also be changed at run time using
+compiling GNU Radius.  Usually it is @file{/usr/local/etc}, or
+@file{/etc}.  This default can also be changed at run time using
 @code{directory} statement:
 
 @deffn {Configuration} directory @var{dir}
@@ -1814,31 +1806,31 @@ the following attributes:
 
 @flindex mailutils.dict
 A dictionary file with appropriate definitions is included in the
-Mailutils distribution: @file{examples/config/mailutils.dict}. This
+Mailutils distribution: @file{examples/config/mailutils.dict}.  This
 file is not installed by default, you will have to manually copy it to
 the GNU Radius @file{raddb/dict} directory and include it in the main
 dictionary file @file{raddb/dictionary} by adding the following
 statement:
 
-@smallexample
+@example
 $INCLUDE dict/mailutils.dict
-@end smallexample
+@end example
 
 Requests to use for authentication and authorization are
 configured using three statements: @code{auth}, @code{getpwnam} and
-@code{getpwuid}. Each statement takes a single argument: a string,
-containing a comma-separated list of assignments. An assignment
+@code{getpwuid}.  Each statement takes a single argument: a string,
+containing a comma-separated list of assignments.  An assignment
 specifies a particular @dfn{attribute-value pair} (@pxref{Overview,
 RADIUS Attributes,, radius, GNU Radius Reference Manual}) to send to
-the server. The left-hand side of the assignment is a symbolic attribute
+the server.  The left-hand side of the assignment is a symbolic attribute
 name, as defined in one of Radius dictionaries (@pxref{dictionary
 file, Dictionary of Attributes,, radius, GNU Radius Reference
-Manual}). The value is specified by the right-hand side of
-assignment. For example:
+Manual}).  The value is specified by the right-hand side of
+assignment.  For example:
 
-@smallexample
+@example
 "Service-Type = Authenticate-Only, NAS-Identifier = \"mail\""
-@end smallexample
+@end example
 
 An assignment may contain references to the following macro-variables
 (@FIXME-pxref{macro-variables}):
@@ -1846,40 +1838,40 @@ An assignment may contain references to the following macro-variables
 @table @asis
 @item user
 The actual user name (for @code{auth} and @code{getpwnam}), or user ID
-(for @code{getpwuid}). For example:
+(for @code{getpwuid}).  For example:
 
-@smallexample
+@example
 User-Name = $@{user@}
-@end smallexample
+@end example
 
 @item passwd
-User password. For examples:
-@smallexample
+User password.  For examples:
+@example
 User-Password = $@{passwd@}
-@end smallexample
+@end example
 @end table
 
 @deffn {Configuration} auth @var{pairlist}
-Specifies the request to be sent to authenticate the user. For example:
+Specifies the request to be sent to authenticate the user.  For example:
 
-@smallexample
+@example
 auth "User-Name = $@{user@}, User-Password = $@{passwd@}";
-@end smallexample
+@end example
 
 The user is authenticated only if this request returns
 @code{Access-Accept} (@pxref{Authentication Requests, Access-Accept,,
-radius, GNU Radius Reference Manual}). Any returned attribute-value
+radius, GNU Radius Reference Manual}).  Any returned attribute-value
 pairs are ignored. 
 @end deffn
 
 @deffn {Configuration} getpwnam @var{pairlist}
 Specifies the request that returns user information for the
-given user name. For example:
+given user name.  For example:
 
-@smallexample
+@example
 getpwnam "User-Name = $@{user@}, State = getpwnam, "
          "Service-Type = Authenticate-Only";
-@end smallexample
+@end example
 
 If the requested user account exists, the Radius server must return
 @code{Access-Accept} packet with the following attributes:
@@ -1890,26 +1882,26 @@ The attributes @code{GNU-MU-Mailbox} and @code{GNU-MU-Quota} are
 optional.
 
 If @code{GNU-MU-Mailbox} is present, it must contain a
-valid mailbox @acronym{URL} (@FIXME-pxref{urls}). If
+valid mailbox @acronym{URL} (@FIXME-pxref{urls}).  If
 @code{GNU-MU-Mailbox} is not present, Mailutils constructs the
 mailbox name using the settings from the @code{mailbox} configuration
 statement (@pxref{Mailbox Statement}), or built-in defaults, if it is
 not present.
 
 If @code{GNU-MU-Quota} is present, it specifies the maximum mailbox
-size for this user, in bytes. In the absence of this attribute, 
+size for this user, in bytes.  In the absence of this attribute, 
 mailbox size is unlimited.
 @end deffn
 
 @deffn {Configuration} getpwuid @var{pairlist}
 Specifies the request that returns user information for the
-given user ID. In @var{pairlist}, the @samp{user} macro-variable is
-expanded to the numeric value of ID. For example:
+given user ID.  In @var{pairlist}, the @samp{user} macro-variable is
+expanded to the numeric value of ID.  For example:
 
-@smallexample
+@example
 getpwuid "User-Name = $@{user@}, State = getpwuid, "
          "Service-Type = Authenticate-Only";
-@end smallexample
+@end example
 
 The reply to @code{getpwuid} request is the same as to @code{getpwnam}
 request (see above).
@@ -1920,7 +1912,7 @@ request (see above).
 @UNREVISED
 @kwindex sql
 @subheading Syntax
-@smallexample
+@example
 sql @{
   # @r{Set SQL interface to use.}
   interface @samp{mysql|odbc|postgres};
@@ -1945,7 +1937,7 @@ sql @{
   # @r{SQL query to use for getpwuid requests.}
   getpwuid @var{query};
 @}
-@end smallexample
+@end example
 @subsection Description
 
 The @code{sql} statement configures access credentials to
@@ -1953,19 +1945,19 @@ The @code{sql} statement configures access credentials to
 authorization.
 
 GNU Mailutils supports three types of @acronym{SQL} interfaces:
-MySQL, PostgreSQL and ODBC. The latter is a standard API for using
+MySQL, PostgreSQL and ODBC.  The latter is a standard API for using
 database management systems, which can be used to communicate with a
 wide variety of DBMS.
 
 @deffn {Configuration} interface @var{type}
-Configures type of DBMS interface. Allowed values for @var{type} are:
+Configures type of DBMS interface.  Allowed values for @var{type} are:
 
 @table @asis
 @item mysql
 Interface with a MySQL server (@uref{http://www.mysql.org}).
 
 @item odbc
-Use ODBC interface. See @uref{http://www.unixodbc.org}, for a detailed
+Use ODBC interface.  See @uref{http://www.unixodbc.org}, for a detailed
 description of ODBC configuration.
 
 @item postgres
@@ -1977,7 +1969,7 @@ The database and database access credentials are configured using the
 following statements:
 
 @deffn {Configuration} host @var{arg}
-The host running the @acronym{SQL} server. The value can be either a
+The host running the @acronym{SQL} server.  The value can be either a
 host name or an IP address in dotted-quad notation, in which case an
 @acronym{INET} connection is used, or a full pathname to a file, in
 which case a connection to @acronym{UNIX} socket is used.
@@ -1985,7 +1977,7 @@ which case a connection to @acronym{UNIX} socket is used.
 
 @deffn {Configuration} port @var{arg}
 TCP port the server is listening on (for @acronym{INET}
-connections). This parameter is optional. Its default value depends on
+connections).  This parameter is optional.  Its default value depends on
 the type of database being used.
 @end deffn
 
@@ -2006,7 +1998,7 @@ Password to access the database.
 @WRITEME
 @kwindex ldap
 @subheading Syntax
-@smallexample
+@example
 ldap @{
   # @r{Enable LDAP lookups.}
   enable @var{bool};
@@ -2029,14 +2021,14 @@ ldap @{
   # @r{LDAP filter to use for getpwuid requests.}
   getpwuid @var{filter};
 @}
-@end smallexample
+@end example
 
 @node TLS Statement
 @subsection TLS Statement
 @WRITEME
 @kwindex tls
 @subheading Syntax
-@smallexample
+@example
 tls @{
   # @r{Enable TLS support.}
   enable @var{bool};
@@ -2047,14 +2039,14 @@ tls @{
   # @r{Specify trusted CAs file.}
   ssl-cafile @var{file};
 @}
-@end smallexample
+@end example
 
 @node GSASL Statement
 @subsection GSASL Statement
 @WRITEME
 @kwindex gsasl
 @subheading Syntax
-@smallexample
+@example
 gsasl @{
   # @r{Name of GSASL password file.}
   cram-passwd @var{file};
@@ -2067,12 +2059,244 @@ gsasl @{
   # @r{Anonymous user name.}
   anonymous-user @var{string};
 @}
-@end smallexample
+@end example
 
 @c -------------------------------------------------------------------
 
+@node debugging
+@section Debugging
+@command{Mailutils} debugging output is controlled by a set of levels, each of
+which can be set independently of others.  Each debug level consists of
+a @dfn{category name}, which identifies the part of
+@command{Mailutils} for which additional debugging is desired, and a
+level number, which tells @command{Mailutils} how verbose should its
+output be.
+
+Valid debug levels are:
+
+@table @asis
+@item error
+Displays error conditions which are normally not reported, but passed
+to the caller layers for handling.
+@item trace0 through trace9
+Ten levels of verbosity, @samp{trace0} producing less output,
+@samp{trace9} producing the maximum amount of output.
+@item prot
+Displays network protocol interaction, where applicable.
+@end table
+
+Implementation and applicability of each level differs between various
+categories.  The full list of categories is available in 
+file @file{libmailutils/diag/debcat} in the Mailutils source tree.
+Most useful categories and levels implemented for them are discussed
+later in this article.
+
+@menu
+* Level Syntax::
+* Level BNF::
+* Debugging Categories::
+@end menu
+
+@node Level Syntax
+@subsection Level Syntax
+
+Debug levels can be set either from the command line, by using the
+@option{--debug-level} command line option, or from the configuration
+file, using the @samp{.debug.level} statement.  In both cases, the
+level is specified as a list of individual levels, delimited with
+semicolons.  Each individual level can be specified as:
+
+@table @asis
+@item !@var{category}
+Disables all levels for the specified @var{category}.
+@item @var{category}
+Enables all levels for the specified @var{category}.
+@item @var{category}.@var{level}
+For the given @var{category}, enables all levels from @samp{error} to
+@var{level}, inclusive.
+@item @var{category}.=@var{level}
+Enables only the given @var{level} for this @var{category}.
+@item @var{category}.!@var{level}
+Disables all levels from @samp{error} to @var{level}, inclusive, for
+this @var{category}.
+@item @var{category}.!=@var{level}
+Disables only the given @var{level} in this @var{category}.
+@item @var{category}.@var{levelA}-@var{levelB}
+Enables all levels in the range from @var{levelA} to @var{levelB}, inclusive.
+@item @var{category}.!@var{levelA}-@var{levelB}
+Disables all levels in the range from @var{levelA} to @var{levelB}, inclusive.
+@end table
+
+Additionally, a comma-separated list of level specifications is
+allowed after the dot.  For example, the following specification:
+
+@example
+acl.prot,!=trace9,!trace2
+@end example
+
+enables in category @samp{acl} all levels, except @samp{trace9},
+@samp{trace0}, @samp{trace1}, and @samp{trace2}.
+
+@node Level BNF
+@subsection BNF
+
+The following specification in Backus-Naur form describes formally the
+Mailutils debug level:
+
+@example
+<debug-spec> ::= <level-spec> | <debug-level-list>
+<debug-level-list> ::= <debug-level> |
+                       <debug-level-list> ";" <debug-level>
+<debug-level> ::= <category> | "!" <category> |
+                  <category> "." <level-list>
+<level-list> ::= <level-spec> | <level-list> "," <level-spec>
+<level-spec> ::=  <level> | <negate-level>
+<negate-level> ::= "!" <level>
+<level> ::= <level-number> | "=" <level-number> |
+            <level-number> "-" <level-number>
+<level-number> ::= "error" | "trace0" | "trace1" | "trace2" | "trace3" |
+                   "trace4" | "trace5" | "trace6" | "trace7" |
+                   "trace8" | "trace9" | "prot"
+@end example
+
+@node Debugging Categories
+@subsection Debugging Categories
+
+@table @asis
+@item acl
+This category enables debugging of Access Control Lists.  Available
+levels are:
+
+@table @asis
+@item error
+As usual, displays errors, not directly reported otherwise.
+@item trace0
+Basic tracing of ACL processing.
+@item trace9
+Traces the process of matching the ACL conditions.
+@end table
+
+@item config
+This category affects configuration parser and/or lexical
+analyzer.  The following levels are supported:
+
+@table @asis
+@item trace0
+Minimal information about configuration statements.
+@item trace2
+Trace lexical structure of the configuration files.
+@item trace7
+Trace execution of the configuration parser.
+@end table
+
+Due to its specific nature, this category cannot be enabled from the
+configuration file.  A special hook is provided to facilitate
+debugging the configuration parser, namely, a pragmatic comment in
+form: 
+
+@example
+#debug=@var{debug-level-list}
+@end example
+
+causes @var{debug-level-list} to be parsed as described above.  Thus, to
+force debugging of the configuration parser, one would add the following
+line at the very beginning of the configuration file: 
+
+@example
+#debug=config.trace7
+@end example
+
+@item mailbox
+Operations over mailboxes.  This module supports the following levels:
+@samp{error}, @samp{trace0}, @samp{trace1}, and @samp{prot}.  The
+latter is used by remote mailbox support libraries.
+
+@item auth
+Enables debugging information about authentication and authorization.
+This category supports the following levels: @samp{error},
+@samp{trace0}, @samp{trace1}, and @samp{trace2}. 
+
+In level @samp{trace0}, user data are reported along with the
+@dfn{data source} they were obtained from.  The output may look like this:
+
+@example
+pop3d: source=system, name=gray, passwd=x, uid=120, gid=100,
+gecos=Sergey Poznyakoff, dir=/home/gray, shell=/bin/bash,
+mailbox=/var/mail/gray, quota=0, change_uid=1
+@end example
+
+In the @samp{trace1} level, additional flow traces are displayed.
+
+In the level @samp{trace2}, a detailed flow trace is displayed, which
+looks like the following:
+
+@example
+pop3d: Trying generic...
+pop3d: generic yields 38=Function not implemented
+pop3d: Trying system...
+pop3d: system yields 0=Success
+pop3d: Trying generic...
+pop3d: generic yields 4135=Authentication failed
+pop3d: Trying system...
+pop3d: system yields 0=Success
+@end example
+
+@item mailer
+Debugs mailer operations.  The following levels are supported: 
+
+@table @asis
+@item error
+Displays mild error conditions.
+@item trace0
+Traces mailer operations in general: displays what part of the message
+is being sent, etc.
+@item trace6
+When used together with @samp{prot}, displays security-sensitive
+information (such as passwords, user keys, etc). in plaintext.  By
+default, such information is replaced with asteriscs to reduce the
+possibility of security compromise.
+@item trace7
+When used together with @samp{prot}, displays the @dfn{payload}
+information as it is being sent.  The @dfn{payload} is the actual
+message contents, i.e. the part of SMTP transaction that goes after
+the @samp{DATA} command and which ends with a terminating dot line.
+Setting this level can generate huge amounts of information. 
+@item prot
+For SMTP mailer: outputs transcripts of SMTP sessions.
+@end table
+
+@emph{Note:} Unless in a very secure environment, it is advised to
+avoid using level settings such as mailer.prot or mailer (without
+explicit level part), because the resulting output tends to be
+extremely copious and reveals sender private and security-sensitive
+data.  If you wish to trace SMTP session flow, use @samp{mailer.=prot}
+or at least @samp{mailer.prot,!trace6}. 
+
+@item serve
+This category provides debugging information for Mailutils IP
+server objects.  It supports the @samp{error} and @samp{trace0} levels. 
+
+@item folder
+This category controls debugging information shown for operations
+related to Mailutils folders. 
+
+@item remote
+The remote category is used by @command{imap4d} and @command{pop3d}
+servers to request showing additional information in the session
+transcripts.  This category takes effect only when the @code{transcript}
+configuration variable is set.  Valid levels are:
+
+@table @asis
+@item trace6
+Show security-sensitive information (user passwords, etc.)
+@item trace7
+Show payload information
+@end table
+@end table
+
 @node frm and from
 @section @command{frm} and @command{from} --- List Headers from a Mailbox
+@UNREVISED
 
 GNU mailutils provides two commands for listing messages in a mailbox.
 These are @command{from} and @command{frm}.
@@ -2092,9 +2316,9 @@ configuration file statements:
 @pindex frm
 
 The @command{frm} utility outputs a header information of
-the selected messages in a mailbox. By default, @command{frm} reads 
+the selected messages in a mailbox.  By default, @command{frm} reads 
 user's system mailbox and outputs the contents of @code{From} and
-@code{Subject} headers for each message. If a folder is specified in
+@code{Subject} headers for each message.  If a folder is specified in
 the command line, the program reads that folder rather than the default
 mailbox.
 
@@ -2110,14 +2334,14 @@ Display the header named by @var{string} instead of @code{From}
 @code{Subject} pair.
 @item -l
 @itemx --to
-Include the contents of @code{To} header to the output. The output field
+Include the contents of @code{To} header to the output.  The output field
 order is then: @code{To} @code{From} @code{Subject}.
 @item -n
 @itemx --number
 Prefix each line with corresponding message number.
 @item -Q
 @itemx --Quiet
-Be very quiet. Nothing is output except error messages. This is useful
+Be very quiet.  Nothing is output except error messages.  This is useful
 in shell scripts where only the return status of the program is
 important.
 @item -q
@@ -2130,12 +2354,12 @@ Print a summary line.
 @itemx --status @var{attr}
 Only display headers from messages with the given status.
 @var{Attr} may be one of the following: @samp{new}, @samp{read},
-@samp{unread}. It is sufficient to specify only first letter of
-an @var{attr}. Multiple @option{-s} options are allowed.
+@samp{unread}.  It is sufficient to specify only first letter of
+an @var{attr}.  Multiple @option{-s} options are allowed.
 @item -t
 @itemx --align
-Tidy mode. In this mode @command{frm} tries to preserve the alignment of
-the output fields. It also enables the use of BIDI algorithm for
+Tidy mode.  In this mode @command{frm} tries to preserve the alignment of
+the output fields.  It also enables the use of BIDI algorithm for
 displaying subject lines that contain text in right-to-left
 orientation (such as Arabic or Hebrew).
 @end table
@@ -2144,9 +2368,9 @@ orientation (such as Arabic or Hebrew).
 @pindex from
 
 The @command{from} utility displays sender and subject of each message
-in a mailbox. By default, it reads the user's system mailbox. If the
+in a mailbox.  By default, it reads the user's system mailbox.  If the
 program is given a single argument, it is interpreted as a name of the
-user whose mailbox is to be read. Obviously, permissions are required
+user whose mailbox is to be read.  Obviously, permissions are required
 to access that user's mailbox, so such invocations may be used only
 by superuser.
 
@@ -2178,24 +2402,25 @@ Examine mailbox from the given @var{url}.
 @node mail
 @section @command{mail} --- Send and Receive Mail
 @pindex mail
+@UNREVISED
 
 @command{Mail} is an enhanced version of standard @command{/bin/mail} program.
 As well as its predecessor, it can be used either in sending mode or
-in reading mode. @command{Mail} enters sending mode when one or more
-email addresses were specified in this command line. In this mode the
+in reading mode.  @command{Mail} enters sending mode when one or more
+email addresses were specified in this command line.  In this mode the
 program waits until user finishes composing the message, then attempts
 to send it to the specified addresses and exits.
 See @ref{Composing Mail}, for a detailed description of this behavior.
 
 If the command line contained no email addresses, @command{mail} switches
-to reading mode. In this mode it allows to read and manipulate the
-contents of the user system mailbox. The @option{--file} (@option{-f})
-command line option allows to specify another mailbox name. For more
+to reading mode.  In this mode it allows to read and manipulate the
+contents of the user system mailbox.  The @option{--file} (@option{-f})
+command line option allows to specify another mailbox name.  For more
 detail, see @ref{Reading Mail}.
 
 In contrast to other GNU Mailutils programs, @command{mail} does not
-use the Mailutils configuration file. Instead, it uses the traditional
-@samp{mailrc}-style configuration. @xref{Mail Configuration Files},
+use the Mailutils configuration file.  Instead, it uses the traditional
+@samp{mailrc}-style configuration.  @xref{Mail Configuration Files},
 for a detailed description of its format.
 
 @menu
@@ -2213,9 +2438,9 @@ for a detailed description of its format.
 
 General usage of @command{mail} program is:
 
-@smallexample
+@example
       mail [@var{option}...] [@var{address}...]
-@end smallexample
+@end example
 @noindent
 If [@var{address}...] part is present, @command{mail} switches to
 mail sending mode, otherwise it operates in mail reading mode.
@@ -2227,26 +2452,26 @@ The program uses following option groups: @FIXME-xref{mailbox}.
 @table @option
 @item -e
 @itemx --exist
-Return true if the mailbox contains some messages. Return false
+Return true if the mailbox contains some messages.  Return false
 otherwise.
 This is useful for writing shell scripts.
 @item -E @var{command}
 @itemx --exec=@var{command}
-Execute @var{command} before opening the mailbox. Any number of
-@option{--exec} options can be given. The commands will be executed
+Execute @var{command} before opening the mailbox.  Any number of
+@option{--exec} options can be given.  The commands will be executed
 after sourcing configuration files (@pxref{Mail Configuration Files}),
 but before opening the mailbox. 
 @item -f
 @itemx --file
 Operate on the mailbox given by the first non-optional command line
-argument. If there is no such argument, read messages from the
-user's @file{mbox} file. @xref{Reading Mail}, for more details about
+argument.  If there is no such argument, read messages from the
+user's @file{mbox} file.  @xref{Reading Mail}, for more details about
 using this option.
 @item -F
 @itemx --byname
 Record outgoing messages in a file named after the first recipient.
 The name is the login-name portion of the address found first on the
-@samp{To:} line in the mail header. This option sets the @samp{byname}
+@samp{To:} line in the mail header.  This option sets the @samp{byname}
 variable, which see (@pxref{byname}).
 @item -H
 @itemx --headers
@@ -2259,7 +2484,7 @@ Ignore interrupts.
 Set path to the mailspool directory
 @item -n
 @itemx --norc
-Do not read the system-wide mailrc file. @xref{Mail Configuration Files}.
+Do not read the system-wide mailrc file.  @xref{Mail Configuration Files}.
 @item -N
 @itemx --nosum
 Do not display initial header summary.
@@ -2267,30 +2492,30 @@ Do not display initial header summary.
 @itemx --print
 @itemx -r
 @itemx --read
-Print all mail to standard output. It is equivalent to issuing following
+Print all mail to standard output.  It is equivalent to issuing following
 commands after starting @samp{mail -N}:
-@smallexample
+@example
 @group
 print *
 quit
 @end group
-@end smallexample
+@end example
 @item -q
 @itemx --quit
 Cause interrupts to terminate program.
 @item -s @var{subj}
 @itemx --subject=@var{subj}
-Send a message with a Subject of @var{subj}. Valid only in sending mode.
+Send a message with a Subject of @var{subj}.  Valid only in sending mode.
 @item -t
 @itemx --to
 Switch to sending mode.
 @item -u @var{user}
 @itemx --user=@var{user}
-Operate on @var{user}'s mailbox. This is equivalent to:
+Operate on @var{user}'s mailbox.  This is equivalent to:
 
-@smallexample
+@example
 mail -f/@var{spool_path}/@var{user}
-@end smallexample
+@end example
 
 @noindent
 with @var{spool_path} being the full path to your mailspool directory
@@ -2309,14 +2534,14 @@ Print program version and exit.
 @subsection How to Specify Message Sets
 
 Many mail commands such as print and delete can be given a @dfn{message list}
-to operate upon. Wherever the message list is omitted, the command
+to operate upon.  Wherever the message list is omitted, the command
 operates on the current message.
 
 The @dfn{message list} in its simplest form is one of:
 
 @table @asis
 @item .
-Selects current message. It is equivalent to empty message list.
+Selects current message.  It is equivalent to empty message list.
 @item *
 Selects all messages in the mailbox.
 @item ^
@@ -2326,7 +2551,7 @@ Selects last non-deleted message.
 @end table
 
 In its complex form, the @dfn{message list} is a comma or whitespace-separated
-list of @dfn{message specifiers}. A @dfn{message specifier} is one
+list of @dfn{message specifiers}.  A @dfn{message specifier} is one
 of
 
 @table @asis
@@ -2335,11 +2560,11 @@ This specifier addresses the message with the given ordinal number
 in the mailbox.
 @item Message range
 @dfn{Message range} is specified as two message numbers separated by
-a dash. It selects all messages with the number lying within that range.
+a dash.  It selects all messages with the number lying within that range.
 @item Attribute specifier
 An @dfn{Attribute specifier} is a colon followed by a single
-letter. The @dfn{Attribute specifier} addresses all messages in the
-mailbox that have the given attribute. These are the valid attribute
+letter.  The @dfn{Attribute specifier} addresses all messages in the
+mailbox that have the given attribute.  These are the valid attribute
 specifiers:
 
 @table @samp
@@ -2362,14 +2587,14 @@ Selects all untagged messages.
 @item Header match
 The @dfn{header match} is a string in the form:
 
-@smallexample
+@example
 [@var{header}:]/@var{string}/
-@end smallexample
+@end example
 @noindent
 
 It selects all messages that contain header field @var{header}
-matching given @var{regexp}. If the variable @code{regexp} is set,
-the @var{string} is assumed to be a POSIX regexp. Otherwise, a
+matching given @var{regexp}.  If the variable @code{regexp} is set,
+the @var{string} is assumed to be a POSIX regexp.  Otherwise, a
 header is considered to match @var{string} if the latter constitutes
 a substring of the former (comparison is case-insensitive).
 
@@ -2377,21 +2602,21 @@ If @var{header}: part is omitted, it is assumed to be @samp{Subject:}.
 @item Message body match
 The @dfn{message body match} is a string in the form:
 
-@smallexample
+@example
 :/@var{string}/
-@end smallexample
+@end example
 @noindent
 
-It selects all messages whose body matches the string. The matching
+It selects all messages whose body matches the string.  The matching
 rules are the same as described under ``Header match''.
 @end table
 
 A @dfn{message specifier} can be followed by @dfn{message part
-specifier}, enclosed in a pair of brackets. A @dfn{message part
+specifier}, enclosed in a pair of brackets.  A @dfn{message part
 specifier} controls which part of a message should be operated upon.
-It is meaningful only for multipart messages. A @dfn{message part
+It is meaningful only for multipart messages.  A @dfn{message part
 specifier} is a comma or whitespace - separated list of part numbers
-or ranges. Each part number can in turn be @dfn{message part specifier},
+or ranges.  Each part number can in turn be @dfn{message part specifier},
 thus allowing for operating upon multiply-encoded messages.
 
 The following are the examples of valid message lists:
@@ -2400,13 +2625,13 @@ The following are the examples of valid message lists:
 @subsection Composing Mail
 
 You can compose the message by simply typing the contents of it, line
-by line. But usually this is not enough, you would need to edit
-your text, to quote some messages, etc. @command{Mail} provides these
-capabilities through @dfn{compose escapes}. The @dfn{compose escapes}
+by line.  But usually this is not enough, you would need to edit
+your text, to quote some messages, etc.  @command{Mail} provides these
+capabilities through @dfn{compose escapes}.  The @dfn{compose escapes}
 are single-character commands, preceded by special @dfn{escape character},
-which defaults to @samp{~}. The combination @code{escape character + command}
+which defaults to @samp{~}.  The combination @code{escape character + command}
 is recognized as a compose escape only if it occurs at the beginning of
-a line. If the escape character must appear at the beginning of a
+a line.  If the escape character must appear at the beginning of a
 line, enter it twice.
 The actual escape character may be changed by setting the value of
 @code{escape} mail variable (@pxref{Mail Variables}).
@@ -2434,7 +2659,7 @@ The actual escape character may be changed by setting the value of
 There are several commands allowing you to quit the compose mode.
 
 Typing the end-of-file character (@samp{C-D}) on a line alone finishes
-compose mode and sends the message to its destination. The @samp{C-D}
+compose mode and sends the message to its destination.  The @samp{C-D}
 character looses its special meaning if @code{ignoreeof} mail variable
 is set.
 
@@ -2445,8 +2670,8 @@ Finally, using @samp{~.} escape always quits compose mode and sends
 out the composed message.
 
 To abort composing of a message without sending it, type interrupt
-character (by default, @samp{C-C}) twice. This behavior is disabled
-when mail variable @code{ignore} is set. In this case, you can use
+character (by default, @samp{C-C}) twice.  This behavior is disabled
+when mail variable @code{ignore} is set.  In this case, you can use
 @samp{~x} escape to achieve the same effect.
 
 @node Getting Help on Compose Escapes
@@ -2454,7 +2679,7 @@ when mail variable @code{ignore} is set. In this case, you can use
 @kyindex ~?, mail escape
 
 The @samp{~?} escape prints on screen a brief summary of the available
-compose escapes. @emph{Please note}, that @samp{~h} escape prompts
+compose escapes.  @emph{Please note}, that @samp{~h} escape prompts
 for changing the header values, and does @emph{not} give help.
 
 @node Editing the Message
@@ -2464,11 +2689,11 @@ for changing the header values, and does @emph{not} give help.
 
 If you are not satisfied with the message as it is, you can edit it
 using a text editor specified either by @code{EDITOR} or by
-@code{VISUAL} environment variables. The @samp{~e} uses the former,
+@code{VISUAL} environment variables.  The @samp{~e} uses the former,
 and @samp{~v} uses the latter.
 
 By default both escapes allow you to edit only the body of the
-message. However, if the @code{editheaders} variable is set,
+message.  However, if the @code{editheaders} variable is set,
 @command{mail} will load into the editor the complete text of
 the message with headers included, thus allowing you to change
 the headers as well.
@@ -2479,20 +2704,20 @@ the headers as well.
 To add new addresses to the list of message recipients, use @samp{~t}
 command, e.g.:
 
-@smallexample
+@example
 ~t name1@@domain.net name2
-@end smallexample
+@end example
 
 To add addresses to @code{Cc} or @code{Bcc}, use @samp{~c} or @samp{~b}
 escapes respectively.
 
 To change the @code{Subject} header, use @samp{~s} escape, e.g.:
 
-@smallexample
+@example
 ~s "Re: your message"
-@end smallexample
+@end example
 
-Finally, to edit all headers, type @samp{~h} escape. This will present
+Finally, to edit all headers, type @samp{~h} escape.  This will present
 you with the values of @code{To}, @code{Cc}, @code{Bcc}, and
 @code{Subject} headers allowing to edit them with normal text editing
 commands.
@@ -2504,7 +2729,7 @@ commands.
 
 If you are sending mail from within mail command mode, you can enclose
 the contents of any message sent to you by using @samp{~m} or @samp{~M}
-commands. Typing @samp{~m} alone will enclose the contents of the
+commands.  Typing @samp{~m} alone will enclose the contents of the
 current message, typing @samp{~m 12} will enclose the contents of
 message #12 and so on.
 
@@ -2519,22 +2744,22 @@ prepended to each line enclosed.
 
 To append the contents of file @var{filename} to the message, type
 
-@smallexample
+@example
 ~r @var{filename}
-@end smallexample
+@end example
 @noindent
 or
 
-@smallexample
+@example
 ~< @var{filename}
-@end smallexample
+@end example
 @noindent
 
 The @samp{~d} escape is a shorthand for
 
-@smallexample
+@example
 ~r dead.letter
-@end smallexample
+@end example
 
 @node Printing And Saving the Message
 @subsubsection Printing And Saving the Message
@@ -2542,8 +2767,8 @@ The @samp{~d} escape is a shorthand for
 @kyindex ~w, mail escape
 
 The @samp{~p} escape types the contents of the message entered so far,
-including headers, on your terminal. You can save the message to
-an arbitrary file using @samp{~w} escape. It takes the filename as its
+including headers, on your terminal.  You can save the message to
+an arbitrary file using @samp{~w} escape.  It takes the filename as its
 argument.
 
 @node Signing the Message
@@ -2552,9 +2777,9 @@ argument.
 @kyindex ~A, mail escape
 
 To save you the effort of typing your signature at the end of each
-message, you can use @samp{~a} or @samp{~A} escapes. If your signature
+message, you can use @samp{~a} or @samp{~A} escapes.  If your signature
 occupies one line only, save it to the variable @code{sign} and use
-@samp{~a} escape to insert it. Otherwise, if it is longer than one
+@samp{~a} escape to insert it.  Otherwise, if it is longer than one
 line, save it to a file, store the name of this file in the
 variable @code{Sign}, and use @samp{~A} escape to insert it into
 the message.
@@ -2565,9 +2790,9 @@ the message.
 @kyindex ~F, mail escape
 
 Sometimes it is necessary to view the contents of another message,
-while composing. These two escapes allow it. Both take the message
-list as their argument. If they are used without argument, the
-contents of the current message is printed. The difference between
+while composing.  These two escapes allow it.  Both take the message
+list as their argument.  If they are used without argument, the
+contents of the current message is printed.  The difference between
 @samp{~f} and @samp{~F} is that the former uses ignored and retained
 lists to select headers to be displayed, whereas the latter prints
 all headers.
@@ -2585,20 +2810,20 @@ the body of the message being composed.
 @kyindex ~-, mail escape
 
 You can execute a mail command from within compose mode using @samp{~:}
-or @samp{~-} escapes. For example, typing
+or @samp{~-} escapes.  For example, typing
 
-@smallexample
+@example
 ~: from :t
-@end smallexample
+@end example
 @noindent
 
-will display the from lines of all tagged messages. Note, that executing
+will display the from lines of all tagged messages.  Note, that executing
 mail-sending commands from within the compose mode is not allowed.
 An attempt to execute such a command will result in diagnostic message
 ``Command not allowed in an escape sequence'' being displayed.
 Also, when starting compose mode immediately from the shell
 (e.g. running @samp{mail address@@domain}), most mail commands are
-meaningless, since there is no mailbox to operate upon. In this case,
+meaningless, since there is no mailbox to operate upon.  In this case,
 the only commands that can reasonably be used are: @code{alias},
 @code{unalias}, @code{alternate}, @code{set}, and @code{unset}.
 
@@ -2608,10 +2833,10 @@ the only commands that can reasonably be used are: @code{alias},
 @kyindex ~|, mail escape
 
 The @samp{~!} escape executes specified command and returns you to
-@command{mail} compose mode without altering your message. When used without
-arguments, it starts your login shell. The @samp{~|} escape pipes the
+@command{mail} compose mode without altering your message.  When used without
+arguments, it starts your login shell.  The @samp{~|} escape pipes the
 message composed so far through the given shell command and replaces the
-message with the output the command produced. If the command produced
+message with the output the command produced.  If the command produced
 no output, @command{mail} assumes that something went wrong and retains
 the old contents of your message.
 
@@ -2646,29 +2871,29 @@ permissions the target mailbox has.
 
 Notice that @var{path_to_mailbox} is not an argument to
 @option{--file} (@option{-f}) option, but rather the first
-non-optional argument on the command line. Therefore, the
+non-optional argument on the command line.  Therefore, the
 following three invocations are equivalent:
 
-@smallexample
+@example
 $ mail -fin mymbox
 $ mail -f mymbox -in
 $ mail --file -in mymbox
 $ mail --file -i mymbox -n
-@end smallexample
+@end example
 
 Additionally, for conformance to the GNU standards, the
 following form is also accepted:
 
-@smallexample
+@example
 $ mail --file=mymbox -i -n
-@end smallexample
+@end example
 
 Unless you have started mail with @option{--norc} command line option,
 it will read the contents of the system-wide configuration file.
 Then it reads the contents of user configuration file, if any.
 For detailed description of these files, see @ref{Mail Configuration Files}.
 After this initial setup, @command{mail} displays the first page of header
-lines and enters interactive mode. In interactive mode, @command{mail}
+lines and enters interactive mode.  In interactive mode, @command{mail}
 displays its prompt (@samp{?}, if not set otherwise) and executes the
 commands the user enters.
 
@@ -2699,10 +2924,10 @@ Following commands quit the program:
 
 @table @samp
 @item quit
-Terminates the session. If @command{mail} was operating upon user's system
+Terminates the session.  If @command{mail} was operating upon user's system
 mailbox, then all undeleted and unsaved messages that have been read and
 are not marked with hold flag are saved to the user's mbox file
-(@file{$HOME/mbox}). The messages, marked with @code{delete} are removed.
+(@file{$HOME/mbox}).  The messages, marked with @code{delete} are removed.
 The program exits to the Shell, unless saving the mailbox fails, in
 which case user can escape with the exit command.
 
@@ -2730,7 +2955,7 @@ help:
 @item help [@var{command}]
 @itemx hel [@var{command}]
 @itemx ? [@var{command}]
-Display detailed command synopsis. If no @var{command} is given, help for
+Display detailed command synopsis.  If no @var{command} is given, help for
 all available commands is displayed.
 @item list
 @itemx *
@@ -2771,23 +2996,23 @@ Move to the previous message.
 @item cd [@var{dir}]
 @itemx chdir [@var{dir}]
 @itemx ch [@var{dir}]
-Change to the specified directory. If @var{dir} is omitted, @env{$HOME} is
+Change to the specified directory.  If @var{dir} is omitted, @env{$HOME} is
 assumed.
 @item file [@var{mailbox}]
 @itemx fi [@var{mailbox}]
 @itemx folder [@var{mailbox}]
 @itemx fold [@var{mailbox}]
-Read in the contents of the specified @var{mailbox}. The current mailbox
+Read in the contents of the specified @var{mailbox}.  The current mailbox
 is updated as if @code{quit} command has been issued.
 If @var{mailbox} is omitted, the command prints the current mailbox
 name followed by the summary information regarding it, e.g.:
 
-@smallexample
+@example
 @cartouche
 & fold
 "/var/spool/mail/gray": 23 messages 22 unread
 @end cartouche
-@end smallexample
+@end example
 @end table
 
 @node Controlling Header Display
@@ -2798,10 +3023,10 @@ name followed by the summary information regarding it, e.g.:
 
 To control which headers in the message should be displayed, @command{mail}
 keeps two lists: a @dfn{retained} header list and an @dfn{ignored}
-header list. If @dfn{retained} header list is not empty, only the
+header list.  If @dfn{retained} header list is not empty, only the
 header fields listed in it are displayed when printing the message.
 Otherwise, if @dfn{ignored} header list is not empty, only the headers
-@emph{not listed} in this list are displayed. The uppercase variants
+@emph{not listed} in this list are displayed.  The uppercase variants
 of message-displaying commands can be used to print all the headers.
 
 The following commands modify and display the contents of both lists.
@@ -2811,11 +3036,11 @@ The following commands modify and display the contents of both lists.
 @itemx di [@var{header-field-list}]
 @itemx ignore [@var{header-field-list}]
 @itemx ig [@var{header-field-list}]
-Add @var{header-field-list} to the ignored list. When used without
+Add @var{header-field-list} to the ignored list.  When used without
 arguments, this command prints the contents of ignored list.
 @item retain [@var{header-field-list}]
 @itemx ret [@var{header-field-list}]
-Add @var{header-field-list} to the retained list. When used without
+Add @var{header-field-list} to the retained list.  When used without
 arguments, this command prints the contents of retained list.
 @end table
 
@@ -2840,17 +3065,17 @@ Lists the current pageful of headers.
 Lists the contents of @samp{From} headers for a given set of messages.
 @item z [@var{arg}]
 Presents message headers in pagefuls as described for @code{headers}
-command. When @var{arg} is @samp{.}, it is generally equivalent to
-@code{headers}. When @var{arg} is omitted or is @samp{+}, the next
-pageful of headers is displayed. If @var{arg} is @samp{-}, the
-previous pageful of headers is displayed. The latter two forms
+command.  When @var{arg} is @samp{.}, it is generally equivalent to
+@code{headers}.  When @var{arg} is omitted or is @samp{+}, the next
+pageful of headers is displayed.  If @var{arg} is @samp{-}, the
+previous pageful of headers is displayed.  The latter two forms
 of @code{z} command may also take a numerical argument meaning the
-number of pages to skip before displaying the headers. For
+number of pages to skip before displaying the headers.  For
 example:
 
-@smallexample
+@example
 & z +2
-@end smallexample
+@end example
 @noindent
 will skip two pages of messages before displaying the header summary.
 @item size [@var{msglist}]
@@ -2861,14 +3086,14 @@ Lists the message number and message size in bytes for each message in
 Displays the value of @code{folder} variable.
 @item summary
 @itemx su
-Displays current mailbox summary. E.g.:
+Displays current mailbox summary.  E.g.:
 
-@smallexample
+@example
 @cartouche
 & summary
 "/var/spool/mail/gray": 23 messages 22 unread
 @end cartouche
-@end smallexample
+@end example
 @end table
 
 @node Displaying Messages
@@ -2888,13 +3113,13 @@ Displays current mailbox summary. E.g.:
 @itemx p [@var{msglist}]
 @item type [@var{msglist}]
 @itemx t [@var{msglist}]
-Prints out the messages from @var{msglist}. The variable @code{crt}
+Prints out the messages from @var{msglist}.  The variable @code{crt}
 determines the minimum number of lines the body of the message must
 contain in order to be piped through pager command specified
-by environment variable @code{PAGER}. If @code{crt} is set to a numeric
-value, this value is taken as the minimum number of lines. Otherwise,
+by environment variable @code{PAGER}.  If @code{crt} is set to a numeric
+value, this value is taken as the minimum number of lines.  Otherwise,
 if @code{crt} is set without a value then the height of the terminal
- screen is used to compute the threshold. The number of lines on
+ screen is used to compute the threshold.  The number of lines on
 screen is controlled by @code{screen} variable.
 @item Print [@var{msglist}]
 @itemx P [@var{msglist}]
@@ -2903,9 +3128,9 @@ screen is controlled by @code{screen} variable.
 Like print but also prints out ignored header fields.
 @item decode [@var{msglist}]
 @itemx dec [@var{msglist}]
-Print a multipart message. The @code{decode} command decodes and prints
-out specified message parts. E.g.
-@smallexample
+Print a multipart message.  The @code{decode} command decodes and prints
+out specified message parts.  E.g.
+@example
 @cartouche
 & decode 15[2]
 +---------------------------------------
@@ -2916,24 +3141,24 @@ out specified message parts. E.g.
 Content-Type: message/delivery-status
 ...
 @end cartouche
-@end smallexample
+@end example
 @item top [@var{msglist}]
 @itemx to [@var{msglist}]
-Prints the top few lines of each message in @var{msglist}. The number
+Prints the top few lines of each message in @var{msglist}.  The number
 of lines printed is controlled by the variable @code{toplines} and
 defaults to five.
 @item pipe [@var{msglist}] [@var{shell-command}]
 @itemx | [@var{msglist}] [@var{shell-command}]
-Pipe the contents of specified messages through @var{shell-command}. If
+Pipe the contents of specified messages through @var{shell-command}.  If
 @var{shell-command} is empty but the string variable @code{cmd} is set,
 the value of this variable is used as a command name.
 @item struct [@var{msglist}]
 Prints the @acronym{MIME} structure of each message from
-@var{msglist}. Empty @var{msglist} means current message.
+@var{msglist}.  Empty @var{msglist} means current message.
 
 Example:
 
-@smallexample
+@example
 @cartouche
 & struct 2
 2      multipart/mixed            14k
@@ -2941,7 +3166,7 @@ Example:
 2[2]   application/octet-stream    5k
 2[3]   text/x-diff                31k
 @end cartouche
-@end smallexample
+@end example
 @end table
 
 @node Marking Messages
@@ -2953,20 +3178,20 @@ Example:
 @table @samp
 @item tag [@var{msglist}]
 @itemx ta [@var{msglist}]
-Tag messages. The tagged messages can be referred to in message list
+Tag messages.  The tagged messages can be referred to in message list
 using @samp{:t} notation.
 @item untag [@var{msglist}]
 @itemx unt [@var{msglist}]
-Clear tags from specified messages. To untag all messages tagged so far
+Clear tags from specified messages.  To untag all messages tagged so far
 type
-@smallexample
+@example
 & untag :t
-@end smallexample
+@end example
 @item hold [@var{msglist}]
 @itemx ho [@var{msglist}]
 @itemx preserve [@var{msglist}]
 @itemx pre [@var{msglist}]
-Marks each message to be held in user's system mailbox. This command
+Marks each message to be held in user's system mailbox.  This command
 does not override the effect of @code{delete} command.
 @end table
 
@@ -2980,8 +3205,8 @@ does not override the effect of @code{delete} command.
 @table @samp
 @item delete [@var{msglist}]
 @itemx d [@var{msglist}]
-Mark messages as deleted. Upon exiting with @code{quit} command these
-messages will be deleted from the mailbox. Until the end of current
+Mark messages as deleted.  Upon exiting with @code{quit} command these
+messages will be deleted from the mailbox.  Until the end of current
 session the deleted messages can be referred to in message lists using
 :d notation.
 @item undelete [@var{msglist}]
@@ -2989,7 +3214,7 @@ session the deleted messages can be referred to in message lists using
 Clear delete mark from the specified messages.
 @item dp [@var{msglist}]
 @itemx dt [@var{msglist}]
-Deletes the current message and prints the next message. If
+Deletes the current message and prints the next message.  If
 @var{msglist} is specified, deletes all messages from the list and
 prints the message, immediately following last deleted one.
 @end table
@@ -3009,16 +3234,16 @@ prints the message, immediately following last deleted one.
 @item save [[@var{msglist}] @var{file}]
 @itemx s [[@var{msglist}] @var{file}]
 Takes a message list and a file name and appends each message in turn to
-the end of the file. The name of file and number of characters appended
-to it is echoed on the terminal. Each saved message is marked for
+the end of the file.  The name of file and number of characters appended
+to it is echoed on the terminal.  Each saved message is marked for
 deletion as if with @code{delete} command, unless the variable
 @code{keepsave} is set.
 @item Save [@var{msglist}]
 @itemx S [@var{msglist}]
 Like @code{save}, but the file to append messages to is named after the
-sender of the first message in @var{msglist}. For example:
+sender of the first message in @var{msglist}.  For example:
 
-@smallexample
+@example
 @cartouche
 @group
 & from 14 15
@@ -3028,7 +3253,7 @@ sender of the first message in @var{msglist}. For example:
 "smith" 22/603
 @end group
 @end cartouche
-@end smallexample
+@end example
 @noindent
 
 i.e., 22 lines (603 characters) have been appended to the file ``smith''.
@@ -3047,7 +3272,7 @@ header) is saved.
 @itemx touch [@var{msglist}]
 @itemx tou [@var{msglist}]
 Mark list of messages to be saved in the user's mailbox (@file{$HOME/mbox})
-upon exiting via @code{quit} command. This is the default action for
+upon exiting via @code{quit} command.  This is the default action for
 all read messages, unless you have variable @code{hold} set.
 @item copy [[@var{msglist}] @var{file}]
 @itemx c [[@var{msglist}] @var{file}]
@@ -3064,7 +3289,7 @@ deletion.
 @kyindex edit, mail command
 @kyindex visual, mail command
 
-These command allow to edit messages in a mailbox. @emph{Please note},
+These command allow to edit messages in a mailbox.  @emph{Please note},
 that modified messages currently do not replace original ones. i.e.
 you have to save them explicitly using your editor's @code{save}
 command if you do not want the effects of your editing to be lost.
@@ -3098,13 +3323,13 @@ With more than one argument, creates a new alias or changes an old one.
 @item unalias [@var{alias}...]
 @itemx una [@var{alias}...]
 Takes a list of names defined by alias commands and discards the
-remembered groups of users. The alias names no longer have any
+remembered groups of users.  The alias names no longer have any
 significance.
 @item alternates @var{name}...
 @itemx alt @var{name}...
 The alternates command is useful if you have accounts on several
-machines. It can be used to inform mail that the listed addresses are
-really you. When you reply to messages, mail will not send a copy of
+machines.  It can be used to inform mail that the listed addresses are
+really you.  When you reply to messages, mail will not send a copy of
 the message to any of the addresses listed on the alternates list.
 If the alternates command is given with no argument, the current set of
 alternate names is displayed.
@@ -3123,7 +3348,7 @@ alternate names is displayed.
 @table @samp
 @item mail [@var{address}...]
 @itemx m [@var{address}...]
-Switches to compose mode. After composing the message, sends messages to
+Switches to compose mode.  After composing the message, sends messages to
 the specified addresses.
 
 @item reply [@var{msglist}]
@@ -3149,7 +3374,7 @@ originators only.
 @item followup [@var{msglist}]
 @itemx fo [@var{msglist}]
 
-Switches to compose mode. After composing, sends the message to the
+Switches to compose mode.  After composing, sends the message to the
 originators and recipients of all messages in @var{msglist}.
 
 @item Followup [@var{msglist}]
@@ -3160,20 +3385,20 @@ originators of messages in @var{msglist}.
 @end table
 
 To determine the sender of the message @command{mail} uses the
-list of sender fields (@pxref{Controlling Sender Fields}). The first field
-from this list is looked up in message headers. If it is found
+list of sender fields (@pxref{Controlling Sender Fields}).  The first field
+from this list is looked up in message headers.  If it is found
 and contains a valid email address, this address is used as
-the sender address. If not, the second field is searched and
-so on. This process continues until a field is found in the
+the sender address.  If not, the second field is searched and
+so on.  This process continues until a field is found in the
 headers, or the sender field list is exhausted, whichever happens
 first.
 
 If the previous step did not determine the sender address, the
 address from SMTP envelope is used.
 
-Let's illustrate this. Suppose your mailbox contains the following:
+Let's illustrate this.  Suppose your mailbox contains the following:
 
-@smallexample
+@example
 @cartouche
  U  1 block@@helsingor.org  Fri Jun 30 18:30  8/245    Re: The Sa
 & Print 1
@@ -3185,12 +3410,12 @@ Subject: News
 
 Hi
 @end cartouche
-@end smallexample
+@end example
 
 @noindent
 Now, you issue the following commands:
 
-@smallexample
+@example
 @cartouche
 & sender mail-followup-to reply-to from
 & reply
@@ -3198,7 +3423,7 @@ To: <root@@helsingor.org>
 Subject: Re: News
 
 @end cartouche
-@end smallexample
+@end example
 
 @noindent
 As you see, the value of @code{Reply-To} field was taken as the
@@ -3206,24 +3431,24 @@ sender address.
 
 Now, let's try the following command sequence:
 
-@smallexample
+@example
 # Clear the sender list
 & nosender
 # Set new sender list
 & sender From
-@end smallexample
+@end example
 
 @noindent
 Now, the @code{From} address will be taken:
 
-@smallexample
+@example
 @cartouche
 & reply
 To: Antonius Block <block@@helsingor.org>
 Subject: Re: News
 
 @end cartouche
-@end smallexample
+@end example
 
 @node Controlling Sender Fields
 @subsubsection Controlling Sender Fields
@@ -3234,10 +3459,10 @@ Commands @code{sender} and @code{nosender} are used to manipulate
 the contents of the sender field list.
 
 If the command @code{sender} is used without arguments, it displays
-the contents of the sender field list. If arguments are given,
-each argument is appended to the sender field list. For example:
+the contents of the sender field list.  If arguments are given,
+each argument is appended to the sender field list.  For example:
 
-@smallexample
+@example
 @cartouche
 & sender
 Sender address is obtained from the envelope
@@ -3251,12 +3476,12 @@ mail-followup-to
 reply-to
 from
 @end cartouche
-@end smallexample
+@end example
 
 Command @code{nosender} is used to remove items from the sender
 field list:
 
-@smallexample
+@example
 @cartouche
 & sender
 mail-followup-to
@@ -3267,23 +3492,23 @@ from
 mail-followup-to
 from
 @end cartouche
-@end smallexample
+@end example
 
 When used without arguments, this command clears the list:
 
-@smallexample
+@example
 @cartouche
 & nosender
 Sender address is obtained from the envelope
 @end cartouche
-@end smallexample
+@end example
 
 @node Incorporating New Mail
 @subsubsection Incorporating New Mail
 @kyindex incorporate, mail command
 
 The @code{incorporate} (@code{inc}) command incorporates newly arrived
-messages to the displayed list of messages. This is done automatically
+messages to the displayed list of messages.  This is done automatically
 before returning to @command{mail} command prompt if the variable
 @code{autoinc} is set.
 
@@ -3293,10 +3518,10 @@ before returning to @command{mail} command prompt if the variable
 @kyindex !, mail command
 
 To run arbitrary shell command from @command{mail} command prompt, use
-@code{shell} (@code{sh}) command. If no arguments are specified, the
-command starts the user login shell. Otherwise, it uses its first
+@code{shell} (@code{sh}) command.  If no arguments are specified, the
+command starts the user login shell.  Otherwise, it uses its first
 argument as a file name to execute and all subsequent arguments are
-passed as positional parameters to this command. The @code{shell}
+passed as positional parameters to this command.  The @code{shell}
 command can also be spelled as @code{!}.
 
 @c **********************************
@@ -3306,7 +3531,7 @@ command can also be spelled as @code{!}.
 
 @subsubheading Comments
 
-The @samp{#} character introduces an end-of-line comment. All characters
+The @samp{#} character introduces an end-of-line comment.  All characters
 until and including the end of line are ignored.
 
 @subsubheading Displaying Arbitrary Text
@@ -3318,19 +3543,19 @@ The @samp{echo} (@samp{ec}) command prints its arguments to stdout.
 @kyindex source, mail command
 
 The command @samp{source @var{filename}} reads commands from the named
-file. Its minimal abbreviation is @samp{so}.
+file.  Its minimal abbreviation is @samp{so}.
 
 @anchor{Setting and Unsetting the Variables}
 @subsubheading Setting and Unsetting the Variables
 @kyindex set, mail command
 @kyindex unset, mail command
 
-The mail variables are set using @samp{set} (@samp{se}) command. The
-command takes a list of assignments. The syntax of an assignment is
+The mail variables are set using @samp{set} (@samp{se}) command.  The
+command takes a list of assignments.  The syntax of an assignment is
 
 @table @samp
 @item @var{name}=@var{string}
-Assign a string value to the variable. If @var{string} contains
+Assign a string value to the variable.  If @var{string} contains
 whitespace characters it must be enclosed in a pair of
 double-quote characters (@samp{"})
 @item @var{name}=@var{number}
@@ -3343,30 +3568,30 @@ Assign boolean @code{False} value.
 
 Example:
 
-@smallexample
+@example
 & set askcc nocrt indentprefix="> "
-@end smallexample
+@end example
 @noindent
 
 This statement sets @code{askcc} to @code{True}, @code{crt} to
 @code{False}, and @code{indentprefix} to ``> ''.
 
-To unset mail variables use @samp{unset}(@samp{uns}) command. The
+To unset mail variables use @samp{unset}(@samp{uns}) command.  The
 command takes a list of variable names to unset.
 
 Example:
 To undo the effect of the previous example, do:
 
-@smallexample
+@example
 & unset askcc crt indentprefix
-@end smallexample
+@end example
 
 When used without arguments, both @command{set} or @command{unset}
-list all currently defined variables. The form of this listing is
-controlled by @code{variable-pretty-print} (@code{varpp}) variable. If
+list all currently defined variables.  The form of this listing is
+controlled by @code{variable-pretty-print} (@code{varpp}) variable.  If
 it is set, a description precedes each variable, e.g.:
 
-@smallexample
+@example
 # prompt user for subject before composing the message
 ask
 # prompt user for cc before composing the message
@@ -3375,32 +3600,32 @@ askcc
 charset="auto"
 # number of columns on terminal screen
 columns=80
-@end smallexample
+@end example
 
 If @code{variable-pretty-print} is not set, only the settings are
 shown, e.g.:
 
-@smallexample
+@example
 ask
 askcc
 charset="auto"
 columns=80
-@end smallexample
+@end example
 
 @kyindex variable, mail command
 A special command is provided to list all internal @command{mail}
 variables:
 
-@smallexample
+@example
 variable [@var{names...}]
-@end smallexample
+@end example
 
-If used without arguments, it prints all known internal variables. If
+If used without arguments, it prints all known internal variables.  If
 arguments are given, it displays only those internal variables that
-are listed in command line. For each variable, this command prints its
-name, data type, current value and a short description. For example:
+are listed in command line.  For each variable, this command prints its
+name, data type, current value and a short description.  For example:
 
-@smallexample
+@example
 & variable ask datefield
 ask, asksub
 Type: boolean
@@ -3411,12 +3636,12 @@ datefield
 Type: boolean
 Current value: [not set]
 get date from the `Date:' header, instead of the envelope
-@end smallexample
+@end example
 
 @subsubheading Setting and Unsetting Shell Environment Variables
 
 Shell environment may be modified using @samp{setenv} (@samp{sete})
-command. The command takes a list of assignments. The syntax of an
+command.  The command takes a list of assignments.  The syntax of an
 assignment is:
 
 @table @samp
@@ -3435,20 +3660,20 @@ Delete the variable @var{name} from the environment (``unset'' it).
 @kyindex endif, mail command
 
 The conditional statement allows to execute a set of mail commands
-depending on the mode the @command{mail} program is in. The conditional
+depending on the mode the @command{mail} program is in.  The conditional
 statement is:
 
-@smallexample
+@example
 if @var{cond}
 ...
 else
 ...
 endif
-@end smallexample
+@end example
 @noindent
 
 where @samp{...} represents the set of commands to be executed in each
-branch of the statement. @var{cond} can be one of the following:
+branch of the statement.  @var{cond} can be one of the following:
 
 @table @samp
 @item s
@@ -3459,13 +3684,13 @@ True if @command{mail} is operating in mail reading mode.
 True if stdout is a terminal device (as opposed to a regular file).
 @end table
 
-The conditional statements can be nested to arbitrary depth. The minimal
+The conditional statements can be nested to arbitrary depth.  The minimal
 abbreviations for @samp{if}, @samp{else} and @samp{endif} commands are
 @samp{i}, @samp{el} and @samp{en}.
 
 Example:
 
-@smallexample
+@example
 if t
 set crt prompt="& "
 else
@@ -3474,7 +3699,7 @@ endif
 if s
 alt gray@@farlep.net gray@@mirddin.farlep.net
 set
-@end smallexample
+@end example
 
 @node Mail Variables
 @subsection How to Alter the Behavior of @command{mail}
@@ -3489,7 +3714,7 @@ Following variables control the behavior of GNU @command{mail}:
 @vrindex append, mail variable
 
 Messages saved in mbox are appended to the end rather than prepended.
-This is the default and cannot be changed. This variable exists only
+This is the default and cannot be changed.  This variable exists only
 for compatibility with other @command{mailx} implementations.
 
 @kwindex appenddeadletter
@@ -3499,7 +3724,7 @@ for compatibility with other @command{mailx} implementations.
 @vrindex appenddeadletter, mail variable
 
 If this variable is @code{True}, the contents of canceled letter is
-appended to the user's @file{dead.letter} file. Otherwise it overwrites
+appended to the user's @file{dead.letter} file.  Otherwise it overwrites
 its contents.
 
 @kwindex askbcc
@@ -3564,7 +3789,7 @@ command is replaced with the last executed command.
 
 Record outgoing messages in a file named after the first recipient.
 The name is the login-name portion of the address found first on the
-@samp{To:} line in the mail header. This variable overrides the
+@samp{To:} line in the mail header.  This variable overrides the
 @samp{record} variable.
 
 It is set by the @option{--byname} (@option{-F}) command line option.
@@ -3577,9 +3802,9 @@ It is set by the @option{--byname} (@option{-F}) command line option.
 @vrindex datefield, mail variable
 
 By default the date in a header summary is taken from the @acronym{SMTP}
-envelope of the message. Setting this variable tells @command{mail}
+envelope of the message.  Setting this variable tells @command{mail}
 to use the date from @code{Date:} header field, converted to
-local time. Notice, that for messages lacking this field @command{mail}
+local time.  Notice, that for messages lacking this field @command{mail}
 will fall back to using @acronym{SMTP} envelope.
 
 @xref{fromfield}.
@@ -3591,11 +3816,11 @@ will fall back to using @acronym{SMTP} envelope.
 @vrindex charset, mail variable
 
 The value of this variable controls the output character set for the
-header fields encoding using RFC 2047. If the variable is unset, no
-decoding is performed and the fields are printed as they are. If the
+header fields encoding using RFC 2047.  If the variable is unset, no
+decoding is performed and the fields are printed as they are.  If the
 variable is set to @samp{auto}, @command{mail} tries to deduce the
 name of the character set from the value of @code{LC_ALL} environment
-variable. Otherwise, its value is taken as the name of the charset.
+variable.  Otherwise, its value is taken as the name of the charset.
 
 @kwindex cmd
 @item cmd
@@ -3608,7 +3833,7 @@ Contains default shell command for @code{pipe}.
 @kwindex columns
 @item columns
 @*Type: Numeric.
-@*Default: Detected at startup by querying the terminal device. If this
+@*Default: Detected at startup by querying the terminal device.  If this
 fails, the value of environment variable @code{COLUMNS} is used.
 @vrindex columns, mail variable
 
@@ -3622,10 +3847,10 @@ This variable contains the number of columns on terminal screen.
 
 The variable @code{crt} determines the minimum number of lines the body
 of the message must contain in order to be piped through pager command
-specified by environment variable @code{PAGER}. If @code{crt} is set
-to a numeric value, this value is taken as the threshold. Otherwise,
+specified by environment variable @code{PAGER}.  If @code{crt} is set
+to a numeric value, this value is taken as the threshold.  Otherwise,
 if @code{crt} is set without a value, then the height of the terminal
-screen is used to compute the threshold. The number of lines on
+screen is used to compute the threshold.  The number of lines on
 screen is controlled by @code{screen} variable.
 
 @kwindex debug
@@ -3638,8 +3863,8 @@ Sets mailutils debug level.  If set to string, the value must be a
 valid Mailutils debugging specification.  @xref{Debug Statement}, for
 a description.
 
-If unset (i.e. @code{set nodebug}), clears and disables all debugging
-information.  If set to @samp{true} (i.e. @code{set debug}), sets
+If unset (i.e.  @code{set nodebug}), clears and disables all debugging
+information.  If set to @samp{true} (i.e.  @code{set debug}), sets
 maximum debugging (@samp{<trace7}) on mailbox and its underlying
 objects.
 
@@ -3650,19 +3875,19 @@ objects.
 @vrindex decode-fallback, mail variable
 
 This variable controls the way to represent characters that cannot
-be rendered using current character set. It can have three values:
+be rendered using current character set.  It can have three values:
 
 @table @samp
 @item none
-Such characters are not printed at all. The conversion process stops
+Such characters are not printed at all.  The conversion process stops
 at the first character that cannot be rendered.
 
 @item copy-pass
-The characters are displayed @samp{as is}. Notice, that depending on
+The characters are displayed @samp{as is}.  Notice, that depending on
 your setup, this may screw-up your terminal settings.
 
 @item copy-octal
-Unprintable characters are represented by their octal codes. Printable
+Unprintable characters are represented by their octal codes.  Printable
 ones are printed @samp{as is}.
 @end table
 
@@ -3691,7 +3916,7 @@ terminator of a message you are sending.
 @vrindex emptystart, mail variable
 
 If the mailbox is empty, @command{mail} normally prints @samp{No mail for user} and
-exits immediately. If this option is set, @command{mail} will start no matter is
+exits immediately.  If this option is set, @command{mail} will start no matter is
 the mailbox empty or not.
 
 @kwindex editheaders
@@ -3728,7 +3953,7 @@ and @code{Reply} commands (@pxref{Replying}).
 @*Default: Unset.
 @vrindex folder, mail variable
 
-The name of the directory to use for storing folders of messages. If
+The name of the directory to use for storing folders of messages.  If
 unset, @env{$HOME} is assumed.
 
 @anchor{fromfield}
@@ -3776,26 +4001,26 @@ introduces a @dfn{format specifier}.  Valid format specifiers are:
 @end multitable
 
 Some additional symbols are allowed between @samp{%} and the specifier
-letter. The @samp{-} character immediately following @samp{%}
-indicates that this field should be left aligned. Similarly, the
-@samp{+} character indicates right alignment. Default alignment
+letter.  The @samp{-} character immediately following @samp{%}
+indicates that this field should be left aligned.  Similarly, the
+@samp{+} character indicates right alignment.  Default alignment
 depends on the type of the specifier: the specifiers that produce
 numeric values (@samp{%l}, @samp{%m}, and @samp{%o}) are aligned to
 the right, whereas the ones producing string values are aligned to the
 left.
 
 A number following @samp{%} or the alignment flag, indicates the
-field width. Consider, for example, the following specifiers:
+field width.  Consider, for example, the following specifiers:
 
 @table @asis
 @item %m
-Print current message number. Take as much screen columns as necessary
+Print current message number.  Take as much screen columns as necessary
 to output it.
 
 @item %4m
 @itemx %+4m
-Print current message number. Occupy 4 screen columns, truncate the
-output if it does not fit that width. Align the output to the right. 
+Print current message number.  Occupy 4 screen columns, truncate the
+output if it does not fit that width.  Align the output to the right. 
 
 @item %-4m
 Same as above, but align to the left.
@@ -3808,8 +4033,8 @@ Same as above, but align to the left.
 @vrindex hold, mail variable
 
 When set to @code{True}, the read or saved messages will be stored in
-user's mailbox (@file{$HOME/mbox}). Otherwise, they will be held in
-system mailbox also. This option is in effect only when operating
+user's mailbox (@file{$HOME/mbox}).  Otherwise, they will be held in
+system mailbox also.  This option is in effect only when operating
 upon user's system mailbox.
 
 @kwindex ignore 
@@ -3819,7 +4044,7 @@ upon user's system mailbox.
 @vrindex ignore, mail variable
 
 When set to @code{True}, @command{mail} will ignore keyboard interrupts
-when composing messages. Otherwise an interrupt will be taken as a
+when composing messages.  Otherwise an interrupt will be taken as a
 signal to abort composing.
 
 @kwindex ignoreeof
@@ -3845,7 +4070,7 @@ String used by the @code{~m} tilde escape for indenting quoted messages.
 @*Default: False
 
 If set, @command{mail} will expand aliases in the address header field
-before entering send mode (@pxref{Composing Mail}). By default, the
+before entering send mode (@pxref{Composing Mail}).  By default, the
 address header fields are left intact while composing, the alias
 expansion takes place immediately before sending message.
 
@@ -3856,7 +4081,7 @@ expansion takes place immediately before sending message.
 @vrindex append, mail variable
 
 Truncate the user's system mailbox when it is empty, instead of
-removing it. This is the default and cannot be changed. This variable
+removing it.  This is the default and cannot be changed.  This variable
 exists only for compatibility with other @command{mailx} implementations.
 
 @kwindex keepsave
@@ -3875,7 +4100,7 @@ mailbox.
 @*Default: False.
 @vrindex mailx, mail variable
 
-When set, enables @dfn{mailx compatibility mode}. This mode
+When set, enables @dfn{mailx compatibility mode}.  This mode
 has the following effects:
 
 @itemize @bullet
@@ -3885,7 +4110,7 @@ The default behavior is to ask for these values before composing
 the body.
 
 @item In send mode, if the composition was interrupted, @command{mail}
-will exit with zero status. By default it exits with zero status only
+will exit with zero status.  By default it exits with zero status only
 if the message was sent successfully.
 @end itemize
 
@@ -3895,23 +4120,23 @@ if the message was sent successfully.
 @*Default: True.
 @vrindex metamail, mail variable
 
-This variable controls operation of @code{decode} command. If
+This variable controls operation of @code{decode} command.  If
 it is unset, @code{decode} will not attempt any interpretation
-of the content of message parts. Otherwise, if @code{metamail}
+of the content of message parts.  Otherwise, if @code{metamail}
 is set to @code{true}, @code{decode} will use internal metamail
-support to interpret message parts. Finally, if @code{metamail}
+support to interpret message parts.  Finally, if @code{metamail}
 is assigned a string, this string is treated as command line of
 the external @command{metamail} command which will be used to
-display parts of a multipart message. For example:
+display parts of a multipart message.  For example:
 
-@smallexample
+@example
 # Disable MIME interpretation:
 set nometamail
 # Enable built-in MIME support:
 set metamail
 # Use external program to display MIME parts:
 set metamail="metamail -m mail -p"
-@end smallexample
+@end example
 
 @kwindex mimenoask
 @item mimenoask
@@ -3920,14 +4145,14 @@ set metamail="metamail -m mail -p"
 @vrindex mimenoask, mail variable
 
 By default @command{mail} asks for confirmation before running
-interpreter to view a part of the multi-part message. If this variable
+interpreter to view a part of the multi-part message.  If this variable
 is set, its value is treated as a comma-separated list of MIME types
-for which no confirmation is needed. Elements of this list may include
+for which no confirmation is needed.  Elements of this list may include
 shell-style globbing patterns, e.g. setting
 
-@smallexample
+@example
 set mimenoask=text/*,image/jpeg
-@end smallexample
+@end example
 
 @noindent
 will disable prompting before displaying any textual files, no
@@ -3941,7 +4166,7 @@ type @samp{image/jpeg}.
 @vrindex metoo, mail variable
 
 Usually, when an alias is expanded that contains the sender, the sender
-is removed from the expansion. Setting this option causes the sender to
+is removed from the expansion.  Setting this option causes the sender to
 be included in the group.
 
 @kwindex mode
@@ -3950,7 +4175,7 @@ be included in the group.
 @*Default: The name of current operation mode.
 @vrindex mode, mail variable
 
-This variable keeps the name of the current operation mode. Its
+This variable keeps the name of the current operation mode.  Its
 possible values are:
 
 @table @asis
@@ -3967,10 +4192,10 @@ The program is started with the @option{--print} (@option{-p}) command
 line option (@pxref{Invoking Mail}).
 
 @item read
-The progran operates in read mode. This is the default.
+The progran operates in read mode.  This is the default.
 
 @item send
-The program operates in send mode. This means it was given one or more
+The program operates in send mode.  This means it was given one or more
 recipient addresses in the command line.
 @end table
 
@@ -3981,23 +4206,23 @@ recipient addresses in the command line.
 @vrindex nullbody, mail variable
 
 Controls whether @command{mail} accepts messages with an empty
-body. The default value, @code{true}, means such messages are sent,
+body.  The default value, @code{true}, means such messages are sent,
 and a warning (traditionally saying @samp{Null message body; hope
-that's ok}) is displayed. The text of the warning can be set using
+that's ok}) is displayed.  The text of the warning can be set using
 @code{nullbodymsg} variable (see below).
 
 If @code{nullbody} is unset, @command{mail} will silently ignore such
-messages. This can be useful in @file{crontab} files, to avoid sending
-mails when nothing important happens. For example, the @file{crontab}
+messages.  This can be useful in @file{crontab} files, to avoid sending
+mails when nothing important happens.  For example, the @file{crontab}
 entry below will send mail only if the utility @command{some-prog}
 outputs something on its standard output or error:
 
-@smallexample
+@example
 @group
 */5 * * * * some-prog 2>&1 | \
    /bin/mail -E'set nonullbody' -s 'Periodic synchronization'
 @end group
-@end smallexample
+@end example
 
 @kwindex showenvelope
 @item showenvelope
@@ -4014,7 +4239,7 @@ If this variable is set, the @code{print} command will include the
 @vrindex nullbodymsg
 
 Keeps the text of the warning, displayed by @command{mail} before
-sending an empty message. When available, the translation of
+sending an empty message.  When available, the translation of
 this text, in accordance with the current locale, is displayed.
 
 Unsetting this variable disables the warning.
@@ -4035,7 +4260,7 @@ This variable is not used.  It exists for compatibility with other
 @vrindex outfolder, mail variable
 
 Contains the directory in which files created by @code{save},
-@code{write}, etc. commands will be stored. When unset, current
+@code{write}, etc. commands will be stored.  When unset, current
 directory is assumed.
 
 @kwindex page
@@ -4079,7 +4304,7 @@ When set, causes keyboard interrupts to terminate the program.
 @vrindex rc, mail variable
 
 When this variable is set, @command{mail} will read the system-wide
-configuration file upon startup. See @ref{Mail Configuration Files}.
+configuration file upon startup.  See @ref{Mail Configuration Files}.
 
 @kwindex readonly
 @item readonly
@@ -4132,17 +4357,17 @@ of a reply message.
 @vrindex replyregex, mail variable
 
 Sets the regular expression used to recognize subjects of reply
-messages. If the @code{Subject} header of the message matches this
+messages.  If the @code{Subject} header of the message matches this
 expression, the value of @code{replyprefix} will not be prepended to
-it before replying. The expression should be a POSIX extended regular
-expression. The comparison is case-insensitive.
+it before replying.  The expression should be a POSIX extended regular
+expression.  The comparison is case-insensitive.
 
 For example, to recognize usual English, Polish, Norwegian and German
 reply subject styles, use:
 
-@smallexample
+@example
 set replyregex="^(re|odp|aw|ang)(\\[[0-9]+\\])?:[[:blank:]]"
-@end smallexample
+@end example
 
 @noindent
 (Notice the quoting of backslash characters).
@@ -4154,12 +4379,12 @@ set replyregex="^(re|odp|aw|ang)(\\[[0-9]+\\])?:[[:blank:]]"
 @vrindex save, mail variable
 
 When set, the aborted messages will be stored in the user's
-@file{dead.file}. See also @code{appenddeadletter}.
+@file{dead.file}.  See also @code{appenddeadletter}.
 
 @kwindex screen
 @item screen
 @*Type: Numeric.
-@*Default: Detected at startup by querying the terminal device. If this
+@*Default: Detected at startup by querying the terminal device.  If this
 fails, the value of environment variable @code{LINES} is used.
 @vrindex screen, mail variable
 
@@ -4197,7 +4422,7 @@ the header summary.
 @*Default: Unset.
 @vrindex Sign, mail variable
 
-Contains the filename holding users signature. The contents of this
+Contains the filename holding users signature.  The contents of this
 file is appended to the end of a message being composed by @code{~A}
 escape.
 
@@ -4207,8 +4432,8 @@ escape.
 @*Default: Unset.
 @vrindex sign, mail variable
 
-Contains the user's signature. The contents of this variable is appended
-to the end of a message being composed by @code{~a} escape. Use
+Contains the user's signature.  The contents of this variable is appended
+to the end of a message being composed by @code{~a} escape.  Use
 @code{Sign} variable, if your signature occupies more than one line.
 
 @kwindex showto
@@ -4227,7 +4452,7 @@ invoked the program.
 @*Default: Unset.
 @vrindex subject, mail variable
 
-Contains default subject line. This will be used when @code{asksub} is
+Contains default subject line.  This will be used when @code{asksub} is
 off.
 
 @kwindex toplines
@@ -4245,8 +4470,8 @@ Number of lines to be displayed by @code{top} and @code{Top} commands.
 @*Default: False.
 
 Setting this variable enables strict control over variable
-settings. In this mode, @command{mail} refuses to set read-only
-variables. Also, if the user is trying to set an unknown variable,
+settings.  In this mode, @command{mail} refuses to set read-only
+variables.  Also, if the user is trying to set an unknown variable,
 @command{mail} prints a warning.
 
 @xref{Setting and Unsetting the Variables}.
@@ -4258,7 +4483,7 @@ variables. Also, if the user is trying to set an unknown variable,
 @*Default: False.
 
 If this variable is set, the listing ouput by @command{set} contains short
-descriptions before each variable. @xref{Setting and Unsetting the Variables}. 
+descriptions before each variable.  @xref{Setting and Unsetting the Variables}. 
 
 @kwindex verbose
 @item verbose
@@ -4275,11 +4500,11 @@ When set, the actual delivery of messages is displayed on the user's terminal.
 @vrindex xmailer, mail variable
 
 Controls whether the header @samp{X-Mailer} should be added to 
-outgoing messages. The default value of this header is
+outgoing messages.  The default value of this header is
 
-@smallexample
+@example
 X-Mailer: mail (GNU Mailutils @value{VERSION})
-@end smallexample
+@end example
 
 @end table
 
@@ -4288,32 +4513,33 @@ X-Mailer: mail (GNU Mailutils @value{VERSION})
 
 Upon startup, @command{mail} reads the contents of the two command files:
 the system-wide configuration file, and the user's configuration
-file. Each line read from these files is processed like a usual
+file.  Each line read from these files is processed like a usual
 @command{mail} command.
 
 When run with @option{--norc} (@option{-N}) option, @command{mail} does
-not read the contents of system-wide configuration file. The user's
+not read the contents of system-wide configuration file.  The user's
 file, if it exists, is always processed.
 
 The user's configuration file is located in the user's home
-directory and is named @file{.mailrc}. The location and name of
+directory and is named @file{.mailrc}.  The location and name of
 the system-wide configuration file is determined when configuring the
-package via @option{--with-mail-rc} option. It defaults to
+package via @option{--with-mail-rc} option.  It defaults to
 @file{@var{sysconfdir}/mail.rc}.
 
 @page
 @node messages
 @section @command{messages} --- Count the Number of Messages in a Mailbox
 @pindex messages
+@UNREVISED
 
 @command{Messages} prints on standard output the number of messages
-contained in each folder specified in command line. If no folders
-are specified, it operates upon user's system mailbox. For each
+contained in each folder specified in command line.  If no folders
+are specified, it operates upon user's system mailbox.  For each
 folder, the following output line is produced:
 
-@smallexample
+@example
 Number of messages in @var{folder}: @var{number}
-@end smallexample
+@end example
 
 @noindent
 where @var{folder} represents the folder name, @var{number} represents
@@ -4337,7 +4563,7 @@ The program accepts following command line options:
 @itemx --quiet
 @itemx -s
 @itemx --silent
-Be quiet. Display only number of messages per mailbox, without leading text.
+Be quiet.  Display only number of messages per mailbox, without leading text.
 @item -?
 @itemx --help
 Output help message and exit.
@@ -4352,26 +4578,27 @@ Output program version and exit.
 @node movemail
 @section @command{movemail} --- Moves Mail from the User Maildrop to the Local File
 @pindex movemail
+@UNREVISED
 
 The purpose of @command{movemail}, as its name implies, is to move mail
-from one location to another. For example, the following invocation:
+from one location to another.  For example, the following invocation:
 
-@smallexample
+@example
 movemail /var/mail/smith INBOX
-@end smallexample
+@end example
 
 @noindent
 moves messages from file @file{/var/mail/smith} to file @file{INBOX}.
 
-You will probably never have to run this program manually. It is
-intended as a replacement for @command{movemail} from GNU Emacs. The
+You will probably never have to run this program manually.  It is
+intended as a replacement for @command{movemail} from GNU Emacs.  The
 @command{movemail} program is run by Emacs @code{Rmail}
-module. @xref{Rmail,,,emacs,Reading Mail with Rmail}, for detailed
+module.  @xref{Rmail,,,emacs,Reading Mail with Rmail}, for detailed
 description of @code{Rmail} interface.
 
 Mailutils version of @command{movemail} is fully
 backward-compatible with its Emacs predecessor, so it should run
-flawlessly with older versions of Emacs. Emacs versions
+flawlessly with older versions of Emacs.  Emacs versions
 starting from 22.1 contain improved @code{Rmail} interface and
 are able to take advantage of all new features mailutils
 @command{movemail} provides.
@@ -4385,6 +4612,7 @@ are able to take advantage of all new features mailutils
 
 @node Movemail Configuration
 @subsection Movemail Configuration
+@UNREVISED
 
 Following configuration file statements affect the behavior of
 @command{movemail}:
@@ -4447,9 +4675,9 @@ 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
+@example
 program-id "$@{progname@}: $@{source@} => $@{dest@}"
-@end smallexample
+@end example
 @end deffn
 
 @deffn {Movemail Config} uidl @var{bool}
@@ -4469,7 +4697,7 @@ elements:
 @anchor{mailbox-ownership-methods}
 @table @asis
 @item copy-id
-Copy owner UID and GID from the source mailbox. This method works only
+Copy owner UID and GID from the source mailbox.  This method works only
 with local mailboxes, i.e.: @samp{mbox} (UNIX mailbox), @samp{maildir}
 and @samp{mh}.
 
@@ -4478,7 +4706,7 @@ Get owner name from the source mailbox URL and obtain UID and GID for
 this user using mailutils authorization methods.
 
 @item set-id=@var{uid}[:@var{gid}]
-Set supplied @var{uid} and @var{gid}. If @var{gid} is not supplied,
+Set supplied @var{uid} and @var{gid}.  If @var{gid} is not supplied,
 it is read from the @file{/etc/passwd} record for this UID.
 
 @item set-name=@var{user}
@@ -4502,6 +4730,7 @@ Make destination mailbox owned by @var{user}.
 
 @node Movemail Options
 @subsection Movemail Options
+@UNREVISED
 
 This subsection discusses @command{movemail} options from the point of
 view of an Emacs @code{Rmail} user.
@@ -4510,7 +4739,7 @@ To set various options to @command{movemail} from @code{Rmail}, use
 @code{rmail-movemail-flags} variable, or @samp{Rmail Movemail Flags}
 section from the menu. 
 
-Some POP servers return messages in reversed order. To fix the
+Some POP servers return messages in reversed order.  To fix the
 order, use @option{-p} option or its synonym @option{--reverse}.
 
 If the remote server supports @acronym{TLS} encryption, use
@@ -4525,17 +4754,17 @@ connection.
 @node Summary
 @subsection Movemail Usage Summary
 
-@smallexample
+@example
 movemail [@var{option}...] @var{inbox} @var{destfile} [@var{remote-password}]
-@end smallexample
+@end example
 
-The first argument, @var{inbox}, is the @acronym{url} (@pxref{URL}) of
-the source mailbox. The second argument, @var{destfile}, traditionally
+The first argument, @var{inbox}, is the @acronym{url} (@FIXME-pxref{URL}) of
+the source mailbox.  The second argument, @var{destfile}, traditionally
 means destination file, i.e. the UNIX mailbox to copy messages
-to. However, mailutils @command{movemail} extends the meaning of this
-parameter. You may actually specify any valid @acronym{URL} as
+to.  However, mailutils @command{movemail} extends the meaning of this
+parameter.  You may actually specify any valid @acronym{URL} as
 @var{destfile} parameter.@footnote{Rmail does not use this
-feature}. Finally, optional third argument is a traditional way of
+feature}.  Finally, optional third argument is a traditional way of
 specifying user passwords for remote (@acronym{POP} or @acronym{IMAP})
 mailboxes.
 
@@ -4571,8 +4800,8 @@ Use UIDLs to avoid downloading the same message twice.
 @item -P @var{method-list}
 @itemx --owner=@var{method-list}
 Define list of methods for setting ownership of the destination
-mailbox. @xref{mailbox-ownership-methods}, for a description of
-@var{method-list}. This option is useful only when running
+mailbox.  @xref{mailbox-ownership-methods}, for a description of
+@var{method-list}.  This option is useful only when running
 @command{movemail} as root.
 
 @item -v
@@ -4586,30 +4815,30 @@ Increase verbosity level.
 @pindex readmsg
 
 The @command{readmsg} utility extracts messages from a mailbox
-according to the criteria specified in the command line. These
+according to the criteria specified in the command line.  These
 criteria are:
 
 @enumerate
 @item A lone @samp{*} means ``select all messages in the mailbox''.
 
 @item
-A list of message numbers may be specified. Values
+A list of message numbers may be specified.  Values
 of  @samp{0}  and @samp{$} in the list both mean the last
-message in the mailbox. For example:
-@smallexample
+message in the mailbox.  For example:
+@example
 readmsg 1 3 0
-@end smallexample
+@end example
 extracts three messages from the folder: the first, the third, and the last.
 
 @item
-Finally, the selection may be some text to match. This will select a mail
-message which exactly matches the specified text. For example,
-@smallexample
+Finally, the selection may be some text to match.  This will select a mail
+message which exactly matches the specified text.  For example,
+@example
 readmsg staff meeting
-@end smallexample
+@end example
 extracts the message which contains the words @samp{staff meeting}.
 Note that it will not match a message containing @samp{Staff Meeting}
--- the matching is case sensitive. Normally only the first message
+-- the matching is case sensitive.  Normally only the first message
 which matches the pattern is printed.
 @end enumerate
 
@@ -4665,9 +4894,9 @@ If @var{bool} is @samp{true}, display entire headers.
 @end deffn
 
 @deffn {Readmsg Conf} weedlist @var{str}
-Set the weedlist. The @var{str} argument is
+Set the weedlist.  The @var{str} argument is
 a string, containing a list of header names, separated by whitespace,
-commands or colons. This corresponds to the @option{--weedlist} command
+commands or colons.  This corresponds to the @option{--weedlist} command
 line option (@pxref{Opt-readmsg, --weedlist}).
 @end deffn
 
@@ -4700,11 +4929,12 @@ only the first.
 @node sieve
 @section @command{sieve}
 @pindex sieve
+@UNREVISED
 
 Sieve is a language for filtering e-mail messages at time of final
-delivery, described in RFC 3028. GNU Mailutils provides two
+delivery, described in RFC 3028.  GNU Mailutils provides two
 implementations of this language: a stand-alone @dfn{sieve interpreter}
-and a @dfn{sieve translator and filter}. The following sections describe these
+and a @dfn{sieve translator and filter}.  The following sections describe these
 utilities in detail.
 
 @menu
@@ -4716,9 +4946,9 @@ utilities in detail.
 @subsection A Sieve Interpreter
 
 Sieve interpreter @command{sieve} allows to apply Sieve scripts to an
-arbitrary number of mailboxes. GNU @command{sieve} implements a superset
-of the Sieve language as described in RFC 3028. @xref{Sieve Language},
-for a description of the Sieve language. @xref{GNU Extensions}, for a
+arbitrary number of mailboxes.  GNU @command{sieve} implements a superset
+of the Sieve language as described in RFC 3028.  @xref{Sieve Language},
+for a description of the Sieve language.  @xref{GNU Extensions}, for a
 discussion of differences between the GNU implementation of Sieve and
 its standard.
 
@@ -4734,9 +4964,9 @@ its standard.
 
 The @command{sieve} invocation syntax is:
 
-@smallexample
+@example
 sieve [@var{options}] @var{script}
-@end smallexample
+@end example
 
 @noindent
 where @var{script} denotes the filename of the sieve program to parse,
@@ -4749,16 +4979,16 @@ Compile script and exit.
 
 @item --clear-library-path
 @itemx --clearpath
-Clear Sieve library path. See also @ref{Sieve Configuration,
+Clear Sieve library path.  See also @ref{Sieve Configuration,
 clear-library-path}.
 
 @item --clear-include-path
-Clear Sieve include path. See also @ref{Sieve Configuration,
+Clear Sieve include path.  See also @ref{Sieve Configuration,
 clear-include-path}. 
 
 @item -d[@var{flags}]
 @itemx --debug[=@var{flags}]
-Specify debug flags. The @var{flags} argument is a sequence of one or
+Specify debug flags.  The @var{flags} argument is a sequence of one or
 more of the following letters:
 
 @multitable @columnfractions .40 .45
@@ -4775,31 +5005,31 @@ Compile the script, dump disassembled code on standard output and exit.
 
 @item -e @var{address}
 @itemx --email @var{address}
-Override the user email address. This is useful for @code{reject} and
-@code{redirect} actions. By default, the user email address is deduced
+Override the user email address.  This is useful for @code{reject} and
+@code{redirect} actions.  By default, the user email address is deduced
 from the user name and the full name of the machine where
-@command{sieve} is executed. See also @ref{Sieve Configuration,
+@command{sieve} is executed.  See also @ref{Sieve Configuration,
 email}. 
 
 @item -I @var{dir}
 @itemx --includedir=@var{dir}
 Append directory @var{dir} to the list of directories searched for
-include files. See also @ref{Sieve Configuration, include-path}.
+include files.  See also @ref{Sieve Configuration, include-path}.
 
 @item -f
 @itemx --mbox-url=@var{mbox}
-Mailbox to sieve (defaults to user's system mailbox). See also
+Mailbox to sieve (defaults to user's system mailbox).  See also
 @ref{Sieve Configuration, mbox-url}.
 
 @item -k
 @itemx --keep-going
-Keep on going if execution fails on a message. See also
+Keep on going if execution fails on a message.  See also
 @ref{Sieve Configuration, keep-going}.
 
 @item -L @var{dir}
 @item --libdir=@var{dir}
 Append directory @var{dir} to the list of directories searched for
-library files. See also @ref{Sieve Configuration, library-path}.
+library files.  See also @ref{Sieve Configuration, library-path}.
 
 @item -n
 @itemx --no-actions
@@ -4807,12 +5037,12 @@ Dry run: do not execute any actions, just print what would be done.
 
 @item -t @var{ticket}
 @itemx --ticket=@var{ticket}
-Ticket file for mailbox authentication. See also
+Ticket file for mailbox authentication.  See also
 @ref{Sieve Configuration, ticket}.
 
 @item -v
 @itemx --verbose
-Log all actions executed. See also @ref{Sieve Configuration, verbose}.
+Log all actions executed.  See also @ref{Sieve Configuration, verbose}.
 @end table
 
 @node Sieve Configuration
@@ -4833,9 +5063,9 @@ configuration statements:
 
 The following statements configure sieve-specific features:
 
-@deffn {Sieve Conf} sieve @{ ... @}
+@deffn {Sieve Conf} sieve @{ ...  @}
 This block statement configures search paths @command{sieve} uses to
-locate its loadable modules. @xref{Require Statement}, for a detailed
+locate its loadable modules.  @xref{Require Statement}, for a detailed
 information of this feature.
 
 This statement may contain the following sub-statements:
@@ -4858,14 +5088,14 @@ If @var{bool} is @samp{true}, clear include search path.
 @deffn {Sieve Conf} library-path @var{path}
 Used within the @code{sieve} block statement.
 
-Add directories to @command{sieve} library search path. Argument is a
+Add directories to @command{sieve} library search path.  Argument is a
 string containing a colon-separated list of directories.
 @end deffn
 
 @deffn {Sieve Conf} include-path @var{path}
 Used within the @code{sieve} block statement.
 
-Add directories to the include search path. Argument is a
+Add directories to the include search path.  Argument is a
 string containing a colon-separated list of directories.
 @end deffn
 
@@ -4883,7 +5113,7 @@ Sets the name of the ticket file for user authentication.
 @end deffn
 
 @deffn {Sieve Conf} debug @var{flags}
-Sets Sieve debug flags. @xref{Logging and Debugging}, for a detailed
+Sets Sieve debug flags.  @xref{Logging and Debugging}, for a detailed
 description.
 @end deffn
 
@@ -4893,13 +5123,13 @@ If @var{bool} is @samp{true}, log all executed actions.
 
 @deffn {Sieve Conf} line-info @var{bool}
 If @var{bool} is @samp{true}, print source locations along with action
-logs. This statement takes effect only if @code{verbose true} is also
+logs.  This statement takes effect only if @code{verbose true} is also
 set.
 @end deffn
 
 @deffn {Sieve Conf} email @var{addr}
-Set user e-mail address. This is useful for @code{reject} and
-@code{redirect} actions. By default, the user email address is deduced
+Set user e-mail address.  This is useful for @code{reject} and
+@code{redirect} actions.  By default, the user email address is deduced
 from the user name and the full name of the machine where @command{sieve} is
 executed. 
 @end deffn
@@ -4908,19 +5138,19 @@ executed.
 @subsubsection Logging and debugging
 
 The default behavior of @command{sieve} is to remain silent about
-anything except errors. However, it is sometimes necessary to see
-which actions are executed and on which messages. This is particularly
-useful when debugging the sieve scripts. The @option{--verbose}
+anything except errors.  However, it is sometimes necessary to see
+which actions are executed and on which messages.  This is particularly
+useful when debugging the sieve scripts.  The @option{--verbose}
 (@option{-v}) option outputs log of every action executed.
 
 Option @option{--debug} allows to produce even more detailed debugging
-information. This option takes an argument specifying the
-debugging level to be enabled. The argument can consist of the
+information.  This option takes an argument specifying the
+debugging level to be enabled.  The argument can consist of the
 following letters:
 
 @table @samp
 @item @samp{t}
-This flag enables sieve tracing. It means that every test will be logged
+This flag enables sieve tracing.  It means that every test will be logged
 when executed.
 
 @item @samp{T}
@@ -4931,18 +5161,18 @@ Trace network protocols: produces log of network transactions executed
 while running the script.
 
 @item @samp{g}
-Enable main parser traces. This is useful for debugging the sieve grammar.
+Enable main parser traces.  This is useful for debugging the sieve grammar.
 
 @item @samp{i}
-Trace the program instructions. It is the most extensive debugging
-level. It produces the full execution log of a sieve program, showing
-each instruction and states of the sieve machine. It is only useful
+Trace the program instructions.  It is the most extensive debugging
+level.  It produces the full execution log of a sieve program, showing
+each instruction and states of the sieve machine.  It is only useful
 for debugging the code generator.
 @end table
 
 @emph{Note}, that there should be no whitespace
 between the short variant of the option (@option{-d}), and its
-argument. Similarly, when using long option (@option{--debug}),
+argument.  Similarly, when using long option (@option{--debug}),
 its argument must be preceded by equal sign.
 
 If the argument to @option{--debug} is omitted, it defaults to
@@ -4952,7 +5182,7 @@ Option @option{--dump} produces the disassembled dump of the compiled
 sieve program. 
 
 By default @command{sieve} output all diagnostics on standard error and verbose
-logs on standard output. This behaviour is changed when
+logs on standard output.  This behaviour is changed when
 @option{--log-facility} is given in the command line (@FIXME-pxref{logging}).
 This option causes @command{sieve} to output its diagnostics to
 the given syslog facility.
@@ -4961,31 +5191,31 @@ the given syslog facility.
 @subsubsection Extending @command{sieve}
 
 The basic set of sieve actions, tests and comparators may be extended
-using loadable extensions. Usual @code{require} mechanism is used for
+using loadable extensions.  Usual @code{require} mechanism is used for
 that.
 
 When processing arguments for @code{require} statement, @command{sieve}
 uses the following algorithm:
 
 @enumerate 1
-@item Look up the name in a symbol table. If the name begins with
-@samp{comparator-} it is looked up in the comparator table. If it
-begins with @samp{test-}, the test table is used instead. Otherwise
+@item Look up the name in a symbol table.  If the name begins with
+@samp{comparator-} it is looked up in the comparator table.  If it
+begins with @samp{test-}, the test table is used instead.  Otherwise
 the name is looked up in the action table.
 
 @item If the name is found, the search is terminated.
 
-@item Otherwise, transform the name. First, any @samp{comparator-} or
-@samp{test-} prefix is stripped. Then, any character other than
+@item Otherwise, transform the name.  First, any @samp{comparator-} or
+@samp{test-} prefix is stripped.  Then, any character other than
 alphanumeric characters, @samp{.} and @samp{,} is replaced with
-dash (@samp{-}). The name thus obtained is used as a file name
+dash (@samp{-}).  The name thus obtained is used as a file name
 of an external loadable module. 
 
-@item Try to load the module. The module is searched in the
+@item Try to load the module.  The module is searched in the
 following search paths (in the order given):
 
 @enumerate 1
-@item Mailutils module directory. By default it is
+@item Mailutils module directory.  By default it is
 @file{$prefix/lib/mailutils}.
 
 @item The value of the environment variable @env{LTDL_LIBRARY_PATH}.
@@ -5011,7 +5241,7 @@ a colon-separated list of absolute directories, for example,
 @samp{"/usr/lib/mypkg:/lib/foo"}.
 
 In any of these directories, @command{sieve} first attempts to find
-and load the given filename. If this fails, it tries to append the
+and load the given filename.  If this fails, it tries to append the
 following suffixes to the file name:
 
 @enumerate 1
@@ -5023,16 +5253,16 @@ platform, e.g., @samp{.so}, @samp{.sl}, etc.
 
 @item If the module is found, @command{sieve} executes its
 initialization function (see below) and again looks up the name
-in the symbol table. If found, search terminates successfully.
+in the symbol table.  If found, search terminates successfully.
 
 @item If either the module is not found, or the symbol wasn't
 found after execution of the module initialization function,
-search is terminated with an error status. @command{sieve} then displays
+search is terminated with an error status.  @command{sieve} then displays
 the following diagnostic message:
 
-@smallexample
+@example
 source for the required action NAME is not available
-@end smallexample
+@end example
 @end enumerate
  
 @c ***********************************************************************
@@ -5040,11 +5270,12 @@ source for the required action NAME is not available
 @page
 @node sieve.scm
 @subsection A Sieve to Scheme Translator and Filter
+@UNREVISED
 
 A Sieve to Scheme Translator @command{sieve.scm} translates a given
 Sieve script into an equivalent Scheme program and optionally executes
-it. The program itself is written in Scheme and requires presence of
-Guile version 1.8 or newer on the system. For more information on
+it.  The program itself is written in Scheme and requires presence of
+Guile version 1.8 or newer on the system.  For more information on
 Guile refer to @ref{Top,,Overview,guile,The Guile Reference Manual}.
 
 @table @option
@@ -5074,6 +5305,7 @@ The Scheme programs produced by @command{sieve.scm} can be used with
 @node guimb
 @section @command{guimb} --- A Mailbox Scanning and Processing Language
 @pindex guimb
+@UNREVISED
 
 @command{Guimb} is for mailboxes what @command{awk} is for text files.
 It processes mailboxes, applying the user-supplied scheme procedures
@@ -5127,8 +5359,8 @@ Execute scheme expression.
 Load Scheme source code from @var{file}.
 @end table
 
-You can specify both of them. In this case, the @var{file} is read
-first, then @var{expr} is executed. You may still pass any additional
+You can specify both of them.  In this case, the @var{file} is read
+first, then @var{expr} is executed.  You may still pass any additional
 arguments to the script using @option{--guile-arg} option.
 
 @node Specifying Mailboxes to Operate Upon
@@ -5142,13 +5374,13 @@ The resulting mailbox is not saved, unless the user-supplied
 scheme program saves it.
 @item guimb [@var{options}] --mailbox @var{defmbox}
 The contents of @var{defmbox} is processed and is replaced with the resulting
-mailbox contents. Useful for applying filters to user's mailbox.
+mailbox contents.  Useful for applying filters to user's mailbox.
 @item guimb [@var{options}] --mailbox @var{defmbox} @var{mailbox} [@var{mailbox}...]
 The contents of specified mailboxes is processed, and the resulting
 mailbox contents is appended to @var{defmbox}.
 @item guimb [@var{options}] --user @var{username} [@var{mailbox}...]
 The contents of specified mailboxes is processed, and the resulting
-mailbox contents is appended to the user's system mailbox. This allows
+mailbox contents is appended to the user's system mailbox.  This allows
 to use @command{guimb} as a mail delivery agent.
 @end table
 
@@ -5159,43 +5391,43 @@ and processes the system mailbox of the current user.
 @subheading Passing Options to Scheme
 
 Sometimes it is necessary to pass some command line options to the
-scheme procedure. There are three ways of doing so.
+scheme procedure.  There are three ways of doing so.
 
 When using @option{--source} (@option{-s}) or @option{--code}
 (@option{-c}) options, all the rest of the command line following
-the option's argument is passed to Scheme program verbatim. This
-allows for making guimb scripts executable by the shell. If your system
+the option's argument is passed to Scheme program verbatim.  This
+allows for making guimb scripts executable by the shell.  If your system
 supports @samp{#!} magic at the start of scripts, add the following two
 lines to the beginning of your script to allow for its immediate execution:
 
-@smallexample
+@example
 #! /usr/local/bin/guimb -s
 !#
-@end smallexample
+@end example
 
 @noindent
 (replace @samp{/usr/local/bin/} with the actual path to the @command{guimb}).
 
 Otherwise, if you use @option{--file} or @option{--expression} options,
 the additional arguments may be passed to the Scheme program @option{-g}
-(@option{--guile-arg}) command line option. For example:
+(@option{--guile-arg}) command line option.  For example:
 
-@smallexample
+@example
 guimb --guile-arg -opt --guile-arg 24 --file @var{progfile}
-@end smallexample
+@end example
 
 In this example, the scheme procedure will see the following command line:
 
-@smallexample
+@example
 @var{progfile} -opt 24
-@end smallexample
+@end example
 
 Finally, if there are many arguments to be passed to Scheme, it is more
 convenient to enclose them in @option{-@{} and @option{-@}} escapes:
 
-@smallexample
+@example
 guimb -@{ -opt 24 -@} --file @var{progfile}
-@end smallexample
+@end example
 
 @node Command Line Option Summary
 @subheading Command Line Option Summary
@@ -5240,23 +5472,24 @@ Display program version.
 @node maidag
 @section maidag
 @pindex maidag
+@UNREVISED
 
-The name @samp{maidag} stands for @i{Mai}l @i{d}elivery @i{ag}ent. It
+The name @samp{maidag} stands for @i{Mai}l @i{d}elivery @i{ag}ent.  It
 is a general-purpose @acronym{MDA} offering a rich set of
-features. It can operate both in traditional mode, reading the message
-from its standard input, and in @acronym{LMTP} mode. @command{Maidag}
+features.  It can operate both in traditional mode, reading the message
+from its standard input, and in @acronym{LMTP} mode.  @command{Maidag}
 is able to deliver mail to any mailbox format, supported by GNU
-Mailutils. These formats, among others, include @samp{remote+smtp},
+Mailutils.  These formats, among others, include @samp{remote+smtp},
 @samp{remote+prog} and @samp{remote+sendmail} which are
 equivalent to forwarding a message over @acronym{SMTP} to a remote
-node. Thus, @command{maidag} supersedes both @command{mail.local} and
+node.  Thus, @command{maidag} supersedes both @command{mail.local} and
 @command{mail.remote} utilities from GNU Mailutils versions prior to
 2.0.
 
 @command{Maidag} is also able to process incoming messages using
 Sieve, Scheme or Python scripts and, based on results of this
 processing, to take a decision on whether to actually deliver and
-where to deliver them. Due to its extensive scripting facilities,
+where to deliver them.  Due to its extensive scripting facilities,
 @command{maidag} offers much more flexibility than other popular
 @acronym{MDA}s, such as @command{procmail}.
 
@@ -5277,11 +5510,11 @@ where to deliver them. Due to its extensive scripting facilities,
 @cindex Sendmail
 When used as a @acronym{MDA} with Sendmail, @command{maidag} must be
 invoked from the local mailer definition in the @file{sendmail.cf}
-file. It must have the following flags set: @samp{lswS}. These mean:
+file.  It must have the following flags set: @samp{lswS}.  These mean:
 the mailer is local, quote characters should be stripped off the
 address before invoking the mailer, the user must have a valid account
 on this machine and the userid should not be reset before calling the 
-mailer. Additionally, the flags @samp{fn} may be specified to allow
+mailer.  Additionally, the flags @samp{fn} may be specified to allow
 @command{maidag} to generate the usual @samp{From } envelope instead
 of the one supplied by @command{sendmail}. 
 
@@ -5292,31 +5525,31 @@ valid account on the machine that runs @command{sendmail}.
 
 Here is an example of mailer definition in @file{sendmail.cf}
 
-@smallexample 
+@example 
 Mlocal, P=/usr/local/sbin/maidag,
         F=lsDFMAw5:/|@@qSPfhn9,
         S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
         T=DNS/RFC822/X-Unix,
         A=mail $u
-@end smallexample
+@end example
 
 To define local mailer in @samp{mc} source file, it will suffice to
 set:
 
-@smallexample
+@example
 define(`LOCAL_MAILER_PATH', `/usr/local/sbin/maidag')
 define(`LOCAL_MAILER_ARGS', `mail $u')
-@end smallexample
+@end example
 
 @node Exim-maidag
 @subsection Using @command{maidag} with Exim.
 @cindex Exim
 
-Using @command{maidag} with Exim is quite straightforward. The
+Using @command{maidag} with Exim is quite straightforward.  The
 following example illustrates the definition of the appropriate transport
 and director in @file{exim.conf}:
 
-@smallexample
+@example
 # transport
 maidag_pipe:
   driver = pipe
@@ -5329,7 +5562,7 @@ maidag_pipe:
 maidag:
   driver = localuser
   transport = maidag_pipe
-@end smallexample
+@end example
 
 @node MeTA1-maidag
 @subsection Using @command{maidag} with MeTA1.
@@ -5339,13 +5572,13 @@ MeTA1 (@uref{http://meta1.org}) communicates with the delivery agent
 using @acronym{LMTP}.
 
 LMTP mode is enabled in @command{maidag} by the @samp{lmpt yes}
-statement. The socket to listen on must be specified using
-@code{server} statement (@pxref{Server Settings}). For the purposes of
+statement.  The socket to listen on must be specified using
+@code{server} statement (@pxref{Server Settings}).  For the purposes of
 this section, let's suppose @command{maidag} will listen on a
-@acronym{UNIX} socket @file{/var/spool/meta1/lmtpsock}. Then, the
+@acronym{UNIX} socket @file{/var/spool/meta1/lmtpsock}.  Then, the
 following (minimal) @command{maidag} configuration will do the job:
 
-@smallexample
+@example
 # @r{Start in LMTP mode.}
 lmtp yes;
 # @r{Run as daemon.}
@@ -5356,43 +5589,43 @@ group meta1c;
 server unix:///var/spool/meta1/lmtpsock @{
   transcript no;
 @};
-@end smallexample
+@end example
   
 To configure MeTA1 to use this socket, add the following statement to
 the @samp{smtpc} section in @file{/etc/meta1/meta1.conf}:
 
-@smallexample
+@example
   LMTP_socket="lmtpsock";
-@end smallexample
+@end example
 
 @node Mailbox Quotas
 @subsection Mailbox Quotas
 
-@dfn{Mailbox quota} is a limit on the size of the mailbox. When a
+@dfn{Mailbox quota} is a limit on the size of the mailbox.  When a
 mailbox size reaches this limit, @command{maidag} stops accepting
 messages for this recipient and returns an error condition to the
-sender. The error code is accompanied by the following error message:
+sender.  The error code is accompanied by the following error message:
 
-@smallexample
+@example
 @var{user}: mailbox quota exceeded for this recipient
-@end smallexample
+@end example
 
 Furthermore, if accepting the incoming message would make the
 mailbox size exceed the quota, such a message will be rejected as
-well. In this case, the error message is:
+well.  In this case, the error message is:
 
-@smallexample
+@example
 @var{user}: message would exceed maximum mailbox size for this recipient
-@end smallexample
+@end example
 
 In both cases, the default return code will be @samp{service
 unavailable} (corresponding to the @acronym{SMTP} return code
 @samp{550}), unless the following statement is present in the
 @command{maidag} configuration file:
 
-@smallexample
+@example
 exit-quota-tempfail yes;
-@end smallexample
+@end example
 
 @noindent
 in which case a temporary error will be returned.
@@ -5416,20 +5649,20 @@ The mailbox quota can be retrieved from the following sources:
 To use @acronym{DBM} quota database, GNU Mailutils must
 be compiled with one of the following command line options:
 @option{--with-gdbm}, @option{--with-berkeley-db}, or
-@option{--with-ndbm}. Examine the output of @command{maidag
+@option{--with-ndbm}.  Examine the output of @command{maidag
 --show-config-options}, if not sure. 
 
 The quota database should have the following structure:
 
 @table @asis
 @item Key
-Key represents the user name. Special key @samp{DEFAULT} means default
+Key represents the user name.  Special key @samp{DEFAULT} means default
 quota value, i.e. the one to be used if the user is not explicitly
 listed in the database.
 
 @item Value
-Mailbox quota for this user. If it is a number, it represents the
-maximum mailbox size in bytes. A number may optionally be followed by
+Mailbox quota for this user.  If it is a number, it represents the
+maximum mailbox size in bytes.  A number may optionally be followed by
 @samp{kb} or @samp{mb}, meaning kilobytes and megabytes, respectively.
 
 A special value @samp{NONE} means no mailbox size limit for this user.
@@ -5437,7 +5670,7 @@ A special value @samp{NONE} means no mailbox size limit for this user.
 
 Here is an example of a valid quota database
 
-@smallexample
+@example
 # Default quota value:
 DEFAULT         5mb
 
@@ -5448,81 +5681,81 @@ smith           NONE
 # Rest of users
 plog            26214400
 karin           10mB
-@end smallexample
+@end example
 
 To use the @acronym{DBM} quota database, specify its absolute name using
 @code{quota-db} configuration statement, e.g.:
 
-@smallexample
+@example
 quota-db /etc/mail/quota.db;
-@end smallexample
+@end example
 
 @node SQL Quotas
 @subsubsection Keeping Quotas in SQL Database
 
 Configuration statement @code{quota-query} allows to specify a special
-query to retrieve the quota from the database. Currently (as of mailutils
+query to retrieve the quota from the database.  Currently (as of mailutils
 version @value{VERSION}) it is assumed that this table can be accessed
 using the credentials set in @samp{sql} configuration statement
 (@pxref{SQL Statement}).
 
 For example, suppose you have the following quota table:
 
-@smallexample
+@example
 create table mailbox_quota (
   user_name varchar(32) binary not null,
   quota int,
   unique (user_name)
 );
-@end smallexample
+@end example
 
 @noindent
 
 To retrieve user quota the following query can be used:
 
-@smallexample
+@example
 SELECT quota FROM mailbox_quota WHERE user_name='$@{user@}'
-@end smallexample
+@end example
 
 There are no special provisions for specifying group quotas, similar to
-@samp{DEFAULT} in @acronym{DBM} databases. This is because group quotas can
-easily be implemented using @acronym{SQL} language. @command{Maidag}
+@samp{DEFAULT} in @acronym{DBM} databases.  This is because group quotas can
+easily be implemented using @acronym{SQL} language.  @command{Maidag}
 always uses the first tuple from the set returned by mailbox quota
-query. So, you may add a special entry to the @code{mailbox_quota}
-table that would keep the group quota. In the discussion below we assume
+query.  So, you may add a special entry to the @code{mailbox_quota}
+table that would keep the group quota.  In the discussion below we assume
 that the @code{user_name} column for this entry is lexicographically
-less than any other user name in the table. Let's suppose the group
-quota name is @samp{00DEFAULT}. Then the following query:
+less than any other user name in the table.  Let's suppose the group
+quota name is @samp{00DEFAULT}.  Then the following query:
 
-@smallexample
+@example
 SELECT quota
 FROM mailbox_quota
 WHERE user_name IN ('$@{user@}','00DEFAULT')
 ORDER BY user_name DESC
-@end smallexample
+@end example
 
 @noindent
 will return two tuples if the user is found in
-@code{mailbox_quota}. Due to @code{ORDER} statement, the first tuple
+@code{mailbox_quota}.  Due to @code{ORDER} statement, the first tuple
 will contain the quota for the user, which will be used by
-@command{maidag}. On the other hand, if the requested user name is not
+@command{maidag}.  On the other hand, if the requested user name is not
 present in the table, the above query will return a single tuple
 containing the group quota.
 
 The following configuration statement instructs @command{maidag} to
 use this query for retrieving the user quota:
 
-@smallexample
+@example
 quota-query "SELECT quota "
             "FROM mailbox_quota "
             "WHERE user_name IN ('$@{user@}','00DEFAULT') "
             "ORDER BY user_name DESC";
-@end smallexample
+@end example
 
 @node Maidag Scripting
 @subsection Maidag Scripting
 @command{Maidag} can use global or per-user @dfn{mail filters} to
-decide whether to deliver the message, and where to deliver it. As of
+decide whether to deliver the message, and where to deliver it.  As of
 Mailutils version @value{VERSION}, such mail filters may be written in
 the following languages:
 
@@ -5535,7 +5768,7 @@ the following languages:
 @end itemize
 
 Mail filters to use are specified using @samp{script} configuration
-statement. The following meta-symbols can be used in its argument:
+statement.  The following meta-symbols can be used in its argument:
 
 @table @asis
 @item ~
@@ -5547,13 +5780,13 @@ Expands to the recipient user name.
 @end table
 
 By default, a filename extension decide which scripting language will
-be used. User can alter the choice using @samp{language} configuration
+be used.  User can alter the choice using @samp{language} configuration
 statement.  For example:
 
-@smallexample
+@example
 language "python"
 script "~/.maidag-py-filter"
-@end smallexample
+@end example
 
 @menu
 * Sieve Maidag Filters::
@@ -5568,9 +5801,9 @@ The file name of the Sieve filter to use is specified using
 @samp{script} configuration statement.  For example, the following
 configuration statement:
 
-@smallexample
+@example
 script "~/.maidag.sv"
-@end smallexample
+@end example
 
 @noindent
 instructs @command{maidag} to use file @file{.maidag.sv} in the
@@ -5579,7 +5812,7 @@ recipient home directory as a Sieve filter.
 Normal message delivery is attempted if execution of the Sieve code
 ended with @code{keep} action (either implicit or explicit).
 
-Other Sieve actions are executed as described in @ref{Actions}. For
+Other Sieve actions are executed as described in @ref{Actions}.  For
 example, to deliver message to another mailbox, use the
 @code{fileinto} action. 
 
@@ -5593,9 +5826,9 @@ The file name of the Scheme mail filter is specified using
 @samp{script} configuration statement.  For example, the following
 configuration statement:
 
-@smallexample
+@example
 script "~/.maidag.scm"
-@end smallexample
+@end example
 
 @noindent
 instructs `maidag' to use file `.maidag.scm' in the recipient home
@@ -5609,9 +5842,9 @@ The file name of the Python mail filter is specified using
 @samp{script} configuration statement.  For example, the following
 configuration statement:
 
-@smallexample
+@example
 script "~/.maidag.py"
-@end smallexample
+@end example
 
 @noindent
 instructs `maidag' to use file `.maidag.py' in the recipient home
@@ -5620,7 +5853,7 @@ directory as a Python filter.
 @noindent
 A simple example of a mail filter written in Python:
 
-@smallexample
+@example
 from mailutils import *
 import maidag
 import re
@@ -5647,34 +5880,34 @@ try:
             msg.attribute.set_deleted ()
 except Exception:
     pass
-@end smallexample
+@end example
 
 @node Forwarding
 @subsection Forwarding
 @cindex forward
 @dfn{Forward file} is a special file in the user's home directory that
 contains the email address of the mailbox where the user wants to
-forward his mail. Normally, forward files are processed by
-@acronym{MTA}. However, there are some @acronym{MTA} that lack this
-feature. One of them is MeTA1.
+forward his mail.  Normally, forward files are processed by
+@acronym{MTA}.  However, there are some @acronym{MTA} that lack this
+feature.  One of them is MeTA1.
 
 @command{Maidag} provides a forwarding feature that is useful to
 compensate the lack of it.
 
 @kwindex forward-file
 Name of the forward file is given using @code{forward-file}
-configuration statement. A common usage is:
+configuration statement.  A common usage is:
 
-@smallexample
+@example
 forward-file .forward;
-@end smallexample
+@end example
 
 The forward file is always searched in the recipient home directory.
 
 @kwindex forward-file-checks
 Before actually using the file, a number of safety checks are
-performed on it. If the file fails to pass one of these checks, no
-forwarding is performed and the message is delivered as usual. These
+performed on it.  If the file fails to pass one of these checks, no
+forwarding is performed and the message is delivered as usual.  These
 checks can be configured using @code{forward-file-checks} statement.
 Its argument is a list of the following keywords:
 
@@ -5706,11 +5939,11 @@ All of the above checks.
 The default is @samp{forward-file-checks all}.
 
 Each of these keywords may be prefixed by @samp{no} to disable this
-particular check. For example:
+particular check.  For example:
 
-@smallexample
+@example
 forward-file-checks (nodir_iwoth, nodir_iwgrp);
-@end smallexample
+@end example
 
 @node Url-mode 
 @subsection Delivering Messages to a URL.
@@ -5720,28 +5953,28 @@ When invoked with the @option{--url} command line option,
 
 For example:
 
-@smallexample
+@example
 $ maidag --url maildir:///home/smith/Mail
-@end smallexample
+@end example
 
 @node Remote Mailbox Delivery
 @subsection Remote Mailbox Delivery
 @command{Maidag} can be used to deliver mail to remote mailboxes, such
-as @samp{imap} or @samp{remote+smtp}. If the mailbox @acronym{URL}
+as @samp{imap} or @samp{remote+smtp}.  If the mailbox @acronym{URL}
 is @samp{remote+smtp} or @samp{remote+sendmail}, the message is
 actually forwarded over @acronym{SMTP} to the remote node, so
-@command{maidag} acts as a message transfer agent. For example:
+@command{maidag} acts as a message transfer agent.  For example:
 
-@smallexample
+@example
 $ maidag --url remote+smtp://10.10.1.100:24
-@end smallexample
+@end example
 
 This command line will send the message to the machine
 @samp{10.10.1.100} using port @samp{24} (private mail system).
 
-The @samp{remote+prog} mailbox may be of special use. Delivering to
+The @samp{remote+prog} mailbox may be of special use.  Delivering to
 this mailbox results in invoking the specified command with the given
-arguments and passing the message to its standard input. There are two
+arguments and passing the message to its standard input.  There are two
 ways to specify a @samp{remote+prog} mailbox:
 
 @table @asis
@@ -5761,7 +5994,7 @@ mailing lists with MeTA1.
 
 For example, suppose that the @command{maidag} configuration contains:
 
-@smallexample
+@example
 auth @{
   authorization sql:system;
   authentication generic:system;
@@ -5776,12 +6009,12 @@ sql @{
            "FROM userdb "
            "WHERE user='$@{user@}'";
 @}
-@end smallexample
+@end example
 
 Then, the following entries in the @samp{userdb} table implement
 @email{mailman@@yourdomain} mailing list:
 
-@smallexample
+@example
 mysql> select * from userdb;
 +---------------------+---------------------------------------+
 | user                | mailbox                               |
@@ -5797,7 +6030,7 @@ mysql> select * from userdb;
 | mailman-subscribe   | |/usr/bin/mailman subscribe mailman   |
 | mailman-unsubscribe | |/usr/bin/mailman unsubscribe mailman |
 +---------------------+---------------------------------------+
-@end smallexample
+@end example
 
 @node Conf-maidag
 @subsection Maidag Configuration File Summary
@@ -5817,7 +6050,7 @@ statements:
 @item ldap          @tab @xref{LDAP Statement}.
 @item auth          @tab @xref{Auth Statement}.
 @item mailer        @tab @xref{Mailer Statement}.
-@item server        @tab @xref{Server Settings}. Used only in
+@item server        @tab @xref{Server Settings}.  Used only in
 @acronym{LMTP} mode.
 @item acl           @tab @xref{ACL Statement}.
 @item tcp-wrappers  @tab @xref{Tcp-wrappers Statement}.
@@ -5830,11 +6063,11 @@ delivery has succeeded.
 
 @deffn {Maidag Config} ex-quota-tempfail @var{bool}
 Indicate temporary failure if the recipient is over his mail quota.
-By default, permanent failure is returned. @xref{Mailbox Quotas}.
+By default, permanent failure is returned.  @xref{Mailbox Quotas}.
 @end deffn
 
 @deffn {Maidag Config} quota-db @var{file}
-Set the name of DBM quota database file. @xref{DBM Quotas}.
+Set the name of DBM quota database file.  @xref{DBM Quotas}.
 @end deffn
 
 @deffn {Maidag Config} sieve-filter @var{pattern}
@@ -5853,7 +6086,7 @@ File name or name pattern for Guile filter file.
 @end deffn
 
 @deffn {Maidag Config} debug @var{flags}
-Set additional debugging flags. Valid flags are:
+Set additional debugging flags.  Valid flags are:
 
 @table @asis
 @item g
@@ -5876,7 +6109,7 @@ Log to stderr instead of syslog.
 @end deffn
 
 @deffn {Maidag Config} forward-file @var{file}
-Process forward file @var{file}. @xref{Forwarding}.
+Process forward file @var{file}.  @xref{Forwarding}.
 @end deffn
 
 @deffn {Maidag Config} forward-file-checks @var{list}
@@ -5893,14 +6126,14 @@ In @acronym{LMTP} mode, retain supplementary groups from @var{list}.
 @end deffn
 
 @deffn {Maidag Config} listen @var{url}
-In @acronym{LMTP} mode, listen on @var{url}. Valid @acronym{URL}s are:
+In @acronym{LMTP} mode, listen on @var{url}.  Valid @acronym{URL}s are:
 @samp{tcp://@var{host}:@var{port}} (note that port is mandatory),
 @samp{file://@var{socket-file-name}} or
 @samp{socket://@var{socket-file-name}}.
 @end deffn
 
 @deffn {Maidag Config} reuse-address @var{bool}
-Reuse existing address (@acronym{LMTP} mode). Default is @samp{yes}.
+Reuse existing address (@acronym{LMTP} mode).  Default is @samp{yes}.
 @end deffn
 
 @page
@@ -5912,16 +6145,16 @@ Reuse existing address (@acronym{LMTP} mode). Default is @samp{yes}.
 to autodetect its type and invoke an appropriate file viewer.
 
   To detect the file type, @command{mimeview} uses @file{mime.types}
-file. This file is a part of Common UNIX Printing System,
-@ref{mime.types,,,mime.types(5), mime.types man page}. By default
+file.  This file is a part of Common UNIX Printing System,
+@ref{mime.types,,,mime.types(5), mime.types man page}.  By default
 @command{mimeview} searches for @file{mime.types} in
 @file{$prefix/etc/cups/}@footnote{The exact location is determined at
 configuration time by setting environment variable
-@env{DEFAULT_CUPS_CONFDIR}. On most sites running 
+@env{DEFAULT_CUPS_CONFDIR}.  On most sites running 
 
-@smallexample
+@example
 ./configure DEFAULT_CUPS_CONFDIR=/etc/cups
-@end smallexample
+@end example
 
 @noindent
 should be recommended.}, however its exact location can be specified
@@ -5929,18 +6162,18 @@ at runtime as well (see @option{--mimetypes} below).
 
   Once file MIME type is successfully determined, @command{mimeview}
 consults @file{mailcap} files in order to determine how to display
-the file. It does so essentially in the same manner as
+the file.  It does so essentially in the same manner as
 @command{metamail} utility, i.e., it scans all files specified
 in @code{METAMAIL} environment variable until it finds an entry
 describing the desired file format or until the list of files is
-exhausted. If @code{METAMAIL} variable is not set, @command{mimeview}
+exhausted.  If @code{METAMAIL} variable is not set, @command{mimeview}
 uses the following default path instead:
 
-@smallexample
+@example
 $HOME/.mailcap:/usr/local/etc/mailcap:\
  /usr/etc/mailcap:/etc/mailcap:\
  /etc/mail/mailcap:/usr/public/lib/mailcap
-@end smallexample
+@end example
 
 @menu
 * Mimeview Invocation::
@@ -5956,16 +6189,16 @@ $HOME/.mailcap:/usr/local/etc/mailcap:\
 @item -a[@var{type-list}]
 @itemx --no-ask[=@var{type-list}]
 By default @command{mimeview} asks for confirmation before running
-interpreter to view a message. If this option is used without
+interpreter to view a message.  If this option is used without
 argument, it disables the default behavior for all message
-types. Otherwise, if argument @var{type-list} is given, it specifies
+types.  Otherwise, if argument @var{type-list} is given, it specifies
 a comma-separated list of MIME types for which no questions should be
-asked. Elements of this list may include shell-style globbing
+asked.  Elements of this list may include shell-style globbing
 patterns, e.g. setting
 
-@smallexample
+@example
 --no-ask='text/*,image/jpeg'
-@end smallexample
+@end example
 
 @noindent
 will disable prompting before displaying any textual files, no
@@ -5974,14 +6207,14 @@ type @samp{image/jpeg}.
 
   Notice, that when the long form is used, its argument
 must be separated from the option by a single equal sign, as shown
-in the example above. When the short form (@option{-a}) is used, its argument
+in the example above.  When the short form (@option{-a}) is used, its argument
 must follow the option immediately, without any intervening whitespace,
-e.g. @option{-a'text/*'}). 
+e.g.  @option{-a'text/*'}). 
 
 @item -d[@var{flags}]
 @itemx --debug[=@var{flags}]
-Enables debugging output. @var{Flags} is a sequence of characters
-specifying the desired debugging level. Following characters are
+Enables debugging output.  @var{Flags} is a sequence of characters
+specifying the desired debugging level.  Following characters are
 meaningful in @var{flags}:
 
 @table @asis
@@ -6011,17 +6244,17 @@ If @var{flags} are not given, the default @samp{9} is assumed.
 
 @item --metamail[=@var{file}]
 Run @command{metamail} to display files, instead of using the internal
-mechanisms. If @var{file} is specified, it is taken as
+mechanisms.  If @var{file} is specified, it is taken as
 @command{metamail} command line.
 
 @item -h
 @itemx --no-interactive
 @itemx --print
 This options tells @command{mimeview} that it should run in
-non-interactive mode. In this mode prompting is disabled, and
-the normal mailcap @code{command} field is not executed. Instead
+non-interactive mode.  In this mode prompting is disabled, and
+the normal mailcap @code{command} field is not executed.  Instead
 @command{mimeview} will execute the command specified in
-the @code{print} field. If there is nothing in the print field,
+the @code{print} field.  If there is nothing in the print field,
 the mailcap entry is ignored and the search continues for a matching
 mailcap entry that does have a @code{print} field.
 
@@ -6038,12 +6271,12 @@ a @asis{tty} device.
 
 @item -n
 @itemx --dry-run
-Do not do anything, just print what would be done. Implies
+Do not do anything, just print what would be done.  Implies
 @option{--debug=1}, unless the debugging level is set up explicitly.
 
 @item -t @var{file}
 @itemx --mimetypes @var{file}
-Use @var{file} as @file{mime.types} file. If @var{file} is a
+Use @var{file} as @file{mime.types} file.  If @var{file} is a
 directory, use @file{@var{file}/mime.types}
 @end table
 
@@ -6059,7 +6292,7 @@ The following configuration statements affect the behavior of
 @end multitable
 
 @deffn {Mimeview Config} debug @var{number}
-Set @command{mimeview} debug level. @xref{Mimeview Invocation,
+Set @command{mimeview} debug level.  @xref{Mimeview Invocation,
 --debug}, for a description of debug levels.
 @end deffn
 
@@ -6075,6 +6308,7 @@ Use @var{program} to display files.
 @node pop3d
 @section POP3 Daemon
 @pindex pop3d
+@UNREVISED
 
 The @command{pop3d} daemon implements the Post Office Protocol
 Version 3 server.
@@ -6085,9 +6319,9 @@ Version 3 server.
 @item Inetd
 The server is started from @file{/etc/inetd.conf} file:
 
-@smallexample
+@example
 pop3  stream tcp nowait  root  /usr/local/sbin/pop3d pop3d
-@end smallexample
+@end example
 
 This is the default operation mode.
 
@@ -6109,60 +6343,57 @@ The server operation mode is configured using @code{mode} statement
 @node Login delay
 @subsection Login delay
 
-  POP3 clients often login frequently to check for new mail. Each new
+  POP3 clients often login frequently to check for new mail.  Each new
 connection implies authenticating the user and opening his maildrop
-and can be very resource consuming. To reduce server load, it is
+and can be very resource consuming.  To reduce server load, it is
 possible to impose a minimum delay between any two consecutive logins.
 This is called @samp{LOGIN-DELAY} capability and is described in RFC
 2449.
 
   As of version @value{VERSION}, GNU Mailutils @command{pop3d} allows
 to set global login delay, i.e. such enforcement will affect all POP3
-users. If a user attempts to log in before the specified login delay
+users.  If a user attempts to log in before the specified login delay
 expires, he will get the following error message:
 
-@smallexample
+@example
 -ERR [LOGIN-DELAY] Attempt to log in within the minimum login delay interval
-@end smallexample
+@end example
 
-The message will be issued after a valid password is entered. This prevents
+The message will be issued after a valid password is entered.  This prevents
 this feature from being used by malicious clients for account
 harvesting.
 
   To enable the login delay capability, specify the minimum delay
 using @code{login-delay} configuration statement, e.g.:
 
-@smallexample
+@example
 login-delay 60;
-@end smallexample
+@end example
 
   The @command{pop3d} utility keeps each user's last login time in a
 special DBM file, called @dfn{login statistics database}, so to be
 able to use this feature, Mailutils must be compiled with DBM support.
 By default, the login statistics database is called
-@file{/var/run/pop3-login.db}. You can change its name using
+@file{/var/run/pop3-login.db}.  You can change its name using
 @code{stat-file} configuration statement:
 
-@smallexample
+@example
 login-delay 60;
-stat-file /tmp/pop.login;
-@end smallexample
-
-  Notice, that there is no need to include the @samp{.db} suffix in the
-file name.
+stat-file /tmp/pop.login.db;
+@end example
 
   The login delay facility will be enabled only if @command{pop3d} is
 able to access the statistics database for both reading and
-writing. If it is not, it will report this using @command{syslog} and
-start up without login delay restrictions. A common error message
+writing.  If it is not, it will report this using @command{syslog} and
+start up without login delay restrictions.  A common error message
 looks like:
 
-@smallexample
+@example
 Unable to open statistics db: Operation not permitted
-@end smallexample
+@end example
 
   You can check whether your @command{pop3d} uses login delays by
-connecting to it and issuing the @samp{CAPA} command. If login delays
+connecting to it and issuing the @samp{CAPA} command.  If login delays
 are in use, there response will contain the string @samp{LOGIN-DELAY
 @var{n}}, where @var{n} is the actual login delay value.
 
@@ -6170,7 +6401,7 @@ are in use, there response will contain the string @samp{LOGIN-DELAY
 @subsection Auto-expire
 
   Automatic expiration of messages allows you to limit the period of
-time users are permitted to keep their messages on the server. It is
+time users are permitted to keep their messages on the server.  It is
 enabled by @code{expire} configuration statement:
 
 @table @code
@@ -6178,16 +6409,16 @@ enabled by @code{expire} configuration statement:
 Enable automatic expiration of messages after @var{n} days.
 @end table
 
-  The current implementation works as follows. When a message is
+  The current implementation works as follows.  When a message is
 downloaded by @code{RETR} or @code{TOP} command, it is marked with
 @samp{X-Expire-Timestamp: @var{n}} header, where @var{n} is current
-value of UNIX timestamp. The exact expiration mechanism 
-depends on you. Mailutils allows you two options:
+value of UNIX timestamp.  The exact expiration mechanism 
+depends on you.  Mailutils allows you two options:
 
 @enumerate
 @item
 Expired messages are deleted by @command{pop3d} upon closing the
-mailbox. You specify this mechanism using @code{delete-expired}
+mailbox.  You specify this mechanism using @code{delete-expired}
 configuration statement:
 
 @table @command
@@ -6197,12 +6428,12 @@ the @code{QUIT} command.
 @end table
 
 @item
-Expired messages remain in the mailbox after closing it. The system
+Expired messages remain in the mailbox after closing it.  The system
 administrator is supposed to run a cron job that purges the mailboxes.
 Such a cron job can be easily implemented using @command{sieve} from
 GNU Mailutils and the following script:
 
-@smallexample
+@example
 @group
 require "timestamp";
 # @r{Replace "5" with the desired expiration period}
@@ -6211,33 +6442,33 @@ if timestamp :before "X-Expire-Timestamp" "now - 5 days"
     discard;
   @}
 @end group
-@end smallexample
+@end example
 
 This script will remove expired messages 5 days after the
-retrieval. Replace @samp{5} with the desired expiration period and
+retrieval.  Replace @samp{5} with the desired expiration period and
 make sure it equals the argument to @command{expire} configuration keyword.
 @end enumerate
 
 The statement @code{expire 0} means the client is not permitted to
-leave mail on the server. It always implies @code{delete-expired true}. 
+leave mail on the server.  It always implies @code{delete-expired true}. 
 
 @node Bulletins
 @subsection Bulletins
 
   The bulletin feature allows you to send important announcements to
-all POP3 users without mailing them. It works by creating a
+all POP3 users without mailing them.  It works by creating a
 @dfn{bulletin source mailbox} and sending the announcements to it.
 
   After a user successfully authenticates, @command{pop3d} checks the
-last @dfn{bulletin number} the user receives. The bulletin number
+last @dfn{bulletin number} the user receives.  The bulletin number
 refers to the number of the bulletin message in the bulletin source
-mailbox. If the latter contains more messages, these are appended to
+mailbox.  If the latter contains more messages, these are appended to
 the user mailbox.
 
-  The user last bulletin number can be kept in two places. First, it
-can be stored in file @file{.popbull} in his home directory. Secondly,
+  The user last bulletin number can be kept in two places.  First, it
+can be stored in file @file{.popbull} in his home directory.  Secondly,
 if Mailutils is compiled with DBM support, the numbers can be kept in
-a DBM file, supplied via @code{bulletin-db} configuration statement. If
+a DBM file, supplied via @code{bulletin-db} configuration statement.  If
 both the database and the @file{.popbull} file are present, the data
 from the database take precedence.
 
@@ -6249,7 +6480,6 @@ Set the @acronym{URL} of the bulletin source mailbox.
 
 @item bulletin-db @var{file}
 Set the name of the database file to keep last bulletin numbers in.
-Be sure not to specify @samp{.db} extension.
 @end table
 
   The following example instructs @command{pop3d} to look for the
@@ -6257,12 +6487,12 @@ bulletin messages in @acronym{MH} folder @file{/var/spool/bull/mbox}
 and to keep the database of last delivered bulletin numbers in
 @file{/var/spool/bull/numbers.db}:
 
-@smallexample
+@example
 @group
 bulletin-source mh:/var/spool/bull/mbox;
-bulletin-db /var/spool/bull/numbers;
+bulletin-db /var/spool/bull/numbers.db;
 @end group
-@end smallexample
+@end example
 
 @node Conf-pop3d
 @subsection Pop3d Configuration
@@ -6294,11 +6524,11 @@ On startup, clear deletion marks from all the messages.
 
 @deffn {Pop3d Conf} expire @var{n}
 Automatically expire read messages after @var{n}
-days. @xref{Auto-expire}, for a detailed description.
+days.  @xref{Auto-expire}, for a detailed description.
 @end deffn
 
 @deffn {Pop3d Conf} delete-expired @var{bool}
-Delete expired messages upon closing the mailbox. @xref{Auto-expire},
+Delete expired messages upon closing the mailbox.  @xref{Auto-expire},
 for a detailed description.
 @end deffn
 
@@ -6314,16 +6544,16 @@ Set the minimal allowed delay between two successive logins.
 
 @deffn {Pop3d Conf} stat-file @var{file}
 Set the name of login statistics file for the @code{login-delay}
-facility. @xref{Login delay}, for more information.
+facility.  @xref{Login delay}, for more information.
 @end deffn
 
 @deffn {Pop3d Conf} bulletin-source @var{file}
-Get bulletins from the specified mailbox. @xref{Bulletins}, for a
+Get bulletins from the specified mailbox.  @xref{Bulletins}, for a
 detailed description.
 @end deffn
 
 @deffn {Pop3d Conf} bulletin-db @var{file}
-Set bulletin database file name. @xref{Bulletins}, for a
+Set bulletin database file name.  @xref{Bulletins}, for a
 detailed description.
 @end deffn
 
@@ -6335,8 +6565,8 @@ The following table summarizes all @command{pop3d} command line options.
 @table @option
 @item -d[@var{number}]
 @itemx --daemon[=@var{number}]
-Run in standalone mode. An optional @var{number} specifies the maximum number
-of child processes allowed to run simultaneously. When it is omitted,
+Run in standalone mode.  An optional @var{number} specifies the maximum number
+of child processes allowed to run simultaneously.  When it is omitted,
 it defaults to 10 processes.
 @emph{Please note}, that there should be no whitespace between the
 @option{-d} and its parameter.
@@ -6353,7 +6583,7 @@ Display short help message and exit.
 Remain in foreground.
 
 @item --tls[=@var{bool}]
-Enable TLS. If optional argument is supplied and is @samp{false}, then
+Enable TLS.  If optional argument is supplied and is @samp{false}, then
 disable it.
 
 @item --debug-auth
@@ -6364,9 +6594,10 @@ Enable debugging of authentication functions.
 @node imap4d
 @section IMAP4 Daemon
 @pindex imap4d
+@UNREVISED
 
 GNU @command{imap4d} is a daemon implementing @sc{imap4} rev1 protocol
-for accessing and handling electronic mail messages on a server. It can
+for accessing and handling electronic mail messages on a server.  It can
 be run either as a standalone program or from @file{inetd.conf} file.
 
 @menu
@@ -6381,8 +6612,8 @@ be run either as a standalone program or from @file{inetd.conf} file.
 @cindex IMAP4 namespace
 
 GNU @command{imap4d} supports a notion of @dfn{namespaces} defined
-in RFC 2342. A namespace is a set of directories upon which the user
-has certain permissions. It should be understood that these permissions
+in RFC 2342.  A namespace is a set of directories upon which the user
+has certain permissions.  It should be understood that these permissions
 apply only if the underlying filesystem allows them.
 
 The three namespaces supported by @command{imap4d} are:
@@ -6390,12 +6621,12 @@ The three namespaces supported by @command{imap4d} are:
 @table @asis
 @item Personal Namespace
 A namespace that is within the personal scope of the authenticated user
-on a particular connection. The user has all permissions on this namespace.
+on a particular connection.  The user has all permissions on this namespace.
 
 @item Other Users' Namespace
 A namespace that consists of mailboxes from the ``Personal Namespaces''
-of other users. The user can read and list mailboxes from this
-namespace. However, he is not allowed to use @samp{%} and @samp{*}
+of other users.  The user can read and list mailboxes from this
+namespace.  However, he is not allowed to use @samp{%} and @samp{*}
 wildcards with @command{LIST} command, that is he can access a
 mailbox only if he knows exactly its location.
 
@@ -6437,9 +6668,9 @@ Set other users' namespace.
 For both statements, the argument is a list of directories that belong
 to this namespace, e.g.:
 
-@smallexample
+@example
 shared-namespace (/var/spool/mail,/var/mail);
-@end smallexample
+@end example
 
 If during the session the user creates a mailbox within either of
 these namespaces, the mode of the mailbox is determined by the
@@ -6454,21 +6685,21 @@ Set file mode for mailboxes created in other users' namespace.
 @end table
 
 In both cases, the argument, @var{mode} is a list of symbolic mode
-settings, similar to that used by @command{chmod}. It is a list of
-comma-separated mode change commands. Each command begins with a
+settings, similar to that used by @command{chmod}.  It is a list of
+comma-separated mode change commands.  Each command begins with a
 letter @samp{g}, which means set mode bits for file group, or
 @samp{o}, which means set mode bits for other users (note, that there
 is no @samp{u} specifier, since user ownership of his mailbox cannot
-be changed). This letter is followed by an @samp{=} (or @samp{+}), and
-a list of modes to be set. This list can contain only two letters:
+be changed).  This letter is followed by an @samp{=} (or @samp{+}), and
+a list of modes to be set.  This list can contain only two letters:
 @samp{r} to set read permission, and @samp{w} to set write permission.
 
 For example, the following statement sets read and write permissions
 for the group:
 
-@smallexample
+@example
 shared-namespace-mode g=rw;
-@end smallexample
+@end example
 
 @node Conf-imap4d
 @subsection Configuration of @command{imap4d}.
@@ -6495,13 +6726,13 @@ configuration statements:
 @end multitable
 
 @deffn {Imap4d Conf} shared-namespace @var{list}
-Set shared namespace. @var{List} is a list of
-strings. @xref{Namespace}, for a detailed description.
+Set shared namespace.  @var{List} is a list of
+strings.  @xref{Namespace}, for a detailed description.
 @end deffn
 
 @deffn {Imap4d Conf} other-namespace @var{list}
-Set other users' namespace. @var{List} is a list of
-strings. @xref{Namespace}, for a detailed description.
+Set other users' namespace.  @var{List} is a list of
+strings.  @xref{Namespace}, for a detailed description.
 @end deffn
 
 @deffn {Imap4d Conf} shared-mailbox-mode @var{str}
@@ -6519,11 +6750,11 @@ Disable @code{LOGIN} command, if @var{bool} is @samp{true}.
 @end deffn
 
 @deffn {Imap4d Conf} create-home-dir @var{bool}
-Create nonexistent user home directories. See also home-dir-mode, below.
+Create nonexistent user home directories.  See also home-dir-mode, below.
 @end deffn
 
 @deffn {Imap4d Conf} home-dir-mode @var{mode}
-Set file mode for created user home directories. Mode is specified in
+Set file mode for created user home directories.  Mode is specified in
 octal.
 
 The default value for @var{mode} is @samp{700} (@samp{drwx------} in
@@ -6536,12 +6767,12 @@ authentication phase.
 @end deffn
 
 @deffn {Imap4d Conf} preauth @var{mode}
-Configure PREAUTH mode. Valid arguments are:
+Configure PREAUTH mode.  Valid arguments are:
 
 @table @asis
 @item prog:///@var{program-name}
 @command{Imap4d} invokes an external program to authenticate the
-connection. The command line is obtained from the supplied string,
+connection.  The command line is obtained from the supplied string,
 by expanding the following meta-variables:
 
 @table @code
@@ -6566,26 +6797,26 @@ Otherwise, it should exit with a non-zero exit code.
 
 @item ident[://:@var{port}]
 The remote machine is asked about the requester identity
-using the identification protocol (RFC 1413). Both plaintext and
-DES encrypted replies are understood. Optional @var{port} specifies
-the port to use, if it differs from the default @samp{113}. It can be
+using the identification protocol (RFC 1413).  Both plaintext and
+DES encrypted replies are understood.  Optional @var{port} specifies
+the port to use, if it differs from the default @samp{113}.  It can be
 either a decimal port number or a symbolic name of a service, listed
 in @file{/etc/services}.
 
 @item stdio
 PREAUTH mode is enabled automatically if imap4d is started
 from command line in interactive mode (@option{-i} command line
-option). The current login name is used as the user name.
+option).  The current login name is used as the user name.
 @end table
 @end deffn
 
 @deffn {Imap4d Conf} preauth-only @var{bool}
-If @var{bool} is @samp{true}, use only preauth mode. If unable to
+If @var{bool} is @samp{true}, use only preauth mode.  If unable to
 setup it, disconnect immediately.
 @end deffn
 
 @deffn {Imap4d Conf} ident-keyfile @var{file}
-Set DES keyfile for decoding encrypted ident responses. Used with
+Set DES keyfile for decoding encrypted ident responses.  Used with
 @samp{ident://} preauth mode.
 @end deffn
 
@@ -6636,24 +6867,24 @@ List of environment variables with their values.
 @subsection Starting @command{imap4d}
 
 @command{imap4d} may run either in @dfn{standalone} or in @dfn{inetd}
-operation modes. When run in ``standalone'' mode, the server disconnects
+operation modes.  When run in ``standalone'' mode, the server disconnects
 from the terminal and runs as a daemon, forking a child for each new
 connection.
 
 The ``inetd'' mode allows to start the server from
-@file{/etc/inetd.conf} file. This is the default operation mode. 
+@file{/etc/inetd.conf} file.  This is the default operation mode. 
 
-@smallexample
+@example
 imap4  stream tcp nowait  root  /usr/local/sbin/imap4d imap4d
-@end smallexample
+@end example
 
 @subheading Command Line Options
 
 @table @option
 @item -d[@var{number}]
 @itemx --daemon[=@var{number}]
-Run in standalone mode. An optional @var{number} specifies the maximum number
-of child processes the daemon is allowed to fork. When it is omitted,
+Run in standalone mode.  An optional @var{number} specifies the maximum number
+of child processes the daemon is allowed to fork.  When it is omitted,
 it defaults to 20 processes.
 @emph{Please note}, that there should be no whitespace between the
 @option{-d} and its parameter.
@@ -6686,9 +6917,10 @@ Display program version and exit.
 @node comsatd
 @section Comsat Daemon
 @pindex comsatd
+@UNREVISED
 
 Comsatd is the server which receives reports of incoming mail and
-notifies users, wishing to get this service. It can be started
+notifies users, wishing to get this service.  It can be started
 either from @file{inetd.conf} or as a standalone daemon.
 
 @menu
@@ -6707,14 +6939,14 @@ either from @file{inetd.conf} or as a standalone daemon.
 @item -C @var{file}
 @itemx --convert-config=@var{file}
 Convert the configuration file @var{file} to the new
-format. @var{File} must be a @command{comsatd} configuration file in
-Mailutils v. 1.x format. The converted file is printed on the standard
-output. For example, the following command can be used to convert old
+format.  @var{File} must be a @command{comsatd} configuration file in
+Mailutils v. 1.x format.  The converted file is printed on the standard
+output.  For example, the following command can be used to convert old
 @command{comsatd} configuration file to new format:
 
-@smallexample
+@example
 $ comsatd --convert-config=/etc/comsatd.conf > /etc/mailutils.d/comsatd
-@end smallexample
+@end example
 
 @item -d
 @itemx --daemon
@@ -6724,22 +6956,22 @@ Run as a standalone daemon.
 @itemx --inetd
 The server is started from @file{/etc/inetd.conf} file:
 
-@smallexample
+@example
 comsat dgram  udp wait  root  /usr/sbin/comsatd \
 comsatd -c /etc/comsat.conf
-@end smallexample
+@end example
 
 This is the default operation mode.
 
 @item -t
 @itemx --test
-Test mode. In this mode, @command{comsatd} takes two arguments:
+Test mode.  In this mode, @command{comsatd} takes two arguments:
 @acronym{URL} of a mailbox and @acronym{QID} of the message from that
 mailbox, e.g.:
 
-@smallexample
+@example
 $ comsatd --test /var/mail/root 34589
-@end smallexample
+@end example
 
 @end table
 
@@ -6773,7 +7005,7 @@ Set maximum number of message body lines to be output.
 @end deffn
 
 @deffn {Comsatd Conf} allow-biffrc @var{bool}
-Enable or disable processing of user's @file{.biffrc} file. By default,
+Enable or disable processing of user's @file{.biffrc} file.  By default,
 it is enabled.
 @end deffn
 
@@ -6797,7 +7029,7 @@ Set initial amount of time to sleep, after the first overflow occurs.
 @end deffn
 
 @deffn {Comsatd Conf} overflow-control-interval @var{duration}
-Set overflow control interval. If two consecutive overflows happen
+Set overflow control interval.  If two consecutive overflows happen
 within that interval, the overflow-delay-time is doubled.
 @end deffn
 
@@ -6806,18 +7038,18 @@ within that interval, the overflow-delay-time is doubled.
 
 By default, when a notification arrives, @command{comsatd} prints subject,
 from headers and the first five lines from the new message to the user's
-tty. The user is allowed to change this behavior by using his own
-configuration file. This file should be located in the user's home
-directory and should be named @file{.biffrc}. It must be owned by the
+tty.  The user is allowed to change this behavior by using his own
+configuration file.  This file should be located in the user's home
+directory and should be named @file{.biffrc}.  It must be owned by the
 user and have its permissions bits set to 0600. (@emph{Please note},
 that the use of per-user configuration files may be disabled, by
 specifying @samp{allow-biffrc no} in the main configuration file, see
 @pxref{Configuring comsatd}).
 
-The @file{.biffrc} file consists of a series of statements. Each
+The @file{.biffrc} file consists of a series of statements.  Each
 statement occupies one line and defines an action to be taken upon
-arrival of a new mail. Very long lines may be split using @samp{\} as
-the last character on the line. As usual, comments may be introduced with
+arrival of a new mail.  Very long lines may be split using @samp{\} as
+the last character on the line.  As usual, comments may be introduced with
 @samp{#} character.
 
 The actions specified in @file{.biffrc} file are executed in turn.
@@ -6827,20 +7059,20 @@ The following actions are defined:
 @item beep
 Produce an audible signal.
 @item echo [-n] @var{string} [@var{string}...]
-Output the arguments to the user's terminal device. If several
+Output the arguments to the user's terminal device.  If several
 arguments are given they will be output separated by single
-spaces. The newline character will be printed at the end of the
+spaces.  The newline character will be printed at the end of the
 output, unless the @option{-n} option is used.
 @item exec @var{prog} @var{arglist}
-Execute program @var{prog} with arguments from @var{arglist}. @var{prog}
-must be specified with absolute pathname. It may not be a setuid or
+Execute program @var{prog} with arguments from @var{arglist}.  @var{prog}
+must be specified with absolute pathname.  It may not be a setuid or
 setgid program.
 @end table
 
 In the description above, @var{string} denotes any sequence of
-characters. This sequence must be enclosed in a pair of double-quotes,
-if it contains whitespace characters. The @samp{\} character inside a
-string starts a C escape sequence. Following meta-characters may be
+characters.  This sequence must be enclosed in a pair of double-quotes,
+if it contains whitespace characters.  The @samp{\} character inside a
+string starts a C escape sequence.  Following meta-characters may be
 used in strings:
 
 @table @asis
@@ -6851,15 +7083,15 @@ Expands to hostname
 @item $H@{name@}
 Expands to value of message header @samp{name}.
 @item $B(@var{c},@var{l})
-Expands to message body. @var{c} and @var{l} give maximum number of
-characters and lines in the expansion. When omitted, they default to 400, 5.
+Expands to message body.  @var{c} and @var{l} give maximum number of
+characters and lines in the expansion.  When omitted, they default to 400, 5.
 @end table
 
 @subsubheading Example I
 
 Dump to the user's terminal the contents of @samp{From} and
 @samp{Subject} headers followed by at most 5 lines of message body.
-@smallexample
+@example
 @group
 echo "Mail to \a$u@@$h\a\n---\n\
 From: $H@{from@}\n\
@@ -6868,11 +7100,11 @@ Subject: $H@{Subject@}\n\
 $B(,5)\
 ---\n"
 @end group
-@end smallexample
+@end example
 
 @noindent
 The above example can also be written as:
-@smallexample
+@example
 @group
 echo Mail to \a$u@@$h\a
 echo ---
@@ -6882,14 +7114,14 @@ echo ---
 echo $B(,5)
 echo ---
 @end group
-@end smallexample
+@end example
 
 @subsubheading Example II
 
 Produce a bell, then pop up the xmessage window on display :0.0 with
 the text formatted in the same manner as in the previous example.
 
-@smallexample
+@example
 @group
 beep
 exec /usr/X11R6/bin/xmessage \
@@ -6900,274 +7132,1085 @@ Subject: $H@{Subject@}\n\
 $B(,5)\
 ---\n"
 @end group
-@end smallexample
+@end example
 
 @page
 @node mh
-@section @acronym{MH} --- The MH Message Handling System
+@section MH --- The MH Message Handling System
+@UNREVISED
 
 @include mu-mh.texi
 
 @page
-@node mailutils-config
-@section @command{mailutils-config} --- Get the Information about the Mailutils Build
-@pindex mailutils-config
-
-This program is designed for developers wishing to link their programs
-against libmailutils. It allows to examine the particulars of the
-current build of Mailutils and to get the command line parameters
-necessary for compiling and linking an application with Mailutils
-libraries.
+@node mu
+@section MU
+@pindex mu
+The @command{mu} utility is a multi-purpose tool shipped with
+Mailutils.  It can be used for various mail- and database-related
+tasks, as well as an auxiliary tool for compiling and linking programs
+with Mailutils. 
 
 @menu
-* Compiler Flags::      Getting Compiler Flags.
-* Loader Flags::        Getting Loader Flags.
-* General Information:: Obtaining General Build Information.
+* mu invocation syntax::
+* mu help::
+* mu info::
+* mu cflags::
+* mu ldflags::
+* mu query::
+* mu 2047::
+* mu filter::
+* mu acl::
+* mu wicket::
+* mu dbm::
+* mu logger::
+* mu pop::
+* mu imap::
 @end menu
 
-@node Compiler Flags
-@subheading Getting Compiler Flags
+@node mu invocation syntax
+@subsection Invocation Syntax
+@command{Mu} is a command line tool.  Its invocation syntax is:
 
-When invoked with the option @option{--compile}, or its short form
-@option{-c}, @command{mailutils-config} prints the flags
-that must be given to the compiler for compiling the program using
-Mailutils functions. An example usage:
+@example
+mu [@var{options}] @var{command} [@var{args}]
+@end example
 
-@smallexample
-cc -omyprog.o `mailutils-config --compile` myprog.c
-@end smallexample               
-
-@node Loader Flags
-@subheading Getting Loader Flags
+where @var{options} are options that affect the behavior of
+@command{mu} as a whole, @var{command} instructs it what it is to do
+and @var{args} are any arguments the @var{command} needs in order to be
+executed. 
 
-The @option{--link}, or its short form @option{-l} prints to the
-standard output the loader flags necessary to link a program against
-Mailutils libraries.
+The commands are:
 
-When invoked without arguments, it produces the flags necessary to
-link against the basic library of Mailutils: @file{libmailutils}.
-Arguments may be given that alter this behavior. These are:
+@table @asis
+@item 2047
+Decodes or encodes email message headers.
+@item acl
+Tests Mailutils access control lists.
+@item cflags
+Shows compiler options needed to compile with Mailutils.
+@item dbm
+Invokes a DBM management tool.
+@item ;filter
+Applies a chain of filters to the input.
+@item help
+Displays a terse help summary.
+@item imap
+Invokes an IMAP4 client shell (in development).
+@item info
+Displays information about Mailutils compile-time configuration.
+@item ldflags
+Constructs a @command{ld}(1) command line for linking a program with Mailutils.
+@item logger
+Logs information using Mailutils log facility.
+@item pop
+Invokes a POP3 client shell.
+@item query
+Queries configuration values.
+@item wicket
+Scans wicket for matching URLs
+@end table
 
-@table @samp
+@node mu help
+@subsection mu help
+The @command{mu help} command lists all available options and command
+names along with short descriptions of what each of them does.  It is
+similar to the @command{mu --help} option. 
+
+A command name can be supplied as an argument to
+@command{help}, in which case it will display a help page for that
+particular command, e.g.: 
+
+@example
+mu help ldflags
+@end example
+
+will output help for the @command{ldflags} command.  It is synonymous
+to the @option{--help} option used with that particular command, e.g.:
+@command{mu ldflags --help}.
+
+@node mu info
+@subsection mu info
+The @command{mu info} command displays information about Mailutils
+compile-time configuration.  In normal form its output lists a single
+configuration flag per line, e.g.: 
+
+@example
+$ mu info
+VERSION=2.99.93
+SYSCONFDIR=/etc
+MAILSPOOLDIR=/var/mail/
+SCHEME=mbox
+LOG_FACILITY=mail
+IPV6
+USE_LIBPAM
+HAVE_LIBLTDL
+WITH_GDBM
+WITH_GNUTLS
+WITH_GSASL
+@end example
+
+A configuration flag can consist either of a single word, indicating
+that a particular capability has been enabled at compile time, or of a
+keyword/value pair delimited by an equal sign, which indicates a
+particular value used by default for that feature.  For example,
+@samp{IPV6} means that Mailutils was compiled with support for IPv6,
+whereas @samp{SYSCONFDIR=/etc} means that the default place for
+configuration files is in @file{/etc} directory. 
+
+Such short output is convenient for using @command{mu info} in scripts
+to decide whether it is possible to use a given feature.  To assist
+human users, the @option{--verbose} (@option{-v}) option is provided.
+It prints a short description next to each flag: 
+
+@example
+$ mu info --verbose
+VERSION=2.99.93           - Version of this package
+SYSCONFDIR=/etc           - System configuration directory
+MAILSPOOLDIR=/var/mail/   - Default mail spool directory
+SCHEME=mbox               - Default mailbox type
+LOG_FACILITY=mail         - Default syslog facility
+IPV6                      - IPv6 support
+USE_LIBPAM                - PAM support
+HAVE_LIBLTDL              - a portable `dlopen' wrapper library
+WITH_GDBM                 - GNU DBM
+WITH_GNUTLS               - TLS support using GNU TLS
+WITH_GSASL                - SASL support using GNU SASL
+@end example
+
+@node mu cflags
+@subsection mu cflags
+The @command{mu cflags} command shows compiler options needed to
+compile a C source with Mailutils.  It is intended for use in
+configuration scripts and Makefiles, e.g.:
+
+@example
+CFLAGS=-g -O2 `mu cflags`
+@end example
+
+@node mu ldflags
+@subsection mu ldflags
+The @command{mu ldflags} command is a counterpart of @command{cflags}
+which is used for linking.  It constructs a @command{ld} command line
+for linking a program with Mailutils.
+
+When used without arguments, it outputs @command{ld} arguments which
+would link only with the core Mailutils library @file{libmailutils}, e.g.: 
+
+@example
+$ mu ldflags
+-L/usr/local/lib -lmailutils 
+@end example
+
+This command accepts a number of keywords which allow to select a
+particular subset of Mailutils libraries to link with.  In particular,
+the argument @samp{all} instructs it to link in all available libraries: 
+
+@example
+$ mu ldflags all
+-L/usr/local/lib -lmu_mbox -lmu_mh -lmu_maildir -lmu_imap -lmu_pop \
+-lmu_mailer -lmu_compat -lmailutils -lmu_auth -lgsasl -lgnutls -lgcrypt \
+-lldap -lgnuradius -lpam -ldl 
+@end example
+
+Other available keywords are:
 
+@table @asis
+@item mbox
+Link in the UNIX mbox format support.
+@item mh
+Link in the MH format support.
+@item maildir
+Link in the Maildir format support.
+@item imap
+Link in the IMAP protocol support.
+@item pop
+Link in the POP protocol support.
+@item nntp
+Link in the NNTP protocol support.
+@item mailer
+Enable support for mailers.
+@item sieve
+Link in the support for Sieve mail filtering language.
+@item dbm
+Link in the support for DBM databases (libmu_dbm library).
+@item compat
+Provide a compatibility layer for Mailutils 2.x.
 @item auth
-Print flags to link against @file{libmu_auth}, the library adding new
-authentication methods to @file{libmailutils}.
-
+Link in the Mailutils authentication library.
 @item guile
-Print flags to link against @file{libmu_scm}, the Guile interface
-library.
+Provide Guile language bindings.
+@item python
+Provide Python language bindings.
+@item cfg
+Link in the Mailutils configuration library.
+@item argp
+Link in the library for command line parsing.
+@end table
 
-@item mbox
-Link against @code{mbox} format library.
+@node mu query
+@subsection mu query
+The @command{mu query} command queries values from Mailutils
+configuration files.  It takes one or more configuration paths
+(@pxref{Paths}) as its arguments.  On output, it displays the values
+it found, each value on a separate line.  If the requested value is a
+block statement it is displayed in full.  For example, if main
+configuration file contained:
 
-@item mh
-Link against @code{mh} format library.
+@example
+logging @{
+   syslog yes;
+   facility mail;
+@}
+@end example
 
-@item maildir
-Link against @code{maildir} format library.
+Then:
 
-@item mailer
-Link against @code{mailer} library.
+@example
+$ mu query .logging.syslog
+syslog yes;
+$ mu query .logging.syslog .logging.facility
+syslog yes;
+facility mail;
+$ mu query .logging
+logging @{
+  syslog yes;
+  facility mail;
+@};
+@end example
 
-@item imap
-Link against @code{imap} format library.
+Several command line options allow to modify output format.  The
+@option{--value} option instructs the command to output only values:
 
-@item pop
-Link against @code{pop} format library.
+@example
+$ mu query --value .logging.syslog
+yes
+@end example
 
-@item all
-Link against all Mailutils format libraries.
-@end table
+The @option{--path} option instructs it to print full pathnames for
+each value: 
 
-The order of arguments does not matter.
+@example
+$ mu query --path .logging.syslog
+logging.syslog: yes
+@end example
 
-For example, if you wrote a program @file{myprog.c} that uses
-standard @sc{unix} mailbox format, @sc{mh} format and the
-Guile interface, then you would link it with the following
+The @option{--program} option instructs @command{mu} to behave as if
+it was called under another program name.  For example, the following
 command:
 
-@smallexample
-cc -omyprog myprog.o `mailutils-config --link mbox mh guile`
-@end smallexample
+@example
+$ mu query --program=pop3d .server.transcript
+@end example
 
-@node General Information
-@subheading Obtaining General Build Information
+will return the value of the @samp{.server.transcript} statement which
+the @command{pop3d} utility would see.
 
-The @option{--info}, or @option{-i} retrieves the options (flags) used
-when building Mailutils. It may be used with or without
-arguments.
+By default, @command{mu query} operates on the main configuration
+file.  Another configuration file can be supplied using the
+@option{--file} (@option{-f}) option:
 
-When used without arguments, it prints the list of all
-build flags, e.g.:
+@example
+$ mu query --file /usr/local/etc/file.conf .pidfile
+@end example
 
-@smallexample
-$ mailutils-config --info
-VERSION=@value{VERSION}
-SYSCONFDIR=/usr/local/etc
-MAILSPOOLDIR=/var/mail/
-SCHEME=mbox
-LOG_FACILITY=mail
-USE_LIBPAM
-HAVE_LIBLTDL
-WITH_GDBM
-WITH_GNUTLS
-WITH_GSASL
-WITH_GUILE
-WITH_PTHREAD
-WITH_READLINE
-HAVE_MYSQL
-ENABLE_VIRTUAL_DOMAINS
-ENABLE_IMAP
-ENABLE_POP
-ENABLE_MH
-ENABLE_MAILDIR
-ENABLE_SMTP
-ENABLE_SENDMAIL
-@end smallexample
-
-When this option is used in conjunction with the @option{--verbose}
-option, a short description is printed to the right of each keyword,
-e.g.:
-
-@smallexample
-$ mailutils-config --info --verbose
-VERSION=1.9.93             - Version of this package
-SYSCONFDIR=/usr/local/etc  - System configuration directory
-MAILSPOOLDIR=/var/mail/    - Default mail spool directory
-SCHEME=mbox                - Default mailbox type
-LOG_FACILITY=mail          - Default syslog facility
-USE_LIBPAM                 - PAM support
-HAVE_LIBLTDL               - a portable `dlopen' wrapper library
-WITH_GDBM                  - GNU DBM
-@dots{}
-@end smallexample
-
-This option also accepts any number of arguments. When these are
-given, each argument is treated as a name of a build flag. 
-@command{Mailutils-config} checks if such a flag was defined and
-prints its full name if so. It exits with zero code if all the
-flags given on the command line are defined. Otherwise, it
-exits with code of 1.
-
-The comparison of the flag names is case-insensitive. The arguments
-given need not include the leading prefix (i.e. the characters up
-to and including the first underscore character).
-
-Given the previous example, the invocation
-
-@smallexample
-$ mailutils --info readline use_libpam pop
-@end smallexample
+@node mu 2047
+@subsection mu 2047
+The @command{mu 2047} command is a filter for decoding or encoding
+email message headers formatted in accordance with RFC 2047 (see
+@uref{http://www.faqs.org/rfcs/rfc2047.html}.  By default, it operates
+in encode mode and assumes the @samp{iso-8859-1} encoding.  If
+arguments are supplied in the command line, they are treated as the
+text to operate upon.  Otherwise the command acts as a UNIX filter,
+reading lines from the standard input and printing results on the
+standard output.
+
+For example:
+
+@example
+$ mu 2047 'Keld J@o{}rn Simonsen <keld@@dkuug.dk>'
+=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@@dkuug.dk>
+@end example
+
+The decode mode can be requested via the @option{--decode}
+(@option{-d}) option:
+
+@example
+$ mu 2047 --decode '=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= \
+ <keld@@dkuug.dk>'
+Keld J@o{}rn Simonsen <keld@@dkuug.dk>
+@end example
+
+The @option{--charset} (@option{-c}) option changes the default
+character set.  It is meaningful both in decode and in encode modes.
+In decode mode it instructs the utility to convert the output to the
+given character set.  In encode mode it indicates the encoding of the
+input data, which will be reflected in the resulting string:
+
+@example
+$ mu 2047 --charset=utf-8 'Keld J@o{}rn Simonsen <keld@@dkuug.dk>'
+=?utf-8?Q?Keld J=C3=B8rn Simonsen <keld@@dkuug.dk>?=
+@end example
+
+The @option{--encoding} (@option{-E}) option can be used in encode
+mode to change the output encoding.  Valid arguments for this option
+are: @samp{quoted-printable} (the default) or @samp{base64}. 
+
+The @option{--newline} (@option{-n}) option prints an additional
+newline character after each line of output.
+
+@node mu filter
+@subsection mu filter
+The @command{mu filter} command applies a chain of filters to the
+input.  The filters to apply and their arguments are given  
+in the command line.  The full invocation syntax is:
+
+@example
+ mu filter [@var{option}] @var{filter-chain}
+@end example
+
+The syntax for @var{filter-chain} in Backus-Naur form follows:
+
+@example
+<filter-chain> ::= <filter> | <filter-chain> "+" <filter>
+<filter> ::= <filter-spec> <@var{ARG}>* 
+<filter-spec> ::= <@var{WORD}> | "~" <@var{WORD}>
+@end example
 
 @noindent
-will produce the following output:
+where @var{<WORD>} stands for the filter name and @var{<ARG>}
+represents filter arguments.  To obtain a list of known filter names,
+run:
 
-@smallexample
-WITH_READLINE
-USE_LIBPAM
-ENABLE_POP
-@end smallexample
+@example
+mu filter --list
+@end example
+
+Filters are applied in the order of their appearence, from left to
+right and operate in encode mode.  The plus sign has the same meaning
+as pipe in shell.  The default mode can be changed using the
+@option{--decode} (@option{-d}) and @option{--encode} (@option{-e}) options.
+Whatever the default mode is, a @samp{~} character before filter
+name reverts the mode for that filter alone. 
+
+For example, to encode the contents of file @file{file.txt} in Base64
+run:
+
+@example
+mu filter base64 < file.txt
+@end example
+
+To convert it to base64 and use CRLF as line delimiters, run:
+
+@example
+mu filter base64 + crlf < file.txt
+@end example
+
+The following command will decode the produced output:
+
+@example
+mu filter --decode crlf + base64
+@end example
+
+It can also be written as
+
+@example
+mu filter ~crlf + ~base64
+@end example
+
+The following example converts the input from ISO-8859-2 to UTF-8,
+quotes eventual @samp{From} occurring at the beginning of a line,
+encodes the result in Base64 and changes line delimiters to CRLF:
+
+@example
+mu filter iconv iso-8859-2 utf-8 + from + base64 + crlf
+@end example
+
+This final example removes UNIX-style comments from the input and
+joins continuation lines:
+
+@example
+mu filter --decode inline-comment -S '#' + linecon 
+@end example
+
+Such invocation can be useful in shell scripts to facilitate
+configuration file processing.
+
+@node mu acl
+@subsection mu acl
+The @command{mu acl} command tests Mailutils Access Control Lists.  By
+default it reads ACL from the Mailutils configiration file section
+@samp{acl}.  The command takes a list of IP addresses as its
+arguments, applies the ACL to each of them in turn and prints the result.
+
+To select the ACL to test, two options are provided.  The
+@option{--file} (@option{-f}) option supplies the name of
+configuration file to read instead of the default one.  The
+@option{--path} (@option{-p} option supplies the pathname
+(@pxref{Paths}) of the ACL section to use instead of the default @samp{.acl}.  For example, to test ACL in section @samp{server 213.130.1.232} of file @file{/etc/pop3d.conf} use:
+
+@example
+mu acl --file=/etc/pop3d.conf \
+       --path=/server="213.130.1.232"/acl @var{address}
+@end example
+
+As an example of its use, consider file @file{test.conf} with the
+following contents:
+
+@example
+acl @{
+        deny from 10.10.10.1;
+        deny from 10.10.1.0/24;
+        log from any "Connect from $@{address@}";
+        allow from 10.0.0.0/8;
+        allow from 192.168.1.0/24;
+        deny from any;
+@}
+@end example 
+
+Then, running @command{mu acl --file=test.conf 127.0.0.1} you will get:
+
+@example
+Testing 127.0.0.1:
+mu: Connect from 127.0.0.1
+127.0.0.1: deny
+@end example
+
+More examples:
+
+@example
+$ mu acl --file=test.conf 127.0.0.1 10.10.10.1 \
+         10.10.1.3 10.5.3.1 192.168.1.0 192.168.2.0
+Testing 127.0.0.1:
+mu: Connect from 127.0.0.1
+127.0.0.1: deny
+Testing 10.10.10.1:
+10.10.10.1: deny
+Testing 10.10.1.3:
+10.10.1.3: deny
+Testing 10.5.3.1:
+mu: Connect from 10.5.3.1
+10.5.3.1: accept
+Testing 192.168.1.0:
+mu: Connect from 192.168.1.0
+192.168.1.0: accept
+Testing 192.168.2.0:
+mu: Connect from 192.168.2.0
+192.168.2.0: accept
+@end example
+
+The @command{mu} option @option{--debug-level} will give you a deeper
+insight into the address matching algorithm:
+
+@example
+$ mu --debug-level=acl.trace9 acl --file test.conf 127.0.0.1
+Testing 127.0.0.1:
+mu: Checking sockaddr 127.0.0.1
+mu: 1:deny: Does 10.10.10.1/255.255.255.255 match 127.0.0.1? no; 
+mu: 2:deny: Does 10.10.1.0/255.255.255.0 match 127.0.0.1? no; 
+mu: 3:log: Does any match 127.0.0.1? yes; 
+mu: Expanding "Connect from $@{address@}";
+mu: Expansion: "Connect from 127.0.0.1";. 
+mu: Connect from 127.0.0.1
+mu: 4:accept: Does 10.0.0.0/255.0.0.0 match 127.0.0.1? no; 
+mu: 5:accept: Does 192.168.0.0/255.255.0.0 match 127.0.0.1? no; 
+mu: 6:deny: Does any match 127.0.0.1? yes; 
+127.0.0.1: deny
+@end example
+
+@xref{Debugging Categories,acl}.
+
+@node mu wicket
+@subsection mu wicket
+The @command{mu wicket} command looks up matching URLs in the
+Mailutils ticket file (by default, @file{~/.mu-tickets}) and prints
+them.  The URLs to look for are supplied in the command line.
+
+Consider the following ticket file as an example:
+
+@example
+smtp://foo:bar@@*
+smtp://bar:baz@@gnu.org
+*://baz:qux@@*
+*://quux:bar@@gnu.org
+@end example
+
+Now, running @command{mu wicket smtp://bar@@gnu.org} will show:
+
+@example
+smtp://bar@@gnu.org: /home/@var{user}/.mu-tickets:2
+@end example
+
+@noindent
+(where @var{user} is your login name).  This means that this URL
+matches the line 2 in your @file{.mu-tickets} file.  The
+@command{wicket} command does not show the actual matching line to
+avoid revealing eventual security-sensitive information.  You can
+instruct it to do so using the @option{--verbose} (@option{-v})
+option:
+
+@example
+$ mu wicket -v smtp://bar@@gnu.org
+smtp://bar@@gnu.org: /home/@var{user}/.mu-tickets:2: smtp://bar:***@@gnu.org
+@end example
+
+As you see, even in that case the tool hides the actual password part
+by replacing it with three asteriscs.  If you are working in a secure
+environment, you can tell @command{mu wicket} to show passwords as
+well, by supplying the @option{-v} option twice.
+
+A counterpart of @option{--verbose} is the @option{--quite}
+(@option{-q}) option, which instructs @command{wicket} to suppress any
+output, excepting error messages.  This can be used in scripts, which
+analyze the @command{mu wicket} exit code to alter the control flow.
+
+The @command{mu wicket} tool exits with code 0 if all URLs were
+matched and with code 1 if some of them were not matched in the ticket
+file.  If an error occurred, the code 2 is returned.
+
+@node mu dbm
+@subsection mu dbm
+The @command{mu dbm} tool manages DBM files using @file{libmu_dbm}
+The invocation syntax is:
+
+@example
+mu dbm @var{subcommand} [@var{options}] @var{file} [@var{keys}]
+@end example
+@noindent
+or
+@example
+mu dbm [@var{options}] @var{subcommand} @var{file} [@var{keys}]
+@end example
 
 @noindent
-and will exit with a zero status.
+where @var{subcommand} selects the operation mode, @var{options}
+modify the tool behavior and @var{file} specifies the DBM file to
+operate upon.  Some @var{command}s allow for optional @var{keys} to be
+specified.
+
+The @var{file} argument can be either a DBM file name or a Database URL. 
+
+@menu
+* Create a Database::
+* Add Records to a Database::
+* Delete Records::
+* List the Database::
+* Dump the Database::
+* Dump Formats::
+* Dbm Exit Codes::
+@end menu
+
+@node Create a Database
+@subsubsection Create a Database
+The @option{create} subcommand and its synonym @option{load} instruct
+the tool to create a new database: 
+
+@example
+mu dbm create file.db
+@end example
+
+If the argument file already exists, it will be truncated prior to
+adding new records to it.
+
+The data to populate the database with are read from the standard
+input.  The @command{mu dbm} command supports several formats for
+these data, which are discussed later.  In the simplest case (a so
+called @samp{format 0.0}) each input line must consist of two fields
+separated by any amount of whitespace.  The first field is treated as
+a key and the second one as the corresponding value. 
+
+The usual way to read data from a file is, of course, by redirecting
+the file to the standard input as in: 
+
+@example
+mu dbm create file.db < input.txt
+@end example
+
+There is also a special option for that purpose: @option{--file}
+(@option{-f}).  Thus, the following command is equivalent to the one
+above:
+
+@example
+mu dbm create --file input.txt file.db 
+@end example
+
+The @option{--file} option has the advantage that it allows, in
+conjunction with another options, for copying input file metadata
+(owner UID, GID and file mode) to the created database.  For example,
+the following command ensures that the created database file will have
+the same metadata as the input file: 
+
+@example
+mu dbm create --file input.txt --copy-permissions file.db
+@end example
+
+The @option{--copy-permissions} (@option{-P}) option is the one that
+does the job.
+
+There are also other ways to control mode and ownership of the created
+database, which are described below. 
+
+More advanced dump formats (e.g.  @samp{version 1.0} format) carry
+additional information about the file, including its original name,
+ownership and mode.  If input is in one of these formats, the file
+name argument becomes optional.  If it is not supplied, the name
+stored in the input stream will be used.  For example, supposing that
+the file @file{users.dump} is in format 1.0, the following command
+suffices to restore the original filename, ownership, mode and, of
+course, data:
+
+@example
+mu dbm create --file users.dump
+@end example
+
+@node Add Records to a Database
+@subsubsection Add Records to a Database
+The @option{add} subcommand adds records to a database.  Records are
+read from the standard input and must be formatted as for
+@option{create}:
+
+@example
+mu dbm add file.db
+@end example
+
+If the argument file does not exist, it will be created.  
+
+Adding a record with a key which is already present in the database
+produces an error.  To replace existing records, use the
+@option{replace} subcommand instead.   
+
+The same options that affect the behavior of @option{create} apply to
+@option{add} and @samp{replace} as well, e.g.:
+
+@example
+mu dbm replace --file input.txt --copy-permissions file.db
+@end example
+
+@node Delete Records
+@subsubsection Delete Records
+To delete records, use the @option{delete} subcommand.  It reads a
+list of keys to delete to be specified as arguments in the command
+line: 
 
-The following command:
+@example
+mu dbm delete file.db foo bar
+@end example
 
-@smallexample
-$ mailutils --info readline gssapi pop
-@end smallexample
+The command above will delete from @file{file.db} records with keys
+@samp{foo} and @samp{bar}.  
+
+It is not an error to attempt to delete a key that does not exist in
+the database, although such use will produce a warning message.
+
+By default, keys are matched literally.  It is also possible to use
+various pattern matching techniques, depending on the option
+specified. 
+
+The @option{--glob} (@option{-G}) option instructs the tool to use UNIX globbing pattern matching.  For example, the command below will delete all keys starting with @samp{foo} and ending with a decimal digit:
+
+@example
+mu dbm delete file.db 'foo*[0-9]'
+@end example
 
 @noindent
-will exit with status 1, and will print:
+(note the quoting necessary to prevent shell from interpreting the
+metacharacters itself).
+
+Another option, @option{--regex} (@option{-R}) instructs @command{mu}
+to treat supplied keys as extended regular expressions: 
+
+@example
+mu dbm delete --regex file.db 'foo.*[0-9]@{1,3@}'
+@end example
+
+Both options are affected by the @option{--ignore-case} (@option{-i})
+option, which turns on case-insensitive matching.
+
+Using pattern matching to delete records can be a risky operation as
+selecting a wrong pattern will lead to removing wrong records.  It is
+recommended to first use the list mode described below to verify that
+the patterns match the right keys.
+
+@node List the Database
+@subsubsection List the Database
+The @option{list} command lists the content of the database:
+
+@example
+mu dbm list file.db
+@end example
+
+By default, entire content is listed on the standard output.
+
+If supplied more than one command line argument, this mode treats the
+rest of arguments after the database file name as the keys to look for
+and lists only records with these keys:
+
+@example
+$ mu dbm list file.db foo bar
+foo 1
+bar 56
+@end example
+
+The @option{--glob} and @option{--regex} options instruct the tool to
+use UNIX globbing or extended regular expression matching,
+correspondingly.  These were described in detail above. 
+
+@node Dump the Database
+@subsubsection
+
+The @option{dump} subcommand dumps the database to the standard output
+in a format suitable for backup or sending over the network (a
+version 1.0 format). 
+
+@example
+mu dbm dump file.db < file.dump
+@end example
+
+The produced file is suitable for input to the @option{create} (@option{load}) command.  Among other uses, it provides an easy way to convert databases between various formats supported by Mailutils.  For example this is how to convert the database file @file{file.db} to the GDBM database @file{new.db}:
+
+@example
+mu dbm dump file.db | mu dbm create gdbm://new.db
+@end example
+
+Both @option{list} and @option{dump} subcommands share the same set of
+options.  In fact, they are pretty similar, except that use different
+defaults.  The @option{list} subcommand is designed to produce a
+human-readable output, whereas the dump subcommand is oriented towards
+backup purposes.
+
+@node Dump Formats
+@subsubsection Dump Formats
+As of version @value{VERSION}, @command{mu dbm} supports two formats
+for dumping DBM databases.  Both formats are line-oriented.  Comments
+are introduced with a sharp (@samp{#}) sign in the column 0 of a line,
+followed by at least one white space character (space or tab).  Sharp
+sign followed by a colon (@samp{#:}) introduces a @dfn{paragmatic
+comment}, which carries some additional information to the loader. 
+
+@anchor{dump version 0.0}
+The @dfn{version 0.0} format is suitable for databases whose records
+contain only ASCII data.  In this format, each record occupies a
+separate line, which consists of the key and value separated by a
+single @sc{tab} character.  Empty lines are ignored.  For example: 
+
+@example
+$ mu list /etc/mail/users.db
+root    guessme
+smith   pAssword
+qed     fooBar
+@end example
+
+The output in version 0.0 format is human readable and can be used as
+input to the popauth utility (@FIXME-pxref{popauth}.  However, version 0.0
+has serious drawbacks.  First of all, it is not suitable for databases
+that contain binary data.  Secondly, it cannot properly handle keys
+beginning with a sharp sign or containing @sc{tab}.  The version 1.0
+format is free from these drawbacks. 
+
+@anchor{dump version 1.0}
+The @dfn{version 1.0} dump format begins with a @dfn{header}
+containing important information about the file, such as its file
+name, ownership and file mode.  This information is stored in
+pragmatic comments and allows @command{mu dbm load} to easily recreate
+an exact copy of the file.  The following comments are defined:
+
+@table @asis
+@item #:version=1.0
+Indicates that the data that follow are in version 1.0 format. 
+@item #:filename=@var{s}
+Original database file name, without directory parts. 
+@item #:uid=@var{n}
+Owner UID. 
+@item #:user=@var{s}
+Owner name. 
+@item #:gid=@var{n}
+Owner GID 
+@item #:group=@var{s}
+Owner group name. 
+@item #:mode=@var{o}
+File mode in octal
+@end table
+    
+Following this header are actual data.  Each record is output in two
+parts: key and value.  Each part begins with a @samp{#:len=@var{n}}
+construct on a line by itself, where @var{n} is the length of the data
+in decimal.  This line is followed by one or more lines of the actual
+data, encoded in base64.  The data are formatted so that each line
+does not exceed 76 bytes in length (not counting the terminating
+newline).  An example of this format follows: 
+
+@example
+# Database dump file created by GNU Mailutils 2.99.93 on
+# Tue Nov  1 13:28:03 2011
+#:version=1.0
+#:file=users.db
+#:uid=0,user=root,gid=25,group=mail,mode=640
+#:len=6
+c21pdGgA
+#:len=9
+cEFzc3dvcmQA
+#:len=5
+cm9vdAA=
+#:len=8
+Z3Vlc3NtZQA=
+#:len=4
+cWVkAA==
+#:len=7
+Zm9vQmFyAA==
+@end example
+
+@node Dbm Exit Codes
+@subsubsection Dbm Exit Codes
+The table below summarizes exit codes used by @command{mu dbm}:
+
+@multitable @columnfractions 0.2 0.3 0.5
+@headitem Code  @tab Symbolic name @tab Meaning
+@item 0 @tab EX_OK @tab Successful termination
+@item 64 @tab EX_USAGE @tab Command line usage error
+@item 65 @tab EX_DATAERR @tab Error in user-supplied data: the input
+file is badly formatted, or some of the data supplied in the command
+line are invalid (e.g. user name, uid or the like), etc.
+@item 66 @tab EX_NOINPUT @tab Cannot open input file
+@item 67 @tab EX_NOUSER  @tab No such user or UID when trying to set
+output file ownership 
+@item 69 @tab EX_UNAVAILABLE @tab Operation cannot be performed due to
+some kind of problem (e.g. access to the file denied, etc.)
+@item 70 @tab EX_SOFTWARE @tab Internal software error
+@item 74 @tab EX_IOERR @tab Input/output error
+@end multitable
+
+@node mu logger
+@subsection mu logger
+The @command{mu logger} tool logs information using Mailutils log facility.  
+
+Syntax:
+
+@example
+mu logger [@var{options}] [@var{message}]
+@end example
 
-@smallexample
-WITH_READLINE
-ENABLE_POP
-@end smallexample
+The @var{message} argument, if supplied, gives the text to log.  If not supplied, the utility reads lines of text from standard input or a file (if the @option{--file} option is given) and sends them to log:
+
+@example
+# Send text to log
+$ mu logger I am here
+# Log each line from file.txt
+$ mu logger --file file.txt
+# Read stdin and log it:
+$ mu logger
+@end example
+
+The default logging channel is bound to standard error.  To bind it to
+syslog, use the @option{--syslog} command line option.  In that case
+@command{mu} uses facility @samp{user} and priority @samp{err}.  You
+can change this by using the @option{--priority} (@option{-p}) option.
+Its argument is either a syslog facility name or facility and severity
+names separated by a dot.  For example, the following invocation will use
+facility @samp{auth}, severity @samp{info}: 
+
+@example
+mu logger --priority auth.info
+@end example
+
+The syslog tag can be set using the @option{--tag} (@option{-t}) option:
+
+@example
+mu logger --tag myprog
+@end example
+
+The default tag is @samp{mu-logger}.
+
+The @option{--severity} (@option{-s}) option sets the Mailutils
+severity level.  Its argument can be any of the following:
+@samp{debug}, @samp{info}, @samp{notice}, @samp{warning},
+@samp{error}, @samp{crit}, @samp{alert}, @samp{emerg}. 
+
+Finally, the @option{--locus} (@option{-l}) option binds log messages
+to a location in a file.  Its argument has the following syntax:
+
+@example
+@var{file}:@var{line}[:@var{col}]
+@end example
 
 @noindent
-since @code{WITH_GSSAPI} flag is not defined.
+where @var{file} is the file name, @var{line} is the line number and
+optional @var{col} is the column number in that file.
+
+For example, the following invocation:
 
-The flags and their meanings are:
+@example
+mu logger --locus mailutils.rc:34 Suspicious statement
+@end example
 
+will send the following to the log:
+
+@example
+mu-logger: mailutils.rc:34: Suspicious statement
+@end example
+
+@node mu pop
+@subsection mu pop
+The @command{mu pop} command invokes an interactive POP3 client shell.
+It reads commands from the standard input, executes them and displays
+the results on the standard output.  If the standard input is
+connected to a terminal, the readline and history facilities are
+enabled (provided that Mailutils is configured with GNU Readline). 
+
+The @command{mu pop} commands form two major groups.  POP3 protocol
+commands interact with the remote POP3 server and display responses
+obtained from it.  These commands are named after their POP3
+equivalents.  Another group, @dfn{internal commands}, are used to
+configure the shell itself.
+
+@subsubheading POP protocol commands
 @table @asis
-@c @item VERSION=" VERSION,
-@item USE_LIBPAM
-The Mailutils uses @sc{pam} libraries.
+@item connect [-tls] @var{hostname} [@var{port}]
+Open connection to @var{hostname}.  If the @option{-tls} option is
+given, TLS encryption (also known as POPS protocol) will be used.  If
+@var{port} argument is not given, the command uses port 110 for a
+plain POP connection or 995 for POPS (if @option{-tls} is given).  
+
+@item stls
+Start TLS negotiation.  This command is valid only after successful
+unencrypted connection has been initiated (using @command{connect}
+without @option{-tls} argument).
 
-@item HAVE_LIBLTDL
-The GNU wrapper library @file{libltdl} is present and is used
-by Mailutils. @xref{Using libltdl,,,libtool,Using libltdl}, for
-more information on @file{libltdl} library.
+@item user @var{name}
+Send user name to the server.  The @command{pass} command must follow.
 
-@item WITH_BDB2
-Support for Berkeley DB is compiled in (the package was configured with
-@option{--with-db2} option).
+@item pass [@var{password}] 
+Send password.  This command is valid only after @command{user}.  If
+the @var{password} argument is omitted, the shell will ask you to
+enter it.  While entering, both echoing and history recording will be
+disabled.  Use this to avoid compromising your password.
 
-@item WITH_NDBM
-Support for NDBM is compiled in (the package was configured with
-@option{--with-ndbm} option).
+@item apop @var{user} [@var{password}] 
+Authenticate with APOP.   If the @var{password} argument is omitted,
+you will be asked to supply it.  While entering, both echoing and
+history recording will be disabled. 
 
-@item WITH_OLD_DBM
-Support for old style DBM is compiled in (the package was configured with
-@option{--with-dbm} option).
+@item capa [-reread] [@var{name}...] 
+List server capabilities.  Any number of arguments is accepted.  If given, the shell will display only the named capabilities, otherwise it displays entire list.  By default @command{capa} reuses the response of its previous invocation (if there was any), instead of resending the @samp{CAPA} command to the server.  To force it do so, use the @option{-reread} option. 
 
-@item WITH_GDBM
-Support for GNU DBM is compiled in (the package was configured with
-@option{--with-gdbm} option). @xref{Top,,Introduction,gdbm,The GNU DBM Manual},
-for more information about this library.
+@item noop 
+Send a @samp{NOOP} (@dfn{no operation}) command to the server.
 
-@item WITH_GNUTLS
-Support for GnuTLS (a Transport Layer Security Library) is compiled in
-(the package was configured with @option{--with-gnutls} option).
+@item stat
+Get the mailbox size and number of messages in it.
 
-@item WITH_GSASL
-Support for GNU SASL is compiled in (the package was configured with
-@option{--with-gsasl} option). @xref{Top,,Introduction,gsasl,The GNU SASL Manual},
-for more information about this library.
+@item uidl [@var{number}]
+Shows unique message identifiers.  Without arguments, shows
+identifiers for each message in the mailbox.  If @var{number} is
+given, the command returns the UIDL of that particular message only.
 
-@item WITH_GSSAPI
-Support for @sc{gssapi} is compiled in (the package was configured with
-@option{--with-gssapi} option).
+@item list [@var{number}]
+Lists messages.  See above for the meaning of @var{number}.  Each line
+of the produced listing contains describes a single message and
+contains at least the message number and size in bytes.  Depending on
+the POP3 server implementation, additional fields may be present.  For
+example, Mailutils @command{pop3d} can also output number of lines in
+the message in the additional third field. 
 
-@item WITH_GUILE
-Support for Guile extension language is built (the package was
-configured with @option{--with-guile} option).
-@xref{Top,,Overview,guile,The Guile Reference Manual},
-for more information about Guile.
+@item retr @var{number}
+Retrieve a message.
+
+@item top @var{msgno} [@var{number}] 
+Display message headers and first @var{number} (default 5) of lines of its body.
+
+@item dele @var{number}
+Mark message for deletion.
+
+@item rset
+Remove deletion marks.
+
+@item quit
+Quit pop3 session.
 
-@item WITH_PTHREAD
-The @sc{posix} thread support is compiled in.
+@item disconnect
+Close existing connection.
+@end table
 
-@item WITH_READLINE
-The readline support is enabled (the package was
-configured with @option{--with-readline} option).
-@xref{Top,,,readline,The GNU Readline Library}, for more information.
+@subsubheading Internal commands
+@table @asis
+@item verbose [on|off|mask|unmask] [secure [payload]]
+Control output verbosity.  Without arguments the @command{verbose}
+command shows current settings.
+
+The argument @samp{off} (the default) turns off all additional output.
+The @samp{verbose on} command enables POP3 protocol tracing output.
+Additional arguments can be used to provide more verbosity.  The
+@samp{secure} argument enables display of user passwords in the trace
+output and the @samp{payload} argument enables showing payload data
+(e.g. response body sent in the reply to @samp{RETR} command, etc.)
+Thus, the full diagnostics output is obtained by 
+
+@example
+verbose on secure payload
+@end example
+
+The @samp{mask} and @samp{unmask} arguments allow to disable and
+enable such additional verbosity.  For example, supposing the command
+above is in action, the following command will suppress the display of
+user passwords in the traces:
+
+@example
+verbose mask secure
+@end example
+
+Similarly, @command{verbose unmask secure} will turn it back again.
+
+@item prompt @var{string}
+Set command prompt.  The argument can contain @dfn{variable
+references} in any of the following forms:
+
+@example
+$@var{name}
+$@{@var{name}@}
+@end example
 
-@item HAVE_MYSQL
-Authentication via MySQL is supported (the package was
-configured with @option{--enable-mysql} option).
+@noindent
+where @var{name} is the variable name.  Such references are expanded
+to the actual value of the variable at the time of expansion.  The
+following variables are defined:
+
+@multitable @columnfractions 0.4 0.6
+@headitem Variable @tab Expansion
+@item user @tab Login name of the authenticated POP3 user.  If the session is not authenticated yet, expands to @samp{[nouser]}.
+@item host @tab Name of the remote host, or @samp{[nohost]} if no
+connection is established. 
+@item program-name @tab Name of the program, as typed on the command
+line to invoke it. 
+@item canonical-program-name @tab @samp{mu}
+@item package @tab @samp{Mailutils}
+@item version @tab Mailutils version number (@value{VERSION})
+@item status @tab Session status.  One of: @samp{disconnected},
+@samp{connected} or @samp{logged in}.
+@end multitable
 
-@item ENABLE_VIRTUAL_DOMAINS
-Support for mail virtual domains is enabled (the package was
-configured with @option{--enable-virtual-domains} option).
+For example:
 
-@item ENABLE_IMAP
-Support for @sc{imap4} protocol is enabled.
+@example
+prompt "[$@{user@}@@$host "
+@end example
 
-@item ENABLE_POP
-Support for @sc{pop3} protocol is enabled.
+Notice the use of quotes to include the space character in the prompt.
 
-@item ENABLE_MH
-Support for mailboxes in @sc{mh} format is enabled.
+@item exit
+Exit the program.
 
-@item ENABLE_MAILDIR
-Support for mailboxes in @sc{Maildir} format is enabled.
+@item help [@var{command}]
+@itemx ? [@var{command}]
+Without arguments displays a list of commands with possible arguments
+and short descriptions.
 
-@item ENABLE_SMTP
-Support for @sc{smtp} mailer is enabled.
+With one argument, displays a terse description for the given @var{command}.
 
-@item ENABLE_SENDMAIL
-Support for Sendmail mailer is enabled.
+@item history
+Shows command history.
 @end table
+
+@node mu imap
+@subsection mu imap
+The @command{mu imap} command is reserved for an interactive IMAP4
+client shell.  It does not do much now (as of version @value{VERSION}.
+
diff --git a/doc/texinfo/sieve.texi b/doc/texinfo/sieve.texi
index e8d0d51..d8308a0 100644
--- a/doc/texinfo/sieve.texi
+++ b/doc/texinfo/sieve.texi
@@ -30,8 +30,8 @@ as described below).
 There are two kinds of comments: hash comments, that begin with a
 @samp{#} character that is not contained within a string and continue
 until the next newline, and C-style or bracketed comments, that are
-delimited by @samp{/*} and @samp{*/} tokens. The bracketed comments
-may span multiple lines. E.g.:
+delimited by @samp{/*} and @samp{*/} tokens.  The bracketed comments
+may span multiple lines.  E.g.:
 
 @smallexample
 if size :over 100K
@@ -53,20 +53,20 @@ Like in C, bracketed comments do not nest.
 The basic lexical entities are @dfn{identifiers} and @dfn{literals}.
 
 An @dfn{identifier} is a sequence of letters, digits and underscores,
-that begins with a letter or underscore. For example, @code{header} and
+that begins with a letter or underscore.  For example, @code{header} and
 @code{check_822_again} are valid identifiers, whereas @code{1st} is not.
 A special form of identifier is @dfn{tag}: it is an identifier prefixed
 with a colon (@samp{:}), e.g.: @code{:comparator}. 
 
 A @dfn{literal} is a data that is not executed, merely evaluated ``as
-is'', to be used as arguments to commands. There are four kinds of
+is'', to be used as arguments to commands.  There are four kinds of
 literals:
 
 @itemize
 @item Number
 @cindex numbers, sieve
 
-@dfn{Numbers} are given as ordinary unsigned decimal numbers. An
+@dfn{Numbers} are given as ordinary unsigned decimal numbers.  An
 optional suffix may be used to indicate a multiple of a power of two.
 The suffixes are: @samp{K} specifying ``kibi-'', or 1,024 (2^10) times
 the value of the number; @samp{M} specifying ``mebi-'', or 1,048,576
@@ -78,24 +78,24 @@ The numbers have 32 bits of magnitude.
 @item String
 @cindex strings, sieve
 A @dfn{string} is any sequence of characters enclosed in double quotes
-(@samp{"}). A string cannot contain newlines and double quote
-characters. This limitation will disappear in future releases.
+(@samp{"}).  A string cannot contain newlines and double quote
+characters.  This limitation will disappear in future releases.
 
 @item Multiline Strings
 @cindex multiline strings, sieve
 @kwindex text:
 A @dfn{multiline string} is used to represent large blocks of text
-with embedded newlines and special characters. It starts with the
+with embedded newlines and special characters.  It starts with the
 keyword @code{text:} followed by a newline and ends with a dot
-(@samp{.}) on a newline by itself. Any characters between these two
-markers are taken verbatim. For example:
+(@samp{.}) on a newline by itself.  Any characters between these two
+markers are taken verbatim.  For example:
 
 @smallexample
 text:
 ** This is an automatic response from my message **
 ** filtering program.                            **
 
-I can not attend your message right now. However it
+I can not attend your message right now.  However it
 will be saved, and I will read it as soon as I am back.
 
 Regards,
@@ -104,10 +104,10 @@ Fred
 @end smallexample
 
 Notice that a hashed comment or whitespace may occur between
-@code{text:} and the newline. However, when used inside the multiline
+@code{text:} and the newline.  However, when used inside the multiline
 string a hash sign looses its special meaning (except in one case, see
 below) and is taken as is, as well as bracketed comment delimiters.
-In other words, no comments are allowed within a multiline string. E.g.:
+In other words, no comments are allowed within a multiline string.  E.g.:
     
 @smallexample
 text: # This is a comment
@@ -131,15 +131,15 @@ text:
 This results in the contents of file @file{myresponse.txt} being read
 and interpreted as the contents of the multiline string.
 
-GNU libmu_sieve extends the described syntax as follows. If the keyword
+GNU libmu_sieve extends the described syntax as follows.  If the keyword
 @code{text:} is immediately followed by a dash (@samp{-}), then all
 leading tab characters are stripped from input lines and the line
-containing delimiter (@samp{.}). This allows multiline strings within
+containing delimiter (@samp{.}).  This allows multiline strings within
 scripts to be indented in a natural fashion.
 
 Furthermore, if the @code{text:} (optionally followed by @samp{-}) is
 immediately followed by a word, this word will be used as ending
-delimiter of multiline string instead of the default dot. For
+delimiter of multiline string instead of the default dot.  For
 example:        
 
 @smallexample
@@ -172,7 +172,7 @@ in a pair of square brackets, e.g.:
 
 For convenience, in any context where a list of strings is appropriate,
 a single string is allowed without being a member of a list: it is
-equivalent to a list with a single member. For example, the following
+equivalent to a list with a single member.  For example, the following
 two statements are equivalent:
 
 @smallexample
@@ -198,7 +198,7 @@ simple syntax.
 @node Commands
 @subsection Commands
 
-The basic syntax element is a @dfn{command}. It is defined as follows:
+The basic syntax element is a @dfn{command}.  It is defined as follows:
 
 @smallexample
 @var{command-name} [@var{tags}] @var{args}
@@ -209,18 +209,18 @@ command, @var{tags} is an optional list of @dfn{optional} or
 @dfn{tagged arguments} and @var{args} is a list of @dfn{required} or
 @dfn{positional arguments}.
 
-Positional arguments are literals delimited with whitespace. They
+Positional arguments are literals delimited with whitespace.  They
 provide the command with the information necessary to its proper
-functioning. Each command has a fixed number of positional arguments. It
+functioning.  Each command has a fixed number of positional arguments.  It
 is an error to supply more arguments to the command or to give it fewer
 arguments than it accepts.
 
 Optional arguments allow to modify the behaviour of the command, like
-command line options in UNIX do. They are a list of @dfn{tags}
-(@pxref{Lexical Structure}) separated by whitespace. An optional
+command line options in UNIX do.  They are a list of @dfn{tags}
+(@pxref{Lexical Structure}) separated by whitespace.  An optional
 argument may have at most one parameter.
 
-Each command understands a set of optional arguments. Supplying it tags
+Each command understands a set of optional arguments.  Supplying it tags
 that it does not understand results in an error.
 
 For example, consider the following command
@@ -233,8 +233,8 @@ header :mime :comparator "i;octet" ["to", "from"] "bug-mailutils@@gnu.org"
 Here, given that @code{header} takes two positional arguments:
 @code{header} is command name, the list @code{["to", "from"]} is first
 positional argument and the string @code{"bug-mailutils@@gnu.org"} is second
-positional argument. There are two optional arguments: @code{:mime} and
-@code{:comparator}. The latter has a string @code{"i;octet"} as its
+positional argument.  There are two optional arguments: @code{:mime} and
+@code{:comparator}.  The latter has a string @code{"i;octet"} as its
 parameter.
 
 @node Actions Described
@@ -242,8 +242,8 @@ parameter.
 @cindex action, sieve
 
 An @dfn{action} is a Sieve command that performs some operation over
-a message. Actions do the main job in any Sieve
-program. Syntactically, an action is a command terminated with
+a message.  Actions do the main job in any Sieve
+program.  Syntactically, an action is a command terminated with
 semicolon, e.g.:
 
 @smallexample
@@ -254,13 +254,13 @@ fileinto "mbox";
 
 GNU Sieve provides the full set of actions described in RFC 3028.
 It also allows to extend this set using loadable
-actions. @xref{Actions}, for detailed discussion of actions.
+actions.  @xref{Actions}, for detailed discussion of actions.
 
 @node Control Flow
 @subsection Control Flow
 @kwindex if, sieve
 
-The only control flow statement Sieve has is @code{if} statement. In its
+The only control flow statement Sieve has is @code{if} statement.  In its
 simplest form it is:
 
 @smallexample
@@ -287,13 +287,13 @@ if @code{cond1} @{ @dots{} @} elsif @code{cond2} @{ @dots{} @} else @{ @dots{} @
 @end smallexample
 
 There may be any number of ``elsif'' branches in an ``if''
-statement. However it may have at most one ``else'' branch.
+statement.  However it may have at most one ``else'' branch.
 Notes for C programmers:
 
 @enumerate
 @item The braces surrounding each branch of an ``if'' statement are
 required.
-@item The ``else if'' construct is disallowed. Use ``elsif'' keyword
+@item The ``else if'' construct is disallowed.  Use ``elsif'' keyword
 instead.
 @end enumerate
 
@@ -321,7 +321,7 @@ statements.
 @subsection Tests and Conditions
 @cindex test, sieve
 
-@dfn{Tests} are Sieve commands that return boolean value. E.g. the
+@dfn{Tests} are Sieve commands that return boolean value.  E.g. the
 test
 
 @smallexample
@@ -336,7 +336,7 @@ The tests shipped with the GNU Sieve are described in @ref{Tests}.
 
 @cindex condition, sieve
 @dfn{Condition} is a Sieve expression that evaluates to @code{true} or
-@code{false}. In its simplest form, condition is just a Sieve test.
+@code{false}.  In its simplest form, condition is just a Sieve test.
 
 @kwindex not, sieve
 To reverse the sense of a condition use keyword @code{not}, e.g.: 
@@ -350,10 +350,10 @@ not header :contains "from" "coyote"
 @kwindex allof
 @kwindex anyof
 The results of several conditions may be joined together by logical
-@code{and} and @code{or} operations. The special form @code{allof}
+@code{and} and @code{or} operations.  The special form @code{allof}
 takes several tests as its arguments and computes the logical @code{and}
-of their results. Similarly, the form @code{anyof} performs logical
-@code{or} over the results of its arguments. E.g.:
+of their results.  Similarly, the form @code{anyof} performs logical
+@code{or} over the results of its arguments.  E.g.:
 
 @smallexample
 if anyof (not exists ["From", "Date"],
@@ -371,7 +371,7 @@ if anyof (not exists ["From", "Date"],
 Preprocessor statements are a GNU extension to the Sieve language.
 The syntax for a preprocessor statement is similar to that used in
 @code{C} programming language, i.e. a pound character (@samp{#})
-followed by a preprocessor directive and its arguments. Any amount of
+followed by a preprocessor directive and its arguments.  Any amount of
 whitespace can be inserted between the @samp{#} and the directive.
 Currently implemented directives are @code{include} and @code{searchpath}.
 
@@ -386,7 +386,7 @@ Currently implemented directives are @code{include} and @code{searchpath}.
 
 The @code{#include} directive reads in the contents of the given file.
 The contents is ``inserted'' into the text being parsed starting at the
-line where the directive appears. The directive takes two forms:
+line where the directive appears.  The directive takes two forms:
 
 @table @code
 @item #include "@var{filename}"
@@ -405,7 +405,7 @@ If @var{filename} starts with a directory separator character
 @kwindex #searchpath, sieve
 
 The @code{#searchpath} directive adds its argument to the list of
-directories searched for loadable modules. It has the same effect
+directories searched for loadable modules.  It has the same effect
 as @command{library-path} Sieve configuration statement
 (@pxref{Sieve Configuration, library-path}). 
 
@@ -419,23 +419,23 @@ Syntax:   require @var{string};
 @end smallexample
 
 The require statement informs the parser that a script makes use of a certain
-extension. Multiple capabilities can be declared using the second form
-of the statement. The actual handling of a capability name depends on
+extension.  Multiple capabilities can be declared using the second form
+of the statement.  The actual handling of a capability name depends on
 its suffix.
 
 If the name starts with @samp{comparator-}, it is understood
-as a request to use the specified comparator. The comparator name
+as a request to use the specified comparator.  The comparator name
 consists of the characters following the suffix.
 
 If the name starts with @samp{test-}, it means a request to use
-the given test. The test name consists of the characters following
+the given test.  The test name consists of the characters following
 the suffix.
 
 Otherwise, the capability is understood as a name of an action to be
 used.
 
 The @code{require} statement, if present, must be used before any other
-statement that is using the required capability. As an extension, the GNU
+statement that is using the required capability.  As an extension, the GNU
 sieve allows the @code{require} and any other statements to be
 interspersed.
 
@@ -464,24 +464,24 @@ When processing arguments for @code{require} statement, GNU libmu_sieve
 uses the following algorithm:
 
 @enumerate 1
-@item Look up the name in a symbol table. If the name begins with
-@samp{comparator-} it is looked up in the comparator table. If it
-begins with @samp{test-}, the test table is used instead. Otherwise
+@item Look up the name in a symbol table.  If the name begins with
+@samp{comparator-} it is looked up in the comparator table.  If it
+begins with @samp{test-}, the test table is used instead.  Otherwise
 the name is looked up in the action table.
 
 @item If the name is found, the search is terminated.
 
-@item Otherwise, transform the name. First, any @samp{comparator-} or
-@samp{test-} prefix is stripped. Then, any character other than
+@item Otherwise, transform the name.  First, any @samp{comparator-} or
+@samp{test-} prefix is stripped.  Then, any character other than
 alphanumeric characters, @samp{.} and @samp{,} is replaced with
-dash (@samp{-}). The name thus obtained is used as a file name
+dash (@samp{-}).  The name thus obtained is used as a file name
 of an external loadable module. 
 
-@item Try to load the module. The module is searched in the
+@item Try to load the module.  The module is searched in the
 following search paths (in the order given):
 
 @enumerate 1
-@item Mailutils module directory. By default it is
+@item Mailutils module directory.  By default it is
 @file{$prefix/lib/mailutils}.
 
 @item Sieve library path as given with the @option{-L} options in
@@ -505,7 +505,7 @@ colon-separated list of absolute directories, for example,
 @samp{"/usr/lib/mypkg:/lib/foo"}.
 
 In any of these directories, @command{libmu_sieve} first attempts to find
-and load the given filename. If this fails, it tries to append the
+and load the given filename.  If this fails, it tries to append the
 following suffixes to the file name:
 
 @enumerate 1
@@ -517,11 +517,11 @@ platform, e.g., @samp{.so}, @samp{.sl}, etc.
 
 @item If the module is found, @command{libmu_sieve} executes its
 initialization function (see below) and again looks up the name
-in the symbol table. If found, search terminates successfully.
+in the symbol table.  If found, search terminates successfully.
 
 @item If either the module is not found, or the symbol wasn't
 found after execution of the module initialization function,
-search is terminated with an error status. @command{libmu_sieve} then
+search is terminated with an error status.  @command{libmu_sieve} then
 issues the following diagnostic message:
 
 @smallexample
@@ -541,11 +541,11 @@ This comparator simply compares the two arguments octet by octet
 
 @item i;ascii-casemap
 It treats uppercase and lowercase characters in the @sc{ascii} subset of
-@sc{utf-8} as the same. This is the default comparator.
+@sc{utf-8} as the same.  This is the default comparator.
 
 @item i;ascii-numeric
 Treats the two arguments as @sc{ascii} representation of decimal
-numbers and compares their numeric values. This comparator must
+numbers and compares their numeric values.  This comparator must
 be explicitly required prior to use.
 @end table 
 
@@ -558,7 +558,7 @@ In the discussion below the following macro-notations are used:
 
 @table @var
 @item match-type
-This tag specifies the matching type to be used with the test. It can
+This tag specifies the matching type to be used with the test.  It can
 be one of the following:
 
 @table @code
@@ -567,26 +567,26 @@ be one of the following:
 @item :is
 The @code{:is} match type describes an absolute match; if the contents of
 the first string are absolutely the same as the contents of the
-second string, they match. Only the string ``frobnitzm'' is the string
-``frobnitzm''. The null key ``:is'' and only ``:is'' the null value.
+second string, they match.  Only the string ``frobnitzm'' is the string
+``frobnitzm''.  The null key ``:is'' and only ``:is'' the null value.
 This is the default match-type.
 
 @kwindex :contains, sieve
 @kwindex contains, sieve
 @item :contains
-The @code{:contains} match type describes a substring match. If the value
+The @code{:contains} match type describes a substring match.  If the value
 argument contains the key argument as a substring, the match is true.
 For instance, the string ``frobnitzm'' contains ``frob'' and ``nit'', but
-not ``fbm''. The null key ``'' is contained in all values.
+not ``fbm''.  The null key ``'' is contained in all values.
 
 @kwindex :matches, sieve
 @kwindex matches, sieve
 @item :matches
 The @code{:matches} version specifies a wildcard match using the
-characters @samp{*} and @samp{?}. @samp{*} matches zero or more
-characters, and @samp{?} matches a single character. @samp{?} and
+characters @samp{*} and @samp{?}.  @samp{*} matches zero or more
+characters, and @samp{?} matches a single character.  @samp{?} and
 @samp{*} may be escaped as @samp{\\?} and @samp{\\*} in strings to match
-against themselves. The first backslash escapes the second backslash;
+against themselves.  The first backslash escapes the second backslash;
 together, they escape the @samp{*}.
 
 @kwindex :regex, sieve
@@ -599,7 +599,7 @@ Expressions.
 @kwindex value, sieve
 @item :value @var{relation}
 The @code{:value} match type does a relational comparison between
-strings. Valid values for @var{relation} are:
+strings.  Valid values for @var{relation} are:
 
 @table @asis
 @item "eq"
@@ -627,7 +627,7 @@ Less than or Equal
 This match type first determines the number of the specified entities
 (headers, addresses, etc.) in the message and does a relational
 comparison of the number of entities to the values specified in the
-test expression. The test expression must be a list of one element.
+test expression.  The test expression must be a list of one element.
 @end table
 
 @kwindex :comparator, sieve
@@ -653,7 +653,7 @@ if header :comparator "i;ascii-numeric" :is "X-Num" "10"
 @end smallexample
 
 @item address-part
-This syntax item is used when testing structured Internet addresses. It
+This syntax item is used when testing structured Internet addresses.  It
 specifies which part of an address must be used in comparisons.
 Exactly one of the following tags may be used:
 
@@ -661,7 +661,7 @@ Exactly one of the following tags may be used:
 @kwindex :all, sieve
 @kwindex all, sieve
 @item :all
-Use the whole address. This is the default.
+Use the whole address.  This is the default.
 
 @kwindex :localpart, sieve
 @kwindex localpart, sieve
@@ -677,9 +677,9 @@ Use domain part of the address.
 @end table
 
 @emph{Notice}, that @var{match-type} modifiers interact with
-comparators. Some comparators are not suitable for matching with
-@code{:contains} or @code{:matches}. If this occurs, sieve issues
-an appropriate error message. For example, the statement:
+comparators.  Some comparators are not suitable for matching with
+@code{:contains} or @code{:matches}.  If this occurs, sieve issues
+an appropriate error message.  For example, the statement:
 
 @smallexample
 if header :matches :comparator "i;ascii-numeric"
@@ -692,7 +692,7 @@ comparator `i;ascii-numeric' is incompatible with match type `:matches'
 in call to `header'
 @end smallexample
 
-GNU Sieve supports two kinds of tests. @dfn{Built-in tests} are
+GNU Sieve supports two kinds of tests.  @dfn{Built-in tests} are
 defined within the library and do not require any external files.
 @dfn{External tests} are loadable modules that can be linked in at run
 time using the @code{require} statement (@pxref{Require Statement}).
@@ -725,7 +725,7 @@ Tagged arguments:
 
 @table @var
 @item address-part
-Selects the address part to compare. Default is the whole email address
+Selects the address part to compare.  Default is the whole email address
 (@code{:all}).
 
 @item comparator
@@ -748,7 +748,7 @@ A list of address values.
 @noindent
 
 The @code{address} test matches Internet addresses in structured headers
-that contain addresses. It returns @code{true} if any header contains any
+that contain addresses.  It returns @code{true} if any header contains any
 key in the specified part of the address, as modified by 
 @var{comparator} and @var{match-type} optional arguments.
 
@@ -756,8 +756,8 @@ This test returns @code{true} if any combination of the
 @var{header-names} and @var{key-list} arguments match.
 
 The @code{address} primitive never acts on the phrase part of an email
-address, nor on comments within that address. Use the @code{header} test
-instead. It also never acts on group names, although it does act on the
+address, nor on comments within that address.  Use the @code{header} test
+instead.  It also never acts on group names, although it does act on the
 addresses within the group construct.
 
 Example:
@@ -771,8 +771,8 @@ if address :is :all "from" "tim@@example.com"
 @end deftypefn
 
 @deftypefn Test {} size [:over | :under] @var{limit}(number)
-The @code{size} test deals with the size of a message. The required
-argument @var{limit} represents the size of the message in bytes. It
+The @code{size} test deals with the size of a message.  The required
+argument @var{limit} represents the size of the message in bytes.  It
 may be suffixed with the following quantifiers:
 
 @table @samp
@@ -796,7 +796,7 @@ If the argument is @samp{:under}, and the size of the message is less than
 the @var{number}, the test is true; otherwise, it is false.
 
 Otherwise, the test is true only if the size of the message equals
-exactly @var{number}. This is a GNU extension.
+exactly @var{number}.  This is a GNU extension.
 
 The size of a message is defined to be the number of octets from the
 initial header until the last character in the message body.
@@ -813,7 +813,7 @@ Tagged arguments:
 
 @table @var
 @item address-part
-Selects the address part to compare. Default is the whole email address
+Selects the address part to compare.  Default is the whole email address
 (@code{:all}).
 
 @item comparator
@@ -859,7 +859,7 @@ List of message header names.
 @sp 1
 @noindent
 The @code{exists} test is @code{true} if the headers listed in
-@var{header-names} argument exist within the message. All of the headers
+@var{header-names} argument exist within the message.  All of the headers
 must exist or the test is false.
 
 The following example throws out mail that doesn't have a From header
@@ -909,15 +909,15 @@ A list of header values.
 @sp 1
 @noindent
 The @code{header} test evaluates to true if any header name matches any
-key. The type of match is specified by the optional match argument,
+key.  The type of match is specified by the optional match argument,
 which defaults to ":is" if not explicitly given.
 
 The test returns @code{true} if any combination of the @var{header-names}
 and @var{key-list} arguments match.
 
 If a header listed in @var{header-names} exists, it contains the null
-key (@samp{""}). However, if the named header is not present, it
-does not contain the null key. So if a message contained the header
+key (@samp{""}).  However, if the named header is not present, it
+does not contain the null key.  So if a message contained the header
 
 @smallexample
 X-Caffeine: C8H10N4O2
@@ -949,12 +949,12 @@ if numaddr @var{args}
   @}
 @end smallexample
 @*Description: 
-This test is provided as an example of loadable extension tests. You
+This test is provided as an example of loadable extension tests.  You
 must use @samp{require "test-numaddr"} statement before actually using
 it.
 
 The @code{numaddr} test counts Internet addresses in structured headers
-that contain addresses. It returns true if the total number of
+that contain addresses.  It returns true if the total number of
 addresses satisfies the requested relation.
 
 @kwindex :over
@@ -985,17 +985,17 @@ if spamd @var{args}
 @end smallexample
   
 @*Description:  
-This test is an interface to SpamAssassin filter. It connects to the
+This test is an interface to SpamAssassin filter.  It connects to the
 @command{spamd} daemon using connection parameters specified by tagged
 arguments @code{:host} and @code{:port} (if the daemon is listening on
 an INET socket), or @code{:socket} (if the daemon is listening on a
 UNIX socket) and returns true, if SpamAssassin qualifies the message
-as spam. Tagged argument @var{limit} alters the default behavior. Its
-value is a string representation of a floating point number. If
+as spam.  Tagged argument @var{limit} alters the default behavior.  Its
+value is a string representation of a floating point number.  If
 the tag @code{:over} is used, then the test returns true if the spam
 score returned from SpamAssassin is greater than @var{limit}.
 Otherwise, if @code{:under} is used, the test returns true if the spam
-score is less than @var{limit}. The comparison takes into account
+score is less than @var{limit}.  The comparison takes into account
 three decimal digits.
 
 Tagged argument @code{:user} allows to select a specific user profile.
@@ -1046,8 +1046,8 @@ if list @var{args}
 @end smallexample  
 @*Description:  
 The @code{list} test evaluates to true if any of @var{headers} match any
-key from @var{keys}. Each header is regarded as containing a list of
-keywords. By default, comma is assumed as list separator. This can be
+key from @var{keys}.  Each header is regarded as containing a list of
+keywords.  By default, comma is assumed as list separator.  This can be
 overridden by specifying the @code{:delim} tag, whose value is a
 string consisting of valid list delimiter characters.
 
@@ -1098,7 +1098,7 @@ date is after the given date, the result is false.
 
 If no tagged argument is supplied, @code{:after} is assumed.
 
-Almost any date format is understood. @xref{Date Input Formats}, for
+Almost any date format is understood.  @xref{Date Input Formats}, for
 a detailed information on date formats.
 
 @*Example:
@@ -1148,19 +1148,19 @@ These actions are described in detail below.
 
 @deffn Action stop
 
-The @code{stop} action ends all processing. If no actions have been
+The @code{stop} action ends all processing.  If no actions have been
 executed, then the @code{keep} action is taken.
 @end deffn
 
 @deffn Action keep
 
 The effect of this action is to preserve the current message in the
-mailbox. This action is executed if no other action has been executed.
+mailbox.  This action is executed if no other action has been executed.
 @end deffn
 
 @deffn Action discard
 
-@code{Discard} silently throws away the current message. No notification
+@code{Discard} silently throws away the current message.  No notification
 is returned to the sender, the message is deleted from the mailbox.
 
 Example:
@@ -1192,12 +1192,12 @@ Specifies the permissions to use, if the mailbox is created.
 @end table
 
 The @code{fileinto} action delivers the message into the specified
-folder. If the folder is local, it is created using permissions
-@samp{0600}, for regular files, and @samp{0700} for directories. This
-default can be changed by using the @code{:permissions} tag. Its
+folder.  If the folder is local, it is created using permissions
+@samp{0600}, for regular files, and @samp{0700} for directories.  This
+default can be changed by using the @code{:permissions} tag.  Its
 argument is a mode specification, similar to that used by
-@command{chmod} shell utility. It is a list of permissions settings
-separated by commas. Each setting begins with one of the following
+@command{chmod} shell utility.  It is a list of permissions settings
+separated by commas.  Each setting begins with one of the following
 letters:
 
 @table @asis
@@ -1209,7 +1209,7 @@ Set permissions for users not in the file's group.
 @end table
 
 This letter must be followed by either @samp{+} or @samp{=} and the
-list of permissions to be set. This latter list is a string
+list of permissions to be set.  This latter list is a string
 containing any one or both of the following characters:
 
 @table @asis
@@ -1237,17 +1237,17 @@ value.
 
 @item
 Only @code{r} and @code{w} permissions can be set, since other
-permissions do not seem to be useful for mailboxes. However, for
+permissions do not seem to be useful for mailboxes.  However, for
 mailboxes that have a directory structure (such as maildir and MH),
 any settings in @samp{g} and @samp{o} sets imply setting the
 executable bit.
 
 @item
-Owner's permissions cannot be set. The owner always has all
+Owner's permissions cannot be set.  The owner always has all
 permissions on the mailbox he created.
 
 @item
-The @code{:permissions} settings apply only to local mailboxes. They
+The @code{:permissions} settings apply only to local mailboxes.  They
 are ignored for remote mailboxes.
 @end enumerate
 
@@ -1256,9 +1256,9 @@ are ignored for remote mailboxes.
 @deffn Action reject @var{reason}
 
 The optional @code{reject} action refuses delivery of a message by sending
-back a message delivery notification to the sender. It resends the
+back a message delivery notification to the sender.  It resends the
 message to the sender, wrapping it in a ``reject'' form, noting that it
-was rejected by the recipient. The required argument @var{reason} is
+was rejected by the recipient.  The required argument @var{reason} is
 a string specifying the reason for rejecting the message.
 
 Example:
@@ -1344,15 +1344,15 @@ if header :mime :matches "Content-Type"
 
 @deffn Action redirect @var{address}
 The @code{redirect} action is used to send the message to another user at
-a supplied @var{address}, as a mail forwarding feature does. This action
+a supplied @var{address}, as a mail forwarding feature does.  This action
 makes no changes to the message body or existing headers, but it may add
-new headers. It also modifies the envelope recipient.
+new headers.  It also modifies the envelope recipient.
 
 The @code{redirect} command performs an MTA-style ``forward'' --- that
 is, what you get from a @file{.forward} file using @code{sendmail} under
-@sc{unix}. The address on the SMTP envelope is replaced with the one on
+@sc{unix}.  The address on the SMTP envelope is replaced with the one on
 the @code{redirect} command and the message is sent back
-out. @emph{Notice}, that it differs from the MUA-style forward, which
+out.  @emph{Notice}, that it differs from the MUA-style forward, which
 creates a new message with a different sender and message ID, wrapping
 the old message in a new one.
 @end deffn
@@ -1361,7 +1361,7 @@ the old message in a new one.
 @subsection External Actions
 @UNREVISED
   GNU Mailutils is shipped with a set of external Sieve
-actions. These actions are compiled as loadable modules and must be
+actions.  These actions are compiled as loadable modules and must be
 required prior to use (@pxref{Require Statement}).
 
 @deftypefn Action {}  moderator [:keep] [:address @var{address}(string)] @
@@ -1391,20 +1391,20 @@ Replying to part 3 while adding an `Approved:' header with the list
 password in it approves the submission.
 
 The @code{moderator} action spawns an inferior Sieve machine and
-filters the original submission (part 2) through it. If the inferior
+filters the original submission (part 2) through it.  If the inferior
 machine marks the message as deleted, the action replies to the
-control message, thereby causing the submission to be discarded. The
+control message, thereby causing the submission to be discarded.  The
 @samp{From:} address of the reply can be modified using
-@code{:address} tag. After discarding the message, @code{moderator}
+@code{:address} tag.  After discarding the message, @code{moderator}
 marks it as deleted, unless it is given @code{:keep} tag. 
 
 The argument of @code{:source} tag, if given, specifies the Sieve
-source file to be used on the message. If @code{:tag} is not present,
+source file to be used on the message.  If @code{:tag} is not present,
 @code{moderator} will create and use a copy of the existing Sieve machine.
 
 The action checks the message structure: it will bail out if the message
 does not have exactly 3 MIME parts, or if parts 2 and 3 are not of
-@samp{message/rfc822} type. It is the responsibility of the caller to
+@samp{message/rfc822} type.  It is the responsibility of the caller to
 make sure the message is actually a valid Mailman moderation request
 (see the example below).
 
@@ -1429,7 +1429,7 @@ if pipe @var{args}
 @end smallexample
 @*Description:
 The @code{pipe} action sends executes a command specified by its
-argument and sends the entire message to its standard input. The
+argument and sends the entire message to its standard input.  The
 @var{command} argument supplies the command line.
 
 The envelope of the message is included, if the @code{:envelope} tag
@@ -1461,15 +1461,15 @@ vacation @var{args};
 @end smallexample
 @*Description:
 The @code{vacation} action returns a message with @var{reply-text} to
-the sender. It is intended to inform the sender that the recipient is
+the sender.  It is intended to inform the sender that the recipient is
 not currently reading his mail.
 
 If the @code{:subject} tag is given, its argument sets the subject of
-the message. Otherwise, the subject is formed by prefixing original
+the message.  Otherwise, the subject is formed by prefixing original
 subject with @samp{Re:}, or @var{prefix}, given with the
-@code{:reply_prefix} tag. Before prefixing, any original prefixes
+@code{:reply_prefix} tag.  Before prefixing, any original prefixes
 matching extended regular expression @var{expr} (@code{:reply_regex}
-tag) are stripped from the subject line. If @code{:reply_regex} is not
+tag) are stripped from the subject line.  If @code{:reply_regex} is not
 specified, the default regexp is @samp{^re: *}. 
 
 The @code{:aliases} tag instructs @code{vacation} to handle messages
@@ -1477,9 +1477,9 @@ for any address in @var{addrlist} in the same manner as those received
 for the user's principal email.
 
 Before processing, @code{vacation} compares the sender address with
-its @dfn{address exclusion list}. Elements of this list are extended
-case-insensitive regular expressions. If the sender address matches
-any of these expressions, the message will not be replied. The default
+its @dfn{address exclusion list}.  Elements of this list are extended
+case-insensitive regular expressions.  If the sender address matches
+any of these expressions, the message will not be replied.  The default
 exclusion list is:
 
 @smallexample
@@ -1495,10 +1495,10 @@ exclusion list is:
 
 New entries can be added to this list using @code{:addresses} tag.
 
-The @code{:days} tag sets the @dfn{reply interval}. A reply is sent to
-each sender once in @var{ndays} days. GNU Sieve keeps track of
+The @code{:days} tag sets the @dfn{reply interval}.  A reply is sent to
+each sender once in @var{ndays} days.  GNU Sieve keeps track of
 sender addresses and dates in a DBM file @file{.vacation} stored in
-the user's home directory. This tag is available only if Mailutils is
+the user's home directory.  This tag is available only if Mailutils is
 compiled with DBM support.
 @end deftypefn
 
@@ -1524,15 +1524,15 @@ The meaning of optional flags is the same as in shell ``here document''
 construct: the dash strips all leading tab characters from the string body,
 thus allowing it to be indented in a natural fashion; @var{delimiter}
 introduces the new end-of-text delimiter instead of the default
-dot. If @var{delimiter} starts with a backslash, no preprocessing will
+dot.  If @var{delimiter} starts with a backslash, no preprocessing will
 be performed within a string.
 
 @item Handling of the @code{require} statement.
 
 @itemize
 @item According to the RFC an error must occur if a @code{require} appears
-after a command other than @code{require}. The GNU sieve library allows
-interspersing the @code{require} and other statements. The only
+after a command other than @code{require}.  The GNU sieve library allows
+interspersing the @code{require} and other statements.  The only
 requirement is that @code{require} must occur before a statement that is
 using the required capability (@pxref{Require Statement}).
 
@@ -1548,12 +1548,12 @@ scan the headers from each part of a multipart message.
 @item @code{size} test
 
 The @code{size} test allows to omit the optional argument
-(:over|:under). In this case exact equality is assumed.
+(:over|:under).  In this case exact equality is assumed.
 
 @item @code{envelope} test
 
 The only value that can be meaningfully used as the first required
-argument of an @code{envelope} test is @samp{from}. This limitation
+argument of an @code{envelope} test is @samp{from}.  This limitation
 may disappear from the subsequent releases.
 
 @item @code{fileinto} action
@@ -1564,7 +1564,7 @@ in case it is created (@pxref{fileinto}).
 @item Match type optional argument.
 
 Along with the usual @code{:is}, @code{:matches} and @code{contains}
-matching type, GNU sieve library understands @code{:regex} type. This
+matching type, GNU sieve library understands @code{:regex} type.  This
 matching type toggles POSIX Extended Regular Expression matching.
 @end enumerate
 
diff --git a/doc/texinfo/usage.texi b/doc/texinfo/usage.texi
index ee2e2ec..fe79375 100644
--- a/doc/texinfo/usage.texi
+++ b/doc/texinfo/usage.texi
@@ -3,15 +3,13 @@
 @c 2008, 2010, 2011 Free Software Foundation, Inc.
 @c See file mailutils.texi for copying conditions.
 @comment *******************************************************************
-@node Usage Vars
-@appendix Configuring Help Summary
 
 Running @command{@var{prog} --help} displays the short usage summary
-for @var{prog} utility (@pxref{Common Options}). This summary is
-organized by @dfn{groups} of semantically close options. The options
+for @var{prog} utility (@pxref{Common Options}).  This summary is
+organized by @dfn{groups} of semantically close options.  The options
 within each group are printed in the following order: a short option,
 eventually followed by a list of corresponding long option names,
-followed by a short description of the option. For example, here is an
+followed by a short description of the option.  For example, here is an
 excerpt from the actual @kbd{sieve --help} output:
 
 @verbatim
@@ -22,12 +20,12 @@ excerpt from the actual @kbd{sieve --help} output:
 
 @vrindex ARGP_HELP_FMT, environment variable
 The exact visual representation of the help output is configurable via
-@env{ARGP_HELP_FMT} environment variable. The value of this variable
-is a comma-separated list of @dfn{format variable} assignments. There
-are two kinds of format variables. An @dfn{offset variable} keeps the
+@env{ARGP_HELP_FMT} environment variable.  The value of this variable
+is a comma-separated list of @dfn{format variable} assignments.  There
+are two kinds of format variables.  An @dfn{offset variable} keeps the
 offset of some part of help output text from the leftmost column on
-the screen. A @dfn{boolean} variable is a flag that toggles some
-output feature on or off. Depending on the type of the corresponding
+the screen.  A @dfn{boolean} variable is a flag that toggles some
+output feature on or off.  Depending on the type of the corresponding
 variable, there are two kinds of assignments:
 
 @table @asis
@@ -45,8 +43,8 @@ numeric value to be assigned to the variable.
 
 @item Boolean assignment
 
-To assign @code{true} value to a variable, simply put this variable name. To
-assign @code{false} value, prefix the variable name with @samp{no-}. For
+To assign @code{true} value to a variable, simply put this variable name.  To
+assign @code{false} value, prefix the variable name with @samp{no-}.  For
 example:
 
 @smallexample
@@ -78,7 +76,7 @@ argument is only shown with the long one, for example:
 
 @noindent
 and a message indicating that the argument is applicable to both
-forms is printed below the options. This message can be disabled
+forms is printed below the options.  This message can be disabled
 using @code{dup-args-note} (see below).
 
 The default is false.
@@ -93,12 +91,12 @@ Mandatory or optional arguments to long options are also mandatory or
 optional for any corresponding short options.
 @end quotation
 
-Setting @code{no-dup-args-note} inhibits this message. Normally, only
+Setting @code{no-dup-args-note} inhibits this message.  Normally, only
 one of variables @code{dup-args} or @code{dup-args-note} should be set.
 @end deftypevr
 
 @deftypevr {Help Output} offset short-opt-col
-Column in which short options start. Default is 2.
+Column in which short options start.  Default is 2.
 
 @smallexample
 @group
@@ -111,7 +109,7 @@ $ @kbd{ARGP_HELP_FMT=short-opt-col=6 sieve --help|grep ARCHIVE}
 @end deftypevr
 
 @deftypevr {Help Output} offset long-opt-col
-Column in which long options start. Default is 6. For example:
+Column in which long options start.  Default is 6.  For example:
 
 @smallexample
 @group
@@ -124,9 +122,9 @@ $ @kbd{ARGP_HELP_FMT=long-opt-col=16 sieve --help|grep ADDRESS}
 @end deftypevr
 
 @deftypevr {Help Output} offset doc-opt-col
-Column in which @dfn{doc options} start. A doc option isn't actually
+Column in which @dfn{doc options} start.  A doc option isn't actually
 an option, but rather an arbitrary piece of documentation that is
-displayed in much the same manner as the options. For example, in
+displayed in much the same manner as the options.  For example, in
 the output of @command{folder --help}:
 
 @verbatim
@@ -138,7 +136,7 @@ GNU MH folder
 @end verbatim
 
 @noindent
-the string @samp{Actions are:} is a doc option. Thus, if you set
+the string @samp{Actions are:} is a doc option.  Thus, if you set
 @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
 will look as follows:
 
@@ -152,7 +150,7 @@ GNU MH folder
 @end deftypevr
 
 @deftypevr {Help Output} offset opt-doc-col
-Column in which option description starts. Default is 29.
+Column in which option description starts.  Default is 29.
 
 @smallexample
 @group
@@ -172,8 +170,8 @@ Notice, that the description starts on a separate line if
 @end deftypevr
 
 @deftypevr {Help Output} offset header-col
-Column in which @dfn{group headers} are printed. A group header is a
-descriptive text preceding an option group. For example, in the
+Column in which @dfn{group headers} are printed.  A group header is a
+descriptive text preceding an option group.  For example, in the
 following text:
 
 @verbatim
@@ -188,10 +186,10 @@ The default value is 1.
 @end deftypevr
 
 @deftypevr {Help Output} offset usage-indent
-Indentation of wrapped usage lines. Affects @option{--usage}
-output. Default is 12.
+Indentation of wrapped usage lines.  Affects @option{--usage}
+output.  Default is 12.
 @end deftypevr
 
 @deftypevr {Help Output} offset rmargin
-Right margin of the text output. Used for wrapping.
+Right margin of the text output.  Used for wrapping.
 @end deftypevr
diff --git a/libmailutils/cfg/lexer.l b/libmailutils/cfg/lexer.l
index 3762d5d..fcf6fdd 100644
--- a/libmailutils/cfg/lexer.l
+++ b/libmailutils/cfg/lexer.l
@@ -100,7 +100,7 @@ P [1-9][0-9]*
 			yylval.string = _mu_line_finish ();
 			return MU_TOK_IDENT; }
          /* Strings */
-[a-zA-Z0-9_\./:\*=-]+ { _mu_line_begin ();
+[a-zA-Z0-9_\./:\*=@-]+ { _mu_line_begin ();
                         _mu_line_add (yytext, yyleng);
                         yylval.string = _mu_line_finish ();
                         return MU_TOK_STRING; }
diff --git a/pop3d/bulletin.c b/pop3d/bulletin.c
index 7bfd052..47efe61 100644
--- a/pop3d/bulletin.c
+++ b/pop3d/bulletin.c
@@ -133,6 +133,8 @@ read_bulletin_db (size_t *pnum)
       return rc;
     }
 
+  mu_dbm_safety_set_flags (db, DEFAULT_GROUP_DB_SAFETY);
+
   rc = mu_dbm_safety_check (db);
   if (rc)
     {
@@ -225,6 +227,8 @@ write_bulletin_db (size_t num)
       return rc;
     }
 
+  mu_dbm_safety_set_flags (db, DEFAULT_GROUP_DB_SAFETY);
+
   rc = mu_dbm_safety_check (db);
   if (rc && rc != ENOENT)
     {
diff --git a/pop3d/logindelay.c b/pop3d/logindelay.c
index 21794ca..f61d6d2 100644
--- a/pop3d/logindelay.c
+++ b/pop3d/logindelay.c
@@ -32,8 +32,10 @@ open_stat_db (int mode)
       return NULL;
     }
 
+  mu_dbm_safety_set_flags (db, DEFAULT_GROUP_DB_SAFETY);
+  
   rc = mu_dbm_safety_check (db);
-  if (rc)
+  if (rc && rc != ENOENT)
     {
       mu_diag_output (MU_DIAG_ERROR,
 		      _("statistics db fails safety check: %s"),
diff --git a/pop3d/pop3d.h b/pop3d/pop3d.h
index 2ae6286..d61f248 100644
--- a/pop3d/pop3d.h
+++ b/pop3d/pop3d.h
@@ -201,6 +201,17 @@ extern char *apop_database_name;
 extern int apop_database_safety;
 extern int apop_database_safety_set;
 
+/* Safety checks for group-rw database files, such as stat and bulletin
+   databases */
+   
+#define DEFAULT_GROUP_DB_SAFETY					\
+  (MU_FILE_SAFETY_WORLD_WRITABLE|				\
+   MU_FILE_SAFETY_WORLD_READABLE|				\
+   MU_FILE_SAFETY_LINKED_WRDIR|					\
+   MU_FILE_SAFETY_DIR_IWGRP|					\
+   MU_FILE_SAFETY_DIR_IWOTH)
+
+
 extern pop3d_command_handler_t pop3d_find_command (const char *name);
 
 extern int pop3d_stat           (char *);


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 05 19:59:15 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RMq8p-0008Eu-TR
	for mharc-commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:59:15 -0400
Received: from eggs.gnu.org ([140.186.70.92]:57996)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq8o-0008Eo-En
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:59:15 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq8n-0007nQ-71
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:59:14 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:36171)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq8n-0007nM-1o
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 19:59:13 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMq8m-0006MI-I2
	for commit-mailutils@gnu.org; Sat, 05 Nov 2011 23:59:12 +0000
Date: Sat, 05 Nov 2011 23:59:12 +0000
Message-Id: <E1RMq8m-0006MI-I2@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-427-g36cd525
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 3ec5d07e67044b614b8beab0e34908b4eec23eab
X-Git-Newrev: 36cd525184c9aabdf61117aa0d0acdccc8bc18cf
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Nov 2011 23:59:15 -0000

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

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

The branch, master has been updated
       via  36cd525184c9aabdf61117aa0d0acdccc8bc18cf (commit)
      from  3ec5d07e67044b614b8beab0e34908b4eec23eab (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 36cd525184c9aabdf61117aa0d0acdccc8bc18cf
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Nov 6 01:59:02 2011 +0200

    Minor fix.
    
    * pop3d/pop3d.c (pop3d_mainloop): start in AUTHORIZATION if tls
    is established.

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

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

diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 3df0551..2639bd6 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -275,7 +275,7 @@ pop3d_mainloop (int ifd, int ofd, int tls)
 
   pop3d_setio (ifd, ofd, tls);
 
-  state = initial_state;
+  state = tls ? AUTHORIZATION : initial_state;
 
   /* Prepare the shared secret for APOP.  */
   {


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sun Nov 06 03:11:55 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RMxpb-0006f5-0j
	for mharc-commit-mailutils@gnu.org; Sun, 06 Nov 2011 03:11:55 -0500
Received: from eggs.gnu.org ([140.186.70.92]:33548)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMxpY-0006eK-FZ
	for commit-mailutils@gnu.org; Sun, 06 Nov 2011 03:11:53 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMxpW-0004Hv-J7
	for commit-mailutils@gnu.org; Sun, 06 Nov 2011 03:11:52 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:51111)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMxpW-0004Hr-Fp
	for commit-mailutils@gnu.org; Sun, 06 Nov 2011 03:11:50 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RMxpU-0006kP-Em
	for commit-mailutils@gnu.org; Sun, 06 Nov 2011 08:11:50 +0000
Date: Sun, 06 Nov 2011 08:11:48 +0000
Message-Id: <E1RMxpU-0006kP-Em@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-428-g1c291e8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 36cd525184c9aabdf61117aa0d0acdccc8bc18cf
X-Git-Newrev: 1c291e80c094f3f7249659bc7b312622b64eb91c
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 06 Nov 2011 08:11:53 -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=1c291e80c094f3f7249659bc7b312622b64eb91c

The branch, master has been updated
       via  1c291e80c094f3f7249659bc7b312622b64eb91c (commit)
      from  36cd525184c9aabdf61117aa0d0acdccc8bc18cf (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 1c291e80c094f3f7249659bc7b312622b64eb91c
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Nov 6 09:41:34 2011 +0200

    Version 2.99.94.

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

Summary of changes:
 NEWS           |   34 +++++++++++++++++-----------------
 configure.ac   |    2 +-
 po/POTFILES.in |    1 -
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index ab9643e..7c974dc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2011-11-05
+GNU mailutils NEWS -- history of user-visible changes. 2011-11-06
 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 Free Software Foundation, Inc.
 See the end of file for copying conditions.
@@ -6,16 +6,16 @@ See the end of file for copying conditions.
 Please send mailutils bug reports to <bug-mailutils@gnu.org>.
 
 
-Version 2.99.93 (Git)
+Version 2.99.94 (Git)
 
 This version is a major rewrite of GNU Mailutils.  Quite a few parts
 of the basic framework were rewritten from scratch, while some others
 undergone a considerable revamping.  The user documentation, at the
 moment, is insufficient, and in some aspects even scarce.  It is being
-worked upon.  However, most utilities self-document themselves.  To
-obtain a summary of available configuration statements for a given
+worked upon.  However, most of the utilities self-document themselves.  
+To obtain a summary of available configuration statements for a given
 program, run `program --config-help'.  For additional documentation,
-please refer to http://mailutils.org/wiki.  If the piece of
+please refer to <http://mailutils.org/wiki>.  If the piece of
 documentation you are looking for is not available there, don't
 hesitate to post your questions to <bug-mailutils@gnu.org>.
 
@@ -62,7 +62,7 @@ NDBM) simultaneously, without need to reconfigure it.  The database
 flavor to use is selected at runtime, using `database URL'.  For
 example, "gdbm:///etc/mail/aliases.db" refers to a GDBM database.
 
-See http://mailutils.org/wiki/libmu_dbm
+See <http://mailutils.org/wiki/libmu_dbm>.
 
 ** New utility `mu'
 
@@ -72,7 +72,7 @@ about Mailutils configuration, check ACLs and authentication tickets,
 list, create or modify DBM files, construct filters of arbitrary
 complexity and many more.
 
-See http://mailutils.org/wiki/mu
+See <http://mailutils.org/wiki/mu>.
 
 ** Configurable file safety checking
 
@@ -84,7 +84,7 @@ are not used to avoid compromising security.
 
 ** Improved debugging and diagnostics
 
-See http://mailutils.org/wiki/debug_level.
+See <http://mailutils.org/wiki/debug_level>.
 
 ** Imap4d undergone a lot of changes to comply to existing RFCs
 
@@ -99,22 +99,22 @@ mailbox allows that (e.g. maildir).
 New extension action `pipe' invokes arbitrary external program and
 pipes the message (or any part thereof) to it.  
 
-See http://mailutils.org/wiki/Pipe
+See <http://mailutils.org/wiki/Pipe>.
 
 A similar test uses the program exit code to decide what to do with
 the message
 
-See http://mailutils.org/wiki/Pipe_test
+See <http://mailutils.org/wiki/Pipe_test>.
 
 New extension test `list' compares values of mail headers from a
 supplied list with a list of values.
 
-See http://mailutils.org/wiki/List_(Sieve_test)
+See <http://mailutils.org/wiki/List_(Sieve_test)>.
 
 New extension test `timestamp' compares the value of a structured date
 header field with the given date.
 
-See http://mailutils.org/wiki/Timestamp_(Sieve_test)
+See <http://mailutils.org/wiki/Timestamp_(Sieve_test)>.
 
 ** MH: improved compatibility with other implementations
 
@@ -123,11 +123,11 @@ See http://mailutils.org/wiki/Timestamp_(Sieve_test)
 Use `mu cflags' and `mu ldflags' instead.  The mailutils-config is
 rewritten as a wrapper over these commands.
 
-See http://mailutils.org/wiki/mu for more information.
+See <http://mailutils.org/wiki/mu> for more information.
 
 ** movemail functionality considerably improved
 
-See http://mailutils.org/wiki/Fetching_Mail_with_Movemail
+See <http://mailutils.org/wiki/Fetching_Mail_with_Movemail>.
 
 * Configuration changes
 
@@ -171,13 +171,13 @@ representations and for building them from parts.
 ** Filter support is rewritten from scratch
 
 Apart from the implementation itself, lots of new filters are
-provided.  See http://mailutils.org/wiki/Category:Filters for a
+provided.  See <http://mailutils.org/wiki/Category:Filters> for a
 list of those.
 
 A concept of `filter chains' was introduced, which allows for
 creating new filters using existing ones as their components.
 
-See http://mailutils.org/wiki/Mu#filter, for a description.
+See <http://mailutils.org/wiki/Mu#filter>, for a description.
 
 ** POP client library is rewritten from scratch
 
@@ -196,7 +196,7 @@ transaction.
 
 ** Debugging support considerably improved.
 
-See http://mailutils.org/wiki/debug_level.
+See <http://mailutils.org/wiki/debug_level>.
 
 ** Configuration file support (libmu_cfg) rewritten.
 
diff --git a/configure.ac b/configure.ac
index 925a6e0..2bcdf49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ dnl You should have received a copy of the GNU General Public License along
 dnl with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
 AC_PREREQ(2.63)
-AC_INIT([GNU Mailutils], [2.99.93], [bug-mailutils@gnu.org], [mailutils])
+AC_INIT([GNU Mailutils], [2.99.94], [bug-mailutils@gnu.org], [mailutils])
 AC_CONFIG_SRCDIR([libmailutils/mailbox/mailbox.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([gnits 1.11 dist-bzip2 dist-xz std-options silent-rules])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 96a73c6..314490e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -38,7 +38,6 @@ libmu_argp/cmdline.c
 libmu_argp/common.c
 libmu_argp/mu_argp.c
 libmu_argp/sieve.c
-libmu_argp/tls.c
 
 libmu_auth/ldap.c
 libmu_auth/radius.c


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 07 18:07:08 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RNYHU-0001vy-2U
	for mharc-commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:07:08 -0500
Received: from eggs.gnu.org ([140.186.70.92]:48321)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYHR-0001vC-3J
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:07:06 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYHQ-0007FZ-1o
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:07:05 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:50078)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYHP-0007FV-VI
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:07:04 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYHO-0000lu-Fl
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 23:07:03 +0000
Date: Mon, 07 Nov 2011 23:07:02 +0000
Message-Id: <E1RNYHO-0000lu-Fl@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-429-g4f81c76
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 1c291e80c094f3f7249659bc7b312622b64eb91c
X-Git-Newrev: 4f81c7692b1ebca0c1deec9f656fcbbed2b98fa3
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 07 Nov 2011 23:07:06 -0000

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

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

The branch, master has been updated
       via  4f81c7692b1ebca0c1deec9f656fcbbed2b98fa3 (commit)
      from  1c291e80c094f3f7249659bc7b312622b64eb91c (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 4f81c7692b1ebca0c1deec9f656fcbbed2b98fa3
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 8 01:06:54 2011 +0200

    Bugfix
    
    * mu/dbm.c (add_records): Reference mu_strin before using it for
    input.

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

Summary of changes:
 mu/dbm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mu/dbm.c b/mu/dbm.c
index 7f275e2..5568bf4 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -1180,7 +1180,10 @@ add_records (int mode, int replace)
 	}
     }
   else
-    instream = mu_strin;
+    {
+      instream = mu_strin;
+      mu_stream_ref (instream);
+    }
   
   rc = mu_filter_create_args (&flt, instream, "inline-comment",
 			      MU_ARRAY_SIZE (flt_argv) - 1, flt_argv,


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 07 18:39:48 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RNYn6-0008Ea-Gw
	for mharc-commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:39:48 -0500
Received: from eggs.gnu.org ([140.186.70.92]:40136)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYn3-0008E5-Jd
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:39:46 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYn2-00043k-E2
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:39:45 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:48167)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYn2-00043g-CY
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 18:39:44 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNYn2-0003g1-0v
	for commit-mailutils@gnu.org; Mon, 07 Nov 2011 23:39:44 +0000
Date: Mon, 07 Nov 2011 23:39:44 +0000
Message-Id: <E1RNYn2-0003g1-0v@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-430-g1145460
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 4f81c7692b1ebca0c1deec9f656fcbbed2b98fa3
X-Git-Newrev: 1145460edacfc660d886d766bc660b940bfa1912
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 07 Nov 2011 23:39:46 -0000

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

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

The branch, master has been updated
       via  1145460edacfc660d886d766bc660b940bfa1912 (commit)
      from  4f81c7692b1ebca0c1deec9f656fcbbed2b98fa3 (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 1145460edacfc660d886d766bc660b940bfa1912
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 8 01:39:27 2011 +0200

    Minor changes in diagnostic messages.
    
    * maidag/maidag.c (cb_delivery_mode): Fix typo.
    * mail/mail.c (mail_warranty): Update copyright years.

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

Summary of changes:
 maidag/maidag.c |    2 +-
 mail/mail.c     |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/maidag/maidag.c b/maidag/maidag.c
index decbe91..7af762c 100644
--- a/maidag/maidag.c
+++ b/maidag/maidag.c
@@ -412,7 +412,7 @@ cb_delivery_mode (void *data, mu_config_value_t *val)
 	mu_log_syslog = 0;
     }
   else
-    mu_error (_("%s is unknonw"), val->v.string);
+    mu_error (_("%s is unknown"), val->v.string);
   return 0;
 }
 
diff --git a/mail/mail.c b/mail/mail.c
index d0643f9..0ea182c 100644
--- a/mail/mail.c
+++ b/mail/mail.c
@@ -563,8 +563,7 @@ mail_warranty (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
 {
   mu_printf (
 	 _("GNU Mailutils -- a suite of utilities for electronic mail\n"
-           "Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,\n"
-           "2007, 2009, 2010 Free Software Foundation, Inc.\n\n"));
+           "Copyright (C) 1999-2011 Free Software Foundation, Inc.\n\n"));
   mu_printf (
   _("   GNU Mailutils is free software; you can redistribute it and/or modify\n"
     "   it under the terms of the GNU General Public License as published by\n"


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 08 04:20:05 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RNhqf-0006kP-FX
	for mharc-commit-mailutils@gnu.org; Tue, 08 Nov 2011 04:20:05 -0500
Received: from eggs.gnu.org ([140.186.70.92]:40769)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNhqY-0006iw-Ng
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 04:20:04 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNhqS-0003SY-9L
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 04:19:58 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:50646)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNhqS-0003SU-7Y
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 04:19:52 -0500
Received: from polak by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNhqR-0003RU-7N
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 09:19:51 +0000
Date: Tue, 08 Nov 2011 09:19:51 +0000
Message-Id: <E1RNhqR-0003RU-7N@vcs.savannah.gnu.org>
From: "Wojciech Polak" <polak@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-431-g87e973d
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 1145460edacfc660d886d766bc660b940bfa1912
X-Git-Newrev: 87e973ddd0b24493db0b316890360a2fdb028626
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Nov 2011 09:20:04 -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=87e973ddd0b24493db0b316890360a2fdb028626

The branch, master has been updated
       via  87e973ddd0b24493db0b316890360a2fdb028626 (commit)
      from  1145460edacfc660d886d766bc660b940bfa1912 (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 87e973ddd0b24493db0b316890360a2fdb028626
Author: Wojciech Polak <polak@gnu.org>
Date:   Tue Nov 8 10:14:52 2011 +0100

    Re-add Tokyo Cabinet DBM support.
    
    * libmu_dbm/tokyo.c: New file.
    * libmu_dbm/Makefile.am (libmu_dbm_la_SOURCES): Add tokyo.c.
    * doc/texinfo/programs.texi: Update.
    * README: Update.

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

Summary of changes:
 README                    |    4 -
 doc/texinfo/programs.texi |    4 +-
 libmu_dbm/Makefile.am     |    3 +-
 libmu_dbm/tokyo.c         |  231 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 235 insertions(+), 7 deletions(-)
 create mode 100644 libmu_dbm/tokyo.c

diff --git a/README b/README
index 8bb2112..47f7b79 100644
--- a/README
+++ b/README
@@ -287,10 +287,6 @@ use DBM-based mail box quotas with maildag.
 
 	Use Tokyo Cabinet DBM
 
-        Only one dbm option may be specified. Which one depends on
-        the flavor of DBM you are using. GDBM is most common for GNU
-        system.
-
 Use following options to disable support for particular protocols or
 features:
 
diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index 84d9034..5932cd2 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -5648,8 +5648,8 @@ The mailbox quota can be retrieved from the following sources:
 
 To use @acronym{DBM} quota database, GNU Mailutils must
 be compiled with one of the following command line options:
-@option{--with-gdbm}, @option{--with-berkeley-db}, or
-@option{--with-ndbm}.  Examine the output of @command{maidag
+@option{--with-gdbm}, @option{--with-berkeley-db}, @option{--with-ndbm},
+or @option{--with-tokyocabinet}.  Examine the output of @command{maidag
 --show-config-options}, if not sure. 
 
 The quota database should have the following structure:
diff --git a/libmu_dbm/Makefile.am b/libmu_dbm/Makefile.am
index 548f46f..8db66ea 100644
--- a/libmu_dbm/Makefile.am
+++ b/libmu_dbm/Makefile.am
@@ -36,7 +36,8 @@ libmu_dbm_la_SOURCES = \
  store.c\
  berkeley.c\
  gdbm.c\
- ndbm.c
+ ndbm.c\
+ tokyo.c
 
 noinst_HEADERS = mudbm.h
 
diff --git a/libmu_dbm/tokyo.c b/libmu_dbm/tokyo.c
new file mode 100644
index 0000000..606769e
--- /dev/null
+++ b/libmu_dbm/tokyo.c
@@ -0,0 +1,231 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <mailutils/types.h>
+#include <mailutils/dbm.h>
+#include <mailutils/util.h>
+#include <mailutils/errno.h>
+#include <mailutils/error.h>
+#include <mailutils/stream.h>
+#include <mailutils/io.h>
+#include "mudbm.h"
+
+#if defined(WITH_TOKYOCABINET)
+#include <tcutil.h>
+#include <tchdb.h>
+
+static int
+_tc_file_safety (mu_dbm_file_t db, int mode, uid_t owner)
+{
+  return mu_file_safety_check (db->db_name, mode, owner, NULL);
+}
+
+int
+_tc_get_fd (mu_dbm_file_t db, int *pag, int *dir)
+{
+  TCHDB *hdb = db->db_descr;
+  *pag = hdb->fd;
+  if (dir)
+    *dir = *pag;
+  return 0;
+}
+
+static int
+_tc_open (mu_dbm_file_t db, int flags, int mode)
+{
+  int f;
+  bool result;
+  mode_t save_um;
+  TCHDB *hdb;
+
+  switch (flags)
+    {
+    case MU_STREAM_CREAT:
+      f = HDBOWRITER | HDBOCREAT;
+      break;
+
+    case MU_STREAM_READ:
+      f = HDBOREADER;
+      break;
+
+    case MU_STREAM_RDWR:
+      f = HDBOREADER | HDBOWRITER;
+      break;
+
+    default:
+      return EINVAL;
+    }
+
+  hdb = tchdbnew ();
+
+  save_um = umask (0666 & ~mode);
+  result = tchdbopen (hdb, db->db_name, f);
+  umask (save_um);
+  if (!result)
+    {
+      db->db_errno.n = tchdbecode (hdb);
+      return MU_ERR_FAILURE;
+    }
+  db->db_descr = hdb;
+  return 0;
+}
+
+static int
+_tc_close (mu_dbm_file_t db)
+{
+  if (db->db_descr)
+    {
+      TCHDB *hdb = db->db_descr;
+      tchdbclose (hdb);
+      tchdbdel (hdb);
+      db->db_descr = NULL;
+    }
+  return 0;
+}
+
+static int
+_tc_fetch (mu_dbm_file_t db, struct mu_dbm_datum const *key,
+	   struct mu_dbm_datum *ret)
+{
+  TCHDB *hdb = db->db_descr;
+  void *ptr;
+  int retsize;
+
+  ptr = tchdbget (hdb, key->mu_dptr, key->mu_dsize, &retsize);
+  if (ptr)
+    {
+      mu_dbm_datum_free (ret);
+      ret->mu_dptr = ptr;
+      ret->mu_dsize = retsize;
+      return 0;
+    }
+  else if ((db->db_errno.n = tchdbecode (hdb)) == TCENOREC)
+    return MU_ERR_NOENT;
+  return MU_ERR_FAILURE;
+}
+
+static int
+_tc_store (mu_dbm_file_t db,
+	   struct mu_dbm_datum const *key,
+	   struct mu_dbm_datum const *contents,
+	   int replace)
+{
+  TCHDB *hdb = db->db_descr;
+  bool result;
+
+  if (replace)
+    result = tchdbput (hdb, key->mu_dptr, key->mu_dsize,
+		       contents->mu_dptr, contents->mu_dsize);
+  else
+    result = tchdbputkeep (hdb, key->mu_dptr, key->mu_dsize,
+			   contents->mu_dptr, contents->mu_dsize);
+  if (result)
+    return 0;
+  db->db_errno.n = tchdbecode (hdb);
+  if (db->db_errno.n == TCEKEEP)
+    return MU_ERR_EXISTS;
+  return MU_ERR_FAILURE;
+}
+
+static int
+_tc_delete (mu_dbm_file_t db, struct mu_dbm_datum const *key)
+{
+  TCHDB *hdb = db->db_descr;
+
+  if (tchdbout (hdb, key->mu_dptr, key->mu_dsize))
+    return 0;
+  db->db_errno.n = tchdbecode (hdb);
+  if (db->db_errno.n == TCENOREC)
+    return MU_ERR_NOENT;
+  return MU_ERR_FAILURE;
+}
+
+static int
+_tc_firstkey (mu_dbm_file_t db, struct mu_dbm_datum *ret)
+{
+  TCHDB *hdb = db->db_descr;
+  void *ptr;
+  int retsize;
+
+  tchdbiterinit (hdb);
+  ptr = tchdbiternext (hdb, &retsize);
+  if (ptr)
+    {
+      mu_dbm_datum_free (ret);
+      ret->mu_dptr = ptr;
+      ret->mu_dsize = retsize;
+      return 0;
+    }
+  else if ((db->db_errno.n = tchdbecode (hdb)) == TCENOREC)
+    return MU_ERR_NOENT;
+  return MU_ERR_FAILURE;
+}
+
+static int
+_tc_nextkey (mu_dbm_file_t db, struct mu_dbm_datum *ret)
+{
+  TCHDB *hdb = db->db_descr;
+  void *ptr;
+  int retsize;
+
+  ptr = tchdbiternext (hdb, &retsize);
+  if (ptr)
+    {
+      mu_dbm_datum_free (ret);
+      ret->mu_dptr = ptr;
+      ret->mu_dsize = retsize;
+      return 0;
+    }
+  else if ((db->db_errno.n = tchdbecode (hdb)) == TCENOREC)
+    return MU_ERR_NOENT;
+  return MU_ERR_FAILURE;
+}
+
+static void
+_tc_datum_free (struct mu_dbm_datum *datum)
+{
+  free (datum->mu_dptr);
+}
+
+static char const *
+_tc_strerror (mu_dbm_file_t db)
+{
+  return tchdberrmsg (db->db_errno.n);
+}
+
+struct mu_dbm_impl _mu_dbm_tokyokabinet = {
+  "tc",
+  _tc_file_safety,
+  _tc_get_fd,
+  _tc_open,
+  _tc_close,
+  _tc_fetch,
+  _tc_store,
+  _tc_delete,
+  _tc_firstkey,
+  _tc_nextkey,
+  _tc_datum_free,
+  _tc_strerror
+};
+#endif


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 08 07:49:56 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RNl7k-0000jc-ID
	for mharc-commit-mailutils@gnu.org; Tue, 08 Nov 2011 07:49:56 -0500
Received: from eggs.gnu.org ([140.186.70.92]:36455)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNl7h-0000jR-Qf
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 07:49:55 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNl7g-0001gr-I3
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 07:49:53 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:35526)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNl7g-0001gj-D8
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 07:49:52 -0500
Received: from polak by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RNl7f-0006uu-A3
	for commit-mailutils@gnu.org; Tue, 08 Nov 2011 12:49:51 +0000
Date: Tue, 08 Nov 2011 12:49:51 +0000
Message-Id: <E1RNl7f-0006uu-A3@vcs.savannah.gnu.org>
From: "Wojciech Polak" <polak@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-432-g61bccb1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 87e973ddd0b24493db0b316890360a2fdb028626
X-Git-Newrev: 61bccb105baae9104f44bb7da090f9ca05b66bf0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Nov 2011 12:49:55 -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=61bccb105baae9104f44bb7da090f9ca05b66bf0

The branch, master has been updated
       via  61bccb105baae9104f44bb7da090f9ca05b66bf0 (commit)
      from  87e973ddd0b24493db0b316890360a2fdb028626 (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 61bccb105baae9104f44bb7da090f9ca05b66bf0
Author: Wojciech Polak <polak@gnu.org>
Date:   Tue Nov 8 13:48:20 2011 +0100

    Fix typos.

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

Summary of changes:
 libmu_dbm/dbm.c   |    2 +-
 libmu_dbm/mudbm.h |    2 +-
 libmu_dbm/tokyo.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmu_dbm/dbm.c b/libmu_dbm/dbm.c
index 2472dcf..7fd98fa 100644
--- a/libmu_dbm/dbm.c
+++ b/libmu_dbm/dbm.c
@@ -81,7 +81,7 @@ mu_dbm_init ()
   mu_dbm_register (&_mu_dbm_ndbm);
 #endif
 #ifdef WITH_TOKYOCABINET
-  mu_dbm_register (&_mu_dbm_tokyokabinet);
+  mu_dbm_register (&_mu_dbm_tokyocabinet);
 #endif
   if (!mu_dbm_hint)
     {
diff --git a/libmu_dbm/mudbm.h b/libmu_dbm/mudbm.h
index 98c2750..adec30c 100644
--- a/libmu_dbm/mudbm.h
+++ b/libmu_dbm/mudbm.h
@@ -40,7 +40,7 @@ extern struct mu_dbm_impl _mu_dbm_bdb;
 extern struct mu_dbm_impl _mu_dbm_ndbm;
 #endif
 #ifdef WITH_TOKYOCABINET
-extern struct mu_dbm_impl _mu_dbm_tokyokabinet;
+extern struct mu_dbm_impl _mu_dbm_tokyocabinet;
 #endif
 
 void _mu_dbm_init (void);
diff --git a/libmu_dbm/tokyo.c b/libmu_dbm/tokyo.c
index 606769e..19e5b89 100644
--- a/libmu_dbm/tokyo.c
+++ b/libmu_dbm/tokyo.c
@@ -214,7 +214,7 @@ _tc_strerror (mu_dbm_file_t db)
   return tchdberrmsg (db->db_errno.n);
 }
 
-struct mu_dbm_impl _mu_dbm_tokyokabinet = {
+struct mu_dbm_impl _mu_dbm_tokyocabinet = {
   "tc",
   _tc_file_safety,
   _tc_get_fd,


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 09 15:20:27 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ROEdH-0004bJ-BE
	for mharc-commit-mailutils@gnu.org; Wed, 09 Nov 2011 15:20:27 -0500
Received: from eggs.gnu.org ([140.186.70.92]:53654)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROEdE-0004bD-U9
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 15:20:26 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROEdD-0007wf-0U
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 15:20:24 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:35629)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROEdC-0007wV-Uq
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 15:20:22 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROEdB-000643-RV
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 20:20:22 +0000
Date: Wed, 09 Nov 2011 20:20:21 +0000
Message-Id: <E1ROEdB-000643-RV@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-433-g65f1d1f
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 61bccb105baae9104f44bb7da090f9ca05b66bf0
X-Git-Newrev: 65f1d1f2ae3781d1b1839a2aace81d79422bff1a
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 09 Nov 2011 20:20:26 -0000

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

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

The branch, master has been updated
       via  65f1d1f2ae3781d1b1839a2aace81d79422bff1a (commit)
      from  61bccb105baae9104f44bb7da090f9ca05b66bf0 (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 65f1d1f2ae3781d1b1839a2aace81d79422bff1a
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 9 18:23:33 2011 +0200

    spamd sieve test: bugfix.
    
    * libmu_sieve/extensions/spamd.c (get_real_message_size): New function.
    (spamd_test): Use get_real_message_size instead of mu_message_size.

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

Summary of changes:
 libmu_sieve/extensions/spamd.c |   55 ++++++++++++++++++++++++++++++++--------
 1 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/libmu_sieve/extensions/spamd.c b/libmu_sieve/extensions/spamd.c
index a5c8116..354149c 100644
--- a/libmu_sieve/extensions/spamd.c
+++ b/libmu_sieve/extensions/spamd.c
@@ -87,7 +87,7 @@ spamd_send_command (mu_stream_t stream, const char *fmt, ...)
 }
 
 static int
-spamd_send_message (mu_stream_t stream, mu_message_t msg)
+spamd_send_message (mu_stream_t stream, mu_message_t msg, int dbg)
 {
   int rc;
   mu_stream_t mstr, flt;
@@ -120,7 +120,8 @@ spamd_send_message (mu_stream_t stream, mu_message_t msg)
       bufchg = 1;
     }
 
-  if (mu_debug_category_level ("sieve", 5, &dlev) == 0 &&
+  if (dbg &&
+      mu_debug_category_level ("sieve", 5, &dlev) == 0 &&
       !(dlev & MU_DEBUG_LEVEL_MASK (MU_DEBUG_TRACE9)))
     {
       /* Mark out the following data as payload */
@@ -296,6 +297,35 @@ parse_response_line (mu_sieve_machine_t mach, const char *buffer)
   return 0;
 }
 
+/* Compute the "real" size of the message.  This takes into account filtering
+   applied by spamd_send_message (LF->CRLF transcription).
+
+   FIXME: Previous versions used mu_message_size, but it turned out to be
+   unreliable, because it sometimes returns a "normalized" size, which differs
+   from the real one.  This happens when the underlying implementation does
+   not provide a _get_size method, so that the size is computed as a sum of
+   message body and header sizes.  This latter is returned by mu_header_size,
+   which ignores extra whitespace around each semicolon (see header_parse in
+   libmailutils/mailbox/header.c).
+ */
+static int
+get_real_message_size (mu_message_t msg, size_t *psize)
+{
+  mu_stream_t null;
+  mu_stream_stat_buffer stat;
+  int rc;
+  
+  rc = mu_nullstream_create (&null, MU_STREAM_WRITE);
+  if (rc)
+    return rc;
+  mu_stream_set_stat (null, MU_STREAM_STAT_MASK (MU_STREAM_STAT_OUT), stat);
+  rc = spamd_send_message (null, msg, 0);
+  mu_stream_destroy (&null);
+  if (rc == 0)
+    *psize = stat[MU_STREAM_STAT_OUT];
+  return rc;
+}
+
 /* The test proper */
 
 /* Syntax: spamd [":host" <tcp-host: string>]
@@ -326,7 +356,7 @@ static int
 spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 {
   char *buffer = NULL;
-  size_t size = 0;
+  size_t size;
   char spam_str[6], score_str[21], threshold_str[21];
   int rc;
   int result;
@@ -334,7 +364,6 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   mu_stream_t stream = NULL, null;
   mu_sieve_value_t *arg;
   mu_message_t msg;
-  size_t m_size, m_lines;
   char *host;
   mu_header_t hdr;
   mu_debug_handle_t lev = 0;
@@ -348,6 +377,15 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   if (mu_sieve_is_dry_run (mach))
     return 0;
   
+  msg = mu_sieve_get_message (mach);
+  rc = get_real_message_size (msg, &size);
+  if (rc)
+    {
+      mu_sieve_error (mach, _("cannot get real message size: %s"),
+		      mu_strerror (rc));
+      mu_sieve_abort (mach);
+    }
+  
   if (mu_sieve_tag_lookup (tags, "host", &arg))
     host = arg->v.string;
   else
@@ -387,14 +425,9 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
 	}
     }
 
-  msg = mu_sieve_get_message (mach);
-  mu_message_size (msg, &m_size);
-  mu_message_lines (msg, &m_lines);
-
   spamd_send_command (stream, "SYMBOLS SPAMC/1.2");
   
-  spamd_send_command (stream, "Content-length: %lu",
-		      (u_long) (m_size + m_lines));
+  spamd_send_command (stream, "Content-length: %lu", (u_long) size);
   if (mu_sieve_tag_lookup (tags, "user", &arg))
     spamd_send_command (stream, "User: %s", arg);
   else
@@ -408,7 +441,7 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
   handler = set_signal_handler (SIGPIPE, sigpipe_handler);
   
   spamd_send_command (stream, "");
-  spamd_send_message (stream, msg);
+  spamd_send_message (stream, msg, 1);
   mu_stream_shutdown (stream, MU_STREAM_WRITE);
 
   spamd_read_line (mach, stream, &buffer, &size);


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 09 16:01:29 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ROFGz-0000ZM-Na
	for mharc-commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:01:29 -0500
Received: from eggs.gnu.org ([140.186.70.92]:45498)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFGw-0000Tz-4g
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:01:27 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFGt-0006ZS-PS
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:01:26 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46708)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFGt-0006ZO-A2
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:01:23 -0500
Received: from polak by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFGd-00045e-Nu
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 21:01:18 +0000
Date: Wed, 09 Nov 2011 21:01:08 +0000
Message-Id: <E1ROFGd-00045e-Nu@vcs.savannah.gnu.org>
From: "Wojciech Polak" <polak@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-434-gdf905e6
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 65f1d1f2ae3781d1b1839a2aace81d79422bff1a
X-Git-Newrev: df905e61a7c77f02203c3445757a6f59a02a85b0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 09 Nov 2011 21:01:27 -0000

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

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

The branch, master has been updated
       via  df905e61a7c77f02203c3445757a6f59a02a85b0 (commit)
      from  65f1d1f2ae3781d1b1839a2aace81d79422bff1a (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 df905e61a7c77f02203c3445757a6f59a02a85b0
Author: Wojciech Polak <polak@gnu.org>
Date:   Wed Nov 9 21:54:34 2011 +0100

    Add Kyoto Cabinet DBM support.
    
    * libmu_dbm/kyoto.c: New file.
    * libmu_dbm/dbm.c: Update.
    * libmu_dbm/mudbm.h: Update.
    * libmu_dbm/Makefile.am: (libmu_dbm_la_SOURCES): Add kyoto.c
    * configure.ac: Add --with-kyotocabinet.
    * README: Update.
    * doc/texinfo/programs.texi: Likewise.
    * libmailutils/base/version.c: Likewise.

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

Summary of changes:
 README                      |    5 +
 configure.ac                |   19 ++++
 doc/texinfo/programs.texi   |    4 +-
 libmailutils/base/version.c |    3 +
 libmu_dbm/Makefile.am       |    1 +
 libmu_dbm/dbm.c             |    3 +
 libmu_dbm/kyoto.c           |  247 +++++++++++++++++++++++++++++++++++++++++++
 libmu_dbm/mudbm.h           |    3 +
 8 files changed, 283 insertions(+), 2 deletions(-)
 create mode 100644 libmu_dbm/kyoto.c

diff --git a/README b/README
index 47f7b79..82ab9cc 100644
--- a/README
+++ b/README
@@ -287,6 +287,11 @@ use DBM-based mail box quotas with maildag.
 
 	Use Tokyo Cabinet DBM
 
+    --with-kyotocabinet
+
+	Use Kyoto Cabinet DBM
+
+
 Use following options to disable support for particular protocols or
 features:
 
diff --git a/configure.ac b/configure.ac
index 2bcdf49..389800e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -413,6 +413,16 @@ case "${withval}" in
   *)   AC_MSG_ERROR(bad value ${withval} for --with-tokyocabinet) ;;
 esac])
 
+AC_ARG_WITH([kyotocabinet],
+            AC_HELP_STRING([--with-kyotocabinet],
+                           [use Kyoto Cabinet]),
+            [
+case "${withval}" in
+  yes) enable_dbm="$enable_dbm KC";;
+  no)  disable_dbm="$disable_dbm KC";;
+  *)   AC_MSG_ERROR(bad value ${withval} for --with-kyotocabinet) ;;
+esac])
+
 dnl Check for DBM
 
 AH_TEMPLATE([WITH_BDB],
@@ -551,6 +561,15 @@ check_dbm_impl() {
 		       DBMLIB_DEPENDENCY="$DBMLIB_DEPENDENCY -lz -lbz2 -lrt"
                        DBMLIBS="$DBMLIBS -ltokyocabinet"
                        status_dbm="$status_dbm,Tokyo Cabinet"]);;
+
+  KC)
+	  AC_CHECK_LIB(kyotocabinet, kcdbnew,
+                       [AC_CHECK_HEADERS(kclangc.h,
+                                         AC_DEFINE(WITH_KYOTOCABINET,1,
+                                                 [Enable use of Kyoto Cabinet]))
+		       DBMLIB_DEPENDENCY="$DBMLIB_DEPENDENCY -lz -lbz2 -lrt"
+                       DBMLIBS="$DBMLIBS -lkyotocabinet"
+                       status_dbm="$status_dbm,Kyoto Cabinet"]);;
   esac
 }
 
diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi
index 5932cd2..e4ff2ec 100644
--- a/doc/texinfo/programs.texi
+++ b/doc/texinfo/programs.texi
@@ -5649,8 +5649,8 @@ The mailbox quota can be retrieved from the following sources:
 To use @acronym{DBM} quota database, GNU Mailutils must
 be compiled with one of the following command line options:
 @option{--with-gdbm}, @option{--with-berkeley-db}, @option{--with-ndbm},
-or @option{--with-tokyocabinet}.  Examine the output of @command{maidag
---show-config-options}, if not sure. 
+@option{--with-tokyocabinet}, or @option{--with-kyotocabinet}.
+Examine the output of @command{maidag --show-config-options}, if not sure. 
 
 The quota database should have the following structure:
 
diff --git a/libmailutils/base/version.c b/libmailutils/base/version.c
index 2184e05..32c893a 100644
--- a/libmailutils/base/version.c
+++ b/libmailutils/base/version.c
@@ -61,6 +61,9 @@ static struct mu_conf_option mu_conf_option[] = {
 #ifdef WITH_TOKYOCABINET
   { "WITH_TOKYOCABINET", N_("Tokyo Cabinet DBM") },
 #endif
+#ifdef WITH_KYOTOCABINET
+  { "WITH_KYOTOCABINET", N_("Kyoto Cabinet DBM") },
+#endif
 #ifdef WITH_GNUTLS
   { "WITH_GNUTLS", N_("TLS support using GNU TLS") },
 #endif
diff --git a/libmu_dbm/Makefile.am b/libmu_dbm/Makefile.am
index 8db66ea..63b3794 100644
--- a/libmu_dbm/Makefile.am
+++ b/libmu_dbm/Makefile.am
@@ -36,6 +36,7 @@ libmu_dbm_la_SOURCES = \
  store.c\
  berkeley.c\
  gdbm.c\
+ kyoto.c\
  ndbm.c\
  tokyo.c
 
diff --git a/libmu_dbm/dbm.c b/libmu_dbm/dbm.c
index 7fd98fa..1e862fc 100644
--- a/libmu_dbm/dbm.c
+++ b/libmu_dbm/dbm.c
@@ -83,6 +83,9 @@ mu_dbm_init ()
 #ifdef WITH_TOKYOCABINET
   mu_dbm_register (&_mu_dbm_tokyocabinet);
 #endif
+#ifdef WITH_KYOTOCABINET
+  mu_dbm_register (&_mu_dbm_kyotocabinet);
+#endif
   if (!mu_dbm_hint)
     {
       struct mu_dbm_impl *impl;
diff --git a/libmu_dbm/kyoto.c b/libmu_dbm/kyoto.c
new file mode 100644
index 0000000..1830b2f
--- /dev/null
+++ b/libmu_dbm/kyoto.c
@@ -0,0 +1,247 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <mailutils/types.h>
+#include <mailutils/dbm.h>
+#include <mailutils/util.h>
+#include <mailutils/errno.h>
+#include <mailutils/error.h>
+#include <mailutils/stream.h>
+#include <mailutils/io.h>
+#include "mudbm.h"
+
+#if defined(WITH_KYOTOCABINET)
+#include <kclangc.h>
+
+struct kc_descr
+{
+  KCDB *db;    /* db */
+  KCCUR *cur;  /* cursor */
+};
+
+static int
+_kc_file_safety (mu_dbm_file_t db, int mode, uid_t owner)
+{
+  return mu_file_safety_check (db->db_name, mode, owner, NULL);
+}
+
+int
+_kc_get_fd (mu_dbm_file_t db, int *pag, int *dir)
+{
+  return ENOSYS;
+}
+
+static int
+_kc_open (mu_dbm_file_t db, int flags, int mode)
+{
+  struct kc_descr *kcd;
+  int f, result;
+  mode_t save_um;
+  KCDB *kdb;
+
+  switch (flags)
+    {
+    case MU_STREAM_CREAT:
+      f = KCOWRITER | KCOCREATE;
+      break;
+
+    case MU_STREAM_READ:
+      f = KCOREADER;
+      break;
+
+    case MU_STREAM_RDWR:
+      f = KCOREADER | KCOWRITER;
+      break;
+
+    default:
+      return EINVAL;
+    }
+
+  kdb = kcdbnew ();
+
+  save_um = umask (0666 & ~mode);
+  result = kcdbopen (kdb, db->db_name, f);
+  umask (save_um);
+  if (!result)
+    {
+      db->db_errno.n = kcdbecode (kdb);
+      return MU_ERR_FAILURE;
+    }
+
+  kcd = calloc (1, sizeof (*kcd));
+  kcd->db = kdb;
+  kcd->cur = NULL;
+  db->db_descr = kcd;
+  return 0;
+}
+
+static int
+_kc_close (mu_dbm_file_t db)
+{
+  if (db->db_descr)
+    {
+      struct kc_descr *kcd = db->db_descr;
+      kcdbclose (kcd->db);
+      kcdbdel (kcd->db);
+      free (kcd);
+      db->db_descr = NULL;
+    }
+  return 0;
+}
+
+static int
+_kc_fetch (mu_dbm_file_t db, struct mu_dbm_datum const *key,
+	   struct mu_dbm_datum *ret)
+{
+  struct kc_descr *kcd = db->db_descr;
+  void *ptr;
+  size_t retsize;
+
+  ptr = kcdbget (kcd->db, key->mu_dptr, key->mu_dsize, &retsize);
+  if (ptr)
+    {
+      mu_dbm_datum_free (ret);
+      ret->mu_dptr = ptr;
+      ret->mu_dsize = retsize;
+      return 0;
+    }
+  else if ((db->db_errno.n = kcdbecode (kcd->db)) == KCENOREC)
+    return MU_ERR_NOENT;
+  return MU_ERR_FAILURE;
+}
+
+static int
+_kc_store (mu_dbm_file_t db,
+	   struct mu_dbm_datum const *key,
+	   struct mu_dbm_datum const *contents,
+	   int replace)
+{
+  struct kc_descr *kcd = db->db_descr;
+  int result;
+
+  if (replace)
+    result = kcdbreplace (kcd->db, key->mu_dptr, key->mu_dsize,
+			  contents->mu_dptr, contents->mu_dsize);
+  else
+    result = kcdbadd (kcd->db, key->mu_dptr, key->mu_dsize,
+		      contents->mu_dptr, contents->mu_dsize);
+  if (result)
+    return 0;
+  db->db_errno.n = kcdbecode (kcd->db);
+  if (db->db_errno.n == KCEDUPREC)
+    return MU_ERR_EXISTS;
+  return MU_ERR_FAILURE;
+}
+
+static int
+_kc_delete (mu_dbm_file_t db, struct mu_dbm_datum const *key)
+{
+  struct kc_descr *kcd = db->db_descr;
+
+  if (kcdbremove (kcd->db, key->mu_dptr, key->mu_dsize))
+    return 0;
+  db->db_errno.n = kcdbecode (kcd->db);
+  if (db->db_errno.n == KCENOREC)
+    return MU_ERR_NOENT;
+  return MU_ERR_FAILURE;
+}
+
+static int
+_kc_firstkey (mu_dbm_file_t db, struct mu_dbm_datum *ret)
+{
+  struct kc_descr *kcd = db->db_descr;
+  void *ptr;
+  size_t retsize;
+
+  kcd->cur = kcdbcursor (kcd->db);
+  kccurjump (kcd->cur);
+
+  ptr = kccurgetkey (kcd->cur, &retsize, 1);
+  if (ptr)
+    {
+      mu_dbm_datum_free (ret);
+      ret->mu_dptr = ptr;
+      ret->mu_dsize = retsize;
+      return 0;
+    }
+  else if ((db->db_errno.n = kcdbecode (kcd->db)) == KCENOREC)
+    {
+      kccurdel (kcd->cur);
+      kcd->cur = NULL;
+      return MU_ERR_NOENT;
+    }
+  return MU_ERR_FAILURE;
+}
+
+static int
+_kc_nextkey (mu_dbm_file_t db, struct mu_dbm_datum *ret)
+{
+  struct kc_descr *kcd = db->db_descr;
+  void *ptr;
+  size_t retsize;
+
+  ptr = kccurgetkey (kcd->cur, &retsize, 1);
+  if (ptr)
+    {
+      mu_dbm_datum_free (ret);
+      ret->mu_dptr = ptr;
+      ret->mu_dsize = retsize;
+      return 0;
+    }
+  else if ((db->db_errno.n = kcdbecode (kcd->db)) == KCENOREC)
+    {
+      kccurdel (kcd->cur);
+      kcd->cur = NULL;
+      return MU_ERR_NOENT;
+    }
+  return MU_ERR_FAILURE;
+}
+
+static void
+_kc_datum_free (struct mu_dbm_datum *datum)
+{
+  free (datum->mu_dptr);
+}
+
+static char const *
+_kc_strerror (mu_dbm_file_t db)
+{
+  return kcecodename (db->db_errno.n);
+}
+
+struct mu_dbm_impl _mu_dbm_kyotocabinet = {
+  "kc",
+  _kc_file_safety,
+  _kc_get_fd,
+  _kc_open,
+  _kc_close,
+  _kc_fetch,
+  _kc_store,
+  _kc_delete,
+  _kc_firstkey,
+  _kc_nextkey,
+  _kc_datum_free,
+  _kc_strerror
+};
+#endif
diff --git a/libmu_dbm/mudbm.h b/libmu_dbm/mudbm.h
index adec30c..b52ec21 100644
--- a/libmu_dbm/mudbm.h
+++ b/libmu_dbm/mudbm.h
@@ -42,6 +42,9 @@ extern struct mu_dbm_impl _mu_dbm_ndbm;
 #ifdef WITH_TOKYOCABINET
 extern struct mu_dbm_impl _mu_dbm_tokyocabinet;
 #endif
+#ifdef WITH_KYOTOCABINET
+extern struct mu_dbm_impl _mu_dbm_kyotocabinet;
+#endif
 
 void _mu_dbm_init (void);
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 09 16:40:31 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ROFsl-0006mX-50
	for mharc-commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:40:31 -0500
Received: from eggs.gnu.org ([140.186.70.92]:55246)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFsj-0006mO-Co
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:40:30 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFsi-0004ul-1F
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:40:29 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:53545)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFsh-0004ug-Rk
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 16:40:27 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROFsa-0000TY-IQ
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 21:40:22 +0000
Date: Wed, 09 Nov 2011 21:40:20 +0000
Message-Id: <E1ROFsa-0000TY-IQ@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-435-g47c1814
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: df905e61a7c77f02203c3445757a6f59a02a85b0
X-Git-Newrev: 47c18140b870504d9ce4d4c386530c1a73dccfe2
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 09 Nov 2011 21:40:30 -0000

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

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

The branch, master has been updated
       via  47c18140b870504d9ce4d4c386530c1a73dccfe2 (commit)
      from  df905e61a7c77f02203c3445757a6f59a02a85b0 (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 47c18140b870504d9ce4d4c386530c1a73dccfe2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 9 23:38:52 2011 +0200

    Implement _dbm_get_fd in Kyoto cabinet.
    
    * libmu_dbm/kyoto.c: Implement _dbm_get_fd.

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

Summary of changes:
 libmu_dbm/kyoto.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/libmu_dbm/kyoto.c b/libmu_dbm/kyoto.c
index 1830b2f..52563d7 100644
--- a/libmu_dbm/kyoto.c
+++ b/libmu_dbm/kyoto.c
@@ -19,6 +19,7 @@
 # include <config.h>
 #endif
 #include <fcntl.h>
+#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -38,6 +39,7 @@ struct kc_descr
 {
   KCDB *db;    /* db */
   KCCUR *cur;  /* cursor */
+  int fd;
 };
 
 static int
@@ -49,7 +51,17 @@ _kc_file_safety (mu_dbm_file_t db, int mode, uid_t owner)
 int
 _kc_get_fd (mu_dbm_file_t db, int *pag, int *dir)
 {
-  return ENOSYS;
+  struct kc_descr *kcd = db->db_descr;
+  if (kcd->fd == -1)
+    {
+      kcd->fd = open (db->db_name, O_RDONLY);
+      if (kcd->fd == -1)
+	return errno;
+    }
+  *pag = kcd->fd;
+  if (dir)
+    *dir = kcd->fd;
+  return 0;
 }
 
 static int
@@ -93,6 +105,7 @@ _kc_open (mu_dbm_file_t db, int flags, int mode)
   kcd->db = kdb;
   kcd->cur = NULL;
   db->db_descr = kcd;
+  kcd->fd = -1;
   return 0;
 }
 
@@ -102,6 +115,8 @@ _kc_close (mu_dbm_file_t db)
   if (db->db_descr)
     {
       struct kc_descr *kcd = db->db_descr;
+      if (kcd->fd != -1)
+	close (kcd->fd);
       kcdbclose (kcd->db);
       kcdbdel (kcd->db);
       free (kcd);


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 09 19:02:53 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ROI6X-00060N-48
	for mharc-commit-mailutils@gnu.org; Wed, 09 Nov 2011 19:02:53 -0500
Received: from eggs.gnu.org ([140.186.70.92]:43934)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROI6T-0005zu-Oj
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 19:02:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROI6R-0003j8-TJ
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 19:02:49 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46592)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROI6R-0003j0-Rc
	for commit-mailutils@gnu.org; Wed, 09 Nov 2011 19:02:47 -0500
Received: from polak by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROI6R-00028Y-1A
	for commit-mailutils@gnu.org; Thu, 10 Nov 2011 00:02:47 +0000
Date: Thu, 10 Nov 2011 00:02:47 +0000
Message-Id: <E1ROI6R-00028Y-1A@vcs.savannah.gnu.org>
From: "Wojciech Polak" <polak@gnu.org>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-436-g243dee2
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 47c18140b870504d9ce4d4c386530c1a73dccfe2
X-Git-Newrev: 243dee23f08cb06311bfb3dbc77a45985cc51ca6
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Nov 2011 00:02:51 -0000

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

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

The branch, master has been updated
       via  243dee23f08cb06311bfb3dbc77a45985cc51ca6 (commit)
      from  47c18140b870504d9ce4d4c386530c1a73dccfe2 (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 243dee23f08cb06311bfb3dbc77a45985cc51ca6
Author: Wojciech Polak <polak@gnu.org>
Date:   Thu Nov 10 00:54:31 2011 +0100

    Update Python interface.
    
    * python/libmu_py/filter.c: Bugfix.
    * python/libmu_py/url.c (api_url_parse): Remove.
    * python/mailutils/error.py: Update MU_ERR_* values.
    * python/mailutils/url.py (Url): Remove parse() method.
    * examples/python/iconv.py: Remove open/close method calls.
    * examples/python/mailcap.py: Likewise.
    * examples/python/url-parse.py: Remove parse() call.

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

Summary of changes:
 examples/python/iconv.py     |   11 +----
 examples/python/mailcap.py   |    2 -
 examples/python/url-parse.py |    1 -
 python/libmu_py/filter.c     |    4 +-
 python/libmu_py/url.c        |   15 ------
 python/mailutils/error.py    |  102 +++++++++++++++++++++++++----------------
 python/mailutils/url.py      |    8 ---
 7 files changed, 65 insertions(+), 78 deletions(-)

diff --git a/examples/python/iconv.py b/examples/python/iconv.py
index b5c7e83..4fb32b0 100644
--- a/examples/python/iconv.py
+++ b/examples/python/iconv.py
@@ -23,22 +23,13 @@ if len (sys.argv) != 3:
     sys.exit (0)
 
 sti = stream.StdioStream (stream.MU_STDIN_FD)
-sti.open ()
-
 cvt = filter.FilterIconvStream (sti, sys.argv[1], sys.argv[2])
-cvt.open ()
-
 out = stream.StdioStream (stream.MU_STDOUT_FD, 0)
-out.open ()
 
 total = 0
 while True:
-    buf = cvt.read (total)
+    buf = cvt.read ()
     out.write (buf)
     total += cvt.read_count
     if not cvt.read_count:
         break
-
-out.flush ()
-out.close ()
-sti.close ()
diff --git a/examples/python/mailcap.py b/examples/python/mailcap.py
index 6b72531..c0abaa3 100644
--- a/examples/python/mailcap.py
+++ b/examples/python/mailcap.py
@@ -17,8 +17,6 @@
 from mailutils import stream, mailcap
 
 stm = stream.FileStream ("/etc/mailcap")
-stm.open ()
-
 mc = mailcap.Mailcap (stm)
 
 for i, entry in enumerate (mc):
diff --git a/examples/python/url-parse.py b/examples/python/url-parse.py
index 593d22d..ed4c5fd 100644
--- a/examples/python/url-parse.py
+++ b/examples/python/url-parse.py
@@ -21,7 +21,6 @@ from mailutils.error import *
 def parse (str):
     try:
 	u = url.Url (str)
-	u.parse ()
         print "URL: %s" % u
 
 	print "\tscheme <%s>" % u.get_scheme ()
diff --git a/python/libmu_py/filter.c b/python/libmu_py/filter.c
index 6e3ce3e..4cc58ed 100644
--- a/python/libmu_py/filter.c
+++ b/python/libmu_py/filter.c
@@ -66,8 +66,8 @@ api_filter_iconv_create (PyObject *self, PyObject *args)
 
   argv[1] = fromcode;
   argv[2] = tocode;
-  mu_filter_create_args (&py_stm->stm, py_transport->stm, argv[0], 3, argv,
-			 MU_FILTER_DECODE, flags);
+  status = mu_filter_create_args (&py_stm->stm, py_transport->stm, argv[0], 3,
+				  argv, MU_FILTER_DECODE, flags);
   return _ro (PyInt_FromLong (status));
 }
 
diff --git a/python/libmu_py/url.c b/python/libmu_py/url.c
index d42bc35..02af1af 100644
--- a/python/libmu_py/url.c
+++ b/python/libmu_py/url.c
@@ -102,18 +102,6 @@ api_url_destroy (PyObject *self, PyObject *args)
   return _ro (Py_None);
 }
 
-/* FIXME: Remove */
-static PyObject *
-api_url_parse (PyObject *self, PyObject *args)
-{
-  PyUrl *py_url;
-
-  if (!PyArg_ParseTuple (args, "O!", &PyUrlType, &py_url))
-    return NULL;
-
-  return _ro (0);
-}
-
 static PyObject *
 api_url_get_port (PyObject *self, PyObject *args)
 {
@@ -255,9 +243,6 @@ static PyMethodDef methods[] = {
   { "destroy", (PyCFunction) api_url_destroy, METH_VARARGS,
     "Destroy the url and free its resources." },
 
-  { "parse", (PyCFunction) api_url_parse, METH_VARARGS,
-    "Parse the url, after calling this the get functions can be called." },
-
   { "to_string", (PyCFunction) api_url_to_string, METH_VARARGS,
     "" },
 
diff --git a/python/mailutils/error.py b/python/mailutils/error.py
index 9eb8492..0e79fa8 100644
--- a/python/mailutils/error.py
+++ b/python/mailutils/error.py
@@ -48,11 +48,11 @@ MU_ERR_BASE = 0x1000
 
 MU_ERR_FAILURE = (MU_ERR_BASE+0)
 MU_ERR_CANCELED = (MU_ERR_BASE+1)
-MU_ERR_NO_HANDLER = (MU_ERR_BASE+2)
-MU_ERR_EMPTY_VFN = (MU_ERR_BASE+3)
-MU_ERR_OUT_NULL = (MU_ERR_BASE+4)
-MU_ERR_OUT_PTR_NULL = (MU_ERR_BASE+5)
-MU_ERR_MBX_NULL = (MU_ERR_BASE+6)
+MU_ERR_EMPTY_VFN = (MU_ERR_BASE+2)
+MU_ERR_OUT_PTR_NULL = (MU_ERR_BASE+3)
+MU_ERR_MBX_REMOVED = (MU_ERR_BASE+4)
+MU_ERR_NOT_OPEN = (MU_ERR_BASE+5)
+MU_ERR_OPEN = (MU_ERR_BASE+6)
 MU_ERR_INVALID_EMAIL = (MU_ERR_BASE+7)
 MU_ERR_EMPTY_ADDRESS = (MU_ERR_BASE+8)
 MU_ERR_LOCKER_NULL = (MU_ERR_BASE+9)
@@ -65,38 +65,60 @@ MU_ERR_LOCK_EXT_ERR = (MU_ERR_BASE+15)
 MU_ERR_LOCK_EXT_KILLED = (MU_ERR_BASE+16)
 MU_ERR_NO_SUCH_USER = (MU_ERR_BASE+17)
 MU_ERR_GETHOSTBYNAME = (MU_ERR_BASE+18)
-MU_ERR_BAD_RESUMPTION = (MU_ERR_BASE+19)
-MU_ERR_MAILER_BAD_FROM = (MU_ERR_BASE+20)
-MU_ERR_MAILER_BAD_TO = (MU_ERR_BASE+21)
-MU_ERR_MAILER_NO_RCPT_TO = (MU_ERR_BASE+22)
-MU_ERR_MAILER_BAD_URL = (MU_ERR_BASE+23)
-MU_ERR_SMTP_RCPT_FAILED = (MU_ERR_BASE+24)
-MU_ERR_TCP_NO_HOST = (MU_ERR_BASE+25)
-MU_ERR_TCP_NO_PORT = (MU_ERR_BASE+26)
-MU_ERR_BAD_2047_INPUT = (MU_ERR_BASE+27)
-MU_ERR_BAD_2047_ENCODING = (MU_ERR_BASE+28)
-MU_ERR_NOUSERNAME = (MU_ERR_BASE+29)
-MU_ERR_NOPASSWORD = (MU_ERR_BASE+30)
-MU_ERR_UNSAFE_PERMS = (MU_ERR_BASE+31)
-MU_ERR_BAD_AUTH_SCHEME = (MU_ERR_BASE+32)
-MU_ERR_AUTH_FAILURE = (MU_ERR_BASE+33)
-MU_ERR_PROCESS_NOEXEC = (MU_ERR_BASE+34)
-MU_ERR_PROCESS_EXITED = (MU_ERR_BASE+35)
-MU_ERR_PROCESS_SIGNALED = (MU_ERR_BASE+36)
-MU_ERR_PROCESS_UNKNOWN_FAILURE = (MU_ERR_BASE+37)
-MU_ERR_CONN_CLOSED = (MU_ERR_BASE+38)
-MU_ERR_PARSE = (MU_ERR_BASE+39)
-MU_ERR_NOENT = (MU_ERR_BASE+40)
-MU_ERR_EXISTS = (MU_ERR_BASE+41)
-MU_ERR_BUFSPACE = (MU_ERR_BASE+42)
-MU_ERR_SQL = (MU_ERR_BASE+43)
-MU_ERR_DB_ALREADY_CONNECTED = (MU_ERR_BASE+44)
-MU_ERR_DB_NOT_CONNECTED = (MU_ERR_BASE+45)
-MU_ERR_RESULT_NOT_RELEASED = (MU_ERR_BASE+46)
-MU_ERR_NO_QUERY = (MU_ERR_BASE+47)
-MU_ERR_BAD_COLUMN = (MU_ERR_BASE+48)
-MU_ERR_NO_RESULT = (MU_ERR_BASE+49)
-MU_ERR_NO_INTERFACE = (MU_ERR_BASE+50)
-MU_ERR_BADOP = (MU_ERR_BASE+51)
-MU_ERR_BAD_FILENAME = (MU_ERR_BASE+52)
-MU_ERR_READ = (MU_ERR_BASE+53)
+MU_ERR_MAILER_BAD_FROM = (MU_ERR_BASE+19)
+MU_ERR_MAILER_BAD_TO = (MU_ERR_BASE+20)
+MU_ERR_MAILER_NO_RCPT_TO = (MU_ERR_BASE+21)
+MU_ERR_MAILER_BAD_URL = (MU_ERR_BASE+22)
+MU_ERR_SMTP_RCPT_FAILED = (MU_ERR_BASE+23)
+MU_ERR_TCP_NO_HOST = (MU_ERR_BASE+24)
+MU_ERR_TCP_NO_PORT = (MU_ERR_BASE+25)
+MU_ERR_BAD_2047_INPUT = (MU_ERR_BASE+26)
+MU_ERR_BAD_2047_ENCODING = (MU_ERR_BASE+27)
+MU_ERR_NOUSERNAME = (MU_ERR_BASE+28)
+MU_ERR_NOPASSWORD = (MU_ERR_BASE+29)
+MU_ERR_BADREPLY = (MU_ERR_BASE+30)
+MU_ERR_SEQ = (MU_ERR_BASE+31)
+MU_ERR_REPLY = (MU_ERR_BASE+32)
+MU_ERR_BAD_AUTH_SCHEME = (MU_ERR_BASE+33)
+MU_ERR_AUTH_FAILURE = (MU_ERR_BASE+34)
+MU_ERR_PROCESS_NOEXEC = (MU_ERR_BASE+35)
+MU_ERR_PROCESS_EXITED = (MU_ERR_BASE+36)
+MU_ERR_PROCESS_SIGNALED = (MU_ERR_BASE+37)
+MU_ERR_PROCESS_UNKNOWN_FAILURE = (MU_ERR_BASE+38)
+MU_ERR_CONN_CLOSED = (MU_ERR_BASE+39)
+MU_ERR_PARSE = (MU_ERR_BASE+40)
+MU_ERR_NOENT = (MU_ERR_BASE+41)
+MU_ERR_EXISTS = (MU_ERR_BASE+42)
+MU_ERR_BUFSPACE = (MU_ERR_BASE+43)
+MU_ERR_SQL = (MU_ERR_BASE+44)
+MU_ERR_DB_ALREADY_CONNECTED = (MU_ERR_BASE+45)
+MU_ERR_DB_NOT_CONNECTED = (MU_ERR_BASE+46)
+MU_ERR_RESULT_NOT_RELEASED = (MU_ERR_BASE+47)
+MU_ERR_NO_QUERY = (MU_ERR_BASE+48)
+MU_ERR_BAD_COLUMN = (MU_ERR_BASE+49)
+MU_ERR_NO_RESULT = (MU_ERR_BASE+50)
+MU_ERR_NO_INTERFACE = (MU_ERR_BASE+51)
+MU_ERR_BADOP = (MU_ERR_BASE+52)
+MU_ERR_BAD_FILENAME = (MU_ERR_BASE+53)
+MU_ERR_READ = (MU_ERR_BASE+54)
+MU_ERR_NO_TRANSPORT = (MU_ERR_BASE+55)
+MU_ERR_AUTH_NO_CRED = (MU_ERR_BASE+56)
+MU_ERR_URL_MISS_PARTS = (MU_ERR_BASE+57)
+MU_ERR_URL_EXTRA_PARTS = (MU_ERR_BASE+58)
+MU_ERR_URL_INVALID_PARAMETER = (MU_ERR_BASE+59)
+MU_ERR_INFO_UNAVAILABLE = (MU_ERR_BASE+60)
+MU_ERR_NONAME = (MU_ERR_BASE+61)
+MU_ERR_BADFLAGS = (MU_ERR_BASE+62)
+MU_ERR_SOCKTYPE = (MU_ERR_BASE+63)
+MU_ERR_FAMILY = (MU_ERR_BASE+64)
+MU_ERR_SERVICE = (MU_ERR_BASE+65)
+MU_ERR_PERM_OWNER_MISMATCH = (MU_ERR_BASE+66)
+MU_ERR_PERM_GROUP_WRITABLE = (MU_ERR_BASE+67)
+MU_ERR_PERM_WORLD_WRITABLE = (MU_ERR_BASE+68)
+MU_ERR_PERM_GROUP_READABLE = (MU_ERR_BASE+69)
+MU_ERR_PERM_WORLD_READABLE = (MU_ERR_BASE+70)
+MU_ERR_PERM_LINKED_WRDIR = (MU_ERR_BASE+71)
+MU_ERR_PERM_DIR_IWGRP = (MU_ERR_BASE+72)
+MU_ERR_PERM_DIR_IWOTH = (MU_ERR_BASE+73)
+MU_ERR_DISABLED = (MU_ERR_BASE+74)
+MU_ERR_LAST = (MU_ERR_BASE+75)
diff --git a/python/mailutils/url.py b/python/mailutils/url.py
index 5c19eec..c9025e5 100644
--- a/python/mailutils/url.py
+++ b/python/mailutils/url.py
@@ -40,14 +40,6 @@ class Url:
     def __str__ (self):
         return url.to_string (self.url)
 
-    def parse (self):
-        """Parses the url, after calling this the get functions
-        can be called."""
-        if self.__owner:
-            status = url.parse (self.url)
-            if status:
-                raise UrlError (status)
-
     def get_port (self):
         status, port = url.get_port (self.url)
         if status:


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 10 07:13:27 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1ROTVX-0000if-Oo
	for mharc-commit-mailutils@gnu.org; Thu, 10 Nov 2011 07:13:27 -0500
Received: from eggs.gnu.org ([140.186.70.92]:44348)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROTVT-0000iE-TA
	for commit-mailutils@gnu.org; Thu, 10 Nov 2011 07:13:25 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROTVS-0002Ir-Fy
	for commit-mailutils@gnu.org; Thu, 10 Nov 2011 07:13:23 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:52416)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROTVS-0002Im-ES
	for commit-mailutils@gnu.org; Thu, 10 Nov 2011 07:13:22 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1ROTVS-0005TE-5Y
	for commit-mailutils@gnu.org; Thu, 10 Nov 2011 12:13:22 +0000
Date: Thu, 10 Nov 2011 12:13:22 +0000
Message-Id: <E1ROTVS-0005TE-5Y@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-439-ge0222cd
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 243dee23f08cb06311bfb3dbc77a45985cc51ca6
X-Git-Newrev: e0222cd50d0970eed9e93dccac98477b55078e5f
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Nov 2011 12:13:25 -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=e0222cd50d0970eed9e93dccac98477b55078e5f

The branch, master has been updated
       via  e0222cd50d0970eed9e93dccac98477b55078e5f (commit)
       via  ebcdaaf0a4293c81229f6b8e5287d3a6a77b8f83 (commit)
       via  56e4e27fba8e192966c9574ec60863da9bea2a38 (commit)
      from  243dee23f08cb06311bfb3dbc77a45985cc51ca6 (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 e0222cd50d0970eed9e93dccac98477b55078e5f
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 10 14:12:31 2011 +0200

    Minor fix
    
    * libmu_dbm/dbm.c (mu_dbm_create_from_url): Fix owner= parameter.

commit ebcdaaf0a4293c81229f6b8e5287d3a6a77b8f83
Merge: 56e4e27 243dee2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 10 14:06:20 2011 +0200

    Merge branch 'master' of ssh://gray@git.sv.gnu.org/srv/git/mailutils

commit 56e4e27fba8e192966c9574ec60863da9bea2a38
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 9 23:02:19 2011 +0200

    Minor change
    
    * libmailutils/base/version.c (mu_conf_option): Reflect BDB support.

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

Summary of changes:
 libmailutils/base/version.c |    6 +++---
 libmu_dbm/dbm.c             |   13 +++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/libmailutils/base/version.c b/libmailutils/base/version.c
index 32c893a..54e9d26 100644
--- a/libmailutils/base/version.c
+++ b/libmailutils/base/version.c
@@ -49,12 +49,12 @@ static struct mu_conf_option mu_conf_option[] = {
 #ifdef WITH_BDB2
   { "WITH_BDB2", N_("Berkeley DB v. 2") },
 #endif
+#ifdef WITH_BDB
+  { "WITH_BDB", N_("Berkeley DB") },
+#endif
 #ifdef WITH_NDBM
   { "WITH_NDBM", },
 #endif
-#ifdef WITH_OLD_DBM
-  { "WITH_OLD_DBM", N_("Old DBM support") },
-#endif
 #ifdef WITH_GDBM
   { "WITH_GDBM", N_("GNU DBM") },
 #endif
diff --git a/libmu_dbm/dbm.c b/libmu_dbm/dbm.c
index 1e862fc..80df67a 100644
--- a/libmu_dbm/dbm.c
+++ b/libmu_dbm/dbm.c
@@ -190,7 +190,12 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
 	      if (name[5] == '=')
 		{
 		  auth = mu_get_auth_by_name (name + 6);
-		  if (!auth)
+		  if (auth)
+		    {
+		      owner_uid = auth->uid;
+		      mu_auth_data_free (auth);
+		    }
+		  else
 		    {
 		      char *end;
 		      unsigned long uid;
@@ -199,11 +204,7 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
 		      uid = strtoul (name + 6, &end, 0);
 		      if (*end || errno)
 			return MU_ERR_NO_SUCH_USER;
-		      auth = mu_get_auth_by_uid (uid);
-		      if (!auth)
-			return MU_ERR_NO_SUCH_USER;
-		      owner_uid = auth->uid;
-		      mu_auth_data_free (auth);
+		      owner_uid = uid;
 		    }
 		}
 	      else if (name[5])


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 12 03:48:06 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RP9Fu-0003Zg-M8
	for mharc-commit-mailutils@gnu.org; Sat, 12 Nov 2011 03:48:06 -0500
Received: from eggs.gnu.org ([140.186.70.92]:34900)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RP9Fs-0003ZW-GK
	for commit-mailutils@gnu.org; Sat, 12 Nov 2011 03:48:05 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RP9Fq-000762-PM
	for commit-mailutils@gnu.org; Sat, 12 Nov 2011 03:48:04 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:58058)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RP9Fq-00075x-Nb
	for commit-mailutils@gnu.org; Sat, 12 Nov 2011 03:48:02 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RP9Fq-00069l-Hw
	for commit-mailutils@gnu.org; Sat, 12 Nov 2011 08:48:02 +0000
Date: Sat, 12 Nov 2011 08:48:02 +0000
Message-Id: <E1RP9Fq-00069l-Hw@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-440-gc7fb4a0
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: e0222cd50d0970eed9e93dccac98477b55078e5f
X-Git-Newrev: c7fb4a0f593a9d79c2fee327441f2905d887f334
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 12 Nov 2011 08:48: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=c7fb4a0f593a9d79c2fee327441f2905d887f334

The branch, master has been updated
       via  c7fb4a0f593a9d79c2fee327441f2905d887f334 (commit)
      from  e0222cd50d0970eed9e93dccac98477b55078e5f (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 c7fb4a0f593a9d79c2fee327441f2905d887f334
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 12 10:48:10 2011 +0200

    Minor change
    
    * mu/dbm.c (add_records): Set DBM meta-data after populating it with
    data.

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

Summary of changes:
 mu/dbm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mu/dbm.c b/mu/dbm.c
index 5568bf4..ee217ca 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -1252,8 +1252,6 @@ add_records (int mode, int replace)
   
   /* Open the database */
   db = open_db_file (mode);
-  if (known_meta_data)
-    set_db_ownership (db);
   
   /* Read and store the actual data */
   if (rc == 0 && input_length (&input) > 0)
@@ -1282,6 +1280,8 @@ add_records (int mode, int replace)
   mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS,
 		   &save_locus);
   
+  if (known_meta_data)
+    set_db_ownership (db);
   mu_dbm_destroy (&db);
   mu_stream_unref (instream);
 }


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 15 15:42:35 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RQPpz-0001lB-2D
	for mharc-commit-mailutils@gnu.org; Tue, 15 Nov 2011 15:42:35 -0500
Received: from eggs.gnu.org ([140.186.70.92]:59151)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQPpr-0001k4-FK
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 15:42:32 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQPpm-0005nO-CA
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 15:42:27 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:57544)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQPpm-0005nH-AZ
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 15:42:22 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQPpl-0004Az-Gz
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 20:42:22 +0000
Date: Tue, 15 Nov 2011 20:42:21 +0000
Message-Id: <E1RQPpl-0004Az-Gz@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-441-g1814cf1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c7fb4a0f593a9d79c2fee327441f2905d887f334
X-Git-Newrev: 1814cf1d9b07f3e6d47c5d23daa03288d8426040
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 15 Nov 2011 20:42:32 -0000

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

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

The branch, master has been updated
       via  1814cf1d9b07f3e6d47c5d23daa03288d8426040 (commit)
      from  c7fb4a0f593a9d79c2fee327441f2905d887f334 (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 1814cf1d9b07f3e6d47c5d23daa03288d8426040
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 15 22:42:08 2011 +0200

    Minor changes.
    
    * libmu_cfg/tls.c (SSL_KEY_FILE_CHECKS): Mask out
    MU_FILE_SAFETY_OWNER_MISMATCH bit.
    * mu/shell.c: Handle SIGPIPE and SIGINTR.

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

Summary of changes:
 libmu_cfg/tls.c |    2 +-
 mu/shell.c      |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/libmu_cfg/tls.c b/libmu_cfg/tls.c
index 8bcc518..e09ab28 100644
--- a/libmu_cfg/tls.c
+++ b/libmu_cfg/tls.c
@@ -28,7 +28,7 @@
 			       MU_FILE_SAFETY_GROUP_WRITABLE |		\
 			       MU_FILE_SAFETY_LINKED_WRDIR)
 
-#define SSL_KEY_FILE_CHECKS   MU_FILE_SAFETY_ALL
+#define SSL_KEY_FILE_CHECKS   (MU_FILE_SAFETY_ALL & ~MU_FILE_SAFETY_OWNER_MISMATCH)
 
 #define SSL_CA_FILE_CHECKS    (MU_FILE_SAFETY_GROUP_WRITABLE |		\
 			       MU_FILE_SAFETY_GROUP_WRITABLE |		\
diff --git a/mu/shell.c b/mu/shell.c
index 9baceb1..9d2c90c 100644
--- a/mu/shell.c
+++ b/mu/shell.c
@@ -19,6 +19,7 @@
 #endif
 #include <stdlib.h>
 #include <string.h>
+#include <signal.h>
 #include <mailutils/mailutils.h>
 #include <mailutils/tls.h>
 #include "mailutils/libargp.h"
@@ -35,6 +36,33 @@ char **mutool_prompt_env;
 int mutool_shell_interactive;
 
 
+static int got_signal = 0;
+
+static void
+_shell_sig (int sig)
+{
+  got_signal = sig;
+}
+
+#define shell_interrupted() (got_signal == SIGINT)
+
+static void
+report_signals ()
+{
+  switch (got_signal)
+    {
+    case 0:
+      break;
+
+    case SIGINT:
+      mu_stream_printf (mu_strerr, _("Interrupt\n"));
+      mu_stream_flush (mu_strerr);
+
+    default:
+      got_signal = 0;
+    }
+}
+
 static int shell_exit (int, char **);
 static int shell_help (int, char **);
 static int shell_prompt (int, char **);
@@ -274,6 +302,27 @@ get_history_file_name ()
   return filename;
 }
 
+static int
+_shell_getc (FILE *stream)
+{
+  unsigned char c;
+
+  while (1)
+    {
+      if (read (fileno (stream), &c, 1) == 1)
+	return c;
+      if (errno == EINTR)
+	{
+	  if (shell_interrupted ())
+	    break;
+	  /* keep going if we handled the signal */
+	}
+      else
+	break;
+    }
+  return EOF;
+}
+
 /* Interface to Readline Completion */
 
 static char *shell_command_generator (const char *, int);
@@ -288,6 +337,7 @@ mutool_initialize_readline (const char *name)
   /* Allow conditional parsing of the ~/.inputrc file. */
   rl_readline_name = (char *) name;
   rl_attempted_completion_function = (CPPFunction *) shell_completion;
+  rl_getc_function = _shell_getc;
   read_history (get_history_file_name ());
 }
 
@@ -507,6 +557,7 @@ input_line_interactive ()
   int wsflags = MU_WRDSF_NOSPLIT | MU_WRDSF_NOCMD;
   struct mu_wordsplit ws;
   
+  report_signals ();
   if (mutool_prompt_env)
     {
       ws.ws_env = (const char **)mutool_prompt_env;
@@ -528,6 +579,7 @@ input_line_script ()
   size_t size = 0, n;
   char *buf = NULL;
 
+  report_signals ();
   if (mu_stream_getline (mu_strin, &buf, &size, &n) || n == 0)
     return NULL;
   return buf;
@@ -541,13 +593,14 @@ shell_exit (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
   done = 1;
   return 0;
 }
-  
+
 int
 mutool_shell (const char *name, struct mutool_command *cmd)
 {
   size_t n;
   char *(*input_line) ();
-
+  static int sigv[] = { SIGPIPE, SIGINT };
+				   
   mutool_shell_interactive = isatty (0);
   input_line = mutool_shell_interactive ?
                              input_line_interactive : input_line_script;
@@ -562,12 +615,21 @@ mutool_shell (const char *name, struct mutool_command *cmd)
   memcpy (shell_comtab + n, default_comtab, sizeof (default_comtab));
 
   mutool_initialize_readline (name);
+  mu_set_signals (_shell_sig, sigv, MU_ARRAY_SIZE (sigv));
   while (!done)
     {
       char *s, *line = input_line ();
       if (!line)
-	break;
-
+	{
+	  if (shell_interrupted ())
+	    {
+	      report_signals ();
+	      continue;
+	    }
+	  else
+	    break;
+	}
+      
       /* Remove leading and trailing whitespace from the line.
          Then, if there is anything left, add it to the history list
          and execute it. */


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 15 17:07:20 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RQRA0-0006yt-AN
	for mharc-commit-mailutils@gnu.org; Tue, 15 Nov 2011 17:07:20 -0500
Received: from eggs.gnu.org ([140.186.70.92]:54051)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQR9t-0006yH-3W
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 17:07:18 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQR9m-0003ZZ-Ul
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 17:07:12 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56536)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQR9m-0003ZV-T4
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 17:07:06 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RQR9k-0003tC-03
	for commit-mailutils@gnu.org; Tue, 15 Nov 2011 22:07:06 +0000
Date: Tue, 15 Nov 2011 22:07:04 +0000
Message-Id: <E1RQR9k-0003tC-03@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-442-gb26b212
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 1814cf1d9b07f3e6d47c5d23daa03288d8426040
X-Git-Newrev: b26b2120ce815173819cf5bea197d4f5264aecdb
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 15 Nov 2011 22:07:18 -0000

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

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

The branch, master has been updated
       via  b26b2120ce815173819cf5bea197d4f5264aecdb (commit)
      from  1814cf1d9b07f3e6d47c5d23daa03288d8426040 (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 b26b2120ce815173819cf5bea197d4f5264aecdb
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 15 23:59:24 2011 +0200

    Import error codes directly from libmailutils to Python.
    
    * python/libmu_py/Makefile.am (libmu_py_la_SOURCES): Add errno.c
    * python/libmu_py/errno.c: New file.
    * python/libmu_py/libmu_py.c (_mu_py_module_name): New function.
    (_mu_py_attach_module): Use _mu_py_module_name to allocate FQ
    module name instead of taking the risk of using fixed size buffer.
    Don't call Py_InitModule if methods is NULL.
    (mu_py_attach_modules): Call _mu_py_attach_errno.
    * python/libmu_py/libmu_py.h (_mu_py_attach_errno): New proto.
    * python/mailutils/error.py: Re-export everything from c_api.errno.
    Remove hardcoded definitions of error codes.

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

Summary of changes:
 python/libmu_py/Makefile.am                       |    1 +
 include/mailutils/io.h => python/libmu_py/errno.c |   33 ++++-----
 python/libmu_py/libmu_py.c                        |   25 +++++--
 python/libmu_py/libmu_py.h                        |    1 +
 python/mailutils/error.py                         |   79 +--------------------
 5 files changed, 37 insertions(+), 102 deletions(-)
 copy include/mailutils/io.h => python/libmu_py/errno.c (70%)

diff --git a/python/libmu_py/Makefile.am b/python/libmu_py/Makefile.am
index 596931c..d3d198d 100644
--- a/python/libmu_py/Makefile.am
+++ b/python/libmu_py/Makefile.am
@@ -19,6 +19,7 @@ INCLUDES = @MU_LIB_COMMON_INCLUDES@ $(PYTHON_INCLUDES)
 lib_LTLIBRARIES=libmu_py.la
 libmu_py_la_SOURCES = \
  error.c \
+ errno.c \
  address.c \
  attribute.c \
  auth.c \
diff --git a/include/mailutils/io.h b/python/libmu_py/errno.c
similarity index 70%
copy from include/mailutils/io.h
copy to python/libmu_py/errno.c
index 8485851..2616bbc 100644
--- a/include/mailutils/io.h
+++ b/python/libmu_py/errno.c
@@ -15,21 +15,20 @@
    Public License along with this library.  If not, see 
    <http://www.gnu.org/licenses/>. */
 
-#ifndef _MAILUTILS_IO_H
-#define _MAILUTILS_IO_H
-
-#include <stdarg.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int mu_asprintf (char **pbuf, const char *fmt, ...);
-int mu_asnprintf (char **pbuf, size_t *psize, const char *fmt, ...);
-int mu_vasnprintf (char **pbuf, size_t *psize, const char *fmt, va_list ap);
-
-#ifdef __cplusplus
+#include "libmu_py.h"
+#include <mailutils/errno.h>
+
+#define PY_MODULE "errno"
+
+void
+_mu_py_attach_errno (void)
+{
+  int i;
+  PyObject *module = _mu_py_attach_module (PY_MODULE, NULL);
+
+  for (i = MU_ERR_BASE; i < MU_ERR_LAST; i++)
+    {
+      const char *en = mu_errname (i);
+      PyModule_AddIntConstant (module, en, i);
+    }
 }
-#endif
-
-#endif
diff --git a/python/libmu_py/libmu_py.c b/python/libmu_py/libmu_py.c
index d9da2b1..16c9dad 100644
--- a/python/libmu_py/libmu_py.c
+++ b/python/libmu_py/libmu_py.c
@@ -42,14 +42,23 @@ status_object (int status, PyObject *py_obj)
 static PyObject *package;
 static PyObject *all;
 
+#define MU_MODULE_ROOT PY_PACKAGE_NAME "." PY_ROOT_NAME "."
+
+static char *
+_mu_py_module_name (const char *nm)
+{
+  char *buf = malloc (sizeof (MU_MODULE_ROOT) + strlen (nm));
+  if (!buf)
+    abort ();
+  return strcat (strcpy (buf, MU_MODULE_ROOT), nm);
+}
+  
 PyObject *
 _mu_py_attach_module (const char *name, PyMethodDef *methods)
 {
-  PyObject *module, *m;
-
-  char ns[64] = PY_PACKAGE_NAME "." PY_ROOT_NAME ".";
-  strcat (ns, name);
-
+  PyObject *module;
+  char *ns = _mu_py_module_name (name);
+  
   if (!(module = PyImport_AddModule (ns)))
     return NULL;
 
@@ -58,11 +67,12 @@ _mu_py_attach_module (const char *name, PyMethodDef *methods)
 
   Py_INCREF (module);
 
-  if (!(m = Py_InitModule (ns, methods)))
+  if (methods && !Py_InitModule (ns, methods))
     return NULL;
 
   PyList_Append (all, PyString_FromString (name));
-  return m;
+  free (ns);
+  return module;
 }
 
 void
@@ -111,6 +121,7 @@ mu_py_attach_modules (void)
   _mu_py_attach_auth ();
   _mu_py_attach_body ();
   _mu_py_attach_envelope ();
+  _mu_py_attach_errno ();
   _mu_py_attach_header ();
   _mu_py_attach_filter ();
   _mu_py_attach_folder ();
diff --git a/python/libmu_py/libmu_py.h b/python/libmu_py/libmu_py.h
index 77f5f64..1a5128e 100644
--- a/python/libmu_py/libmu_py.h
+++ b/python/libmu_py/libmu_py.h
@@ -65,6 +65,7 @@ extern void _mu_py_attach_attribute (void);
 extern void _mu_py_attach_auth (void);
 extern void _mu_py_attach_body (void);
 extern void _mu_py_attach_envelope (void);
+extern void _mu_py_attach_errno (void);
 extern void _mu_py_attach_header  (void);
 extern void _mu_py_attach_filter (void);
 extern void _mu_py_attach_folder (void);
diff --git a/python/mailutils/error.py b/python/mailutils/error.py
index 0e79fa8..503ffef 100644
--- a/python/mailutils/error.py
+++ b/python/mailutils/error.py
@@ -16,6 +16,7 @@
 #  <http://www.gnu.org/licenses/>.
 
 from mailutils.c_api import error
+from mailutils.c_api.errno import *
 
 def strerror (status):
     return error.strerror (status)
@@ -44,81 +45,3 @@ class SieveMachineError (Error): pass
 class StreamError (Error): pass
 class UrlError (Error): pass
 
-MU_ERR_BASE = 0x1000
-
-MU_ERR_FAILURE = (MU_ERR_BASE+0)
-MU_ERR_CANCELED = (MU_ERR_BASE+1)
-MU_ERR_EMPTY_VFN = (MU_ERR_BASE+2)
-MU_ERR_OUT_PTR_NULL = (MU_ERR_BASE+3)
-MU_ERR_MBX_REMOVED = (MU_ERR_BASE+4)
-MU_ERR_NOT_OPEN = (MU_ERR_BASE+5)
-MU_ERR_OPEN = (MU_ERR_BASE+6)
-MU_ERR_INVALID_EMAIL = (MU_ERR_BASE+7)
-MU_ERR_EMPTY_ADDRESS = (MU_ERR_BASE+8)
-MU_ERR_LOCKER_NULL = (MU_ERR_BASE+9)
-MU_ERR_LOCK_CONFLICT = (MU_ERR_BASE+10)
-MU_ERR_LOCK_BAD_LOCK = (MU_ERR_BASE+11)
-MU_ERR_LOCK_BAD_FILE = (MU_ERR_BASE+12)
-MU_ERR_LOCK_NOT_HELD = (MU_ERR_BASE+13)
-MU_ERR_LOCK_EXT_FAIL = (MU_ERR_BASE+14)
-MU_ERR_LOCK_EXT_ERR = (MU_ERR_BASE+15)
-MU_ERR_LOCK_EXT_KILLED = (MU_ERR_BASE+16)
-MU_ERR_NO_SUCH_USER = (MU_ERR_BASE+17)
-MU_ERR_GETHOSTBYNAME = (MU_ERR_BASE+18)
-MU_ERR_MAILER_BAD_FROM = (MU_ERR_BASE+19)
-MU_ERR_MAILER_BAD_TO = (MU_ERR_BASE+20)
-MU_ERR_MAILER_NO_RCPT_TO = (MU_ERR_BASE+21)
-MU_ERR_MAILER_BAD_URL = (MU_ERR_BASE+22)
-MU_ERR_SMTP_RCPT_FAILED = (MU_ERR_BASE+23)
-MU_ERR_TCP_NO_HOST = (MU_ERR_BASE+24)
-MU_ERR_TCP_NO_PORT = (MU_ERR_BASE+25)
-MU_ERR_BAD_2047_INPUT = (MU_ERR_BASE+26)
-MU_ERR_BAD_2047_ENCODING = (MU_ERR_BASE+27)
-MU_ERR_NOUSERNAME = (MU_ERR_BASE+28)
-MU_ERR_NOPASSWORD = (MU_ERR_BASE+29)
-MU_ERR_BADREPLY = (MU_ERR_BASE+30)
-MU_ERR_SEQ = (MU_ERR_BASE+31)
-MU_ERR_REPLY = (MU_ERR_BASE+32)
-MU_ERR_BAD_AUTH_SCHEME = (MU_ERR_BASE+33)
-MU_ERR_AUTH_FAILURE = (MU_ERR_BASE+34)
-MU_ERR_PROCESS_NOEXEC = (MU_ERR_BASE+35)
-MU_ERR_PROCESS_EXITED = (MU_ERR_BASE+36)
-MU_ERR_PROCESS_SIGNALED = (MU_ERR_BASE+37)
-MU_ERR_PROCESS_UNKNOWN_FAILURE = (MU_ERR_BASE+38)
-MU_ERR_CONN_CLOSED = (MU_ERR_BASE+39)
-MU_ERR_PARSE = (MU_ERR_BASE+40)
-MU_ERR_NOENT = (MU_ERR_BASE+41)
-MU_ERR_EXISTS = (MU_ERR_BASE+42)
-MU_ERR_BUFSPACE = (MU_ERR_BASE+43)
-MU_ERR_SQL = (MU_ERR_BASE+44)
-MU_ERR_DB_ALREADY_CONNECTED = (MU_ERR_BASE+45)
-MU_ERR_DB_NOT_CONNECTED = (MU_ERR_BASE+46)
-MU_ERR_RESULT_NOT_RELEASED = (MU_ERR_BASE+47)
-MU_ERR_NO_QUERY = (MU_ERR_BASE+48)
-MU_ERR_BAD_COLUMN = (MU_ERR_BASE+49)
-MU_ERR_NO_RESULT = (MU_ERR_BASE+50)
-MU_ERR_NO_INTERFACE = (MU_ERR_BASE+51)
-MU_ERR_BADOP = (MU_ERR_BASE+52)
-MU_ERR_BAD_FILENAME = (MU_ERR_BASE+53)
-MU_ERR_READ = (MU_ERR_BASE+54)
-MU_ERR_NO_TRANSPORT = (MU_ERR_BASE+55)
-MU_ERR_AUTH_NO_CRED = (MU_ERR_BASE+56)
-MU_ERR_URL_MISS_PARTS = (MU_ERR_BASE+57)
-MU_ERR_URL_EXTRA_PARTS = (MU_ERR_BASE+58)
-MU_ERR_URL_INVALID_PARAMETER = (MU_ERR_BASE+59)
-MU_ERR_INFO_UNAVAILABLE = (MU_ERR_BASE+60)
-MU_ERR_NONAME = (MU_ERR_BASE+61)
-MU_ERR_BADFLAGS = (MU_ERR_BASE+62)
-MU_ERR_SOCKTYPE = (MU_ERR_BASE+63)
-MU_ERR_FAMILY = (MU_ERR_BASE+64)
-MU_ERR_SERVICE = (MU_ERR_BASE+65)
-MU_ERR_PERM_OWNER_MISMATCH = (MU_ERR_BASE+66)
-MU_ERR_PERM_GROUP_WRITABLE = (MU_ERR_BASE+67)
-MU_ERR_PERM_WORLD_WRITABLE = (MU_ERR_BASE+68)
-MU_ERR_PERM_GROUP_READABLE = (MU_ERR_BASE+69)
-MU_ERR_PERM_WORLD_READABLE = (MU_ERR_BASE+70)
-MU_ERR_PERM_LINKED_WRDIR = (MU_ERR_BASE+71)
-MU_ERR_PERM_DIR_IWGRP = (MU_ERR_BASE+72)
-MU_ERR_PERM_DIR_IWOTH = (MU_ERR_BASE+73)
-MU_ERR_DISABLED = (MU_ERR_BASE+74)
-MU_ERR_LAST = (MU_ERR_BASE+75)


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 17 14:05:25 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RR7H3-0006Q1-DG
	for mharc-commit-mailutils@gnu.org; Thu, 17 Nov 2011 14:05:25 -0500
Received: from eggs.gnu.org ([140.186.70.92]:44742)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR7H1-0006Pa-1L
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 14:05:24 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR7Gy-0007Yy-H8
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 14:05:23 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33575)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR7Gy-0007Yt-E9
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 14:05:20 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR7Gw-0005v6-RW
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 19:05:19 +0000
Date: Thu, 17 Nov 2011 19:05:19 +0000
Message-Id: <E1RR7Gw-0005v6-RW@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-443-g2ec525a
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b26b2120ce815173819cf5bea197d4f5264aecdb
X-Git-Newrev: 2ec525acff5a090dcba8a0c7c166bbe745340902
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 17 Nov 2011 19:05:24 -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=2ec525acff5a090dcba8a0c7c166bbe745340902

The branch, master has been updated
       via  2ec525acff5a090dcba8a0c7c166bbe745340902 (commit)
      from  b26b2120ce815173819cf5bea197d4f5264aecdb (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 2ec525acff5a090dcba8a0c7c166bbe745340902
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 17 18:19:15 2011 +0200

    Improve wordsplit.
    
    * include/mailutils/wordsplit.h (mu_wordsplit) <ws_escape>: New member.
    (MU_WRDSF_ESCAPE): New flag.
    (mu_wordsplit_general_unquote_copy): New function.
    * libmailutils/string/wordsplit.c: Remove empty nodes after whitespace
    trimming.  If MU_WRDSF_ESCAPE is set, remove only backslashes appearing
    in front of a character in ws_escape.
    * libmailutils/tests/wordsplit.at: Test new features.

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

Summary of changes:
 include/mailutils/wordsplit.h   |    6 ++++
 libmailutils/string/wordsplit.c |   55 ++++++++++++++++++++++++++++++--------
 libmailutils/tests/wordsplit.at |   17 ++++++++++++
 3 files changed, 66 insertions(+), 12 deletions(-)

diff --git a/include/mailutils/wordsplit.h b/include/mailutils/wordsplit.h
index 3ddedb6..0ce33a3 100644
--- a/include/mailutils/wordsplit.h
+++ b/include/mailutils/wordsplit.h
@@ -28,6 +28,7 @@ struct mu_wordsplit
   int ws_flags;
   const char *ws_delim;
   const char *ws_comment;
+  const char *ws_escape;
   void (*ws_alloc_die) (struct mu_wordsplit *wsp);
   void (*ws_error) (const char *, ...)
 		    __attribute__ ((__format__ (__printf__, 1, 2)));
@@ -110,6 +111,9 @@ struct mu_wordsplit
    stored in the element that follows its name. */
 #define MU_WRDSF_ENV_KV            0x4000000
 
+/* ws_escape is set */
+#define MU_WRDSF_ESCAPE            0x8000000
+
 #define MU_WRDSF_DEFFLAGS	       \
   (MU_WRDSF_NOVAR | MU_WRDSF_NOCMD | \
    MU_WRDSF_QUOTE | MU_WRDSF_SQUEEZE_DELIMS | MU_WRDSF_CESCAPES)
@@ -132,6 +136,8 @@ int mu_wordsplit_c_unquote_char (int c);
 int mu_wordsplit_c_quote_char (int c);
 size_t mu_wordsplit_c_quoted_length (const char *str, int quote_hex,
 				     int *quote);
+void mu_wordsplit_general_unquote_copy (char *dst, const char *src, size_t n,
+					const char *escapable);
 void mu_wordsplit_sh_unquote_copy (char *dst, const char *src, size_t n);
 void mu_wordsplit_c_unquote_copy (char *dst, const char *src, size_t n);
 void mu_wordsplit_c_quote_copy (char *dst, const char *src, int quote_hex);
diff --git a/libmailutils/string/wordsplit.c b/libmailutils/string/wordsplit.c
index 26342dc..4536cc2 100644
--- a/libmailutils/string/wordsplit.c
+++ b/libmailutils/string/wordsplit.c
@@ -500,7 +500,12 @@ wsnode_quoteremoval (struct mu_wordsplit *wsp)
 	      p->v.word = newstr;
 	      p->flags |= _WSNF_WORD;
 	    }
-	  uqfn (p->v.word, str, slen);
+
+	  if (wsp->ws_flags & MU_WRDSF_ESCAPE)
+	    mu_wordsplit_general_unquote_copy (p->v.word, str, slen,
+					       wsp->ws_escape);
+	  else
+	    uqfn (p->v.word, str, slen);
 	}
     }
   return 0;
@@ -906,32 +911,39 @@ node_expand_vars (struct mu_wordsplit *wsp, struct mu_wordsplit_node *node)
   return 0;
 }
 
-static int
-mu_wordsplit_varexp (struct mu_wordsplit *wsp)
+/* Remove NULL lists */
+static void
+wsnode_nullelim (struct mu_wordsplit *wsp)
 {
   struct mu_wordsplit_node *p;
 
   for (p = wsp->ws_head; p;)
     {
       struct mu_wordsplit_node *next = p->next;
-      if (!(p->flags & _WSNF_NOEXPAND))
-	if (node_expand_vars (wsp, p))
-	  return 1;
+      if (p->flags & _WSNF_NULL)
+	{
+	  wsnode_remove (wsp, p);
+	  wsnode_free (p);
+	}
       p = next;
     }
+}
+
+static int
+mu_wordsplit_varexp (struct mu_wordsplit *wsp)
+{
+  struct mu_wordsplit_node *p;
 
-  /* Remove NULL lists */
   for (p = wsp->ws_head; p;)
     {
       struct mu_wordsplit_node *next = p->next;
-      if (p->flags & _WSNF_NULL)
-	{
-	  wsnode_remove (wsp, p);
-	  wsnode_free (p);
-	}
+      if (!(p->flags & _WSNF_NOEXPAND))
+	if (node_expand_vars (wsp, p))
+	  return 1;
       p = next;
     }
 
+  wsnode_nullelim (wsp);
   return 0;
 }
 
@@ -959,7 +971,11 @@ mu_wordsplit_trimws (struct mu_wordsplit *wsp)
       for (n = p->v.segm.end; n > p->v.segm.beg && ISWS (wsp->ws_input[n-1]);
 	   n--);
       p->v.segm.end = n;
+      if (p->v.segm.beg == p->v.segm.end)
+	p->flags |= _WSNF_NULL;
     }
+
+  wsnode_nullelim (wsp);
 }
 
 static int
@@ -1217,6 +1233,21 @@ mu_wordsplit_c_quoted_length (const char *str, int quote_hex, int *quote)
 }
 
 void
+mu_wordsplit_general_unquote_copy (char *dst, const char *src, size_t n,
+				   const char *escapable)
+{
+  int i;
+
+  for (i = 0; i < n;)
+    {
+      if (src[i] == '\\' && i < n && strchr (escapable, src[i+1]))
+	i++;
+      *dst++ = src[i++];
+    }
+  *dst = 0;
+}
+
+void
 mu_wordsplit_sh_unquote_copy (char *dst, const char *src, size_t n)
 {
   int i;
diff --git a/libmailutils/tests/wordsplit.at b/libmailutils/tests/wordsplit.at
index 8625f95..99b0dcb 100644
--- a/libmailutils/tests/wordsplit.at
+++ b/libmailutils/tests/wordsplit.at
@@ -313,6 +313,15 @@ TESTWSP([C escapes off],[],[-cescapes],
 3: newnline
 ])
 
+TESTWSP([ws elimination],[],[delim ' ()' ws return_delims],
+[( list  items  )],
+[NF: 4
+0: (
+1: list
+2: items
+3: )
+])
+
 TESTWSP([empty quotes],[],[delim : ws return_delims],
 [t=""],
 [NF: 1
@@ -338,4 +347,12 @@ TESTWSP([suppress ws trimming within quotes],[],
 4: "formatfield=In message %{text}, "
 ])
 
+TESTWSP([unescape],[],[-default novar nocmd quote escape '\"'],
+[\Seen "quote \"" "bs \\"],
+[NF: 3
+0: \\Seen
+1: "quote \""
+2: "bs \\"
+])
+
 m4_popdef([TESTWSP])


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 17 15:08:26 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RR8G2-0001MD-E2
	for mharc-commit-mailutils@gnu.org; Thu, 17 Nov 2011 15:08:26 -0500
Received: from eggs.gnu.org ([140.186.70.92]:35948)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR8Fx-0001IE-F0
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 15:08:24 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR8Ft-0002AV-Az
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 15:08:21 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:45016)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR8Ft-0002AR-8j
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 15:08:17 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RR8Fq-0004RM-2J
	for commit-mailutils@gnu.org; Thu, 17 Nov 2011 20:08:17 +0000
Date: Thu, 17 Nov 2011 20:08:14 +0000
Message-Id: <E1RR8Fq-0004RM-2J@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-444-g6f309ce
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 2ec525acff5a090dcba8a0c7c166bbe745340902
X-Git-Newrev: 6f309ce61dcfb461c3fe1270efe2b23a7ac5d676
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 17 Nov 2011 20:08:24 -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=6f309ce61dcfb461c3fe1270efe2b23a7ac5d676

The branch, master has been updated
       via  6f309ce61dcfb461c3fe1270efe2b23a7ac5d676 (commit)
      from  2ec525acff5a090dcba8a0c7c166bbe745340902 (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 6f309ce61dcfb461c3fe1270efe2b23a7ac5d676
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 17 21:07:52 2011 +0200

    Implement IMAP I/O functions for client and server.
    
    * include/mailutils/imapio.h: New file.
    * include/mailutils/sys/imapio.h: New file.
    * libmailutils/imapio/create.c: New file.
    * libmailutils/imapio/getline.c: New file.
    * libmailutils/imapio/literal.c: New file.
    * libmailutils/imapio/printf.c: New file.
    * libmailutils/imapio/qstring.c: New file.
    * libmailutils/imapio/send.c: New file.
    * libmailutils/imapio/trace.c: New file.
    * libmailutils/imapio/words.c: New file.
    * libmailutils/imapio/xscript.c: New file.
    
    * configure.ac: Build libmailutils/imapio/Makefile
    * include/mailutils/Makefile.am (pkginclude_HEADERS): Add imapio.h.
    * include/mailutils/imapio.h: New file.
    * include/mailutils/sys/Makefile.am (sysinclude_HEADERS): Add imapio.h.
    * include/mailutils/sys/imapio.h: New file.
    * include/mailutils/types.hin (mu_imapio_t): New data type.
    * libmailutils/Makefile.am (SUBDIRS): Add imapio.
    
    * libmailutils/tests/Makefile.am: Build imapio
    * libmailutils/tests/imapio.c: New source.
    * libmailutils/tests/wsp.c: Handle escape argument

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

Summary of changes:
 configure.ac                                      |    1 +
 include/mailutils/Makefile.am                     |    1 +
 include/mailutils/imapio.h                        |   52 ++++++++++
 include/mailutils/sys/Makefile.am                 |    1 +
 mail/help.c => include/mailutils/sys/imapio.h     |   39 +++----
 include/mailutils/types.hin                       |    2 +
 libmailutils/Makefile.am                          |    3 +-
 libmailutils/{sockaddr => imapio}/Makefile.am     |   20 ++--
 libmailutils/imapio/create.c                      |   63 +++++++++++
 libmailutils/imapio/getline.c                     |  114 +++++++++++++++++++++
 mail/exit.c => libmailutils/imapio/literal.c      |   18 ++-
 mail/cd.c => libmailutils/imapio/printf.c         |   38 +++----
 libmailutils/imapio/qstring.c                     |   72 +++++++++++++
 mail/exit.c => libmailutils/imapio/send.c         |   16 ++-
 libmailutils/imapio/trace.c                       |   86 ++++++++++++++++
 examples/muemail.c => libmailutils/imapio/words.c |   47 ++++-----
 lib/tcpwrap.h => libmailutils/imapio/xscript.c    |   41 +++++---
 libmailutils/tests/.gitignore                     |    1 +
 libmailutils/tests/Makefile.am                    |    1 +
 libmailutils/tests/imapio.c                       |   95 +++++++++++++++++
 libmailutils/tests/wsp.c                          |    5 +
 21 files changed, 607 insertions(+), 109 deletions(-)
 create mode 100644 include/mailutils/imapio.h
 copy mail/help.c => include/mailutils/sys/imapio.h (62%)
 copy libmailutils/{sockaddr => imapio}/Makefile.am (85%)
 create mode 100644 libmailutils/imapio/create.c
 create mode 100644 libmailutils/imapio/getline.c
 copy mail/exit.c => libmailutils/imapio/literal.c (62%)
 copy mail/cd.c => libmailutils/imapio/printf.c (62%)
 create mode 100644 libmailutils/imapio/qstring.c
 copy mail/exit.c => libmailutils/imapio/send.c (67%)
 create mode 100644 libmailutils/imapio/trace.c
 copy examples/muemail.c => libmailutils/imapio/words.c (55%)
 copy lib/tcpwrap.h => libmailutils/imapio/xscript.c (51%)
 create mode 100644 libmailutils/tests/imapio.c

diff --git a/configure.ac b/configure.ac
index 389800e..7251453 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1472,6 +1472,7 @@ AC_CONFIG_FILES([
  libmailutils/cfg/Makefile
  libmailutils/diag/Makefile
  libmailutils/filter/Makefile
+ libmailutils/imapio/Makefile
  libmailutils/mailbox/Makefile
  libmailutils/mailer/Makefile
  libmailutils/mime/Makefile
diff --git a/include/mailutils/Makefile.am b/include/mailutils/Makefile.am
index 6682884..27c1b5a 100644
--- a/include/mailutils/Makefile.am
+++ b/include/mailutils/Makefile.am
@@ -52,6 +52,7 @@ pkginclude_HEADERS = \
  guile.h\
  header.h\
  imap.h\
+ imapio.h\
  io.h\
  iterator.h\
  kwd.h\
diff --git a/include/mailutils/imapio.h b/include/mailutils/imapio.h
new file mode 100644
index 0000000..387e3df
--- /dev/null
+++ b/include/mailutils/imapio.h
@@ -0,0 +1,52 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _MAILUTILS_IMAPIO_H
+# define _MAILUTILS_IMAPIO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+# include <mailutils/types.h>
+  
+int mu_imapio_create (mu_imapio_t *iop, mu_stream_t str);
+void mu_imapio_free (mu_imapio_t io);
+void mu_imapio_destroy (mu_imapio_t *pio);
+  
+int mu_imapio_getline (mu_imapio_t io);
+int mu_imapio_set_xscript_level (mu_imapio_t io, int xlev);  
+int mu_imapio_get_words (mu_imapio_t io, size_t *pwc, char ***pwv);
+
+int mu_imapio_send (mu_imapio_t io, const char *buf, size_t bytes);
+int mu_imapio_printf (mu_imapio_t io, const char *fmt, ...);
+int mu_imapio_send_literal (struct _mu_imapio *io, const char *buffer);
+int mu_imapio_send_qstring (struct _mu_imapio *io, const char *buffer);
+int mu_imapio_send_qstring_unfold (struct _mu_imapio *io, const char *buffer,
+				   int unfold);
+
+int mu_imapio_trace_enable (mu_imapio_t io);
+int mu_imapio_trace_disable (mu_imapio_t io);
+int mu_imapio_get_trace (mu_imapio_t io);
+
+int mu_imapio_getbuf (mu_imapio_t io, char **pptr, size_t *psize);
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _MAILUTILS_IMAPIO_H */
+  
diff --git a/include/mailutils/sys/Makefile.am b/include/mailutils/sys/Makefile.am
index e46a294..86412d0 100644
--- a/include/mailutils/sys/Makefile.am
+++ b/include/mailutils/sys/Makefile.am
@@ -31,6 +31,7 @@ sysinclude_HEADERS = \
  header_stream.h\
  header.h\
  imap.h\
+ imapio.h\
  iterator.h\
  iostream.h\
  list.h\
diff --git a/mail/help.c b/include/mailutils/sys/imapio.h
similarity index 62%
copy from mail/help.c
copy to include/mailutils/sys/imapio.h
index 16e873d..524c5be 100644
--- a/mail/help.c
+++ b/include/mailutils/sys/imapio.h
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007, 2010, 2011 Free Software
-   Foundation, Inc.
+   Copyright (C) 2011 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -15,26 +14,22 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "mail.h"
+#ifndef _MAILUTILS_SYS_IMAPIO_H
+# define _MAILUTILS_SYS_IMAPIO_H
 
-/*
- * hel[p] [command]
- * ? [command]
- */
+#include <mailutils/types.h>
+#include <mailutils/wordsplit.h>
 
-int
-mail_help (int argc, char **argv)
+struct _mu_imapio
 {
-  if (argc < 2)
-    return mail_command_help (NULL);
-  else
-    {
-      int status = 0;
-
-      while (--argc)
-	status |= mail_command_help (*++argv);
-
-      return status;
-    }
-  return 1;
-}
+  mu_stream_t _imap_stream;
+  char *_imap_buf_base;
+  size_t _imap_buf_size;
+  size_t _imap_buf_level;
+  struct mu_wordsplit _imap_ws;
+  int _imap_ws_flags;
+  int _imap_transcript:1;
+  int _imap_reply_ready:1;
+};
+  
+#endif
diff --git a/include/mailutils/types.hin b/include/mailutils/types.hin
index c1f4b44..b98d617 100644
--- a/include/mailutils/types.hin
+++ b/include/mailutils/types.hin
@@ -76,6 +76,7 @@ struct _mu_acl;
 struct _mu_server;
 struct _mu_tcp_server;
 struct _mu_dbm_file;
+struct _mu_imapio;
   
 struct mu_sockaddr; /* defined in mailutils/sockaddr.h */  
 struct mu_cidr;     /* defined in mailutils/cidr.h */  
@@ -123,6 +124,7 @@ typedef struct _mu_progmailer *mu_progmailer_t;
 typedef struct _mu_secret *mu_secret_t;
 typedef struct _mu_mime_io_buffer *mu_mime_io_buffer_t;
 typedef struct _mu_dbm_file *mu_dbm_file_t;
+typedef struct _mu_imapio *mu_imapio_t;
 
 typedef void (*mu_onexit_t) (void*);
 typedef unsigned int mu_debug_handle_t;
diff --git a/libmailutils/Makefile.am b/libmailutils/Makefile.am
index 5aef338..7c1c5c4 100644
--- a/libmailutils/Makefile.am
+++ b/libmailutils/Makefile.am
@@ -17,7 +17,7 @@
 # <http://www.gnu.org/licenses/>.
 
 SUBDIRS = auth base address sockaddr cidr cfg diag filter mailbox mailer mime\
- server string stream stdstream property url . tests 
+ server string stream stdstream property url imapio . tests 
 
 lib_LTLIBRARIES = libmailutils.la
 
@@ -33,6 +33,7 @@ libmailutils_la_LIBADD = \
  cfg/libcfg.la\
  diag/libdiag.la\
  filter/libfilter.la\
+ imapio/libimapio.la\
  mailbox/libmailbox.la\
  mailer/libmailer.la\
  mime/libmime.la\
diff --git a/libmailutils/sockaddr/Makefile.am b/libmailutils/imapio/Makefile.am
similarity index 85%
copy from libmailutils/sockaddr/Makefile.am
copy to libmailutils/imapio/Makefile.am
index dcfb184..74f36a2 100644
--- a/libmailutils/sockaddr/Makefile.am
+++ b/libmailutils/imapio/Makefile.am
@@ -15,17 +15,17 @@
 # Public License along with this library.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-noinst_LTLIBRARIES = libsockaddr.la
+noinst_LTLIBRARIES = libimapio.la
 
-libsockaddr_la_SOURCES = \
- copy.c\
+libimapio_la_SOURCES = \
  create.c\
- free.c\
- fromnode.c\
- insert.c\
- ipaddr.c\
- str.c\
- unlink.c\
- url.c
+ getline.c\
+ literal.c\
+ printf.c\
+ qstring.c\
+ send.c\
+ trace.c\
+ words.c\
+ xscript.c
 
 INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
diff --git a/libmailutils/imapio/create.c b/libmailutils/imapio/create.c
new file mode 100644
index 0000000..4a3a9af
--- /dev/null
+++ b/libmailutils/imapio/create.c
@@ -0,0 +1,63 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <stdlib.h>
+#include <mailutils/stream.h>
+#include <mailutils/errno.h>
+#include <mailutils/sys/imapio.h>
+
+int
+mu_imapio_create (mu_imapio_t *iop, mu_stream_t str)
+{
+  struct _mu_imapio *io = calloc (1, sizeof (*io));
+  if (!io)
+    return ENOMEM;
+  io->_imap_stream = str;
+  mu_stream_ref (str);
+  io->_imap_ws.ws_delim = " \t()";
+  io->_imap_ws.ws_escape = "\\\"";
+  io->_imap_ws_flags = MU_WRDSF_DELIM |
+                       MU_WRDSF_ESCAPE |
+                       MU_WRDSF_NOVAR |
+                       MU_WRDSF_NOCMD | 
+                       MU_WRDSF_QUOTE |
+                       MU_WRDSF_RETURN_DELIMS |
+                       MU_WRDSF_WS;
+  *iop = io;
+  return 0;
+}
+
+void
+mu_imapio_free (mu_imapio_t io)
+{
+  if (!io)
+    return;
+  if (io->_imap_ws_flags & MU_WRDSF_REUSE)
+    mu_wordsplit_free (&io->_imap_ws);
+  mu_stream_unref (io->_imap_stream);
+  free (io);
+}
+
+void
+mu_imapio_destroy (mu_imapio_t *pio)
+{
+  if (!pio)
+    return;
+  mu_imapio_free (*pio);
+  *pio = NULL;
+}
+
diff --git a/libmailutils/imapio/getline.c b/libmailutils/imapio/getline.c
new file mode 100644
index 0000000..28c8d4b
--- /dev/null
+++ b/libmailutils/imapio/getline.c
@@ -0,0 +1,114 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/imapio.h>
+#include <mailutils/stream.h>
+#include <mailutils/cstr.h>
+#include <mailutils/cctype.h>
+#include <mailutils/errno.h>
+#include <mailutils/sys/imapio.h>
+
+int
+mu_imapio_getline (struct _mu_imapio *io)
+{
+  int rc;
+  char *last_arg;
+
+  io->_imap_ws_flags &= ~MU_WRDSF_APPEND;
+
+  if (io->_imap_reply_ready)
+    {
+      mu_wordsplit_free_words (&io->_imap_ws);
+      io->_imap_reply_ready = 0;
+    }
+  
+  for (;;)
+    {
+      rc = mu_stream_getline (io->_imap_stream,
+			      &io->_imap_buf_base, &io->_imap_buf_size,
+			      &io->_imap_buf_level);
+      if (rc)
+	return rc;
+      if (io->_imap_buf_level == 0)
+	break;
+      io->_imap_buf_level = mu_rtrim_class (io->_imap_buf_base,
+					    MU_CTYPE_ENDLN);
+
+      if (mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
+			    &io->_imap_ws, io->_imap_ws_flags))
+	return MU_ERR_PARSE;
+      io->_imap_ws_flags |= MU_WRDSF_REUSE|MU_WRDSF_APPEND;
+
+      last_arg = io->_imap_ws.ws_wordv[io->_imap_ws.ws_wordc - 1];
+      if (last_arg[0] == '{' && last_arg[strlen (last_arg)-1] == '}')
+	{
+	  int rc;
+	  unsigned long number;
+	  char *sp = NULL;
+	  int xlev = mu_imapio_set_xscript_level (io, MU_XSCRIPT_PAYLOAD);
+	  
+	  number = strtoul (last_arg + 1, &sp, 10);
+	  /* Client can ask for non-synchronised literal,
+	     if a '+' is appended to the octet count. */
+	  if (*sp == '}')
+	    mu_stream_printf (io->_imap_stream, "+ GO AHEAD\n");
+	  else if (*sp != '+')
+	    break;
+
+	  if (number + 1 > io->_imap_buf_size)
+	    {
+	      size_t newsize = number + 1;
+	      void *newp = realloc (&io->_imap_buf_base, newsize);
+	      if (!newp)
+		return ENOMEM;
+	      io->_imap_buf_base = newp;
+	      io->_imap_buf_size = newsize;
+	    }
+	      
+          for (io->_imap_buf_level = 0; io->_imap_buf_level < number; )
+            {
+               size_t sz;
+	       rc = mu_stream_read (io->_imap_stream,
+				    io->_imap_buf_base + io->_imap_buf_level,
+				    number - io->_imap_buf_level,
+				    &sz);
+               if (rc || sz == 0)
+                 break;
+               io->_imap_buf_level += sz;
+            }
+	  mu_imapio_set_xscript_level (io, xlev);
+	  if (rc)
+	    return rc;
+	  io->_imap_buf_base[io->_imap_buf_level++] = 0;
+
+	  free (last_arg);
+	  io->_imap_ws.ws_wordv[--io->_imap_ws.ws_wordc] = NULL;
+	  if (mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
+				&io->_imap_ws,
+				io->_imap_ws_flags|MU_WRDSF_NOSPLIT))
+	    return MU_ERR_PARSE;
+	}
+      else
+	break;
+    }
+
+  io->_imap_reply_ready = 1;
+  return 0;
+}
diff --git a/mail/exit.c b/libmailutils/imapio/literal.c
similarity index 62%
copy from mail/exit.c
copy to libmailutils/imapio/literal.c
index 888cfd6..e46d23e 100644
--- a/mail/exit.c
+++ b/libmailutils/imapio/literal.c
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007, 2010, 2011 Free Software
-   Foundation, Inc.
+   Copyright (C) 2011 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -15,11 +14,18 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "mail.h"
+#include <config.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/imapio.h>
+#include <mailutils/sys/imapio.h>
+#include <mailutils/stream.h>
 
 int
-mail_exit (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
+mu_imapio_send_literal (struct _mu_imapio *io, const char *buffer)
 {
-  mu_mailbox_close (mbox);
-  exit (0);
+  return mu_stream_printf (io->_imap_stream,
+			   "{%lu}\n%s", (unsigned long) strlen (buffer),
+			   buffer);
 }
diff --git a/mail/cd.c b/libmailutils/imapio/printf.c
similarity index 62%
copy from mail/cd.c
copy to libmailutils/imapio/printf.c
index c8b078a..801e82a 100644
--- a/mail/cd.c
+++ b/libmailutils/imapio/printf.c
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2005, 2007, 2010, 2011 Free Software Foundation,
-   Inc.
+   Copyright (C) 2011 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -15,29 +14,22 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "mail.h"
-
-/*
- * cd [directory]
- * ch[dir] [directory]
- */
+#include <config.h>
+#include <stdarg.h>
+#include <mailutils/types.h>
+#include <mailutils/imapio.h>
+#include <mailutils/stream.h>
+#include <mailutils/sys/imapio.h>
 
 int
-mail_cd (int argc, char **argv)
+mu_imapio_printf (mu_imapio_t io, const char *fmt, ...)
 {
-  char *dir;
+  va_list ap;
+  int status;
   
-  if (argc > 2)
-    return 1;
-  else if (argc == 2)
-    dir = argv[1];
-  else 
-    dir = getenv ("HOME");
-
-  if (chdir (dir))
-    {
-      mu_diag_funcall (MU_DIAG_ERROR, "chdir", dir, errno);
-      return 1;
-    }
-  return 0;
+  va_start (ap, fmt);
+  status = mu_stream_vprintf (io->_imap_stream, fmt, ap);
+  va_end (ap);
+  return status;
 }
+    
diff --git a/libmailutils/imapio/qstring.c b/libmailutils/imapio/qstring.c
new file mode 100644
index 0000000..f50c15c
--- /dev/null
+++ b/libmailutils/imapio/qstring.c
@@ -0,0 +1,72 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/imapio.h>
+#include <mailutils/stream.h>
+#include <mailutils/sys/imapio.h>
+
+/* Send NIL if empty string, change the quoted string to a literal if the
+   string contains: double quotes, CR, LF, or \. */
+
+int
+mu_imapio_send_qstring_unfold (struct _mu_imapio *io, const char *buffer,
+			       int unfold)
+{
+  if (buffer == NULL || *buffer == '\0')
+    return mu_imapio_printf (io, "NIL");
+  if (strchr (buffer, '"') ||
+      strchr (buffer, '\r') ||
+      strchr (buffer, '\n') ||
+      strchr (buffer, '\\'))
+    {
+      if (unfold)
+	{
+	  int rc;
+	  size_t len = strlen (buffer);
+
+	  rc = mu_stream_printf (io->_imap_stream,
+				 "{%lu}\n", (unsigned long) strlen (buffer));
+	  if (rc)
+	    return rc;
+	  for (;;)
+	    {
+	      size_t s = strcspn (buffer, "\r\n");
+	      rc = mu_stream_write (io->_imap_stream, buffer, s, NULL);
+	      if (rc)
+		return rc;
+	      len -= s;
+	      if (len == 0)
+		break;
+	      buffer += s;
+	      rc = mu_stream_write (io->_imap_stream, " ", 1, NULL);
+	      if (rc)
+		return rc;
+	    }
+	}
+      else
+	return mu_imapio_send_literal (io, buffer);
+    }
+  return mu_imapio_printf (io, "\"%s\"", buffer);
+}
+
+int
+mu_imapio_send_qstring (struct _mu_imapio *io, const char *buffer)
+{
+  return mu_imapio_send_qstring_unfold (io, buffer, 0);
+}
diff --git a/mail/exit.c b/libmailutils/imapio/send.c
similarity index 67%
copy from mail/exit.c
copy to libmailutils/imapio/send.c
index 888cfd6..11ee049 100644
--- a/mail/exit.c
+++ b/libmailutils/imapio/send.c
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2005, 2007, 2010, 2011 Free Software
-   Foundation, Inc.
+   Copyright (C) 2011 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -15,11 +14,16 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "mail.h"
+#include <config.h>
+#include <stdarg.h>
+#include <mailutils/types.h>
+#include <mailutils/imapio.h>
+#include <mailutils/stream.h>
+#include <mailutils/sys/imapio.h>
 
 int
-mail_exit (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
+mu_imapio_send (mu_imapio_t io, const char *buf, size_t bytes)
 {
-  mu_mailbox_close (mbox);
-  exit (0);
+  return mu_stream_write (io->_imap_stream, buf, bytes, NULL);
 }
+    
diff --git a/libmailutils/imapio/trace.c b/libmailutils/imapio/trace.c
new file mode 100644
index 0000000..ae60745
--- /dev/null
+++ b/libmailutils/imapio/trace.c
@@ -0,0 +1,86 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <errno.h>
+#include <mailutils/types.h>
+#include <mailutils/imapio.h>
+#include <mailutils/stream.h>
+#include <mailutils/errno.h>
+#include <mailutils/error.h>
+#include <mailutils/nls.h>
+#include <mailutils/sys/imapio.h>
+
+static const char *imapio_prefix[] = {
+  "S: ", "C: "
+};
+
+int
+mu_imapio_trace_enable (mu_imapio_t io)
+{
+  int rc = 0;
+  mu_stream_t dstr, xstr;
+
+  if (io->_imap_transcript)
+    return MU_ERR_OPEN;
+  
+  rc = mu_dbgstream_create (&dstr, MU_DIAG_DEBUG);
+  if (rc)
+    mu_error (_("cannot create debug stream; transcript disabled: %s"),
+	      mu_strerror (rc));
+  else
+    {
+      rc = mu_xscript_stream_create (&xstr, io->_imap_stream, dstr,
+				     imapio_prefix);
+      if (rc)
+	mu_error (_("cannot create transcript stream: %s"),
+		  mu_strerror (rc));
+      else
+	{
+	  mu_stream_unref (io->_imap_stream);
+	  io->_imap_stream = xstr;
+	  io->_imap_transcript = 1;
+	}
+    }
+
+  return rc;
+}
+
+int
+mu_imapio_trace_disable (mu_imapio_t io)
+{
+  mu_stream_t xstr = io->_imap_stream;
+  mu_stream_t stream[2];
+  int rc;
+
+  if (!io->_imap_transcript)
+    return MU_ERR_NOT_OPEN;
+  
+  rc = mu_stream_ioctl (xstr, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, stream);
+  if (rc)
+    return rc;
+
+  io->_imap_stream = stream[0];
+  mu_stream_destroy (&xstr);
+  io->_imap_transcript = 0;
+  return 0;
+}
+
+int
+mu_imapio_get_trace (mu_imapio_t io)
+{
+  return io ? io->_imap_transcript : 0; 
+}
diff --git a/examples/muemail.c b/libmailutils/imapio/words.c
similarity index 55%
copy from examples/muemail.c
copy to libmailutils/imapio/words.c
index 39a8099..7fa1c81 100644
--- a/examples/muemail.c
+++ b/libmailutils/imapio/words.c
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2007, 2010, 2011 Free Software
-   Foundation, Inc.
+   Copyright (C) 2011 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -15,35 +14,29 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
 #include <stdlib.h>
-#include <stdio.h>
-#include <mailutils/util.h>
-#include "mailutils/libargp.h"
-
-const char *capa[] = {
-  "address",
-  NULL
-};
+#include <mailutils/errno.h>
+#include <mailutils/imapio.h>
+#include <mailutils/sys/imapio.h>
 
 int
-main (int argc, char *argv[])
+mu_imapio_get_words (mu_imapio_t io, size_t *pwc, char ***pwv)
 {
-  int arg = 1;
-
-  if (mu_app_init (NULL, capa, NULL, argc, argv, 0, &arg, NULL))
-    exit (1);
-
-  if (!argv[arg])
-    printf ("current user -> %s\n", mu_get_user_email (0));
-  else
-    {
-      for (; argv[arg]; arg++)
-        printf ("%s -> %s\n", argv[arg], mu_get_user_email (argv[arg]));
-    }
-
+  if (!io->_imap_reply_ready)
+    return MU_ERR_INFO_UNAVAILABLE;
+  *pwc = io->_imap_ws.ws_wordc;
+  *pwv = io->_imap_ws.ws_wordv;
   return 0;
 }
 
+int
+mu_imapio_getbuf (mu_imapio_t io, char **pptr, size_t *psize)
+{
+  if (!io->_imap_reply_ready)
+    return MU_ERR_INFO_UNAVAILABLE;
+  *pptr  = io->_imap_buf_base;
+  *psize = io->_imap_buf_level;
+  return 0;
+}
+  
diff --git a/lib/tcpwrap.h b/libmailutils/imapio/xscript.c
similarity index 51%
copy from lib/tcpwrap.h
copy to libmailutils/imapio/xscript.c
index 939889a..ebb003b 100644
--- a/lib/tcpwrap.h
+++ b/libmailutils/imapio/xscript.c
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2010, 2011 Free Software Foundation, Inc.
+   2009, 2010, 2011 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -15,19 +15,32 @@
    You should have received a copy of the GNU General Public License
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
+#include <config.h>
+#include <errno.h>
 #include <mailutils/types.h>
+#include <mailutils/stream.h>
+#include <mailutils/diag.h>
+#include <mailutils/imapio.h>
+#include <mailutils/sys/imapio.h>
 
-extern int mu_tcp_wrapper_enable;
-const char *mu_tcp_wrapper_daemon;
-extern int mu_tcpwrapper_access (int fd);
-extern void mu_tcpwrapper_cfg_init (void);
-extern int mu_tcp_wrapper_prefork (int fd, 
-				   struct sockaddr *sa, int salen,
-				   struct mu_srv_config *pconf,
-				   void *data);
+int
+mu_imapio_set_xscript_level (struct _mu_imapio *io, int xlev)
+{
+  if (!io)
+    return EINVAL;
+  if (io->_imap_transcript)
+    {
+      if (xlev != MU_XSCRIPT_NORMAL)
+	{
+	  if (mu_debug_level_p (MU_DEBCAT_REMOTE, 
+	                        xlev == MU_XSCRIPT_SECURE ?
+				  MU_DEBUG_TRACE6 : MU_DEBUG_TRACE7))
+	    return MU_XSCRIPT_NORMAL;
+	}
 
-#ifdef WITH_LIBWRAP
-# define TCP_WRAPPERS_CONFIG { "tcp-wrappers", mu_cfg_section },
-#else
-# define TCP_WRAPPERS_CONFIG
-#endif
+      if (mu_stream_ioctl (io->_imap_stream, MU_IOCTL_XSCRIPTSTREAM,
+                           MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev) == 0)
+	return xlev;
+    }
+  return MU_XSCRIPT_NORMAL;
+}
diff --git a/libmailutils/tests/.gitignore b/libmailutils/tests/.gitignore
index 0860f07..444e39e 100644
--- a/libmailutils/tests/.gitignore
+++ b/libmailutils/tests/.gitignore
@@ -12,6 +12,7 @@ decode2047
 encode2047
 fltst
 fsaf
+imapio
 listop
 mailcap
 prop
diff --git a/libmailutils/tests/Makefile.am b/libmailutils/tests/Makefile.am
index 66d83ca..0ac3ec1 100644
--- a/libmailutils/tests/Makefile.am
+++ b/libmailutils/tests/Makefile.am
@@ -47,6 +47,7 @@ noinst_PROGRAMS = \
  encode2047\
  fltst\
  fsaf\
+ imapio\
  listop\
  mailcap\
  prop\
diff --git a/libmailutils/tests/imapio.c b/libmailutils/tests/imapio.c
new file mode 100644
index 0000000..652f0d6
--- /dev/null
+++ b/libmailutils/tests/imapio.c
@@ -0,0 +1,95 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif 
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <mailutils/imapio.h>
+#include <mailutils/errno.h>
+#include <mailutils/error.h>
+#include <mailutils/stream.h>
+#include <mailutils/stdstream.h>
+
+void
+usage ()
+{
+  mu_stream_printf (mu_strout, "usage: %s [debug=SPEC] [-transcript]\n",
+		    mu_program_name);
+  exit (0);
+}
+
+int
+main (int argc, char **argv)
+{
+  int i, rc;
+  int transcript = 0;
+  mu_imapio_t io;
+  mu_stream_t str;
+  
+  mu_set_program_name (argv[0]);
+  mu_stdstream_setup (MU_STDSTREAM_RESET_NONE);
+  
+  for (i = 1; i < argc; i++)
+    {
+      char *opt = argv[i];
+
+      if (strncmp (opt, "debug=", 6) == 0)
+	mu_debug_parse_spec (opt + 6);
+      else if (strcmp (opt, "-transcript") == 0)
+	transcript = 1;
+      else if (strcmp (opt, "-h") == 0)
+	usage ();
+      else
+	{
+	  mu_error ("%s: unrecognized argument", opt);
+	  exit (1);
+	}
+    }
+
+  MU_ASSERT (mu_iostream_create (&str, mu_strin, mu_strout));
+
+  
+  MU_ASSERT (mu_imapio_create (&io, str));
+
+  if (transcript)
+    mu_imapio_trace_enable (io);
+  mu_stream_unref (str);
+
+  while ((rc = mu_imapio_getline (io)) == 0)
+    {
+      size_t wc;
+      char **wv;
+
+      MU_ASSERT (mu_imapio_get_words (io, &wc, &wv));
+      if (wc == 0)
+	break;
+
+      mu_stream_printf (mu_strerr, "%d\n", wc);
+      for (i = 0; i < wc; i++)
+	{
+	  mu_stream_printf (mu_strerr, "%d: '%s'\n", i, wv[i]);
+	}
+    }
+
+  if (rc)
+    mu_error ("mu_imap_getline: %s", mu_strerror (rc));
+
+  mu_imapio_free (io);
+  return 0;
+}
diff --git a/libmailutils/tests/wsp.c b/libmailutils/tests/wsp.c
index 0b8d622..47cd4ff 100644
--- a/libmailutils/tests/wsp.c
+++ b/libmailutils/tests/wsp.c
@@ -53,6 +53,7 @@ struct mu_kwd bool_keytab[] = {
 struct mu_kwd string_keytab[] = {
   { "delim",   MU_WRDSF_DELIM },
   { "comment", MU_WRDSF_COMMENT },
+  { "escape",  MU_WRDSF_ESCAPE },
   { NULL, 0 }
 };
 
@@ -239,6 +240,10 @@ main (int argc, char **argv)
 		case MU_WRDSF_COMMENT:
 		  ws.ws_comment = argv[i];
 		  break;
+
+		case MU_WRDSF_ESCAPE:
+		  ws.ws_escape = argv[i];
+		  break;
 		}
 	      
 	      wsflags |= flag;


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 18 05:59:54 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRMAk-0002kV-2i
	for mharc-commit-mailutils@gnu.org; Fri, 18 Nov 2011 05:59:54 -0500
Received: from eggs.gnu.org ([140.186.70.92]:44372)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRMAd-0002jk-4t
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 05:59:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRMAV-0001tA-Pl
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 05:59:47 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:58981)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRMAV-0001t3-Hq
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 05:59:39 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRMAR-0000Bw-VZ
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 10:59:39 +0000
Date: Fri, 18 Nov 2011 10:59:36 +0000
Message-Id: <E1RRMAR-0000Bw-VZ@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-446-gf7942ce
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 6f309ce61dcfb461c3fe1270efe2b23a7ac5d676
X-Git-Newrev: f7942ced21d97774e678be261cc5b9094e47e8da
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Nov 2011 10:59:51 -0000

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

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

The branch, master has been updated
       via  f7942ced21d97774e678be261cc5b9094e47e8da (commit)
       via  a4a3755edc99af0d3522179f9f5213b7646ef078 (commit)
      from  6f309ce61dcfb461c3fe1270efe2b23a7ac5d676 (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 f7942ced21d97774e678be261cc5b9094e47e8da
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 18 13:00:05 2011 +0200

    Rewrite existing imap client support using imapio.

commit a4a3755edc99af0d3522179f9f5213b7646ef078
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 18 09:51:53 2011 +0200

    Implement mu_imapio_reply_string function.
    
    * include/mailutils/imapio.h (mu_imapio_reply_string): New proto.
    * libmailutils/imapio/replstr.c: New file.
    * libmailutils/imapio/Makefile.am: Add replstr.c

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

Summary of changes:
 include/mailutils/imap.h                   |    2 +-
 include/mailutils/imapio.h                 |    2 +
 include/mailutils/sys/imap.h               |   32 +++-
 libmailutils/imapio/Makefile.am            |    1 +
 libmailutils/imapio/getline.c              |    2 +-
 libmailutils/imapio/{words.c => replstr.c} |   32 ++--
 libproto/imap/Makefile.am                  |    1 +
 libproto/imap/capability.c                 |   47 +++---
 libproto/imap/carrier.c                    |   19 ++-
 libproto/imap/connect.c                    |   83 ++++-----
 libproto/imap/create.c                     |    2 +-
 libproto/imap/destroy.c                    |    9 +-
 libproto/imap/disconnect.c                 |    8 +-
 libproto/imap/id.c                         |  163 ++++++++++--------
 libproto/imap/login.c                      |    4 +-
 libproto/imap/logout.c                     |    4 +-
 libproto/imap/resplist.c                   |  256 ++++++++++++++++++++++++++++
 libproto/imap/response.c                   |   93 +++++------
 libproto/imap/trace.c                      |   81 +++------
 mu/imap.c                                  |   58 ++++---
 20 files changed, 565 insertions(+), 334 deletions(-)
 copy libmailutils/imapio/{words.c => replstr.c} (63%)
 create mode 100644 libproto/imap/resplist.c

diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index 9855856..3e04391 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -53,7 +53,7 @@ int mu_imap_capability_test (mu_imap_t imap, const char *name,
 int mu_imap_login (mu_imap_t imap, const char *user, const char *pass);
 int mu_imap_logout (mu_imap_t imap);
 
-int mu_imap_id (mu_imap_t imap, char **idenv, mu_list_t *plist);
+int mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc);
   
 int mu_imap_set_carrier (mu_imap_t imap, mu_stream_t carrier);
 int mu_imap_get_carrier (mu_imap_t imap, mu_stream_t *pcarrier);
diff --git a/include/mailutils/imapio.h b/include/mailutils/imapio.h
index 387e3df..9b92622 100644
--- a/include/mailutils/imapio.h
+++ b/include/mailutils/imapio.h
@@ -43,6 +43,8 @@ int mu_imapio_trace_disable (mu_imapio_t io);
 int mu_imapio_get_trace (mu_imapio_t io);
 
 int mu_imapio_getbuf (mu_imapio_t io, char **pptr, size_t *psize);
+
+int mu_imapio_reply_string (struct _mu_imapio *io, size_t start, char **pbuf);
   
 #ifdef __cplusplus
 }
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index 3e90809..17a0095 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -22,6 +22,7 @@
 # include <mailutils/sys/mailbox.h>
 # include <mailutils/sys/registrar.h>
 # include <mailutils/sys/auth.h>
+# include <mailutils/imapio.h>
 # include <mailutils/imap.h>
 
 # ifdef __cplusplus
@@ -29,7 +30,7 @@ extern "C" {
 # endif
 
 #define MU_IMAP_RESP  0x01
-#define MU_IMAP_TRACE 0x02  
+#define MU_IMAP_TRACE 0x02
 #define MU_IMAP_XSCRIPT_MASK(n) (1<<((n)+1))
 
 enum mu_imap_client_state
@@ -56,9 +57,7 @@ struct _mu_imap
   {
     int flags;
 
-    /* Holds the tagged response to the last command */
-    char *tagbuf;
-    size_t tagsize;
+    /* Holds the recect response code */
     enum mu_imap_response resp_code;
     
     /* Untagged responses */
@@ -68,10 +67,6 @@ struct _mu_imap
     char *errstr;
     size_t errsize;
     
-    /* Input line buffer */
-    char *rdbuf;
-    size_t rdsize;
-
     enum mu_imap_state state;
     enum mu_imap_state imap_state;
 
@@ -81,7 +76,23 @@ struct _mu_imap
     char *tag_str;   /* String representation (tag_len + 1 bytes, asciiz) */
     
     mu_list_t capa;
-    mu_stream_t carrier;
+    mu_imapio_t io;
+};
+
+enum imap_eltype
+  {
+    imap_eltype_string,
+    imap_eltype_list
+  };
+
+struct imap_list_element
+{
+  enum imap_eltype type;
+  union
+  {
+    mu_list_t list;
+    char *string;
+  } v;
 };
 
 #define MU_IMAP_FSET(p,f) ((p)->flags |= (f))
@@ -137,6 +148,9 @@ int _mu_imap_tag_next (mu_imap_t imap);
 int _mu_imap_tag_clr (mu_imap_t imap);
 
 int _mu_imap_response (mu_imap_t imap);
+
+int _mu_imap_untagged_response_clear (mu_imap_t imap);
+int _mu_imap_untagged_response_add (mu_imap_t imap);
   
 # ifdef __cplusplus
 }
diff --git a/libmailutils/imapio/Makefile.am b/libmailutils/imapio/Makefile.am
index 74f36a2..20c0784 100644
--- a/libmailutils/imapio/Makefile.am
+++ b/libmailutils/imapio/Makefile.am
@@ -23,6 +23,7 @@ libimapio_la_SOURCES = \
  literal.c\
  printf.c\
  qstring.c\
+ replstr.c\
  send.c\
  trace.c\
  words.c\
diff --git a/libmailutils/imapio/getline.c b/libmailutils/imapio/getline.c
index 28c8d4b..f586d86 100644
--- a/libmailutils/imapio/getline.c
+++ b/libmailutils/imapio/getline.c
@@ -30,7 +30,7 @@ mu_imapio_getline (struct _mu_imapio *io)
 {
   int rc;
   char *last_arg;
-
+  
   io->_imap_ws_flags &= ~MU_WRDSF_APPEND;
 
   if (io->_imap_reply_ready)
diff --git a/libmailutils/imapio/words.c b/libmailutils/imapio/replstr.c
similarity index 63%
copy from libmailutils/imapio/words.c
copy to libmailutils/imapio/replstr.c
index 7fa1c81..56b3fa2 100644
--- a/libmailutils/imapio/words.c
+++ b/libmailutils/imapio/replstr.c
@@ -15,28 +15,26 @@
    along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
-#include <stdlib.h>
-#include <mailutils/errno.h>
+#include <mailutils/types.h>
 #include <mailutils/imapio.h>
+#include <mailutils/errno.h>
+#include <mailutils/argcv.h>
 #include <mailutils/sys/imapio.h>
 
+/* FIXME: It would be good to have a `, size_t *psize' argument, to allow
+   for passing an already allocated buffer.  This implies similar changes
+   to mu_argcv_join. */
 int
-mu_imapio_get_words (mu_imapio_t io, size_t *pwc, char ***pwv)
+mu_imapio_reply_string (struct _mu_imapio *io, size_t start, char **pbuf)
 {
   if (!io->_imap_reply_ready)
-    return MU_ERR_INFO_UNAVAILABLE;
-  *pwc = io->_imap_ws.ws_wordc;
-  *pwv = io->_imap_ws.ws_wordv;
-  return 0;
-}
+    return MU_ERR_NOENT;
 
-int
-mu_imapio_getbuf (mu_imapio_t io, char **pptr, size_t *psize)
-{
-  if (!io->_imap_reply_ready)
-    return MU_ERR_INFO_UNAVAILABLE;
-  *pptr  = io->_imap_buf_base;
-  *psize = io->_imap_buf_level;
-  return 0;
-}
+  if (start >= io->_imap_ws.ws_wordc)
+    return EINVAL;
   
+  return mu_argcv_join (io->_imap_ws.ws_wordc - start,
+			io->_imap_ws.ws_wordv + start, " ",
+			mu_argcv_escape_no,
+			pbuf);
+}
diff --git a/libproto/imap/Makefile.am b/libproto/imap/Makefile.am
index c280042..2f54f70 100644
--- a/libproto/imap/Makefile.am
+++ b/libproto/imap/Makefile.am
@@ -39,6 +39,7 @@ libmu_imap_la_SOURCES = \
  id.c\
  login.c\
  logout.c\
+ resplist.c\
  response.c\
  state.c\
  tag.c\
diff --git a/libproto/imap/capability.c b/libproto/imap/capability.c
index 1f74702..ab69ad2 100644
--- a/libproto/imap/capability.c
+++ b/libproto/imap/capability.c
@@ -19,13 +19,14 @@
 # include <config.h>
 #endif
 
+#include <string.h>
 #include <mailutils/types.h>
 #include <mailutils/cctype.h>
 #include <mailutils/cstr.h>
 #include <mailutils/errno.h>
 #include <mailutils/stream.h>
 #include <mailutils/list.h>
-#include <mailutils/wordsplit.h>
+#include <mailutils/iterator.h>
 #include <mailutils/sys/imap.h>
 
 static int
@@ -50,7 +51,7 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
   
   if (imap == NULL)
     return EINVAL;
-  if (!imap->carrier)
+  if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
   if (imap->state != MU_IMAP_CONNECTED)
     return MU_ERR_SEQ;
@@ -78,7 +79,7 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
     case MU_IMAP_CONNECTED:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      status = mu_stream_printf (imap->carrier, "%s CAPABILITY\r\n",
+      status = mu_imapio_printf (imap->io, "%s CAPABILITY\r\n",
 				 imap->tag_str); 
       MU_IMAP_CHECK_EAGAIN (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
@@ -92,35 +93,35 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
       else
 	{
 	  size_t count;
-	  char *str;
+	  struct imap_list_element *elt;
 	  
 	  imap->state = MU_IMAP_CONNECTED;
 	  mu_list_count (imap->untagged_resp, &count);
-	  if (mu_list_get (imap->untagged_resp, 0, (void*)&str) == 0)
+	  if (mu_list_get (imap->untagged_resp, 0, (void*)&elt) == 0)
 	    {
-	      size_t i;
+	      /* Top-level elements are always of imap_eltype_list type. */
+	      mu_iterator_t itr;
 	      
-	      struct mu_wordsplit ws;
-
-	      if (mu_wordsplit (str, &ws,
-				MU_WRDSF_NOVAR | MU_WRDSF_NOCMD |
-				MU_WRDSF_QUOTE | MU_WRDSF_SQUEEZE_DELIMS))
-		{
-		  int ec = errno;
-		  mu_error ("mu_imap_capability: cannot split line: %s",
-			    mu_wordsplit_strerror (&ws));
-		  return ec;
-		}
-	      if (ws.ws_wordc > 1 &&
-		  mu_c_strcasecmp (ws.ws_wordv[0], "CAPABILITY") == 0)
+	      mu_list_get_iterator (elt->v.list, &itr);
+	      mu_iterator_first (itr);
+	      if (mu_iterator_is_done (itr))
+		return MU_ERR_PARSE;
+	      mu_iterator_current (itr, (void **) &elt);
+	      if (elt->type == imap_eltype_string &&
+		  strcmp (elt->v.string, "CAPABILITY") == 0)
 		{
-		  for (i = 1; i < ws.ws_wordc; i++)
+		  for (mu_iterator_next (itr); !mu_iterator_is_done (itr);
+		       mu_iterator_next (itr))
 		    {
-		      mu_list_append (imap->capa, ws.ws_wordv[i]);
-		      ws.ws_wordv[i] = NULL;
+		      mu_iterator_current (itr, (void **) &elt);
+		      if (elt->type == imap_eltype_string)
+			{
+			  mu_list_append (imap->capa, elt->v.string);
+			  elt->v.string = NULL;
+			}
 		    }
 		}
-	      mu_wordsplit_free (&ws);
+	      mu_iterator_destroy (&itr);
 	    }
 	  if (piter)
 	    status = mu_list_get_iterator (imap->capa, piter);
diff --git a/libproto/imap/carrier.c b/libproto/imap/carrier.c
index 0ff40e5..afb8563 100644
--- a/libproto/imap/carrier.c
+++ b/libproto/imap/carrier.c
@@ -23,23 +23,30 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <mailutils/errno.h>
+#include <mailutils/imapio.h>
 #include <mailutils/sys/imap.h>
+#include <mailutils/sys/imapio.h>
 
 int
 mu_imap_set_carrier (mu_imap_t imap, mu_stream_t carrier)
 {
+  int rc;
+  mu_imapio_t io;
+  
   /* Sanity checks.  */
   if (imap == NULL)
     return EINVAL;
 
-  if (imap->carrier)
+  rc = mu_imapio_create (&io, carrier);
+  if (rc)
+    return rc;
+  if (imap->io)
     {
       /* Close any old carrier.  */
       mu_imap_disconnect (imap);
-      mu_stream_destroy (&imap->carrier);
+      mu_imapio_free (imap->io);
     }
-  mu_stream_ref (carrier);
-  imap->carrier = carrier;
+  imap->io = io;
   if (MU_IMAP_FISSET (imap, MU_IMAP_TRACE))
     _mu_imap_trace_enable (imap);
   imap->state = MU_IMAP_CONNECT;
@@ -55,8 +62,8 @@ mu_imap_get_carrier (mu_imap_t imap, mu_stream_t *pcarrier)
   if (pcarrier == NULL)
     return MU_ERR_OUT_PTR_NULL;
 
-  mu_stream_ref (imap->carrier);
-  *pcarrier = imap->carrier;
+  mu_stream_ref (imap->io->_imap_stream);
+  *pcarrier = imap->io->_imap_stream;
   return 0;
 }
 
diff --git a/libproto/imap/connect.c b/libproto/imap/connect.c
index 6585e8c..a925e84 100644
--- a/libproto/imap/connect.c
+++ b/libproto/imap/connect.c
@@ -24,18 +24,23 @@
 #include <sys/select.h>
 #include <sys/time.h>
 #include <mailutils/errno.h>
-#include <mailutils/wordsplit.h>
+#include <mailutils/imapio.h>
 #include <mailutils/sys/imap.h>
+#include <mailutils/sys/imapio.h>
 
 
 int
 mu_imap_connect (mu_imap_t imap)
 {
   int status;
-
+  size_t wc;
+  char **wv;
+  char *bufptr;
+  size_t bufsize;
+  
   if (imap == NULL)
     return EINVAL;
-  if (imap->carrier == NULL)
+  if (imap->io == NULL)
     return EINVAL;
   switch (imap->state)
     {
@@ -54,66 +59,48 @@ mu_imap_connect (mu_imap_t imap)
 
     case MU_IMAP_CONNECT:
       /* Establish the connection.  */
-      if (!mu_stream_is_open (imap->carrier))
+      if (!mu_stream_is_open (imap->io->_imap_stream))
         {
-          status = mu_stream_open (imap->carrier);
+          status = mu_stream_open (imap->io->_imap_stream);
           MU_IMAP_CHECK_EAGAIN (imap, status);
           MU_IMAP_FCLR (imap, MU_IMAP_RESP);
         }
       imap->state = MU_IMAP_GREETINGS;
 
     case MU_IMAP_GREETINGS:
-      status = mu_stream_getline (imap->carrier, &imap->rdbuf,
-				  &imap->rdsize, NULL);
+      status = mu_imapio_getline (imap->io);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      if (imap->rdsize < 2 ||
-	  !(imap->rdbuf[0] == '*' && imap->rdbuf[1] == ' '))
+      mu_imapio_get_words (imap->io, &wc, &wv);
+      if (wc < 2 || strcmp (wv[0], "*"))
 	{
+	  mu_imapio_getbuf (imap->io, &bufptr, &bufsize);
 	  mu_error ("mu_imap_connect: invalid server response: %s",
-		    imap->rdbuf);
+		    bufptr);
 	  imap->state = MU_IMAP_ERROR;
 	  return MU_ERR_BADREPLY;
 	}
+      else if (strcmp (wv[1], "BYE") == 0)
+	{
+	  status = EACCES;
+	  mu_imapio_getbuf (imap->io, &bufptr, &bufsize);
+	  _mu_imap_seterrstr (imap, bufptr + 2, bufsize - 2);
+	}
+      else if (strcmp (wv[1], "PREAUTH") == 0)
+	{
+	  status = 0;
+	  imap->state = MU_IMAP_CONNECTED;
+	  imap->imap_state = MU_IMAP_STATE_AUTH;
+	}
+      else if (strcmp (wv[1], "OK") == 0)
+	{
+	  status = 0;
+	  imap->state = MU_IMAP_CONNECTED;
+	  imap->imap_state = MU_IMAP_STATE_NONAUTH;
+	}
       else
 	{
-	  struct mu_wordsplit ws;
-	  
- 	  if (mu_wordsplit (imap->rdbuf, &ws,
-			    MU_WRDSF_NOVAR | MU_WRDSF_NOCMD |
-			    MU_WRDSF_SQUEEZE_DELIMS))
-	    {
-	      int ec = errno;
-	      mu_error ("mu_imap_connect: cannot split line: %s",
-			mu_wordsplit_strerror (&ws));
-	      imap->state = MU_IMAP_ERROR;
-	      return ec;
-	    }
-	  if (ws.ws_wordc < 2)
-	    status = MU_ERR_BADREPLY;
-	  else if (strcmp (ws.ws_wordv[1], "BYE") == 0)
-	    {
-	      status = EACCES;
-	      _mu_imap_seterrstr (imap, imap->rdbuf + 2,
-				  strlen (imap->rdbuf + 2));
-	    }
-	  else if (strcmp (ws.ws_wordv[1], "PREAUTH") == 0)
-	    {
-	      status = 0;
-	      imap->state = MU_IMAP_CONNECTED;
-	      imap->imap_state = MU_IMAP_STATE_AUTH;
-	    }
-	  else if (strcmp (ws.ws_wordv[1], "OK") == 0)
-	    {
-	      status = 0;
-	      imap->state = MU_IMAP_CONNECTED;
-	      imap->imap_state = MU_IMAP_STATE_NONAUTH;
-	    }
-	  else
-	    {
-	      status = MU_ERR_BADREPLY;
-	      imap->state = MU_IMAP_ERROR;
-	    }
-	  mu_wordsplit_free (&ws);
+	  status = MU_ERR_BADREPLY;
+	  imap->state = MU_IMAP_ERROR;
 	}
     }
   
diff --git a/libproto/imap/create.c b/libproto/imap/create.c
index e3d9901..96cc4ac 100644
--- a/libproto/imap/create.c
+++ b/libproto/imap/create.c
@@ -49,7 +49,7 @@ _mu_imap_init (mu_imap_t imap)
 {
   if (imap == NULL)
     return EINVAL;
-  if (imap->carrier == 0)
+  if (!imap->io)
     {
       int rc;
       
diff --git a/libproto/imap/destroy.c b/libproto/imap/destroy.c
index e49a844..ff8076f 100644
--- a/libproto/imap/destroy.c
+++ b/libproto/imap/destroy.c
@@ -31,13 +31,6 @@ mu_imap_destroy (mu_imap_t *pimap)
     {
       mu_imap_t imap = *pimap;
       
-      /* Free the response buffer.  */
-      if (imap->tagbuf)
-	free (imap->tagbuf);
-      /* Free the read buffer.  */
-      if (imap->rdbuf)
-	free (imap->rdbuf);
-
       if (imap->errstr)
 	free (imap->errstr);
 
@@ -49,7 +42,7 @@ mu_imap_destroy (mu_imap_t *pimap)
       mu_list_destroy (&imap->untagged_resp);
       mu_list_destroy (&imap->capa);
       
-      mu_stream_destroy (&imap->carrier);
+      mu_imapio_destroy (&imap->io);
 
       free (imap);
 
diff --git a/libproto/imap/disconnect.c b/libproto/imap/disconnect.c
index 36a34ab..6803008 100644
--- a/libproto/imap/disconnect.c
+++ b/libproto/imap/disconnect.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <mailutils/imapio.h>
 #include <mailutils/sys/imap.h>
 
 int
@@ -34,14 +35,11 @@ mu_imap_disconnect (mu_imap_t imap)
   imap->state = MU_IMAP_NO_STATE;
   MU_IMAP_FCLR (imap, MU_IMAP_RESP);
 
-  if (imap->rdbuf)
-    imap->rdbuf[0] = 0;
-
   mu_list_clear (imap->untagged_resp);
   mu_list_clear (imap->capa);
   
   /* Close the stream.  */
-  if (mu_stream_is_open (imap->carrier))
-    return mu_stream_close (imap->carrier);
+  mu_imapio_destroy (&imap->io);
+
   return 0;
 }
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index 03db874..ef0974d 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -22,93 +22,109 @@
 #include <stdlib.h>
 #include <string.h>
 #include <mailutils/errno.h>
-#include <mailutils/cstr.h>
-#include <mailutils/wordsplit.h>
+#include <mailutils/assoc.h>
 #include <mailutils/stream.h>
+#include <mailutils/imap.h>
 #include <mailutils/sys/imap.h>
 
-static int
-id_comp (const void *item, const void *value)
+void
+_id_free (void *data)
 {
-  const char *id = item;
-  const char *needle = value;
-  return mu_c_strcasecmp (id, needle);
+  char *s = *(char**)data;
+  free (s);
 }
 
+struct id_convert_state
+{
+  int item;
+  mu_assoc_t assoc;
+  int ret;
+};
+
 static int
-parse_id_reply (mu_imap_t imap, mu_list_t *plist)
+_id_convert (void *item, void *data)
+{
+  struct imap_list_element *elt = item;
+  struct id_convert_state *stp = data;
+
+  switch (stp->item)
+    {
+    case 0:
+      if (!(elt->type == imap_eltype_string &&
+	    strcmp (elt->v.string, "ID") == 0))
+	{
+	  stp->ret = MU_ERR_PARSE;
+	  return 1;
+	}
+      stp->item++;
+      return 0;
+
+    case 1:
+      if (elt->type == imap_eltype_list)
+	{
+	  mu_iterator_t itr;
+
+	  mu_list_get_iterator (elt->v.list, &itr);
+	  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
+	       mu_iterator_next (itr))
+	    {
+	      char *key, *val;
+	      mu_iterator_current (itr, (void **) &elt);
+
+	      if (elt->type != imap_eltype_string)
+		break;
+	      key = elt->v.string;
+	      elt->v.string = NULL;
+
+	      mu_iterator_next (itr);
+	      if (mu_iterator_is_done (itr))
+		break;
+	      mu_iterator_current (itr, (void **) &elt);
+	      if (elt->type != imap_eltype_string)
+		break;
+	      val = elt->v.string;
+	      elt->v.string = NULL;
+	      mu_assoc_install (stp->assoc, key, &val);
+	    }
+	}
+    }
+  return 1;
+}	
+
+static int
+parse_id_reply (mu_imap_t imap, mu_assoc_t *passoc)
 {
-  mu_list_t list;
   int rc;
-  const char *response;
-  struct mu_wordsplit ws;
-  size_t i;
-    
-  rc = mu_list_create (&list);
+  struct imap_list_element const *response;
+  struct id_convert_state st;
+  mu_assoc_t assoc;
+  
+  rc = mu_assoc_create (&assoc, sizeof (char**), MU_ASSOC_ICASE);
   if (rc)
     return rc;
-  mu_list_set_comparator (list, id_comp);
-  mu_list_set_destroy_item (list, mu_list_free_item);
+  mu_assoc_set_free (assoc, _id_free);
   
   rc = mu_list_get (imap->untagged_resp, 0, (void*) &response);
+  *passoc = assoc;
   if (rc == MU_ERR_NOENT)
-    {
-      *plist = list;
-      return 0;
-    }
-  else if (rc)
-    {
-      mu_list_destroy (&list);
-      return rc;
-    }
-
-  ws.ws_delim = "() \t";
-  if (mu_wordsplit (response, &ws,
-		    MU_WRDSF_NOVAR | MU_WRDSF_NOCMD |
-		    MU_WRDSF_QUOTE | MU_WRDSF_DELIM |
-		    MU_WRDSF_SQUEEZE_DELIMS |
-		    MU_WRDSF_WS))
-    {
-      int ec = errno;
-      mu_error ("mu_imap_id: cannot split line: %s",
-		mu_wordsplit_strerror (&ws));
-      mu_list_destroy (&list);
-      return ec;
-    }
+    return 0;
 
-  for (i = 1; i < ws.ws_wordc; i += 2)
-    {
-      size_t len, l1, l2;
-      char *elt;
-      
-      if (i + 1 == ws.ws_wordc)
-	break;
-      l1 = strlen (ws.ws_wordv[i]);
-      l2 = strlen (ws.ws_wordv[i+1]);
-      len = l1 + l2 + 1;
-      elt = malloc (len + 1);
-      if (!elt)
-	break;
-
-      memcpy (elt, ws.ws_wordv[i], l1);
-      elt[l1] = 0;
-      memcpy (elt + l1 + 1, ws.ws_wordv[i+1], l2);
-      elt[len] = 0;
-      mu_list_append (list, elt);
-    }
-  mu_wordsplit_free (&ws);
-  *plist = list;
-  return 0;
+  st.item = 0;
+  st.assoc = assoc;
+  st.ret = 0;
+  mu_list_do (response->v.list, _id_convert, &st);
+  return st.ret;
 }
-
+  
+  
 int
-mu_imap_id (mu_imap_t imap, char **idenv, mu_list_t *plist)
+mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
 {
   int status;
   
   if (imap == NULL)
     return EINVAL;
-  if (!imap->carrier)
+  if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
   if (imap->state != MU_IMAP_CONNECTED)
     return MU_ERR_SEQ;
@@ -118,11 +134,10 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_list_t *plist)
     case MU_IMAP_CONNECTED:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      status = mu_stream_printf (imap->carrier, "%s ID ",
-				 imap->tag_str);
+      status = mu_imapio_printf (imap->io, "%s ID ", imap->tag_str);
       MU_IMAP_CHECK_ERROR (imap, status);
       if (!idenv)
-	status = mu_stream_printf (imap->carrier, "NIL");
+	status = mu_imapio_printf (imap->io, "NIL");
       else
 	{
 	  if (idenv[0])
@@ -131,7 +146,7 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_list_t *plist)
 	      char *delim = "(";
 	      for (i = 0; idenv[i]; i++)
 		{
-		  status = mu_stream_printf (imap->carrier, "%s\"%s\"",
+		  status = mu_imapio_printf (imap->io, "%s\"%s\"",
 					     delim, idenv[i]);
 		  MU_IMAP_CHECK_ERROR (imap, status);
 		  
@@ -139,13 +154,13 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_list_t *plist)
 		  if (status)
 		    break;
 		}
-	      status = mu_stream_printf (imap->carrier, ")");
+	      status = mu_imapio_printf (imap->io, ")");
 	    }
 	  else
-	    status = mu_stream_printf (imap->carrier, "()");
+	    status = mu_imapio_printf (imap->io, "()");
 	}
       MU_IMAP_CHECK_ERROR (imap, status);
-      status = mu_stream_printf (imap->carrier, "\r\n");
+      status = mu_imapio_printf (imap->io, "\r\n");
       MU_IMAP_CHECK_ERROR (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
       imap->state = MU_IMAP_ID_RX;
@@ -157,8 +172,8 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_list_t *plist)
 	{
 	case MU_IMAP_OK:
 	  imap->imap_state = MU_IMAP_STATE_AUTH;
-	  if (plist)
-	    status = parse_id_reply (imap, plist);
+	  if (passoc)
+	    status = parse_id_reply (imap, passoc);
 	  break;
 
 	case MU_IMAP_NO:
diff --git a/libproto/imap/login.c b/libproto/imap/login.c
index bce17ee..fe0af0c 100644
--- a/libproto/imap/login.c
+++ b/libproto/imap/login.c
@@ -30,7 +30,7 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
   
   if (imap == NULL)
     return EINVAL;
-  if (!imap->carrier)
+  if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
   if (imap->state != MU_IMAP_CONNECTED)
     return MU_ERR_SEQ;
@@ -44,7 +44,7 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
 	_mu_imap_xscript_level (imap, MU_XSCRIPT_SECURE);
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      status = mu_stream_printf (imap->carrier, "%s LOGIN \"%s\" \"%s\"\r\n",
+      status = mu_imapio_printf (imap->io, "%s LOGIN \"%s\" \"%s\"\r\n",
 				 imap->tag_str, user, pass);
       _mu_imap_xscript_level (imap, MU_XSCRIPT_NORMAL);
       /* FIXME: how to obscure the passwd in the stream buffer? */
diff --git a/libproto/imap/logout.c b/libproto/imap/logout.c
index 922fc33..3565bb7 100644
--- a/libproto/imap/logout.c
+++ b/libproto/imap/logout.c
@@ -30,7 +30,7 @@ mu_imap_logout (mu_imap_t imap)
   
   if (imap == NULL)
     return EINVAL;
-  if (!imap->carrier)
+  if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
   if (imap->state != MU_IMAP_CONNECTED)
     return MU_ERR_SEQ;
@@ -40,7 +40,7 @@ mu_imap_logout (mu_imap_t imap)
     case MU_IMAP_CONNECTED:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      status = mu_stream_printf (imap->carrier, "%s LOGOUT\r\n",
+      status = mu_imapio_printf (imap->io, "%s LOGOUT\r\n",
 				 imap->tag_str); 
       MU_IMAP_CHECK_EAGAIN (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
diff --git a/libproto/imap/resplist.c b/libproto/imap/resplist.c
new file mode 100644
index 0000000..3031fee
--- /dev/null
+++ b/libproto/imap/resplist.c
@@ -0,0 +1,256 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
+#include <mailutils/stream.h>
+#include <mailutils/errno.h>
+#include <mailutils/sys/imap.h>
+
+static void
+_imap_list_free (void *ptr)
+{
+  struct imap_list_element *elt = ptr;
+
+  switch (elt->type)
+    {
+    case imap_eltype_string:
+      free (elt->v.string);
+      break;
+      
+    case imap_eltype_list:
+      mu_list_destroy (&elt->v.list);
+    }
+  free (ptr);
+}
+
+static int
+_mu_imap_response_list_create (mu_imap_t imap, mu_list_t *plist)
+{
+  mu_list_t list;
+  int status = mu_list_create (&list);
+  MU_IMAP_CHECK_ERROR (imap, status);
+  mu_list_set_destroy_item (list, _imap_list_free);
+  *plist = list;
+  return 0;
+}
+
+int
+_mu_imap_untagged_response_clear (mu_imap_t imap)
+{
+  if (imap->untagged_resp)
+    mu_list_clear (imap->untagged_resp);
+  else
+    return _mu_imap_response_list_create (imap, &imap->untagged_resp);
+  return 0;
+}
+
+#define IS_LBRACE(p) ((p)[0] == '(')
+#define IS_RBRACE(p) ((p)[0] == ')')
+
+static struct imap_list_element *
+_new_imap_list_element (mu_imap_t imap, enum imap_eltype type)
+{
+  struct imap_list_element *elt = calloc (1, sizeof (*elt));
+  if (!elt)
+    {
+      imap->state = MU_IMAP_ERROR;
+    }
+  else
+    elt->type = type;
+  return elt;
+}
+
+struct parsebuf
+{
+  mu_imap_t pb_imap;
+  size_t pb_count;
+  char **pb_arr;
+  int pb_err;
+  int pb_inlist;
+};
+
+static void
+parsebuf_init (struct parsebuf *pb, mu_imap_t imap)
+{
+  memset (pb, 0, sizeof *pb);
+  pb->pb_imap = imap;
+}
+
+static int
+parsebuf_advance (struct parsebuf *pb)
+{
+  if (pb->pb_count == 0)
+    return MU_ERR_NOENT;
+  pb->pb_count--;
+  pb->pb_arr++;
+  return 0;
+}
+
+static char *
+parsebuf_gettok (struct parsebuf *pb)
+{
+  char *p;
+  
+  if (pb->pb_count == 0)
+    return NULL;
+  p = *pb->pb_arr;
+  parsebuf_advance (pb);
+  return p;
+}
+
+static char *
+parsebuf_peek (struct parsebuf *pb)
+{
+  if (pb->pb_count == 0)
+    return NULL;
+  return *pb->pb_arr;
+}
+
+static void
+parsebuf_seterr (struct parsebuf *pb, int err)
+{
+  pb->pb_err = err;
+}
+
+static struct imap_list_element *_parse_element (struct parsebuf *pb);
+
+static struct imap_list_element *
+_parse_list (struct parsebuf *pb)
+{
+  int rc;
+  struct imap_list_element *elt, *list_elt;
+
+  elt = _new_imap_list_element (pb->pb_imap, imap_eltype_list);
+  if (!elt)
+    {
+      parsebuf_seterr (pb, ENOMEM);
+      return NULL;
+    }
+
+  rc = _mu_imap_response_list_create (pb->pb_imap, &elt->v.list);
+  if (rc)
+    {
+      free (elt);
+      parsebuf_seterr (pb, rc);
+      return NULL;
+    }
+
+  while ((list_elt = _parse_element (pb)))
+    mu_list_append (elt->v.list, list_elt);
+
+  return elt;
+}
+
+static struct imap_list_element *
+_parse_element (struct parsebuf *pb)
+{
+  struct imap_list_element *elt;
+  char *tok;
+
+  if (pb->pb_err)
+    return NULL;
+
+  tok = parsebuf_gettok (pb);
+  
+  if (!tok)
+    {
+      if (pb->pb_inlist)
+	parsebuf_seterr (pb, MU_ERR_PARSE);
+      return NULL;
+    }
+  
+  if (IS_LBRACE (tok))
+    {
+      tok = parsebuf_peek (pb);
+      if (!tok)
+	{
+	  parsebuf_seterr (pb, MU_ERR_PARSE);
+	  return NULL;
+	}
+      
+      if (IS_RBRACE (tok))
+	{
+	  elt = _new_imap_list_element (pb->pb_imap, imap_eltype_list);
+	  if (!elt)
+	    {
+	      parsebuf_seterr (pb, ENOMEM);
+	      return NULL;
+	    }
+	  elt->v.list = NULL;
+	}
+      else
+	{
+	  pb->pb_inlist++;
+	  elt = _parse_list (pb);
+	}
+    }
+  else if (IS_RBRACE (tok))
+    {
+      if (pb->pb_inlist)
+	pb->pb_inlist--;
+      else
+	parsebuf_seterr (pb, MU_ERR_PARSE);
+      return NULL;
+    }
+  else
+    {
+      char *s;
+      elt = _new_imap_list_element (pb->pb_imap, imap_eltype_string);
+      if (!elt)
+	{
+	  parsebuf_seterr (pb, ENOMEM);
+	  return NULL;
+	}
+      s = strdup (tok);
+      if (!s)
+	{
+	  free (elt);
+	  parsebuf_seterr (pb, ENOMEM);
+	  return NULL;
+	}
+      elt->v.string = s;
+    }
+  return elt;
+}
+
+int
+_mu_imap_untagged_response_add (mu_imap_t imap)
+{
+  struct imap_list_element *elt;
+  struct parsebuf pb;
+
+  parsebuf_init (&pb, imap);
+  mu_imapio_get_words (imap->io, &pb.pb_count, &pb.pb_arr);
+  parsebuf_advance (&pb); /* Skip initial '*' */
+  elt = _parse_list (&pb);
+  if (pb.pb_err)
+    {
+      if (elt)
+	_imap_list_free (elt);
+      imap->state = MU_IMAP_ERROR;
+      return pb.pb_err;
+    }
+  mu_list_append (imap->untagged_resp, elt);
+  return 0;
+}
diff --git a/libproto/imap/response.c b/libproto/imap/response.c
index 7612b71..67087ad 100644
--- a/libproto/imap/response.c
+++ b/libproto/imap/response.c
@@ -27,15 +27,9 @@
 #include <mailutils/errno.h>
 #include <mailutils/sys/imap.h>
 
-#define IS_PREFIX(s, len, pfx)				\
-  ((len) >= sizeof (pfx) - 1 &&				\
-   memcmp ((s), (pfx), sizeof (pfx) - 1) == 0 &&	\
-   s[sizeof (pfx) - 1] == ' ')
-
 int
 _mu_imap_response (mu_imap_t imap)
 {
-  size_t n = 0;
   int status = 0;
 
   if (imap == NULL)
@@ -45,81 +39,74 @@ _mu_imap_response (mu_imap_t imap)
     return 0;
 
   _mu_imap_clrerrstr (imap);
-  if (imap->untagged_resp)
-    mu_list_clear (imap->untagged_resp);
-  else
-    {
-      status = mu_list_create (&imap->untagged_resp);
-      MU_IMAP_CHECK_ERROR (imap, status);
-      mu_list_set_destroy_item (imap->untagged_resp, mu_list_free_item);
-    }
-
+  status = _mu_imap_untagged_response_clear (imap);
+  if (status)
+    return status;
+  
   while (1)
     {
-      status = mu_stream_getline (imap->carrier, &imap->rdbuf,
-				  &imap->rdsize, NULL);
+      status = mu_imapio_getline (imap->io);
       if (status == 0)
 	{
-	  n = mu_rtrim_class (imap->rdbuf, MU_CTYPE_SPACE);
-	  if (imap->rdbuf[0] == '*' && imap->rdbuf[1] == ' ')
+	  char **wv;
+	  size_t wc;
+	  char *p;
+	  
+	  mu_imapio_get_words (imap->io, &wc, &wv);
+	  if (strcmp (wv[0], "*") == 0)
 	    {
-	      char *p = mu_str_skip_cset (imap->rdbuf + 2, " ");
-	      mu_list_append (imap->untagged_resp, strdup (p));
+	      _mu_imap_untagged_response_add (imap);/* FIXME: error checking */
+	      continue;
 	    }
-	  else if (n > imap->tag_len + 3 &&
-		   memcmp (imap->rdbuf, imap->tag_str, imap->tag_len) == 0
-		   && imap->rdbuf[imap->tag_len] == ' ')
+	  else if (strlen (wv[0]) == imap->tag_len &&
+		   memcmp (wv[0], imap->tag_str, imap->tag_len) == 0)
 	    {
-	      char *p = mu_str_skip_cset (imap->rdbuf + imap->tag_len, " ");
-	      size_t len = strlen (p);
-
-	      if (len >= imap->tagsize)
+	      /* Handle the tagged response */
+	      if (wc < 2)
 		{
-		  char *np = realloc (imap->tagbuf, len + 1);
-		  if (!np)
-		    {
-		      imap->state = MU_IMAP_ERROR;
-		      return ENOMEM;
-		    }
-		  imap->tagsize = len + 1;
-		  imap->tagbuf = np;
+		  /*imap->state = MU_IMAP_ERROR;*/
+		  status = MU_ERR_BADREPLY;
 		}
-	      strcpy (imap->tagbuf, p);
-	      if (IS_PREFIX (p, len, "OK"))
+	      else if (strcmp (wv[1], "OK") == 0)
 		{
 		  imap->resp_code = MU_IMAP_OK;
-		  p = mu_str_skip_cset (p + 2, " ");
-		  _mu_imap_seterrstr (imap, p, strlen (p));
+		  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
+		    {
+		      _mu_imap_seterrstr (imap, p, strlen (p));
+		      free (p);
+		    }
 		}
-	      else if (IS_PREFIX (p, len, "NO"))
+	      else if (strcmp (wv[1], "NO") == 0)
 		{
 		  imap->resp_code = MU_IMAP_NO;
-		  p = mu_str_skip_cset (p + 2, " ");
-		  _mu_imap_seterrstr (imap, p, strlen (p));
+		  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
+		    {
+		      _mu_imap_seterrstr (imap, p, strlen (p));
+		      free (p);
+		    }
 		}
-	      else if (IS_PREFIX (p, len, "BAD"))
+	      else if (strcmp (wv[1], "BAD") == 0)
 		{
 		  imap->resp_code = MU_IMAP_BAD;
-		  p = mu_str_skip_cset (p + 2, " ");
-		  _mu_imap_seterrstr (imap, p, strlen (p));
+		  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
+		    {
+		      _mu_imap_seterrstr (imap, p, strlen (p));
+		      free (p);
+		    }
 		}
 	      else
 		status = MU_ERR_BADREPLY;
 	      MU_IMAP_FSET (imap, MU_IMAP_RESP);
-	      break;
 	    }
 	  else
 	    {
 	      imap->state = MU_IMAP_ERROR;
-	      return MU_ERR_BADREPLY;
+	      status = MU_ERR_BADREPLY;
 	    }
 	}
       else
-	{
-	  imap->state = MU_IMAP_ERROR;
-	  return status;
-	}
+	imap->state = MU_IMAP_ERROR;
+      break;
     }
   return status;
 }
-	  
diff --git a/libproto/imap/trace.c b/libproto/imap/trace.c
index 0fc274b..152e9df 100644
--- a/libproto/imap/trace.c
+++ b/libproto/imap/trace.c
@@ -19,78 +19,50 @@
 # include <config.h>
 #endif
 
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <mailutils/error.h>
 #include <mailutils/errno.h>
-#include <mailutils/nls.h>
-#include <mailutils/stream.h>
+#include <mailutils/imapio.h>
 #include <mailutils/sys/imap.h>
 
-static const char *imap_prefix[] = {
-  "S: ", "C: "
-};
-
 int
 _mu_imap_trace_enable (mu_imap_t imap)
 {
-  int rc = 0;
-  mu_stream_t dstr, xstr;
-
-  if (!imap->carrier)
+  int rc;
+  if (!imap->io)
+    return 0;
+  rc = mu_imapio_trace_enable (imap->io);
+  switch (rc)
     {
+    case 0:
+    case MU_ERR_OPEN:
       MU_IMAP_FSET (imap, MU_IMAP_TRACE);
-      return 0;
-    }
-  
-  rc = mu_dbgstream_create (&dstr, MU_DIAG_DEBUG);
-  if (rc)
-    mu_error (_("cannot create debug stream; transcript disabled: %s"),
-	      mu_strerror (rc));
-  else
-    {
-      rc = mu_xscript_stream_create (&xstr, imap->carrier, dstr,
-				     imap_prefix);
-      if (rc)
-	mu_error (_("cannot create transcript stream: %s"),
-		  mu_strerror (rc));
-      else
-	{
-	  mu_stream_unref (imap->carrier);
-	  imap->carrier = xstr;
-	  MU_IMAP_FSET (imap, MU_IMAP_TRACE);
-	}
+      break;
     }
-
   return rc;
 }
 
 int
 _mu_imap_trace_disable (mu_imap_t imap)
 {
-  mu_stream_t xstr = imap->carrier;
-  mu_stream_t stream[2];
   int rc;
-
-  if (!xstr)
+  if (!imap->io)
     return 0;
-  
-  rc = mu_stream_ioctl (xstr, MU_IOCTL_TRANSPORT, MU_IOCTL_OP_GET, stream);
-  if (rc)
-    return rc;
+  rc = mu_imapio_trace_disable (imap->io);
+  switch (rc)
+    {
+    case 0:
+    case MU_ERR_NOT_OPEN:
+      MU_IMAP_FCLR (imap, MU_IMAP_TRACE);
+      break;
+    }
+  return rc;
 
-  imap->carrier = stream[0];
-  mu_stream_destroy (&xstr);
-  MU_IMAP_FCLR (imap, MU_IMAP_TRACE);
-  return 0;
 }
 
 int
 mu_imap_trace (mu_imap_t imap, int op)
 {
-  int trace_on = MU_IMAP_FISSET (imap, MU_IMAP_TRACE);
-  
+  int trace_on = mu_imapio_get_trace (imap->io);
+
   switch (op)
     {
     case MU_IMAP_TRACE_SET:
@@ -117,15 +89,15 @@ mu_imap_trace_mask (mu_imap_t imap, int op, int lev)
   switch (op)
     {
     case MU_IMAP_TRACE_SET:
-      imap->flags |= MU_IMAP_XSCRIPT_MASK(lev);
+      imap->flags |= MU_IMAP_XSCRIPT_MASK (lev);
       break;
       
     case MU_IMAP_TRACE_CLR:
-      imap->flags &= ~MU_IMAP_XSCRIPT_MASK(lev);
+      imap->flags &= ~MU_IMAP_XSCRIPT_MASK (lev);
       break;
       
     case MU_IMAP_TRACE_QRY:
-      if (imap->flags & MU_IMAP_XSCRIPT_MASK(lev))
+      if (imap->flags & MU_IMAP_XSCRIPT_MASK (lev))
 	break;
       return MU_ERR_NOENT;
       
@@ -138,8 +110,5 @@ mu_imap_trace_mask (mu_imap_t imap, int op, int lev)
 int
 _mu_imap_xscript_level (mu_imap_t imap, int xlev)
 {
-  if (mu_stream_ioctl (imap->carrier, MU_IOCTL_XSCRIPTSTREAM,
-                       MU_IOCTL_XSCRIPTSTREAM_LEVEL, &xlev) == 0)
-    return xlev;
-  return MU_XSCRIPT_NORMAL;
+  return mu_imapio_set_xscript_level (imap->io, xlev);
 }
diff --git a/mu/imap.c b/mu/imap.c
index c531d9b..e6fa2d1 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -364,6 +364,12 @@ com_login (int argc, char **argv)
   int status;
   char *pwd, *passbuf = NULL;
 
+  if (!imap)
+    {
+      mu_error (_("you need to connect first"));
+      return 0;
+    }
+  
   if (argc == 2)
     {
       if (!mutool_shell_interactive)
@@ -395,22 +401,13 @@ com_login (int argc, char **argv)
   return 0;
 }
 
-
-static int
-_print_id (void *item, void *data)
-{
-  const char *id = item;
-  mu_printf ("ID: %s %s\n", id, id + strlen (id) + 1);
-  return 0;
-}
-
 static int
 com_id (int argc, char **argv)
 {
-  mu_list_t list;
+  mu_assoc_t assoc;
   char *test = NULL;
   int status;
-  
+
   argv++;
   if (argv[0] && strcmp (argv[0], "-test") == 0)
     {
@@ -424,31 +421,36 @@ com_id (int argc, char **argv)
       argv++;
     }
   
-  status = mu_imap_id (imap, argv + 1, &list);
+  status = mu_imap_id (imap, argv + 1, &assoc);
   if (status == 0)
     {
       if (test)
 	{
-	  const char *res;
-	  int rc = mu_list_locate (list, test, (void*)&res);
-
-	  switch (rc)
+	  void *res = mu_assoc_ref (assoc, test);
+	  if (res)
 	    {
-	    case 0:
-	      mu_printf ("%s: %s\n", test, res + strlen (res) + 1);
-	      break;
-	      
-	    case MU_ERR_NOENT:
-	      mu_printf ("%s is not set\n", test);
-	      break;
-
-	    default:
-	      return rc;
+	      mu_printf ("%s: %s\n", test, *(char **)res);
 	    }
+	  else
+	    mu_printf ("%s is not set\n", test);
 	}
       else
-	mu_list_do (list, _print_id, NULL);
-      mu_list_destroy (&list);
+	{
+	  mu_iterator_t itr;
+	  
+	  mu_assoc_get_iterator (assoc, &itr);
+	  for (mu_iterator_first (itr);
+	       !mu_iterator_is_done (itr); mu_iterator_next (itr))
+	    {
+	      char *key;
+	      void *val;
+
+	      mu_iterator_current_kv (itr, (const void**)&key, &val);
+	      mu_printf ("ID: %s %s\n", key, *(char**)val);
+	    }
+	  mu_iterator_destroy (&itr);
+	}
+      mu_assoc_destroy (&assoc);
     }
   return status;
 }


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 18 11:48:27 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRRc3-0001q5-UF
	for mharc-commit-mailutils@gnu.org; Fri, 18 Nov 2011 11:48:27 -0500
Received: from eggs.gnu.org ([140.186.70.92]:35734)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRRbv-0001af-Bv
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 11:48:25 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRRbo-0005Ec-SH
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 11:48:19 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33319)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRRbo-0005EV-Lp
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 11:48:12 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRRbl-0005B7-RQ
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 16:48:13 +0000
Date: Fri, 18 Nov 2011 16:48:09 +0000
Message-Id: <E1RRRbl-0005B7-RQ@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-449-ga736b7a
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f7942ced21d97774e678be261cc5b9094e47e8da
X-Git-Newrev: a736b7a9a775db4b82806a6214deefc3ac7a4dd4
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Nov 2011 16:48:25 -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=a736b7a9a775db4b82806a6214deefc3ac7a4dd4

The branch, master has been updated
       via  a736b7a9a775db4b82806a6214deefc3ac7a4dd4 (commit)
       via  e4a76054ba29cd5af1bc80a96089580d3515279a (commit)
       via  db7e58b41501fda7629080195e33946f6d26e2a3 (commit)
      from  f7942ced21d97774e678be261cc5b9094e47e8da (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 a736b7a9a775db4b82806a6214deefc3ac7a4dd4
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 18 18:47:50 2011 +0200

    imap client: redo capability and id support via list mappers.
    
    * libproto/imap/capability.c (mu_imap_capability): Use mu_list_map to
    create the capability list.
    * libproto/imap/id.c (_id_convert): Likewise for ID pairs.

commit e4a76054ba29cd5af1bc80a96089580d3515279a
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 18 17:16:02 2011 +0200

    Implement list mapping.
    
    * include/mailutils/list.h (MU_LIST_MAP_OK)
    (MU_LIST_MAP_SKIP,MU_LIST_MAP_STOP): New constants.
    (mu_list_mapper_t): New typedef.
    (mu_list_map): New proto.
    * libmailutils/list/gmap.c: New file.
    * libmailutils/list/map.c: New file.
    * libmailutils/list/Makefile.am: Add gmap.c and map.c
    * libmailutils/tests/listop.c: New command "map".
    * libmailutils/tests/list.at: Test the list mapping.

commit db7e58b41501fda7629080195e33946f6d26e2a3
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 18 13:35:30 2011 +0200

    Move list support into a separate convenience library.
    
    * configure.ac: Build libmailutils/list/Makefile
    * include/mailutils/sys/list.h (DESTROY_ITEM): New define.
    (_mu_list_insert_item): New proto.
    * libmailutils/Makefile.am (SUBDIRS): Add list.
    (libmailutils_la_LIBADD): Add list/liblist.la
    * libmailutils/base/Makefile.am (libbase_la_SOURCES): Remove list sources.
    * libmailutils/base/list.c: Split into smaller files (see below).
    * libmailutils/base/listlist.c: Move to libmailutils/list/listlist.c
    * libmailutils/list/Makefile.am: New file.
    * libmailutils/list/append.c: New file.
    * libmailutils/list/array.c: New file.
    * libmailutils/list/clear.c: New file.
    * libmailutils/list/count.c: New file.
    * libmailutils/list/create.c: New file.
    * libmailutils/list/destroy.c: New file.
    * libmailutils/list/do.c: New file.
    * libmailutils/list/empty.c: New file.
    * libmailutils/list/get.c: New file.
    * libmailutils/list/getcomp.c: New file.
    * libmailutils/list/insert.c: New file.
    * libmailutils/list/intersect.c: New file.
    * libmailutils/list/iterator.c: New file.
    * libmailutils/list/locate.c: New file.
    * libmailutils/list/prepend.c: New file.
    * libmailutils/list/remove.c: New file.
    * libmailutils/list/replace.c: New file.
    * libmailutils/list/setcomp.c: New file.
    * libmailutils/list/setdestr.c: New file.

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

Summary of changes:
 configure.ac                                       |    1 +
 include/mailutils/list.h                           |   44 ++
 include/mailutils/sys/list.h                       |   11 +
 libmailutils/Makefile.am                           |    7 +-
 libmailutils/base/Makefile.am                      |    2 -
 libmailutils/base/list.c                           |  705 --------------------
 libmailutils/{sockaddr => list}/Makefile.am        |   32 +-
 libmailutils/{property/propitr.c => list/append.c} |   33 +-
 libmailutils/{property/propitr.c => list/array.c}  |   34 +-
 libmailutils/{property/propitr.c => list/clear.c}  |   33 +-
 libmailutils/{property/propitr.c => list/count.c}  |   21 +-
 libmailutils/{property/propitr.c => list/create.c} |   33 +-
 .../{property/propitr.c => list/destroy.c}         |   26 +-
 libmailutils/{property/propitr.c => list/do.c}     |   33 +-
 libmailutils/{url/urlinv.c => list/empty.c}        |   18 +-
 libmailutils/{property/propitr.c => list/get.c}    |   36 +-
 libmailutils/{url/urlinv.c => list/getcomp.c}      |   15 +-
 libmailutils/{property/propset.c => list/gmap.c}   |   75 +--
 libmailutils/list/insert.c                         |   72 ++
 libmailutils/list/intersect.c                      |   90 +++
 libmailutils/list/iterator.c                       |  250 +++++++
 libmailutils/{base => list}/listlist.c             |    4 -
 libmailutils/{property/propitr.c => list/locate.c} |   43 +-
 libmailutils/list/map.c                            |   87 +++
 .../{property/propitr.c => list/prepend.c}         |   32 +-
 libmailutils/list/remove.c                         |   66 ++
 .../{property/propset.c => list/replace.c}         |   65 +-
 .../{property/propitr.c => list/setcomp.c}         |   25 +-
 .../{property/propitr.c => list/setdestr.c}        |   21 +-
 libmailutils/tests/list.at                         |   80 +++-
 libmailutils/tests/listop.c                        |  202 ++++++-
 libproto/imap/capability.c                         |   46 +-
 libproto/imap/id.c                                 |   41 +-
 33 files changed, 1277 insertions(+), 1006 deletions(-)
 delete mode 100644 libmailutils/base/list.c
 copy libmailutils/{sockaddr => list}/Makefile.am (75%)
 copy libmailutils/{property/propitr.c => list/append.c} (62%)
 copy libmailutils/{property/propitr.c => list/array.c} (64%)
 copy libmailutils/{property/propitr.c => list/clear.c} (63%)
 copy libmailutils/{property/propitr.c => list/count.c} (74%)
 copy libmailutils/{property/propitr.c => list/create.c} (64%)
 copy libmailutils/{property/propitr.c => list/destroy.c} (71%)
 copy libmailutils/{property/propitr.c => list/do.c} (61%)
 copy libmailutils/{url/urlinv.c => list/empty.c} (76%)
 copy libmailutils/{property/propitr.c => list/get.c} (59%)
 copy libmailutils/{url/urlinv.c => list/getcomp.c} (75%)
 copy libmailutils/{property/propset.c => list/gmap.c} (51%)
 create mode 100644 libmailutils/list/insert.c
 create mode 100644 libmailutils/list/intersect.c
 create mode 100644 libmailutils/list/iterator.c
 rename libmailutils/{base => list}/listlist.c (98%)
 copy libmailutils/{property/propitr.c => list/locate.c} (53%)
 create mode 100644 libmailutils/list/map.c
 copy libmailutils/{property/propitr.c => list/prepend.c} (61%)
 create mode 100644 libmailutils/list/remove.c
 copy libmailutils/{property/propset.c => list/replace.c} (50%)
 copy libmailutils/{property/propitr.c => list/setcomp.c} (71%)
 copy libmailutils/{property/propitr.c => list/setdestr.c} (71%)

diff --git a/configure.ac b/configure.ac
index 7251453..f28c42b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1473,6 +1473,7 @@ AC_CONFIG_FILES([
  libmailutils/diag/Makefile
  libmailutils/filter/Makefile
  libmailutils/imapio/Makefile
+ libmailutils/list/Makefile
  libmailutils/mailbox/Makefile
  libmailutils/mailer/Makefile
  libmailutils/mime/Makefile
diff --git a/include/mailutils/list.h b/include/mailutils/list.h
index d6f3f45..becf280 100644
--- a/include/mailutils/list.h
+++ b/include/mailutils/list.h
@@ -72,7 +72,51 @@ extern int mu_list_insert_list (mu_list_t list, void *item, mu_list_t new_list,
 				int insert_before);
 extern void mu_list_append_list (mu_list_t list, mu_list_t new_list);
 extern void mu_list_prepend_list (mu_list_t list, mu_list_t new_list);
+
+/* List mapper functions */
+typedef int (*mu_list_mapper_t) (void **itmv, size_t itmc, void *call_data);
+
+/* A generalized list mapping function.
+
+   Mu_list_gmap iterates over the LIST, gathering its elements in an
+   array of type void **.  When NELEM elements has been collected, it
+   calls the MAP function, passing it as arguments the constructed array,
+   number of elements in it (can be less than NELEM on the last call),
+   and call-specific DATA.  Iteration continues while MAP returns 0 and
+   until all elements from the array have been visited.
+
+   Mu_list_gmap returns 0 on success and a non-zero error code on failure.
+   If MAP returns !0, its return value is propagated to the caller.
+*/
+   
+int mu_list_gmap (mu_list_t list, mu_list_mapper_t map, size_t nelem,
+		  void *data);
   
+  
+#define MU_LIST_MAP_OK     0x00
+#define MU_LIST_MAP_SKIP   0x01
+#define MU_LIST_MAP_STOP   0x02
+
+/* List-to-list mapping.
+   
+   Apply the list mapping function MAP to each NELEM elements from the source
+   LIST and use its return values to form a new list, which will be returned
+   in RES.
+
+   MAP gets pointers to the collected elements in its first argument (ITMV).
+   Its second argument (ITMC) gives the number of elements filled in ARR.
+   It can be less than NELEM on the last call to MAP.  The DATA pointer is
+   passed as the 3rd argument.
+
+   Return value from MAP governs the mapping process.  Unless it has the
+   MU_LIST_MAP_SKIP bit set, the itmv[0] element is appended to the new
+   list.  If it has MU_LIST_MAP_STOP bit set, iteration is stopped
+   immediately and any remaining elements in LIST are ignored.
+*/
+
+int mu_list_map (mu_list_t list, mu_list_mapper_t map,
+		 void *data, size_t nelem,
+		 mu_list_t *res);
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/sys/list.h b/include/mailutils/sys/list.h
index ba00ae7..6769e78 100644
--- a/include/mailutils/sys/list.h
+++ b/include/mailutils/sys/list.h
@@ -46,6 +46,14 @@ struct _mu_list
   struct _mu_iterator *itr;
 };
 
+#define DESTROY_ITEM(list, elt)			\
+  do						\
+    {						\
+       if ((list)->destroy_item)		\
+	 (list)->destroy_item ((elt)->item);	\
+    }						\
+  while (0)
+
 extern void _mu_list_clear (mu_list_t list);
 extern void _mu_list_insert_sublist (mu_list_t list,
 				     struct list_data *current,
@@ -53,6 +61,9 @@ extern void _mu_list_insert_sublist (mu_list_t list,
 				     struct list_data *tail,
 				     size_t count,
 				     int insert_before);
+extern int _mu_list_insert_item (mu_list_t list, struct list_data *current,
+				 void *new_item,
+				 int insert_before);
 
 # ifdef __cplusplus
 }
diff --git a/libmailutils/Makefile.am b/libmailutils/Makefile.am
index 7c1c5c4..b321382 100644
--- a/libmailutils/Makefile.am
+++ b/libmailutils/Makefile.am
@@ -16,8 +16,10 @@
 # Public License along with this library.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-SUBDIRS = auth base address sockaddr cidr cfg diag filter mailbox mailer mime\
- server string stream stdstream property url imapio . tests 
+SUBDIRS = \
+ auth base address list sockaddr cidr cfg diag\
+ filter mailbox mailer mime server string stream stdstream\
+ property url imapio . tests 
 
 lib_LTLIBRARIES = libmailutils.la
 
@@ -34,6 +36,7 @@ libmailutils_la_LIBADD = \
  diag/libdiag.la\
  filter/libfilter.la\
  imapio/libimapio.la\
+ list/liblist.la\
  mailbox/libmailbox.la\
  mailer/libmailer.la\
  mime/libmime.la\
diff --git a/libmailutils/base/Makefile.am b/libmailutils/base/Makefile.am
index 5f41b0c..cb6c521 100644
--- a/libmailutils/base/Makefile.am
+++ b/libmailutils/base/Makefile.am
@@ -39,8 +39,6 @@ libbase_la_SOURCES = \
  iterator.c\
  kwd.c\
  lcall.c\
- list.c\
- listlist.c\
  locale.c\
  locker.c\
  mailcap.c\
diff --git a/libmailutils/base/list.c b/libmailutils/base/list.c
deleted file mode 100644
index 74ec644..0000000
--- a/libmailutils/base/list.c
+++ /dev/null
@@ -1,705 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
-   Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library.  If not, see 
-   <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <mailutils/sys/list.h>
-#include <mailutils/sys/iterator.h>
-#include <mailutils/errno.h>
-
-#define DESTROY_ITEM(list, elt)			\
-  do						\
-    {						\
-       if ((list)->destroy_item)		\
-	 (list)->destroy_item ((elt)->item);	\
-    }						\
-  while (0)
-
-int
-mu_list_create (mu_list_t *plist)
-{
-  mu_list_t list;
-  int status;
-
-  if (plist == NULL)
-    return MU_ERR_OUT_PTR_NULL;
-  list = calloc (sizeof (*list), 1);
-  if (list == NULL)
-    return ENOMEM;
-  status = mu_monitor_create (&list->monitor, 0,  list);
-  if (status != 0)
-    {
-      free (list);
-      return status;
-    }
-  list->head.next = &list->head;
-  list->head.prev = &list->head;
-  *plist = list;
-  return 0;
-}
-
-void
-mu_list_clear (mu_list_t list)
-{
-  struct list_data *current;
-  struct list_data *previous;
-
-  if (!list)
-    return;
-  mu_monitor_wrlock (list->monitor);
-  for (current = list->head.next; current != &list->head;)
-    {
-      previous = current;
-      current = current->next;
-      DESTROY_ITEM (list, previous);
-      free (previous);
-    }
-  list->head.next = list->head.prev = &list->head;
-  mu_monitor_unlock (list->monitor);
-}
-
-void
-mu_list_destroy (mu_list_t *plist)
-{
-  if (plist && *plist)
-    {
-      mu_list_t list = *plist;
-      mu_list_clear (list);
-      mu_monitor_destroy (&list->monitor, list);
-      free (list);
-      *plist = NULL;
-    }
-}
-
-int
-mu_list_append (mu_list_t list, void *item)
-{
-  struct list_data *ldata;
-  struct list_data *last;
-
-  if (list == NULL)
-    return EINVAL;
-  last = list->head.prev;
-  ldata = calloc (sizeof (*ldata), 1);
-  if (ldata == NULL)
-    return ENOMEM;
-  ldata->item = item;
-  mu_monitor_wrlock (list->monitor);
-  ldata->next = &list->head;
-  ldata->prev = list->head.prev;
-  last->next = ldata;
-  list->head.prev = ldata;
-  list->count++;
-  mu_monitor_unlock (list->monitor);
-  return 0;
-}
-
-int
-mu_list_prepend (mu_list_t list, void *item)
-{
-  struct list_data *ldata;
-  struct list_data *first;
-
-  if (list == NULL)
-    return EINVAL;
-  first = list->head.next;
-  ldata = calloc (sizeof (*ldata), 1);
-  if (ldata == NULL)
-    return ENOMEM;
-  ldata->item = item;
-  mu_monitor_wrlock (list->monitor);
-  ldata->prev = &list->head;
-  ldata->next = list->head.next;
-  first->prev = ldata;
-  list->head.next = ldata;
-  list->count++;
-  mu_monitor_unlock (list->monitor);
-  return 0;
-}
-
-int
-mu_list_is_empty (mu_list_t list)
-{
-  size_t n = 0;
-
-  mu_list_count (list, &n);
-  return (n == 0);
-}
-
-int
-mu_list_count (mu_list_t list, size_t *pcount)
-{
-  if (list == NULL)
-    return EINVAL;
-  if (pcount == NULL)
-    return MU_ERR_OUT_PTR_NULL;
-  *pcount = list->count;
-  return 0;
-}
-
-mu_list_comparator_t
-mu_list_set_comparator (mu_list_t list, mu_list_comparator_t comp)
-{
-  mu_list_comparator_t old_comp;
-
-  if (list == NULL)
-    return NULL;
-  old_comp = list->comp;
-  list->comp = comp;
-  return old_comp;
-}
-
-int
-mu_list_get_comparator (mu_list_t list, mu_list_comparator_t *comp)
-{
-  if (!list)
-    return EINVAL;
-  *comp = list->comp;
-  return 0;
-}
-
-int
-_mu_list_ptr_comparator (const void *item, const void *value)
-{
-  return item != value;
-}
-
-int
-mu_list_locate (mu_list_t list, void *item, void **ret_item)
-{
-  struct list_data *current, *previous;
-  mu_list_comparator_t comp;
-  int status = MU_ERR_NOENT;
-
-  if (list == NULL)
-    return EINVAL;
-  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
-  mu_monitor_wrlock (list->monitor);
-  for (previous = &list->head, current = list->head.next;
-       current != &list->head; previous = current, current = current->next)
-    {
-      if (comp (current->item, item) == 0)
-	{
-	  if (ret_item)
-	    *ret_item = current->item;
-	  status = 0;
-	  break;
-	}
-    }
-  mu_monitor_unlock (list->monitor);
-  return status;
-}
-
-static int
-_insert_item (mu_list_t list, struct list_data *current, void *new_item,
-	      int insert_before)
-{
-  int status;
-  struct list_data *ldata = calloc (sizeof (*ldata), 1);
-  if (ldata == NULL)
-    status = ENOMEM;
-  else
-    {
-      ldata->item = new_item;
-      _mu_list_insert_sublist (list, current,
-			       ldata, ldata,
-			       1,
-			       insert_before);
-      status = 0;
-    }
-  return status;
-}
-
-int
-mu_list_insert (mu_list_t list, void *item, void *new_item, int insert_before)
-{
-  struct list_data *current;
-  mu_list_comparator_t comp;
-  int status = MU_ERR_NOENT;
-
-  if (list == NULL)
-    return EINVAL;
-  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
-
-  mu_monitor_wrlock (list->monitor);
-  for (current = list->head.next;
-       current != &list->head;
-       current = current->next)
-    {
-      if (comp (current->item, item) == 0)
-	{
-	  status = _insert_item (list, current, new_item, insert_before);
-	  break;
-	}
-    }
-  mu_monitor_unlock (list->monitor);
-  return status;
-}
-
-int
-mu_list_remove (mu_list_t list, void *item)
-{
-  struct list_data *current;
-  mu_list_comparator_t comp;
-  int status = MU_ERR_NOENT;
-
-  if (list == NULL)
-    return EINVAL;
-  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
-  mu_monitor_wrlock (list->monitor);
-  for (current = list->head.next;
-       current != &list->head; current = current->next)
-    {
-      if (comp (current->item, item) == 0)
-	{
-	  struct list_data *previous = current->prev;
-	  
-	  mu_iterator_advance (list->itr, current);
-	  previous->next = current->next;
-	  current->next->prev = previous;
-	  DESTROY_ITEM (list, current);
-	  free (current);
-	  list->count--;
-	  status = 0;
-	  break;
-	}
-    }
-  mu_monitor_unlock (list->monitor);
-  return status;
-}
-
-int
-mu_list_remove_nd (mu_list_t list, void *item)
-{
-  mu_list_destroy_item_t dptr = mu_list_set_destroy_item (list, NULL);
-  int rc = mu_list_remove (list, item);
-  mu_list_set_destroy_item (list, dptr);
-  return rc;
-}
-
-int
-mu_list_replace (mu_list_t list, void *old_item, void *new_item)
-{
-  struct list_data *current, *previous;
-  mu_list_comparator_t comp;
-  int status = MU_ERR_NOENT;
-
-  if (list == NULL)
-    return EINVAL;
-  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
-  mu_monitor_wrlock (list->monitor);
-  for (previous = &list->head, current = list->head.next;
-       current != &list->head; previous = current, current = current->next)
-    {
-      if (comp (current->item, old_item) == 0)
-	{
-	  DESTROY_ITEM (list, current);
-	  current->item = new_item;
-	  status = 0;
-	  break;
-	}
-    }
-  mu_monitor_unlock (list->monitor);
-  return status;
-}
-
-int
-mu_list_replace_nd (mu_list_t list, void *item, void *new_item)
-{
-  mu_list_destroy_item_t dptr = mu_list_set_destroy_item (list, NULL);
-  int rc = mu_list_replace (list, item, new_item);
-  mu_list_set_destroy_item (list, dptr);
-  return rc;
-}
-
-int
-mu_list_get (mu_list_t list, size_t indx, void **pitem)
-{
-  struct list_data *current;
-  size_t count;
-  int status = MU_ERR_NOENT;
-
-  if (list == NULL)
-    return EINVAL;
-  if (pitem == NULL)
-    return MU_ERR_OUT_PTR_NULL;
-  mu_monitor_rdlock (list->monitor);
-  for (current = list->head.next, count = 0; current != &list->head;
-       current = current->next, count++)
-    {
-      if (count == indx)
-        {
-          *pitem = current->item;
-	  status = 0;
-	  break;
-        }
-    }
-  mu_monitor_unlock (list->monitor);
-  return status;
-}
-
-int
-mu_list_do (mu_list_t list, mu_list_action_t *action, void *cbdata)
-{
-  mu_iterator_t itr;
-  int status = 0;
-
-  if (list == NULL || action == NULL)
-    return EINVAL;
-  status = mu_list_get_iterator (list, &itr);
-  if (status)
-    return status;
-  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
-       mu_iterator_next (itr))
-    {
-      void *item;
-      mu_iterator_current (itr, &item);
-      if ((status = action (item, cbdata)))
-	break;
-    }
-  mu_iterator_destroy (&itr);
-  return status;
-}
-
-mu_list_destroy_item_t
-mu_list_set_destroy_item (mu_list_t list, void (*destroy_item)(void *item))
-{
-  mu_list_destroy_item_t ret = list->destroy_item;
-  list->destroy_item = destroy_item;
-  return ret;
-}
-
-int
-mu_list_to_array (mu_list_t list, void **array, size_t count, size_t *pcount)
-{
-  size_t total = 0;
-
-  if (!list)
-    return EINVAL;
-
-  total = (count < list->count) ? count : list->count;
-
-  if (array)
-    {
-      size_t i;
-      struct list_data *current;
-
-      for (i = 0, current = list->head.next;
-	   i < total && current != &list->head; current = current->next)
-	array[i++] = current->item;
-    }
-  if (pcount)
-    *pcount = total;
-  return 0;
-}
-
-/* Computes an intersection of two lists and returns it in PDEST.
-   The resulting list contains elements from A that are
-   also encountered in B (as per comparison function of
-   the latter).
-
-   If DUP_ITEM is not NULL, it is used to create copies of
-   items to be stored in PDEST.  In this case, the destroy_item
-   function of B is also attached to PDEST.  Otherwise, if
-   DUP_ITEM is NULL, pointers to elements are stored and
-   no destroy_item function is assigned. */
-int
-mu_list_intersect_dup (mu_list_t *pdest, mu_list_t a, mu_list_t b,
-		       int (*dup_item) (void **, void *, void *),
-		       void *dup_closure)
-{
-  mu_list_t dest;
-  int rc;
-  mu_iterator_t itr;
-  
-  rc = mu_list_create (&dest);
-  if (rc)
-    return rc;
-
-  mu_list_set_comparator (dest, b->comp);
-  if (dup_item)
-    mu_list_set_destroy_item (dest, b->destroy_item);
-  
-  rc = mu_list_get_iterator (a, &itr);
-  if (rc)
-    {
-      mu_list_destroy (&dest);
-      return rc;
-    }
-
-  rc = 0;
-  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
-       mu_iterator_next (itr))
-    {
-      void *data;
-      mu_iterator_current (itr, &data);
-      if (mu_list_locate (b, data, NULL) == 0)
-	{
-	  void *new_data;
-	  if (dup_item && data)
-	    {
-	      rc = dup_item (&new_data, data, dup_closure);
-	      if (rc)
-		break;
-	    }
-	  else
-	    new_data = data;
-	
-	  mu_list_append (dest, new_data); /* FIXME: Check return, and? */
-	}
-    }
-  mu_iterator_destroy (&itr);
-  *pdest = dest;
-  return rc;
-}
-
-int
-mu_list_intersect (mu_list_t *pdest, mu_list_t a, mu_list_t b)
-{
-  return mu_list_intersect_dup (pdest, a, b, NULL, NULL);
-}
-
-
-/* Iterator interface */
-
-struct list_iterator
-{
-  mu_list_t list;
-  struct list_data *cur;
-  int backwards; /* true if iterating backwards */
-};
-
-static int
-first (void *owner)
-{
-  struct list_iterator *itr = owner;
-  if (itr->backwards)
-    itr->cur = itr->list->head.prev;
-  else
-    itr->cur = itr->list->head.next;
-  return 0;
-}
-
-static int
-next (void *owner)
-{
-  struct list_iterator *itr = owner;
-  if (itr->backwards)
-    itr->cur = itr->cur->prev;
-  else
-    itr->cur = itr->cur->next;
-  return 0;
-}
-
-static int
-getitem (void *owner, void **pret, const void **pkey)
-{
-  struct list_iterator *itr = owner;
-  *pret = itr->cur->item;
-  if (pkey)
-    *pkey = NULL;
-  return 0;
-}
-
-static int
-finished_p (void *owner)
-{
-  struct list_iterator *itr = owner;
-  return itr->cur == &itr->list->head;
-}
-
-static int
-destroy (mu_iterator_t iterator, void *data)
-{
-  struct list_iterator *itr = data;
-  mu_iterator_detach (&itr->list->itr, iterator);
-  free (data);
-  return 0;
-}
-
-static int
-curitem_p (void *owner, void *item)
-{
-  struct list_iterator *itr = owner;
-  return itr->cur == item;
-}
-
-static int
-list_data_dup (void **ptr, void *owner)
-{
-  *ptr = malloc (sizeof (struct list_iterator));
-  if (*ptr == NULL)
-    return ENOMEM;
-  memcpy (*ptr, owner, sizeof (struct list_iterator));
-  return 0;
-}
-
-static int
-list_itrctl (void *owner, enum mu_itrctl_req req, void *arg)
-{
-  struct list_iterator *itr = owner;
-  mu_list_t list = itr->list;
-  struct list_data *ptr;
-  
-  switch (req)
-    {
-    case mu_itrctl_tell:
-      /* Return current position in the object */
-      if (itr->cur == NULL)
-	return MU_ERR_NOENT;
-      else
-	{
-	  size_t count;
-
-	  for (count = 0, ptr = list->head.next; ptr != &list->head;
-	       ptr = ptr->next, count++)
-	    {
-	      if (ptr == itr->cur)
-		{
-		  *(size_t*)arg = count;
-		  return 0;
-		}
-	    }
-	  return MU_ERR_NOENT;
-	}
-      break;
-      
-    case mu_itrctl_delete:
-    case mu_itrctl_delete_nd:
-      /* Delete current element */
-      if (itr->cur == NULL)
-	return MU_ERR_NOENT;
-      else
-	{
-	  struct list_data *prev;
-	
-	  ptr = itr->cur;
-	  prev = ptr->prev;
-	
-	  mu_iterator_advance (list->itr, ptr);
-	  prev->next = ptr->next;
-	  ptr->next->prev = prev;
-	  if (req == mu_itrctl_delete)
-	    DESTROY_ITEM (list, ptr);
-	  free (ptr);
-	  list->count--;
-	}
-      break;
-      
-    case mu_itrctl_replace:
-    case mu_itrctl_replace_nd:
-      /* Replace current element */
-      if (itr->cur == NULL)
-	return MU_ERR_NOENT;
-      if (!arg)
-	return EINVAL;
-      ptr = itr->cur;
-      if (req == mu_itrctl_replace)
-	  DESTROY_ITEM (list, ptr);
-      ptr = itr->cur;
-      ptr->item = arg;
-      break;
-      
-    case mu_itrctl_insert:
-      /* Insert new element in the current position */
-      if (itr->cur == NULL)
-	return MU_ERR_NOENT;
-      if (!arg)
-	return EINVAL;
-      return _insert_item (list, itr->cur, arg, 0);
-
-    case mu_itrctl_insert_list:
-      /* Insert a list of elements */
-      if (itr->cur == NULL)
-	return MU_ERR_NOENT;
-      if (!arg)
-	return EINVAL;
-      else
-	{
-	  mu_list_t new_list = arg;
-	  _mu_list_insert_sublist (list, itr->cur,
-				   new_list->head.next, new_list->head.prev,
-				   new_list->count,
-				   0);
-	  _mu_list_clear (new_list);
-	}
-      break;
-
-    case mu_itrctl_qry_direction:
-      if (!arg)
-	return EINVAL;
-      else
-	*(int*)arg = itr->backwards;
-      break;
-
-    case mu_itrctl_set_direction:
-      if (!arg)
-	return EINVAL;
-      else
-	itr->backwards = !!*(int*)arg;
-      break;
-      
-    default:
-      return ENOSYS;
-    }
-  return 0;
-}
-
-int
-mu_list_get_iterator (mu_list_t list, mu_iterator_t *piterator)
-{
-  mu_iterator_t iterator;
-  int status;
-  struct list_iterator *itr;
-
-  if (!list)
-    return EINVAL;
-
-  itr = calloc (1, sizeof *itr);
-  if (!itr)
-    return ENOMEM;
-  itr->list = list;
-  itr->cur = NULL;
-
-  status = mu_iterator_create (&iterator, itr);
-  if (status)
-    {
-      free (itr);
-      return status;
-    }
-
-  mu_iterator_set_first (iterator, first);
-  mu_iterator_set_next (iterator, next);
-  mu_iterator_set_getitem (iterator, getitem);
-  mu_iterator_set_finished_p (iterator, finished_p);
-  mu_iterator_set_curitem_p (iterator, curitem_p);
-  mu_iterator_set_destroy (iterator, destroy);
-  mu_iterator_set_dup (iterator, list_data_dup);
-  mu_iterator_set_itrctl (iterator, list_itrctl);
-  
-  mu_iterator_attach (&list->itr, iterator);
-
-  *piterator = iterator;
-  return 0;
-}
diff --git a/libmailutils/sockaddr/Makefile.am b/libmailutils/list/Makefile.am
similarity index 75%
copy from libmailutils/sockaddr/Makefile.am
copy to libmailutils/list/Makefile.am
index dcfb184..3b959fc 100644
--- a/libmailutils/sockaddr/Makefile.am
+++ b/libmailutils/list/Makefile.am
@@ -15,17 +15,31 @@
 # Public License along with this library.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-noinst_LTLIBRARIES = libsockaddr.la
+noinst_LTLIBRARIES = liblist.la
 
-libsockaddr_la_SOURCES = \
- copy.c\
+liblist_la_SOURCES = \
+ append.c\
+ array.c\
+ clear.c\
+ count.c\
  create.c\
- free.c\
- fromnode.c\
+ destroy.c\
+ do.c\
+ empty.c\
+ get.c\
+ getcomp.c\
+ gmap.c\
  insert.c\
- ipaddr.c\
- str.c\
- unlink.c\
- url.c
+ intersect.c\
+ iterator.c\
+ listlist.c\
+ locate.c\
+ map.c\
+ prepend.c\
+ remove.c\
+ replace.c\
+ setcomp.c\
+ setdestr.c
 
 INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
+
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/append.c
similarity index 62%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/append.c
index 0c3fd86..f514b3f 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/append.c
@@ -17,20 +17,31 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_append (mu_list_t list, void *item)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  struct list_data *ldata;
+  struct list_data *last;
+
+  if (list == NULL)
+    return EINVAL;
+  last = list->head.prev;
+  ldata = calloc (sizeof (*ldata), 1);
+  if (ldata == NULL)
+    return ENOMEM;
+  ldata->item = item;
+  mu_monitor_wrlock (list->monitor);
+  ldata->next = &list->head;
+  ldata->prev = list->head.prev;
+  last->next = ldata;
+  list->head.prev = ldata;
+  list->count++;
+  mu_monitor_unlock (list->monitor);
+  return 0;
 }
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/array.c
similarity index 64%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/array.c
index 0c3fd86..65433af 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/array.c
@@ -17,20 +17,32 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_to_array (mu_list_t list, void **array, size_t count, size_t *pcount)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  size_t total = 0;
+
+  if (!list)
+    return EINVAL;
+
+  total = (count < list->count) ? count : list->count;
+
+  if (array)
+    {
+      size_t i;
+      struct list_data *current;
+
+      for (i = 0, current = list->head.next;
+	   i < total && current != &list->head; current = current->next)
+	array[i++] = current->item;
+    }
+  if (pcount)
+    *pcount = total;
+  return 0;
 }
+
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/clear.c
similarity index 63%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/clear.c
index 0c3fd86..e39b389 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/clear.c
@@ -17,20 +17,27 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 
-#include <mailutils/types.h>
-#include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
-
-int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+void
+mu_list_clear (mu_list_t list)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  struct list_data *current;
+  struct list_data *previous;
+
+  if (!list)
+    return;
+  mu_monitor_wrlock (list->monitor);
+  for (current = list->head.next; current != &list->head;)
+    {
+      previous = current;
+      current = current->next;
+      DESTROY_ITEM (list, previous);
+      free (previous);
+    }
+  list->head.next = list->head.prev = &list->head;
+  mu_monitor_unlock (list->monitor);
 }
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/count.c
similarity index 74%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/count.c
index 0c3fd86..981dbcc 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/count.c
@@ -17,20 +17,19 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_count (mu_list_t list, size_t *pcount)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  if (list == NULL)
+    return EINVAL;
+  if (pcount == NULL)
+    return MU_ERR_OUT_PTR_NULL;
+  *pcount = list->count;
+  return 0;
 }
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/create.c
similarity index 64%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/create.c
index 0c3fd86..c5d59e1 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/create.c
@@ -17,20 +17,33 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
-#include <mailutils/types.h>
+#include <stdlib.h>
+
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_create (mu_list_t *plist)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  mu_list_t list;
+  int status;
+
+  if (plist == NULL)
+    return MU_ERR_OUT_PTR_NULL;
+  list = calloc (sizeof (*list), 1);
+  if (list == NULL)
+    return ENOMEM;
+  status = mu_monitor_create (&list->monitor, 0,  list);
+  if (status != 0)
+    {
+      free (list);
+      return status;
+    }
+  list->head.next = &list->head;
+  list->head.prev = &list->head;
+  *plist = list;
+  return 0;
 }
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/destroy.c
similarity index 71%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/destroy.c
index 0c3fd86..ebfd813 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/destroy.c
@@ -17,20 +17,20 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 
-#include <mailutils/types.h>
-#include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
-
-int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+void
+mu_list_destroy (mu_list_t *plist)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  if (plist && *plist)
+    {
+      mu_list_t list = *plist;
+      mu_list_clear (list);
+      mu_monitor_destroy (&list->monitor, list);
+      free (list);
+      *plist = NULL;
+    }
 }
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/do.c
similarity index 61%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/do.c
index 0c3fd86..ef9ef17 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/do.c
@@ -17,20 +17,31 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_do (mu_list_t list, mu_list_action_t *action, void *cbdata)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  mu_iterator_t itr;
+  int status = 0;
+
+  if (list == NULL || action == NULL)
+    return EINVAL;
+  status = mu_list_get_iterator (list, &itr);
+  if (status)
+    return status;
+  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
+       mu_iterator_next (itr))
+    {
+      void *item;
+      mu_iterator_current (itr, &item);
+      if ((status = action (item, cbdata)))
+	break;
+    }
+  mu_iterator_destroy (&itr);
+  return status;
 }
diff --git a/libmailutils/url/urlinv.c b/libmailutils/list/empty.c
similarity index 76%
copy from libmailutils/url/urlinv.c
copy to libmailutils/list/empty.c
index c4f8113..4498414 100644
--- a/libmailutils/url/urlinv.c
+++ b/libmailutils/list/empty.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
+   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
@@ -18,16 +19,13 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-#include <stdlib.h>
-#include <errno.h>
-#include <mailutils/sys/url.h>
+#include <mailutils/sys/list.h>
 
 int
-mu_url_invalidate (mu_url_t url)
+mu_list_is_empty (mu_list_t list)
 {
-  if (!url)
-    return EINVAL;
-  free (url->name);
-  url->name = NULL;
-  return 0;
+  size_t n = 0;
+
+  mu_list_count (list, &n);
+  return (n == 0);
 }
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/get.c
similarity index 59%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/get.c
index 0c3fd86..03ed739 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/get.c
@@ -17,20 +17,34 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_get (mu_list_t list, size_t indx, void **pitem)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  struct list_data *current;
+  size_t count;
+  int status = MU_ERR_NOENT;
+
+  if (list == NULL)
+    return EINVAL;
+  if (pitem == NULL)
+    return MU_ERR_OUT_PTR_NULL;
+  mu_monitor_rdlock (list->monitor);
+  for (current = list->head.next, count = 0; current != &list->head;
+       current = current->next, count++)
+    {
+      if (count == indx)
+        {
+          *pitem = current->item;
+	  status = 0;
+	  break;
+        }
+    }
+  mu_monitor_unlock (list->monitor);
+  return status;
 }
diff --git a/libmailutils/url/urlinv.c b/libmailutils/list/getcomp.c
similarity index 75%
copy from libmailutils/url/urlinv.c
copy to libmailutils/list/getcomp.c
index c4f8113..520ca6f 100644
--- a/libmailutils/url/urlinv.c
+++ b/libmailutils/list/getcomp.c
@@ -1,5 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
+   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
@@ -18,16 +19,14 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-#include <stdlib.h>
-#include <errno.h>
-#include <mailutils/sys/url.h>
+#include <mailutils/sys/list.h>
+#include <mailutils/errno.h>
 
 int
-mu_url_invalidate (mu_url_t url)
+mu_list_get_comparator (mu_list_t list, mu_list_comparator_t *comp)
 {
-  if (!url)
+  if (!list)
     return EINVAL;
-  free (url->name);
-  url->name = NULL;
+  *comp = list->comp;
   return 0;
 }
diff --git a/libmailutils/property/propset.c b/libmailutils/list/gmap.c
similarity index 51%
copy from libmailutils/property/propset.c
copy to libmailutils/list/gmap.c
index 147471d..4a20a44 100644
--- a/libmailutils/property/propset.c
+++ b/libmailutils/list/gmap.c
@@ -17,54 +17,49 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <stdlib.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
+#include <mailutils/sys/list.h>
 
 int
-mu_property_set_value (mu_property_t prop, const char *key,
-		       const char *value, int overwrite)
+mu_list_gmap (mu_list_t list, mu_list_mapper_t map, size_t nelem, void *data)
 {
   int rc;
+  int status;
+  mu_iterator_t itr;
+  void **buf;
+  size_t i;
   
-  if (!value)
-    rc = mu_property_unset (prop, key);
-  else
+  if (!list || !map || nelem == 0)
+    return EINVAL;
+  rc = mu_list_get_iterator (list, &itr);
+  if (rc)
+    return status;
+  buf = calloc (nelem, sizeof (buf[0]));
+  if (!buf)
     {
-      rc = _mu_property_check (prop);
-      if (rc)
-	return rc;
-      if (!prop->_prop_setval)
-	return MU_ERR_EMPTY_VFN;
-      rc = prop->_prop_setval (prop, key, value, overwrite);
-      if (rc == 0)
-	prop->_prop_flags |= MU_PROP_MODIFIED;
+      mu_iterator_destroy (&itr);
+      return ENOMEM;
     }
+  for (i = 0, mu_iterator_first (itr); !mu_iterator_is_done (itr);
+       mu_iterator_next (itr))
+    {
+      void *item;
+      mu_iterator_current (itr, &item);
+      buf[i++] = item;
+      if (i == nelem)
+	{
+	  i = 0;
+	  rc = map (buf, nelem, data);
+	  if (rc)
+	    break;
+	}
+    }
+  if (rc == 0 && i > 0 && i < nelem)
+    rc = map (buf, i, data);
+  mu_iterator_destroy (&itr);
+  free (buf);
   return rc;
 }
-
-int
-mu_property_unset (mu_property_t prop, const char *key)
-{
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_unset)
-    return MU_ERR_EMPTY_VFN;
-  rc = prop->_prop_unset (prop, key);
-  if (rc == 0)
-    prop->_prop_flags |= MU_PROP_MODIFIED;
-  return rc;
-}
-
-int
-mu_property_set (mu_property_t prop, const char *key)
-{
-  return mu_property_set_value (prop, key, "", 1);
-}
-
-  
-
diff --git a/libmailutils/list/insert.c b/libmailutils/list/insert.c
new file mode 100644
index 0000000..3e7846c
--- /dev/null
+++ b/libmailutils/list/insert.c
@@ -0,0 +1,72 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
+#include <mailutils/errno.h>
+
+int
+_mu_list_insert_item (mu_list_t list, struct list_data *current,
+		      void *new_item,
+		      int insert_before)
+{
+  int status;
+  struct list_data *ldata = calloc (sizeof (*ldata), 1);
+  if (ldata == NULL)
+    status = ENOMEM;
+  else
+    {
+      ldata->item = new_item;
+      _mu_list_insert_sublist (list, current,
+			       ldata, ldata,
+			       1,
+			       insert_before);
+      status = 0;
+    }
+  return status;
+}
+
+int
+mu_list_insert (mu_list_t list, void *item, void *new_item, int insert_before)
+{
+  struct list_data *current;
+  mu_list_comparator_t comp;
+  int status = MU_ERR_NOENT;
+
+  if (list == NULL)
+    return EINVAL;
+  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
+
+  mu_monitor_wrlock (list->monitor);
+  for (current = list->head.next;
+       current != &list->head;
+       current = current->next)
+    {
+      if (comp (current->item, item) == 0)
+	{
+	  status = _mu_list_insert_item (list, current, new_item,
+					 insert_before);
+	  break;
+	}
+    }
+  mu_monitor_unlock (list->monitor);
+  return status;
+}
diff --git a/libmailutils/list/intersect.c b/libmailutils/list/intersect.c
new file mode 100644
index 0000000..d191c8f
--- /dev/null
+++ b/libmailutils/list/intersect.c
@@ -0,0 +1,90 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
+#include <mailutils/errno.h>
+
+/* Computes an intersection of two lists and returns it in PDEST.
+   The resulting list contains elements from A that are
+   also encountered in B (as per comparison function of
+   the latter).
+
+   If DUP_ITEM is not NULL, it is used to create copies of
+   items to be stored in PDEST.  In this case, the destroy_item
+   function of B is also attached to PDEST.  Otherwise, if
+   DUP_ITEM is NULL, pointers to elements are stored and
+   no destroy_item function is assigned. */
+int
+mu_list_intersect_dup (mu_list_t *pdest, mu_list_t a, mu_list_t b,
+		       int (*dup_item) (void **, void *, void *),
+		       void *dup_closure)
+{
+  mu_list_t dest;
+  int rc;
+  mu_iterator_t itr;
+  
+  rc = mu_list_create (&dest);
+  if (rc)
+    return rc;
+
+  mu_list_set_comparator (dest, b->comp);
+  if (dup_item)
+    mu_list_set_destroy_item (dest, b->destroy_item);
+  
+  rc = mu_list_get_iterator (a, &itr);
+  if (rc)
+    {
+      mu_list_destroy (&dest);
+      return rc;
+    }
+
+  rc = 0;
+  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
+       mu_iterator_next (itr))
+    {
+      void *data;
+      mu_iterator_current (itr, &data);
+      if (mu_list_locate (b, data, NULL) == 0)
+	{
+	  void *new_data;
+	  if (dup_item && data)
+	    {
+	      rc = dup_item (&new_data, data, dup_closure);
+	      if (rc)
+		break;
+	    }
+	  else
+	    new_data = data;
+	
+	  mu_list_append (dest, new_data); /* FIXME: Check return, and? */
+	}
+    }
+  mu_iterator_destroy (&itr);
+  *pdest = dest;
+  return rc;
+}
+
+int
+mu_list_intersect (mu_list_t *pdest, mu_list_t a, mu_list_t b)
+{
+  return mu_list_intersect_dup (pdest, a, b, NULL, NULL);
+}
diff --git a/libmailutils/list/iterator.c b/libmailutils/list/iterator.c
new file mode 100644
index 0000000..8287ea3
--- /dev/null
+++ b/libmailutils/list/iterator.c
@@ -0,0 +1,250 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/sys/list.h>
+#include <mailutils/sys/iterator.h>
+#include <mailutils/errno.h>
+
+/* Iterator interface */
+
+struct list_iterator
+{
+  mu_list_t list;
+  struct list_data *cur;
+  int backwards; /* true if iterating backwards */
+};
+
+static int
+first (void *owner)
+{
+  struct list_iterator *itr = owner;
+  if (itr->backwards)
+    itr->cur = itr->list->head.prev;
+  else
+    itr->cur = itr->list->head.next;
+  return 0;
+}
+
+static int
+next (void *owner)
+{
+  struct list_iterator *itr = owner;
+  if (itr->backwards)
+    itr->cur = itr->cur->prev;
+  else
+    itr->cur = itr->cur->next;
+  return 0;
+}
+
+static int
+getitem (void *owner, void **pret, const void **pkey)
+{
+  struct list_iterator *itr = owner;
+  *pret = itr->cur->item;
+  if (pkey)
+    *pkey = NULL;
+  return 0;
+}
+
+static int
+finished_p (void *owner)
+{
+  struct list_iterator *itr = owner;
+  return itr->cur == &itr->list->head;
+}
+
+static int
+destroy (mu_iterator_t iterator, void *data)
+{
+  struct list_iterator *itr = data;
+  mu_iterator_detach (&itr->list->itr, iterator);
+  free (data);
+  return 0;
+}
+
+static int
+curitem_p (void *owner, void *item)
+{
+  struct list_iterator *itr = owner;
+  return itr->cur == item;
+}
+
+static int
+list_data_dup (void **ptr, void *owner)
+{
+  *ptr = malloc (sizeof (struct list_iterator));
+  if (*ptr == NULL)
+    return ENOMEM;
+  memcpy (*ptr, owner, sizeof (struct list_iterator));
+  return 0;
+}
+
+static int
+list_itrctl (void *owner, enum mu_itrctl_req req, void *arg)
+{
+  struct list_iterator *itr = owner;
+  mu_list_t list = itr->list;
+  struct list_data *ptr;
+  
+  switch (req)
+    {
+    case mu_itrctl_tell:
+      /* Return current position in the object */
+      if (itr->cur == NULL)
+	return MU_ERR_NOENT;
+      else
+	{
+	  size_t count;
+
+	  for (count = 0, ptr = list->head.next; ptr != &list->head;
+	       ptr = ptr->next, count++)
+	    {
+	      if (ptr == itr->cur)
+		{
+		  *(size_t*)arg = count;
+		  return 0;
+		}
+	    }
+	  return MU_ERR_NOENT;
+	}
+      break;
+      
+    case mu_itrctl_delete:
+    case mu_itrctl_delete_nd:
+      /* Delete current element */
+      if (itr->cur == NULL)
+	return MU_ERR_NOENT;
+      else
+	{
+	  struct list_data *prev;
+	
+	  ptr = itr->cur;
+	  prev = ptr->prev;
+	
+	  mu_iterator_advance (list->itr, ptr);
+	  prev->next = ptr->next;
+	  ptr->next->prev = prev;
+	  if (req == mu_itrctl_delete)
+	    DESTROY_ITEM (list, ptr);
+	  free (ptr);
+	  list->count--;
+	}
+      break;
+      
+    case mu_itrctl_replace:
+    case mu_itrctl_replace_nd:
+      /* Replace current element */
+      if (itr->cur == NULL)
+	return MU_ERR_NOENT;
+      if (!arg)
+	return EINVAL;
+      ptr = itr->cur;
+      if (req == mu_itrctl_replace)
+	  DESTROY_ITEM (list, ptr);
+      ptr = itr->cur;
+      ptr->item = arg;
+      break;
+      
+    case mu_itrctl_insert:
+      /* Insert new element in the current position */
+      if (itr->cur == NULL)
+	return MU_ERR_NOENT;
+      if (!arg)
+	return EINVAL;
+      return _mu_list_insert_item (list, itr->cur, arg, 0);
+
+    case mu_itrctl_insert_list:
+      /* Insert a list of elements */
+      if (itr->cur == NULL)
+	return MU_ERR_NOENT;
+      if (!arg)
+	return EINVAL;
+      else
+	{
+	  mu_list_t new_list = arg;
+	  _mu_list_insert_sublist (list, itr->cur,
+				   new_list->head.next, new_list->head.prev,
+				   new_list->count,
+				   0);
+	  _mu_list_clear (new_list);
+	}
+      break;
+
+    case mu_itrctl_qry_direction:
+      if (!arg)
+	return EINVAL;
+      else
+	*(int*)arg = itr->backwards;
+      break;
+
+    case mu_itrctl_set_direction:
+      if (!arg)
+	return EINVAL;
+      else
+	itr->backwards = !!*(int*)arg;
+      break;
+      
+    default:
+      return ENOSYS;
+    }
+  return 0;
+}
+
+int
+mu_list_get_iterator (mu_list_t list, mu_iterator_t *piterator)
+{
+  mu_iterator_t iterator;
+  int status;
+  struct list_iterator *itr;
+
+  if (!list)
+    return EINVAL;
+
+  itr = calloc (1, sizeof *itr);
+  if (!itr)
+    return ENOMEM;
+  itr->list = list;
+  itr->cur = NULL;
+
+  status = mu_iterator_create (&iterator, itr);
+  if (status)
+    {
+      free (itr);
+      return status;
+    }
+
+  mu_iterator_set_first (iterator, first);
+  mu_iterator_set_next (iterator, next);
+  mu_iterator_set_getitem (iterator, getitem);
+  mu_iterator_set_finished_p (iterator, finished_p);
+  mu_iterator_set_curitem_p (iterator, curitem_p);
+  mu_iterator_set_destroy (iterator, destroy);
+  mu_iterator_set_dup (iterator, list_data_dup);
+  mu_iterator_set_itrctl (iterator, list_itrctl);
+  
+  mu_iterator_attach (&list->itr, iterator);
+
+  *piterator = iterator;
+  return 0;
+}
diff --git a/libmailutils/base/listlist.c b/libmailutils/list/listlist.c
similarity index 98%
rename from libmailutils/base/listlist.c
rename to libmailutils/list/listlist.c
index 1032f7a..38bd588 100644
--- a/libmailutils/base/listlist.c
+++ b/libmailutils/list/listlist.c
@@ -19,11 +19,7 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
-#include <errno.h>
 #include <stdlib.h>
-#include <string.h>
-
 #include <mailutils/sys/list.h>
 #include <mailutils/sys/iterator.h>
 #include <mailutils/errno.h>
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/locate.c
similarity index 53%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/locate.c
index 0c3fd86..10170c4 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/locate.c
@@ -17,20 +17,41 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+_mu_list_ptr_comparator (const void *item, const void *value)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  return item != value;
 }
+
+int
+mu_list_locate (mu_list_t list, void *item, void **ret_item)
+{
+  struct list_data *current, *previous;
+  mu_list_comparator_t comp;
+  int status = MU_ERR_NOENT;
+
+  if (list == NULL)
+    return EINVAL;
+  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
+  mu_monitor_wrlock (list->monitor);
+  for (previous = &list->head, current = list->head.next;
+       current != &list->head; previous = current, current = current->next)
+    {
+      if (comp (current->item, item) == 0)
+	{
+	  if (ret_item)
+	    *ret_item = current->item;
+	  status = 0;
+	  break;
+	}
+    }
+  mu_monitor_unlock (list->monitor);
+  return status;
+}
+
diff --git a/libmailutils/list/map.c b/libmailutils/list/map.c
new file mode 100644
index 0000000..e16f129
--- /dev/null
+++ b/libmailutils/list/map.c
@@ -0,0 +1,87 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <mailutils/errno.h>
+#include <mailutils/sys/list.h>
+
+struct map_closure
+{
+  mu_list_mapper_t map;
+  void *data;
+  mu_list_t list;
+  int status;
+};
+
+static int
+_list_mapper (void **itmv, size_t itmc, void *data)
+{
+  struct map_closure *clos = data;
+  int rc, status;
+      
+  if (!clos->list)
+    {
+      status = mu_list_create (&clos->list);
+      if (status)
+	{
+	  clos->status = status;
+	  return MU_ERR_FAILURE;
+	}
+    }
+  
+  rc = clos->map (itmv, itmc, clos->data);
+  if (!(rc & MU_LIST_MAP_SKIP))
+    {
+      status = mu_list_append (clos->list, itmv[0]);
+      if (status)
+	{
+	  clos->status = status;
+	  return MU_ERR_FAILURE;
+	}
+    }
+  if (rc & MU_LIST_MAP_STOP)
+    return MU_ERR_CANCELED;
+  return 0;
+}
+		
+int
+mu_list_map (mu_list_t list, mu_list_mapper_t map, void *data, size_t nelem,
+	     mu_list_t *res)
+{
+  int rc;
+  struct map_closure cl;
+
+  if (!res)
+    return MU_ERR_OUT_PTR_NULL;
+
+  cl.map = map;
+  cl.data = data;
+  cl.list = NULL;
+  cl.status = 0;
+
+  rc = mu_list_gmap (list, _list_mapper, nelem, &cl);
+
+  if (cl.list)
+    *res = cl.list;
+  if (rc == MU_ERR_FAILURE)
+    return cl.status;
+  return 0;
+}
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/prepend.c
similarity index 61%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/prepend.c
index 0c3fd86..35b7623 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/prepend.c
@@ -17,20 +17,32 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
-#include <mailutils/types.h>
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_prepend (mu_list_t list, void *item)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  struct list_data *ldata;
+  struct list_data *first;
+
+  if (list == NULL)
+    return EINVAL;
+  first = list->head.next;
+  ldata = calloc (sizeof (*ldata), 1);
+  if (ldata == NULL)
+    return ENOMEM;
+  ldata->item = item;
+  mu_monitor_wrlock (list->monitor);
+  ldata->prev = &list->head;
+  ldata->next = list->head.next;
+  first->prev = ldata;
+  list->head.next = ldata;
+  list->count++;
+  mu_monitor_unlock (list->monitor);
+  return 0;
 }
diff --git a/libmailutils/list/remove.c b/libmailutils/list/remove.c
new file mode 100644
index 0000000..ab5951d
--- /dev/null
+++ b/libmailutils/list/remove.c
@@ -0,0 +1,66 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
+#include <mailutils/errno.h>
+
+int
+mu_list_remove (mu_list_t list, void *item)
+{
+  struct list_data *current;
+  mu_list_comparator_t comp;
+  int status = MU_ERR_NOENT;
+
+  if (list == NULL)
+    return EINVAL;
+  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
+  mu_monitor_wrlock (list->monitor);
+  for (current = list->head.next;
+       current != &list->head; current = current->next)
+    {
+      if (comp (current->item, item) == 0)
+	{
+	  struct list_data *previous = current->prev;
+	  
+	  mu_iterator_advance (list->itr, current);
+	  previous->next = current->next;
+	  current->next->prev = previous;
+	  DESTROY_ITEM (list, current);
+	  free (current);
+	  list->count--;
+	  status = 0;
+	  break;
+	}
+    }
+  mu_monitor_unlock (list->monitor);
+  return status;
+}
+
+int
+mu_list_remove_nd (mu_list_t list, void *item)
+{
+  mu_list_destroy_item_t dptr = mu_list_set_destroy_item (list, NULL);
+  int rc = mu_list_remove (list, item);
+  mu_list_set_destroy_item (list, dptr);
+  return rc;
+}
+
diff --git a/libmailutils/property/propset.c b/libmailutils/list/replace.c
similarity index 50%
copy from libmailutils/property/propset.c
copy to libmailutils/list/replace.c
index 147471d..bebdd9a 100644
--- a/libmailutils/property/propset.c
+++ b/libmailutils/list/replace.c
@@ -17,54 +17,43 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
-
-#include <mailutils/types.h>
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
 
 int
-mu_property_set_value (mu_property_t prop, const char *key,
-		       const char *value, int overwrite)
+mu_list_replace (mu_list_t list, void *old_item, void *new_item)
 {
-  int rc;
-  
-  if (!value)
-    rc = mu_property_unset (prop, key);
-  else
+  struct list_data *current, *previous;
+  mu_list_comparator_t comp;
+  int status = MU_ERR_NOENT;
+
+  if (list == NULL)
+    return EINVAL;
+  comp = list->comp ? list->comp : _mu_list_ptr_comparator;
+  mu_monitor_wrlock (list->monitor);
+  for (previous = &list->head, current = list->head.next;
+       current != &list->head; previous = current, current = current->next)
     {
-      rc = _mu_property_check (prop);
-      if (rc)
-	return rc;
-      if (!prop->_prop_setval)
-	return MU_ERR_EMPTY_VFN;
-      rc = prop->_prop_setval (prop, key, value, overwrite);
-      if (rc == 0)
-	prop->_prop_flags |= MU_PROP_MODIFIED;
+      if (comp (current->item, old_item) == 0)
+	{
+	  DESTROY_ITEM (list, current);
+	  current->item = new_item;
+	  status = 0;
+	  break;
+	}
     }
-  return rc;
+  mu_monitor_unlock (list->monitor);
+  return status;
 }
 
 int
-mu_property_unset (mu_property_t prop, const char *key)
+mu_list_replace_nd (mu_list_t list, void *item, void *new_item)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_unset)
-    return MU_ERR_EMPTY_VFN;
-  rc = prop->_prop_unset (prop, key);
-  if (rc == 0)
-    prop->_prop_flags |= MU_PROP_MODIFIED;
+  mu_list_destroy_item_t dptr = mu_list_set_destroy_item (list, NULL);
+  int rc = mu_list_replace (list, item, new_item);
+  mu_list_set_destroy_item (list, dptr);
   return rc;
 }
-
-int
-mu_property_set (mu_property_t prop, const char *key)
-{
-  return mu_property_set_value (prop, key, "", 1);
-}
-
-  
-
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/setcomp.c
similarity index 71%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/setcomp.c
index 0c3fd86..2eafc6b 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/setcomp.c
@@ -17,20 +17,19 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 
-#include <mailutils/types.h>
-#include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
-
-int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_comparator_t
+mu_list_set_comparator (mu_list_t list, mu_list_comparator_t comp)
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  mu_list_comparator_t old_comp;
+
+  if (list == NULL)
+    return NULL;
+  old_comp = list->comp;
+  list->comp = comp;
+  return old_comp;
 }
diff --git a/libmailutils/property/propitr.c b/libmailutils/list/setdestr.c
similarity index 71%
copy from libmailutils/property/propitr.c
copy to libmailutils/list/setdestr.c
index 0c3fd86..9edd7d0 100644
--- a/libmailutils/property/propitr.c
+++ b/libmailutils/list/setdestr.c
@@ -17,20 +17,15 @@
    <http://www.gnu.org/licenses/>. */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
+#include <stdlib.h>
+#include <mailutils/sys/list.h>
 
-#include <mailutils/types.h>
-#include <mailutils/errno.h>
-#include <mailutils/sys/property.h>
-
-int
-mu_property_get_iterator (mu_property_t prop, mu_iterator_t *pitr)
+mu_list_destroy_item_t
+mu_list_set_destroy_item (mu_list_t list, void (*destroy_item)(void *item))
 {
-  int rc = _mu_property_check (prop);
-  if (rc)
-    return rc;
-  if (!prop->_prop_getitr)
-    return MU_ERR_EMPTY_VFN;
-  return prop->_prop_getitr (prop, pitr);
+  mu_list_destroy_item_t ret = list->destroy_item;
+  list->destroy_item = destroy_item;
+  return ret;
 }
diff --git a/libmailutils/tests/list.at b/libmailutils/tests/list.at
index eab485b..f32249f 100644
--- a/libmailutils/tests/list.at
+++ b/libmailutils/tests/list.at
@@ -109,7 +109,7 @@ TESTLIST([get],[],
 # ------------------------------------------------------------
 
 m4_define([MU_TEST_GROUP],[Iterator])
-m4_define([MU_TEST_KEYWORDS],MU_TEST_KEYWORDS[ iterator itr])
+m4_pushdef([MU_TEST_KEYWORDS],MU_TEST_KEYWORDS[ iterator itr])
 
 TESTLIST([forward],[],
 [add en to tre fire fem
@@ -246,6 +246,84 @@ cur
 0:2:fire
 ])
 
+m4_popdef([MU_TEST_KEYWORDS])
+
+
+# ------------------------------------------------------------
+# Maps
+# ------------------------------------------------------------
+
+m4_define([MU_TEST_GROUP],[Map])
+m4_pushdef([MU_TEST_KEYWORDS],MU_TEST_KEYWORDS[ map])
+
+TESTLIST([even],[],
+[add null en to tre fire fem
+map even
+],
+[# items: 3
+null
+to
+fire
+])
+
+TESTLIST([odd],[],
+[add null en to tre fire fem
+map odd
+],
+[# items: 3
+en
+tre
+fem
+])
+
+TESTLIST([odd0],[],
+[add null
+map odd
+],
+[# items: 0
+])
+
+TESTLIST([concat],[],
+[add en to tre fire fem
+map concat 2 -
+],
+[# items: 3
+en-to
+tre-fire
+fem
+])
+
+TESTLIST([concat3],[],
+[add en to tre fire fem
+map concat 3 -
+],
+[# items: 2
+en-to-tre
+fire-fem
+])
+
+TESTLIST([skip],[],
+[add null en to tre fire fem
+map skip 3
+],
+[# items: 3
+tre
+fire
+fem
+])
+
+TESTLIST([trim],[],
+[add null en to tre fire fem
+map trim 3
+],
+[# items: 3
+null
+en
+to
+])
+
+m4_popdef([MU_TEST_KEYWORDS])
+
 dnl ------------------------------------------------------------
 dnl Cleanup
 m4_popdef([TESTLIST])
diff --git a/libmailutils/tests/listop.c b/libmailutils/tests/listop.c
index 0672b7d..fceec54 100644
--- a/libmailutils/tests/listop.c
+++ b/libmailutils/tests/listop.c
@@ -428,6 +428,197 @@ cur (int num, mu_iterator_t itr)
   printf ("%s\n", text);
 }
 
+static int
+map_even (void **itmv, size_t itmc, void *call_data)
+{
+  int *num = call_data, n = *num;
+  *num = !*num;
+  if ((n % 2) == 0)
+    {
+      itmv[0] = strdup (itmv[0]);
+      return MU_LIST_MAP_OK;
+    }
+  return MU_LIST_MAP_SKIP;
+}
+
+static int
+map_odd (void **itmv, size_t itmc, void *call_data)
+{
+  int *num = call_data, n = *num;
+  *num = !*num;
+  if (n % 2)
+    {
+      itmv[0] = strdup (itmv[0]);
+      return MU_LIST_MAP_OK;
+    }
+  return MU_LIST_MAP_SKIP;
+}
+
+static int
+map_concat (void **itmv, size_t itmc, void *call_data)
+{
+  char *delim = call_data;
+  size_t dlen = strlen (delim);
+  size_t i;
+  size_t len = 0;
+  char *res, *p;
+  
+  for (i = 0; i < itmc; i++)
+    len += strlen (itmv[i]);
+  len += (itmc - 1) * dlen + 1;
+
+  res = malloc (len);
+  if (!res)
+    abort ();
+  p = res;
+  for (i = 0; ; )
+    {
+      p = mu_stpcpy (p, itmv[i++]);
+      if (i == itmc)
+	break;
+      p = mu_stpcpy (p, delim);
+    }
+  itmv[0] = res;
+  return MU_LIST_MAP_OK;
+}
+
+struct trim_data
+{
+  size_t n;
+  size_t lim;
+};
+
+static int
+map_skip (void **itmv, size_t itmc, void *call_data)
+{
+  struct trim_data *td = call_data;
+
+  if (td->n++ < td->lim)
+    return MU_LIST_MAP_SKIP;
+  itmv[0] = strdup (itmv[0]);
+  return MU_LIST_MAP_OK;
+}
+
+static int
+map_trim (void **itmv, size_t itmc, void *call_data)
+{
+  struct trim_data *td = call_data;
+
+  if (td->n++ < td->lim)
+    {
+      itmv[0] = strdup (itmv[0]);
+      return MU_LIST_MAP_OK;
+    }
+  return MU_LIST_MAP_STOP|MU_LIST_MAP_SKIP;
+}
+
+int
+map (mu_list_t *plist, int argc, char **argv)
+{
+  mu_list_t list = *plist;
+  mu_list_t result;
+  int rc;
+  int replace = 0;
+
+  if (argc > 1 && strcmp (argv[1], "-replace") == 0)
+    {
+      replace = 1;
+      argc--;
+      argv++;
+    }
+  
+  if (argc < 2)
+    {
+      fprintf (stderr, "map [-replace] even|odd|concat|keep|trim\n");
+      return 0;
+    }
+
+  if (strcmp (argv[1], "even") == 0)
+    {
+      int n = 0;
+      rc = mu_list_map (list, map_even, &n, 1, &result);
+    }
+  else if (strcmp (argv[1], "odd") == 0)
+    {
+      int n = 0;
+      rc = mu_list_map (list, map_odd, &n, 1, &result);
+    }
+  else if (strcmp (argv[1], "concat") == 0)
+    {
+      size_t num;
+      char *delim = "";
+      
+      if (argc < 3 || argc > 4)
+	{
+	  fprintf (stderr, "map concat NUM [DELIM]?\n");
+	  return 0;
+	}
+      num = atoi (argv[2]);
+      if (argc == 4)
+	delim = argv[3];
+      
+      rc = mu_list_map (list, map_concat, delim, num, &result);
+    }
+  else if (strcmp (argv[1], "skip") == 0)
+    {
+      struct trim_data td;
+
+      if (argc < 3 || argc > 4)
+	{
+	  fprintf (stderr, "map skip NUM?\n");
+	  return 0;
+	}
+      td.n = 0;
+      td.lim = atoi (argv[2]);
+      rc = mu_list_map (list, map_skip, &td, 1, &result);
+    }
+  else if (strcmp (argv[1], "trim") == 0)
+    {
+      struct trim_data td;
+
+      if (argc < 3 || argc > 4)
+	{
+	  fprintf (stderr, "map trim NUM?\n");
+	  return 0;
+	}
+      td.n = 0;
+      td.lim = atoi (argv[2]);
+      rc = mu_list_map (list, map_trim, &td, 1, &result);
+    }
+  else
+    {
+      mu_error ("unknown map name\n");
+      return 0;
+    }
+  
+  if (rc)
+    {
+      mu_error ("map failed: %s", mu_strerror (rc));
+      return 0;
+    }
+
+  mu_list_set_destroy_item (result, mu_list_free_item);
+
+  if (replace)
+    {
+      size_t count[2];
+      mu_list_count (list, &count[0]);
+      mu_list_count (result, &count[1]);
+      
+      printf ("%lu in, %lu out\n", (unsigned long) count[0],
+	      (unsigned long) count[1]);
+      mu_list_destroy (&list);
+      *plist = result;
+      return 1;
+    }
+  else
+    {
+      print (result);
+      mu_list_destroy (&result);
+    }
+  return 0;
+}
+
 void
 help ()
 {
@@ -446,6 +637,7 @@ help ()
   printf ("ictl repl item\n");
   printf ("ictl ins item [item*]\n");
   printf ("ictl dir [backwards|forwards]\n");
+  printf ("map NAME [ARGS]\n");
   printf ("print\n");
   printf ("quit\n");
   printf ("iter num\n");
@@ -517,6 +709,14 @@ shell (mu_list_t list)
 	    print (list);
 	  else if (strcmp (ws.ws_wordv[0], "cur") == 0)
 	    cur (num, itr[num]);
+	  else if (strcmp (ws.ws_wordv[0], "map") == 0)
+	    {
+	      int i;
+	      
+	      if (map (&list, ws.ws_wordc, ws.ws_wordv))
+		for (i = 0; i < NITR; i++)
+		  mu_iterator_destroy (&itr[i]);
+	    }
 	  else if (strcmp (ws.ws_wordv[0], "quit") == 0)
 	    return;
 	  else if (strcmp (ws.ws_wordv[0], "iter") == 0)
@@ -591,7 +791,7 @@ main (int argc, char **argv)
   
   while (argc--)
     {
-      rc = mu_list_append (list, *argv++);
+      rc = mu_list_append (list, strdup (*argv++));
       if (rc)
 	lperror ("mu_list_append", rc);
     }
diff --git a/libproto/imap/capability.c b/libproto/imap/capability.c
index ab69ad2..feaed0d 100644
--- a/libproto/imap/capability.c
+++ b/libproto/imap/capability.c
@@ -44,6 +44,27 @@ capa_comp (const void *item, const void *value)
   return !(*capa == 0 || *capa == '=');
 }
 
+static int
+_map_capa (void **itmv, size_t itmc, void *call_data)
+{
+  int *n = call_data;
+  struct imap_list_element *elt = itmv[0];
+
+  if (elt->type != imap_eltype_string)
+    return MU_LIST_MAP_STOP;
+  if (*n == 0)
+    {
+      ++*n;
+      if (strcmp (elt->v.string, "CAPABILITY") == 0)
+	return MU_LIST_MAP_SKIP;
+      else
+	return MU_LIST_MAP_STOP;
+    }
+  itmv[0] = elt->v.string;
+  elt->v.string = NULL;
+  return MU_LIST_MAP_OK;
+}
+
 int
 mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
 {
@@ -100,28 +121,9 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
 	  if (mu_list_get (imap->untagged_resp, 0, (void*)&elt) == 0)
 	    {
 	      /* Top-level elements are always of imap_eltype_list type. */
-	      mu_iterator_t itr;
-	      
-	      mu_list_get_iterator (elt->v.list, &itr);
-	      mu_iterator_first (itr);
-	      if (mu_iterator_is_done (itr))
-		return MU_ERR_PARSE;
-	      mu_iterator_current (itr, (void **) &elt);
-	      if (elt->type == imap_eltype_string &&
-		  strcmp (elt->v.string, "CAPABILITY") == 0)
-		{
-		  for (mu_iterator_next (itr); !mu_iterator_is_done (itr);
-		       mu_iterator_next (itr))
-		    {
-		      mu_iterator_current (itr, (void **) &elt);
-		      if (elt->type == imap_eltype_string)
-			{
-			  mu_list_append (imap->capa, elt->v.string);
-			  elt->v.string = NULL;
-			}
-		    }
-		}
-	      mu_iterator_destroy (&itr);
+	      int n = 0;
+	      status = mu_list_map (elt->v.list, _map_capa, &n, 1,
+				    &imap->capa);
 	    }
 	  if (piter)
 	    status = mu_list_get_iterator (imap->capa, piter);
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index ef0974d..a6e6254 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -34,6 +34,20 @@ _id_free (void *data)
   free (s);
 }
 
+static int
+_id_mapper (void **itmv, size_t itmc, void *call_data)
+{
+  int rc;
+  mu_assoc_t assoc = call_data;
+  struct imap_list_element *key = itmv[0], *val = itmv[1];
+  if (key->type != imap_eltype_string || val->type != imap_eltype_string)
+    return MU_ERR_FAILURE;
+  rc = mu_assoc_install (assoc, key->v.string, &val->v.string);
+  if (rc == 0)
+    val->v.string = NULL;
+  return rc;
+}
+
 struct id_convert_state
 {
   int item;
@@ -61,32 +75,7 @@ _id_convert (void *item, void *data)
 
     case 1:
       if (elt->type == imap_eltype_list)
-	{
-	  mu_iterator_t itr;
-
-	  mu_list_get_iterator (elt->v.list, &itr);
-	  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
-	       mu_iterator_next (itr))
-	    {
-	      char *key, *val;
-	      mu_iterator_current (itr, (void **) &elt);
-
-	      if (elt->type != imap_eltype_string)
-		break;
-	      key = elt->v.string;
-	      elt->v.string = NULL;
-
-	      mu_iterator_next (itr);
-	      if (mu_iterator_is_done (itr))
-		break;
-	      mu_iterator_current (itr, (void **) &elt);
-	      if (elt->type != imap_eltype_string)
-		break;
-	      val = elt->v.string;
-	      elt->v.string = NULL;
-	      mu_assoc_install (stp->assoc, key, &val);
-	    }
-	}
+	mu_list_gmap (elt->v.list, _id_mapper, 2, stp->assoc);
     }
   return 1;
 }	


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 18 14:28:15 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRU6h-0005Yr-KQ
	for mharc-commit-mailutils@gnu.org; Fri, 18 Nov 2011 14:28:15 -0500
Received: from eggs.gnu.org ([140.186.70.92]:36347)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRU6a-0005Yk-QE
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 14:28:13 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRU6V-0001tm-J3
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 14:28:08 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:42328)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRU6V-0001tg-H0
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 14:28:03 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRU6T-00014k-QR
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 19:28:02 +0000
Date: Fri, 18 Nov 2011 19:28:01 +0000
Message-Id: <E1RRU6T-00014k-QR@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-450-gebbbc39
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a736b7a9a775db4b82806a6214deefc3ac7a4dd4
X-Git-Newrev: ebbbc397fba86fd32fb2cccb377a59f8e38d03e9
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Nov 2011 19:28:13 -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=ebbbc397fba86fd32fb2cccb377a59f8e38d03e9

The branch, master has been updated
       via  ebbbc397fba86fd32fb2cccb377a59f8e38d03e9 (commit)
      from  a736b7a9a775db4b82806a6214deefc3ac7a4dd4 (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 ebbbc397fba86fd32fb2cccb377a59f8e38d03e9
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 18 21:23:15 2011 +0200

    imap client: implement select/examine.
    
    * include/mailutils/imap.h (mu_imap_stat): New structs.
    (MU_IMAP_STAT_DEFINED_FLAGS,MU_IMAP_STAT_PERMANENT_FLAGS)
    (MU_IMAP_STAT_MESSAGE_COUNT,MU_IMAP_STAT_RECENT_COUNT)
    (MU_IMAP_STAT_FIRST_UNSEEN,MU_IMAP_STAT_UIDNEXT)
    (MU_IMAP_STAT_UIDVALIDITY):  New flags.
    (mu_imap_select): New proto.
    * include/mailutils/imapio.h (mu_imap_flag_to_attribute)
    (mu_imap_format_flags): New protos.
    * include/mailutils/sys/imap.h (mu_imap_client_state)
    <MU_IMAP_SELECT_RX>: New state.
    (_mu_imap) <mbox_name,mbox_writable,mbox_stat>: New members.
    * libmailutils/imapio/flags.c: New file.
    * libmailutils/imapio/Makefile.am: Add flags.c
    * libproto/imap/select.c: New file.
    * libproto/imap/Makefile.am: Add select.c
    * libproto/imap/err.c (_mu_imap_seterrstr)
    (_mu_imap_clrerrstr, mu_imap_strerror): Allow for imap==NULL.
    * libproto/imap/id.c (mu_imap_id): Set errstr on MU_ERR_BADREPLY
    * libproto/imap/login.c (mu_imap_login): Likewise.
    * libproto/imap/resplist.c (_mu_imap_list_element_is_string): New function.
    * mu/imap.c: Implement examine and select.

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

Summary of changes:
 include/mailutils/imap.h        |   28 +++++-
 include/mailutils/imapio.h      |    3 +
 include/mailutils/sys/imap.h    |    8 ++
 libmailutils/imapio/Makefile.am |    1 +
 libmailutils/imapio/flags.c     |   85 ++++++++++++++
 libproto/imap/Makefile.am       |    1 +
 libproto/imap/err.c             |    9 ++-
 libproto/imap/id.c              |    7 +-
 libproto/imap/login.c           |    9 ++-
 libproto/imap/resplist.c        |   10 ++
 libproto/imap/select.c          |  230 +++++++++++++++++++++++++++++++++++++++
 mu/imap.c                       |   72 ++++++++++++
 12 files changed, 458 insertions(+), 5 deletions(-)
 create mode 100644 libmailutils/imapio/flags.c
 create mode 100644 libproto/imap/select.c

diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index 3e04391..e8369cb 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -37,7 +37,7 @@ enum mu_imap_state
     MU_IMAP_STATE_NONAUTH,  /* Non-Authenticated State */
     MU_IMAP_STATE_AUTH,     /* Authenticated State */
     MU_IMAP_STATE_SELECTED, /* Selected State */
-    MU_IMAP_STATE_LOGOUT    /* Logout State */
+    MU_IMAP_STATE_LOGOUT,   /* Logout State */
   };
   
 int mu_imap_create (mu_imap_t *pimap);
@@ -70,7 +70,31 @@ int mu_imap_state (mu_imap_t imap, int *pstate);
 int mu_imap_state_str (int state, const char **pstr);
 
 int mu_imap_tag (mu_imap_t imap, const char **pseq);
-  
+
+
+#define MU_IMAP_STAT_DEFINED_FLAGS   0x01
+#define MU_IMAP_STAT_PERMANENT_FLAGS 0x02
+#define MU_IMAP_STAT_MESSAGE_COUNT   0x04
+#define MU_IMAP_STAT_RECENT_COUNT    0x08
+#define MU_IMAP_STAT_FIRST_UNSEEN    0x10
+#define MU_IMAP_STAT_UIDNEXT         0x20
+#define MU_IMAP_STAT_UIDVALIDITY     0x40
+
+struct mu_imap_stat
+{
+  int flags;                 /* Bitmap of what fields are filled */
+  int defined_flags;         /* Flags defined for this mailbox */
+  int permanent_flags;       /* Flags that can be changed permanently */
+  size_t message_count;      /* Number of messages */
+  size_t recent_count;       /* Number of recent messages */
+  size_t first_unseen;       /* Sequence number of the first unseen message */
+  size_t uidnext;            /* The next unique identifier value. */
+  unsigned long uidvalidity; /* The unique identifier validity value. */
+};
+
+int mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
+		    struct mu_imap_stat *ps);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/imapio.h b/include/mailutils/imapio.h
index 9b92622..f5ebb70 100644
--- a/include/mailutils/imapio.h
+++ b/include/mailutils/imapio.h
@@ -45,6 +45,9 @@ int mu_imapio_get_trace (mu_imapio_t io);
 int mu_imapio_getbuf (mu_imapio_t io, char **pptr, size_t *psize);
 
 int mu_imapio_reply_string (struct _mu_imapio *io, size_t start, char **pbuf);
+
+int mu_imap_flag_to_attribute (const char *item, int *attr);
+int mu_imap_format_flags (mu_stream_t str, int flags);
   
 #ifdef __cplusplus
 }
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index 17a0095..89ff4db 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -44,6 +44,7 @@ enum mu_imap_client_state
     MU_IMAP_LOGIN_RX,
     MU_IMAP_LOGOUT_RX,
     MU_IMAP_ID_RX,
+    MU_IMAP_SELECT_RX
   };
 
 enum mu_imap_response
@@ -77,6 +78,10 @@ struct _mu_imap
     
     mu_list_t capa;
     mu_imapio_t io;
+
+    char *mbox_name;  /* Name of the currently opened mailbox */
+    int mbox_writable:1; /* Is it open read/write? */
+    struct mu_imap_stat mbox_stat;  /* Stats obtained from it */
 };
 
 enum imap_eltype
@@ -151,6 +156,9 @@ int _mu_imap_response (mu_imap_t imap);
 
 int _mu_imap_untagged_response_clear (mu_imap_t imap);
 int _mu_imap_untagged_response_add (mu_imap_t imap);
+
+int _mu_imap_list_element_is_string (struct imap_list_element *elt,
+				     const char *str);
   
 # ifdef __cplusplus
 }
diff --git a/libmailutils/imapio/Makefile.am b/libmailutils/imapio/Makefile.am
index 20c0784..c856d9d 100644
--- a/libmailutils/imapio/Makefile.am
+++ b/libmailutils/imapio/Makefile.am
@@ -19,6 +19,7 @@ noinst_LTLIBRARIES = libimapio.la
 
 libimapio_la_SOURCES = \
  create.c\
+ flags.c\
  getline.c\
  literal.c\
  printf.c\
diff --git a/libmailutils/imapio/flags.c b/libmailutils/imapio/flags.c
new file mode 100644
index 0000000..5d07297
--- /dev/null
+++ b/libmailutils/imapio/flags.c
@@ -0,0 +1,85 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <mailutils/types.h>
+#include <mailutils/imapio.h>
+#include <mailutils/attribute.h>
+#include <mailutils/stream.h>
+#include <mailutils/errno.h>
+#include <mailutils/cstr.h>
+#include <mailutils/sys/imapio.h>
+
+static struct
+{
+  char *name;
+  int flag;
+}
+_imap4_attrlist[] =
+{
+  { "\\Answered", MU_ATTRIBUTE_ANSWERED },
+  { "\\Flagged", MU_ATTRIBUTE_FLAGGED },
+  { "\\Deleted", MU_ATTRIBUTE_DELETED },
+  { "\\Draft", MU_ATTRIBUTE_DRAFT },
+  { "\\Seen", MU_ATTRIBUTE_SEEN|MU_ATTRIBUTE_READ },
+};
+
+static int _imap4_nattr = MU_ARRAY_SIZE (_imap4_attrlist);
+
+int
+mu_imap_flag_to_attribute (const char *item, int *attr)
+{
+  int i;
+
+  if (mu_c_strcasecmp (item, "\\Recent") == 0)
+    {
+      *attr |= MU_ATTRIBUTE_RECENT;
+      return 0;
+    }
+  
+  for (i = 0; i < _imap4_nattr; i++)
+    if (mu_c_strcasecmp (item, _imap4_attrlist[i].name) == 0)
+      {
+	*attr |= _imap4_attrlist[i].flag;
+	return 0;
+      }
+  return MU_ERR_NOENT;
+}
+
+int
+mu_imap_format_flags (mu_stream_t str, int flags)
+{
+  int i;
+  int delim = 0;
+  
+  for (i = 0; i < _imap4_nattr; i++)
+    if ((flags & _imap4_attrlist[i].flag) == _imap4_attrlist[i].flag)
+      {
+	if (delim)
+	  mu_stream_printf (str, " ");
+	mu_stream_printf (str, "%s", _imap4_attrlist[i].name);
+	delim = 1;
+      }
+
+  if (MU_ATTRIBUTE_IS_UNSEEN (flags))
+    {
+      if (delim)
+	mu_stream_printf (str, " ");
+      mu_stream_printf (str, "\\Recent");
+    }
+  
+  return 0;
+}
diff --git a/libproto/imap/Makefile.am b/libproto/imap/Makefile.am
index 2f54f70..cf8dcbe 100644
--- a/libproto/imap/Makefile.am
+++ b/libproto/imap/Makefile.am
@@ -41,6 +41,7 @@ libmu_imap_la_SOURCES = \
  logout.c\
  resplist.c\
  response.c\
+ select.c\
  state.c\
  tag.c\
  trace.c
diff --git a/libproto/imap/err.c b/libproto/imap/err.c
index 4e77362..29e275d 100644
--- a/libproto/imap/err.c
+++ b/libproto/imap/err.c
@@ -26,6 +26,8 @@
 int
 _mu_imap_seterrstr (mu_imap_t imap, const char *str, size_t len)
 {
+  if (!imap)
+    return EINVAL;
   if (len + 1 > imap->errsize)
     {
       char *p = realloc (imap->errstr, len + 1);
@@ -42,13 +44,18 @@ _mu_imap_seterrstr (mu_imap_t imap, const char *str, size_t len)
 void
 _mu_imap_clrerrstr (mu_imap_t imap)
 {
-  if (imap->errstr)
+  if (imap && imap->errstr)
     imap->errstr[0] = 0;
 }
     
 int
 mu_imap_strerror (mu_imap_t imap, const char **pstr)
 {
+  if (!imap)
+    {
+      *pstr = "(imap not initialized)";
+      return EINVAL;
+    }
   if (imap->errstr)
     {
       *pstr = imap->errstr;
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index a6e6254..4e03c5d 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -105,11 +105,11 @@ parse_id_reply (mu_imap_t imap, mu_assoc_t *passoc)
   return st.ret;
 }
   
-  
 int
 mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
 {
   int status;
+  char *p;
   
   if (imap == NULL)
     return EINVAL;
@@ -171,6 +171,11 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
 
 	case MU_IMAP_BAD:
 	  status = MU_ERR_BADREPLY;
+	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
+	    {
+	      _mu_imap_seterrstr (imap, p, strlen (p));
+	      free (p);
+	    }
 	  break;
 	}
       imap->state = MU_IMAP_CONNECTED;
diff --git a/libproto/imap/login.c b/libproto/imap/login.c
index fe0af0c..b1f840f 100644
--- a/libproto/imap/login.c
+++ b/libproto/imap/login.c
@@ -18,7 +18,8 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
+#include <stdlib.h>
+#include <string.h>
 #include <mailutils/errno.h>
 #include <mailutils/stream.h>
 #include <mailutils/sys/imap.h>
@@ -27,6 +28,7 @@ int
 mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
 {
   int status;
+  char *p;
   
   if (imap == NULL)
     return EINVAL;
@@ -67,6 +69,11 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
 
 	case MU_IMAP_BAD:
 	  status = MU_ERR_BADREPLY;
+	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
+	    {
+	      _mu_imap_seterrstr (imap, p, strlen (p));
+	      free (p);
+	    }
 	  break;
 	}
       imap->state = MU_IMAP_CONNECTED;
diff --git a/libproto/imap/resplist.c b/libproto/imap/resplist.c
index 3031fee..f46417c 100644
--- a/libproto/imap/resplist.c
+++ b/libproto/imap/resplist.c
@@ -254,3 +254,13 @@ _mu_imap_untagged_response_add (mu_imap_t imap)
   mu_list_append (imap->untagged_resp, elt);
   return 0;
 }
+
+int
+_mu_imap_list_element_is_string (struct imap_list_element *elt,
+				 const char *str)
+{
+  if (elt->type != imap_eltype_string)
+    return 0;
+  return strcmp (elt->v.string, str) == 0;
+}
+
diff --git a/libproto/imap/select.c b/libproto/imap/select.c
new file mode 100644
index 0000000..130bb8d
--- /dev/null
+++ b/libproto/imap/select.c
@@ -0,0 +1,230 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/errno.h>
+#include <mailutils/assoc.h>
+#include <mailutils/stream.h>
+#include <mailutils/imap.h>
+#include <mailutils/sys/imap.h>
+
+static int
+_collect_flags (void *item, void *data)
+{
+  struct imap_list_element *elt = item;
+  int *args = data;
+
+  if (elt->type == imap_eltype_string)
+    mu_imap_flag_to_attribute (elt->v.string, args);
+  return 0;
+}
+
+static int
+_parse_stat (void *item, void *data)
+{
+  struct imap_list_element *response = item;
+  mu_imap_t imap = data;
+  struct imap_list_element *elt;
+  size_t count;
+  int rc;
+  char *p;
+  
+  if (response->type != imap_eltype_list)
+    return 0;
+
+  mu_list_count (response->v.list, &count);
+  
+  rc = mu_list_get (response->v.list, 0, (void*) &elt);
+  if (rc)
+    return rc;
+  
+  if (_mu_imap_list_element_is_string (elt, "OK"))
+    {
+      struct imap_list_element *arg;
+      
+      if (count < 3)
+	return 0; /* ignore the line */
+      rc = mu_list_get (response->v.list, 1, (void*) &elt);
+      if (rc)
+	return rc;
+      rc = mu_list_get (response->v.list, 2, (void*) &arg);
+      if (rc)
+	return rc;
+      
+      if (_mu_imap_list_element_is_string (elt, "[UIDVALIDITY"))
+	{
+	  if (arg->type != imap_eltype_string)
+	    return 0;
+	  imap->mbox_stat.uidvalidity = strtoul (arg->v.string, &p, 10);
+	  if (*p == ']')
+	    imap->mbox_stat.flags |= MU_IMAP_STAT_UIDVALIDITY;
+	}
+      else if (_mu_imap_list_element_is_string (elt, "[UIDNEXT"))
+	{
+	  if (arg->type != imap_eltype_string)
+	    return 0;
+	  imap->mbox_stat.uidnext = strtoul (arg->v.string, &p, 10);
+	  if (*p == ']')
+	    imap->mbox_stat.flags |= MU_IMAP_STAT_UIDNEXT;
+	}
+      else if (_mu_imap_list_element_is_string (elt, "[UNSEEN"))
+	{
+	  if (arg->type != imap_eltype_string)
+	    return 0;
+	  imap->mbox_stat.first_unseen = strtoul (arg->v.string, &p, 10);
+	  if (*p == ']')
+	    imap->mbox_stat.flags |= MU_IMAP_STAT_FIRST_UNSEEN;
+	}
+      else if (_mu_imap_list_element_is_string (elt, "[PERMANENTFLAGS"))
+	{
+	  if (arg->type != imap_eltype_list)
+	    return 0;
+	  mu_list_do (arg->v.list, _collect_flags,
+		      &imap->mbox_stat.permanent_flags);
+	  imap->mbox_stat.flags |= MU_IMAP_STAT_PERMANENT_FLAGS;
+	}
+    }
+  else if (_mu_imap_list_element_is_string (elt, "FLAGS"))
+    {
+      struct imap_list_element *arg;
+      rc = mu_list_get (response->v.list, 1, (void*) &arg);
+      if (rc)
+	return 0;
+      if (arg->type != imap_eltype_list)
+	return 0;
+      mu_list_do (arg->v.list, _collect_flags, &imap->mbox_stat.defined_flags);
+      imap->mbox_stat.flags |= MU_IMAP_STAT_DEFINED_FLAGS;
+    }
+  else if (count == 2)
+    {
+      struct imap_list_element *arg;
+      rc = mu_list_get (response->v.list, 1, (void*) &arg);
+      if (rc)
+	return rc;
+      if (_mu_imap_list_element_is_string (arg, "EXISTS"))
+	{
+	  imap->mbox_stat.message_count = strtoul (elt->v.string, &p, 10);
+	  if (*p == 0)
+	    imap->mbox_stat.flags |= MU_IMAP_STAT_MESSAGE_COUNT;
+	}
+      else if (_mu_imap_list_element_is_string (arg, "RECENT"))
+	{
+	  imap->mbox_stat.recent_count = strtoul (elt->v.string, &p, 10);
+	  if (*p == 0)
+	    imap->mbox_stat.flags |= MU_IMAP_STAT_RECENT_COUNT;
+	}
+    }
+  
+  return 0;
+}
+
+int
+mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
+		struct mu_imap_stat *ps)
+{
+  int status;
+  char *p;
+  
+  if (imap == NULL)
+    return EINVAL;
+  if (!imap->io)
+    return MU_ERR_NO_TRANSPORT;
+  if (imap->state != MU_IMAP_CONNECTED)
+    return MU_ERR_SEQ;
+  if (imap->imap_state != MU_IMAP_STATE_AUTH &&
+      imap->imap_state != MU_IMAP_STATE_SELECTED)
+    return MU_ERR_SEQ;
+
+  if (!mbox)
+    {
+      if (imap->imap_state == MU_IMAP_STATE_SELECTED)
+	{
+	  if (ps)
+	    *ps = imap->mbox_stat;
+	  return 0;
+	}
+      return MU_ERR_INFO_UNAVAILABLE;
+    }
+  
+  if (imap->mbox_name && strcmp (imap->mbox_name, mbox) == 0
+      && writable == imap->mbox_writable)
+    {
+      if (ps)
+	*ps = imap->mbox_stat;
+      return 0;
+    }
+  
+  switch (imap->state)
+    {
+    case MU_IMAP_CONNECTED:
+      status = _mu_imap_tag_next (imap);
+      MU_IMAP_CHECK_EAGAIN (imap, status);
+      status = mu_imapio_printf (imap->io, "%s %s %s\r\n",
+				 imap->tag_str,
+				 writable ? "SELECT" : "EXAMINE",
+				 mbox);
+      MU_IMAP_CHECK_ERROR (imap, status);
+      MU_IMAP_FCLR (imap, MU_IMAP_RESP);
+      imap->state = MU_IMAP_SELECT_RX;
+
+    case MU_IMAP_SELECT_RX:
+      status = _mu_imap_response (imap);
+      MU_IMAP_CHECK_EAGAIN (imap, status);
+      switch (imap->resp_code)
+	{
+	case MU_IMAP_OK:
+	  imap->imap_state = MU_IMAP_STATE_SELECTED;
+	  free (imap->mbox_name);
+	  imap->mbox_name = strdup (mbox);
+	  if (!imap->mbox_name)
+	    {
+	      imap->state = MU_IMAP_ERROR;
+	      return errno;
+	    }
+	  imap->mbox_writable = writable;
+	  memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
+	  mu_list_do (imap->untagged_resp, _parse_stat, imap);
+	  if (ps)
+	    *ps = imap->mbox_stat;
+	  break;
+
+	case MU_IMAP_NO:
+	  status = EACCES;
+	  break;
+
+	case MU_IMAP_BAD:
+	  status = MU_ERR_BADREPLY;
+	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
+	    {
+	      _mu_imap_seterrstr (imap, p, strlen (p));
+	      free (p);
+	    }
+	  break;
+	}
+      imap->state = MU_IMAP_CONNECTED;
+      break;
+
+    default:
+      status = EINPROGRESS;
+    }
+  return status;
+}
diff --git a/mu/imap.c b/mu/imap.c
index e6fa2d1..156fdf3 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -25,6 +25,7 @@
 #include <netinet/in.h>
 #include <mailutils/mailutils.h>
 #include <mailutils/imap.h>
+#include <mailutils/imapio.h>
 #include "mu.h"
 #include "argp.h"
 #include "xalloc.h"
@@ -454,6 +455,71 @@ com_id (int argc, char **argv)
     }
   return status;
 }
+
+static void
+print_imap_stats (struct mu_imap_stat *st)
+{
+  if (st->flags & MU_IMAP_STAT_DEFINED_FLAGS)
+    {
+      mu_printf (_("Flags defined: "));
+      mu_imap_format_flags (mu_strout, st->defined_flags);
+      mu_printf ("\n");
+    }
+  if (st->flags & MU_IMAP_STAT_PERMANENT_FLAGS)
+    {
+      mu_printf (_("Flags permanent: "));
+      mu_imap_format_flags (mu_strout, st->permanent_flags);
+      mu_printf ("\n");
+    }
+
+  if (st->flags & MU_IMAP_STAT_MESSAGE_COUNT)
+    mu_printf (_("Total messages: %lu\n"), (unsigned long) st->message_count);
+  if (st->flags & MU_IMAP_STAT_RECENT_COUNT)
+    mu_printf (_("Recent messages: %lu\n"), (unsigned long) st->recent_count);
+  if (st->flags & MU_IMAP_STAT_FIRST_UNSEEN)
+    mu_printf (_("First unseen message: %lu\n"),
+	       (unsigned long) st->first_unseen);
+  if (st->flags & MU_IMAP_STAT_UIDNEXT)
+    mu_printf (_("Next UID: %lu\n"), (unsigned long) st->uidnext);
+  if (st->flags & MU_IMAP_STAT_UIDVALIDITY)
+    mu_printf (_("UID validity: %lu\n"), st->uidvalidity);
+}
+
+
+static int
+select_mbox (int argc, char **argv, int writable)
+{
+  int status;
+  struct mu_imap_stat st;
+
+  status = mu_imap_select (imap, argv[1], writable, &st);
+  if (status == 0)
+    {
+      print_imap_stats (&st);
+      imap_prompt_env ();
+    }
+  else
+    {
+      const char *str;
+      
+      mu_error ("select failed: %s", mu_strerror (status));
+      if (mu_imap_strerror (imap, &str) == 0)
+	mu_error ("server reply: %s", str);
+    }
+  return 0;
+}
+
+static int
+com_select (int argc, char **argv)
+{
+  return select_mbox (argc, argv, 1);
+}
+
+static int
+com_examine (int argc, char **argv)
+{
+  return select_mbox (argc, argv, 0);
+}
 
 
 struct mutool_command imap_comtab[] = {
@@ -481,6 +547,12 @@ struct mutool_command imap_comtab[] = {
   { "id",           1, -1, com_id,
     N_("[-test KW] [ARG [ARG...]]"),
     N_("send ID command") },
+  { "select",       1, 2, com_select,
+    N_("MBOX"),
+    N_("select a mailbox") },
+  { "examine",       1, 2, com_examine,
+    N_("MBOX"),
+    N_("examine a mailbox") },  
   { "quit",         1, 1, com_logout,
     NULL,
     N_("same as `logout'") },


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Nov 18 18:17:54 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRXgw-0001Tm-Bm
	for mharc-commit-mailutils@gnu.org; Fri, 18 Nov 2011 18:17:54 -0500
Received: from eggs.gnu.org ([140.186.70.92]:47386)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRXgt-0001TL-Gi
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 18:17:53 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRXgr-0003yy-8p
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 18:17:51 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:43836)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRXgr-0003yt-5U
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 18:17:49 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRXgp-0002YG-G7
	for commit-mailutils@gnu.org; Fri, 18 Nov 2011 23:17:48 +0000
Date: Fri, 18 Nov 2011 23:17:47 +0000
Message-Id: <E1RRXgp-0002YG-G7@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-451-gc96bc2c
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ebbbc397fba86fd32fb2cccb377a59f8e38d03e9
X-Git-Newrev: c96bc2c092dda2d3c9fe3f1498857c7d4afb56dc
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Nov 2011 23:17:53 -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=c96bc2c092dda2d3c9fe3f1498857c7d4afb56dc

The branch, master has been updated
       via  c96bc2c092dda2d3c9fe3f1498857c7d4afb56dc (commit)
      from  ebbbc397fba86fd32fb2cccb377a59f8e38d03e9 (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 c96bc2c092dda2d3c9fe3f1498857c7d4afb56dc
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 19 01:13:35 2011 +0200

    imap client: implement status command
    
    * include/mailutils/imap.h (mu_imap_status): New proto.
    (_mu_imap_status_name_table): New declaration.
    * include/mailutils/sys/imap.h (mu_imap_client_state)
    <MU_IMAP_STATUS_RX>: New state.
    * libproto/imap/status.c: New file.
    * libproto/imap/Makefile.am (libmu_imap_la_SOURCES): Add status.c
    * mu/imap.c: Implement "status"

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

Summary of changes:
 include/mailutils/imap.h     |    5 +
 include/mailutils/sys/imap.h |    3 +-
 libproto/imap/Makefile.am    |    1 +
 libproto/imap/status.c       |  224 ++++++++++++++++++++++++++++++++++++++++++
 mu/imap.c                    |   45 ++++++++-
 5 files changed, 273 insertions(+), 5 deletions(-)
 create mode 100644 libproto/imap/status.c

diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index e8369cb..3093ec6 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -21,6 +21,7 @@
 #include <mailutils/iterator.h>
 #include <mailutils/debug.h>
 #include <mailutils/stream.h>
+#include <mailutils/kwd.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -95,6 +96,10 @@ struct mu_imap_stat
 int mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 		    struct mu_imap_stat *ps);
 
+int mu_imap_status (mu_imap_t imap, const char *mbox, struct mu_imap_stat *ps);
+
+extern struct mu_kwd _mu_imap_status_name_table[];
+  
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index 89ff4db..dd4b1df 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -44,7 +44,8 @@ enum mu_imap_client_state
     MU_IMAP_LOGIN_RX,
     MU_IMAP_LOGOUT_RX,
     MU_IMAP_ID_RX,
-    MU_IMAP_SELECT_RX
+    MU_IMAP_SELECT_RX,
+    MU_IMAP_STATUS_RX
   };
 
 enum mu_imap_response
diff --git a/libproto/imap/Makefile.am b/libproto/imap/Makefile.am
index cf8dcbe..956b0b5 100644
--- a/libproto/imap/Makefile.am
+++ b/libproto/imap/Makefile.am
@@ -43,6 +43,7 @@ libmu_imap_la_SOURCES = \
  response.c\
  select.c\
  state.c\
+ status.c\
  tag.c\
  trace.c
 
diff --git a/libproto/imap/status.c b/libproto/imap/status.c
new file mode 100644
index 0000000..d071801
--- /dev/null
+++ b/libproto/imap/status.c
@@ -0,0 +1,224 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/errno.h>
+#include <mailutils/assoc.h>
+#include <mailutils/stream.h>
+#include <mailutils/imap.h>
+#include <mailutils/sys/imap.h>
+
+#define STATUS_FLAG_MASK \
+  (MU_IMAP_STAT_MESSAGE_COUNT|			\
+   MU_IMAP_STAT_RECENT_COUNT|			\
+   MU_IMAP_STAT_UIDNEXT|			\
+   MU_IMAP_STAT_UIDVALIDITY|			\
+   MU_IMAP_STAT_FIRST_UNSEEN)
+
+struct mu_kwd _mu_imap_status_name_table[] = {
+  { "MESSAGES",    MU_IMAP_STAT_MESSAGE_COUNT },
+  { "RECENT",      MU_IMAP_STAT_RECENT_COUNT  },
+  { "UIDNEXT",     MU_IMAP_STAT_UIDNEXT       },
+  { "UIDVALIDITY", MU_IMAP_STAT_UIDVALIDITY   },
+  { "UNSEEN",      MU_IMAP_STAT_FIRST_UNSEEN  },
+  { NULL }
+};
+
+static int
+_status_mapper (void **itmv, size_t itmc, void *call_data)
+{
+  struct mu_imap_stat *ps = call_data;
+  struct imap_list_element *kw = itmv[0], *val = itmv[1];
+  size_t value;
+  char *p;
+  int flag;
+  
+  if (kw->type != imap_eltype_string || val->type != imap_eltype_string)
+    return MU_ERR_PARSE;
+  if (mu_kwd_xlat_name_ci (_mu_imap_status_name_table, kw->v.string, &flag))
+    return MU_ERR_PARSE;
+
+  value = strtoul (val->v.string, &p, 10);
+  if (*p)
+    return MU_ERR_PARSE;
+
+  ps->flags |= flag;
+
+  switch (flag)
+    {
+    case MU_IMAP_STAT_MESSAGE_COUNT:
+      ps->message_count = value;
+      break;
+      
+    case MU_IMAP_STAT_RECENT_COUNT:
+      ps->recent_count = value;
+      break;
+      
+    case MU_IMAP_STAT_UIDNEXT:
+      ps->uidnext = value;
+      break;
+      
+    case MU_IMAP_STAT_UIDVALIDITY:
+      ps->uidvalidity = value;
+      break;
+      
+    case MU_IMAP_STAT_FIRST_UNSEEN:
+      ps->first_unseen = value;
+    }
+  return 0;
+}
+
+static int
+_parse_status_response (mu_imap_t imap, const char *mboxname,
+			struct mu_imap_stat *ps)
+{
+  struct imap_list_element *response, *elt;
+  size_t count;
+  int rc;
+  
+  rc = mu_list_get (imap->untagged_resp, 0, (void*) &response);
+  if (rc)
+    return rc;
+
+  mu_list_count (response->v.list, &count);
+  if (count != 3)
+    return MU_ERR_PARSE;
+  rc = mu_list_get (response->v.list, 0, (void*) &elt);
+  if (rc)
+    return rc;
+  if (!_mu_imap_list_element_is_string (elt, "STATUS"))
+    return MU_ERR_NOENT;
+  
+  rc = mu_list_get (response->v.list, 1, (void*) &elt);
+  if (rc)
+    return rc;
+  if (!_mu_imap_list_element_is_string (elt, mboxname))
+    return MU_ERR_NOENT;
+
+  rc = mu_list_get (response->v.list, 2, (void*) &elt);
+  if (rc)
+    return rc;
+  if (elt->type != imap_eltype_list)
+    return MU_ERR_PARSE;
+
+  ps->flags = 0;
+  return mu_list_gmap (elt->v.list, _status_mapper, 2, ps);
+}
+
+int
+mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
+{
+  int status;
+  char *p;
+  int delim = 0;
+  int i;
+  
+  if (imap == NULL)
+    return EINVAL;
+  if (!imap->io)
+    return MU_ERR_NO_TRANSPORT;
+  if (imap->state != MU_IMAP_CONNECTED)
+    return MU_ERR_SEQ;
+  if (imap->imap_state != MU_IMAP_STATE_AUTH &&
+      imap->imap_state != MU_IMAP_STATE_SELECTED)
+    return MU_ERR_SEQ;
+  if (!ps)
+    return MU_ERR_OUT_PTR_NULL;
+  if ((ps->flags & STATUS_FLAG_MASK) == 0)
+    return EINVAL;
+      
+  if (!mboxname)
+    {
+      if (imap->imap_state == MU_IMAP_STATE_SELECTED)
+	{
+	  if (ps)
+	    *ps = imap->mbox_stat;
+	  return 0;
+	}
+      return EINVAL;
+    }
+  
+  if (imap->mbox_name && strcmp (imap->mbox_name, mboxname) == 0)
+    {
+      if (ps)
+	*ps = imap->mbox_stat;
+      return 0;
+    }
+  
+  switch (imap->state)
+    {
+    case MU_IMAP_CONNECTED:
+      status = _mu_imap_tag_next (imap);
+      MU_IMAP_CHECK_EAGAIN (imap, status);
+      status = mu_imapio_printf (imap->io, "%s STATUS %s (",
+				 imap->tag_str, mboxname);
+      MU_IMAP_CHECK_ERROR (imap, status);
+      delim = 0;
+      for (i = 0; status == 0 && _mu_imap_status_name_table[i].name; i++)
+	{
+	  if (ps->flags & _mu_imap_status_name_table[i].tok)
+	    {
+	      if (delim)
+		status = mu_imapio_send (imap->io, " ", 1);
+	      if (status == 0)
+		status = mu_imapio_printf (imap->io, "%s",
+					   _mu_imap_status_name_table[i].name);
+	    }
+	  delim = 1;
+	}
+      if (status == 0)
+	status = mu_imapio_send (imap->io, ")\r\n", 3);
+      MU_IMAP_CHECK_ERROR (imap, status);
+      MU_IMAP_FCLR (imap, MU_IMAP_RESP);
+      imap->state = MU_IMAP_STATUS_RX;
+
+    case MU_IMAP_STATUS_RX:
+      status = _mu_imap_response (imap);
+      MU_IMAP_CHECK_EAGAIN (imap, status);
+      switch (imap->resp_code)
+	{
+	case MU_IMAP_OK:
+	  memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
+	  status = _parse_status_response (imap, mboxname, ps);
+	  break;
+
+	case MU_IMAP_NO:
+	  status = EACCES;
+	  break;
+
+	case MU_IMAP_BAD:
+	  status = MU_ERR_BADREPLY;
+	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
+	    {
+	      _mu_imap_seterrstr (imap, p, strlen (p));
+	      free (p);
+	    }
+	  break;
+	}
+      imap->state = MU_IMAP_CONNECTED;
+      break;
+
+    default:
+      status = EINPROGRESS;
+    }
+  return status;
+}
diff --git a/mu/imap.c b/mu/imap.c
index 156fdf3..103829e 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -520,6 +520,40 @@ com_examine (int argc, char **argv)
 {
   return select_mbox (argc, argv, 0);
 }
+
+static int
+com_status (int argc, char **argv)
+{
+  struct mu_imap_stat st;
+  int i, flag;
+  int status;
+    
+  st.flags = 0;
+  for (i = 2; i < argc; i++)
+    {
+      if (mu_kwd_xlat_name_ci (_mu_imap_status_name_table, argv[i], &flag))
+	{
+	  mu_error (_("unknown data item: %s"), argv[i]);
+	  return 0;
+	}
+      st.flags |= flag;
+    }
+
+  status = mu_imap_status (imap, argv[1], &st);
+  if (status == 0)
+    {
+      print_imap_stats (&st);
+    }
+  else
+    {
+      const char *str;
+      
+      mu_error ("status failed: %s", mu_strerror (status));
+      if (mu_imap_strerror (imap, &str) == 0)
+	mu_error ("server reply: %s", str);
+    }
+  return 0;
+}
 
 
 struct mutool_command imap_comtab[] = {
@@ -548,11 +582,14 @@ struct mutool_command imap_comtab[] = {
     N_("[-test KW] [ARG [ARG...]]"),
     N_("send ID command") },
   { "select",       1, 2, com_select,
-    N_("MBOX"),
+    N_("[MBOX]"),
     N_("select a mailbox") },
-  { "examine",       1, 2, com_examine,
-    N_("MBOX"),
-    N_("examine a mailbox") },  
+  { "examine",      1, 2, com_examine,
+    N_("[MBOX]"),
+    N_("examine a mailbox") },
+  { "status",       3, -1, com_status,
+    N_("MBOX KW [KW...]"),
+    N_("get mailbox status") },
   { "quit",         1, 1, com_logout,
     NULL,
     N_("same as `logout'") },


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 19 09:37:04 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRm2S-0001Rd-Af
	for mharc-commit-mailutils@gnu.org; Sat, 19 Nov 2011 09:37:04 -0500
Received: from eggs.gnu.org ([140.186.70.92]:51409)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRm2M-0001R4-DS
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 09:37:01 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRm2I-0003Bt-7w
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 09:36:58 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:39508)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRm2I-0003Bp-13
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 09:36:54 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRm2G-0006D6-2H
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 14:36:53 +0000
Date: Sat, 19 Nov 2011 14:36:52 +0000
Message-Id: <E1RRm2G-0006D6-2H@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-452-g530953e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c96bc2c092dda2d3c9fe3f1498857c7d4afb56dc
X-Git-Newrev: 530953e151f011eb2f57918039c402f475431a09
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 Nov 2011 14:37:01 -0000

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

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

The branch, master has been updated
       via  530953e151f011eb2f57918039c402f475431a09 (commit)
      from  c96bc2c092dda2d3c9fe3f1498857c7d4afb56dc (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 530953e151f011eb2f57918039c402f475431a09
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 19 16:08:48 2011 +0200

    Rename mu_list_do to mu_list_foreach.  Add comments to mailutils/list.h

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

Summary of changes:
 imap4d/authenticate.c                 |    4 +-
 imap4d/capability.c                   |    2 +-
 imap4d/fetch.c                        |    4 +-
 imap4d/namespace.c                    |    6 +-
 imap4d/util.c                         |    2 +-
 include/mailutils/list.h              |  242 ++++++++++++++++++++++++---------
 libmailutils/auth/auth.c              |    2 +-
 libmailutils/cfg/driver.c             |    4 +-
 libmailutils/cfg/format.c             |    4 +-
 libmailutils/cfg/gocs.c               |    2 +-
 libmailutils/cfg/parser.y             |    8 +-
 libmailutils/list/Makefile.am         |    2 +-
 libmailutils/list/{do.c => foreach.c} |   10 ++-
 libmailutils/server/acl.c             |    2 +-
 libmailutils/server/msrv.c            |    4 +-
 libmu_cpp/list.cc                     |    2 +-
 libmu_sieve/comparator.c              |    4 +-
 libmu_sieve/conf.c                    |    6 +-
 libmu_sieve/load.c                    |    4 +-
 libmu_sieve/prog.c                    |    4 +-
 libmu_sieve/sieve.l                   |    2 +-
 libmu_sieve/sieve.y                   |    2 +-
 libmu_sieve/tests.c                   |    2 +-
 libmu_sieve/util.c                    |   12 +-
 libproto/imap/id.c                    |    2 +-
 libproto/imap/select.c                |    6 +-
 libproto/mailer/smtp_mech.c           |    4 +-
 maidag/lmtp.c                         |   10 +-
 maidag/script.c                       |    2 +-
 mail/send.c                           |    6 +-
 mail/util.c                           |    2 +-
 mh/mark.c                             |    6 +-
 mh/mh_format.c                        |    4 +-
 mh/mh_list.c                          |    8 +-
 mh/mh_whatnow.c                       |    2 +-
 mh/mh_whom.c                          |    6 +-
 mh/pick.c                             |    2 +-
 mh/send.c                             |    2 +-
 mh/sortm.c                            |    4 +-
 mimeview/mimetypes.y                  |    2 +-
 mu/dbm.c                              |    2 +-
 mu/filter.c                           |    2 +-
 sql/odbc.c                            |    2 +-
 testsuite/smtpsend.c                  |    2 +-
 44 files changed, 264 insertions(+), 148 deletions(-)
 rename libmailutils/list/{do.c => foreach.c} (84%)

diff --git a/imap4d/authenticate.c b/imap4d/authenticate.c
index 9f2c40a..3b6e258 100644
--- a/imap4d/authenticate.c
+++ b/imap4d/authenticate.c
@@ -83,7 +83,7 @@ _auth_try (void *item, void *data)
 void
 imap4d_auth_capability ()
 {
-  mu_list_do (imap_auth_list, _auth_capa, NULL);
+  mu_list_foreach (imap_auth_list, _auth_capa, NULL);
 }
 
 /*
@@ -112,7 +112,7 @@ imap4d_authenticate (struct imap4d_command *command, imap4d_tokbuf_t tok)
   adata.auth_type = auth_type;
   adata.username = NULL;
 
-  res = mu_list_do (imap_auth_list, _auth_try, &adata);
+  res = mu_list_foreach (imap_auth_list, _auth_try, &adata);
 
   switch (res)
     {
diff --git a/imap4d/capability.c b/imap4d/capability.c
index 9f1d4fc..71e59fc 100644
--- a/imap4d/capability.c
+++ b/imap4d/capability.c
@@ -75,7 +75,7 @@ imap4d_capability (struct imap4d_command *command, imap4d_tokbuf_t tok)
   
   io_sendf ("* CAPABILITY");
 
-  mu_list_do (capa_list, print_capa, NULL);
+  mu_list_foreach (capa_list, print_capa, NULL);
   
   imap4d_auth_capability ();
   io_sendf ("\n");
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 077e38b..aee0a6f 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -1057,7 +1057,7 @@ _frt_header_fields (struct fetch_function_closure *ffc,
     io_sendf (".NOT");
   io_sendf (" (");
   status = 0;
-  mu_list_do (ffc->headers, _send_header_name, &status);
+  mu_list_foreach (ffc->headers, _send_header_name, &status);
   io_sendf (")]");
   
   msg = fetch_get_part (ffc, frt);
@@ -1683,7 +1683,7 @@ imap4d_fetch0 (imap4d_tokbuf_t tok, int isuid, char **err_text)
 	    {
 	      io_sendf ("* %lu FETCH (", (unsigned long) frc.msgno);
 	      frc.eltno = 0;
-	      rc = mu_list_do (pclos.fnlist, _do_fetch, &frc);
+	      rc = mu_list_foreach (pclos.fnlist, _do_fetch, &frc);
 	      io_sendf (")\n");
 	    }
 	}
diff --git a/imap4d/namespace.c b/imap4d/namespace.c
index 9f85fd3..bee550a 100644
--- a/imap4d/namespace.c
+++ b/imap4d/namespace.c
@@ -56,7 +56,7 @@ print_namespace (int nsid)
       int count;
       count = 0;
       io_sendf ("(");
-      mu_list_do (list, print_namespace_fun, &count);
+      mu_list_foreach (list, print_namespace_fun, &count);
       io_sendf (")");
     }
 }
@@ -84,7 +84,7 @@ namespace_enumerate (int id, nsfp_t f, void *closure)
   nsc.fun = f;
   nsc.closure = closure;
   return namespace[id] == 0 ? 0 :
-          mu_list_do (namespace[id], _enum_fun, &nsc);
+          mu_list_foreach (namespace[id], _enum_fun, &nsc);
 }
 
 static int
@@ -271,7 +271,7 @@ namespace_init ()
 	  mu_list_t list;
 	  mu_list_create (&list);
 	  mu_list_set_destroy_item (list, mu_list_free_item);
-	  mu_list_do (namespace[i], normalize_fun, list);
+	  mu_list_foreach (namespace[i], normalize_fun, list);
 	  mu_list_set_destroy_item (namespace[i], mu_list_free_item);
 	  mu_list_destroy (&namespace[i]);
 	  namespace[i] = list;
diff --git a/imap4d/util.c b/imap4d/util.c
index 2b546f0..4e960b2 100644
--- a/imap4d/util.c
+++ b/imap4d/util.c
@@ -659,7 +659,7 @@ util_bye ()
 {
   mu_stream_close (iostream);
   mu_stream_destroy (&iostream);
-  mu_list_do (atexit_list, atexit_run, 0);
+  mu_list_foreach (atexit_list, atexit_run, 0);
 }
 
 void
diff --git a/include/mailutils/list.h b/include/mailutils/list.h
index becf280..296b6ec 100644
--- a/include/mailutils/list.h
+++ b/include/mailutils/list.h
@@ -25,72 +25,180 @@
 extern "C" {
 #endif
 
-extern int mu_list_create   (mu_list_t *);
-extern void mu_list_destroy (mu_list_t *);
-extern void mu_list_clear (mu_list_t list);
-extern int mu_list_append   (mu_list_t, void *item);
-extern int mu_list_prepend  (mu_list_t, void *item);
-extern int mu_list_insert   (mu_list_t list, void *item, void *new_item, 
-                          int insert_before);
-extern int mu_list_is_empty (mu_list_t);
-extern int mu_list_count    (mu_list_t, size_t *pcount);
-extern int mu_list_remove   (mu_list_t, void *item);
-extern int mu_list_remove_nd  (mu_list_t, void *item);
-extern int mu_list_replace  (mu_list_t list, void *old_item, void *new_item);  
-extern int mu_list_replace_nd (mu_list_t list, void *old_item, void *new_item);  
-extern int mu_list_get      (mu_list_t, size_t _index, void **pitem);
-extern int mu_list_to_array (mu_list_t list, void **array, size_t count, size_t *pcount);
-extern int mu_list_locate   (mu_list_t list, void *item, void **ret_item);
-extern int mu_list_get_iterator (mu_list_t, mu_iterator_t *);
-
-typedef int mu_list_action_t (void *item, void *cbdata);
-
-extern int mu_list_do       (mu_list_t list, mu_list_action_t *action, void *cbdata);
-
-typedef int (*mu_list_comparator_t) (const void*, const void*);
-
-extern int _mu_list_ptr_comparator (const void*, const void*);
+  /* ************************************************* */
+  /* List creation and destruction                     */
+  /* ************************************************* */
+int mu_list_create (mu_list_t *_plist);
+void mu_list_destroy (mu_list_t *_plist);
+  /* Remove all elements from the list, reclaiming the associated memory
+     if necessary (see mu_list_set_destroy_item), but don't destroy the
+     list itself. */
+void mu_list_clear (mu_list_t _list);
+
+  /* ************************************************* */
+  /* List Comparators                                  */
+  /* ************************************************* */
   
-extern mu_list_comparator_t mu_list_set_comparator (mu_list_t,
-						    mu_list_comparator_t);
-extern int mu_list_get_comparator (mu_list_t, mu_list_comparator_t *);
-
-extern void mu_list_free_item (void *item);
+  /* A comparator is associated with each list, which is used to compare
+     two elements for equality.  The comparator is a function of
+     mu_list_comparator_t type, which returns 0 if its arguments are equal
+     and non-zero otherwise: */
+typedef int (*mu_list_comparator_t) (const void*, const void*);
+  /* The default comparator function compares two pointers for equality. */
+int _mu_list_ptr_comparator (const void*, const void*);
+  /* Set _cmp as a new comparator function for _list.  Return old
+     comparator. */
+mu_list_comparator_t mu_list_set_comparator (mu_list_t _list,
+					     mu_list_comparator_t _cmp);
+  /* Returns in _pcmp a pointer to the comparator function of _list: */
+int mu_list_get_comparator (mu_list_t _list, mu_list_comparator_t *_pcmp);
+
+  /* ************************************************* */
+  /* Memory management                                 */
+  /* ************************************************* */
 
+  /* The destroy function is responsible for deallocating a list element.
+     By default, it is not set. */
 typedef void (*mu_list_destroy_item_t) (void *);
-  
-extern mu_list_destroy_item_t mu_list_set_destroy_item
-              (mu_list_t list, mu_list_destroy_item_t destroy_item);
 
+  /* An often used destroy function.  It simply calls free(3) over the
+     _item. */
+void mu_list_free_item (void *_item);
 
-extern int mu_list_intersect_dup (mu_list_t *, mu_list_t, mu_list_t,
-				  int (*dup_item) (void **, void *, void *),
-				  void *);
-extern int mu_list_intersect (mu_list_t *, mu_list_t, mu_list_t);  
-
-extern int mu_list_insert_list (mu_list_t list, void *item, mu_list_t new_list,
-				int insert_before);
-extern void mu_list_append_list (mu_list_t list, mu_list_t new_list);
-extern void mu_list_prepend_list (mu_list_t list, mu_list_t new_list);
+  /* Sets the destroy function for _list and returns old destroy
+     function: */
+mu_list_destroy_item_t mu_list_set_destroy_item (mu_list_t _list,
+			   mu_list_destroy_item_t _destroy_item);
+
+  /* ************************************************* */
+  /* List informational functions:                     */
+  /* ************************************************* */
+
+  /* Return true if _list has no items. */
+int mu_list_is_empty (mu_list_t _list);
+  /* Write the number of items currently in _list to the memory location
+     pointed to by _pcount. */
+int mu_list_count    (mu_list_t _list, size_t *_pcount);
 
-/* List mapper functions */
-typedef int (*mu_list_mapper_t) (void **itmv, size_t itmc, void *call_data);
+  /* ************************************************* */
+  /* Functions for retrieving list elements:           */
+  /* ************************************************* */
+  
+  /* Get _indexth element from the list and store it in _pitem. */
+int mu_list_get      (mu_list_t _list, size_t _index, void **_pitem);
+  /* Store at most _count first elements from _list in the _array.  Unless
+     _pcount is NULL, fill it with the actual number of elements copied. */
+int mu_list_to_array (mu_list_t _list, void **_array, size_t _count,
+		      size_t *_pcount);
+  /* Look for the element matching _item (in the sense of the item comparator
+     method, see mu_list_set_comparator) and return it in the memory location
+     pointed to by _ret_item. */
+int mu_list_locate   (mu_list_t list, void *item, void **ret_item);
+  
+  /* ************************************************* */
+  /* Functions for adding and removing elements:       */
+  /* ************************************************* */
+  
+  /* Add _item to the tail of the _list. */
+int mu_list_append   (mu_list_t _list, void *_item);
+  /* Add _item to the head of the _list */
+int mu_list_prepend  (mu_list_t _list, void *_item);
+  /* Insert _item after _new_item in _list (or before it, if _insert_before
+     is 1. */
+int mu_list_insert   (mu_list_t _list, void *_item, void *_new_item, 
+                      int _insert_before);
+  /* Remove _item from _list and deallocate any memory associated with it
+     using the `destroy_item' method. */
+int mu_list_remove   (mu_list_t _list, void *_item);
+  /* A non-destructive version of mu_list_remove: removes the _item but does
+     not deallocate it. */
+int mu_list_remove_nd  (mu_list_t _list, void *_item);
+  /* Find _old_item in _list and if found, replace it with _new_item,
+     deallocating the removed item via the `destroy_item' method. */
+int mu_list_replace  (mu_list_t _list, void *_old_item, void *_new_item);
+  /* A non-destructive version of mu_list_replace: the removed item is not
+     deallocated. */
+int mu_list_replace_nd (mu_list_t _list, void *_old_item, void *_new_item);
+
+  /* ************************************************* */
+  /* Interation over lists.                            */
+  /* ************************************************* */
+
+  /* Get iterator for this _list and return it in _pitr, if successful. */
+int mu_list_get_iterator (mu_list_t _list, mu_iterator_t *_pitr);
+
+  /* A general-purpose iteration function.  When called, _item points to
+     the item currently visited and _data points to call-specific data. */
+typedef int mu_list_action_t (void *_item, void *_data);
+
+  /* Execute _action for each element in _list.  Use _data as the call-specific
+     data. */
+int mu_list_foreach (mu_list_t _list, mu_list_action_t *_action, void *_data);
+  /* A historical alias to the above. */
+int mu_list_do (mu_list_t, mu_list_action_t *, void *) MU_DEPRECATED;
+
+  /* ************************************************* */
+  /* Functions for combining two lists.                */
+  /* ************************************************* */
+
+  /* Move elements from _new_list to _list, adding them to the tail of
+     the latter. */
+void mu_list_append_list (mu_list_t _list, mu_list_t _new_list);
+  /* Move elements from _new_list to _list, adding them to the head of
+     the latter. */
+void mu_list_prepend_list (mu_list_t _list, mu_list_t _new_list);
+
+  /* Move data from _new_list to _list, inserting them after the
+     element matching _anchor (in the sense of _list's comparator
+     function).  If _insert_before is 1, items are inserted before
+     _achor instead. */
+int mu_list_insert_list (mu_list_t _list, void *_anchor,
+			 mu_list_t _new_list,
+			 int _insert_before);
+
+  /* Compute an intersection of two lists (_list1 and _list2) and return
+     it in _pdest.  The resulting list contains elements from _list1 that
+     are also encountered in _list2 (as per comparison function of
+     the latter).
+     
+     If _dup_item is not NULL, it is called to create copies of
+     items to be stored in _pdest.  In this case, the destroy_item
+     function of _list2 is also attached to _pdest.
+
+     The _dup_item parameters are: a pointer for returned data, the
+     original item and call-specific data.  The _dup_data 
+     argument is passed as the 3rd argument in each call to _dup_item.
+     
+     If _dup_item is NULL, pointers to elements are stored and
+     no destroy_item function is assigned. */
+int mu_list_intersect_dup (mu_list_t *_pdest,
+			   mu_list_t _list1, mu_list_t _list2,
+			   int (*_dup_item) (void **, void *, void *),
+			   void *_dup_data);
+  
+  /* Same as mu_list_intersect_dup with _dup_item = NULL */
+int mu_list_intersect (mu_list_t *, mu_list_t, mu_list_t);  
+
+  /* ************************************************* */
+  /* List mapper functions                             */
+  /* ************************************************* */
+  
+typedef int (*mu_list_mapper_t) (void **_itmv, size_t _itmc, void *_call_data);
 
 /* A generalized list mapping function.
 
-   Mu_list_gmap iterates over the LIST, gathering its elements in an
-   array of type void **.  When NELEM elements has been collected, it
-   calls the MAP function, passing it as arguments the constructed array,
-   number of elements in it (can be less than NELEM on the last call),
-   and call-specific DATA.  Iteration continues while MAP returns 0 and
-   until all elements from the array have been visited.
+   Mu_list_gmap iterates over the _list, gathering its elements in an
+   array of type void **.  Each time _nelem elements has been collected,
+   it calls the _map function, passing it as arguments the constructed array,
+   the number of elements in it (which can be less than _nelem on the last
+   call), and call-specific _data.  Iteration continues while _map returns 0
+   and until all elements from the array have been visited.
 
    Mu_list_gmap returns 0 on success and a non-zero error code on failure.
-   If MAP returns !0, its return value is propagated to the caller.
-*/
+   If _map returns non-zero, its return value is propagated to the caller. */
    
-int mu_list_gmap (mu_list_t list, mu_list_mapper_t map, size_t nelem,
-		  void *data);
+int mu_list_gmap (mu_list_t _list, mu_list_mapper_t _map, size_t _nelem,
+		  void *_data);
   
   
 #define MU_LIST_MAP_OK     0x00
@@ -99,24 +207,24 @@ int mu_list_gmap (mu_list_t list, mu_list_mapper_t map, size_t nelem,
 
 /* List-to-list mapping.
    
-   Apply the list mapping function MAP to each NELEM elements from the source
-   LIST and use its return values to form a new list, which will be returned
-   in RES.
+   Apply the list mapping function _map to each _nelem elements from the source
+   _list and use its return values to form a new list, which will be returned
+   in _res.
 
-   MAP gets pointers to the collected elements in its first argument (ITMV).
-   Its second argument (ITMC) gives the number of elements filled in ARR.
-   It can be less than NELEM on the last call to MAP.  The DATA pointer is
-   passed as the 3rd argument.
+   The _map function gets pointers to the collected elements in its first
+   argument (_itmv).  Its second argument (_itmc) keeps the number of elements
+   filled in there.  It can be less than _nelem on the last call to _map.
+   The _data pointer is passed as the 3rd argument.
 
-   Return value from MAP governs the mapping process.  Unless it has the
-   MU_LIST_MAP_SKIP bit set, the itmv[0] element is appended to the new
+   The return value from _map governs the mapping process.  Unless it has the
+   MU_LIST_MAP_SKIP bit set, the _itmv[0] element is appended to the new
    list.  If it has MU_LIST_MAP_STOP bit set, iteration is stopped
-   immediately and any remaining elements in LIST are ignored.
+   immediately and any remaining elements in _list are ignored.
 */
 
-int mu_list_map (mu_list_t list, mu_list_mapper_t map,
-		 void *data, size_t nelem,
-		 mu_list_t *res);
+int mu_list_map (mu_list_t _list, mu_list_mapper_t _map,
+		 void *_data, size_t _nelem,
+		 mu_list_t *_res);
 #ifdef __cplusplus
 }
 #endif
diff --git a/libmailutils/auth/auth.c b/libmailutils/auth/auth.c
index 502c9af..b72d918 100644
--- a/libmailutils/auth/auth.c
+++ b/libmailutils/auth/auth.c
@@ -136,7 +136,7 @@ mu_authority_authenticate (mu_authority_t authority)
       struct auth_cb cb;
       cb.status = MU_ERR_AUTH_FAILURE;
       cb.authority = authority;
-      mu_list_do (authority->auth_methods, try_auth, &cb);
+      mu_list_foreach (authority->auth_methods, try_auth, &cb);
       return cb.status;
     }
   return EINVAL;
diff --git a/libmailutils/cfg/driver.c b/libmailutils/cfg/driver.c
index 8db81a2..47ca794 100644
--- a/libmailutils/cfg/driver.c
+++ b/libmailutils/cfg/driver.c
@@ -169,7 +169,7 @@ dup_container (struct mu_cfg_cont **pcont)
       newcont->v.section.offset = oldcont->v.section.offset;
       newcont->v.section.docstring = oldcont->v.section.docstring;
       newcont->v.section.children = NULL;
-      mu_list_do (oldcont->v.section.children, _dup_cont_action, &dd);
+      mu_list_foreach (oldcont->v.section.children, _dup_cont_action, &dd);
       break;
 
     case mu_cfg_cont_param:
@@ -329,7 +329,7 @@ mu_config_clone_container (struct mu_cfg_cont *cont)
   switch (cont->type)
     {
     case mu_cfg_cont_section:
-      mu_list_do (cont->v.section.children, _clone_action, NULL);
+      mu_list_foreach (cont->v.section.children, _clone_action, NULL);
       break;
 
     case mu_cfg_cont_param:
diff --git a/libmailutils/cfg/format.c b/libmailutils/cfg/format.c
index 2faee80..c1bc377 100644
--- a/libmailutils/cfg/format.c
+++ b/libmailutils/cfg/format.c
@@ -401,7 +401,7 @@ format_section (mu_stream_t stream, struct mu_cfg_section *sect, int level)
       mu_stream_write (stream, " {\n", 3, NULL);
       c.stream = stream;
       c.level = level + 1; 
-      mu_list_do (sect->children, _f_helper, &c);
+      mu_list_foreach (sect->children, _f_helper, &c);
       format_level (stream, level);
       mu_stream_write (stream, "};\n\n", 4, NULL);
     }
@@ -409,7 +409,7 @@ format_section (mu_stream_t stream, struct mu_cfg_section *sect, int level)
     {
       c.stream = stream;
       c.level = level; 
-      mu_list_do (sect->children, _f_helper, &c);
+      mu_list_foreach (sect->children, _f_helper, &c);
     }
 }
 
diff --git a/libmailutils/cfg/gocs.c b/libmailutils/cfg/gocs.c
index ba376b3..e8ed629 100644
--- a/libmailutils/cfg/gocs.c
+++ b/libmailutils/cfg/gocs.c
@@ -376,7 +376,7 @@ void
 mu_gocs_flush ()
 {
   int i;
-  mu_list_do (data_list, _gocs_flush, NULL);
+  mu_list_foreach (data_list, _gocs_flush, NULL);
 
   for (i = 0; _gocs_table[i].name; i++)
     _gocs_table[i].init (mu_gocs_op_flush, NULL);
diff --git a/libmailutils/cfg/parser.y b/libmailutils/cfg/parser.y
index 9a64bfb..2ee1057 100644
--- a/libmailutils/cfg/parser.y
+++ b/libmailutils/cfg/parser.y
@@ -234,7 +234,7 @@ block   : ident tag '{' '}' opt_sc
 	  {
 	    $$ = mu_cfg_alloc_node (mu_cfg_node_statement, &$1.locus,
 				    $1.name, $2, $4);
-	    mu_list_do ($4, _node_set_parent, $$);
+	    mu_list_foreach ($4, _node_set_parent, $$);
 	  }
 	;
 
@@ -568,7 +568,7 @@ mu_cfg_tree_postprocess (mu_cfg_tree_t *tree,
 		      && strcmp (node->label->v.string, hints->program) == 0)
 		    {
 		      /* Reset the parent node */
-		      mu_list_do (node->nodes, _node_set_parent,
+		      mu_list_foreach (node->nodes, _node_set_parent,
 				  node->parent);
 		      /* Move all nodes from this block to the topmost
 			 level */
@@ -656,7 +656,7 @@ _mu_cfg_preorder_recursive (void *item, void *cbdata)
 int
 mu_cfg_preorder (mu_list_t nodelist, struct mu_cfg_iter_closure *clos)
 {
-  return mu_list_do (nodelist, _mu_cfg_preorder_recursive, clos);
+  return mu_list_foreach (nodelist, _mu_cfg_preorder_recursive, clos);
 }
 
 
@@ -1254,7 +1254,7 @@ parse_param (struct scan_tree_data *sdata, const mu_cfg_node_t *node)
 	}
       
       mu_list_create (&clos.list);
-      mu_list_do (node->label->v.list, _set_fun, &clos);
+      mu_list_foreach (node->label->v.list, _set_fun, &clos);
       *(mu_list_t*)tgt = clos.list;
     }
   else if (clos.type == mu_cfg_callback)
diff --git a/libmailutils/list/Makefile.am b/libmailutils/list/Makefile.am
index 3b959fc..0ed2480 100644
--- a/libmailutils/list/Makefile.am
+++ b/libmailutils/list/Makefile.am
@@ -24,8 +24,8 @@ liblist_la_SOURCES = \
  count.c\
  create.c\
  destroy.c\
- do.c\
  empty.c\
+ foreach.c\
  get.c\
  getcomp.c\
  gmap.c\
diff --git a/libmailutils/list/do.c b/libmailutils/list/foreach.c
similarity index 84%
rename from libmailutils/list/do.c
rename to libmailutils/list/foreach.c
index ef9ef17..131f587 100644
--- a/libmailutils/list/do.c
+++ b/libmailutils/list/foreach.c
@@ -24,7 +24,7 @@
 #include <mailutils/errno.h>
 
 int
-mu_list_do (mu_list_t list, mu_list_action_t *action, void *cbdata)
+mu_list_foreach (mu_list_t list, mu_list_action_t *action, void *cbdata)
 {
   mu_iterator_t itr;
   int status = 0;
@@ -45,3 +45,11 @@ mu_list_do (mu_list_t list, mu_list_action_t *action, void *cbdata)
   mu_iterator_destroy (&itr);
   return status;
 }
+
+/* Retained for compatibility with previous versions.
+   In the future it will be removed, or changed to a define or weak alias. */
+int
+mu_list_do (mu_list_t list, mu_list_action_t *action, void *cbdata)
+{
+  return mu_list_foreach (list, action, cbdata);
+}
diff --git a/libmailutils/server/acl.c b/libmailutils/server/acl.c
index ba1a4b8..8228b0e 100644
--- a/libmailutils/server/acl.c
+++ b/libmailutils/server/acl.c
@@ -556,7 +556,7 @@ mu_acl_check_sockaddr (mu_acl_t acl, const struct sockaddr *sa, int salen,
   r.result = pres;
   *r.result = mu_acl_result_undefined;
   r.numbuf = NULL;
-  mu_list_do (acl->aclist, _run_entry, &r);
+  mu_list_foreach (acl->aclist, _run_entry, &r);
   free (r.numbuf);
   free (r.addrstr);
   return 0;
diff --git a/libmailutils/server/msrv.c b/libmailutils/server/msrv.c
index fca9322..19bb201 100644
--- a/libmailutils/server/msrv.c
+++ b/libmailutils/server/msrv.c
@@ -229,7 +229,7 @@ mu_m_server_idle (void *server_data MU_ARG_UNUSED)
       need_cleanup = 0;
       while ( (ex.pid = waitpid (-1, &ex.status, WNOHANG)) > 0)
 	/* Iterate over all m-servers and notify them about the fact. */
-	mu_list_do (m_server_list, m_server_cleanup, &ex);
+	mu_list_foreach (m_server_list, m_server_cleanup, &ex);
     }
   return stop;
 }
@@ -619,7 +619,7 @@ mu_m_server_run (mu_m_server_t msrv)
   int rc;
   size_t count;
   mode_t saved_umask = umask (0117);
-  mu_list_do (msrv->srvlist, _open_conn, msrv);
+  mu_list_foreach (msrv->srvlist, _open_conn, msrv);
   umask (saved_umask);
   mu_list_destroy (&msrv->srvlist);
   MU_ASSERT (mu_server_count (msrv->server, &count));
diff --git a/libmu_cpp/list.cc b/libmu_cpp/list.cc
index 822bb85..8272d96 100644
--- a/libmu_cpp/list.cc
+++ b/libmu_cpp/list.cc
@@ -201,7 +201,7 @@ List :: size ()
 void
 List :: apply (mu_list_action_t* action, void* cbdata)
 {
-  int status = mu_list_do (mu_list, action, cbdata);
+  int status = mu_list_foreach (mu_list, action, cbdata);
   if (status)
     throw Exception ("List::apply", status);
 }
diff --git a/libmu_sieve/comparator.c b/libmu_sieve/comparator.c
index 7d8856d..346a168 100644
--- a/libmu_sieve/comparator.c
+++ b/libmu_sieve/comparator.c
@@ -131,7 +131,7 @@ mu_sieve_get_comparator (mu_sieve_machine_t mach, mu_list_t tags)
 {
   mu_sieve_comparator_t comp = NULL;
 
-  mu_list_do (tags, _find_comparator, &comp);
+  mu_list_foreach (tags, _find_comparator, &comp);
   return comp ? comp : mu_sieve_comparator_lookup (mach,
 						"i;ascii-casemap",
 						MU_SIEVE_MATCH_IS);
@@ -192,7 +192,7 @@ static void
 _free_reglist (void *data)
 {
   mu_list_t list = data;
-  mu_list_do (list, _free_regex, NULL);
+  mu_list_foreach (list, _free_regex, NULL);
   mu_list_destroy (&list);
 }
 
diff --git a/libmu_sieve/conf.c b/libmu_sieve/conf.c
index a76134b..7ef2c15 100644
--- a/libmu_sieve/conf.c
+++ b/libmu_sieve/conf.c
@@ -62,15 +62,15 @@ mu_sieve_module_init (enum mu_gocs_op op, void *data)
 
   if (p->clearflags & MU_SIEVE_CLEAR_INCLUDE_PATH)
     mu_list_destroy (&mu_sieve_include_path);
-  mu_list_do (p->include_path, _path_append, &mu_sieve_include_path);
+  mu_list_foreach (p->include_path, _path_append, &mu_sieve_include_path);
   if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH)
     {
       mu_list_destroy (&mu_sieve_library_path);
       mu_list_destroy (&mu_sieve_library_path_prefix);
     }
-  mu_list_do (p->library_path_prefix, _path_append,
+  mu_list_foreach (p->library_path_prefix, _path_append,
 	      &mu_sieve_library_path_prefix);
-  mu_list_do (p->library_path, _path_append, &mu_sieve_library_path);
+  mu_list_foreach (p->library_path, _path_append, &mu_sieve_library_path);
   mu_list_destroy (&p->library_path);
   mu_list_destroy (&p->library_path_prefix);
   mu_list_destroy (&p->include_path);
diff --git a/libmu_sieve/load.c b/libmu_sieve/load.c
index d10a198..7d91405 100644
--- a/libmu_sieve/load.c
+++ b/libmu_sieve/load.c
@@ -52,11 +52,11 @@ sieve_init_load_path ()
     {
       if (lt_dlinit ())
 	return 1;
-      mu_list_do (mu_sieve_library_path_prefix, _add_load_dir, NULL);
+      mu_list_foreach (mu_sieve_library_path_prefix, _add_load_dir, NULL);
 #ifdef MU_SIEVE_MODDIR
       _add_load_dir (MU_SIEVE_MODDIR, NULL);
 #endif
-      mu_list_do (mu_sieve_library_path, _add_load_dir, NULL);
+      mu_list_foreach (mu_sieve_library_path, _add_load_dir, NULL);
       inited = 1;
     }
   return 0;
diff --git a/libmu_sieve/prog.c b/libmu_sieve/prog.c
index 13e8290..d24cbe1 100644
--- a/libmu_sieve/prog.c
+++ b/libmu_sieve/prog.c
@@ -234,7 +234,7 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 		      err = 1;
 		      break;
 		    }
-		  if (mu_list_do (chk_list, _compare_ptr, cf) == 0)
+		  if (mu_list_foreach (chk_list, _compare_ptr, cf) == 0)
 		    mu_list_append (chk_list, cf);
 		}
 	    }
@@ -307,7 +307,7 @@ mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
 	  chk_arg.name = reg->name;
 	  chk_arg.tags = tag_list;
 	  chk_arg.args = arg_list;
-	  err = mu_list_do (chk_list, _run_checker, &chk_arg);
+	  err = mu_list_foreach (chk_list, _run_checker, &chk_arg);
 	}
     }
   
diff --git a/libmu_sieve/sieve.l b/libmu_sieve/sieve.l
index 8abd121..5677ec7 100644
--- a/libmu_sieve/sieve.l
+++ b/libmu_sieve/sieve.l
@@ -382,7 +382,7 @@ sieve_include ()
     {
       char *p = name;
       if (mu_sieve_include_path
-	  && mu_list_do (mu_sieve_include_path, _try_include, &p))
+	  && mu_list_foreach (mu_sieve_include_path, _try_include, &p))
 	{
 	  push_source (p);
 	  free (name);
diff --git a/libmu_sieve/sieve.y b/libmu_sieve/sieve.y
index 9abe35a..e5218fb 100644
--- a/libmu_sieve/sieve.y
+++ b/libmu_sieve/sieve.y
@@ -565,7 +565,7 @@ mu_sieve_machine_destroy (mu_sieve_machine_t *pmach)
                    MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL);
   mu_stream_destroy (&mach->errstream);
   mu_mailer_destroy (&mach->mailer);
-  mu_list_do (mach->destr_list, _run_destructor, NULL);
+  mu_list_foreach (mach->destr_list, _run_destructor, NULL);
   mu_list_destroy (&mach->destr_list);
   mu_list_destroy (&mach->action_list);
   mu_list_destroy (&mach->test_list);
diff --git a/libmu_sieve/tests.c b/libmu_sieve/tests.c
index 19fbd84..81eb112 100644
--- a/libmu_sieve/tests.c
+++ b/libmu_sieve/tests.c
@@ -51,7 +51,7 @@ address_aget_t
 sieve_get_address_part (mu_list_t tags)
 {
   address_aget_t ret = mu_address_aget_email;
-  mu_list_do (tags, _get_address_part, &ret);
+  mu_list_foreach (tags, _get_address_part, &ret);
   return ret;
 }
 
diff --git a/libmu_sieve/util.c b/libmu_sieve/util.c
index 1fa7378..6dddfb4 100644
--- a/libmu_sieve/util.c
+++ b/libmu_sieve/util.c
@@ -136,7 +136,7 @@ mu_sieve_slist_destroy (mu_list_t *plist)
 {
   if (!plist)
     return;
-  mu_list_do (*plist, _destroy_item, NULL);
+  mu_list_foreach (*plist, _destroy_item, NULL);
   mu_list_destroy (plist);
 }
 
@@ -344,11 +344,11 @@ sieve_print_value (mu_sieve_value_t *val, mu_stream_t str)
       break;
       
     case SVT_STRING_LIST:
-      mu_list_do (val->v.list, string_printer, str);
+      mu_list_foreach (val->v.list, string_printer, str);
       break;
 
     case SVT_VALUE_LIST:
-      mu_list_do (val->v.list, value_printer, str);
+      mu_list_foreach (val->v.list, value_printer, str);
 
     case SVT_POINTER:
       mu_stream_printf (str, "%p", val->v.ptr);
@@ -386,7 +386,7 @@ tag_printer (void *item, void *data)
 void
 mu_sv_print_tag_list (mu_list_t list, mu_stream_t str)
 {
-  mu_list_do (list, tag_printer, str);
+  mu_list_foreach (list, tag_printer, str);
 }
 
 static int
@@ -409,7 +409,7 @@ mu_sieve_tag_lookup (mu_list_t taglist, char *name, mu_sieve_value_t **arg)
   mu_sieve_runtime_tag_t t;
 
   t.tag = name;
-  if (taglist && mu_list_do (taglist, tag_finder, &t))
+  if (taglist && mu_list_foreach (taglist, tag_finder, &t))
     {
       if (arg)
 	*arg = t.arg;
@@ -425,7 +425,7 @@ mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t *ac, void *data)
     {
     case SVT_VALUE_LIST:
     case SVT_STRING_LIST:
-      return mu_list_do (val->v.list, ac, data);
+      return mu_list_foreach (val->v.list, ac, data);
       
     default:
       return -1;
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index 4e03c5d..2ba44ef 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -101,7 +101,7 @@ parse_id_reply (mu_imap_t imap, mu_assoc_t *passoc)
   st.item = 0;
   st.assoc = assoc;
   st.ret = 0;
-  mu_list_do (response->v.list, _id_convert, &st);
+  mu_list_foreach (response->v.list, _id_convert, &st);
   return st.ret;
 }
   
diff --git a/libproto/imap/select.c b/libproto/imap/select.c
index 130bb8d..75e94e6 100644
--- a/libproto/imap/select.c
+++ b/libproto/imap/select.c
@@ -98,7 +98,7 @@ _parse_stat (void *item, void *data)
 	{
 	  if (arg->type != imap_eltype_list)
 	    return 0;
-	  mu_list_do (arg->v.list, _collect_flags,
+	  mu_list_foreach (arg->v.list, _collect_flags,
 		      &imap->mbox_stat.permanent_flags);
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_PERMANENT_FLAGS;
 	}
@@ -111,7 +111,7 @@ _parse_stat (void *item, void *data)
 	return 0;
       if (arg->type != imap_eltype_list)
 	return 0;
-      mu_list_do (arg->v.list, _collect_flags, &imap->mbox_stat.defined_flags);
+      mu_list_foreach (arg->v.list, _collect_flags, &imap->mbox_stat.defined_flags);
       imap->mbox_stat.flags |= MU_IMAP_STAT_DEFINED_FLAGS;
     }
   else if (count == 2)
@@ -202,7 +202,7 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 	    }
 	  imap->mbox_writable = writable;
 	  memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
-	  mu_list_do (imap->untagged_resp, _parse_stat, imap);
+	  mu_list_foreach (imap->untagged_resp, _parse_stat, imap);
 	  if (ps)
 	    *ps = imap->mbox_stat;
 	  break;
diff --git a/libproto/mailer/smtp_mech.c b/libproto/mailer/smtp_mech.c
index e916076..22b7017 100644
--- a/libproto/mailer/smtp_mech.c
+++ b/libproto/mailer/smtp_mech.c
@@ -80,7 +80,7 @@ mu_smtp_add_auth_mech_list (mu_smtp_t smtp, mu_list_t list)
 {
   if (!smtp)
     return EINVAL;
-  return mu_list_do (list, _mech_append, smtp);
+  return mu_list_foreach (list, _mech_append, smtp);
 }
 
 /* Set a list of implemented authentication mechanisms */
@@ -127,7 +127,7 @@ mu_smtp_mech_select (mu_smtp_t smtp, const char **pmech)
     {
       rc = mu_list_create (&alist);
       if (rc == 0)
-	rc = mu_list_do (smtp->authimpl, _mech_copy, alist);
+	rc = mu_list_foreach (smtp->authimpl, _mech_copy, alist);
     }
   else
     {
diff --git a/maidag/lmtp.c b/maidag/lmtp.c
index 12f4214..0273e20 100644
--- a/maidag/lmtp.c
+++ b/maidag/lmtp.c
@@ -381,7 +381,7 @@ cfun_data (mu_stream_t iostr, char *arg)
       maidag_error (_("copy error: %s"), mu_strerror (rc));
       mu_stream_destroy (&flt);
       mu_stream_destroy (&tempstr);
-      mu_list_do (rcpt_list, dot_temp_fail, iostr);
+      mu_list_foreach (rcpt_list, dot_temp_fail, iostr);
     }
 
   lmtp_reply (iostr, "354", NULL, "Go ahead");
@@ -413,7 +413,7 @@ cfun_data (mu_stream_t iostr, char *arg)
   if (rc)
     {
       maidag_error (_("copy error: %s"), mu_strerror (rc));
-      mu_list_do (rcpt_list, dot_temp_fail, iostr);
+      mu_list_foreach (rcpt_list, dot_temp_fail, iostr);
     }
 
   rc = mu_stream_to_message (tempstr, &mesg);
@@ -422,14 +422,14 @@ cfun_data (mu_stream_t iostr, char *arg)
     {
       maidag_error (_("error creating temporary message: %s"),
 		    mu_strerror (rc));
-      mu_list_do (rcpt_list, dot_temp_fail, iostr);
+      mu_list_foreach (rcpt_list, dot_temp_fail, iostr);
     }
   
-  rc = mu_list_do (rcpt_list, dot_deliver, iostr);
+  rc = mu_list_foreach (rcpt_list, dot_deliver, iostr);
 
   mu_message_destroy (&mesg, mu_message_get_owner (mesg));
   if (rc)
-    mu_list_do (rcpt_list, dot_temp_fail, iostr);
+    mu_list_foreach (rcpt_list, dot_temp_fail, iostr);
 
   return 0;
 }
diff --git a/maidag/script.c b/maidag/script.c
index 36145de..750c458 100644
--- a/maidag/script.c
+++ b/maidag/script.c
@@ -162,7 +162,7 @@ script_apply (mu_message_t msg, struct mu_auth_data *auth)
       if (switch_user_id (auth, 1) == 0)
 	{
 	  chdir (auth->dir);
-	  rc = mu_list_do (script_list, apply_script, &clos);
+	  rc = mu_list_foreach (script_list, apply_script, &clos);
 	  chdir ("/");
 	  switch_user_id (auth, 0);
 	}
diff --git a/mail/send.c b/mail/send.c
index a150875..12270d2 100644
--- a/mail/send.c
+++ b/mail/send.c
@@ -112,13 +112,13 @@ int
 mail_sendheader (int argc, char **argv)
 {
   if (argc == 1)
-    mu_list_do (add_header_list, list_headers, NULL);
+    mu_list_foreach (add_header_list, list_headers, NULL);
   else if (argc == 2)
     {
       if (strchr (argv[1], ':'))
 	send_append_header (argv[1]);
       else
-	mu_list_do (add_header_list, list_headers, argv[1]);
+	mu_list_foreach (add_header_list, list_headers, argv[1]);
     }
   else
     {
@@ -207,7 +207,7 @@ void
 compose_init (compose_env_t * env)
 {
   memset (env, 0, sizeof (*env));
-  mu_list_do (add_header_list, seed_headers, env);
+  mu_list_foreach (add_header_list, seed_headers, env);
 }
 
 int
diff --git a/mail/util.c b/mail/util.c
index bb5a905..b008048 100644
--- a/mail/util.c
+++ b/mail/util.c
@@ -1061,7 +1061,7 @@ _run_and_free (void *item, void *data)
 void
 util_run_cached_commands (mu_list_t *list)
 {
-  mu_list_do (*list, _run_and_free, NULL);
+  mu_list_foreach (*list, _run_and_free, NULL);
   mu_list_destroy (list);
 }
 
diff --git a/mh/mark.c b/mh/mark.c
index ba8c5df..da9297e 100644
--- a/mh/mark.c
+++ b/mh/mark.c
@@ -222,7 +222,7 @@ main (int argc, char **argv)
 	  mu_error (_("--add requires at least one --sequence argument"));
 	  return 1;
 	}
-      mu_list_do (seq_list, action_add, (void *) &clos);
+      mu_list_foreach (seq_list, action_add, (void *) &clos);
       mh_global_save_state ();
       break;
       
@@ -232,7 +232,7 @@ main (int argc, char **argv)
 	  mu_error (_("--delete requires at least one --sequence argument"));
 	  return 1;
 	}
-      mu_list_do (seq_list, action_delete, (void *) &clos);
+      mu_list_foreach (seq_list, action_delete, (void *) &clos);
       mh_global_save_state ();
       break;
       
@@ -240,7 +240,7 @@ main (int argc, char **argv)
       if (!seq_list)
 	list_all (mbox);
       else
-	mu_list_do (seq_list, action_list, &clos);
+	mu_list_foreach (seq_list, action_list, &clos);
       break;
     }
   mu_mailbox_close (mbox);
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 22a6ace..0e51496 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -454,7 +454,7 @@ addr_cmp (void *item, void *data)
 static int
 addrlist_lookup (mu_list_t list, mu_address_t addr)
 {
-  return mu_list_do (list, addr_cmp, addr);
+  return mu_list_foreach (list, addr_cmp, addr);
 }
 
 static int
@@ -468,7 +468,7 @@ addr_free (void *item, void *data)
 static void
 addrlist_destroy (mu_list_t *list)
 {
-  mu_list_do (*list, addr_free, NULL);
+  mu_list_foreach (*list, addr_free, NULL);
   mu_list_destroy (list);
 }
 
diff --git a/mh/mh_list.c b/mh/mh_list.c
index ebedf41..bcf6aa6 100644
--- a/mh/mh_list.c
+++ b/mh/mh_list.c
@@ -356,7 +356,7 @@ _destroy_stmt (void *item, void *data)
 void
 mhl_format_destroy (mu_list_t *fmt)
 {
-  mu_list_do (*fmt, _destroy_stmt, NULL);
+  mu_list_foreach (*fmt, _destroy_stmt, NULL);
   mu_list_destroy (fmt);
 }
 
@@ -474,7 +474,7 @@ _comp_name (void *item, void *date)
 int
 header_is_printed (struct eval_env *env, const char *name)
 {
-  return mu_list_do (env->printed_fields, _comp_name, (void*) name) == 1;
+  return mu_list_foreach (env->printed_fields, _comp_name, (void*) name) == 1;
 }
 
 int
@@ -781,7 +781,7 @@ eval_comp (struct eval_env *env, char *compname, mu_list_t format)
 {
   struct eval_env lenv = *env;
   
-  mu_list_do (format, eval_stmt, &lenv);
+  mu_list_foreach (format, eval_stmt, &lenv);
 
   goto_offset (&lenv, lenv.ivar[I_OFFSET]);
 
@@ -852,7 +852,7 @@ mhl_format_run (mu_list_t fmt,
   env.nlines = 0;
   env.msg = msg;
   env.output = output;
-  rc = mu_list_do (fmt, eval_stmt, &env);
+  rc = mu_list_foreach (fmt, eval_stmt, &env);
   mu_list_destroy (&env.printed_fields);
   return rc;
 }
diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c
index ad27490..4b4b210 100644
--- a/mh/mh_whatnow.c
+++ b/mh/mh_whatnow.c
@@ -307,7 +307,7 @@ annotate (struct mh_whatnow_env *wh)
 	  d.field = wh->anno_field;
 	  d.date = i == 1;
 	  mu_address_to_string (subaddr, d.value, size + 1, NULL);
-	  mu_list_do (wh->anno_list, anno, &d);
+	  mu_list_foreach (wh->anno_list, anno, &d);
 	  free (d.value);
 	  mu_address_destroy (&subaddr);
 	}
diff --git a/mh/mh_whom.c b/mh/mh_whom.c
index cd5abeb..30a295c 100644
--- a/mh/mh_whom.c
+++ b/mh/mh_whom.c
@@ -152,7 +152,7 @@ destroy_addrs (mu_list_t *list)
 {
   if (!*list)
     return;
-  mu_list_do (*list, _destroy_recipient, NULL);
+  mu_list_foreach (*list, _destroy_recipient, NULL);
   mu_list_destroy (list);
 }
 
@@ -296,13 +296,13 @@ mh_whom (const char *filename, int check)
       if (local_rcp)
 	{
 	  printf ("  %s\n", _("-- Local Recipients --"));
-	  mu_list_do (local_rcp, _print_local_recipient, &count);
+	  mu_list_foreach (local_rcp, _print_local_recipient, &count);
 	}
 
       if (network_rcp)
 	{
 	  printf ("  %s\n", _("-- Network Recipients --"));
-	  mu_list_do (network_rcp, _print_recipient, &count);
+	  mu_list_foreach (network_rcp, _print_recipient, &count);
 	}
 
       if (count == 0)
diff --git a/mh/pick.c b/mh/pick.c
index db7aa43..c819a29 100644
--- a/mh/pick.c
+++ b/mh/pick.c
@@ -410,7 +410,7 @@ main (int argc, char **argv)
       msgset.list = obstack_finish (&msgno_stk);
       clos.mbox = mbox;
       clos.msgset = &msgset;
-      mu_list_do (seq_list, action_add, &clos);
+      mu_list_foreach (seq_list, action_add, &clos);
     }
 
   mh_global_save_state ();
diff --git a/mh/send.c b/mh/send.c
index 1f015a7..b654f10 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -838,7 +838,7 @@ main (int argc, char **argv)
   free (p);
   
   /* Finally, do the work */
-  rc = mu_list_do (mesg_list, _action_send, NULL);
+  rc = mu_list_foreach (mesg_list, _action_send, NULL);
 
   mu_mailbox_destroy (&mbox);
   return !!rc;
diff --git a/mh/sortm.c b/mh/sortm.c
index 3a34b10..841e4eb 100644
--- a/mh/sortm.c
+++ b/mh/sortm.c
@@ -243,7 +243,7 @@ remop (compfun comp)
   struct rem_data d;
   d.comp = comp;
   d.op = NULL;
-  mu_list_do (oplist, rem_action, &d);
+  mu_list_foreach (oplist, rem_action, &d);
   mu_list_remove (oplist, d.op);
 }
 
@@ -297,7 +297,7 @@ compare_messages (mu_message_t a, mu_message_t b, size_t anum, size_t bnum)
   d.r = 0;
   d.m[0] = a;
   d.m[1] = b;
-  mu_list_do (oplist, compare_action, &d);
+  mu_list_foreach (oplist, compare_action, &d);
   if (d.r == 0)
     {
       if (anum < bnum)
diff --git a/mimeview/mimetypes.y b/mimeview/mimetypes.y
index b71f628..3250384 100644
--- a/mimeview/mimetypes.y
+++ b/mimeview/mimetypes.y
@@ -702,7 +702,7 @@ const char *
 get_file_type ()
 {
   const char *type = NULL;
-  mu_list_do (rule_list, evaluate, &type);
+  mu_list_foreach (rule_list, evaluate, &type);
   return type;
 }
     
diff --git a/mu/dbm.c b/mu/dbm.c
index ee217ca..1408d58 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -1419,7 +1419,7 @@ delete_database (int argc, char **argv)
 	free_regexes (&m);
       }
     }
-  mu_list_do (templist, do_delete, db);
+  mu_list_foreach (templist, do_delete, db);
   mu_list_destroy (&templist);
   mu_dbm_destroy (&db);
 }
diff --git a/mu/filter.c b/mu/filter.c
index 8821e64..0639fc2 100644
--- a/mu/filter.c
+++ b/mu/filter.c
@@ -95,7 +95,7 @@ list_filters ()
       mu_diag_funcall (MU_DIAG_ERROR, "mu_filter_get_list", NULL, rc);
       return 1;
     }
-  return mu_list_do (list, filter_printer, NULL);
+  return mu_list_foreach (list, filter_printer, NULL);
 }
 
 static int
diff --git a/sql/odbc.c b/sql/odbc.c
index c2d5381..c476f6b 100644
--- a/sql/odbc.c
+++ b/sql/odbc.c
@@ -188,7 +188,7 @@ static int
 odbc_release_result (mu_sql_connection_t conn)
 {
   struct mu_odbc_data *dp = conn->data;
-  mu_list_do (dp->result, odbc_free_char_data, NULL);
+  mu_list_foreach (dp->result, odbc_free_char_data, NULL);
   mu_list_destroy (&dp->result);
   mu_argcv_free (dp->fcount, dp->fnames);
   dp->fcount = 0;
diff --git a/testsuite/smtpsend.c b/testsuite/smtpsend.c
index 7eaa670..9dcc4e7 100644
--- a/testsuite/smtpsend.c
+++ b/testsuite/smtpsend.c
@@ -250,7 +250,7 @@ main (int argc, char **argv)
     }
   
   MU_ASSERT (mu_smtp_mail_basic (smtp, from, NULL));
-  mu_list_do (rcpt_list, send_rcpt_command, smtp);
+  mu_list_foreach (rcpt_list, send_rcpt_command, smtp);
   
   if (raw)
     {


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 19 13:39:21 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRpov-00020y-5r
	for mharc-commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:39:21 -0500
Received: from eggs.gnu.org ([140.186.70.92]:50392)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRpop-00020B-Of
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:39:19 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRpom-00011r-Qe
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:39:15 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56267)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRpom-00011c-MK
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:39:12 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRpoi-0007g9-Eu
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 18:39:12 +0000
Date: Sat, 19 Nov 2011 18:39:08 +0000
Message-Id: <E1RRpoi-0007g9-Eu@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-453-g3571832
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 530953e151f011eb2f57918039c402f475431a09
X-Git-Newrev: 35718326403f83b3e44cbeb8a3899e9d0d4dab90
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 Nov 2011 18:39:19 -0000

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

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

The branch, master has been updated
       via  35718326403f83b3e44cbeb8a3899e9d0d4dab90 (commit)
      from  530953e151f011eb2f57918039c402f475431a09 (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 35718326403f83b3e44cbeb8a3899e9d0d4dab90
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 19 20:34:24 2011 +0200

    Implement general-purpose processing of unsolicited responses in imap client.
    
    * include/mailutils/imap.h (mu_imap_response_action_t): New typedef.
    (mu_imap_foreach_response): New proto.
    (MU_IMAP_CB_PERMANENT_FLAGS,MU_IMAP_CB_MESSAGE_COUNT)
    (MU_IMAP_CB_RECENT_COUNT,MU_IMAP_CB_FIRST_UNSEEN)
    (MU_IMAP_CB_UIDNEXT,MU_IMAP_CB_UIDVALIDITY)
    (MU_IMAP_CB_OK,_MU_IMAP_CB_MAX): New constants.
    (mu_imap_callback_t): New typedef.
    (mu_imap_callback,mu_imap_register_callback_function): New protos.
    (MU_IMAP_RESPONSE_ALERT,MU_IMAP_RESPONSE_BADCHARSET)
    (MU_IMAP_RESPONSE_CAPABILITY,MU_IMAP_RESPONSE_PARSE)
    (MU_IMAP_RESPONSE_PERMANENTFLAGS,MU_IMAP_RESPONSE_READ_ONLY)
    (MU_IMAP_RESPONSE_READ_WRITE,MU_IMAP_RESPONSE_TRYCREATE)
    (MU_IMAP_RESPONSE_UIDNEXT,MU_IMAP_RESPONSE_UIDVALIDITY)
    (MU_IMAP_RESPONSE_UNSEEN): New constants.
    (mu_imap_response_codes): New extern.
    * include/mailutils/sys/imap.h (_mu_imap) <callback>: New member.
    (_mu_imap_collect_flags, _mu_imap_list_at): New protos.
    * libproto/imap/resplist.c (_mu_imap_list_at): New function.
    * libproto/imap/callback.c: New file.
    * libproto/imap/resproc.c: New file.
    * libproto/imap/Makefile.am: Add new files.
    * libproto/imap/capability.c: Rewrite using mu_imap_foreach_response.
    * libproto/imap/id.c: Likewise.
    * libproto/imap/select.c: Likewise.

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

Summary of changes:
 include/mailutils/imap.h                          |   40 ++++
 include/mailutils/sys/imap.h                      |   11 +
 libproto/imap/Makefile.am                         |    2 +
 libmu_dbm/datumfree.c => libproto/imap/callback.c |   35 ++-
 libproto/imap/capability.c                        |   39 ++--
 libproto/imap/id.c                                |   50 +---
 libproto/imap/resplist.c                          |   16 ++
 libproto/imap/resproc.c                           |  260 +++++++++++++++++++++
 libproto/imap/select.c                            |  111 ++--------
 9 files changed, 406 insertions(+), 158 deletions(-)
 copy libmu_dbm/datumfree.c => libproto/imap/callback.c (51%)
 create mode 100644 libproto/imap/resproc.c

diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index 3093ec6..e33ff08 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -18,6 +18,7 @@
 #ifndef _MAILUTILS_IMAP_H
 #define _MAILUTILS_IMAP_H
 
+#include <stdarg.h>
 #include <mailutils/iterator.h>
 #include <mailutils/debug.h>
 #include <mailutils/stream.h>
@@ -99,6 +100,45 @@ int mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 int mu_imap_status (mu_imap_t imap, const char *mbox, struct mu_imap_stat *ps);
 
 extern struct mu_kwd _mu_imap_status_name_table[];
+
+typedef void (*mu_imap_response_action_t) (mu_imap_t imap, mu_list_t resp,
+					   void *data);
+
+int mu_imap_foreach_response (mu_imap_t imap, mu_imap_response_action_t fun,
+			      void *data);
+  
+
+#define MU_IMAP_CB_PERMANENT_FLAGS  0
+#define MU_IMAP_CB_MESSAGE_COUNT    1
+#define MU_IMAP_CB_RECENT_COUNT     2
+#define MU_IMAP_CB_FIRST_UNSEEN     3
+#define MU_IMAP_CB_UIDNEXT          4 
+#define MU_IMAP_CB_UIDVALIDITY      5
+#define MU_IMAP_CB_OK               6
+#define _MU_IMAP_CB_MAX             7
+
+typedef void (*mu_imap_callback_t) (void *, int code, mu_list_t resp,
+				    va_list ap);
+  
+void mu_imap_callback (mu_imap_t imap, int code, mu_list_t resp, ...);
+
+void mu_imap_register_callback_function (mu_imap_t imap, int code,
+					 mu_imap_callback_t callback,
+					 void *data);
+
+#define MU_IMAP_RESPONSE_ALERT            0
+#define MU_IMAP_RESPONSE_BADCHARSET       1
+#define MU_IMAP_RESPONSE_CAPABILITY       2
+#define MU_IMAP_RESPONSE_PARSE            3
+#define MU_IMAP_RESPONSE_PERMANENTFLAGS   4
+#define MU_IMAP_RESPONSE_READ_ONLY        5     
+#define MU_IMAP_RESPONSE_READ_WRITE       6
+#define MU_IMAP_RESPONSE_TRYCREATE        7
+#define MU_IMAP_RESPONSE_UIDNEXT          8
+#define MU_IMAP_RESPONSE_UIDVALIDITY      9
+#define MU_IMAP_RESPONSE_UNSEEN          10
+
+extern struct mu_kwd mu_imap_response_codes[];  
   
 #ifdef __cplusplus
 }
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index dd4b1df..de3d1bf 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -83,6 +83,13 @@ struct _mu_imap
     char *mbox_name;  /* Name of the currently opened mailbox */
     int mbox_writable:1; /* Is it open read/write? */
     struct mu_imap_stat mbox_stat;  /* Stats obtained from it */
+
+    /* Callbacks */
+    struct
+    {
+      mu_imap_callback_t action;
+      void *data;
+    } callback[_MU_IMAP_CB_MAX];
 };
 
 enum imap_eltype
@@ -160,6 +167,10 @@ int _mu_imap_untagged_response_add (mu_imap_t imap);
 
 int _mu_imap_list_element_is_string (struct imap_list_element *elt,
 				     const char *str);
+int _mu_imap_collect_flags (struct imap_list_element *arg, int *res);
+
+struct imap_list_element *_mu_imap_list_at (mu_list_t list, int idx);
+  
   
 # ifdef __cplusplus
 }
diff --git a/libproto/imap/Makefile.am b/libproto/imap/Makefile.am
index 956b0b5..ee89f90 100644
--- a/libproto/imap/Makefile.am
+++ b/libproto/imap/Makefile.am
@@ -28,6 +28,7 @@ libmu_imap_la_LIBADD = ${MU_LIB_AUTH} ${MU_LIB_MAILUTILS} @INTLLIBS@
 #  url.c
 libmu_imap_la_SOURCES = \
  fake-folder.c\
+ callback.c\
  capability.c\
  capatst.c\
  carrier.c\
@@ -41,6 +42,7 @@ libmu_imap_la_SOURCES = \
  logout.c\
  resplist.c\
  response.c\
+ resproc.c\
  select.c\
  state.c\
  status.c\
diff --git a/libmu_dbm/datumfree.c b/libproto/imap/callback.c
similarity index 51%
copy from libmu_dbm/datumfree.c
copy to libproto/imap/callback.c
index c11db26..63df696 100644
--- a/libmu_dbm/datumfree.c
+++ b/libproto/imap/callback.c
@@ -1,4 +1,5 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
+/* Response processing for IMAP client.
+   GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 2011 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
@@ -18,19 +19,33 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-#include <stdlib.h>
-#include <mailutils/types.h>
-#include <mailutils/dbm.h>
 #include <mailutils/errno.h>
-#include "mudbm.h"
+#include <mailutils/sys/imap.h>
 
 void
-mu_dbm_datum_free (struct mu_dbm_datum *datum)
+mu_imap_callback (mu_imap_t imap, int code, mu_list_t resp, ...)
 {
-  if (datum && datum->mu_data &&
-      datum->mu_sys && datum->mu_sys->_dbm_datum_free)
+  va_list ap;
+  
+  if (code < 0 || code > _MU_IMAP_CB_MAX || !imap->callback[code].action)
+    return;
+  
+  va_start (ap, resp);
+  imap->callback[code].action (imap->callback[code].data, code, resp, ap);
+  va_end (ap);
+}
+
+void
+mu_imap_register_callback_function (mu_imap_t imap, int code,
+				    mu_imap_callback_t callback,
+				    void *data)
+{
+  if (code < 0 || code > _MU_IMAP_CB_MAX)
     {
-      datum->mu_sys->_dbm_datum_free (datum);
-      datum->mu_data = NULL;
+      mu_error ("%s:%d: ignoring unsupported callback code %d",
+		__FILE__, __LINE__, code);
+      return;
     }
+  imap->callback[code].action = callback;
+  imap->callback[code].data = data;
 }
diff --git a/libproto/imap/capability.c b/libproto/imap/capability.c
index feaed0d..14dff87 100644
--- a/libproto/imap/capability.c
+++ b/libproto/imap/capability.c
@@ -54,17 +54,25 @@ _map_capa (void **itmv, size_t itmc, void *call_data)
     return MU_LIST_MAP_STOP;
   if (*n == 0)
     {
-      ++*n;
-      if (strcmp (elt->v.string, "CAPABILITY") == 0)
-	return MU_LIST_MAP_SKIP;
-      else
-	return MU_LIST_MAP_STOP;
+      *n = 1;
+      return MU_LIST_MAP_SKIP;
     }
   itmv[0] = elt->v.string;
   elt->v.string = NULL;
   return MU_LIST_MAP_OK;
 }
 
+static void
+_capability_response_action (mu_imap_t imap, mu_list_t response, void *data)
+{
+  struct imap_list_element *elt = _mu_imap_list_at (response, 0);
+  if (elt && _mu_imap_list_element_is_string (elt, "CAPABILITY"))
+    {
+      int n = 0;
+      mu_list_map (response, _map_capa, &n, 1, &imap->capa);
+    }
+}
+
 int
 mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
 {
@@ -113,22 +121,17 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
 	return MU_ERR_REPLY;
       else
 	{
-	  size_t count;
-	  struct imap_list_element *elt;
-	  
 	  imap->state = MU_IMAP_CONNECTED;
-	  mu_list_count (imap->untagged_resp, &count);
-	  if (mu_list_get (imap->untagged_resp, 0, (void*)&elt) == 0)
+	  status = mu_imap_foreach_response (imap,
+					     _capability_response_action,
+					     NULL);
+	  if (status == 0)
 	    {
-	      /* Top-level elements are always of imap_eltype_list type. */
-	      int n = 0;
-	      status = mu_list_map (elt->v.list, _map_capa, &n, 1,
-				    &imap->capa);
+	      if (piter)
+		status = mu_list_get_iterator (imap->capa, piter);
+	      else
+		status = 0;
 	    }
-	  if (piter)
-	    status = mu_list_get_iterator (imap->capa, piter);
-	  else
-	    status = 0;
 	}  
       break;
       
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index 2ba44ef..bd5d447 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -48,44 +48,25 @@ _id_mapper (void **itmv, size_t itmc, void *call_data)
   return rc;
 }
 
-struct id_convert_state
+static void
+_id_response_action (mu_imap_t imap, mu_list_t response, void *data)
 {
-  int item;
-  mu_assoc_t assoc;
-  int ret;
-};
-
-static int
-_id_convert (void *item, void *data)
-{
-  struct imap_list_element *elt = item;
-  struct id_convert_state *stp = data;
+  mu_assoc_t assoc = data;
+  struct imap_list_element *elt;
 
-  switch (stp->item)
+  elt = _mu_imap_list_at (response, 0);
+  if (elt && _mu_imap_list_element_is_string (elt, "ID"))
     {
-    case 0:
-      if (!(elt->type == imap_eltype_string &&
-	    strcmp (elt->v.string, "ID") == 0))
-	{
-	  stp->ret = MU_ERR_PARSE;
-	  return 1;
-	}
-      stp->item++;
-      return 0;
-
-    case 1:
+      elt = _mu_imap_list_at (response, 1);
       if (elt->type == imap_eltype_list)
-	mu_list_gmap (elt->v.list, _id_mapper, 2, stp->assoc);
+	mu_list_gmap (elt->v.list, _id_mapper, 2, assoc);
     }
-  return 1;
-}	
+}
 
 static int
 parse_id_reply (mu_imap_t imap, mu_assoc_t *passoc)
 {
   int rc;
-  struct imap_list_element const *response;
-  struct id_convert_state st;
   mu_assoc_t assoc;
   
   rc = mu_assoc_create (&assoc, sizeof (char**), MU_ASSOC_ICASE);
@@ -93,16 +74,11 @@ parse_id_reply (mu_imap_t imap, mu_assoc_t *passoc)
     return rc;
   mu_assoc_set_free (assoc, _id_free);
   
-  rc = mu_list_get (imap->untagged_resp, 0, (void*) &response);
+  rc = mu_imap_foreach_response (imap, _id_response_action, assoc);
+  if (rc)
+    return rc;
   *passoc = assoc;
-  if (rc == MU_ERR_NOENT)
-    return 0;
-
-  st.item = 0;
-  st.assoc = assoc;
-  st.ret = 0;
-  mu_list_foreach (response->v.list, _id_convert, &st);
-  return st.ret;
+  return 0;
 }
   
 int
diff --git a/libproto/imap/resplist.c b/libproto/imap/resplist.c
index f46417c..de2e523 100644
--- a/libproto/imap/resplist.c
+++ b/libproto/imap/resplist.c
@@ -264,3 +264,19 @@ _mu_imap_list_element_is_string (struct imap_list_element *elt,
   return strcmp (elt->v.string, str) == 0;
 }
 
+struct imap_list_element *
+_mu_imap_list_at (mu_list_t list, int idx)
+{
+  struct imap_list_element *arg;
+  int rc = mu_list_get (list, idx, (void*) &arg);
+  if (rc)
+    {
+      mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
+		("%s:%d: cannot get list element: %s",
+		 __FILE__, __LINE__, mu_strerror (rc)));
+      return NULL;
+    }
+  return arg;
+}
+
+
diff --git a/libproto/imap/resproc.c b/libproto/imap/resproc.c
new file mode 100644
index 0000000..af752b9
--- /dev/null
+++ b/libproto/imap/resproc.c
@@ -0,0 +1,260 @@
+/* Response processing for IMAP client.
+   GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <mailutils/cstr.h>
+#include <mailutils/stream.h>
+#include <mailutils/errno.h>
+#include <mailutils/sys/imap.h>
+
+struct mu_kwd mu_imap_response_codes[] = {
+  /* [ALERT] */
+  { "ALERT",          MU_IMAP_RESPONSE_ALERT },
+  /* [BADCHARSET (opt-list)] */
+  { "BADCHARSET",     MU_IMAP_RESPONSE_BADCHARSET },
+  /* [CAPABILITY (list)] */
+  { "CAPABILITY",     MU_IMAP_RESPONSE_CAPABILITY },
+  /* [PARSE] text */
+  { "PARSE",          MU_IMAP_RESPONSE_PARSE }, 
+  /* [PERMANENTFLAGS (list)] */
+  { "PERMANENTFLAGS", MU_IMAP_RESPONSE_PERMANENTFLAGS },
+  /* [READ-ONLY] */
+  { "READ-ONLY",      MU_IMAP_RESPONSE_READ_ONLY },
+  /* [READ-WRITE] */
+  { "READ-WRITE",     MU_IMAP_RESPONSE_READ_WRITE },
+  /* [TRYCREATE] */
+  { "TRYCREATE",      MU_IMAP_RESPONSE_TRYCREATE },  
+  /* [UIDNEXT N] */
+  { "UIDNEXT",        MU_IMAP_RESPONSE_UIDNEXT }, 
+  /* [UIDVALIDITY N] */
+  { "UIDVALIDITY",    MU_IMAP_RESPONSE_UIDVALIDITY },
+  /* [UNSEEN N] */
+  { "UNSEEN",         MU_IMAP_RESPONSE_UNSEEN },
+  { NULL }
+};
+
+static void
+ok_response (mu_imap_t imap, mu_list_t resp, void *data)
+{
+  struct imap_list_element *arg;
+  int rcode = -1;
+  size_t n = 0;
+  
+  arg = _mu_imap_list_at (resp, 1);
+  if (!arg)
+    return;
+  if (arg->type == imap_eltype_string && arg->v.string[0] == '[')
+    {
+      char *p;
+      
+      size_t len = strcspn (arg->v.string, "]");
+      
+      if (mu_kwd_xlat_name_len (mu_imap_response_codes,
+				arg->v.string + 1, len - 1, &rcode))
+	rcode = -1;
+      
+      switch (rcode)
+	{
+	case MU_IMAP_RESPONSE_PERMANENTFLAGS:
+	  arg = _mu_imap_list_at (resp, 2);
+	  if (!arg ||
+	      _mu_imap_collect_flags (arg, &imap->mbox_stat.permanent_flags))
+	    break;
+	  imap->mbox_stat.flags |= MU_IMAP_STAT_PERMANENT_FLAGS;
+	  mu_imap_callback (imap, MU_IMAP_CB_PERMANENT_FLAGS, resp,
+			    &imap->mbox_stat);
+	  return;
+	  
+	case MU_IMAP_RESPONSE_UIDNEXT:
+	  arg = _mu_imap_list_at (resp, 2);
+	  if (!arg || arg->type != imap_eltype_string)
+	    break;
+	  n = strtoul (arg->v.string, &p, 10);
+	  if (*p == ']')
+	    {
+	      imap->mbox_stat.uidnext = n;
+	      imap->mbox_stat.flags |= MU_IMAP_STAT_UIDNEXT;
+	      mu_imap_callback (imap, MU_IMAP_CB_UIDNEXT, resp,
+				&imap->mbox_stat);
+	    }
+	  return;
+			    
+	case MU_IMAP_RESPONSE_UIDVALIDITY:
+	  arg = _mu_imap_list_at (resp, 2);
+	  if (!arg || arg->type != imap_eltype_string)
+	    break;
+	  n = strtoul (arg->v.string, &p, 10);
+	  if (*p == ']')
+	    {
+	      imap->mbox_stat.uidvalidity = n;
+	      imap->mbox_stat.flags |= MU_IMAP_STAT_UIDVALIDITY;
+	      mu_imap_callback (imap, MU_IMAP_CB_UIDVALIDITY, resp,
+				&imap->mbox_stat);
+	    }
+	  return;
+			    
+	case MU_IMAP_RESPONSE_UNSEEN:
+	  arg = _mu_imap_list_at (resp, 2);
+	  if (!arg || arg->type != imap_eltype_string)
+	    break;
+	  n = strtoul (arg->v.string, &p, 10);
+	  if (*p == ']')
+	    {
+	      imap->mbox_stat.first_unseen = n;
+	      imap->mbox_stat.flags |= MU_IMAP_STAT_FIRST_UNSEEN;
+	      mu_imap_callback (imap, MU_IMAP_CB_FIRST_UNSEEN, resp,
+				&imap->mbox_stat);
+	    }
+	  return;
+	}
+    }
+  mu_imap_callback (imap, MU_IMAP_CB_OK, resp, rcode);
+}
+
+
+struct response_closure
+{
+  mu_imap_t imap;
+  mu_imap_response_action_t fun;
+  void *data;
+};
+
+struct resptab
+{
+  char *name;
+  mu_imap_response_action_t action;
+};
+
+static struct resptab resptab[] = {
+  { "OK", ok_response },
+  { "NO", },
+  { "BAD", },
+  { "PREAUTH", },
+  { "BYE", },
+  { NULL }
+};
+
+static int
+_std_unsolicited_response (mu_imap_t imap, size_t count, mu_list_t resp)
+{
+  struct resptab *rp;
+  struct imap_list_element *arg = _mu_imap_list_at (resp, 0);
+
+  if (!arg)
+    return 1;
+
+  if (arg->type == imap_eltype_string)
+    for (rp = resptab; rp->name; rp++)
+      {
+	if (mu_c_strcasecmp (rp->name, arg->v.string) == 0)
+	  {
+	    if (!rp->action)
+	      mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_TRACE9,
+			("%s:%d: ignoring %s response",
+			 __FILE__, __LINE__, rp->name));
+	    else
+	      rp->action (imap, resp, NULL);
+	    return 0;
+	  }
+      }
+  return 1;
+}
+
+static int
+_process_unsolicited_response (mu_imap_t imap, mu_list_t resp)
+{
+  size_t count;
+  struct imap_list_element *arg;
+  
+  if (mu_list_count (resp, &count))
+    return 1;
+
+  if (_std_unsolicited_response (imap, count, resp) == 0)
+    return 0;
+  if (count == 2)
+    {
+      size_t n;
+      char *p;
+
+      arg = _mu_imap_list_at (resp, 1);
+      if (!arg)
+	return 1;
+      
+      if (_mu_imap_list_element_is_string (arg, "EXISTS"))
+	{
+	  arg = _mu_imap_list_at (resp, 0);
+	  if (!arg)
+	    return 1;
+	  
+	  n = strtoul (arg->v.string, &p, 10);
+	  if (*p)
+	    return 1;
+	  imap->mbox_stat.message_count = n;
+	  imap->mbox_stat.flags |= MU_IMAP_STAT_MESSAGE_COUNT;
+	  mu_imap_callback (imap, MU_IMAP_CB_MESSAGE_COUNT, resp, n);
+	  return 0;
+	}
+      else if (_mu_imap_list_element_is_string (arg, "RECENT"))
+	{
+	  arg = _mu_imap_list_at (resp, 0);
+	  if (!arg)
+	    return 1;
+	  n = strtoul (arg->v.string, &p, 10);
+	  if (*p)
+	    return 1;
+	  imap->mbox_stat.recent_count = n;
+	  imap->mbox_stat.flags |= MU_IMAP_STAT_RECENT_COUNT;
+	  mu_imap_callback (imap, MU_IMAP_CB_RECENT_COUNT, resp, n);
+	  return 0;
+	}
+    }
+  return 1;
+}
+
+static int
+_process_response (void *item, void *data)
+{
+  struct imap_list_element *elt = item;
+  struct response_closure *clos = data;
+
+  if (elt->type != imap_eltype_list)
+    {
+      mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
+		("ignoring string response \"%s\"", elt->v.string));
+    }
+  else if (_process_unsolicited_response (clos->imap, elt->v.list))
+    clos->fun (clos->imap, elt->v.list, clos->data);
+  return 0;
+}
+
+int
+mu_imap_foreach_response (mu_imap_t imap, mu_imap_response_action_t fun,
+			  void *data)
+{
+  struct response_closure clos;
+  clos.imap = imap;
+  clos.fun = fun;
+  clos.data = data;
+  return mu_list_foreach (imap->untagged_resp, _process_response, &clos);
+}
+			  
diff --git a/libproto/imap/select.c b/libproto/imap/select.c
index 75e94e6..0679197 100644
--- a/libproto/imap/select.c
+++ b/libproto/imap/select.c
@@ -38,103 +38,28 @@ _collect_flags (void *item, void *data)
   return 0;
 }
 
-static int
-_parse_stat (void *item, void *data)
+int
+_mu_imap_collect_flags (struct imap_list_element *arg, int *res)
+{
+  if (arg->type != imap_eltype_list)
+    return EINVAL;
+  mu_list_foreach (arg->v.list, _collect_flags, res);
+  return 0;
+}
+
+static void
+_select_response_action (mu_imap_t imap, mu_list_t response, void *data)
 {
-  struct imap_list_element *response = item;
-  mu_imap_t imap = data;
   struct imap_list_element *elt;
-  size_t count;
-  int rc;
-  char *p;
   
-  if (response->type != imap_eltype_list)
-    return 0;
-
-  mu_list_count (response->v.list, &count);
-  
-  rc = mu_list_get (response->v.list, 0, (void*) &elt);
-  if (rc)
-    return rc;
-  
-  if (_mu_imap_list_element_is_string (elt, "OK"))
-    {
-      struct imap_list_element *arg;
-      
-      if (count < 3)
-	return 0; /* ignore the line */
-      rc = mu_list_get (response->v.list, 1, (void*) &elt);
-      if (rc)
-	return rc;
-      rc = mu_list_get (response->v.list, 2, (void*) &arg);
-      if (rc)
-	return rc;
-      
-      if (_mu_imap_list_element_is_string (elt, "[UIDVALIDITY"))
-	{
-	  if (arg->type != imap_eltype_string)
-	    return 0;
-	  imap->mbox_stat.uidvalidity = strtoul (arg->v.string, &p, 10);
-	  if (*p == ']')
-	    imap->mbox_stat.flags |= MU_IMAP_STAT_UIDVALIDITY;
-	}
-      else if (_mu_imap_list_element_is_string (elt, "[UIDNEXT"))
-	{
-	  if (arg->type != imap_eltype_string)
-	    return 0;
-	  imap->mbox_stat.uidnext = strtoul (arg->v.string, &p, 10);
-	  if (*p == ']')
-	    imap->mbox_stat.flags |= MU_IMAP_STAT_UIDNEXT;
-	}
-      else if (_mu_imap_list_element_is_string (elt, "[UNSEEN"))
-	{
-	  if (arg->type != imap_eltype_string)
-	    return 0;
-	  imap->mbox_stat.first_unseen = strtoul (arg->v.string, &p, 10);
-	  if (*p == ']')
-	    imap->mbox_stat.flags |= MU_IMAP_STAT_FIRST_UNSEEN;
-	}
-      else if (_mu_imap_list_element_is_string (elt, "[PERMANENTFLAGS"))
-	{
-	  if (arg->type != imap_eltype_list)
-	    return 0;
-	  mu_list_foreach (arg->v.list, _collect_flags,
-		      &imap->mbox_stat.permanent_flags);
-	  imap->mbox_stat.flags |= MU_IMAP_STAT_PERMANENT_FLAGS;
-	}
-    }
-  else if (_mu_imap_list_element_is_string (elt, "FLAGS"))
-    {
-      struct imap_list_element *arg;
-      rc = mu_list_get (response->v.list, 1, (void*) &arg);
-      if (rc)
-	return 0;
-      if (arg->type != imap_eltype_list)
-	return 0;
-      mu_list_foreach (arg->v.list, _collect_flags, &imap->mbox_stat.defined_flags);
-      imap->mbox_stat.flags |= MU_IMAP_STAT_DEFINED_FLAGS;
-    }
-  else if (count == 2)
+  elt = _mu_imap_list_at (response, 0);
+  if (elt && _mu_imap_list_element_is_string (elt, "FLAGS"))
     {
-      struct imap_list_element *arg;
-      rc = mu_list_get (response->v.list, 1, (void*) &arg);
-      if (rc)
-	return rc;
-      if (_mu_imap_list_element_is_string (arg, "EXISTS"))
-	{
-	  imap->mbox_stat.message_count = strtoul (elt->v.string, &p, 10);
-	  if (*p == 0)
-	    imap->mbox_stat.flags |= MU_IMAP_STAT_MESSAGE_COUNT;
-	}
-      else if (_mu_imap_list_element_is_string (arg, "RECENT"))
-	{
-	  imap->mbox_stat.recent_count = strtoul (elt->v.string, &p, 10);
-	  if (*p == 0)
-	    imap->mbox_stat.flags |= MU_IMAP_STAT_RECENT_COUNT;
-	}
+      struct imap_list_element *arg = _mu_imap_list_at (response, 1);
+      if (arg &&
+	  _mu_imap_collect_flags (arg, &imap->mbox_stat.defined_flags) == 0)
+	imap->mbox_stat.flags |= MU_IMAP_STAT_DEFINED_FLAGS;
     }
-  
-  return 0;
 }
 
 int
@@ -202,7 +127,7 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 	    }
 	  imap->mbox_writable = writable;
 	  memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
-	  mu_list_foreach (imap->untagged_resp, _parse_stat, imap);
+	  mu_imap_foreach_response (imap, _select_response_action, NULL);
 	  if (ps)
 	    *ps = imap->mbox_stat;
 	  break;


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 19 13:52:00 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRq1A-00036x-PA
	for mharc-commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:52:00 -0500
Received: from eggs.gnu.org ([140.186.70.92]:35302)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRq18-00036U-06
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:51:59 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRq16-0002qe-Rx
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:51:57 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46378)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRq16-0002qW-PC
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 13:51:56 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRq16-0000g0-I8
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 18:51:56 +0000
Date: Sat, 19 Nov 2011 18:51:56 +0000
Message-Id: <E1RRq16-0000g0-I8@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-454-g58d01e1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 35718326403f83b3e44cbeb8a3899e9d0d4dab90
X-Git-Newrev: 58d01e1e081f2767ac07e9735c20d7f74c1bc637
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 Nov 2011 18:51: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=58d01e1e081f2767ac07e9735c20d7f74c1bc637

The branch, master has been updated
       via  58d01e1e081f2767ac07e9735c20d7f74c1bc637 (commit)
      from  35718326403f83b3e44cbeb8a3899e9d0d4dab90 (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 58d01e1e081f2767ac07e9735c20d7f74c1bc637
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 19 20:52:46 2011 +0200

    Imap client: fix status implementation.

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

Summary of changes:
 libproto/imap/status.c |   62 +++++++++++++++++++++--------------------------
 1 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/libproto/imap/status.c b/libproto/imap/status.c
index d071801..1957bf9 100644
--- a/libproto/imap/status.c
+++ b/libproto/imap/status.c
@@ -87,41 +87,32 @@ _status_mapper (void **itmv, size_t itmc, void *call_data)
   return 0;
 }
 
-static int
-_parse_status_response (mu_imap_t imap, const char *mboxname,
-			struct mu_imap_stat *ps)
+struct status_data
 {
-  struct imap_list_element *response, *elt;
-  size_t count;
-  int rc;
-  
-  rc = mu_list_get (imap->untagged_resp, 0, (void*) &response);
-  if (rc)
-    return rc;
+  const char *mboxname;
+  struct mu_imap_stat *ps;
+};
 
-  mu_list_count (response->v.list, &count);
-  if (count != 3)
-    return MU_ERR_PARSE;
-  rc = mu_list_get (response->v.list, 0, (void*) &elt);
-  if (rc)
-    return rc;
-  if (!_mu_imap_list_element_is_string (elt, "STATUS"))
-    return MU_ERR_NOENT;
-  
-  rc = mu_list_get (response->v.list, 1, (void*) &elt);
-  if (rc)
-    return rc;
-  if (!_mu_imap_list_element_is_string (elt, mboxname))
-    return MU_ERR_NOENT;
-
-  rc = mu_list_get (response->v.list, 2, (void*) &elt);
-  if (rc)
-    return rc;
-  if (elt->type != imap_eltype_list)
-    return MU_ERR_PARSE;
+static void
+_status_response_action (mu_imap_t imap, mu_list_t response, void *data)
+{
+  struct status_data *sd = data;
+  struct imap_list_element *elt;
 
-  ps->flags = 0;
-  return mu_list_gmap (elt->v.list, _status_mapper, 2, ps);
+  elt = _mu_imap_list_at (response, 0);
+  if (elt && _mu_imap_list_element_is_string (elt, "STATUS"))
+    {
+      elt = _mu_imap_list_at (response, 1);
+      if (elt && _mu_imap_list_element_is_string (elt, sd->mboxname))
+	{
+	  elt = _mu_imap_list_at (response, 2);
+	  if (elt && elt->type == imap_eltype_list)
+	    {
+	      sd->ps->flags = 0;
+	      mu_list_gmap (elt->v.list, _status_mapper, 2, sd->ps);
+	    }
+	}
+    }
 }
 
 int
@@ -197,8 +188,11 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
       switch (imap->resp_code)
 	{
 	case MU_IMAP_OK:
-	  memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
-	  status = _parse_status_response (imap, mboxname, ps);
+	  {
+	    struct status_data sd = { mboxname, ps };
+	    status = mu_imap_foreach_response (imap, _status_response_action,
+					       &sd);
+	  }
 	  break;
 
 	case MU_IMAP_NO:


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 19 16:41:12 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RRseu-0006zv-84
	for mharc-commit-mailutils@gnu.org; Sat, 19 Nov 2011 16:41:12 -0500
Received: from eggs.gnu.org ([140.186.70.92]:35200)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRseq-0006zQ-Le
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 16:41:10 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRseo-0007Nv-7y
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 16:41:08 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:44821)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRseo-0007No-61
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 16:41:06 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RRseg-0005BI-RL
	for commit-mailutils@gnu.org; Sat, 19 Nov 2011 21:41:05 +0000
Date: Sat, 19 Nov 2011 21:40:58 +0000
Message-Id: <E1RRseg-0005BI-RL@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-455-gc2dcdc0
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 58d01e1e081f2767ac07e9735c20d7f74c1bc637
X-Git-Newrev: c2dcdc0c950c030f96cabcafd9d860327bf02d71
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 Nov 2011 21:41:10 -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=c2dcdc0c950c030f96cabcafd9d860327bf02d71

The branch, master has been updated
       via  c2dcdc0c950c030f96cabcafd9d860327bf02d71 (commit)
      from  58d01e1e081f2767ac07e9735c20d7f74c1bc637 (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 c2dcdc0c950c030f96cabcafd9d860327bf02d71
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sat Nov 19 23:39:17 2011 +0200

    Implement list slicing functions.
    
    * include/mailutils/list.h (mu_list_slice_dup,mu_list_slice)
    (mu_list_slice2_dup,mu_list_slice2): New protos.
    * libmailutils/list/slice.c: New file.
    * libmailutils/list/slice2.c: New file.
    * libmailutils/list/Makefile.am: Add slice.c and slice2.c
    * libmailutils/tests/list.at: Add slicing tests.
    * libmailutils/tests/listop.c: New command: "slice"

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

Summary of changes:
 include/mailutils/list.h                        |   40 +++++++-
 libmailutils/list/Makefile.am                   |    4 +-
 libmailutils/list/slice.c                       |  125 +++++++++++++++++++++++
 libmailutils/{sockaddr/free.c => list/slice2.c} |   36 +++----
 libmailutils/tests/list.at                      |   53 ++++++++++
 libmailutils/tests/listop.c                     |   76 ++++++++++++++-
 6 files changed, 309 insertions(+), 25 deletions(-)
 create mode 100644 libmailutils/list/slice.c
 copy libmailutils/{sockaddr/free.c => list/slice2.c} (65%)

diff --git a/include/mailutils/list.h b/include/mailutils/list.h
index 296b6ec..e695bb7 100644
--- a/include/mailutils/list.h
+++ b/include/mailutils/list.h
@@ -177,7 +177,45 @@ int mu_list_intersect_dup (mu_list_t *_pdest,
 			   void *_dup_data);
   
   /* Same as mu_list_intersect_dup with _dup_item = NULL */
-int mu_list_intersect (mu_list_t *, mu_list_t, mu_list_t);  
+int mu_list_intersect (mu_list_t *, mu_list_t, mu_list_t);
+
+  /* ************************************************* */
+  /* List slicing                                      */
+  /* ************************************************* */
+  /* Create a new list from elements of _list located between
+     indices in _posv.  Return the result in _pdest.  
+     The resulting list will contain elements between _posv[0] and
+     _posv[1], _posv[2] and _posv[3], ..., _posv[_posc-2]
+     and _posv[_posc-1], inclusive.  If _posc is an odd number, an extra
+     element with the value [count-1] (where count is the number of
+     elements in _list) is implied.
+
+     The elements in _posv are sorted in ascending order prior to use. 
+     
+     See mu_list_intersect_dup for a description of _dup_item and
+     _dup_data */
+int mu_list_slice_dup (mu_list_t *_pdest, mu_list_t _list,
+		       size_t *_posv, size_t _posc,
+		       int (*_dup_item) (void **, void *, void *),
+		       void *_dup_data);
+  /* Same as mu_list_slice_dup invoked with _dup_item=NULL */
+int mu_list_slice (mu_list_t *_pdest, mu_list_t _list,
+		   size_t *_posv, size_t _posc);
+  
+  /* Two functions for the most common case: */
+  /* Create a slice containing elements between indices _from and
+     _to in the _list.
+
+     See mu_list_intersect_dup for a description of _dup_item and
+     _dup_data */
+int mu_list_slice2_dup (mu_list_t *_pdest, mu_list_t _list,
+			size_t _from, size_t _to,
+			int (*_dup_item) (void **, void *, void *),
+			void *_dup_data);
+  /* Same as mu_list_slice2_dup with _dup_item=NULL */
+int mu_list_slice2 (mu_list_t *_pdest, mu_list_t _list,
+                    size_t _from, size_t _to);
+  
 
   /* ************************************************* */
   /* List mapper functions                             */
diff --git a/libmailutils/list/Makefile.am b/libmailutils/list/Makefile.am
index 0ed2480..6d46fde 100644
--- a/libmailutils/list/Makefile.am
+++ b/libmailutils/list/Makefile.am
@@ -39,7 +39,9 @@ liblist_la_SOURCES = \
  remove.c\
  replace.c\
  setcomp.c\
- setdestr.c
+ setdestr.c\
+ slice.c\
+ slice2.c
 
 INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
 
diff --git a/libmailutils/list/slice.c b/libmailutils/list/slice.c
new file mode 100644
index 0000000..1d4f81e
--- /dev/null
+++ b/libmailutils/list/slice.c
@@ -0,0 +1,125 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <mailutils/list.h>
+#include <mailutils/sys/list.h>
+
+struct slice_info
+{
+  size_t cur;
+  size_t *posv;
+  size_t posc;
+  size_t idx;
+  int (*dup_item) (void **, void *, void *);
+  void *dup_data;
+  int err;
+};
+
+static int
+_slice_mapper (void **itmv, size_t itmc, void *call_data)
+{
+  struct slice_info *si = call_data;
+  size_t cur = si->cur++;
+
+  while (1)
+    {
+      if (cur < si->posv[si->idx])
+	return MU_LIST_MAP_SKIP;
+      if (si->idx + 1 < si->posc && cur > si->posv[si->idx + 1])
+	{
+	  si->idx += 2;
+	  if (si->idx >= si->posc)
+	    return MU_LIST_MAP_STOP|MU_LIST_MAP_SKIP;
+	}
+      else
+	break;
+    }
+  
+  if (si->dup_item && itmv[0])
+    {
+      void *p;
+      int rc = si->dup_item (&p, itmv[0], si->dup_data);
+      if (rc)
+	{
+	  si->err = rc;
+	  return MU_LIST_MAP_STOP|MU_LIST_MAP_SKIP;
+	}
+      itmv[0] = p;
+    }
+  return MU_LIST_MAP_OK;
+}
+
+static int
+poscmp (const void *a, const void *b)
+{
+  size_t posa = *(size_t*)a;
+  size_t posb = *(size_t*)b;
+
+  if (posa < posb)
+    return -1;
+  else if (posa > posb)
+    return 1;
+  return 0;
+}
+
+int
+mu_list_slice_dup (mu_list_t *pdest, mu_list_t list, size_t *posv, size_t posc,
+		   int (*dup_item) (void **, void *, void *),
+		   void *dup_data)
+{
+  int rc;
+  struct slice_info si;
+  mu_list_t dest;
+  
+  si.cur = 0;
+  si.idx = 0;
+  si.posv = posv;
+  si.posc = posc;
+  si.dup_item = dup_item;
+  si.dup_data = dup_data;
+  si.err = 0;
+
+  qsort (posv, posc, sizeof (posv[0]), poscmp);
+  
+  rc = mu_list_map (list, _slice_mapper, &si, 1, &dest);
+
+  if (rc == 0)
+    {
+      if (si.err)
+	{
+	  mu_list_destroy (&dest);
+	  rc = si.err;
+	}
+      else
+	{
+	  if (dup_item)
+	    mu_list_set_destroy_item (dest, list->destroy_item);
+	  *pdest = dest;
+	}
+    }
+  return rc;
+}
+
+int
+mu_list_slice (mu_list_t *pdest, mu_list_t list, size_t *posv, size_t posc)
+{
+  return mu_list_slice_dup (pdest, list, posv, posc, NULL, NULL);
+}
diff --git a/libmailutils/sockaddr/free.c b/libmailutils/list/slice2.c
similarity index 65%
copy from libmailutils/sockaddr/free.c
copy to libmailutils/list/slice2.c
index 2a31ec3..4a757b9 100644
--- a/libmailutils/sockaddr/free.c
+++ b/libmailutils/list/slice2.c
@@ -18,33 +18,25 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-
 #include <stdlib.h>
-#include <mailutils/sockaddr.h>
-
-void
-mu_sockaddr_free (struct mu_sockaddr *addr)
+#include <mailutils/list.h>
+#include <mailutils/sys/list.h>
+
+int
+mu_list_slice2_dup (mu_list_t *pdest, mu_list_t list,
+		    size_t from, size_t to,
+		    int (*dup_item) (void **, void *, void *),
+		    void *dup_data)
 {
-  if (!addr)
-    return;
-  free (addr->addr);
-  free (addr->str);
+  size_t arr[2] = { from, to };
+  return mu_list_slice_dup (pdest, list, arr, 2, dup_item, dup_data);
 }
 
-void
-mu_sockaddr_free_list (struct mu_sockaddr *addr)
+int
+mu_list_slice2 (mu_list_t *pdest, mu_list_t list, size_t from, size_t to)
 {
-  if (!addr)
-    return;
-  if (addr->prev)
-    addr->prev->next = NULL;
-  while (addr)
-    {
-      struct mu_sockaddr *next = addr->next;
-      mu_sockaddr_free (addr);
-      addr = next;
-    }
+  return mu_list_slice2_dup (pdest, list, from, to, NULL, NULL);
 }
 
 
-    
+  
diff --git a/libmailutils/tests/list.at b/libmailutils/tests/list.at
index f32249f..c2a39cc 100644
--- a/libmailutils/tests/list.at
+++ b/libmailutils/tests/list.at
@@ -323,7 +323,60 @@ to
 ])
 
 m4_popdef([MU_TEST_KEYWORDS])
+
+# ------------------------------------------------------------
+# Slices
+# ------------------------------------------------------------
+
+m4_define([MU_TEST_GROUP],[Slice])
+m4_pushdef([MU_TEST_KEYWORDS],MU_TEST_KEYWORDS[ slice])
+
+TESTLIST([one limit],[],
+[add null en to tre fire
+slice 3
+],
+[# items: 2
+tre
+fire
+])
+
+TESTLIST([two limits],[],
+[add null en to tre fire fem seks syv atte ni ti
+slice 4 7
+],
+[# items: 4
+fire
+fem
+seks
+syv
+])
 
+TESTLIST([four limits],[],
+[add null en to tre fire fem seks syv atte ni ti
+slice 4 6 9 10
+],
+[# items: 5
+fire
+fem
+seks
+ni
+ti
+])
+
+TESTLIST([four limits unsorted],[],
+[add null en to tre fire fem seks syv atte ni ti
+slice 10 6 9 4 
+],
+[# items: 5
+fire
+fem
+seks
+ni
+ti
+])
+
+m4_popdef([MU_TEST_KEYWORDS])
+
 dnl ------------------------------------------------------------
 dnl Cleanup
 m4_popdef([TESTLIST])
diff --git a/libmailutils/tests/listop.c b/libmailutils/tests/listop.c
index fceec54..a71de9e 100644
--- a/libmailutils/tests/listop.c
+++ b/libmailutils/tests/listop.c
@@ -619,6 +619,71 @@ map (mu_list_t *plist, int argc, char **argv)
   return 0;
 }
 
+static int
+dup_string (void **res, void *itm, void *closure)
+{
+  *res = strdup (itm);
+  return *res ? 0 : ENOMEM;
+}
+
+int
+slice (mu_list_t *plist, int argc, char **argv)
+{
+  mu_list_t list = *plist;
+  mu_list_t result;
+  int rc, i;
+  int replace = 0;
+  size_t *buf;
+  
+  argc--;
+  argv++;
+  
+  if (argc > 0 && strcmp (argv[0], "-replace") == 0)
+    {
+      replace = 1;
+      argc--;
+      argv++;
+    }
+  
+  if (argc < 1)
+    {
+      fprintf (stderr, "slice [-replace] num [num...]\n");
+      return 0;
+    }
+
+  buf = calloc (argc, sizeof (buf[0]));
+  if (!buf)
+    abort ();
+  for (i = 0; i < argc; i++)
+    buf[i] = atoi (argv[i]);
+
+  rc = mu_list_slice_dup (&result, list, buf, argc,
+			  dup_string, NULL);
+  if (rc)
+    {
+      mu_error ("slice failed: %s", mu_strerror (rc));
+      return 0;
+    }
+  if (replace)
+    {
+      size_t count[2];
+      mu_list_count (list, &count[0]);
+      mu_list_count (result, &count[1]);
+      
+      printf ("%lu in, %lu out\n", (unsigned long) count[0],
+	      (unsigned long) count[1]);
+      mu_list_destroy (&list);
+      *plist = result;
+      return 1;
+    }
+  else
+    {
+      print (result);
+      mu_list_destroy (&result);
+    }
+  return 0;  
+}
+
 void
 help ()
 {
@@ -637,8 +702,9 @@ help ()
   printf ("ictl repl item\n");
   printf ("ictl ins item [item*]\n");
   printf ("ictl dir [backwards|forwards]\n");
-  printf ("map NAME [ARGS]\n");
+  printf ("map [-replace] NAME [ARGS]\n");
   printf ("print\n");
+  printf ("slice [-replace] num [num...]\n");
   printf ("quit\n");
   printf ("iter num\n");
   printf ("help\n");
@@ -717,6 +783,14 @@ shell (mu_list_t list)
 		for (i = 0; i < NITR; i++)
 		  mu_iterator_destroy (&itr[i]);
 	    }
+	  else if (strcmp (ws.ws_wordv[0], "slice") == 0)
+	    {
+	      int i;
+	      
+	      if (slice (&list, ws.ws_wordc, ws.ws_wordv))
+		for (i = 0; i < NITR; i++)
+		  mu_iterator_destroy (&itr[i]);
+	    }
 	  else if (strcmp (ws.ws_wordv[0], "quit") == 0)
 	    return;
 	  else if (strcmp (ws.ws_wordv[0], "iter") == 0)


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 21 03:10:39 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RSOxb-00042e-2E
	for mharc-commit-mailutils@gnu.org; Mon, 21 Nov 2011 03:10:39 -0500
Received: from eggs.gnu.org ([140.186.70.92]:34559)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSOxY-00042Y-1O
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 03:10:37 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSOxW-0002W3-Fm
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 03:10:36 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56733)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSOxW-0002Vz-DC
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 03:10:34 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSOxV-0003pH-LJ
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 08:10:34 +0000
Date: Mon, 21 Nov 2011 08:10:33 +0000
Message-Id: <E1RSOxV-0003pH-LJ@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-456-gd220748
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c2dcdc0c950c030f96cabcafd9d860327bf02d71
X-Git-Newrev: d2207485610080f7f3c60b2a435c57fe5edb4ade
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 21 Nov 2011 08:10:37 -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=d2207485610080f7f3c60b2a435c57fe5edb4ade

The branch, master has been updated
       via  d2207485610080f7f3c60b2a435c57fe5edb4ade (commit)
      from  c2dcdc0c950c030f96cabcafd9d860327bf02d71 (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 d2207485610080f7f3c60b2a435c57fe5edb4ade
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Nov 20 14:12:22 2011 +0200

    wordsplit: implement separate single- and double-quote parsing.
    
    * include/mailutils/wordsplit.h (MU_WRDSF_SQUOTE,MU_WRDSF_DQUOTE): New flags.
    (MU_WRDSF_QUOTE): Redefine as an OR of the above two.
    * libmailutils/string/wordsplit.c (scan_word): Treat '\'' and '"'
    separately, depending on the flags.
    * libmailutils/tests/wsp.c: Add squote and dquote options.
    * libmailutils/tests/wordsplit.at: Test separate quoting support.

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

Summary of changes:
 include/mailutils/wordsplit.h   |   64 +++++++++++++++++++++-----------------
 libmailutils/string/wordsplit.c |    3 +-
 libmailutils/tests/wordsplit.at |   18 +++++++++++
 libmailutils/tests/wsp.c        |    2 +
 4 files changed, 57 insertions(+), 30 deletions(-)

diff --git a/include/mailutils/wordsplit.h b/include/mailutils/wordsplit.h
index 0ce33a3..5129121 100644
--- a/include/mailutils/wordsplit.h
+++ b/include/mailutils/wordsplit.h
@@ -46,73 +46,79 @@ struct mu_wordsplit
   struct mu_wordsplit_node *ws_head, *ws_tail;
 };
 
-/* Append  the words found to the array resulting from a previous
+/* Wordsplit flags.  Only 3 bits of a 32-bit word remain unused.
+   It is getting crowded... */
+/* Append the words found to the array resulting from a previous
    call. */
-#define MU_WRDSF_APPEND            0x0000001
+#define MU_WRDSF_APPEND            0x00000001
 /* Insert we_offs initial NULLs in the array ws_wordv.
    (These are not counted in the returned ws_wordc.) */
-#define MU_WRDSF_DOOFFS            0x0000002
+#define MU_WRDSF_DOOFFS            0x00000002
 /* Don't do command substitution. Reserved for future use. */
-#define MU_WRDSF_NOCMD             0x0000004
+#define MU_WRDSF_NOCMD             0x00000004
 /* The parameter p resulted from a previous call to
    mu_wordsplit(), and mu_wordsplit_free() was not called. Reuse the
    allocated storage. */
-#define MU_WRDSF_REUSE             0x0000008
+#define MU_WRDSF_REUSE             0x00000008
 /* Print errors */
-#define MU_WRDSF_SHOWERR           0x0000010
+#define MU_WRDSF_SHOWERR           0x00000010
 /* Consider it an error if an undefined shell variable
    is expanded. */
-#define MU_WRDSF_UNDEF             0x0000020
+#define MU_WRDSF_UNDEF             0x00000020
 
 /* Don't do variable expansion. */
-#define MU_WRDSF_NOVAR             0x0000040
+#define MU_WRDSF_NOVAR             0x00000040
 /* Abort on ENOMEM error */
-#define MU_WRDSF_ENOMEMABRT        0x0000080
+#define MU_WRDSF_ENOMEMABRT        0x00000080
 /* Trim off any leading and trailind whitespace */
-#define MU_WRDSF_WS                0x0000100
+#define MU_WRDSF_WS                0x00000100
+/* Handle single quotes */
+#define MU_WRDSF_SQUOTE            0x00000200
+/* Handle double quotes */
+#define MU_WRDSF_DQUOTE            0x00000400
 /* Handle quotes and escape directives */
-#define MU_WRDSF_QUOTE             0x0000200
+#define MU_WRDSF_QUOTE             (MU_WRDSF_SQUOTE|MU_WRDSF_DQUOTE)
 /* Replace each input sequence of repeated delimiters with a single
    delimiter */
-#define MU_WRDSF_SQUEEZE_DELIMS    0x0000400
+#define MU_WRDSF_SQUEEZE_DELIMS    0x00000800
 /* Return delimiters */
-#define MU_WRDSF_RETURN_DELIMS     0x0000800
+#define MU_WRDSF_RETURN_DELIMS     0x00001000
 /* Treat sed expressions as words */
-#define MU_WRDSF_SED_EXPR          0x0001000
+#define MU_WRDSF_SED_EXPR          0x00002000
 /* ws_delim field is initialized */
-#define MU_WRDSF_DELIM             0x0002000
+#define MU_WRDSF_DELIM             0x00004000
 /* ws_comment field is initialized */
-#define MU_WRDSF_COMMENT           0x0004000
+#define MU_WRDSF_COMMENT           0x00008000
 /* ws_alloc_die field is initialized */
-#define MU_WRDSF_ALLOC_DIE         0x0008000
+#define MU_WRDSF_ALLOC_DIE         0x00010000
 /* ws_error field is initialized */
-#define MU_WRDSF_ERROR             0x0010000
+#define MU_WRDSF_ERROR             0x00020000
 /* ws_debug field is initialized */
-#define MU_WRDSF_DEBUG             0x0020000
+#define MU_WRDSF_DEBUG             0x00040000
 /* ws_env field is initialized */
-#define MU_WRDSF_ENV               0x0040000
+#define MU_WRDSF_ENV               0x00080000
 /* ws_getvar field is initialized */
-#define MU_WRDSF_GETVAR            0x0080000
+#define MU_WRDSF_GETVAR            0x00100000
 /* enable debugging */
-#define MU_WRDSF_SHOWDBG           0x0100000
+#define MU_WRDSF_SHOWDBG           0x00200000
 /* Don't split input into words.  Useful for side effects. */
-#define MU_WRDSF_NOSPLIT           0x0200000
+#define MU_WRDSF_NOSPLIT           0x00400000
 /* Keep undefined variables in place, instead of expanding them to
    empty string */
-#define MU_WRDSF_KEEPUNDEF         0x0400000
+#define MU_WRDSF_KEEPUNDEF         0x00800000
 /* Warn about undefined variables */
-#define MU_WRDSF_WARNUNDEF         0x0800000
+#define MU_WRDSF_WARNUNDEF         0x01000000
 /* Handle C escapes */
-#define MU_WRDSF_CESCAPES          0x1000000
+#define MU_WRDSF_CESCAPES          0x02000000
 
 /* ws_closure is set */
-#define MU_WRDSF_CLOSURE           0x2000000
+#define MU_WRDSF_CLOSURE           0x04000000
 /* ws_env is a Key/Value environment, i.e. the value of a variable is
    stored in the element that follows its name. */
-#define MU_WRDSF_ENV_KV            0x4000000
+#define MU_WRDSF_ENV_KV            0x08000000
 
 /* ws_escape is set */
-#define MU_WRDSF_ESCAPE            0x8000000
+#define MU_WRDSF_ESCAPE            0x10000000
 
 #define MU_WRDSF_DEFFLAGS	       \
   (MU_WRDSF_NOVAR | MU_WRDSF_NOCMD | \
diff --git a/libmailutils/string/wordsplit.c b/libmailutils/string/wordsplit.c
index 4536cc2..a15b975 100644
--- a/libmailutils/string/wordsplit.c
+++ b/libmailutils/string/wordsplit.c
@@ -1115,7 +1115,8 @@ scan_word (struct mu_wordsplit *wsp, size_t start)
 		  continue;
 		}
 
-	      if (command[i] == '\'' || command[i] == '"')
+	      if (((wsp->ws_flags & MU_WRDSF_SQUOTE) && command[i] == '\'') ||
+		  ((wsp->ws_flags & MU_WRDSF_DQUOTE) && command[i] == '"'))
 		{
 		  if (join && wsp->ws_tail)
 		    wsp->ws_tail->flags |= _WSNF_JOIN;
diff --git a/libmailutils/tests/wordsplit.at b/libmailutils/tests/wordsplit.at
index 99b0dcb..ca43789 100644
--- a/libmailutils/tests/wordsplit.at
+++ b/libmailutils/tests/wordsplit.at
@@ -355,4 +355,22 @@ TESTWSP([unescape],[],[-default novar nocmd quote escape '\"'],
 2: "bs \\"
 ])
 
+TESTWSP([dquote],[],[-default novar nocmd dquote],
+[a "quoted example" isn't it],
+[NF: 4
+0: a
+1: "quoted example"
+2: isn't
+3: it
+])
+
+TESTWSP([squote],[],[-default novar nocmd squote],
+[a 'quoted example' isn"t it],
+[NF: 4
+0: a
+1: "quoted example"
+2: "isn\"t"
+3: it
+])
+
 m4_popdef([TESTWSP])
diff --git a/libmailutils/tests/wsp.c b/libmailutils/tests/wsp.c
index 47cd4ff..5af17be 100644
--- a/libmailutils/tests/wsp.c
+++ b/libmailutils/tests/wsp.c
@@ -37,6 +37,8 @@ struct mu_kwd bool_keytab[] = {
   { "nocmd",  MU_WRDSF_NOCMD },
   { "ws",     MU_WRDSF_WS },
   { "quote",  MU_WRDSF_QUOTE },
+  { "squote", MU_WRDSF_SQUOTE },
+  { "dquote", MU_WRDSF_DQUOTE },
   { "squeeze_delims", MU_WRDSF_SQUEEZE_DELIMS },
   { "return_delims",  MU_WRDSF_RETURN_DELIMS },
   { "sed",     MU_WRDSF_SED_EXPR },


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 21 12:38:31 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RSXp9-0006ho-2R
	for mharc-commit-mailutils@gnu.org; Mon, 21 Nov 2011 12:38:31 -0500
Received: from eggs.gnu.org ([140.186.70.92]:45027)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSXp1-0006gU-JY
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 12:38:28 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSXov-0002rT-Or
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 12:38:23 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:48994)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSXov-0002rO-Kv
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 12:38:17 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSXot-0000Ob-RR
	for commit-mailutils@gnu.org; Mon, 21 Nov 2011 17:38:17 +0000
Date: Mon, 21 Nov 2011 17:38:16 +0000
Message-Id: <E1RSXot-0000Ob-RR@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-458-gc6ed0db
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d2207485610080f7f3c60b2a435c57fe5edb4ade
X-Git-Newrev: c6ed0dbaefd47e4eb961162e6ed103b143f73929
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 21 Nov 2011 17:38:28 -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=c6ed0dbaefd47e4eb961162e6ed103b143f73929

The branch, master has been updated
       via  c6ed0dbaefd47e4eb961162e6ed103b143f73929 (commit)
       via  a9e36974c11d4a4c429867a63bc0814917985089 (commit)
      from  d2207485610080f7f3c60b2a435c57fe5edb4ade (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 c6ed0dbaefd47e4eb961162e6ed103b143f73929
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 21 15:07:13 2011 +0200

    Version 2.99.95

commit a9e36974c11d4a4c429867a63bc0814917985089
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 21 14:58:23 2011 +0200

    libmu_dbm: Functions for DB creation take default safety flags in their last argument.
    
    * configure.ac (check_dbm_impl): Fix improper usage of expr in BDB=* case.
    * include/mailutils/dbm.h (mu_dbm_create_from_url)
    (mu_dbm_create): Take default safety flags as the last argument.
    * libmailutils/base/filesafety.c (_check_linkwrdir): Check for both
    hard and symbolic links.  Fix the latter check.
    * libmailutils/tests/fsaf.at: Add check for softlink in a writable dir.
    * libmu_dbm/create.c (mu_dbm_create): Take default file safety as the
    last argument.
    * libmu_dbm/dbm.c (mu_dbm_create_from_url): Likewise.
    * maidag/mailquota.c (dbm_retrieve_quota): Update call to mu_dbm_create.
    Impose MU_FILE_SAFETY_ALL by default.
    * mu/dbm.c (open_db_file): Update call to mu_dbm_create.  No checks
    by default.
    * pop3d/apop.c (pop3d_apopuser): Update call to mu_dbm_create.  Use
    apop_database_safety as the default checks.
    * pop3d/bulletin.c (read_bulletin_db,write_bulletin_db): Update calls to
    mu_dbm_create.  Use DEFAULT_GROUP_DB_SAFETY as default.
    * pop3d/logindelay.c (open_stat_db): Update call to mu_dbm_create.
    Use DEFAULT_GROUP_DB_SAFETY as default.
    * pop3d/pop3d.c (apop_database_safety): Initialize to MU_FILE_SAFETY_ALL.
    (apop_database_safety_set): Remove.
    * pop3d/pop3d.h (apop_database_safety_set): Remove.
    * pop3d/popauth.c (open_db_file): Update call to mu_dbm_create.  Use
    safety_flags by default.

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

Summary of changes:
 NEWS                           |    8 ++------
 configure.ac                   |    4 ++--
 include/mailutils/dbm.h        |    4 ++--
 libmailutils/base/filesafety.c |    7 ++++---
 libmailutils/tests/fsaf.at     |    9 +++++++++
 libmu_dbm/create.c             |    4 ++--
 libmu_dbm/dbm.c                |   10 +++++++---
 maidag/mailquota.c             |    2 +-
 mu/dbm.c                       |    2 +-
 pop3d/apop.c                   |    5 +----
 pop3d/bulletin.c               |    6 ++----
 pop3d/logindelay.c             |    4 +---
 pop3d/pop3d.c                  |    4 +---
 pop3d/pop3d.h                  |    1 -
 pop3d/popauth.c                |   20 +++++++++-----------
 15 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/NEWS b/NEWS
index 7c974dc..bbdf090 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2011-11-06
+GNU mailutils NEWS -- history of user-visible changes. 2011-11-21
 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 Free Software Foundation, Inc.
 See the end of file for copying conditions.
@@ -6,7 +6,7 @@ See the end of file for copying conditions.
 Please send mailutils bug reports to <bug-mailutils@gnu.org>.
 
 
-Version 2.99.94 (Git)
+Version 2.99.95 (Git)
 
 This version is a major rewrite of GNU Mailutils.  Quite a few parts
 of the basic framework were rewritten from scratch, while some others
@@ -25,7 +25,6 @@ experimental.  Not currently implemented are:
 
  - imap client
  - nntp client
- - Tokyocabinet support
  
 Experimental features are:
 
@@ -146,9 +145,6 @@ It is normally not needed to specify --with-gdbm, --with-berkeley-db
 or --with-ndbm explicitly.  Configuration will automatically pick up
 all available DBM libraries it can use.
 
-The Tokyocabinet support (--with-tokyocabinet) is temporarily not
-available.
-
 ** Imap and nntp clients are not yet implemented
 
 ** Experimental features
diff --git a/configure.ac b/configure.ac
index f28c42b..ca89212 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ dnl You should have received a copy of the GNU General Public License along
 dnl with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
 AC_PREREQ(2.63)
-AC_INIT([GNU Mailutils], [2.99.94], [bug-mailutils@gnu.org], [mailutils])
+AC_INIT([GNU Mailutils], [2.99.95], [bug-mailutils@gnu.org], [mailutils])
 AC_CONFIG_SRCDIR([libmailutils/mailbox/mailbox.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([gnits 1.11 dist-bzip2 dist-xz std-options silent-rules])
@@ -518,7 +518,7 @@ check_dbm_impl() {
 	  done;;
 
   BDB=*)
-	  name=`expr $use_dbm : 'BDB=\(.*\)'`
+	  name=`expr $1 : 'BDB=\(.*\)'`
   	  case $name in
 	  [[0-9]]*)  check_slackware_bdb $name;;
 	  *)	     for version in 4 3 2
diff --git a/include/mailutils/dbm.h b/include/mailutils/dbm.h
index ad04359..b651345 100644
--- a/include/mailutils/dbm.h
+++ b/include/mailutils/dbm.h
@@ -53,8 +53,8 @@ void mu_dbm_init (void);
 mu_url_t mu_dbm_get_hint (void);
 
 int mu_dbm_register (struct mu_dbm_impl *impl);
-int mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db);
-int mu_dbm_create (char *name, mu_dbm_file_t *db);
+int mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db, int defsafety);
+int mu_dbm_create (char *name, mu_dbm_file_t *db, int defsafety);
 int mu_dbm_close (mu_dbm_file_t db);
 void mu_dbm_datum_free (struct mu_dbm_datum *datum);
 int mu_dbm_delete (mu_dbm_file_t db, struct mu_dbm_datum const *key);
diff --git a/libmailutils/base/filesafety.c b/libmailutils/base/filesafety.c
index ca075b4..262f194 100644
--- a/libmailutils/base/filesafety.c
+++ b/libmailutils/base/filesafety.c
@@ -68,8 +68,9 @@ _check_awrfil (struct file_check_buffer *fb)
 static int
 _check_linkwrdir (struct file_check_buffer *fb)
 {
-  return (fb->filst.st_mode & S_IFLNK) &&
-         (fb->dirst.st_mode & (S_IWGRP | S_IWOTH));
+  return ((((fb->filst.st_mode & S_IFMT) == S_IFLNK) ||
+	   fb->filst.st_nlink > 1) &&
+	  (fb->dirst.st_mode & (S_IWGRP | S_IWOTH)));
 }
 
 static int
@@ -199,7 +200,7 @@ mu_file_safety_check (const char *filename, int mode,
   if (!filename)
     return EFAULT;
   memset (&buf, 0, sizeof (buf));
-  if (stat (filename, &buf.filst) == 0)
+  if (lstat (filename, &buf.filst) == 0)
     {
       struct safety_checker *pck;
 
diff --git a/libmailutils/tests/fsaf.at b/libmailutils/tests/fsaf.at
index 3d6b530..d27364c 100644
--- a/libmailutils/tests/fsaf.at
+++ b/libmailutils/tests/fsaf.at
@@ -59,6 +59,15 @@ ln ../data file
 ],
 [Linked file in a writable directory])
 
+FSAFCODE([+linkwrdir],
+[mkdir dir
+chmod g+w dir
+> data
+cd dir
+ln -s ../data file
+],
+[Linked file in a writable directory])
+
 FSAFCODE([+awrdir],
 [mkdir dir
 chmod o+w dir
diff --git a/libmu_dbm/create.c b/libmu_dbm/create.c
index b3e9340..44c161d 100644
--- a/libmu_dbm/create.c
+++ b/libmu_dbm/create.c
@@ -29,7 +29,7 @@
 #include "mudbm.h"
 
 int
-mu_dbm_create (char *name, mu_dbm_file_t *db)
+mu_dbm_create (char *name, mu_dbm_file_t *db, int defsafety)
 {
   int rc;
   mu_url_t url;
@@ -38,7 +38,7 @@ mu_dbm_create (char *name, mu_dbm_file_t *db)
   rc = mu_url_create_hint (&url, name, 0, mu_dbm_hint);
   if (rc)
     return rc;
-  rc = mu_dbm_create_from_url (url, db);
+  rc = mu_dbm_create_from_url (url, db, defsafety);
   mu_url_destroy (&url);
   return rc;
 }
diff --git a/libmu_dbm/dbm.c b/libmu_dbm/dbm.c
index 80df67a..2f3256c 100644
--- a/libmu_dbm/dbm.c
+++ b/libmu_dbm/dbm.c
@@ -132,7 +132,7 @@ mu_dbm_register (struct mu_dbm_impl *impl)
 }
 
 int
-mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
+mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db, int defsafety)
 {
   mu_dbm_file_t p;
   int flags;
@@ -142,6 +142,7 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
   struct mu_dbm_impl *impl;
   struct mu_auth_data *auth;
   int safety_flags = 0;
+  int safety_flags_set = 0;
   uid_t owner_uid = getuid ();
 
   mu_dbm_init ();
@@ -183,7 +184,8 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
 	    }
 	  else if (*name == '+')
 	    name++;
-
+	  
+	  safety_flags_set = 1;
 	  if (strncmp (name, "owner", 5) == 0)
 	    {
 	      val = MU_FILE_SAFETY_OWNER_MISMATCH;
@@ -243,7 +245,8 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db)
       free (p);
       return ENOMEM;
     }
-  p->db_safety_flags = safety_flags;
+
+  p->db_safety_flags = safety_flags_set ? safety_flags : defsafety;
   p->db_owner = owner_uid;
   p->db_sys = impl;
 
@@ -257,3 +260,4 @@ mu_dbm_impl_iterator (mu_iterator_t *itr)
   mu_dbm_init ();
   return mu_list_get_iterator (implist, itr);
 }
+
diff --git a/maidag/mailquota.c b/maidag/mailquota.c
index 216cc11..de14368 100644
--- a/maidag/mailquota.c
+++ b/maidag/mailquota.c
@@ -77,7 +77,7 @@ dbm_retrieve_quota (char *name, mu_off_t *quota)
   if (!quotadbname)
     return RETR_FAILURE;
 
-  rc = mu_dbm_create (quotadbname, &db);
+  rc = mu_dbm_create (quotadbname, &db, MU_FILE_SAFETY_ALL);
   if (rc)
     {
       mu_error (_("unable to create quota db"));
diff --git a/mu/dbm.c b/mu/dbm.c
index 1408d58..212768d 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -106,7 +106,7 @@ open_db_file (int mode)
       exit (EX_USAGE);
     }
   
-  rc = mu_dbm_create (db_name, &db);
+  rc = mu_dbm_create (db_name, &db, 0);
   if (rc)
     {
       mu_diag_output (MU_DIAG_ERROR, _("unable to create database %s: %s"),
diff --git a/pop3d/apop.c b/pop3d/apop.c
index ac9fbd7..5f27ff8 100644
--- a/pop3d/apop.c
+++ b/pop3d/apop.c
@@ -50,16 +50,13 @@ pop3d_apopuser (const char *user)
     mu_dbm_file_t db;
     struct mu_dbm_datum key, data;
 
-    rc = mu_dbm_create (apop_database_name, &db);
+    rc = mu_dbm_create (apop_database_name, &db, apop_database_safety);
     if (rc)
       {
 	mu_diag_output (MU_DIAG_ERROR, _("unable to create APOP db"));
 	return NULL;
       }
 
-    if (apop_database_safety_set)
-      mu_dbm_safety_set_flags (db, apop_database_safety);
-    
     rc = mu_dbm_safety_check (db);
     if (rc)
       {
diff --git a/pop3d/bulletin.c b/pop3d/bulletin.c
index 47efe61..5efd777 100644
--- a/pop3d/bulletin.c
+++ b/pop3d/bulletin.c
@@ -126,7 +126,7 @@ read_bulletin_db (size_t *pnum)
   size_t s;
   char *p;
 
-  rc = mu_dbm_create (bulletin_db_name, &db);
+  rc = mu_dbm_create (bulletin_db_name, &db, DEFAULT_GROUP_DB_SAFETY);
   if (rc)
     {
       mu_diag_output (MU_DIAG_ERROR, _("unable to create bulletin db"));
@@ -220,15 +220,13 @@ write_bulletin_db (size_t num)
   int rc;
   const char *p;
   
-  rc = mu_dbm_create (bulletin_db_name, &db);
+  rc = mu_dbm_create (bulletin_db_name, &db, DEFAULT_GROUP_DB_SAFETY);
   if (rc)
     {
       mu_diag_output (MU_DIAG_ERROR, _("unable to create bulletin db"));
       return rc;
     }
 
-  mu_dbm_safety_set_flags (db, DEFAULT_GROUP_DB_SAFETY);
-
   rc = mu_dbm_safety_check (db);
   if (rc && rc != ENOENT)
     {
diff --git a/pop3d/logindelay.c b/pop3d/logindelay.c
index f61d6d2..1fc93d1 100644
--- a/pop3d/logindelay.c
+++ b/pop3d/logindelay.c
@@ -25,15 +25,13 @@ open_stat_db (int mode)
   mu_dbm_file_t db;
   int rc;
 
-  rc = mu_dbm_create (login_stat_file, &db);
+  rc = mu_dbm_create (login_stat_file, &db, DEFAULT_GROUP_DB_SAFETY);
   if (rc)
     {
       mu_diag_output (MU_DIAG_ERROR, _("unable to create statistics db"));
       return NULL;
     }
 
-  mu_dbm_safety_set_flags (db, DEFAULT_GROUP_DB_SAFETY);
-  
   rc = mu_dbm_safety_check (db);
   if (rc && rc != ENOENT)
     {
diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c
index 2639bd6..776b059 100644
--- a/pop3d/pop3d.c
+++ b/pop3d/pop3d.c
@@ -33,8 +33,7 @@ int debug_mode;
 int tls_required;
 int pop3d_xlines;
 char *apop_database_name = APOP_PASSFILE;
-int apop_database_safety;
-int apop_database_safety_set;
+int apop_database_safety = MU_FILE_SAFETY_ALL;
 
 #ifdef WITH_TLS
 int tls_available;
@@ -92,7 +91,6 @@ cb2_file_safety_checks (const char *name, void *data)
 static int
 cb_apop_safety_checks (void *data, mu_config_value_t *arg)
 {
-  apop_database_safety_set = 1;
   return mu_cfg_string_value_cb (arg, cb2_file_safety_checks,
 				 &apop_database_safety);
 }
diff --git a/pop3d/pop3d.h b/pop3d/pop3d.h
index d61f248..978ab59 100644
--- a/pop3d/pop3d.h
+++ b/pop3d/pop3d.h
@@ -199,7 +199,6 @@ extern size_t pop3d_output_bufsize;
 extern int pop3d_xlines;
 extern char *apop_database_name;
 extern int apop_database_safety;
-extern int apop_database_safety_set;
 
 /* Safety checks for group-rw database files, such as stat and bulletin
    databases */
diff --git a/pop3d/popauth.c b/pop3d/popauth.c
index 8ae7c95..827116b 100644
--- a/pop3d/popauth.c
+++ b/pop3d/popauth.c
@@ -273,15 +273,6 @@ open_db_file (int action, struct action_data *ap, int *my_file)
 
   uid = getuid ();
 
-  rc = mu_dbm_create (db_name, &db);
-  if (rc)
-    {
-      mu_diag_output (MU_DIAG_ERROR, _("unable to create database %s: %s"),
-		      db_name, mu_strerror (rc));
-      exit (EX_SOFTWARE);
-    }
-
-  //  mu_dbm_safety_set_owner (db, uid);
   /* Adjust safety flags */
   if (permissions & 0002)
     safety_flags &= ~MU_FILE_SAFETY_WORLD_WRITABLE;
@@ -291,8 +282,15 @@ open_db_file (int action, struct action_data *ap, int *my_file)
     safety_flags &= ~MU_FILE_SAFETY_GROUP_WRITABLE;
   if (permissions & 0040)
     safety_flags &= ~MU_FILE_SAFETY_GROUP_READABLE;
-  
-  mu_dbm_safety_set_flags (db, safety_flags);
+
+  rc = mu_dbm_create (db_name, &db, safety_flags);
+  if (rc)
+    {
+      mu_diag_output (MU_DIAG_ERROR, _("unable to create database %s: %s"),
+		      db_name, mu_strerror (rc));
+      exit (EX_SOFTWARE);
+    }
+
   rc = mu_dbm_safety_check (db);
   if (rc && rc != ENOENT)
     {


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 22 08:08:58 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RSq5q-0004lg-BA
	for mharc-commit-mailutils@gnu.org; Tue, 22 Nov 2011 08:08:58 -0500
Received: from eggs.gnu.org ([140.186.70.92]:57978)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSq5f-0004lE-Ei
	for commit-mailutils@gnu.org; Tue, 22 Nov 2011 08:08:56 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSq5Y-0008Vo-Ov
	for commit-mailutils@gnu.org; Tue, 22 Nov 2011 08:08:47 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33120)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSq5Y-0008Vk-N8
	for commit-mailutils@gnu.org; Tue, 22 Nov 2011 08:08:40 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RSq5W-0001DB-4b
	for commit-mailutils@gnu.org; Tue, 22 Nov 2011 13:08:40 +0000
Date: Tue, 22 Nov 2011 13:08:39 +0000
Message-Id: <E1RSq5W-0001DB-4b@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-460-g00906d3
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c6ed0dbaefd47e4eb961162e6ed103b143f73929
X-Git-Newrev: 00906d3b3bcef1a948ceff6f27b6052e47081552
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 22 Nov 2011 13:08:56 -0000

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

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

The branch, master has been updated
       via  00906d3b3bcef1a948ceff6f27b6052e47081552 (commit)
       via  1b475f7ea7e8b2d6168622f9bc2dd95950179237 (commit)
      from  c6ed0dbaefd47e4eb961162e6ed103b143f73929 (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 00906d3b3bcef1a948ceff6f27b6052e47081552
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 22 13:06:33 2011 +0200

    Bugfixes.
    
    * libmu_dbm/dbm.c (mu_dbm_create_from_url): Parameter list beginning
    with a negative parameter implies default safety criteria.
    Fix semantics of the "default" keyword: it is different from "all".
    * libmu_dbm/mudbm.h (DEFAULT_DBM_SAFETY_FLAGS): Remove.  Not needed now.
    * pop3d/bulletin.c (read_bulletin_db): Remove a leftover call to
    mu_dbm_safety_set_flags.

commit 1b475f7ea7e8b2d6168622f9bc2dd95950179237
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 22 11:54:39 2011 +0200

    Implement new DBM dump format.
    
    The new format, called "C", allows programmers to create input data
    for use by mu load using conventional means.  It represents both key and
    content as C strings (hence its name), with usual C (literal and octal)
    escapes to represent non-printable characters.
    
    * mu/dbm.c (IOBUF_REREAD,IOBUF_EOF): New constants.
    (iobuf) <state>: New member.
    (input_eof): New macro.
    (input_getline): Use iobuf.state to detect EOF.
    (input_ungetline): Reset state only if it is 0.
    (format_tab): New format "C".
    (write_quoted_string,C_writer,C_read_datum)
    (C_reader): New functions to implement the C dump format.
    * libmailutils/tests/testsuite.at: Minor change.

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

Summary of changes:
 libmailutils/tests/testsuite.at |    2 +
 libmu_dbm/dbm.c                 |    5 +-
 libmu_dbm/mudbm.h               |    2 -
 mu/dbm.c                        |  203 +++++++++++++++++++++++++++++++++++---
 pop3d/bulletin.c                |    2 -
 5 files changed, 193 insertions(+), 21 deletions(-)

diff --git a/libmailutils/tests/testsuite.at b/libmailutils/tests/testsuite.at
index e29846b..893175d 100644
--- a/libmailutils/tests/testsuite.at
+++ b/libmailutils/tests/testsuite.at
@@ -76,6 +76,8 @@ m4_include([fromflt.at])
 m4_include([inline-comment.at])
 m4_include([hdrflt.at])
 m4_include([linecon.at])
+
+AT_BANNER(Debug Specification)
 m4_include([debugspec.at])
 
 m4_include([fsaf.at])
\ No newline at end of file
diff --git a/libmu_dbm/dbm.c b/libmu_dbm/dbm.c
index 2f3256c..8e76e0d 100644
--- a/libmu_dbm/dbm.c
+++ b/libmu_dbm/dbm.c
@@ -179,6 +179,9 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db, int defsafety)
 
 	  if (*name == '-')
 	    {
+	      if (!safety_flags_set)
+		/* Imply default safety settings */
+		safety_flags = defsafety;
 	      negate = 1;
 	      name++;
 	    }
@@ -224,7 +227,7 @@ mu_dbm_create_from_url (mu_url_t url, mu_dbm_file_t *db, int defsafety)
 	    }
 	  else if (strcmp (name, "default") == 0)
 	    {
-	      val = DEFAULT_DBM_SAFETY_FLAGS;
+	      val = defsafety;
 	    }
 	  else if (mu_file_safety_name_to_code (name, &val))
 	    return MU_ERR_URL_INVALID_PARAMETER;
diff --git a/libmu_dbm/mudbm.h b/libmu_dbm/mudbm.h
index b52ec21..5546c7c 100644
--- a/libmu_dbm/mudbm.h
+++ b/libmu_dbm/mudbm.h
@@ -28,8 +28,6 @@
     }								\
   while (0)
 
-#define DEFAULT_DBM_SAFETY_FLAGS MU_FILE_SAFETY_ALL
-
 #ifdef WITH_GDBM
 extern struct mu_dbm_impl _mu_dbm_gdbm;
 #endif
diff --git a/mu/dbm.c b/mu/dbm.c
index 212768d..72c1ab7 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -209,13 +209,16 @@ set_db_ownership (mu_dbm_file_t db)
 }
 
 
+#define IOBUF_REREAD 1
+#define IOBUF_EOF    2
+
 struct iobuf
 {
   mu_stream_t stream;
   char *buffer;
   size_t bufsize;
   size_t length;
-  int read;
+  int flag;            /* 0 or one of the IOBUF_ constants above. */
 };
 
 static int is_dbm_directive (struct iobuf *input);
@@ -224,15 +227,25 @@ static int is_ignored_directive (const char *name);
 static int set_directive (char *val);
 static void print_header (const char *name, mu_stream_t str);
 
+#define input_eof(iob) ((iob)->flag == IOBUF_EOF)
+
 static int
 input_getline (struct iobuf *inp)
 {
   int rc;
   size_t len;
 
-  if (inp->read)
+  switch (inp->flag)
     {
-      inp->read = 0;
+    case 0:
+      break;
+
+    case IOBUF_REREAD:
+      inp->flag = 0;
+      return 0;
+
+    case IOBUF_EOF:
+      inp->length = 0;
       return 0;
     }
   
@@ -243,6 +256,7 @@ input_getline (struct iobuf *inp)
 	return rc;
       if (len == 0)
 	{
+	  inp->flag = IOBUF_EOF;
 	  inp->length = 0;
 	  break;
 	}
@@ -270,7 +284,8 @@ input_getline (struct iobuf *inp)
 static void
 input_ungetline (struct iobuf *inp)
 {
-  inp->read = 1;
+  if (inp->flag == 0)
+    inp->flag = IOBUF_REREAD;
 }
 
 static size_t
@@ -298,6 +313,13 @@ static int ascii_writer (struct iobuf *, void *data,
 			 struct mu_dbm_datum const *key,
 			 struct mu_dbm_datum const *content);
 
+static int C_reader (struct iobuf *, void *data,
+		     struct mu_dbm_datum *key,
+		     struct mu_dbm_datum *content);
+static int C_writer (struct iobuf *, void *data,
+		     struct mu_dbm_datum const *key,
+		     struct mu_dbm_datum const *content);
+
 static void newfmt_init (struct xfer_format *fmt,
 			 const char *version, struct iobuf *iop, int wr);
 
@@ -309,14 +331,15 @@ static int newfmt_writer (struct iobuf *, void *data,
 			  struct mu_dbm_datum const *content);
 
 static struct xfer_format format_tab[] = {
+  { "C",   NULL, C_reader,     C_writer, NULL },
   { "0.0", NULL, ascii_reader, ascii_writer, NULL },
   { "1.0", newfmt_init, newfmt_reader, newfmt_writer, NULL },
   { NULL }
 };
 						     
-#define DEFAULT_LIST_FORMAT (&format_tab[0])
-#define DEFAULT_DUMP_FORMAT (&format_tab[1])
-#define DEFAULT_LOAD_FORMAT (&format_tab[0])
+#define DEFAULT_LIST_FORMAT (&format_tab[1])
+#define DEFAULT_DUMP_FORMAT (&format_tab[2])
+#define DEFAULT_LOAD_FORMAT (&format_tab[1])
 
 static struct xfer_format *format;
 static const char *dump_format_version;
@@ -405,8 +428,13 @@ ascii_reader (struct iobuf *inp, void *data MU_ARG_UNUSED,
       mu_error ("%s", mu_strerror (rc));
       return -1;
     }
-  if (input_length (inp) == 0)
+  if (input_eof (inp))
     return 1;
+  if (input_length (inp) == 0)
+    {
+      key->mu_dsize = 0;
+      return 0;
+    }
   kstr = mu_str_stripws (inp->buffer);
   val = mu_str_skip_class_comp (kstr, MU_CTYPE_SPACE);
   *val++ = 0;
@@ -424,6 +452,150 @@ ascii_reader (struct iobuf *inp, void *data MU_ARG_UNUSED,
   return 0;
 }  
 
+void
+write_quoted_string (mu_stream_t stream, char *str, size_t len)
+{
+  for (; len; str++, len--)
+    {
+      if (*str == '"')
+	{
+	  mu_stream_write (stream, "\\", 1, NULL);
+	  mu_stream_write (stream, str, 1, NULL);
+	}
+      else if (*str != '\t' && *str != '\\' && mu_isprint (*str))
+	mu_stream_write (stream, str, 1, NULL);
+      else
+	{
+	  int c = mu_wordsplit_c_quote_char (*str);
+
+	  mu_stream_write (stream, "\\", 1, NULL);
+	  if (c != -1)
+	    mu_stream_write (stream, str, 1, NULL);
+	  else
+	    mu_stream_printf (stream, "%03o", *(unsigned char *) str);
+	}
+    }
+}
+
+static int
+C_writer (struct iobuf *iop, void *data MU_ARG_UNUSED,
+	  struct mu_dbm_datum const *key,
+	  struct mu_dbm_datum const *content)
+{
+  write_quoted_string (iop->stream, key->mu_dptr, key->mu_dsize);
+  mu_stream_write (iop->stream, "\n", 1, NULL);
+  write_quoted_string (iop->stream, content->mu_dptr, content->mu_dsize);
+  mu_stream_write (iop->stream, "\n\n", 2, NULL);
+  return 0;
+}
+
+#define ISODIGIT(c) ((c) >= '0' && c < '8')
+#define OCTVAL(c) ((c) - '0')
+
+static int
+C_read_datum (struct iobuf *inp, struct mu_dbm_datum *datum)
+{
+  size_t i = 0;
+  char *base, *ptr;
+  size_t length;
+  int rc;
+  
+  free (datum->mu_dptr);
+  memset (datum, 0, sizeof (*datum));
+
+  rc = input_getline (inp);
+  if (rc)
+    {
+      mu_error ("%s", mu_strerror (rc));
+      return -1;
+    }
+  if (input_eof (inp))
+    return 1;
+  if ((length = input_length (inp)) == 0)
+    {
+      mu_error (_("empty line"));
+      return -1;
+    }
+
+  memset (datum, 0, sizeof (*datum));
+  datum->mu_dptr = ptr = xmalloc (length);
+  base = inp->buffer;
+  for (i = 0; i < length; ptr++)
+    {
+      if (base[i] == '\\')
+	{
+	  if (++i >= length)
+	    {
+	      mu_error (_("unfinished string"));
+	      return -1;
+	    }
+	  else if (ISODIGIT (base[i]))
+	    {
+	      unsigned c;
+
+	      if (i + 3 > length)
+		{
+		  mu_error (_("unfinished string"));
+		  return -1;
+		}
+	      c = OCTVAL (base[i]);
+	      c <<= 3;
+	      c |= OCTVAL (base[i + 1]);
+	      c <<= 3;
+	      c |= OCTVAL (base[i + 2]);
+	      *ptr = c;
+	      i += 3;
+	    }
+	  else
+	    {
+	      int c = mu_wordsplit_c_unquote_char (base[i]);
+	      if (c == -1)
+		{
+		  mu_error (_("invalid escape sequence (\\%c)"), base[i]);
+		  return -1;
+		}
+	      *ptr = c;
+	    }
+	}
+      else
+	*ptr = base[i++];
+    }
+  datum->mu_dsize = ptr - datum->mu_dptr;
+  return 0;
+}
+
+static int
+C_reader (struct iobuf *inp, void *data MU_ARG_UNUSED,
+	  struct mu_dbm_datum *key,
+	  struct mu_dbm_datum *content)
+{
+  int rc;
+
+  rc = C_read_datum (inp, key);
+  if (rc < 0)
+    exit (EX_DATAERR);
+  else if (rc == 1)
+    return 1;
+  
+  if (C_read_datum (inp, content))
+    exit (EX_DATAERR);
+
+  rc = input_getline (inp);
+  if (rc)
+    {
+      mu_error ("%s", mu_strerror (rc));
+      return -1;
+    }
+
+  if (input_length (inp) != 0)
+    {
+      mu_error (_("unrecognized line"));
+      return -1;
+    }
+
+  return 0;
+}  
+
 static void
 newfmt_init (struct xfer_format *fmt, const char *version,
 	     struct iobuf *iop, int wr)
@@ -465,15 +637,16 @@ newfmt_read_datum (struct iobuf *iop, mu_opool_t pool,
   unsigned char *ptr, *out;
   size_t len;
 
-  mu_dbm_datum_free (datum);
-  
+  free (datum->mu_dptr);
+  memset (datum, 0, sizeof (*datum));
+	  
   rc = input_getline (iop);
   if (rc)
     {
       mu_error ("%s", mu_strerror (rc));
       exit (EX_IOERR);
     }
-  if (iop->length == 0)
+  if (input_eof (iop))
     return 1;
   
   if (!is_len_directive (iop))
@@ -505,7 +678,7 @@ newfmt_read_datum (struct iobuf *iop, mu_opool_t pool,
 	  mu_error ("%s", mu_strerror (rc));
 	  exit (EX_IOERR);
 	}
-      if (iop->length == 0)
+      if (input_eof (iop))
 	break;
       if (is_len_directive (iop))
 	{
@@ -524,8 +697,6 @@ newfmt_read_datum (struct iobuf *iop, mu_opool_t pool,
       exit (EX_SOFTWARE);
     }
 
-  mu_dbm_datum_free (datum);
-  
   datum->mu_dptr = (void*) out;
   return 0;
 }
@@ -559,7 +730,7 @@ newfmt_write_datum (struct iobuf *iop, struct mu_dbm_datum const *datum)
       exit (EX_SOFTWARE);
     }
   mu_stream_write (iop->stream, iop->buffer, iop->bufsize, NULL);
-  free (iop->buffer); // FIXME
+  free (iop->buffer); /* FIXME */
   mu_stream_write (iop->stream, "\n", 1, NULL);
 }
 
@@ -1220,7 +1391,7 @@ add_records (int mode, int replace)
   input.buffer = NULL;
   input.bufsize = 0;
   input.length = 0;
-  input.read = 0;
+  input.flag = 0;
   input.stream = instream;
 
   /* Read directive header */
diff --git a/pop3d/bulletin.c b/pop3d/bulletin.c
index 5efd777..9f4105d 100644
--- a/pop3d/bulletin.c
+++ b/pop3d/bulletin.c
@@ -133,8 +133,6 @@ read_bulletin_db (size_t *pnum)
       return rc;
     }
 
-  mu_dbm_safety_set_flags (db, DEFAULT_GROUP_DB_SAFETY);
-
   rc = mu_dbm_safety_check (db);
   if (rc)
     {


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 23 03:50:34 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RT8XK-0007Af-8o
	for mharc-commit-mailutils@gnu.org; Wed, 23 Nov 2011 03:50:34 -0500
Received: from eggs.gnu.org ([140.186.70.92]:34837)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RT8XG-0007AH-P0
	for commit-mailutils@gnu.org; Wed, 23 Nov 2011 03:50:32 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RT8XF-0006gz-5x
	for commit-mailutils@gnu.org; Wed, 23 Nov 2011 03:50:30 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:44819)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RT8XF-0006gt-4B
	for commit-mailutils@gnu.org; Wed, 23 Nov 2011 03:50:29 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RT8XD-0007Qr-QB
	for commit-mailutils@gnu.org; Wed, 23 Nov 2011 08:50:29 +0000
Date: Wed, 23 Nov 2011 08:50:28 +0000
Message-Id: <E1RT8XD-0007Qr-QB@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-461-g424589b
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 00906d3b3bcef1a948ceff6f27b6052e47081552
X-Git-Newrev: 424589b91c3f367e4c9926804df4bf73bf100e59
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Nov 2011 08:50:32 -0000

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

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

The branch, master has been updated
       via  424589b91c3f367e4c9926804df4bf73bf100e59 (commit)
      from  00906d3b3bcef1a948ceff6f27b6052e47081552 (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 424589b91c3f367e4c9926804df4bf73bf100e59
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 23 10:44:26 2011 +0200

    Enable GSASL by default.
    
    * am/gsasl.m4 (MU_CHECK_GSASL): Enable GSASL by default.  Other minor fixes.
    * am/tls.m4 (MU_CHECK_TLS): Rename to MU_CHECK_GNUTLS.  Check option
    arguments.  Check for gnutls library version.
    * configure.ac: Update.
    * README: Document the change.
    * NEWS: Document the change.

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

Summary of changes:
 NEWS         |   11 ++++++++++-
 README       |   11 +++++++----
 am/gsasl.m4  |   22 +++++++++++++++-------
 am/tls.m4    |   50 +++++++++++++++++++++++++++++++++++++++-----------
 configure.ac |   22 +++++++++++-----------
 5 files changed, 82 insertions(+), 34 deletions(-)

diff --git a/NEWS b/NEWS
index bbdf090..a50433b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2011-11-21
+GNU mailutils NEWS -- history of user-visible changes. 2011-11-23
 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 Free Software Foundation, Inc.
 See the end of file for copying conditions.
@@ -147,6 +147,15 @@ all available DBM libraries it can use.
 
 ** Imap and nntp clients are not yet implemented
 
+** Link with GSASL by default
+
+GSASL is used by several Mailutils components (notably pop3d
+and imap4d as well as their client counterparts) for authentification.
+Since this version, it is enabled by default if configure detects the
+presense of GNU SASL version 0.2.3 or later.
+
+This can be disabled using the --without-gsasl option.
+
 ** Experimental features
 
 The C++ and Python bindings are considered experimental and unstable.
diff --git a/README b/README
index 82ab9cc..9f3ab43 100644
--- a/README
+++ b/README
@@ -156,11 +156,14 @@ mailutils-specific configuration options:
 	Disable the TLS/SSL encryption via GnuTLS (a Transport Layer
 	Security Library) in IMAP4/POP3 daemons and utilities.
 
-    --with-gsasl
+    --without-gsasl
 
-	Enable GNU SASL support (Simple Authentication and Security
-	Layer framework). IMAP4d supports this mechanism. This
-	requires GSASL version 0.2.3 or newer. 
+	Disable GNU SASL support.
+
+	GSASL is used by several Mailutils components (notably pop3d
+	and imap4d as well as their client counterparts) for
+	authentification.  It is enabled by default if configure
+	detects the presense of GNU SASL version 0.2.3 or later.
 
     --with-gssapi
 
diff --git a/am/gsasl.m4 b/am/gsasl.m4
index 45b7608..a0e27a5 100644
--- a/am/gsasl.m4
+++ b/am/gsasl.m4
@@ -14,20 +14,20 @@ dnl
 dnl You should have received a copy of the GNU General Public License along
 dnl with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 dnl
+
+dnl MU_CHECK_GSASL([VERSION = `'],[ACTION-IF-TRUE=`'],[ACTION-IF-FALSE=`']
 AC_DEFUN([MU_CHECK_GSASL],
-[AC_CACHE_CHECK([whether to use GNU SASL library],
-                 [mu_cv_lib_gsasl],
- [if test "x$mu_cv_lib_gsasl" = x; then
+[if test "x$mu_cv_lib_gsasl" = x; then
    cached=""
    mu_cv_lib_gsasl=no
 
    AC_ARG_WITH(gsasl,
-     AC_HELP_STRING([--with-gsasl], [use libgsasl for SASL authentication]),
+     AC_HELP_STRING([--without-gsasl], [do not use libgsasl]),
      [case $withval in
       yes|no) wantgsasl=$withval;;
       *) AC_MSG_ERROR([bad value for --with-gsasl: $withval]);;
       esac],
-     [wantgsasl=no])
+     [wantgsasl=yes])
 
    if test $wantgsasl = yes; then
      AC_CHECK_HEADER(gsasl.h,
@@ -56,9 +56,17 @@ main()
        LIBS=$save_LIBS
      fi       
    fi
-  fi])
+ else
+  cached=" (cached) "
+ fi
  if test $mu_cv_lib_gsasl != no; then
    GSASL_LIBS=$mu_cv_lib_gsasl
-   ifelse([$2],,,[$2])
+   m4_if([$2],,,[$2])
+ fi
+ m4_if([$3],,,[if test $mu_cv_lib_gsasl = no; then
+   $3
  fi])
+ AC_MSG_CHECKING([whether to use GSASL])
+ AC_MSG_RESULT(${cached}${mu_cv_lib_gsasl})
+ ])
  
diff --git a/am/tls.m4 b/am/tls.m4
index aeb0726..6d4408e 100644
--- a/am/tls.m4
+++ b/am/tls.m4
@@ -15,34 +15,62 @@ dnl
 dnl You should have received a copy of the GNU General Public License along
 dnl with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 dnl
-AC_DEFUN([MU_CHECK_TLS],
+
+dnl MU_CHECK_GNUTLS([VERSION = `'],[ACTION-IF-TRUE=`'],[ACTION-IF-FALSE=`']
+AC_DEFUN([MU_CHECK_GNUTLS],
 [
- if test "x$WITH_GNUTLS" = x; then
+ if test "x$mu_cv_lib_gnutls" = x; then
    cached=""
    AC_ARG_WITH([gnutls],
                AC_HELP_STRING([--without-gnutls],
                               [do not use GNU TLS library]),
-               [WITH_GNUTLS=$withval],
-               [WITH_GNUTLS=yes])
+               [case "$withval" in
+	        yes|no) mu_cv_lib_gnutls=$withval;;
+	        *) AC_MSG_ERROR([bad value for --with-gnutls: $withval]);;
+                esac],
+               [mu_cv_lib_gnutls=yes])
 
-   if test "$WITH_GNUTLS" != "no"; then
+   if test "$mu_cv_lib_gnutls" != "no"; then
      AC_CHECK_HEADER(gnutls/gnutls.h,
                      [:],
-                     [WITH_GNUTLS=no])
-     if test "$WITH_GNUTLS" != "no"; then
+                     [mu_cv_lib_gnutls=no])
+     if test "$mu_cv_lib_gnutls" != "no"; then
        saved_LIBS=$LIBS
        AC_CHECK_LIB(gcrypt, main,
                     [TLS_LIBS="-lgcrypt"],
-                    [WITH_GNUTLS=no])
+                    [mu_cv_lib_gnutls=no])
        LIBS="$LIBS $TLS_LIBS"
        AC_CHECK_LIB(gnutls, gnutls_global_init,
                     [TLS_LIBS="-lgnutls $TLS_LIBS"],
-                    [WITH_GNUTLS=no])
+                    [mu_cv_lib_gnutls=no])
        LIBS=$saved_LIBS
+       m4_if([$1],,,[if test $mu_cv_lib_gnutls != no; then
+         LIBS="$LIBS $TLS_LIBS"
+         AC_TRY_RUN([
+#include <gnutls/gnutls.h>
+
+int
+main()
+{
+  return gnutls_check_version ("$1") == (char*) 0;
+}],
+                    [:],
+                    [mu_cv_lib_gnutls=no],
+                    [mu_cv_lib_gnutls=no])
+         LIBS=$saved_LIBS
+       fi])
      fi
    fi
  else
   cached=" (cached) "
  fi
- AC_MSG_CHECKING([whether to use TLS libraries])
- AC_MSG_RESULT(${cached}${WITH_GNUTLS})])
+ 
+ m4_if([$2],,,[if test $mu_cv_lib_gnutls != no; then
+   $2
+ fi])
+ m4_if([$3],,,[if test $mu_cv_lib_gnutls = no; then
+   $3
+ fi])
+ 
+ AC_MSG_CHECKING([whether to use GNU TLS])
+ AC_MSG_RESULT(${cached}${mu_cv_lib_gnutls})])
diff --git a/configure.ac b/configure.ac
index ca89212..f720b7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -251,13 +251,13 @@ AC_SUBST(SERV_AUTHLIBS)
 AC_SUBST(SERV_AUTHINCS)
 
 AC_ARG_WITH([gssapi],
-            AC_HELP_STRING([--with-gssapi],
+            AC_HELP_STRING([--with-gssapi@<:@=PATH@:>@],
                            [use GSSAPI authentication]),
-            [WITH_GSSAPI=$withval],
-            [WITH_GSSAPI=no])
+            [status_gssapi=$withval],
+            [status_gssapi=no])
 
-if test "x$WITH_GSSAPI" != "xno"; then
-  MU_CHECK_GSSAPI($WITH_GSSAPI)
+if test "x$status_gssapi" != "xno"; then
+  MU_CHECK_GSSAPI($status_gssapi)
   if test "$GSSAPI_IMPL" = "none"; then
     AC_CACHE_SAVE
     AC_MSG_RESULT([GSSAPI libraries not found])
@@ -299,19 +299,19 @@ AC_SUBST(SITE_CRAM_MD5_PWD,"\$(sysconfdir)/cram-md5.pwd")
 
 AC_ARG_WITH(cram-passwd,
             AC_HELP_STRING([--with-cram-passwd=FILE],
-                           [use keep passwords for CRAM-MD5 authentication method in FILE (default $SITE_CRAM_MD5_PWD)]),
+                           [keep passwords for CRAM-MD5 authentication method in FILE (default $SITE_CRAM_MD5_PWD)]),
             [case "${withval}" in
             /*) SITE_CRAM_MD5_PWD="${withval}";;
             ./*|../*) AC_MSG_ERROR(Bad value for --with-cram-passwd);;
             *)  SITE_CRAM_MD5_PWD="\$(sysconfdir)/${withval}";;
             esac])
 
-MU_CHECK_TLS
-if test "$WITH_GNUTLS" != "no"; then
+MU_CHECK_GNUTLS([1.2.1],[
   MU_AUTHLIBS="$MU_AUTHLIBS $TLS_LIBS"
   AC_DEFINE(WITH_GNUTLS,1,[Define if mailutils is using GNU TLS])
   AC_DEFINE(WITH_TLS,1,[Define if mailutils is using TLS])
-fi
+  status_gnutls=yes
+])
 
 AC_SUBST(SITE_MAIL_RC)
 AC_ARG_WITH([mail-rc],
@@ -1394,9 +1394,9 @@ status_pam=$status_pam
 status_ltdl=$status_ltdl
 status_dbm="$status_dbm"
 status_ldap=$status_ldap
-status_gnutls=$WITH_GNUTLS
+status_gnutls=$status_gnutls
 status_gsasl=$status_gsasl
-status_gssapi=$WITH_GSSAPI
+status_gssapi=$status_gssapi
 status_guile=$useguile
 status_python=$status_python
 status_cxx=$mu_cv_enable_cxx


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 24 16:41:32 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RTh2y-0005td-Nw
	for mharc-commit-mailutils@gnu.org; Thu, 24 Nov 2011 16:41:32 -0500
Received: from eggs.gnu.org ([140.186.70.92]:33896)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTh2s-0005pY-Ik
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 16:41:30 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTh2n-0006yb-83
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 16:41:26 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:44596)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTh2n-0006yU-2S
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 16:41:21 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTh2l-0006hc-5u
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 21:41:21 +0000
Date: Thu, 24 Nov 2011 21:41:19 +0000
Message-Id: <E1RTh2l-0006hc-5u@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-468-g80b012f
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 424589b91c3f367e4c9926804df4bf73bf100e59
X-Git-Newrev: 80b012f7f89ca6acbf1191ef1b8073239509b941
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 24 Nov 2011 21:41:30 -0000

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

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

The branch, master has been updated
       via  80b012f7f89ca6acbf1191ef1b8073239509b941 (commit)
       via  bbc46f0ca2ec67b0c20355ceba3b9e5349032b47 (commit)
       via  9a419c505d4e72bea50fe33de1aab1d82fde4f82 (commit)
       via  54eb06740c906c696749cd04c9afa6c43694f647 (commit)
       via  0e8d5bfe95e90df34616f780c9e11c076ca306c3 (commit)
       via  9316bc63c12f6caa0303bb0c89a5831a90e523b4 (commit)
       via  45ecec0da61992ea2add464da3be67078b8dbe0e (commit)
      from  424589b91c3f367e4c9926804df4bf73bf100e59 (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 80b012f7f89ca6acbf1191ef1b8073239509b941
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 23:32:26 2011 +0200

    Change callback handling in imap client.
    
    * include/mailutils/imap.h (MU_IMAP_CB_NO)
    (MU_IMAP_CB_BAD,MU_IMAP_CB_BYE)
    (MU_IMAP_CB_PREAUTH): New callbacks.
    (mu_imap_callback_t): Change signature.
    (mu_imap_callback): Change signature.
    * include/mailutils/sys/imap.h (mu_imap_client_state)
    <MU_IMAP_CLOSING>: New state.
    * libproto/imap/callback.c (mu_imap_callback): Change signature.
    Fix boundary check.
    (mu_imap_register_callback_function): Fix boundary check.
    * libproto/imap/connect.c (mu_imap_connect): Use mu_imap_foreach_response
    to parse response.
    * libproto/imap/response.c (_mu_imap_response): Check number of words
    before dereferencing them.
    * libproto/imap/resproc.c: Handle all server responses.
    * mu/imap.c (com_connect): Set POPAUTH callback.
    Set verbosity flags after I/O structure has been created.

commit bbc46f0ca2ec67b0c20355ceba3b9e5349032b47
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 21:30:07 2011 +0200

    list: new operations: head and tail.
    
    * include/mailutils/list.h (mu_list_head, mu_list_tail): New prototypes.
    * libmailutils/list/head.c: New file.
    * libmailutils/list/tail.c: New file.
    * libmailutils/list/Makefile.am (liblist_la_SOURCES): Add new files.
    * libmailutils/tests/listop.c (head,tail): New commands.
    * libmailutils/tests/list.at: Test head and tail.

commit 9a419c505d4e72bea50fe33de1aab1d82fde4f82
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 19:21:38 2011 +0200

    imap client: reflect changes to imapio parser.
    
    * include/mailutils/sys/imap.h (_mu_imap_seterrstrz): New proto.
    * libmailutils/imapio/replstr.c: Update.
    * libproto/imap/err.c (_mu_imap_seterrstrz): New function.
    * libproto/imap/id.c: Remove superfluous calls to _mu_imap_seterrstr.
    * libproto/imap/login.c: Likewise.
    * libproto/imap/select.c: Likewise.
    * libproto/imap/status.c: Likewise.
    * libproto/imap/response.c: Set human-readable text as errstr.
    * libproto/imap/resproc.c (ok_response): Reflect changes to
    mu_imapio_getline.

commit 54eb06740c906c696749cd04c9afa6c43694f647
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 17:09:45 2011 +0200

    imapio: improve getline parser
    
    * libmailutils/imapio/create.c (mu_imapio_create): Treat [ and ] as
    delimiters.
    Use MU_WRDSF_DQUOTE flag instead of MU_WRDSF_QUOTE.
    Use MU_WRDSF_APPEND
    * libmailutils/imapio/getline.c (mu_imapio_getline): Use incremental
    wordsplit mode.  Return human-readable part of status responses as a
    single token.

commit 0e8d5bfe95e90df34616f780c9e11c076ca306c3
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 16:58:47 2011 +0200

    wordsplit: minor fix in return_delims mode
    
    * libmailutils/string/wordsplit.c (scan_word): Return only one delimiter
    if MU_WRDSF_RETURN_DELIMS is on
    * libmailutils/tests/wordsplit.at: Reflect that.

commit 9316bc63c12f6caa0303bb0c89a5831a90e523b4
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Nov 24 15:15:40 2011 +0200

    wordsplit: add incremental mode.
    
    * include/mailutils/wordsplit.h (MU_WRDSF_INCREMENTAL): New flag.
    (MU_WRDSE_NOINPUT): New error code.
    * libmailutils/string/wordsplit.c (mu_wordsplit_init0): New function.
    (mu_wordsplit_init): Call mu_wordsplit_init0.
    (expvar): Use MU_WRDSF_WS instead of MU_WRDSF_SQUEEZE_DELIMS in
    call to subordinate mu_wordsplit.
    (skip_delim): If both MU_WRDSF_RETURN_DELIMS and MU_WRDSF_SQUEEZE_DELIMS
    are given, squeeze only the same delimiter characters.
    * libmailutils/tests/wordsplit.at: Add tests for incremental mode.
    * libmailutils/tests/wsp.c: Support incremental mode.

commit 45ecec0da61992ea2add464da3be67078b8dbe0e
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 23 14:10:54 2011 +0200

    tls: do not generate DH params.
    
    * libmu_auth/tls.c: Don't generate DH params at all.

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

Summary of changes:
 include/mailutils/imap.h              |   19 +++-
 include/mailutils/imapio.h            |    2 +-
 include/mailutils/list.h              |    5 +
 include/mailutils/sys/imap.h          |    4 +-
 include/mailutils/wordsplit.h         |    6 +-
 libmailutils/imapio/create.c          |    7 +-
 libmailutils/imapio/getline.c         |  120 +++++++++++++++++-
 libmailutils/imapio/replstr.c         |    3 +-
 libmailutils/list/Makefile.am         |    4 +-
 libmailutils/list/{count.c => head.c} |   11 +-
 libmailutils/list/{count.c => tail.c} |   11 +-
 libmailutils/string/wordsplit.c       |  179 +++++++++++++++++++--------
 libmailutils/tests/list.at            |   12 ++
 libmailutils/tests/listop.c           |   42 ++++++
 libmailutils/tests/wordsplit.at       |   63 ++++++++-
 libmailutils/tests/wsp.c              |   36 +++++-
 libmu_auth/tls.c                      |   10 --
 libproto/imap/callback.c              |   10 +-
 libproto/imap/connect.c               |   45 ++++---
 libproto/imap/err.c                   |    6 +
 libproto/imap/id.c                    |    6 -
 libproto/imap/login.c                 |    6 -
 libproto/imap/response.c              |   33 +++---
 libproto/imap/resproc.c               |  223 ++++++++++++++++++++++-----------
 libproto/imap/select.c                |    6 -
 libproto/imap/status.c                |    6 -
 mu/imap.c                             |   33 ++++--
 27 files changed, 661 insertions(+), 247 deletions(-)
 copy libmailutils/list/{count.c => head.c} (82%)
 copy libmailutils/list/{count.c => tail.c} (82%)

diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index e33ff08..01faba0 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -108,19 +108,30 @@ int mu_imap_foreach_response (mu_imap_t imap, mu_imap_response_action_t fun,
 			      void *data);
   
 
+  /* The following five callbacks correspond to members of struct
+     mu_imap_stat and take a pointer to struct mu_imap_stat as their
+     only argument. */
 #define MU_IMAP_CB_PERMANENT_FLAGS  0
 #define MU_IMAP_CB_MESSAGE_COUNT    1
 #define MU_IMAP_CB_RECENT_COUNT     2
 #define MU_IMAP_CB_FIRST_UNSEEN     3
 #define MU_IMAP_CB_UIDNEXT          4 
 #define MU_IMAP_CB_UIDVALIDITY      5
+
+  /* The following callbacks correspond to server responses and take two
+     argument: a response code (see MU_IMAP_RESPONSE, below), and
+     human-readable text string as returned by the server.  The latter can
+     be NULL. */
 #define MU_IMAP_CB_OK               6
-#define _MU_IMAP_CB_MAX             7
+#define MU_IMAP_CB_NO               7
+#define MU_IMAP_CB_BAD              8
+#define MU_IMAP_CB_BYE              9
+#define MU_IMAP_CB_PREAUTH         10
+#define _MU_IMAP_CB_MAX            11
 
-typedef void (*mu_imap_callback_t) (void *, int code, mu_list_t resp,
-				    va_list ap);
+typedef void (*mu_imap_callback_t) (void *, int code, va_list ap);
   
-void mu_imap_callback (mu_imap_t imap, int code, mu_list_t resp, ...);
+void mu_imap_callback (mu_imap_t imap, int code, ...);
 
 void mu_imap_register_callback_function (mu_imap_t imap, int code,
 					 mu_imap_callback_t callback,
diff --git a/include/mailutils/imapio.h b/include/mailutils/imapio.h
index f5ebb70..5f60545 100644
--- a/include/mailutils/imapio.h
+++ b/include/mailutils/imapio.h
@@ -48,7 +48,7 @@ int mu_imapio_reply_string (struct _mu_imapio *io, size_t start, char **pbuf);
 
 int mu_imap_flag_to_attribute (const char *item, int *attr);
 int mu_imap_format_flags (mu_stream_t str, int flags);
-  
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/list.h b/include/mailutils/list.h
index e695bb7..6d88819 100644
--- a/include/mailutils/list.h
+++ b/include/mailutils/list.h
@@ -86,6 +86,11 @@ int mu_list_count    (mu_list_t _list, size_t *_pcount);
   
   /* Get _indexth element from the list and store it in _pitem. */
 int mu_list_get      (mu_list_t _list, size_t _index, void **_pitem);
+  /* Retrieve first element of _list */
+int mu_list_head (mu_list_t _list, void **_pitem);
+  /* Retrieve last element of _list */
+int mu_list_tail (mu_list_t _list, void **_pitem);
+  
   /* Store at most _count first elements from _list in the _array.  Unless
      _pcount is NULL, fill it with the actual number of elements copied. */
 int mu_list_to_array (mu_list_t _list, void **_array, size_t _count,
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index de3d1bf..c7c9a35 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -45,7 +45,8 @@ enum mu_imap_client_state
     MU_IMAP_LOGOUT_RX,
     MU_IMAP_ID_RX,
     MU_IMAP_SELECT_RX,
-    MU_IMAP_STATUS_RX
+    MU_IMAP_STATUS_RX,
+    MU_IMAP_CLOSING
   };
 
 enum mu_imap_response
@@ -155,6 +156,7 @@ int _mu_imap_xscript_level (mu_imap_t imap, int xlev);
   while (0)
 
 int _mu_imap_seterrstr (mu_imap_t imap, const char *str, size_t len);
+int _mu_imap_seterrstrz (mu_imap_t imap, const char *str);
 void _mu_imap_clrerrstr (mu_imap_t imap);
 
 int _mu_imap_tag_next (mu_imap_t imap);
diff --git a/include/mailutils/wordsplit.h b/include/mailutils/wordsplit.h
index 5129121..2538da6 100644
--- a/include/mailutils/wordsplit.h
+++ b/include/mailutils/wordsplit.h
@@ -46,7 +46,7 @@ struct mu_wordsplit
   struct mu_wordsplit_node *ws_head, *ws_tail;
 };
 
-/* Wordsplit flags.  Only 3 bits of a 32-bit word remain unused.
+/* Wordsplit flags.  Only 2 bits of a 32-bit word remain unused.
    It is getting crowded... */
 /* Append the words found to the array resulting from a previous
    call. */
@@ -120,6 +120,9 @@ struct mu_wordsplit
 /* ws_escape is set */
 #define MU_WRDSF_ESCAPE            0x10000000
 
+/* Incremental mode */
+#define MU_WRDSF_INCREMENTAL       0x20000000
+
 #define MU_WRDSF_DEFFLAGS	       \
   (MU_WRDSF_NOVAR | MU_WRDSF_NOCMD | \
    MU_WRDSF_QUOTE | MU_WRDSF_SQUEEZE_DELIMS | MU_WRDSF_CESCAPES)
@@ -131,6 +134,7 @@ struct mu_wordsplit
 #define MU_WRDSE_USAGE      4
 #define MU_WRDSE_CBRACE     5
 #define MU_WRDSE_UNDEF      6
+#define MU_WRDSE_NOINPUT    7
 
 int mu_wordsplit (const char *s, struct mu_wordsplit *p, int flags);
 int mu_wordsplit_len (const char *s, size_t len,
diff --git a/libmailutils/imapio/create.c b/libmailutils/imapio/create.c
index 4a3a9af..a28e742 100644
--- a/libmailutils/imapio/create.c
+++ b/libmailutils/imapio/create.c
@@ -28,15 +28,16 @@ mu_imapio_create (mu_imapio_t *iop, mu_stream_t str)
     return ENOMEM;
   io->_imap_stream = str;
   mu_stream_ref (str);
-  io->_imap_ws.ws_delim = " \t()";
+  io->_imap_ws.ws_delim = " \t()[]";
   io->_imap_ws.ws_escape = "\\\"";
   io->_imap_ws_flags = MU_WRDSF_DELIM |
                        MU_WRDSF_ESCAPE |
                        MU_WRDSF_NOVAR |
                        MU_WRDSF_NOCMD | 
-                       MU_WRDSF_QUOTE |
+                       MU_WRDSF_DQUOTE |
                        MU_WRDSF_RETURN_DELIMS |
-                       MU_WRDSF_WS;
+                       MU_WRDSF_WS |
+                       MU_WRDSF_APPEND;
   *iop = io;
   return 0;
 }
diff --git a/libmailutils/imapio/getline.c b/libmailutils/imapio/getline.c
index f586d86..e54e5d6 100644
--- a/libmailutils/imapio/getline.c
+++ b/libmailutils/imapio/getline.c
@@ -23,16 +23,86 @@
 #include <mailutils/cstr.h>
 #include <mailutils/cctype.h>
 #include <mailutils/errno.h>
+#include <mailutils/kwd.h>
 #include <mailutils/sys/imapio.h>
 
+#define STATUS_RESPONSE           1
+#define STATUS_RESPONSE_UNTAGGED  2
+
+static int
+is_status_response (const char *word)
+{
+  static struct mu_kwd resptab[] = {
+    /* RFC 3501, 7.1:
+
+       Status responses are OK, NO, BAD, PREAUTH and BYE.  OK, NO, and BAD
+       can be tagged or untagged.  PREAUTH and BYE are always untagged.
+    */
+    { "OK", STATUS_RESPONSE },
+    { "NO", STATUS_RESPONSE },
+    { "BAD", STATUS_RESPONSE },
+    { "PREAUTH", STATUS_RESPONSE_UNTAGGED },
+    { "BYE", STATUS_RESPONSE_UNTAGGED },
+    { NULL }
+  };
+  int result;
+  
+  if (mu_kwd_xlat_name (resptab, word, &result))
+    return 0;
+  return result;
+}
+
+static int
+get_response_code (struct _mu_imapio *io)
+{
+  size_t end = io->_imap_ws.ws_endp;
+  size_t wc = io->_imap_ws.ws_wordc;
+  int rc, i;
+  
+  do
+    {
+      if ((rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL)))
+	{
+	  if (rc == MU_WRDSE_NOINPUT)
+	    break;
+	  return MU_ERR_PARSE;
+	}
+
+      if (strcmp (io->_imap_ws.ws_wordv[io->_imap_ws.ws_wordc-1], "[") == 0)
+	{
+	  do
+	    {
+	      /* Get word */
+	      if ((rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL)))
+		{
+		  if (rc == MU_WRDSE_NOINPUT)
+		    break;
+		  return MU_ERR_PARSE;
+		}
+	    }
+	  while (strcmp (io->_imap_ws.ws_wordv[io->_imap_ws.ws_wordc-1], "]"));
+	  if (rc)
+	    break;
+	  return 0;
+	}
+    }
+  while (0);
+
+  for (i = wc; i < io->_imap_ws.ws_wordc; i++)
+    free (io->_imap_ws.ws_wordv[i]);
+  io->_imap_ws.ws_wordv[wc] = NULL;
+  io->_imap_ws.ws_wordc = wc;
+  io->_imap_ws.ws_endp = end;
+  return 0;
+}
+
 int
 mu_imapio_getline (struct _mu_imapio *io)
 {
   int rc;
   char *last_arg;
+  int type;
   
-  io->_imap_ws_flags &= ~MU_WRDSF_APPEND;
-
   if (io->_imap_reply_ready)
     {
       mu_wordsplit_free_words (&io->_imap_ws);
@@ -50,11 +120,51 @@ mu_imapio_getline (struct _mu_imapio *io)
 	break;
       io->_imap_buf_level = mu_rtrim_class (io->_imap_buf_base,
 					    MU_CTYPE_ENDLN);
+      if ((rc = mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
+				  &io->_imap_ws,
+				  io->_imap_ws_flags | MU_WRDSF_INCREMENTAL)))
+	{
+	  if (rc == MU_WRDSE_NOINPUT)
+	    break;
+	  return MU_ERR_PARSE;
+	}
+      io->_imap_ws_flags |= MU_WRDSF_REUSE;
+
+      if ((rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL)))
+	{
+	  if (rc == MU_WRDSE_NOINPUT)
+	    break;
+	  return MU_ERR_PARSE;
+	}
+      
+      if ((type = is_status_response (io->_imap_ws.ws_wordv[1]))
+	  && (type == STATUS_RESPONSE ||
+	      strcmp (io->_imap_ws.ws_wordv[0], "*") == 0))
+	{
+	  rc = get_response_code (io);
+	  if (rc)
+	    return MU_ERR_PARSE;
+	  while (io->_imap_ws.ws_endp < io->_imap_ws.ws_len &&
+		 mu_isblank (io->_imap_ws.ws_input[io->_imap_ws.ws_endp]))
+	    io->_imap_ws.ws_endp++;
+	  io->_imap_ws.ws_flags |= MU_WRDSF_NOSPLIT;
+	  rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL);
+	  io->_imap_ws.ws_flags &= ~MU_WRDSF_NOSPLIT;
+	  if (rc)
+	    {
+	      if (rc == MU_WRDSE_NOINPUT)
+		break;
+	      return MU_ERR_PARSE;
+	    }
+	  break;
+	}
 
-      if (mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
-			    &io->_imap_ws, io->_imap_ws_flags))
+      
+      rc = mu_wordsplit_len (io->_imap_buf_base + io->_imap_ws.ws_endp,
+			     io->_imap_buf_level - io->_imap_ws.ws_endp,
+			     &io->_imap_ws, io->_imap_ws_flags);
+      if (rc)
 	return MU_ERR_PARSE;
-      io->_imap_ws_flags |= MU_WRDSF_REUSE|MU_WRDSF_APPEND;
 
       last_arg = io->_imap_ws.ws_wordv[io->_imap_ws.ws_wordc - 1];
       if (last_arg[0] == '{' && last_arg[strlen (last_arg)-1] == '}')
diff --git a/libmailutils/imapio/replstr.c b/libmailutils/imapio/replstr.c
index 56b3fa2..ed183f3 100644
--- a/libmailutils/imapio/replstr.c
+++ b/libmailutils/imapio/replstr.c
@@ -21,7 +21,8 @@
 #include <mailutils/argcv.h>
 #include <mailutils/sys/imapio.h>
 
-/* FIXME: It would be good to have a `, size_t *psize' argument, to allow
+/* FIXME: 1. Is it needed at all?
+   2. It would be good to have a `, size_t *psize' argument, to allow
    for passing an already allocated buffer.  This implies similar changes
    to mu_argcv_join. */
 int
diff --git a/libmailutils/list/Makefile.am b/libmailutils/list/Makefile.am
index 6d46fde..ee6913c 100644
--- a/libmailutils/list/Makefile.am
+++ b/libmailutils/list/Makefile.am
@@ -29,6 +29,7 @@ liblist_la_SOURCES = \
  get.c\
  getcomp.c\
  gmap.c\
+ head.c\
  insert.c\
  intersect.c\
  iterator.c\
@@ -41,7 +42,8 @@ liblist_la_SOURCES = \
  setcomp.c\
  setdestr.c\
  slice.c\
- slice2.c
+ slice2.c\
+ tail.c
 
 INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
 
diff --git a/libmailutils/list/count.c b/libmailutils/list/head.c
similarity index 82%
copy from libmailutils/list/count.c
copy to libmailutils/list/head.c
index 981dbcc..7c52b89 100644
--- a/libmailutils/list/count.c
+++ b/libmailutils/list/head.c
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2011 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
@@ -24,12 +23,14 @@
 #include <mailutils/errno.h>
 
 int
-mu_list_count (mu_list_t list, size_t *pcount)
+mu_list_head (mu_list_t list, void **pitem)
 {
   if (list == NULL)
     return EINVAL;
-  if (pcount == NULL)
+  if (pitem == NULL)
     return MU_ERR_OUT_PTR_NULL;
-  *pcount = list->count;
+  if (!list->head.next)
+    return MU_ERR_NOENT;
+  *pitem = list->head.next->item;
   return 0;
 }
diff --git a/libmailutils/list/count.c b/libmailutils/list/tail.c
similarity index 82%
copy from libmailutils/list/count.c
copy to libmailutils/list/tail.c
index 981dbcc..a8d1472 100644
--- a/libmailutils/list/count.c
+++ b/libmailutils/list/tail.c
@@ -1,6 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2008, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2011 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
@@ -24,12 +23,14 @@
 #include <mailutils/errno.h>
 
 int
-mu_list_count (mu_list_t list, size_t *pcount)
+mu_list_tail (mu_list_t list, void **pitem)
 {
   if (list == NULL)
     return EINVAL;
-  if (pcount == NULL)
+  if (pitem == NULL)
     return MU_ERR_OUT_PTR_NULL;
-  *pcount = list->count;
+  if (!list->head.prev)
+    return MU_ERR_NOENT;
+  *pitem = list->head.prev->item;
   return 0;
 }
diff --git a/libmailutils/string/wordsplit.c b/libmailutils/string/wordsplit.c
index a15b975..12af725 100644
--- a/libmailutils/string/wordsplit.c
+++ b/libmailutils/string/wordsplit.c
@@ -85,6 +85,25 @@ _wsplt_nomem (struct mu_wordsplit *wsp)
   return wsp->ws_errno;
 }
 
+static void
+mu_wordsplit_init0 (struct mu_wordsplit *wsp)
+{
+  if (wsp->ws_flags & MU_WRDSF_REUSE)
+    {
+      if (!(wsp->ws_flags & MU_WRDSF_APPEND))
+	mu_wordsplit_free_words (wsp);
+    }
+  else
+    {
+      wsp->ws_wordv = NULL;
+      wsp->ws_wordc = 0;
+      wsp->ws_wordn = 0;
+    }
+
+  wsp->ws_errno = 0;
+  wsp->ws_head = wsp->ws_tail = NULL;
+}  
+
 static int
 mu_wordsplit_init (struct mu_wordsplit *wsp, const char *input, size_t len,
 		   int flags)
@@ -140,24 +159,13 @@ mu_wordsplit_init (struct mu_wordsplit *wsp, const char *input, size_t len,
   if (!(wsp->ws_flags & MU_WRDSF_COMMENT))
     wsp->ws_comment = NULL;
 
-  if (wsp->ws_flags & MU_WRDSF_REUSE)
-    {
-      if (!(wsp->ws_flags & MU_WRDSF_APPEND))
-	mu_wordsplit_free_words (wsp);
-    }
-  else
-    {
-      wsp->ws_wordv = NULL;
-      wsp->ws_wordc = 0;
-      wsp->ws_wordn = 0;
-    }
-
   if (!(wsp->ws_flags & MU_WRDSF_CLOSURE))
     wsp->ws_closure = NULL;
-  
+
   wsp->ws_endp = 0;
-  wsp->ws_errno = 0;
-  wsp->ws_head = wsp->ws_tail = NULL;
+  
+  mu_wordsplit_init0 (wsp);
+
   return 0;
 }
 
@@ -815,7 +823,7 @@ expvar (struct mu_wordsplit *wsp, const char *str, size_t len,
 	  ws.ws_delim = wsp->ws_delim;
 	  if (mu_wordsplit (value, &ws,
 			    MU_WRDSF_NOVAR | MU_WRDSF_NOCMD |
-			    MU_WRDSF_DELIM | MU_WRDSF_SQUEEZE_DELIMS))
+			    MU_WRDSF_DELIM | MU_WRDSF_WS))
 	    {
 	      mu_wordsplit_free (&ws);
 	      return 1;
@@ -1017,10 +1025,20 @@ skip_delim (struct mu_wordsplit *wsp)
   size_t start = wsp->ws_endp;
   if (wsp->ws_flags & MU_WRDSF_SQUEEZE_DELIMS)
     {
-      do
-	start++;
-      while (start < wsp->ws_len
-	     && ISDELIM (wsp, wsp->ws_input[start]));
+      if ((wsp->ws_flags & MU_WRDSF_RETURN_DELIMS) &&
+	  ISDELIM (wsp, wsp->ws_input[start]))
+	{
+	  int delim = wsp->ws_input[start];
+	  do
+	    start++;
+	  while (start < wsp->ws_len && delim == wsp->ws_input[start]);
+	}
+      else
+	{
+	  do
+	    start++;
+	  while (start < wsp->ws_len && ISDELIM (wsp, wsp->ws_input[start]));
+	}
       start--;
     }
 
@@ -1030,9 +1048,9 @@ skip_delim (struct mu_wordsplit *wsp)
   return start;
 }
 
-#define _MU_WRDS_EOF  0
-#define _MU_WRDS_OK   1
-#define _MU_WRDS_ERR  2
+#define _MU_WRDS_EOF   0
+#define _MU_WRDS_OK    1
+#define _MU_WRDS_ERR   2
 
 static int
 scan_qstring (struct mu_wordsplit *wsp, size_t start, size_t * end)
@@ -1137,11 +1155,7 @@ scan_word (struct mu_wordsplit *wsp, size_t start)
     }
   else if (wsp->ws_flags & MU_WRDSF_RETURN_DELIMS)
     {
-      do
-	{
-	  i++;
-	}
-      while (i < len && ISDELIM (wsp, command[i]));
+      i++;
     }
   else if (!(wsp->ws_flags & MU_WRDSF_SQUEEZE_DELIMS))
     flags |= _WSNF_EMPTYOK;
@@ -1151,7 +1165,8 @@ scan_word (struct mu_wordsplit *wsp, size_t start)
   if (mu_wordsplit_add_segm (wsp, start, i, flags))
     return _MU_WRDS_ERR;
   wsp->ws_endp = i;
-
+  if (wsp->ws_flags & MU_WRDSF_INCREMENTAL)
+    return _MU_WRDS_EOF;
   return _MU_WRDS_OK;
 }
 
@@ -1366,33 +1381,26 @@ mu_wordsplit_c_quote_copy (char *dst, const char *src, int quote_hex)
     }
 }
 
-int
-mu_wordsplit_len (const char *command, size_t len, struct mu_wordsplit *wsp,
-		  int flags)
+static int
+wordsplit_process_list (struct mu_wordsplit *wsp, size_t start)
 {
-  int rc;
-  size_t start = 0;
-
-  rc = mu_wordsplit_init (wsp, command, len, flags);
-  if (rc)
-    return rc;
-
-  if (wsp->ws_flags & MU_WRDSF_SHOWDBG)
-    wsp->ws_debug ("Input:%.*s;", (int)len, command);
-
   if (wsp->ws_flags & MU_WRDSF_NOSPLIT)
     {
       /* Treat entire input as a quoted argument */
-      if (mu_wordsplit_add_segm (wsp, 0, len, _WSNF_QUOTE))
+      if (mu_wordsplit_add_segm (wsp, start, wsp->ws_len, _WSNF_QUOTE))
 	return wsp->ws_errno;
     }
   else
     {
+      int rc;
+  
       while ((rc = scan_word (wsp, start)) == _MU_WRDS_OK)
 	start = skip_delim (wsp);
       /* Make sure tail element is not joinable */
       if (wsp->ws_tail)
 	wsp->ws_tail->flags &= ~_WSNF_JOIN;
+      if (rc == _MU_WRDS_ERR)
+	return wsp->ws_errno;
     }
 
   if (wsp->ws_flags & MU_WRDSF_SHOWDBG)
@@ -1400,11 +1408,6 @@ mu_wordsplit_len (const char *command, size_t len, struct mu_wordsplit *wsp,
       wsp->ws_debug ("Initial list:");
       mu_wordsplit_dump_nodes (wsp);
     }
-  if (rc)
-    {
-      mu_wordsplit_free_nodes (wsp);
-      return wsp->ws_errno;
-    }
 
   if (wsp->ws_flags & MU_WRDSF_WS)
     {
@@ -1450,10 +1453,75 @@ mu_wordsplit_len (const char *command, size_t len, struct mu_wordsplit *wsp,
 	  wsp->ws_debug ("Coalesced list:");
 	  mu_wordsplit_dump_nodes (wsp);
 	}
-
-      mu_wordsplit_finish (wsp);
     }
   while (0);
+  return wsp->ws_errno;
+}  
+
+int
+mu_wordsplit_len (const char *command, size_t length, struct mu_wordsplit *wsp,
+		  int flags)
+{
+  int rc;
+  size_t start;
+  const char *cmdptr;
+  size_t cmdlen;
+
+  if (!command)
+    {
+      if (!(flags & MU_WRDSF_INCREMENTAL))
+	return EINVAL;
+
+      start = skip_delim (wsp);
+      if (wsp->ws_endp == wsp->ws_len)
+	{
+	  wsp->ws_errno = MU_WRDSE_NOINPUT;
+	  if (wsp->ws_flags & MU_WRDSF_SHOWERR)
+	    mu_wordsplit_perror (wsp);
+	  return wsp->ws_errno;
+	}
+      
+      cmdptr = wsp->ws_input + wsp->ws_endp;
+      cmdlen = wsp->ws_len - wsp->ws_endp;
+      wsp->ws_flags |= MU_WRDSF_REUSE;
+      mu_wordsplit_init0 (wsp);
+    }
+  else
+    {
+      cmdptr = command;
+      cmdlen = length;
+      start = 0;
+      rc = mu_wordsplit_init (wsp, cmdptr, cmdlen, flags);
+      if (rc)
+	return rc;
+    }
+
+  if (wsp->ws_flags & MU_WRDSF_SHOWDBG)
+    wsp->ws_debug ("Input:%.*s;", (int)cmdlen, cmdptr);
+
+  rc = wordsplit_process_list (wsp, start);
+  if (rc == 0 && (flags & MU_WRDSF_INCREMENTAL))
+    {
+      while (!wsp->ws_head && wsp->ws_endp < wsp->ws_len)
+	{
+	  start = skip_delim (wsp);
+	  if (wsp->ws_flags & MU_WRDSF_SHOWDBG)
+	    {
+	      cmdptr = wsp->ws_input + wsp->ws_endp;
+	      cmdlen = wsp->ws_len - wsp->ws_endp;
+	      wsp->ws_debug ("Restart:%.*s;", (int)cmdlen, cmdptr);
+	    }
+	  rc = wordsplit_process_list (wsp, start);
+	  if (rc)
+	    break;
+	}
+    }
+  if (rc)
+    {
+      mu_wordsplit_free_nodes (wsp);
+      return rc;
+    }
+  mu_wordsplit_finish (wsp);
   mu_wordsplit_free_nodes (wsp);
   return wsp->ws_errno;
 }
@@ -1461,7 +1529,7 @@ mu_wordsplit_len (const char *command, size_t len, struct mu_wordsplit *wsp,
 int
 mu_wordsplit (const char *command, struct mu_wordsplit *ws, int flags)
 {
-  return mu_wordsplit_len (command, strlen (command), ws, flags);
+  return mu_wordsplit_len (command, command ? strlen (command) : 0, ws, flags);
 }
 
 void
@@ -1523,6 +1591,10 @@ mu_wordsplit_perror (struct mu_wordsplit *wsp)
       wsp->ws_error (_("undefined variable"));
       break;
 
+    case MU_WRDSE_NOINPUT:
+      wsp->ws_error (_("input exhausted"));
+      break;
+      
     default:
       wsp->ws_error (_("unknown error"));
     }
@@ -1532,10 +1604,11 @@ const char *_mu_wordsplit_errstr[] = {
   N_("no error"),
   N_("missing closing quote"),
   N_("memory exhausted"),
-  N_("variable expansion and command substitution " "are not yet supported"),
+  N_("command substitution is not yet supported"),
   N_("invalid mu_wordsplit usage"),
   N_("unbalanced curly brace"),
-  N_("undefined variable")
+  N_("undefined variable"),
+  N_("input exhausted")
 };
 int _mu_wordsplit_nerrs =
   sizeof (_mu_wordsplit_errstr) / sizeof (_mu_wordsplit_errstr[0]);
diff --git a/libmailutils/tests/list.at b/libmailutils/tests/list.at
index c2a39cc..408e78e 100644
--- a/libmailutils/tests/list.at
+++ b/libmailutils/tests/list.at
@@ -103,6 +103,18 @@ TESTLIST([get],[],
 [fire
 ])
 
+TESTLIST([head],[],
+[add en to tre fire fem
+head],
+[en
+])
+
+TESTLIST([tail],[],
+[add en to tre fire fem
+tail],
+[fem
+])
+
 
 # ------------------------------------------------------------
 # Iterators
diff --git a/libmailutils/tests/listop.c b/libmailutils/tests/listop.c
index a71de9e..68e59e4 100644
--- a/libmailutils/tests/listop.c
+++ b/libmailutils/tests/listop.c
@@ -685,6 +685,42 @@ slice (mu_list_t *plist, int argc, char **argv)
 }
 
 void
+head (size_t argc, mu_list_t list)
+{
+  int rc;
+  const char *text;
+    
+  if (argc != 1)
+    {
+      fprintf (stderr, "head ?\n");
+      return;
+    }
+  rc = mu_list_head (list, (void**) &text);
+  if (rc)
+    mu_diag_funcall (MU_DIAG_ERROR, "mu_list_head", NULL, rc);
+  else
+    printf ("%s\n", text);
+}
+
+void
+tail (size_t argc, mu_list_t list)
+{
+  int rc;
+  const char *text;
+    
+  if (argc != 1)
+    {
+      fprintf (stderr, "head ?\n");
+      return;
+    }
+  rc = mu_list_tail (list, (void**) &text);
+  if (rc)
+    mu_diag_funcall (MU_DIAG_ERROR, "mu_list_tail", NULL, rc);
+  else
+    printf ("%s\n", text);
+}
+
+void
 help ()
 {
   printf ("count\n");
@@ -708,6 +744,8 @@ help ()
   printf ("quit\n");
   printf ("iter num\n");
   printf ("help\n");
+  printf ("head\n");
+  printf ("tail\n");
   printf ("NUMBER\n");
 }
 
@@ -819,6 +857,10 @@ shell (mu_list_t list)
 	    find (itr[num], ws.ws_wordv[1]);
 	  else if (strcmp (ws.ws_wordv[0], "help") == 0)
 	    help ();
+	  else if (strcmp (ws.ws_wordv[0], "head") == 0)
+	    head (ws.ws_wordc, list);
+	  else if (strcmp (ws.ws_wordv[0], "tail") == 0)
+	    tail (ws.ws_wordc, list);
 	  else if (ws.ws_wordc == 1)
 	    {
 	      char *p;
diff --git a/libmailutils/tests/wordsplit.at b/libmailutils/tests/wordsplit.at
index ca43789..69c26f1 100644
--- a/libmailutils/tests/wordsplit.at
+++ b/libmailutils/tests/wordsplit.at
@@ -275,16 +275,17 @@ TESTWSP([custom, with returned delimiters],[],[delim : -ws trimnl return_delims]
 
 TESTWSP([custom, with returned & squeezed delimiters],[],[delim : -ws trimnl return_delims -squeeze_delims],
 [semicolon: separated::list: of :words],
-[NF: 9
+[NF: 10
 0: semicolon
 1: :
 2: " separated"
-3: ::
-4: list
-5: :
-6: " of "
-7: :
-8: words
+3: :
+4: :
+5: list
+6: :
+7: " of "
+8: :
+9: words
 ])
 
 TESTWSP([sed expressions],[],[sed],
@@ -373,4 +374,52 @@ TESTWSP([squote],[],[-default novar nocmd squote],
 3: it
 ])
 
+TESTWSP([incremental],[],[incremental],
+[incremental "input test" line
+
+
+],
+[NF: 1
+0: incremental
+NF: 1
+0: "input test"
+NF: 1
+0: line
+],
+[input exhausted
+])
+
+TESTWSP([incremental append],[],[incremental append],
+[incremental "input test" line
+
+
+],
+[NF: 1
+0: incremental
+NF: 2
+0: incremental
+1: "input test"
+NF: 3
+0: incremental
+1: "input test"
+2: line
+],
+[input exhausted
+])
+
+TESTWSP([incremental ws],[],[return_delims -squeeze_delims incremental ws],
+[a   list  test
+
+
+],
+[NF: 1
+0: a
+NF: 1
+0: list
+NF: 1
+0: test
+],
+[input exhausted
+])
+
 m4_popdef([TESTWSP])
diff --git a/libmailutils/tests/wsp.c b/libmailutils/tests/wsp.c
index 5af17be..1dc85df 100644
--- a/libmailutils/tests/wsp.c
+++ b/libmailutils/tests/wsp.c
@@ -49,6 +49,7 @@ struct mu_kwd bool_keytab[] = {
   { "cescapes", MU_WRDSF_CESCAPES },
   { "default", MU_WRDSF_DEFFLAGS },
   { "env_kv", MU_WRDSF_ENV_KV },
+  { "incremental", MU_WRDSF_INCREMENTAL },
   { NULL, 0 }
 };
 
@@ -164,7 +165,7 @@ make_env_kv ()
 int
 main (int argc, char **argv)
 {
-  char buf[1024];
+  char buf[1024], *ptr;
   int i, offarg = 0;
   int trimnl_option = 0;
   int plaintext_option = 0;
@@ -172,6 +173,7 @@ main (int argc, char **argv)
                  MU_WRDSF_ENOMEMABRT |
                  MU_WRDSF_ENV | MU_WRDSF_SHOWERR;
   struct mu_wordsplit ws;
+  int next_call = 0;
 
   for (i = 1; i < argc; i++)
     {
@@ -296,15 +298,39 @@ main (int argc, char **argv)
     ws.ws_env = (const char **) make_env_kv ();
   else
     ws.ws_env = (const char **) environ;
-	
-  while (fgets (buf, sizeof (buf), stdin))
+
+  if (wsflags & MU_WRDSF_INCREMENTAL)
+    trimnl_option = 1;
+  
+  next_call = 0;
+  while ((ptr = fgets (buf, sizeof (buf), stdin)))
     {
       int rc;
       size_t i;
       
       if (trimnl_option)
-	mu_rtrim_cset (buf, "\n");
-      rc = mu_wordsplit (buf, &ws, wsflags);
+	mu_rtrim_cset (ptr, "\n");
+      
+      if (wsflags & MU_WRDSF_INCREMENTAL)
+	{
+	  if (next_call)
+	    {
+	      if (*ptr == 0)
+		ptr = NULL;
+	      else
+		free ((void*)ws.ws_input);
+	    }
+	  else
+	    next_call = 1;
+	  if (ptr)
+	    {
+	      ptr = strdup (ptr);
+	      if (!ptr)
+		abort ();
+	    }
+	}
+	
+      rc = mu_wordsplit (ptr, &ws, wsflags);
       if (rc)
 	{
 	  if (!(wsflags & MU_WRDSF_SHOWERR))
diff --git a/libmu_auth/tls.c b/libmu_auth/tls.c
index ef8df93..655730c 100644
--- a/libmu_auth/tls.c
+++ b/libmu_auth/tls.c
@@ -67,9 +67,6 @@ mu_tls_module_init (enum mu_gocs_op op, void *data)
 #include <gnutls/gnutls.h>
 #include <mailutils/sys/tls-stream.h>
 
-#define DH_BITS 768
-
-static gnutls_dh_params dh_params;
 static gnutls_certificate_server_credentials x509_cred;
 
 /* Return: zero means NOT READY, one means READY */
@@ -145,7 +142,6 @@ mu_init_tls_libs (int x509_setup)
 
   if (x509_setup && !x509_cred)
     {
-      mu_diag_output (MU_DIAG_INFO, _("initializing X509..."));
       gnutls_certificate_allocate_credentials (&x509_cred);
       if (mu_tls_module_config.ssl_cafile)
 	gnutls_certificate_set_x509_trust_file (x509_cred,
@@ -156,11 +152,6 @@ mu_init_tls_libs (int x509_setup)
 					    mu_tls_module_config.ssl_cert, 
 					    mu_tls_module_config.ssl_key,
 					    GNUTLS_X509_FMT_PEM);
-      
-      gnutls_dh_params_init (&dh_params);
-      gnutls_dh_params_generate2 (dh_params, DH_BITS);
-      gnutls_certificate_set_dh_params (x509_cred, dh_params);
-      mu_diag_output (MU_DIAG_INFO, _("finished initializing X509"));
     }
   
 #ifdef DEBUG_TLS
@@ -191,7 +182,6 @@ initialize_tls_session (void)
   gnutls_set_default_priority (session);
   gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
   gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
-  gnutls_dh_set_prime_bits (session, DH_BITS);
 
   return session;
 }
diff --git a/libproto/imap/callback.c b/libproto/imap/callback.c
index 63df696..7fbc998 100644
--- a/libproto/imap/callback.c
+++ b/libproto/imap/callback.c
@@ -23,15 +23,15 @@
 #include <mailutils/sys/imap.h>
 
 void
-mu_imap_callback (mu_imap_t imap, int code, mu_list_t resp, ...)
+mu_imap_callback (mu_imap_t imap, int code, ...)
 {
   va_list ap;
   
-  if (code < 0 || code > _MU_IMAP_CB_MAX || !imap->callback[code].action)
+  if (code < 0 || code >= _MU_IMAP_CB_MAX || !imap->callback[code].action)
     return;
   
-  va_start (ap, resp);
-  imap->callback[code].action (imap->callback[code].data, code, resp, ap);
+  va_start (ap, code);
+  imap->callback[code].action (imap->callback[code].data, code, ap);
   va_end (ap);
 }
 
@@ -40,7 +40,7 @@ mu_imap_register_callback_function (mu_imap_t imap, int code,
 				    mu_imap_callback_t callback,
 				    void *data)
 {
-  if (code < 0 || code > _MU_IMAP_CB_MAX)
+  if (code < 0 || code >= _MU_IMAP_CB_MAX)
     {
       mu_error ("%s:%d: ignoring unsupported callback code %d",
 		__FILE__, __LINE__, code);
diff --git a/libproto/imap/connect.c b/libproto/imap/connect.c
index a925e84..552530b 100644
--- a/libproto/imap/connect.c
+++ b/libproto/imap/connect.c
@@ -37,11 +37,17 @@ mu_imap_connect (mu_imap_t imap)
   char **wv;
   char *bufptr;
   size_t bufsize;
-  
+
   if (imap == NULL)
     return EINVAL;
   if (imap->io == NULL)
     return EINVAL;
+
+  _mu_imap_clrerrstr (imap);
+  status = _mu_imap_untagged_response_clear (imap);
+  if (status)
+    return status;
+  
   switch (imap->state)
     {
     default:
@@ -79,29 +85,26 @@ mu_imap_connect (mu_imap_t imap)
 	  imap->state = MU_IMAP_ERROR;
 	  return MU_ERR_BADREPLY;
 	}
-      else if (strcmp (wv[1], "BYE") == 0)
-	{
-	  status = EACCES;
-	  mu_imapio_getbuf (imap->io, &bufptr, &bufsize);
-	  _mu_imap_seterrstr (imap, bufptr + 2, bufsize - 2);
-	}
-      else if (strcmp (wv[1], "PREAUTH") == 0)
-	{
-	  status = 0;
-	  imap->state = MU_IMAP_CONNECTED;
-	  imap->imap_state = MU_IMAP_STATE_AUTH;
-	}
-      else if (strcmp (wv[1], "OK") == 0)
-	{
-	  status = 0;
-	  imap->state = MU_IMAP_CONNECTED;
-	  imap->imap_state = MU_IMAP_STATE_NONAUTH;
-	}
       else
 	{
-	  status = MU_ERR_BADREPLY;
-	  imap->state = MU_IMAP_ERROR;
+	  _mu_imap_untagged_response_add (imap);
+	  mu_imap_foreach_response (imap, NULL, NULL);
+	  switch (imap->state)
+	    {
+	    case MU_IMAP_CONNECTED:
+	      status = 0;
+	      break;
+
+	    case MU_IMAP_CLOSING:
+	      status = EACCES;
+	      break;
+
+	    default:
+	      imap->state = MU_IMAP_ERROR;
+	      status = MU_ERR_BADREPLY;
+	    }
 	}
+      break;
     }
   
   return status;
diff --git a/libproto/imap/err.c b/libproto/imap/err.c
index 29e275d..0145b7e 100644
--- a/libproto/imap/err.c
+++ b/libproto/imap/err.c
@@ -41,6 +41,12 @@ _mu_imap_seterrstr (mu_imap_t imap, const char *str, size_t len)
   return 0;
 }
 
+int
+_mu_imap_seterrstrz (mu_imap_t imap, const char *str)
+{
+  return _mu_imap_seterrstr (imap, str, strlen (str));
+}
+
 void
 _mu_imap_clrerrstr (mu_imap_t imap)
 {
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index bd5d447..527cd69 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -85,7 +85,6 @@ int
 mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
 {
   int status;
-  char *p;
   
   if (imap == NULL)
     return EINVAL;
@@ -147,11 +146,6 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
 
 	case MU_IMAP_BAD:
 	  status = MU_ERR_BADREPLY;
-	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
-	    {
-	      _mu_imap_seterrstr (imap, p, strlen (p));
-	      free (p);
-	    }
 	  break;
 	}
       imap->state = MU_IMAP_CONNECTED;
diff --git a/libproto/imap/login.c b/libproto/imap/login.c
index b1f840f..d4b05fd 100644
--- a/libproto/imap/login.c
+++ b/libproto/imap/login.c
@@ -28,7 +28,6 @@ int
 mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
 {
   int status;
-  char *p;
   
   if (imap == NULL)
     return EINVAL;
@@ -69,11 +68,6 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
 
 	case MU_IMAP_BAD:
 	  status = MU_ERR_BADREPLY;
-	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
-	    {
-	      _mu_imap_seterrstr (imap, p, strlen (p));
-	      free (p);
-	    }
 	  break;
 	}
       imap->state = MU_IMAP_CONNECTED;
diff --git a/libproto/imap/response.c b/libproto/imap/response.c
index 67087ad..0f959e2 100644
--- a/libproto/imap/response.c
+++ b/libproto/imap/response.c
@@ -27,6 +27,13 @@
 #include <mailutils/errno.h>
 #include <mailutils/sys/imap.h>
 
+static void
+response_to_errstr (mu_imap_t imap, size_t argc, char **argv)
+{
+  if (argc && strcmp (argv[argc-1], "]"))
+    _mu_imap_seterrstrz (imap, argv[argc-1]);
+}
+
 int
 _mu_imap_response (mu_imap_t imap)
 {
@@ -50,9 +57,15 @@ _mu_imap_response (mu_imap_t imap)
 	{
 	  char **wv;
 	  size_t wc;
-	  char *p;
 	  
 	  mu_imapio_get_words (imap->io, &wc, &wv);
+	  if (wc == 0)
+	    {
+	      imap->state = MU_IMAP_ERROR;
+	      status = MU_ERR_BADREPLY;/* FIXME: ECONNRESET ? */
+	      break;
+	    }
+	    
 	  if (strcmp (wv[0], "*") == 0)
 	    {
 	      _mu_imap_untagged_response_add (imap);/* FIXME: error checking */
@@ -70,29 +83,17 @@ _mu_imap_response (mu_imap_t imap)
 	      else if (strcmp (wv[1], "OK") == 0)
 		{
 		  imap->resp_code = MU_IMAP_OK;
-		  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
-		    {
-		      _mu_imap_seterrstr (imap, p, strlen (p));
-		      free (p);
-		    }
+		  response_to_errstr (imap, wc, wv);
 		}
 	      else if (strcmp (wv[1], "NO") == 0)
 		{
 		  imap->resp_code = MU_IMAP_NO;
-		  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
-		    {
-		      _mu_imap_seterrstr (imap, p, strlen (p));
-		      free (p);
-		    }
+		  response_to_errstr (imap, wc, wv);
 		}
 	      else if (strcmp (wv[1], "BAD") == 0)
 		{
 		  imap->resp_code = MU_IMAP_BAD;
-		  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
-		    {
-		      _mu_imap_seterrstr (imap, p, strlen (p));
-		      free (p);
-		    }
+		  response_to_errstr (imap, wc, wv);
 		}
 	      else
 		status = MU_ERR_BADREPLY;
diff --git a/libproto/imap/resproc.c b/libproto/imap/resproc.c
index af752b9..3097795 100644
--- a/libproto/imap/resproc.c
+++ b/libproto/imap/resproc.c
@@ -53,84 +53,157 @@ struct mu_kwd mu_imap_response_codes[] = {
   { NULL }
 };
 
-static void
-ok_response (mu_imap_t imap, mu_list_t resp, void *data)
+static int
+parse_response_code (mu_imap_t imap, mu_list_t resp)
 {
   struct imap_list_element *arg;
   int rcode = -1;
-  size_t n = 0;
-  
+
   arg = _mu_imap_list_at (resp, 1);
   if (!arg)
-    return;
-  if (arg->type == imap_eltype_string && arg->v.string[0] == '[')
+    return -1;
+  
+  if (_mu_imap_list_element_is_string (arg, "["))
     {
-      char *p;
+      arg = _mu_imap_list_at (resp, 2);
+      if (!arg || arg->type != imap_eltype_string)
+	return -1;
       
-      size_t len = strcspn (arg->v.string, "]");
+      if (mu_kwd_xlat_name (mu_imap_response_codes, arg->v.string, &rcode))
+	return -1;
       
-      if (mu_kwd_xlat_name_len (mu_imap_response_codes,
-				arg->v.string + 1, len - 1, &rcode))
-	rcode = -1;
-      
-      switch (rcode)
-	{
-	case MU_IMAP_RESPONSE_PERMANENTFLAGS:
-	  arg = _mu_imap_list_at (resp, 2);
-	  if (!arg ||
-	      _mu_imap_collect_flags (arg, &imap->mbox_stat.permanent_flags))
-	    break;
-	  imap->mbox_stat.flags |= MU_IMAP_STAT_PERMANENT_FLAGS;
-	  mu_imap_callback (imap, MU_IMAP_CB_PERMANENT_FLAGS, resp,
-			    &imap->mbox_stat);
-	  return;
+      arg = _mu_imap_list_at (resp, 4);
+      if (!arg || !_mu_imap_list_element_is_string (arg, "]"))
+	return -1;
+    }
+  return rcode;
+}
+  
+static void
+ok_response (mu_imap_t imap, mu_list_t resp, void *data)
+{
+  struct imap_list_element *arg;
+  int rcode;
+  size_t n = 0;
+  char *p;
+
+  rcode = parse_response_code (imap, resp);
+  switch (rcode)
+    {
+    case MU_IMAP_RESPONSE_PERMANENTFLAGS:
+      arg = _mu_imap_list_at (resp, 3);
+      if (!arg ||
+	  _mu_imap_collect_flags (arg, &imap->mbox_stat.permanent_flags))
+	break;
+      imap->mbox_stat.flags |= MU_IMAP_STAT_PERMANENT_FLAGS;
+      mu_imap_callback (imap, MU_IMAP_CB_PERMANENT_FLAGS, &imap->mbox_stat);
+      return;
 	  
-	case MU_IMAP_RESPONSE_UIDNEXT:
-	  arg = _mu_imap_list_at (resp, 2);
-	  if (!arg || arg->type != imap_eltype_string)
-	    break;
-	  n = strtoul (arg->v.string, &p, 10);
-	  if (*p == ']')
-	    {
-	      imap->mbox_stat.uidnext = n;
-	      imap->mbox_stat.flags |= MU_IMAP_STAT_UIDNEXT;
-	      mu_imap_callback (imap, MU_IMAP_CB_UIDNEXT, resp,
-				&imap->mbox_stat);
-	    }
-	  return;
-			    
-	case MU_IMAP_RESPONSE_UIDVALIDITY:
-	  arg = _mu_imap_list_at (resp, 2);
-	  if (!arg || arg->type != imap_eltype_string)
-	    break;
-	  n = strtoul (arg->v.string, &p, 10);
-	  if (*p == ']')
-	    {
-	      imap->mbox_stat.uidvalidity = n;
-	      imap->mbox_stat.flags |= MU_IMAP_STAT_UIDVALIDITY;
-	      mu_imap_callback (imap, MU_IMAP_CB_UIDVALIDITY, resp,
-				&imap->mbox_stat);
-	    }
-	  return;
+    case MU_IMAP_RESPONSE_UIDNEXT:
+      arg = _mu_imap_list_at (resp, 3);
+      if (!arg || arg->type != imap_eltype_string)
+	break;
+      n = strtoul (arg->v.string, &p, 10);
+      if (*p == 0)
+	{
+	  imap->mbox_stat.uidnext = n;
+	  imap->mbox_stat.flags |= MU_IMAP_STAT_UIDNEXT;
+	  mu_imap_callback (imap, MU_IMAP_CB_UIDNEXT, &imap->mbox_stat);
+	}
+      return;
 			    
-	case MU_IMAP_RESPONSE_UNSEEN:
-	  arg = _mu_imap_list_at (resp, 2);
-	  if (!arg || arg->type != imap_eltype_string)
-	    break;
-	  n = strtoul (arg->v.string, &p, 10);
-	  if (*p == ']')
-	    {
-	      imap->mbox_stat.first_unseen = n;
-	      imap->mbox_stat.flags |= MU_IMAP_STAT_FIRST_UNSEEN;
-	      mu_imap_callback (imap, MU_IMAP_CB_FIRST_UNSEEN, resp,
-				&imap->mbox_stat);
-	    }
-	  return;
+    case MU_IMAP_RESPONSE_UIDVALIDITY:
+      arg = _mu_imap_list_at (resp, 3);
+      if (!arg || arg->type != imap_eltype_string)
+	break;
+      n = strtoul (arg->v.string, &p, 10);
+      if (*p == 0)
+	{
+	  imap->mbox_stat.uidvalidity = n;
+	  imap->mbox_stat.flags |= MU_IMAP_STAT_UIDVALIDITY;
+	  mu_imap_callback (imap, MU_IMAP_CB_UIDVALIDITY, &imap->mbox_stat);
 	}
+      return;
+      
+    case MU_IMAP_RESPONSE_UNSEEN:
+      arg = _mu_imap_list_at (resp, 3);
+      if (!arg || arg->type != imap_eltype_string)
+	break;
+      n = strtoul (arg->v.string, &p, 10);
+      if (*p == 0)
+	{
+	  imap->mbox_stat.first_unseen = n;
+	  imap->mbox_stat.flags |= MU_IMAP_STAT_FIRST_UNSEEN;
+	  mu_imap_callback (imap, MU_IMAP_CB_FIRST_UNSEEN, &imap->mbox_stat);
+	}
+      return;
+    }
+
+  if (mu_list_tail (resp, (void*) &arg) || arg->type != imap_eltype_string)
+    arg = NULL;
+  mu_imap_callback (imap, MU_IMAP_CB_OK, rcode, arg ? arg->v.string : NULL);
+  if (imap->state == MU_IMAP_GREETINGS)
+    {
+      imap->state = MU_IMAP_CONNECTED;
+      imap->imap_state = MU_IMAP_STATE_NONAUTH;
+    }
+}
+
+static void
+default_response (mu_imap_t imap, int code, mu_list_t resp, void *data)
+{
+  struct imap_list_element *arg;
+
+  if (mu_list_tail (resp, (void*) &arg) || arg->type != imap_eltype_string)
+    arg = NULL;
+  mu_imap_callback (imap, code, parse_response_code (imap, resp),
+		    arg ? arg->v.string : NULL);
+}
+
+static void
+no_response (mu_imap_t imap, mu_list_t resp, void *data)
+{
+  default_response (imap, MU_IMAP_CB_NO, resp, data);
+  if (imap->state == MU_IMAP_GREETINGS)
+    imap->state = MU_IMAP_ERROR;
+}
+
+static void
+bad_response (mu_imap_t imap, mu_list_t resp, void *data)
+{
+  default_response (imap, MU_IMAP_CB_BAD, resp, data);
+  if (imap->state == MU_IMAP_GREETINGS)
+    imap->state = MU_IMAP_ERROR;
+}
+
+static void
+bye_response (mu_imap_t imap, mu_list_t resp, void *data)
+{
+  default_response (imap, MU_IMAP_CB_BYE, resp, data);
+  imap->state = MU_IMAP_CLOSING;
+}
+
+static void
+preauth_response (mu_imap_t imap, mu_list_t resp, void *data)
+{
+  if (imap->state == MU_IMAP_GREETINGS)
+    {
+      struct imap_list_element *arg;
+
+      if (mu_list_tail (resp, (void*) &arg) || arg->type != imap_eltype_string)
+	arg = NULL;
+      mu_imap_callback (imap, MU_IMAP_CB_PREAUTH,
+			parse_response_code (imap, resp),
+			arg ? arg->v.string : NULL);
+      imap->state = MU_IMAP_CONNECTED;
+      imap->imap_state = MU_IMAP_STATE_AUTH;
     }
-  mu_imap_callback (imap, MU_IMAP_CB_OK, resp, rcode);
+  else
+    mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
+	      ("ignoring unexpected PREAUTH response"));
 }
 
+
 
 struct response_closure
 {
@@ -147,10 +220,10 @@ struct resptab
 
 static struct resptab resptab[] = {
   { "OK", ok_response },
-  { "NO", },
-  { "BAD", },
-  { "PREAUTH", },
-  { "BYE", },
+  { "NO", no_response },
+  { "BAD", bad_response },
+  { "PREAUTH", preauth_response },
+  { "BYE", bye_response },
   { NULL }
 };
 
@@ -211,7 +284,8 @@ _process_unsolicited_response (mu_imap_t imap, mu_list_t resp)
 	    return 1;
 	  imap->mbox_stat.message_count = n;
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_MESSAGE_COUNT;
-	  mu_imap_callback (imap, MU_IMAP_CB_MESSAGE_COUNT, resp, n);
+	  mu_imap_callback (imap, MU_IMAP_CB_MESSAGE_COUNT, resp,
+			    &imap->mbox_stat);
 	  return 0;
 	}
       else if (_mu_imap_list_element_is_string (arg, "RECENT"))
@@ -224,7 +298,8 @@ _process_unsolicited_response (mu_imap_t imap, mu_list_t resp)
 	    return 1;
 	  imap->mbox_stat.recent_count = n;
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_RECENT_COUNT;
-	  mu_imap_callback (imap, MU_IMAP_CB_RECENT_COUNT, resp, n);
+	  mu_imap_callback (imap, MU_IMAP_CB_RECENT_COUNT, resp,
+			    &imap->mbox_stat);
 	  return 0;
 	}
     }
@@ -243,7 +318,13 @@ _process_response (void *item, void *data)
 		("ignoring string response \"%s\"", elt->v.string));
     }
   else if (_process_unsolicited_response (clos->imap, elt->v.list))
-    clos->fun (clos->imap, elt->v.list, clos->data);
+    {
+      if (clos->fun)
+	clos->fun (clos->imap, elt->v.list, clos->data);
+      else
+	mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
+		  ("ignoring unexpected response"));
+    }
   return 0;
 }
 
diff --git a/libproto/imap/select.c b/libproto/imap/select.c
index 0679197..83a0926 100644
--- a/libproto/imap/select.c
+++ b/libproto/imap/select.c
@@ -67,7 +67,6 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 		struct mu_imap_stat *ps)
 {
   int status;
-  char *p;
   
   if (imap == NULL)
     return EINVAL;
@@ -138,11 +137,6 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 
 	case MU_IMAP_BAD:
 	  status = MU_ERR_BADREPLY;
-	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
-	    {
-	      _mu_imap_seterrstr (imap, p, strlen (p));
-	      free (p);
-	    }
 	  break;
 	}
       imap->state = MU_IMAP_CONNECTED;
diff --git a/libproto/imap/status.c b/libproto/imap/status.c
index 1957bf9..3870572 100644
--- a/libproto/imap/status.c
+++ b/libproto/imap/status.c
@@ -119,7 +119,6 @@ int
 mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
 {
   int status;
-  char *p;
   int delim = 0;
   int i;
   
@@ -201,11 +200,6 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
 
 	case MU_IMAP_BAD:
 	  status = MU_ERR_BADREPLY;
-	  if (mu_imapio_reply_string (imap->io, 2, &p) == 0)
-	    {
-	      _mu_imap_seterrstr (imap, p, strlen (p));
-	      free (p);
-	    }
 	  break;
 	}
       imap->state = MU_IMAP_CONNECTED;
diff --git a/mu/imap.c b/mu/imap.c
index 103829e..6fc0a24 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -150,7 +150,18 @@ imap_prompt_env ()
 
   mutool_prompt_env[14] = NULL;
 }
-
+
+/* Callbacks */
+static void
+imap_popauth_callback (void *data, int code, va_list ap)
+{
+  int rcode = va_arg (ap, int);
+  const char *text = va_arg (ap, const char *);
+  if (text)
+    mu_diag_output (MU_DIAG_INFO, _("session authenticated: %s"), text);
+  else
+    mu_diag_output (MU_DIAG_INFO, _("session authenticated"));
+}
 
 static int
 com_disconnect (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
@@ -206,12 +217,6 @@ com_connect (int argc, char **argv)
       struct mu_sockaddr *sa;
       struct mu_sockaddr_hints hints;
 
-      if (QRY_VERBOSE ())
-	{
-	  imap_set_verbose ();
-	  imap_set_verbose_mask ();
-	}
-
       memset (&hints, 0, sizeof (hints));
       hints.flags = MU_AH_DETECT_FAMILY;
       hints.port = tls ? MU_IMAP_DEFAULT_SSL_PORT : MU_IMAP_DEFAULT_PORT;
@@ -243,6 +248,19 @@ com_connect (int argc, char **argv)
 	    }
 #endif
 	  mu_imap_set_carrier (imap, tcp);
+
+	  if (QRY_VERBOSE ())
+	    {
+	      imap_set_verbose ();
+	      imap_set_verbose_mask ();
+	    }
+
+	  /* Set callbacks */
+	  mu_imap_register_callback_function (imap, MU_IMAP_CB_PREAUTH,
+					      imap_popauth_callback,
+					      NULL);
+
+	  
 	  status = mu_imap_connect (imap);
 	  if (status)
 	    {
@@ -554,7 +572,6 @@ com_status (int argc, char **argv)
     }
   return 0;
 }
-
 
 struct mutool_command imap_comtab[] = {
   { "capability", 1, -1, com_capability,


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 24 18:08:38 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RTiPG-0007Qb-1f
	for mharc-commit-mailutils@gnu.org; Thu, 24 Nov 2011 18:08:38 -0500
Received: from eggs.gnu.org ([140.186.70.92]:38325)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTiP9-0007Oq-K6
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 18:08:35 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTiP6-0004jV-F6
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 18:08:31 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46305)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTiP6-0004jL-D5
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 18:08:28 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTiP3-00089S-IO
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 23:08:27 +0000
Date: Thu, 24 Nov 2011 23:08:25 +0000
Message-Id: <E1RTiP3-00089S-IO@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-471-ge5ec3ce
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 80b012f7f89ca6acbf1191ef1b8073239509b941
X-Git-Newrev: e5ec3ce6c45278e853453c2332dbc140fe2a0ac6
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 24 Nov 2011 23:08: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=e5ec3ce6c45278e853453c2332dbc140fe2a0ac6

The branch, master has been updated
       via  e5ec3ce6c45278e853453c2332dbc140fe2a0ac6 (commit)
       via  1981c5192804ef834c7abdef68ed22b1e967c594 (commit)
       via  4faa3659d6140a25f05cf03e27429c7f1408851c (commit)
      from  80b012f7f89ca6acbf1191ef1b8073239509b941 (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 e5ec3ce6c45278e853453c2332dbc140fe2a0ac6
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 01:06:52 2011 +0200

    imap client: implement noop.
    
    * include/mailutils/imap.h (mu_imap_noop): New proto.
    * include/mailutils/sys/imap.h (mu_imap_client_state)
    <MU_IMAP_NOOP_RX>: New state.
    * libproto/imap/noop.c: New file.
    * libproto/imap/Makefile.am (libmu_imap_la_SOURCES): Add noop.c
    * mu/imap.c (report_failure): New function.
    (com_login,select_mbox,com_status): Use report_failure for
    error reporting.
    (com_noop): New function.
    (imap_comtab)<noop>: New command.

commit 1981c5192804ef834c7abdef68ed22b1e967c594
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 00:54:46 2011 +0200

    Minor change.
    
    * mu/imap.c: Add missing gettext markers.

commit 4faa3659d6140a25f05cf03e27429c7f1408851c
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 00:36:29 2011 +0200

    Process untagged responses synchronously.
    
    * include/mailutils/imap.h (mu_imap_response_action_t): Move to
    sys/imap.h
    (mu_imap_foreach_response): Remove.
    * include/mailutils/sys/imap.h (_mu_imap)<untagged_resp>: Remove.
    All sources updated.
    (_mu_imap_response): Change sigature.
    (_mu_imap_untagged_response_clear)
    (_mu_imap_untagged_response_add): Remove.
    (_mu_imap_untagged_response_to_list)
    (_mu_imap_process_untagged_response): New protos.
    * libproto/imap/connect.c: Use _mu_imap_untagged_response_to_list
    and _mu_imap_process_untagged_response.
    * libproto/imap/create.c: Update.
    * libproto/imap/destroy.c: Update.
    * libproto/imap/disconnect.c: Update.
    * libproto/imap/capability.c: Update calls to _mu_imap_response
    * libproto/imap/id.c: Likewise.
    * libproto/imap/login.c: Likewise.
    * libproto/imap/logout.c: Likewise.
    * libproto/imap/select.c: Likewise.
    * libproto/imap/status.c: Likewise.
    * libproto/imap/resplist.c (_mu_imap_untagged_response_clear): Remove.
    (_mu_imap_untagged_response_add): Remove.
    (_mu_imap_untagged_response_to_list): New function.
    * libproto/imap/response.c (_mu_imap_response): Take response-processing
    function and its closure as arguments.
    * libproto/imap/resproc.c (_mu_imap_process_untagged_response): New
    function.
    (mu_imap_foreach_response): Remove.
    
    * mu/imap.c: Install a BYE callback.

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

Summary of changes:
 include/mailutils/imap.h           |   11 +----
 include/mailutils/sys/imap.h       |   21 ++++++----
 libproto/imap/Makefile.am          |    1 +
 libproto/imap/capability.c         |   19 +++-----
 libproto/imap/connect.c            |   13 ++++--
 libproto/imap/create.c             |    2 -
 libproto/imap/destroy.c            |    1 -
 libproto/imap/disconnect.c         |    1 -
 libproto/imap/id.c                 |   46 +++++++++------------
 libproto/imap/login.c              |    4 +-
 libproto/imap/logout.c             |    2 +-
 libproto/imap/{logout.c => noop.c} |   35 +++++++++++-----
 libproto/imap/resplist.c           |   15 +-----
 libproto/imap/response.c           |   13 ++++--
 libproto/imap/resproc.c            |   30 +++----------
 libproto/imap/select.c             |    5 +-
 libproto/imap/status.c             |   35 ++++++++--------
 mu/imap.c                          |   79 ++++++++++++++++++++++--------------
 18 files changed, 164 insertions(+), 169 deletions(-)
 copy libproto/imap/{logout.c => noop.c} (69%)

diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index 01faba0..5448ef2 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -56,7 +56,9 @@ int mu_imap_login (mu_imap_t imap, const char *user, const char *pass);
 int mu_imap_logout (mu_imap_t imap);
 
 int mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc);
-  
+
+int mu_imap_noop (mu_imap_t imap);
+
 int mu_imap_set_carrier (mu_imap_t imap, mu_stream_t carrier);
 int mu_imap_get_carrier (mu_imap_t imap, mu_stream_t *pcarrier);
 
@@ -101,13 +103,6 @@ int mu_imap_status (mu_imap_t imap, const char *mbox, struct mu_imap_stat *ps);
 
 extern struct mu_kwd _mu_imap_status_name_table[];
 
-typedef void (*mu_imap_response_action_t) (mu_imap_t imap, mu_list_t resp,
-					   void *data);
-
-int mu_imap_foreach_response (mu_imap_t imap, mu_imap_response_action_t fun,
-			      void *data);
-  
-
   /* The following five callbacks correspond to members of struct
      mu_imap_stat and take a pointer to struct mu_imap_stat as their
      only argument. */
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index c7c9a35..58bffd4 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -46,6 +46,7 @@ enum mu_imap_client_state
     MU_IMAP_ID_RX,
     MU_IMAP_SELECT_RX,
     MU_IMAP_STATUS_RX,
+    MU_IMAP_NOOP_RX,
     MU_IMAP_CLOSING
   };
 
@@ -63,9 +64,6 @@ struct _mu_imap
     /* Holds the recect response code */
     enum mu_imap_response resp_code;
     
-    /* Untagged responses */
-    mu_list_t untagged_resp;
-
     /* Error string (if any) */
     char *errstr;
     size_t errsize;
@@ -162,11 +160,18 @@ void _mu_imap_clrerrstr (mu_imap_t imap);
 int _mu_imap_tag_next (mu_imap_t imap);
 int _mu_imap_tag_clr (mu_imap_t imap);
 
-int _mu_imap_response (mu_imap_t imap);
-
-int _mu_imap_untagged_response_clear (mu_imap_t imap);
-int _mu_imap_untagged_response_add (mu_imap_t imap);
-
+
+typedef void (*mu_imap_response_action_t) (mu_imap_t imap, mu_list_t resp,
+					   void *data);
+
+int _mu_imap_untagged_response_to_list (mu_imap_t imap, mu_list_t *plist);
+int _mu_imap_process_untagged_response (mu_imap_t imap, mu_list_t list,
+					mu_imap_response_action_t fun,
+					void *data);
+ 
+int _mu_imap_response (mu_imap_t imap, mu_imap_response_action_t fun,
+		       void *data);
+  
 int _mu_imap_list_element_is_string (struct imap_list_element *elt,
 				     const char *str);
 int _mu_imap_collect_flags (struct imap_list_element *arg, int *res);
diff --git a/libproto/imap/Makefile.am b/libproto/imap/Makefile.am
index ee89f90..c14b76d 100644
--- a/libproto/imap/Makefile.am
+++ b/libproto/imap/Makefile.am
@@ -40,6 +40,7 @@ libmu_imap_la_SOURCES = \
  id.c\
  login.c\
  logout.c\
+ noop.c\
  resplist.c\
  response.c\
  resproc.c\
diff --git a/libproto/imap/capability.c b/libproto/imap/capability.c
index 14dff87..a90d5f9 100644
--- a/libproto/imap/capability.c
+++ b/libproto/imap/capability.c
@@ -115,23 +115,18 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
       imap->state = MU_IMAP_CAPABILITY_RX;
 
     case MU_IMAP_CAPABILITY_RX:
-      status = _mu_imap_response (imap);
+      status = _mu_imap_response (imap, _capability_response_action,
+				  NULL);
+      imap->state = MU_IMAP_CONNECTED;
       MU_IMAP_CHECK_EAGAIN (imap, status);
       if (imap->resp_code != MU_IMAP_OK)
 	return MU_ERR_REPLY;
       else
 	{
-	  imap->state = MU_IMAP_CONNECTED;
-	  status = mu_imap_foreach_response (imap,
-					     _capability_response_action,
-					     NULL);
-	  if (status == 0)
-	    {
-	      if (piter)
-		status = mu_list_get_iterator (imap->capa, piter);
-	      else
-		status = 0;
-	    }
+	  if (piter)
+	    status = mu_list_get_iterator (imap->capa, piter);
+	  else
+	    status = 0;
 	}  
       break;
       
diff --git a/libproto/imap/connect.c b/libproto/imap/connect.c
index 552530b..e9be515 100644
--- a/libproto/imap/connect.c
+++ b/libproto/imap/connect.c
@@ -44,9 +44,6 @@ mu_imap_connect (mu_imap_t imap)
     return EINVAL;
 
   _mu_imap_clrerrstr (imap);
-  status = _mu_imap_untagged_response_clear (imap);
-  if (status)
-    return status;
   
   switch (imap->state)
     {
@@ -87,8 +84,14 @@ mu_imap_connect (mu_imap_t imap)
 	}
       else
 	{
-	  _mu_imap_untagged_response_add (imap);
-	  mu_imap_foreach_response (imap, NULL, NULL);
+	  mu_list_t list;
+
+	  status = _mu_imap_untagged_response_to_list (imap, &list);
+	  if (status)
+	    break;
+	  _mu_imap_process_untagged_response (imap, list, NULL, NULL);
+	  mu_list_destroy (&list);
+
 	  switch (imap->state)
 	    {
 	    case MU_IMAP_CONNECTED:
diff --git a/libproto/imap/create.c b/libproto/imap/create.c
index 96cc4ac..9b2743e 100644
--- a/libproto/imap/create.c
+++ b/libproto/imap/create.c
@@ -53,8 +53,6 @@ _mu_imap_init (mu_imap_t imap)
     {
       int rc;
       
-      if (imap->untagged_resp)
-	mu_list_clear (imap->untagged_resp);
       mu_list_destroy (&imap->capa);
       _mu_imap_clrerrstr (imap);
       rc = _mu_imap_tag_clr (imap);
diff --git a/libproto/imap/destroy.c b/libproto/imap/destroy.c
index ff8076f..3bf131e 100644
--- a/libproto/imap/destroy.c
+++ b/libproto/imap/destroy.c
@@ -39,7 +39,6 @@ mu_imap_destroy (mu_imap_t *pimap)
       if (imap->tag_buf)
 	free (imap->tag_buf);
       
-      mu_list_destroy (&imap->untagged_resp);
       mu_list_destroy (&imap->capa);
       
       mu_imapio_destroy (&imap->io);
diff --git a/libproto/imap/disconnect.c b/libproto/imap/disconnect.c
index 6803008..7683b26 100644
--- a/libproto/imap/disconnect.c
+++ b/libproto/imap/disconnect.c
@@ -35,7 +35,6 @@ mu_imap_disconnect (mu_imap_t imap)
   imap->state = MU_IMAP_NO_STATE;
   MU_IMAP_FCLR (imap, MU_IMAP_RESP);
 
-  mu_list_clear (imap->untagged_resp);
   mu_list_clear (imap->capa);
   
   /* Close the stream.  */
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index 527cd69..05938ab 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -49,36 +49,30 @@ _id_mapper (void **itmv, size_t itmc, void *call_data)
 }
 
 static void
-_id_response_action (mu_imap_t imap, mu_list_t response, void *data)
+parse_id_reply (mu_imap_t imap, mu_list_t resp, void *data)
 {
-  mu_assoc_t assoc = data;
+  int rc;
+  mu_assoc_t *passoc = data;
   struct imap_list_element *elt;
 
-  elt = _mu_imap_list_at (response, 0);
+  if (!data)
+    return;
+  elt = _mu_imap_list_at (resp, 0);
   if (elt && _mu_imap_list_element_is_string (elt, "ID"))
     {
-      elt = _mu_imap_list_at (response, 1);
+      elt = _mu_imap_list_at (resp, 1);
       if (elt->type == imap_eltype_list)
-	mu_list_gmap (elt->v.list, _id_mapper, 2, assoc);
-    }
-}
+	{
+	  mu_assoc_t assoc;
 
-static int
-parse_id_reply (mu_imap_t imap, mu_assoc_t *passoc)
-{
-  int rc;
-  mu_assoc_t assoc;
-  
-  rc = mu_assoc_create (&assoc, sizeof (char**), MU_ASSOC_ICASE);
-  if (rc)
-    return rc;
-  mu_assoc_set_free (assoc, _id_free);
-  
-  rc = mu_imap_foreach_response (imap, _id_response_action, assoc);
-  if (rc)
-    return rc;
-  *passoc = assoc;
-  return 0;
+	  rc = mu_assoc_create (&assoc, sizeof (char**), MU_ASSOC_ICASE);
+	  if (rc)
+	    return;
+	  mu_assoc_set_free (assoc, _id_free);
+	  mu_list_gmap (elt->v.list, _id_mapper, 2, assoc);
+	  *passoc = assoc;
+	}
+    }
 }
   
 int
@@ -130,14 +124,12 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
       imap->state = MU_IMAP_ID_RX;
 
     case MU_IMAP_ID_RX:
-      status = _mu_imap_response (imap);
+      status = _mu_imap_response (imap, parse_id_reply, passoc);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
 	{
 	case MU_IMAP_OK:
-	  imap->imap_state = MU_IMAP_STATE_AUTH;
-	  if (passoc)
-	    status = parse_id_reply (imap, passoc);
+	  status = 0;
 	  break;
 
 	case MU_IMAP_NO:
diff --git a/libproto/imap/login.c b/libproto/imap/login.c
index d4b05fd..b0d3597 100644
--- a/libproto/imap/login.c
+++ b/libproto/imap/login.c
@@ -54,7 +54,8 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
       imap->state = MU_IMAP_LOGIN_RX;
 
     case MU_IMAP_LOGIN_RX:
-      status = _mu_imap_response (imap);
+      status = _mu_imap_response (imap, NULL, NULL);
+      imap->state = MU_IMAP_CONNECTED;
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
 	{
@@ -70,7 +71,6 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
 	  status = MU_ERR_BADREPLY;
 	  break;
 	}
-      imap->state = MU_IMAP_CONNECTED;
       break;
 
     default:
diff --git a/libproto/imap/logout.c b/libproto/imap/logout.c
index 3565bb7..11bef62 100644
--- a/libproto/imap/logout.c
+++ b/libproto/imap/logout.c
@@ -47,7 +47,7 @@ mu_imap_logout (mu_imap_t imap)
       imap->state = MU_IMAP_LOGOUT_RX;
 
     case MU_IMAP_LOGOUT_RX:
-      status = _mu_imap_response (imap);
+      status = _mu_imap_response (imap, NULL, NULL);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       imap->state = MU_IMAP_NO_STATE;
       imap->imap_state = MU_IMAP_STATE_LOGOUT;
diff --git a/libproto/imap/logout.c b/libproto/imap/noop.c
similarity index 69%
copy from libproto/imap/logout.c
copy to libproto/imap/noop.c
index 3565bb7..6d7accc 100644
--- a/libproto/imap/logout.c
+++ b/libproto/imap/noop.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011 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
@@ -19,12 +19,13 @@
 # include <config.h>
 #endif
 
+#include <stdlib.h>
 #include <mailutils/errno.h>
-#include <mailutils/stream.h>
+#include <mailutils/imap.h>
 #include <mailutils/sys/imap.h>
 
 int
-mu_imap_logout (mu_imap_t imap)
+mu_imap_noop (mu_imap_t imap)
 {
   int status;
   
@@ -40,17 +41,29 @@ mu_imap_logout (mu_imap_t imap)
     case MU_IMAP_CONNECTED:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      status = mu_imapio_printf (imap->io, "%s LOGOUT\r\n",
-				 imap->tag_str); 
-      MU_IMAP_CHECK_EAGAIN (imap, status);
+      status = mu_imapio_printf (imap->io, "%s NOOP\r\n", imap->tag_str);
+      MU_IMAP_CHECK_ERROR (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_LOGOUT_RX;
+      imap->state = MU_IMAP_NOOP_RX;
 
-    case MU_IMAP_LOGOUT_RX:
-      status = _mu_imap_response (imap);
+    case MU_IMAP_NOOP_RX:
+      status = _mu_imap_response (imap, NULL, NULL);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      imap->state = MU_IMAP_NO_STATE;
-      imap->imap_state = MU_IMAP_STATE_LOGOUT;
+      switch (imap->resp_code)
+	{
+	case MU_IMAP_OK:
+	  status = 0;
+	  break;
+
+	case MU_IMAP_NO:
+	  status = MU_ERR_FAILURE;
+	  break;
+
+	case MU_IMAP_BAD:
+	  status = MU_ERR_BADREPLY;
+	  break;
+	}
+      imap->state = MU_IMAP_CONNECTED;
       break;
 
     default:
diff --git a/libproto/imap/resplist.c b/libproto/imap/resplist.c
index de2e523..4a42633 100644
--- a/libproto/imap/resplist.c
+++ b/libproto/imap/resplist.c
@@ -55,16 +55,6 @@ _mu_imap_response_list_create (mu_imap_t imap, mu_list_t *plist)
   return 0;
 }
 
-int
-_mu_imap_untagged_response_clear (mu_imap_t imap)
-{
-  if (imap->untagged_resp)
-    mu_list_clear (imap->untagged_resp);
-  else
-    return _mu_imap_response_list_create (imap, &imap->untagged_resp);
-  return 0;
-}
-
 #define IS_LBRACE(p) ((p)[0] == '(')
 #define IS_RBRACE(p) ((p)[0] == ')')
 
@@ -235,7 +225,7 @@ _parse_element (struct parsebuf *pb)
 }
 
 int
-_mu_imap_untagged_response_add (mu_imap_t imap)
+_mu_imap_untagged_response_to_list (mu_imap_t imap, mu_list_t *plist)
 {
   struct imap_list_element *elt;
   struct parsebuf pb;
@@ -251,7 +241,8 @@ _mu_imap_untagged_response_add (mu_imap_t imap)
       imap->state = MU_IMAP_ERROR;
       return pb.pb_err;
     }
-  mu_list_append (imap->untagged_resp, elt);
+  *plist = elt->v.list;
+  free (elt);
   return 0;
 }
 
diff --git a/libproto/imap/response.c b/libproto/imap/response.c
index 0f959e2..653b074 100644
--- a/libproto/imap/response.c
+++ b/libproto/imap/response.c
@@ -35,7 +35,8 @@ response_to_errstr (mu_imap_t imap, size_t argc, char **argv)
 }
 
 int
-_mu_imap_response (mu_imap_t imap)
+_mu_imap_response (mu_imap_t imap, mu_imap_response_action_t fun,
+		   void *data)
 {
   int status = 0;
 
@@ -46,9 +47,6 @@ _mu_imap_response (mu_imap_t imap)
     return 0;
 
   _mu_imap_clrerrstr (imap);
-  status = _mu_imap_untagged_response_clear (imap);
-  if (status)
-    return status;
   
   while (1)
     {
@@ -68,7 +66,12 @@ _mu_imap_response (mu_imap_t imap)
 	    
 	  if (strcmp (wv[0], "*") == 0)
 	    {
-	      _mu_imap_untagged_response_add (imap);/* FIXME: error checking */
+	      mu_list_t list;
+	      status = _mu_imap_untagged_response_to_list (imap, &list);
+	      if (status)
+		break;
+	      _mu_imap_process_untagged_response (imap, list, fun, data);
+	      mu_list_destroy (&list);
 	      continue;
 	    }
 	  else if (strlen (wv[0]) == imap->tag_len &&
diff --git a/libproto/imap/resproc.c b/libproto/imap/resproc.c
index 3097795..d40d9b2 100644
--- a/libproto/imap/resproc.c
+++ b/libproto/imap/resproc.c
@@ -306,21 +306,15 @@ _process_unsolicited_response (mu_imap_t imap, mu_list_t resp)
   return 1;
 }
 
-static int
-_process_response (void *item, void *data)
+int
+_mu_imap_process_untagged_response (mu_imap_t imap, mu_list_t list,
+				    mu_imap_response_action_t fun,
+				    void *data)
 {
-  struct imap_list_element *elt = item;
-  struct response_closure *clos = data;
-
-  if (elt->type != imap_eltype_list)
-    {
-      mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
-		("ignoring string response \"%s\"", elt->v.string));
-    }
-  else if (_process_unsolicited_response (clos->imap, elt->v.list))
+  if (_process_unsolicited_response (imap, list))
     {
-      if (clos->fun)
-	clos->fun (clos->imap, elt->v.list, clos->data);
+      if (fun)
+	fun (imap, list, data);
       else
 	mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
 		  ("ignoring unexpected response"));
@@ -328,14 +322,4 @@ _process_response (void *item, void *data)
   return 0;
 }
 
-int
-mu_imap_foreach_response (mu_imap_t imap, mu_imap_response_action_t fun,
-			  void *data)
-{
-  struct response_closure clos;
-  clos.imap = imap;
-  clos.fun = fun;
-  clos.data = data;
-  return mu_list_foreach (imap->untagged_resp, _process_response, &clos);
-}
 			  
diff --git a/libproto/imap/select.c b/libproto/imap/select.c
index 83a0926..5d30db3 100644
--- a/libproto/imap/select.c
+++ b/libproto/imap/select.c
@@ -111,7 +111,8 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
       imap->state = MU_IMAP_SELECT_RX;
 
     case MU_IMAP_SELECT_RX:
-      status = _mu_imap_response (imap);
+      memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
+      status = _mu_imap_response (imap, _select_response_action, NULL);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
 	{
@@ -125,8 +126,6 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 	      return errno;
 	    }
 	  imap->mbox_writable = writable;
-	  memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
-	  mu_imap_foreach_response (imap, _select_response_action, NULL);
 	  if (ps)
 	    *ps = imap->mbox_stat;
 	  break;
diff --git a/libproto/imap/status.c b/libproto/imap/status.c
index 3870572..b8969ce 100644
--- a/libproto/imap/status.c
+++ b/libproto/imap/status.c
@@ -182,27 +182,26 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
       imap->state = MU_IMAP_STATUS_RX;
 
     case MU_IMAP_STATUS_RX:
-      status = _mu_imap_response (imap);
-      MU_IMAP_CHECK_EAGAIN (imap, status);
-      switch (imap->resp_code)
-	{
-	case MU_IMAP_OK:
+      {
+	struct status_data sd = { mboxname, ps };
+
+	status = _mu_imap_response (imap, _status_response_action, &sd);
+	MU_IMAP_CHECK_EAGAIN (imap, status);
+	switch (imap->resp_code)
 	  {
-	    struct status_data sd = { mboxname, ps };
-	    status = mu_imap_foreach_response (imap, _status_response_action,
-					       &sd);
-	  }
-	  break;
+	  case MU_IMAP_OK:
+	    break;
 
-	case MU_IMAP_NO:
-	  status = EACCES;
-	  break;
+	  case MU_IMAP_NO:
+	    status = EACCES;
+	    break;
 
-	case MU_IMAP_BAD:
-	  status = MU_ERR_BADREPLY;
-	  break;
-	}
-      imap->state = MU_IMAP_CONNECTED;
+	  case MU_IMAP_BAD:
+	    status = MU_ERR_BADREPLY;
+	    break;
+	  }
+	imap->state = MU_IMAP_CONNECTED;
+      }
       break;
 
     default:
diff --git a/mu/imap.c b/mu/imap.c
index 6fc0a24..892fb87 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -112,6 +112,16 @@ com_verbose (int argc, char **argv)
   
 }
 
+static void
+report_failure (const char *what, int status)
+{
+  const char *str;
+      
+  mu_error (_("%s failed: %s"), what, mu_strerror (status));
+  if (mu_imap_strerror (imap, &str) == 0)
+    mu_error (_("server reply: %s"), str);
+}
+
 static int connect_argc;
 static char **connect_argv;
 #define host connect_argv[0]
@@ -162,6 +172,18 @@ imap_popauth_callback (void *data, int code, va_list ap)
   else
     mu_diag_output (MU_DIAG_INFO, _("session authenticated"));
 }
+
+static void
+imap_bye_callback (void *data, int code, va_list ap)
+{
+  int rcode = va_arg (ap, int);
+  const char *text = va_arg (ap, const char *);
+  if (text)
+    mu_diag_output (MU_DIAG_INFO, _("server is closing connection: %s"), text);
+  else
+    mu_diag_output (MU_DIAG_INFO, _("server is closing connection"));
+}
+
 
 static int
 com_disconnect (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
@@ -194,7 +216,7 @@ com_connect (int argc, char **argv)
 #ifdef WITH_TLS
 	    tls = 1;
 #else
-            mu_error ("TLS not supported");
+            mu_error (_("TLS not supported"));
 	    return 0;
 #endif
 	}
@@ -240,7 +262,7 @@ com_connect (int argc, char **argv)
 	      mu_stream_unref (tcp);
 	      if (status)
 		{
-		  mu_error ("cannot create TLS stream: %s",
+		  mu_error (_("cannot create TLS stream: %s"),
 			    mu_strerror (status));
 		  return 0;
 		}
@@ -259,6 +281,9 @@ com_connect (int argc, char **argv)
 	  mu_imap_register_callback_function (imap, MU_IMAP_CB_PREAUTH,
 					      imap_popauth_callback,
 					      NULL);
+	  mu_imap_register_callback_function (imap, MU_IMAP_CB_BYE,
+					      imap_bye_callback,
+					      NULL);
 
 	  
 	  status = mu_imap_connect (imap);
@@ -276,7 +301,7 @@ com_connect (int argc, char **argv)
 	mu_imap_destroy (&imap);
     }
   else
-    mu_error ("Failed to create imap: %s", mu_strerror (status));
+    mu_error (_("Failed to create imap connection: %s"), mu_strerror (status));
   
   if (!status)
     {
@@ -308,7 +333,7 @@ com_logout (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
 	}
     }
   else
-    mu_printf ("Try 'exit' to leave %s\n", mu_program_name);
+    mu_printf (_("Try 'exit' to leave %s\n"), mu_program_name);
   return status;
 }
 
@@ -346,11 +371,11 @@ com_capability (int argc, char **argv)
 	      if (*elt)
 		mu_printf ("%s: %s\n", argv[i], elt);
 	      else
-		mu_printf ("%s is set\n", argv[i]);
+		mu_printf (_("%s is set\n"), argv[i]);
 	      break;
 
 	    case MU_ERR_NOENT:
-	      mu_printf ("%s is not set\n", argv[i]);
+	      mu_printf (_("%s is not set\n"), argv[i]);
 	      break;
 
 	    default:
@@ -396,7 +421,7 @@ com_login (int argc, char **argv)
 	  mu_error (_("login: password required"));
 	  return 1;
 	}
-      status = mu_getpass (mu_strin, mu_strout, "Password:", &passbuf);
+      status = mu_getpass (mu_strin, mu_strout, _("Password:"), &passbuf);
       if (status)
 	return status;
       pwd = passbuf;
@@ -410,13 +435,7 @@ com_login (int argc, char **argv)
   if (status == 0)
     imap_prompt_env ();
   else
-    {
-      const char *str;
-      
-      mu_error ("authentication failed: %s", mu_strerror (status));
-      if (mu_imap_strerror (imap, &str) == 0)
-	mu_error ("server reply: %s", str);
-    }
+    report_failure ("login", status);
   return 0;
 }
 
@@ -433,7 +452,7 @@ com_id (int argc, char **argv)
       argv++;
       if (argv[0] == NULL)
 	{
-	  mu_error ("id -test requires an argument");
+	  mu_error (_("id -test requires an argument"));
 	  return 0;
 	}
       test = argv[0];
@@ -451,7 +470,7 @@ com_id (int argc, char **argv)
 	      mu_printf ("%s: %s\n", test, *(char **)res);
 	    }
 	  else
-	    mu_printf ("%s is not set\n", test);
+	    mu_printf (_("%s is not set\n"), test);
 	}
       else
 	{
@@ -517,13 +536,7 @@ select_mbox (int argc, char **argv, int writable)
       imap_prompt_env ();
     }
   else
-    {
-      const char *str;
-      
-      mu_error ("select failed: %s", mu_strerror (status));
-      if (mu_imap_strerror (imap, &str) == 0)
-	mu_error ("server reply: %s", str);
-    }
+    report_failure ("select", status);
   return 0;
 }
 
@@ -563,13 +576,16 @@ com_status (int argc, char **argv)
       print_imap_stats (&st);
     }
   else
-    {
-      const char *str;
-      
-      mu_error ("status failed: %s", mu_strerror (status));
-      if (mu_imap_strerror (imap, &str) == 0)
-	mu_error ("server reply: %s", str);
-    }
+    report_failure ("status", status);
+  return 0;
+}
+
+static int
+com_noop (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
+{
+  int status = mu_imap_noop (imap);
+  if (status)
+    report_failure ("noop", status);
   return 0;
 }
 
@@ -598,6 +614,9 @@ struct mutool_command imap_comtab[] = {
   { "id",           1, -1, com_id,
     N_("[-test KW] [ARG [ARG...]]"),
     N_("send ID command") },
+  { "noop",         1, 1, com_noop,
+    NULL,
+    N_("no operation (keepalive)") },
   { "select",       1, 2, com_select,
     N_("[MBOX]"),
     N_("select a mailbox") },


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 24 19:12:44 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RTjPI-00080T-BU
	for mharc-commit-mailutils@gnu.org; Thu, 24 Nov 2011 19:12:44 -0500
Received: from eggs.gnu.org ([140.186.70.92]:36120)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTjPE-00080I-W5
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 19:12:42 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTjPD-0001Kv-MC
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 19:12:40 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33597)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTjPD-0001Kd-Jy
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 19:12:39 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTjPC-0005YI-0B
	for commit-mailutils@gnu.org; Fri, 25 Nov 2011 00:12:39 +0000
Date: Fri, 25 Nov 2011 00:12:38 +0000
Message-Id: <E1RTjPC-0005YI-0B@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-472-g342d218
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: e5ec3ce6c45278e853453c2332dbc140fe2a0ac6
X-Git-Newrev: 342d21837df24291e46864e040794ac8f3d57125
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Nov 2011 00:12:42 -0000

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

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

The branch, master has been updated
       via  342d21837df24291e46864e040794ac8f3d57125 (commit)
      from  e5ec3ce6c45278e853453c2332dbc140fe2a0ac6 (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 342d21837df24291e46864e040794ac8f3d57125
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 02:12:40 2011 +0200

    Minor change.
    
    * mu/shell.c: Output newline when EOF is received.

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

Summary of changes:
 mu/shell.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mu/shell.c b/mu/shell.c
index 9d2c90c..39081c1 100644
--- a/mu/shell.c
+++ b/mu/shell.c
@@ -627,7 +627,10 @@ mutool_shell (const char *name, struct mutool_command *cmd)
 	      continue;
 	    }
 	  else
-	    break;
+	    {
+	      mu_printf ("\n");
+	      break;
+	    }
 	}
       
       /* Remove leading and trailing whitespace from the line.


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Thu Nov 24 20:26:09 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RTkYL-0001Ic-P3
	for mharc-commit-mailutils@gnu.org; Thu, 24 Nov 2011 20:26:09 -0500
Received: from eggs.gnu.org ([140.186.70.92]:37116)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTkYJ-0001IW-24
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 20:26:08 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTkYH-0004qD-Em
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 20:26:07 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:36993)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTkYH-0004q8-C1
	for commit-mailutils@gnu.org; Thu, 24 Nov 2011 20:26:05 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RTkY8-0004tQ-Ai
	for commit-mailutils@gnu.org; Fri, 25 Nov 2011 01:26:04 +0000
Date: Fri, 25 Nov 2011 01:25:56 +0000
Message-Id: <E1RTkY8-0004tQ-Ai@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-473-g55cd448
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 342d21837df24291e46864e040794ac8f3d57125
X-Git-Newrev: 55cd448fe25f2e8b703b6847bb0b88c117697f0a
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Nov 2011 01:26: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=55cd448fe25f2e8b703b6847bb0b88c117697f0a

The branch, master has been updated
       via  55cd448fe25f2e8b703b6847bb0b88c117697f0a (commit)
      from  342d21837df24291e46864e040794ac8f3d57125 (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 55cd448fe25f2e8b703b6847bb0b88c117697f0a
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 03:24:13 2011 +0200

    Improve IMAP I/O module.  Add testcase.
    
    * libmailutils/imapio/getline.c (initial_parse): New function.
    (mu_imapio_getline): Use initial_parse.
    * libmailutils/tests/imapio.c (main): Do not set progname.
    * libmailutils/tests/imapio.at: New file.
    * libmailutils/tests/Makefile.am: Add imapio.at.
    * libmailutils/tests/testsuite.at: Include imapio.at

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

Summary of changes:
 libmailutils/imapio/getline.c   |   96 ++++++++++++++++++++++++--------------
 libmailutils/tests/Makefile.am  |    1 +
 libmailutils/tests/imapio.at    |   97 +++++++++++++++++++++++++++++++++++++++
 libmailutils/tests/imapio.c     |    1 -
 libmailutils/tests/testsuite.at |    3 +
 5 files changed, 161 insertions(+), 37 deletions(-)
 create mode 100644 libmailutils/tests/imapio.at

diff --git a/libmailutils/imapio/getline.c b/libmailutils/imapio/getline.c
index e54e5d6..6383631 100644
--- a/libmailutils/imapio/getline.c
+++ b/libmailutils/imapio/getline.c
@@ -96,12 +96,60 @@ get_response_code (struct _mu_imapio *io)
   return 0;
 }
 
+#define IMAPIO_OK   0
+#define IMAPIO_RESP 1 
+#define IMAPIO_ERR  2
+
+static int
+initial_parse (struct _mu_imapio *io)
+{
+  int rc, type;
+  
+  if ((rc = mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
+			      &io->_imap_ws,
+			      io->_imap_ws_flags | MU_WRDSF_INCREMENTAL)))
+    {
+      if (rc == MU_WRDSE_NOINPUT)
+	return IMAPIO_OK;
+      return IMAPIO_ERR;
+    }
+  io->_imap_ws_flags |= MU_WRDSF_REUSE;
+
+  if ((rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL)))
+    {
+      if (rc == MU_WRDSE_NOINPUT)
+	return IMAPIO_OK;
+      return IMAPIO_ERR;
+    }
+  
+  if ((type = is_status_response (io->_imap_ws.ws_wordv[1]))
+      && (type == STATUS_RESPONSE ||
+	  strcmp (io->_imap_ws.ws_wordv[0], "*") == 0))
+    {
+      rc = get_response_code (io);
+      if (rc)
+	return IMAPIO_ERR;
+      while (io->_imap_ws.ws_endp < io->_imap_ws.ws_len &&
+	     mu_isblank (io->_imap_ws.ws_input[io->_imap_ws.ws_endp]))
+	io->_imap_ws.ws_endp++;
+      io->_imap_ws.ws_flags |= MU_WRDSF_NOSPLIT;
+      rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL);
+      io->_imap_ws.ws_flags &= ~MU_WRDSF_NOSPLIT;
+      if (rc)
+	{
+	  if (rc != MU_WRDSE_NOINPUT)
+	    return IMAPIO_ERR;
+	}
+      return IMAPIO_RESP;
+    }
+  return IMAPIO_OK;
+}  
+
 int
 mu_imapio_getline (struct _mu_imapio *io)
 {
   int rc;
   char *last_arg;
-  int type;
   
   if (io->_imap_reply_ready)
     {
@@ -120,52 +168,28 @@ mu_imapio_getline (struct _mu_imapio *io)
 	break;
       io->_imap_buf_level = mu_rtrim_class (io->_imap_buf_base,
 					    MU_CTYPE_ENDLN);
-      if ((rc = mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
-				  &io->_imap_ws,
-				  io->_imap_ws_flags | MU_WRDSF_INCREMENTAL)))
-	{
-	  if (rc == MU_WRDSE_NOINPUT)
-	    break;
-	  return MU_ERR_PARSE;
-	}
-      io->_imap_ws_flags |= MU_WRDSF_REUSE;
-
-      if ((rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL)))
+      
+      rc = initial_parse (io);
+      if (rc == IMAPIO_ERR)
 	{
-	  if (rc == MU_WRDSE_NOINPUT)
-	    break;
-	  return MU_ERR_PARSE;
+	  rc = MU_ERR_PARSE;
+	  break;
 	}
-      
-      if ((type = is_status_response (io->_imap_ws.ws_wordv[1]))
-	  && (type == STATUS_RESPONSE ||
-	      strcmp (io->_imap_ws.ws_wordv[0], "*") == 0))
+      else if (rc == IMAPIO_RESP)
 	{
-	  rc = get_response_code (io);
-	  if (rc)
-	    return MU_ERR_PARSE;
-	  while (io->_imap_ws.ws_endp < io->_imap_ws.ws_len &&
-		 mu_isblank (io->_imap_ws.ws_input[io->_imap_ws.ws_endp]))
-	    io->_imap_ws.ws_endp++;
-	  io->_imap_ws.ws_flags |= MU_WRDSF_NOSPLIT;
-	  rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL);
-	  io->_imap_ws.ws_flags &= ~MU_WRDSF_NOSPLIT;
-	  if (rc)
-	    {
-	      if (rc == MU_WRDSE_NOINPUT)
-		break;
-	      return MU_ERR_PARSE;
-	    }
+	  rc = 0;
 	  break;
 	}
-
-      
+	
       rc = mu_wordsplit_len (io->_imap_buf_base + io->_imap_ws.ws_endp,
 			     io->_imap_buf_level - io->_imap_ws.ws_endp,
 			     &io->_imap_ws, io->_imap_ws_flags);
       if (rc)
 	return MU_ERR_PARSE;
 
+      if (io->_imap_ws.ws_wordc == 0)
+	break;
+      
       last_arg = io->_imap_ws.ws_wordv[io->_imap_ws.ws_wordc - 1];
       if (last_arg[0] == '{' && last_arg[strlen (last_arg)-1] == '}')
 	{
diff --git a/libmailutils/tests/Makefile.am b/libmailutils/tests/Makefile.am
index 0ac3ec1..8463ffe 100644
--- a/libmailutils/tests/Makefile.am
+++ b/libmailutils/tests/Makefile.am
@@ -75,6 +75,7 @@ TESTSUITE_AT = \
  fromflt.at\
  fsaf.at\
  hdrflt.at\
+ imapio.at\
  inline-comment.at\
  linecon.at\
  list.at\
diff --git a/libmailutils/tests/imapio.at b/libmailutils/tests/imapio.at
new file mode 100644
index 0000000..4810e13
--- /dev/null
+++ b/libmailutils/tests/imapio.at
@@ -0,0 +1,97 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+AT_BANNER(IMAP IO)
+
+dnl ------------------------------------------------------------
+dnl IMAPIO([NAME], [KW = `'], [INPUT], [STDOUT = `'],
+dnl        [STDERR = `'])
+dnl
+m4_pushdef([IMAPIO],[
+m4_pushdef([MU_TEST_GROUP],[imapio])
+m4_pushdef([MU_TEST_KEYWORDS],[imapio])
+m4_pushdef([MU_TEST_COMMAND],[imapio])
+MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5])
+m4_popdef([MU_TEST_COMMAND])
+m4_popdef([MU_TEST_KEYWORDS])
+m4_popdef([MU_TEST_GROUP])
+])
+
+dnl ------------------------------------------------------------
+dnl Tests
+dnl ------------------------------------------------------------
+
+IMAPIO([simple string],[],
+[1 select INBOX
+],
+[],
+[3
+0: '1'
+1: 'select'
+2: 'INBOX'
+])
+
+IMAPIO([quoted string],[],
+[1 select "Test mailbox"
+],
+[],
+[3
+0: '1'
+1: 'select'
+2: 'Test mailbox'
+])
+
+IMAPIO([server response],[],
+[1 OK That's OK
+],
+[],
+[3
+0: '1'
+1: 'OK'
+2: 'That's OK'
+])
+
+IMAPIO([server response with code],[],
+[* OK [[UIDNEXT 61]] Predicted next uid
+],
+[],
+[7
+0: '*'
+1: 'OK'
+[2: '['
+3: 'UIDNEXT'
+4: '61'
+5: ']']
+6: 'Predicted next uid'
+])
+
+IMAPIO([literals],[literal],
+[A001 LOGIN {11}
+FRED FOOBAR {7}
+fat man
+],
+[+ GO AHEAD
++ GO AHEAD
+],
+[4
+0: 'A001'
+1: 'LOGIN'
+2: 'FRED FOOBAR'
+3: 'fat man'
+])
+
+dnl ------------------------------------------------------------
+m4_popdef([IMAPIO])
diff --git a/libmailutils/tests/imapio.c b/libmailutils/tests/imapio.c
index 652f0d6..6093561 100644
--- a/libmailutils/tests/imapio.c
+++ b/libmailutils/tests/imapio.c
@@ -42,7 +42,6 @@ main (int argc, char **argv)
   mu_imapio_t io;
   mu_stream_t str;
   
-  mu_set_program_name (argv[0]);
   mu_stdstream_setup (MU_STDSTREAM_RESET_NONE);
   
   for (i = 1; i < argc; i++)
diff --git a/libmailutils/tests/testsuite.at b/libmailutils/tests/testsuite.at
index 893175d..59366ab 100644
--- a/libmailutils/tests/testsuite.at
+++ b/libmailutils/tests/testsuite.at
@@ -80,4 +80,7 @@ m4_include([linecon.at])
 AT_BANNER(Debug Specification)
 m4_include([debugspec.at])
 
+AT_BANNER([IMAP IO])
+m4_include([imapio.at])
+
 m4_include([fsaf.at])
\ No newline at end of file


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 26 03:32:53 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RUDgr-0001jh-FK
	for mharc-commit-mailutils@gnu.org; Sat, 26 Nov 2011 03:32:53 -0500
Received: from eggs.gnu.org ([140.186.70.92]:54964)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUDgo-0001jE-Ph
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 03:32:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUDgn-0000AA-8z
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 03:32:50 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:42317)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUDgn-0000A4-67
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 03:32:49 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUDgl-0001zC-A6
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 08:32:48 +0000
Date: Sat, 26 Nov 2011 08:32:47 +0000
Message-Id: <E1RUDgl-0001zC-A6@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-474-g904b2a7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 55cd448fe25f2e8b703b6847bb0b88c117697f0a
X-Git-Newrev: 904b2a7506205ce12c0f88ae0f30f6bdcd222cab
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 26 Nov 2011 08:32:51 -0000

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

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

The branch, master has been updated
       via  904b2a7506205ce12c0f88ae0f30f6bdcd222cab (commit)
      from  55cd448fe25f2e8b703b6847bb0b88c117697f0a (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 904b2a7506205ce12c0f88ae0f30f6bdcd222cab
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 12:48:03 2011 +0200

    Add a test for non-synchronized imap literals.

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

Summary of changes:
 libmailutils/tests/imapio.at |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libmailutils/tests/imapio.at b/libmailutils/tests/imapio.at
index 4810e13..b601c97 100644
--- a/libmailutils/tests/imapio.at
+++ b/libmailutils/tests/imapio.at
@@ -93,5 +93,18 @@ fat man
 3: 'fat man'
 ])
 
+IMAPIO([non-synch literals],[literal],
+[A001 LOGIN {11+}
+FRED FOOBAR {7+}
+fat man
+],
+[],
+[4
+0: 'A001'
+1: 'LOGIN'
+2: 'FRED FOOBAR'
+3: 'fat man'
+])
+
 dnl ------------------------------------------------------------
 m4_popdef([IMAPIO])


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sat Nov 26 18:46:26 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RURww-0004Yf-0M
	for mharc-commit-mailutils@gnu.org; Sat, 26 Nov 2011 18:46:26 -0500
Received: from eggs.gnu.org ([140.186.70.92]:39193)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RURws-0004VP-F0
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 18:46:24 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RURwq-00043Q-6d
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 18:46:22 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56634)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RURwq-00043L-4n
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 18:46:20 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RURwn-0001TV-UO
	for commit-mailutils@gnu.org; Sat, 26 Nov 2011 23:46:19 +0000
Date: Sat, 26 Nov 2011 23:46:18 +0000
Message-Id: <E1RURwn-0001TV-UO@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-476-g30594fa
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 904b2a7506205ce12c0f88ae0f30f6bdcd222cab
X-Git-Newrev: 30594fa89df0ffbfb40644ef7fec819511dae6eb
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 26 Nov 2011 23:46:24 -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=30594fa89df0ffbfb40644ef7fec819511dae6eb

The branch, master has been updated
       via  30594fa89df0ffbfb40644ef7fec819511dae6eb (commit)
       via  9a400bf9bf5ccfe0db5644238d7c055d75d7a436 (commit)
      from  904b2a7506205ce12c0f88ae0f30f6bdcd222cab (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 30594fa89df0ffbfb40644ef7fec819511dae6eb
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Nov 27 01:39:26 2011 +0200

    imap4d: Fix the functionality of FETCH BODY sections HEADER, TEXT and MIME.
    
    According to RFC 3501 HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part
    specifiers refer to the RFC-2822 header of the message or of an encapsulated
    MESSAGE/RFC822 message.  They return NILs if applied to a MIME part other
    than MESSAGE/RFC822.
    
    * imap4d/fetch.c (fetch_get_part_rfc822): New function.
    (_frt_body): Used only for BODY[]. Consequently, do not try to resolve
    message part, use the message itself instead.
    (_frt_body_n): New function.
    (_frt_mime): New function.
    (_frt_body_text,_frt_header,_frt_header_fields): Use fetch_get_part_rfc822.
    Unref the retrieved message when through.
    (parse_section_text): Use _frt_mime for BODY[<n>.MIME]
    (parse_section): Use _frt_body_n for BODY[<n>].
    * imap4d/testsuite/imap4d/fetch.exp: Remove incorrect tests.

commit 9a400bf9bf5ccfe0db5644238d7c055d75d7a436
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Nov 25 15:02:59 2011 +0200

    Change callback signature in imap client.
    
    The purpose is to avoid using variadic calls in order to let the compiler
    do the necessary argument checking.
    
    * include/mailutils/imap.h (mu_imap_callback_t): Take a pair of size_t
    and void * arguments instead of the single va_list.
    (mu_imap_callback): Likewise.
    * libproto/imap/callback.c: Likewise.
    * libproto/imap/resproc.c: Update callback calls.
    * mu/imap.c: Update callback declarations.

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

Summary of changes:
 imap4d/fetch.c                    |  145 ++++++++++++++++++++++++++++++++++---
 imap4d/testsuite/imap4d/fetch.exp |   59 ---------------
 include/mailutils/imap.h          |    5 +-
 libproto/imap/callback.c          |    9 +--
 libproto/imap/resproc.c           |   13 ++--
 mu/imap.c                         |   10 +--
 6 files changed, 148 insertions(+), 93 deletions(-)

diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index aee0a6f..ec8d1e8 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -685,6 +685,62 @@ fetch_get_part (struct fetch_function_closure *ffc,
   return msg;
 }
 
+static mu_message_t 
+fetch_get_part_rfc822 (struct fetch_function_closure *ffc,
+		       struct fetch_runtime_closure *frt)
+{
+  mu_message_t msg = frt->msg, retmsg = NULL;
+  size_t i;
+  mu_header_t header;
+  const char *hval;
+  
+  if (ffc->nset == 0)
+    {
+      mu_message_ref (msg);
+      return msg;
+    }
+  
+  for (i = 0; i < ffc->nset; i++)
+    if (mu_message_get_part (msg, ffc->section_part[i], &msg))
+      return NULL;
+
+  if (mu_message_get_header (msg, &header))
+    return NULL;
+  
+  if (mu_header_sget_value (header, MU_HEADER_CONTENT_TYPE, &hval) == 0)
+    {
+      struct mu_wordsplit ws;
+      int rc;
+      
+      ws.ws_delim = " \t\r\n;=";
+      ws.ws_alloc_die = imap4d_ws_alloc_die;
+      if (mu_wordsplit (hval, &ws, IMAP4D_WS_FLAGS))
+	{
+	  mu_error (_("%s failed: %s"), "mu_wordsplit",
+		    mu_wordsplit_strerror (&ws));
+	  return NULL;
+	}
+
+      rc = mu_c_strcasecmp (ws.ws_wordv[0], "MESSAGE/RFC822");
+      mu_wordsplit_free (&ws);
+
+      if (rc == 0)
+	{
+	  mu_body_t body;
+	  mu_stream_t str;
+	  
+	  if (mu_message_get_body (msg, &body) ||
+	      mu_body_get_streamref (body, &str))
+	    return NULL;
+
+	  rc = mu_stream_to_message (str, &retmsg);
+	  mu_stream_unref (str);
+	}
+    }
+  
+  return retmsg;
+}
+
 static void
 fetch_send_section_part (struct fetch_function_closure *ffc,
                          const char *suffix, int close_bracket)
@@ -918,7 +974,7 @@ static int
 _frt_body (struct fetch_function_closure *ffc,
 	   struct fetch_runtime_closure *frt)
 {
-  mu_message_t msg;
+  mu_message_t msg = frt->msg;
   mu_stream_t stream = NULL;
   size_t size = 0, lines = 0;
   int rc;
@@ -928,17 +984,44 @@ _frt_body (struct fetch_function_closure *ffc,
     io_sendf ("%s", ffc->name);
   else
     fetch_send_section_part (ffc, NULL, 1);
+  mu_message_get_streamref (msg, &stream);
+  mu_message_size (msg, &size);
+  mu_message_lines (msg, &lines);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  return rc;
+}
+
+/* BODY[N] */
+static int
+_frt_body_n (struct fetch_function_closure *ffc,
+	     struct fetch_runtime_closure *frt)
+{
+  mu_message_t msg;
+  mu_body_t body = NULL;
+  mu_stream_t stream = NULL;
+  size_t size = 0, lines = 0;
+  int rc;
+  
+  set_seen (ffc, frt);
+  if (ffc->name)
+    io_sendf ("%s",  ffc->name);
+  else
+    fetch_send_section_part (ffc, ffc->section_tag, 1);
   msg = fetch_get_part (ffc, frt);
   if (!msg)
     {
-      io_sendf (" \"\"");
+      io_sendf (" NIL");
       return RESP_OK;
     }
-  mu_message_get_streamref (msg, &stream);
-  mu_message_size (msg, &size);
-  mu_message_lines (msg, &lines);
+
+  mu_message_get_body (msg, &body);
+  mu_body_size (body, &size);
+  mu_body_lines (body, &lines);
+  mu_body_get_streamref (body, &stream);
   rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
+
   return rc;
 }
 
@@ -957,10 +1040,10 @@ _frt_body_text (struct fetch_function_closure *ffc,
     io_sendf ("%s",  ffc->name);
   else
     fetch_send_section_part (ffc, ffc->section_tag, 1);
-  msg = fetch_get_part (ffc, frt);
+  msg = fetch_get_part_rfc822 (ffc, frt);
   if (!msg)
     {
-      io_sendf (" \"\"");
+      io_sendf (" NIL");
       return RESP_OK;
     }
 
@@ -970,6 +1053,7 @@ _frt_body_text (struct fetch_function_closure *ffc,
   mu_body_get_streamref (body, &stream);
   rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
+  mu_message_unref (msg);
   return rc;
 }
 
@@ -1002,10 +1086,42 @@ _frt_header (struct fetch_function_closure *ffc,
   else
     fetch_send_section_part (ffc, ffc->section_tag, 1);
 
+  msg = fetch_get_part_rfc822 (ffc, frt);
+  if (!msg)
+    {
+      io_sendf (" NIL");
+      return RESP_OK;
+    }
+  mu_message_get_header (msg, &header);
+  mu_header_size (header, &size);
+  mu_header_lines (header, &lines);
+  mu_header_get_streamref (header, &stream);
+  rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
+  mu_stream_destroy (&stream);
+  mu_message_unref (msg);
+  return rc;
+}
+
+static int
+_frt_mime (struct fetch_function_closure *ffc,
+	     struct fetch_runtime_closure *frt)
+{
+  mu_message_t msg;
+  mu_header_t header = NULL;
+  mu_stream_t stream = NULL;
+  size_t size = 0, lines = 0;
+  int rc;
+  
+  set_seen (ffc, frt);
+  if (ffc->name)
+    io_sendf ("%s",  ffc->name);
+  else
+    fetch_send_section_part (ffc, ffc->section_tag, 1);
+
   msg = fetch_get_part (ffc, frt);
   if (!msg)
     {
-      io_sendf (" \"\"");
+      io_sendf (" NIL");
       return RESP_OK;
     }
   mu_message_get_header (msg, &header);
@@ -1014,6 +1130,7 @@ _frt_header (struct fetch_function_closure *ffc,
   mu_header_get_streamref (header, &stream);
   rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
+
   return rc;
 }
 
@@ -1060,10 +1177,10 @@ _frt_header_fields (struct fetch_function_closure *ffc,
   mu_list_foreach (ffc->headers, _send_header_name, &status);
   io_sendf (")]");
   
-  msg = fetch_get_part (ffc, frt);
+  msg = fetch_get_part_rfc822 (ffc, frt);
   if (!msg)
     {
-      io_sendf (" \"\"");
+      io_sendf (" NIL");
       return RESP_OK;
     }
 
@@ -1071,7 +1188,8 @@ _frt_header_fields (struct fetch_function_closure *ffc,
   if (mu_message_get_header (msg, &header)
       || mu_header_get_iterator (header, &itr))
     {
-      io_sendf (" \"\"");
+      mu_message_unref (msg);
+      io_sendf (" NIL");
       return RESP_OK;
     }
 
@@ -1109,6 +1227,7 @@ _frt_header_fields (struct fetch_function_closure *ffc,
   mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   status = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
+  mu_message_unref (msg);
   
   return status;
 }
@@ -1347,7 +1466,7 @@ parse_section_text (imap4d_parsebuf_t p, struct fetch_function_closure *ffc,
   else if (allow_mime && mu_c_strcasecmp (p->token, "MIME") == 0)
     {
       imap4d_parsebuf_next (p, 1);
-      ffc->fun = _frt_header;
+      ffc->fun = _frt_mime;
       ffc->section_tag = "MIME";
     }
   else
@@ -1436,6 +1555,8 @@ parse_section (imap4d_parsebuf_t p, struct fetch_function_closure *ffc)
 	      imap4d_parsebuf_next (p, 1);
 	      parse_section_text (p, ffc, 1);
 	    }
+	  else
+	    ffc->fun = _frt_body_n;
 	}
       else
 	imap4d_parsebuf_exit (p, "Syntax error");
diff --git a/imap4d/testsuite/imap4d/fetch.exp b/imap4d/testsuite/imap4d/fetch.exp
index dedcc5d..60286c7 100644
--- a/imap4d/testsuite/imap4d/fetch.exp
+++ b/imap4d/testsuite/imap4d/fetch.exp
@@ -340,65 +340,6 @@ imap4d_test "FETCH 4 BODY\[2.2.1\]"\
 ")"\
 "OK"
 
-imap4d_test "FETCH 4 BODY\[2.2.1.TEXT\]"\
-"4 FETCH (BODY\[2.2.1.TEXT\] {490}"\
--literal\
-"YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh"\
-"awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv"\
-"b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn"\
-"ZSB0byBkbyBpdD8nCgpgSW4gbXkgeW91dGgsJyBzYWlkIGhpcyBmYXRoZXIsIGBJIHRvb2sgdG8g"\
-"dGhlIGxhdywKQW5kIGFyZ3VlZCBlYWNoIGNhc2Ugd2l0aCBteSB3aWZlOwpBbmQgdGhlIG11c2N1"\
-"bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz"\
-"dCBvZiBteSBsaWZlLicK"\
-")"\
-"OK"
-
-imap4d_test "FETCH 4 BODY\[2.2.TEXT\]"\
-"4 FETCH (BODY\[2.2.TEXT\] {1432}"\
--literal\
--- "------- =_aaaaaaaaaa2"\
-"Content-Type: application/octet-stream; name=\"msg.23\""\
-"Content-ID: <5122.1026510654.6@example.net>"\
-"Content-Description: Father William Part III"\
-"Content-Transfer-Encoding: base64"\
-""\
-"YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh"\
-"awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv"\
-"b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn"\
-"ZSB0byBkbyBpdD8nCgpgSW4gbXkgeW91dGgsJyBzYWlkIGhpcyBmYXRoZXIsIGBJIHRvb2sgdG8g"\
-"dGhlIGxhdywKQW5kIGFyZ3VlZCBlYWNoIGNhc2Ugd2l0aCBteSB3aWZlOwpBbmQgdGhlIG11c2N1"\
-"bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz"\
-"dCBvZiBteSBsaWZlLicK"\
-""\
--- "------- =_aaaaaaaaaa2"\
-"Content-Type: application/octet-stream; name=\"msg.24\""\
-"Content-ID: <5122.1026510654.7@example.net>"\
-"Content-Description: Father William Part IV"\
-"Content-Transfer-Encoding: base64"\
-""\
-"YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBvbmUgd291bGQgaGFyZGx5IHN1cHBvc2UK"\
-"VGhhdCB5b3VyIGV5ZSB3YXMgYXMgc3RlYWR5IGFzIGV2ZXI7CllldCB5b3UgYmFsYW5jZWQgYW4g"\
-"ZWVsIG9uIHRoZSBlbmQgb2YgeW91ciBub3NlLS0KV2hhdCBtYWRlIHlvdSBzbyBhd2Z1bGx5IGNs"\
-"ZXZlcj8nCgpgSSBoYXZlIGFuc3dlcmVkIHRocmVlIHF1ZXN0aW9ucywgYW5kIHRoYXQgaXMgZW5v"\
-"dWdoLCcKU2FpZCBoaXMgZmF0aGVyOyBgZG9uJ3QgZ2l2ZSB5b3Vyc2VsZiBhaXJzIQpEbyB5b3Ug"\
-"dGhpbmsgSSBjYW4gbGlzdGVuIGFsbCBkYXkgdG8gc3VjaCBzdHVmZj8KQmUgb2ZmLCBvciBJJ2xs"\
-"IGtpY2sgeW91IGRvd24gc3RhaXJzIScK"\
-""\
--- "------- =_aaaaaaaaaa2--"\
-")"\
-"OK"
-
-imap4d_test "FETCH 5 BODY\[1.TEXT\]"\
-"5 FETCH (FLAGS (\\Seen) BODY\[1.TEXT\] \"\")"\
-"OK"
-
-imap4d_test "FETCH 5 BODY\[2.TEXT\]"\
-"5 FETCH (BODY\[2.TEXT\] {2}"\
--literal\
-""\
-")"\
-"OK"
-
 ###############
 # Test RFC822 operations
 
diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index 5448ef2..cb679d0 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -18,7 +18,6 @@
 #ifndef _MAILUTILS_IMAP_H
 #define _MAILUTILS_IMAP_H
 
-#include <stdarg.h>
 #include <mailutils/iterator.h>
 #include <mailutils/debug.h>
 #include <mailutils/stream.h>
@@ -124,9 +123,9 @@ extern struct mu_kwd _mu_imap_status_name_table[];
 #define MU_IMAP_CB_PREAUTH         10
 #define _MU_IMAP_CB_MAX            11
 
-typedef void (*mu_imap_callback_t) (void *, int code, va_list ap);
+typedef void (*mu_imap_callback_t) (void *, int code, size_t sdat, void *pdat);
   
-void mu_imap_callback (mu_imap_t imap, int code, ...);
+void mu_imap_callback (mu_imap_t imap, int code, size_t sdat, void *pdat);
 
 void mu_imap_register_callback_function (mu_imap_t imap, int code,
 					 mu_imap_callback_t callback,
diff --git a/libproto/imap/callback.c b/libproto/imap/callback.c
index 7fbc998..9800169 100644
--- a/libproto/imap/callback.c
+++ b/libproto/imap/callback.c
@@ -23,16 +23,11 @@
 #include <mailutils/sys/imap.h>
 
 void
-mu_imap_callback (mu_imap_t imap, int code, ...)
+mu_imap_callback (mu_imap_t imap, int code, size_t sdat, void *pdat)
 {
-  va_list ap;
-  
   if (code < 0 || code >= _MU_IMAP_CB_MAX || !imap->callback[code].action)
     return;
-  
-  va_start (ap, code);
-  imap->callback[code].action (imap->callback[code].data, code, ap);
-  va_end (ap);
+  imap->callback[code].action (imap->callback[code].data, code, sdat, pdat);
 }
 
 void
diff --git a/libproto/imap/resproc.c b/libproto/imap/resproc.c
index d40d9b2..d939690 100644
--- a/libproto/imap/resproc.c
+++ b/libproto/imap/resproc.c
@@ -96,7 +96,7 @@ ok_response (mu_imap_t imap, mu_list_t resp, void *data)
 	  _mu_imap_collect_flags (arg, &imap->mbox_stat.permanent_flags))
 	break;
       imap->mbox_stat.flags |= MU_IMAP_STAT_PERMANENT_FLAGS;
-      mu_imap_callback (imap, MU_IMAP_CB_PERMANENT_FLAGS, &imap->mbox_stat);
+      mu_imap_callback (imap, MU_IMAP_CB_PERMANENT_FLAGS, 0, &imap->mbox_stat);
       return;
 	  
     case MU_IMAP_RESPONSE_UIDNEXT:
@@ -108,7 +108,7 @@ ok_response (mu_imap_t imap, mu_list_t resp, void *data)
 	{
 	  imap->mbox_stat.uidnext = n;
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_UIDNEXT;
-	  mu_imap_callback (imap, MU_IMAP_CB_UIDNEXT, &imap->mbox_stat);
+	  mu_imap_callback (imap, MU_IMAP_CB_UIDNEXT, 0, &imap->mbox_stat);
 	}
       return;
 			    
@@ -121,7 +121,7 @@ ok_response (mu_imap_t imap, mu_list_t resp, void *data)
 	{
 	  imap->mbox_stat.uidvalidity = n;
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_UIDVALIDITY;
-	  mu_imap_callback (imap, MU_IMAP_CB_UIDVALIDITY, &imap->mbox_stat);
+	  mu_imap_callback (imap, MU_IMAP_CB_UIDVALIDITY, 0, &imap->mbox_stat);
 	}
       return;
       
@@ -134,7 +134,8 @@ ok_response (mu_imap_t imap, mu_list_t resp, void *data)
 	{
 	  imap->mbox_stat.first_unseen = n;
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_FIRST_UNSEEN;
-	  mu_imap_callback (imap, MU_IMAP_CB_FIRST_UNSEEN, &imap->mbox_stat);
+	  mu_imap_callback (imap, MU_IMAP_CB_FIRST_UNSEEN, 0,
+			    &imap->mbox_stat);
 	}
       return;
     }
@@ -284,7 +285,7 @@ _process_unsolicited_response (mu_imap_t imap, mu_list_t resp)
 	    return 1;
 	  imap->mbox_stat.message_count = n;
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_MESSAGE_COUNT;
-	  mu_imap_callback (imap, MU_IMAP_CB_MESSAGE_COUNT, resp,
+	  mu_imap_callback (imap, MU_IMAP_CB_MESSAGE_COUNT, 0,
 			    &imap->mbox_stat);
 	  return 0;
 	}
@@ -298,7 +299,7 @@ _process_unsolicited_response (mu_imap_t imap, mu_list_t resp)
 	    return 1;
 	  imap->mbox_stat.recent_count = n;
 	  imap->mbox_stat.flags |= MU_IMAP_STAT_RECENT_COUNT;
-	  mu_imap_callback (imap, MU_IMAP_CB_RECENT_COUNT, resp,
+	  mu_imap_callback (imap, MU_IMAP_CB_RECENT_COUNT, 0,
 			    &imap->mbox_stat);
 	  return 0;
 	}
diff --git a/mu/imap.c b/mu/imap.c
index 892fb87..4edce2d 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -163,10 +163,9 @@ imap_prompt_env ()
 
 /* Callbacks */
 static void
-imap_popauth_callback (void *data, int code, va_list ap)
+imap_popauth_callback (void *data, int code, size_t sdat, void *pdat)
 {
-  int rcode = va_arg (ap, int);
-  const char *text = va_arg (ap, const char *);
+  const char *text = pdat;
   if (text)
     mu_diag_output (MU_DIAG_INFO, _("session authenticated: %s"), text);
   else
@@ -174,10 +173,9 @@ imap_popauth_callback (void *data, int code, va_list ap)
 }
 
 static void
-imap_bye_callback (void *data, int code, va_list ap)
+imap_bye_callback (void *data, int code, size_t sdat, void *pdat)
 {
-  int rcode = va_arg (ap, int);
-  const char *text = va_arg (ap, const char *);
+  const char *text = pdat;
   if (text)
     mu_diag_output (MU_DIAG_INFO, _("server is closing connection: %s"), text);
   else


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 28 05:12:59 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RUyCp-0007hW-BU
	for mharc-commit-mailutils@gnu.org; Mon, 28 Nov 2011 05:12:59 -0500
Received: from eggs.gnu.org ([140.186.70.92]:56188)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUyCe-0007gm-SB
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 05:12:57 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUyCV-00086t-HH
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 05:12:48 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:57107)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUyCV-00086o-6W
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 05:12:39 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUyCO-0006wR-LT
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 10:12:38 +0000
Date: Mon, 28 Nov 2011 10:12:32 +0000
Message-Id: <E1RUyCO-0006wR-LT@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-478-g9370af7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 30594fa89df0ffbfb40644ef7fec819511dae6eb
X-Git-Newrev: 9370af7c2bbb53b7873ca6e26df058c84a0e487f
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Nov 2011 10:12:57 -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=9370af7c2bbb53b7873ca6e26df058c84a0e487f

The branch, master has been updated
       via  9370af7c2bbb53b7873ca6e26df058c84a0e487f (commit)
       via  0d6303f869ef2525c0bda2cbeae92668ccf95308 (commit)
      from  30594fa89df0ffbfb40644ef7fec819511dae6eb (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 9370af7c2bbb53b7873ca6e26df058c84a0e487f
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 28 12:01:30 2011 +0200

    imap4d: rewrite testsuite in Autotest.
    
    * configure.ac (IMAP_AUTHOBJS): Remove subst variable.  Use conditional
    instead.
    Configure imap4d/tests for testing.
    Build imap4d/tests/Makefile and imap4d/tests/atlocal.
    * imap4d/Makefile.am (SUBDIRS): Add tests.
    [MU_COND_GSASL]: Define AUTH_GSASL
    [MU_COND_GSSAPI]: Define AUTH_GSSAPI
    (imap4d_SOURCES): Include AUTH_GSASL and AUTH_GSSAPI
    (imap4d_LDADD,imap4d_DEPENDENCIES): Remove reference to IMAP_AUTHOBJS.
    (EXTRA_DIST): Remove.
    
    * imap4d/tests/.gitignore: New file.
    * imap4d/tests/IDEF0955.at: New file
    * imap4d/tests/IDEF0956.at: New file
    * imap4d/tests/Makefile.am
    * imap4d/tests/anystate.at: New file
    * imap4d/tests/atlocal.in
    * imap4d/tests/create01.at: New file
    * imap4d/tests/create02.at: New file
    * imap4d/tests/examine.at: New file
    * imap4d/tests/expunge.at: New file
    * imap4d/tests/id.at: New file
    * imap4d/tests/list.at: New file
    * imap4d/tests/search.at: New file
    * imap4d/tests/select.at: New file
    * imap4d/tests/status.at: New file
    * imap4d/tests/testsuite.at: New file
    
    * imap4d/fetch.c (fetch_io): Improve range checking.  If the requested
    number of bytes is greater than maximum, truncate it.
    * imap4d/imap4d.c: New option --test.
    (test_mode): New global variable.
    (imap4d_session_setup0): Fix improperly allocated automatic variable.
    (main): Call GSASL and GSSAPI initializations only if mu_gsasl_enabled()
    returns true.
    * imap4d/imap4d.h (test_mode): New extern.
    * imap4d/preauth.c: Do not complain about failed getpeername in test mode.
    * imap4d/select.c: Fix human-readable response texts.
    
    * include/mailutils/gsasl.h (mu_gsasl_module_data)<enable>: New member.
    (mu_gsasl_enabled): New proto.
    * libmailutils/mailbox/mailbox.c (mu_mailbox_flush):
    (mu_mailbox_append_message,mu_mailbox_sync)
    (mu_mailbox_expunge): Use MU_STREAM_WRITE instead of MU_STREAM_RDWR.
    * libmu_auth/gsasl.c (mu_gsasl_module_data): Fix initialization.
    (mu_gsasl_enabled): New function.
    * libmu_cfg/gsasl.c (mu_gsasl_param): New parameter "enable".

commit 0d6303f869ef2525c0bda2cbeae92668ccf95308
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Nov 27 12:05:18 2011 +0200

    imap4d: fix FETCH (BODYSTRUCTURE)
    
    * imap4d/fetch.c (bodystructure): Do not emit CHARSET pair if there is
    none in the Content-Type header.
    (fetch_get_part_rfc822): Use mu_message_unencapsulate
    * libmailutils/mime/attachment.c (mu_message_unencapsulate): Use
    mu_stream_to_message to create destination message.  This ensures that
    the latter can be handled by other MU functions (e.g. mu_header_*
    family).

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

Summary of changes:
 configure.ac                                       |    7 +-
 imap4d/Makefile.am                                 |   22 ++--
 imap4d/fetch.c                                     |   39 ++----
 imap4d/imap4d.c                                    |   32 +++--
 imap4d/imap4d.h                                    |    2 +
 imap4d/preauth.c                                   |    9 +-
 imap4d/select.c                                    |    4 +-
 {maidag => imap4d}/tests/.gitignore                |    0
 imap4d/tests/IDEF0955.at                           |   54 +++++++
 imap4d/tests/IDEF0956.at                           |   52 +++++++
 {maidag => imap4d}/tests/Makefile.am               |   21 ++-
 .../encode2047.at => imap4d/tests/anystate.at      |   30 +++--
 imap4d/tests/atlocal.in                            |   32 ++++
 .../encode2047.at => imap4d/tests/create01.at      |   22 ++-
 .../encode2047.at => imap4d/tests/create02.at      |   22 ++-
 sieve/tests/ext.at => imap4d/tests/examine.at      |   41 +++---
 sieve/tests/ext.at => imap4d/tests/expunge.at      |   49 ++++---
 .../tests/encode2047.at => imap4d/tests/id.at      |   33 +++--
 imap4d/tests/list.at                               |  143 ++++++++++++++++++
 imap4d/tests/search.at                             |  153 ++++++++++++++++++++
 sieve/tests/ext.at => imap4d/tests/select.at       |   41 +++---
 .../tests/encode2047.at => imap4d/tests/status.at  |   26 ++--
 imap4d/tests/testsuite.at                          |   84 +++++++++++
 include/mailutils/gsasl.h                          |    9 +-
 libmailutils/mailbox/mailbox.c                     |    8 +-
 libmailutils/mime/attachment.c                     |   14 +--
 libmu_auth/gsasl.c                                 |   20 +++-
 libmu_cfg/gsasl.c                                  |    2 +
 28 files changed, 773 insertions(+), 198 deletions(-)
 copy {maidag => imap4d}/tests/.gitignore (100%)
 create mode 100644 imap4d/tests/IDEF0955.at
 create mode 100644 imap4d/tests/IDEF0956.at
 copy {maidag => imap4d}/tests/Makefile.am (90%)
 copy libmailutils/tests/encode2047.at => imap4d/tests/anystate.at (60%)
 create mode 100644 imap4d/tests/atlocal.in
 copy libmailutils/tests/encode2047.at => imap4d/tests/create01.at (69%)
 copy libmailutils/tests/encode2047.at => imap4d/tests/create02.at (68%)
 copy sieve/tests/ext.at => imap4d/tests/examine.at (58%)
 copy sieve/tests/ext.at => imap4d/tests/expunge.at (51%)
 copy libmailutils/tests/encode2047.at => imap4d/tests/id.at (60%)
 create mode 100644 imap4d/tests/list.at
 create mode 100644 imap4d/tests/search.at
 copy sieve/tests/ext.at => imap4d/tests/select.at (57%)
 copy libmailutils/tests/encode2047.at => imap4d/tests/status.at (65%)
 create mode 100644 imap4d/tests/testsuite.at

diff --git a/configure.ac b/configure.ac
index f720b7a..6d6fb9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -246,7 +246,6 @@ case "${withval}" in
   *)   AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
 esac],[usereadline=yes])
 
-AC_SUBST(IMAP_AUTHOBJS)
 AC_SUBST(SERV_AUTHLIBS)
 AC_SUBST(SERV_AUTHINCS)
 
@@ -283,15 +282,14 @@ if test "x$status_gssapi" != "xno"; then
       esac
     done
     SERV_AUTHINCS="$SERV_AUTHINCS $GSSAPI_CFLAGS"
-    IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gss.o"
     AC_DEFINE(WITH_GSSAPI,1,[Define if mailutils is using GSSAPI])
   fi
 fi
+AM_CONDITIONAL([MU_COND_GSSAPI],[test "$status_gssapi" = "yes"])
 
 MU_CHECK_GSASL(0.2.3, [
     AC_DEFINE(WITH_GSASL,1,[Define if mailutils is using GNU SASL])
     MU_AUTHLIBS="$MU_AUTHLIBS $GSASL_LIBS"
-    IMAP_AUTHOBJS="$IMAP_AUTHOBJS auth_gsasl.o"
     status_gsasl=yes])
 AM_CONDITIONAL([MU_COND_GSASL],[test "$status_gsasl" = "yes"])
 
@@ -1304,6 +1302,7 @@ AC_CONFIG_TESTDIR(readmsg/tests)
 AC_CONFIG_TESTDIR(sieve/tests)
 AC_CONFIG_TESTDIR(mh/tests)
 AC_CONFIG_TESTDIR(comsat/tests)
+AC_CONFIG_TESTDIR(imap4d/tests)
 
 AC_CONFIG_FILES([libmailutils/tests/Makefile
                  libmailutils/tests/atlocal
@@ -1315,6 +1314,8 @@ AC_CONFIG_FILES([libmailutils/tests/Makefile
                  comsat/tests/atlocal
                  frm/tests/Makefile
                  frm/tests/atlocal
+                 imap4d/tests/Makefile
+                 imap4d/tests/atlocal
 		 maidag/tests/Makefile
 		 maidag/tests/atlocal
 		 messages/tests/Makefile
diff --git a/imap4d/Makefile.am b/imap4d/Makefile.am
index d8a7b96..8ecd427 100644
--- a/imap4d/Makefile.am
+++ b/imap4d/Makefile.am
@@ -16,13 +16,22 @@
 ## along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
 INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@ 
-SUBDIRS = testsuite
+SUBDIRS = tests testsuite
 
 sbin_PROGRAMS =	imap4d
 
+if MU_COND_GSASL
+ AUTH_GSASL = auth_gsasl.c
+endif
+
+if MU_COND_GSSAPI
+ AUTH_GSSAPI = auth_gss.c
+endif
+
 imap4d_SOURCES = \
  append.c\
  authenticate.c\
+ $(AUTH_GSASL)\
  bye.c\
  capability.c\
  check.c\
@@ -62,7 +71,6 @@ imap4d_SOURCES = \
  util.c
 
 imap4d_LDADD = \
- @IMAP_AUTHOBJS@\
  ${MU_APP_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_MH}\
@@ -72,16 +80,12 @@ imap4d_LDADD = \
  ${MU_LIB_MAILUTILS}\
  @SERV_AUTHLIBS@ @MU_COMMON_LIBRARIES@ @TCPWRAP_LIBRARIES@
 
-## This kludge is necessary to correctly establish imap4d -> IMAP_AUTHOBJS
-## and imap4d -> MU_AUTHLIBS dependencies. Automake stupidly refuses to 
-## include them.
-## Same kludge appears in pop3d/Makefile.am and auth/Makefile.am
+## This kludge is necessary to correctly establish imap4d -> MU_AUTHLIBS
+## dependencies. Automake stupidly refuses to include them.
+## The same kludge appears in pop3d/Makefile.am and auth/Makefile.am
 ## Think about better approach         --gray
 imap4d_DEPENDENCIES = \
- @IMAP_AUTHOBJS@\
  @MU_AUTHLIBS_DEPENDENCY@\
  ../lib/libmuaux.a\
  ${MU_LIB_MBOX}\
  ${MU_LIB_MAILUTILS}
-
-EXTRA_DIST=auth_gss.c auth_gsasl.c
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index ec8d1e8..05c843e 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -393,11 +393,10 @@ bodystructure (mu_message_t msg, int extension)
       io_send_qstring (s);
 
       /* body parameter parenthesized list: Content-type attributes */
-      if (ws.ws_wordc > 1 || text_plain)
+      if (ws.ws_wordc > 1)
 	{
 	  int space = 0;
 	  char *lvalue = NULL;
-	  int have_charset = 0;
 	  int i;
 	  
 	  io_sendf (" (");
@@ -429,8 +428,6 @@ bodystructure (mu_message_t msg, int extension)
 		  
 		default:
 		  lvalue = ws.ws_wordv[i];
-		  if (mu_c_strcasecmp (lvalue, "charset") == 0)
-		    have_charset = 1;
 		}
 	    }
 	  
@@ -440,13 +437,7 @@ bodystructure (mu_message_t msg, int extension)
 		io_sendf (" ");
 	      io_send_qstring (lvalue);
 	    }
-	  
-	  if (!have_charset && text_plain)
-	    {
-	      if (space)
-		io_sendf (" ");
-	      io_sendf ("\"CHARSET\" \"US-ASCII\"");
-	    }
+
 	  io_sendf (")");
 	}
       else
@@ -726,15 +717,10 @@ fetch_get_part_rfc822 (struct fetch_function_closure *ffc,
 
       if (rc == 0)
 	{
-	  mu_body_t body;
-	  mu_stream_t str;
-	  
-	  if (mu_message_get_body (msg, &body) ||
-	      mu_body_get_streamref (body, &str))
-	    return NULL;
-
-	  rc = mu_stream_to_message (str, &retmsg);
-	  mu_stream_unref (str);
+	  rc = mu_message_unencapsulate  (msg, &retmsg, NULL);
+	  if (rc)
+	    mu_error (_("%s failed: %s"), "mu_message_unencapsulate",
+		      mu_strerror (rc));
 	}
     }
   
@@ -798,17 +784,20 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
       io_sendf ("<%lu>", (unsigned long) start);
       io_sendf (" \"\"");
     }
-  else if (size + 2 < size) /* Check for integer overflow */
-    {
-      mu_stream_destroy (&rfc);
-      return RESP_BAD;
-    }
   else
     {
       int rc;
       char *buffer, *p;
       size_t total = 0;
 
+      if (size > max)
+	size = max;
+      if (size + 2 < size) /* Check for integer overflow */
+	{
+	  mu_stream_destroy (&rfc);
+	  return RESP_BAD;
+	}
+      
       p = buffer = malloc (size + 1);
       if (!p)
 	imap4d_bye (ERR_NO_MEM);
diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c
index 65d678c..e27948f 100644
--- a/imap4d/imap4d.c
+++ b/imap4d/imap4d.c
@@ -52,18 +52,22 @@ int ident_port;
 char *ident_keyfile;
 int ident_encrypt_only;
 
+int test_mode;
+
 const char *program_version = "imap4d (" PACKAGE_STRING ")";
 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon.");
 
 #define OPT_PREAUTH         259
 #define OPT_FOREGROUND      260
+#define OPT_TEST_MODE       261
 
 static struct argp_option options[] = {
   { "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0},
   { "inetd",  'i', 0, 0, N_("run in inetd mode"), 0},
   { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL,
     N_("runs in daemon mode with a maximum of NUMBER children"), 0 },
-
+  { "test", OPT_TEST_MODE, 0, 0,
+    N_("run in test mode"), 0 },
   { "preauth", OPT_PREAUTH, NULL, 0,
     N_("start in preauth mode") },
   
@@ -119,6 +123,11 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state)
     case OPT_PREAUTH:
       preauth_mode = preauth_stdio;
       break;
+
+    case OPT_TEST_MODE:
+      mu_argp_node_list_new (lst, "mode", "inetd");
+      test_mode = 1;
+      break;
       
     case ARGP_KEY_INIT:
       mu_argp_node_list_init (&lst);
@@ -318,7 +327,7 @@ imap4d_session_setup0 ()
     {
       char *expr = mu_tilde_expansion (modify_homedir, "/", real_homedir);
       struct mu_wordsplit ws;
-      const char *env[3];
+      const char *env[5];
 
       env[0] = "user";
       env[1] = auth_data->name;
@@ -414,9 +423,11 @@ imap4d_mainloop (int ifd, int ofd, int tls)
 {
   imap4d_tokbuf_t tokp;
   char *text;
-  int debug_mode = isatty (ifd);
   int signo;
 
+  if (!test_mode)
+    test_mode = isatty (ifd);
+
   if ((signo = setjmp (child_jmp)))
     {
       mu_diag_output (MU_DIAG_CRIT, _("got signal `%s'"), strsignal (signo));
@@ -453,10 +464,10 @@ imap4d_mainloop (int ifd, int ofd, int tls)
 
   if (imap4d_preauth_setup (ifd) == 0)
     {
-      if (debug_mode)
+      if (test_mode)
 	{
-	  mu_diag_output (MU_DIAG_INFO, _("started in debugging mode"));
-	  text = "IMAP4rev1 Debugging mode";
+	  mu_diag_output (MU_DIAG_INFO, _("started in test mode"));
+	  text = "IMAP4rev1 Test mode";
 	}
       else
 	text = "IMAP4rev1";
@@ -603,9 +614,12 @@ main (int argc, char **argv)
 #endif
 
   namespace_init ();
-  
-  auth_gssapi_init ();
-  auth_gsasl_init ();
+
+  if (mu_gsasl_enabled ())
+    {
+      auth_gssapi_init ();
+      auth_gsasl_init ();
+    }
 
 #ifdef USE_LIBPAM
   if (!mu_pam_service)
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index 3ece140..b2290a1 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -204,6 +204,8 @@ extern int imap4d_argc;
 extern char **imap4d_argv;
 extern jmp_buf child_jmp;
 
+extern int test_mode;
+  
 /* Input functions */
 extern mu_stream_t iostream;
 extern int  io_untagged_response (int, const char *, ...) MU_PRINTFLIKE(2,3);
diff --git a/imap4d/preauth.c b/imap4d/preauth.c
index 43cd6b2..f9380aa 100644
--- a/imap4d/preauth.c
+++ b/imap4d/preauth.c
@@ -485,8 +485,13 @@ imap4d_preauth_setup (int fd)
     }
   else
     psrv_sa = &srv_sa;
-  
-  if (getpeername (fd, (struct sockaddr *) &clt_sa, &clt_len) == -1)
+
+  if (test_mode)
+    {
+      pclt_sa = NULL;
+      clt_len = 0;
+    }
+  else if (getpeername (fd, (struct sockaddr *) &clt_sa, &clt_len) == -1)
     {
       mu_diag_output (MU_DIAG_ERROR,
 		      _("cannot obtain IP address of client: %s"),
diff --git a/imap4d/select.c b/imap4d/select.c
index 166e0d7..8a61ad5 100644
--- a/imap4d/select.c
+++ b/imap4d/select.c
@@ -137,14 +137,14 @@ imap4d_select_status ()
   io_untagged_response (RESP_OK, "[UIDNEXT %lu] Predicted next uid",
 	                   (unsigned long) uidnext);
   if (unseen)
-    io_untagged_response (RESP_OK, "[UNSEEN %lu] first unseen messsage ",
+    io_untagged_response (RESP_OK, "[UNSEEN %lu] first unseen messsage",
 	                     (unsigned long) unseen);
   io_untagged_response (RESP_NONE, "FLAGS (%s)", mflags);
   /* 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_WRITE))
-    io_untagged_response (RESP_OK, "[PERMANENTFLAGS ()] No Permanent flags");
+    io_untagged_response (RESP_OK, "[PERMANENTFLAGS ()] No permanent flags");
   else
     io_untagged_response (RESP_OK, "[PERMANENTFLAGS (%s)] Permanent flags",
                           mflags);
diff --git a/maidag/tests/.gitignore b/imap4d/tests/.gitignore
similarity index 100%
copy from maidag/tests/.gitignore
copy to imap4d/tests/.gitignore
diff --git a/imap4d/tests/IDEF0955.at b/imap4d/tests/IDEF0955.at
new file mode 100644
index 0000000..63fd765
--- /dev/null
+++ b/imap4d/tests/IDEF0955.at
@@ -0,0 +1,54 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([IDEF0955])
+
+AT_CHECK([
+limit=`expr $MU_ULONG_MAX - 1`
+
+cat > input <<EOT
+1 select INBOX
+2 FETCH 1:$limit FLAGS
+3 UID FETCH 1:$limit FLAGS
+X LOGOUT
+EOT
+
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/mbox1,INBOX)
+
+imap4d IMAP4D_OPTIONS < input | remove_uidvalidity | tr -d '\r'
+],
+[0],
+[* PREAUTH IMAP4rev1 Test mode
+* 5 EXISTS
+* 5 RECENT
+* OK [[UIDNEXT 6]] Predicted next uid
+* OK [[UNSEEN 1]] first unseen messsage
+* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
+* OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
+1 OK [[READ-WRITE]] SELECT Completed
+2 OK FETCH Completed
+* 1 FETCH (UID 1 FLAGS (\Recent))
+* 2 FETCH (UID 2 FLAGS (\Recent))
+* 3 FETCH (UID 3 FLAGS (\Recent))
+* 4 FETCH (UID 4 FLAGS (\Recent))
+* 5 FETCH (UID 5 FLAGS (\Recent))
+3 OK UID FETCH Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+])
+
+AT_CLEANUP
+
diff --git a/imap4d/tests/IDEF0956.at b/imap4d/tests/IDEF0956.at
new file mode 100644
index 0000000..5a72d00
--- /dev/null
+++ b/imap4d/tests/IDEF0956.at
@@ -0,0 +1,52 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([IDEF0956])
+
+AT_CHECK([
+limit=`expr $MU_ULONG_MAX - 1`
+
+cat > input <<EOT
+1 select INBOX
+2 FETCH 1 BODY[[TEXT]]<0.$limit>
+X LOGOUT
+EOT
+
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
+
+imap4d IMAP4D_OPTIONS < input | remove_uidvalidity | tr -d '\r'
+],
+[0],
+[* PREAUTH IMAP4rev1 Test mode
+* 8 EXISTS
+* 5 RECENT
+* OK [[UIDNEXT 9]] Predicted next uid
+* OK [[UNSEEN 4]] first unseen messsage
+* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
+* OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
+1 OK [[READ-WRITE]] SELECT Completed
+* 1 FETCH (BODY[[TEXT]]<0> {161}
+ABASEMENT, n.  A decent and customary mental attitude in the presence
+of wealth of power.  Peculiarly appropriate in an employee when
+addressing an employer.
+)
+2 OK FETCH Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+])
+
+AT_CLEANUP
+
diff --git a/maidag/tests/Makefile.am b/imap4d/tests/Makefile.am
similarity index 90%
copy from maidag/tests/Makefile.am
copy to imap4d/tests/Makefile.am
index 70ed751..0b55221 100644
--- a/maidag/tests/Makefile.am
+++ b/imap4d/tests/Makefile.am
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils.
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -40,11 +39,19 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
 ## ------------ ##
 
 TESTSUITE_AT = \
- forward.at\
- lmtp.at\
- mda.at\
- testsuite.at\
- url-mbox.at
+ anystate.at\
+ create01.at\
+ create02.at\
+ examine.at\
+ expunge.at\
+ id.at\
+ IDEF0955.at\
+ IDEF0956.at\
+ list.at\
+ search.at\
+ select.at\
+ status.at\
+ testsuite.at
 
 TESTSUITE = $(srcdir)/testsuite
 M4=m4
diff --git a/libmailutils/tests/encode2047.at b/imap4d/tests/anystate.at
similarity index 60%
copy from libmailutils/tests/encode2047.at
copy to imap4d/tests/anystate.at
index 5cfcea5..2d25b12 100644
--- a/libmailutils/tests/encode2047.at
+++ b/imap4d/tests/anystate.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,18 +14,27 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([encode2047])
-AT_KEYWORDS([encode])
+AT_SETUP([Non-authenticated state])
+AT_KEYWORDS([anystate])
 
-AT_CHECK([
-AT_DATA(input,[dnl
-\\345\326\305\304\316\305\327\316\331\312\040\317\324\336\305\324
-])
+m4_pushdef([IMAP4D_OPTIONS],[IMAP4D_DEFAULT_OPTIONS])
 
-encode2047 -c koi8-r -eB -o < input],
-[0],
-[=?koi8-r?B?5dbFxM7F187ZyiDP1N7F1A==?=
+IMAP4D_CHECK([],
+[1 CAPABILITY
+2 NOOP
+3 NAMESPACE
+X LOGOUT
+],
+[* OK IMAP4rev1 Test mode
+* CAPABILITY IMAP4rev1 NAMESPACE ID IDLE LITERAL+ UNSELECT
+1 OK CAPABILITY Completed
+2 OK NOOP Completed
+3 BAD NAMESPACE Wrong state
+* BYE Session terminating.
+X OK LOGOUT Completed
 ])
 
+m4_popdef([IMAP4D_OPTIONS])
+
 AT_CLEANUP
 
diff --git a/imap4d/tests/atlocal.in b/imap4d/tests/atlocal.in
new file mode 100644
index 0000000..d1d49ef
--- /dev/null
+++ b/imap4d/tests/atlocal.in
@@ -0,0 +1,32 @@
+# @configure_input@                                     -*- shell-script -*-
+# Configurable variable values for Mailutils test suite.
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+PATH=@abs_builddir@:@abs_top_builddir@/imap4d:$top_srcdir:$srcdir:$PATH
+MU_ULONG_MAX=@MU_ULONG_MAX@
+
+remove_untagged() {
+  sed '/^\*/d'
+}
+
+filter_untagged() {
+  sed 's/\(^\* \(OK\|BAD\|NO\|PREAUTH\)\).*/\1/'
+}
+
+remove_uidvalidity() {
+  sed '/^\* OK \[UIDVALIDITY/d'
+}
+
+remove_select_unagged() {
+  sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d'
+}
+
+sorted_list_output() {
+  sed '/^\* PREAUTH/d
+       /^\* OK/d
+       /^\* BYE/d
+       /^\* [0-9][0-9]* EXISTS/d
+       /^\* [0-9][0-9]* RECENT/d
+       /^\* FLAGS/d
+       /^[0-9X][0-9]* OK/d' | sort
+}       
diff --git a/libmailutils/tests/encode2047.at b/imap4d/tests/create01.at
similarity index 69%
copy from libmailutils/tests/encode2047.at
copy to imap4d/tests/create01.at
index 5cfcea5..986eb86 100644
--- a/libmailutils/tests/encode2047.at
+++ b/imap4d/tests/create01.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,17 +14,24 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([encode2047])
-AT_KEYWORDS([encode])
+AT_SETUP([create])
+AT_KEYWORDS([create create00])
 
 AT_CHECK([
-AT_DATA(input,[dnl
-\\345\326\305\304\316\305\327\316\331\312\040\317\324\336\305\324
+AT_DATA([input],[dnl
+1 create flat
+X LOGOUT
 ])
 
-encode2047 -c koi8-r -eB -o < input],
+imap4d IMAP4D_OPTIONS < input | tr -d '\r'
+find . -name flat
+],
 [0],
-[=?koi8-r?B?5dbFxM7F187ZyiDP1N7F1A==?=
+[* PREAUTH IMAP4rev1 Test mode
+1 OK CREATE Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+./flat
 ])
 
 AT_CLEANUP
diff --git a/libmailutils/tests/encode2047.at b/imap4d/tests/create02.at
similarity index 68%
copy from libmailutils/tests/encode2047.at
copy to imap4d/tests/create02.at
index 5cfcea5..552e8d3 100644
--- a/libmailutils/tests/encode2047.at
+++ b/imap4d/tests/create02.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,17 +14,24 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([encode2047])
-AT_KEYWORDS([encode])
+AT_SETUP([create nested])
+AT_KEYWORDS([create create01])
 
 AT_CHECK([
-AT_DATA(input,[dnl
-\\345\326\305\304\316\305\327\316\331\312\040\317\324\336\305\324
+AT_DATA([input],[dnl
+1 create en/to/tre
+X LOGOUT
 ])
 
-encode2047 -c koi8-r -eB -o < input],
+imap4d IMAP4D_OPTIONS < input | tr -d '\r'
+find . -name tre
+],
 [0],
-[=?koi8-r?B?5dbFxM7F187ZyiDP1N7F1A==?=
+[* PREAUTH IMAP4rev1 Test mode
+1 OK CREATE Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+./en/to/tre
 ])
 
 AT_CLEANUP
diff --git a/sieve/tests/ext.at b/imap4d/tests/examine.at
similarity index 58%
copy from sieve/tests/ext.at
copy to imap4d/tests/examine.at
index f4c7193..6b3dbff 100644
--- a/sieve/tests/ext.at
+++ b/imap4d/tests/examine.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,30 +14,24 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([loadable extensions: numaddr])
-AT_KEYWORDS([ext])
+AT_SETUP([examine])
 
-AT_CHECK([
-MUT_PREREQ_CAPA([HAVE_LIBLTDL])
-
-AT_DATA([prog],[
-require "test-numaddr";
-
-if numaddr [[ "to", "cc" ]] :over 5
-  {
-    discard;
-  }
-])
-
-MUT_MBCOPY($abs_top_srcdir/testsuite/spool/bigto.mbox)
-
-sieve MUT_SIEVE_CMDLINE dnl
- --clearpath -L "${abs_top_builddir}/examples" -f ./bigto.mbox prog
+IMAP4D_CHECK([
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
+],
+[1 EXAMINE INBOX
+X LOGOUT
 ],
-[0],
-[],
-[DISCARD on msg uid 1: marking as deleted
+[* PREAUTH IMAP4rev1 Test mode
+* 8 EXISTS
+* 5 RECENT
+* OK [[UIDNEXT 9]] Predicted next uid
+* OK [[UNSEEN 4]] first unseen messsage
+* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
+* OK [[PERMANENTFLAGS ()]] No permanent flags
+1 OK [[READ-ONLY]] EXAMINE Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
 ])
 
 AT_CLEANUP
-
diff --git a/sieve/tests/ext.at b/imap4d/tests/expunge.at
similarity index 51%
copy from sieve/tests/ext.at
copy to imap4d/tests/expunge.at
index f4c7193..fe01f79 100644
--- a/sieve/tests/ext.at
+++ b/imap4d/tests/expunge.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,30 +14,32 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([loadable extensions: numaddr])
-AT_KEYWORDS([ext])
+AT_SETUP([expunge])
 
-AT_CHECK([
-MUT_PREREQ_CAPA([HAVE_LIBLTDL])
-
-AT_DATA([prog],[
-require "test-numaddr";
-
-if numaddr [[ "to", "cc" ]] :over 5
-  {
-    discard;
-  }
-])
-
-MUT_MBCOPY($abs_top_srcdir/testsuite/spool/bigto.mbox)
-
-sieve MUT_SIEVE_CMDLINE dnl
- --clearpath -L "${abs_top_builddir}/examples" -f ./bigto.mbox prog
+IMAP4D_CHECK([
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,temp)
+sed 's/^\(Status: .*\)/\1D/' temp > INBOX
+],
+[1 SELECT INBOX
+2 EXPUNGE
+X LOGOUT
 ],
-[0],
-[],
-[DISCARD on msg uid 1: marking as deleted
+[* PREAUTH IMAP4rev1 Test mode
+* 8 EXISTS
+* 5 RECENT
+* OK [[UIDNEXT 9]] Predicted next uid
+* OK [[UNSEEN 4]] first unseen messsage
+* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
+* OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
+1 OK [[READ-WRITE]] SELECT Completed
+* 1 EXPUNGED
+* 1 EXPUNGED
+* 1 EXPUNGED
+* 5 EXISTS
+* 5 RECENT
+2 OK EXPUNGE Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
 ])
 
 AT_CLEANUP
-
diff --git a/libmailutils/tests/encode2047.at b/imap4d/tests/id.at
similarity index 60%
copy from libmailutils/tests/encode2047.at
copy to imap4d/tests/id.at
index 5cfcea5..a43e91d 100644
--- a/libmailutils/tests/encode2047.at
+++ b/imap4d/tests/id.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,17 +14,31 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([encode2047])
-AT_KEYWORDS([encode])
+AT_SETUP([ID command])
+AT_KEYWORDS([id])
 
-AT_CHECK([
-AT_DATA(input,[dnl
-\\345\326\305\304\316\305\327\316\331\312\040\317\324\336\305\324
+m4_pushdef([IMAP4D_OPTIONS],[IMAP4D_DEFAULT_OPTIONS])
+
+IMAP4D_CHECK([],
+[1 ID NIL
+X LOGOUT
+],
+[* OK IMAP4rev1 Test mode
+1 BAD ID Wrong state
+* BYE Session terminating.
+X OK LOGOUT Completed
 ])
 
-encode2047 -c koi8-r -eB -o < input],
-[0],
-[=?koi8-r?B?5dbFxM7F187ZyiDP1N7F1A==?=
+m4_popdef([IMAP4D_OPTIONS])
+
+IMAP4D_CHECK([],
+[1 ID NIL
+X LOGOUT
+],
+[* PREAUTH IMAP4rev1 Test mode
+1 OK ID Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
 ])
 
 AT_CLEANUP
diff --git a/imap4d/tests/list.at b/imap4d/tests/list.at
new file mode 100644
index 0000000..bb0480d
--- /dev/null
+++ b/imap4d/tests/list.at
@@ -0,0 +1,143 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+m4_pushdef([IMAP4D_HOMEDIR],[spool])
+
+dnl LIST_CHECK([NAME],[KW],[ARG],[OUTPUT],[EXTRA-CODE],[filter,][expand]
+m4_define([LIST_CHECK],[
+AT_SETUP([$1])
+AT_KEYWORDS([list $2])
+
+IMAP4D_CHECK([
+mkdir IMAP4D_HOMEDIR
+m4_foreach([MAILBOX],[bigto.mbox,mbox1,mbox,relational.mbox,relational.mbox,
+ search.mbox,sieve.mbox,teaparty.mbox],[
+  MUT_MBCOPY($abs_top_srcdir/testsuite/spool/MAILBOX,IMAP4D_HOMEDIR)
+])
+$5
+],
+[1 LIST $3
+X LOGOUT
+],
+[$4],
+[],
+[sorted_list_output[]m4_if([$6],,,|[$6])],[$7])
+AT_CLEANUP
+])
+
+dnl ----------------------------------------------------------------------
+LIST_CHECK([asterisk],[list00],
+["~" "*"],
+[dnl
+* LIST (\NoInferiors) "/" ~/bigto.mbox
+* LIST (\NoInferiors) "/" ~/mbox
+* LIST (\NoInferiors) "/" ~/mbox1
+* LIST (\NoInferiors) "/" ~/relational.mbox
+* LIST (\NoInferiors) "/" ~/search.mbox
+* LIST (\NoInferiors) "/" ~/sieve.mbox
+* LIST (\NoInferiors) "/" ~/teaparty.mbox
+])
+
+LIST_CHECK([percent],[list01],
+["~" "%"],
+[dnl
+* LIST (\NoInferiors) "/" ~/bigto.mbox
+* LIST (\NoInferiors) "/" ~/mbox
+* LIST (\NoInferiors) "/" ~/mbox1
+* LIST (\NoInferiors) "/" ~/relational.mbox
+* LIST (\NoInferiors) "/" ~/search.mbox
+* LIST (\NoInferiors) "/" ~/sieve.mbox
+* LIST (\NoInferiors) "/" ~/teaparty.mbox
+])
+
+LIST_CHECK([empty ref + asterisk],[list02],
+["" "*"],
+[dnl
+* LIST (\NoInferiors) "/" bigto.mbox
+* LIST (\NoInferiors) "/" mbox
+* LIST (\NoInferiors) "/" mbox1
+* LIST (\NoInferiors) "/" relational.mbox
+* LIST (\NoInferiors) "/" search.mbox
+* LIST (\NoInferiors) "/" sieve.mbox
+* LIST (\NoInferiors) "/" teaparty.mbox
+* LIST (\NoInferiors) NIL INBOX
+])
+
+LIST_CHECK([root ref + asterisk],[list03],
+["/" "*"],
+[dnl
+1 NO LIST The requested item could not be found.
+])
+
+LIST_CHECK([absolute reference + asterisk],[list04],
+["$cwd/spool" "*"],
+[dnl
+* LIST (\NoInferiors) "/" ////bigto.mbox
+* LIST (\NoInferiors) "/" ////folder/one
+* LIST (\NoInferiors) "/" ////folder/two
+* LIST (\NoInferiors) "/" ////mbox
+* LIST (\NoInferiors) "/" ////mbox1
+* LIST (\NoInferiors) "/" ////relational.mbox
+* LIST (\NoInferiors) "/" ////search.mbox
+* LIST (\NoInferiors) "/" ////sieve.mbox
+* LIST (\NoInferiors) "/" ////teaparty.mbox
+* LIST (\NoSelect) "/" ////folder
+],
+[mkdir IMAP4D_HOMEDIR/folder
+ MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
+ MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)],
+[sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
+[expand])
+
+LIST_CHECK([absolute reference + percent],[list05],
+["$cwd/spool" "%"],
+[dnl
+* LIST (\NoInferiors) "/" ////bigto.mbox
+* LIST (\NoInferiors) "/" ////mbox
+* LIST (\NoInferiors) "/" ////mbox1
+* LIST (\NoInferiors) "/" ////relational.mbox
+* LIST (\NoInferiors) "/" ////search.mbox
+* LIST (\NoInferiors) "/" ////sieve.mbox
+* LIST (\NoInferiors) "/" ////teaparty.mbox
+* LIST (\NoSelect) "/" ////folder
+],
+[mkdir IMAP4D_HOMEDIR/folder
+ MUT_MBCOPY($abs_top_srcdir/testsuite/folder/one,IMAP4D_HOMEDIR/folder)
+ MUT_MBCOPY($abs_top_srcdir/testsuite/folder/two,IMAP4D_HOMEDIR/folder)],
+[sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
+[expand])
+
+LIST_CHECK([absolute reference + mailbox],[list06],
+["$cwd/spool" "search.mbox"],
+[dnl
+* LIST (\NoInferiors) "/" ////search.mbox
+],
+[],
+[sed "s|$cwd/IMAP4D_HOMEDIR|///|"],
+[expand])
+
+LIST_CHECK([empty reference + INBOX],[list07],
+["" INBOX],
+[dnl
+* LIST (\NoInferiors) NIL INBOX
+])
+
+dnl ----------------------------------------------------------------------
+
+m4_popdef([IMAP4D_HOMEDIR])
+
+
+
diff --git a/imap4d/tests/search.at b/imap4d/tests/search.at
new file mode 100644
index 0000000..4d55068
--- /dev/null
+++ b/imap4d/tests/search.at
@@ -0,0 +1,153 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl SEARCH_CHECK([NAME],[KW],[ARG],[OUTPUT])
+m4_define([SEARCH_CHECK],[
+AT_SETUP([$1])
+AT_KEYWORDS([search $2])
+IMAP4D_CHECK([
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
+],
+[1 SELECT INBOX
+2 SEARCH $3
+X LOGOUT
+],
+[* PREAUTH IMAP4rev1 Test mode
+* SEARCH $4
+2 OK SEARCH Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+],
+[],
+[remove_select_unagged])
+
+AT_CLEANUP
+])
+
+dnl ----------------------------------------------------------------------
+# <message set>  Messages with message sequence numbers
+#                corresponding to the specified message sequence
+#                number set
+SEARCH_CHECK([search sequence number],[search00],
+[1:*],[1 2 3 4 5 6 7 8])
+
+# ALL            All messages in the mailbox; the default initial
+#                key for ANDing.
+SEARCH_CHECK([search all],[search01],
+[ALL],[1 2 3 4 5 6 7 8])
+
+# NEW            Messages that have the \Recent flag set but not the
+#                \Seen flag.  This is functionally equivalent to
+#                "(RECENT UNSEEN)".
+SEARCH_CHECK([search new],[search02],
+[NEW],[4 5 6 7 8])
+
+# FROM <string>  Messages that contain the specified string in the
+#                envelope structure's FROM field.
+SEARCH_CHECK([search from personal],[search03],
+[FROM corrector],[2 4 8])
+
+SEARCH_CHECK([search from email],[search04],
+[FROM lexi@example.net],[1 3 5 6 7])
+
+# LARGER <n>     Messages with an [RFC-822] size larger than the
+#                specified number of octets.
+SEARCH_CHECK([search larger],[search05],
+[LARGER 512],[3 4])
+
+# SMALLER <n>    Messages with an [RFC-822] size smaller than the
+#                specified number of octets.
+SEARCH_CHECK([search smaller],[search06],
+[SMALLER 400],[7 8])
+
+# SUBJECT <string>   Messages that contain the specified string in the
+#                    envelope structure's SUBJECT field.
+SEARCH_CHECK([search subject],[search07],
+[SUBJECT "Alliance"],[6])
+
+# HEADER <field-name> <string>
+#                    Messages that have a header with the specified
+#                    field-name (as defined in [RFC-822]) and that
+#                    contains the specified string in the [RFC-822]
+#                    field-body.
+SEARCH_CHECK([search header],[search08],
+[HEADER Message-Id "<200207291200.3303@example.org>"],[3])
+
+# CC <string>    Messages that contain the specified string in the
+#                 envelope structure's CC field.
+SEARCH_CHECK([search cc],[search09],
+[CC Corrector],[6])
+
+# TO <string>    Messages that contain the specified string in the
+#                envelope structure's TO field.
+SEARCH_CHECK([search to],[search10],
+[TO editor+recheck],[7])
+
+# SENTBEFORE <date>
+#                Messages whose [RFC-822] Date: header is earlier
+#                than the specified date.
+SEARCH_CHECK([search sentbefore],[search11],
+[SENTBEFORE "30-Jul-2002"],[1 2])
+
+# SENTSINCE <date>
+#                Messages whose [RFC-822] Date: header is within or
+#                later than the specified date.
+SEARCH_CHECK([search sentsince],[search12],
+[SENTSINCE "31-Jul-2002"],[5 6 7 8])
+
+# BEFORE <date>  Messages whose internal date is earlier than the
+#                specified date.
+SEARCH_CHECK([search beforedate],[search13],
+[BEFORE "30-Jul-2002"],[1])
+
+# SINCE <date>   Messages whose internal date is within or later
+#                than the specified date.
+SEARCH_CHECK([search since],[search14],
+[SINCE "30-Jul-2002"],[2 3 4 5 6 7 8])
+
+# ANSWERED       Messages with the \Answered flag set.
+SEARCH_CHECK([search answered],[search15],
+[ANSWERED],[2 3])
+
+# TEXT <string>  Messages that contain the specified string in the
+#                header or body of the message.
+SEARCH_CHECK([search text],[search16],
+[TEXT person],[2 5 8])
+
+# When multiple keys are specified, the result is the intersection
+# (AND function) of all the messages that match those keys.
+SEARCH_CHECK([search multiple keys (implicit AND) 1],[search17],
+[TEXT person FROM corrector],[2 8])
+
+SEARCH_CHECK([search multiple keys (implicit AND) 2],[search18],
+[SENTSINCE "30-Jul-2002" SENTBEFORE "31-Jul-2002"],[3 4])
+
+# OR <search-key1> <search-key2>
+#                Messages that match either search key.
+SEARCH_CHECK([search or],[search19],
+[OR FROM corrector ANSWERED],[2 3 4 8])
+
+# Test precedence 
+SEARCH_CHECK([precedence 1],[search20],
+[(OR FROM corrector ANSWERED) SENTSINCE "30-Jul-2002"],[3 4 8])
+
+SEARCH_CHECK([precedence 2],[search21],
+[OR FROM corrector ANSWERED SENTSINCE "30-Jul-2002"],[3 4 8])
+
+SEARCH_CHECK([precedence 3],[search22],
+[OR FROM corrector (ANSWERED SENTSINCE "30-Jul-2002")],[2 3 4 8])
+
+dnl ----------------------------------------------------------------------
diff --git a/sieve/tests/ext.at b/imap4d/tests/select.at
similarity index 57%
copy from sieve/tests/ext.at
copy to imap4d/tests/select.at
index f4c7193..1eb0c22 100644
--- a/sieve/tests/ext.at
+++ b/imap4d/tests/select.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,30 +14,26 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([loadable extensions: numaddr])
-AT_KEYWORDS([ext])
+AT_SETUP([select])
 
-AT_CHECK([
-MUT_PREREQ_CAPA([HAVE_LIBLTDL])
-
-AT_DATA([prog],[
-require "test-numaddr";
-
-if numaddr [[ "to", "cc" ]] :over 5
-  {
-    discard;
-  }
-])
-
-MUT_MBCOPY($abs_top_srcdir/testsuite/spool/bigto.mbox)
-
-sieve MUT_SIEVE_CMDLINE dnl
- --clearpath -L "${abs_top_builddir}/examples" -f ./bigto.mbox prog
+IMAP4D_CHECK([
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
+],
+[1 SELECT INBOX
+X LOGOUT
 ],
-[0],
-[],
-[DISCARD on msg uid 1: marking as deleted
+[* PREAUTH IMAP4rev1 Test mode
+* 8 EXISTS
+* 5 RECENT
+* OK [[UIDNEXT 9]] Predicted next uid
+* OK [[UNSEEN 4]] first unseen messsage
+* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
+* OK [[PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]] Permanent flags
+1 OK [[READ-WRITE]] SELECT Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
 ])
 
 AT_CLEANUP
 
+
diff --git a/libmailutils/tests/encode2047.at b/imap4d/tests/status.at
similarity index 65%
copy from libmailutils/tests/encode2047.at
copy to imap4d/tests/status.at
index 5cfcea5..629ba6b 100644
--- a/libmailutils/tests/encode2047.at
+++ b/imap4d/tests/status.at
@@ -1,6 +1,5 @@
 # This file is part of GNU Mailutils. -*- Autotest -*-
-# Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2011 Free Software Foundation, Inc.
 #
 # GNU Mailutils is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -15,18 +14,19 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-AT_SETUP([encode2047])
-AT_KEYWORDS([encode])
+AT_SETUP([status])
 
-AT_CHECK([
-AT_DATA(input,[dnl
-\\345\326\305\304\316\305\327\316\331\312\040\317\324\336\305\324
-])
-
-encode2047 -c koi8-r -eB -o < input],
-[0],
-[=?koi8-r?B?5dbFxM7F187ZyiDP1N7F1A==?=
+IMAP4D_CHECK([
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
+],
+[1 STATUS INBOX (MESSAGES RECENT UNSEEN UIDNEXT)
+X LOGOUT
+],
+[* PREAUTH IMAP4rev1 Test mode
+* STATUS INBOX (MESSAGES 8 RECENT 5 UNSEEN 5 UIDNEXT 9)
+1 OK STATUS Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
 ])
 
 AT_CLEANUP
-
diff --git a/imap4d/tests/testsuite.at b/imap4d/tests/testsuite.at
new file mode 100644
index 0000000..fd1c7a7
--- /dev/null
+++ b/imap4d/tests/testsuite.at
@@ -0,0 +1,84 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+m4_include([testsuite.inc])
+
+m4_define([IMAP4D_HOMEDIR])
+
+m4_define([IMAP4D_DEFAULT_OPTIONS],[dnl
+--no-site-config dnl
+--no-user-config dnl
+--test dnl
+--set logging.syslog=0 dnl
+--set logging.severity=notice dnl
+--set .gsasl.enable=0 dnl
+--set '|homedir='`pwd`m4_if([IMAP4D_HOMEDIR],,,/[IMAP4D_HOMEDIR]) dnl
+--set '|mailbox|folder='`pwd` dnl
+--set '|mailbox|mailbox-pattern='`pwd`/INBOX dnl
+])
+
+m4_define([IMAP4D_PREAUTH_OPTIONS],[dnl
+IMAP4D_DEFAULT_OPTIONS dnl
+--preauth dnl
+])
+
+m4_define([IMAP4D_OPTIONS],[IMAP4D_PREAUTH_OPTIONS])
+
+dnl ------------------------------------------------------------
+dnl IMAP4D_CHECK([PREP], [INPUT], [STDOUT = `'], [STDERR = `'],
+dnl              [FILTER = `'],[expand])
+dnl
+m4_pushdef([IMAP4D_CHECK],[
+cwd=`pwd`
+m4_if([$6],,[dnl
+AT_DATA([input],[$2])dnl
+],[cat > input <<EOT
+[$2]
+EOT
+])
+$1
+AT_CHECK([
+imap4d IMAP4D_OPTIONS < input | tr -d '\r' | dnl
+ m4_if([$5],,[remove_uidvalidity],[$5])
+],
+[0],
+[$3],
+[$4])
+])
+
+AT_INIT
+AT_TESTED([imap4d])
+MUT_VERSION(imap4d)
+
+m4_include([anystate.at])
+m4_include([id.at])
+
+m4_include([select.at])
+m4_include([examine.at])
+m4_include([status.at])
+m4_include([expunge.at])
+m4_include([create01.at])
+m4_include([create02.at])
+
+AT_BANNER([LIST])
+m4_include([list.at])
+
+AT_BANNER([SEARCH])
+m4_include([search.at])
+
+AT_BANNER([IDEF Checks])
+m4_include([IDEF0955.at])
+m4_include([IDEF0956.at])
diff --git a/include/mailutils/gsasl.h b/include/mailutils/gsasl.h
index d15141e..d7bdacf 100644
--- a/include/mailutils/gsasl.h
+++ b/include/mailutils/gsasl.h
@@ -21,6 +21,7 @@
 
 struct mu_gsasl_module_data
 {
+  int enable;
   char *service;
   char *realm;
   char *hostname;
@@ -28,13 +29,15 @@ struct mu_gsasl_module_data
   char *cram_md5_pwd;
 };
 
-int mu_gsasl_module_init (enum mu_gocs_op, void *);
-
-extern struct mu_gsasl_module_data mu_gsasl_module_data;
+int mu_gsasl_enabled (void);
 
 #ifdef WITH_GSASL
 #include <gsasl.h>
 
+int mu_gsasl_module_init (enum mu_gocs_op, void *);
+extern struct mu_gsasl_module_data mu_gsasl_module_data;
+
+
 int gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport,
 			  Gsasl_session *ctx, int flags);
 int gsasl_decoder_stream (mu_stream_t *pstr, mu_stream_t transport,
diff --git a/libmailutils/mailbox/mailbox.c b/libmailutils/mailbox/mailbox.c
index 4ffdab1..e25ded3 100644
--- a/libmailutils/mailbox/mailbox.c
+++ b/libmailutils/mailbox/mailbox.c
@@ -330,7 +330,7 @@ mu_mailbox_flush (mu_mailbox_t mbox, int expunge)
     return MU_ERR_MBX_REMOVED;
   if (!(mbox->flags & _MU_MAILBOX_OPEN))
     return _MU_MAILBOX_OPEN;
-  if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
+  if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
     return 0;
 
   mu_mailbox_messages_count (mbox, &total);
@@ -375,7 +375,7 @@ int
 mu_mailbox_append_message (mu_mailbox_t mbox, mu_message_t msg)
 {
   _MBOX_CHECK_Q (mbox, _append_message);
-  if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
+  if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
     return EACCES;
   return mbox->_append_message (mbox, msg);
 }
@@ -422,7 +422,7 @@ int
 mu_mailbox_sync (mu_mailbox_t mbox)
 {
   _MBOX_CHECK_Q (mbox, _sync);
-  if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
+  if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
     return 0;
   return mbox->_sync (mbox);
 }
@@ -438,7 +438,7 @@ int
 mu_mailbox_expunge (mu_mailbox_t mbox)
 {
   _MBOX_CHECK_Q (mbox, _expunge);
-  if (!(mbox->flags & (MU_STREAM_RDWR|MU_STREAM_WRITE|MU_STREAM_APPEND)))
+  if (!(mbox->flags & (MU_STREAM_WRITE|MU_STREAM_APPEND)))
     return EACCES;
   return mbox->_expunge (mbox);
 }
diff --git a/libmailutils/mime/attachment.c b/libmailutils/mime/attachment.c
index d8207ec..fcb74ea 100644
--- a/libmailutils/mime/attachment.c
+++ b/libmailutils/mime/attachment.c
@@ -346,7 +346,7 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
 {
   int ret = 0;
   mu_header_t hdr;
-  mu_stream_t istream, ostream;
+  mu_stream_t istream;
 
   if (msg == NULL)
     return EINVAL;
@@ -364,18 +364,10 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
     }
   if ((ret = _attachment_setup (&info, msg, &istream)) != 0)
     return ret;
-  if (info->msg == NULL)
-    ret = mu_message_create (&info->msg, NULL);
-  if (ret == 0)
-    {
-      mu_message_get_streamref (info->msg, &ostream);
-      mu_stream_seek (ostream, 0, MU_SEEK_SET, NULL);
-      ret = mu_stream_copy (ostream, istream, 0, NULL);
-      mu_stream_destroy (&ostream);
-    }
+  ret = mu_stream_to_message (istream, &info->msg);
+  mu_stream_unref (istream);
   if (ret == 0)
     *newmsg = info->msg;
-  mu_stream_destroy (&istream);
   _attachment_free (info, ret && ret != EAGAIN);
   return ret;
 }
diff --git a/libmu_auth/gsasl.c b/libmu_auth/gsasl.c
index f7f6441..8f98139 100644
--- a/libmu_auth/gsasl.c
+++ b/libmu_auth/gsasl.c
@@ -38,7 +38,12 @@
 #include <gsasl.h>
 
 struct mu_gsasl_module_data mu_gsasl_module_data = {
-    SITE_CRAM_MD5_PWD
+  1,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  SITE_CRAM_MD5_PWD
 };
 
 int
@@ -49,6 +54,12 @@ mu_gsasl_module_init (enum mu_gocs_op op, void *data)
   return 0;
 }
 
+int
+mu_gsasl_enabled (void)
+{
+  return mu_gsasl_module_data.enable;
+}
+
 
 static enum mu_filter_result
 _gsasl_encoder (void *xdata,
@@ -214,5 +225,10 @@ mu_gsasl_stream_create (mu_stream_t *stream, mu_stream_t transport,
   mu_stream_unref (out);
   return rc;
 }
-  
+#else
+int
+mu_gsasl_enabled (void)
+{
+  return 0;
+}
 #endif
diff --git a/libmu_cfg/gsasl.c b/libmu_cfg/gsasl.c
index 02d00da..e7bd6c3 100644
--- a/libmu_cfg/gsasl.c
+++ b/libmu_cfg/gsasl.c
@@ -25,6 +25,8 @@
 static struct mu_gsasl_module_data gsasl_settings;
 
 static struct mu_cfg_param mu_gsasl_param[] = {
+  { "enable", mu_cfg_bool, &gsasl_settings.enable, 0, NULL,
+    N_("Enable GSASL (default)") },
   { "cram-passwd", mu_cfg_string, &gsasl_settings.cram_md5_pwd, 0, NULL,
     N_("Name of GSASL password file."),
     N_("file") },


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 28 06:19:00 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RUzEi-0000TS-BF
	for mharc-commit-mailutils@gnu.org; Mon, 28 Nov 2011 06:19:00 -0500
Received: from eggs.gnu.org ([140.186.70.92]:59872)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUzEa-0000T1-T4
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 06:18:58 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUzEV-0003Dh-0x
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 06:18:52 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:49035)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUzEU-0003Dd-UT
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 06:18:46 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RUzEU-0000MP-3D
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 11:18:47 +0000
Date: Mon, 28 Nov 2011 11:18:46 +0000
Message-Id: <E1RUzEU-0000MP-3D@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-479-g5115e10
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 9370af7c2bbb53b7873ca6e26df058c84a0e487f
X-Git-Newrev: 5115e1055493e0ffe9ba3bdcf57f93d968feb608
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Nov 2011 11:18:58 -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=5115e1055493e0ffe9ba3bdcf57f93d968feb608

The branch, master has been updated
       via  5115e1055493e0ffe9ba3bdcf57f93d968feb608 (commit)
      from  9370af7c2bbb53b7873ca6e26df058c84a0e487f (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 5115e1055493e0ffe9ba3bdcf57f93d968feb608
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 28 13:17:37 2011 +0200

    imap4d: reimplement append tests.
    
    * imap4d/tests/Makefile.am (TESTSUITE_AT): Add append00.at and
    append01.at
    * imap4d/tests/testsuite.at: Include append tests.
    * imap4d/tests/append00.at: New file.
    * imap4d/tests/append01.at: New file.

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

Summary of changes:
 imap4d/tests/Makefile.am  |    2 +
 imap4d/tests/append00.at  |   60 +++++++++++++++++++++++++++++++++++++++++++++
 imap4d/tests/append01.at  |   60 +++++++++++++++++++++++++++++++++++++++++++++
 imap4d/tests/testsuite.at |    4 +++
 4 files changed, 126 insertions(+), 0 deletions(-)
 create mode 100644 imap4d/tests/append00.at
 create mode 100644 imap4d/tests/append01.at

diff --git a/imap4d/tests/Makefile.am b/imap4d/tests/Makefile.am
index 0b55221..e036fd9 100644
--- a/imap4d/tests/Makefile.am
+++ b/imap4d/tests/Makefile.am
@@ -40,6 +40,8 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
 
 TESTSUITE_AT = \
  anystate.at\
+ append00.at\
+ append01.at\
  create01.at\
  create02.at\
  examine.at\
diff --git a/imap4d/tests/append00.at b/imap4d/tests/append00.at
new file mode 100644
index 0000000..2e02c0c
--- /dev/null
+++ b/imap4d/tests/append00.at
@@ -0,0 +1,60 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([append with flags])
+AT_KEYWORDS([append00])
+
+AT_DATA([input],
+[1 APPEND mbox (\Seen) {300+}
+Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
+From: Fred Foobar <foobar@Blurdybloop.COM>
+Subject: afternoon meeting
+To: mooch@owatagu.siam.edu
+Message-Id: <B27397-0100000@Blurdybloop.COM>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
+
+Hello Joe, do you think we can meet at 3:30 tomorrow
+
+X LOGOUT
+])
+
+AT_CHECK([
+> mbox
+imap4d IMAP4D_OPTIONS < input | tr -d '\r'
+echo "=="
+awk 'NR==1 {print "1:",$1,$2; next} NF==0 {print NR":"; next} {print NR":",$0}' mbox
+],
+[0],
+[* PREAUTH IMAP4rev1 Test mode
+1 OK APPEND Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+==
+1: From GNU-imap4d
+2: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
+3: From: Fred Foobar <foobar@Blurdybloop.COM>
+4: Subject: afternoon meeting
+5: To: mooch@owatagu.siam.edu
+6: Message-Id: <B27397-0100000@Blurdybloop.COM>
+7: MIME-Version: 1.0
+8: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
+9:
+10: Hello Joe, do you think we can meet at 3:30 tomorrow
+11:
+])
+
+AT_CLEANUP
diff --git a/imap4d/tests/append01.at b/imap4d/tests/append01.at
new file mode 100644
index 0000000..9a6e347
--- /dev/null
+++ b/imap4d/tests/append01.at
@@ -0,0 +1,60 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([append with envelope date])
+AT_KEYWORDS([append01])
+
+AT_DATA([input],
+[1 APPEND mbox "25-Aug-2002 18:00:00 +0200" {274+}
+Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
+From: Fred Foobar <foobar@Blurdybloop.COM>
+Subject: afternoon meeting again
+To: mooch@owatagu.siam.edu
+Message-Id: <B27397-0200000@Blurdybloop.COM>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
+
+Better yet at 04:00?
+
+X LOGOUT
+])
+
+AT_CHECK([
+> mbox
+imap4d IMAP4D_OPTIONS < input | tr -d '\r'
+echo "=="
+awk 'NF==0 {print NR":"; next} {print NR":",$0}' mbox
+],
+[0],
+[* PREAUTH IMAP4rev1 Test mode
+1 OK APPEND Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+==
+1: From GNU-imap4d Sun Aug 25 16:00:00 2002
+2: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
+3: From: Fred Foobar <foobar@Blurdybloop.COM>
+4: Subject: afternoon meeting again
+5: To: mooch@owatagu.siam.edu
+6: Message-Id: <B27397-0200000@Blurdybloop.COM>
+7: MIME-Version: 1.0
+8: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
+9:
+10: Better yet at 04:00?
+11:
+])
+
+AT_CLEANUP
diff --git a/imap4d/tests/testsuite.at b/imap4d/tests/testsuite.at
index fd1c7a7..1bc3a8e 100644
--- a/imap4d/tests/testsuite.at
+++ b/imap4d/tests/testsuite.at
@@ -73,6 +73,10 @@ m4_include([expunge.at])
 m4_include([create01.at])
 m4_include([create02.at])
 
+AT_BANNER([APPEND])
+m4_include([append00.at])
+m4_include([append01.at])
+
 AT_BANNER([LIST])
 m4_include([list.at])
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 28 07:31:27 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RV0Mp-0008V1-1g
	for mharc-commit-mailutils@gnu.org; Mon, 28 Nov 2011 07:31:27 -0500
Received: from eggs.gnu.org ([140.186.70.92]:33302)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV0Mj-0008Uv-14
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 07:31:25 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV0Md-0006bS-Sl
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 07:31:21 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:55667)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV0Md-0006bL-M3
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 07:31:15 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV0MX-00012n-VK
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 12:31:14 +0000
Date: Mon, 28 Nov 2011 12:31:11 +0000
Message-Id: <E1RV0MX-00012n-VK@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-480-gfb32f88
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 5115e1055493e0ffe9ba3bdcf57f93d968feb608
X-Git-Newrev: fb32f8895aaedc58873dca5eb368c07e978df461
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Nov 2011 12:31:25 -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=fb32f8895aaedc58873dca5eb368c07e978df461

The branch, master has been updated
       via  fb32f8895aaedc58873dca5eb368c07e978df461 (commit)
      from  5115e1055493e0ffe9ba3bdcf57f93d968feb608 (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 fb32f8895aaedc58873dca5eb368c07e978df461
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 28 14:01:18 2011 +0200

    Minor fix

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

Summary of changes:
 imap4d/Makefile.am |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/imap4d/Makefile.am b/imap4d/Makefile.am
index 8ecd427..69555fc 100644
--- a/imap4d/Makefile.am
+++ b/imap4d/Makefile.am
@@ -32,6 +32,7 @@ imap4d_SOURCES = \
  append.c\
  authenticate.c\
  $(AUTH_GSASL)\
+ $(AUTH_GSSAPI)\
  bye.c\
  capability.c\
  check.c\


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 28 11:41:43 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RV4H1-0005VP-9h
	for mharc-commit-mailutils@gnu.org; Mon, 28 Nov 2011 11:41:43 -0500
Received: from eggs.gnu.org ([140.186.70.92]:39658)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV4Gt-0005Tt-B7
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 11:41:42 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV4Gk-0008A4-Ta
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 11:41:35 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:37844)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV4Gk-00089z-P3
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 11:41:26 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV4Ga-0000A4-3h
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 16:41:25 +0000
Date: Mon, 28 Nov 2011 16:41:19 +0000
Message-Id: <E1RV4Ga-0000A4-3h@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-481-g759cf45
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: fb32f8895aaedc58873dca5eb368c07e978df461
X-Git-Newrev: 759cf45adacfe54b505ad7deebf3e54602ce46f0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Nov 2011 16:41:42 -0000

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

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

The branch, master has been updated
       via  759cf45adacfe54b505ad7deebf3e54602ce46f0 (commit)
      from  fb32f8895aaedc58873dca5eb368c07e978df461 (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 759cf45adacfe54b505ad7deebf3e54602ce46f0
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 28 17:17:06 2011 +0200

    imap4d: reimplement fetch tests in Autotest.  Remove DejaGNU-based testsuite.
    
    * configure.ac: Update.
    * imap4d/Makefile.am (SUBDIRS): Remove testsuite.
    * imap4d/fetch.c (fetch_thunk): Add a FIXME reference.
    * imap4d/tests/fetch.at: New file.
    * imap4d/tests/Makefile.am (TESTSUITE_AT): Add fetch.at
    * imap4d/tests/testsuite.at: Include fetch.at
    * imap4d/tests/atlocal.in (fixup_tz): New filter.
    * imap4d/tests/Makefile.am (EXTRA_DIST): Remove unexisting file.
    * imap4d/testsuite: Remove

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

Summary of changes:
 configure.ac                         |    1 -
 imap4d/Makefile.am                   |    2 +-
 imap4d/fetch.c                       |    6 +-
 imap4d/tests/Makefile.am             |    3 +-
 imap4d/tests/atlocal.in              |    6 +-
 imap4d/tests/fetch.at                |  452 +++++++++++++++++++++++++++++++++
 imap4d/tests/search.at               |    2 +-
 imap4d/tests/testsuite.at            |    3 +
 imap4d/testsuite/.gitignore          |    8 -
 imap4d/testsuite/Makefile.am         |   89 -------
 imap4d/testsuite/config/DISTFILES    |    1 -
 imap4d/testsuite/config/default.exp  |    1 -
 imap4d/testsuite/imap4d.rcin         |   36 ---
 imap4d/testsuite/imap4d/DISTFILES    |   11 -
 imap4d/testsuite/imap4d/IDEF0955.exp |   50 ----
 imap4d/testsuite/imap4d/IDEF0956.exp |   45 ----
 imap4d/testsuite/imap4d/anystate.exp |   30 ---
 imap4d/testsuite/imap4d/append.exp   |  109 --------
 imap4d/testsuite/imap4d/create.exp   |   72 ------
 imap4d/testsuite/imap4d/examine.exp  |   61 -----
 imap4d/testsuite/imap4d/expunge.exp  |   74 ------
 imap4d/testsuite/imap4d/fetch.exp    |  464 ----------------------------------
 imap4d/testsuite/imap4d/list.exp     |   90 -------
 imap4d/testsuite/imap4d/search.exp   |  205 ---------------
 imap4d/testsuite/imap4d/x.exp        |   31 ---
 imap4d/testsuite/lib/DISTFILES       |    1 -
 imap4d/testsuite/lib/imap4d.exp      |  335 ------------------------
 27 files changed, 469 insertions(+), 1719 deletions(-)
 create mode 100644 imap4d/tests/fetch.at
 delete mode 100644 imap4d/testsuite/.gitignore
 delete mode 100644 imap4d/testsuite/Makefile.am
 delete mode 100644 imap4d/testsuite/config/DISTFILES
 delete mode 100644 imap4d/testsuite/config/default.exp
 delete mode 100644 imap4d/testsuite/imap4d.rcin
 delete mode 100644 imap4d/testsuite/imap4d/DISTFILES
 delete mode 100644 imap4d/testsuite/imap4d/IDEF0955.exp
 delete mode 100644 imap4d/testsuite/imap4d/IDEF0956.exp
 delete mode 100644 imap4d/testsuite/imap4d/anystate.exp
 delete mode 100644 imap4d/testsuite/imap4d/append.exp
 delete mode 100644 imap4d/testsuite/imap4d/create.exp
 delete mode 100644 imap4d/testsuite/imap4d/examine.exp
 delete mode 100644 imap4d/testsuite/imap4d/expunge.exp
 delete mode 100644 imap4d/testsuite/imap4d/fetch.exp
 delete mode 100644 imap4d/testsuite/imap4d/list.exp
 delete mode 100644 imap4d/testsuite/imap4d/search.exp
 delete mode 100644 imap4d/testsuite/imap4d/x.exp
 delete mode 100644 imap4d/testsuite/lib/DISTFILES
 delete mode 100644 imap4d/testsuite/lib/imap4d.exp

diff --git a/configure.ac b/configure.ac
index 6d6fb9b..62b4409 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1438,7 +1438,6 @@ AC_CONFIG_FILES([
  frm/Makefile
  scheme/Makefile
  imap4d/Makefile
- imap4d/testsuite/Makefile
  include/Makefile
  include/mailutils/Makefile
  include/mailutils/sys/Makefile
diff --git a/imap4d/Makefile.am b/imap4d/Makefile.am
index 69555fc..2790e3f 100644
--- a/imap4d/Makefile.am
+++ b/imap4d/Makefile.am
@@ -16,7 +16,7 @@
 ## along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
 INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@ 
-SUBDIRS = tests testsuite
+SUBDIRS = tests
 
 sbin_PROGRAMS =	imap4d
 
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 05c843e..40b7453 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -1728,7 +1728,11 @@ fetch_thunk (imap4d_parsebuf_t pb)
 
 	 Obviously the same holds true for non-existing message numbers
 	 as well, although I did not find any explicit mention thereof
-	 in the RFC. */
+	 in the RFC.
+
+	 FIXME: This code also causes imap4d to silently ignore erroneous
+	 msgset specifications (e.g. FETCH foobar (FLAGS)), which should
+	 be fixed.  */
       
       pb->err_text = "Completed";
       return RESP_OK;
diff --git a/imap4d/tests/Makefile.am b/imap4d/tests/Makefile.am
index e036fd9..6d471c5 100644
--- a/imap4d/tests/Makefile.am
+++ b/imap4d/tests/Makefile.am
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 input.msg
+EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 
 DISTCLEANFILES       = atconfig $(check_SCRIPTS)
 MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
 
@@ -46,6 +46,7 @@ TESTSUITE_AT = \
  create02.at\
  examine.at\
  expunge.at\
+ fetch.at\
  id.at\
  IDEF0955.at\
  IDEF0956.at\
diff --git a/imap4d/tests/atlocal.in b/imap4d/tests/atlocal.in
index d1d49ef..3438654 100644
--- a/imap4d/tests/atlocal.in
+++ b/imap4d/tests/atlocal.in
@@ -17,10 +17,14 @@ remove_uidvalidity() {
   sed '/^\* OK \[UIDVALIDITY/d'
 }
 
-remove_select_unagged() {
+remove_select_untagged() {
   sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d'
 }
 
+fixup_tz() {
+  sed '/^\* [0-9][0-9]* FETCH/s/ [+-][0-9][0-9][0-9][0-9]"/ +0000"/'
+}
+
 sorted_list_output() {
   sed '/^\* PREAUTH/d
        /^\* OK/d
diff --git a/imap4d/tests/fetch.at b/imap4d/tests/fetch.at
new file mode 100644
index 0000000..dd895d6
--- /dev/null
+++ b/imap4d/tests/fetch.at
@@ -0,0 +1,452 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl FETCH_CHECK([NAME=`'],[KW=`'],[ARG=`'],[OUTPUT=`'],[MBOX=mbox1],[FILTERS=`'])
+m4_define([FETCH_CHECK],[
+AT_SETUP([$1])
+AT_KEYWORDS([fetch $2])
+IMAP4D_CHECK([
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/m4_if([$5],,mbox1,[$5]),INBOX)
+],
+[1 SELECT INBOX
+2 FETCH $3
+X LOGOUT
+],
+[* PREAUTH IMAP4rev1 Test mode
+$4
+2 OK FETCH Completed
+* BYE Session terminating.
+X OK LOGOUT Completed
+],
+[],
+[remove_select_untagged[]m4_if([$6],,,|[$6])])
+
+AT_CLEANUP
+])
+
+dnl ----------------------------------------------------------------------
+# 6.4.5.  FETCH Command
+# Arguments:  message set
+#             message data item names
+# Responses:  untagged responses: FETCH
+# Result:     OK - fetch completed
+#             NO - fetch error: can't fetch that data
+#             BAD - command unknown or arguments invalid
+#
+#      The FETCH command retrieves data associated with a message in the
+#      mailbox.  The data items to be fetched can be either a single atom
+#      or a parenthesized list.
+
+# FLAGS          The flags that are set for this message.
+
+FETCH_CHECK([flags],[fetch-flags fetch00],
+[3 (FLAGS)],
+[* 3 FETCH (FLAGS (\Recent))])
+
+# INTERNALDATE   The internal date of the message.
+FETCH_CHECK([internaldate],[fetch-internaldate fetch01],
+[3 INTERNALDATE],
+[* 3 FETCH (INTERNALDATE "13-Jul-2002 00:43:18 +0000")],
+[],
+[fixup_tz])
+
+# UID            The unique identifier for the message.
+FETCH_CHECK([uid],[fetch-uid fetch02],
+[3 UID],
+[* 3 FETCH (UID 3)])
+
+FETCH_CHECK([uid + internaldate],[fetch-internaldate-uid fetch03],
+[3 (FLAGS INTERNALDATE UID)],
+[* 3 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:43:18 +0000" UID 3)],
+[],
+[fixup_tz])
+
+# ENVELOPE       The envelope structure of the message.  This is
+#                computed by the server by parsing the [RFC-822]
+#                header into the component parts, defaulting various
+#                fields as necessary.
+
+FETCH_CHECK([envelope],[fetch-envelope fetch04],
+[1:* ENVELOPE],
+[* 1 FETCH (ENVELOPE ("Fri, 28 Dec 2001 22:18:08 +0200" "Jabberwocky" (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Bar" NIL "bar" "dontmailme.org")) NIL NIL NIL "<200112282018.fBSKI8N04906@nonexistent.net>"))
+* 2 FETCH (ENVELOPE ("Fri, 28 Dec 2001 23:28:08 +0200" "Re: Jabberwocky" (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200112232808.fERKR9N16790@dontmailme.org>"))
+* 3 FETCH (ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Simple MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))
+* 4 FETCH (ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>"))
+* 5 FETCH (ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Empty MIME Parts" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))])
+
+# ALL            Macro equivalent to: (FLAGS INTERNALDATE
+#                RFC822.SIZE ENVELOPE)
+
+FETCH_CHECK([ALL],[fetch-all fetch05],
+[1:* ALL],
+[* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298 ENVELOPE ("Fri, 28 Dec 2001 22:18:08 +0200" "Jabberwocky" (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) (("Bar" NIL "bar" "dontmailme.org")) NIL NIL NIL "<200112282018.fBSKI8N04906@nonexistent.net>"))
+* 2 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 23:28:09 +0000" RFC822.SIZE 547 ENVELOPE ("Fri, 28 Dec 2001 23:28:08 +0200" "Re: Jabberwocky" (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Bar" NIL "bar" "dontmailme.org")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200112232808.fERKR9N16790@dontmailme.org>"))
+* 3 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:43:18 +0000" RFC822.SIZE 1611 ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Simple MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))
+* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>"))
+* 5 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:43:18 +0000" RFC822.SIZE 884 ENVELOPE ("Sat, 13 Jul 2002 00:43:18 +0300" "Empty MIME Parts" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122143.g6CLhIb05086@example.net>"))],
+[],
+[fixup_tz])
+
+# BODYSTRUCTURE  The [MIME-IMB] body structure of the message.  This
+#                is computed by the server by parsing the [MIME-IMB]
+#                header fields in the [RFC-822] header and
+#                [MIME-IMB] headers.
+FETCH_CHECK([BODYSTRUCTURE],[fetch-bodystructure fetch06],
+[1:* BODYSTRUCTURE],
+[* 1 FETCH (BODYSTRUCTURE ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 972 35 NIL NIL NIL))
+* 2 FETCH (BODYSTRUCTURE ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 219 4 NIL NIL NIL))
+* 3 FETCH (BODYSTRUCTURE (("text" "plain" ("name" "msg.1" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "How doth" "7BIT" 239 9 NIL NIL NIL)("application" "octet-stream" ("name" "msg.21") "<5082.1026510189.2@example.net>" "Father William Part I" "base64" 468 NIL NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa0") NIL NIL))
+* 4 FETCH (BODYSTRUCTURE (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10 NIL NIL NIL)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486 NIL NIL NIL)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490 NIL NIL NIL)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502 NIL NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa2") NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa1") NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa0") NIL NIL))
+* 5 FETCH (BODYSTRUCTURE (("text" "plain" ("name" "empty" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "Empty part" "7BIT" 0 0 NIL NIL NIL)("text" "plain" ("name" "single.line" "charset" "us-ascii") "<5082.1026510189.2@example.net>" "Single line part" "7BIT" 2 1 NIL NIL NIL) "mixed" ("boundary" "----- =_aaaaaaaaaa0") NIL NIL))])
+
+# BODY
+#         Non-extensible form of BODYSTRUCTURE.
+FETCH_CHECK([BODY],[fetch-body fetch07],
+[1:* BODY],
+[* 1 FETCH (BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 972 35))
+* 2 FETCH (BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 219 4))
+* 3 FETCH (BODY (("text" "plain" ("name" "msg.1" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "How doth" "7BIT" 239 9)("application" "octet-stream" ("name" "msg.21") "<5082.1026510189.2@example.net>" "Father William Part I" "base64" 468) "mixed" NIL NIL NIL))
+* 4 FETCH (BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))
+* 5 FETCH (BODY (("text" "plain" ("name" "empty" "charset" "us-ascii") "<5082.1026510189.1@example.net>" "Empty part" "7BIT" 0 0)("text" "plain" ("name" "single.line" "charset" "us-ascii") "<5082.1026510189.2@example.net>" "Single line part" "7BIT" 2 1) "mixed" NIL NIL NIL))])
+
+# BODY[<section>]<<partial>>
+#         The text of a particular body section.  The section
+#         specification is a set of zero or more part specifiers
+#         delimited by periods.  A part specifier is either a part number
+#         or one of the following: HEADER, HEADER.FIELDS,
+#         HEADER.FIELDS.NOT, MIME, and TEXT.  An empty section
+#         specification refers to the entire message, including the
+#         header.
+
+# The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT
+# part specifiers refer to the [RFC-822] header of
+# the message or of an encapsulated [MIME-IMT]
+# MESSAGE/RFC822 message.
+
+FETCH_CHECK([BODY[[HEADER]]],[fetch-body-header fetch08],
+[1 BODY[[HEADER]]],
+[* 1 FETCH (FLAGS (\Seen) BODY[[HEADER]] {326}
+Received: (from foobar@nonexistent.net)
+	by nonexistent.net id fBSKI8N04906
+	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
+Date: Fri, 28 Dec 2001 22:18:08 +0200
+From: Foo Bar <foobar@nonexistent.net>
+Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
+To: Bar <bar@dontmailme.org>
+Subject: Jabberwocky
+
+)])
+
+# HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a list of
+# field-name (as defined in [RFC-822]) names, and return a subset
+# of the header.
+
+# The subset returned by HEADER.FIELDS contains only those header fields
+# with a field-name that matches one of the names in the list;
+
+FETCH_CHECK([BODY[[HEADER.FIELDS]]],[fetch-body-header-fields fetch09],
+[1 BODY[[HEADER.FIELDS (FROM TO SUBJECT)]]],
+[* 1 FETCH (FLAGS (\Seen) BODY[[HEADER.FIELDS (FROM TO SUBJECT)]] {94}
+FROM: Foo Bar <foobar@nonexistent.net>
+TO: Bar <bar@dontmailme.org>
+SUBJECT: Jabberwocky
+
+)])
+
+# similarly, the subset returned by HEADER.FIELDS.NOT contains only
+# the header fields with a non-matching field-name. 
+
+FETCH_CHECK([BODY[[HEADER.FIELDS.NOT]]],[fetch-body-header-fields-not fetch10],
+[1 BODY[[HEADER.FIELDS.NOT (FROM TO SUBJECT)]]],
+[* 1 FETCH (FLAGS (\Seen) BODY[[HEADER.FIELDS.NOT (FROM TO SUBJECT)]] {234}
+Received: (from foobar@nonexistent.net)
+	by nonexistent.net id fBSKI8N04906
+	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
+Date: Fri, 28 Dec 2001 22:18:08 +0200
+Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
+
+)])
+
+# The TEXT part specifier refers to the text body of
+# the message, omitting the [RFC-822] header.
+FETCH_CHECK([BODY[[TEXT]]],[fetch-body-text fetch11],
+[1 BODY[[TEXT]]],
+[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]] {972}
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+`Beware the Jabberwock, my son!
+The jaws that bite, the claws that catch!
+Beware the Jujub bird, and shun
+The frumious Bandersnatch!'
+
+He took his vorpal sword in hand:
+Long time the manxome foe he sought --
+So rested he by the Tumtum gree,
+And stood awhile in thought.
+
+And as in uffish thought he stood,
+The Jabberwock, with eyes of flame,
+Came whiffling through the tulgey wook,
+And burbled as it came!
+
+One, two!  One, two!  And through and through
+The vorpal blade went snicker-snack!
+He left it dead, and with its head
+He went galumphing back.
+
+`And has thou slain the Jabberwock?
+Come to my arms, my beamish boy!
+O frabjous day!  Calloh!  Callay!
+He chortled in his joy.
+
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+)])
+
+# It is possible to fetch a substring of the
+# designated text.  This is done by appending an open
+# angle bracket ("<"), the octet position of the
+# first desired octet, a period, the maximum number
+# of octets desired, and a close angle bracket (">")
+# to the part specifier.  
+FETCH_CHECK([BODY[[TEXT]]<X.Y>],[fetch-body-text-substring fetch12],
+[1 BODY[[TEXT]]<0.20>],
+[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<0> {20}
+`Twas brillig, and t)])
+
+FETCH_CHECK([BODY[[TEXT]]<Y.X>],[fetch-body-text-rev-substring fetch13],
+[1 BODY[[TEXT]]<200.100>],
+[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<200> {100}
+t catch!
+Beware the Jujub bird, and shun
+The frumious Bandersnatch!'
+
+He took his vorpal sword i)])
+
+# If the starting octet is beyond the end of
+# the text, an empty string is returned.
+FETCH_CHECK([BODY[[TEXT]]<X-too-big>],[fetch-body-text-off2big fetch14],
+[1 BODY[[TEXT]]<3900.4000>],
+[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<3900> "")])
+
+# Any partial fetch that attempts to read beyond the
+# end of the text is truncated as appropriate.  A
+# partial fetch that starts at octet 0 is returned as
+# a partial fetch, even if this truncation happened.
+#
+# Note: this means that BODY[]<0.2048> of a 1500-octet
+# message will return BODY[]<0> with a literal of size 1500,
+# not BODY[].
+
+FETCH_CHECK([BODY[[TEXT]] (truncated)],[fetch-body-text-truncated fetch15],
+[1 BODY[[TEXT]]<0.4000>],
+[* 1 FETCH (FLAGS (\Seen) BODY[[TEXT]]<0> {972}
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+`Beware the Jabberwock, my son!
+The jaws that bite, the claws that catch!
+Beware the Jujub bird, and shun
+The frumious Bandersnatch!'
+
+He took his vorpal sword in hand:
+Long time the manxome foe he sought --
+So rested he by the Tumtum gree,
+And stood awhile in thought.
+
+And as in uffish thought he stood,
+The Jabberwock, with eyes of flame,
+Came whiffling through the tulgey wook,
+And burbled as it came!
+
+One, two!  One, two!  And through and through
+The vorpal blade went snicker-snack!
+He left it dead, and with its head
+He went galumphing back.
+
+`And has thou slain the Jabberwock?
+Come to my arms, my beamish boy!
+O frabjous day!  Calloh!  Callay!
+He chortled in his joy.
+
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+)])
+
+# The MIME part specifier refers to the [MIME-IMB]
+# header for this part.
+
+# The MIME part specifier MUST be prefixed by one or
+# more numeric part specifiers.
+
+FETCH_CHECK([BODY[[N.MIME]]],[fetch-body-mime fetch16],
+[3 BODY[[1.MIME]]],
+[* 3 FETCH (FLAGS (\Seen) BODY[[1.MIME]] {138}
+Content-Type: text/plain; name="msg.1"; charset="us-ascii"
+Content-ID: <5082.1026510189.1@example.net>
+Content-Description: How doth
+
+)])
+
+FETCH_CHECK([BODY[[<section>]]],[fetch-body-section fetch17],
+[4 BODY[[2.2.1]]],
+[* 4 FETCH (FLAGS (\Seen) BODY[[2.2.1]] {490}
+YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh
+awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv
+b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn
+ZSB0byBkbyBpdD8nCgpgSW4gbXkgeW91dGgsJyBzYWlkIGhpcyBmYXRoZXIsIGBJIHRvb2sgdG8g
+dGhlIGxhdywKQW5kIGFyZ3VlZCBlYWNoIGNhc2Ugd2l0aCBteSB3aWZlOwpBbmQgdGhlIG11c2N1
+bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz
+dCBvZiBteSBsaWZlLicK
+)])
+
+# BODY.PEEK[<section>]<<partial>>
+#                    An alternate form of BODY[<section>] that does not
+#                    implicitly set the \Seen flag.
+FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch18],
+[1 BODY.PEEK[[HEADER]]],
+[* 1 FETCH (BODY[[HEADER]] {326}
+Received: (from foobar@nonexistent.net)
+	by nonexistent.net id fBSKI8N04906
+	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
+Date: Fri, 28 Dec 2001 22:18:08 +0200
+From: Foo Bar <foobar@nonexistent.net>
+Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
+To: Bar <bar@dontmailme.org>
+Subject: Jabberwocky
+
+)])
+
+# RFC822         Functionally equivalent to BODY[], differing in the
+#                syntax of the resulting untagged FETCH data (RFC822
+#                is returned).
+
+FETCH_CHECK([RFC822],[fetch-rfc822 fetch19],
+[1 RFC822],
+[* 1 FETCH (FLAGS (\Seen) RFC822 {1298}
+Received: (from foobar@nonexistent.net)
+	by nonexistent.net id fBSKI8N04906
+	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200
+Date: Fri, 28 Dec 2001 22:18:08 +0200
+From: Foo Bar <foobar@nonexistent.net>
+Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>
+To: Bar <bar@dontmailme.org>
+Subject: Jabberwocky
+
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+`Beware the Jabberwock, my son!
+The jaws that bite, the claws that catch!
+Beware the Jujub bird, and shun
+The frumious Bandersnatch!'
+
+He took his vorpal sword in hand:
+Long time the manxome foe he sought --
+So rested he by the Tumtum gree,
+And stood awhile in thought.
+
+And as in uffish thought he stood,
+The Jabberwock, with eyes of flame,
+Came whiffling through the tulgey wook,
+And burbled as it came!
+
+One, two!  One, two!  And through and through
+The vorpal blade went snicker-snack!
+He left it dead, and with its head
+He went galumphing back.
+
+`And has thou slain the Jabberwock?
+Come to my arms, my beamish boy!
+O frabjous day!  Calloh!  Callay!
+He chortled in his joy.
+
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+)])
+
+# RFC822.HEADER  Functionally equivalent to BODY.PEEK[HEADER],
+#                differing in the syntax of the resulting untagged
+#                FETCH data (RFC822.HEADER is returned).
+# FIXME: Should it set \Seen flag?
+FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch20],
+[2 RFC822.HEADER],
+[* 2 FETCH (RFC822.HEADER {328}
+Received: (from bar@dontmailme.org)
+	by dontmailme.org id fERKR9N16790
+	for foobar@nonexistent.net; Fri, 28 Dec 2001 22:18:08 +0200
+Date: Fri, 28 Dec 2001 23:28:08 +0200
+From: Bar <bar@dontmailme.org>
+To: Foo Bar <foobar@nonexistent.net>
+Message-Id: <200112232808.fERKR9N16790@dontmailme.org>
+Subject: Re: Jabberwocky
+
+)])
+
+# RFC822.SIZE    The [RFC-822] size of the message.
+
+FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch21],
+[3 RFC822.SIZE],
+[* 3 FETCH (RFC822.SIZE 1611)])
+
+# RFC822.TEXT    Functionally equivalent to BODY[TEXT], differing in
+#                the syntax of the resulting untagged FETCH data
+#                (RFC822.TEXT is returned).
+FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text  fetch22],
+[2 RFC822.TEXT],
+[* 2 FETCH (FLAGS (\Seen) RFC822.TEXT {219}
+It seems very pretty, but it's *rather* hard to understand!'
+Somehow it seems to fill my head with ideas -- only I don't
+exactly know what they are!  However, SOMEBODY killed SOMETHING:
+that's clear, at any rate...
+)])
+
+# FAST           Macro equivalent to: (FLAGS INTERNALDATE
+#                RFC822.SIZE)
+
+FETCH_CHECK([FAST],[fetch-fast fetch23],
+[1 FAST],
+[* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298)],
+[],
+[fixup_tz])
+
+# FULL           Macro equivalent to: (FLAGS INTERNALDATE
+#                RFC822.SIZE ENVELOPE BODY)
+
+FETCH_CHECK([FULL],[fetch-full fetch24],
+[4 FULL],
+[* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>") BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))],
+[],
+[fixup_tz])
+
+
+dnl ----------------------------------------------------------------------
diff --git a/imap4d/tests/search.at b/imap4d/tests/search.at
index 4d55068..71f0bbd 100644
--- a/imap4d/tests/search.at
+++ b/imap4d/tests/search.at
@@ -32,7 +32,7 @@ X LOGOUT
 X OK LOGOUT Completed
 ],
 [],
-[remove_select_unagged])
+[remove_select_untagged])
 
 AT_CLEANUP
 ])
diff --git a/imap4d/tests/testsuite.at b/imap4d/tests/testsuite.at
index 1bc3a8e..0a18641 100644
--- a/imap4d/tests/testsuite.at
+++ b/imap4d/tests/testsuite.at
@@ -83,6 +83,9 @@ m4_include([list.at])
 AT_BANNER([SEARCH])
 m4_include([search.at])
 
+AT_BANNER([FETCH])
+m4_include([fetch.at])
+
 AT_BANNER([IDEF Checks])
 m4_include([IDEF0955.at])
 m4_include([IDEF0956.at])
diff --git a/imap4d/testsuite/.gitignore b/imap4d/testsuite/.gitignore
deleted file mode 100644
index 1dc7ede..0000000
--- a/imap4d/testsuite/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-*.log
-*.sum
-imap4d.rc
-site.exp
-remote.exp
-data
diff --git a/imap4d/testsuite/Makefile.am b/imap4d/testsuite/Makefile.am
deleted file mode 100644
index 0916bd1..0000000
--- a/imap4d/testsuite/Makefile.am
+++ /dev/null
@@ -1,89 +0,0 @@
-## This file is part of GNU Mailutils.
-## Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
-## Inc.
-##
-## GNU Mailutils is free software; you can redistribute it and/or
-## modify it under the terms of the GNU General Public License as
-## published by the Free Software Foundation; either version 3, or (at
-## your option) any later version.
-##
-## GNU Mailutils is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-AUTOMAKE_OPTIONS = dejagnu
-DEJATOOL = imap4d
-RUNTESTFLAGS = 
-CLEANFILES = *.log imap4d.rc
-EXTRA_DIST = imap4d.rcin
-test_dirs = lib imap4d config
-
-dist-hook:
-	here=`cd $(top_builddir)/$(subdir) && pwd`; \
-	srcdir=`cd $(srcdir) && pwd`; \
-	distdir=`cd $(distdir) && pwd`; \
-	for dir in $(test_dirs); \
-	do \
-            cd $$srcdir;\
-            mkdir $$distdir/$$dir;\
-	    cd $$dir;\
-	    for file in DISTFILES `cat DISTFILES`; do \
-	        d=$$srcdir/$$dir; \
-	        if test -d $$d/$$file; then \
-                    cp -pr $$d/$$file $$distdir/$$dir/$$file; \
-		else \
-	            test -f $$distdir/$$dir/$$file \
-                        || cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \
-                fi; \
-	    done;\
-        done;\
-	cd $$here
-
-site.exp: Makefile remote.exp
-	@echo 'Making a new site.exp file...'
-	@test ! -f site.bak || rm -f site.bak
-	@echo '## these variables are automatically generated by make ##' > $@-t
-	@echo '# Do not edit here.  If you wish to override these values' >> $@-t
-	@echo '# edit the last section' >> $@-t
-	@echo 'set tool $(DEJATOOL)' >> $@-t
-	@echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t
-	@echo "set srcdir `cd $(srcdir); pwd`" >> $@-t
-	@echo 'set objdir' `pwd` >> $@-t
-	@echo 'set host_alias "$(host_alias)"' >> $@-t
-	@echo 'set host_triplet $(host_triplet)' >> $@-t
-	@echo 'set target_alias "$(target_alias)"' >> $@-t
-	@echo 'set target_triplet $(target_triplet)' >> $@-t
-	@echo 'set build_alias "$(build_alias)"' >> $@-t
-	@echo 'set build_triplet $(build_triplet)' >> $@-t
-	@echo 'set MU_ULONG_MAX $(MU_ULONG_MAX)' >> $@-t
-	@echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
-	@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
-	@test ! -f site.exp || mv site.exp site.bak
-	@mv $@-t site.exp
-
-remote.exp:;
-	@echo 'Making a new remote.exp file...'
-	@test ! -f remote.bak || rm -f remote.bak
-	@echo '## These variables are used to set up for the remote testing.' >> $@-t
-	@echo '## Please, read file README in this directory for instructions' >> $@-t
-	@echo '## on how to use this file' >> $@-t
-	@echo "set host_board `hostname`" >> $@-t
-	@echo 'set board_info($$host_board,connect) rlogin' >> $@-t
-	@echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t
-	@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
-	@echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t
-	@echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t
-	@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
-	@echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t
-	@test ! -f remote.exp || mv remote.exp remote.bak
-	@mv $@-t remote.exp
-
-
-DISTCLEANFILES=*.exp *.log *.sum 
-
-distclean-local:
-	-rm -rf	data
diff --git a/imap4d/testsuite/config/DISTFILES b/imap4d/testsuite/config/DISTFILES
deleted file mode 100644
index 7ba99f0..0000000
--- a/imap4d/testsuite/config/DISTFILES
+++ /dev/null
@@ -1 +0,0 @@
-default.exp
diff --git a/imap4d/testsuite/config/default.exp b/imap4d/testsuite/config/default.exp
deleted file mode 100644
index 4b8c15d..0000000
--- a/imap4d/testsuite/config/default.exp
+++ /dev/null
@@ -1 +0,0 @@
-load_lib imap4d.exp
diff --git a/imap4d/testsuite/imap4d.rcin b/imap4d/testsuite/imap4d.rcin
deleted file mode 100644
index 8c1f9b9..0000000
--- a/imap4d/testsuite/imap4d.rcin
+++ /dev/null
@@ -1,36 +0,0 @@
-# Configuration file for Mailutils Imap4d testsuite.
-# Copyright (C) 2008, 2010, 2011 Free Software Foundation, Inc.
-#
-# GNU Mailutils is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3, or (at
-# your option) any later version.
-#
-# GNU Mailutils is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. 
-
-mailbox {
-  mail-spool "$objdir/data/spool";
-  mailbox-pattern "$objdir/data/spool/INBOX";
-}
-
-auth {
-  authentication generic;
-  authorization virtdomain;
-}
-
-virtdomain {
-  passwd-dir "$objdir/data/etc";
-}
-
-shared-namespace "$objdir/data";
-
-logging {
-  syslog no;
-  print-severity yes;
-};
diff --git a/imap4d/testsuite/imap4d/DISTFILES b/imap4d/testsuite/imap4d/DISTFILES
deleted file mode 100644
index 5098fbe..0000000
--- a/imap4d/testsuite/imap4d/DISTFILES
+++ /dev/null
@@ -1,11 +0,0 @@
-IDEF0955.exp
-IDEF0956.exp
-anystate.exp  
-append.exp    
-create.exp    
-examine.exp  
-expunge.exp  
-fetch.exp    
-list.exp   
-search.exp 
-x.exp
diff --git a/imap4d/testsuite/imap4d/IDEF0955.exp b/imap4d/testsuite/imap4d/IDEF0955.exp
deleted file mode 100644
index 06629c5..0000000
--- a/imap4d/testsuite/imap4d/IDEF0955.exp
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2005, 2007, 2008, 2010, 2011 Free Software Foundation,
-# Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-# Mailutils versions prior to 0.6.1 allowed to use any numbers in message
-# sets, even those greater than the maximum id (message number or uid),
-# available in the mailbox.
-# Reported: by idefense.com on Thu, 12 May 2005 13:30:06 -0400
-# References: <FB24803D1DF2A34FA59FC157B77C9705043322C1@IDSERV04.idef.com>
-
-if { $MU_ULONG_MAX > 0 } {
-    imap4d_start 
-    imap4d_auth "user!passwd" "guessme"
-
-    imap4d_test "SELECT mbox1" \
-	"5 EXISTS"\
-	"5 RECENT"\
-	-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-	"OK \[UIDNEXT 6\] Predicted next uid"\
-	"OK \[UNSEEN 1\] first unseen messsage"\
-	"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-	"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
-	"OK"
-
-    set limit [expr $MU_ULONG_MAX - 1]
-    verbose "LIMIT is $limit"
-    imap4d_test "FETCH 1:$limit FLAGS" \
-	"OK"
-
-    imap4d_test "UID FETCH 1:$limit FLAGS" \
-	"OK"
-} else {
-    unsupported "IDEF0955";
-}
-
-# End of IDEF0955.exp
diff --git a/imap4d/testsuite/imap4d/IDEF0956.exp b/imap4d/testsuite/imap4d/IDEF0956.exp
deleted file mode 100644
index 9a22815..0000000
--- a/imap4d/testsuite/imap4d/IDEF0956.exp
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2005, 2007, 2010, 2011 Free Software Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-# Mailutils versions prior to 0.6.1 missed check for integer overflow
-# in fetch_io. 
-# Reported: by idefense.com on Thu, 12 May 2005 13:30:04 -0400
-# References: <FB24803D1DF2A34FA59FC157B77C9705043322C0@IDSERV04.idef.com>
-
-if { $MU_ULONG_MAX > 0 } {
-    imap4d_start 
-    imap4d_auth "user!passwd" "guessme"
-
-    imap4d_test "SELECT mbox1" \
-	"5 EXISTS"\
-	"5 RECENT"\
-	-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-	"OK \[UIDNEXT 6\] Predicted next uid"\
-	"OK \[UNSEEN 1\] first unseen messsage"\
-	"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-	"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
-	"OK"
-
-    set limit [expr $MU_ULONG_MAX - 1]
-    verbose "LIMIT is $limit"
-    
-    imap4d_test "FETCH 1 BODY\[TEXT\]<0.$limit>" \
-	"BAD FETCH Completed"
-} else {
-    unsupported "IDEF0956"
-}
-# End of IDEF0956.exp
diff --git a/imap4d/testsuite/imap4d/anystate.exp b/imap4d/testsuite/imap4d/anystate.exp
deleted file mode 100644
index 4a3509d..0000000
--- a/imap4d/testsuite/imap4d/anystate.exp
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
-# Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-imap4d_start 
-
-imap4d_test "CAPABILITY" \
-            "CAPABILITY IMAP4rev1 NAMESPACE ID IDLE LITERAL+ UNSELECT" \
-	    "OK"
-imap4d_test "NOOP"
-
-imap4d_test "NAMESPACE" "BAD"
-
-imap4d_stop
-
-# End of anystate.exp 
diff --git a/imap4d/testsuite/imap4d/append.exp b/imap4d/testsuite/imap4d/append.exp
deleted file mode 100644
index 6289964..0000000
--- a/imap4d/testsuite/imap4d/append.exp
+++ /dev/null
@@ -1,109 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-# 6.3.11. APPEND Command
-#   Arguments:  mailbox name
-#               OPTIONAL flag parenthesized list
-#               OPTIONAL date/time string
-#               message literal
-#   Responses:  no specific responses for this command
-#   Result:     OK - append completed
-#               NO - append error: can't append to that mailbox, error
-#                    in flags or date/time or message text
-#               BAD - command unknown or arguments invalid
-#
-#      The APPEND command appends the literal argument as a new message
-#      to the end of the specified destination mailbox.  This argument
-#      SHOULD be in the format of an [RFC-822] message.
-
-imap4d_start 
-imap4d_auth "user!passwd" "guessme"
-
-imap4d_test -long "APPEND mbox (\\Seen)"\
-"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
-From: Fred Foobar <foobar@Blurdybloop.COM>
-Subject: afternoon meeting
-To: mooch@owatagu.siam.edu
-Message-Id: <B27397-0100000@Blurdybloop.COM>
-MIME-Version: 1.0
-Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
-
-Hello Joe, do you think we can meet at 3:30 tomorrow?
-
-" 
-
-imap4d_test -long "APPEND mbox \"25-Aug-2002 18:00:00 +0200\""\
-"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
-From: Fred Foobar <foobar@Blurdybloop.COM>
-Subject: afternoon meeting again
-To: mooch@owatagu.siam.edu
-Message-Id: <B27397-0200000@Blurdybloop.COM>
-MIME-Version: 1.0
-Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
-
-Better yet at 04:00?
-
-" 
-
-imap4d_test "SELECT mbox"\
-"3 EXISTS"\
-"3 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 4\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage"\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
-"OK"
-
-imap4d_test "FETCH 2:3 BODY\[\]"\
-"2 FETCH (FLAGS (\\Seen) BODY\[\] {312}"\
--literal\
-"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
-"From: Fred Foobar <foobar@Blurdybloop.COM>"\
-"Subject: afternoon meeting"\
-"To: mooch@owatagu.siam.edu"\
-"Message-Id: <B27397-0100000@Blurdybloop.COM>"\
-"MIME-Version: 1.0"\
-"Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
-""\
-"Hello Joe, do you think we can meet at 3:30 tomorrow?"\
-""\
-")"\
--noliteral\
-"3 FETCH (FLAGS (\\Seen) BODY\[\] {285}"\
--literal\
-"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
-"From: Fred Foobar <foobar@Blurdybloop.COM>"\
-"Subject: afternoon meeting again"\
-"To: mooch@owatagu.siam.edu"\
-"Message-Id: <B27397-0200000@Blurdybloop.COM>"\
-"MIME-Version: 1.0"\
-"Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
-""\
-"Better yet at 04:00?"\
-")"\
-"OK"	
-
-
-imap4d_stop
-
-# End of append.exp
-
-
-
-
-
diff --git a/imap4d/testsuite/imap4d/create.exp b/imap4d/testsuite/imap4d/create.exp
deleted file mode 100644
index 0ca83b7..0000000
--- a/imap4d/testsuite/imap4d/create.exp
+++ /dev/null
@@ -1,72 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-# 6.3.3.  CREATE Command
-#   Arguments:  mailbox name
-#   Responses:  no specific responses for this command
-#   Result:     OK - create completed
-#               NO - create failure: can't create mailbox with that name
-#               BAD - command unknown or arguments invalid
-#
-#      The CREATE command creates a mailbox with the given name.  An OK
-#      response is returned only if a new mailbox with that name has been
-#      created.  It is an error to attempt to create INBOX or a mailbox
-#      with a name that refers to an extant mailbox.  Any error in
-#      creation will return a tagged NO response.
-
-imap4d_start 
-imap4d_auth "user!passwd" "guessme"
-
-imap4d_test "CREATE flat"
-
-imap4d_test "CREATE en/to/tre"
-
-imap4d_test -long "APPEND en/to/tre \"25-Aug-2002 18:00:00 +0200\""\
-"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
-From: Fred Foobar <foobar@Blurdybloop.COM>
-Subject: afternoon meeting again
-To: mooch@owatagu.siam.edu
-Message-Id: <B27397-0200000@Blurdybloop.COM>
-MIME-Version: 1.0
-Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
-
-Better yet at 04:00?
-
-" 
-
-#      If the server's hierarchy separator character appears elsewhere in
-#      the name, the server SHOULD create any superior hierarchical names
-#      that are needed for the CREATE command to complete successfully.
-
-imap4d_test "SELECT en/to/tre"\
-"1 EXISTS"\
-"1 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 2\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage"\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
-"OK \[READ-WRITE\] SELECT Completed"
-
-imap4d_test "FETCH 1 ALL"\
--re {1 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"25-Aug-2002 16:00:00 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 285 ENVELOPE \(\"Mon, 7 Feb 1994 21:52:25 -0800 \(PST\)\" \"afternoon meeting again\" \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(NIL NIL \"mooch\" \"owatagu.siam.edu\"\)\) NIL NIL NIL \"<B27397-0200000@Blurdybloop.COM>\"\)\)}\
-"OK"
-
-	
-imap4d_stop
-
-# End of create.exp	
diff --git a/imap4d/testsuite/imap4d/examine.exp b/imap4d/testsuite/imap4d/examine.exp
deleted file mode 100644
index 64dcc15..0000000
--- a/imap4d/testsuite/imap4d/examine.exp
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
-# Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. 
-
-imap4d_start 
-imap4d_auth "user!passwd" "guessme"
-imap4d_test "EXAMINE INBOX"\
-"95 EXISTS"\
-"95 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 96\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage"\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS ()\] No Permanent flags"\
-"OK \[READ-ONLY\] EXAMINE Completed"
-
-imap4d_test "SELECT INBOX"\
-"95 EXISTS"\
-"95 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 96\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage "\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
-"OK \[READ-WRITE\] SELECT Completed"
-
-imap4d_test "STATUS INBOX (MESSAGES RECENT UNSEEN UIDVALIDITY UIDNEXT)" \
--re {STATUS INBOX \(MESSAGES 95 RECENT 95 UNSEEN 95 UIDVALIDITY [0-9]+ UIDNEXT 96\)} \
-"OK"
-
-imap4d_test "STATUS mbox1 (MESSAGES RECENT UNSEEN UIDNEXT)" \
-"STATUS mbox1 (MESSAGES 5 RECENT 5 UNSEEN 5 UIDNEXT 6)" \
-"OK"
-
-imap4d_test "EXAMINE mbox1" \
-"5 EXISTS"\
-"5 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 6\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage"\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS ()\] No Permanent flags"\
-"OK \[READ-ONLY\] EXAMINE Completed"
-
-imap4d_stop
-
-# End of examine.exp
diff --git a/imap4d/testsuite/imap4d/expunge.exp b/imap4d/testsuite/imap4d/expunge.exp
deleted file mode 100644
index 2d0e745..0000000
--- a/imap4d/testsuite/imap4d/expunge.exp
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-# 6.4.3.  EXPUNGE Command
-#   Arguments:  none
-#   Responses:  untagged responses: EXPUNGE
-#   Result:     OK - expunge completed
-#               NO - expunge failure: can't expunge (e.g. permission
-#                    denied)
-#               BAD - command unknown or arguments invalid
-#
-#      The EXPUNGE command permanently removes from the currently
-#      selected mailbox all messages that have the \Deleted flag set.
-#      Before returning an OK to the client, an untagged EXPUNGE response
-#      is sent for each message that is removed.
-
-imap4d_start 
-imap4d_auth "user!passwd" "guessme"
-
-imap4d_test "SELECT mbox1" \
-"5 EXISTS"\
-"5 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 6\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage"\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
-"OK"
-
-imap4d_test "STORE 2:* +FLAGS (\\Deleted)"\
-"2 FETCH (FLAGS (\\Deleted \\Recent))"\
-"3 FETCH (FLAGS (\\Deleted \\Recent))"\
-"4 FETCH (FLAGS (\\Deleted \\Recent))"\
-"5 FETCH (FLAGS (\\Deleted \\Recent))"\
-"OK"	
-
-imap4d_test "EXPUNGE"\
-"2 EXPUNGED"\
-"2 EXPUNGED"\
-"2 EXPUNGED"\
-"2 EXPUNGED"\
-"1 EXISTS"\
-"1 RECENT"\
-"OK"
-
-imap4d_test "CLOSE"
-
-imap4d_test "SELECT mbox1" \
-"1 EXISTS"\
-"0 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 6\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage"\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
-"OK"
-
-imap4d_stop
-
-# End of expunge.exp
diff --git a/imap4d/testsuite/imap4d/fetch.exp b/imap4d/testsuite/imap4d/fetch.exp
deleted file mode 100644
index 60286c7..0000000
--- a/imap4d/testsuite/imap4d/fetch.exp
+++ /dev/null
@@ -1,464 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-# 6.4.5.  FETCH Command
-# Arguments:  message set
-#             message data item names
-# Responses:  untagged responses: FETCH
-# Result:     OK - fetch completed
-#             NO - fetch error: can't fetch that data
-#             BAD - command unknown or arguments invalid
-#
-#      The FETCH command retrieves data associated with a message in the
-#      mailbox.  The data items to be fetched can be either a single atom
-#      or a parenthesized list.
-
-imap4d_start 
-imap4d_auth "user!passwd" "guessme"
-
-imap4d_test "SELECT mbox1" \
-"5 EXISTS"\
-"5 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 6\] Predicted next uid"\
-"OK \[UNSEEN 1\] first unseen messsage"\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
-"OK"
-
-# FLAGS          The flags that are set for this message.
-imap4d_test "FETCH 3 (FLAGS)"\
-"3 FETCH (FLAGS (\\Recent))"\
-"OK"
-
-# INTERNALDATE   The internal date of the message.
-imap4d_test "FETCH 3 INTERNALDATE"\
--re {3 FETCH \(INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\"\)} \
-"OK"
-
-# UID            The unique identifier for the message.
-imap4d_test "FETCH 3 UID"\
-"3 FETCH (UID 3)"\
-"OK"
-
-imap4d_test "FETCH 3 (FLAGS INTERNALDATE UID)"\
--re {3 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\" UID 3\)}\
-"OK"
-
-# ENVELOPE       The envelope structure of the message.  This is
-#                computed by the server by parsing the [RFC-822]
-#                header into the component parts, defaulting various
-#                fields as necessary.
-
-imap4d_test "FETCH 1:* ENVELOPE"\
-"1 FETCH (ENVELOPE (\"Fri, 28 Dec 2001 22:18:08 +0200\" \"Jabberwocky\" ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) NIL NIL NIL \"<200112282018.fBSKI8N04906@nonexistent.net>\"))"\
-"2 FETCH (ENVELOPE (\"Fri, 28 Dec 2001 23:28:08 +0200\" \"Re: Jabberwocky\" ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) ((\"Bar\" NIL \"bar\" \"dontmailme.org\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200112232808.fERKR9N16790@dontmailme.org>\"))"\
-"3 FETCH (ENVELOPE (\"Sat, 13 Jul 2002 00:43:18 +0300\" \"Simple MIME\" ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"))"\
-"4 FETCH (ENVELOPE (\"Sat, 13 Jul 2002 00:50:58 +0300\" \"Nested MIME\" ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200207122150.g6CLowb05126@example.net>\"))"\
-"5 FETCH (ENVELOPE (\"Sat, 13 Jul 2002 00:43:18 +0300\" \"Empty MIME Parts\" ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\")) ((\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\")) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"))"\
-"OK"
-
-# ALL            Macro equivalent to: (FLAGS INTERNALDATE
-#                RFC822.SIZE ENVELOPE)
-
-imap4d_test "FETCH 1:\* ALL"\
--re {1 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"28-Dec-2001 22:18:09 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 1298 ENVELOPE \(\"Fri, 28 Dec 2001 22:18:08 \+0200\" \"Jabberwocky\" \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) NIL NIL NIL \"<200112282018.fBSKI8N04906@nonexistent.net>\"\)\)}\
--re {2 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"28-Dec-2001 23:28:09 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 547 ENVELOPE \(\"Fri, 28 Dec 2001 23:28:08 \+0200\" \"Re: Jabberwocky\" \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) \(\(\"Bar\" NIL \"bar\" \"dontmailme.org\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200112232808.fERKR9N16790@dontmailme.org>\"\)\)}\
--re {3 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 1611 ENVELOPE \(\"Sat, 13 Jul 2002 00:43:18 \+0300\" \"Simple MIME\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"\)\)}\
--re {4 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:50:58 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 3483 ENVELOPE \(\"Sat, 13 Jul 2002 00:50:58 \+0300\" \"Nested MIME\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122150.g6CLowb05126@example.net>\"\)\)}\
--re {5 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:43:18 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 884 ENVELOPE \(\"Sat, 13 Jul 2002 00:43:18 \+0300\" \"Empty MIME Parts\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122143.g6CLhIb05086@example.net>\"\)\)}\
-"OK"
-
-# BODYSTRUCTURE  The [MIME-IMB] body structure of the message.  This
-#                is computed by the server by parsing the [MIME-IMB]
-#                header fields in the [RFC-822] header and
-#                [MIME-IMB] headers.
-
-imap4d_test "FETCH 1 BODYSTRUCTURE"\
-"1 FETCH (BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 972 35 NIL NIL NIL))"\
-"OK"
-
-imap4d_test "FETCH 2 BODYSTRUCTURE"\
-"2 FETCH (BODYSTRUCTURE (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 219 4 NIL NIL NIL))"\
-"OK"
-
-imap4d_test "FETCH 3 BODYSTRUCTURE"\
-"3 FETCH (BODYSTRUCTURE ((\"text\" \"plain\" (\"name\" \"msg.1\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"How doth\" \"7BIT\" 239 9 NIL NIL NIL)(\"application\" \"octet-stream\" (\"name\" \"msg.21\") \"<5082.1026510189.2@example.net>\" \"Father William Part I\" \"base64\" 468 NIL NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa0\") NIL NIL))"\
-"OK"
-
-imap4d_test "FETCH 4 BODYSTRUCTURE"\
-"4 FETCH (BODYSTRUCTURE ((\"text\" \"plain\" (\"name\" \"msg.21\" \"charset\" \"us-ascii\") \"<5122.1026510654.2@example.net>\" \"Father William Part I\" \"7BIT\" 351 10 NIL NIL NIL)((\"application\" \"octet-stream\" (\"name\" \"msg.22\") \"<5122.1026510654.4@example.net>\" \"Father William Part II\" \"base64\" 486 NIL NIL NIL)((\"application\" \"octet-stream\" (\"name\" \"msg.23\") \"<5122.1026510654.6@example.net>\" \"Father William Part III\" \"base64\" 490 NIL NIL NIL)(\"application\" \"octet-stream\" (\"name\" \"msg.24\") \"<5122.1026510654.7@example.net>\" \"Father William Part IV\" \"base64\" 502 NIL NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa2\") NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa1\") NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa0\") NIL NIL))"\
-"OK"
-
-imap4d_test "FETCH 5 BODYSTRUCTURE"\
-"5 FETCH (BODYSTRUCTURE ((\"text\" \"plain\" (\"name\" \"empty\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"Empty part\" \"7BIT\" 0 0 NIL NIL NIL)(\"text\" \"plain\" (\"name\" \"single.line\" \"charset\" \"us-ascii\") \"<5082.1026510189.2@example.net>\" \"Single line part\" \"7BIT\" 2 1 NIL NIL NIL) \"mixed\" (\"boundary\" \"----- =_aaaaaaaaaa0\") NIL NIL))"\
-"OK" 
-
-# BODY       The text of a particular body section. 
-imap4d_test "FETCH 1:* BODY"\
-"1 FETCH (BODY (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 972 35))"\
-"2 FETCH (BODY (\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 219 4))"\
-"3 FETCH (BODY ((\"text\" \"plain\" (\"name\" \"msg.1\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"How doth\" \"7BIT\" 239 9)(\"application\" \"octet-stream\" (\"name\" \"msg.21\") \"<5082.1026510189.2@example.net>\" \"Father William Part I\" \"base64\" 468) \"mixed\" NIL NIL NIL))"\
-"4 FETCH (BODY ((\"text\" \"plain\" (\"name\" \"msg.21\" \"charset\" \"us-ascii\") \"<5122.1026510654.2@example.net>\" \"Father William Part I\" \"7BIT\" 351 10)((\"application\" \"octet-stream\" (\"name\" \"msg.22\") \"<5122.1026510654.4@example.net>\" \"Father William Part II\" \"base64\" 486)((\"application\" \"octet-stream\" (\"name\" \"msg.23\") \"<5122.1026510654.6@example.net>\" \"Father William Part III\" \"base64\" 490)(\"application\" \"octet-stream\" (\"name\" \"msg.24\") \"<5122.1026510654.7@example.net>\" \"Father William Part IV\" \"base64\" 502) \"mixed\" NIL NIL NIL) \"mixed\" NIL NIL NIL) \"mixed\" NIL NIL NIL))"\
-"5 FETCH (BODY ((\"text\" \"plain\" (\"name\" \"empty\" \"charset\" \"us-ascii\") \"<5082.1026510189.1@example.net>\" \"Empty part\" \"7BIT\" 0 0)(\"text\" \"plain\" (\"name\" \"single.line\" \"charset\" \"us-ascii\") \"<5082.1026510189.2@example.net>\" \"Single line part\" \"7BIT\" 2 1) \"mixed\" NIL NIL NIL))"\
-"OK"
-
-# BODY.PEEK[<section>]<<partial>>
-#                    An alternate form of BODY[<section>] that does not
-#                    implicitly set the \Seen flag.
-
-imap4d_test "FETCH 1 BODY.PEEK\[HEADER\]"\
-"1 FETCH (BODY\[HEADER\] {326}"\
--literal\
-"Received: (from foobar@nonexistent.net)"\
-"	by nonexistent.net id fBSKI8N04906"\
-"	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
-"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
-"From: Foo Bar <foobar@nonexistent.net>"\
-"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
-"To: Bar <bar@dontmailme.org>"\
-"Subject: Jabberwocky"\
-""\
-")"\
-"OK"
-
-# The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT
-# part specifiers refer to the [RFC-822] header of
-# the message or of an encapsulated [MIME-IMT]
-# MESSAGE/RFC822 message.
-
-imap4d_test "FETCH 1 BODY\[HEADER\]"\
-"1 FETCH (FLAGS (\\Seen) BODY\[HEADER\] {326}"\
--literal\
-"Received: (from foobar@nonexistent.net)"\
-"	by nonexistent.net id fBSKI8N04906"\
-"	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
-"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
-"From: Foo Bar <foobar@nonexistent.net>"\
-"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
-"To: Bar <bar@dontmailme.org>"\
-"Subject: Jabberwocky"\
-""\
-")"\
-"OK"
-
-# HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a list of
-# field-name (as defined in [RFC-822]) names, and return a subset
-# of the header.
-
-# The subset returned by HEADER.FIELDS contains only those header fields
-# with a field-name that matches one of the names in the list;
-
-imap4d_test "FETCH 1 BODY\[HEADER.FIELDS (FROM TO SUBJECT)\]"\
-"1 FETCH (BODY\[HEADER.FIELDS (FROM TO SUBJECT)\] {94}"\
--literal\
-"FROM: Foo Bar <foobar@nonexistent.net>"\
-"TO: Bar <bar@dontmailme.org>"\
-"SUBJECT: Jabberwocky"\
-""\
-")"\
-"OK"
-
-# similarly, the subset returned by HEADER.FIELDS.NOT contains only
-# the header fields with a non-matching field-name. 
-
-imap4d_test "FETCH 1 BODY\[HEADER.FIELDS.NOT (FROM TO SUBJECT)\]"\
-"1 FETCH (BODY\[HEADER.FIELDS.NOT (FROM TO SUBJECT)\] {234}"\
--literal\
-"Received: (from foobar@nonexistent.net)"\
-"	by nonexistent.net id fBSKI8N04906"\
-"	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
-"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
-"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
-""\
-")"\
-"OK"
-
-# The TEXT part specifier refers to the text body of
-# the message, omitting the [RFC-822] header.
-
-imap4d_test "FETCH 1 BODY\[TEXT\]"\
-"1 FETCH (BODY\[TEXT\] {972}"\
--literal\
-"`Twas brillig, and the slithy toves"\
-"Did gyre and gimble in the wabe;"\
-"All mimsy were the borogoves,"\
-"And the mome raths outgrabe."\
-""\
-"`Beware the Jabberwock, my son!"\
-"The jaws that bite, the claws that catch!"\
-"Beware the Jujub bird, and shun"\
-"The frumious Bandersnatch!'"\
-""\
-"He took his vorpal sword in hand:"\
-"Long time the manxome foe he sought --"\
-"So rested he by the Tumtum gree,"\
-"And stood awhile in thought."\
-""\
-"And as in uffish thought he stood,"\
-"The Jabberwock, with eyes of flame,"\
-"Came whiffling through the tulgey wook,"\
-"And burbled as it came!"\
-""\
-"One, two!  One, two!  And through and through"\
-"The vorpal blade went snicker-snack!"\
-"He left it dead, and with its head"\
-"He went galumphing back."\
-""\
-"`And has thou slain the Jabberwock?"\
-"Come to my arms, my beamish boy!"\
-"O frabjous day!  Calloh!  Callay!"\
-"He chortled in his joy."\
-""\
-"`Twas brillig, and the slithy toves"\
-"Did gyre and gimble in the wabe;"\
-"All mimsy were the borogoves,"\
-"And the mome raths outgrabe."\
-""\
-")"\
-"OK"
-
-# It is possible to fetch a substring of the
-# designated text.  This is done by appending an open
-# angle bracket ("<"), the octet position of the
-# first desired octet, a period, the maximum number
-# of octets desired, and a close angle bracket (">")
-# to the part specifier.  
-imap4d_test "FETCH 1 BODY\[TEXT\]<0.20>"\
-"1 FETCH (BODY\[TEXT\]<0> {20}"\
--literal\
-"`Twas brillig, and t)"\
-"OK"
-
-imap4d_test "FETCH 1 BODY\[TEXT\]<200.100>"\
-"1 FETCH (BODY\[TEXT\]<200> {100}"\
--literal\
-"t catch!"\
-"Beware the Jujub bird, and shun"\
-"The frumious Bandersnatch!'"\
-""\
-"He took his vorpal sword i)"\
-"OK"
-
-# If the starting octet is beyond the end of
-# the text, an empty string is returned.
-imap4d_test "FETCH 1 BODY\[TEXT\]<3900.4000>"\
-"1 FETCH (BODY\[TEXT\]<3900> \"\")"\
-"OK"
-
-
-# Any partial fetch that attempts to read beyond the
-# end of the text is truncated as appropriate.  A
-# partial fetch that starts at octet 0 is returned as
-# a partial fetch, even if this truncation happened.
-#
-# Note: this means that BODY[]<0.2048> of a 1500-octet
-# message will return BODY[]<0> with a literal of size 1500,
-# not BODY[].
-
-imap4d_test "FETCH 1 BODY\[TEXT\]<0.4000>"\
-"1 FETCH (BODY\[TEXT\]<0> {972}"\
--literal\
-"`Twas brillig, and the slithy toves"\
-"Did gyre and gimble in the wabe;"\
-"All mimsy were the borogoves,"\
-"And the mome raths outgrabe."\
-""\
-"`Beware the Jabberwock, my son!"\
-"The jaws that bite, the claws that catch!"\
-"Beware the Jujub bird, and shun"\
-"The frumious Bandersnatch!'"\
-""\
-"He took his vorpal sword in hand:"\
-"Long time the manxome foe he sought --"\
-"So rested he by the Tumtum gree,"\
-"And stood awhile in thought."\
-""\
-"And as in uffish thought he stood,"\
-"The Jabberwock, with eyes of flame,"\
-"Came whiffling through the tulgey wook,"\
-"And burbled as it came!"\
-""\
-"One, two!  One, two!  And through and through"\
-"The vorpal blade went snicker-snack!"\
-"He left it dead, and with its head"\
-"He went galumphing back."\
-""\
-"`And has thou slain the Jabberwock?"\
-"Come to my arms, my beamish boy!"\
-"O frabjous day!  Calloh!  Callay!"\
-"He chortled in his joy."\
-""\
-"`Twas brillig, and the slithy toves"\
-"Did gyre and gimble in the wabe;"\
-"All mimsy were the borogoves,"\
-"And the mome raths outgrabe."\
-""\
-")"\
-"OK"
-
-# The MIME part specifier refers to the [MIME-IMB]
-# header for this part.
-
-# The MIME part specifier MUST be prefixed by one or
-# more numeric part specifiers.
-
-imap4d_test "FETCH 3 BODY\[1.MIME\]"\
-"3 FETCH (FLAGS (\\Seen) BODY\[1.MIME\] {138}"\
--literal\
-"Content-Type: text/plain; name=\"msg.1\"; charset=\"us-ascii\""\
-"Content-ID: <5082.1026510189.1@example.net>"\
-"Content-Description: How doth"\
-""\
-")"\
-"OK"
-
-imap4d_test "FETCH 4 BODY\[2.2.1\]"\
-"4 FETCH (FLAGS (\\Seen) BODY\[2.2.1\] {490}"\
--literal\
-"YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh"\
-"awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv"\
-"b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn"\
-"ZSB0byBkbyBpdD8nCgpgSW4gbXkgeW91dGgsJyBzYWlkIGhpcyBmYXRoZXIsIGBJIHRvb2sgdG8g"\
-"dGhlIGxhdywKQW5kIGFyZ3VlZCBlYWNoIGNhc2Ugd2l0aCBteSB3aWZlOwpBbmQgdGhlIG11c2N1"\
-"bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz"\
-"dCBvZiBteSBsaWZlLicK"\
-")"\
-"OK"
-
-###############
-# Test RFC822 operations
-
-# Clean \Seen flags
-
-imap4d_test "STORE 1:* -FLAGS (\\Seen)"\
-"1 FETCH (FLAGS (\\Recent))"\
-"2 FETCH (FLAGS (\\Recent))"\
-"3 FETCH (FLAGS (\\Recent))"\
-"4 FETCH (FLAGS (\\Recent))"\
-"5 FETCH (FLAGS (\\Recent))"\
-"OK"
-
-# RFC822         Functionally equivalent to BODY[], differing in the
-#                syntax of the resulting untagged FETCH data (RFC822
-#                is returned).
-
-imap4d_test "FETCH 1 RFC822"\
-"1 FETCH (FLAGS (\\Seen) RFC822 {1298}"\
--literal\
-"Received: (from foobar@nonexistent.net)"\
-"	by nonexistent.net id fBSKI8N04906"\
-"	for bar@dontmailme.org; Fri, 28 Dec 2001 22:18:08 +0200"\
-"Date: Fri, 28 Dec 2001 22:18:08 +0200"\
-"From: Foo Bar <foobar@nonexistent.net>"\
-"Message-Id: <200112282018.fBSKI8N04906@nonexistent.net>"\
-"To: Bar <bar@dontmailme.org>"\
-"Subject: Jabberwocky"\
-""\
-"`Twas brillig, and the slithy toves"\
-"Did gyre and gimble in the wabe;"\
-"All mimsy were the borogoves,"\
-"And the mome raths outgrabe."\
-""\
-"`Beware the Jabberwock, my son!"\
-"The jaws that bite, the claws that catch!"\
-"Beware the Jujub bird, and shun"\
-"The frumious Bandersnatch!'"\
-""\
-"He took his vorpal sword in hand:"\
-"Long time the manxome foe he sought --"\
-"So rested he by the Tumtum gree,"\
-"And stood awhile in thought."\
-""\
-"And as in uffish thought he stood,"\
-"The Jabberwock, with eyes of flame,"\
-"Came whiffling through the tulgey wook,"\
-"And burbled as it came!"\
-""\
-"One, two!  One, two!  And through and through"\
-"The vorpal blade went snicker-snack!"\
-"He left it dead, and with its head"\
-"He went galumphing back."\
-""\
-"`And has thou slain the Jabberwock?"\
-"Come to my arms, my beamish boy!"\
-"O frabjous day!  Calloh!  Callay!"\
-"He chortled in his joy."\
-""\
-"`Twas brillig, and the slithy toves"\
-"Did gyre and gimble in the wabe;"\
-"All mimsy were the borogoves,"\
-"And the mome raths outgrabe."\
-""\
-")"\
-"OK"
-
-# RFC822.HEADER  Functionally equivalent to BODY.PEEK[HEADER],
-#                differing in the syntax of the resulting untagged
-#                FETCH data (RFC822.HEADER is returned).
-
-imap4d_test "FETCH 2 RFC822.HEADER"\
-"2 FETCH (RFC822.HEADER {328}"\
--literal\
-"Received: (from bar@dontmailme.org)"\
-"	by dontmailme.org id fERKR9N16790"\
-"	for foobar@nonexistent.net; Fri, 28 Dec 2001 22:18:08 +0200"\
-"Date: Fri, 28 Dec 2001 23:28:08 +0200"\
-"From: Bar <bar@dontmailme.org>"\
-"To: Foo Bar <foobar@nonexistent.net>"\
-"Message-Id: <200112232808.fERKR9N16790@dontmailme.org>"\
-"Subject: Re: Jabberwocky"\
-""\
-")"\
-"OK"
-
-# RFC822.SIZE    The [RFC-822] size of the message.
-
-imap4d_test "FETCH 3 RFC822.SIZE"\
-"3 FETCH (RFC822.SIZE 1611)"\
-"OK"
-
-# RFC822.TEXT    Functionally equivalent to BODY[TEXT], differing in
-#                the syntax of the resulting untagged FETCH data
-#                (RFC822.TEXT is returned).
-imap4d_test "FETCH 2 RFC822.TEXT"\
-"2 FETCH (FLAGS (\\Seen) RFC822.TEXT {219}"\
--literal\
-"It seems very pretty, but it's *rather* hard to understand!'"\
-"Somehow it seems to fill my head with ideas -- only I don't"\
-"exactly know what they are!  However, SOMEBODY killed SOMETHING:"\
-"that's clear, at any rate..."\
-")"\
-"OK"
-
-# FAST           Macro equivalent to: (FLAGS INTERNALDATE
-#                RFC822.SIZE)
-
-imap4d_test "FETCH 1 FAST" \
--re {1 FETCH \(FLAGS \(\\Seen \\Recent\) INTERNALDATE \"28-Dec-2001 22:18:09 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 1298\)}\
-"OK"
-
-# FULL           Macro equivalent to: (FLAGS INTERNALDATE
-#                RFC822.SIZE ENVELOPE BODY)
-
-imap4d_test "FETCH 4 FULL"\
-    -re {4 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"13-Jul-2002 00:50:58 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 3483 ENVELOPE \(\"Sat, 13 Jul 2002 00:50:58 \+0300\" \"Nested MIME\" \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Sergey Poznyakoff\" NIL \"gray\" \"example.net\"\)\) \(\(\"Foo Bar\" NIL \"foobar\" \"nonexistent.net\"\)\) NIL NIL NIL \"<200207122150.g6CLowb05126@example.net>\"\) BODY \(\(\"text\" \"plain\" \(\"name\" \"msg.21\" \"charset\" \"us-ascii\"\) \"<5122.1026510654.2@example.net>\" \"Father William Part I\" \"7BIT\" 351 10\)\(\(\"application\" \"octet-stream\" \(\"name\" \"msg.22\"\) \"<5122.1026510654.4@example.net>\" \"Father William Part II\" \"base64\" 486\)\(\(\"application\" \"octet-stream\" \(\"name\" \"msg.23\"\) \"<5122.1026510654.6@example.net>\" \"Father William Part III\" \"base64\" 490\)\(\"application\" \"octet-stream\" \(\"name\" \"msg.24\"\) \"<5122.1026510654.7@example.net>\" \"Father William Part IV\" \"base64\" 502\) \"mixed\" NIL NIL NIL\) \"mixed\" NIL NIL NIL\) \"mixed\" NIL NIL NIL\)\)}\
-"OK"
-
-imap4d_stop
-
-# End of fetch.exp
diff --git a/imap4d/testsuite/imap4d/list.exp b/imap4d/testsuite/imap4d/list.exp
deleted file mode 100644
index a0db60b..0000000
--- a/imap4d/testsuite/imap4d/list.exp
+++ /dev/null
@@ -1,90 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 Free Software
-# Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-imap4d_start 
-imap4d_auth "user!passwd" "guessme"
-
-imap4d_test -sort "LIST \"~\" \"*\""\
-"LIST (\\NoInferiors) \"/\" ~/mbox1"\
-"LIST (\\NoInferiors) \"/\" ~/mbox"\
-"LIST (\\NoInferiors) \"/\" ~/search.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
-"OK LIST Completed"
-
-imap4d_test -sort "LIST \"~\" \"%\""\
-"LIST (\\NoInferiors) \"/\" ~/mbox1"\
-"LIST (\\NoInferiors) \"/\" ~/mbox"\
-"LIST (\\NoInferiors) \"/\" ~/search.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
-"LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
-"OK LIST Completed"
-
-imap4d_test -sort "LIST \"\" \"*\""\
-"LIST (\\NoInferiors) NIL INBOX"\
-"LIST (\\NoInferiors) \"/\" mbox1"\
-"LIST (\\NoInferiors) \"/\" mbox"\
-"LIST (\\NoInferiors) \"/\" search.mbox"\
-"LIST (\\NoInferiors) \"/\" sieve.mbox"\
-"LIST (\\NoInferiors) \"/\" teaparty.mbox"\
-"LIST (\\NoInferiors) \"/\" bigto.mbox"\
-"LIST (\\NoInferiors) \"/\" relational.mbox" \
-"OK LIST Completed"
-
-imap4d_test "LIST \"/\" \"*\""\
-"NO LIST The requested item could not be found."
-
-imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"*\""\
-"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mail.rc"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mailutils.rc"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/passwd"\
-"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/bigto.mbox"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/relational.mbox" \
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox1"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/search.mbox"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/sieve.mbox"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/teaparty.mbox"\
-"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/two"\
-"OK LIST Completed"	
-
-imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"%\""\
-"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
-"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
-"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
-"OK LIST Completed"	
-
-imap4d_test "LIST \"$MU_DATA_DIR/folder\" \"one\""\
-"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
-"OK LIST Completed"
-
-imap4d_test -sort "LIST \"\" INBOX"\
-"LIST (\\NoInferiors) NIL INBOX"\
-"OK LIST Completed"	
-
-imap4d_stop
-
-# End of list.exp
diff --git a/imap4d/testsuite/imap4d/search.exp b/imap4d/testsuite/imap4d/search.exp
deleted file mode 100644
index dc55e9a..0000000
--- a/imap4d/testsuite/imap4d/search.exp
+++ /dev/null
@@ -1,205 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. 
-
-# 6.4.4.  SEARCH Command
-# Arguments:  OPTIONAL [CHARSET] specification
-#             searching criteria (one or more)
-# Responses:  REQUIRED untagged response: SEARCH
-# Result:     OK - search completed
-#             NO - search error: can't search that [CHARSET] or
-#             criteria
-#             BAD - command unknown or arguments invalid
-#
-#      The SEARCH command searches the mailbox for messages that match
-#      the given searching criteria.  Searching criteria consist of one
-#      or more search keys.  The untagged SEARCH response from the server
-#      contains a listing of message sequence numbers corresponding to
-#      those messages that match the searching criteria.
-
-imap4d_start -mbox "search.mbox"
-imap4d_auth "user!passwd" "guessme"
-
-imap4d_test "SELECT INBOX"\
-"8 EXISTS"\
-"5 RECENT"\
--re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
-"OK \[UIDNEXT 9\] Predicted next uid"\
-"OK \[UNSEEN 4\] first unseen messsage "\
-"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
-"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
-"OK \[READ-WRITE\] SELECT Completed"
-
-# <message set>  Messages with message sequence numbers
-#                corresponding to the specified message sequence
-#                number set
-
-imap4d_test "SEARCH 1:*" \
-"SEARCH 1 2 3 4 5 6 7 8" \
-"OK"
-
-# ALL            All messages in the mailbox; the default initial
-#                key for ANDing.
-
-imap4d_test "SEARCH ALL" \
-"SEARCH 1 2 3 4 5 6 7 8" \
-"OK"
-
-# NEW            Messages that have the \Recent flag set but not the
-#                \Seen flag.  This is functionally equivalent to
-#                "(RECENT UNSEEN)".
-
-# All messages are still new
-imap4d_test "SEARCH NEW" \
-"SEARCH 4 5 6 7 8" \
-"OK"
-
-# FROM <string>  Messages that contain the specified string in the
-#                envelope structure's FROM field.
-
-imap4d_test "SEARCH FROM corrector" \
-"SEARCH 2 4 8" \
-"OK"
-
-imap4d_test "SEARCH FROM lexi@example.net" \
-"SEARCH 1 3 5 6 7" \
-"OK"
-
-# LARGER <n>     Messages with an [RFC-822] size larger than the
-#                specified number of octets.
-
-imap4d_test "SEARCH LARGER 512" \
-"SEARCH 3 4" \
-"OK"
-
-# SMALLER <n>    Messages with an [RFC-822] size smaller than the
-#                specified number of octets.
-
-imap4d_test "SEARCH SMALLER 400" \
-"SEARCH 7 8" \
-"OK"
-
-# SUBJECT <string>   Messages that contain the specified string in the
-#                    envelope structure's SUBJECT field.
-
-imap4d_test "SEARCH SUBJECT \"Alliance\"" \
-"SEARCH 6"\
-"OK"
-
-# HEADER <field-name> <string>
-#                    Messages that have a header with the specified
-#                    field-name (as defined in [RFC-822]) and that
-#                    contains the specified string in the [RFC-822]
-#                    field-body.
-
-imap4d_test "SEARCH HEADER Message-Id \"<200207291200.3303@example.org>\"" \
-"SEARCH 3" \
-"OK"	
-
-# CC <string>    Messages that contain the specified string in the
-#                 envelope structure's CC field.
-
-imap4d_test "SEARCH CC Corrector" \
-"SEARCH 6" \
-"OK"
-
-# TO <string>    Messages that contain the specified string in the
-#                envelope structure's TO field.
-
-imap4d_test "SEARCH TO editor+recheck"\
-"SEARCH 7" \
-"OK"
-
-# SENTBEFORE <date>
-#                Messages whose [RFC-822] Date: header is earlier
-#                than the specified date.
-
-imap4d_test "SEARCH SENTBEFORE \"30-Jul-2002\"" \
-"SEARCH 1 2"\
-"OK"
-
-# SENTSINCE <date>
-#                Messages whose [RFC-822] Date: header is within or
-#                later than the specified date.
-
-imap4d_test "SEARCH SENTSINCE \"31-Jul-2002\""\
-"SEARCH 5 6 7 8"\
-"OK"
-
-# BEFORE <date>  Messages whose internal date is earlier than the
-#                specified date.
-
-imap4d_test "SEARCH BEFORE \"30-Jul-2002\""\
-"SEARCH 1"\
-"OK"
-
-# SINCE <date>   Messages whose internal date is within or later
-#                than the specified date.
-
-imap4d_test "SEARCH SINCE \"30-Jul-2002\""\
-"SEARCH 2 3 4 5 6 7 8"\
-"OK"
-
-# ANSWERED       Messages with the \Answered flag set.
-
-imap4d_test "SEARCH ANSWERED"\
-"SEARCH 2 3"\
-"OK"
-
-# TEXT <string>  Messages that contain the specified string in the
-#                header or body of the message.
-
-imap4d_test "SEARCH TEXT person"\
-"SEARCH 2 5 8"\
-"OK"
-
-## Boolean operations
-
-# When multiple keys are specified, the result is the intersection
-# (AND function) of all the messages that match those keys.
-
-imap4d_test "SEARCH TEXT person FROM corrector"\
-"SEARCH 2"\
-"OK"
-
-imap4d_test "SEARCH SENTSINCE \"30-Jul-2002\" SENTBEFORE \"31-Jul-2002\"" \
-"SEARCH 3 4" \
-"OK"    
-
-# OR <search-key1> <search-key2>
-#                Messages that match either search key.
-
-imap4d_test "SEARCH OR FROM corrector ANSWERED"\
-"SEARCH 2 3 4 8" \
-"OK"    
-
-## Check precedence
-
-imap4d_test "SEARCH (OR FROM corrector ANSWERED) SENTSINCE \"30-Jul-2002\""\
-"SEARCH 3 4 8" \
-"OK"
-
-imap4d_test "SEARCH OR FROM corrector ANSWERED SENTSINCE \"30-Jul-2002\""\
-"SEARCH 3 4 8" \
-"OK"
-
-imap4d_test "SEARCH OR FROM corrector (ANSWERED SENTSINCE \"30-Jul-2002\")"\
-"SEARCH 2 3 4 8" \
-"OK"
-
-imap4d_stop
-
-# End of search.exp
diff --git a/imap4d/testsuite/imap4d/x.exp b/imap4d/testsuite/imap4d/x.exp
deleted file mode 100644
index 8e3d0b0..0000000
--- a/imap4d/testsuite/imap4d/x.exp
+++ /dev/null
@@ -1,31 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
-# Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-imap4d_start 
-
-imap4d_test -message "ID in initail state" "ID NIL"\
-"BAD ID Wrong state"
-
-imap4d_auth "user!passwd" "guessme"
-
-imap4d_test -message "ID in auth state" "ID NIL"\
-"OK"
-
-imap4d_stop
-
-# End of x.exp
diff --git a/imap4d/testsuite/lib/DISTFILES b/imap4d/testsuite/lib/DISTFILES
deleted file mode 100644
index a69c5c5..0000000
--- a/imap4d/testsuite/lib/DISTFILES
+++ /dev/null
@@ -1 +0,0 @@
-imap4d.exp
diff --git a/imap4d/testsuite/lib/imap4d.exp b/imap4d/testsuite/lib/imap4d.exp
deleted file mode 100644
index b15de23..0000000
--- a/imap4d/testsuite/lib/imap4d.exp
+++ /dev/null
@@ -1,335 +0,0 @@
-# -*- tcl -*-
-# This file is part of Mailutils testsuite.
-# Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 Free Software
-# Foundation, Inc.
-#  
-# GNU Mailutils is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# GNU Mailutils is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#  
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
-
-source $top_srcdir/testsuite/lib/mailutils.exp
-    
-mu_init "--rcfile=$objdir/imap4d.rc"
-mu_version
-if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] {
-    clone_output "WARNING: Support for virtual domains not compiled in"
-    clone_output "WARNING: Skipping tests for imap4d"
-    exit 0
-}
-
-set IMAP4D_ETC_DIR "$MU_DATA_DIR/etc"
-
-mu_makespool "$MU_RC_DIR" "$IMAP4D_ETC_DIR"
-mu_create_config imap4d
-
-set IMAP4D_TAG 0
-
-### Only procedures should come after this point.
-
-proc imap4d_version {} {
-    global MU_TOOL
-    global MU_TOOL_FLAGS
-    global MU_TOOL_VERSION
-    
-    mu_version
-    if ![is_remote host] {
-	clone_output "[which $MU_TOOL] version $MU_TOOL_VERSION"
-    } else {
-	clone_output "$MU_TOOL on remote host version $MU_TOOL_VERSION"
-    }
-}
-
-proc default_imap4d_start {args} {
-    global verbose
-    global MU_TOOL
-    global MU_TOOL_FLAGS
-    global expect_out
-    global imap4d_spawn_id
-    
-    mu_version
-
-    set args [lindex $args 0]
-    if [info exists MU_TOOL_FLAGS] {
-	set sw "$MU_TOOL_FLAGS "
-    } else {
-	set sw ""
-    }
-    
-    if [llength $args] {
-	append sw $args
-    } 
-    
-    set imap4d_cmd "$MU_TOOL $sw"
-    verbose "Spawning $imap4d_cmd"
-
-    set imap4d_spawn_id [remote_spawn host $imap4d_cmd]
-    if { $imap4d_spawn_id < 0 || $imap4d_spawn_id == "" } {
-	perror "Spawning $imap4d_cmd failed."
-	return 1;
-    }
-
-    mu_expect 360 {
-	-re "\\* (OK)|(PREAUTH) IMAP4rev1 Debugging mode.*\r\n" {
-	    verbose "imap4d initialized."
-	}
-	default {
-	    perror "imap4d not initialized"
-            exit 1
-	}
-    }
-    return 0
-}
-
-proc default_imap4d_stop {} {
-    verbose "Stopping imap4d"
-    if [imap4d_test "LOGOUT"\
-	    "BYE Session terminating." \
-	    "OK LOGOUT Completed"] {
-	perror "LOGOUT failed"
-	exit 1
-    }
-    remote_close host;
-    return 0
-}
-
-proc imap4d_start {args} {
-    global MU_SPOOL_DIR
-    
-    verbose "Starting imap4d"
-
-    set reuse_spool 0
-    set mbox "teaparty.mbox"
-    
-    for {set i 0} {$i < [llength $args]} {incr i} {
-	set a [lindex $args $i]
-	if {"$a" == "-reuse-spool"} {
-	    set reuse_spool 1
-	} elseif {"$a" == "-mbox"} {
-	    set mbox [lindex $args [expr $i + 1]]
-	    incr i
-	} else {
-	    break;
-	}
-    }
-
-    if {$reuse_spool == 0} {
-	mu_prepare_spools
-	mu_copy_file $MU_SPOOL_DIR/$mbox $MU_SPOOL_DIR/INBOX
-    }
-    return [default_imap4d_start [concat [lrange $args $i end]]]
-}
-    
-proc imap4d_stop {} {
-    global imap4d_spawn_id
-    if {[info exists imap4d_spawn_id] && $imap4d_spawn_id > 0} {
-	default_imap4d_stop
-	unset imap4d_spawn_id
-    }
-}
-
-##
-
-proc imap4d_make_command { string } {
-    global IMAP4D_TAG
-    
-    incr IMAP4D_TAG
-    return "$IMAP4D_TAG $string"
-}
-
-proc imap4d_send { string } {
-    return [mu_send "$string"]
-}
-
-proc imap4d_command { cmd } {
-    return [mu_command [imap4d_make_command $cmd]]
-}
-
-proc imap4d_uidvalidity {} {
-    regsub "(\[0-9\]*)\[0-9\]" "[clock seconds]" "\\1\[0-9\]" val
-    return $val
-}
-
-proc imap4d_exit {} {
-    imap4d_stop
-}
-
-proc imap4d_auth {args} {
-    set user [lindex $args 0]
-    set pass [lindex $args 1]
-    if [imap4d_test "LOGIN $user $pass"] {
-	perror "Failed to authorize."
-	exit 1
-    }
-}    
-    
-# imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)][-long][-silent][-sort]
-#            COMMAND [UNTAGGED...][TAGGED]
-# COMMAND   - Command to send.
-# UNTAGGED  - A list of untagged responses to expect in return. 
-# TAGGED    - A tagged response to expect in return. Defaults to "OK"
-# MESSAGE   - [optional] message to output
-proc imap4d_test {args} {
-    global IMAP4D_TAG
-    global verbose
-    
-    set default ""
-    set message ""
-    set long 0
-    set silent 0
-    set sort 0
-    for {set i 0} {$i < [llength $args]} {incr i} {
-	set a [lindex $args $i]
-	if {"$a" == "-default"} {
-	    set default [lindex $args [expr $i + 1]]
-	    incr i
-	} elseif {"$a" == "-message"} {
-	    set message [lindex $args [expr $i + 1]]
-	    incr i
-	} elseif {"$a" == "-long"} {
-	    set long 1
-	} elseif {"$a" == "-silent"} {
-	    set silent 1
-	} elseif {"$a" == "-sort"} {
-	    set sort 1
-	} else {
-	    set args [lrange $args $i end]
-	    break
-	}
-    }
-
-    if {"$message" == ""}  {
-	set message [lindex $args 0]
-    }
-
-    if $verbose>2 then {
-	send_user "Message is \"$message\"\n"
-    }
-
-    set command [lindex $args 0]
-    if {$long} {
-	set command_data [lindex $args 1]
-	set args [lrange $args 1 end]
-    } 
-	
-    set pattern [list]
-    set len [expr [llength $args] - 1]
-
-    if {$len >= 2} {
-	set regexp 0
-	set literal 0
-	for {set i 1} {$i <= [expr $len - 1]} {incr i} {
-	    switch -regexp -- "[lindex $args $i]" {
-		^-re.*$	-
-		^--     { set item "[lindex $args $i]"; set regexp 1 }
-		^-literal   { set literal 1; continue }
-		^-noliteral { set literal 0; continue }
-		default {  if {!$literal} {
-				if {$regexp} {
-				    set item "\\* [lindex $args $i]"
-				} else {
-				    set item "* [lindex $args $i]"
-				}
-			   } else {
-				set item [lindex $args $i]
-			   }
- 		           set regexp 0
-		       }
-	    }
-	    
-	    set pattern [concat $pattern [list $item]]
-	}
-	set tagged [lindex $args end]
-    } elseif {$len == 1} {
-	set tagged [lindex $args end]
-    } else {
-	set tagged "OK"
-    }
-
-    verbose "TAGGED $tagged"
-    if {$long} {
-	set command "$command {[string length $command_data]}"
-	imap4d_command $command
-	set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
-
-	mu_expect 360 {
-	    -re "^\\+ GO AHEAD.*$" { }
-	    default {
-		perror "imap4d_long_test failed"
-		return 1
-	    }
-	}
-
-	verbose "Sending $command_data" 3
-	mu_send "$command_data\n"
-
-	set s [split $command_data "\n"]
-        set s [lrange $s 0 [expr [llength $s] - 2]]
-        set result [mu_expect_list 360 [concat $s $pattern]]
-    } elseif {$sort && [llength $pattern] > 0} {
-	set command [imap4d_make_command $command]
-	set result [mu_test $command [list "-re" "(.*)\n$IMAP4D_TAG $tagged"]]
-	if {$result == 0} {
-	    if [info exists expect_out(1,string)] {
-		set out [lsort -ascii [split $expect_out(1,string) "\n"]]
-		set in [lsort -ascii $pattern]
-		if {[llength $in] == [llength $out]} {
-		    for {set i 0} {$i < [llength $in]} {incr i} {
-			regexp "(\[^\r\]*)" [lindex $out $i] dummy tmp
-			if [string compare [lindex $in $i] $tmp] {
-			    verbose "Item $i comparison failed"
-			    set result 1
-			    break
-			}
-		    }
-		} else {
-		    verbose "Input and output lists have different lengths"
-		    set result 1
-		}
-
-		if {$result} {
-		    verbose "Input: $in"
-		    verbose "Output: $out"
-		}
-		
-	    } else {
-		verbose "expect_out(1,string) does not exist. Buffer: $expect_out(buffer)"
-		set result 1
-	    }
-	} 
-    } else {
-	set command [imap4d_make_command $command]
-	set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
-        set result [mu_test $command $pattern]
-    }
-
-    if {!$silent} {
-	if {$result == 0} {
-	    pass "$message"
-	} elseif {$result == 1} {
-	    if { "$default" == "" || "$default" != "FAIL" } {
-		fail "$message"
-	    } else {
-		xfail "$message"
-		set result 0
-	    }
-	} elseif {$result == -2} {
-	    fail "$message (timeout)"
-        } elseif {$result == -3} {
-	    fail "$message (eof)"
-        } else {
-	    fail "$message"
-        }
-    }
-    return $result
-}
-	    
-


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Nov 28 14:47:11 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RV7AV-00066G-73
	for mharc-commit-mailutils@gnu.org; Mon, 28 Nov 2011 14:47:11 -0500
Received: from eggs.gnu.org ([140.186.70.92]:37803)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV7AR-00065D-Oy
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 14:47:09 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV7AQ-0007cT-15
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 14:47:07 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:45225)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV7AP-0007cH-UR
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 14:47:05 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RV7AJ-0002PD-Ut
	for commit-mailutils@gnu.org; Mon, 28 Nov 2011 19:47:05 +0000
Date: Mon, 28 Nov 2011 19:47:00 +0000
Message-Id: <E1RV7AJ-0002PD-Ut@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-483-g806f824
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 759cf45adacfe54b505ad7deebf3e54602ce46f0
X-Git-Newrev: 806f824c26af5389ddd0cfa4d479a6f6454e28b1
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Nov 2011 19:47:09 -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=806f824c26af5389ddd0cfa4d479a6f6454e28b1

The branch, master has been updated
       via  806f824c26af5389ddd0cfa4d479a6f6454e28b1 (commit)
       via  b3e5945c1432efd96a6bc80d5b0031d5ea4ddde3 (commit)
      from  759cf45adacfe54b505ad7deebf3e54602ce46f0 (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 806f824c26af5389ddd0cfa4d479a6f6454e28b1
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 28 21:46:23 2011 +0200

    Update ignored file list.
    
    * scheme/.gitignore: Update

commit b3e5945c1432efd96a6bc80d5b0031d5ea4ddde3
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Nov 28 21:37:17 2011 +0200

    Fix a bug in imap4d parser, add more tests.
    
    * imap4d/io.c (gettok): Fix memory overwrite.
    * imap4d/tests/fetch.at: Add checks for HEADER, HEADER.FIELDS,
    HEADER.FIELDS.NOT, and TEXT applied to message/rfc822 parts.
    * testsuite/spool/msg.mbox: New file.
    * testsuite/spool/DISTFILES: Add msg.mbox.

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

Summary of changes:
 imap4d/io.c               |    4 +-
 imap4d/tests/fetch.at     |   56 +++++++++++++++++++++++++++++++++++++-------
 scheme/.gitignore         |    5 ++-
 testsuite/spool/DISTFILES |    1 +
 testsuite/spool/msg.mbox  |   44 +++++++++++++++++++++++++++++++++++
 5 files changed, 97 insertions(+), 13 deletions(-)
 create mode 100644 testsuite/spool/msg.mbox

diff --git a/imap4d/io.c b/imap4d/io.c
index c0535fd..c622162 100644
--- a/imap4d/io.c
+++ b/imap4d/io.c
@@ -528,9 +528,9 @@ gettok (struct imap4d_tokbuf *tok, size_t off)
 	return insert_nul (tok, off);
       off++;
     }
-  buf[off++] = 0;
+  insert_nul (tok, off);
   
-  return off;
+  return off + 1;
 }
 
 static void
diff --git a/imap4d/tests/fetch.at b/imap4d/tests/fetch.at
index dd895d6..66fc2ff 100644
--- a/imap4d/tests/fetch.at
+++ b/imap4d/tests/fetch.at
@@ -14,7 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
 
-dnl FETCH_CHECK([NAME=`'],[KW=`'],[ARG=`'],[OUTPUT=`'],[MBOX=mbox1],[FILTERS=`'])
+dnl FETCH_CHECK([NAME=`'],[KW=`'],[ARG=`'],[OUTPUT=`'],[MBOX=mbox1],
+dnl             [FILTERS=`'])
 m4_define([FETCH_CHECK],[
 AT_SETUP([$1])
 AT_KEYWORDS([fetch $2])
@@ -324,10 +325,48 @@ bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz
 dCBvZiBteSBsaWZlLicK
 )])
 
+#         The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part
+#         specifiers can be the sole part specifier or can be prefixed by
+#         one or more numeric part specifiers, provided that the numeric
+#         part specifier refers to a part of type MESSAGE/RFC822.  The
+#         MIME part specifier MUST be prefixed by one or more numeric
+#         part specifiers.
+
+FETCH_CHECK([N.HEADER (text/plain)],[fetch-header-subpart-text fetch18],
+[1 BODY[[1.HEADER]]],
+[* 1 FETCH (BODY[[1.HEADER]] NIL)],
+[msg.mbox])
+
+FETCH_CHECK([N.HEADER (message/rfc822)],[fetch-header-subpart-msg fetch19],
+[1 BODY[[2.HEADER]]],
+[* 1 FETCH (BODY[[2.HEADER]] {406}
+Message-ID: <20111123103317.27412@host.example.org>
+Date: Wed, 23 Nov 2011 10:33:17 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <gray@example.com>
+Subject: Re: RFC822 Subtype
+In-reply-to: Your message of Wed, 23 Nov 2011 08:48:16 +0100
+         <87wrar6zzz@example.com>
+References: <87wrar6zzz@example.com>
+X-Envelope-Date: Wed Nov 23 08:33:17 2011
+X-Envelope-Sender: gray@example.org
+
+)],
+[msg.mbox])
+
+FETCH_CHECK([N.HEADER.FIELDS],[fetch-header-fields-subpart fetch20],
+[1 BODY[[2.HEADER.FIELDS (FROM TO)]]],
+[* 1 FETCH (BODY[[2.HEADER.FIELDS (FROM TO)]] {70}
+FROM: Sergey Poznyakoff <gray@example.org>
+TO: <gray@example.com>
+
+)],
+[msg.mbox])
+
 # BODY.PEEK[<section>]<<partial>>
 #                    An alternate form of BODY[<section>] that does not
 #                    implicitly set the \Seen flag.
-FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch18],
+FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch21],
 [1 BODY.PEEK[[HEADER]]],
 [* 1 FETCH (BODY[[HEADER]] {326}
 Received: (from foobar@nonexistent.net)
@@ -345,7 +384,7 @@ Subject: Jabberwocky
 #                syntax of the resulting untagged FETCH data (RFC822
 #                is returned).
 
-FETCH_CHECK([RFC822],[fetch-rfc822 fetch19],
+FETCH_CHECK([RFC822],[fetch-rfc822 fetch22],
 [1 RFC822],
 [* 1 FETCH (FLAGS (\Seen) RFC822 {1298}
 Received: (from foobar@nonexistent.net)
@@ -398,7 +437,7 @@ And the mome raths outgrabe.
 #                differing in the syntax of the resulting untagged
 #                FETCH data (RFC822.HEADER is returned).
 # FIXME: Should it set \Seen flag?
-FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch20],
+FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch23],
 [2 RFC822.HEADER],
 [* 2 FETCH (RFC822.HEADER {328}
 Received: (from bar@dontmailme.org)
@@ -414,14 +453,14 @@ Subject: Re: Jabberwocky
 
 # RFC822.SIZE    The [RFC-822] size of the message.
 
-FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch21],
+FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch24],
 [3 RFC822.SIZE],
 [* 3 FETCH (RFC822.SIZE 1611)])
 
 # RFC822.TEXT    Functionally equivalent to BODY[TEXT], differing in
 #                the syntax of the resulting untagged FETCH data
 #                (RFC822.TEXT is returned).
-FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text  fetch22],
+FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text  fetch25],
 [2 RFC822.TEXT],
 [* 2 FETCH (FLAGS (\Seen) RFC822.TEXT {219}
 It seems very pretty, but it's *rather* hard to understand!'
@@ -433,7 +472,7 @@ that's clear, at any rate...
 # FAST           Macro equivalent to: (FLAGS INTERNALDATE
 #                RFC822.SIZE)
 
-FETCH_CHECK([FAST],[fetch-fast fetch23],
+FETCH_CHECK([FAST],[fetch-fast fetch26],
 [1 FAST],
 [* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298)],
 [],
@@ -442,11 +481,10 @@ FETCH_CHECK([FAST],[fetch-fast fetch23],
 # FULL           Macro equivalent to: (FLAGS INTERNALDATE
 #                RFC822.SIZE ENVELOPE BODY)
 
-FETCH_CHECK([FULL],[fetch-full fetch24],
+FETCH_CHECK([FULL],[fetch-full fetch27],
 [4 FULL],
 [* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>") BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))],
 [],
 [fixup_tz])
 
-
 dnl ----------------------------------------------------------------------
diff --git a/scheme/.gitignore b/scheme/.gitignore
index 3ab9db1..5e791b9 100644
--- a/scheme/.gitignore
+++ b/scheme/.gitignore
@@ -1,2 +1,3 @@
-sieve.scm
-sieve.sed
\ No newline at end of file
+guimb
+package.sed
+sieve2scm
diff --git a/testsuite/spool/DISTFILES b/testsuite/spool/DISTFILES
index 59bb01e..383ba02 100644
--- a/testsuite/spool/DISTFILES
+++ b/testsuite/spool/DISTFILES
@@ -1,6 +1,7 @@
 bigto.mbox
 mbox1
 mbox
+msg.mbox
 search.mbox
 sieve.mbox
 relational.mbox
diff --git a/testsuite/spool/msg.mbox b/testsuite/spool/msg.mbox
new file mode 100644
index 0000000..dc90cb0
--- /dev/null
+++ b/testsuite/spool/msg.mbox
@@ -0,0 +1,44 @@
+From gray@example.org Sat Nov 26 22:45:20 2011
+Date: Sat, 26 Nov 2011 22:45:20 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <root@example.com>
+Subject: rfc2046
+Content-Type: multipart/mixed; boundary="1595057156-1322340286=:8528"
+MIME-Version: 1.0
+Status: OR
+
+--1595057156-1322340286=:8528
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: text/plain
+
+An excerpt from RFC 2046 regarding message/rfc822.
+
+
+--1595057156-1322340286=:8528
+Content-Transfer-Encoding: 7bit
+Content-Description: 
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: message/rfc822; name="1.msg"
+
+Message-ID: <20111123103317.27412@host.example.org>
+Date: Wed, 23 Nov 2011 10:33:17 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <gray@example.com>
+Subject: Re: RFC822 Subtype
+In-reply-to: Your message of Wed, 23 Nov 2011 08:48:16 +0100
+         <87wrar6zzz@example.com>
+References: <87wrar6zzz@example.com>
+X-Envelope-Date: Wed Nov 23 08:33:17 2011
+X-Envelope-Sender: gray@example.org
+
+5.2.1.  RFC822 Subtype
+
+   A media type of "message/rfc822" indicates that the body contains an
+   encapsulated message, with the syntax of an RFC 822 message.
+   However, unlike top-level RFC 822 messages, the restriction that each
+   "message/rfc822" body must include a "From", "Date", and at least one
+   destination header is removed and replaced with the requirement that
+   at least one of "From", "Subject", or "Date" must be present.
+
+--1595057156-1322340286=:8528--
+


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Nov 29 13:10:41 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RVS8f-0003Ec-2H
	for mharc-commit-mailutils@gnu.org; Tue, 29 Nov 2011 13:10:41 -0500
Received: from eggs.gnu.org ([140.186.70.92]:40151)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVS8Y-0003E5-DU
	for commit-mailutils@gnu.org; Tue, 29 Nov 2011 13:10:39 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVS8R-0000wW-0I
	for commit-mailutils@gnu.org; Tue, 29 Nov 2011 13:10:34 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:48994)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVS8Q-0000w0-UW
	for commit-mailutils@gnu.org; Tue, 29 Nov 2011 13:10:26 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVS8Q-0001Fx-1W
	for commit-mailutils@gnu.org; Tue, 29 Nov 2011 18:10:26 +0000
Date: Tue, 29 Nov 2011 18:10:26 +0000
Message-Id: <E1RVS8Q-0001Fx-1W@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-484-g326f5d7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 806f824c26af5389ddd0cfa4d479a6f6454e28b1
X-Git-Newrev: 326f5d74bc530df2f1b759f4131611b36be754fe
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 29 Nov 2011 18:10:39 -0000

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

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

The branch, master has been updated
       via  326f5d74bc530df2f1b759f4131611b36be754fe (commit)
      from  806f824c26af5389ddd0cfa4d479a6f6454e28b1 (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 326f5d74bc530df2f1b759f4131611b36be754fe
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Nov 29 13:23:03 2011 +0200

    Imap4d: fix handling of nested message/rfc822 parts.
    
    * imap4d/fetch.c (fetch_runtime_closure) <msglist>: New member.
    (frt_register_message,frt_unregister_messages): New functions.
    (fetch_get_part_rfc822): Look into encapsulated rfc822 messages.
    (_frt_body_text,_frt_header)
    (_frt_header_fields): Use frt_unregister_messages.
    (imap4d_fetch0): Initialize all fields in struct fetch_runtime_closure.
    Destroy msglist when finished using it.
    * imap4d/tests/fetch.at: Add test cases for nested message/rfc822.
    * testsuite/spool/msg.mbox: Add a message with nested message/rfc822 part.

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

Summary of changes:
 imap4d/fetch.c           |  127 ++++++++++++++++++-------
 imap4d/tests/fetch.at    |   44 ++++++++--
 testsuite/spool/msg.mbox |  229 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 358 insertions(+), 42 deletions(-)

diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 40b7453..5781769 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -32,10 +32,11 @@
 
 struct fetch_runtime_closure
 {
-  int eltno;
-  size_t msgno;
-  mu_message_t msg;
-  char *err_text;
+  int eltno;           /* Serial number of the last output FETCH element */
+  size_t msgno;        /* Sequence number of the message being processed */
+  mu_message_t msg;    /* The message itself */
+  mu_list_t msglist;   /* A list of referenced messages.  See KLUDGE below. */
+  char *err_text;      /* On return: error description if failed. */
 };
 
 struct fetch_function_closure;
@@ -662,7 +663,7 @@ set_seen (struct fetch_function_closure *ffc,
 	}
     }
 }
-
+
 static mu_message_t 
 fetch_get_part (struct fetch_function_closure *ffc,
 		struct fetch_runtime_closure *frt)
@@ -675,7 +676,50 @@ fetch_get_part (struct fetch_function_closure *ffc,
       return NULL;
   return msg;
 }
+
+/* FIXME: This is a KLUDGE.
+
+   There is so far no way to unref the MU elements being used to construct
+   a certain entity when this entity itself is being destroyed.  In particular,
+   retrieving a nested message/rfc822 part involves creating several messages
+   while unencapsulating, which messages should be unreferenced when the
+   topmost one is destroyed.
+
+   A temporary solution used here is to keep a list of such messages and
+   unreference them together with the topmost one when no longer needed.
+   A message is added to the list by frt_register_message().  All messages
+   in the list are unreferenced by calling frt_unregister_messages().
+
+   The proper solution is of course providing a way for mu_message_t (and
+   other MU objects) to unreference its parent elements.  This should be fixed
+   in later releases.
+ */
+
+static void
+_unref_message_item (void *data)
+{
+  mu_message_unref ((mu_message_t)data);
+}
+
+static int
+frt_register_message (struct fetch_runtime_closure *frt, mu_message_t msg)
+{
+  if (!frt->msglist)
+    {
+      int rc = mu_list_create (&frt->msglist);
+      if (rc)
+	return rc;
+      mu_list_set_destroy_item (frt->msglist, _unref_message_item);
+    }
+  return mu_list_append (frt->msglist, msg);
+}
 
+static void
+frt_unregister_messages (struct fetch_runtime_closure *frt)
+{
+  mu_list_clear (frt->msglist);
+}
+
 static mu_message_t 
 fetch_get_part_rfc822 (struct fetch_function_closure *ffc,
 		       struct fetch_runtime_closure *frt)
@@ -692,35 +736,46 @@ fetch_get_part_rfc822 (struct fetch_function_closure *ffc,
     }
   
   for (i = 0; i < ffc->nset; i++)
-    if (mu_message_get_part (msg, ffc->section_part[i], &msg))
-      return NULL;
+    {
+      if (mu_message_get_part (msg, ffc->section_part[i], &msg))
+	return NULL;
 
-  if (mu_message_get_header (msg, &header))
-    return NULL;
+      if (mu_message_get_header (msg, &header))
+	return NULL;
   
-  if (mu_header_sget_value (header, MU_HEADER_CONTENT_TYPE, &hval) == 0)
-    {
-      struct mu_wordsplit ws;
-      int rc;
-      
-      ws.ws_delim = " \t\r\n;=";
-      ws.ws_alloc_die = imap4d_ws_alloc_die;
-      if (mu_wordsplit (hval, &ws, IMAP4D_WS_FLAGS))
+      if (mu_header_sget_value (header, MU_HEADER_CONTENT_TYPE, &hval) == 0)
 	{
-	  mu_error (_("%s failed: %s"), "mu_wordsplit",
-		    mu_wordsplit_strerror (&ws));
-	  return NULL;
-	}
+	  struct mu_wordsplit ws;
+	  int rc;
+      
+	  ws.ws_delim = " \t\r\n;=";
+	  ws.ws_alloc_die = imap4d_ws_alloc_die;
+	  if (mu_wordsplit (hval, &ws, IMAP4D_WS_FLAGS))
+	    {
+	      mu_error (_("%s failed: %s"), "mu_wordsplit",
+			mu_wordsplit_strerror (&ws));
+	      return NULL;
+	    }
 
-      rc = mu_c_strcasecmp (ws.ws_wordv[0], "MESSAGE/RFC822");
-      mu_wordsplit_free (&ws);
+	  rc = mu_c_strcasecmp (ws.ws_wordv[0], "MESSAGE/RFC822");
+	  mu_wordsplit_free (&ws);
 
-      if (rc == 0)
-	{
-	  rc = mu_message_unencapsulate  (msg, &retmsg, NULL);
-	  if (rc)
-	    mu_error (_("%s failed: %s"), "mu_message_unencapsulate",
-		      mu_strerror (rc));
+	  if (rc == 0)
+	    {
+	      rc = mu_message_unencapsulate  (msg, &retmsg, NULL);
+	      if (rc)
+		{
+		  mu_error (_("%s failed: %s"), "mu_message_unencapsulate",
+			    mu_strerror (rc));
+		  return NULL;
+		}
+	      if (frt_register_message (frt, retmsg))
+		{
+		  frt_unregister_messages (frt);
+		  return NULL;
+		}
+	      msg = retmsg;
+	    }
 	}
     }
   
@@ -1042,7 +1097,7 @@ _frt_body_text (struct fetch_function_closure *ffc,
   mu_body_get_streamref (body, &stream);
   rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
-  mu_message_unref (msg);
+  frt_unregister_messages (frt);
   return rc;
 }
 
@@ -1087,7 +1142,7 @@ _frt_header (struct fetch_function_closure *ffc,
   mu_header_get_streamref (header, &stream);
   rc = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
-  mu_message_unref (msg);
+  frt_unregister_messages (frt);
   return rc;
 }
 
@@ -1177,7 +1232,7 @@ _frt_header_fields (struct fetch_function_closure *ffc,
   if (mu_message_get_header (msg, &header)
       || mu_header_get_iterator (header, &itr))
     {
-      mu_message_unref (msg);
+      frt_unregister_messages (frt);
       io_sendf (" NIL");
       return RESP_OK;
     }
@@ -1216,7 +1271,7 @@ _frt_header_fields (struct fetch_function_closure *ffc,
   mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   status = fetch_io (stream, ffc->start, ffc->size, size + lines);
   mu_stream_destroy (&stream);
-  mu_message_unref (msg);
+  frt_unregister_messages (frt);
   
   return status;
 }
@@ -1783,7 +1838,8 @@ imap4d_fetch0 (imap4d_tokbuf_t tok, int isuid, char **err_text)
     {
       size_t i;
       struct fetch_runtime_closure frc;
-      
+
+      memset (&frc, 0, sizeof (frc));
       /* Prepare status code. It will be replaced if an error occurs in the
 	 loop below */
       frc.err_text = "Completed";
@@ -1801,7 +1857,8 @@ imap4d_fetch0 (imap4d_tokbuf_t tok, int isuid, char **err_text)
 	      io_sendf (")\n");
 	    }
 	}
-      }
+      mu_list_destroy (&frc.msglist);
+    }
   
   mu_list_destroy (&pclos.fnlist);
   free (pclos.set);
diff --git a/imap4d/tests/fetch.at b/imap4d/tests/fetch.at
index 66fc2ff..e55bd60 100644
--- a/imap4d/tests/fetch.at
+++ b/imap4d/tests/fetch.at
@@ -363,10 +363,40 @@ TO: <gray@example.com>
 )],
 [msg.mbox])
 
+FETCH_CHECK([nested message/rfc822],[fetch-nested fetch21],
+[2 BODY[[2.2.TEXT]]],
+[* 2 FETCH (FLAGS (\Seen) BODY[[2.2.TEXT]] {451}
+5.2.1.  RFC822 Subtype
+
+   A media type of "message/rfc822" indicates that the body contains an
+   encapsulated message, with the syntax of an RFC 822 message.
+   However, unlike top-level RFC 822 messages, the restriction that each
+   "message/rfc822" body must include a "From", "Date", and at least one
+   destination header is removed and replaced with the requirement that
+   at least one of "From", "Subject", or "Date" must be present.
+)],
+[msg.mbox])
+
+FETCH_CHECK([nested multipart + message/rfc822],[fetch-nested fetch22],
+[2 BODY[[2.2.TEXT]]],
+[* 2 FETCH (FLAGS (\Seen) BODY[[2.2.TEXT]] {451}
+5.2.1.  RFC822 Subtype
+
+   A media type of "message/rfc822" indicates that the body contains an
+   encapsulated message, with the syntax of an RFC 822 message.
+   However, unlike top-level RFC 822 messages, the restriction that each
+   "message/rfc822" body must include a "From", "Date", and at least one
+   destination header is removed and replaced with the requirement that
+   at least one of "From", "Subject", or "Date" must be present.
+)],
+[msg.mbox])
+
+
+
 # BODY.PEEK[<section>]<<partial>>
 #                    An alternate form of BODY[<section>] that does not
 #                    implicitly set the \Seen flag.
-FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch21],
+FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch23],
 [1 BODY.PEEK[[HEADER]]],
 [* 1 FETCH (BODY[[HEADER]] {326}
 Received: (from foobar@nonexistent.net)
@@ -384,7 +414,7 @@ Subject: Jabberwocky
 #                syntax of the resulting untagged FETCH data (RFC822
 #                is returned).
 
-FETCH_CHECK([RFC822],[fetch-rfc822 fetch22],
+FETCH_CHECK([RFC822],[fetch-rfc822 fetch24],
 [1 RFC822],
 [* 1 FETCH (FLAGS (\Seen) RFC822 {1298}
 Received: (from foobar@nonexistent.net)
@@ -437,7 +467,7 @@ And the mome raths outgrabe.
 #                differing in the syntax of the resulting untagged
 #                FETCH data (RFC822.HEADER is returned).
 # FIXME: Should it set \Seen flag?
-FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch23],
+FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch25],
 [2 RFC822.HEADER],
 [* 2 FETCH (RFC822.HEADER {328}
 Received: (from bar@dontmailme.org)
@@ -453,14 +483,14 @@ Subject: Re: Jabberwocky
 
 # RFC822.SIZE    The [RFC-822] size of the message.
 
-FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch24],
+FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch26],
 [3 RFC822.SIZE],
 [* 3 FETCH (RFC822.SIZE 1611)])
 
 # RFC822.TEXT    Functionally equivalent to BODY[TEXT], differing in
 #                the syntax of the resulting untagged FETCH data
 #                (RFC822.TEXT is returned).
-FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text  fetch25],
+FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text  fetch27],
 [2 RFC822.TEXT],
 [* 2 FETCH (FLAGS (\Seen) RFC822.TEXT {219}
 It seems very pretty, but it's *rather* hard to understand!'
@@ -472,7 +502,7 @@ that's clear, at any rate...
 # FAST           Macro equivalent to: (FLAGS INTERNALDATE
 #                RFC822.SIZE)
 
-FETCH_CHECK([FAST],[fetch-fast fetch26],
+FETCH_CHECK([FAST],[fetch-fast fetch28],
 [1 FAST],
 [* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298)],
 [],
@@ -481,7 +511,7 @@ FETCH_CHECK([FAST],[fetch-fast fetch26],
 # FULL           Macro equivalent to: (FLAGS INTERNALDATE
 #                RFC822.SIZE ENVELOPE BODY)
 
-FETCH_CHECK([FULL],[fetch-full fetch27],
+FETCH_CHECK([FULL],[fetch-full fetch29],
 [4 FULL],
 [* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>") BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))],
 [],
diff --git a/testsuite/spool/msg.mbox b/testsuite/spool/msg.mbox
index dc90cb0..126934e 100644
--- a/testsuite/spool/msg.mbox
+++ b/testsuite/spool/msg.mbox
@@ -42,3 +42,232 @@ X-Envelope-Sender: gray@example.org
 
 --1595057156-1322340286=:8528--
 
+From gray@example.org Tue Nov 29 09:42:53 2011
+Message-ID: <20111129114253.10123@host.example.org>
+From: "Sergey Poznyakoff" <gray@example.org>
+Date: Tue, 29 Nov 2011 11:42:53 +0200
+To: <root@example.com>
+Subject: nested message
+Content-Type: multipart/mixed; boundary="1727955616-1322559692=:10106"
+MIME-Version: 1.0
+
+--1727955616-1322559692=:10106
+Content-ID: <20111129114132.10106.1@host.example.org>
+Content-Type: text/plain
+
+An example of nested message/rfc822
+
+
+--1727955616-1322559692=:10106
+Content-Transfer-Encoding: 7bit
+Content-Description: 
+Content-ID: <20111129114132.10106.1@host.example.org>
+Content-Type: message/rfc822; name="msg.mbox"
+
+Date: Sat, 26 Nov 2011 22:45:20 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <root@example.com>
+Subject: rfc2046
+Content-Type: multipart/mixed; boundary="1595057156-1322340286=:8528"
+MIME-Version: 1.0
+Status: OR
+
+--1595057156-1322340286=:8528
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: text/plain
+
+An excerpt from RFC 2046 regarding message/rfc822.
+
+
+--1595057156-1322340286=:8528
+Content-Transfer-Encoding: 7bit
+Content-Description: 
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: message/rfc822; name="1.msg"
+
+Message-ID: <20111123103317.27412@host.example.org>
+Date: Wed, 23 Nov 2011 10:33:17 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <gray@example.com>
+Subject: Re: RFC822 Subtype
+In-reply-to: Your message of Wed, 23 Nov 2011 08:48:16 +0100
+         <87wrar6zzz@example.com>
+References: <87wrar6zzz@example.com>
+X-Envelope-Date: Wed Nov 23 08:33:17 2011
+X-Envelope-Sender: gray@example.org
+
+5.2.1.  RFC822 Subtype
+
+   A media type of "message/rfc822" indicates that the body contains an
+   encapsulated message, with the syntax of an RFC 822 message.
+   However, unlike top-level RFC 822 messages, the restriction that each
+   "message/rfc822" body must include a "From", "Date", and at least one
+   destination header is removed and replaced with the requirement that
+   at least one of "From", "Subject", or "Date" must be present.
+
+--1595057156-1322340286=:8528--
+
+
+--1727955616-1322559692=:10106--
+From gray@example.org Tue Nov 29 13:16:16 2011
+To: gray@example.com
+Subject: nested multipart + message/rfc822.
+Content-Type: multipart/mixed; boundary="2059362778-1322566623=:4927"
+MIME-Version: 1.0
+Status: OR
+
+--2059362778-1322566623=:4927
+Content-ID: <20111129133703.4927.1@host.example.org>
+Content-Type: text/plain
+
+The following multipart attachment contains a message/rfc822 as one of
+its parts.
+
+
+--2059362778-1322566623=:4927
+Content-Type: multipart/mixed; boundary="1110782568-1322566623=:4927"
+MIME-Version: 1.0
+
+--1110782568-1322566623=:4927
+Content-ID: <20111129133703.4927.2@host.example.org>
+Content-Type: text/plain
+
+Introductory text
+
+
+--1110782568-1322566623=:4927
+Content-Transfer-Encoding: 7bit
+Content-Description: Nested message
+Content-ID: <20111129133703.4927.2@host.example.org>
+Content-Type: message/rfc822; name="1.msg"
+
+Date: Sat, 26 Nov 2011 22:45:20 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <root@example.com>
+Subject: rfc2046
+Content-Type: multipart/mixed; boundary="1595057156-1322340286=:8528"
+MIME-Version: 1.0
+Status: OR
+
+--1595057156-1322340286=:8528
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: text/plain
+
+An excerpt from RFC 2046 regarding message/rfc822.
+
+
+--1595057156-1322340286=:8528
+Content-Transfer-Encoding: 7bit
+Content-Description: 
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: message/rfc822; name="1.msg"
+
+Message-ID: <20111123103317.27412@host.example.org>
+Date: Wed, 23 Nov 2011 10:33:17 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <gray@example.com>
+Subject: Re: RFC822 Subtype
+In-reply-to: Your message of Wed, 23 Nov 2011 08:48:16 +0100
+         <87wrar6zzz@example.com>
+References: <87wrar6zzz@example.com>
+X-Envelope-Date: Wed Nov 23 08:33:17 2011
+X-Envelope-Sender: gray@example.org
+
+5.2.1.  RFC822 Subtype
+
+   A media type of "message/rfc822" indicates that the body contains an
+   encapsulated message, with the syntax of an RFC 822 message.
+   However, unlike top-level RFC 822 messages, the restriction that each
+   "message/rfc822" body must include a "From", "Date", and at least one
+   destination header is removed and replaced with the requirement that
+   at least one of "From", "Subject", or "Date" must be present.
+
+--1595057156-1322340286=:8528--
+
+
+--1110782568-1322566623=:4927--
+
+--2059362778-1322566623=:4927--
+
+From gray@example.org Tue Nov 29 13:16:16 2011
+To: gray@example.com
+Subject: nested multipart + message/rfc822.
+Content-Type: multipart/mixed; boundary="2059362778-1322566623=:4927"
+MIME-Version: 1.0
+X-IMAPbase: 1322575861 2
+Status: OR
+X-UID: 1
+
+--2059362778-1322566623=:4927
+Content-ID: <20111129133703.4927.1@host.example.org>
+Content-Type: text/plain
+
+The following multipart attachment contains a message/rfc822 as one of
+its parts.
+
+
+--2059362778-1322566623=:4927
+Content-Type: multipart/mixed; boundary="1110782568-1322566623=:4927"
+MIME-Version: 1.0
+
+--1110782568-1322566623=:4927
+Content-ID: <20111129133703.4927.2@host.example.org>
+Content-Type: text/plain
+
+Introductory text
+
+
+--1110782568-1322566623=:4927
+Content-Transfer-Encoding: 7bit
+Content-Description: Nested message
+Content-ID: <20111129133703.4927.2@host.example.org>
+Content-Type: message/rfc822; name="1.msg"
+
+Date: Sat, 26 Nov 2011 22:45:20 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <root@example.com>
+Subject: rfc2046
+Content-Type: multipart/mixed; boundary="1595057156-1322340286=:8528"
+MIME-Version: 1.0
+Status: OR
+
+--1595057156-1322340286=:8528
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: text/plain
+
+An excerpt from RFC 2046 regarding message/rfc822.
+
+
+--1595057156-1322340286=:8528
+Content-Transfer-Encoding: 7bit
+Content-Description: 
+Content-ID: <20111126224446.8528.1@host.example.org>
+Content-Type: message/rfc822; name="1.msg"
+
+Message-ID: <20111123103317.27412@host.example.org>
+Date: Wed, 23 Nov 2011 10:33:17 +0200
+From: Sergey Poznyakoff <gray@example.org>
+To: <gray@example.com>
+Subject: Re: RFC822 Subtype
+In-reply-to: Your message of Wed, 23 Nov 2011 08:48:16 +0100
+         <87wrar6zzz@example.com>
+References: <87wrar6zzz@example.com>
+X-Envelope-Date: Wed Nov 23 08:33:17 2011
+X-Envelope-Sender: gray@example.org
+
+5.2.1.  RFC822 Subtype
+
+   A media type of "message/rfc822" indicates that the body contains an
+   encapsulated message, with the syntax of an RFC 822 message.
+   However, unlike top-level RFC 822 messages, the restriction that each
+   "message/rfc822" body must include a "From", "Date", and at least one
+   destination header is removed and replaced with the requirement that
+   at least one of "From", "Subject", or "Date" must be present.
+
+--1595057156-1322340286=:8528--
+
+
+--1110782568-1322566623=:4927--
+
+--2059362778-1322566623=:4927--
+


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 30 09:35:07 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RVlFb-0007lx-L9
	for mharc-commit-mailutils@gnu.org; Wed, 30 Nov 2011 09:35:07 -0500
Received: from eggs.gnu.org ([140.186.70.92]:41252)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVlFP-0007j3-Mi
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 09:35:05 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVlFN-0001VX-7R
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 09:34:55 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:42958)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVlFN-0001VT-1u
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 09:34:53 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVlFL-0005NQ-C7
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 14:34:52 +0000
Date: Wed, 30 Nov 2011 14:34:51 +0000
Message-Id: <E1RVlFL-0005NQ-C7@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-486-g7ca7546
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 326f5d74bc530df2f1b759f4131611b36be754fe
X-Git-Newrev: 7ca7546248a32a53049e1d59889013925c01ed85
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 30 Nov 2011 14:35: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=7ca7546248a32a53049e1d59889013925c01ed85

The branch, master has been updated
       via  7ca7546248a32a53049e1d59889013925c01ed85 (commit)
       via  48fb45e67906da7673f50ef47cef0a405ebe6342 (commit)
      from  326f5d74bc530df2f1b759f4131611b36be754fe (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 7ca7546248a32a53049e1d59889013925c01ed85
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 30 15:04:57 2011 +0200

    imapio: fix payload tracing and handling of continuation responses
    
    * include/mailutils/imapio.h (mu_imapio_create): Change signature. All
    uses updated.
    (mu_imapio_trace_payload,mu_imapio_get_trace_payload): New protos.
    * include/mailutils/sys/imapio.h (_mu_imapio) <_imap_server>
    <_imap_trace_payload>: New bits.
    * libmailutils/imapio/create.c (mu_imapio_create): Take three arguments,
    the third one specifying whether the imapio object is intended for server
    or client.
    * libmailutils/imapio/getline.c (initial_parse): In server mode, parse
    everything at once.
    Handle continuation responses in client mode.
    (mu_imapio_getline): Toggle MU_XSCRIPT_PAYLOAD only if requested.
    * libmailutils/imapio/literal.c: Wait for continuation response (in
    client mode).
    * libmailutils/imapio/trace.c (mu_imapio_trace_payload)
    (mu_imapio_get_trace_payload): New functions.
    * libmailutils/tests/imapio.c: New option -server.
    * libmailutils/tests/imapio.at: Update literal tests.

commit 48fb45e67906da7673f50ef47cef0a405ebe6342
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 30 13:22:48 2011 +0200

    Bugfix.
    
    * libmailutils/imapio/getline.c (mu_imapio_getline): Fix the call to
    realloc.

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

Summary of changes:
 include/mailutils/imapio.h     |    9 +++++-
 include/mailutils/sys/imapio.h |    2 +
 libmailutils/imapio/create.c   |    3 +-
 libmailutils/imapio/getline.c  |   59 +++++++++++++++++++++++++++++----------
 libmailutils/imapio/literal.c  |   18 ++++++++++--
 libmailutils/imapio/trace.c    |   12 ++++++++
 libmailutils/tests/imapio.at   |   25 +++++++++++++++--
 libmailutils/tests/imapio.c    |    7 +++-
 8 files changed, 109 insertions(+), 26 deletions(-)

diff --git a/include/mailutils/imapio.h b/include/mailutils/imapio.h
index 5f60545..0ae7fb2 100644
--- a/include/mailutils/imapio.h
+++ b/include/mailutils/imapio.h
@@ -22,8 +22,11 @@ extern "C" {
 #endif
 
 # include <mailutils/types.h>
-  
-int mu_imapio_create (mu_imapio_t *iop, mu_stream_t str);
+
+#define MU_IMAPIO_CLIENT 0
+#define MU_IMAPIO_SERVER 1
+
+int mu_imapio_create (mu_imapio_t *iop, mu_stream_t str, int server);
 void mu_imapio_free (mu_imapio_t io);
 void mu_imapio_destroy (mu_imapio_t *pio);
   
@@ -41,6 +44,8 @@ int mu_imapio_send_qstring_unfold (struct _mu_imapio *io, const char *buffer,
 int mu_imapio_trace_enable (mu_imapio_t io);
 int mu_imapio_trace_disable (mu_imapio_t io);
 int mu_imapio_get_trace (mu_imapio_t io);
+void mu_imapio_trace_payload (mu_imapio_t io, int val);
+int mu_imapio_get_trace_payload (mu_imapio_t io);
 
 int mu_imapio_getbuf (mu_imapio_t io, char **pptr, size_t *psize);
 
diff --git a/include/mailutils/sys/imapio.h b/include/mailutils/sys/imapio.h
index 524c5be..51df259 100644
--- a/include/mailutils/sys/imapio.h
+++ b/include/mailutils/sys/imapio.h
@@ -28,7 +28,9 @@ struct _mu_imapio
   size_t _imap_buf_level;
   struct mu_wordsplit _imap_ws;
   int _imap_ws_flags;
+  int _imap_server:1;
   int _imap_transcript:1;
+  int _imap_trace_payload:1;
   int _imap_reply_ready:1;
 };
   
diff --git a/libmailutils/imapio/create.c b/libmailutils/imapio/create.c
index a28e742..6d66b82 100644
--- a/libmailutils/imapio/create.c
+++ b/libmailutils/imapio/create.c
@@ -21,7 +21,7 @@
 #include <mailutils/sys/imapio.h>
 
 int
-mu_imapio_create (mu_imapio_t *iop, mu_stream_t str)
+mu_imapio_create (mu_imapio_t *iop, mu_stream_t str, int server)
 {
   struct _mu_imapio *io = calloc (1, sizeof (*io));
   if (!io)
@@ -38,6 +38,7 @@ mu_imapio_create (mu_imapio_t *iop, mu_stream_t str)
                        MU_WRDSF_RETURN_DELIMS |
                        MU_WRDSF_WS |
                        MU_WRDSF_APPEND;
+  io->_imap_server = server;
   *iop = io;
   return 0;
 }
diff --git a/libmailutils/imapio/getline.c b/libmailutils/imapio/getline.c
index 6383631..68020d3 100644
--- a/libmailutils/imapio/getline.c
+++ b/libmailutils/imapio/getline.c
@@ -104,31 +104,42 @@ static int
 initial_parse (struct _mu_imapio *io)
 {
   int rc, type;
-  
+  int eat_rest = 0;
+
   if ((rc = mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
 			      &io->_imap_ws,
-			      io->_imap_ws_flags | MU_WRDSF_INCREMENTAL)))
+			      io->_imap_ws_flags |
+			      (io->_imap_server ? 0 : MU_WRDSF_INCREMENTAL))))
     {
       if (rc == MU_WRDSE_NOINPUT)
 	return IMAPIO_OK;
       return IMAPIO_ERR;
     }
   io->_imap_ws_flags |= MU_WRDSF_REUSE;
-
+  if (io->_imap_server)
+    return IMAPIO_OK;
+  
   if ((rc = mu_wordsplit (NULL, &io->_imap_ws, MU_WRDSF_INCREMENTAL)))
     {
       if (rc == MU_WRDSE_NOINPUT)
 	return IMAPIO_OK;
       return IMAPIO_ERR;
     }
-  
-  if ((type = is_status_response (io->_imap_ws.ws_wordv[1]))
+
+  if (strcmp (io->_imap_ws.ws_wordv[0], "+") == 0)
+    eat_rest = 1;
+  else if ((type = is_status_response (io->_imap_ws.ws_wordv[1]))
       && (type == STATUS_RESPONSE ||
 	  strcmp (io->_imap_ws.ws_wordv[0], "*") == 0))
     {
       rc = get_response_code (io);
       if (rc)
 	return IMAPIO_ERR;
+      eat_rest = 1;
+    }
+
+  if (eat_rest)
+    {
       while (io->_imap_ws.ws_endp < io->_imap_ws.ws_len &&
 	     mu_isblank (io->_imap_ws.ws_input[io->_imap_ws.ws_endp]))
 	io->_imap_ws.ws_endp++;
@@ -150,6 +161,7 @@ mu_imapio_getline (struct _mu_imapio *io)
 {
   int rc;
   char *last_arg;
+  int xlev = MU_XSCRIPT_NORMAL;
   
   if (io->_imap_reply_ready)
     {
@@ -163,7 +175,7 @@ mu_imapio_getline (struct _mu_imapio *io)
 			      &io->_imap_buf_base, &io->_imap_buf_size,
 			      &io->_imap_buf_level);
       if (rc)
-	return rc;
+	break;
       if (io->_imap_buf_level == 0)
 	break;
       io->_imap_buf_level = mu_rtrim_class (io->_imap_buf_base,
@@ -185,8 +197,11 @@ mu_imapio_getline (struct _mu_imapio *io)
 			     io->_imap_buf_level - io->_imap_ws.ws_endp,
 			     &io->_imap_ws, io->_imap_ws_flags);
       if (rc)
-	return MU_ERR_PARSE;
-
+	{
+	  rc = MU_ERR_PARSE;
+	  break;
+	}
+      
       if (io->_imap_ws.ws_wordc == 0)
 	break;
       
@@ -196,22 +211,30 @@ mu_imapio_getline (struct _mu_imapio *io)
 	  int rc;
 	  unsigned long number;
 	  char *sp = NULL;
-	  int xlev = mu_imapio_set_xscript_level (io, MU_XSCRIPT_PAYLOAD);
+
+	  if (!io->_imap_trace_payload)
+	    xlev = mu_imapio_set_xscript_level (io, MU_XSCRIPT_PAYLOAD);
 	  
 	  number = strtoul (last_arg + 1, &sp, 10);
 	  /* Client can ask for non-synchronised literal,
 	     if a '+' is appended to the octet count. */
 	  if (*sp == '}')
-	    mu_stream_printf (io->_imap_stream, "+ GO AHEAD\n");
+	    {
+	      if (io->_imap_server)
+		mu_stream_printf (io->_imap_stream, "+ GO AHEAD\n");
+	    }
 	  else if (*sp != '+')
 	    break;
 
 	  if (number + 1 > io->_imap_buf_size)
 	    {
 	      size_t newsize = number + 1;
-	      void *newp = realloc (&io->_imap_buf_base, newsize);
+	      void *newp = realloc (io->_imap_buf_base, newsize);
 	      if (!newp)
-		return ENOMEM;
+		{
+		  rc = ENOMEM;
+		  break;
+		}
 	      io->_imap_buf_base = newp;
 	      io->_imap_buf_size = newsize;
 	    }
@@ -229,7 +252,7 @@ mu_imapio_getline (struct _mu_imapio *io)
             }
 	  mu_imapio_set_xscript_level (io, xlev);
 	  if (rc)
-	    return rc;
+	    break;
 	  io->_imap_buf_base[io->_imap_buf_level++] = 0;
 
 	  free (last_arg);
@@ -237,12 +260,18 @@ mu_imapio_getline (struct _mu_imapio *io)
 	  if (mu_wordsplit_len (io->_imap_buf_base, io->_imap_buf_level,
 				&io->_imap_ws,
 				io->_imap_ws_flags|MU_WRDSF_NOSPLIT))
-	    return MU_ERR_PARSE;
+	    {
+	      rc = MU_ERR_PARSE;
+	      break;
+	    }
 	}
       else
 	break;
     }
 
+  if (!io->_imap_trace_payload)
+    mu_imapio_set_xscript_level (io, xlev);
+
   io->_imap_reply_ready = 1;
-  return 0;
+  return rc;
 }
diff --git a/libmailutils/imapio/literal.c b/libmailutils/imapio/literal.c
index e46d23e..5908dd8 100644
--- a/libmailutils/imapio/literal.c
+++ b/libmailutils/imapio/literal.c
@@ -18,6 +18,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <mailutils/types.h>
+#include <mailutils/errno.h>
 #include <mailutils/imapio.h>
 #include <mailutils/sys/imapio.h>
 #include <mailutils/stream.h>
@@ -25,7 +26,18 @@
 int
 mu_imapio_send_literal (struct _mu_imapio *io, const char *buffer)
 {
-  return mu_stream_printf (io->_imap_stream,
-			   "{%lu}\n%s", (unsigned long) strlen (buffer),
-			   buffer);
+  size_t len = strlen (buffer);
+
+  mu_stream_printf (io->_imap_stream, "{%lu}\n", (unsigned long) len);
+
+  if (!io->_imap_server)
+    {
+      int rc = mu_imapio_getline (io);
+      if (rc)
+	return rc;
+      if (!(io->_imap_reply_ready && io->_imap_ws.ws_wordv[0][0] == '+'))
+	return MU_ERR_BADREPLY;
+    }
+
+  return mu_stream_write (io->_imap_stream, buffer, len, NULL);
 }
diff --git a/libmailutils/imapio/trace.c b/libmailutils/imapio/trace.c
index ae60745..952b945 100644
--- a/libmailutils/imapio/trace.c
+++ b/libmailutils/imapio/trace.c
@@ -84,3 +84,15 @@ mu_imapio_get_trace (mu_imapio_t io)
 {
   return io ? io->_imap_transcript : 0; 
 }
+
+void
+mu_imapio_trace_payload (mu_imapio_t io, int val)
+{
+  io->_imap_trace_payload = !!val;
+}
+
+int
+mu_imapio_get_trace_payload (mu_imapio_t io)
+{
+  return io ? io->_imap_trace_payload : 0;
+}
diff --git a/libmailutils/tests/imapio.at b/libmailutils/tests/imapio.at
index b601c97..0a34eca 100644
--- a/libmailutils/tests/imapio.at
+++ b/libmailutils/tests/imapio.at
@@ -16,6 +16,8 @@
 
 AT_BANNER(IMAP IO)
 
+m4_pushdef([IMAPIO_FLAGS])
+
 dnl ------------------------------------------------------------
 dnl IMAPIO([NAME], [KW = `'], [INPUT], [STDOUT = `'],
 dnl        [STDERR = `'])
@@ -23,7 +25,7 @@ dnl
 m4_pushdef([IMAPIO],[
 m4_pushdef([MU_TEST_GROUP],[imapio])
 m4_pushdef([MU_TEST_KEYWORDS],[imapio])
-m4_pushdef([MU_TEST_COMMAND],[imapio])
+m4_pushdef([MU_TEST_COMMAND],[imapio IMAPIO_FLAGS])
 MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5])
 m4_popdef([MU_TEST_COMMAND])
 m4_popdef([MU_TEST_KEYWORDS])
@@ -78,7 +80,21 @@ IMAPIO([server response with code],[],
 6: 'Predicted next uid'
 ])
 
-IMAPIO([literals],[literal],
+IMAPIO([literals (client)],[literal],
+[A001 LOGIN {11}
+FRED FOOBAR {7}
+fat man
+],
+[],
+[4
+0: 'A001'
+1: 'LOGIN'
+2: 'FRED FOOBAR'
+3: 'fat man'
+])
+
+m4_pushdef([IMAPIO_FLAGS],[-server])
+IMAPIO([literals (server)],[literal],
 [A001 LOGIN {11}
 FRED FOOBAR {7}
 fat man
@@ -93,7 +109,7 @@ fat man
 3: 'fat man'
 ])
 
-IMAPIO([non-synch literals],[literal],
+IMAPIO([non-synchronized literals (server)],[literal],
 [A001 LOGIN {11+}
 FRED FOOBAR {7+}
 fat man
@@ -105,6 +121,9 @@ fat man
 2: 'FRED FOOBAR'
 3: 'fat man'
 ])
+m4_popdef([IMAPIO_FLAGS])
 
 dnl ------------------------------------------------------------
 m4_popdef([IMAPIO])
+m4_pushdef([IMAPIO_FLAGS])
+
diff --git a/libmailutils/tests/imapio.c b/libmailutils/tests/imapio.c
index 6093561..9783115 100644
--- a/libmailutils/tests/imapio.c
+++ b/libmailutils/tests/imapio.c
@@ -29,7 +29,7 @@
 void
 usage ()
 {
-  mu_stream_printf (mu_strout, "usage: %s [debug=SPEC] [-transcript]\n",
+  mu_stream_printf (mu_strout, "usage: %s [debug=SPEC] [-transcript] [-server]\n",
 		    mu_program_name);
   exit (0);
 }
@@ -41,6 +41,7 @@ main (int argc, char **argv)
   int transcript = 0;
   mu_imapio_t io;
   mu_stream_t str;
+  int imapio_mode = MU_IMAPIO_CLIENT;
   
   mu_stdstream_setup (MU_STDSTREAM_RESET_NONE);
   
@@ -52,6 +53,8 @@ main (int argc, char **argv)
 	mu_debug_parse_spec (opt + 6);
       else if (strcmp (opt, "-transcript") == 0)
 	transcript = 1;
+      else if (strcmp (opt, "-server") == 0)
+	imapio_mode = MU_IMAPIO_SERVER;
       else if (strcmp (opt, "-h") == 0)
 	usage ();
       else
@@ -64,7 +67,7 @@ main (int argc, char **argv)
   MU_ASSERT (mu_iostream_create (&str, mu_strin, mu_strout));
 
   
-  MU_ASSERT (mu_imapio_create (&io, str));
+  MU_ASSERT (mu_imapio_create (&io, str, imapio_mode));
 
   if (transcript)
     mu_imapio_trace_enable (io);


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 30 11:10:31 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RVmjv-0004KL-0n
	for mharc-commit-mailutils@gnu.org; Wed, 30 Nov 2011 11:10:31 -0500
Received: from eggs.gnu.org ([140.186.70.92]:42716)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVmjn-0004Jz-KQ
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 11:10:29 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVmjg-0004bm-Lk
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 11:10:23 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:55235)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVmjg-0004bh-JA
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 11:10:16 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVmjd-0001Hs-Eb
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 16:10:16 +0000
Date: Wed, 30 Nov 2011 16:10:13 +0000
Message-Id: <E1RVmjd-0001Hs-Eb@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-488-gb848706
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 7ca7546248a32a53049e1d59889013925c01ed85
X-Git-Newrev: b848706b89934be5a4419ab2ec382157d2f30aba
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 30 Nov 2011 16:10:29 -0000

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

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

The branch, master has been updated
       via  b848706b89934be5a4419ab2ec382157d2f30aba (commit)
       via  29021e954aaec4a5db1c50a505ec914fe8bbae69 (commit)
      from  7ca7546248a32a53049e1d59889013925c01ed85 (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 b848706b89934be5a4419ab2ec382157d2f30aba
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 30 18:00:38 2011 +0200

    imap client: initial implementation of fetch.
    
    * include/mailutils/imap.h (mu_imap_fetch): New proto.
    (MU_IMAP_CB_FETCH): New callback code.
    (MU_IMAP_FETCH_BODY,MU_IMAP_FETCH_BODYSTRUCTURE)
    (MU_IMAP_FETCH_ENVELOPE,MU_IMAP_FETCH_FLAGS)
    (MU_IMAP_FETCH_INTERNALDATE,MU_IMAP_FETCH_RFC822_SIZE)
    (MU_IMAP_FETCH_UID): New constants.
    (mu_imap_fetch_body,mu_imap_fetch_bodystructure)
    (mu_imap_fetch_envelope,mu_imap_fetch_flags)
    (mu_imap_fetch_internaldate,mu_imap_fetch_rfc822_size)
    (mu_imap_fetch_uid,mu_imap_fetch_response): New structures.
    * include/mailutils/sys/imap.h (MU_IMAP_SET_XSCRIPT_MASK)
    (MU_IMAP_CLR_XSCRIPT_MASK): New macros.
    (mu_imap_client_state)<MU_IMAP_FETCH_RX>: New state.
    (_mu_imap_list_nth_element_is_string): New proto.
    * libproto/imap/fetch.c: New file.
    * libproto/imap/Makefile.am (libmu_imap_la_SOURCES): Add fetch.c
    * libproto/imap/carrier.c (mu_imap_set_carrier): Update call to
    mu_imapio_create.
    * libproto/imap/resplist.c (_mu_imap_list_nth_element_is_string): New
    function.
    * libproto/imap/resproc.c (_process_unsolicited_response): Handle FETCH
    response.
    * libproto/imap/trace.c (mu_imap_trace_mask): Call mu_imapio_trace_payload
    if needed.
    * mu/imap.c (imap_bad_callback): New function.
    (com_disconnect): Register imap_bad_callback.
    (com_fetch): New function.
    (imap_comtab): Add the "fetch" command.
    * mu/mu.h (mutool_command) <flags>: New member.
    * mu/pop.c (pop_comtab): Update initializers.
    * mu/shell.c (default_comtab): Update initializers.
    (execute_line): Rewrite using incremental wordsplit.  This allows for
    optionally coalescing arguments with indices >= argmax into one argument.
    This is useful for such commands as "prompt" and "fetch".

commit 29021e954aaec4a5db1c50a505ec914fe8bbae69
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 30 17:59:24 2011 +0200

    Add a function for creating an empty email address object.
    
    * include/mailutils/address.h (mu_address_create_null): New proto.
    * libmailutils/address/address.c (mu_address_create_null): New function.

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

Summary of changes:
 imap4d/fetch.c                 |    1 -
 include/mailutils/address.h    |    2 +
 include/mailutils/imap.h       |  103 ++++++-
 include/mailutils/sys/imap.h   |   17 +-
 libmailutils/address/address.c |   10 +
 libproto/imap/Makefile.am      |    1 +
 libproto/imap/carrier.c        |    2 +-
 libproto/imap/fetch.c          |  647 ++++++++++++++++++++++++++++++++++++++++
 libproto/imap/resplist.c       |    9 +
 libproto/imap/resproc.c        |   32 ++-
 libproto/imap/trace.c          |   11 +-
 mu/imap.c                      |   58 +++-
 mu/mu.h                        |    6 +-
 mu/pop.c                       |   34 +-
 mu/shell.c                     |  118 +++++---
 15 files changed, 969 insertions(+), 82 deletions(-)
 create mode 100644 libproto/imap/fetch.c

diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 5781769..bf6ad9e 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -560,7 +560,6 @@ fetch_bodystructure0 (mu_message_t message, int extension)
 
       mu_message_get_header (message, &header);
 
-
       /* The subtype.  */
       if (mu_header_aget_value (header, MU_HEADER_CONTENT_TYPE, &buffer) == 0)
 	{
diff --git a/include/mailutils/address.h b/include/mailutils/address.h
index 65d6209..96640be 100644
--- a/include/mailutils/address.h
+++ b/include/mailutils/address.h
@@ -62,6 +62,8 @@ struct mu_address
   struct mu_address *next;
 };
 
+extern int mu_address_create_null (mu_address_t *);
+  
 extern int mu_address_create_hint (mu_address_t *, const char *,
 				   mu_address_t, int);
   
diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index cb679d0..cfb879c 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -21,6 +21,7 @@
 #include <mailutils/iterator.h>
 #include <mailutils/debug.h>
 #include <mailutils/stream.h>
+#include <mailutils/util.h>
 #include <mailutils/kwd.h>
 
 #ifdef __cplusplus
@@ -58,6 +59,8 @@ int mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc);
 
 int mu_imap_noop (mu_imap_t imap);
 
+int mu_imap_fetch (mu_imap_t imap, const char *msgset, const char *items);
+  
 int mu_imap_set_carrier (mu_imap_t imap, mu_stream_t carrier);
 int mu_imap_get_carrier (mu_imap_t imap, mu_stream_t *pcarrier);
 
@@ -104,7 +107,7 @@ extern struct mu_kwd _mu_imap_status_name_table[];
 
   /* The following five callbacks correspond to members of struct
      mu_imap_stat and take a pointer to struct mu_imap_stat as their
-     only argument. */
+     PDAT argument.  SDAT is always 0. */
 #define MU_IMAP_CB_PERMANENT_FLAGS  0
 #define MU_IMAP_CB_MESSAGE_COUNT    1
 #define MU_IMAP_CB_RECENT_COUNT     2
@@ -113,15 +116,20 @@ extern struct mu_kwd _mu_imap_status_name_table[];
 #define MU_IMAP_CB_UIDVALIDITY      5
 
   /* The following callbacks correspond to server responses and take two
-     argument: a response code (see MU_IMAP_RESPONSE, below), and
-     human-readable text string as returned by the server.  The latter can
-     be NULL. */
+     arguments: a response code (see MU_IMAP_RESPONSE, below) in SDAT, and
+     human-readable text string as returned by the server in PDAT.  The
+     latter can be NULL. */
 #define MU_IMAP_CB_OK               6
 #define MU_IMAP_CB_NO               7
 #define MU_IMAP_CB_BAD              8
 #define MU_IMAP_CB_BYE              9
 #define MU_IMAP_CB_PREAUTH         10
-#define _MU_IMAP_CB_MAX            11
+
+  /* FETCH callback.  Arguments: SDAT - message sequence number, PDAT - a
+     list (mu_list_t) of union mu_imap_fetch_response (see below). */
+#define MU_IMAP_CB_FETCH           11
+
+#define _MU_IMAP_CB_MAX            12
 
 typedef void (*mu_imap_callback_t) (void *, int code, size_t sdat, void *pdat);
   
@@ -144,7 +152,92 @@ void mu_imap_register_callback_function (mu_imap_t imap, int code,
 #define MU_IMAP_RESPONSE_UNSEEN          10
 
 extern struct mu_kwd mu_imap_response_codes[];  
+
+  /* FETCH Response Codes */
+
+  /* BODY[<section>]<<origin octet>> */
+#define MU_IMAP_FETCH_BODY                 0
+  /* BODY & BODYSTRUCTURE */
+#define MU_IMAP_FETCH_BODYSTRUCTURE        1
+  /* ENVELOPE */
+#define MU_IMAP_FETCH_ENVELOPE             2 
+  /* FLAGS */
+#define MU_IMAP_FETCH_FLAGS                3
+  /* INTERNALDATE */
+#define MU_IMAP_FETCH_INTERNALDATE         4
+  /* RFC822.SIZE */
+#define MU_IMAP_FETCH_RFC822_SIZE          5
+  /* UID */
+#define MU_IMAP_FETCH_UID                  6
+
+struct mu_imap_fetch_body
+{
+  int type;
+  size_t *partv;
+  size_t partc;
+  char *key;
+  char *text;
+};
+
+struct mu_imap_fetch_bodystructure
+{
+  int type;
+  //FIXME?
+};
   
+struct mu_imap_fetch_envelope
+{
+  int type;
+  struct tm date;
+  struct mu_timezone tz;
+  char *subject;
+  mu_address_t from;
+  mu_address_t sender;
+  mu_address_t reply_to;
+  mu_address_t to;
+  mu_address_t cc;
+  mu_address_t bcc;
+  char *in_reply_to;
+  char *message_id;
+};
+
+struct mu_imap_fetch_flags
+{
+  int type;
+  int flags;
+};
+
+struct mu_imap_fetch_internaldate
+{
+  int type;
+  struct tm tm;
+  struct mu_timezone tz;
+};
+  
+struct mu_imap_fetch_rfc822_size
+{
+  int type;
+  size_t size;
+};
+  
+struct mu_imap_fetch_uid
+{
+  int type;
+  size_t uid;
+};
+
+union mu_imap_fetch_response
+{
+  int type;
+  struct mu_imap_fetch_body body;
+  struct mu_imap_fetch_bodystructure bodystructure;
+  struct mu_imap_fetch_envelope envelope;
+  struct mu_imap_fetch_flags flags;
+  struct mu_imap_fetch_internaldate internaldate;
+  struct mu_imap_fetch_rfc822_size rfc822_size;
+  struct mu_imap_fetch_uid uid;
+};
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index 58bffd4..ff23a91 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -32,7 +32,17 @@ extern "C" {
 #define MU_IMAP_RESP  0x01
 #define MU_IMAP_TRACE 0x02
 #define MU_IMAP_XSCRIPT_MASK(n) (1<<((n)+1))
-
+#define MU_IMAP_SET_XSCRIPT_MASK(imap,n)	\
+  do						\
+    (imap)->flags |= MU_IMAP_XSCRIPT_MASK (n);	\
+  while (0)
+#define MU_IMAP_CLR_XSCRIPT_MASK(imap,n)	\
+  do						\
+    (imap)->flags &= ~MU_IMAP_XSCRIPT_MASK (n);	\
+  while (0)
+#define MU_IMAP_IS_XSCRIPT_MASK(imap,n)         \
+  ((imap)->flags & MU_IMAP_XSCRIPT_MASK (n))
+  
 enum mu_imap_client_state
   {
     MU_IMAP_NO_STATE,
@@ -47,6 +57,7 @@ enum mu_imap_client_state
     MU_IMAP_SELECT_RX,
     MU_IMAP_STATUS_RX,
     MU_IMAP_NOOP_RX,
+    MU_IMAP_FETCH_RX,
     MU_IMAP_CLOSING
   };
 
@@ -174,10 +185,14 @@ int _mu_imap_response (mu_imap_t imap, mu_imap_response_action_t fun,
   
 int _mu_imap_list_element_is_string (struct imap_list_element *elt,
 				     const char *str);
+int _mu_imap_list_nth_element_is_string (mu_list_t list, size_t n,
+					 const char *str);
+  
 int _mu_imap_collect_flags (struct imap_list_element *arg, int *res);
 
 struct imap_list_element *_mu_imap_list_at (mu_list_t list, int idx);
   
+int _mu_imap_parse_fetch_response (mu_list_t resp, mu_list_t *result_list);
   
 # ifdef __cplusplus
 }
diff --git a/libmailutils/address/address.c b/libmailutils/address/address.c
index 69b105d..117d10e 100644
--- a/libmailutils/address/address.c
+++ b/libmailutils/address/address.c
@@ -36,6 +36,16 @@
 #include <mailutils/address.h>
 #include <mailutils/cstr.h>
 
+int
+mu_address_create_null (mu_address_t *pa)
+{
+  mu_address_t a = calloc (1, sizeof (*a));
+  if (!a)
+    return ENOMEM;
+  *pa = a;
+  return 0;
+}
+
 /* Get email addresses from rfc822 address.  */
 int
 mu_address_create_hint (mu_address_t *a, const char *s, mu_address_t hint,
diff --git a/libproto/imap/Makefile.am b/libproto/imap/Makefile.am
index c14b76d..fbd14bd 100644
--- a/libproto/imap/Makefile.am
+++ b/libproto/imap/Makefile.am
@@ -28,6 +28,7 @@ libmu_imap_la_LIBADD = ${MU_LIB_AUTH} ${MU_LIB_MAILUTILS} @INTLLIBS@
 #  url.c
 libmu_imap_la_SOURCES = \
  fake-folder.c\
+ fetch.c\
  callback.c\
  capability.c\
  capatst.c\
diff --git a/libproto/imap/carrier.c b/libproto/imap/carrier.c
index afb8563..ecc170c 100644
--- a/libproto/imap/carrier.c
+++ b/libproto/imap/carrier.c
@@ -37,7 +37,7 @@ mu_imap_set_carrier (mu_imap_t imap, mu_stream_t carrier)
   if (imap == NULL)
     return EINVAL;
 
-  rc = mu_imapio_create (&io, carrier);
+  rc = mu_imapio_create (&io, carrier, MU_IMAPIO_CLIENT);
   if (rc)
     return rc;
   if (imap->io)
diff --git a/libproto/imap/fetch.c b/libproto/imap/fetch.c
new file mode 100644
index 0000000..4b6e65d
--- /dev/null
+++ b/libproto/imap/fetch.c
@@ -0,0 +1,647 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/errno.h>
+#include <mailutils/address.h>
+#include <mailutils/cstr.h>
+#include <mailutils/cctype.h>
+#include <mailutils/imap.h>
+#include <mailutils/sys/imap.h>
+
+int
+mu_imap_fetch (mu_imap_t imap, const char *msgset, const char *items)
+{
+  int status;
+  
+  if (imap == NULL)
+    return EINVAL;
+  if (!imap->io)
+    return MU_ERR_NO_TRANSPORT;
+  if (imap->state != MU_IMAP_CONNECTED)
+    return MU_ERR_SEQ;
+
+  if (imap->imap_state != MU_IMAP_STATE_SELECTED)
+    return MU_ERR_SEQ;
+  
+  switch (imap->state)
+    {
+    case MU_IMAP_CONNECTED:
+      status = _mu_imap_tag_next (imap);
+      MU_IMAP_CHECK_EAGAIN (imap, status);
+      status = mu_imapio_printf (imap->io, "%s FETCH %s %s\r\n",
+				 imap->tag_str, msgset, items);
+      MU_IMAP_CHECK_ERROR (imap, status);
+      MU_IMAP_FCLR (imap, MU_IMAP_RESP);
+      imap->state = MU_IMAP_FETCH_RX;
+
+    case MU_IMAP_FETCH_RX:
+      status = _mu_imap_response (imap, NULL, NULL);
+      MU_IMAP_CHECK_EAGAIN (imap, status);
+      switch (imap->resp_code)
+	{
+	case MU_IMAP_OK:
+	  status = 0;
+	  break;
+
+	case MU_IMAP_NO:
+	  status = MU_ERR_FAILURE;
+	  break;
+
+	case MU_IMAP_BAD:
+	  status = MU_ERR_BADREPLY;
+	  break;
+	}
+      imap->state = MU_IMAP_CONNECTED;
+      break;
+
+    default:
+      status = EINPROGRESS;
+    }
+  return status;
+}
+
+static void
+_free_fetch_response (void *ptr)
+{
+  union mu_imap_fetch_response *resp = ptr;
+  switch (resp->type)
+    {
+    case MU_IMAP_FETCH_BODY:
+      free (resp->body.partv);
+      free (resp->body.key);
+      free (resp->body.text);
+      break;
+      
+    case MU_IMAP_FETCH_BODYSTRUCTURE:
+      /* FIXME */
+      break;
+      
+    case MU_IMAP_FETCH_ENVELOPE:
+      free (resp->envelope.subject);
+      mu_address_destroy (&resp->envelope.from);
+      mu_address_destroy (&resp->envelope.sender);
+      mu_address_destroy (&resp->envelope.reply_to);
+      mu_address_destroy (&resp->envelope.to);
+      mu_address_destroy (&resp->envelope.cc);
+      mu_address_destroy (&resp->envelope.bcc);
+      free (resp->envelope.in_reply_to);
+      free (resp->envelope.message_id);
+      break;
+      
+    case MU_IMAP_FETCH_FLAGS:
+    case MU_IMAP_FETCH_INTERNALDATE:
+    case MU_IMAP_FETCH_RFC822_SIZE:
+    case MU_IMAP_FETCH_UID:
+      break;
+    }
+  free (resp);
+}
+
+static int
+alloc_response (union mu_imap_fetch_response **resp, int type)
+{
+  static size_t sizetab[] = {
+    sizeof (struct mu_imap_fetch_body),
+    sizeof (struct mu_imap_fetch_bodystructure),
+    sizeof (struct mu_imap_fetch_envelope),
+    sizeof (struct mu_imap_fetch_flags),
+    sizeof (struct mu_imap_fetch_internaldate),
+    sizeof (struct mu_imap_fetch_rfc822_size),
+    sizeof (struct mu_imap_fetch_uid)
+  };
+  union mu_imap_fetch_response *p;
+  
+  if (type < 0 || type >= MU_ARRAY_SIZE (sizetab))
+    return EINVAL;
+  p = calloc (1, sizetab[type]);
+  if (!p)
+    return ENOMEM;
+  p->type = type;
+  *resp = p;
+  return 0;
+}
+
+static int
+_uid_mapper (struct imap_list_element **elt,
+	     union mu_imap_fetch_response **return_resp)
+{
+  union mu_imap_fetch_response *resp;
+  int rc;
+  char *p;
+  size_t uid;
+  
+  if (elt[1]->type != imap_eltype_string)
+    return MU_ERR_FAILURE;
+  uid = strtoul (elt[1]->v.string, &p, 0);
+  if (*p)
+    return MU_ERR_FAILURE;
+  rc = alloc_response (&resp, MU_IMAP_FETCH_UID);
+  if (rc)
+    return rc;
+  resp->uid.uid = uid;
+  *return_resp = resp;
+  return 0;
+}
+			 
+static int
+_size_mapper (struct imap_list_element **elt,
+	      union mu_imap_fetch_response **return_resp)
+{
+  union mu_imap_fetch_response *resp;
+  int rc;
+  char *p;
+  size_t size;
+  
+  if (elt[1]->type != imap_eltype_string)
+    return MU_ERR_FAILURE;
+  size = strtoul (elt[1]->v.string, &p, 0);
+  if (*p)
+    return MU_ERR_FAILURE;
+  rc = alloc_response (&resp, MU_IMAP_FETCH_RFC822_SIZE);
+  if (rc)
+    return rc;
+  resp->rfc822_size.size = size;
+  *return_resp = resp;
+  return 0;
+}
+
+static int
+_body_mapper (struct imap_list_element **elt,
+	      union mu_imap_fetch_response **return_resp)
+{
+  union mu_imap_fetch_response *resp;
+  int rc;
+  char *section, *p;
+  size_t partc = 0;
+  size_t *partv = NULL;
+  
+  if (elt[1]->type != imap_eltype_string)
+    return MU_ERR_FAILURE;
+  rc = alloc_response (&resp, MU_IMAP_FETCH_BODY);
+  if (rc)
+    return rc;
+
+  section = strchr (elt[0]->v.string, '[');
+  if (section)
+    {
+      p = section;
+      while (1)
+	{
+	  p = strchr (p, '.');
+	  if (*p)
+	    {
+	      p++;
+	      if (mu_isdigit (p[1]))
+		{
+		  partc++;
+		  continue;
+		}
+	    }
+	  
+	  break;
+	}
+    }
+  
+  if (partc)
+    {
+      size_t i;
+      
+      partv = calloc (partc, sizeof (partv[0]));
+      for (i = 0, p = section; i < partc; i++)
+	{
+	  partv[i] = strtoul (p, &p, 10);
+	  p++;
+	}
+    }
+
+  resp->body.partc = partc;
+  resp->body.partv = partv;
+
+  if (p)
+    {
+      size_t len = strlen (p);
+      resp->body.key = malloc (len);
+      if (!resp->body.key)
+	{
+	  free (resp->body.partv);
+	  free (resp);
+	  return ENOMEM;
+	}
+      len--;
+      memcpy (resp->body.key, p, len);
+      resp->body.key[len] = 0;
+    }
+  
+  resp->body.text = strdup (elt[1]->v.string);
+  if (!resp->body.text)
+    {
+      free (resp->body.key);
+      free (resp->body.partv);
+      free (resp);
+      return ENOMEM;
+    }
+  *return_resp = resp;
+  return 0;
+}
+
+static int
+_rfc822_mapper (const char *key, struct imap_list_element *elt,
+		union mu_imap_fetch_response **return_resp)
+{
+  union mu_imap_fetch_response *resp;
+  int rc;
+  
+  if (elt->type != imap_eltype_string)
+    return MU_ERR_FAILURE;
+  rc = alloc_response (&resp, MU_IMAP_FETCH_BODY);
+  if (rc)
+    return rc;
+
+  resp->body.partc = 0;
+  resp->body.partv = NULL;
+
+  resp->body.key = strdup (key);
+  if (!resp->body.key)
+    {
+      free (resp);
+      return ENOMEM;
+    }
+  
+  resp->body.text = strdup (elt->v.string);
+  if (!resp->body.text)
+    {
+      free (resp->body.key);
+      free (resp->body.partv);
+      free (resp);
+      return ENOMEM;
+    }
+  *return_resp = resp;
+  return 0;
+}
+
+static int
+_rfc822_header_mapper (struct imap_list_element **elt,
+		       union mu_imap_fetch_response **return_resp)
+{
+  return _rfc822_mapper ("HEADER", elt[1], return_resp);
+}
+
+static int
+_rfc822_text_mapper (struct imap_list_element **elt,
+		     union mu_imap_fetch_response **return_resp)
+{
+  return _rfc822_mapper ("TEXT", elt[1], return_resp);
+}
+
+static int
+_flags_mapper (struct imap_list_element **elt,
+	       union mu_imap_fetch_response **return_resp)
+{
+  union mu_imap_fetch_response *resp;
+  int rc;
+  int flags;
+  
+  if (elt[1]->type != imap_eltype_list)
+    return MU_ERR_FAILURE;
+  if (_mu_imap_collect_flags (elt[1], &flags))
+    return MU_ERR_FAILURE;
+
+  rc = alloc_response (&resp, MU_IMAP_FETCH_FLAGS);
+  if (rc)
+    return rc;
+  resp->flags.flags = flags;
+  *return_resp = resp;
+  return 0;
+}
+
+static int
+_date_mapper (struct imap_list_element **elt,
+	      union mu_imap_fetch_response **return_resp)
+{
+  struct mu_imap_fetch_internaldate idate;
+  union mu_imap_fetch_response *resp;
+  int rc;
+  const char *p;
+  
+  if (elt[1]->type != imap_eltype_string)
+    return MU_ERR_FAILURE;
+  p = elt[1]->v.string;
+  if (mu_parse_imap_date_time (&p, &idate.tm, &idate.tz))
+    return MU_ERR_FAILURE;
+  rc = alloc_response (&resp, MU_IMAP_FETCH_INTERNALDATE);
+  if (rc)
+    return rc;
+  resp->internaldate = idate;
+  *return_resp = resp;
+  return 0;
+}
+
+struct fill_env
+{
+  struct mu_imap_fetch_envelope *envelope;
+  size_t n;
+};
+
+enum env_index
+  {
+    env_date,
+    env_subject,
+    env_from,
+    env_sender,
+    env_reply_to,
+    env_to,
+    env_cc,
+    env_bcc,
+    env_in_reply_to,
+    env_message_id
+  };
+
+static int
+elt_to_string (struct imap_list_element *elt, char **pstr)
+{
+  char *p;
+  
+  if (elt->type != imap_eltype_string)
+    return EINVAL;
+  if (mu_c_strcasecmp (elt->v.string, "NIL") == 0)
+    p = NULL;
+  else
+    {
+      p = strdup (elt->v.string);
+      if (!p)
+	return ENOMEM;
+    }
+  *pstr = p;
+  return 0;
+}
+
+struct addr_env
+{
+  mu_address_t addr;
+  size_t n;
+};
+
+static int
+_fill_subaddr (void *item, void *data)
+{
+  struct addr_env *addr_env = data;
+  struct imap_list_element *elt = item, *arg;
+  const char *domain = NULL, *local = NULL, *personal = NULL;
+  
+  if (elt->type != imap_eltype_list)
+    return 0;
+  
+  arg = _mu_imap_list_at (elt->v.list, 0);
+  if (arg && arg->type == imap_eltype_string && strcmp (arg->v.string, "NIL"))
+    personal = arg->v.string;
+  arg = _mu_imap_list_at (elt->v.list, 2);
+  if (arg && arg->type == imap_eltype_string && strcmp (arg->v.string, "NIL"))
+    local = arg->v.string;
+  arg = _mu_imap_list_at (elt->v.list, 3);
+  if (arg && arg->type == imap_eltype_string && strcmp (arg->v.string, "NIL"))
+    domain = arg->v.string;
+
+  if (domain && local)
+    {
+      if (!addr_env->addr)
+	{
+	  int rc = mu_address_create_null (&addr_env->addr);
+	  if (rc)
+	    return rc;
+	}
+      mu_address_set_local_part (addr_env->addr, addr_env->n, local);
+      mu_address_set_domain (addr_env->addr, addr_env->n, domain);
+      mu_address_set_personal (addr_env->addr, addr_env->n, personal);
+      addr_env->n++;
+    }
+  return 0;
+}
+
+static int
+elt_to_address (struct imap_list_element *elt, mu_address_t *paddr)
+{
+  if (elt->type != imap_eltype_list)
+    {
+      if (mu_c_strcasecmp (elt->v.string, "NIL") == 0)
+	*paddr = NULL;
+      else
+	return EINVAL;
+    }
+  else
+    {
+      struct addr_env addr_env;
+      addr_env.addr = NULL;
+      addr_env.n = 1;
+      mu_list_foreach (elt->v.list, _fill_subaddr, &addr_env);
+      *paddr = addr_env.addr;
+    }
+  return 0;
+}
+
+static int
+_fill_response (void *item, void *data)
+{
+  int rc;
+  struct imap_list_element *elt = item;
+  struct fill_env *env = data;
+
+  switch (env->n++)
+    {
+    case env_date:
+      if (elt->type != imap_eltype_string)
+	rc = MU_ERR_FAILURE;
+      else
+	{
+	  char const *p = elt->v.string;
+	  if (mu_parse_imap_date_time (&p,
+				       &env->envelope->date,
+				       &env->envelope->tz))
+	    rc = MU_ERR_FAILURE;
+	  else
+	    rc = 0;
+	}
+      break;
+      
+    case env_subject:
+      rc = elt_to_string (elt, &env->envelope->subject);
+      break;
+
+    case env_from:
+      rc = elt_to_address (elt, &env->envelope->from);
+      break;
+	
+    case env_sender:
+      rc = elt_to_address (elt, &env->envelope->sender);
+      break;
+      
+    case env_reply_to:
+      rc = elt_to_address (elt, &env->envelope->reply_to);
+      break;
+      
+    case env_to:
+      rc = elt_to_address (elt, &env->envelope->to);
+      break;
+      
+    case env_cc:
+      rc = elt_to_address (elt, &env->envelope->cc);
+      break;
+      
+    case env_bcc:
+      rc = elt_to_address (elt, &env->envelope->bcc);
+      break;
+      
+    case env_in_reply_to:
+      rc = elt_to_string (elt, &env->envelope->in_reply_to);
+      break;
+      
+    case env_message_id:
+      rc = elt_to_string (elt, &env->envelope->message_id);
+      break;
+    }
+  return rc;
+}
+  
+static int
+_envelope_mapper (struct imap_list_element **elt,
+		  union mu_imap_fetch_response **return_resp)
+{
+  union mu_imap_fetch_response *resp;
+  int rc;
+  struct fill_env env;
+  
+  if (elt[1]->type != imap_eltype_list)
+    return MU_ERR_FAILURE;
+  rc = alloc_response (&resp, MU_IMAP_FETCH_ENVELOPE);
+  if (rc)
+    return rc;
+  env.envelope = &resp->envelope;
+  env.n = 0;
+  mu_list_foreach (elt[1]->v.list, _fill_response, &env);
+  
+  *return_resp = resp;
+  return 0;
+}
+
+struct mapper_tab
+{
+  char *name;
+  size_t size;
+  int prefix;
+  int (*mapper) (struct imap_list_element **, union mu_imap_fetch_response **);
+};
+  
+static struct mapper_tab mapper_tab[] = {
+#define S(s) s, (sizeof (s) - 1)
+  { S("BODYSTRUCTURE"), 0, },
+  { S("BODY["),         1, _body_mapper },
+  { S("BODY"),          0, _body_mapper },
+  { S("ENVELOPE"),      0, _envelope_mapper },
+  { S("FLAGS"),         0, _flags_mapper },
+  { S("INTERNALDATE"),  0, _date_mapper },
+  { S("RFC822"),        0, _body_mapper},
+  { S("RFC822.HEADER"), 0, _rfc822_header_mapper }, 
+  { S("RFC822.SIZE"),   0, _size_mapper },
+  { S("RFC822.TEXT"),   0, _rfc822_text_mapper },
+  { S("UID"),           0, _uid_mapper },
+#undef S
+  { NULL }
+};
+  
+static int
+_fetch_mapper (void **itmv, size_t itmc, void *call_data)
+{
+  int *status = call_data;
+  struct mapper_tab *mt;
+  struct imap_list_element *elt[2];
+  char *kw;
+  size_t kwlen;
+  union mu_imap_fetch_response *resp;
+
+  elt[0] = itmv[0];
+  elt[1] = itmv[1];
+  
+  if (elt[0]->type != imap_eltype_string)
+    {
+      *status = MU_ERR_FAILURE;
+      return MU_LIST_MAP_STOP|MU_LIST_MAP_SKIP;
+    }
+  kw = elt[0]->v.string;
+  kwlen = strlen (kw);
+  for (mt = mapper_tab; mt->name; mt++)
+    {
+      if (mt->prefix)
+	{
+	  if (mt->size >= kwlen && memcmp (mt->name, kw, kwlen) == 0)
+	    break;
+	}
+      else if (mt->size == kwlen && memcmp (mt->name, kw, kwlen) == 0)
+	break;
+    }
+
+  if (!mt->name)
+    {
+      mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_TRACE9,
+		("ignoring unknown FETCH item '%s'", kw));
+      return MU_LIST_MAP_SKIP;
+    }
+
+  if (mt->mapper)
+    {
+      int rc = mt->mapper (elt, &resp);
+      if (rc == 0)
+	{
+	  itmv[0] = resp;
+	  return MU_LIST_MAP_OK;
+	}
+      else
+	{
+	  *status = rc;
+	  return MU_LIST_MAP_STOP|MU_LIST_MAP_SKIP;
+	}
+    }
+      
+  return MU_LIST_MAP_SKIP;
+}
+
+int
+_mu_imap_parse_fetch_response (mu_list_t input, mu_list_t *result_list)
+{
+  mu_list_t result;
+  int status;
+
+  status = mu_list_create (&result);
+  if (status)
+    {
+      mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_ERROR,
+		("mu_list_create: %s", mu_strerror (status)));
+      return 1;
+    }
+  mu_list_set_destroy_item (result, _free_fetch_response);
+  mu_list_map (input, _fetch_mapper, &status, 2, &result);
+  if (status)
+    mu_list_destroy (&result);
+  else
+    *result_list = result;
+  
+  return status;
+}
diff --git a/libproto/imap/resplist.c b/libproto/imap/resplist.c
index 4a42633..98b8a22 100644
--- a/libproto/imap/resplist.c
+++ b/libproto/imap/resplist.c
@@ -270,4 +270,13 @@ _mu_imap_list_at (mu_list_t list, int idx)
   return arg;
 }
 
+int
+_mu_imap_list_nth_element_is_string (mu_list_t list, size_t n,
+				     const char *str)
+{
+  struct imap_list_element *elt = _mu_imap_list_at (list, n);
+  return elt && elt->type == imap_eltype_string &&
+	 strcmp (elt->v.string, str) == 0;
+}
+
 
diff --git a/libproto/imap/resproc.c b/libproto/imap/resproc.c
index d939690..373e258 100644
--- a/libproto/imap/resproc.c
+++ b/libproto/imap/resproc.c
@@ -304,6 +304,34 @@ _process_unsolicited_response (mu_imap_t imap, mu_list_t resp)
 	  return 0;
 	}
     }
+  else if (count == 3 &&
+	   _mu_imap_list_nth_element_is_string (resp, 1, "FETCH"))
+    {
+      size_t msgno;
+
+      arg = _mu_imap_list_at (resp, 0);
+      if (arg && arg->type == imap_eltype_string)
+	{
+	  char *p;
+	  msgno = strtoul (arg->v.string, &p, 10);
+	  if (*p)
+	    return 1;
+	  
+	  arg = _mu_imap_list_at (resp, 2);
+	  if (arg->type == imap_eltype_list)
+	    {
+	      mu_list_t list;
+	      
+	      if (_mu_imap_parse_fetch_response (arg->v.list, &list) == 0)
+		{
+		  mu_imap_callback (imap, MU_IMAP_CB_FETCH, msgno, list);
+		  mu_list_destroy (&list);
+		}
+	      return 0;
+	    }
+	}
+    }
+
   return 1;
 }
 
@@ -317,8 +345,8 @@ _mu_imap_process_untagged_response (mu_imap_t imap, mu_list_t list,
       if (fun)
 	fun (imap, list, data);
       else
-	mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
-		  ("ignoring unexpected response"));
+	mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_TRACE9,
+		  ("ignoring unrecognized response"));
     }
   return 0;
 }
diff --git a/libproto/imap/trace.c b/libproto/imap/trace.c
index 152e9df..68daa61 100644
--- a/libproto/imap/trace.c
+++ b/libproto/imap/trace.c
@@ -89,21 +89,26 @@ mu_imap_trace_mask (mu_imap_t imap, int op, int lev)
   switch (op)
     {
     case MU_IMAP_TRACE_SET:
-      imap->flags |= MU_IMAP_XSCRIPT_MASK (lev);
+      MU_IMAP_SET_XSCRIPT_MASK (imap, lev);
+      if (lev & MU_XSCRIPT_PAYLOAD)
+	mu_imapio_trace_payload (imap->io, 1);
       break;
       
     case MU_IMAP_TRACE_CLR:
-      imap->flags &= ~MU_IMAP_XSCRIPT_MASK (lev);
+      MU_IMAP_CLR_XSCRIPT_MASK (imap, lev);
+      if (lev & MU_XSCRIPT_PAYLOAD)
+	mu_imapio_trace_payload (imap->io, 0);
       break;
       
     case MU_IMAP_TRACE_QRY:
-      if (imap->flags & MU_IMAP_XSCRIPT_MASK (lev))
+      if (MU_IMAP_IS_XSCRIPT_MASK (imap, lev))
 	break;
       return MU_ERR_NOENT;
       
     default:
       return EINVAL;
     }
+  
   return 0;
 }
 
diff --git a/mu/imap.c b/mu/imap.c
index 4edce2d..44a6cdb 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -182,6 +182,13 @@ imap_bye_callback (void *data, int code, size_t sdat, void *pdat)
     mu_diag_output (MU_DIAG_INFO, _("server is closing connection"));
 }
 
+static void
+imap_bad_callback (void *data, int code, size_t sdat, void *pdat)
+{
+  const char *text = pdat;
+  mu_diag_output (MU_DIAG_CRIT, "SERVER ALERT: %s", text);
+}
+
 
 static int
 com_disconnect (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
@@ -282,6 +289,9 @@ com_connect (int argc, char **argv)
 	  mu_imap_register_callback_function (imap, MU_IMAP_CB_BYE,
 					      imap_bye_callback,
 					      NULL);
+	  mu_imap_register_callback_function (imap, MU_IMAP_CB_BAD,
+					      imap_bad_callback,
+					      NULL);
 
 	  
 	  status = mu_imap_connect (imap);
@@ -587,44 +597,68 @@ com_noop (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
   return 0;
 }
 
+static int
+com_fetch (int argc, char **argv)
+{
+  int status = mu_imap_fetch (imap, argv[1], argv[2]);
+  if (status)
+    report_failure ("fetch", status);
+  return 0;  
+}
+
 struct mutool_command imap_comtab[] = {
-  { "capability", 1, -1, com_capability,
+  { "capability", 1, -1, 0,
+    com_capability,
     /* TRANSLATORS: -reread is a keyword; do not translate. */
     N_("[-reread] [NAME...]"),
     N_("list server capabilities") },
-  { "verbose",    1, 4, com_verbose,
+  { "verbose",    1, 4, 0,
+    com_verbose,
     "[on|off|mask|unmask] [secure [payload]]",
     N_("control the protocol tracing") },
-  { "connect",    1, 4, com_connect,
+  { "connect",    1, 4, 0,
+    com_connect,
     /* TRANSLATORS: --tls is a keyword. */
     N_("[-tls] HOSTNAME [PORT]"),
     N_("open connection") },
-  { "disconnect", 1, 1,
+  { "disconnect", 1, 1, 0,
     com_disconnect,
     NULL,
     N_("close connection") },
-  { "login",        2, 3, com_login,
+  { "login",        2, 3, 0,
+    com_login,
     N_("USER [PASS]"),
     N_("login to the server") },
-  { "logout",       1, 1, com_logout,
+  { "logout",       1, 1, 0,
+    com_logout,
     NULL,
     N_("quit imap session") },
-  { "id",           1, -1, com_id,
+  { "id",           1, -1, 0,
+    com_id,
     N_("[-test KW] [ARG [ARG...]]"),
     N_("send ID command") },
-  { "noop",         1, 1, com_noop,
+  { "noop",         1, 1, 0,
+    com_noop,
     NULL,
     N_("no operation (keepalive)") },
-  { "select",       1, 2, com_select,
+  { "select",       1, 2, 0,
+    com_select,
     N_("[MBOX]"),
     N_("select a mailbox") },
-  { "examine",      1, 2, com_examine,
+  { "examine",      1, 2, 0,
+    com_examine,
     N_("[MBOX]"),
     N_("examine a mailbox") },
-  { "status",       3, -1, com_status,
+  { "status",       3, -1, 0,
+    com_status,
     N_("MBOX KW [KW...]"),
     N_("get mailbox status") },
-  { "quit",         1, 1, com_logout,
+  { "fetch",        3, 3, CMD_COALESCE_EXTRA_ARGS,
+    com_fetch,
+    N_("MSGSET ITEMS"),
+    N_("fetch message data") },
+  { "quit",         1, 1, 0,
+    com_logout,
     NULL,
     N_("same as `logout'") },
   { NULL }
diff --git a/mu/mu.h b/mu/mu.h
index cfb24a2..74544b5 100644
--- a/mu/mu.h
+++ b/mu/mu.h
@@ -18,13 +18,15 @@
 
 typedef int (*mutool_action_t) (int argc, char **argv);
 
+#define CMD_COALESCE_EXTRA_ARGS 0x01
+
 struct mutool_command
 {
   const char *name;	/* User printable name of the function. */
-  int argmin;           /* Min. acceptable number of arguments (-1 means
-			   pass all arguments as a single string */ 
+  int argmin;           /* Min. acceptable number of arguments (> 1) */ 
   int argmax;           /* Max. allowed number of arguments (-1 means not
 			   limited */
+  int flags;
   mutool_action_t func;	/* Function to call to do the job. */
   const char *argdoc;   /* Documentation for the arguments */
   const char *docstring;/* Documentation for this function.  */
diff --git a/mu/pop.c b/mu/pop.c
index 088ebfe..da1452c 100644
--- a/mu/pop.c
+++ b/mu/pop.c
@@ -611,59 +611,59 @@ com_quit (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
 }
 
 struct mutool_command pop_comtab[] = {
-  { "apop",       2,  3, com_apop,
+  { "apop",       2,  3, 0, com_apop,
     N_("USER [PASS]"),
     N_("authenticate with APOP") },
-  { "capa",       1, -1, com_capa,
+  { "capa",       1, -1, 0, com_capa,
     /* TRANSLATORS: -reread is a keyword; do not translate. */
     N_("[-reread] [NAME...]"),
     N_("list server capabilities") },
-  { "disconnect", 1, 1,
+  { "disconnect", 1, 1, 0,
     com_disconnect,
     NULL,
     N_("close connection") },
-  { "dele",       2, 2, com_dele,
+  { "dele",       2, 2, 0, com_dele,
     N_("NUMBER"),
     N_("mark message for deletion") },
-  { "list",       1, 2, com_list,
+  { "list",       1, 2, 0, com_list,
     N_("[NUMBER]"),
     N_("list messages") },
-  { "noop",       1, 1, com_noop,
+  { "noop",       1, 1, 0, com_noop,
     NULL,
     N_("send a \"no operation\"") },
-  { "pass",       1, 2, com_pass,
+  { "pass",       1, 2, 0, com_pass,
     N_("[PASSWORD]"),
     N_("send password") },
-  { "connect",    1, 4, com_connect,
+  { "connect",    1, 4, 0, com_connect,
     /* TRANSLATORS: --tls is a keyword. */
     N_("[-tls] HOSTNAME [PORT]"),
     N_("open connection") },
-  { "quit",       1, 1, com_quit,
+  { "quit",       1, 1, 0, com_quit,
     NULL,
     N_("quit pop3 session") },
-  { "retr",       2, 2, com_retr,
+  { "retr",       2, 2, 0, com_retr,
     "NUMBER",
     N_("retrieve a message") },
-  { "rset",       1, 1, com_rset,
+  { "rset",       1, 1, 0, com_rset,
     NULL,
     N_("remove deletion marks") },
-  { "stat",       1, 1, com_stat,
+  { "stat",       1, 1, 0, com_stat,
     NULL,
     N_("get the mailbox size and number of messages in it") },
-  { "stls",       1, 1, com_stls,
+  { "stls",       1, 1, 0, com_stls,
     NULL,
     N_("start TLS negotiation") },
-  { "top",        2, 3, com_top,
+  { "top",        2, 3, 0, com_top,
     "MSGNO [NUMBER]",
     N_("display message headers and first NUMBER (default 5) lines of"
        " its body") },
-  { "uidl",       1, 2, com_uidl,
+  { "uidl",       1, 2, 0, com_uidl,
     N_("[NUMBER]"),
     N_("show unique message identifiers") },
-  { "user",       2, 2, com_user,
+  { "user",       2, 2, 0, com_user,
     N_("NAME"),
     N_("send login") },
-  { "verbose",    1, 4, com_verbose,
+  { "verbose",    1, 4, 0, com_verbose,
     "[on|off|mask|unmask] [secure [payload]]",
     N_("control the protocol tracing") },
   { NULL }
diff --git a/mu/shell.c b/mu/shell.c
index 39081c1..0426788 100644
--- a/mu/shell.c
+++ b/mu/shell.c
@@ -71,18 +71,18 @@ static int shell_history (int, char **);
 #endif
 
 struct mutool_command default_comtab[] = {
-  { "prompt",   -1, -1, shell_prompt,
+  { "prompt",     1, 2, CMD_COALESCE_EXTRA_ARGS, shell_prompt,
     N_("STRING"),
     N_("set command prompt") },
-  { "exit",       1, 1, shell_exit,    NULL,        N_("exit program") },
-  { "help",       1, 2, shell_help,
+  { "exit",       1, 1, 0, shell_exit,    NULL,        N_("exit program") },
+  { "help",       1, 2, 0, shell_help,
     N_("[COMMAND]"),
     N_("display this text") },
-  { "?",          1, 1, shell_help,
+  { "?",          1, 1, 0, shell_help,
     N_("[COMMAND]"),
     N_("synonym for `help'") },
 #ifdef WITH_READLINE
-  { "history",    1, 1, shell_history,
+  { "history",    1, 1, 0, shell_history,
     NULL,
     N_("show command history") },
 #endif
@@ -492,59 +492,101 @@ add_history (const char *s MU_ARG_UNUSED)
 }
 #endif
 
+static int
+next_arg (struct mu_wordsplit *ws)
+{
+  int rc = mu_wordsplit (NULL, ws, MU_WRDSF_INCREMENTAL);
+  if (rc == MU_WRDSE_NOINPUT)
+    {
+      mu_error ("%s: too few arguments", ws->ws_wordv[0]);
+      mu_wordsplit_free (ws);
+      return -1;
+    }
+  else if (rc)
+    {
+      mu_error ("cannot parse input line: %s",
+		mu_wordsplit_strerror (ws));
+      return 1;
+    }
+  return 0;
+}
+
 /* Parse and execute a command line. */
 int
 execute_line (char *line)
 {
+  int rc;
   struct mu_wordsplit ws;
-  int argc;
-  char **argv;
+  struct mutool_command *cmd;
   int status = 0;
-
+  
   ws.ws_comment = "#";
-  ws.ws_offs = 1; /* Keep extra slot for expansion in case when argmin == -1 */
-  if (mu_wordsplit (line, &ws,
-		    MU_WRDSF_DEFFLAGS|MU_WRDSF_COMMENT|MU_WRDSF_DOOFFS))
+  rc = mu_wordsplit (line, &ws,
+		     MU_WRDSF_DEFFLAGS|MU_WRDSF_COMMENT|
+		     MU_WRDSF_INCREMENTAL|MU_WRDSF_APPEND);
+  if (rc == MU_WRDSE_NOINPUT)
+    {
+      mu_wordsplit_free (&ws);
+      return 0;
+    }
+  else if (rc)
     {
-      mu_error("cannot parse input line: %s", mu_wordsplit_strerror (&ws));
+      mu_error ("cannot parse input line: %s", mu_wordsplit_strerror (&ws));
       return 0;
     }
-  argc = ws.ws_wordc;
-  argv = ws.ws_wordv + 1;
   
-  if (argc >= 0)
+  if (ws.ws_wordc)
     {
-      struct mutool_command *cmd = find_command (argv[0]);
-      
+      int argmin;
+      cmd = find_command (ws.ws_wordv[0]);
+
       if (!cmd)
-	mu_error ("%s: no such command.", argv[0]);
-      else if (cmd->argmin > 0 && argc < cmd->argmin)
-	mu_error ("%s: too few arguments", argv[0]);
-      else if (cmd->argmax > 0 && argc > cmd->argmax)
-	mu_error ("%s: too many arguments", argv[0]);
+	{
+	  mu_error ("%s: no such command.", ws.ws_wordv[0]);
+	  mu_wordsplit_free (&ws);
+	  return 0;
+	}
+
+      argmin = cmd->argmin;
+      if (cmd->flags & CMD_COALESCE_EXTRA_ARGS)
+	--argmin;
+      while (ws.ws_wordc < argmin)
+	{
+	  if (next_arg (&ws))
+	    return 0;
+	}
+
+      if (cmd->flags & CMD_COALESCE_EXTRA_ARGS)
+	{
+	  ws.ws_flags |= MU_WRDSF_NOSPLIT;
+	  if (next_arg (&ws))
+	    return 0;
+	}
       else
 	{
-	  if (cmd->argmin <= 0 && argc != 2)
+	  for (;;)
 	    {
-	      size_t i;
-	      char *word = mu_str_skip_class (line, MU_CTYPE_SPACE);
-	      char *arg = mu_str_skip_class_comp (word, MU_CTYPE_SPACE);
-	      if (*arg)
+	      if (cmd->argmax > 0 && ws.ws_wordc > cmd->argmax)
+		{
+		  mu_error ("%s: too many arguments", ws.ws_wordv[0]);
+		  mu_wordsplit_free (&ws);
+		  return 0;
+		}
+	      rc = mu_wordsplit (NULL, &ws, MU_WRDSF_INCREMENTAL);
+	      if (rc == 0)
+		continue;
+	      else if (rc == MU_WRDSE_NOINPUT)
+		break;
+	      else
 		{
-		  *arg++ = 0;
-		  arg = mu_str_skip_class (arg, MU_CTYPE_SPACE);
+		  mu_error ("cannot parse input line: %s",
+			    mu_wordsplit_strerror (&ws));
+		  return 0;
 		}
-	      for (i = 0; i < ws.ws_wordc; i++)
-		free (ws.ws_wordv[i + 1]);
-	      ws.ws_wordv[0] = xstrdup (word);
-	      ws.ws_wordv[1] = xstrdup (arg);
-	      ws.ws_wordv[2] = NULL;
-	      ws.ws_wordc = 2;
-	      argc = ws.ws_wordc;
-	      argv = ws.ws_wordv;
 	    }
-	  status = cmd->func (argc, argv);
 	}
+
+      status = cmd->func (ws.ws_wordc, ws.ws_wordv);
     }
   mu_wordsplit_free (&ws);
   return status;


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 30 18:53:43 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RVtyB-0004Is-8I
	for mharc-commit-mailutils@gnu.org; Wed, 30 Nov 2011 18:53:43 -0500
Received: from eggs.gnu.org ([140.186.70.92]:37776)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVty4-0004IK-QB
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 18:53:40 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVtxz-0006Ht-CJ
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 18:53:36 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:36244)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVtxz-0006Hp-5U
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 18:53:31 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVtxv-0000BG-9S
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 23:53:30 +0000
Date: Wed, 30 Nov 2011 23:53:27 +0000
Message-Id: <E1RVtxv-0000BG-9S@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-491-g98ca43a
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b848706b89934be5a4419ab2ec382157d2f30aba
X-Git-Newrev: 98ca43a049365269e4052170eba3103a8d35e20b
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 30 Nov 2011 23:53:41 -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=98ca43a049365269e4052170eba3103a8d35e20b

The branch, master has been updated
       via  98ca43a049365269e4052170eba3103a8d35e20b (commit)
       via  827a4ba256a0d3cfc6b3caab546cea0c1ee96263 (commit)
       via  de2376862a1d3a9f00602eea7976751266287401 (commit)
      from  b848706b89934be5a4419ab2ec382157d2f30aba (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 98ca43a049365269e4052170eba3103a8d35e20b
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Dec 1 01:47:53 2011 +0200

    imap client: improve parsing of BODY[] items.
    
    * include/mailutils/imap.h (mu_imap_fetch_body) <key>: Rename to section.
    <fields>: New member.
    * libproto/imap/fetch.c: Rewrite response item parser.
    * mu/imap.c: Improve fetch_response_printer

commit 827a4ba256a0d3cfc6b3caab546cea0c1ee96263
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 30 23:27:23 2011 +0200

    Implement list folding functions.
    
    * include/mailutils/list.h (mu_list_folder_t): New typedef.
    (mu_list_fold, mu_list_rfold): New functions.
    * libmailutils/list/fold.c: New file.
    * libmailutils/list/rfold.c: New file.
    * libmailutils/list/Makefile.am (liblist_la_SOURCES): Add fold.c and
    rfold.c
    * libmailutils/list/gmap.c (mu_list_gmap): Access list elements directly,
    instead of using iterators.
    * libmailutils/tests/list.at: Add test cases for list folding.
    * libmailutils/tests/listop.c: Add fold and rfold commands.

commit de2376862a1d3a9f00602eea7976751266287401
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Nov 30 20:13:09 2011 +0200

    Clean-up state changes in imap client.  Fix error handling in it and in pop3.
    
    * include/mailutils/imap.h (mu_imap_state): Rename to struct
    mu_imap_session_state, prefix all values with MU_IMAP_STATE_.
    All uses updated.
    * include/mailutils/sys/imap.h (mu_imap_client_state): Prefix all
    values with MU_IMAP_CLIENT. Rename MU_IMAP_NO_STATE to MU_IMAP_READY.
    All uses updated.
    (_mu_imap)<state>: Rename to client_state, fix data type.
    (imap_state): Rename to imap_state. All uses updated.
    (MU_IMAP_CHECK_EAGAIN): Reset state to MU_IMAP_CLIENT_READY if
    MU_ERR_REPLY or MU_ERR_BADREPLY is reported.
    * include/mailutils/sys/pop3.h (MU_POP3_CHECK_EAGAIN): Reset state
    to MU_POP3_NO_STATE, if MU_ERR_REPLY or MU_ERR_BADREPLY is reported.
    * libproto/imap/fetch.c (_date_mapper): Avoid overwriting resp->type.
    * libproto/imap/select.c (_mu_imap_collect_flags): Initialize *res
    prior to collecting flags into it.
    * mu/imap.c: Install a FETCH callback.

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

Summary of changes:
 include/mailutils/imap.h              |   15 +-
 include/mailutils/list.h              |   50 ++++-
 include/mailutils/sys/imap.h          |   87 ++++----
 include/mailutils/sys/pop3.h          |    2 +
 libmailutils/list/Makefile.am         |    2 +
 libmailutils/list/{head.c => fold.c}  |   26 ++-
 libmailutils/list/gmap.c              |   22 +--
 libmailutils/list/{head.c => rfold.c} |   26 ++-
 libmailutils/tests/list.at            |   56 +++++
 libmailutils/tests/listop.c           |   60 +++++
 libproto/imap/capability.c            |   15 +-
 libproto/imap/carrier.c               |    3 +-
 libproto/imap/connect.c               |   39 ++--
 libproto/imap/create.c                |    3 +-
 libproto/imap/disconnect.c            |    2 +-
 libproto/imap/fetch.c                 |  423 +++++++++++++++++++--------------
 libproto/imap/id.c                    |   14 +-
 libproto/imap/login.c                 |   16 +-
 libproto/imap/logout.c                |   15 +-
 libproto/imap/noop.c                  |   12 +-
 libproto/imap/resplist.c              |    4 +-
 libproto/imap/response.c              |    8 +-
 libproto/imap/resproc.c               |   22 +-
 libproto/imap/select.c                |   23 +-
 libproto/imap/state.c                 |    2 +-
 libproto/imap/status.c                |   18 +-
 mu/imap.c                             |  160 ++++++++++++-
 27 files changed, 756 insertions(+), 369 deletions(-)
 copy libmailutils/list/{head.c => fold.c} (68%)
 copy libmailutils/list/{head.c => rfold.c} (68%)

diff --git a/include/mailutils/imap.h b/include/mailutils/imap.h
index cfb879c..86e365c 100644
--- a/include/mailutils/imap.h
+++ b/include/mailutils/imap.h
@@ -33,13 +33,13 @@ extern "C" {
   
 typedef struct _mu_imap *mu_imap_t;
 
-enum mu_imap_state
+enum mu_imap_session_state
   {
-    MU_IMAP_STATE_INIT,     /* Initial state */
-    MU_IMAP_STATE_NONAUTH,  /* Non-Authenticated State */
-    MU_IMAP_STATE_AUTH,     /* Authenticated State */
-    MU_IMAP_STATE_SELECTED, /* Selected State */
-    MU_IMAP_STATE_LOGOUT,   /* Logout State */
+    MU_IMAP_SESSION_INIT,     /* Initial state (disconnected) */
+    MU_IMAP_SESSION_NONAUTH,  /* Non-Authenticated State */
+    MU_IMAP_SESSION_AUTH,     /* Authenticated State */
+    MU_IMAP_SESSION_SELECTED, /* Selected State */
+    MU_IMAP_SESSION_LOGOUT,   /* Logout State */
   };
   
 int mu_imap_create (mu_imap_t *pimap);
@@ -175,7 +175,8 @@ struct mu_imap_fetch_body
   int type;
   size_t *partv;
   size_t partc;
-  char *key;
+  char *section;
+  mu_list_t fields;
   char *text;
 };
 
diff --git a/include/mailutils/list.h b/include/mailutils/list.h
index 6d88819..2f860fb 100644
--- a/include/mailutils/list.h
+++ b/include/mailutils/list.h
@@ -238,7 +238,10 @@ typedef int (*mu_list_mapper_t) (void **_itmv, size_t _itmc, void *_call_data);
    and until all elements from the array have been visited.
 
    Mu_list_gmap returns 0 on success and a non-zero error code on failure.
-   If _map returns non-zero, its return value is propagated to the caller. */
+   If _map returns non-zero, its return value is propagated to the caller.
+
+   The _map function is not allowed to alter the _list.
+*/
    
 int mu_list_gmap (mu_list_t _list, mu_list_mapper_t _map, size_t _nelem,
 		  void *_data);
@@ -263,11 +266,56 @@ int mu_list_gmap (mu_list_t _list, mu_list_mapper_t _map, size_t _nelem,
    MU_LIST_MAP_SKIP bit set, the _itmv[0] element is appended to the new
    list.  If it has MU_LIST_MAP_STOP bit set, iteration is stopped
    immediately and any remaining elements in _list are ignored.
+
+   The mapper function (_map) is not allowed to alter the _list.
 */
 
 int mu_list_map (mu_list_t _list, mu_list_mapper_t _map,
 		 void *_data, size_t _nelem,
 		 mu_list_t *_res);
+
+  /* List fold */
+
+typedef int (*mu_list_folder_t) (void *_item, void *_data,
+				 void *_prev, void **_ret);
+
+  /* mu_list_fold iterates over list elements from first to last.
+     For each element it calls _fold with the following arguments:
+
+       _item     -  the current list element,
+       _data     -  call-specific data,
+       _prev     -  on the first call, _init; on subsequent calls,
+                    points to the value returned from the previous call
+		    to _fold in the _ret varialble,
+       _ret      -  memory location where to store the result of this
+                    call.
+
+     When all elements have been visited, mu_list_fold stores the result
+     of the last _fold invocation (as returned in *_ret) in the memory
+     location pointed to by _return_value.
+
+     If _fold returns a non-zero value, mu_list_fold stops iteration and
+     returns this value.  The *_return_value is filled in this case as
+     well.
+
+     Possible return codes:
+
+       0                   - success,
+       EINVAL              - _list or _fold is NULL,
+       MU_ERR_OUT_PTR_NULL - _return_code is NULL
+       other value         - non-zero value returned by _fold.
+
+     The _fold function is not allowed to alter the list it is being applied
+     to.
+       
+     The mu_list_rfold acts similarly, except that it iterates over list
+     elements from last to first.
+  */
+int mu_list_fold (mu_list_t _list, mu_list_folder_t _fold, void *_data,
+		  void *_init, void *_return_value);
+int mu_list_rfold (mu_list_t _list, mu_list_folder_t _fold, void *_data,
+		   void *_init, void *_return_value);
+  
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/mailutils/sys/imap.h b/include/mailutils/sys/imap.h
index ff23a91..02deead 100644
--- a/include/mailutils/sys/imap.h
+++ b/include/mailutils/sys/imap.h
@@ -45,20 +45,19 @@ extern "C" {
   
 enum mu_imap_client_state
   {
-    MU_IMAP_NO_STATE,
-    MU_IMAP_ERROR,
-    MU_IMAP_CONNECT,
-    MU_IMAP_GREETINGS,
-    MU_IMAP_CONNECTED,
-    MU_IMAP_CAPABILITY_RX,
-    MU_IMAP_LOGIN_RX,
-    MU_IMAP_LOGOUT_RX,
-    MU_IMAP_ID_RX,
-    MU_IMAP_SELECT_RX,
-    MU_IMAP_STATUS_RX,
-    MU_IMAP_NOOP_RX,
-    MU_IMAP_FETCH_RX,
-    MU_IMAP_CLOSING
+    MU_IMAP_CLIENT_READY,
+    MU_IMAP_CLIENT_ERROR,
+    MU_IMAP_CLIENT_CONNECT_RX,
+    MU_IMAP_CLIENT_GREETINGS,
+    MU_IMAP_CLIENT_CAPABILITY_RX,
+    MU_IMAP_CLIENT_LOGIN_RX,
+    MU_IMAP_CLIENT_LOGOUT_RX,
+    MU_IMAP_CLIENT_ID_RX,
+    MU_IMAP_CLIENT_SELECT_RX,
+    MU_IMAP_CLIENT_STATUS_RX,
+    MU_IMAP_CLIENT_NOOP_RX,
+    MU_IMAP_CLIENT_FETCH_RX,
+    MU_IMAP_CLIENT_CLOSING
   };
 
 enum mu_imap_response
@@ -79,8 +78,8 @@ struct _mu_imap
     char *errstr;
     size_t errsize;
     
-    enum mu_imap_state state;
-    enum mu_imap_state imap_state;
+    enum mu_imap_client_state client_state;
+    enum mu_imap_session_state session_state;
 
     /* Tag */
     size_t tag_len;  /* Length of the command tag */
@@ -129,39 +128,41 @@ int _mu_imap_xscript_level (mu_imap_t imap, int xlev);
 
 /* If status indicates an error, return.
   */
-#define MU_IMAP_CHECK_ERROR(imap, status)	\
-  do						\
-    {						\
-      if (status != 0)				\
-	{					\
-          imap->state = MU_IMAP_ERROR;		\
-          return status;			\
-	}					\
-    }						\
+#define MU_IMAP_CHECK_ERROR(imap, status)			\
+  do								\
+    {								\
+      if (status != 0)						\
+	{							\
+          imap->client_state = MU_IMAP_CLIENT_ERROR;		\
+          return status;					\
+	}							\
+    }								\
   while (0)
 
 /* Check if status indicates an error.
    If the error is recoverable just return the status.
    Otherwise, set the error state and return the status
  */
-#define MU_IMAP_CHECK_EAGAIN(imap, status)	\
-  do						\
-    {						\
-      switch (status)				\
-	{					\
-        case 0:                                 \
-	  break;				\
-        case EAGAIN:                            \
-        case EINPROGRESS:                       \
-        case EINTR:                             \
-        case MU_ERR_REPLY:                      \
-        case MU_ERR_BADREPLY:                   \
-	  return status;                        \
-        default:                                \
-          imap->state = MU_IMAP_ERROR;		\
-	  return status;			\
-	}					\
-    }						\
+#define MU_IMAP_CHECK_EAGAIN(imap, status)		\
+  do							\
+    {							\
+      switch (status)					\
+	{						\
+        case 0:						\
+	  break;					\
+        case EAGAIN:					\
+        case EINPROGRESS:				\
+        case EINTR:					\
+	  return status;				\
+        case MU_ERR_REPLY:				\
+        case MU_ERR_BADREPLY:				\
+	  imap->client_state = MU_IMAP_CLIENT_READY;	\
+	  return status;				\
+        default:					\
+          imap->client_state = MU_IMAP_CLIENT_ERROR;	\
+	  return status;				\
+	}						\
+    }							\
   while (0)
 
 int _mu_imap_seterrstr (mu_imap_t imap, const char *str, size_t len);
diff --git a/include/mailutils/sys/pop3.h b/include/mailutils/sys/pop3.h
index c727ca8..826dffb 100644
--- a/include/mailutils/sys/pop3.h
+++ b/include/mailutils/sys/pop3.h
@@ -107,8 +107,10 @@ int _mu_pop3_init (mu_pop3_t pop3);
         case EAGAIN:                            \
         case EINPROGRESS:                       \
         case EINTR:                             \
+	  return status;                        \
         case MU_ERR_REPLY:                      \
         case MU_ERR_BADREPLY:                   \
+	  pop3->state = MU_POP3_NO_STATE;	\
 	  return status;                        \
         default:                                \
           pop3->state = MU_POP3_ERROR;		\
diff --git a/libmailutils/list/Makefile.am b/libmailutils/list/Makefile.am
index ee6913c..cd17a9e 100644
--- a/libmailutils/list/Makefile.am
+++ b/libmailutils/list/Makefile.am
@@ -25,6 +25,7 @@ liblist_la_SOURCES = \
  create.c\
  destroy.c\
  empty.c\
+ fold.c\
  foreach.c\
  get.c\
  getcomp.c\
@@ -39,6 +40,7 @@ liblist_la_SOURCES = \
  prepend.c\
  remove.c\
  replace.c\
+ rfold.c\
  setcomp.c\
  setdestr.c\
  slice.c\
diff --git a/libmailutils/list/head.c b/libmailutils/list/fold.c
similarity index 68%
copy from libmailutils/list/head.c
copy to libmailutils/list/fold.c
index 7c52b89..1bae72c 100644
--- a/libmailutils/list/head.c
+++ b/libmailutils/list/fold.c
@@ -19,18 +19,28 @@
 # include <config.h>
 #endif
 #include <stdlib.h>
-#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
+#include <mailutils/sys/list.h>
 
 int
-mu_list_head (mu_list_t list, void **pitem)
+mu_list_fold (mu_list_t list, mu_list_folder_t fold, void *data, void *prev,
+	      void *return_value)
 {
-  if (list == NULL)
+  struct list_data *current;
+  int status = 0;
+  
+  if (list == NULL || fold == NULL)
     return EINVAL;
-  if (pitem == NULL)
+  if (return_value == NULL)
     return MU_ERR_OUT_PTR_NULL;
-  if (!list->head.next)
-    return MU_ERR_NOENT;
-  *pitem = list->head.next->item;
-  return 0;
+
+  for (current = list->head.next; current != &list->head;
+       current = current->next)
+    {
+      status = fold (current->item, data, prev, &prev);
+      if (status)
+	break;
+    }
+  *(void **) return_value = prev;
+  return status;
 }
diff --git a/libmailutils/list/gmap.c b/libmailutils/list/gmap.c
index 4a20a44..4c91d10 100644
--- a/libmailutils/list/gmap.c
+++ b/libmailutils/list/gmap.c
@@ -27,28 +27,21 @@ int
 mu_list_gmap (mu_list_t list, mu_list_mapper_t map, size_t nelem, void *data)
 {
   int rc;
-  int status;
-  mu_iterator_t itr;
+  struct list_data *current;
   void **buf;
   size_t i;
   
   if (!list || !map || nelem == 0)
     return EINVAL;
-  rc = mu_list_get_iterator (list, &itr);
-  if (rc)
-    return status;
   buf = calloc (nelem, sizeof (buf[0]));
   if (!buf)
+    return ENOMEM;
+
+  i = 0;
+  for (current = list->head.next; current != &list->head;
+       current = current->next)
     {
-      mu_iterator_destroy (&itr);
-      return ENOMEM;
-    }
-  for (i = 0, mu_iterator_first (itr); !mu_iterator_is_done (itr);
-       mu_iterator_next (itr))
-    {
-      void *item;
-      mu_iterator_current (itr, &item);
-      buf[i++] = item;
+      buf[i++] = current->item;
       if (i == nelem)
 	{
 	  i = 0;
@@ -59,7 +52,6 @@ mu_list_gmap (mu_list_t list, mu_list_mapper_t map, size_t nelem, void *data)
     }
   if (rc == 0 && i > 0 && i < nelem)
     rc = map (buf, i, data);
-  mu_iterator_destroy (&itr);
   free (buf);
   return rc;
 }
diff --git a/libmailutils/list/head.c b/libmailutils/list/rfold.c
similarity index 68%
copy from libmailutils/list/head.c
copy to libmailutils/list/rfold.c
index 7c52b89..4628422 100644
--- a/libmailutils/list/head.c
+++ b/libmailutils/list/rfold.c
@@ -19,18 +19,28 @@
 # include <config.h>
 #endif
 #include <stdlib.h>
-#include <mailutils/sys/list.h>
 #include <mailutils/errno.h>
+#include <mailutils/sys/list.h>
 
 int
-mu_list_head (mu_list_t list, void **pitem)
+mu_list_rfold (mu_list_t list, mu_list_folder_t fold, void *data, void *prev,
+	       void *return_value)
 {
-  if (list == NULL)
+  struct list_data *current;
+  int status = 0;
+  
+  if (list == NULL || fold == NULL)
     return EINVAL;
-  if (pitem == NULL)
+  if (return_value == NULL)
     return MU_ERR_OUT_PTR_NULL;
-  if (!list->head.next)
-    return MU_ERR_NOENT;
-  *pitem = list->head.next->item;
-  return 0;
+
+  for (current = list->head.prev; current != &list->head;
+       current = current->prev)
+    {
+      status = fold (current->item, data, prev, &prev);
+      if (status)
+	break;
+    }
+  *(void **) return_value = prev;
+  return status;
 }
diff --git a/libmailutils/tests/list.at b/libmailutils/tests/list.at
index 408e78e..fcc578e 100644
--- a/libmailutils/tests/list.at
+++ b/libmailutils/tests/list.at
@@ -388,6 +388,62 @@ ti
 ])
 
 m4_popdef([MU_TEST_KEYWORDS])
+# ------------------------------------------------------------
+# Fold
+# ------------------------------------------------------------
+
+m4_define([MU_TEST_GROUP],[Fold])
+m4_pushdef([MU_TEST_KEYWORDS],MU_TEST_KEYWORDS[ fold])
+
+TESTLIST([empty list],[],
+[fold
+],
+[NULL
+])
+
+TESTLIST([one element],[],
+[add en
+fold
+],
+[en
+])
+
+TESTLIST([many elements],[],
+[add en to tre fire fem
+fold
+],
+[entotrefirefem
+])
+
+m4_popdef([MU_TEST_KEYWORDS])
+# ------------------------------------------------------------
+# Reverse Fold
+# ------------------------------------------------------------
+
+m4_define([MU_TEST_GROUP],[Reverse Fold])
+m4_pushdef([MU_TEST_KEYWORDS],MU_TEST_KEYWORDS[ rfold])
+
+TESTLIST([empty list],[],
+[rfold
+],
+[NULL
+])
+
+TESTLIST([one element],[],
+[add en
+rfold
+],
+[en
+])
+
+TESTLIST([many elements],[],
+[add en to tre fire fem
+rfold
+],
+[femfiretretoen
+])
+
+m4_popdef([MU_TEST_KEYWORDS])
 
 dnl ------------------------------------------------------------
 dnl Cleanup
diff --git a/libmailutils/tests/listop.c b/libmailutils/tests/listop.c
index 68e59e4..93362ec 100644
--- a/libmailutils/tests/listop.c
+++ b/libmailutils/tests/listop.c
@@ -720,6 +720,60 @@ tail (size_t argc, mu_list_t list)
     printf ("%s\n", text);
 }
 
+static int
+fold_concat (void *item, void *data, void *prev, void **ret)
+{
+  char *s;
+  size_t len = strlen (item);
+  size_t prevlen = 0;
+  
+  if (prev)
+    prevlen = strlen (prev);
+
+  s = realloc (prev, len + prevlen + 1);
+  if (!s)
+    abort ();
+  strcpy (s + prevlen, item);
+  *ret = s;
+  return 0;
+}
+
+void
+fold (mu_list_t list)
+{
+  char *text = NULL;
+  int rc;
+
+  rc = mu_list_fold (list, fold_concat, NULL, NULL, &text);
+  if (rc)
+    mu_diag_funcall (MU_DIAG_ERROR, "mu_list_fold", NULL, rc);
+  else if (text)
+    {
+      printf ("%s\n", text);
+      free (text);
+    }
+  else
+    printf ("NULL\n");
+}
+
+void
+rfold (mu_list_t list)
+{
+  char *text = NULL;
+  int rc;
+
+  rc = mu_list_rfold (list, fold_concat, NULL, NULL, &text);
+  if (rc)
+    mu_diag_funcall (MU_DIAG_ERROR, "mu_list_fold", NULL, rc);
+  else if (text)
+    {
+      printf ("%s\n", text);
+      free (text);
+    }
+  else
+    printf ("NULL\n");
+}
+  
 void
 help ()
 {
@@ -739,6 +793,8 @@ help ()
   printf ("ictl ins item [item*]\n");
   printf ("ictl dir [backwards|forwards]\n");
   printf ("map [-replace] NAME [ARGS]\n");
+  printf ("fold\n");
+  printf ("rfold\n");
   printf ("print\n");
   printf ("slice [-replace] num [num...]\n");
   printf ("quit\n");
@@ -813,6 +869,10 @@ shell (mu_list_t list)
 	    print (list);
 	  else if (strcmp (ws.ws_wordv[0], "cur") == 0)
 	    cur (num, itr[num]);
+	  else if (strcmp (ws.ws_wordv[0], "fold") == 0)
+	    fold (list);
+	  else if (strcmp (ws.ws_wordv[0], "rfold") == 0)
+	    rfold (list);
 	  else if (strcmp (ws.ws_wordv[0], "map") == 0)
 	    {
 	      int i;
diff --git a/libproto/imap/capability.c b/libproto/imap/capability.c
index a90d5f9..e4bb4b7 100644
--- a/libproto/imap/capability.c
+++ b/libproto/imap/capability.c
@@ -82,7 +82,8 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
+  if (imap->session_state == MU_IMAP_SESSION_INIT ||
+      imap->client_state != MU_IMAP_CLIENT_READY)
     return MU_ERR_SEQ;
 
   if (imap->capa)
@@ -103,21 +104,21 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
       mu_list_set_destroy_item (imap->capa, mu_list_free_item);
     }
 
-  switch (imap->state)
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       status = mu_imapio_printf (imap->io, "%s CAPABILITY\r\n",
 				 imap->tag_str); 
       MU_IMAP_CHECK_EAGAIN (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_CAPABILITY_RX;
+      imap->client_state = MU_IMAP_CLIENT_CAPABILITY_RX;
 
-    case MU_IMAP_CAPABILITY_RX:
+    case MU_IMAP_CLIENT_CAPABILITY_RX:
       status = _mu_imap_response (imap, _capability_response_action,
 				  NULL);
-      imap->state = MU_IMAP_CONNECTED;
+      imap->client_state = MU_IMAP_CLIENT_READY;
       MU_IMAP_CHECK_EAGAIN (imap, status);
       if (imap->resp_code != MU_IMAP_OK)
 	return MU_ERR_REPLY;
@@ -130,7 +131,7 @@ mu_imap_capability (mu_imap_t imap, int reread, mu_iterator_t *piter)
 	}  
       break;
       
-    case MU_IMAP_ERROR:
+    case MU_IMAP_CLIENT_ERROR:
       status = ECANCELED;
       break;
 
diff --git a/libproto/imap/carrier.c b/libproto/imap/carrier.c
index ecc170c..432f035 100644
--- a/libproto/imap/carrier.c
+++ b/libproto/imap/carrier.c
@@ -49,7 +49,8 @@ mu_imap_set_carrier (mu_imap_t imap, mu_stream_t carrier)
   imap->io = io;
   if (MU_IMAP_FISSET (imap, MU_IMAP_TRACE))
     _mu_imap_trace_enable (imap);
-  imap->state = MU_IMAP_CONNECT;
+  imap->client_state = MU_IMAP_CLIENT_READY;
+  imap->session_state = MU_IMAP_SESSION_INIT;
   return 0;
 }
 
diff --git a/libproto/imap/connect.c b/libproto/imap/connect.c
index e9be515..7097f17 100644
--- a/libproto/imap/connect.c
+++ b/libproto/imap/connect.c
@@ -45,22 +45,25 @@ mu_imap_connect (mu_imap_t imap)
 
   _mu_imap_clrerrstr (imap);
   
-  switch (imap->state)
+  switch (imap->client_state)
     {
     default:
-    case MU_IMAP_NO_STATE:
-      status = mu_imap_disconnect (imap);
-      if (status != 0)
+    case MU_IMAP_CLIENT_READY:
+      if (imap->session_state != MU_IMAP_SESSION_INIT)
 	{
-	  /* Sleep for 2 seconds (FIXME: Must be configurable) */
-	  struct timeval tval;
-	  tval.tv_sec = 2;
-	  tval.tv_usec = 0;
-	  select (0, NULL, NULL, NULL, &tval);
+	  status = mu_imap_disconnect (imap);
+	  if (status != 0)
+	    {
+	      /* Sleep for 2 seconds (FIXME: Must be configurable) */
+	      struct timeval tval;
+	      tval.tv_sec = 2;
+	      tval.tv_usec = 0;
+	      select (0, NULL, NULL, NULL, &tval);
+	    }
 	}
-      imap->state = MU_IMAP_CONNECT;
+      imap->client_state = MU_IMAP_CLIENT_CONNECT_RX;
 
-    case MU_IMAP_CONNECT:
+    case MU_IMAP_CLIENT_CONNECT_RX:
       /* Establish the connection.  */
       if (!mu_stream_is_open (imap->io->_imap_stream))
         {
@@ -68,9 +71,9 @@ mu_imap_connect (mu_imap_t imap)
           MU_IMAP_CHECK_EAGAIN (imap, status);
           MU_IMAP_FCLR (imap, MU_IMAP_RESP);
         }
-      imap->state = MU_IMAP_GREETINGS;
+      imap->client_state = MU_IMAP_CLIENT_GREETINGS;
 
-    case MU_IMAP_GREETINGS:
+    case MU_IMAP_CLIENT_GREETINGS:
       status = mu_imapio_getline (imap->io);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       mu_imapio_get_words (imap->io, &wc, &wv);
@@ -79,7 +82,7 @@ mu_imap_connect (mu_imap_t imap)
 	  mu_imapio_getbuf (imap->io, &bufptr, &bufsize);
 	  mu_error ("mu_imap_connect: invalid server response: %s",
 		    bufptr);
-	  imap->state = MU_IMAP_ERROR;
+	  imap->client_state = MU_IMAP_CLIENT_ERROR;
 	  return MU_ERR_BADREPLY;
 	}
       else
@@ -92,18 +95,18 @@ mu_imap_connect (mu_imap_t imap)
 	  _mu_imap_process_untagged_response (imap, list, NULL, NULL);
 	  mu_list_destroy (&list);
 
-	  switch (imap->state)
+	  switch (imap->client_state)
 	    {
-	    case MU_IMAP_CONNECTED:
+	    case MU_IMAP_CLIENT_READY:
 	      status = 0;
 	      break;
 
-	    case MU_IMAP_CLOSING:
+	    case MU_IMAP_CLIENT_CLOSING:
 	      status = EACCES;
 	      break;
 
 	    default:
-	      imap->state = MU_IMAP_ERROR;
+	      imap->client_state = MU_IMAP_CLIENT_ERROR;
 	      status = MU_ERR_BADREPLY;
 	    }
 	}
diff --git a/libproto/imap/create.c b/libproto/imap/create.c
index 9b2743e..9ae92eb 100644
--- a/libproto/imap/create.c
+++ b/libproto/imap/create.c
@@ -60,6 +60,7 @@ _mu_imap_init (mu_imap_t imap)
       if (rc)
 	return rc;
     }
-  imap->state = MU_IMAP_NO_STATE; /* Init with no state.  */
+  imap->client_state = MU_IMAP_CLIENT_READY; 
+  imap->session_state = MU_IMAP_SESSION_INIT;
   return 0;
 }
diff --git a/libproto/imap/disconnect.c b/libproto/imap/disconnect.c
index 7683b26..3863142 100644
--- a/libproto/imap/disconnect.c
+++ b/libproto/imap/disconnect.c
@@ -32,7 +32,7 @@ mu_imap_disconnect (mu_imap_t imap)
   if (imap == NULL)
     return EINVAL;
 
-  imap->state = MU_IMAP_NO_STATE;
+  imap->client_state = MU_IMAP_CLIENT_READY;
   MU_IMAP_FCLR (imap, MU_IMAP_RESP);
 
   mu_list_clear (imap->capa);
diff --git a/libproto/imap/fetch.c b/libproto/imap/fetch.c
index 4b6e65d..1b6a70a 100644
--- a/libproto/imap/fetch.c
+++ b/libproto/imap/fetch.c
@@ -37,24 +37,22 @@ mu_imap_fetch (mu_imap_t imap, const char *msgset, const char *items)
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
-    return MU_ERR_SEQ;
 
-  if (imap->imap_state != MU_IMAP_STATE_SELECTED)
+  if (imap->session_state != MU_IMAP_SESSION_SELECTED)
     return MU_ERR_SEQ;
   
-  switch (imap->state)
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       status = mu_imapio_printf (imap->io, "%s FETCH %s %s\r\n",
 				 imap->tag_str, msgset, items);
       MU_IMAP_CHECK_ERROR (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_FETCH_RX;
+      imap->client_state = MU_IMAP_CLIENT_FETCH_RX;
 
-    case MU_IMAP_FETCH_RX:
+    case MU_IMAP_CLIENT_FETCH_RX:
       status = _mu_imap_response (imap, NULL, NULL);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
@@ -71,7 +69,7 @@ mu_imap_fetch (mu_imap_t imap, const char *msgset, const char *items)
 	  status = MU_ERR_BADREPLY;
 	  break;
 	}
-      imap->state = MU_IMAP_CONNECTED;
+      imap->client_state = MU_IMAP_CLIENT_READY;
       break;
 
     default:
@@ -88,7 +86,8 @@ _free_fetch_response (void *ptr)
     {
     case MU_IMAP_FETCH_BODY:
       free (resp->body.partv);
-      free (resp->body.key);
+      free (resp->body.section);
+      mu_list_destroy (&resp->body.fields);
       free (resp->body.text);
       break;
       
@@ -141,87 +140,112 @@ alloc_response (union mu_imap_fetch_response **resp, int type)
   return 0;
 }
 
-static int
-_uid_mapper (struct imap_list_element **elt,
-	     union mu_imap_fetch_response **return_resp)
+enum parse_response_state
+  {
+    resp_kw,
+    resp_val,
+    resp_body,
+    resp_body_section,
+    resp_skip,
+    resp_body_hlist,
+    resp_body_end
+  };
+
+struct parse_response_env;
+
+typedef int (*mapper_fn) (union mu_imap_fetch_response *resp,
+			  struct imap_list_element *elt,
+			  struct parse_response_env *env);
+
+struct parse_response_env
 {
+  mu_list_t result;
+  struct imap_list_element *elt;
+  enum parse_response_state state;
   union mu_imap_fetch_response *resp;
-  int rc;
+  mapper_fn mapper;
+  const char *section;
+  mu_list_t hlist;
+  int status;
+};
+
+
+static int
+_uid_mapper (union mu_imap_fetch_response *resp,
+	     struct imap_list_element *elt,
+	     struct parse_response_env *parse_env)
+{
   char *p;
   size_t uid;
   
-  if (elt[1]->type != imap_eltype_string)
+  if (elt->type != imap_eltype_string)
     return MU_ERR_FAILURE;
-  uid = strtoul (elt[1]->v.string, &p, 0);
+  uid = strtoul (elt->v.string, &p, 0);
   if (*p)
     return MU_ERR_FAILURE;
-  rc = alloc_response (&resp, MU_IMAP_FETCH_UID);
-  if (rc)
-    return rc;
   resp->uid.uid = uid;
-  *return_resp = resp;
   return 0;
 }
 			 
 static int
-_size_mapper (struct imap_list_element **elt,
-	      union mu_imap_fetch_response **return_resp)
+_size_mapper (union mu_imap_fetch_response *resp,
+	      struct imap_list_element *elt,
+	      struct parse_response_env *parse_env)
 {
-  union mu_imap_fetch_response *resp;
-  int rc;
   char *p;
   size_t size;
   
-  if (elt[1]->type != imap_eltype_string)
+  if (elt->type != imap_eltype_string)
     return MU_ERR_FAILURE;
-  size = strtoul (elt[1]->v.string, &p, 0);
+  size = strtoul (elt->v.string, &p, 0);
   if (*p)
     return MU_ERR_FAILURE;
-  rc = alloc_response (&resp, MU_IMAP_FETCH_RFC822_SIZE);
-  if (rc)
-    return rc;
   resp->rfc822_size.size = size;
-  *return_resp = resp;
   return 0;
 }
 
 static int
-_body_mapper (struct imap_list_element **elt,
-	      union mu_imap_fetch_response **return_resp)
+_body_mapper (union mu_imap_fetch_response *resp,
+	      struct imap_list_element *elt,
+	      struct parse_response_env *parse_env)
 {
-  union mu_imap_fetch_response *resp;
-  int rc;
-  char *section, *p;
+  const char *section, *p;
   size_t partc = 0;
   size_t *partv = NULL;
   
-  if (elt[1]->type != imap_eltype_string)
+  if (elt->type != imap_eltype_string)
     return MU_ERR_FAILURE;
-  rc = alloc_response (&resp, MU_IMAP_FETCH_BODY);
-  if (rc)
-    return rc;
 
-  section = strchr (elt[0]->v.string, '[');
+  section = parse_env->section;
   if (section)
     {
       p = section;
-      while (1)
+      while (mu_isdigit (*p))
 	{
+	  partc++;
 	  p = strchr (p, '.');
-	  if (*p)
+	  if (p)
 	    {
 	      p++;
-	      if (mu_isdigit (p[1]))
-		{
-		  partc++;
-		  continue;
-		}
+	      continue;
 	    }
 	  
 	  break;
 	}
     }
-  
+  else
+    p = NULL;
+
+  if (p)
+    {
+      resp->body.section = strdup (p);
+      if (!resp->body.section)
+	{
+	  free (resp);
+	  return ENOMEM;
+	}
+    }
+
   if (partc)
     {
       size_t i;
@@ -237,51 +261,33 @@ _body_mapper (struct imap_list_element **elt,
   resp->body.partc = partc;
   resp->body.partv = partv;
 
-  if (p)
-    {
-      size_t len = strlen (p);
-      resp->body.key = malloc (len);
-      if (!resp->body.key)
-	{
-	  free (resp->body.partv);
-	  free (resp);
-	  return ENOMEM;
-	}
-      len--;
-      memcpy (resp->body.key, p, len);
-      resp->body.key[len] = 0;
-    }
+  resp->body.fields = parse_env->hlist;
+  parse_env->hlist = NULL;
   
-  resp->body.text = strdup (elt[1]->v.string);
+  resp->body.text = strdup (elt->v.string);
   if (!resp->body.text)
     {
-      free (resp->body.key);
+      free (resp->body.section);
       free (resp->body.partv);
       free (resp);
       return ENOMEM;
     }
-  *return_resp = resp;
   return 0;
 }
 
 static int
-_rfc822_mapper (const char *key, struct imap_list_element *elt,
-		union mu_imap_fetch_response **return_resp)
+_rfc822_mapper (union mu_imap_fetch_response *resp,
+		struct imap_list_element *elt,
+		struct parse_response_env *parse_env)
 {
-  union mu_imap_fetch_response *resp;
-  int rc;
-  
   if (elt->type != imap_eltype_string)
     return MU_ERR_FAILURE;
-  rc = alloc_response (&resp, MU_IMAP_FETCH_BODY);
-  if (rc)
-    return rc;
 
   resp->body.partc = 0;
   resp->body.partv = NULL;
 
-  resp->body.key = strdup (key);
-  if (!resp->body.key)
+  resp->body.section = strdup (parse_env->section);
+  if (!resp->body.section)
     {
       free (resp);
       return ENOMEM;
@@ -290,72 +296,66 @@ _rfc822_mapper (const char *key, struct imap_list_element *elt,
   resp->body.text = strdup (elt->v.string);
   if (!resp->body.text)
     {
-      free (resp->body.key);
+      free (resp->body.section);
       free (resp->body.partv);
       free (resp);
       return ENOMEM;
     }
-  *return_resp = resp;
   return 0;
 }
 
 static int
-_rfc822_header_mapper (struct imap_list_element **elt,
-		       union mu_imap_fetch_response **return_resp)
+_rfc822_header_mapper (union mu_imap_fetch_response *resp,
+		       struct imap_list_element *elt,
+		       struct parse_response_env *parse_env)
 {
-  return _rfc822_mapper ("HEADER", elt[1], return_resp);
+  parse_env->section = "HEADER";
+  return _rfc822_mapper (resp, elt, parse_env);
 }
 
 static int
-_rfc822_text_mapper (struct imap_list_element **elt,
-		     union mu_imap_fetch_response **return_resp)
+_rfc822_text_mapper (union mu_imap_fetch_response *resp,
+		     struct imap_list_element *elt,
+		     struct parse_response_env *parse_env)
 {
-  return _rfc822_mapper ("TEXT", elt[1], return_resp);
+  parse_env->section = "TEXT";
+  return _rfc822_mapper (resp, elt, parse_env);
 }
 
 static int
-_flags_mapper (struct imap_list_element **elt,
-	       union mu_imap_fetch_response **return_resp)
+_flags_mapper (union mu_imap_fetch_response *resp,
+	       struct imap_list_element *elt,
+	       struct parse_response_env *parse_env)
 {
-  union mu_imap_fetch_response *resp;
-  int rc;
-  int flags;
-  
-  if (elt[1]->type != imap_eltype_list)
+  if (elt->type != imap_eltype_list)
     return MU_ERR_FAILURE;
-  if (_mu_imap_collect_flags (elt[1], &flags))
+  if (_mu_imap_collect_flags (elt, &resp->flags.flags))
     return MU_ERR_FAILURE;
-
-  rc = alloc_response (&resp, MU_IMAP_FETCH_FLAGS);
-  if (rc)
-    return rc;
-  resp->flags.flags = flags;
-  *return_resp = resp;
   return 0;
 }
 
 static int
-_date_mapper (struct imap_list_element **elt,
-	      union mu_imap_fetch_response **return_resp)
+_date_mapper (union mu_imap_fetch_response *resp,
+	      struct imap_list_element *elt,
+	      struct parse_response_env *parse_env)
 {
-  struct mu_imap_fetch_internaldate idate;
-  union mu_imap_fetch_response *resp;
-  int rc;
   const char *p;
+  struct tm tm;
+  struct mu_timezone tz;
   
-  if (elt[1]->type != imap_eltype_string)
+  if (elt->type != imap_eltype_string)
     return MU_ERR_FAILURE;
-  p = elt[1]->v.string;
-  if (mu_parse_imap_date_time (&p, &idate.tm, &idate.tz))
+  p = elt->v.string;
+  if (mu_parse_imap_date_time (&p, &tm, &tz))
     return MU_ERR_FAILURE;
-  rc = alloc_response (&resp, MU_IMAP_FETCH_INTERNALDATE);
-  if (rc)
-    return rc;
-  resp->internaldate = idate;
-  *return_resp = resp;
+  resp->internaldate.tm = tm;
+  resp->internaldate.tz = tz;
   return 0;
 }
 
+/* FIXME */
+#define _bodystructure_mapper NULL
+
 struct fill_env
 {
   struct mu_imap_fetch_envelope *envelope;
@@ -522,23 +522,17 @@ _fill_response (void *item, void *data)
 }
   
 static int
-_envelope_mapper (struct imap_list_element **elt,
-		  union mu_imap_fetch_response **return_resp)
+_envelope_mapper (union mu_imap_fetch_response *resp,
+		  struct imap_list_element *elt,
+		  struct parse_response_env *parse_env)
 {
-  union mu_imap_fetch_response *resp;
-  int rc;
   struct fill_env env;
   
-  if (elt[1]->type != imap_eltype_list)
+  if (elt->type != imap_eltype_list)
     return MU_ERR_FAILURE;
-  rc = alloc_response (&resp, MU_IMAP_FETCH_ENVELOPE);
-  if (rc)
-    return rc;
   env.envelope = &resp->envelope;
   env.n = 0;
-  mu_list_foreach (elt[1]->v.list, _fill_response, &env);
-  
-  *return_resp = resp;
+  mu_list_foreach (elt->v.list, _fill_response, &env);
   return 0;
 }
 
@@ -546,81 +540,146 @@ struct mapper_tab
 {
   char *name;
   size_t size;
-  int prefix;
-  int (*mapper) (struct imap_list_element **, union mu_imap_fetch_response **);
+  int type;
+  mapper_fn mapper;
 };
   
 static struct mapper_tab mapper_tab[] = {
 #define S(s) s, (sizeof (s) - 1)
-  { S("BODYSTRUCTURE"), 0, },
-  { S("BODY["),         1, _body_mapper },
-  { S("BODY"),          0, _body_mapper },
-  { S("ENVELOPE"),      0, _envelope_mapper },
-  { S("FLAGS"),         0, _flags_mapper },
-  { S("INTERNALDATE"),  0, _date_mapper },
-  { S("RFC822"),        0, _body_mapper},
-  { S("RFC822.HEADER"), 0, _rfc822_header_mapper }, 
-  { S("RFC822.SIZE"),   0, _size_mapper },
-  { S("RFC822.TEXT"),   0, _rfc822_text_mapper },
-  { S("UID"),           0, _uid_mapper },
+  { S("BODYSTRUCTURE"), },
+  { S("BODY"),          MU_IMAP_FETCH_BODY,        _body_mapper },
+  { S("ENVELOPE"),      MU_IMAP_FETCH_ENVELOPE,    _envelope_mapper },
+  { S("FLAGS"),         MU_IMAP_FETCH_FLAGS,       _flags_mapper },
+  { S("INTERNALDATE"),  MU_IMAP_FETCH_INTERNALDATE, _date_mapper },
+  { S("RFC822"),        MU_IMAP_FETCH_BODY,        _body_mapper},
+  { S("RFC822.HEADER"), MU_IMAP_FETCH_BODY,        _rfc822_header_mapper }, 
+  { S("RFC822.SIZE"),   MU_IMAP_FETCH_RFC822_SIZE, _size_mapper },
+  { S("RFC822.TEXT"),   MU_IMAP_FETCH_BODY,        _rfc822_text_mapper },
+  { S("UID"),           MU_IMAP_FETCH_UID,         _uid_mapper },
 #undef S
   { NULL }
 };
-  
+
 static int
-_fetch_mapper (void **itmv, size_t itmc, void *call_data)
+_extract_string (void **itmv, size_t itmc, void *call_data)
 {
-  int *status = call_data;
-  struct mapper_tab *mt;
-  struct imap_list_element *elt[2];
-  char *kw;
-  size_t kwlen;
-  union mu_imap_fetch_response *resp;
+  struct imap_list_element *elt = itmv[0];
+  if (elt->type != imap_eltype_string)
+    return MU_LIST_MAP_SKIP;
+  itmv[0] = elt->v.string;
+  return 0;
+}
 
-  elt[0] = itmv[0];
-  elt[1] = itmv[1];
-  
-  if (elt[0]->type != imap_eltype_string)
-    {
-      *status = MU_ERR_FAILURE;
-      return MU_LIST_MAP_STOP|MU_LIST_MAP_SKIP;
-    }
-  kw = elt[0]->v.string;
-  kwlen = strlen (kw);
-  for (mt = mapper_tab; mt->name; mt++)
+static int
+_fetch_fold (void *item, void *data)
+{
+  struct imap_list_element *elt = item;
+  struct parse_response_env *env = data;
+
+  switch (env->state)
     {
-      if (mt->prefix)
+    case resp_kw:
+      {
+	int rc;
+	char *kw;
+	size_t kwlen;
+	struct mapper_tab *mt;
+
+	if (elt->type != imap_eltype_string)
+	  {
+	    env->status = MU_ERR_FAILURE;
+	    return MU_ERR_FAILURE;
+	  }
+	kw = elt->v.string;
+	kwlen = strlen (kw);
+	for (mt = mapper_tab; mt->name; mt++)
+	  {
+	    if (mt->size == kwlen && memcmp (mt->name, kw, kwlen) == 0)
+	      break;
+	  }
+
+	if (!mt->name)
+	  {
+	    mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_TRACE9,
+		      ("ignoring unknown FETCH item '%s'", kw));
+	    env->state = resp_skip;
+	    return 0;
+	  }
+
+	env->mapper = mt->mapper;
+	rc = alloc_response (&env->resp, mt->type);
+	if (rc)
+	  {
+	    env->status = rc;
+	    return MU_ERR_FAILURE;
+	  }
+	env->state = mt->type == MU_IMAP_FETCH_BODY ? resp_body : resp_val;
+	break;
+      }
+      
+    case resp_val:
+      if (env->mapper)
 	{
-	  if (mt->size >= kwlen && memcmp (mt->name, kw, kwlen) == 0)
-	    break;
+	  int rc = env->mapper (env->resp, elt, env);
+	  if (rc)
+	    _free_fetch_response (env->resp);
+	  else
+	    mu_list_append (env->result, env->resp);
 	}
-      else if (mt->size == kwlen && memcmp (mt->name, kw, kwlen) == 0)
-	break;
-    }
-
-  if (!mt->name)
-    {
-      mu_debug (MU_DEBCAT_MAILER, MU_DEBUG_TRACE9,
-		("ignoring unknown FETCH item '%s'", kw));
-      return MU_LIST_MAP_SKIP;
-    }
-
-  if (mt->mapper)
-    {
-      int rc = mt->mapper (elt, &resp);
-      if (rc == 0)
+      env->resp = NULL;
+      mu_list_destroy (&env->hlist);
+      env->state = resp_kw;
+      break;
+      
+    case resp_body:
+      if (_mu_imap_list_element_is_string (elt, "["))
+	env->state = resp_body_section;
+      else
+	{
+	  env->mapper = _bodystructure_mapper;
+	  env->state = resp_val;
+	}
+      break;
+      
+    case resp_body_section:
+      if (elt->type != imap_eltype_string)
+	{
+	  env->status = MU_ERR_PARSE;
+	  return MU_ERR_FAILURE;
+	}
+      else if (strncmp (elt->v.string, "HEADER.FIELDS", 13) == 0)
+	env->state = resp_body_hlist;
+      else
+	env->state = resp_body_end;
+      env->section = elt->v.string;
+      break;
+      
+    case resp_skip:
+      mu_list_destroy (&env->hlist);
+      env->state = resp_kw;
+      break;
+      
+    case resp_body_hlist:
+      if (elt->type != imap_eltype_list)
 	{
-	  itmv[0] = resp;
-	  return MU_LIST_MAP_OK;
+	  env->status = MU_ERR_PARSE;
+	  return MU_ERR_FAILURE;
 	}
+      mu_list_map (elt->v.list, _extract_string, NULL, 1, &env->hlist);
+      env->state = resp_body_end;
+      break;
+      
+    case resp_body_end:
+      if (_mu_imap_list_element_is_string (elt, "]"))
+	env->state = resp_val;
       else
 	{
-	  *status = rc;
-	  return MU_LIST_MAP_STOP|MU_LIST_MAP_SKIP;
+	  env->status = MU_ERR_PARSE;
+	  return MU_ERR_FAILURE;
 	}
     }
-      
-  return MU_LIST_MAP_SKIP;
+  
+  return 0;
 }
 
 int
@@ -628,7 +687,8 @@ _mu_imap_parse_fetch_response (mu_list_t input, mu_list_t *result_list)
 {
   mu_list_t result;
   int status;
-
+  struct parse_response_env env;
+  
   status = mu_list_create (&result);
   if (status)
     {
@@ -637,11 +697,14 @@ _mu_imap_parse_fetch_response (mu_list_t input, mu_list_t *result_list)
       return 1;
     }
   mu_list_set_destroy_item (result, _free_fetch_response);
-  mu_list_map (input, _fetch_mapper, &status, 2, &result);
-  if (status)
+  memset (&env, 0, sizeof (env));
+
+  env.result = result;
+  mu_list_foreach (input, _fetch_fold, &env);
+  if (env.status)
     mu_list_destroy (&result);
   else
     *result_list = result;
-  
+  mu_list_destroy (&env.hlist);
   return status;
 }
diff --git a/libproto/imap/id.c b/libproto/imap/id.c
index 05938ab..487ecf3 100644
--- a/libproto/imap/id.c
+++ b/libproto/imap/id.c
@@ -84,12 +84,12 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
+  if (imap->session_state == MU_IMAP_SESSION_INIT)
     return MU_ERR_SEQ;
-
-  switch (imap->state)
+  
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       status = mu_imapio_printf (imap->io, "%s ID ", imap->tag_str);
@@ -121,9 +121,9 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
       status = mu_imapio_printf (imap->io, "\r\n");
       MU_IMAP_CHECK_ERROR (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_ID_RX;
+      imap->client_state = MU_IMAP_CLIENT_ID_RX;
 
-    case MU_IMAP_ID_RX:
+    case MU_IMAP_CLIENT_ID_RX:
       status = _mu_imap_response (imap, parse_id_reply, passoc);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
@@ -140,7 +140,7 @@ mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc)
 	  status = MU_ERR_BADREPLY;
 	  break;
 	}
-      imap->state = MU_IMAP_CONNECTED;
+      imap->client_state = MU_IMAP_CLIENT_READY;
       break;
 
     default:
diff --git a/libproto/imap/login.c b/libproto/imap/login.c
index b0d3597..2a8f363 100644
--- a/libproto/imap/login.c
+++ b/libproto/imap/login.c
@@ -33,14 +33,12 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
-    return MU_ERR_SEQ;
-  if (imap->imap_state != MU_IMAP_STATE_NONAUTH)
+  if (imap->session_state != MU_IMAP_SESSION_NONAUTH)
     return MU_ERR_SEQ;
   
-  switch (imap->state)
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       if (mu_imap_trace_mask (imap, MU_IMAP_TRACE_QRY, MU_XSCRIPT_SECURE))
 	_mu_imap_xscript_level (imap, MU_XSCRIPT_SECURE);
       status = _mu_imap_tag_next (imap);
@@ -51,16 +49,16 @@ mu_imap_login (mu_imap_t imap, const char *user, const char *pass)
       /* FIXME: how to obscure the passwd in the stream buffer? */
       MU_IMAP_CHECK_EAGAIN (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_LOGIN_RX;
+      imap->client_state = MU_IMAP_CLIENT_LOGIN_RX;
 
-    case MU_IMAP_LOGIN_RX:
+    case MU_IMAP_CLIENT_LOGIN_RX:
       status = _mu_imap_response (imap, NULL, NULL);
-      imap->state = MU_IMAP_CONNECTED;
+      imap->client_state = MU_IMAP_CLIENT_READY;
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
 	{
 	case MU_IMAP_OK:
-	  imap->imap_state = MU_IMAP_STATE_AUTH;
+	  imap->session_state = MU_IMAP_SESSION_AUTH;
 	  break;
 
 	case MU_IMAP_NO:
diff --git a/libproto/imap/logout.c b/libproto/imap/logout.c
index 11bef62..e91e1ce 100644
--- a/libproto/imap/logout.c
+++ b/libproto/imap/logout.c
@@ -32,25 +32,26 @@ mu_imap_logout (mu_imap_t imap)
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
+  if (!(imap->session_state == MU_IMAP_SESSION_AUTH ||
+	imap->session_state == MU_IMAP_SESSION_SELECTED))
     return MU_ERR_SEQ;
 
-  switch (imap->state)
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       status = mu_imapio_printf (imap->io, "%s LOGOUT\r\n",
 				 imap->tag_str); 
       MU_IMAP_CHECK_EAGAIN (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_LOGOUT_RX;
+      imap->client_state = MU_IMAP_CLIENT_LOGOUT_RX;
 
-    case MU_IMAP_LOGOUT_RX:
+    case MU_IMAP_CLIENT_LOGOUT_RX:
       status = _mu_imap_response (imap, NULL, NULL);
       MU_IMAP_CHECK_EAGAIN (imap, status);
-      imap->state = MU_IMAP_NO_STATE;
-      imap->imap_state = MU_IMAP_STATE_LOGOUT;
+      imap->client_state = MU_IMAP_CLIENT_READY;
+      imap->session_state = MU_IMAP_SESSION_LOGOUT;
       break;
 
     default:
diff --git a/libproto/imap/noop.c b/libproto/imap/noop.c
index 6d7accc..a4b22e7 100644
--- a/libproto/imap/noop.c
+++ b/libproto/imap/noop.c
@@ -33,20 +33,20 @@ mu_imap_noop (mu_imap_t imap)
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
+  if (imap->session_state == MU_IMAP_SESSION_INIT)
     return MU_ERR_SEQ;
 
-  switch (imap->state)
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       status = mu_imapio_printf (imap->io, "%s NOOP\r\n", imap->tag_str);
       MU_IMAP_CHECK_ERROR (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_NOOP_RX;
+      imap->client_state = MU_IMAP_CLIENT_NOOP_RX;
 
-    case MU_IMAP_NOOP_RX:
+    case MU_IMAP_CLIENT_NOOP_RX:
       status = _mu_imap_response (imap, NULL, NULL);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
@@ -63,7 +63,7 @@ mu_imap_noop (mu_imap_t imap)
 	  status = MU_ERR_BADREPLY;
 	  break;
 	}
-      imap->state = MU_IMAP_CONNECTED;
+      imap->client_state = MU_IMAP_CLIENT_READY;
       break;
 
     default:
diff --git a/libproto/imap/resplist.c b/libproto/imap/resplist.c
index 98b8a22..cca7f33 100644
--- a/libproto/imap/resplist.c
+++ b/libproto/imap/resplist.c
@@ -64,7 +64,7 @@ _new_imap_list_element (mu_imap_t imap, enum imap_eltype type)
   struct imap_list_element *elt = calloc (1, sizeof (*elt));
   if (!elt)
     {
-      imap->state = MU_IMAP_ERROR;
+      imap->client_state = MU_IMAP_CLIENT_ERROR;
     }
   else
     elt->type = type;
@@ -238,7 +238,7 @@ _mu_imap_untagged_response_to_list (mu_imap_t imap, mu_list_t *plist)
     {
       if (elt)
 	_imap_list_free (elt);
-      imap->state = MU_IMAP_ERROR;
+      imap->client_state = MU_IMAP_CLIENT_ERROR;
       return pb.pb_err;
     }
   *plist = elt->v.list;
diff --git a/libproto/imap/response.c b/libproto/imap/response.c
index 653b074..c74f656 100644
--- a/libproto/imap/response.c
+++ b/libproto/imap/response.c
@@ -59,7 +59,7 @@ _mu_imap_response (mu_imap_t imap, mu_imap_response_action_t fun,
 	  mu_imapio_get_words (imap->io, &wc, &wv);
 	  if (wc == 0)
 	    {
-	      imap->state = MU_IMAP_ERROR;
+	      imap->client_state = MU_IMAP_CLIENT_ERROR;
 	      status = MU_ERR_BADREPLY;/* FIXME: ECONNRESET ? */
 	      break;
 	    }
@@ -80,7 +80,7 @@ _mu_imap_response (mu_imap_t imap, mu_imap_response_action_t fun,
 	      /* Handle the tagged response */
 	      if (wc < 2)
 		{
-		  /*imap->state = MU_IMAP_ERROR;*/
+		  /*imap->client_state = MU_IMAP_CLIENT_ERROR;*/
 		  status = MU_ERR_BADREPLY;
 		}
 	      else if (strcmp (wv[1], "OK") == 0)
@@ -104,12 +104,12 @@ _mu_imap_response (mu_imap_t imap, mu_imap_response_action_t fun,
 	    }
 	  else
 	    {
-	      imap->state = MU_IMAP_ERROR;
+	      imap->client_state = MU_IMAP_CLIENT_ERROR;
 	      status = MU_ERR_BADREPLY;
 	    }
 	}
       else
-	imap->state = MU_IMAP_ERROR;
+	imap->client_state = MU_IMAP_CLIENT_ERROR;
       break;
     }
   return status;
diff --git a/libproto/imap/resproc.c b/libproto/imap/resproc.c
index 373e258..2aac6a4 100644
--- a/libproto/imap/resproc.c
+++ b/libproto/imap/resproc.c
@@ -143,10 +143,10 @@ ok_response (mu_imap_t imap, mu_list_t resp, void *data)
   if (mu_list_tail (resp, (void*) &arg) || arg->type != imap_eltype_string)
     arg = NULL;
   mu_imap_callback (imap, MU_IMAP_CB_OK, rcode, arg ? arg->v.string : NULL);
-  if (imap->state == MU_IMAP_GREETINGS)
+  if (imap->client_state == MU_IMAP_CLIENT_GREETINGS)
     {
-      imap->state = MU_IMAP_CONNECTED;
-      imap->imap_state = MU_IMAP_STATE_NONAUTH;
+      imap->client_state = MU_IMAP_CLIENT_READY;
+      imap->session_state = MU_IMAP_SESSION_NONAUTH;
     }
 }
 
@@ -165,29 +165,29 @@ static void
 no_response (mu_imap_t imap, mu_list_t resp, void *data)
 {
   default_response (imap, MU_IMAP_CB_NO, resp, data);
-  if (imap->state == MU_IMAP_GREETINGS)
-    imap->state = MU_IMAP_ERROR;
+  if (imap->client_state == MU_IMAP_CLIENT_GREETINGS)
+    imap->client_state = MU_IMAP_CLIENT_ERROR;
 }
 
 static void
 bad_response (mu_imap_t imap, mu_list_t resp, void *data)
 {
   default_response (imap, MU_IMAP_CB_BAD, resp, data);
-  if (imap->state == MU_IMAP_GREETINGS)
-    imap->state = MU_IMAP_ERROR;
+  if (imap->client_state == MU_IMAP_CLIENT_GREETINGS)
+    imap->client_state = MU_IMAP_CLIENT_ERROR;
 }
 
 static void
 bye_response (mu_imap_t imap, mu_list_t resp, void *data)
 {
   default_response (imap, MU_IMAP_CB_BYE, resp, data);
-  imap->state = MU_IMAP_CLOSING;
+  imap->client_state = MU_IMAP_CLIENT_CLOSING;
 }
 
 static void
 preauth_response (mu_imap_t imap, mu_list_t resp, void *data)
 {
-  if (imap->state == MU_IMAP_GREETINGS)
+  if (imap->client_state == MU_IMAP_CLIENT_GREETINGS)
     {
       struct imap_list_element *arg;
 
@@ -196,8 +196,8 @@ preauth_response (mu_imap_t imap, mu_list_t resp, void *data)
       mu_imap_callback (imap, MU_IMAP_CB_PREAUTH,
 			parse_response_code (imap, resp),
 			arg ? arg->v.string : NULL);
-      imap->state = MU_IMAP_CONNECTED;
-      imap->imap_state = MU_IMAP_STATE_AUTH;
+      imap->client_state = MU_IMAP_CLIENT_READY;
+      imap->session_state = MU_IMAP_SESSION_AUTH;
     }
   else
     mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
diff --git a/libproto/imap/select.c b/libproto/imap/select.c
index 5d30db3..be19668 100644
--- a/libproto/imap/select.c
+++ b/libproto/imap/select.c
@@ -43,6 +43,7 @@ _mu_imap_collect_flags (struct imap_list_element *arg, int *res)
 {
   if (arg->type != imap_eltype_list)
     return EINVAL;
+  *res = 0;
   mu_list_foreach (arg->v.list, _collect_flags, res);
   return 0;
 }
@@ -72,15 +73,13 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
-    return MU_ERR_SEQ;
-  if (imap->imap_state != MU_IMAP_STATE_AUTH &&
-      imap->imap_state != MU_IMAP_STATE_SELECTED)
+  if (imap->session_state != MU_IMAP_SESSION_AUTH &&
+      imap->session_state != MU_IMAP_SESSION_SELECTED)
     return MU_ERR_SEQ;
 
   if (!mbox)
     {
-      if (imap->imap_state == MU_IMAP_STATE_SELECTED)
+      if (imap->session_state == MU_IMAP_SESSION_SELECTED)
 	{
 	  if (ps)
 	    *ps = imap->mbox_stat;
@@ -97,9 +96,9 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
       return 0;
     }
   
-  switch (imap->state)
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       status = mu_imapio_printf (imap->io, "%s %s %s\r\n",
@@ -108,21 +107,21 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 				 mbox);
       MU_IMAP_CHECK_ERROR (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_SELECT_RX;
+      imap->client_state = MU_IMAP_CLIENT_SELECT_RX;
 
-    case MU_IMAP_SELECT_RX:
+    case MU_IMAP_CLIENT_SELECT_RX:
       memset (&imap->mbox_stat, 0, sizeof (imap->mbox_stat));
       status = _mu_imap_response (imap, _select_response_action, NULL);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       switch (imap->resp_code)
 	{
 	case MU_IMAP_OK:
-	  imap->imap_state = MU_IMAP_STATE_SELECTED;
+	  imap->session_state = MU_IMAP_SESSION_SELECTED;
 	  free (imap->mbox_name);
 	  imap->mbox_name = strdup (mbox);
 	  if (!imap->mbox_name)
 	    {
-	      imap->state = MU_IMAP_ERROR;
+	      imap->client_state = MU_IMAP_CLIENT_ERROR;
 	      return errno;
 	    }
 	  imap->mbox_writable = writable;
@@ -138,7 +137,7 @@ mu_imap_select (mu_imap_t imap, const char *mbox, int writable,
 	  status = MU_ERR_BADREPLY;
 	  break;
 	}
-      imap->state = MU_IMAP_CONNECTED;
+      imap->client_state = MU_IMAP_CLIENT_READY;
       break;
 
     default:
diff --git a/libproto/imap/state.c b/libproto/imap/state.c
index b77f0c2..a957aa1 100644
--- a/libproto/imap/state.c
+++ b/libproto/imap/state.c
@@ -36,7 +36,7 @@ mu_imap_state (mu_imap_t imap, int *pstate)
 {
   if (imap == NULL || pstate == NULL)
     return EINVAL;
-  *pstate = imap->imap_state;
+  *pstate = imap->session_state;
   return 0;
 }
 
diff --git a/libproto/imap/status.c b/libproto/imap/status.c
index b8969ce..7a3a287 100644
--- a/libproto/imap/status.c
+++ b/libproto/imap/status.c
@@ -126,10 +126,8 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
     return EINVAL;
   if (!imap->io)
     return MU_ERR_NO_TRANSPORT;
-  if (imap->state != MU_IMAP_CONNECTED)
-    return MU_ERR_SEQ;
-  if (imap->imap_state != MU_IMAP_STATE_AUTH &&
-      imap->imap_state != MU_IMAP_STATE_SELECTED)
+  if (imap->session_state != MU_IMAP_SESSION_AUTH &&
+      imap->session_state != MU_IMAP_SESSION_SELECTED)
     return MU_ERR_SEQ;
   if (!ps)
     return MU_ERR_OUT_PTR_NULL;
@@ -138,7 +136,7 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
       
   if (!mboxname)
     {
-      if (imap->imap_state == MU_IMAP_STATE_SELECTED)
+      if (imap->session_state == MU_IMAP_SESSION_SELECTED)
 	{
 	  if (ps)
 	    *ps = imap->mbox_stat;
@@ -154,9 +152,9 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
       return 0;
     }
   
-  switch (imap->state)
+  switch (imap->client_state)
     {
-    case MU_IMAP_CONNECTED:
+    case MU_IMAP_CLIENT_READY:
       status = _mu_imap_tag_next (imap);
       MU_IMAP_CHECK_EAGAIN (imap, status);
       status = mu_imapio_printf (imap->io, "%s STATUS %s (",
@@ -179,9 +177,9 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
 	status = mu_imapio_send (imap->io, ")\r\n", 3);
       MU_IMAP_CHECK_ERROR (imap, status);
       MU_IMAP_FCLR (imap, MU_IMAP_RESP);
-      imap->state = MU_IMAP_STATUS_RX;
+      imap->client_state = MU_IMAP_CLIENT_STATUS_RX;
 
-    case MU_IMAP_STATUS_RX:
+    case MU_IMAP_CLIENT_STATUS_RX:
       {
 	struct status_data sd = { mboxname, ps };
 
@@ -200,7 +198,7 @@ mu_imap_status (mu_imap_t imap, const char *mboxname, struct mu_imap_stat *ps)
 	    status = MU_ERR_BADREPLY;
 	    break;
 	  }
-	imap->state = MU_IMAP_CONNECTED;
+	imap->client_state = MU_IMAP_CLIENT_READY;
       }
       break;
 
diff --git a/mu/imap.c b/mu/imap.c
index 44a6cdb..54ebca7 100644
--- a/mu/imap.c
+++ b/mu/imap.c
@@ -62,17 +62,17 @@ static struct argp imap_argp = {
 
 static mu_imap_t imap;
 
-static enum mu_imap_state
+static enum mu_imap_session_state
 current_imap_state ()
 {
   int state;
   if (imap == NULL)
-    state = MU_IMAP_STATE_INIT;
+    state = MU_IMAP_SESSION_INIT;
   else
     {
       mu_imap_state (imap, &state);
-      if (state == MU_IMAP_STATE_LOGOUT)
-	state = MU_IMAP_STATE_INIT;
+      if (state == MU_IMAP_SESSION_LOGOUT)
+	state = MU_IMAP_SESSION_INIT;
     }
   return state;
 }
@@ -131,12 +131,12 @@ static char *username;
 static void
 imap_prompt_env ()
 {
-  enum mu_imap_state state = current_imap_state ();
+  enum mu_imap_session_state state = current_imap_state ();
   if (!mutool_prompt_env)
     mutool_prompt_env = xcalloc (2*7 + 1, sizeof(mutool_prompt_env[0]));
 
   mutool_prompt_env[0] = "user";
-  mutool_prompt_env[1] = (state >= MU_IMAP_STATE_AUTH && username) ?
+  mutool_prompt_env[1] = (state >= MU_IMAP_SESSION_AUTH && username) ?
                            username : "[nouser]";
 
   mutool_prompt_env[2] = "host"; 
@@ -188,7 +188,135 @@ imap_bad_callback (void *data, int code, size_t sdat, void *pdat)
   const char *text = pdat;
   mu_diag_output (MU_DIAG_CRIT, "SERVER ALERT: %s", text);
 }
+
+/* Fetch callback */
+static void
+format_email (mu_stream_t str, const char *name, mu_address_t addr)
+{
+  mu_stream_printf (str, "  %s = ", name);
+  if (!addr)
+    mu_stream_printf (str, "NIL");
+  else
+    {
+      size_t sz = mu_address_format_string (addr, NULL, 0);
+      char *buf = xmalloc (sz + 1);
+      mu_address_format_string (addr, buf, sz);
+      mu_stream_write (str, buf, strlen (buf), NULL);
+    }
+  mu_stream_printf (str, "\n");
+}
+
+static void
+format_date (mu_stream_t str, char *name,
+	     struct tm *tm, struct mu_timezone *tz)
+{
+  char date[128];
+  
+  strftime (date, sizeof (date), "%a %b %e %H:%M:%S", tm);
+  mu_stream_printf (str, "  %s = %s", name, date);
+  if (tz->tz_name)
+    mu_stream_printf (str, " %s", tz->tz_name);
+  else
+    {
+      int off = tz->utc_offset;
+      if (off < 0)
+	{
+	  mu_stream_printf (str, " -");
+	  off = - off;
+	}
+      else
+	mu_stream_printf (str, " +");
+      off /= 60;
+      mu_stream_printf (str, "%02d%02d", off / 60, off % 60);
+    }
+  mu_stream_printf (str, "\n");
+}
 
+static int
+fetch_response_printer (void *item, void *data)
+{
+  union mu_imap_fetch_response *resp = item;
+  mu_stream_t str = data;
+
+  switch (resp->type)
+    {
+    case MU_IMAP_FETCH_BODY:
+      mu_stream_printf (str, "BODY [");
+      if (resp->body.partv)
+	{
+	  size_t i;
+	  
+	  for (i = 0; i < resp->body.partc; i++)
+	    mu_stream_printf (str, "%lu.",
+			      (unsigned long) resp->body.partv[i]);
+	}
+      if (resp->body.section)
+	mu_stream_printf (str, "%s", resp->body.section);
+      mu_stream_printf (str, "]");
+      mu_stream_printf (str, "\nBEGIN\n%s\nEND\n", resp->body.text);
+      break;
+      
+    case MU_IMAP_FETCH_BODYSTRUCTURE:
+      /* FIXME */
+      mu_stream_printf (str, "BODYSTRUCTURE (not yet implemented)\n");
+      break;
+      
+    case MU_IMAP_FETCH_ENVELOPE:
+      {
+	mu_stream_printf (str, "ENVELOPE:\n");
+	
+	format_date (str, "date", &resp->envelope.date, &resp->envelope.tz);
+
+	format_email (str, "from", resp->envelope.from);
+	format_email (str, "sender", resp->envelope.sender);
+	format_email (str, "reply-to", resp->envelope.reply_to);
+	format_email (str, "to", resp->envelope.to);
+	format_email (str, "cc", resp->envelope.cc);
+	format_email (str, "bcc", resp->envelope.bcc);
+
+	mu_stream_printf (str, "  in-reply-to = %s\n",
+			  resp->envelope.in_reply_to ?
+			   resp->envelope.in_reply_to : "NIL");
+	mu_stream_printf (str, "  message-id = %s\n",
+			  resp->envelope.message_id ?
+			   resp->envelope.message_id : "NIL");
+      }
+      break;
+      
+    case MU_IMAP_FETCH_FLAGS:
+      mu_stream_printf (str, "  flags = ");
+      mu_imap_format_flags (str, resp->flags.flags);
+      mu_stream_printf (str, "\n");
+      break;
+      
+    case MU_IMAP_FETCH_INTERNALDATE:
+      format_date (str, "internaldate", &resp->internaldate.tm,
+		   &resp->internaldate.tz);
+      break;
+      
+    case MU_IMAP_FETCH_RFC822_SIZE:
+      mu_stream_printf (str, "  size = %lu\n",
+			(unsigned long) resp->rfc822_size.size);
+      break;
+      
+    case MU_IMAP_FETCH_UID:
+      mu_stream_printf (str, "  UID = %lu\n",
+			(unsigned long) resp->uid.uid);
+    }
+  return 0;
+}
+
+static void
+imap_fetch_callback (void *data, int code, size_t sdat, void *pdat)
+{
+  mu_stream_t str = data;
+  mu_list_t list = pdat;
+
+  mu_stream_printf (str, "Message #%lu:\n", (unsigned long) sdat);
+  mu_list_foreach (list, fetch_response_printer, str);
+  mu_stream_printf (str, "\n\n");
+}
+  
 
 static int
 com_disconnect (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
@@ -212,7 +340,7 @@ com_connect (int argc, char **argv)
   int status;
   int tls = 0;
   int i = 1;
-  enum mu_imap_state state;
+  enum mu_imap_session_state state;
   
   for (i = 1; i < argc; i++)
     {
@@ -234,7 +362,7 @@ com_connect (int argc, char **argv)
   
   state = current_imap_state ();
   
-  if (state != MU_IMAP_STATE_INIT)
+  if (state != MU_IMAP_SESSION_INIT)
     com_disconnect (0, NULL);
   
   status = mu_imap_create (&imap);
@@ -292,7 +420,9 @@ com_connect (int argc, char **argv)
 	  mu_imap_register_callback_function (imap, MU_IMAP_CB_BAD,
 					      imap_bad_callback,
 					      NULL);
-
+	  mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH,
+					      imap_fetch_callback,
+					      mu_strout);
 	  
 	  status = mu_imap_connect (imap);
 	  if (status)
@@ -600,7 +730,17 @@ com_noop (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
 static int
 com_fetch (int argc, char **argv)
 {
-  int status = mu_imap_fetch (imap, argv[1], argv[2]);
+  int status;
+  mu_stream_t out = mutool_open_pager ();
+  
+  mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH,
+				      imap_fetch_callback,
+				      out);
+  status = mu_imap_fetch (imap, argv[1], argv[2]);
+  mu_stream_destroy (&out);
+  mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH,
+				      imap_fetch_callback,
+				      mu_strout);
   if (status)
     report_failure ("fetch", status);
   return 0;  


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Nov 30 20:07:19 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RVv7P-0005sB-9D
	for mharc-commit-mailutils@gnu.org; Wed, 30 Nov 2011 20:07:19 -0500
Received: from eggs.gnu.org ([140.186.70.92]:38563)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVv7M-0005rj-Cx
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 20:07:17 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVv7K-0001Vx-Ic
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 20:07:16 -0500
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33087)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVv7K-0001Vt-Gz
	for commit-mailutils@gnu.org; Wed, 30 Nov 2011 20:07:14 -0500
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1RVv7H-0006y4-Dd
	for commit-mailutils@gnu.org; Thu, 01 Dec 2011 01:07:14 +0000
Date: Thu, 01 Dec 2011 01:07:11 +0000
Message-Id: <E1RVv7H-0006y4-Dd@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-492-gbd55279
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 98ca43a049365269e4052170eba3103a8d35e20b
X-Git-Newrev: bd55279a9af52b1e6d88b6d8cb483e17174db106
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 01 Dec 2011 01:07: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=bd55279a9af52b1e6d88b6d8cb483e17174db106

The branch, master has been updated
       via  bd55279a9af52b1e6d88b6d8cb483e17174db106 (commit)
      from  98ca43a049365269e4052170eba3103a8d35e20b (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 bd55279a9af52b1e6d88b6d8cb483e17174db106
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Thu Dec 1 03:01:01 2011 +0200

    Implement list sorting.
    
    * include/mailutils/list.h (mu_list_sort): New proto.
    * libmailutils/list/sort.c: New file.
    * libmailutils/list/Makefile.am (liblist_la_SOURCES): Add sort.c
    * libmailutils/tests/listop.c: Implement the sort command.
    * libmailutils/tests/list.at: Test list sorting.

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

Summary of changes:
 include/mailutils/list.h      |   16 +++++-
 libmailutils/list/Makefile.am |    1 +
 libmailutils/list/sort.c      |  121 +++++++++++++++++++++++++++++++++++++++++
 libmailutils/tests/list.at    |   62 +++++++++++++++++++++
 libmailutils/tests/listop.c   |   17 ++++++-
 5 files changed, 215 insertions(+), 2 deletions(-)
 create mode 100644 libmailutils/list/sort.c

diff --git a/include/mailutils/list.h b/include/mailutils/list.h
index 2f860fb..60f0031 100644
--- a/include/mailutils/list.h
+++ b/include/mailutils/list.h
@@ -274,7 +274,9 @@ int mu_list_map (mu_list_t _list, mu_list_mapper_t _map,
 		 void *_data, size_t _nelem,
 		 mu_list_t *_res);
 
-  /* List fold */
+  /* ************************************************* */
+  /* List folding                                      */
+  /* ************************************************* */
 
 typedef int (*mu_list_folder_t) (void *_item, void *_data,
 				 void *_prev, void **_ret);
@@ -315,6 +317,18 @@ int mu_list_fold (mu_list_t _list, mu_list_folder_t _fold, void *_data,
 		  void *_init, void *_return_value);
 int mu_list_rfold (mu_list_t _list, mu_list_folder_t _fold, void *_data,
 		   void *_init, void *_return_value);
+
+  /* ************************************************* */
+  /* Sorting                                           */
+  /* ************************************************* */
+
+  /* Sort _list using quicksort algorithm.  Use _comp to compare elements.
+     If it is NULL, use the comparator method of _list.
+
+     Comparator must return 0 if the two elements are equal, -1 if
+     first of them is less than the second, and +1 otherwise.
+  */
+void mu_list_sort (mu_list_t _list, mu_list_comparator_t _comp);
   
 #ifdef __cplusplus
 }
diff --git a/libmailutils/list/Makefile.am b/libmailutils/list/Makefile.am
index cd17a9e..eb6084a 100644
--- a/libmailutils/list/Makefile.am
+++ b/libmailutils/list/Makefile.am
@@ -45,6 +45,7 @@ liblist_la_SOURCES = \
  setdestr.c\
  slice.c\
  slice2.c\
+ sort.c\
  tail.c
 
 INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
diff --git a/libmailutils/list/sort.c b/libmailutils/list/sort.c
new file mode 100644
index 0000000..a021abb
--- /dev/null
+++ b/libmailutils/list/sort.c
@@ -0,0 +1,121 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/errno.h>
+#include <mailutils/sys/list.h>
+
+static void
+_list_append_entry (struct _mu_list *list, struct list_data *ent)
+{
+  ent->prev = list->head.prev ? list->head.prev : &list->head;
+  ent->next = &list->head;
+  if (list->head.prev)
+    list->head.prev->next = ent;
+  else
+    list->head.next = ent;
+  list->head.prev = ent;
+  list->count++;
+}
+
+static void
+_list_qsort (mu_list_t list, mu_list_comparator_t cmp)
+{
+  struct list_data *cur, *middle;
+  struct _mu_list high_list, low_list;
+  int rc;
+
+  if (list->count < 2)
+    return;
+  if (list->count == 2)
+    {
+      if (cmp (list->head.prev->item, list->head.next->item) < 0)
+	{
+	  cur = list->head.prev;
+	  list->head.prev = list->head.next;
+	  list->head.next = cur;
+	  
+	  list->head.next->prev = &list->head;
+	  list->head.next->next = list->head.prev;
+	  
+	  list->head.prev->next = &list->head;
+	  list->head.prev->prev = list->head.next;
+	}
+      return;
+    }
+  
+  cur = list->head.next;
+  do {
+    cur = cur->next;
+    if (!cur)
+      return;
+  } while ((rc = cmp (list->head.next->item, cur->item)) == 0);
+
+  /* Select the lower of the two as the middle value */
+  middle = (rc > 0) ? cur : list->head.next;
+
+  /* Split into two sublists */
+  memset (&high_list, 0, sizeof (high_list));
+  memset (&low_list, 0, sizeof (low_list));
+
+  for (cur = list->head.next; cur != &list->head; )
+    {
+      struct list_data *next = cur->next;
+      cur->next = NULL;
+
+      if (cmp (middle->item, cur->item) < 0)
+	_list_append_entry (&high_list, cur);
+      else
+	_list_append_entry (&low_list, cur);
+      cur = next;
+    }
+
+  /* Sort both sublists recursively */
+  _list_qsort (&low_list, cmp);
+  _list_qsort (&high_list, cmp);
+
+  /* Join both lists in order */
+  if (low_list.head.prev)
+    cur = low_list.head.prev;
+  else
+    cur = &low_list.head;
+  cur->next = high_list.head.next;
+  if (high_list.head.next)
+    high_list.head.next->prev = cur;
+  
+  low_list.head.prev = high_list.head.prev;
+  high_list.head.prev = &low_list.head;
+  low_list.count += high_list.count;
+    
+  /* Return the resulting list */
+  list->head = low_list.head;
+  if (list->head.next)
+    list->head.next->prev = &list->head;
+  if (list->head.prev)
+    list->head.prev->next = &list->head;
+}
+
+void
+mu_list_sort (mu_list_t list, mu_list_comparator_t comp)
+{
+  if (list)
+    _list_qsort (list, comp ? comp : list->comp);
+}
diff --git a/libmailutils/tests/list.at b/libmailutils/tests/list.at
index fcc578e..d49ab43 100644
--- a/libmailutils/tests/list.at
+++ b/libmailutils/tests/list.at
@@ -445,6 +445,68 @@ rfold
 
 m4_popdef([MU_TEST_KEYWORDS])
 
+# ------------------------------------------------------------
+# Sort
+# ------------------------------------------------------------
+
+m4_define([MU_TEST_GROUP],[Sort])
+m4_pushdef([MU_TEST_KEYWORDS],MU_TEST_KEYWORDS[ sort])
+
+TESTLIST([empty list],[],
+[sort
+print
+],
+[# items: 0
+])
+
+TESTLIST([sorted list asc],[],
+[add a b c d e f
+sort
+print
+],
+[# items: 6
+a
+b
+c
+d
+e
+f
+])
+
+TESTLIST([sorted list desc],[],
+[add f e d c b a
+sort
+print
+],
+[# items: 6
+a
+b
+c
+d
+e
+f
+])
+
+TESTLIST([unsorted list],[],
+[add en to tre fire fem seks syv atte ni ti
+sort
+print
+],
+[# items: 10
+atte
+en
+fem
+fire
+ni
+seks
+syv
+ti
+to
+tre
+])
+
+m4_popdef([MU_TEST_KEYWORDS])
+
 dnl ------------------------------------------------------------
 dnl Cleanup
 m4_popdef([TESTLIST])
diff --git a/libmailutils/tests/listop.c b/libmailutils/tests/listop.c
index 93362ec..00d3949 100644
--- a/libmailutils/tests/listop.c
+++ b/libmailutils/tests/listop.c
@@ -773,7 +773,13 @@ rfold (mu_list_t list)
   else
     printf ("NULL\n");
 }
-  
+
+void
+sort (mu_list_t list)
+{
+  mu_list_sort (list, NULL);
+}
+
 void
 help ()
 {
@@ -802,6 +808,7 @@ help ()
   printf ("help\n");
   printf ("head\n");
   printf ("tail\n");
+  printf ("sort\n");
   printf ("NUMBER\n");
 }
 
@@ -921,6 +928,14 @@ shell (mu_list_t list)
 	    head (ws.ws_wordc, list);
 	  else if (strcmp (ws.ws_wordv[0], "tail") == 0)
 	    tail (ws.ws_wordc, list);
+	  else if (strcmp (ws.ws_wordv[0], "sort") == 0)
+	    {
+	      int i;
+	      sort (list);
+
+	      for (i = 0; i < NITR; i++)
+		mu_iterator_destroy (&itr[i]);
+	    }
 	  else if (ws.ws_wordc == 1)
 	    {
 	      char *p;


hooks/post-receive
-- 
GNU Mailutils


