r8625: move the ldb_wrap logic into the ldb code. This logic is meant to
[metze/samba/wip.git] / source4 / lib / ldb / ldb_tdb / ldb_tdb.h
1
2 #ifdef _SAMBA_BUILD_
3 #include "system/filesys.h"
4 #include "lib/tdb/include/tdb.h"
5 #else
6 #include "tdb.h"
7 #endif
8
9 /* this private structure is used by the ltdb backend in the
10    ldb_context */
11 struct ltdb_private {
12         TDB_CONTEXT *tdb;
13         unsigned int connect_flags;
14         
15         /* a double is used for portability and ease of string
16            handling. It has plenty of digits of precision */
17         double sequence_number;
18
19         struct ltdb_cache {
20                 struct ldb_message *baseinfo;
21                 struct ldb_message *indexlist;
22                 struct ldb_message *attributes;
23                 struct ldb_message *subclasses;
24
25                 struct {
26                         char *name;
27                         int flags;
28                 } last_attribute;
29         } *cache;
30
31         /* error if an internal ldb+tdb error */
32         const char *last_err_string;
33 };
34
35 /* special record types */
36 #define LTDB_INDEX      "@INDEX"
37 #define LTDB_INDEXLIST  "@INDEXLIST"
38 #define LTDB_IDX        "@IDX"
39 #define LTDB_IDXATTR    "@IDXATTR"
40 #define LTDB_BASEINFO   "@BASEINFO"
41 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
42 #define LTDB_SUBCLASSES "@SUBCLASSES"
43
44 /* special attribute types */
45 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
46 #define LTDB_OBJECTCLASS "objectClass"
47
48 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c  */
49
50 int ltdb_cache_reload(struct ldb_module *module);
51 int ltdb_cache_load(struct ldb_module *module);
52 int ltdb_increase_sequence_number(struct ldb_module *module);
53 int ltdb_check_at_attributes_values(const struct ldb_val *value);
54
55 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c  */
56
57 struct ldb_parse_tree;
58
59 int ltdb_search_indexed(struct ldb_module *module, 
60                         const char *base,
61                         enum ldb_scope scope,
62                         struct ldb_parse_tree *tree,
63                         const char * const attrs[], struct ldb_message ***res);
64 int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
65 int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
66 int ltdb_reindex(struct ldb_module *module);
67
68 /* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c  */
69
70 int ltdb_pack_data(struct ldb_module *module,
71                    const struct ldb_message *message,
72                    struct TDB_DATA *data);
73 void ltdb_unpack_data_free(struct ldb_module *module,
74                            struct ldb_message *message);
75 int ltdb_unpack_data(struct ldb_module *module,
76                      const struct TDB_DATA *data,
77                      struct ldb_message *message);
78
79 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c  */
80
81 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, 
82                       const struct ldb_val *val);
83 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
84 int ltdb_search_dn1(struct ldb_module *module, const char *dn, struct ldb_message *msg);
85 int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
86                           const char * const attrs[], 
87                           int *count, 
88                           struct ldb_message ***res);
89 int ltdb_search(struct ldb_module *module, const char *base,
90                 enum ldb_scope scope, const char *expression,
91                 const char * const attrs[], struct ldb_message ***res);
92 int ltdb_search_bytree(struct ldb_module *module, const char *base,
93                        enum ldb_scope scope, struct ldb_parse_tree *tree,
94                        const char * const attrs[], struct ldb_message ***res);
95
96
97 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
98 struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn);
99 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
100 int ltdb_delete_noindex(struct ldb_module *module, const char *dn);
101 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg);
102 int ltdb_lock_read(struct ldb_module *module);
103 int ltdb_unlock_read(struct ldb_module *module);
104
105 int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
106                          struct ldb_message_element *el, int v_idx);
107
108 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
109                                    const char *path, int hash_size, int tdb_flags,
110                                    int open_flags, mode_t mode);
111