aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-07-20 07:11:13 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-07-20 07:11:13 +0800
commit49e81a0bda0d8914a4785d73e366b680186e9406 (patch)
treef2d637e244fdc12eb9b822b0586140c879b85e71
parentd20ac81f624dd26da52a921add73cb96f96cddbb (diff)
downloadgsoc2013-evolution-49e81a0bda0d8914a4785d73e366b680186e9406.tar
gsoc2013-evolution-49e81a0bda0d8914a4785d73e366b680186e9406.tar.gz
gsoc2013-evolution-49e81a0bda0d8914a4785d73e366b680186e9406.tar.bz2
gsoc2013-evolution-49e81a0bda0d8914a4785d73e366b680186e9406.tar.lz
gsoc2013-evolution-49e81a0bda0d8914a4785d73e366b680186e9406.tar.xz
gsoc2013-evolution-49e81a0bda0d8914a4785d73e366b680186e9406.tar.zst
gsoc2013-evolution-49e81a0bda0d8914a4785d73e366b680186e9406.zip
Modified to treat the return value from camel_charset_locale_name() as a
2001-07-19 Jeffrey Stedfast <fejj@ximian.com> * camel-pgp-context.c (pgp_verify): Modified to treat the return value from camel_charset_locale_name() as a const char*. * camel-sasl-digest-md5.c (digest_response): Modified to treat the return value from camel_charset_locale_name() as a const char*. * camel-charset-map.c (camel_charset_locale_name): Modify to return const char* by returning the static locale_charset which is created inside of camel_charset_map_init(). (camel_charset_map_init): Find the locale charset here and set the static variable. svn path=/trunk/; revision=11245
-rw-r--r--camel/ChangeLog52
-rw-r--r--camel/camel-charset-map.c75
-rw-r--r--camel/camel-charset-map.h2
-rw-r--r--camel/camel-pgp-context.c6
-rw-r--r--camel/camel-sasl-digest-md5.c6
5 files changed, 79 insertions, 62 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 3e767da515..9119e3439c 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,26 +1,42 @@
+2001-07-19 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-pgp-context.c (pgp_verify): Modified to treat the return
+ value from camel_charset_locale_name() as a const char*.
+
+ * camel-sasl-digest-md5.c (digest_response): Modified to treat the
+ return value from camel_charset_locale_name() as a const char*.
+
+ * camel-charset-map.c (camel_charset_locale_name): Modify to
+ return const char* by returning the static locale_charset which is
+ created inside of camel_charset_map_init().
+ (camel_charset_map_init): Find the locale charset here and set the
+ static variable.
+
2001-07-19 Peter Williams <peterw@ximian.com>
- Policy change: NULL url's are no longer allowed in CamelFolderInfos. They used
- to signify that the folder was, in IMAP jargon, NoSelect; now the same effect
- is achieved by adding a "noselect=yes" parameter to the end of the URL. As far
- as I know, IMAP is the only affected provider.
+ Policy change: NULL url's are no longer allowed in
+ CamelFolderInfos. They used to signify that the folder was, in
+ IMAP jargon, NoSelect; now the same effect is achieved by adding a
+ "noselect=yes" parameter to the end of the URL. As far as I know,
+ IMAP is the only affected provider.
- * providers/imap/camel-imap-store.c (delete_folder): New function. Implement
- folder deletion.
- (camel_imap_store_class_init): Set the delete_folder class function here.
- (get_folder_status): New function. Utility wrapper around the STATUS command.
- (create_folder): If the parent folder is NoSelect but is empty, delete it
- and recreate it as a a subfolder-containing folder. If it is NoSelect but
- contains messages, set an exception.
- (parse_list_response_as_folder_info): Always set the FolderInfo's URL, but
- add a NoSelect parameter if it isn't selectable.
- (get_folder_info_online): Change logic of removing the namespace to reflect
- URL change. Same for logic of checking unread counts.
+ * providers/imap/camel-imap-store.c (delete_folder): New
+ function. Implement folder deletion.
+ (camel_imap_store_class_init): Set the delete_folder class
+ function here.
+ (get_folder_status): New function. Utility wrapper around the
+ STATUS command.
+ (create_folder): If the parent folder is NoSelect but is empty,
+ delete it and recreate it as a a subfolder-containing folder. If
+ it is NoSelect but contains messages, set an exception.
+ (parse_list_response_as_folder_info): Always set the FolderInfo's
+ URL, but add a NoSelect parameter if it isn't selectable.
+ (get_folder_info_online): Change logic of removing the namespace
+ to reflect URL change. Same for logic of checking unread counts.
(get_folder_info_online): Use get_folder_status to simplify this.
- * camel-store.c (camel_folder_info_build): When creating
- dummy parents, copy the child's URL and set the NoSelect
- parameter.
+ * camel-store.c (camel_folder_info_build): When creating dummy
+ parents, copy the child's URL and set the NoSelect parameter.
2001-07-19 Jeffrey Stedfast <fejj@ximian.com>
diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c
index d609321997..d03da27c61 100644
--- a/camel/camel-charset-map.c
+++ b/camel/camel-charset-map.c
@@ -217,6 +217,7 @@ static pthread_mutex_t iconv_charsets_lock = PTHREAD_MUTEX_INITIALIZER;
#endif /* ENABLE_THREADS */
static GHashTable *iconv_charsets = NULL;
+static char *locale_charset = NULL;
struct {
char *charset;
@@ -248,11 +249,13 @@ camel_charset_map_shutdown (void)
{
g_hash_table_foreach (iconv_charsets, shutdown_foreach, NULL);
g_hash_table_destroy (iconv_charsets);
+ g_free (locale_charset);
}
void
camel_charset_map_init (void)
{
+ char *locale;
int i;
if (iconv_charsets)
@@ -264,6 +267,33 @@ camel_charset_map_init (void)
g_strdup (known_iconv_charsets[i].iconv_name));
}
+ 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 {
+ /* 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 *p;
+ int len;
+
+ p = strchr (locale, '@');
+ len = p ? (p - locale) : strlen (locale);
+ if ((p = strchr (locale, '.'))) {
+ locale_charset = g_strndup (p + 1, len - (p - locale) + 1);
+ g_strdown (locale_charset);
+ }
+ }
+
g_atexit (camel_charset_map_shutdown);
}
@@ -327,12 +357,12 @@ camel_charset_best_mask(unsigned int mask)
}
const char *
-camel_charset_best_name(CamelCharset *charset)
+camel_charset_best_name (CamelCharset *charset)
{
if (charset->level == 1)
return "ISO-8859-1";
else if (charset->level == 2)
- return camel_charset_best_mask(charset->mask);
+ return camel_charset_best_mask (charset->mask);
else
return NULL;
@@ -340,48 +370,19 @@ camel_charset_best_name(CamelCharset *charset)
/* finds the minimum charset for this string NULL means US-ASCII */
const char *
-camel_charset_best(const char *in, int len)
+camel_charset_best (const char *in, int len)
{
CamelCharset charset;
- camel_charset_init(&charset);
- camel_charset_step(&charset, in, len);
- return camel_charset_best_name(&charset);
+ camel_charset_init (&charset);
+ camel_charset_step (&charset, in, len);
+ return camel_charset_best_name (&charset);
}
-char *
+const char *
camel_charset_locale_name (void)
{
- char *locale, *charset = NULL;
-
- 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.
- */
-
- return NULL;
- } 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 *p;
- int len;
-
- p = strchr (locale, '@');
- len = p ? (p - locale) : strlen (locale);
- if ((p = strchr (locale, '.'))) {
- charset = g_strndup (p + 1, len - (p - locale) + 1);
- g_strdown (charset);
- }
- }
-
- return charset;
+ return locale_charset;
}
const char *
diff --git a/camel/camel-charset-map.h b/camel/camel-charset-map.h
index 47b3cc0cab..0a0efb1cd3 100644
--- a/camel/camel-charset-map.h
+++ b/camel/camel-charset-map.h
@@ -37,7 +37,7 @@ const char *camel_charset_best_name(CamelCharset *);
/* helper function */
const char *camel_charset_best(const char *in, int len);
-char *camel_charset_locale_name (void);
+const char *camel_charset_locale_name (void);
const char *camel_charset_get_iconv_friendly_name (const char *name);
diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c
index cde9f76d25..3f377909f7 100644
--- a/camel/camel-pgp-context.c
+++ b/camel/camel-pgp-context.c
@@ -981,7 +981,8 @@ pgp_verify (CamelCipherContext *ctx, CamelCipherHash hash, CamelStream *istream,
}
if (diagnostics) {
- char *locale, *desc, *outbuf;
+ const char *locale;
+ char *desc, *outbuf;
size_t inlen, outlen;
iconv_t cd;
@@ -992,10 +993,9 @@ pgp_verify (CamelCipherContext *ctx, CamelCipherHash hash, CamelStream *istream,
locale = camel_charset_locale_name ();
if (!locale)
- locale = g_strdup ("iso-8859-1");
+ locale = "iso-8859-1";
cd = iconv_open ("UTF-8", locale);
- g_free (locale);
if (cd != (iconv_t) -1) {
const char *inbuf;
diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c
index 51b2026abc..106414fa2c 100644
--- a/camel/camel-sasl-digest-md5.c
+++ b/camel/camel-sasl-digest-md5.c
@@ -692,17 +692,17 @@ digest_response (struct _DigestResponse *resp)
g_byte_array_append (buffer, "username=\"", 10);
if (resp->charset) {
/* Encode the username using the requested charset */
- char *charset, *username, *outbuf;
+ char *username, *outbuf;
+ const char *charset;
size_t len, outlen;
const char *buf;
iconv_t cd;
charset = camel_charset_locale_name ();
if (!charset)
- charset = g_strdup ("iso-8859-1");
+ charset = "iso-8859-1";
cd = iconv_open (resp->charset, charset);
- g_free (charset);
len = strlen (resp->username);
outlen = 2 * len; /* plenty of space */