From 75a43c7f91fcb27dee75976cc7c094dd5fa589f6 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 5 Dec 2011 15:51:35 +0100 Subject: Export the function to convert ldb_result to sysdb_attrs It will be reused later in the sudo responder --- src/db/sysdb.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/db/sysdb.c') diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 034e5da0d..8ca4c17fb 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -1765,3 +1765,32 @@ done: talloc_free(tmp_ctx); return ret; } + +errno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count, + struct ldb_message **msgs, + struct sysdb_attrs ***attrs) +{ + int i; + struct sysdb_attrs **a; + + a = talloc_array(mem_ctx, struct sysdb_attrs *, count); + if (a == NULL) { + DEBUG(1, ("talloc_array failed.\n")); + return ENOMEM; + } + + for (i = 0; i < count; i++) { + a[i] = talloc(a, struct sysdb_attrs); + if (a[i] == NULL) { + DEBUG(1, ("talloc_array failed.\n")); + talloc_free(a); + return ENOMEM; + } + a[i]->num = msgs[i]->num_elements; + a[i]->a = talloc_steal(a[i], msgs[i]->elements); + } + + *attrs = a; + + return EOK; +} -- cgit