diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map.c | 23 | ||||
-rw-r--r-- | src/map.h | 4 |
2 files changed, 19 insertions, 8 deletions
@@ -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 @@ -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, |