From 22ff4ffb24db349456ffdd207c5b5c9119d85e49 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Wed, 2 Apr 2008 18:08:34 -0400 Subject: - start making it possible to add entries on the fly --- src/map.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/map.c') diff --git a/src/map.c b/src/map.c index 263c22d..c09cff0 100644 --- a/src/map.c +++ b/src/map.c @@ -476,6 +476,7 @@ map_data_unset_map_entry(struct plugin_state *state, free(entry); } } + static void map_data_unset_entry(struct plugin_state *state, const char *domain_name, @@ -489,6 +490,7 @@ map_data_unset_entry(struct plugin_state *state, entry = map_data_find_map_entry(state, map, key_len, key); map_data_unset_map_entry(state, map, entry); } + static void map_data_unset_entry_dn(struct plugin_state *state, const char *domain_name, @@ -502,6 +504,45 @@ map_data_unset_entry_dn(struct plugin_state *state, map_data_unset_map_entry(state, map, entry); } +static void +map_data_set_entry_dn(struct plugin_state *state, + const char *domain_name, + const char *map_name, + const char *dn, + unsigned int key_len, + char *key, + unsigned int value_len, + char *value) +{ + struct map *map; + struct entry *entry; + map = map_data_find_map(state, domain_name, map_name); + entry = map_data_find_map_entry_dn(state, map, dn); + if (entry != NULL) { + free(entry->key); + free(entry->value); + entry->key = key; + entry->key_len = key_len; + entry->value = value; + entry->value_len = value_len; + } else { + entry = malloc(sizeof(*entry)); + if (entry != NULL) { + memset(entry, 0, sizeof(*entry)); + entry->dn = strdup(dn); + entry->key = key; + entry->key_len = key_len; + entry->value = value; + entry->value_len = value_len; + entry->next = map->entries; + if (map->entries != NULL) { + map->entries->prev = entry; + } + map->entries = entry; + } + } +} + void map_init(struct plugin_state *state) { -- cgit