r6470: Remove ldb_search_free() it is not needed anymore.
[samba.git] / source / 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 (*add_record)(struct ldb_module *, const struct ldb_message *);
61         int (*modify_record)(struct ldb_module *, const struct ldb_message *);
62         int (*delete_record)(struct ldb_module *, const char *);
63         int (*rename_record)(struct ldb_module *, const char *, const char *);
64         int (*named_lock)(struct ldb_module *, const char *);
65         int (*named_unlock)(struct ldb_module *, const char *);
66         const char * (*errstring)(struct ldb_module *);
67 };
68
69 /*
70   every ldb connection is started by establishing a ldb_context
71 */
72 struct ldb_context {
73         /* the operations provided by the backend */
74         struct ldb_module *modules;
75
76         /* debugging operations */
77         struct ldb_debug_ops debug_ops;
78 };
79
80 /* the modules init function */
81 typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]);
82
83 /* The following definitions come from lib/ldb/common/ldb_modules.c  */
84
85 int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
86 int ldb_next_search(struct ldb_module *module, 
87                const char *base,
88                enum ldb_scope scope,
89                const char *expression,
90                const char * const *attrs, struct ldb_message ***res);
91 int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message);
92 int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
93 int ldb_next_delete_record(struct ldb_module *module, const char *dn);
94 int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn);
95 int ldb_next_named_lock(struct ldb_module *module, const char *lockname);
96 int ldb_next_named_unlock(struct ldb_module *module, const char *lockname);
97 const char *ldb_next_errstring(struct ldb_module *module);
98
99 /* The following definitions come from lib/ldb/common/ldb_debug.c  */
100 void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
101
102 /* The following definitions come from lib/ldb/common/ldb_ldif.c  */
103 char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len);
104 int ldb_should_b64_encode(const struct ldb_val *val);
105
106 struct ldb_context *ltdb_connect(const char *url, 
107                                  unsigned int flags, 
108                                  const char *options[]);
109 struct ldb_context *lldb_connect(const char *url, 
110                                  unsigned int flags, 
111                                  const char *options[]);
112 struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]);
113
114 const char **ldb_options_parse(const char **options, int *ldbopts, const char *arg);
115
116 #endif