Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-local
[jelmer/samba4-debian.git] / source / lib / ldb / modules / paged_searches.c
index 3e0941357e022f0e8fdfe00a46c76dba1388bd03..40e87f70d60c83e124a5e7ae0877d941c6102c67 100644 (file)
@@ -90,7 +90,10 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
        ac->up_context = context;
        ac->up_callback = callback;
 
-       ac->pending = False;
+       ac->pending = false;
+
+
+
        ac->saved_referrals = NULL;
        ac->num_referrals = 0;
 
@@ -110,7 +113,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac)
        rep_control = talloc_get_type(ares->controls[0]->data, struct ldb_paged_control);
        if (rep_control->cookie_len == 0) {
                /* we are done */
-               ac->pending = False;
+               ac->pending = false;
                return LDB_SUCCESS;
        }
 
@@ -135,7 +138,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac)
                                            rep_control->cookie_len);
        req_control->cookie_len = rep_control->cookie_len;
 
-       ac->pending = True;
+       ac->pending = true;
        return LDB_SUCCESS;
 }
 
@@ -309,7 +312,7 @@ static int ps_continuation(struct ldb_handle *handle)
        return ldb_next_request(handle->module, ac->new_req);
 }
 
-static int ps_wait_none(struct ldb_handle *handle)
+static int ps_wait_once(struct ldb_handle *handle)
 {
        struct ps_context *ac;
        int ret;
@@ -362,27 +365,25 @@ done:
        return ret;
 }
 
-static int ps_wait_all(struct ldb_handle *handle)
+static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type)
 {
        int ret;
 
-       while (handle->state != LDB_ASYNC_DONE) {
-               ret = ps_wait_none(handle);
-               if (ret != LDB_SUCCESS) {
-                       return ret;
-               }
+       if (!handle || !handle->private_data) {
+               return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       return handle->status;
-}
-
-static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type)
-{
        if (type == LDB_WAIT_ALL) {
-               return ps_wait_all(handle);
-       } else {
-               return ps_wait_none(handle);
+               while (handle->state != LDB_ASYNC_DONE) {
+                       ret = ps_wait_once(handle);
+                       if (ret != LDB_SUCCESS) {
+                               return ret;
+                       }
+               }
+
+               return handle->status;
        }
+       return ps_wait_once(handle);
 }
 
 static int check_supported_paged(struct ldb_context *ldb, void *context, 
@@ -395,7 +396,7 @@ static int check_supported_paged(struct ldb_context *ldb, void *context,
                if (ldb_msg_check_string_attribute(ares->message,
                                                   "supportedControl",
                                                   LDB_CONTROL_PAGED_RESULTS_OID)) {
-                       data->paged_supported = True;
+                       data->paged_supported = true;
                }
        }
        return LDB_SUCCESS;
@@ -415,7 +416,7 @@ static int ps_init(struct ldb_module *module)
                return LDB_ERR_OTHER;
        }
        module->private_data = data;
-       data->paged_supported = False;
+       data->paged_supported = false;
 
        req = talloc(module, struct ldb_request);
        if (req == NULL) {
@@ -454,15 +455,9 @@ static int ps_init(struct ldb_module *module)
        return ldb_next_init(module);
 }
 
-static const struct ldb_module_ops ps_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_paged_searches_module_ops = {
        .name           = "paged_searches",
        .search         = ps_search,
        .wait           = ps_wait,
        .init_context   = ps_init
 };
-
-int ldb_paged_searches_init(void)
-{
-       return ldb_register_module(&ps_ops);
-}
-