From: Pierre Habouzit Date: Wed, 23 May 2007 21:29:30 +0000 (+0200) Subject: base64 implementation from madmutt--. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=378ab81aa9abf4db714638c3e2e786e6cc58d2b1;p=apps%2Fmadmutt.git base64 implementation from madmutt--. It seems this one is not used anymore \o/ Signed-off-by: Pierre Habouzit --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c01875..79f6f56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,7 +322,6 @@ MADMUTT_SOURCES(madmuttsrc madmuttgen account.c attach.c - base64.c browser.c commands.c compose.c diff --git a/base64.c b/base64.c deleted file mode 100644 index 9fdf037..0000000 --- a/base64.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -/* - * Base64 handling elsewhere in mutt should be modified to call - * these routines. These routines were written because IMAP's - * AUTHENTICATE protocol required them, and base64 handling - * elsewhere wasn't sufficiently generic. - * - */ - -/* - * This code is heavily modified from fetchmail (also GPL'd, of - * course) by Brendan Cully . - * - * Original copyright notice: - * - * The code in the fetchmail distribution is Copyright 1997 by Eric - * S. Raymond. Portions are also copyrighted by Carl Harris, 1993 - * and 1995. Copyright retained for the purpose of protecting free - * redistribution of source. - * - */ - -#include -#include - -#include "mutt.h" - -/* raw bytes to null-terminated base 64 string */ -void mutt_to_base64 (unsigned char *out, const unsigned char *in, ssize_t len, - ssize_t olen) -{ - while (len >= 3 && olen > 10) { - *out++ = __m_b64chars[in[0] >> 2]; - *out++ = __m_b64chars[((in[0] << 4) & 0x30) | (in[1] >> 4)]; - *out++ = __m_b64chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; - *out++ = __m_b64chars[in[2] & 0x3f]; - olen -= 4; - len -= 3; - in += 3; - } - - /* clean up remainder */ - if (len > 0 && olen > 4) { - unsigned char fragment; - - *out++ = __m_b64chars[in[0] >> 2]; - fragment = (in[0] << 4) & 0x30; - if (len > 1) - fragment |= in[1] >> 4; - *out++ = __m_b64chars[fragment]; - *out++ = (len < 2) ? '=' : __m_b64chars[(in[1] << 2) & 0x3c]; - *out++ = '='; - } - *out = '\0'; -} - -/* Convert '\0'-terminated base 64 string to raw bytes. - * Returns length of returned buffer, or -1 on error */ -int mutt_from_base64 (char *out, const char *in) -{ - int len = 0; - register unsigned char digit1, digit2, digit3, digit4; - - do { - digit1 = in[0]; - if (base64val(digit1) < 0) - return -1; - digit2 = in[1]; - if (base64val(digit2) < 0) - return -1; - digit3 = in[2]; - if (digit3 != '=' && base64val(digit3) < 0) - return -1; - digit4 = in[3]; - if (digit4 != '=' && base64val(digit4) < 0) - return -1; - in += 4; - - /* digits are already sanity-checked */ - *out++ = (base64val(digit1) << 2) | (base64val(digit2) >> 4); - len++; - if (digit3 != '=') { - *out++ = ((base64val(digit2) << 4) & 0xf0) | (base64val(digit3) >> 2); - len++; - if (digit4 != '=') { - *out++ = ((base64val(digit3) << 6) & 0xc0) | base64val(digit4); - len++; - } - } - } while (*in && digit4 != '='); - - return len; -} diff --git a/imap/imap.c b/imap/imap.c index 15f02f2..8fd96f8 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1336,7 +1336,6 @@ int imap_subscribe (char *path, int subscribe) IMAP_DATA *idata; char buf[LONG_STRING]; char mbox[LONG_STRING]; - char errstr[STRING]; IMAP_MBOX mx; if (mx_get_magic (path) != M_IMAP || imap_parse_path (path, &mx) < 0) { diff --git a/protos.h b/protos.h index 6e7f5b2..c97198b 100644 --- a/protos.h +++ b/protos.h @@ -143,10 +143,6 @@ int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int); void mutt_sleep (short); int mutt_save_confirm (const char *, struct stat *); -/* base64.c */ -void mutt_to_base64 (unsigned char *, const unsigned char *, ssize_t, ssize_t); -int mutt_from_base64 (char *, const char *); - void ci_bounce_message (HEADER *, int *); int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *);