aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-13 22:30:07 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-13 22:30:07 +0800
commit0472611db8f67bb0c4fc09138e1131802d85b9c3 (patch)
tree172974a6cace4cfdc16867ad52f0701470e93387
parent18aeb0ec732ed54dcf556d62162fe0392807a675 (diff)
downloadgsoc2013-evolution-0472611db8f67bb0c4fc09138e1131802d85b9c3.tar
gsoc2013-evolution-0472611db8f67bb0c4fc09138e1131802d85b9c3.tar.gz
gsoc2013-evolution-0472611db8f67bb0c4fc09138e1131802d85b9c3.tar.bz2
gsoc2013-evolution-0472611db8f67bb0c4fc09138e1131802d85b9c3.tar.lz
gsoc2013-evolution-0472611db8f67bb0c4fc09138e1131802d85b9c3.tar.xz
gsoc2013-evolution-0472611db8f67bb0c4fc09138e1131802d85b9c3.tar.zst
gsoc2013-evolution-0472611db8f67bb0c4fc09138e1131802d85b9c3.zip
those two func go here now.
1999-08-13 bertrand <Bertrand.Guiheneuf@aful.org> * camel/hash-table-utils.c (g_strcase_equal): (g_strcase_hash): those two func go here now. * camel/hash_table_utils.c (hash_table_generic_free): free a (gpointer, gpointer) hash table pair. * camel/camel-mime-message.c (camel_mime_message_init): use case insensitive hash table functions. (_set_flag): (camel_mime_message_set_flag): (_get_flag): (camel_mime_message_get_flag): Use const for flag name, they are now duplicated. svn path=/trunk/; revision=1110
-rw-r--r--ChangeLog17
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-mime-message.c28
-rw-r--r--camel/camel-mime-message.h8
-rw-r--r--camel/camel-session.c1
-rw-r--r--camel/hash-table-utils.c79
-rw-r--r--camel/hash-table-utils.h43
-rw-r--r--camel/string-utils.c44
-rw-r--r--camel/string-utils.h3
9 files changed, 161 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index 66ec5e040f..d23ba7dcb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+1999-08-13 bertrand <Bertrand.Guiheneuf@aful.org>
+
+ * camel/hash-table-utils.c (g_strcase_equal):
+ (g_strcase_hash): those two func go here now.
+
+ * camel/hash_table_utils.c (hash_table_generic_free):
+ free a (gpointer, gpointer) hash table pair.
+
+ * camel/camel-mime-message.c (camel_mime_message_init): use
+ case insensitive hash table functions.
+ (_set_flag):
+ (camel_mime_message_set_flag):
+ (_get_flag):
+ (camel_mime_message_get_flag):
+ Use const for flag name, they are now
+ duplicated.
+
1999-08-12 bertrand <Bertrand.Guiheneuf@aful.org>
* tests/ui-tests/store_listing.c (show_folder_messages):
diff --git a/camel/Makefile.am b/camel/Makefile.am
index fc3f155726..5f23d2ee9c 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -32,6 +32,7 @@ libcamel_la_SOURCES = \
gmime-content-field.c \
gmime-utils.c \
gstring-util.c \
+ hash-table-utils.c \
string-utils.c \
url-util.c
@@ -56,6 +57,7 @@ libcamelinclude_HEADERS = \
gmime-content-field.h \
gmime-utils.h \
gstring-util.h \
+ hash-table-utils.h \
string-utils.h \
url-util.h
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index acff82ca71..019903d75a 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -28,6 +28,7 @@
#include "string-utils.h"
#include "camel-log.h"
#include "gmime-utils.h"
+#include "hash-table-utils.h"
typedef enum {
HEADER_UNKNOWN,
@@ -65,8 +66,8 @@ static void _add_recipient (CamelMimeMessage *mime_message, gchar *recipient_typ
static void _remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient);
static const GList *_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type);
-static void _set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value);
-static gboolean _get_flag (CamelMimeMessage *mime_message, gchar *flag);
+static void _set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value);
+static gboolean _get_flag (CamelMimeMessage *mime_message, const gchar *flag);
static void _set_message_number (CamelMimeMessage *mime_message, guint number);
static guint _get_message_number (CamelMimeMessage *mime_message);
@@ -143,8 +144,8 @@ camel_mime_message_init (gpointer object, gpointer klass)
{
CamelMimeMessage *camel_mime_message = CAMEL_MIME_MESSAGE (object);
- camel_mime_message->recipients = g_hash_table_new (g_str_hash, g_str_equal);
- camel_mime_message->flags = g_hash_table_new (g_str_hash, g_str_equal);
+ camel_mime_message->recipients = g_hash_table_new (g_strcase_hash, g_strcase_equal);
+ camel_mime_message->flags = g_hash_table_new (g_strcase_hash, g_strcase_equal);
}
GtkType
@@ -184,10 +185,13 @@ _finalize (GtkObject *object)
if (message->reply_to) g_free (message->reply_to);
if (message->from) g_free (message->from);
-#warning free recipients and flags.
+#warning free recipients.
if (message->folder) gtk_object_unref (GTK_OBJECT (message->folder));
if (message->session) gtk_object_unref (GTK_OBJECT (message->session));
+ if (message->flags)
+ g_hash_table_foreach (message->flags, g_hash_table_generic_free, NULL);
+
GTK_OBJECT_CLASS (parent_class)->finalize (object);
CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimeMessage::finalize\n");
}
@@ -459,7 +463,7 @@ camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const gchar *
static void
-_set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value)
+_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value)
{
gchar old_flags;
gboolean *ptr_value;
@@ -469,16 +473,14 @@ _set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value)
(gpointer)&(ptr_value)) ) {
ptr_value = g_new (gboolean, 1);
- g_hash_table_insert (mime_message->flags, flag, ptr_value);
- } else {
- g_free (flag);
- }
+ g_hash_table_insert (mime_message->flags, g_strdup (flag), ptr_value);
+ }
*ptr_value = value;
}
void
-camel_mime_message_set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value)
+camel_mime_message_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value)
{
CMM_CLASS (mime_message)->set_flag (mime_message, flag, value);
}
@@ -486,7 +488,7 @@ camel_mime_message_set_flag (CamelMimeMessage *mime_message, gchar *flag, gboole
static gboolean
-_get_flag (CamelMimeMessage *mime_message, gchar *flag)
+_get_flag (CamelMimeMessage *mime_message, const gchar *flag)
{
gboolean *value;
value = (gboolean *)g_hash_table_lookup (mime_message->flags, flag);
@@ -494,7 +496,7 @@ _get_flag (CamelMimeMessage *mime_message, gchar *flag)
}
gboolean
-camel_mime_message_get_flag (CamelMimeMessage *mime_message, gchar *flag)
+camel_mime_message_get_flag (CamelMimeMessage *mime_message, const gchar *flag)
{
return CMM_CLASS (mime_message)->get_flag (mime_message, flag);
}
diff --git a/camel/camel-mime-message.h b/camel/camel-mime-message.h
index 17fa510987..f88c78ddbd 100644
--- a/camel/camel-mime-message.h
+++ b/camel/camel-mime-message.h
@@ -95,8 +95,8 @@ typedef struct {
void (*add_recipient) (CamelMimeMessage *mime_message, gchar *recipient_type, gchar *recipient);
void (*remove_recipient) (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient);
const GList * (*get_recipients) (CamelMimeMessage *mime_message, const gchar *recipient_type);
- void (*set_flag) (CamelMimeMessage *mime_message, gchar *flag, gboolean value);
- gboolean (*get_flag) (CamelMimeMessage *mime_message, gchar *flag);
+ void (*set_flag) (CamelMimeMessage *mime_message, const gchar *flag, gboolean value);
+ gboolean (*get_flag) (CamelMimeMessage *mime_message, const gchar *flag);
void (*set_message_number)(CamelMimeMessage *mime_message, guint number);
guint (*get_message_number)(CamelMimeMessage *mime_message);
@@ -126,8 +126,8 @@ void camel_mime_message_add_recipient (CamelMimeMessage *mime_message, gchar *re
void camel_mime_message_remove_recipient (CamelMimeMessage *mime_message, const gchar *recipient_type, const gchar *recipient);
const GList *camel_mime_message_get_recipients (CamelMimeMessage *mime_message, const gchar *recipient_type);
-void camel_mime_message_set_flag (CamelMimeMessage *mime_message, gchar *flag, gboolean value);
-gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, gchar *flag);
+void camel_mime_message_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value);
+gboolean camel_mime_message_get_flag (CamelMimeMessage *mime_message, const gchar *flag);
guint camel_mime_message_get_message_number (CamelMimeMessage *mime_message);
diff --git a/camel/camel-session.c b/camel/camel-session.c
index 20f0462368..907e086672 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -25,6 +25,7 @@
#include "string-utils.h"
#include "url-util.h"
#include "camel-provider.h"
+#include "hash-table-utils.h"
static GtkObjectClass *parent_class=NULL;
diff --git a/camel/hash-table-utils.c b/camel/hash-table-utils.c
new file mode 100644
index 0000000000..fb3743109b
--- /dev/null
+++ b/camel/hash-table-utils.c
@@ -0,0 +1,79 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* generic utilities for hash tables */
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+
+#include "glib.h"
+#include "hash-table-utils.h"
+
+
+/*
+ * free a (key/value) hash table pair.
+ * to be called in a g_hash_table_foreach()
+ * before g_hash_table_destroy().
+ */
+void
+g_hash_table_generic_free (gpointer key, gpointer value, gpointer user_data)
+{
+ g_free (key);
+ if (value) g_free (value);
+}
+
+
+
+/***/
+/* use these two funcs for case insensitive hash table */
+
+gint
+g_strcase_equal (gconstpointer a, gconstpointer b)
+{
+ return (g_strcasecmp ((gchar *)a, (gchar *)b) == 0);
+}
+
+
+/* modified g_str_hash from glib/gstring.c
+ because it would have been too slow to
+ us g_strdown() on the string */
+/* a char* hash function from ASU */
+guint
+g_strcase_hash (gconstpointer v)
+{
+ const char *s = (char*)v;
+ const char *p;
+ char c;
+ guint h=0, g;
+
+ for(p = s; *p != '\0'; p += 1) {
+ c = isupper ((guchar)*p) ? tolower ((guchar)*p) : *p;
+ h = ( h << 4 ) + c;
+ if ( ( g = h & 0xf0000000 ) ) {
+ h = h ^ (g >> 24);
+ h = h ^ g;
+ }
+ }
+
+ return h /* % M */;
+}
+
+
+
+/***/
diff --git a/camel/hash-table-utils.h b/camel/hash-table-utils.h
new file mode 100644
index 0000000000..ada9dfc140
--- /dev/null
+++ b/camel/hash-table-utils.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* generic utilities for hash tables */
+
+/*
+ *
+ * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+
+#ifndef HASH_TABLE_UTILS_H
+#define HASH_TABLE_UTILS_H 1
+
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus }*/
+
+void g_hash_table_generic_free (gpointer key, gpointer value, gpointer user_data);
+
+gint g_strcase_equal (gconstpointer a, gconstpointer b);
+guint g_strcase_hash (gconstpointer v);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* HASH_TABLE_UTILS_H */
diff --git a/camel/string-utils.c b/camel/string-utils.c
index bfda0f0f8d..b0d17aec5c 100644
--- a/camel/string-utils.c
+++ b/camel/string-utils.c
@@ -251,47 +251,3 @@ string_trim (gchar *string, const gchar *trim_chars, StringTrimOption options)
-
-/***/
-/* use these two funcs for case insensitive hash table */
-
-gint
-g_strcase_equal (gconstpointer a, gconstpointer b)
-{
- return (g_strcasecmp ((gchar *)a, (gchar *)b) == 0);
-}
-
-
-/* modified g_str_hash from glib/gstring.c
- because it would have been too slow to
- us g_strdown() on the string */
-/* a char* hash function from ASU */
-guint
-g_strcase_hash (gconstpointer v)
-{
- const char *s = (char*)v;
- const char *p;
- char c;
- guint h=0, g;
-
- for(p = s; *p != '\0'; p += 1) {
- c = isupper ((guchar)*p) ? tolower ((guchar)*p) : *p;
- h = ( h << 4 ) + c;
- if ( ( g = h & 0xf0000000 ) ) {
- h = h ^ (g >> 24);
- h = h ^ g;
- }
- }
-
- return h /* % M */;
-}
-
-
-
-
-
-
-
-
-
-/***/
diff --git a/camel/string-utils.h b/camel/string-utils.h
index e75e1af9b1..9805861daf 100644
--- a/camel/string-utils.h
+++ b/camel/string-utils.h
@@ -60,9 +60,6 @@ GList *string_split (const gchar *string, char sep,
void string_trim (gchar *string, const gchar *chars,
StringTrimOption options);
-gint g_strcase_equal (gconstpointer a, gconstpointer b);
-guint g_strcase_hash (gconstpointer v);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */