struct ldb_module *module;
void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
const char * const *attrs;
BOOL remove_guid;
int extended_type;
};
-static int extended_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int extended_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct extended_async_context *ac;
struct ldb_module *module;
void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
enum user_is user_type;
};
-static int kludge_acl_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int kludge_acl_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct kludge_acl_async_context *ac;
struct kludge_private_data *data;
struct partition **partitions;
};
-struct partition_async_context {
+struct partition_context {
struct ldb_module *module;
struct ldb_request *orig_req;
int num_searches;
};
-static struct ldb_async_handle *partition_init_handle(struct ldb_request *req, struct ldb_module *module)
+static struct ldb_handle *partition_init_handle(struct ldb_request *req, struct ldb_module *module)
{
- struct partition_async_context *ac;
- struct ldb_async_handle *h;
+ struct partition_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(req, struct ldb_async_handle);
+ h = talloc_zero(req, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc_zero(h, struct partition_async_context);
+ ac = talloc_zero(h, struct partition_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
return module;
};
-static int partition_send_search(struct partition_async_context *ac, struct ldb_module *partition)
+static int partition_send_search(struct partition_context *ac, struct ldb_module *partition)
{
int ret;
struct ldb_module *next = make_module_for_next_request(ac->module, ac->module->ldb, partition);
* partitions (for 'invisible' partition behaviour */
if (ldb_get_opaque(module->ldb, "global_catalog")) {
int ret, i;
- struct ldb_async_handle *h;
- struct partition_async_context *ac;
+ struct ldb_handle *h;
+ struct partition_context *ac;
h = partition_init_handle(req, module);
if (!h) {
/* return our own handle to deal with this call */
req->async.handle = h;
- ac = talloc_get_type(h->private_data, struct partition_async_context);
+ ac = talloc_get_type(h->private_data, struct partition_context);
ac->orig_req = req;
ac->num_searches = 0;
return ldb_next_init(module);
}
-static int partition_async_wait_none(struct ldb_async_handle *handle) {
- struct partition_async_context *ac;
+static int partition_wait_none(struct ldb_handle *handle) {
+ struct partition_context *ac;
int ret;
int i;
handle->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS;
- ac = talloc_get_type(handle->private_data, struct partition_async_context);
+ ac = talloc_get_type(handle->private_data, struct partition_context);
for (i=0; i < ac->num_searches; i++) {
- ret = ldb_async_wait(ac->search_req[i]->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->search_req[i]->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
}
-static int partition_async_wait_all(struct ldb_async_handle *handle) {
+static int partition_wait_all(struct ldb_handle *handle) {
int ret;
while (handle->state != LDB_ASYNC_DONE) {
- ret = partition_async_wait_none(handle);
+ ret = partition_wait_none(handle);
if (ret != LDB_SUCCESS) {
return ret;
}
return handle->status;
}
-static int partition_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int partition_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
if (type == LDB_WAIT_ALL) {
- return partition_async_wait_all(handle);
+ return partition_wait_all(handle);
} else {
- return partition_async_wait_none(handle);
+ return partition_wait_none(handle);
}
}
.end_transaction = partition_end_trans,
.del_transaction = partition_del_trans,
.sequence_number = partition_sequence_number,
- .async_wait = partition_async_wait
+ .wait = partition_wait
};
int ldb_partition_init(void)
*
*/
-struct ph_async_context {
+struct ph_context {
enum ph_type {PH_ADD, PH_MOD} type;
enum ph_step {PH_ADD_SEARCH_DOM, PH_ADD_DO_ADD, PH_MOD_DO_REQ, PH_MOD_SEARCH_SELF, PH_MOD_SEARCH_DOM, PH_MOD_DO_MOD} step;
struct ldb_request *orig_req;
struct ldb_request *dom_req;
- struct ldb_async_result *dom_res;
+ struct ldb_reply *dom_res;
struct ldb_request *down_req;
struct ldb_request *search_req;
- struct ldb_async_result *search_res;
+ struct ldb_reply *search_res;
struct ldb_request *mod_req;
return LDB_SUCCESS;
}
-static struct ldb_async_handle *ph_init_handle(struct ldb_request *req, struct ldb_module *module, enum ph_type type)
+static struct ldb_handle *ph_init_handle(struct ldb_request *req, struct ldb_module *module, enum ph_type type)
{
- struct ph_async_context *ac;
- struct ldb_async_handle *h;
+ struct ph_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(req, struct ldb_async_handle);
+ h = talloc_zero(req, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc_zero(h, struct ph_async_context);
+ ac = talloc_zero(h, struct ph_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
return h;
}
-static int get_domain_data_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int get_domain_data_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct ph_async_context *ac;
+ struct ph_context *ac;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(context, struct ph_async_context);
+ ac = talloc_get_type(context, struct ph_context);
/* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) {
return LDB_SUCCESS;
}
-static int build_domain_data_request(struct ph_async_context *ac)
+static int build_domain_data_request(struct ph_context *ac)
{
/* attrs[] is returned from this function in
ac->dom_req->op.search.attrs, so it must be static, as
return LDB_SUCCESS;
}
-static struct domain_data *get_domain_data(struct ldb_module *module, void *ctx, struct ldb_async_result *res)
+static struct domain_data *get_domain_data(struct ldb_module *module, void *ctx, struct ldb_reply *res)
{
struct domain_data *data;
const char *tmp;
- struct ph_async_context *ac;
+ struct ph_context *ac;
- ac = talloc_get_type(ctx, struct ph_async_context);
+ ac = talloc_get_type(ctx, struct ph_context);
data = talloc_zero(ac, struct domain_data);
if (data == NULL) {
static int password_hash_add(struct ldb_module *module, struct ldb_request *req)
{
- struct ldb_async_handle *h;
- struct ph_async_context *ac;
+ struct ldb_handle *h;
+ struct ph_context *ac;
struct ldb_message_element *sambaAttr;
struct ldb_message_element *ntAttr;
struct ldb_message_element *lmAttr;
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct ph_async_context);
+ ac = talloc_get_type(h->private_data, struct ph_context);
/* get user domain data */
ac->domain_sid = samdb_result_sid_prefix(ac, req->op.add.message, "objectSid");
return ldb_next_request(module, ac->dom_req);
}
-static int password_hash_add_do_add(struct ldb_async_handle *h) {
+static int password_hash_add_do_add(struct ldb_handle *h) {
- struct ph_async_context *ac;
+ struct ph_context *ac;
struct domain_data *domain;
struct smb_krb5_context *smb_krb5_context;
struct ldb_message_element *sambaAttr;
struct ldb_message *msg;
int ret;
- ac = talloc_get_type(h->private_data, struct ph_async_context);
+ ac = talloc_get_type(h->private_data, struct ph_context);
domain = get_domain_data(ac->module, ac, ac->dom_res);
if (domain == NULL) {
return ldb_next_request(ac->module, ac->down_req);
}
-static int password_hash_mod_search_self(struct ldb_async_handle *h);
+static int password_hash_mod_search_self(struct ldb_handle *h);
static int password_hash_modify(struct ldb_module *module, struct ldb_request *req)
{
- struct ldb_async_handle *h;
- struct ph_async_context *ac;
+ struct ldb_handle *h;
+ struct ph_context *ac;
struct ldb_message_element *sambaAttr;
struct ldb_message_element *ntAttr;
struct ldb_message_element *lmAttr;
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct ph_async_context);
+ ac = talloc_get_type(h->private_data, struct ph_context);
/* return or own handle to deal with this call */
req->async.handle = h;
return ldb_next_request(module, ac->down_req);
}
-static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct ph_async_context *ac;
+ struct ph_context *ac;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(context, struct ph_async_context);
+ ac = talloc_get_type(context, struct ph_context);
/* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) {
return LDB_SUCCESS;
}
-static int password_hash_mod_search_self(struct ldb_async_handle *h) {
+static int password_hash_mod_search_self(struct ldb_handle *h) {
- struct ph_async_context *ac;
+ struct ph_context *ac;
static const char * const attrs[] = { "userAccountControl", "sambaLMPwdHistory",
"sambaNTPwdHistory",
"objectSid", "msDS-KeyVersionNumber",
"lmPwdHash", "ntPwdHash",
NULL };
- ac = talloc_get_type(h->private_data, struct ph_async_context);
+ ac = talloc_get_type(h->private_data, struct ph_context);
/* prepare the search operation */
ac->search_req = talloc_zero(ac, struct ldb_request);
return ldb_next_request(ac->module, ac->search_req);
}
-static int password_hash_mod_search_dom(struct ldb_async_handle *h) {
+static int password_hash_mod_search_dom(struct ldb_handle *h) {
- struct ph_async_context *ac;
+ struct ph_context *ac;
int ret;
- ac = talloc_get_type(h->private_data, struct ph_async_context);
+ ac = talloc_get_type(h->private_data, struct ph_context);
/* get object domain sid */
ac->domain_sid = samdb_result_sid_prefix(ac, ac->search_res->message, "objectSid");
return ldb_next_request(ac->module, ac->dom_req);
}
-static int password_hash_mod_do_mod(struct ldb_async_handle *h) {
+static int password_hash_mod_do_mod(struct ldb_handle *h) {
- struct ph_async_context *ac;
+ struct ph_context *ac;
struct domain_data *domain;
struct smb_krb5_context *smb_krb5_context;
struct ldb_message_element *sambaAttr;
int ret;
BOOL added_hashes = False;
- ac = talloc_get_type(h->private_data, struct ph_async_context);
+ ac = talloc_get_type(h->private_data, struct ph_context);
domain = get_domain_data(ac->module, ac, ac->dom_res);
if (domain == NULL) {
return ldb_next_request(ac->module, ac->mod_req);
}
-static int ph_async_wait(struct ldb_async_handle *handle) {
- struct ph_async_context *ac;
+static int ph_wait(struct ldb_handle *handle) {
+ struct ph_context *ac;
int ret;
if (!handle || !handle->private_data) {
handle->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS;
- ac = talloc_get_type(handle->private_data, struct ph_async_context);
+ ac = talloc_get_type(handle->private_data, struct ph_context);
switch (ac->step) {
case PH_ADD_SEARCH_DOM:
- ret = ldb_async_wait(ac->dom_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->dom_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return password_hash_add_do_add(handle);
case PH_ADD_DO_ADD:
- ret = ldb_async_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
break;
case PH_MOD_DO_REQ:
- ret = ldb_async_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return password_hash_mod_search_self(handle);
case PH_MOD_SEARCH_SELF:
- ret = ldb_async_wait(ac->search_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->search_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return password_hash_mod_search_dom(handle);
case PH_MOD_SEARCH_DOM:
- ret = ldb_async_wait(ac->dom_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->dom_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return password_hash_mod_do_mod(handle);
case PH_MOD_DO_MOD:
- ret = ldb_async_wait(ac->mod_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->mod_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return ret;
}
-static int ph_async_wait_all(struct ldb_async_handle *handle) {
+static int ph_wait_all(struct ldb_handle *handle) {
int ret;
while (handle->state != LDB_ASYNC_DONE) {
- ret = ph_async_wait(handle);
+ ret = ph_wait(handle);
if (ret != LDB_SUCCESS) {
return ret;
}
return handle->status;
}
-static int password_hash_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int password_hash_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
if (type == LDB_WAIT_ALL) {
- return ph_async_wait_all(handle);
+ return ph_wait_all(handle);
} else {
- return ph_async_wait(handle);
+ return ph_wait(handle);
}
}
.name = "password_hash",
.add = password_hash_add,
.modify = password_hash_modify,
- .async_wait = password_hash_async_wait
+ .wait = password_hash_wait
};
struct rootdse_async_context {
struct ldb_module *module;
void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
const char * const * attrs;
};
-static int rootdse_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int rootdse_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct rootdse_async_context *ac;
return NT_STATUS_OK;
}
-static int ldapsrv_SearchCallback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int ldapsrv_SearchCallback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct ldb_result *res;
int n;
goto reply;
}
- ldb_ret = ldb_async_wait(lreq->async.handle, LDB_WAIT_ALL);
+ ldb_ret = ldb_wait(lreq->async.handle, LDB_WAIT_ALL);
if (ldb_ret == LDB_SUCCESS) {
for (i = 0; i < res->count; i++) {
ret = ldb_request(ldb, req);
if (ret == LDB_SUCCESS) {
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ ret = ldb_wait(req->async.handle, LDB_WAIT_ALL);
}
if (ret == LDB_SUCCESS) {
return ret;
}
-int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
if (!handle) {
return LDB_SUCCESS;
}
- return handle->module->ops->async_wait(handle, type);
+ return handle->module->ops->wait(handle, type);
}
/* set the specified timeout or, if timeout is 0 set the default timeout */
Use talloc_free to free the ldb_message returned in 'res', if successful
*/
-static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct ldb_result *res;
int n;
ret = ldb_request(ldb, req);
if (ret == LDB_SUCCESS) {
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ ret = ldb_wait(req->async.handle, LDB_WAIT_ALL);
}
if (ret != LDB_SUCCESS) {
LDB_REPLY_DONE
};
-enum ldb_async_wait_type {
+enum ldb_wait_type {
LDB_WAIT_ALL,
LDB_WAIT_NONE
};
-enum ldb_async_state {
+enum ldb_state {
LDB_ASYNC_INIT,
LDB_ASYNC_PENDING,
LDB_ASYNC_DONE
struct ldb_control **controls;
};
-struct ldb_async_result {
+struct ldb_reply {
enum ldb_reply_type type;
struct ldb_message *message;
char *referral;
struct ldb_control **controls;
};
-struct ldb_async_handle {
+struct ldb_handle {
int status;
- enum ldb_async_state state;
+ enum ldb_state state;
void *private_data;
struct ldb_module *module;
};
struct {
void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
int timeout;
time_t starttime;
- struct ldb_async_handle *handle;
+ struct ldb_handle *handle;
} async;
};
int ldb_request(struct ldb_context *ldb, struct ldb_request *request);
-int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type);
+int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type);
int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout);
int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq);
int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *);
int (*del_transaction)(struct ldb_module *);
- int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type);
+ int (*wait)(struct ldb_handle *, enum ldb_wait_type);
int (*sequence_number)(struct ldb_module *, struct ldb_request *);
};
struct ldb_context *ldb;
};
-struct ildb_async_context {
+struct ildb_context {
struct ldb_module *module;
struct ldap_request *req;
void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
};
/*
static void ildb_request_timeout(struct event_context *ev, struct timed_event *te,
struct timeval t, void *private_data)
{
- struct ldb_async_handle *handle = talloc_get_type(private_data, struct ldb_async_handle);
- struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
+ struct ldb_handle *handle = talloc_get_type(private_data, struct ldb_handle);
+ struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context);
if (ac->req->state == LDAP_REQUEST_PENDING) {
DLIST_REMOVE(ac->req->conn->pending, ac->req);
static void ildb_callback(struct ldap_request *req)
{
- struct ldb_async_handle *handle = talloc_get_type(req->async.private_data, struct ldb_async_handle);
- struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
+ struct ldb_handle *handle = talloc_get_type(req->async.private_data, struct ldb_handle);
+ struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context);
struct ildb_private *ildb = talloc_get_type(ac->module->private_data, struct ildb_private);
NTSTATUS status;
int i;
/* loop over all messages */
for (i = 0; i < req->num_replies; i++) {
struct ldap_SearchResEntry *search;
- struct ldb_async_result *ares = NULL;
+ struct ldb_reply *ares = NULL;
struct ldap_message *msg;
int ret;
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR;
return;
static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
int timeout,
- struct ldb_async_handle **handle)
+ struct ldb_handle **handle)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ildb_async_context *ildb_ac;
- struct ldb_async_handle *h;
+ struct ildb_context *ildb_ac;
+ struct ldb_handle *h;
struct ldap_request *req;
- h = talloc_zero(ildb->ldap, struct ldb_async_handle);
+ h = talloc_zero(ildb->ldap, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return LDB_ERR_OPERATIONS_ERROR;
h->module = module;
- ildb_ac = talloc(h, struct ildb_async_context);
+ ildb_ac = talloc(h, struct ildb_context);
if (ildb_ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
return LDB_ERR_OPERATIONS_ERROR;
}
-static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int ildb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
- struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
+ struct ildb_context *ac = talloc_get_type(handle->private_data, struct ildb_context);
if (handle->state == LDB_ASYNC_DONE) {
return handle->status;
return handle->status;
}
-static int ildb_rootdse_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int ildb_rootdse_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct ildb_private *ildb;
return ret;
}
- ret = ildb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ ret = ildb_wait(req->async.handle, LDB_WAIT_ALL);
talloc_free(req);
return ret;
.start_transaction = ildb_start_trans,
.end_transaction = ildb_end_trans,
.del_transaction = ildb_del_trans,
- .async_wait = ildb_async_wait,
+ .wait = ildb_wait,
.init_context = ildb_init
};
LDAP *ldap;
};
-struct lldb_async_context {
+struct lldb_context {
struct ldb_module *module;
int msgid;
int timeout;
time_t starttime;
void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
};
static int lldb_ldap_to_ldb(int err) {
return err;
}
-static struct ldb_async_handle *init_handle(struct lldb_private *lldb, struct ldb_module *module,
+static struct ldb_handle *init_handle(struct lldb_private *lldb, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
int timeout, time_t starttime)
{
- struct lldb_async_context *ac;
- struct ldb_async_handle *h;
+ struct lldb_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(lldb, struct ldb_async_handle);
+ h = talloc_zero(lldb, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc(h, struct lldb_async_context);
+ ac = talloc(h, struct lldb_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
static int lldb_search(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_async_context *lldb_ac;
+ struct lldb_context *lldb_ac;
struct timeval tv;
int ldap_scope;
char *search_base;
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context);
search_base = ldb_dn_linearize(lldb_ac, req->op.search.base);
if (req->op.search.base == NULL) {
static int lldb_add(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_async_context *lldb_ac;
+ struct lldb_context *lldb_ac;
LDAPMod **mods;
char *dn;
int ret;
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context);
mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0);
if (mods == NULL) {
static int lldb_modify(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_async_context *lldb_ac;
+ struct lldb_context *lldb_ac;
LDAPMod **mods;
char *dn;
int ret;
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context);
mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1);
if (mods == NULL) {
static int lldb_delete(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_async_context *lldb_ac;
+ struct lldb_context *lldb_ac;
char *dnstr;
int ret;
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context);
dnstr = ldb_dn_linearize(lldb_ac, req->op.del.dn);
static int lldb_rename(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct lldb_async_context *lldb_ac;
+ struct lldb_context *lldb_ac;
char *old_dn;
char *newrdn;
char *parentdn;
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_context);
old_dn = ldb_dn_linearize(lldb_ac, req->op.rename.olddn);
if (old_dn == NULL) {
return lldb_ldap_to_ldb(ret);
}
-static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *result)
+static int lldb_parse_result(struct ldb_handle *handle, LDAPMessage *result)
{
- struct lldb_async_context *ac = talloc_get_type(handle->private_data, struct lldb_async_context);
+ struct lldb_context *ac = talloc_get_type(handle->private_data, struct lldb_context);
struct lldb_private *lldb = talloc_get_type(ac->module->private_data, struct lldb_private);
- struct ldb_async_result *ares = NULL;
+ struct ldb_reply *ares = NULL;
LDAPMessage *msg;
int type;
char *matcheddnp = NULL;
BerElement *berptr = NULL;
char *attr, *dn;
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
ret = LDB_ERR_OPERATIONS_ERROR;
goto error;
goto error;
}
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
ret = LDB_ERR_OPERATIONS_ERROR;
goto error;
goto error;
}
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
ret = LDB_ERR_OPERATIONS_ERROR;
goto error;
return ret;
}
-static int lldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int lldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
- struct lldb_async_context *ac = talloc_get_type(handle->private_data, struct lldb_async_context);
+ struct lldb_context *ac = talloc_get_type(handle->private_data, struct lldb_context);
struct lldb_private *lldb = talloc_get_type(handle->module->private_data, struct lldb_private);
struct timeval timeout;
LDAPMessage *result;
.start_transaction = lldb_start_trans,
.end_transaction = lldb_end_trans,
.del_transaction = lldb_del_trans,
- .async_wait = lldb_async_wait
+ .wait = lldb_wait
};
sqlite3 *sqlite;
};
-struct lsql_async_context {
+struct lsql_context {
struct ldb_module *module;
/* search stuff */
long long current_eid;
const char * const * attrs;
- struct ldb_async_result *ares;
+ struct ldb_reply *ares;
/* async stuff */
void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
};
-static struct ldb_async_handle *init_handle(struct lsqlite3_private *lsqlite3, struct ldb_module *module,
+static struct ldb_handle *init_handle(struct lsqlite3_private *lsqlite3, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
{
- struct lsql_async_context *ac;
- struct ldb_async_handle *h;
+ struct lsql_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(lsqlite3, struct ldb_async_handle);
+ h = talloc_zero(lsqlite3, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc(h, struct lsql_async_context);
+ ac = talloc(h, struct lsql_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
*/
static int lsqlite3_search_callback(void *result, int col_num, char **cols, char **names)
{
- struct ldb_async_handle *handle = talloc_get_type(result, struct ldb_async_handle);
- struct lsql_async_context *ac = talloc_get_type(handle->private_data, struct lsql_async_context);
+ struct ldb_handle *handle = talloc_get_type(result, struct ldb_handle);
+ struct lsql_context *ac = talloc_get_type(handle->private_data, struct lsql_context);
struct ldb_message *msg;
long long eid;
int i;
}
/* start over */
- ac->ares = talloc_zero(ac, struct ldb_async_result);
+ ac->ares = talloc_zero(ac, struct ldb_reply);
if (!ac->ares)
return SQLITE_ABORT;
* Interface functions referenced by lsqlite3_ops
*/
-static int lsql_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int lsql_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct ldb_result *res = NULL;
enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const *attrs,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
+ struct ldb_handle **handle)
{
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private);
- struct lsql_async_context *lsql_ac;
+ struct lsql_context *lsql_ac;
char *norm_basedn;
char *sqlfilter;
char *errmsg;
return LDB_ERR_OPERATIONS_ERROR;
}
- lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context);
+ lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context);
if (base) {
norm_basedn = ldb_dn_linearize(lsql_ac, ldb_dn_casefold(module->ldb, base));
enum ldb_scope scope, struct ldb_parse_tree * tree,
const char * const * attrs, struct ldb_result ** res)
{
- struct ldb_async_handle *handle;
+ struct ldb_handle *handle;
int ret;
*res = talloc_zero(module, struct ldb_result);
&handle);
if (ret == LDB_SUCCESS) {
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle);
}
/* add a record */
static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
+ struct ldb_handle **handle)
{
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private);
- struct lsql_async_context *lsql_ac;
+ struct lsql_context *lsql_ac;
long long eid;
char *dn, *ndn;
char *errmsg;
if (*handle == NULL) {
goto failed;
}
- lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context);
+ lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context);
(*handle)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS;
static int lsql_add(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ldb_async_handle *handle;
+ struct ldb_handle *handle;
int ret;
ret = lsql_add_async(module, msg, NULL, NULL, &handle);
if (ret != LDB_SUCCESS)
return ret;
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle);
return ret;
/* modify a record */
static int lsql_modify_async(struct ldb_module *module, const struct ldb_message *msg,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
+ struct ldb_handle **handle)
{
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private);
- struct lsql_async_context *lsql_ac;
+ struct lsql_context *lsql_ac;
long long eid;
char *errmsg;
int i;
if (*handle == NULL) {
goto failed;
}
- lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context);
+ lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context);
(*handle)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS;
static int lsql_modify(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ldb_async_handle *handle;
+ struct ldb_handle *handle;
int ret;
ret = lsql_modify_async(module, msg, NULL, NULL, &handle);
if (ret != LDB_SUCCESS)
return ret;
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle);
return ret;
/* delete a record */
static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
+ struct ldb_handle **handle)
{
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private);
- struct lsql_async_context *lsql_ac;
+ struct lsql_context *lsql_ac;
long long eid;
char *errmsg;
char *query;
if (*handle == NULL) {
goto failed;
}
- lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context);
+ lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context);
(*handle)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS;
static int lsql_delete(struct ldb_module *module, const struct ldb_dn *dn)
{
- struct ldb_async_handle *handle;
+ struct ldb_handle *handle;
int ret;
/* ignore ltdb specials */
if (ret != LDB_SUCCESS)
return ret;
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle);
return ret;
/* rename a record */
static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *),
+ struct ldb_handle **handle)
{
struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private);
- struct lsql_async_context *lsql_ac;
+ struct lsql_context *lsql_ac;
char *new_dn, *new_cdn, *old_cdn;
char *errmsg;
char *query;
if (*handle == NULL) {
goto failed;
}
- lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_async_context);
+ lsql_ac = talloc_get_type((*handle)->private_data, struct lsql_context);
(*handle)->state = LDB_ASYNC_DONE;
(*handle)->status = LDB_SUCCESS;
static int lsql_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
{
- struct ldb_async_handle *handle;
+ struct ldb_handle *handle;
int ret;
/* ignore ltdb specials */
if (ret != LDB_SUCCESS)
return ret;
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_wait(handle, LDB_WAIT_ALL);
talloc_free(handle);
return ret;
return 0;
}
-static int lsql_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int lsql_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
return handle->status;
}
.start_transaction = lsql_start_trans,
.end_transaction = lsql_end_trans,
.del_transaction = lsql_del_trans,
- .async_wait = lsql_async_wait,
+ .wait = lsql_wait,
};
/*
extracting just the given attributes
*/
static int ltdb_index_filter(const struct dn_list *dn_list,
- struct ldb_async_handle *handle)
+ struct ldb_handle *handle)
{
- struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context);
- struct ldb_async_result *ares = NULL;
+ struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
+ struct ldb_reply *ares = NULL;
unsigned int i;
for (i = 0; i < dn_list->count; i++) {
struct ldb_dn *dn;
int ret;
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR;
handle->state = LDB_ASYNC_DONE;
returns -1 if an indexed search is not possible, in which
case the caller should call ltdb_search_full()
*/
-int ltdb_search_indexed(struct ldb_async_handle *handle)
+int ltdb_search_indexed(struct ldb_handle *handle)
{
- struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context);
+ struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
struct dn_list *dn_list;
int ret;
*/
static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
- struct ldb_async_handle *handle = talloc_get_type(state, struct ldb_async_handle);
- struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context);
- struct ldb_async_result *ares = NULL;
+ struct ldb_handle *handle = talloc_get_type(state, struct ldb_handle);
+ struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
+ struct ldb_reply *ares = NULL;
int ret;
if (key.dsize < 4 ||
return 0;
}
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR;
handle->state = LDB_ASYNC_DONE;
search the database with a LDAP-like expression.
this is the "full search" non-indexed variant
*/
-static int ltdb_search_full(struct ldb_async_handle *handle)
+static int ltdb_search_full(struct ldb_handle *handle)
{
- struct ltdb_async_context *ac = talloc_get_type(handle->private_data, struct ltdb_async_context);
+ struct ltdb_context *ac = talloc_get_type(handle->private_data, struct ltdb_context);
struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
int ret;
int ltdb_search(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
- struct ltdb_async_context *ltdb_ac;
+ struct ltdb_context *ltdb_ac;
int ret;
if ((req->op.search.base == NULL || req->op.search.base->comp_num == 0) &&
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context);
ltdb_ac->tree = req->op.search.tree;
ltdb_ac->scope = req->op.search.scope;
}
-struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
+struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
{
- struct ltdb_async_context *ac;
- struct ldb_async_handle *h;
+ struct ltdb_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(ltdb, struct ldb_async_handle);
+ h = talloc_zero(ltdb, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc_zero(h, struct ltdb_async_context);
+ ac = talloc_zero(h, struct ltdb_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
static int ltdb_add(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
- struct ltdb_async_context *ltdb_ac;
+ struct ltdb_context *ltdb_ac;
int tret, ret = LDB_SUCCESS;
if (req->controls != NULL) {
if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context);
tret = ltdb_add_internal(module, req->op.add.message);
if (tret != LDB_SUCCESS) {
static int ltdb_delete(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
- struct ltdb_async_context *ltdb_ac;
+ struct ltdb_context *ltdb_ac;
int tret, ret = LDB_SUCCESS;
if (req->controls != NULL) {
if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context);
tret = ltdb_delete_internal(module, req->op.del.dn);
if (tret != LDB_SUCCESS) {
static int ltdb_modify(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
- struct ltdb_async_context *ltdb_ac;
+ struct ltdb_context *ltdb_ac;
int tret, ret = LDB_SUCCESS;
if (req->controls != NULL) {
if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context);
tret = ltdb_check_special_dn(module, req->op.mod.message);
if (tret != LDB_SUCCESS) {
static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
- struct ltdb_async_context *ltdb_ac;
+ struct ltdb_context *ltdb_ac;
struct ldb_message *msg;
int tret, ret = LDB_SUCCESS;
if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_context);
msg = talloc(ltdb_ac, struct ldb_message);
if (msg == NULL) {
return LDB_SUCCESS;
}
-static int ltdb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int ltdb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
return handle->status;
}
.start_transaction = ltdb_start_trans,
.end_transaction = ltdb_end_trans,
.del_transaction = ltdb_del_trans,
- .async_wait = ltdb_async_wait,
+ .wait = ltdb_wait,
.sequence_number = ltdb_sequence_number
};
the async local context
holds also internal search state during a full db search
*/
-struct ltdb_async_context {
+struct ltdb_context {
struct ldb_module *module;
/* search stuff */
/* async stuff */
void *context;
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
};
/* special record types */
struct ldb_parse_tree;
-int ltdb_search_indexed(struct ldb_async_handle *handle);
+int ltdb_search_indexed(struct ldb_handle *handle);
int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_reindex(struct ldb_module *module);
int ltdb_search(struct ldb_module *module, struct ldb_request *req);
/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
-struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
+struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *));
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *));
struct TDB_DATA ltdb_key(struct ldb_module *module, const struct ldb_dn *dn);
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn);
#define ASQ_CTRL_UNWILLING_TO_PERFORM 53
#define ASQ_CTRL_AFFECTS_MULTIPLE_DSA 71
-struct asq_async_context {
+struct asq_context {
enum {ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step;
struct ldb_module *module;
void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
const char * const *req_attrs;
char *req_attribute;
int asq_ret;
struct ldb_request *base_req;
- struct ldb_async_result *base_res;
+ struct ldb_reply *base_res;
struct ldb_request **reqs;
int num_reqs;
struct ldb_control **controls;
};
-static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module,
+static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
{
- struct asq_async_context *ac;
- struct ldb_async_handle *h;
+ struct asq_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(mem_ctx, struct ldb_async_handle);
+ h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc_zero(h, struct asq_async_context);
+ ac = talloc_zero(h, struct asq_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
return h;
}
-static int asq_terminate(struct ldb_async_handle *handle)
+static int asq_terminate(struct ldb_handle *handle)
{
- struct asq_async_context *ac;
- struct ldb_async_result *ares;
+ struct asq_context *ac;
+ struct ldb_reply *ares;
struct ldb_asq_control *asq;
int i;
- ac = talloc_get_type(handle->private_data, struct asq_async_context);
+ ac = talloc_get_type(handle->private_data, struct asq_context);
handle->status = LDB_SUCCESS;
handle->state = LDB_ASYNC_DONE;
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (ares == NULL)
return LDB_ERR_OPERATIONS_ERROR;
return LDB_SUCCESS;
}
-static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct asq_async_context *ac;
+ struct asq_context *ac;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error;
}
- ac = talloc_get_type(context, struct asq_async_context);
+ ac = talloc_get_type(context, struct asq_context);
/* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) {
return LDB_ERR_OPERATIONS_ERROR;
}
-static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct asq_async_context *ac;
+ struct asq_context *ac;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error;
}
- ac = talloc_get_type(context, struct asq_async_context);
+ ac = talloc_get_type(context, struct asq_context);
/* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) {
{
struct ldb_control *control;
struct ldb_asq_control *asq_ctrl;
- struct asq_async_context *ac;
- struct ldb_async_handle *h;
+ struct asq_context *ac;
+ struct ldb_handle *h;
char **base_attrs;
int ret;
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct asq_async_context);
+ ac = talloc_get_type(h->private_data, struct asq_context);
req->async.handle = h;
return LDB_SUCCESS;
}
-static int asq_async_requests(struct ldb_async_handle *handle) {
- struct asq_async_context *ac;
+static int asq_requests(struct ldb_handle *handle) {
+ struct asq_context *ac;
struct ldb_message_element *el;
int i;
- ac = talloc_get_type(handle->private_data, struct asq_async_context);
+ ac = talloc_get_type(handle->private_data, struct asq_context);
/* look up the DNs */
el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute);
return LDB_SUCCESS;
}
-static int asq_async_wait_none(struct ldb_async_handle *handle)
+static int asq_wait_none(struct ldb_handle *handle)
{
- struct asq_async_context *ac;
+ struct asq_context *ac;
int ret;
if (!handle || !handle->private_data) {
handle->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS;
- ac = talloc_get_type(handle->private_data, struct asq_async_context);
+ ac = talloc_get_type(handle->private_data, struct asq_context);
switch (ac->step) {
case ASQ_SEARCH_BASE:
- ret = ldb_async_wait(ac->base_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->base_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return LDB_SUCCESS;
}
- ret = asq_async_requests(handle);
+ ret = asq_requests(handle);
case ASQ_SEARCH_MULTI:
}
}
- ret = ldb_async_wait(ac->reqs[ac->cur_req]->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->reqs[ac->cur_req]->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return ret;
}
-static int asq_async_wait_all(struct ldb_async_handle *handle)
+static int asq_wait_all(struct ldb_handle *handle)
{
int ret;
while (handle->state != LDB_ASYNC_DONE) {
- ret = asq_async_wait_none(handle);
+ ret = asq_wait_none(handle);
if (ret != LDB_SUCCESS) {
return ret;
}
return handle->status;
}
-static int asq_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int asq_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
if (type == LDB_WAIT_ALL) {
- return asq_async_wait_all(handle);
+ return asq_wait_all(handle);
} else {
- return asq_async_wait_none(handle);
+ return asq_wait_none(handle);
}
}
static const struct ldb_module_ops asq_ops = {
.name = "asq",
.search = asq_search,
- .async_wait = asq_async_wait,
+ .wait = asq_wait,
.init_context = asq_init
};
#include "includes.h"
#include "ldb/include/includes.h"
-struct oc_async_context {
+struct oc_context {
enum oc_step {OC_DO_REQ, OC_SEARCH_SELF, OC_DO_MOD} step;
struct ldb_request *down_req;
struct ldb_request *search_req;
- struct ldb_async_result *search_res;
+ struct ldb_reply *search_res;
struct ldb_request *mod_req;
};
const char *objectclass;
};
-static struct ldb_async_handle *oc_init_handle(struct ldb_request *req, struct ldb_module *module)
+static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_module *module)
{
- struct oc_async_context *ac;
- struct ldb_async_handle *h;
+ struct oc_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(req, struct ldb_async_handle);
+ h = talloc_zero(req, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc_zero(h, struct oc_async_context);
+ ac = talloc_zero(h, struct oc_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
}
{
- struct ldb_async_handle *h;
- struct oc_async_context *ac;
+ struct ldb_handle *h;
+ struct oc_context *ac;
h = oc_init_handle(req, module);
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct oc_async_context);
+ ac = talloc_get_type(h->private_data, struct oc_context);
/* return or own handle to deal with this call */
req->async.handle = h;
}
}
-static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct oc_async_context *ac;
+ struct oc_context *ac;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(context, struct oc_async_context);
+ ac = talloc_get_type(context, struct oc_context);
/* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) {
return LDB_SUCCESS;
}
-static int objectclass_search_self(struct ldb_async_handle *h) {
+static int objectclass_search_self(struct ldb_handle *h) {
- struct oc_async_context *ac;
+ struct oc_context *ac;
static const char * const attrs[] = { "objectClass", NULL };
- ac = talloc_get_type(h->private_data, struct oc_async_context);
+ ac = talloc_get_type(h->private_data, struct oc_context);
/* prepare the search operation */
ac->search_req = talloc_zero(ac, struct ldb_request);
return ldb_next_request(ac->module, ac->search_req);
}
-static int objectclass_do_mod(struct ldb_async_handle *h) {
+static int objectclass_do_mod(struct ldb_handle *h) {
- struct oc_async_context *ac;
+ struct oc_context *ac;
struct ldb_message_element *objectclass_element;
struct ldb_message *msg;
TALLOC_CTX *mem_ctx;
struct class_list *sorted, *current;
int ret;
- ac = talloc_get_type(h->private_data, struct oc_async_context);
+ ac = talloc_get_type(h->private_data, struct oc_context);
mem_ctx = talloc_new(ac);
if (mem_ctx == NULL) {
return ldb_next_request(ac->module, ac->mod_req);
}
-static int oc_async_wait(struct ldb_async_handle *handle) {
- struct oc_async_context *ac;
+static int oc_wait(struct ldb_handle *handle) {
+ struct oc_context *ac;
int ret;
if (!handle || !handle->private_data) {
handle->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS;
- ac = talloc_get_type(handle->private_data, struct oc_async_context);
+ ac = talloc_get_type(handle->private_data, struct oc_context);
switch (ac->step) {
case OC_DO_REQ:
- ret = ldb_async_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return objectclass_search_self(handle);
case OC_SEARCH_SELF:
- ret = ldb_async_wait(ac->search_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->search_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return objectclass_do_mod(handle);
case OC_DO_MOD:
- ret = ldb_async_wait(ac->mod_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->mod_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
return ret;
}
-static int oc_async_wait_all(struct ldb_async_handle *handle) {
+static int oc_wait_all(struct ldb_handle *handle) {
int ret;
while (handle->state != LDB_ASYNC_DONE) {
- ret = oc_async_wait(handle);
+ ret = oc_wait(handle);
if (ret != LDB_SUCCESS) {
return ret;
}
return handle->status;
}
-static int objectclass_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int objectclass_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
if (type == LDB_WAIT_ALL) {
- return oc_async_wait_all(handle);
+ return oc_wait_all(handle);
} else {
- return oc_async_wait(handle);
+ return oc_wait(handle);
}
}
.name = "objectclass",
.add = objectclass_add,
.modify = objectclass_modify,
- .async_wait = objectclass_async_wait
+ .wait = objectclass_wait
};
int ldb_objectclass_init(void)
struct ldb_module *module;
void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
const char * const *attrs;
};
-static int operational_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int operational_async_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
struct operational_async_context *ac;
#include "ldb/include/includes.h"
struct message_store {
- /* keep the whole ldb_async_result as an optimization
+ /* keep the whole ldb_reply as an optimization
* instead of freeing and talloc-ing the container
* on each result */
- struct ldb_async_result *r;
+ struct ldb_reply *r;
struct message_store *next;
};
return new;
}
-struct paged_async_context {
+struct paged_context {
struct ldb_module *module;
void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
int size;
struct results_store *store;
};
-static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module,
+static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
{
- struct paged_async_context *ac;
- struct ldb_async_handle *h;
+ struct paged_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(mem_ctx, struct ldb_async_handle);
+ h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc_zero(h, struct paged_async_context);
+ ac = talloc_zero(h, struct paged_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
return h;
}
-static int paged_search_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int paged_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct paged_async_context *ac = NULL;
+ struct paged_context *ac = NULL;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error;
}
- ac = talloc_get_type(context, struct paged_async_context);
+ ac = talloc_get_type(context, struct paged_context);
if (ares->type == LDB_REPLY_ENTRY) {
if (ac->store->first == NULL) {
struct private_data *private_data;
struct ldb_paged_control *paged_ctrl;
struct ldb_control **saved_controls;
- struct paged_async_context *ac;
- struct ldb_async_handle *h;
+ struct paged_context *ac;
+ struct ldb_handle *h;
int ret;
/* check if there's a paged request control */
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct paged_async_context);
+ ac = talloc_get_type(h->private_data, struct paged_context);
ac->size = paged_ctrl->size;
}
ac->store->req->async.context = ac;
- ac->store->req->async.callback = paged_search_async_callback;
+ ac->store->req->async.callback = paged_search_callback;
ldb_set_timeout_from_prev_req(module->ldb, req, ac->store->req);
ret = ldb_next_request(module, ac->store->req);
}
-static int paged_results(struct ldb_async_handle *handle)
+static int paged_results(struct ldb_handle *handle)
{
- struct paged_async_context *ac;
+ struct paged_context *ac;
struct ldb_paged_control *paged;
- struct ldb_async_result *ares;
+ struct ldb_reply *ares;
struct message_store *msg;
int i, num_ctrls, ret;
- ac = talloc_get_type(handle->private_data, struct paged_async_context);
+ ac = talloc_get_type(handle->private_data, struct paged_context);
if (ac->store == NULL)
return LDB_ERR_OPERATIONS_ERROR;
talloc_free(msg);
}
- ares = talloc_zero(ac->store, struct ldb_async_result);
+ ares = talloc_zero(ac->store, struct ldb_reply);
if (ares == NULL) {
handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status;
return ret;
}
-static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int paged_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
- struct paged_async_context *ac;
+ struct paged_context *ac;
int ret;
if (!handle || !handle->private_data) {
handle->state = LDB_ASYNC_PENDING;
- ac = talloc_get_type(handle->private_data, struct paged_async_context);
+ ac = talloc_get_type(handle->private_data, struct paged_context);
if (ac->store->req->async.handle->state == LDB_ASYNC_DONE) {
/* if lower level is finished we do not need to call it anymore */
if (type == LDB_WAIT_ALL) {
while (ac->store->req->async.handle->state != LDB_ASYNC_DONE) {
- ret = ldb_async_wait(ac->store->req->async.handle, type);
+ ret = ldb_wait(ac->store->req->async.handle, type);
if (ret != LDB_SUCCESS) {
handle->state = LDB_ASYNC_DONE;
handle->status = ret;
return ret;
}
- ret = ldb_async_wait(ac->store->req->async.handle, type);
+ ret = ldb_wait(ac->store->req->async.handle, type);
if (ret != LDB_SUCCESS) {
handle->state = LDB_ASYNC_DONE;
handle->status = ret;
static const struct ldb_module_ops paged_ops = {
.name = "paged_results",
.search = paged_search,
- .async_wait = paged_async_wait,
+ .wait = paged_wait,
.init_context = paged_request_init
};
return ret;
}
-struct rename_async_context {
+struct rename_context {
enum {RENAME_RENAME, RENAME_MODIFY} step;
struct ldb_request *orig_req;
static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req)
{
- struct ldb_async_handle *h;
- struct rename_async_context *ac;
+ struct ldb_handle *h;
+ struct rename_context *ac;
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n");
return ldb_next_request(module, req);
}
- h = talloc_zero(req, struct ldb_async_handle);
+ h = talloc_zero(req, struct ldb_handle);
if (h == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
h->module = module;
- ac = talloc_zero(h, struct rename_async_context);
+ ac = talloc_zero(h, struct rename_context);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
return ldb_next_request(module, ac->down_req);
}
-static int rdn_name_rename_do_mod(struct ldb_async_handle *h) {
+static int rdn_name_rename_do_mod(struct ldb_handle *h) {
- struct rename_async_context *ac;
+ struct rename_context *ac;
struct ldb_dn_component *rdn;
struct ldb_message *msg;
- ac = talloc_get_type(h->private_data, struct rename_async_context);
+ ac = talloc_get_type(h->private_data, struct rename_context);
rdn = ldb_dn_get_rdn(ac, ac->orig_req->op.rename.newdn);
if (rdn == NULL) {
return ldb_request(h->module->ldb, ac->mod_req);
}
-static int rename_async_wait(struct ldb_async_handle *handle)
+static int rename_wait(struct ldb_handle *handle)
{
- struct rename_async_context *ac;
+ struct rename_context *ac;
int ret;
if (!handle || !handle->private_data) {
handle->state = LDB_ASYNC_PENDING;
handle->status = LDB_SUCCESS;
- ac = talloc_get_type(handle->private_data, struct rename_async_context);
+ ac = talloc_get_type(handle->private_data, struct rename_context);
switch(ac->step) {
case RENAME_RENAME:
- ret = ldb_async_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->down_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
goto done;
return rdn_name_rename_do_mod(handle);
case RENAME_MODIFY:
- ret = ldb_async_wait(ac->mod_req->async.handle, LDB_WAIT_NONE);
+ ret = ldb_wait(ac->mod_req->async.handle, LDB_WAIT_NONE);
if (ret != LDB_SUCCESS) {
handle->status = ret;
goto done;
return ret;
}
-static int rename_async_wait_all(struct ldb_async_handle *handle) {
+static int rename_wait_all(struct ldb_handle *handle) {
int ret;
while (handle->state != LDB_ASYNC_DONE) {
- ret = rename_async_wait(handle);
+ ret = rename_wait(handle);
if (ret != LDB_SUCCESS) {
return ret;
}
return handle->status;
}
-static int rdn_name_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int rdn_name_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
if (type == LDB_WAIT_ALL) {
- return rename_async_wait_all(handle);
+ return rename_wait_all(handle);
} else {
- return rename_async_wait(handle);
+ return rename_wait(handle);
}
}
.name = "rdn_name",
.add = rdn_name_add,
.rename = rdn_name_rename,
- .async_wait = rdn_name_async_wait
+ .wait = rdn_name_wait
};
int result;
};
-struct sort_async_context {
+struct sort_context {
struct ldb_module *module;
void *up_context;
- int (*up_callback)(struct ldb_context *, void *, struct ldb_async_result *);
+ int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *);
char *attributeName;
char *orderingRule;
int sort_result;
};
-static struct ldb_async_handle *init_handle(void *mem_ctx, struct ldb_module *module,
+static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
+ int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
{
- struct sort_async_context *ac;
- struct ldb_async_handle *h;
+ struct sort_context *ac;
+ struct ldb_handle *h;
- h = talloc_zero(mem_ctx, struct ldb_async_handle);
+ h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return NULL;
h->module = module;
- ac = talloc_zero(h, struct sort_async_context);
+ ac = talloc_zero(h, struct sort_context);
if (ac == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, void *opaque)
{
- struct sort_async_context *ac = talloc_get_type(opaque, struct sort_async_context);
+ struct sort_context *ac = talloc_get_type(opaque, struct sort_context);
struct ldb_message_element *el1, *el2;
if (ac->sort_result != 0) {
return ac->h->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]);
}
-static int server_sort_search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int server_sort_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct sort_async_context *ac = NULL;
+ struct sort_context *ac = NULL;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
goto error;
}
- ac = talloc_get_type(context, struct sort_async_context);
+ ac = talloc_get_type(context, struct sort_context);
if (ares->type == LDB_REPLY_ENTRY) {
ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2);
struct ldb_control *control;
struct ldb_server_sort_control **sort_ctrls;
struct ldb_control **saved_controls;
- struct sort_async_context *ac;
- struct ldb_async_handle *h;
+ struct sort_context *ac;
+ struct ldb_handle *h;
int ret;
/* check if there's a paged request control */
if (!h) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(h->private_data, struct sort_async_context);
+ ac = talloc_get_type(h->private_data, struct sort_context);
sort_ctrls = talloc_get_type(control->data, struct ldb_server_sort_control *);
if (!sort_ctrls) {
if (sort_ctrls[1] != NULL) {
if (control->critical) {
- struct ldb_async_result *ares;
+ struct ldb_reply *ares;
- ares = talloc_zero(req, struct ldb_async_result);
+ ares = talloc_zero(req, struct ldb_reply);
if (!ares)
return LDB_ERR_OPERATIONS_ERROR;
return ldb_next_request(module, ac->req);
}
-static int server_sort_results(struct ldb_async_handle *handle)
+static int server_sort_results(struct ldb_handle *handle)
{
- struct sort_async_context *ac;
- struct ldb_async_result *ares;
+ struct sort_context *ac;
+ struct ldb_reply *ares;
int i, ret;
- ac = talloc_get_type(handle->private_data, struct sort_async_context);
+ ac = talloc_get_type(handle->private_data, struct sort_context);
ac->h = ldb_attrib_handler(ac->module->ldb, ac->attributeName);
ac->sort_result = 0;
ac, (ldb_qsort_cmp_fn_t)sort_compare);
for (i = 0; i < ac->num_msgs; i++) {
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status;
}
for (i = 0; i < ac->num_refs; i++) {
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status;
}
}
- ares = talloc_zero(ac, struct ldb_async_result);
+ ares = talloc_zero(ac, struct ldb_reply);
if (!ares) {
handle->status = LDB_ERR_OPERATIONS_ERROR;
return handle->status;
return LDB_SUCCESS;
}
-static int server_sort_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
+static int server_sort_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
- struct sort_async_context *ac;
+ struct sort_context *ac;
int ret;
if (!handle || !handle->private_data) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_get_type(handle->private_data, struct sort_async_context);
+ ac = talloc_get_type(handle->private_data, struct sort_context);
- ret = ldb_async_wait(ac->req->async.handle, type);
+ ret = ldb_wait(ac->req->async.handle, type);
if (ret != LDB_SUCCESS) {
handle->status = ret;
static const struct ldb_module_ops server_sort_ops = {
.name = "server_sort",
.search = server_sort_search,
- .async_wait = server_sort_async_wait,
+ .wait = server_sort_wait,
.init_context = server_sort_init
};
return ldb_dn_compare(ldb, (*el1)->dn, (*el2)->dn);
}
-struct async_context {
+struct search_context {
struct ldb_control **req_ctrls;
int sort;
int status;
};
-static int store_message(struct ldb_message *msg, struct async_context *actx) {
+static int store_message(struct ldb_message *msg, struct search_context *sctx) {
- actx->store = talloc_realloc(actx, actx->store, struct ldb_message *, actx->num_stored + 2);
- if (!actx->store) {
+ sctx->store = talloc_realloc(sctx, sctx->store, struct ldb_message *, sctx->num_stored + 2);
+ if (!sctx->store) {
fprintf(stderr, "talloc_realloc failed while storing messages\n");
return -1;
}
- actx->store[actx->num_stored] = talloc_steal(actx->store, msg);
- if (!actx->store[actx->num_stored]) {
+ sctx->store[sctx->num_stored] = talloc_steal(sctx->store, msg);
+ if (!sctx->store[sctx->num_stored]) {
fprintf(stderr, "talloc_steal failed while storing messages\n");
return -1;
}
- actx->num_stored++;
- actx->store[actx->num_stored] = NULL;
+ sctx->num_stored++;
+ sctx->store[sctx->num_stored] = NULL;
return 0;
}
-static int store_referral(char *referral, struct async_context *actx) {
+static int store_referral(char *referral, struct search_context *sctx) {
- actx->refs_store = talloc_realloc(actx, actx->refs_store, char *, actx->refs + 2);
- if (!actx->refs_store) {
+ sctx->refs_store = talloc_realloc(sctx, sctx->refs_store, char *, sctx->refs + 2);
+ if (!sctx->refs_store) {
fprintf(stderr, "talloc_realloc failed while storing referrals\n");
return -1;
}
- actx->refs_store[actx->refs] = talloc_steal(actx->refs_store, referral);
- if (!actx->refs_store[actx->refs]) {
+ sctx->refs_store[sctx->refs] = talloc_steal(sctx->refs_store, referral);
+ if (!sctx->refs_store[sctx->refs]) {
fprintf(stderr, "talloc_steal failed while storing referrals\n");
return -1;
}
- actx->refs++;
- actx->refs_store[actx->refs] = NULL;
+ sctx->refs++;
+ sctx->refs_store[sctx->refs] = NULL;
return 0;
}
-static int display_message(struct ldb_context *ldb, struct ldb_message *msg, struct async_context *actx) {
+static int display_message(struct ldb_context *ldb, struct ldb_message *msg, struct search_context *sctx) {
struct ldb_ldif ldif;
- actx->entries++;
- printf("# record %d\n", actx->entries);
+ sctx->entries++;
+ printf("# record %d\n", sctx->entries);
ldif.changetype = LDB_CHANGETYPE_NONE;
ldif.msg = msg;
- if (actx->sort) {
+ if (sctx->sort) {
/*
* Ensure attributes are always returned in the same
* order. For testing, this makes comparison of old
return 0;
}
-static int display_referral(char *referral, struct async_context *actx) {
+static int display_referral(char *referral, struct search_context *sctx) {
- actx->refs++;
+ sctx->refs++;
printf("# Referral\nref: %s\n\n", referral);
return 0;
}
-static int search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct async_context *actx = talloc_get_type(context, struct async_context);
+ struct search_context *sctx = talloc_get_type(context, struct search_context);
int ret;
switch (ares->type) {
case LDB_REPLY_ENTRY:
- if (actx->sort) {
- ret = store_message(ares->message, actx);
+ if (sctx->sort) {
+ ret = store_message(ares->message, sctx);
} else {
- ret = display_message(ldb, ares->message, actx);
+ ret = display_message(ldb, ares->message, sctx);
}
break;
case LDB_REPLY_REFERRAL:
- if (actx->sort) {
- ret = store_referral(ares->referral, actx);
+ if (sctx->sort) {
+ ret = store_referral(ares->referral, sctx);
} else {
- ret = display_referral(ares->referral, actx);
+ ret = display_referral(ares->referral, sctx);
}
break;
case LDB_REPLY_DONE:
if (ares->controls) {
- if (handle_controls_reply(ares->controls, actx->req_ctrls) == 1)
- actx->pending = 1;
+ if (handle_controls_reply(ares->controls, sctx->req_ctrls) == 1)
+ sctx->pending = 1;
}
ret = 0;
break;
if (talloc_free(ares) == -1) {
fprintf(stderr, "talloc_free failed\n");
- actx->pending = 0;
+ sctx->pending = 0;
return LDB_ERR_OPERATIONS_ERROR;
}
const char * const *attrs)
{
struct ldb_request *req;
- struct async_context *actx;
+ struct search_context *sctx;
int ret;
req = talloc(ldb, struct ldb_request);
if (!req) return -1;
- actx = talloc(req, struct async_context);
- if (!actx) return -1;
+ sctx = talloc(req, struct search_context);
+ if (!sctx) return -1;
- actx->sort = options->sorted;
- actx->num_stored = 0;
- actx->store = NULL;
- actx->req_ctrls = parse_controls(ldb, options->controls);
- if (options->controls != NULL && actx->req_ctrls== NULL) return -1;
- actx->entries = 0;
- actx->refs = 0;
+ sctx->sort = options->sorted;
+ sctx->num_stored = 0;
+ sctx->store = NULL;
+ sctx->req_ctrls = parse_controls(ldb, options->controls);
+ if (options->controls != NULL && sctx->req_ctrls== NULL) return -1;
+ sctx->entries = 0;
+ sctx->refs = 0;
req->operation = LDB_SEARCH;
req->op.search.base = basedn;
req->op.search.tree = ldb_parse_tree(ldb, expression);
if (req->op.search.tree == NULL) return -1;
req->op.search.attrs = attrs;
- req->controls = actx->req_ctrls;
- req->async.context = actx;
+ req->controls = sctx->req_ctrls;
+ req->async.context = sctx;
req->async.callback = &search_callback;
ldb_set_timeout(ldb, req, 0); /* TODO: make this settable by command line */
again:
- actx->pending = 0;
+ sctx->pending = 0;
ret = ldb_request(ldb, req);
if (ret != LDB_SUCCESS) {
return -1;
}
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ ret = ldb_wait(req->async.handle, LDB_WAIT_ALL);
if (ret != LDB_SUCCESS) {
printf("search error - %s\n", ldb_errstring(ldb));
return -1;
}
- if (actx->pending)
+ if (sctx->pending)
goto again;
- if (actx->sort && actx->num_stored != 0) {
+ if (sctx->sort && sctx->num_stored != 0) {
int i;
- ldb_qsort(actx->store, ret, sizeof(struct ldb_message *),
+ ldb_qsort(sctx->store, ret, sizeof(struct ldb_message *),
ldb, (ldb_qsort_cmp_fn_t)do_compare_msg);
if (ret != 0) {
exit(1);
}
- for (i = 0; i < actx->num_stored; i++) {
- display_message(ldb, actx->store[i], actx);
+ for (i = 0; i < sctx->num_stored; i++) {
+ display_message(ldb, sctx->store[i], sctx);
}
- for (i = 0; i < actx->refs; i++) {
- display_referral(actx->refs_store[i], actx);
+ for (i = 0; i < sctx->refs; i++) {
+ display_referral(sctx->refs_store[i], sctx);
}
}
printf("# returned %d records\n# %d entries\n# %d referrals\n",
- actx->entries + actx->refs, actx->entries, actx->refs);
+ sctx->entries + sctx->refs, sctx->entries, sctx->refs);
talloc_free(req);
const char *schemadn;
};
-struct test_schema_async_ctx {
+struct test_schema_ctx {
struct ldb_paged_control *ctrl;
uint32_t count;
BOOL pending;
return True;
}
-static int test_schema_search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int test_schema_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
{
- struct test_schema_async_ctx *actx = talloc_get_type(context, struct test_schema_async_ctx);
+ struct test_schema_ctx *actx = talloc_get_type(context, struct test_schema_ctx);
int ret = LDB_SUCCESS;
switch (ares->type) {
struct ldb_paged_control *control;
struct ldb_request *req;
int ret;
- struct test_schema_async_ctx *actx;
+ struct test_schema_ctx *actx;
req = talloc(ldb, struct ldb_request);
- actx = talloc(req, struct test_schema_async_ctx);
+ actx = talloc(req, struct test_schema_ctx);
ctrl = talloc_array(req, struct ldb_control *, 2);
ctrl[0] = talloc(ctrl, struct ldb_control);
return False;
}
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ ret = ldb_wait(req->async.handle, LDB_WAIT_ALL);
if (ret != LDB_SUCCESS) {
d_printf("search error - %s\n", ldb_errstring(ldb));
return False;