r17525: This is a merge from the Google Summer of Code 2006 project by Martin Kühl
[metze/samba/wip.git] / source4 / lib / ldb / modules / ldb_map_private.h
1
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"));
4
5 /* The type of search callback functions */
6 typedef int (*ldb_search_callback)(struct ldb_context *, void *, 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 /* Global private data */
17 struct map_private {
18         struct ldb_map_context context;
19 };
20
21 /* Context data for mapped requests */
22 struct map_context {
23         enum map_step {
24                 MAP_SEARCH_REMOTE,
25                 MAP_ADD_REMOTE,
26                 MAP_ADD_LOCAL,
27                 MAP_SEARCH_SELF_MODIFY,
28                 MAP_MODIFY_REMOTE,
29                 MAP_MODIFY_LOCAL,
30                 MAP_SEARCH_SELF_DELETE,
31                 MAP_DELETE_REMOTE,
32                 MAP_DELETE_LOCAL,
33                 MAP_SEARCH_SELF_RENAME,
34                 MAP_RENAME_REMOTE,
35                 MAP_RENAME_FIXUP,
36                 MAP_RENAME_LOCAL
37         } step;
38
39         struct ldb_module *module;
40
41         const struct ldb_dn *local_dn;
42         const struct ldb_parse_tree *local_tree;
43         const char * const *local_attrs;
44
45         struct ldb_request *orig_req;
46         struct ldb_request *local_req;
47         struct ldb_request *remote_req;
48         struct ldb_request *down_req;
49         struct ldb_request *search_req;
50
51         /* for search, we may have a lot of contexts */
52         int num_searches;
53         struct ldb_request **search_reqs;
54 };
55
56 /* Context data for mapped search requests */
57 struct map_search_context {
58         struct map_context *ac;
59         struct ldb_reply *local_res;
60         struct ldb_reply *remote_res;
61 };
62
63
64 /* Common operations
65  * ================= */
66
67 /* The following definitions come from lib/ldb/modules/ldb_map.c */
68 const struct ldb_map_context *map_get_context(struct ldb_module *module);
69 struct map_search_context *map_init_search_context(struct map_context *ac, struct ldb_reply *ares);
70 struct ldb_handle *map_init_handle(struct ldb_request *req, struct ldb_module *module);
71
72 int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request);
73
74 BOOL map_check_local_db(struct ldb_module *module);
75 BOOL map_attr_check_remote(const struct ldb_map_context *data, const char *attr);
76 BOOL ldb_dn_check_local(struct ldb_module *module, const struct ldb_dn *dn);
77
78 const struct ldb_map_attribute *map_attr_find_local(const struct ldb_map_context *data, const char *name);
79 const struct ldb_map_attribute *map_attr_find_remote(const struct ldb_map_context *data, const char *name);
80
81 const char *map_attr_map_local(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
82 const char *map_attr_map_remote(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
83
84 struct ldb_val ldb_val_map_local(struct ldb_module *module, void *mem_ctx, const struct ldb_map_attribute *map, struct ldb_val val);
85 struct ldb_val ldb_val_map_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_map_attribute *map, struct ldb_val val);
86
87 struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, const struct ldb_dn *dn);
88 struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_dn *dn);
89 struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_dn *dn);
90
91 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);
92 struct ldb_request *map_search_self_req(struct map_context *ac, const struct ldb_dn *dn);
93 struct ldb_request *map_build_fixup_req(struct map_context *ac, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
94
95
96 /* LDB Requests
97  * ============ */
98
99 /* The following definitions come from lib/ldb/modules/ldb_map_inbound.c */
100 int map_add_do_remote(struct ldb_handle *handle);
101 int map_add_do_local(struct ldb_handle *handle);
102 int map_add(struct ldb_module *module, struct ldb_request *req);
103
104 int map_modify_do_remote(struct ldb_handle *handle);
105 int map_modify_do_local(struct ldb_handle *handle);
106 int map_modify(struct ldb_module *module, struct ldb_request *req);
107
108 int map_delete_do_remote(struct ldb_handle *handle);
109 int map_delete_do_local(struct ldb_handle *handle);
110 int map_delete(struct ldb_module *module, struct ldb_request *req);
111
112 int map_rename_do_remote(struct ldb_handle *handle);
113 int map_rename_do_fixup(struct ldb_handle *handle);
114 int map_rename_do_local(struct ldb_handle *handle);
115 int map_rename(struct ldb_module *module, struct ldb_request *req);
116
117 /* The following definitions come from lib/ldb/modules/ldb_map_outbound.c */
118 int map_search(struct ldb_module *module, struct ldb_request *req);