diff options
author | 2 <NotZed@Ximian.com> | 2001-10-03 08:12:49 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-10-03 08:12:49 +0800 |
commit | 65014a74aa55209e8e5b65549be26645dabd7cba (patch) | |
tree | b64e6409bde5e0b0310df1928b30fd3d85c831cd /camel/camel-mime-utils.c | |
parent | 7d2487975feeee0be69890e92fe3eca609fe25c3 (diff) | |
download | gsoc2013-evolution-65014a74aa55209e8e5b65549be26645dabd7cba.tar.gz gsoc2013-evolution-65014a74aa55209e8e5b65549be26645dabd7cba.tar.zst gsoc2013-evolution-65014a74aa55209e8e5b65549be26645dabd7cba.zip |
Change to camel_charset_iconv_open/close.
2001-10-02 <NotZed@Ximian.com>
* camel-sasl-digest-md5.c (digest_response): Change to
camel_charset_iconv_open/close.
* camel-pgp-context.c (pgp_verify): Change to
camel_charset_iconv_open/close.
* camel-mime-part-utils.c (convert_buffer): Change to
camel_charset_iconv_open().
* camel-mime-filter-charset.c
(camel_mime_filter_charset_new_convert, finalise): Change to
camel_charset_iconv_open, etc.
* camel-mime-utils.c: Use the camel_charset_iconv_open/close()
functions to open/close it.
* camel-charset-map.c (camel_charset_iconv_open): New function,
wrap iconv_open, so we can cache ic's.
(camel_charset_iconv_close): Likewise for close.
(camel_charset_map_init,shutdown): Init/free iconv cache.
svn path=/trunk/; revision=13361
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r-- | camel/camel-mime-utils.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index aed930eca5..38b932a280 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -963,9 +963,8 @@ rfc2047_decode_word(const char *in, int len) outbase = alloca (outlen); outbuf = outbase; - /* TODO: Should this cache iconv converters? */ retry: - ic = iconv_open ("UTF-8", charset); + ic = camel_charset_iconv_open ("UTF-8", charset); if (ic != (iconv_t)-1) { ret = iconv (ic, &inbuf, &inlen, &outbuf, &outlen); if (ret >= 0) { @@ -973,7 +972,7 @@ rfc2047_decode_word(const char *in, int len) *outbuf = 0; decoded = g_strdup (outbase); } - iconv_close (ic); + camel_charset_iconv_close (ic); } else { w(g_warning ("Cannot decode charset, header display may be corrupt: %s: %s", charset, g_strerror (errno))); @@ -1039,7 +1038,7 @@ append_8bit (GString *out, const char *inbuf, int inlen, const char *charset) int outlen; iconv_t ic; - ic = iconv_open ("UTF-8", charset); + ic = camel_charset_iconv_open ("UTF-8", charset); if (ic == (iconv_t) -1) return FALSE; @@ -1049,13 +1048,14 @@ append_8bit (GString *out, const char *inbuf, int inlen, const char *charset) if (iconv(ic, &inbuf, &inlen, &outbuf, &outlen) == -1) { w(g_warning("Conversion to '%s' failed: %s", charset, strerror(errno))); g_free(outbase); + camel_charset_iconv_close(ic); return FALSE; } *outbuf = 0; g_string_append(out, outbase); g_free(outbase); - iconv_close(ic); + camel_charset_iconv_close(ic); return TRUE; @@ -1141,7 +1141,7 @@ rfc2047_encode_word(GString *outstring, const char *in, int len, const char *typ ascii = alloca (bufflen); if (strcasecmp (type, "UTF-8") != 0) - ic = iconv_open (type, "UTF-8"); + ic = camel_charset_iconv_open (type, "UTF-8"); while (inlen) { int convlen, i, proclen; @@ -1218,9 +1218,8 @@ rfc2047_encode_word(GString *outstring, const char *in, int len, const char *typ } } - if (ic != (iconv_t) -1) { - iconv_close(ic); - } + if (ic != (iconv_t) -1) + camel_charset_iconv_close(ic); } @@ -1795,7 +1794,7 @@ rfc2184_decode (const char *in, int len) inbuf = decword = hex_decode (inptr, inend - inptr); inlen = strlen (inbuf); - ic = iconv_open ("UTF-8", charset); + ic = camel_charset_iconv_open("UTF-8", charset); if (ic != (iconv_t) -1) { int ret; @@ -1810,7 +1809,7 @@ rfc2184_decode (const char *in, int len) decoded = outbase; } - iconv_close (ic); + camel_charset_iconv_close(ic); } else { decoded = decword; } @@ -1950,7 +1949,7 @@ header_decode_param (const char **in, char **paramp, char **valuep, int *is_rfc2 inlen = strlen (inbuf); charset = camel_charset_locale_name (); - ic = iconv_open ("UTF-8", charset ? charset : "ISO-8859-1"); + ic = camel_charset_iconv_open ("UTF-8", charset ? charset : "ISO-8859-1"); if (ic != (iconv_t) -1) { int ret; @@ -1963,7 +1962,7 @@ header_decode_param (const char **in, char **paramp, char **valuep, int *is_rfc2 *outbuf = '\0'; } - iconv_close (ic); + camel_charset_iconv_close (ic); g_free (value); value = outbase; |