summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb_modules.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-11-08 00:11:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:53 -0500
commit5c9590587197dcb95007fdc54318187d5716c7c6 (patch)
treed5161aa628d8a4bc4f11bf849d76a451ff44522c /source4/lib/ldb/common/ldb_modules.c
parent14b59bcbec1a288810efee5c9442dff30f1a474a (diff)
downloadsamba-5c9590587197dcb95007fdc54318187d5716c7c6.tar.gz
samba-5c9590587197dcb95007fdc54318187d5716c7c6.tar.bz2
samba-5c9590587197dcb95007fdc54318187d5716c7c6.zip
r11567: Ldb API change patch.
This patch changes the way lsb_search is called and the meaning of the returned integer. The last argument of ldb_search is changed from struct ldb_message to struct ldb_result which contains a pointer to a struct ldb_message list and a count of the number of messages. The return is not the count of messages anymore but instead it is an ldb error value. I tryed to keep the patch as tiny as possible bu as you can guess I had to change a good amount of places. I also tried to double check all my changes being sure that the calling functions would still behave as before. But this patch is big enough that I fear some bug may have been introduced anyway even if it passes the test suite. So if you are currently working on any file being touched please give it a deep look and blame me for any error. Simo. (This used to be commit 22c8c97e6fb466b41859e090e959d7f1134be780)
Diffstat (limited to 'source4/lib/ldb/common/ldb_modules.c')
-rw-r--r--source4/lib/ldb/common/ldb_modules.c73
1 files changed, 13 insertions, 60 deletions
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index f3ca4df9b4..91338c2e10 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -35,6 +35,7 @@
#include "includes.h"
#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
#include "ldb/include/ldb_private.h"
#include "dlinklist.h"
#include <sys/types.h>
@@ -153,7 +154,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
if ((modules == NULL) && (strcmp("ldap", ldb->modules->ops->name) != 0)) {
int ret;
const char * const attrs[] = { "@LIST" , NULL};
- struct ldb_message **msg = NULL;
+ struct ldb_result *res = NULL;
struct ldb_dn *mods;
mods = ldb_dn_explode(ldb, "@MODULES");
@@ -161,27 +162,27 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
return -1;
}
- ret = ldb_search(ldb, mods, LDB_SCOPE_BASE, "", attrs, &msg);
+ ret = ldb_search(ldb, mods, LDB_SCOPE_BASE, "", attrs, &res);
talloc_free(mods);
- if (ret == 0 || (ret == 1 && msg[0]->num_elements == 0)) {
+ if (ret == LDB_SUCCESS && (res->count == 0 || res->msgs[0]->num_elements == 0)) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "no modules required by the db\n");
} else {
- if (ret < 0) {
+ if (ret != LDB_SUCCESS) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "ldb error (%s) occurred searching for modules, bailing out\n", ldb_errstring(ldb));
return -1;
}
- if (ret > 1) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "Too many records found (%d), bailing out\n", ret);
- talloc_free(msg);
+ if (res->count > 1) {
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "Too many records found (%d), bailing out\n", res->count);
+ talloc_free(res);
return -1;
}
modules = ldb_modules_list_from_string(ldb,
- (const char *)msg[0]->elements[0].values[0].data);
+ (const char *)res->msgs[0]->elements[0].values[0].data);
}
- talloc_free(msg);
+ talloc_free(res);
}
if (modules == NULL) {
@@ -228,58 +229,10 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
/*
helper functions to call the next module in chain
*/
-int ldb_next_search_bytree(struct ldb_module *module,
- const struct ldb_dn *base,
- enum ldb_scope scope,
- struct ldb_parse_tree *tree,
- const char * const *attrs, struct ldb_message ***res)
+int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
{
- FIND_OP(module, search_bytree);
- return module->ops->search_bytree(module, base, scope, tree, attrs, res);
-}
-
-int ldb_next_search(struct ldb_module *module,
- const struct ldb_dn *base,
- enum ldb_scope scope,
- const char *expression,
- const char * const *attrs, struct ldb_message ***res)
-{
- struct ldb_parse_tree *tree;
- int ret;
- FIND_OP(module, search_bytree);
- tree = ldb_parse_tree(module, expression);
- if (tree == NULL) {
- ldb_set_errstring(module, talloc_strdup(module, "Unable to parse search expression"));
- return -1;
- }
- ret = module->ops->search_bytree(module, base, scope, tree, attrs, res);
- talloc_free(tree);
- return ret;
-}
-
-
-int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message)
-{
- FIND_OP(module, add_record);
- return module->ops->add_record(module, message);
-}
-
-int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message)
-{
- FIND_OP(module, modify_record);
- return module->ops->modify_record(module, message);
-}
-
-int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn)
-{
- FIND_OP(module, delete_record);
- return module->ops->delete_record(module, dn);
-}
-
-int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
-{
- FIND_OP(module, rename_record);
- return module->ops->rename_record(module, olddn, newdn);
+ FIND_OP(module, request);
+ return module->ops->request(module, request);
}
int ldb_next_start_trans(struct ldb_module *module)