diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-05-16 19:16:56 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-05-16 19:16:56 -0400 |
| commit | 7528629d383f679f5ef631c4b4ee9ebd52a57df6 (patch) | |
| tree | 7a91f28dc4dc46e3519fa2939c48549b05fc954d /src | |
| parent | 77993730c95d779e4dc0a8649a00a4bf41000adc (diff) | |
- implement maplist, finally
Diffstat (limited to 'src')
| -rw-r--r-- | src/nis.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -343,6 +343,37 @@ nis_order(struct plugin_state *state, } } +static PRBool +nis_maplist_cb(const char *domain, const char *mapname, + void *backend_data, void *cbdata) +{ + struct ypmaplist **list, *next; + list = cbdata; + next = malloc(sizeof(*next)); + if (next != NULL) { + memset(next, 0, sizeof(*next)); + next->map = strdup(mapname); + if (next->map == NULL) { + free(next); + return PR_TRUE; + } + next->next = *list; + *list = next; + } + return PR_TRUE; +} +static void +nis_free_maplist_cb_result(struct ypmaplist **list) +{ + struct ypmaplist *node, *next; + node = *list; + while (node != NULL) { + next = node->next; + free(node->map); + free(node); + node = next; + } +} static void nis_maplist(struct plugin_state *state, int client, struct sockaddr *client_addr, socklen_t client_addrlen, @@ -354,8 +385,10 @@ nis_maplist(struct plugin_state *state, struct ypmaplist *list; memset(reply_maplist, 0, sizeof(*reply_maplist)); if (xdr_string(request_xdrs, &domain, YPMAXDOMAIN)) { + list = NULL; + map_data_foreach_map(state, domain, nis_maplist_cb, &list); reply_maplist->status = YP_TRUE; - reply_maplist->list = NULL; /* XXX */ + reply_maplist->list = list; if (reply_maplist->list == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, @@ -373,6 +406,7 @@ nis_maplist(struct plugin_state *state, } nis_reply(state, client, client_addr, client_addrlen, reply, reply_xdrs, reply_buf); + nis_free_maplist_cb_result(&list); } else { /* XXX */ } |
