sync with 0.7.8cvs26
authorPaul Mangan <paul@claws-mail.org>
Fri, 12 Jul 2002 08:07:08 +0000 (08:07 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 12 Jul 2002 08:07:08 +0000 (08:07 +0000)
16 files changed:
COPYING
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
po/POTFILES.in
src/Makefile.am
src/about.c
src/base64.c
src/base64.h
src/codeconv.c
src/compose.c
src/rfc822.c [deleted file]
src/rfc822.h [deleted file]
src/smtp.c
src/unmime.c

diff --git a/COPYING b/COPYING
index f3c029eb56752f3ba3a15b3bdb63b2fa26c36ab5..1d35334371557a96aab67885b07c838480afa4e1 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,10 +1,5 @@
 The code in this distribution is Copyright 1999-2002 by Hiroyuki Yamamoto.
 
 The code in this distribution is Copyright 1999-2002 by Hiroyuki Yamamoto.
 
-The portions applied from fetchmail is Copyright 1997 by Eric S. Raymond.
-Portions of those are also copyrighted by Carl Harris, 1993 and 1995.
-Copyright retained for the purpose of protecting free redistribution of
-source.
-
 Specific permission is granted for the GPLed code in this distribition to
 be linked to OpenSSL without invoking GPL clause 2(b).
 
 Specific permission is granted for the GPLed code in this distribition to
 be linked to OpenSSL without invoking GPL clause 2(b).
 
index a0c54f1c6347ede9d16f0922e68a9f022e23de85..27aad948ee83368966bbe9255d414035a8267539 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,28 @@
+2002-07-12
+
+       * src/base64.c: a minor fix for BASE64VAL() macro.
+
+2002-07-11
+
+       * src/base64.c: base64_decode(): fixed a buffer overrun bug.
+
+2002-07-11
+
+       * src/codeconv.c
+         src/compose.c
+         src/smtp.c
+         src/unmime.c
+         src/base64.[ch]: rewrote the BASE64 encode / decode routines.
+         base64_encode(), base64_decode(): new.
+       * src/rfc822.[ch]: removed.
+       * COPYING
+         src/about.c: removed the copyright notice for fetchmail.
+
 2002-07-10
 
        * src/codeconv.c
          src/procmime.c
 2002-07-10
 
        * src/codeconv.c
          src/procmime.c
-         src/unmime.[ch]: rewritten the MIME decode routines.
+         src/unmime.[ch]: rewrote the MIME decode routines.
          unmime_header()
          unmime_quoted_printable_line(): new.
        * src/procheader.c:
          unmime_header()
          unmime_quoted_printable_line(): new.
        * src/procheader.c:
index aa03ea299c59114905d48e84102bbf51bbc991b2..16454b6e4a3fcbaa52cd3caa4a7fb9608eedff7d 100644 (file)
@@ -1,3 +1,8 @@
+2002-07-12 [paul]      0.7.8claws61
+
+       * sync with 0.7.8cvs26
+               see ChangeLog 2002-07-11 and 2002-07-12
+
 2002-07-11 [christoph] 0.7.8claws60
 
        * src/compose.c
 2002-07-11 [christoph] 0.7.8claws60
 
        * src/compose.c
index 9e09a21429d902b4eccfc8f5454afd1f2bcfc4eb..33f4c9c71d928130cccf3072f6593cbe4b3cb35c 100644 (file)
@@ -1,8 +1,28 @@
+2002-07-12
+
+       * src/base64.c: BASE64VAL() ¥Þ¥¯¥í¤Î¥Þ¥¤¥Ê¡¼¤Ê½¤Àµ¡£
+
+2002-07-11
+
+       * src/base64.c: base64_decode(): ¥Ð¥Ã¥Õ¥¡¥ª¡¼¥Ð¡¼¥é¥ó¤Î¥Ð¥°¤ò½¤Àµ¡£
+
+2002-07-11
+
+       * src/codeconv.c
+         src/compose.c
+         src/smtp.c
+         src/unmime.c
+         src/base64.[ch]: BASE64 ¥¨¥ó¥³¡¼¥É / ¥Ç¥³¡¼¥É¥ë¡¼¥Á¥ó¤ò½ñ¤­Ä¾¤·¤¿¡£
+         base64_encode(), base64_decode(): ¿·µ¬¡£
+       * src/rfc822.[ch]: ºï½ü¡£
+       * COPYING
+         src/about.c: fetchmail ¤ÎÃøºî¸¢É½¼¨¤òºï½ü¡£
+
 2002-07-10
 
        * src/codeconv.c
          src/procmime.c
 2002-07-10
 
        * src/codeconv.c
          src/procmime.c
-         src/unmime.[ch]: MIME ¥Ç¥³¡¼¥É¥ë¡¼¥Á¥ó¤ò½ñ¤­´¹¤¨¤¿¡£
+         src/unmime.[ch]: MIME ¥Ç¥³¡¼¥É¥ë¡¼¥Á¥ó¤ò½ñ¤­Ä¾¤·¤¿¡£
          unmime_header()
          unmime_quoted_printable_line(): ¿·µ¬¡£
        * src/procheader.c:
          unmime_header()
          unmime_quoted_printable_line(): ¿·µ¬¡£
        * src/procheader.c:
index a551e2479b8b4529a0eaeb3dbb329a2ed616a2d8..9a400878a4846470a404a312eba94a6eba808d78 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws60
+EXTRA_VERSION=claws61
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 3bfbd7939ac3b7f9446bed08e18542d7dafb1a1e..aee4ed31511f2de27418f3a1c45a82202cc500e4 100644 (file)
@@ -66,6 +66,7 @@ src/pine.c
 src/pop.c
 src/prefs.c
 src/prefs_account.c
 src/pop.c
 src/prefs.c
 src/prefs_account.c
+src/prefs_actions.c
 src/prefs_common.c
 src/prefs_customheader.c
 src/prefs_display_header.c
 src/prefs_common.c
 src/prefs_customheader.c
 src/prefs_display_header.c
@@ -74,7 +75,6 @@ src/prefs_filtering.c
 src/prefs_folder_item.c
 src/prefs_matcher.c
 src/prefs_scoring.c
 src/prefs_folder_item.c
 src/prefs_matcher.c
 src/prefs_scoring.c
-src/prefs_actions.c
 src/prefs_summary_column.c
 src/prefs_template.c
 src/procheader.c
 src/prefs_summary_column.c
 src/prefs_template.c
 src/procheader.c
@@ -83,7 +83,6 @@ src/procmsg.c
 src/progressdialog.c
 src/quote_fmt.c
 src/recv.c
 src/progressdialog.c
 src/quote_fmt.c
 src/recv.c
-src/rfc822.c
 src/rfc2015.c
 src/scoring.c
 src/select-keys.c
 src/rfc2015.c
 src/scoring.c
 src/select-keys.c
index 31cdb0cf18d208d47991ffe307adb39809908b05..b723d39d103843f11c4dcaba79f2f11394a764d4 100644 (file)
@@ -93,7 +93,6 @@ sylpheed_SOURCES = \
        base64.c base64.h \
        uuencode.c uuencode.h \
        md5.c md5.h \
        base64.c base64.h \
        uuencode.c uuencode.h \
        md5.c md5.h \
-       rfc822.c rfc822.h \
        socket.c socket.h \
        ssl.c ssl.h \
        automaton.c automaton.h \
        socket.c socket.h \
        ssl.c ssl.h \
        automaton.c automaton.h \
index dd5faac13dbcbb50f257e7319c05513cc9c2aebb..6b833204ce05a8753bc0a183415fc66f8f78f3c1 100644 (file)
@@ -205,12 +205,6 @@ static void about_create(void)
 
        gtk_text_freeze(GTK_TEXT(text));
 
 
        gtk_text_freeze(GTK_TEXT(text));
 
-       gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
-               _("The portions applied from fetchmail is Copyright 1997 by Eric S. "
-                 "Raymond.  Portions of those are also copyrighted by Carl Harris, "
-                 "1993 and 1995.  Copyright retained for the purpose of protecting free "
-                 "redistribution of source.\n\n"), -1);
-
 #if USE_GPGME
        gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
                _("GPGME is copyright 2001 by Werner Koch <dd9jn@gnu.org>\n\n"), -1);
 #if USE_GPGME
        gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
                _("GPGME is copyright 2001 by Werner Koch <dd9jn@gnu.org>\n\n"), -1);
