r11567: Ldb API change patch.
[samba.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
32 /* special record types */
33 #define LTDB_INDEX      "@INDEX"
34 #define LTDB_INDEXLIST  "@INDEXLIST"
35 #define LTDB_IDX        "@IDX"
36 #define LTDB_IDXATTR    "@IDXATTR"
37 #define LTDB_BASEINFO   "@BASEINFO"
38 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
39 #define LTDB_SUBCLASSES "@SUBCLASSES"
40
41 /* special attribute types */
42 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
43 #define LTDB_OBJECTCLASS "objectClass"
44
45 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c  */
46
47 int ltdb_cache_reload(struct ldb_module *module);
48 int ltdb_cache_load(struct ldb_module *module);
49 int ltdb_increase_sequence_number(struct ldb_module *module);
50 int ltdb_check_at_attributes_values(const struct ldb_val *value);
51
52 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c  */
53
54 struct ldb_parse_tree;
55
56 int ltdb_search_indexed(struct ldb_module *module, 
57                         const struct ldb_dn *base,
58                         enum ldb_scope scope,
59                         struct ldb_parse_tree *tree,
60                         const char * const attrs[], struct ldb_result **res);
61 int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
62 int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
63 int ltdb_reindex(struct ldb_module *module);
64
65 /* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c  */
66
67 int ltdb_pack_data(struct ldb_module *module,
68                    const struct ldb_message *message,
69                    struct TDB_DATA *data);
70 void ltdb_unpack_data_free(struct ldb_module *module,
71                            struct ldb_message *message);
72 int ltdb_unpack_data(struct ldb_module *module,
73                      const struct TDB_DATA *data,
74                      struct ldb_message *message);
75
76 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c  */
77
78 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, 
79                       const struct ldb_val *val);
80 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
81 int ltdb_search_dn1(struct ldb_module *module, const struct ldb_dn *dn, struct ldb_message *msg);
82 int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
83                           const char * const attrs[], 
84                           unsigned int *count, 
85                           struct ldb_message ***res);
86 int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
87                        enum ldb_scope scope, struct ldb_parse_tree *tree,
88                        const char * const attrs[], struct ldb_result **res);
89
90
91 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
92 struct TDB_DATA ltdb_key(struct ldb_module *module, const struct ldb_dn *dn);
93 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
94 int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn);
95 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg);
96
97 int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
98                          struct ldb_message_element *el, int v_idx);
99
100 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
101                                    const char *path, int hash_size, int tdb_flags,
102                                    int open_flags, mode_t mode);
103