diff options
author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-13 15:04:07 -0400 |
---|---|---|
committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-13 15:04:07 -0400 |
commit | 6dec108a9e26edce33feda9e67b7372a3cb9c643 (patch) | |
tree | f8164ec24cd1dce57adc168dc8d31a44e4d673fa /src/map.c | |
parent | 82328ad41a048d4386eaaf01d60087426f09223b (diff) | |
download | slapi-nis-6dec108a9e26edce33feda9e67b7372a3cb9c643.tar.gz slapi-nis-6dec108a9e26edce33feda9e67b7372a3cb9c643.tar.xz slapi-nis-6dec108a9e26edce33feda9e67b7372a3cb9c643.zip |
- add search-by-id interfaces
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 66 |
1 files changed, 63 insertions, 3 deletions
@@ -367,7 +367,8 @@ map_match(struct plugin_state *state, const char *domain_name, const char *map_name, bool_t *secure, unsigned int key_len, char *key, - unsigned int *value_len, char **value) + unsigned int *value_len, char **value, + const char **id) { struct map *map; struct map_entry *entry; @@ -382,6 +383,35 @@ map_match(struct plugin_state *state, *secure = map->secure; *value_len = entry->value_len; *value = entry->value; + *id = entry->id; + return TRUE; +} + +bool_t +map_match_id(struct plugin_state *state, + const char *domain_name, const char *map_name, + bool_t *secure, + const char *in_id, + unsigned int *key_len, char **key, + unsigned int *value_len, char **value, + const char **id) +{ + struct map *map; + struct map_entry *entry; + map = map_data_find_map(state, domain_name, map_name); + if (map == NULL) { + return FALSE; + } + entry = map_data_find_map_entry_id(state, map, in_id); + if (entry == NULL) { + return FALSE; + } + *secure = map->secure; + *key_len = entry->key_len; + *key = entry->key; + *value_len = entry->value_len; + *value = entry->value; + *id = entry->id; return TRUE; } @@ -392,7 +422,8 @@ map_first(struct plugin_state *state, const char *domain_name, const char *map_name, bool_t *secure, unsigned int *first_key_len, char **first_key, - unsigned int *first_value_len, char **first_value) + unsigned int *first_value_len, char **first_value, + const char **first_id) { struct map *map; struct map_entry *entry; @@ -409,6 +440,7 @@ map_first(struct plugin_state *state, *first_key = entry->key; *first_value_len = entry->value_len; *first_value = entry->value; + *first_id = entry->id; return TRUE; } @@ -420,7 +452,8 @@ 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) + unsigned int *next_value_len, char **next_value, + const char **next_id) { struct map *map; struct map_entry *entry; @@ -437,6 +470,33 @@ 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 +map_next_id(struct plugin_state *state, + const char *domain_name, const char *map_name, bool_t *secure, + const char *prev_id, + unsigned int *next_key_len, char **next_key, + unsigned int *next_value_len, char **next_value, + const char **next_id) +{ + struct map *map; + struct map_entry *entry; + map = map_data_find_map(state, domain_name, map_name); + if (map == NULL) { + return FALSE; + } + entry = map_data_find_map_entry_id(state, map, prev_id); + if ((entry == NULL) || (entry->next == NULL)) { + return FALSE; + } + *secure = map->secure; + *next_key_len = entry->next->key_len; + *next_key = entry->next->key; + *next_value_len = entry->next->value_len; + *next_value = entry->next->value; + *next_id = entry->next->id; return TRUE; } |