index f0ef2061cd290aa664c3ad264f0654751090b61a..a448df9abbaadf9b87fac2ad0428e599724990bd 100644 (file)
 /*
 /*
- * base64.c -- base-64 conversion routines.
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
  *
  *
- * For license terms, see the file COPYING in this directory.
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
  *
  *
- * This base 64 encoding is defined in RFC2045 section 6.8,
- * "Base64 Content-Transfer-Encoding", but lines must not be broken in the
- * scheme used here.
+ * This program 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.
  *
  *
- * Modified by Hiroyuki Yamamoto <hiro-y@kcn.ne.jp>
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
  */
 
-#include "defs.h"
-
-#include <ctype.h>
-#include <string.h>
 #include <glib.h>
 #include <glib.h>
+#include <ctype.h>
 
 #include "base64.h"
 
 
 #include "base64.h"
 
-static const char base64digits[] =
-   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-#define BAD    -1
-static const char base64val[] = {
-    BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
-    BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
-    BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD, 62, BAD,BAD,BAD, 63,
-     52, 53, 54, 55,  56, 57, 58, 59,  60, 61,BAD,BAD, BAD,BAD,BAD,BAD,
-    BAD,  0,  1,  2,   3,  4,  5,  6,   7,  8,  9, 10,  11, 12, 13, 14,
-     15, 16, 17, 18,  19, 20, 21, 22,  23, 24, 25,BAD, BAD,BAD,BAD,BAD,
-    BAD, 26, 27, 28,  29, 30, 31, 32,  33, 34, 35, 36,  37, 38, 39, 40,
-     41, 42, 43, 44,  45, 46, 47, 48,  49, 50, 51,BAD, BAD,BAD,BAD,BAD
+static const gchar base64char[64] =
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static const gchar base64val[128] = {
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
+       52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
+       -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
+       15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+       -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+       41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
 };
 };
