05311346f4e659f2ec38ee9020b03304521788c0
[samba.git] / source4 / lib / ldb / ldb_tdb / ldb_tdb.h
1
2 #ifdef STANDALONE
3 #include "tdb.h"
4 #endif
5
6 /* this private structure is used by the ltdb backend in the
7    ldb_context */
8 struct ltdb_private {
9         TDB_CONTEXT *tdb;
10         unsigned int connect_flags;
11         
12         /* a double is used for portability and ease of string
13            handling. It has plenty of digits of precision */
14         double sequence_number;
15
16         struct {
17                 struct ldb_message baseinfo;
18                 struct ldb_message indexlist;
19                 struct ldb_message attributes;
20                 struct ldb_message subclasses;
21
22                 struct {
23                         char *name;
24                         int flags;
25                 } last_attribute;
26         } cache;
27
28         /* error if an internal ldb+tdb error */
29         const char *last_err_string;
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 /* well known attribute flags */
46 #define LTDB_FLAG_CASE_INSENSITIVE (1<<0)
47 #define LTDB_FLAG_INTEGER          (1<<1)
48 #define LTDB_FLAG_WILDCARD         (1<<2)
49 #define LTDB_FLAG_OBJECTCLASS      (1<<3)
50 #define LTDB_FLAG_HIDDEN           (1<<4)
51
52 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c  */
53
54 void ltdb_cache_free(struct ldb_module *module);
55 int ltdb_cache_load(struct ldb_module *module);
56 int ltdb_increase_sequence_number(struct ldb_module *module);
57 int ltdb_attribute_flags(struct ldb_module *module, const char *attr_name);
58
59 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c  */
60
61 struct ldb_parse_tree;
62
63 int ltdb_search_indexed(struct ldb_module *module, 
64                         const char *base,
65                         enum ldb_scope scope,
66                         struct ldb_parse_tree *tree,
67                         const char * const attrs[], struct ldb_message ***res);
68 int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
69 int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
70 int ltdb_reindex(struct ldb_module *module);
71
72 /* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c  */
73
74 int ltdb_pack_data(struct ldb_module *module,
75                    const struct ldb_message *message,
76                    struct TDB_DATA *data);
77 void ltdb_unpack_data_free(struct ldb_module *module,
78                            struct ldb_message *message);
79 int ltdb_unpack_data(struct ldb_module *module,
80                      const struct TDB_DATA *data,
81                      struct ldb_message *message);
82
83 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c  */
84
85 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, 
86                       const struct ldb_val *val);
87 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
88 int ltdb_search_dn1(struct ldb_module *module, const char *dn, struct ldb_message *msg);
89 int ltdb_search_dn(struct ldb_module *module, char *dn,
90                    const char * const attrs[], struct ldb_message ***res);
91 int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
92                           const char * const attrs[], 
93                           int *count, 
94                           struct ldb_message ***res);
95 int ltdb_search_free(struct ldb_module *module, struct ldb_message **msgs);
96 int ltdb_search(struct ldb_module *module, const char *base,
97                 enum ldb_scope scope, const char *expression,
98                 const char * const attrs[], struct ldb_message ***res);
99
100 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
101 struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn);
102 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
103 int ltdb_delete_noindex(struct ldb_module *module, const char *dn);
104 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg);
105
106 /* The following definitions come from lib/ldb/ldb_tdb/ldb_match.c  */
107 int ltdb_val_equal(struct ldb_module *module,
108                   const char *attr_name,
109                   const struct ldb_val *v1, const struct ldb_val *v2);
110 int ltdb_message_match(struct ldb_module *module, 
111                       struct ldb_message *msg,
112                       struct ldb_parse_tree *tree,
113                       const char *base,
114                       enum ldb_scope scope);
115
116 int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
117                          struct ldb_message_element *el, int v_idx);
118