From accd0ff71964d825c86ee4d796dce48b36f010b5 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 1 Jul 2008 17:13:02 -0400 Subject: - fixup entry the iteration API so that its new, only, consumer can use it right --- src/map.c | 23 ++++++++++++++++------- src/map.h | 4 +++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/map.c b/src/map.c index 6f95e61..b361fe2 100644 --- a/src/map.c +++ b/src/map.c @@ -47,7 +47,7 @@ #include "wrap.h" /* The singleton for the cache. */ -struct { +static struct { char *master; struct domain { char *name; @@ -228,7 +228,8 @@ map_data_find_map_entry_id(struct plugin_state *state, * returns FALSE, then we abort and return FALSE, otherwise we return TRUE. */ static bool_t map_data_foreach_entry(struct plugin_state *state, - bool_t all, const char *id, + const char *domain_name, const char *map_name, + const char *id, bool_t (*fn)(const char *domain, const char *map, bool_t secure, const char *key, unsigned int key_len, @@ -245,14 +246,21 @@ map_data_foreach_entry(struct plugin_state *state, struct map_entry *entry; for (i = 0; i < map_data.n_domains; i++) { domain = &map_data.domains[i]; + if ((domain_name != NULL) && + (strcmp(domain_name, domain->name) != 0)) { + continue; + } for (j = 0; j < domain->n_maps; j++) { map = &domain->maps[j]; + if ((map_name != NULL) && + (strcmp(map_name, map->name) != 0)) { + continue; + } for (entry = map->entries; entry != NULL; entry = entry->next) { - if (all || - ((id != NULL) && - (strcmp(id, entry->id) == 0))) { + if ((id == NULL) || + (strcmp(id, entry->id) == 0)) { for (k = 0; k < entry->n_keys; k++) { if (!(*fn)(domain->name, map->name, @@ -276,7 +284,8 @@ map_data_foreach_entry(struct plugin_state *state, /* Iterate over every entry which matches the corresponding ID. */ bool_t -map_data_foreach_entry_id(struct plugin_state *state, const char *id, +map_data_foreach_entry_id(struct plugin_state *state, + const char *domain, const char *map, const char *id, bool_t (*fn)(const char *domain, const char *map, bool_t secure, const char *key, @@ -287,7 +296,7 @@ map_data_foreach_entry_id(struct plugin_state *state, const char *id, void *backend_data, void *cbdata), void *cbdata) { - return map_data_foreach_entry(state, FALSE, id, fn, cbdata); + return map_data_foreach_entry(state, domain, map, id, fn, cbdata); } /* Iterate over all maps, calling the callback with information about the map diff --git a/src/map.h b/src/map.h index 6a8e4a5..5f7749b 100644 --- a/src/map.h +++ b/src/map.h @@ -85,7 +85,9 @@ void map_data_set_entry(struct plugin_state *state, bool_t map_data_check_entry(struct plugin_state *state, const char *domain_name, const char *map_name, const char *id); -bool_t map_data_foreach_entry_id(struct plugin_state *state, const char *id, +bool_t map_data_foreach_entry_id(struct plugin_state *state, + const char *domain, const char *map, + const char *id, bool_t (*fn)(const char *domain, const char *map, bool_t secure, -- cgit