-#define DECODE64(c)  (isascii(c) ? base64val[c] : BAD)
 
 
-void to64frombits(unsigned char *out, const unsigned char *in, int inlen)
-/* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
-{
-    for (; inlen >= 3; inlen -= 3)
-    {
-       *out++ = base64digits[in[0] >> 2];
-       *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
-       *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
-       *out++ = base64digits[in[2] & 0x3f];
-       in += 3;
-    }
-    if (inlen > 0)
-    {
-       unsigned char fragment;
-    
-       *out++ = base64digits[in[0] >> 2];
-       fragment = (in[0] << 4) & 0x30;
-       if (inlen > 1)
-           fragment |= in[1] >> 4;
-       *out++ = base64digits[fragment];
-       *out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
-       *out++ = '=';
-    }
-    *out = '\0';
-}
+#define BASE64VAL(c)   (isascii(c) ? base64val[(gint)(c)] : -1)
 
 
-int from64tobits(char *out, const char *in)
-/* base 64 to raw bytes in quasi-big-endian order, returning count of bytes */
+void base64_encode(gchar *out, const guchar *in, gint inlen)
 {
 {
-    int len = 0;
-    register unsigned char digit1, digit2, digit3, digit4;
-
-    if (in[0] == '+' && in[1] == ' ')
-       in += 2;
-    if (*in == '\r' || *in == '\n')
-       return 0;
-
-    do {
-       digit1 = in[0];
-       if (DECODE64(digit1) == BAD)
-           return -1;
-       digit2 = in[1];
-       if (DECODE64(digit2) == BAD)
-           return -1;
-       digit3 = in[2];
-       if (digit3 != '=' && DECODE64(digit3) == BAD)
-           return -1; 
-       digit4 = in[3];
-       if (digit4 != '=' && DECODE64(digit4) == BAD)
-           return -1;
-       in += 4;
-       *out++ = (DECODE64(digit1) << 2) | ((DECODE64(digit2) >> 4) & 0x03);
-       ++len;
-       if (digit3 != '=')
-       {
-           *out++ = ((DECODE64(digit2) << 4) & 0xf0) | (DECODE64(digit3) >> 2);
-           ++len;
-           if (digit4 != '=')
-           {
-               *out++ = ((DECODE64(digit3) << 6) & 0xc0) | DECODE64(digit4);
-               ++len;
-           }
+       const guchar *inp = in;
+       gchar *outp = out;
+
+       while (inlen >= 3) {
+               *outp++ = base64char[(inp[0] >> 2) & 0x3f];
+               *outp++ = base64char[((inp[0] & 0x03) << 4) |
+                                    ((inp[1] >> 4) & 0x0f)];
+               *outp++ = base64char[((inp[1] & 0x0f) << 2) |
+                                    ((inp[2] >> 6) & 0x03)];
+               *outp++ = base64char[inp[2] & 0x3f];
+
+               inp += 3;
+               inlen -= 3;
+       }
+
+       if (inlen > 0) {
+               *outp++ = base64char[(inp[0] >> 2) & 0x3f];
+               if (inlen == 1) {
+                       *outp++ = base64char[(inp[0] & 0x03) << 4];
+                       *outp++ = '=';
+               } else {
+                       *outp++ = base64char[((inp[0] & 0x03) << 4) |
+                                            ((inp[1] >> 4) & 0x0f)];
+                       *outp++ = base64char[((inp[1] & 0x0f) << 2)];
+               }
+               *outp++ = '=';
        }
        }
-    } while (*in && *in != '\r' && *in != '\n' && digit4 != '=');
 
 
-    return len;
+       *outp = '\0';
 }
 
 }
 
-struct _Base64Decoder
+gint base64_decode(guchar *out, const gchar *in, gint inlen)
 {
 {
-       int buf_len;
-       unsigned char buf[4];
-};
+       const gchar *inp = in;
+       guchar *outp = out;
+       gchar buf[4];
+
+       if (inlen < 0)
+               inlen = G_MAXINT;
+
+       while (inlen >= 4 && *inp != '\0') {
+               buf[0] = *inp++;
+               inlen--;
+               if (BASE64VAL(buf[0]) == -1) break;
+
+               buf[1] = *inp++;
+               inlen--;
+               if (BASE64VAL(buf[1]) == -1) break;
 
 
-Base64Decoder *
-base64_decoder_new (void)
+               buf[2] = *inp++;
+               inlen--;
+               if (buf[2] != '=' && BASE64VAL(buf[2]) == -1) break;
+
+               buf[3] = *inp++;
+               inlen--;
+               if (buf[3] != '=' && BASE64VAL(buf[3]) == -1) break;
+
+               *outp++ = ((BASE64VAL(buf[0]) << 2) & 0xfc) |
+                         ((BASE64VAL(buf[1]) >> 4) & 0x03);
+               if (buf[2] != '=') {
+                       *outp++ = ((BASE64VAL(buf[1]) & 0x0f) << 4) |
+                                 ((BASE64VAL(buf[2]) >> 2) & 0x0f);
+                       if (buf[3] != '=') {
+                               *outp++ = ((BASE64VAL(buf[2]) & 0x03) << 6) |
+                                          (BASE64VAL(buf[3]) & 0x3f);
+                       }
+               }
+       }
+
+       return outp - out;
+}
+
+Base64Decoder *base64_decoder_new(void)
 {
        Base64Decoder *decoder;
 
 {
        Base64Decoder *decoder;
 
-       decoder = g_new0 (Base64Decoder, 1);
+       decoder = g_new0(Base64Decoder, 1);
        return decoder;
 }
 
        return decoder;
 }
 
-void
-base64_decoder_free (Base64Decoder *decoder)
+void base64_decoder_free(Base64Decoder *decoder)
 {
 {
-       g_free (decoder);
+       g_free(decoder);
 }
 
 }
 
