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
This commit is contained in:
@ -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,
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user