aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-01-23 07:10:22 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-01-23 07:10:22 +0800
commitfa5982c96a3d17d6c61027e2ab4e7456d11348ef (patch)
tree906ca87c1ada387914724019160f34405ee76301 /e-util
parent38ae9b4005a01b869947dc075b6300dabd8769f7 (diff)
downloadgsoc2013-evolution-fa5982c96a3d17d6c61027e2ab4e7456d11348ef.tar
gsoc2013-evolution-fa5982c96a3d17d6c61027e2ab4e7456d11348ef.tar.gz
gsoc2013-evolution-fa5982c96a3d17d6c61027e2ab4e7456d11348ef.tar.bz2
gsoc2013-evolution-fa5982c96a3d17d6c61027e2ab4e7456d11348ef.tar.lz
gsoc2013-evolution-fa5982c96a3d17d6c61027e2ab4e7456d11348ef.tar.xz
gsoc2013-evolution-fa5982c96a3d17d6c61027e2ab4e7456d11348ef.tar.zst
gsoc2013-evolution-fa5982c96a3d17d6c61027e2ab4e7456d11348ef.zip
New function, can't use strlen on the md5 hash because it might have null
2001-01-22 JP Rosevear <jpr@ximian.com> * e-dbhash.c (md5_to_dbt): New function, can't use strlen on the md5 hash because it might have null chars in it. (e_dbhash_add): use md5_to_dbt svn path=/trunk/; revision=7726
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog13
-rw-r--r--e-util/e-dbhash.c9
-rw-r--r--e-util/e-pilot-map.c39
-rw-r--r--e-util/e-pilot-map.h3
4 files changed, 63 insertions, 1 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 379eae390e..51e256028c 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,16 @@
+2001-01-22 JP Rosevear <jpr@ximian.com>
+
+ * e-dbhash.c (md5_to_dbt): New function, can't use strlen on the md5
+ hash because it might have null chars in it.
+ (e_dbhash_add): use md5_to_dbt
+
+2001-01-19 JP Rosevear <jpr@ximian.com>
+
+ * e-pilot-map.c (e_pilot_map_remove_by_pid): Remove an item by pid
+ (e_pilot_map_remove_by_uid): ditto for uid
+
+ * e-pilot-map.h: new protos
+
2001-01-17 Jason Leach <jasonleach@usa.net>
* e-gtk-utils.c (gtk_radio_button_get_nth_selected): New function,
diff --git a/e-util/e-dbhash.c b/e-util/e-dbhash.c
index 2bcedb8676..e286500066 100644
--- a/e-util/e-dbhash.c
+++ b/e-util/e-dbhash.c
@@ -55,6 +55,13 @@ string_to_dbt(const char *str, DBT *dbt)
dbt->size = strlen (str) + 1;
}
+static void
+md5_to_dbt(const char str[16], DBT *dbt)
+{
+ dbt->data = (void*)str;
+ dbt->size = 16;
+}
+
void
e_dbhash_add (EDbHash *edbh, const gchar *key, const gchar *data)
{
@@ -76,7 +83,7 @@ e_dbhash_add (EDbHash *edbh, const gchar *key, const gchar *data)
/* Data dbt */
md5_get_digest (data, strlen (data), local_hash);
- string_to_dbt (local_hash, &ddata);
+ md5_to_dbt (local_hash, &ddata);
/* Add to database */
db->put (db, &dkey, &ddata, 0);
diff --git a/e-util/e-pilot-map.c b/e-util/e-pilot-map.c
index 4f985ccace..67aacdcf2a 100644
--- a/e-util/e-pilot-map.c
+++ b/e-util/e-pilot-map.c
@@ -162,6 +162,45 @@ e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archi
g_hash_table_insert (map->uid_map, new_uid, unode);
}
+void
+e_pilot_map_remove_by_pid (EPilotMap *map, guint32 pid)
+{
+ EPilotMapPidNode *pnode;
+ EPilotMapUidNode *unode;
+
+ pnode = g_hash_table_lookup (map->pid_map, &pid);
+ if (!pnode)
+ return;
+
+ unode = g_hash_table_lookup (map->uid_map, pnode->uid);
+
+ g_hash_table_remove (map->pid_map, &pid);
+ g_hash_table_remove (map->uid_map, pnode->uid);
+
+ g_free (pnode);
+ g_free (unode);
+}
+
+void
+e_pilot_map_remove_by_uid (EPilotMap *map, const char *uid)
+{
+ EPilotMapPidNode *pnode;
+ EPilotMapUidNode *unode;
+
+ unode = g_hash_table_lookup (map->uid_map, uid);
+ if (!unode)
+ return;
+
+ pnode = g_hash_table_lookup (map->pid_map, &unode->pid);
+
+ g_hash_table_remove (map->uid_map, uid);
+ g_hash_table_remove (map->pid_map, &unode->pid);
+
+ g_free (unode);
+ g_free (pnode);
+}
+
+
guint32
e_pilot_map_lookup_pid (EPilotMap *map, const char *uid)
{
diff --git a/e-util/e-pilot-map.h b/e-util/e-pilot-map.h
index 8e3d2b71f6..d8d307ac3d 100644
--- a/e-util/e-pilot-map.h
+++ b/e-util/e-pilot-map.h
@@ -40,6 +40,9 @@ gboolean e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pid);
gboolean e_pilot_map_uid_is_archived (EPilotMap *map, const char *uid);
void e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archived);
+void e_pilot_map_remove_by_pid (EPilotMap *map, guint32 pid);
+void e_pilot_map_remove_by_uid (EPilotMap *map, const char *uid);
+
guint32 e_pilot_map_lookup_pid (EPilotMap *map, const char *uid);
const char * e_pilot_map_lookup_uid (EPilotMap *map, guint32 pid);