X-Git-Url: http://git.madism.org/?a=blobdiff_plain;ds=sidebyside;f=rfc2047.c;h=23fffd4a3160b4befceee1b5139ea32968e8bd41;hb=b36dc16c428cc2b1371bb99c0581aa014f302791;hp=84028abcf7c8a5591fe8420fbacd46600252c738;hpb=7f7a0be369840b290248e5b0302beb447fa1b3cd;p=apps%2Fmadmutt.git diff --git a/rfc2047.c b/rfc2047.c index 84028ab..23fffd4 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -14,10 +14,11 @@ #include #include +#include + +#include #include "mutt.h" -#include "ascii.h" -#include "mime.h" #include "charset.h" #include "rfc2047.h" #include "thread.h" @@ -154,24 +155,24 @@ static size_t b_encoder (char *s, const char *d, size_t dlen, 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; } } @@ -582,9 +583,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) for (; pp < pp1; pp++) { if (*pp == '_') *pd++ = ' '; - else if (*pp == '=' && - (!(pp[1] & ~127) && hexval (pp[1]) != -1) && - (!(pp[2] & ~127) && hexval (pp[2]) != -1)) { + else if (*pp == '=' && hexval(pp[1]) >= 0 && hexval(pp[2]) >= 0) { *pd++ = (hexval (pp[1]) << 4) | hexval (pp[2]); pp += 2; } @@ -599,7 +598,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) for (; pp < pp1; pp++) { if (*pp == '=') break; - if ((*pp & ~127) || (c = base64val (*pp)) == -1) + if ((c = base64val(*pp)) < 0) continue; if (k + 6 >= 8) { k -= 2; @@ -619,7 +618,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) if (charset) mutt_convert_string (&d0, charset, Charset, M_ICONV_HOOK_FROM); - strfcpy (d, d0, len); + m_strcpy(d, len, d0); p_delete(&charset); p_delete(&d0); return (0);