summaryrefslogtreecommitdiff
path: root/src
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
parent4dbc76b8784eed6dbf4d9b40c0f59fd0bceeeec7 (diff)
downloadsssd-0a4b0580d8f5de1733ea065553992edfcb793de5.tar.gz
sssd-0a4b0580d8f5de1733ea065553992edfcb793de5.tar.bz2
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')
-rw-r--r--src/providers/ldap/sdap.h10
-rw-r--r--src/providers/ldap/sdap_async.c35
2 files changed, 45 insertions, 0 deletions
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
index c00b3d3e..cef2d23a 100644
--- a/src/providers/ldap/sdap.h
+++ b/src/providers/ldap/sdap.h
@@ -305,6 +305,16 @@ struct sdap_server_opts {
struct sdap_id_ctx;
+struct sdap_attr_map_info {
+ struct sdap_attr_map *map;
+ int num_attrs;
+};
+
+struct sdap_deref_attrs {
+ struct sdap_attr_map *map;
+ struct sysdb_attrs *attrs;
+};
+
int sdap_get_map(TALLOC_CTX *memctx,
struct confdb_ctx *cdb,
const char *conf_path,
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
index 7c7e2699..94ffcc39 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,