diff options
author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-01 17:13:02 -0400 |
---|---|---|
committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-01 17:13:02 -0400 |
commit | accd0ff71964d825c86ee4d796dce48b36f010b5 (patch) | |
tree | 811fb8a570ec90fe4e8bef77857ed76acecf705e /src/map.c | |
parent | 8fd9aba6535dc5c5413aed497cd20e64fa703a83 (diff) | |
download | slapi-nis-accd0ff71964d825c86ee4d796dce48b36f010b5.tar.gz slapi-nis-accd0ff71964d825c86ee4d796dce48b36f010b5.tar.xz slapi-nis-accd0ff71964d825c86ee4d796dce48b36f010b5.zip |
- fixup entry the iteration API so that its new, only, consumer can use it right
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 23 |
1 files changed, 16 insertions, 7 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 |