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-207-g5974043


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-207-g5974043
Date: Sat, 20 Nov 2010 23:03: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=597404315ba308889ea2776c56c184d1eb9b02fc

The branch, master has been updated
       via  597404315ba308889ea2776c56c184d1eb9b02fc (commit)
       via  72beac0a0f1bc97283ffefac9c79730b94e62f53 (commit)
      from  c08b926f664b27953483a0dffcbe381ddaa154e5 (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 597404315ba308889ea2776c56c184d1eb9b02fc
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun Nov 21 00:45:46 2010 +0200

    mh: improve component reading (profile, context and whom).
    
    * libmailutils/filter/header.c: New file.
    * libmailutils/filter/Makefile.am (libfilter_la_SOURCES): Add header.c.
    * libmailutils/filter/filter.c (mu_filter_get_list): Register
    mu_header_filter.
    * libmailutils/filter/inline-comment.c: (ilcmt_ws)
    (ilcmt_rollback): New states.
    (ILCMT_REMOVE_EMPTY_LINES,ILCMT_SQUEEZE_WS): New flags.
    (ilcmt_data)<buf,size,level,replay>: New members.
    (ilcmt_action): New enum
    (new_ilcmt_state): Return enum ilcmt_action.
    (_ilcmt_decoder): Optionally remove
    empty lines and squeeze leading white space.
    * libmailutils/property/mhprop.c (_mh_prop_read_stream): Remove
    empty lines from the input.
    
    * libmailutils/tests/Makefile.am (TESTSUITE_AT): Add hdrflt.at
    and inline-comment.at.
    * libmailutils/tests/testsuite.at: Include hdrflt.at and inline-comment.at.
    * libmailutils/tests/fltst.c: Pass optional arguments to the
    filter creation procedure.
    
    * mh/mh_whom.c (read_header): New function.
    (mh_whom): Rewrite using headers.
    
    * include/mailutils/filter.h: Fix a typo.
    * libmailutils/stream/fltstream.c: Likewise.
    * libmu_auth/gsasl.c: Likewise.

commit 72beac0a0f1bc97283ffefac9c79730b94e62f53
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Nov 20 21:12:12 2010 +0200

    Move MH profile & context support to libproto.
    
    * mh/mh_ctx.c: Remove.
    * mh/Makefile.am (libmh_a_SOURCES): Remove mh_ctx.c
    * mh/folder.c (read_seq_file): Use mu_property_t.
    * mh/mh.h (mh_context_iterator): Remove typedef.
    (mh_global_profile_get, mh_global_profile_set)
    (mh_global_profile_iterate)
    (mh_global_context_set,mh_global_context_set)
    (mh_global_context_iterate): Rewrite as macros.
    (mh_global_sequences_iterate): Change signature.
    (mh_read_property_file,mh_property_merge): New protos.
    (mh_context_create,mh_context_read,mh_context_write)
    (mh_context_get_value,mh_context_set_value,mh_context_iterate)
    (mh_context_destroy,mh_context_merge): Remove protos.
    * mh/mh_global.c (mh_global_profile_get, mh_global_profile_set)
    (mh_global_profile_iterate)
    (mh_global_context_set,mh_global_context_set)
    (mh_global_context_iterate): Remove.
    (mh_read_property_file,mh_property_merge): New functions.
    (_mh_init_global_context,mh_read_profile)
    (mh_set_current_folder,mh_global_sequences_iterate): Rewrite.
    (mh_global_save_state): Rewrite.
    * mh/mh_whom.c (mh_whom): Use mu_property_t.
    * mh/send.c: Use mu_property_t.
    * po/POTFILES.in: Add mh/mboxprop.c.

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

Summary of changes:
 include/mailutils/filter.h                      |    3 +-
 libmailutils/filter/Makefile.am                 |    1 +
 libmailutils/filter/filter.c                    |    1 +
 libmailutils/filter/header.c                    |  121 ++++++++++++
 libmailutils/filter/inline-comment.c            |  171 ++++++++++++++++--
 libmailutils/property/mhprop.c                  |    5 +-
 libmailutils/stream/fltstream.c                 |    6 +-
 libmailutils/tests/Makefile.am                  |    2 +
 libmailutils/tests/fltst.c                      |   24 ++-
 mh/tests/mhl.at => libmailutils/tests/hdrflt.at |   38 ++--
 libmailutils/tests/inline-comment.at            |  113 +++++++++++
 libmailutils/tests/testsuite.at                 |    2 +
 libmu_auth/gsasl.c                              |    4 +-
 mh/Makefile.am                                  |    1 -
 mh/folder.c                                     |   11 +-
 mh/mh.h                                         |   40 ++--
 mh/mh_ctx.c                                     |  231 -----------------------
 mh/mh_global.c                                  |  145 ++++++++-------
 mh/mh_whom.c                                    |  100 +++++++++--
 mh/send.c                                       |   71 +++++---
 po/POTFILES.in                                  |    1 +
 21 files changed, 677 insertions(+), 414 deletions(-)
 create mode 100644 libmailutils/filter/header.c
 copy mh/tests/mhl.at => libmailutils/tests/hdrflt.at (58%)
 create mode 100644 libmailutils/tests/inline-comment.at
 delete mode 100644 mh/mh_ctx.c

diff --git a/include/mailutils/filter.h b/include/mailutils/filter.h
index aff0031..20d4880 100644
--- a/include/mailutils/filter.h
+++ b/include/mailutils/filter.h
@@ -56,7 +56,7 @@ enum mu_filter_command
 enum mu_filter_result
   {
     mu_filter_ok,
-    mu_filter_falure,
+    mu_filter_failure,
     mu_filter_moreinput,
     mu_filter_moreoutput,
     mu_filter_again
@@ -109,6 +109,7 @@ extern mu_filter_record_t mu_rfc_2047_Q_filter;
 extern mu_filter_record_t mu_rfc_2047_B_filter;
 extern mu_filter_record_t mu_from_filter;
 extern mu_filter_record_t mu_inline_comment_filter;
+extern mu_filter_record_t mu_header_filter;
 
 enum mu_iconv_fallback_mode
   {
diff --git a/libmailutils/filter/Makefile.am b/libmailutils/filter/Makefile.am
index e870a09..0dc7388 100644
--- a/libmailutils/filter/Makefile.am
+++ b/libmailutils/filter/Makefile.am
@@ -27,6 +27,7 @@ libfilter_la_SOURCES =\
  filter.c\
  filter_iconv.c\
  fromflt.c\
+ header.c\
  inline-comment.c\
  linelenflt.c\
  qpflt.c
diff --git a/libmailutils/filter/filter.c b/libmailutils/filter/filter.c
index 7525cf1..5b37cc6 100644
--- a/libmailutils/filter/filter.c
+++ b/libmailutils/filter/filter.c
@@ -79,6 +79,7 @@ mu_filter_get_list (mu_list_t *plist)
       mu_list_append (filter_list, mu_rfc_2047_B_filter);
       mu_list_append (filter_list, mu_from_filter);
       mu_list_append (filter_list, mu_inline_comment_filter);
+      mu_list_append (filter_list, mu_header_filter);
       /* FIXME: add the default encodings?  */
     }
   *plist = filter_list;
diff --git a/libmailutils/filter/header.c b/libmailutils/filter/header.c
new file mode 100644
index 0000000..8369d6a
--- /dev/null
+++ b/libmailutils/filter/header.c
@@ -0,0 +1,121 @@
+/* Message header filter for GNU Mailutils.
+   Copyright (C) 2010 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/>. */
+
+/* This filter reads the input data up to the first empty line (i.e. \n\n).
+   It is suitable to extract headers from RFC822 messages.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/errno.h>
+#include <mailutils/filter.h>
+#include <mailutils/cctype.h>
+
+enum hflt_state
+  {
+    hflt_initial,
+    hflt_newline,
+    hflt_copy
+  };
+
+static int
+new_state (int *pd, unsigned c)
+{
+  switch (*pd)
+    {
+    case hflt_initial:
+    case hflt_copy:
+      *pd = (c == '\n') ? hflt_newline : hflt_copy;
+      break;
+      
+    case hflt_newline:
+      if (c == '\n')
+       return 1;
+      *pd = hflt_copy;
+      break;
+    }
+  return 0;
+}
+
+static enum mu_filter_result
+_hflt_decoder (void *xd, enum mu_filter_command cmd,
+               struct mu_filter_io *iobuf)
+{
+  int *pd = xd;
+  size_t i, j;
+  const unsigned char *iptr;
+  size_t isize;
+  char *optr;
+  size_t osize;
+
+  switch (cmd)
+    {
+    case mu_filter_init:
+      *pd = hflt_initial;
+      return mu_filter_ok;
+      
+    case mu_filter_done:
+      return mu_filter_ok;
+      
+    default:
+      break;
+    }
+  
+  iptr = (const unsigned char *) iobuf->input;
+  isize = iobuf->isize;
+  optr = iobuf->output;
+  osize = iobuf->osize;
+
+  for (i = j = 0; i < isize && j < osize; i++)
+    {
+      unsigned char c = *iptr++;
+      if (new_state (pd, c))
+       {
+         iobuf->eof = 1;
+         break;
+       }
+      optr[j++] = c;
+    }
+
+  iobuf->isize = i;
+  iobuf->osize = j;
+  return mu_filter_ok;
+}
+  
+static int
+alloc_state (void **pret, int mode MU_ARG_UNUSED,
+            int argc MU_ARG_UNUSED, const char **argv MU_ARG_UNUSED)
+{
+  int *pd = malloc (sizeof (*pd));
+  
+  if (!pd)
+    return ENOMEM;
+  *pret = pd;
+  return 0;
+}
+
+static struct _mu_filter_record _header_filter = {
+  "HEADER",
+  0,
+  alloc_state,
+  NULL,
+  _hflt_decoder
+};
+
+mu_filter_record_t mu_header_filter = &_header_filter;
diff --git a/libmailutils/filter/inline-comment.c 
b/libmailutils/filter/inline-comment.c
index ec6d238..018e70f 100644
--- a/libmailutils/filter/inline-comment.c
+++ b/libmailutils/filter/inline-comment.c
@@ -36,22 +36,65 @@
 #include <string.h>
 #include <mailutils/errno.h>
 #include <mailutils/filter.h>
+#include <mailutils/cctype.h>
 
 enum ilcmt_state
   {
     ilcmt_initial,
     ilcmt_newline,
     ilcmt_copy,
-    ilcmt_comment
+    ilcmt_comment,
+    ilcmt_ws,
+    ilcmt_rollback
   };
 
+#define ILCMT_REMOVE_EMPTY_LINES 0x01
+#define ILCMT_SQUEEZE_WS         0x02
+
 struct ilcmt_data
 {
   enum ilcmt_state state;
   int cstart;
+  int flags;
+  char *buf;
+  size_t size;
+  size_t level;
+  size_t replay;
 };
 
+enum ilcmt_action
+  {
+    action_echo,
+    action_noecho,
+    action_error
+  };
+
+#define ILCMT_BUF_INIT 80
+#define ILCMT_BUF_INCR 16
+
 static int
+ilcmt_save (struct ilcmt_data *pd, int c)
+{
+  if (pd->level == pd->size)
+    {
+      size_t nsz;
+      char *np;
+      
+      if (pd->size == 0)
+       nsz = ILCMT_BUF_INIT;
+      else
+       nsz = pd->size + ILCMT_BUF_INCR;
+      np = realloc (pd->buf, nsz);
+      if (!np)
+       return 1;
+      pd->buf = np;
+      pd->size = nsz;
+    }
+  pd->buf[pd->level++] = c;
+  return 0;
+}
+
+static enum ilcmt_action
 new_ilcmt_state (struct ilcmt_data *pd, int c)
 {
   switch (pd->state)
@@ -61,11 +104,47 @@ new_ilcmt_state (struct ilcmt_data *pd, int c)
       if (c == pd->cstart)
        {
          pd->state = ilcmt_comment;
-         return 0;
+         return action_noecho;
        }
-      else
-       pd->state = ilcmt_copy;
+      else if (c == '\n')
+       {
+         if (pd->flags & ILCMT_REMOVE_EMPTY_LINES)
+           return action_noecho;
+       }
+      else if (mu_isspace (c))
+       {
+         if (pd->flags & ILCMT_REMOVE_EMPTY_LINES)
+           {
+             pd->state = ilcmt_ws;
+             pd->level = 0;
+             if (!(pd->flags & ILCMT_SQUEEZE_WS))
+               {
+                 if (ilcmt_save (pd, c))
+                   return action_error;
+               }
+             return action_noecho;
+           }
+       }
+      pd->state = ilcmt_copy;
       break;
+
+    case ilcmt_ws:
+      if (c == '\n')
+       pd->state = ilcmt_newline;
+      else if (mu_isspace (c))
+       {
+         if (!(pd->flags & ILCMT_SQUEEZE_WS))
+           {
+             if (ilcmt_save (pd, c))
+               return action_error;
+           }
+       }
+      else
+       {
+         pd->replay = 0;
+         pd->state = ilcmt_rollback;
+       }
+      return action_noecho;
       
     case ilcmt_copy:
       if (c == '\n')
@@ -75,9 +154,13 @@ new_ilcmt_state (struct ilcmt_data *pd, int c)
     case ilcmt_comment:
       if (c == '\n')
        pd->state = ilcmt_newline;
-      return 0;
+      return action_noecho;
+
+    default:
+      /* should not happen */
+      break;
     }
-  return 1;
+  return action_echo;
 }
 
 static enum mu_filter_result
