diff options
author | Simo Sorce <idra@samba.org> | 2006-01-06 16:12:45 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:49:48 -0500 |
commit | dbef4d76de92c3388f4e1819a76d6febf90be290 (patch) | |
tree | 9de9afa682085de347e6cdd632a9d0e06baa26c7 /source4/lib/ldb/modules | |
parent | 8f4dc51345dc48f5a6bfb1a49297f205ba53ef0a (diff) | |
download | samba-dbef4d76de92c3388f4e1819a76d6febf90be290.tar.gz samba-dbef4d76de92c3388f4e1819a76d6febf90be290.tar.bz2 samba-dbef4d76de92c3388f4e1819a76d6febf90be290.zip |
r12743: Remove the ugly way we had to make a second stage init and introduce
a second_stage_init private function for modules that need a second stage init.
Simo.
(This used to be commit 5e8b365fa2d93801a5de1d9ea76ce9d5546bd248)
Diffstat (limited to 'source4/lib/ldb/modules')
-rw-r--r-- | source4/lib/ldb/modules/objectclass.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/modules/operational.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/modules/paged_results.c | 37 | ||||
-rw-r--r-- | source4/lib/ldb/modules/rdn_name.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/modules/schema.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/modules/skel.c | 16 | ||||
-rw-r--r-- | source4/lib/ldb/modules/sort.c | 37 |
7 files changed, 53 insertions, 53 deletions
diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c index 7a037cc98a..c38b3167e8 100644 --- a/source4/lib/ldb/modules/objectclass.c +++ b/source4/lib/ldb/modules/objectclass.c @@ -305,12 +305,10 @@ static const struct ldb_module_ops objectclass_ops = { .request = objectclass_request, }; -struct ldb_module *objectclass_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index 09de0936a1..65d9f12e34 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -368,12 +368,10 @@ static const struct ldb_module_ops operational_ops = { /* the init function */ -struct ldb_module *operational_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index 31b73d2ae4..8e9fc28348 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -248,32 +248,35 @@ static int paged_request(struct ldb_module *module, struct ldb_request *req) } } +static int paged_request_init_2(struct ldb_module *module) +{ + struct ldb_request request; + int ret; + + request.operation = LDB_REQ_REGISTER; + request.op.reg.oid = LDB_CONTROL_PAGED_RESULTS_OID; + request.controls = NULL; + + ret = ldb_request(module->ldb, &request); + if (ret != LDB_SUCCESS) { + ldb_debug(module->ldb, LDB_DEBUG_ERROR, "paged_request: Unable to register control with rootdse!\n"); + return LDB_ERR_OTHER; + } + + return ldb_next_second_stage_init(module); +} + static const struct ldb_module_ops paged_ops = { .name = "paged_results", .request = paged_request, + .second_stage_init = paged_request_init_2 }; -struct ldb_module *paged_results_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; struct private_data *data; - if (stage == LDB_MODULES_INIT_STAGE_2) { - struct ldb_request request; - int ret; - - request.operation = LDB_REQ_REGISTER; - request.op.reg.oid = LDB_CONTROL_PAGED_RESULTS_OID; - request.controls = NULL; - - ret = ldb_request(ldb, &request); - if (ret != LDB_SUCCESS) { - ldb_debug(ldb, LDB_DEBUG_ERROR, "paged_request: Unable to register control with rootdse!\n"); - } - - return NULL; - } - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index f6dbc38740..f35cff916c 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -214,12 +214,10 @@ static const struct ldb_module_ops rdn_name_ops = { /* the init function */ -struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/lib/ldb/modules/schema.c b/source4/lib/ldb/modules/schema.c index 778f52885c..9fb2efee30 100644 --- a/source4/lib/ldb/modules/schema.c +++ b/source4/lib/ldb/modules/schema.c @@ -484,12 +484,10 @@ static const struct ldb_module_ops schema_ops = { .request = schema_request }; -struct ldb_module *schema_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage != LDB_MODULES_INIT_STAGE_1) return NULL; - ctx = talloc(ldb, struct ldb_module); if (!ctx) { return NULL; diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c index dacbd6960e..10f730b2f9 100644 --- a/source4/lib/ldb/modules/skel.c +++ b/source4/lib/ldb/modules/skel.c @@ -123,25 +123,27 @@ static int skel_request(struct ldb_module *module, struct ldb_request *req) } } +static int skel_init_2(struct ldb_module *module) +{ + /* second stage init stuff */ + /* see control modules as example */ + return ldb_next_second_stage_init(module); +} + static const struct ldb_module_ops skel_ops = { .name = "skel", .request = skel_request, .start_transaction = skel_start_trans, .end_transaction = skel_end_trans, .del_transaction = skel_del_trans, + .second_stage_init = skel_init_2 }; -struct ldb_module *skel_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *skel_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; struct private_data *data; - if (stage == LDB_MODULES_INIT_STAGE_2) { - /* second stage init stuff */ - /* see control modules as example */ - return NULL; - } - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index 2757647710..88b967b276 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -227,31 +227,34 @@ static int server_sort(struct ldb_module *module, struct ldb_request *req) } } +static int server_sort_init_2(struct ldb_module *module) +{ + struct ldb_request request; + int ret; + + request.operation = LDB_REQ_REGISTER; + request.op.reg.oid = LDB_CONTROL_SERVER_SORT_OID; + request.controls = NULL; + + ret = ldb_request(module->ldb, &request); + if (ret != LDB_SUCCESS) { + ldb_debug(module->ldb, LDB_DEBUG_ERROR, "server_sort: Unable to register control with rootdse!\n"); + return LDB_ERR_OTHER; + } + + return ldb_next_second_stage_init(module); +} + static const struct ldb_module_ops server_sort_ops = { .name = "server_sort", .request = server_sort, + .second_stage_init = server_sort_init_2 }; -struct ldb_module *server_sort_module_init(struct ldb_context *ldb, int stage, const char *options[]) +struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[]) { struct ldb_module *ctx; - if (stage == LDB_MODULES_INIT_STAGE_2) { - struct ldb_request request; - int ret; - - request.operation = LDB_REQ_REGISTER; - request.op.reg.oid = LDB_CONTROL_SERVER_SORT_OID; - request.controls = NULL; - - ret = ldb_request(ldb, &request); - if (ret != LDB_SUCCESS) { - ldb_debug(ldb, LDB_DEBUG_ERROR, "server_sort: Unable to register control with rootdse!\n"); - } - - return NULL; - } - ctx = talloc(ldb, struct ldb_module); if (!ctx) return NULL; |