r19744: merge from samba4
[Samba/nascimento.git] / source / lib / ldb / modules / ldb_map_private.h
blob8a08d0a5b6ff64d00be3db138ea91c1c7500b988
2 /* A handy macro to report Out of Memory conditions */
3 #define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
5 /* The type of search callback functions */
6 typedef int (*ldb_search_callback)(struct ldb_context *, void *, struct ldb_reply *);
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"
13 /* Private data structures
14 * ======================= */
16 /* Context data for mapped requests */
17 struct map_context {
18 enum map_step {
19 MAP_SEARCH_REMOTE,
20 MAP_ADD_REMOTE,
21 MAP_ADD_LOCAL,
22 MAP_SEARCH_SELF_MODIFY,
23 MAP_MODIFY_REMOTE,
24 MAP_MODIFY_LOCAL,
25 MAP_SEARCH_SELF_DELETE,
26 MAP_DELETE_REMOTE,
27 MAP_DELETE_LOCAL,
28 MAP_SEARCH_SELF_RENAME,
29 MAP_RENAME_REMOTE,
30 MAP_RENAME_FIXUP,
31 MAP_RENAME_LOCAL
32 } step;
34 struct ldb_module *module;
36 const struct ldb_dn *local_dn;
37 const struct ldb_parse_tree *local_tree;
38 const char * const *local_attrs;
39 const char * const *remote_attrs;
40 const char * const *all_attrs;
42 struct ldb_request *orig_req;
43 struct ldb_request *local_req;
44 struct ldb_request *remote_req;
45 struct ldb_request *down_req;
46 struct ldb_request *search_req;
48 /* for search, we may have a lot of contexts */
49 int num_searches;
50 struct ldb_request **search_reqs;
53 /* Context data for mapped search requests */
54 struct map_search_context {
55 struct map_context *ac;
56 struct ldb_reply *local_res;
57 struct ldb_reply *remote_res;
61 /* Common operations
62 * ================= */
64 /* The following definitions come from lib/ldb/modules/ldb_map.c */
65 const struct ldb_map_context *map_get_context(struct ldb_module *module);
66 struct map_search_context *map_init_search_context(struct map_context *ac, struct ldb_reply *ares);
67 struct ldb_handle *map_init_handle(struct ldb_request *req, struct ldb_module *module);
69 int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request);
71 BOOL map_check_local_db(struct ldb_module *module);
72 BOOL map_attr_check_remote(const struct ldb_map_context *data, const char *attr);
73 BOOL ldb_dn_check_local(struct ldb_module *module, const struct ldb_dn *dn);
75 const struct ldb_map_attribute *map_attr_find_local(const struct ldb_map_context *data, const char *name);
76 const struct ldb_map_attribute *map_attr_find_remote(const struct ldb_map_context *data, const char *name);
78 const char *map_attr_map_local(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
79 const char *map_attr_map_remote(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
80 int map_attrs_merge(struct ldb_module *module, void *mem_ctx, const char ***attrs, const char * const *more_attrs);
82 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);
83 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);
85 struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, const struct ldb_dn *dn);
86 struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_dn *dn);
87 struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_dn *dn);
89 struct ldb_request *map_search_base_req(struct map_context *ac, const struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_search_callback callback);
90 struct ldb_request *map_search_self_req(struct map_context *ac, const struct ldb_dn *dn);
91 struct ldb_request *map_build_fixup_req(struct map_context *ac, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
93 int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *tree, const struct ldb_map_attribute *map);
95 /* LDB Requests
96 * ============ */
98 /* The following definitions come from lib/ldb/modules/ldb_map_inbound.c */
99 int map_add_do_remote(struct ldb_handle *handle);
100 int map_add_do_local(struct ldb_handle *handle);
101 int map_add(struct ldb_module *module, struct ldb_request *req);
103 int map_modify_do_remote(struct ldb_handle *handle);
104 int map_modify_do_local(struct ldb_handle *handle);
105 int map_modify(struct ldb_module *module, struct ldb_request *req);
107 int map_delete_do_remote(struct ldb_handle *handle);
108 int map_delete_do_local(struct ldb_handle *handle);
109 int map_delete(struct ldb_module *module, struct ldb_request *req);
111 int map_rename_do_remote(struct ldb_handle *handle);
112 int map_rename_do_fixup(struct ldb_handle *handle);
113 int map_rename_do_local(struct ldb_handle *handle);
114 int map_rename(struct ldb_module *module, struct ldb_request *req);
116 /* The following definitions come from lib/ldb/modules/ldb_map_outbound.c */
117 int map_search(struct ldb_module *module, struct ldb_request *req);