@@ -109,11 +192,50 @@ _ilcmt_decoder (void *xd, enum mu_filter_command cmd,
   optr = iobuf->output;
   osize = iobuf->osize;
 
-  for (i = j = 0; i < isize && j < osize; i++)
+  i = j = 0;
+  if (pd->state == ilcmt_rollback)
+    {
+      if (pd->flags & ILCMT_SQUEEZE_WS)
+       {
+         if (j == osize)
+           {
+             iobuf->osize = 1;
+             return mu_filter_moreoutput;
+           }
+         optr[j++] = ' ';
+         pd->state = ilcmt_copy;
+       }
+      else
+       while (j < osize)
+         {
+           if (pd->replay == pd->level)
+             {
+               pd->state = ilcmt_copy;
+               break;
+             }
+           optr[j++] = pd->buf[pd->replay++];
+         }
+      
+      if (pd->state == ilcmt_copy)
+       {
+         /* Clear the buffer state. */
+         pd->level = pd->replay = 0;
+       }
+    }
+    
+  for (; i < isize && j < osize; i++)
     {
       unsigned char c = *iptr++;
-      if (new_ilcmt_state (pd, c))
+      enum ilcmt_action action = new_ilcmt_state (pd, c);
+      if (action == action_echo)
        optr[j++] = c;
+      else if (action == action_noecho)
+       {
+         if (pd->state == ilcmt_rollback)
+           break;
+       }
+      else
+       return mu_filter_failure;
     }
 
   iobuf->isize = i;
@@ -125,14 +247,39 @@ static int
 alloc_state (void **pret, int mode MU_ARG_UNUSED, int argc, const char **argv)
 {
   struct ilcmt_data *pd = malloc (sizeof (*pd));
+  int i;
   
   if (!pd)
     return ENOMEM;
 
-  if (argc == 2)
-    pd->cstart = argv[1][0];
-  else
-    pd->cstart = ';';
+  pd->cstart = ';';
+  pd->flags = 0;
+  pd->buf = NULL;
+  pd->size = pd->level = pd->replay = 0;
+
+  for (i = 1; i < argc; i++)
+    {
+      if (argv[i][1] == 0)
+       pd->cstart = argv[i][0];
+      else if (argv[i][0] == '-')
+       {
+         switch (argv[i][1])
+           {
+           case 'r':
+             pd->flags |= ILCMT_REMOVE_EMPTY_LINES;
+             break;
+
+           case 's':
+             pd->flags |= ILCMT_SQUEEZE_WS;
+             break;
+
+           default:
+             free (pd);
+             return MU_ERR_PARSE;
+           }
+       }
+    }
+
   *pret = pd;
   
   return 0;
diff --git a/libmailutils/property/mhprop.c b/libmailutils/property/mhprop.c
index 12b16e9..9aedd22 100644
--- a/libmailutils/property/mhprop.c
+++ b/libmailutils/property/mhprop.c
@@ -100,7 +100,7 @@ _mh_prop_read_stream (mu_header_t *phdr, mu_stream_t stream)
 {
   int rc;
   mu_stream_t flt;
-  const char *argv[3];
+  const char *argv[4];
   mu_off_t size;
   size_t total;
   char *blurb;
@@ -111,7 +111,8 @@ _mh_prop_read_stream (mu_header_t *phdr, mu_stream_t stream)
   
   argv[0] = "INLINE-COMMENT";
   argv[1] = "#";
-  argv[2] = NULL;
+  argv[2] = "-r";
+  argv[3] = NULL;
   rc = mu_filter_create_args (&flt, stream, argv[0], 2, argv,
                              MU_FILTER_DECODE, MU_STREAM_READ);
   if (rc)
diff --git a/libmailutils/stream/fltstream.c b/libmailutils/stream/fltstream.c
index ad4d0f1..ea08c81 100644
--- a/libmailutils/stream/fltstream.c
+++ b/libmailutils/stream/fltstream.c
@@ -60,7 +60,7 @@ filter_stream_init (struct _mu_filter_stream *fs)
     {
       struct mu_filter_io iobuf;
       memset (&iobuf, 0, sizeof (iobuf));
-      if (fs->xcode (fs->xdata, mu_filter_init, &iobuf) == mu_filter_falure)
+      if (fs->xcode (fs->xdata, mu_filter_init, &iobuf) == mu_filter_failure)
        return iobuf.errcode;
     }
   return 0;
@@ -182,7 +182,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, 
size_t *pret)
                }
              break;
          
-           case mu_filter_falure:
+           case mu_filter_failure:
              return iobuf.errcode;
              
            case mu_filter_moreinput:
@@ -288,7 +288,7 @@ filter_write_internal (mu_stream_t stream, enum 
mu_filter_command cmd,
            }
          break;
          
-       case mu_filter_falure:
+       case mu_filter_failure:
          return iobuf.errcode;
          
        case mu_filter_moreinput:
diff --git a/libmailutils/tests/Makefile.am b/libmailutils/tests/Makefile.am
index a3ae2aa..67b62fc 100644
--- a/libmailutils/tests/Makefile.am
+++ b/libmailutils/tests/Makefile.am
@@ -68,6 +68,8 @@ TESTSUITE_AT = \
  decode2047.at\
  encode2047.at\
  fromflt.at\
+ hdrflt.at\
+ inline-comment.at\
  list.at\
  mailcap.at\
  prop.at\
diff --git a/libmailutils/tests/fltst.c b/libmailutils/tests/fltst.c
index cc72f2d..a92f1ec 100644
--- a/libmailutils/tests/fltst.c
+++ b/libmailutils/tests/fltst.c
@@ -99,7 +99,7 @@ usage (const char *diag)
     fp = stdout;
 
   fprintf (fp, "%s",
-          "usage: fltst FILTER {encode|decode} {read|write} [shift=N] 
[linelen=N] [verbose] [printable] [nl]\n");
+          "usage: fltst FILTER {encode|decode} {read|write} [shift=N] 
[linelen=N] [verbose] [printable] [nl] [-- args]\n");
   exit (diag ? 1 : 0);
 }
 
@@ -152,9 +152,17 @@ main (int argc, char * argv [])
        printable++;
       else if (strcmp (argv[i], "nl") == 0)
        newline_option++;
+      else if (strcmp (argv[i], "--") == 0)
+       {
+         argv[i] = fltname;
+         break;
+       }
       else
        usage ("wrong option");
     }
