Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / lib / ldb / ldb_tdb / ldb_tdb.h
1 #if (_SAMBA_BUILD_ == 3)
2 #include "tdb/include/tdb.h"
3 #else
4 #include "replace.h"
5 #include "system/wait.h"
6 #include "tdb.h"
7 #endif
8
9 #include "ldb_module.h"
10
11 /* this private structure is used by the ltdb backend in the
12    ldb_context */
13 struct ltdb_private {
14         TDB_CONTEXT *tdb;
15         unsigned int connect_flags;
16         
17         /* a double is used for portability and ease of string
18            handling. It has plenty of digits of precision */
19         unsigned long long sequence_number;
20
21         /* the low level tdb seqnum - used to avoid loading BASEINFO when
22            possible */
23         int tdb_seqnum;
24
25         struct ltdb_cache {
26                 struct ldb_message *indexlist;
27                 struct ldb_message *attributes;
28
29                 struct {
30                         char *name;
31                         int flags;
32                 } last_attribute;
33         } *cache;
34
35         int in_transaction;
36
37         bool check_base;
38         struct ltdb_idxptr *idxptr;
39 };
40
41 /*
42   the async local context
43   holds also internal search state during a full db search
44 */
45 struct ltdb_context {
46         struct ldb_module *module;
47         struct ldb_request *req;
48
49         bool callback_failed;
50
51         /* search stuff */
52         const struct ldb_parse_tree *tree;
53         struct ldb_dn *base;
54         enum ldb_scope scope;
55         const char * const *attrs;
56         struct tevent_timer *timeout_event;
57 };
58
59 /* special record types */
60 #define LTDB_INDEX      "@INDEX"
61 #define LTDB_INDEXLIST  "@INDEXLIST"
62 #define LTDB_IDX        "@IDX"
63 #define LTDB_IDXPTR     "@IDXPTR"
64 #define LTDB_IDXATTR    "@IDXATTR"
65 #define LTDB_IDXONE     "@IDXONE"
66 #define LTDB_BASEINFO   "@BASEINFO"
67 #define LTDB_OPTIONS    "@OPTIONS"
68 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
69
70 /* special attribute types */
71 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
72 #define LTDB_CHECK_BASE "checkBaseOnSearch"
73 #define LTDB_MOD_TIMESTAMP "whenChanged"
74 #define LTDB_OBJECTCLASS "objectClass"
75
76 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c  */
77
78 int ltdb_cache_reload(struct ldb_module *module);
79 int ltdb_cache_load(struct ldb_module *module);
80 int ltdb_increase_sequence_number(struct ldb_module *module);
81 int ltdb_check_at_attributes_values(const struct ldb_val *value);
82
83 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c  */
84
85 struct ldb_parse_tree;
86
87 int ltdb_search_indexed(struct ltdb_context *ctx);
88 int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
89 int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
90 int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add);
91 int ltdb_reindex(struct ldb_module *module);
92 int ltdb_index_transaction_start(struct ldb_module *module);
93 int ltdb_index_transaction_commit(struct ldb_module *module);
94 int ltdb_index_transaction_cancel(struct ldb_module *module);
95
96 /* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c  */
97
98 int ltdb_pack_data(struct ldb_module *module,
99                    const struct ldb_message *message,
100                    struct TDB_DATA *data);
101 void ltdb_unpack_data_free(struct ldb_module *module,
102                            struct ldb_message *message);
103 int ltdb_unpack_data(struct ldb_module *module,
104                      const struct TDB_DATA *data,
105                      struct ldb_message *message);
106
107 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c  */
108
109 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, 
110                       const struct ldb_val *val);
111 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
112 int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg);
113 int ltdb_add_attr_results(struct ldb_module *module,
114                           TALLOC_CTX *mem_ctx, 
115                           struct ldb_message *msg,
116                           const char * const attrs[], 
117                           unsigned int *count, 
118                           struct ldb_message ***res);
119 int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs);
120 int ltdb_search(struct ltdb_context *ctx);
121
122 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
123 int ltdb_lock_read(struct ldb_module *module);
124 int ltdb_unlock_read(struct ldb_module *module);
125 struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
126 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
127 int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn);
128 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg);
129
130 int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
131                          struct ldb_message_element *el, int v_idx);
132
133 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
134                                    const char *path, int hash_size, int tdb_flags,
135                                    int open_flags, mode_t mode,
136                                    struct ldb_context *ldb);