r7527: - added a ldb_search_bytree() interface, which takes a ldb_parse_tree
[obnox/samba/samba-obnox.git] / source4 / lib / ldb / include / ldb_private.h
1 /* 
2    ldb database library
3
4    Copyright (C) Andrew Tridgell  2004
5    Copyright (C) Stefan Metzmacher  2004
6
7      ** NOTE! The following LGPL license applies to the ldb
8      ** library. This does NOT imply that all of Samba is released
9      ** under the LGPL
10    
11    This library is free software; you can redistribute it and/or
12    modify it under the terms of the GNU Lesser General Public
13    License as published by the Free Software Foundation; either
14    version 2 of the License, or (at your option) any later version.
15
16    This library is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    Lesser General Public License for more details.
20
21    You should have received a copy of the GNU Lesser General Public
22    License along with this library; if not, write to the Free Software
23    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 */
25
26 /*
27  *  Name: ldb
28  *
29  *  Component: ldb private header
30  *
31  *  Description: defines internal ldb structures used by th esubsystem and modules
32  *
33  *  Author: Andrew Tridgell
34  *  Author: Stefan Metzmacher
35  */
36
37 #ifndef _LDB_PRIVATE_H_
38 #define _LDB_PRIVATE_H_ 1
39
40 struct ldb_context;
41
42 struct ldb_module_ops;
43
44 /* basic module structure */
45 struct ldb_module {
46         struct ldb_module *prev, *next;
47         struct ldb_context *ldb;
48         void *private_data;
49         const struct ldb_module_ops *ops;
50 };
51
52 /* 
53    these function pointers define the operations that a ldb module must perform
54    they correspond exactly to the ldb_*() interface 
55 */
56 struct ldb_module_ops {
57         const char *name;
58         int (*search)(struct ldb_module *, const char *, enum ldb_scope,
59                       const char *, const char * const [], struct ldb_message ***);
60         int (*search_bytree)(struct ldb_module *, const char *, enum ldb_scope,
61                              struct ldb_parse_tree *, const char * const [], struct ldb_message ***);
62         int (*add_record)(struct ldb_module *, const struct ldb_message *);
63         int (*modify_record)(struct ldb_module *, const struct ldb_message *);
64         int (*delete_record)(struct ldb_module *, const char *);
65         int (*rename_record)(struct ldb_module *, const char *, const char *);
66         int (*named_lock)(struct ldb_module *, const char *);
67         int (*named_unlock)(struct ldb_module *, const char *);
68         const char * (*errstring)(struct ldb_module *);
69 };
70
71 /*
72   every ldb connection is started by establishing a ldb_context
73 */
74 struct ldb_context {
75         /* the operations provided by the backend */
76         struct ldb_module *modules;
77
78         /* debugging operations */
79         struct ldb_debug_ops debug_ops;
80 };
81
82 /* the modules init function */
83 typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]);
84
85 /* The following definitions come from lib/ldb/common/ldb_modules.c  */
86
87 int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
88 int ldb_next_search(struct ldb_module *module, 
89                const char *base,
90                enum ldb_scope scope,
91                const char *expression,
92                const char * const *attrs, struct ldb_message ***res);
93 int ldb_next_search_bytree(struct ldb_module *module, 
94                            const char *base,
95                            enum ldb_scope scope,
96                            struct ldb_parse_tree *tree,
97                            const char * const *attrs, struct ldb_message ***res);
98 int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message);
99 int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
100 int ldb_next_delete_record(struct ldb_module *module, const char *dn);
101 int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn);
102 int ldb_next_named_lock(struct ldb_module *module, const char *lockname);
103 int ldb_next_named_unlock(struct ldb_module *module, const char *lockname);
104 const char *ldb_next_errstring(struct ldb_module *module);
105
106 /* The following definitions come from lib/ldb/common/ldb_debug.c  */
107 void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
108
109 /* The following definitions come from lib/ldb/common/ldb_ldif.c  */
110 char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len);
111 int ldb_should_b64_encode(const struct ldb_val *val);
112
113 struct ldb_context *ltdb_connect(const char *url, 
114                                  unsigned int flags, 
115                                  const char *options[]);
116 struct ldb_context *lldb_connect(const char *url, 
117                                  unsigned int flags, 
118                                  const char *options[]);
119 struct ldb_context *lsqlite3_connect(const char *url, 
120                                      unsigned int flags, 
121                                      const char *options[]);
122 struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]);
123 struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]);
124
125 const char **ldb_options_parse(const char **options, int *ldbopts, const char *arg);
126
127 #endif