+
+  argc -= i;
+  argv += i;
   
   MU_ASSERT (mu_stdio_stream_create (&in, MU_STDIN_FD, 0));
   MU_ASSERT (mu_stdio_stream_create (&out, MU_STDOUT_FD, 0));
@@ -164,17 +172,21 @@ main (int argc, char * argv [])
   
   if (flags == MU_STREAM_READ)
     {
-      MU_ASSERT (mu_filter_create (&flt, in, fltname, mode,
-                                  MU_STREAM_READ|MU_STREAM_SEEK|
-                                  MU_STREAM_AUTOCLOSE));
+      MU_ASSERT (mu_filter_create_args (&flt, in, fltname,
+                                       argc, (const char **)argv,
+                                       mode,
+                                       MU_STREAM_READ|MU_STREAM_SEEK|
+                                       MU_STREAM_AUTOCLOSE));
       if (shift)
        MU_ASSERT (mu_stream_seek (flt, shift, MU_SEEK_SET, NULL));
       c_copy (out, flt);
     }
   else
     {
-      MU_ASSERT (mu_filter_create (&flt, out, fltname, mode,
-                                  MU_STREAM_WRITE));
+      MU_ASSERT (mu_filter_create_args (&flt, out, fltname,
+                                       argc, (const char **)argv,
+                                       mode,
+                                       MU_STREAM_WRITE));
       if (shift)
        MU_ASSERT (mu_stream_seek (in, shift, MU_SEEK_SET, NULL));
       c_copy (flt, in);
diff --git a/mh/tests/mhl.at b/libmailutils/tests/hdrflt.at
similarity index 58%
copy from mh/tests/mhl.at
copy to libmailutils/tests/hdrflt.at
index c9c99da..aed3c96 100644
--- a/mh/tests/mhl.at
+++ b/libmailutils/tests/hdrflt.at
@@ -14,25 +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/>.
 
-m4_pushdef([MH_KEYWORDS],[mhl])
+AT_SETUP([header filter])
+AT_KEYWORDS([header-filter hdrflt])
 
-MH_CHECK([mhl],[mhl00],[
-MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
-mhl -form $abs_top_srcdir/mh/mhl.format Mail/inbox/2
-],
-[0],
-[ -- using template mhl.format --
-Date:    Mon, 29 Jul 2002 22:00:02 +0100
-To:      March Hare  <address@hidden>
+AT_DATA([input],
+[From: address@hidden
+To: address@hidden
+Subject: test
 
-From:    Alice  <address@hidden>
-Subject: Re: Invitation
+Mon beau pays par l'hiver soumis
+Quand reverrons-nous l'hirondelle
+Noire et blanche, noire et blanche
+Quand reverrons-nous l'hirondelle
+Blanche au ventre et noire aux ailes
+])
 
-X-Envelope-Date: Mon Jul 29 22:00:09 2002
-X-Envelope-Sender: address@hidden
+AT_DATA([expout],[dnl
+From: address@hidden
+To: address@hidden
+Subject: test
+])
 
-I don't see any wine
-]) 
 
-m4_popdef[MH_KEYWORDS])
-# End of mhl.at
+AT_CHECK([fltst header decode read < input],[0],[expout])
+AT_CHECK([fltst header decode write < input],[0],[expout])
+
+AT_CLEANUP
\ No newline at end of file
diff --git a/libmailutils/tests/inline-comment.at 
b/libmailutils/tests/inline-comment.at
new file mode 100644
index 0000000..bfaf492
--- /dev/null
+++ b/libmailutils/tests/inline-comment.at
@@ -0,0 +1,113 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2010 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 -------------------------------------------------------------------
+dnl INLINECOM(NAME, [KW = `'], [OPTS = `'], [TEXT], [OUTPUT = `'])
+dnl -------------------------------------------------------------------
+m4_pushdef([INLINECOM],[
+AT_SETUP([inline-comment: $1])
+AT_KEYWORDS([filter inline-comment icmt $2])
+sed 's/\$.*//' > input <<EOT
+$4
+EOT
+sed 's/\$.*//' > expout <<EOT
+$5
+EOT
+
+AT_CHECK([fltst inline-comment decode read $3 < input],
+[0],
+[expout])
+AT_CHECK([fltst inline-comment decode write $3 < input],
+[0],
+[expout])
+AT_CLEANUP
+])
+
+dnl -------------------------------------------------------------------
+
+INLINECOM([default], [icmt00], [],
+[; comment 1
+text 1
+; comment 2
+text 2
+
+text 3
+; comment 3
+],
+[text 1
+text 2
+
+text 3
+])
+
+INLINECOM([change comment starter], [icmt02], [-- %],
+[% comment 1
+text 1
+% comment 2
+text 2
+
+text 3
+% comment 3
+],
+[text 1
+text 2
+
+text 3
+])
+
+INLINECOM([remove empty lines],[icmt03],[-- -r],
+[; comment 1
+text 1
+; comment 2
+; comment 3
+text 2
+
+       text 3
+
+       $
+text 4
+     text 5
+],
+[text 1
+text 2
+       text 3
+text 4
+     text 5[]dnl
+])     
+
+INLINECOM([remove empty lines/squeeze whitespace],[icmt04],[-- -r -s],
+[; comment 1
+text 1
+; comment 2
+; comment 3
+text 2
+
+       text 3
+
+       $
+text 4
+     text 5
+],
+[text 1
+text 2
+ text 3
+text 4
+ text 5[]dnl
+])     
+
+
+m4_popdef([INLINECOM])
+# End of inline-comment.at
diff --git a/libmailutils/tests/testsuite.at b/libmailutils/tests/testsuite.at
index 43806c7..722e839 100644
--- a/libmailutils/tests/testsuite.at
+++ b/libmailutils/tests/testsuite.at
@@ -66,4 +66,6 @@ m4_include([encode2047.at])
 m4_include([fromflt.at])
 m4_include([wicket.at])
 m4_include([prop.at])
