From 5c9590587197dcb95007fdc54318187d5716c7c6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 8 Nov 2005 00:11:45 +0000 Subject: 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) --- source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 54 ++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 11 deletions(-) (limited to 'source4/lib/ldb/ldb_sqlite3') diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index 1054722178..1d23478941 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -810,7 +810,7 @@ done: /* search for matching records, by tree */ static int lsqlite3_search_bytree(struct ldb_module * module, const struct ldb_dn* basedn, enum ldb_scope scope, struct ldb_parse_tree * tree, - const char * const * attrs, struct ldb_message *** res) + const char * const * attrs, struct ldb_result ** res) { TALLOC_CTX *local_ctx; struct lsqlite3_private *lsqlite3 = module->private_data; @@ -973,21 +973,25 @@ static int lsqlite3_search_bytree(struct ldb_module * module, const struct ldb_d for (i = 0; i < msgs.count; i++) { msgs.msgs[i] = ldb_msg_canonicalize(module->ldb, msgs.msgs[i]); if (msgs.msgs[i] == NULL) { - ret = LDB_ERR_OTHER; goto failed; } } - *res = talloc_steal(module, msgs.msgs); - ret = msgs.count; + *res = talloc(module, struct ldb_result); + if (! *res) { + goto failed; + } + + (*res)->msgs = talloc_steal(*res, msgs.msgs); + (*res)->count = msgs.count; talloc_free(local_ctx); - return ret; + return LDB_SUCCESS; /* If error, return error code; otherwise return number of results */ failed: talloc_free(local_ctx); - return -1; + return LDB_ERR_OTHER; } @@ -1777,17 +1781,45 @@ destructor(void *p) } +static int lsqlite3_request(struct ldb_module *module, struct ldb_request *req) +{ + switch (req->operation) { + + case LDB_REQ_SEARCH: + return lsqlite3_search_bytree(module, + req->op.search.base, + req->op.search.scope, + req->op.search.tree, + req->op.search.attrs, + req->op.search.res); + + case LDB_REQ_ADD: + return lsqlite3_add(module, req->op.add.message); + + case LDB_REQ_MODIFY: + return lsqlite3_modify(module, req->op.mod.message); + + case LDB_REQ_DELETE: + return lsqlite3_delete(module, req->op.del.dn); + + case LDB_REQ_RENAME: + return lsqlite3_rename(module, + req->op.rename.olddn, + req->op.rename.newdn); + + default: + return LDB_ERR_OPERATIONS_ERROR; + + } +} + /* * Table of operations for the sqlite3 backend */ static const struct ldb_module_ops lsqlite3_ops = { .name = "sqlite", - .search_bytree = lsqlite3_search_bytree, - .add_record = lsqlite3_add, - .modify_record = lsqlite3_modify, - .delete_record = lsqlite3_delete, - .rename_record = lsqlite3_rename, + .request = lsqlite3_request, .start_transaction = lsqlite3_start_trans, .end_transaction = lsqlite3_end_trans, .del_transaction = lsqlite3_del_trans -- cgit