aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-02-26 03:43:22 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-02-26 03:43:22 +0800
commit74205e83d12157f4c3c379722a0e6736d19c13ce (patch)
treecc32c6df4eec053249dfe58764e5349306577088
parentf9f6af4bcef7e33543a343048e0da492d3941861 (diff)
downloadgsoc2013-evolution-74205e83d12157f4c3c379722a0e6736d19c13ce.tar.gz
gsoc2013-evolution-74205e83d12157f4c3c379722a0e6736d19c13ce.tar.zst
gsoc2013-evolution-74205e83d12157f4c3c379722a0e6736d19c13ce.zip
Same as the ones below.
2003-02-25 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-message.c: Same as the ones below. * camel-mime-part.c: Reverted back to pre-camel-iconv * camel-filter-search.c: Same as below. * camel-folder-summary.c: Reverted back to pre-camel-iconv * camel.c (camel_init): Reverted to pre-camel-iconv * camel-charset-map.c (camel_charset_locale_name): Removed (part of the revert). (camel_charset_canonical_name): Same. * camel-mime-filter-charset.c: Revert back to using e_iconv from GAL. * camel-mime-part-utils.c: Revert back to using e_iconv from GAL. * camel-mime-utils.c: Revert back to using e_iconv from GAL. * camel-sasl-digest-md5.c: Revert back to using e-iconv from GAL. svn path=/trunk/; revision=20056
-rw-r--r--camel/ChangeLog24
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-charset-map.c170
-rw-r--r--camel/camel-charset-map.h3
-rw-r--r--camel/camel-filter-search.c7
-rw-r--r--camel/camel-folder-summary.c9
-rw-r--r--camel/camel-mime-filter-charset.c15
-rw-r--r--camel/camel-mime-filter-tohtml.c2
-rw-r--r--camel/camel-mime-message.c9
-rw-r--r--camel/camel-mime-part-utils.c19
-rw-r--r--camel/camel-mime-part.c4
-rw-r--r--camel/camel-mime-utils.c77
-rw-r--r--camel/camel-sasl-digest-md5.c14
-rw-r--r--camel/camel-utf8.h2
-rw-r--r--camel/camel.c4
15 files changed, 107 insertions, 254 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 3b557d9b03..34f36dcd53 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,27 @@
+2003-02-25 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-mime-message.c: Same as the ones below.
+
+ * camel-mime-part.c: Reverted back to pre-camel-iconv
+
+ * camel-filter-search.c: Same as below.
+
+ * camel-folder-summary.c: Reverted back to pre-camel-iconv
+
+ * camel.c (camel_init): Reverted to pre-camel-iconv
+
+ * camel-charset-map.c (camel_charset_locale_name): Removed (part
+ of the revert).
+ (camel_charset_canonical_name): Same.
+
+ * camel-mime-filter-charset.c: Revert back to using e_iconv from GAL.
+
+ * camel-mime-part-utils.c: Revert back to using e_iconv from GAL.
+
+ * camel-mime-utils.c: Revert back to using e_iconv from GAL.
+
+ * camel-sasl-digest-md5.c: Revert back to using e-iconv from GAL.
+
2003-02-24 Jeffrey Stedfast <fejj@ximian.com>
* camel-charset-map.c (camel_charset_canonical_name): g_alloca
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 7192e5e48a..119798b233 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -47,7 +47,6 @@ libcamel_la_SOURCES = \
camel-gpg-context.c \
camel-html-parser.c \
camel-http-stream.c \
- camel-iconv.c \
camel-index.c \
camel-internet-address.c \
camel-lock.c \
@@ -149,7 +148,6 @@ libcamelinclude_HEADERS = \
camel-folder.h \
camel-gpg-context.h \
camel-http-stream.h \
- camel-iconv.h \
camel-index.h \
camel-internet-address.h \
camel-i18n.h \
diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c
index 3ae00a5fb8..f81e3c5c6d 100644
--- a/camel/camel-charset-map.c
+++ b/camel/camel-charset-map.c
@@ -299,176 +299,6 @@ camel_charset_best (const char *in, int len)
}
-#ifdef G_THREADS_ENABLED
-static GStaticMutex lock = G_STATIC_MUTEX_INIT;
-#define LOCK() g_static_mutex_lock(&lock)
-#define UNLOCK() g_static_mutex_unlock(&lock)
-#else
-#define LOCK()
-#define UNLOCK()
-#endif
-
-static char *locale_charset = NULL;
-static GHashTable *canon_charsets = NULL;
-
-static void
-canon_charsets_init (int keep)
-{
- char *locale;
-
- LOCK ();
-
- if (canon_charsets != NULL) {
- if (!keep)
- UNLOCK ();
- return;
- }
-
- canon_charsets = g_hash_table_new (g_str_hash, g_str_equal);
-
- locale = setlocale (LC_ALL, NULL);
-
- if (!locale || !strcmp (locale, "C") || !strcmp (locale, "POSIX")) {
- /* The locale "C" or "POSIX" is a portable locale; its
- * LC_CTYPE part corresponds to the 7-bit ASCII character
- * set.
- */
-
- locale_charset = NULL;
- } else {
-#ifdef HAVE_CODESET
- locale_charset = g_strdup (nl_langinfo (CODESET));
- g_ascii_strdown (locale_charset, -1);
-#else
- /* A locale name is typically of the form language[_terri-
- * tory][.codeset][@modifier], where language is an ISO 639
- * language code, territory is an ISO 3166 country code, and
- * codeset is a character set or encoding identifier like
- * ISO-8859-1 or UTF-8.
- */
- char *codeset, *p;
-
- codeset = strchr (locale, '.');
- if (codeset) {
- codeset++;
-
- /* ; is a hack for debian systems and / is a hack for Solaris systems */
- for (p = codeset; *p && !strchr ("@;/", *p); p++)
- ;
- locale_charset = g_strndup (codeset, p - codeset);
- g_ascii_strdown (locale_charset, -1);
- } else {
- /* charset unknown */
- locale_charset = NULL;
- }
-#endif
- }
-
- if (!keep)
- UNLOCK ();
-}
-
-
-/**
- * camel_charset_locale_name:
- *
- * Returns the name of the system's locale charset.
- **/
-const char *
-camel_charset_locale_name (void)
-{
- canon_charsets_init (FALSE);
-
- return locale_charset;
-}
-
-
-/**
- * camel_charset_canonical_name:
- * @charset: charset to canonicalise
- *
- * Returns the charset in its canonical format. This is currently only
- * needed for iso charsets but also handles canonicalisation of
- * windows charsets. May need to expand this to handle canincalisation
- * of more charsets in the future?
- **/
-const char *
-camel_charset_canonical_name (const char *charset)
-{
- char *name, *canon, *tmp;
-
- if (charset == NULL)
- return NULL;
-
- name = g_alloca (strlen (charset) + 1);
- strcpy (name, charset);
- g_ascii_strdown (name, -1);
-
- canon_charsets_init (TRUE);
- canon = g_hash_table_lookup (canon_charsets, name);
- if (canon != NULL) {
- UNLOCK ();
- return canon;
- }
-
- /* Unknown, try canonicalise some basic charset types to something that should work */
- if (strncmp (name, "iso", 3) == 0) {
- /* Convert iso-nnnn-n or isonnnn-n or iso_nnnn-n to iso-nnnn-n or isonnnn-n */
- int iso, codepage;
- char *p;
-
- tmp = name + 3;
- if (*tmp == '-' || *tmp == '_')
- tmp++;
-
- iso = strtoul (tmp, &p, 10);
-
- if (iso == 10646) {
- /* they all become iso-10646 */
- canon = g_strdup ("iso-10646");
- } else {
- /* iso-8859-# */
- tmp = p;
- if (*tmp == '-' || *tmp == '_')
- tmp++;
-
- codepage = strtoul (tmp, &p, 10);
-
- if (p > tmp) {
- /* codepage is numeric */
- canon = g_strdup_printf ("iso-%d-%d", iso, codepage);
- } else {
- /* codepage is a string - probably iso-2022-jp or something */
- canon = g_strdup_printf ("iso-%d-%s", iso, p);
- }
- }
- } else if (strncmp (name, "windows-", 8) == 0) {
- /* Convert windows-#### and windows-cp#### to windows-cp#### */
- tmp = name + 8;
- if (!strncmp (tmp, "cp", 2))
- tmp += 2;
- canon = g_strdup_printf ("windows-cp%s", tmp);
- } else if (strncmp (name, "microsoft-", 10) == 0) {
- /* Convert microsoft-#### or microsoft-cp#### to windows-cp#### */
- tmp = name + 10;
- if (!strncmp (tmp, "cp", 2))
- tmp += 2;
- canon = g_strdup_printf ("windows-cp%s", tmp);
- } else if (strncmp (name, "cp125", 5) == 0) {
- /* Convert cp125# to windows-cp#### */
- canon = g_strdup_printf ("windows-%s", name);
- } else {
- /* Just assume its ok enough as is, case and all */
- canon = g_strdup (charset);
- }
-
- g_hash_table_insert (canon_charsets, g_strdup (name), canon);
- UNLOCK ();
-
- return canon;
-}
-
-
/**
* camel_charset_iso_to_windows:
* @isocharset: a canonicalised ISO charset
diff --git a/camel/camel-charset-map.h b/camel/camel-charset-map.h
index d18f782ea0..b0a47615ca 100644
--- a/camel/camel-charset-map.h
+++ b/camel/camel-charset-map.h
@@ -38,9 +38,6 @@ struct _CamelCharset {
void camel_charset_init(CamelCharset *);
void camel_charset_step(CamelCharset *, const char *in, int len);
-const char *camel_charset_locale_name (void);
-const char *camel_charset_canonical_name (const char *charset);
-
const char *camel_charset_best_name (CamelCharset *);
/* helper function */
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 2439a9b23d..627b7ad78b 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -42,9 +42,10 @@
#include <signal.h>
#include <sys/wait.h>
-#include "e-util/e-sexp.h"
+#include <e-util/e-sexp.h>
+
+#include <gal/util/e-iconv.h>
-#include "camel-charset-map.h"
#include "camel-mime-message.h"
#include "camel-provider.h"
#include "camel-session.h"
@@ -163,7 +164,7 @@ check_header (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMess
ct = camel_mime_part_get_content_type (CAMEL_MIME_PART (message));
if (ct) {
charset = header_content_type_param (ct, "charset");
- charset = camel_charset_canonical_name (charset);
+ charset = e_iconv_charset_name (charset);
}
}
}
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 75f22121ea..b9645754cb 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -33,9 +33,10 @@
#include <errno.h>
#include <stdlib.h>
+#include <gal/util/e-iconv.h>
+
#include "camel-folder-summary.h"
-#include <camel/camel-charset-map.h>
#include <camel/camel-file-utils.h>
#include <camel/camel-mime-filter.h>
#include <camel/camel-mime-filter-index.h>
@@ -1575,7 +1576,7 @@ message_info_new(CamelFolderSummary *s, struct _header_raw *h)
&& (strcasecmp(charset, "us-ascii") == 0))
charset = NULL;
- charset = camel_charset_canonical_name (charset);
+ charset = charset ? e_iconv_charset_name (charset) : NULL;
subject = summary_format_string(h, "subject", charset);
from = summary_format_address(h, "from");
@@ -1836,7 +1837,7 @@ content_info_new (CamelFolderSummary *s, struct _header_raw *h)
ci = camel_folder_summary_content_info_new (s);
- charset = camel_charset_locale_name ();
+ charset = e_iconv_locale_charset ();
ci->id = header_msgid_decode (header_raw_find (&h, "content-id", NULL));
ci->description = header_decode_string (header_raw_find (&h, "content-description", NULL), NULL);
ci->encoding = header_content_encoding_decode (header_raw_find (&h, "content-transfer-encoding", NULL));
@@ -2562,7 +2563,7 @@ camel_message_info_new_from_header (struct _header_raw *header)
&& (strcasecmp(charset, "us-ascii") == 0))
charset = NULL;
- charset = camel_charset_canonical_name (charset);
+ charset = charset ? e_iconv_charset_name (charset) : NULL;
subject = summary_format_string(header, "subject", charset);
from = summary_format_address(header, "from");
diff --git a/camel/camel-mime-filter-charset.c b/camel/camel-mime-filter-charset.c
index 0e1c111786..6d5bb4f000 100644
--- a/camel/camel-mime-filter-charset.c
+++ b/camel/camel-mime-filter-charset.c
@@ -27,9 +27,10 @@
#include <string.h>
#include <errno.h>
+#include <gal/util/e-iconv.h>
+
#include "camel-mime-filter-charset.h"
#include "camel-charset-map.h"
-#include "camel-iconv.h"
#define d(x)
@@ -65,7 +66,7 @@ camel_mime_filter_charset_finalize(CamelObject *o)
g_free(f->from);
g_free(f->to);
if (f->ic != (iconv_t) -1) {
- camel_iconv_close (f->ic);
+ e_iconv_close (f->ic);
f->ic = (iconv_t) -1;
}
}
@@ -81,7 +82,7 @@ reset(CamelMimeFilter *mf)
/* what happens with the output bytes if this resets the state? */
if (f->ic != (iconv_t) -1) {
buffer = buf;
- camel_iconv (f->ic, NULL, 0, &buffer, &outlen);
+ e_iconv (f->ic, NULL, 0, &buffer, &outlen);
}
}
@@ -105,7 +106,7 @@ complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out,
if (inleft > 0) {
do {
- converted = camel_iconv (charset->ic, &inbuf, &inleft, &outbuf, &outleft);
+ converted = e_iconv (charset->ic, &inbuf, &inleft, &outbuf, &outleft);
if (converted == (size_t) -1) {
if (errno == E2BIG) {
/*
@@ -145,7 +146,7 @@ complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out,
}
/* flush the iconv conversion */
- camel_iconv (charset->ic, NULL, NULL, &outbuf, &outleft);
+ e_iconv (charset->ic, NULL, NULL, &outbuf, &outleft);
*out = mf->outbuf;
*outlen = mf->outsize - outleft;
@@ -179,7 +180,7 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s
inleft = len;
do {
- converted = camel_iconv (charset->ic, &inbuf, &inleft, &outbuf, &outleft);
+ converted = e_iconv (charset->ic, &inbuf, &inleft, &outbuf, &outleft);
if (converted == (size_t) -1) {
if (errno == E2BIG || errno == EINVAL)
break;
@@ -259,7 +260,7 @@ camel_mime_filter_charset_new_convert (const char *from_charset, const char *to_
new = CAMEL_MIME_FILTER_CHARSET (camel_object_new (camel_mime_filter_charset_get_type ()));
- new->ic = camel_iconv_open (to_charset, from_charset);
+ new->ic = e_iconv_open (to_charset, from_charset);
if (new->ic == (iconv_t) -1) {
g_warning ("Cannot create charset conversion from %s to %s: %s",
from_charset, to_charset, g_strerror (errno));
diff --git a/camel/camel-mime-filter-tohtml.c b/camel/camel-mime-filter-tohtml.c
index 320ebf34fc..60c4686824 100644
--- a/camel/camel-mime-filter-tohtml.c
+++ b/camel/camel-mime-filter-tohtml.c
@@ -155,7 +155,7 @@ writeln (CamelMimeFilter *filter, const char *in, const char *inend, char *outpt
outptr = check_size (filter, outptr, outend, 16);
- u = camel_utf8_getc_limit(&inptr, inend);
+ u = camel_utf8_getc_limit ((const unsigned char **) &inptr, inend);
switch (u) {
case 0xffff:
g_warning("Truncated utf8 buffer");
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 6bd1f7360e..aa15eeec5f 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -32,7 +32,10 @@
#include <string.h>
#include <errno.h>
-#include "camel-charset-map.h"
+#include <gal/util/e-iconv.h>
+
+#include <e-util/e-time-utils.h>
+
#include "camel-mime-message.h"
#include "camel-multipart.h"
#include "camel-stream-mem.h"
@@ -44,8 +47,6 @@
#include "camel-mime-filter-charset.h"
#include "camel-mime-filter-bestenc.h"
-#include "e-time-utils.h"
-
#define d(x)
/* these 2 below should be kept in sync */
@@ -544,7 +545,7 @@ process_header (CamelMedium *medium, const char *header_name, const char *header
g_free (message->subject);
if (((CamelMimePart *) message)->content_type) {
charset = header_content_type_param (((CamelMimePart *) message)->content_type, "charset");
- charset = camel_charset_canonical_name (charset);
+ charset = e_iconv_charset_name (charset);
} else
charset = NULL;
message->subject = g_strstrip (header_decode_string (header_value, charset));
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index c7c0d15907..f7f1d7dfe7 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -29,12 +29,12 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <ctype.h>
#include <errno.h>
-#include <glib/gunicode.h>
+#include <gal/util/e-iconv.h>
#include "string-utils.h"
-#include "camel-iconv.h"
#include "camel-charset-map.h"
#include "camel-mime-part-utils.h"
#include "camel-mime-message.h"
@@ -87,7 +87,7 @@ check_html_charset(char *buffer, int length)
&& (val = camel_html_parser_attr(hp, "content"))
&& (ct = header_content_type_decode(val))) {
charset = header_content_type_param(ct, "charset");
- charset = camel_charset_canonical_name (charset);
+ charset = e_iconv_charset_name (charset);
header_content_type_unref(ct);
}
break;
@@ -118,7 +118,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from)
d(fwrite(in->data, 1, (int)in->len, stdout));
d(printf("\n"));
- cd = camel_iconv_open(to, from);
+ cd = e_iconv_open(to, from);
if (cd == (iconv_t) -1) {
g_warning ("Cannot convert from '%s' to '%s': %s", from, to, strerror (errno));
return NULL;
@@ -135,7 +135,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from)
outbuf = out->data + converted;
outleft = outlen - converted;
- converted = camel_iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
+ converted = e_iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
if (converted == (size_t) -1) {
if (errno != E2BIG && errno != EINVAL)
goto fail;
@@ -164,7 +164,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from)
*/
/* flush the iconv conversion */
- camel_iconv (cd, NULL, NULL, &outbuf, &outleft);
+ e_iconv (cd, NULL, NULL, &outbuf, &outleft);
/* now set the true length on the GByteArray */
converted = outbuf - (char *)out->data;
@@ -174,7 +174,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from)
d(fwrite(out->data, 1, (int)out->len, stdout));
d(printf("\n"));
- camel_iconv_close (cd);
+ e_iconv_close (cd);
return out;
@@ -183,7 +183,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from)
g_byte_array_free (out, TRUE);
- camel_iconv_close (cd);
+ e_iconv_close (cd);
return NULL;
}
@@ -262,7 +262,7 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser
ct = camel_mime_parser_content_type (mp);
if (header_content_type_is (ct, "text", "*")) {
charset = header_content_type_param (ct, "charset");
- charset = camel_charset_canonical_name (charset);
+ charset = e_iconv_charset_name (charset);
if (fdec) {
d(printf ("Adding CRLF conversion filter\n"));
@@ -311,6 +311,7 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser
* as being in ISO-8859-1 even when in fact they contain funny
* characters from the Windows-CP1252 superset.
*/
+ /* FIXME: not all systems will use the canonical "iso-8859-#" format */
if (!strncasecmp (charset, "iso-8859", 8)) {
/* check for Windows-specific chars... */
if (broken_windows_charset (buffer, charset))
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 765a9af5b5..c33a351413 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -31,6 +31,8 @@
#include <ctype.h>
#include <errno.h>
+#include <gal/util/e-iconv.h>
+
#include "camel-mime-parser.h"
#include "camel-stream-mem.h"
#include "camel-stream-filter.h"
@@ -222,7 +224,7 @@ process_header(CamelMedium *medium, const char *header_name, const char *header_
g_free (mime_part->description);
if (mime_part->content_type) {
charset = header_content_type_param (mime_part->content_type, "charset");
- charset = camel_charset_canonical_name (charset);
+ charset = e_iconv_charset_name (charset);
} else
charset = NULL;
mime_part->description = g_strstrip (header_decode_string (header_value, charset));
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index b12c116b28..9513d920e3 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -46,10 +46,9 @@
#include <regex.h>
#include <glib.h>
-#include <glib/gunicode.h>
-#include "e-time-utils.h"
+#include <gal/util/e-iconv.h>
+#include <e-util/e-time-utils.h>
-#include "camel-iconv.h"
#include "camel-mime-utils.h"
#include "camel-charset-map.h"
#include "camel-service.h" /* for camel_gethostbyname() */
@@ -1012,7 +1011,7 @@ rfc2047_decode_word(const char *in, size_t len)
d(printf("found ?, encoding is '%c'\n", inptr[0]));
inptr++;
tmplen = inend-inptr-2;
- decword = alloca(tmplen); /* this will always be more-than-enough room */
+ decword = g_alloca (tmplen); /* this will always be more-than-enough room */
switch(toupper(inptr[0])) {
case 'Q':
inlen = quoted_decode(inptr+2, tmplen, decword);
@@ -1033,7 +1032,7 @@ rfc2047_decode_word(const char *in, size_t len)
if (inlen > 0) {
/* yuck, all this snot is to setup iconv! */
tmplen = inptr - in - 3;
- encname = alloca (tmplen + 1);
+ encname = g_alloca (tmplen + 1);
memcpy (encname, in + 2, tmplen);
encname[tmplen] = '\0';
@@ -1049,30 +1048,30 @@ rfc2047_decode_word(const char *in, size_t len)
if (p)
*p = '\0';
- charset = camel_charset_canonical_name (encname);
+ charset = e_iconv_charset_name (encname);
inbuf = decword;
outlen = inlen * 6 + 16;
- outbase = alloca (outlen);
+ outbase = g_alloca (outlen);
outbuf = outbase;
retry:
- ic = camel_iconv_open ("UTF-8", charset);
+ ic = e_iconv_open ("UTF-8", charset);
if (ic != (iconv_t) -1) {
- ret = camel_iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
+ ret = e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
if (ret != (size_t) -1) {
- camel_iconv (ic, NULL, 0, &outbuf, &outlen);
+ e_iconv (ic, NULL, 0, &outbuf, &outlen);
*outbuf = 0;
decoded = g_strdup (outbase);
}
- camel_iconv_close (ic);
+ e_iconv_close (ic);
} else {
w(g_warning ("Cannot decode charset, header display may be corrupt: %s: %s",
charset, strerror (errno)));
if (!retried) {
- charset = camel_charset_locale_name ();
+ charset = e_iconv_locale_charset ();
if (!charset)
charset = "iso-8859-1";
@@ -1120,24 +1119,24 @@ append_8bit (GString *out, const char *inbuf, size_t inlen, const char *charset)
size_t outlen;
iconv_t ic;
- ic = camel_iconv_open ("UTF-8", charset);
+ ic = e_iconv_open ("UTF-8", charset);
if (ic == (iconv_t) -1)
return FALSE;
outlen = inlen * 6 + 16;
outbuf = outbase = g_malloc(outlen);
- if (camel_iconv (ic, &inbuf, &inlen, &outbuf, &outlen) == (size_t) -1) {
+ if (e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen) == (size_t) -1) {
w(g_warning("Conversion to '%s' failed: %s", charset, strerror (errno)));
g_free(outbase);
- camel_iconv_close (ic);
+ e_iconv_close (ic);
return FALSE;
}
*outbuf = 0;
g_string_append(out, outbase);
g_free(outbase);
- camel_iconv_close (ic);
+ e_iconv_close (ic);
return TRUE;
@@ -1151,9 +1150,9 @@ header_decode_text (const char *in, size_t inlen, const char *default_charset)
const char *inptr, *inend, *start, *chunk, *locale_charset;
char *dword = NULL;
- locale_charset = camel_charset_locale_name ();
+ locale_charset = e_iconv_locale_charset ();
- out = g_string_new("");
+ out = g_string_new ("");
inptr = in;
inend = inptr + inlen;
chunk = NULL;
@@ -1224,14 +1223,14 @@ rfc2047_encode_word(GString *outstring, const char *in, size_t len, const char *
/* convert utf8->encoding */
bufflen = len * 6 + 16;
- buffer = alloca (bufflen);
+ buffer = g_alloca (bufflen);
inlen = len;
inptr = in;
- ascii = alloca (bufflen);
+ ascii = g_alloca (bufflen);
if (strcasecmp (type, "UTF-8") != 0)
- ic = camel_iconv_open (type, "UTF-8");
+ ic = e_iconv_open (type, "UTF-8");
while (inlen) {
size_t convlen, proclen;
@@ -1279,13 +1278,13 @@ rfc2047_encode_word(GString *outstring, const char *in, size_t len, const char *
hopefully-small-enough chunks, and leave it at that */
convlen = MIN(inlen, CAMEL_FOLD_PREENCODED);
p = inptr;
- if (camel_iconv (ic, &inptr, &convlen, &out, &outlen) == (size_t) -1) {
+ if (e_iconv (ic, &inptr, &convlen, &out, &outlen) == (size_t) -1) {
w(g_warning("Conversion problem: conversion truncated: %s", strerror (errno)));
/* blah, we include it anyway, better than infinite loop ... */
inptr = p + convlen;
} else {
/* make sure we flush out any shift state */
- camel_iconv (ic, NULL, 0, &out, &outlen);
+ e_iconv (ic, NULL, 0, &out, &outlen);
}
inlen -= (inptr - p);
}
@@ -1310,7 +1309,7 @@ rfc2047_encode_word(GString *outstring, const char *in, size_t len, const char *
}
if (ic != (iconv_t) -1)
- camel_iconv_close (ic);
+ e_iconv_close (ic);
}
@@ -1867,7 +1866,7 @@ rfc2184_decode (const char *in, size_t len)
return NULL;
encoding = g_strndup (in, inptr - in);
- charset = camel_charset_canonical_name (encoding);
+ charset = e_iconv_charset_name (encoding);
g_free (encoding);
inptr = memchr (inptr + 1, '\'', inend - inptr - 1);
@@ -1884,22 +1883,22 @@ rfc2184_decode (const char *in, size_t len)
inbuf = decword = hex_decode (inptr, inend - inptr);
inlen = strlen (inbuf);
- ic = camel_iconv_open ("UTF-8", charset);
+ ic = e_iconv_open ("UTF-8", charset);
if (ic != (iconv_t) -1) {
size_t ret;
outlen = inlen * 6 + 16;
outbuf = outbase = g_malloc (outlen);
- ret = camel_iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
+ ret = e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
if (ret != (size_t) -1) {
- camel_iconv (ic, NULL, 0, &outbuf, &outlen);
+ e_iconv (ic, NULL, 0, &outbuf, &outlen);
*outbuf = '\0';
g_free (decoded);
decoded = outbase;
}
- camel_iconv_close (ic);
+ e_iconv_close (ic);
} else {
decoded = decword;
}
@@ -2039,21 +2038,21 @@ header_decode_param (const char **in, char **paramp, char **valuep, int *is_rfc2
inbuf = value;
inlen = strlen (inbuf);
- charset = camel_charset_locale_name ();
- ic = camel_iconv_open ("UTF-8", charset ? charset : "ISO-8859-1");
+ charset = e_iconv_locale_charset ();
+ ic = e_iconv_open ("UTF-8", charset ? charset : "ISO-8859-1");
if (ic != (iconv_t) -1) {
size_t ret;
outlen = inlen * 6 + 16;
outbuf = outbase = g_malloc (outlen);
- ret = camel_iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
+ ret = e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
if (ret != (size_t) -1) {
- camel_iconv (ic, NULL, 0, &outbuf, &outlen);
+ e_iconv (ic, NULL, 0, &outbuf, &outlen);
*outbuf = '\0';
}
- camel_iconv_close (ic);
+ e_iconv_close (ic);
g_free (value);
value = outbase;
@@ -2968,7 +2967,7 @@ header_encode_param (const unsigned char *in, gboolean *encoded)
charset = "iso-8859-1";
if (strcasecmp (charset, "UTF-8") != 0)
- cd = camel_iconv_open (charset, "UTF-8");
+ cd = e_iconv_open (charset, "UTF-8");
if (cd == (iconv_t) -1) {
charset = "UTF-8";
@@ -2984,13 +2983,13 @@ header_encode_param (const unsigned char *in, gboolean *encoded)
outptr = outbuf = g_malloc (outleft);
inbuf = in;
- if (camel_iconv (cd, &inbuf, &inleft, &outptr, &outleft) == (size_t) -1) {
+ if (e_iconv (cd, &inbuf, &inleft, &outptr, &outleft) == (size_t) -1) {
w(g_warning ("Conversion problem: conversion truncated: %s", strerror (errno)));
} else {
- camel_iconv (cd, NULL, 0, &outptr, &outleft);
+ e_iconv (cd, NULL, 0, &outptr, &outleft);
}
- camel_iconv_close (cd);
+ e_iconv_close (cd);
inptr = outbuf;
inend = outptr;
@@ -3547,7 +3546,7 @@ header_raw_append_parse(struct _header_raw **list, const char *header, int offse
printf("Invalid header line: '%s'\n", header);
return;
}
- name = alloca(fieldlen+1);
+ name = g_alloca (fieldlen + 1);
memcpy(name, header, fieldlen);
name[fieldlen] = 0;
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index be67d32163..7c50c4f4a7 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -2,7 +2,7 @@
/*
* Authors: Jeffrey Stedfast <fejj@ximian.com>
*
- * Copyright 2001 Ximian, Inc. (www.ximian.com)
+ * Copyright 2001-2003 Ximian, Inc. (www.ximian.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@@ -20,6 +20,7 @@
*
*/
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -31,7 +32,8 @@
#include <e-util/md5-utils.h>
-#include "camel-iconv.h"
+#include <gal/util/e-iconv.h>
+
#include "camel-charset-map.h"
#include "camel-mime-utils.h"
#include "camel-sasl-digest-md5.h"
@@ -699,18 +701,18 @@ digest_response (struct _DigestResponse *resp)
const char *inbuf;
iconv_t cd;
- charset = camel_charset_locale_name ();
+ charset = e_iconv_locale_charset ();
if (!charset)
charset = "iso-8859-1";
- cd = camel_iconv_open (resp->charset, charset);
+ cd = e_iconv_open (resp->charset, charset);
len = strlen (resp->username);
outlen = 2 * len; /* plenty of space */
outbuf = username = g_malloc0 (outlen + 1);
inbuf = resp->username;
- if (cd == (iconv_t) -1 || camel_iconv (cd, &inbuf, &len, &outbuf, &outlen) == (size_t) -1) {
+ if (cd == (iconv_t) -1 || e_iconv (cd, &inbuf, &len, &outbuf, &outlen) == (size_t) -1) {
/* We can't convert to UTF-8 - pretend we never got a charset param? */
g_free (resp->charset);
resp->charset = NULL;
@@ -721,7 +723,7 @@ digest_response (struct _DigestResponse *resp)
}
if (cd != (iconv_t) -1)
- camel_iconv_close (cd);
+ e_iconv_close (cd);
g_byte_array_append (buffer, username, strlen (username));
g_free (username);
diff --git a/camel/camel-utf8.h b/camel/camel-utf8.h
index 7d6fac5410..47b54012c9 100644
--- a/camel/camel-utf8.h
+++ b/camel/camel-utf8.h
@@ -4,6 +4,7 @@
void camel_utf8_putc(unsigned char **ptr, guint32 c);
guint32 camel_utf8_getc(const unsigned char **ptr);
+guint32 camel_utf8_getc_limit (const unsigned char **ptr, const unsigned char *end);
/* utility func for utf8 gstrings */
void g_string_append_u(GString *out, guint32 c);
@@ -12,5 +13,4 @@ void g_string_append_u(GString *out, guint32 c);
char *camel_utf7_utf8(const char *ptr);
char *camel_utf8_utf7(const char *ptr);
-
#endif /* ! _CAMEL_UTF8_H */
diff --git a/camel/camel.c b/camel/camel.c
index 0a3974a913..79f82eb345 100644
--- a/camel/camel.c
+++ b/camel/camel.c
@@ -58,8 +58,6 @@ camel_shutdown (void)
camel_certdb_save (certdb);
camel_object_unref (certdb);
}
-
- camel_iconv_shutdown ();
}
gint
@@ -82,8 +80,6 @@ camel_init (const char *configdir, gboolean nss_init)
/* initialise global camel_object_type */
camel_object_get_type();
- camel_iconv_init ();
-
camel_mime_utils_init ();
#ifdef HAVE_NSS