4 Copyright (C) Andrew Tridgell 2004
5 Copyright (C) Stefan Metzmacher 2004
6 Copyright (C) Simo Sorce 2004-2005
8 ** NOTE! The following LGPL license applies to the ldb
9 ** library. This does NOT imply that all of Samba is released
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * Component: ldb private header
32 * Description: defines internal ldb structures used by th esubsystem and modules
34 * Author: Andrew Tridgell
35 * Author: Stefan Metzmacher
38 #ifndef _LDB_PRIVATE_H_
39 #define _LDB_PRIVATE_H_ 1
43 struct ldb_module_ops;
45 /* basic module structure */
47 struct ldb_module *prev, *next;
48 struct ldb_context *ldb;
50 const struct ldb_module_ops *ops;
54 these function pointers define the operations that a ldb module must perform
55 they correspond exactly to the ldb_*() interface
57 struct ldb_module_ops {
59 int (*search)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope,
60 const char *, const char * const [], struct ldb_message ***);
61 int (*search_bytree)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope,
62 struct ldb_parse_tree *, const char * const [], struct ldb_message ***);
63 int (*add_record)(struct ldb_module *, const struct ldb_message *);
64 int (*modify_record)(struct ldb_module *, const struct ldb_message *);
65 int (*delete_record)(struct ldb_module *, const struct ldb_dn *);
66 int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *);
67 int (*start_transaction)(struct ldb_module *);
68 int (*end_transaction)(struct ldb_module *, int);
73 schema related information needed for matching rules
76 /* attribute handling table */
77 unsigned num_attrib_handlers;
78 struct ldb_attrib_handler *attrib_handlers;
80 /* objectclass information */
89 every ldb connection is started by establishing a ldb_context
92 /* the operations provided by the backend */
93 struct ldb_module *modules;
95 /* debugging operations */
96 struct ldb_debug_ops debug_ops;
98 /* backend specific opaque parameters */
100 struct ldb_opaque *next;
105 struct ldb_schema schema;
110 /* the modules init function */
111 typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]);
114 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
118 simplify out of memory handling
120 #define ldb_oom(ldb) ldb_debug(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
122 /* The following definitions come from lib/ldb/common/ldb_modules.c */
124 int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
125 int ldb_next_search(struct ldb_module *module,
126 const struct ldb_dn *base,
127 enum ldb_scope scope,
128 const char *expression,
129 const char * const *attrs, struct ldb_message ***res);
130 int ldb_next_search_bytree(struct ldb_module *module,
131 const struct ldb_dn *base,
132 enum ldb_scope scope,
133 struct ldb_parse_tree *tree,
134 const char * const *attrs, struct ldb_message ***res);
135 int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message);
136 int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
137 int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn);
138 int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
139 int ldb_next_start_trans(struct ldb_module *module);
140 int ldb_next_end_trans(struct ldb_module *module, int status);
142 void ldb_set_errstring(struct ldb_module *module, char *err_string);
144 /* The following definitions come from lib/ldb/common/ldb_debug.c */
145 void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
147 /* The following definitions come from lib/ldb/common/ldb_ldif.c */
148 int ldb_should_b64_encode(const struct ldb_val *val);
150 int ltdb_connect(struct ldb_context *ldb, const char *url,
152 const char *options[]);
153 int lldb_connect(struct ldb_context *ldb, const char *url,
155 const char *options[]);
156 int ildb_connect(struct ldb_context *ldb,
159 const char *options[]);
160 int lsqlite3_connect(struct ldb_context *ldb,
163 const char *options[]);
164 struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]);
165 struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]);
166 struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]);
169 int ldb_match_msg(struct ldb_context *ldb,
170 struct ldb_message *msg,
171 struct ldb_parse_tree *tree,
172 const struct ldb_dn *base,
173 enum ldb_scope scope);
175 void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib);
176 const struct ldb_attrib_handler *ldb_attrib_handler_syntax(struct ldb_context *ldb,
178 int ldb_set_attrib_handlers(struct ldb_context *ldb,
179 const struct ldb_attrib_handler *handlers,
180 unsigned num_handlers);
181 int ldb_setup_wellknown_attributes(struct ldb_context *ldb);
183 /* The following definitions come from lib/ldb/common/ldb_attributes.c */
184 const char **ldb_subclass_list(struct ldb_context *ldb, const char *class);
185 void ldb_subclass_remove(struct ldb_context *ldb, const char *class);
186 int ldb_subclass_add(struct ldb_context *ldb, const char *class, const char *subclass);
188 int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx,
189 const struct ldb_val *in, struct ldb_val *out);
190 int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
191 const struct ldb_val *v1, const struct ldb_val *v2);