-int
-base64_decoder_decode (Base64Decoder *decoder,
-                      const char    *in, 
-                      char          *out)
+gint base64_decoder_decode(Base64Decoder *decoder,
+                          const gchar *in, guchar *out)
 {
 {
-       int len = 0;
-       int buf_len;
-       unsigned char buf[4];
+       gint len, total_len = 0;
+       gint buf_len;
+       gchar buf[4];
 
 
-       g_return_val_if_fail (decoder != NULL, -1);
-       g_return_val_if_fail (in != NULL, -1);
-       g_return_val_if_fail (out != NULL, -1);
+       g_return_val_if_fail(decoder != NULL, -1);
+       g_return_val_if_fail(in != NULL, -1);
+       g_return_val_if_fail(out != NULL, -1);
 
        buf_len = decoder->buf_len;
 
        buf_len = decoder->buf_len;
-       memcpy (buf, decoder->buf, sizeof(buf));
-       while (1) {
+       memcpy(buf, decoder->buf, sizeof(buf));
+
+       for (;;) {
                while (buf_len < 4) {
                while (buf_len < 4) {
-                       int c = *(unsigned char *)in++;
+                       gchar c = *in;
+
+                       in++;
                        if (c == '\0') break;
                        if (c == '\r' || c == '\n') continue;
                        if (c == '\0') break;
                        if (c == '\r' || c == '\n') continue;
-                       if (c != '=' && DECODE64(c) == BAD)
+                       if (c != '=' && BASE64VAL(c) == -1)
                                return -1;
                        buf[buf_len++] = c;
                }
                if (buf_len < 4 || buf[0] == '=' || buf[1] == '=') {
                        decoder->buf_len = buf_len;
                                return -1;
                        buf[buf_len++] = c;
                }
                if (buf_len < 4 || buf[0] == '=' || buf[1] == '=') {
                        decoder->buf_len = buf_len;
-                       memcpy (decoder->buf, buf, sizeof(buf));
-                       return len;
-               }
-               *out++ = ((DECODE64(buf[0]) << 2)
-                         | ((DECODE64(buf[1]) >> 4) & 0x03));
-               ++len;
-               if (buf[2] != '=') {
-                       *out++ = (((DECODE64(buf[1]) << 4) & 0xf0)
-                                 | (DECODE64(buf[2]) >> 2));
-                       ++len;
-                       if (buf[3] != '=') {
-                               *out++ = (((DECODE64(buf[2]) << 6) & 0xc0)
-                                         | DECODE64(buf[3]));
-                               ++len;
-                       }
+                       memcpy(decoder->buf, buf, sizeof(buf));
+                       return total_len;
                }
                }
+               len = base64_decode(out, buf, 4);
+               out += len;
+               total_len += len;
                buf_len = 0;
                buf_len = 0;
-               if (buf[2] == '=' || buf[3] == '=') {
+               if (len < 3) {
                        decoder->buf_len = 0;
                        decoder->buf_len = 0;
-                       return len;
+                       return total_len;
                }
        }
 }
                }
        }
 }
-
-/* base64.c ends here */
index 327dfbf643a7b0fc7ce736cbf4e9372dec80bf86..4aa557583430a96ae83dcae1b667fc6a38c73054 100644 (file)
@@ -1,15 +1,46 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
 #ifndef __BASE64_H__
 #define __BASE64_H__
 
 #ifndef __BASE64_H__
 #define __BASE64_H__
 
-typedef struct _Base64Decoder Base64Decoder;
+#include <glib.h>
+
+typedef struct _Base64Decoder  Base64Decoder;
+
+struct _Base64Decoder
+{
+       gint buf_len;
+       gchar buf[4];
+};
 
 
-Base64Decoder * base64_decoder_new     (void);
-void           base64_decoder_free     (Base64Decoder *decoder);
-int            base64_decoder_decode   (Base64Decoder *decoder,
-                                        const char    *in, 
-                                        char          *out);
+void base64_encode     (gchar          *out,
+                        const guchar   *in,
+                        gint            inlen);
+gint base64_decode     (guchar         *out,
+                        const gchar    *in,
+                        gint            inlen);
 
 
-void to64frombits(unsigned char *, const unsigned char *, int);
-int from64tobits(char *, const char *);
+Base64Decoder *base64_decoder_new      (void);
+void          base64_decoder_free      (Base64Decoder  *decoder);
+gint          base64_decoder_decode    (Base64Decoder  *decoder,
+                                        const gchar    *in,
+                                        guchar         *out);
 
 #endif /* __BASE64_H__ */
 
 #endif /* __BASE64_H__ */
index 75974e1d547b3e12e1ba389805d1b16a6981e9f4..320f9b5be03048967001df776701dbdcfe9ef8dc 100644 (file)
@@ -1185,7 +1185,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                destp += mimehdr_begin_len;
                                line_len += mimehdr_begin_len;
 
                                destp += mimehdr_begin_len;
                                line_len += mimehdr_begin_len;
 
-                               to64frombits(destp, raw, raw_len);
+                               base64_encode(destp, raw, raw_len);
                                line_len += strlen(destp);
                                destp += strlen(destp);
 
                                line_len += strlen(destp);
                                destp += strlen(destp);
 
@@ -1380,7 +1380,7 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
                                destp += mimehdr_begin_len;
                                line_len += mimehdr_begin_len;
 
                                destp += mimehdr_begin_len;
                                line_len += mimehdr_begin_len;
 
-                               to64frombits(destp, tmp_jis, strlen(tmp_jis));
+                               base64_encode(destp, tmp_jis, strlen(tmp_jis));
                                line_len += strlen(destp);
                                destp += strlen(destp);
 
                                line_len += strlen(destp);
                                destp += strlen(destp);
 