+m4_include([inline-comment.at])
+m4_include([hdrflt.at])
 
diff --git a/libmu_auth/gsasl.c b/libmu_auth/gsasl.c
index 10b14bf..0ff7e5d 100644
--- a/libmu_auth/gsasl.c
+++ b/libmu_auth/gsasl.c
@@ -82,7 +82,7 @@ _gsasl_encoder (void *xdata,
       if (status)
        {
          flt->gsasl_err = status;
-         return mu_filter_falure;
+         return mu_filter_failure;
        }
     }
     
@@ -141,7 +141,7 @@ _gsasl_decoder (void *xdata,
          
        default:
          flt->gsasl_err = status;
-         return mu_filter_falure;
+         return mu_filter_failure;
        }
     }
 
diff --git a/mh/Makefile.am b/mh/Makefile.am
index 5ddf5fd..07bc60c 100644
--- a/mh/Makefile.am
+++ b/mh/Makefile.am
@@ -68,7 +68,6 @@ libmh_a_SOURCES= \
  mh_alias_gram.c\
  mh_alias_lex.c\
  mh_argp.c\
- mh_ctx.c\
  mh_getopt.c\
  mh_global.c\
  mh_format.c\
diff --git a/mh/folder.c b/mh/folder.c
index 0df51c3..d38bc4b 100644
--- a/mh/folder.c
+++ b/mh/folder.c
@@ -272,18 +272,15 @@ static void
 read_seq_file (struct folder_info *info, const char *prefix, const char *name)
 {
   char *pname = NULL;
-  mh_context_t *ctx;
+  mu_property_t prop;
   const char *p;
   
   pname = mh_safe_make_file_name (prefix, name);
-  ctx = mh_context_create (pname, 1);
-  mh_context_read (ctx);
+  prop = mh_read_property_file (pname, 1);
   
-  p = mh_context_get_value (ctx, "cur", NULL);
-  if (p)
+  if (mu_property_sget_value (prop, "cur", &p) == 0)
     info->cur = strtoul (p, NULL, 0);
-  free (pname);
-  free (ctx);
+  mu_property_destroy (&prop);
 }
 
 static void
