r7709: - convert ldb to use popt, so that it can interact with the samba
[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 /* well known attribute flags */
49 #define LTDB_FLAG_CASE_INSENSITIVE (1<<0)
50 #define LTDB_FLAG_INTEGER          (1<<1)
51 #define LTDB_FLAG_WILDCARD         (1<<2)
52 #define LTDB_FLAG_OBJECTCLASS      (1<<3)
53 #define LTDB_FLAG_HIDDEN           (1<<4)
54 #define LTDB_FLAG_NONE             0 
55
56 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c  */
57
58 int ltdb_cache_reload(struct ldb_module *module);
59 int ltdb_cache_load(struct ldb_module *module);
60 int ltdb_increase_sequence_number(struct ldb_module *module);
61 int ltdb_attribute_flags(struct ldb_module *module, const char *attr_name);
62 int ltdb_check_at_attributes_values(const struct ldb_val *value);
63
64 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c  */
65
66 struct ldb_parse_tree;
67
68 int ltdb_search_indexed(struct ldb_module *module, 
69                         const char *base,
70                         enum ldb_scope scope,
71                         struct ldb_parse_tree *tree,
72                         const char * const attrs[], struct ldb_message ***res);
73 int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
74 int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
75 int ltdb_reindex(struct ldb_module *module);
76
77 /* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c  */
78
79 int ltdb_pack_data(struct ldb_module *module,
80                    const struct ldb_message *message,
81                    struct TDB_DATA *data);
82 void ltdb_unpack_data_free(struct ldb_module *module,
83                            struct ldb_message *message);
84 int ltdb_unpack_data(struct ldb_module *module,
85                      const struct TDB_DATA *data,
86                      struct ldb_message *message);
87
88 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c  */
89
90 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, 
91                       const struct ldb_val *val);
92 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
93 int ltdb_search_dn1(struct ldb_module *module, const char *dn, struct ldb_message *msg);
94 int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
95                           const char * const attrs[], 
96                           int *count, 
97                           struct ldb_message ***res);
98 int ltdb_search(struct ldb_module *module, const char *base,
99                 enum ldb_scope scope, const char *expression,
100                 const char * const attrs[], struct ldb_message ***res);
101 int ltdb_search_bytree(struct ldb_module *module, const char *base,
102                        enum ldb_scope scope, struct ldb_parse_tree *tree,
103                        const char * const attrs[], struct ldb_message ***res);
104
105
106 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
107 struct TDB_DATA ltdb_key(struct ldb_module *module, const char *dn);
108 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
109 int ltdb_delete_noindex(struct ldb_module *module, const char *dn);
110 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg);
111 int ltdb_lock_read(struct ldb_module *module);
112 int ltdb_unlock_read(struct ldb_module *module);
113
114 /* The following definitions come from lib/ldb/ldb_tdb/ldb_match.c  */
115 int ltdb_val_equal(struct ldb_module *module,
116                   const char *attr_name,
117                   const struct ldb_val *v1, const struct ldb_val *v2);
118 int ltdb_message_match(struct ldb_module *module, 
119                       struct ldb_message *msg,
120                       struct ldb_parse_tree *tree,
121                       const char *base,
122                       enum ldb_scope scope);
123
124 int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
125                          struct ldb_message_element *el, int v_idx);
126