index 1d5f98929faf75fd2f7c38958356d8026e4ddcd6..fd686887c20a7d0a70175917f35632bef087ee01 100644 (file)
@@ -3172,7 +3172,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
 
                for (i = 0; i < len; i += B64_LINE_SIZE) {
                        l = MIN(B64_LINE_SIZE, len - i);
 
                for (i = 0; i < len; i += B64_LINE_SIZE) {
                        l = MIN(B64_LINE_SIZE, len - i);
-                       to64frombits(outbuf, buf + i, l);
+                       base64_encode(outbuf, buf + i, l);
                        fputs(outbuf, fp);
                        fputc('\n', fp);
                }
                        fputs(outbuf, fp);
                        fputc('\n', fp);
                }
@@ -3555,12 +3555,12 @@ static void compose_write_attach(Compose *compose, FILE *fp)
                        while ((len = fread(inbuf, sizeof(gchar),
                                            B64_LINE_SIZE, attach_fp))
                               == B64_LINE_SIZE) {
                        while ((len = fread(inbuf, sizeof(gchar),
                                            B64_LINE_SIZE, attach_fp))
                               == B64_LINE_SIZE) {
-                               to64frombits(outbuf, inbuf, B64_LINE_SIZE);
+                               base64_encode(outbuf, inbuf, B64_LINE_SIZE);
                                fputs(outbuf, fp);
                                fputc('\n', fp);
                        }
                        if (len > 0 && feof(attach_fp)) {
                                fputs(outbuf, fp);
                                fputc('\n', fp);
                        }
                        if (len > 0 && feof(attach_fp)) {
-                               to64frombits(outbuf, inbuf, len);
+                               base64_encode(outbuf, inbuf, len);
                                fputs(outbuf, fp);
                                fputc('\n', fp);
                        }
                                fputs(outbuf, fp);
                                fputc('\n', fp);
                        }