diff --git a/mh/mh.h b/mh/mh.h
index b9b89ef..b2873f3 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -56,6 +56,7 @@
 #include <mailutils/mime.h>
 #include <mailutils/io.h>
 #include <mailutils/property.h>
+#include <mailutils/mh.h>
 
 #include <mu_umaxtostr.h>
 
@@ -228,9 +229,6 @@ struct mh_whatnow_env     /* whatnow shell environment */
 #define DISP_USE 1
 #define DISP_REPLACE 2
 
-typedef int (*mh_context_iterator) (const char *field, const char *value,
-                                   void *data);
-
 #define SEQ_PRIVATE 1
 #define SEQ_ZERO    2
 
@@ -246,10 +244,23 @@ mu_message_t mh_file_to_message (const char *folder, 
const char *file_name);
 mu_message_t mh_stream_to_message (mu_stream_t stream);
 void mh_install (char *name, int automode);
 
-const char *mh_global_profile_get (const char *name, const char *defval);
-int mh_global_profile_set (const char *name, const char *value);
-const char *mh_global_context_get (const char *name, const char *defval);
-int mh_global_context_set (const char *name, const char *value);
+mu_property_t mh_read_property_file (char *name, int ro);
+void mh_property_merge (mu_property_t dst, mu_property_t src);
+
+#define mh_global_profile_get(name, defval) \
+  mu_mhprop_get_value (mu_mh_profile, name, defval)
+#define mh_global_profile_set(name, value) \
+  mu_property_set_value (mu_mh_profile, name, value, 1))
+#define mh_global_profile_iterate(fp, data) \
+  mu_mhprop_iterate (mu_mh_profile, fp, data)
+
+#define mh_global_context_get(name, defval) \
+  mu_mhprop_get_value (mu_mh_context, name, defval)
+#define mh_global_context_set(name, value) \
+  mu_property_set_value (mu_mh_context, name, value, 1)
+#define mh_global_context_iterate(fp, data) \
+  mu_mhprop_iterate (mu_mh_context, fp, data)
+
 const char *mh_set_current_folder (const char *val);
 const char *mh_current_folder (void);
 
@@ -259,12 +270,10 @@ const char *mh_global_sequences_get (mu_mailbox_t mbox,
 void mh_global_sequences_set (mu_mailbox_t mbox,
                              const char *name, const char *value);
 void mh_global_sequences_iterate (mu_mailbox_t mbox,
-                                 mh_context_iterator fp, void *data);
+                                 mu_mhprop_iterator_t fp, void *data);
 void mh_global_sequences_drop (mu_mailbox_t mbox);
 
 void mh_global_save_state (void);
-int mh_global_profile_iterate (mh_context_iterator fp, void *data);
-int mh_global_context_iterate (mh_context_iterator fp, void *data);
 
 int mh_interactive_mode_p (void);
 int mh_getyn (const char *fmt, ...) MU_PRINTFLIKE(1,2);
@@ -287,17 +296,6 @@ void mh_err_memory (int fatal);
 FILE *mh_audit_open (char *name, mu_mailbox_t mbox);
 void mh_audit_close (FILE *fp);
 
-mh_context_t *mh_context_create (const char *name, int copy);
-int mh_context_read (mh_context_t *ctx);
-int mh_context_write (mh_context_t *ctx);
-const char *mh_context_get_value (mh_context_t *ctx, const char *name,
-                                 const char *defval);
-int mh_context_set_value (mh_context_t *ctx, const char *name,
-                         const char *value);
-int mh_context_iterate (mh_context_t *ctx, mh_context_iterator fp, void *data);
-void mh_context_destroy (mh_context_t **pctx);
-void mh_context_merge (mh_context_t *dst, mh_context_t *src);
-
 int mh_message_number (mu_message_t msg, size_t *pnum);
 
 mu_mailbox_t mh_open_folder (const char *folder, int create);
