r4474: - converted ldb to use talloc internally
[kamenim/samba.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 (*close)(struct ldb_module *);
59         int (*search)(struct ldb_module *, const char *, enum ldb_scope,
60                       const char *, const char * const [], struct ldb_message ***);
61         int (*search_free)(struct ldb_module *, 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 /* the modules init function */
72 typedef struct ldb_module *(*ldb_module_init_function)(void);
73
74 /*
75   every ldb connection is started by establishing a ldb_context
76 */
77 struct ldb_context {
78         /* the operations provided by the backend */
79         struct ldb_module *modules;
80
81         /* debugging operations */
82         struct ldb_debug_ops debug_ops;
83 };
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_close(struct ldb_module *module);
89 int ldb_next_search(struct ldb_module *module, 
90                const char *base,
91                enum ldb_scope scope,
92                const char *expression,
93                const char * const *attrs, struct ldb_message ***res);
94 int ldb_next_search_free(struct ldb_module *module, struct ldb_message **msg);
95 int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message);
96 int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
97 int ldb_next_delete_record(struct ldb_module *module, const char *dn);
98 int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn);
99 int ldb_next_named_lock(struct ldb_module *module, const char *lockname);
100 int ldb_next_named_unlock(struct ldb_module *module, const char *lockname);
101 const char *ldb_next_errstring(struct ldb_module *module);
102
103 /* The following definitions come from lib/ldb/common/util.c  */
104 int ldb_list_find(const void *needle, 
105               const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn);
106
107 /* The following definitions come from lib/ldb/common/ldb_debug.c  */
108 void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
109
110 /* The following definitions come from lib/ldb/common/ldb_ldif.c  */
111 char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len);
112 int ldb_should_b64_encode(const struct ldb_val *val);
113
114 struct ldb_context *ltdb_connect(const char *url, 
115                                  unsigned int flags, 
116                                  const char *options[]);
117 struct ldb_context *lldb_connect(const char *url, 
118                                  unsigned int flags, 
119                                  const char *options[]);
120 struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]);
121
122 const char **ldb_options_parse(const char **options, int *ldbopts, const char *arg);
123
124 #endif