diff --git a/src/rfc822.c b/src/rfc822.c
deleted file mode 100644 (file)
index 766029a..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * rfc822.c -- code for slicing and dicing RFC822 mail headers
- *
- * Copyright 1997 by Eric S. Raymond
- * For license terms, see the file COPYING in this directory.
- *
- * Modified by Hiroyuki Yamamoto <hiro-y@kcn.ne.jp>
- */
-
-#include  <stdio.h>
-#include  <ctype.h>
-#include  <string.h>
-#include  <stdlib.h>
-#include  <glib.h>
-#include  "rfc822.h"
-
-/* output noise level */
-#define                O_SILENT        0       /* mute, max squelch, etc. */
-#define                O_NORMAL        1       /* user-friendly */
-#define                O_VERBOSE       2       /* chatty */
-#define                O_DEBUG         3       /* prolix */
-#define                O_MONITOR       O_VERBOSE
-
-static int outlevel = O_SILENT;
-
-#define                POPBUFSIZE      512     /* max length of response (RFC1939) */
-
-#define HEADER_END(p)  ((p)[0] == '\n' && ((p)[1] != ' ' && (p)[1] != '\t'))
-
-#ifdef TESTMAIN
-static int verbose;
-char *program_name = "rfc822";
-#endif /* TESTMAIN */
-
-char *reply_hack(buf, host)
-/* hack message headers so replies will work properly */
-char *buf;             /* header to be hacked */
-const char *host;      /* server hostname */
-{
-    char *from, *cp, last_nws = '\0', *parens_from = NULL;
-    int parendepth, state, has_bare_name_part, has_host_part;
-#ifndef TESTMAIN
-    int addresscount = 1;
-#endif /* TESTMAIN */
-
-    if (strncasecmp("From: ", buf, 6)
-       && strncasecmp("To: ", buf, 4)
-       && strncasecmp("Reply-To: ", buf, 10)
-       && strncasecmp("Return-Path: ", buf, 13)
-       && strncasecmp("Cc: ", buf, 4)
-       && strncasecmp("Bcc: ", buf, 5)
-       && strncasecmp("Resent-From: ", buf, 13)
-       && strncasecmp("Resent-To: ", buf, 11)
-       && strncasecmp("Resent-Cc: ", buf, 11)
-       && strncasecmp("Resent-Bcc: ", buf, 12)
-       && strncasecmp("Apparently-From:", buf, 16)
-       && strncasecmp("Apparently-To:", buf, 14)
-       && strncasecmp("Sender:", buf, 7)
-       && strncasecmp("Resent-Sender:", buf, 14)
-       ) {
-       return(buf);
-    }
-
-#ifndef TESTMAIN
-    if (outlevel >= O_DEBUG)
-       fprintf(stdout, "About to rewrite %s", buf);
-
-    /* make room to hack the address; buf must be malloced */
-    for (cp = buf; *cp; cp++)
-       if (*cp == ',' || isspace(*cp))
-           addresscount++;
-    buf = (char *)g_realloc(buf, strlen(buf) + addresscount * strlen(host) + 1);
-#endif /* TESTMAIN */
-
-    /*
-     * This is going to foo up on some ill-formed addresses.
-     * Note that we don't rewrite the fake address <> in order to
-     * avoid screwing up bounce suppression with a null Return-Path.
-     */
-
-    parendepth = state = 0;
-    has_host_part = has_bare_name_part = FALSE;
-    for (from = buf; *from; from++)
-    {
-#ifdef TESTMAIN
-       if (verbose)
-       {
-           printf("state %d: %s", state, buf);
-           printf("%*s^\n", from - buf + 10, " ");
-       }
-#endif /* TESTMAIN */
-       if (state != 2) {
-           if (*from == '(')
-               ++parendepth;
-           else if (*from == ')')
-               --parendepth;
-       }
-
-       if (!parendepth && !has_host_part)
-           switch (state)
-           {
-           case 0:     /* before header colon */
-               if (*from == ':')
-                   state = 1;
-               break;
-
-           case 1:     /* we've seen the colon, we're looking for addresses */
-               if (!isspace(*from))
-                   last_nws = *from;
-               if (*from == '<')
-                   state = 3;
-               else if (*from == '@')
-                   has_host_part = TRUE;
-               else if (*from == '"')
-                   state = 2;
-               /*
-                * Not expanding on last non-WS == ';' deals with groupnames,
-                * an obscure misfeature described in sections
-                * 6.1, 6.2.6, and A.1.5 of the RFC822 standard.
-                */
-               else if ((*from == ',' || HEADER_END(from))
-                        && has_bare_name_part
-                        && !has_host_part
-                        && last_nws != ';')
-               {
-                   int hostlen;
-                   char *p;
-
-                   p = from;
-                   if (parens_from)
-                       from = parens_from;
-                   while (isspace(*from) || (*from == ','))
-                       --from;
-                   from++;
-                   hostlen = strlen(host);
-                   for (cp = from + strlen(from); cp >= from; --cp)
-                       cp[hostlen+1] = *cp;
-                   *from++ = '@';
-                   memcpy(from, host, hostlen);
-                   from = p + hostlen + 1;
-                   has_host_part = TRUE;
-               } 
-               else if (from[1] == '('
-                        && has_bare_name_part
-                        && !has_host_part
-                        && last_nws != ';' && last_nws != ')')
-               {
-                   parens_from = from;
-               } 
-               else if (!isspace(*from))
-                   has_bare_name_part = TRUE;
-               break;
-
-           case 2:     /* we're in a string */
-               if (*from == '"')
-                   state = 1;
-               break;
-
-           case 3:     /* we're in a <>-enclosed address */
-               if (*from == '@')
-                   has_host_part = TRUE;
-               else if (*from == '>' && from[-1] != '<')
-               {
-                   state = 1;
-                   if (!has_host_part)
-                   {
-                       int hostlen;
-
-                       hostlen = strlen(host);
-                       for (cp = from + strlen(from); cp >= from; --cp)
-                           cp[hostlen+1] = *cp;
-                       *from++ = '@';
-                       memcpy(from, host, hostlen);
-                       from += hostlen;
-                       has_host_part = TRUE;
-                   }
-               }
-               break;
-           }
-
-       /*
-        * If we passed a comma, reset everything.
-        */
-       if (from[-1] == ',' && !parendepth) {
-         has_host_part = has_bare_name_part = FALSE;
-         parens_from = NULL;
-       }
-    }
-
-#ifndef TESTMAIN
-    if (outlevel >= O_DEBUG)
-       fprintf(stdout, "Rewritten version is %s\n", buf);
-#endif /* TESTMAIN */
-    return(buf);
-}
-
-char *nxtaddr(hdr)
-/* parse addresses in succession out of a specified RFC822 header */
-const char *hdr;       /* header to be parsed, NUL to continue previous hdr */
-{
-    static char *tp, address[POPBUFSIZE+1];
-    static const char *hp;
-    static int state, oldstate;
-#ifdef TESTMAIN
-    static const char *orighdr;
-#endif /* TESTMAIN */
-    int parendepth = 0;
-
-#define START_HDR      0       /* before header colon */
-#define SKIP_JUNK      1       /* skip whitespace, \n, and junk */
-#define BARE_ADDRESS   2       /* collecting address without delimiters */
-#define INSIDE_DQUOTE  3       /* inside double quotes */
-#define INSIDE_PARENS  4       /* inside parentheses */
-#define INSIDE_BRACKETS        5       /* inside bracketed address */
-#define ENDIT_ALL      6       /* after last address */
-
-    if (hdr)
-    {
-       hp = hdr;
-       state = START_HDR;
-#ifdef TESTMAIN
-       orighdr = hdr;
-#endif /* TESTMAIN */
-       tp = address;
-    }
-
-    for (; *hp; hp++)
-    {
-#ifdef TESTMAIN
-       if (verbose)
-       {
-           printf("state %d: %s", state, orighdr);
-           printf("%*s^\n", hp - orighdr + 10, " ");
-       }
-#endif /* TESTMAIN */
-
-       if (state == ENDIT_ALL)         /* after last address */
-           return(NULL);
-       else if (HEADER_END(hp))
-       {
-           state = ENDIT_ALL;
-           if (tp > address)
-           {
-               while (isspace(*--tp))
-                   continue;
-               *++tp = '\0';
-           }
-           return(tp > address ? (tp = address) : (char *)NULL);
-       }
-       else if (*hp == '\\')           /* handle RFC822 escaping */
-       {
-           if (state != INSIDE_PARENS)
-           {
-               *tp++ = *hp++;                  /* take the escape */
-               *tp++ = *hp;                    /* take following char */
-           }
-       }
-       else switch (state)
-       {
-       case START_HDR:   /* before header colon */
-           if (*hp == ':')
-               state = SKIP_JUNK;
-           break;
-
-       case SKIP_JUNK:         /* looking for address start */
-           if (*hp == '"')     /* quoted string */
-           {
-               oldstate = SKIP_JUNK;
-               state = INSIDE_DQUOTE;
-               *tp++ = *hp;
-           }
-           else if (*hp == '(')        /* address comment -- ignore */
-           {
-               parendepth = 1;
-               oldstate = SKIP_JUNK;
-               state = INSIDE_PARENS;    
-           }
-           else if (*hp == '<')        /* begin <address> */
-           {
-               state = INSIDE_BRACKETS;
-               tp = address;
-           }
-           else if (*hp != ',' && !isspace(*hp))
-           {
-               --hp;
-               state = BARE_ADDRESS;
-           }
-           break;
-
-       case BARE_ADDRESS:      /* collecting address without delimiters */
-           if (*hp == ',')     /* end of address */
-           {
-               if (tp > address)
-               {
-                   *tp++ = '\0';
-                   state = SKIP_JUNK;
-                   return(tp = address);
-               }
-           }
-           else if (*hp == '(')        /* beginning of comment */
-           {
-               parendepth = 1;
-               oldstate = BARE_ADDRESS;
-               state = INSIDE_PARENS;    
-           }
-           else if (*hp == '<')        /* beginning of real address */
-           {
-               state = INSIDE_BRACKETS;
-               tp = address;
-           }
-           else if (!isspace(*hp))     /* just take it, ignoring whitespace */
-               *tp++ = *hp;
-           break;
-
-       case INSIDE_DQUOTE:     /* we're in a quoted string, copy verbatim */
-           if (*hp != '"')
-               *tp++ = *hp;
-           else
-           {
-               *tp++ = *hp;
-               state = oldstate;
-           }
-           break;
-
-       case INSIDE_PARENS:     /* we're in a parenthesized comment, ignore */
-           if (*hp == '(')
-               ++parendepth;
-           else if (*hp == ')')
-               --parendepth;
-           if (parendepth == 0)
-               state = oldstate;
-           break;
-
-       case INSIDE_BRACKETS:   /* possible <>-enclosed address */
-           if (*hp == '>')     /* end of address */
-           {
-               *tp++ = '\0';
-               state = SKIP_JUNK;
-               ++hp;
-               return(tp = address);
-           }
-           else if (*hp == '<')        /* nested <> */
-               tp = address;
-           else if (*hp == '"')        /* quoted address */
-           {
-               *tp++ = *hp;
-               oldstate = INSIDE_BRACKETS;
-               state = INSIDE_DQUOTE;
-           }
-           else                        /* just copy address */
-               *tp++ = *hp;
-           break;
-       }
-    }
-
-    return(NULL);
-}
-
-#ifdef TESTMAIN
-static void parsebuf(char *longbuf, int reply)
-{
-    char       *cp;
-
-    if (reply)
-    {
-       reply_hack(longbuf, "HOSTNAME.NET");
-       printf("Rewritten buffer: %s", longbuf);
-    }
-    else
-       if ((cp = nxtaddr(longbuf)) != (char *)NULL)
-           do {
-               printf("\t-> \"%s\"\n", cp);
-           } while
-               ((cp = nxtaddr((char *)NULL)) != (char *)NULL);
-}
-
-
-
-main(int argc, char *argv[])
-{
-    char       buf[MSGBUFSIZE], longbuf[BUFSIZ];
-    int                ch, reply;
-    
-    verbose = reply = FALSE;
-    while ((ch = getopt(argc, argv, "rv")) != EOF)
-       switch(ch)
-       {
-       case 'r':
-           reply = TRUE;
-           break;
-
-       case 'v':
-           verbose = TRUE;
-           break;
-       }
-
-    while (fgets(buf, sizeof(buf)-1, stdin))
-    {
-       if (buf[0] == ' ' || buf[0] == '\t')
-           strcat(longbuf, buf);
-       else if (!strncasecmp("From: ", buf, 6)
-                   || !strncasecmp("To: ", buf, 4)
-                   || !strncasecmp("Reply-", buf, 6)
-                   || !strncasecmp("Cc: ", buf, 4)
-                   || !strncasecmp("Bcc: ", buf, 5))
-           strcpy(longbuf, buf);       
-       else if (longbuf[0])
-       {
-           if (verbose)
-               fputs(longbuf, stdout);
-           parsebuf(longbuf, reply);
-           longbuf[0] = '\0';
-       }
-    }
-    if (longbuf[0])
-    {
-       if (verbose)
-           fputs(longbuf, stdout);
-       parsebuf(longbuf, reply);
-    }
-}
-#endif /* TESTMAIN */
-
-/* rfc822.c end */
diff --git a/src/rfc822.h b/src/rfc822.h
deleted file mode 100644 (file)
index 75c0fed..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* rfc822.c: RFC822 header parsing */
-char *reply_hack(char *, const char *);
-char *nxtaddr(const char *);
index bf7eda42ad2d3c46018ab2a0f633730efebb9590..8a2399f479d4e4c7a6013739605517c518f2750b 100644 (file)
@@ -201,7 +201,7 @@ gint smtp_auth(SMTPSession *session, SMTPAuthType forced_auth_type)
        switch (authtype) {
        case SMTPAUTH_LOGIN:
                if (!strncmp(buf, "334 ", 4))
        switch (authtype) {
        case SMTPAUTH_LOGIN:
                if (!strncmp(buf, "334 ", 4))
-                       to64frombits(buf, session->user, strlen(session->user));
+                       base64_encode(buf, session->user, strlen(session->user));
                else
                        /* Server rejects AUTH */
                        g_snprintf(buf, sizeof(buf), "*");
                else
                        /* Server rejects AUTH */
                        g_snprintf(buf, sizeof(buf), "*");
@@ -212,7 +212,7 @@ gint smtp_auth(SMTPSession *session, SMTPAuthType forced_auth_type)
                smtp_ok(sock, buf, sizeof(buf));
 
                if (!strncmp(buf, "334 ", 4))
                smtp_ok(sock, buf, sizeof(buf));
 
                if (!strncmp(buf, "334 ", 4))
-                       to64frombits(buf, session->pass, strlen(session->pass));
+                       base64_encode(buf, session->pass, strlen(session->pass));
                else
                        /* Server rejects AUTH */
                        g_snprintf(buf, sizeof(buf), "*");
                else
                        /* Server rejects AUTH */
                        g_snprintf(buf, sizeof(buf), "*");
@@ -223,7 +223,7 @@ gint smtp_auth(SMTPSession *session, SMTPAuthType forced_auth_type)
        case SMTPAUTH_CRAM_MD5:
                if (!strncmp(buf, "334 ", 4)) {
                        challenge = g_malloc(strlen(buf + 4) + 1);
        case SMTPAUTH_CRAM_MD5:
                if (!strncmp(buf, "334 ", 4)) {
                        challenge = g_malloc(strlen(buf + 4) + 1);
-                       challengelen = from64tobits(challenge, buf + 4);
+                       challengelen = base64_decode(challenge, buf + 4, -1);
                        challenge[challengelen] = '\0';
                        if (verbose)
                                log_print("ESMTP< [Decoded: %s]\n", challenge);
                        challenge[challengelen] = '\0';
                        if (verbose)
                                log_print("ESMTP< [Decoded: %s]\n", challenge);
@@ -239,7 +239,7 @@ gint smtp_auth(SMTPSession *session, SMTPAuthType forced_auth_type)
                                log_print("ESMTP> [Encoded: %s]\n", response);
 
                        response64 = g_malloc((strlen(response) + 3) * 2 + 1);
                                log_print("ESMTP> [Encoded: %s]\n", response);
 
                        response64 = g_malloc((strlen(response) + 3) * 2 + 1);
-                       to64frombits(response64, response, strlen(response));
+                       base64_encode(response64, response, strlen(response));
                        g_free(response);
 
                        sock_printf(sock, "%s\r\n", response64);
                        g_free(response);
 
                        sock_printf(sock, "%s\r\n", response64);
index 442c5dc09dda6d466191e42178787a6da27caff2..1ba54c1f20c1f018bea5c8d0e2452bda4e542205 100644 (file)
@@ -42,7 +42,7 @@ void unmime_header(gchar *out, const gchar *str)
        const gchar *sp;
        const gchar *eword_begin_p, *encoding_begin_p, *text_begin_p,
                    *eword_end_p;
        const gchar *sp;
        const gchar *eword_begin_p, *encoding_begin_p, *text_begin_p,
                    *eword_end_p;
-       gchar *charset;
+       gchar charset[32];
        gchar encoding;
        gchar *conv_str;
        gint len;
        gchar encoding;
        gchar *conv_str;
        gint len;
@@ -87,23 +87,18 @@ void unmime_header(gchar *out, const gchar *str)
                        }
                }
 
                        }
                }
 
