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-359-g5acfb2a


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-359-g5acfb2a
Date: Wed, 23 Mar 2011 07:59:42 +0000

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

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

The branch, master has been updated
       via  5acfb2a37b1bb49474d3bbb0137f22604b508310 (commit)
      from  dd33613b562970a194917f1934aeab56e3cfc4f9 (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 5acfb2a37b1bb49474d3bbb0137f22604b508310
Author: Sergey Poznyakoff <address@hidden>
Date:   Tue Mar 22 17:27:00 2011 +0200

    New filter "c-escape".
    
    * libmailutils/filter/c-escape.c: New file.
    * include/mailutils/filter.h (mu_c_escape_filter): New extern.
    * libmailutils/filter/Makefile.am (libfilter_la_SOURCES): Add c-escape.c
    * libmailutils/filter/filter.c (mu_filter_get_list): Add
    mu_c_escape_filter to the list.

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

Summary of changes:
 include/mailutils/filter.h                    |    1 +
 libmailutils/filter/Makefile.am               |    1 +
 libmailutils/filter/{crlfflt.c => c-escape.c} |  144 ++++++++++--------------
 libmailutils/filter/filter.c                  |    1 +
 mh/etc/components                             |    6 +-
 5 files changed, 66 insertions(+), 87 deletions(-)
 copy libmailutils/filter/{crlfflt.c => c-escape.c} (50%)

diff --git a/include/mailutils/filter.h b/include/mailutils/filter.h
index 09d2b92..d723066 100644
--- a/include/mailutils/filter.h
+++ b/include/mailutils/filter.h
@@ -123,6 +123,7 @@ extern mu_filter_record_t mu_header_filter;
 extern mu_filter_record_t mu_linecon_filter;
 extern mu_filter_record_t mu_linelen_filter;
 extern mu_filter_record_t mu_iconv_filter;
+extern mu_filter_record_t mu_c_escape_filter;
   
 enum mu_iconv_fallback_mode
   {
diff --git a/libmailutils/filter/Makefile.am b/libmailutils/filter/Makefile.am
index 0788a5c..5208b7c 100644
--- a/libmailutils/filter/Makefile.am
+++ b/libmailutils/filter/Makefile.am
@@ -20,6 +20,7 @@ noinst_LTLIBRARIES = libfilter.la
 libfilter_la_SOURCES =\
  base64.c\
  binflt.c\
+ c-escape.c\
  crlfdot.c\
  crlfflt.c\
  decode.c\
diff --git a/libmailutils/filter/crlfflt.c b/libmailutils/filter/c-escape.c
similarity index 50%
copy from libmailutils/filter/crlfflt.c
copy to libmailutils/filter/c-escape.c
index 96291b8..52ea48c 100644
--- a/libmailutils/filter/crlfflt.c
+++ b/libmailutils/filter/c-escape.c
@@ -1,19 +1,31 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011 Free Software Foundation, Inc.
 
-   This library is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 3, or (at your option)
-   any later version.
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
 
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
-
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library.  If not, see 
+   <http://www.gnu.org/licenses/>. */
+
+/* A C-escape filter.
+   In encode mode, replaces control characters with their C escapes.
+   For example, newline (ASCII 10) becomes \n, horizontal tab (ASCII 9)
+   becomes \t etc.
+   In decode mode, the reverse operation is performed, i.e. each C escape
+   is replaced with the corresponding character.  Unrecognized escape
+   sequences are copied verbatim.
+
+   FIXME: Only named escapes are supported.
+*/
+   
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
@@ -21,31 +33,25 @@
 #include <string.h>
 #include <mailutils/errno.h>
 #include <mailutils/filter.h>
+#include <mailutils/wordsplit.h>
+#include <mailutils/cctype.h>
 
-enum crlf_state
-{
-  state_init,
-  state_cr
-};
-  
-/* Move min(isize,osize) bytes from iptr to optr, replacing each \n
-   with \r\n.  Any input \r\n sequences remain untouched. */
+/* Move min(isize,osize) bytes from iptr to optr, replacing each
+   escapable control character with its escape sequence. */
 static enum mu_filter_result
-_crlf_encoder (void *xd,
-              enum mu_filter_command cmd,
-              struct mu_filter_io *iobuf)
+_c_escape_encoder (void *xd MU_ARG_UNUSED,
+                  enum mu_filter_command cmd,
+                  struct mu_filter_io *iobuf)
 {
   size_t i, j;
   const unsigned char *iptr;
   size_t isize;
   char *optr;
   size_t osize;
-  enum crlf_state *state = xd;
   
   switch (cmd)
     {
     case mu_filter_init:
-      *state = state_init;
     case mu_filter_done:
       return mu_filter_ok;
     default:
@@ -60,13 +66,14 @@ _crlf_encoder (void *xd,
   for (i = j = 0; i < isize && j < osize; i++)
     {
       unsigned char c = *iptr++;
-      if (c == '\n')
+
+      if (mu_iscntrl (c))
        {
-         if (*state == state_cr)
-           {
-             *state = state_init;
-             optr[j++] = c;
-           }
+         int x;
+
+         x = mu_wordsplit_c_quote_char (c);
+         if (x == -1)
+           optr[j++] = c;
          else if (j + 1 == osize)
            {
              if (i == 0)
@@ -78,15 +85,10 @@ _crlf_encoder (void *xd,
            }
          else
            {
-             optr[j++] = '\r';
-             optr[j++] = '\n';
+             optr[j++] = '\\';
+             optr[j++] = x;
            }
        }
-      else if (c == '\r')
-       {
-         *state = state_cr;
-         optr[j++] = c;
-       }
       else
        optr[j++] = c;
     }
@@ -95,19 +97,19 @@ _crlf_encoder (void *xd,
   return mu_filter_ok;
 }
 
-/* Move min(isize,osize) bytes from iptr to optr, replacing each \r\n
-   with \n. */
+/* Move min(isize,osize) bytes from iptr to optr, replacing each escape
+   sequence with its ASCII code. */
 static enum mu_filter_result
-_crlf_decoder (void *xd MU_ARG_UNUSED,
-              enum mu_filter_command cmd,
-              struct mu_filter_io *iobuf)
+_c_escape_decoder (void *xd MU_ARG_UNUSED,
+                  enum mu_filter_command cmd,
+                  struct mu_filter_io *iobuf)
 {
   size_t i, j;
   const unsigned char *iptr;
   size_t isize;
   char *optr;
   size_t osize;
-
+  
   switch (cmd)
     {
     case mu_filter_init:
@@ -125,57 +127,31 @@ _crlf_decoder (void *xd MU_ARG_UNUSED,
   for (i = j = 0; i < isize && j < osize; i++)
     {
       unsigned char c = *iptr++;
-      if (c == '\r')
+      if (c == '\\')
        {
+         int x;
          if (i + 1 == isize)
            break;
-         if (*iptr == '\n')
-           continue;
+         c = *iptr++;
+         i++;
+         x = mu_wordsplit_c_unquote_char (c);
+         optr[j++] = (x == -1) ? c : x;
        }
-      optr[j++] = c;
+      else
+       optr[j++] = c;
     }
+
   iobuf->isize = i;
   iobuf->osize = j;
   return mu_filter_ok;
 }
 
-static int
-alloc_state (void **pret, int mode,
-            int argc MU_ARG_UNUSED, const char **argv MU_ARG_UNUSED)
-{
-  switch (mode)
-    {
-    case MU_FILTER_ENCODE:
-      *pret = malloc (sizeof (int));
-      if (!*pret)
-       return ENOMEM;
-      break;
-
-    case MU_FILTER_DECODE:
-      *pret = NULL;
-    }
-  return 0;
-}
-  
-
-static struct _mu_filter_record _crlf_filter = {
-  "CRLF",
-  alloc_state,
-  _crlf_encoder,
-  _crlf_decoder
+static struct _mu_filter_record _c_escape_filter = {
+  "C-escape",
+  NULL,
+  _c_escape_encoder,
+  _c_escape_decoder,
 };
 
-mu_filter_record_t mu_crlf_filter = &_crlf_filter;
-
-
-/* For compatibility with previous versions */
-static struct _mu_filter_record _rfc822_filter = {
-  "RFC822",
-  alloc_state,
-  _crlf_encoder,
-  _crlf_decoder
-};
-
-mu_filter_record_t mu_rfc822_filter = &_rfc822_filter;
-
+mu_filter_record_t mu_c_escape_filter = &_c_escape_filter;
 
diff --git a/libmailutils/filter/filter.c b/libmailutils/filter/filter.c
index 9cc9045..a9e6eeb 100644
--- a/libmailutils/filter/filter.c
+++ b/libmailutils/filter/filter.c
@@ -83,6 +83,7 @@ mu_filter_get_list (mu_list_t *plist)
       mu_list_append (filter_list, mu_linecon_filter);
       mu_list_append (filter_list, mu_linelen_filter);
       mu_list_append (filter_list, mu_iconv_filter);
+      mu_list_append (filter_list, mu_c_escape_filter);
       /* FIXME: add the default encodings?  */
     }
   *plist = filter_list;
diff --git a/mh/etc/components b/mh/etc/components
index 512352e..e754508 100644
--- a/mh/etc/components
+++ b/mh/etc/components
@@ -1,6 +1,6 @@
 ;; Default components file for GNU MH.
 ;; Lines beginning with ; are ignored.  Rest of lines is copied verbatim.
-To:
-cc:
-Subject:
+To: 
+cc: 
+Subject: 
 --------


hooks/post-receive
-- 
GNU Mailutils



reply via email to

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