summaryrefslogtreecommitdiff
path: root/ldb/include
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-09-25 02:28:56 -0400
committerSimo Sorce <idra@samba.org>2008-09-25 03:21:34 -0400
commit9bd63b97c9c3132a0b3c8c6bd1c67f8c31a54c3c (patch)
treeaf51399e30505f1111308f8d582934ab83d31396 /ldb/include
parentf698831f0ae0cd86225eb647ae4aeb813f08d3b5 (diff)
downloadsssd-9bd63b97c9c3132a0b3c8c6bd1c67f8c31a54c3c.tar.gz
sssd-9bd63b97c9c3132a0b3c8c6bd1c67f8c31a54c3c.tar.bz2
sssd-9bd63b97c9c3132a0b3c8c6bd1c67f8c31a54c3c.zip
Sync ldb with upstream (includes uncommitted ldb async patches)
Diffstat (limited to 'ldb/include')
-rw-r--r--ldb/include/ldb.h129
-rw-r--r--ldb/include/ldb_private.h99
2 files changed, 146 insertions, 82 deletions
diff --git a/ldb/include/ldb.h b/ldb/include/ldb.h
index 937029f5..b1ce3ef7 100644
--- a/ldb/include/ldb.h
+++ b/ldb/include/ldb.h
@@ -181,6 +181,7 @@ enum ldb_scope {LDB_SCOPE_DEFAULT=-1,
LDB_SCOPE_SUBTREE=2};
struct ldb_context;
+struct event_context;
/* debugging uses one of the following levels */
enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR,
@@ -659,7 +660,6 @@ enum ldb_request_type {
enum ldb_reply_type {
LDB_REPLY_ENTRY,
LDB_REPLY_REFERRAL,
- LDB_REPLY_EXTENDED,
LDB_REPLY_DONE
};
@@ -693,14 +693,11 @@ struct ldb_reply {
struct ldb_extended *response;
char *referral;
struct ldb_control **controls;
+ int error;
};
-struct ldb_handle {
- int status;
- enum ldb_state state;
- void *private_data;
- struct ldb_module *module;
-};
+struct ldb_request;
+struct ldb_handle;
struct ldb_search {
struct ldb_dn *base;
@@ -747,7 +744,8 @@ struct ldb_sequence_number {
uint32_t flags;
};
-typedef int (*ldb_request_callback_t)(struct ldb_context *, void *, struct ldb_reply *);
+typedef int (*ldb_request_callback_t)(struct ldb_request *, struct ldb_reply *);
+
struct ldb_request {
enum ldb_request_type operation;
@@ -775,7 +773,10 @@ struct ldb_request {
};
int ldb_request(struct ldb_context *ldb, struct ldb_request *request);
+int ldb_request_done(struct ldb_request *req, int status);
+bool ldb_request_is_done(struct ldb_request *req);
+int ldb_modules_wait(struct ldb_handle *handle);
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);
@@ -831,6 +832,19 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx);
(that is, with LDB_FLG_RDONLY). However in read-write mode, the database will be
created if it does not exist.
*/
+
+typedef void (*ldb_async_timeout_fn) (void *);
+typedef bool (*ldb_async_callback_fn) (void *);
+typedef int (*ldb_async_ctx_add_op_fn)(void *, time_t, void *, ldb_async_timeout_fn, ldb_async_callback_fn);
+typedef int (*ldb_async_ctx_wait_op_fn)(void *);
+
+void ldb_async_ctx_set_private_data(struct ldb_context *ldb,
+ void *private_data);
+void ldb_async_ctx_set_add_op(struct ldb_context *ldb,
+ ldb_async_ctx_add_op_fn add_op);
+void ldb_async_ctx_set_wait_op(struct ldb_context *ldb,
+ ldb_async_ctx_wait_op_fn wait_op);
+
int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]);
/*
@@ -860,13 +874,12 @@ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb);
/**
The default async search callback function
- \param ldb the context associated with the database (from ldb_init())
- \param context the callback context (struct ldb_result *)
+ \param req the request we are callback of
\param ares a single reply from the async core
\return result code (LDB_SUCCESS on success, or a failure code)
- \note this function expects the context to always be an struct ldb_result pointer
+ \note this function expects req->context to always be an struct ldb_result pointer
AND a talloc context, this function will steal on the context each message
from the ares reply passed on by the async core so that in the end all the
messages will be in the context (ldb_result) memory tree.
@@ -875,7 +888,18 @@ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb);
request that can be freed as sson as the search request is finished)
*/
-int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares);
+int ldb_search_default_callback(struct ldb_request *req, struct ldb_reply *ares);
+
+/**
+ The default async extended operation callback function
+
+ \param req the request we are callback of
+ \param ares a single reply from the async core
+
+ \return result code (LDB_SUCCESS on success, or a failure code)
+*/
+int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares);
+
/**
Helper function to build a search request
@@ -889,7 +913,8 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l
\param attrs the search attributes for the query (pass NULL if none required)
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -903,7 +928,20 @@ int ldb_build_search_req(struct ldb_request **ret_req,
const char * const *attrs,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
+
+int ldb_build_search_req_ex(struct ldb_request **ret_req,
+ struct ldb_context *ldb,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_dn *base,
+ enum ldb_scope scope,
+ struct ldb_parse_tree *tree,
+ const char * const *attrs,
+ struct ldb_control **controls,
+ void *context,
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build an add request
@@ -914,7 +952,8 @@ int ldb_build_search_req(struct ldb_request **ret_req,
\param message contains the entry to be added
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -925,7 +964,8 @@ int ldb_build_add_req(struct ldb_request **ret_req,
const struct ldb_message *message,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build a modify request
@@ -936,7 +976,8 @@ int ldb_build_add_req(struct ldb_request **ret_req,
\param message contains the entry to be modified
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -947,7 +988,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
const struct ldb_message *message,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build a delete request
@@ -958,7 +1000,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
\param dn the DN to be deleted
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -969,7 +1012,8 @@ int ldb_build_del_req(struct ldb_request **ret_req,
struct ldb_dn *dn,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Helper function to build a rename request
@@ -981,7 +1025,8 @@ int ldb_build_del_req(struct ldb_request **ret_req,
\param newdn the new DN
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -993,7 +1038,8 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
struct ldb_dn *newdn,
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
Add a ldb_control to a ldb_request
@@ -1023,31 +1069,21 @@ struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char
records that match an LDAP-like search expression
\param ldb the context associated with the database (from ldb_init())
+ \param mem_ctx the memory context to use for the request and the results
+ \param result the return result
\param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one)
\param scope the search scope for the query
- \param expression the search expression to use for this query
\param attrs the search attributes for the query (pass NULL if none required)
- \param res the return result
+ \param exp_fmt the search expression to use for this query (printf like)
\return result code (LDB_SUCCESS on success, or a failure code)
\note use talloc_free() to free the ldb_result returned
*/
-int ldb_search(struct ldb_context *ldb,
- struct ldb_dn *base,
- enum ldb_scope scope,
- const char *expression,
- const char * const *attrs, struct ldb_result **res);
-
-/*
- * a useful search function where you can easily define the expression and
- * that takes a memory context where results are allocated
-*/
-
-int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
- struct ldb_result **result, struct ldb_dn *base,
- enum ldb_scope scope, const char * const *attrs,
- const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8);
+int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+ struct ldb_result **result, struct ldb_dn *base,
+ enum ldb_scope scope, const char * const *attrs,
+ const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8);
/**
Add a record to the database.
@@ -1113,13 +1149,12 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn);
/**
The default async extended operation callback function
- \param ldb the context associated with the database (from ldb_init())
- \param context the callback context (struct ldb_result *)
+ \param req the request we are callback of
\param ares a single reply from the async core
\return result code (LDB_SUCCESS on success, or a failure code)
- \note this function expects the context to always be an struct ldb_result pointer
+ \note this function expects req->context to always be an struct ldb_result pointer
AND a talloc context, this function will steal on the context each message
from the ares reply passed on by the async core so that in the end all the
messages will be in the context (ldb_result) memory tree.
@@ -1127,7 +1162,9 @@ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn);
(the request need to be freed separately and the result doe not depend on the
request that can be freed as sson as the search request is finished)
*/
-int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares);
+
+int ldb_extended_default_callback(struct ldb_request *req, struct ldb_reply *ares);
+
/**
Helper function to build a extended request
@@ -1140,7 +1177,8 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct
it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
\param controls an array of controls
\param context the callback function context
- \param callback the callback function to handle the async replies
+ \param the callback function to handle the async replies
+ \param the parent request if any
\return result code (LDB_SUCCESS on success, or a failure code)
*/
@@ -1151,7 +1189,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req,
void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */
struct ldb_control **controls,
void *context,
- ldb_request_callback_t callback);
+ ldb_request_callback_t callback,
+ struct ldb_request *parent);
/**
call an extended operation
diff --git a/ldb/include/ldb_private.h b/ldb/include/ldb_private.h
index e1026ab7..a92549d9 100644
--- a/ldb/include/ldb_private.h
+++ b/ldb/include/ldb_private.h
@@ -43,6 +43,12 @@ struct ldb_module_ops;
struct ldb_backend_ops;
+struct ldb_handle {
+ int status;
+ enum ldb_state state;
+ struct ldb_context *ldb;
+};
+
/* basic module structure */
struct ldb_module {
struct ldb_module *prev, *next;
@@ -51,9 +57,8 @@ struct ldb_module {
const struct ldb_module_ops *ops;
};
-/*
- these function pointers define the operations that a ldb module must perform
- they correspond exactly to the ldb_*() interface
+/*
+ these function pointers define the operations that a ldb module can intercept
*/
struct ldb_module_ops {
const char *name;
@@ -68,22 +73,10 @@ struct ldb_module_ops {
int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *);
int (*del_transaction)(struct ldb_module *);
- int (*wait)(struct ldb_handle *, enum ldb_wait_type);
int (*sequence_number)(struct ldb_module *, struct ldb_request *);
+ void *private_data;
};
-
-typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[],
- struct ldb_module **module);
-
-
-struct ldb_backend_ops {
- const char *name;
- ldb_connect_fn connect_fn;
-};
-
-const char *ldb_default_modules_dir(void);
-
/*
schema related information needed for matching rules
*/
@@ -145,27 +138,6 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op
struct ldb_module **backend_module);
void ldb_set_default_dns(struct ldb_context *ldb);
-/* The following definitions come from lib/ldb/common/ldb_modules.c */
-
-const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
-int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out);
-int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
-int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);
-int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
-int ldb_next_start_trans(struct ldb_module *module);
-int ldb_next_end_trans(struct ldb_module *module);
-int ldb_next_del_trans(struct ldb_module *module);
-int ldb_next_init(struct ldb_module *module);
-
-void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
-void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-void ldb_reset_err_string(struct ldb_context *ldb);
-
-int ldb_register_module(const struct ldb_module_ops *);
-int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
-void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
- const char *symbol);
-
/* The following definitions come from lib/ldb/common/ldb_debug.c */
void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
@@ -248,4 +220,57 @@ int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, ui
#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02
+/* MODULES specific headers -- SSS */
+
+/* The following definitions come from lib/ldb/common/ldb_modules.c */
+
+const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
+int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out);
+int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
+int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);
+int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
+int ldb_next_start_trans(struct ldb_module *module);
+int ldb_next_end_trans(struct ldb_module *module);
+int ldb_next_del_trans(struct ldb_module *module);
+int ldb_next_init(struct ldb_module *module);
+
+void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
+void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
+void ldb_reset_err_string(struct ldb_context *ldb);
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_module(const struct ldb_module_ops *);
+
+typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url,
+ unsigned int flags, const char *options[],
+ struct ldb_module **module);
+
+struct ldb_backend_ops {
+ const char *name;
+ ldb_connect_fn connect_fn;
+};
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
+
+void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
+ const char *symbol);
+
+struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
+
+int ldb_module_send_entry(struct ldb_request *req,
+ struct ldb_message *msg);
+
+int ldb_module_send_referral(struct ldb_request *req,
+ char *ref);
+
+int ldb_module_done(struct ldb_request *req,
+ struct ldb_control **ctrls,
+ struct ldb_extended *response,
+ int error);
+
+int ldb_mod_register_control(struct ldb_module *module, const char *oid);
+
#endif