diff --git a/mh/mh_ctx.c b/mh/mh_ctx.c
deleted file mode 100644
index ca497f2..0000000
--- a/mh/mh_ctx.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2009,
-   2010 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/>. */
-
-/* MH context functions. */
-  
-#include <mh.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-mh_context_t *
-mh_context_create (const char *name, int copy)
-{
-  mh_context_t *ctx;
-  ctx = malloc (sizeof (*ctx));
-  if (!ctx)
-    mh_err_memory (1);
-  if (copy)
-    ctx->name = name;
-  else
-    {
-      ctx->name = strdup (name);
-      if (!ctx->name)
-        mh_err_memory (1);
-    }
-  ctx->header = NULL;
-  return ctx;
-}
-
-void
-mh_context_destroy (mh_context_t **pctx)
-{
-  mh_context_t *ctx = *pctx;
-  
-  free ((char*) ctx->name);
-  if (ctx->header)
-    mu_header_destroy (&ctx->header);
-  free (ctx);
-  *pctx = NULL;
-}
-
-void
-mh_context_merge (mh_context_t *dst, mh_context_t *src)
-{
-  if (!dst->header)
-    {
-      dst->header = src->header;
-      src->header = NULL;
-    }
-  else
-    {
-      size_t i, count;
-      
-      mu_header_get_field_count (src->header, &count);
-      for (i = 1; i <= count; i++)
-       {
-         const char *name = NULL;
-         const char *value = NULL;
-         
-         mu_header_sget_field_name (src->header, i, &name);
-         mu_header_sget_field_value (src->header, i, &value);
-         mu_header_set_value (dst->header, name, value, 1);
-       }
-    }
-}
-
-int 
-mh_context_read (mh_context_t *ctx)
-{
-  int rc;
-  char *blurb, *p;
-  mu_stream_t stream;
-  mu_off_t stream_size;
-  char *buf = NULL;
-  size_t size = 0, n;
-  
-  if (!ctx)
-    return MU_ERR_OUT_NULL;
-  
-  rc = mu_file_stream_create (&stream, ctx->name, MU_STREAM_READ);
-  if (rc)
-    return rc;
-
-  rc = mu_stream_size (stream, &stream_size);
-  if (rc)
-    {
-      mu_stream_destroy (&stream);
-      return rc;
-    }
-
-  blurb = malloc (stream_size + 1);
-  if (!blurb)
-    {
-      mu_stream_destroy (&stream);
-      return ENOMEM;
-    }
-  
-  p = blurb;
-  while (mu_stream_getline (stream, &buf, &size, &n) == 0 && n > 0)
-    {
-      char *q = mu_str_skip_class (buf, MU_CTYPE_SPACE);
-      if (!*q || *q == '#')
-       continue;
-      for (q = buf; *q;)
-       *p++ = *q++;
-    }
-  mu_stream_destroy (&stream);
-  rc = mu_header_create (&ctx->header, blurb, p - blurb);
-  free (blurb);
-
-  return rc;
-}
-
-int 
-mh_context_write (mh_context_t *ctx)
-{
-  int rc;
-  mu_stream_t instream, outstream;
-  mu_off_t size;
-  
-  if (!ctx)
-    return MU_ERR_OUT_NULL;
-
-  rc = mu_file_stream_create (&outstream, ctx->name,
-                             MU_STREAM_WRITE|MU_STREAM_CREAT);
-  if (rc)
-    {
-      mu_error (_("cannot open context file %s for writing: %s"),
-               ctx->name, mu_strerror (rc));
-      return MU_ERR_FAILURE;
-    }
-  
-  mu_header_get_streamref (ctx->header, &instream);
-  rc = mu_stream_copy (outstream, instream, 0, &size);
-  if (rc)
-    {
-      mu_error (_("error writing to context file %s: %s"),
-               ctx->name, mu_strerror (rc));
-      return MU_ERR_FAILURE;
-    }
-  else
-    rc = mu_stream_truncate (outstream, size);
-  mu_stream_destroy (&instream);
-  mu_stream_destroy (&outstream);
-  return 0;
-}
-
-const char *
-mh_context_get_value (mh_context_t *ctx, const char *name, const char *defval)
-{
-  const char *p;
-
-  if (!ctx || mu_header_sget_value (ctx->header, name, &p))
-    p = defval; 
-  return p;
-}
-
-int
-mh_context_set_value (mh_context_t *ctx, const char *name, const char *value)
-{
-  if (!ctx)
-    return EINVAL;
-  if (!ctx->header)
-    {
-      int rc;
-      if ((rc = mu_header_create (&ctx->header, NULL, 0)) != 0)
-       {
-         mu_error (_("cannot create context %s: %s"),
-                   ctx->name,
-                   mu_strerror (rc));
-         return 1;
-       }
-    }
-  return mu_header_set_value (ctx->header, name, value, 1);
-}
-
-int
-mh_context_iterate (mh_context_t *ctx, mh_context_iterator fp, void *data)
-{
-  size_t i, nfields;
-  int rc = 0;
-  
-  if (!ctx)
-    return EINVAL;
-  if (!ctx->header)
-    return 0;
-  rc = mu_header_get_field_count (ctx->header, &nfields);
-  if (rc)
-    {
-      mu_error (_("cannot obtain field count for context %s"), ctx->name);
-      return rc;
-    }
-  
-  for (i = 1; i <= nfields && rc == 0; i++)
-    {
-      const char *name, *value;
-      
-      rc = mu_header_sget_field_name (ctx->header, i, &name);
-      if (rc)
-       {
-         mu_error (_("cannot obtain field name for context %s:%d: %s"),
-                   ctx->name,i,mu_strerror (rc));
-         break;
-       }
-      
-      rc = mu_header_sget_field_value (ctx->header, i, &value);
-      if (rc)
-       {
-         mu_error (_("cannot obtain field value for context %s:%d: %s"),
-                   ctx->name,i,mu_strerror (rc));
-         break;
-       }
-      
-      rc = fp (name, value, data);
-    }
-
-  return rc;
-}
diff --git a/mh/mh_global.c b/mh/mh_global.c
index 2294477..7de44b8 100644
--- a/mh/mh_global.c
+++ b/mh/mh_global.c
@@ -20,29 +20,70 @@
 #include <mh.h>
 
 static const char *current_folder = NULL;
-mh_context_t *context;
-mh_context_t *profile;
 int rcpt_mask = RCPT_DEFAULT;
 int mh_auto_install = 1;
 
-/* Global profile */
+mu_property_t
+mh_read_property_file (char *name, int ro)
+{
+  mu_property_t prop;
+  struct mu_mh_prop *mhprop;
+  int rc;
+  
+  mhprop = xzalloc (sizeof (mhprop[0]));
+  mhprop->filename = name;
+  mhprop->ro = ro;
+  rc = mu_property_create_init (&prop, mu_mh_property_init, mhprop);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_property_create_init", name, rc);
+      exit (1);
+    }
+  return prop;
+}
 
-const char *
-mh_global_profile_get (const char *name, const char *defval)
+static int
+prop_merger (const char *field, const char *value, void *data)
 {
-  return mh_context_get_value (profile, name, defval);
+  mu_property_t dst;
+  return mu_property_set_value (dst, field, value, 1);
 }
 
-int
-mh_global_profile_set (const char *name, const char *value)
+void
+mh_property_merge (mu_property_t dst, mu_property_t src)
 {
-  return mh_context_set_value (profile, name, value);
+  int rc;
+  
+  if (!src)
+    return;
+  rc = mu_mhprop_iterate (src, prop_merger, dst);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_mhprop_iterate", NULL, rc);
+      exit (1);
+    }
 }
