diff options
| author | Nalin Dahyabhai <nalin@dahyabhai.net> | 2008-06-17 16:41:04 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin@dahyabhai.net> | 2008-06-17 16:41:04 -0400 |
| commit | cd158d753a24f84a096d1c2211cd1da400a66036 (patch) | |
| tree | 332e0c12dc8e3cc7a8aa021e53aefa2a55ca85bf /src/map.c | |
| parent | 4f5e14211ff8238f62cb15186379b6b9ecffef51 (diff) | |
| download | slapi-nis-cd158d753a24f84a096d1c2211cd1da400a66036.tar.gz slapi-nis-cd158d753a24f84a096d1c2211cd1da400a66036.tar.xz slapi-nis-cd158d753a24f84a096d1c2211cd1da400a66036.zip | |
- get most of the tree in shape to handle multiple keys per entry
- make map_next() not expose entry IDs or key indices, because it has to do
all of the heavy lifting anyway
Diffstat (limited to 'src/map.c')
| -rw-r--r-- | src/map.c | 39 |
1 files changed, 22 insertions, 17 deletions
@@ -64,9 +64,10 @@ struct { /* The name of the backend entry for this * entry. */ char *id; - /* Key and value. */ - char *key; - unsigned int key_len; + /* Keys and value. */ + int n_keys; + char **key; + unsigned int *key_len; char *value; unsigned int value_len; } *entries; @@ -209,10 +210,11 @@ map_data_foreach_entry(struct plugin_state *state, bool_t secure, const char *key, unsigned int key_len, const char *value, unsigned int value_len, - const char *id, void *cbdata), + const char *id, int key_index, + void *cbdata), void *cbdata) { - int i, j; + int i, j, k; struct domain *domain; struct map *map; struct map_entry *entry; @@ -226,14 +228,18 @@ map_data_foreach_entry(struct plugin_state *state, if (all || ((id != NULL) && (strcmp(id, entry->id) == 0))) { - if (!(*fn)(domain->name, map->name, - map->secure, - entry->key, - entry->key_len, - entry->value, - entry->value_len, - entry->id, cbdata)) { - return FALSE; + for (k = 0; k < entry->n_keys; k++) { + if (!(*fn)(domain->name, + map->name, + map->secure, + entry->key[k], + entry->key_len[k], + entry->value, + entry->value_len, + entry->id, k, + cbdata)) { + return FALSE; + } } } } @@ -251,7 +257,8 @@ map_data_foreach_entry_id(struct plugin_state *state, const char *id, unsigned int key_len, const char *value, unsigned int value_len, - const char *id, void *cbdata), + const char *id, int key_index, + void *cbdata), void *cbdata) { return map_data_foreach_entry(state, FALSE, id, fn, cbdata); @@ -452,8 +459,7 @@ map_next(struct plugin_state *state, const char *domain_name, const char *map_name, bool_t *secure, unsigned int prev_len, const char *prev, unsigned int *next_key_len, char **next_key, - unsigned int *next_value_len, char **next_value, - const char **next_id) + unsigned int *next_value_len, char **next_value) { struct map *map; struct map_entry *entry; @@ -470,7 +476,6 @@ map_next(struct plugin_state *state, *next_key = entry->next->key; *next_value_len = entry->next->value_len; *next_value = entry->next->value; - *next_id = entry->next->id; return TRUE; } bool_t |
