From bd7a474b1967423711ff93c0080ce0f89270e3f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 20 Jun 2005 04:56:43 +0000 Subject: r7776: add a method for getting arbitrary opaque data into a ldb context, for use by backends. Currently only EventContext is used in this way. (This used to be commit 9fa21b245843371f7777682ee4e5b98e2925b4d0) --- source4/lib/ldb/common/ldb.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source4/lib/ldb/common/ldb.c') diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 450fa75d8e..e268a8d0d7 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -178,3 +178,34 @@ const char *ldb_errstring(struct ldb_context *ldb) return ldb->modules->ops->errstring(ldb->modules); } + +/* + set backend specific opaque parameters +*/ +int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value) +{ + struct ldb_opaque *o = talloc(ldb, struct ldb_opaque); + if (o == NULL) { + ldb_oom(ldb); + return -1; + } + o->next = ldb->opaque; + o->name = name; + o->value = value; + ldb->opaque = o; + return 0; +} + +/* + get a previously set opaque value +*/ +void *ldb_get_opaque(struct ldb_context *ldb, const char *name) +{ + struct ldb_opaque *o; + for (o=ldb->opaque;o;o=o->next) { + if (strcmp(o->name, name) == 0) { + return o->value; + } + } + return NULL; +} -- cgit