+  
+/* Global profile */
 
-int
-mh_global_profile_iterate (mh_context_iterator fp, void *data)
+void
+_mh_init_global_context ()
 {
-  return mh_context_iterate (profile, fp, data);
+  char *p, *ctx_name;
+  
+  if (mu_mh_context)
+    return;
+  p = getenv ("CONTEXT");
+  if (!p)
+    p = MH_CONTEXT_FILE;
+  ctx_name = mh_expand_name (NULL, p, 0);
+
+  mu_mh_context = mh_read_property_file (ctx_name, 0);
+  
+  if (!current_folder)
+    current_folder = mh_global_context_get ("Current-Folder",
+                                           mh_global_profile_get ("Inbox",
+                                                                  "inbox"));
 }
 
 void
@@ -66,8 +107,7 @@ mh_read_profile ()
   if (mh_auto_install && access (p, R_OK))
     mh_install (p, 1);
 
-  profile = mh_context_create (p, 1);
-  mh_context_read (profile);
+  mu_mh_profile = mh_read_property_file (p, 0);
 
   mu_set_folder_directory (mh_get_dir ());
 
@@ -75,55 +115,15 @@ mh_read_profile ()
   fallback = mh_global_profile_get ("Decode-Fallback", NULL);
   if (fallback && mu_set_default_fallback (fallback))
     mu_error (_("Incorrect value for decode-fallback"));
-}
-
-/* Global context */
 
-void
-_mh_init_global_context ()
-{
-  char *p, *ctx_name;
-  
-  if (context)
-    return;
-  p = getenv ("CONTEXT");
-  if (!p)
-    p = MH_CONTEXT_FILE;
-  ctx_name = mh_expand_name (NULL, p, 0);
-  context = mh_context_create (ctx_name, 1);
-  mh_context_read (context);
-  
-  if (!current_folder)
-    current_folder = mh_context_get_value (context, "Current-Folder",
-                                          mh_global_profile_get ("Inbox",
-                                                                 "inbox"));
-}
-
-const char *
-mh_global_context_get (const char *name, const char *defval)
-{
-  _mh_init_global_context ();
-  return mh_context_get_value (context, name, defval);
-}
-
-int
-mh_global_context_set (const char *name, const char *value)
-{
   _mh_init_global_context ();
-  return mh_context_set_value (context, name, value);
 }
 
-int
-mh_global_context_iterate (mh_context_iterator fp, void *data)
-{
-  _mh_init_global_context ();
-  return mh_context_iterate (context, fp, data);
-}
+/* Global context */
 
 const char *
 mh_current_folder ()
 {
-  _mh_init_global_context ();
   return mh_global_context_get ("Current-Folder",
                                mh_global_profile_get ("Inbox", "inbox"));
 }
@@ -131,7 +131,13 @@ mh_current_folder ()
 const char *
 mh_set_current_folder (const char *val)
 {
-  mh_global_context_set ("Current-Folder", val);
+  int rc = mh_global_context_set ("Current-Folder", val);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mh_global_context_set",
+                      "Current-Folder", rc);
+      exit (1);
+    }
   current_folder = mh_current_folder ();
   return current_folder;
 }
@@ -192,10 +198,9 @@ mh_global_sequences_set (mu_mailbox_t mbox, const char 
*name,
     }
 }
 
-/* FIXME: Rewrite using mu_mhprop_iterate */
 void
 mh_global_sequences_iterate (mu_mailbox_t mbox,
-                            mh_context_iterator fp, void *data)
+                             mu_mhprop_iterator_t fp, void *data)
 {
   int rc;
   mu_iterator_t itr;
@@ -207,16 +212,7 @@ mh_global_sequences_iterate (mu_mailbox_t mbox,
       mu_diag_funcall (MU_DIAG_ERROR, "mu_property_get_iterator", NULL, rc);
       exit (1);
     }
-  for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
-       mu_iterator_next (itr))
-    {
-      const char *name, *val;
-      
-      mu_iterator_current_kv (itr, (const void **)&name, (void**)&val);
-      if (fp (name, val, data))
-       break;
-    }
-  mu_iterator_destroy (&itr);
+  mu_mhprop_iterate (prop, fp, data);
 }
 
 /* Global state */
@@ -224,6 +220,15 @@ mh_global_sequences_iterate (mu_mailbox_t mbox,
 void
 mh_global_save_state ()
 {
-  mh_context_set_value (context, "Current-Folder", current_folder);
-  mh_context_write (context);
+  int rc;
+  
+  mh_global_context_set ("Current-Folder", current_folder);
+  rc = mu_property_save (mu_mh_context);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_profile_save", "context", rc);
+      exit (1);
+    }
 }
+
+
diff --git a/mh/mh_whom.c b/mh/mh_whom.c
index 4b70b25..8523a16 100644
--- a/mh/mh_whom.c
+++ b/mh/mh_whom.c
@@ -197,31 +197,101 @@ _print_local_recipient (void *item, void *data)
   (*count)++;
   return 0;
 }
