summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/sdap_async.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-05-17 10:20:04 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-05-20 07:21:45 -0400
commit0a4b0580d8f5de1733ea065553992edfcb793de5 (patch)
tree2669ca1068821d377056c21f395d337ee42218ae /src/providers/ldap/sdap_async.c
parent4dbc76b8784eed6dbf4d9b40c0f59fd0bceeeec7 (diff)
downloadsssd-0a4b0580d8f5de1733ea065553992edfcb793de5.tar.gz
sssd-0a4b0580d8f5de1733ea065553992edfcb793de5.tar.xz
sssd-0a4b0580d8f5de1733ea065553992edfcb793de5.zip
Generic dereference data structures and utilities
These will be shared by both dereference methods in a later patch.
Diffstat (limited to 'src/providers/ldap/sdap_async.c')
-rw-r--r--src/providers/ldap/sdap_async.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
index 7c7e2699a..94ffcc392 100644
--- a/src/providers/ldap/sdap_async.c
+++ b/src/providers/ldap/sdap_async.c
@@ -821,6 +821,41 @@ static errno_t add_to_reply(TALLOC_CTX *mem_ctx,
return EOK;
}
+struct sdap_deref_reply {
+ size_t reply_max;
+ size_t reply_count;
+ struct sdap_deref_attrs **reply;
+};
+
+static errno_t add_to_deref_reply(TALLOC_CTX *mem_ctx,
+ int num_maps,
+ struct sdap_deref_reply *dreply,
+ struct sdap_deref_attrs **res)
+{
+ int i;
+
+ for (i=0; i < num_maps; i++) {
+ if (res[i]->attrs == NULL) continue; /* Nothing in this map */
+
+ if (dreply->reply == NULL ||
+ dreply->reply_max == dreply->reply_count) {
+ dreply->reply_max += REPLY_REALLOC_INCREMENT;
+ dreply->reply = talloc_realloc(mem_ctx, dreply->reply,
+ struct sdap_deref_attrs *,
+ dreply->reply_max);
+ if (dreply->reply == NULL) {
+ DEBUG(1, ("talloc_realloc failed.\n"));
+ return ENOMEM;
+ }
+ }
+
+ dreply->reply[dreply->reply_count++] =
+ talloc_steal(dreply->reply, res[i]);
+ }
+
+ return EOK;
+}
+
/* ==Generic Search exposing all options======================= */
typedef errno_t (*sdap_parse_cb)(struct sdap_handle *sh,
struct sdap_msg *msg,