commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-478-g9370af7


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-478-g9370af7
Date: Mon, 28 Nov 2011 10:12: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=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 <address@hidden>
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 <address@hidden>
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 = \
- @address@hidden
  ${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 = \
- @address@hidden
  @address@hidden
  ../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.
+
address@hidden@:@abs_top_builddir@/imap4d:$top_srcdir:$srcdir:$PATH
address@hidden@
+
+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 address@hidden,[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 "<address@hidden>"],[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]