Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / lib / ldb / ldb_map / ldb_map_private.h
1
2 /* A handy macro to report Out of Memory conditions */
3 #define map_oom(module) ldb_set_errstring(ldb_module_get_ctx(module), talloc_asprintf(module, "Out of Memory"));
4
5 /* The type of search callback functions */
6 typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *);
7
8 /* The special DN from which the local and remote base DNs are fetched */
9 #define MAP_DN_NAME     "@MAP"
10 #define MAP_DN_FROM     "@FROM"
11 #define MAP_DN_TO       "@TO"
12
13 /* Private data structures
14  * ======================= */
15
16 struct map_reply {
17         struct map_reply *next;
18         struct ldb_reply *remote;
19         struct ldb_reply *local;
20 };
21
22 /* Context data for mapped requests */
23 struct map_context {
24
25         struct ldb_module *module;
26         struct ldb_request *req;
27
28         struct ldb_dn *local_dn;
29         const struct ldb_parse_tree *local_tree;
30         const char * const *local_attrs;
31         const char * const *remote_attrs;
32         const char * const *all_attrs;
33
34         struct ldb_message *local_msg;
35         struct ldb_request *remote_req;
36
37         struct map_reply *r_list;
38         struct map_reply *r_current;
39 };
40
41 /* Common operations
42  * ================= */
43
44 /* The following definitions come from lib/ldb/modules/ldb_map.c */
45 const struct ldb_map_context *map_get_context(struct ldb_module *module);
46 struct map_context *map_init_context(struct ldb_module *module,
47                                         struct ldb_request *req);
48
49 int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request);
50
51 bool map_check_local_db(struct ldb_module *module);
52 bool map_attr_check_remote(const struct ldb_map_context *data, const char *attr);
53 bool ldb_dn_check_local(struct ldb_module *module, struct ldb_dn *dn);
54
55 const struct ldb_map_attribute *map_attr_find_local(const struct ldb_map_context *data, const char *name);
56 const struct ldb_map_attribute *map_attr_find_remote(const struct ldb_map_context *data, const char *name);
57
58 const char *map_attr_map_local(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
59 const char *map_attr_map_remote(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
60 int map_attrs_merge(struct ldb_module *module, void *mem_ctx, const char ***attrs, const char * const *more_attrs);
61
62 struct ldb_val ldb_val_map_local(struct ldb_module *module, void *mem_ctx, const struct ldb_map_attribute *map, const struct ldb_val *val);
63 struct ldb_val ldb_val_map_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_map_attribute *map, const struct ldb_val *val);
64
65 struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
66 struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
67 struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
68
69 struct ldb_request *map_search_base_req(struct map_context *ac,
70                                         struct ldb_dn *dn,
71                                         const char * const *attrs,
72                                         const struct ldb_parse_tree *tree,
73                                         void *context,
74                                         ldb_map_callback_t callback);
75 struct ldb_request *map_build_fixup_req(struct map_context *ac,
76                                         struct ldb_dn *olddn,
77                                         struct ldb_dn *newdn,
78                                         void *context,
79                                         ldb_map_callback_t callback);
80 int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
81                                         struct ldb_parse_tree **new,
82                                         const struct ldb_parse_tree *tree,
83                                         const struct ldb_map_attribute *map);
84 int map_return_fatal_error(struct ldb_request *req,
85                            struct ldb_reply *ares);
86 int map_return_normal_error(struct ldb_request *req,
87                             struct ldb_reply *ares,
88                             int error);
89
90 int map_return_entry(struct map_context *ac, struct ldb_reply *ares);