X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=rfc2047.c;h=3769fef90433d9a7fd5f8fc93a58783bff023e66;hp=ae4a52b9623811fdb2e21c6352a003ecca7c4949;hb=c98480f8568e6c1bc927c6c5f2b5e80b4aa6548c;hpb=8e037c67a88cb4680c4391134c578e3b55a80f8a diff --git a/rfc2047.c b/rfc2047.c index ae4a52b..3769fef 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -13,16 +13,15 @@ #endif #include +#include +#include #include "mutt.h" -#include "ascii.h" #include "mime.h" #include "charset.h" #include "rfc2047.h" #include "thread.h" -#include "lib/mem.h" -#include "lib/str.h" #include #include @@ -40,7 +39,7 @@ #endif #define ENCWORD_LEN_MAX 75 -#define ENCWORD_LEN_MIN 9 /* str_len ("=?.?.?.?=") */ +#define ENCWORD_LEN_MIN 9 /* m_strlen("=?.?.?.?=") */ #define HSPACE(x) ((x) == '\0' || (x) == ' ' || (x) == '\t') @@ -77,7 +76,7 @@ static size_t convert_string (const char *f, size_t flen, *tlen = ob - buf; - mem_realloc (&buf, ob - buf + 1); + p_realloc(&buf, ob - buf + 1); *t = buf; iconv_close (cd); @@ -98,7 +97,7 @@ char *mutt_choose_charset (const char *fromcode, const char *charsets, q = strchr (p, ':'); - n = q ? q - p : str_len (p); + n = q ? q - p : m_strlen(p); if (!n || /* Assume that we never need more than 12 characters of @@ -149,7 +148,7 @@ static size_t b_encoder (char *s, const char *d, size_t dlen, char *s0 = s; memcpy (s, "=?", 2), s += 2; - memcpy (s, tocode, str_len (tocode)), s += str_len (tocode); + memcpy (s, tocode, m_strlen(tocode)), s += m_strlen(tocode); memcpy (s, "?B?", 3), s += 3; for (;;) { if (!dlen) @@ -187,7 +186,7 @@ static size_t q_encoder (char *s, const char *d, size_t dlen, char *s0 = s; memcpy (s, "=?", 2), s += 2; - memcpy (s, tocode, str_len (tocode)), s += str_len (tocode); + memcpy (s, tocode, m_strlen(tocode)), s += m_strlen(tocode); memcpy (s, "?Q?", 3), s += 3; while (dlen--) { unsigned char c = *d++; @@ -229,7 +228,7 @@ static size_t try_block (const char *d, size_t dlen, if (fromcode) { cd = mutt_iconv_open (tocode, fromcode, 0); assert (cd != (iconv_t) (-1)); - ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - str_len (tocode); + ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - m_strlen(tocode); if (my_iconv(cd, &ib, &ibl, &ob, &obl) == (size_t) (-1) || my_iconv(cd, 0, 0, &ob, &obl) == (size_t) (-1)) { assert (errno == E2BIG); @@ -240,8 +239,8 @@ static size_t try_block (const char *d, size_t dlen, iconv_close (cd); } else { - if (dlen > sizeof (buf1) - str_len (tocode)) - return sizeof (buf1) - str_len (tocode) + 1; + if (dlen > sizeof (buf1) - m_strlen(tocode)) + return sizeof (buf1) - m_strlen(tocode) + 1; memcpy (buf1, d, dlen); ob = buf1 + dlen; } @@ -256,7 +255,7 @@ static size_t try_block (const char *d, size_t dlen, ++count; } - len = ENCWORD_LEN_MIN - 2 + str_len (tocode); + len = ENCWORD_LEN_MIN - 2 + m_strlen(tocode); len_b = len + (((ob - buf1) + 2) / 3) * 4; len_q = len + (ob - buf1) + 2 * count; @@ -295,7 +294,7 @@ static size_t encode_block (char *s, char *d, size_t dlen, if (fromcode) { cd = mutt_iconv_open (tocode, fromcode, 0); assert (cd != (iconv_t) (-1)); - ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - str_len (tocode); + ib = d, ibl = dlen, ob = buf1, obl = sizeof (buf1) - m_strlen(tocode); n1 = my_iconv(cd, &ib, &ibl, &ob, &obl); n2 = my_iconv(cd, 0, 0, &ob, &obl); assert (n1 != (size_t) (-1) && n2 != (size_t) (-1)); @@ -480,15 +479,15 @@ static int rfc2047_encode (const char *d, size_t dlen, int col, /* Add to output buffer. */ #define LINEBREAK "\n\t" - if (bufpos + wlen + str_len (LINEBREAK) > buflen) { - buflen = bufpos + wlen + str_len (LINEBREAK); - mem_realloc (&buf, buflen); + if (bufpos + wlen + m_strlen(LINEBREAK) > buflen) { + buflen = bufpos + wlen + m_strlen(LINEBREAK); + p_realloc(&buf, buflen); } r = encode_block (buf + bufpos, t, n, icode, tocode, encoder); assert (r == wlen); bufpos += wlen; - memcpy (buf + bufpos, LINEBREAK, str_len (LINEBREAK)); - bufpos += str_len (LINEBREAK); + memcpy (buf + bufpos, LINEBREAK, m_strlen(LINEBREAK)); + bufpos += m_strlen(LINEBREAK); #undef LINEBREAK col = 1; @@ -498,7 +497,7 @@ static int rfc2047_encode (const char *d, size_t dlen, int col, /* Add last encoded word and us-ascii suffix to buffer. */ buflen = bufpos + wlen + (u + ulen - t1); - mem_realloc (&buf, buflen + 1); + p_realloc(&buf, buflen + 1); r = encode_block (buf + bufpos, t, t1 - t, icode, tocode, encoder); assert (r == wlen); bufpos += wlen; @@ -527,7 +526,7 @@ void _rfc2047_encode_string (char **pd, int encode_specials, int col) if (!charsets || !*charsets) charsets = "UTF-8"; - rfc2047_encode (*pd, str_len (*pd), col, + rfc2047_encode (*pd, m_strlen(*pd), col, Charset, charsets, &e, &elen, encode_specials ? RFC822Specials : NULL); @@ -538,7 +537,7 @@ void _rfc2047_encode_string (char **pd, int encode_specials, int col) void rfc2047_encode_adrlist (ADDRESS * addr, const char *tag) { ADDRESS *ptr = addr; - int col = tag ? str_len (tag) + 2 : 32; + int col = tag ? m_strlen(tag) + 2 : 32; while (ptr) { if (ptr->personal) @@ -555,7 +554,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) int enc = 0, count = 0; char *charset = NULL; - pd = d0 = p_new(char, str_len(s)); + pd = d0 = p_new(char, m_strlen(s)); for (pp = s; (pp1 = strchr (pp, '?')); pp = pp1 + 1) { count++; @@ -709,14 +708,14 @@ void rfc2047_decode (char **pd) if (!s || !*s) return; - dlen = 4 * str_len (s); /* should be enough */ + dlen = 4 * m_strlen(s); /* should be enough */ d = d0 = p_new(char, dlen + 1); while (*s && dlen > 0) { if (!(p = find_encoded_word (s, &q))) { /* no encoded words */ if (!option (OPTSTRICTMIME)) { - n = str_len (s); + n = m_strlen(s); if (found_encoded && (m = lwslen (s, n)) != 0) { if (m != n) *d = ' ', d++, dlen--; @@ -728,7 +727,7 @@ void rfc2047_decode (char **pd) t = p_dupstr(s, n); if (mutt_convert_nonmime_string (&t) == 0) { - tlen = str_len (t); + tlen = m_strlen(t); strncpy (d, t, tlen); d += tlen; } @@ -778,7 +777,7 @@ void rfc2047_decode (char **pd) rfc2047_decode_word (d, p, dlen); found_encoded = 1; s = q; - n = str_len (d); + n = m_strlen(d); dlen -= n; d += n; }