-                 
+
+static mu_header_t
+read_header (mu_stream_t stream)
+{
+  int rc;
+  mu_stream_t flt;
+  mu_off_t size;
+  size_t total;
+  char *blurb;
+  mu_header_t hdr;
+  
+  rc = mu_stream_size (stream, &size);
+  if (rc)
+    {
+      mu_error (_("cannot get stream size: %s"), mu_strerror (rc));
+      exit (1);
+    }
+  
+  rc = mu_filter_create (&flt, stream, "HEADER",
+                        MU_FILTER_DECODE, MU_STREAM_READ);
+  if (rc)
+    {
+      mu_error (_("cannot open filter stream: %s"), mu_strerror (rc));
+      exit (1);
+    }
+
+  blurb = xmalloc (size + 1);
+
+  total = 0;
+  while (1)
+    {
+      size_t n;
+      
+      rc = mu_stream_read (flt, blurb + total, size - total, &n);
+      if (rc)
+       break;
+      if (n == 0)
+       break;
+      total += n;
+    }
+
+  mu_stream_destroy (&flt);
+  if (rc)
+    {
+      free (blurb);
+      mu_error (_("read error: %s"), mu_strerror (rc));
+      exit (1);
+    }
+
+  rc = mu_header_create (&hdr, blurb, total);
+  free (blurb);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_header_create", NULL, rc);
+      exit (1);
+    }
+  return hdr;
+}
+
 int
 mh_whom (const char *filename, int check)
 {
   int rc = 0;
-  mh_context_t *ctx;
 
-  mh_read_aliases ();
-  ctx = mh_context_create (filename, 1);
-  if ((rc = mh_context_read (ctx)))
+  if (access (filename, R_OK))
     {
-      if (rc == ENOENT)
-       mu_error ("%s: %s", filename, mu_strerror (rc));
-      else
-       mu_error ("%s: %s (%s)", filename, _("malformed message"),
-                 mu_strerror (rc));
+      mu_error ("%s: %s", filename, mu_strerror (errno));
       rc = -1;
     }
   else
     {
       size_t count = 0;
-      
-      scan_addrs (mh_context_get_value (ctx, MU_HEADER_TO, NULL), 0);
-      scan_addrs (mh_context_get_value (ctx, MU_HEADER_CC, NULL), 0);
-      scan_addrs (mh_context_get_value (ctx, MU_HEADER_BCC, NULL), 1);
+      mu_header_t hdr;
+      mu_stream_t str;
+      int rc;
+      const char *val;
+
+      rc = mu_file_stream_create (&str, filename, MU_STREAM_READ);
+      if (rc)
+       {
+         mu_diag_funcall (MU_DIAG_ERROR, "mu_file_stream_create",
+                          filename, rc);
+         exit (1);
+       }
+      hdr = read_header (str);
+      mu_stream_unref (str);
+
+      mh_read_aliases ();
+
+      if (mu_header_sget_value (hdr, MU_HEADER_TO, &val) == 0)
+       scan_addrs (val, 0);
+      if (mu_header_sget_value (hdr, MU_HEADER_CC, &val) == 0)
+       scan_addrs (val, 0);
+      if (mu_header_sget_value (hdr, MU_HEADER_BCC, &val) == 0)
+       scan_addrs (val, 1);
 
       if (local_rcp)
        {
@@ -240,8 +310,8 @@ mh_whom (const char *filename, int check)
          mu_error(_("no recipients"));
          rc = -1;
        }
+      mu_header_destroy (&hdr);
     }
-  free (ctx);
   destroy_addrs (&network_rcp);
   destroy_addrs (&local_rcp);
   return rc;
diff --git a/mh/send.c b/mh/send.c
index d717bb9..f4b799f 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -283,7 +283,7 @@ struct list_elt           /* Element of the send list */
 };
 
 static mu_list_t mesg_list;
-static mh_context_t *mts_profile;
+static mu_property_t mts_profile;
 
 int
 check_file (char *name)
@@ -313,36 +313,42 @@ check_file (char *name)
 void
 read_mts_profile ()
 {
+  char *name;
   const char *p;
   char *hostname = NULL;
   int rc;
-  mh_context_t *local_profile;
+  mu_property_t local_profile;
 
-  p = mh_expand_name (MHLIBDIR, "mtstailor", 0);
-  mts_profile = mh_context_create (p, 1);
-  mh_context_read (mts_profile);
+  name = mh_expand_name (MHLIBDIR, "mtstailor", 0);
+  mts_profile = mh_read_property_file (name, 1);
 
-  p = mu_tilde_expansion ("~/.mtstailor", "/", NULL);
-  local_profile = mh_context_create (p, 1);
-  if (mh_context_read (local_profile) == 0)
-    mh_context_merge (mts_profile, local_profile);
-  mh_context_destroy (&local_profile);
+  name = mu_tilde_expansion ("~/.mtstailor", "/", NULL);
+  local_profile = mh_read_property_file (name, 1);
 
-  if ((p = mh_context_get_value (mts_profile, "localname", NULL)))
+  mh_property_merge (mts_profile, local_profile);
+  mu_property_destroy (&local_profile);
+
+  rc = mu_property_aget_value (mts_profile, "localname", &hostname);
+  if (rc == MU_ERR_NOENT)
+    {
+      rc = mu_get_host_name (&hostname);
+      if (rc)
+       {
+         mu_error (_("cannot get system host name: %s"), mu_strerror (rc));
+         exit (1);
+       }
+    }
+  else
     {
-      hostname = xstrdup (p);
-      mu_set_user_email_domain (p);
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_profile_aget_value", "localname", 
rc);
+      exit (1);
     }
-  else if ((rc = mu_get_host_name (&hostname)))
-    mu_error (_("cannot get system host name: %s"), mu_strerror (rc));
 
-  if ((p = mh_context_get_value (mts_profile, "localdomain", NULL)))
+  rc = mu_property_sget_value (mts_profile, "localdomain", &p);
+  if (rc == 0)
     {
       char *newdomain;
 
-      if (!hostname)
-       exit (1);
-      
       newdomain = xmalloc (strlen (hostname) + 1 + strlen (p) + 1);
       strcpy (newdomain, hostname);
       strcat (newdomain, ".");
@@ -355,8 +361,15 @@ read_mts_profile ()
          exit (1);
        }
     }
-
-  if ((p = mh_context_get_value (mts_profile, "username", NULL)))
+  else if (rc != MU_ERR_NOENT)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_profile_sget_value",
+                      "localdomain", rc);
+      exit (1);
+    }
+  
+  rc = mu_property_sget_value (mts_profile, "username", &p);
+  if (rc == 0)
     {
       size_t len;
       const char *domain;
@@ -385,15 +398,21 @@ read_mts_profile ()
       
       free (newemail);
     }
+  else if (rc != MU_ERR_NOENT)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_profile_sget_value",
+                      "username", rc);
+      exit (1);
+    }
 }
 
 
 mu_mailer_t
 open_mailer ()
 {
-  const char *url = mh_context_get_value (mts_profile,
-                                         "url",
-                                         "sendmail:/usr/sbin/sendmail");
+  const char *url = mu_mhprop_get_value (mts_profile,
+                                        "url",
+                                        "sendmail:/usr/sbin/sendmail");
   mu_mailer_t mailer;
   int status;
     
@@ -667,8 +686,8 @@ _action_send (void *item, void *data)
 
       if (mu_header_get_value (hdr, MU_HEADER_X_MAILER, NULL, 0, &n))
        {
-         const char *p = mh_context_get_value (mts_profile,
-                                               "x-mailer", "yes");
+         const char *p = mu_mhprop_get_value (mts_profile,
+                                              "x-mailer", "yes");
 
          if (!strcmp (p, "yes"))
            mu_header_set_value (hdr, MU_HEADER_X_MAILER,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 001f754..d1ecf45 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -165,6 +165,7 @@ mh/forw.c
 mh/inc.c
 mh/install-mh.c
 mh/mark.c
+mh/mboxprop.c
 mh/mh_argp.c
 mh/mh_ctx.c
 mh/mh_fmtgram.y


hooks/post-receive
-- 
GNU Mailutils



reply via email to

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