-               charset = g_strndup(eword_begin_p + 2,
-                                   encoding_begin_p - (eword_begin_p + 2));
+               len = MIN(sizeof(charset) - 1,
+                         encoding_begin_p - (eword_begin_p + 2));
+               memcpy(charset, eword_begin_p + 2, len);
+               charset[len] = '\0';
                encoding = toupper(*(encoding_begin_p + 1));
 
                if (encoding == 'B') {
                encoding = toupper(*(encoding_begin_p + 1));
 
                if (encoding == 'B') {
-                       gchar *encoded_text;
-
-                       encoded_text =
-                               g_strndup(text_begin_p + 1,
-                                         eword_end_p - (text_begin_p + 1));
                        decoded_text = g_malloc
                                (eword_end_p - (text_begin_p + 1) + 1);
                        decoded_text = g_malloc
                                (eword_end_p - (text_begin_p + 1) + 1);
-
-                       len = from64tobits(decoded_text, encoded_text); //
+                       len = base64_decode(decoded_text, text_begin_p + 1,
+                                           eword_end_p - (text_begin_p + 1));
                        decoded_text[len] = '\0';
                        decoded_text[len] = '\0';
-
-                       g_free(encoded_text);
                } else if (encoding == 'Q') {
                        const gchar *ep = text_begin_p + 1;
                        gchar *dp;
                } else if (encoding == 'Q') {
                        const gchar *ep = text_begin_p + 1;
                        gchar *dp;
@@ -132,7 +127,6 @@ void unmime_header(gchar *out, const gchar *str)
                        memcpy(outp, p, eword_end_p + 2 - p);
                        outp += eword_end_p + 2 - p;
                        p = eword_end_p + 2;
                        memcpy(outp, p, eword_end_p + 2 - p);
                        outp += eword_end_p + 2 - p;
                        p = eword_end_p + 2;
-                       g_free(charset);
                        continue;
                }
 
                        continue;
                }
 
@@ -149,7 +143,6 @@ void unmime_header(gchar *out, const gchar *str)
                outp += len;
 
                g_free(decoded_text);
                outp += len;
 
                g_free(decoded_text);
-               g_free(charset);
 
                p = eword_end_p + 2;
        }
 
                p = eword_end_p + 2;
        }