size_t olen)
{
while (len >= 3 && olen > 10) {
- *out++ = B64Chars[in[0] >> 2];
- *out++ = B64Chars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
- *out++ = B64Chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
- *out++ = B64Chars[in[2] & 0x3f];
+ *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;
if (len > 0 && olen > 4) {
unsigned char fragment;
- *out++ = B64Chars[in[0] >> 2];
+ *out++ = __m_b64chars[in[0] >> 2];
fragment = (in[0] << 4) & 0x30;
if (len > 1)
fragment |= in[1] >> 4;
- *out++ = B64Chars[fragment];
- *out++ = (len < 2) ? '=' : B64Chars[(in[1] << 2) & 0x3c];
+ *out++ = __m_b64chars[fragment];
+ *out++ = (len < 2) ? '=' : __m_b64chars[(in[1] << 2) & 0x3c];
*out++ = '=';
}
*out = '\0';
#include "charset.h"
#include "imap_private.h"
-static int Index_64[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, 63, -1, -1, -1,
- 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
-};
-
-static char B64Chars[64] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
- 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', '+', ','
-};
-
/*
* Convert the data (u7,u7len) from RFC 2060's UTF-7 to UTF-8.
* The result is null-terminated and returned, and also stored
ch = 0;
k = 10;
for (; u7len; u7++, u7len--) {
- if ((*u7 & 0x80) || (b = Index_64[(int) *u7]) == -1)
+ if ((b = base64val(*u7)) < 0)
break;
if (k > 0) {
ch |= b << k;
}
if (ch & ~0xffff)
ch = 0xfffe;
- *p++ = B64Chars[b | ch >> k];
+ *p++ = __m_b64chars[b | ch >> k];
k -= 6;
for (; k >= 0; k -= 6)
- *p++ = B64Chars[(ch >> k) & 0x3f];
+ *p++ = __m_b64chars[(ch >> k) & 0x3f];
b = (ch << (-k)) & 0x3f;
k += 16;
}
else {
if (base64) {
if (k > 10)
- *p++ = B64Chars[b];
+ *p++ = __m_b64chars[b];
*p++ = '-';
base64 = 0;
}
if (base64) {
if (k > 10)
- *p++ = B64Chars[b];
+ *p++ = __m_b64chars[b];
*p++ = '-';
}
};
#undef XX
+char const __m_b64chars[64] = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
+ 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', '+', '/'
+};
+
+
ssize_t m_strcpy(char *dst, ssize_t n, const char *src)
{
ssize_t len = m_strlen(src);
extern unsigned char const __m_strdigits[128];
extern signed char const __m_b64digits[128];
+extern char const __m_b64chars[64];
/****************************************************************************/
/* char related */
/* MIME encoding/decoding global vars */
-#ifndef _SENDLIB_C
-extern char B64Chars[];
-#endif
-
#define is_multipart(x) \
((x)->type == TYPEMULTIPART \
|| ((x)->type == TYPEMESSAGE && (!strcasecmp((x)->subtype, "rfc822") \
if (!dlen)
break;
else if (dlen == 1) {
- *s++ = B64Chars[(*d >> 2) & 0x3f];
- *s++ = B64Chars[(*d & 0x03) << 4];
+ *s++ = __m_b64chars[(*d >> 2) & 0x3f];
+ *s++ = __m_b64chars[(*d & 0x03) << 4];
*s++ = '=';
*s++ = '=';
break;
}
else if (dlen == 2) {
- *s++ = B64Chars[(*d >> 2) & 0x3f];
- *s++ = B64Chars[((*d & 0x03) << 4) | ((d[1] >> 4) & 0x0f)];
- *s++ = B64Chars[(d[1] & 0x0f) << 2];
+ *s++ = __m_b64chars[(*d >> 2) & 0x3f];
+ *s++ = __m_b64chars[((*d & 0x03) << 4) | ((d[1] >> 4) & 0x0f)];
+ *s++ = __m_b64chars[(d[1] & 0x0f) << 2];
*s++ = '=';
break;
}
else {
- *s++ = B64Chars[(*d >> 2) & 0x3f];
- *s++ = B64Chars[((*d & 0x03) << 4) | ((d[1] >> 4) & 0x0f)];
- *s++ = B64Chars[((d[1] & 0x0f) << 2) | ((d[2] >> 6) & 0x03)];
- *s++ = B64Chars[d[2] & 0x3f];
+ *s++ = __m_b64chars[(*d >> 2) & 0x3f];
+ *s++ = __m_b64chars[((*d & 0x03) << 4) | ((d[1] >> 4) & 0x0f)];
+ *s++ = __m_b64chars[((d[1] & 0x0f) << 2) | ((d[2] >> 6) & 0x03)];
+ *s++ = __m_b64chars[d[2] & 0x3f];
d += 3, dlen -= 3;
}
}
const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t";
-char B64Chars[64] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
- 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', '+', '/'
-};
-
static char MsgIdPfx = 'A';
static void transform_to_7bit (BODY * a, FILE * fpin);
for (i = b64_num; i < 3; i++)
b64_buffer[i] = '\0';
- fputc (B64Chars[(b64_buffer[0] >> 2) & 0x3f], fout);
+ fputc(__m_b64chars[(b64_buffer[0] >> 2) & 0x3f], fout);
b64_linelen++;
- fputc (B64Chars
+ fputc(__m_b64chars
[((b64_buffer[0] & 0x3) << 4) | ((b64_buffer[1] >> 4) & 0xf)], fout);
b64_linelen++;
if (b64_num > 1) {
- fputc (B64Chars
+ fputc (__m_b64chars
[((b64_buffer[1] & 0xf) << 2) | ((b64_buffer[2] >> 6) & 0x3)],
fout);
b64_linelen++;
if (b64_num > 2) {
- fputc (B64Chars[b64_buffer[2] & 0x3f], fout);
+ fputc (__m_b64chars[b64_buffer[2] & 0x3f], fout);
b64_linelen++;
}
}
rs[BOUNDARYLEN] = 0;
for (i = 0; i < BOUNDARYLEN; i++)
- *p++ = B64Chars[LRAND () % sizeof (B64Chars)];
+ *p++ = __m_b64chars[LRAND() % sizeof(__m_b64chars)];
*p = 0;
mutt_set_parameter ("boundary", rs, parm);