r9785: Add some testdata
[samba.git] / source / lib / ldb / ldb_map / ldb_map.h
index da3198429df488650cf4c8e4336fab5aefafea61..02fec649c691ec223e5d6d573fb92a633eb83ba9 100644 (file)
  * returning too much attributes in ldb_search() doesn't)
  */
 
+struct ldb_map_context;
+
 struct ldb_map_attribute 
 {
        const char *local_name; /* local name */
 
-       enum { 
+       enum ldb_map_attr_type 
                MAP_IGNORE, /* Ignore this local attribute. Doesn't exist remotely.  */
-               MAP_KEEP,   /* Keep as is */
+               MAP_KEEP,   /* Keep as is. Same name locally and remotely. */
                MAP_RENAME, /* Simply rename the attribute. Name changes, data is the same */
                MAP_CONVERT, /* Rename + convert data */
                MAP_GENERATE /* Use generate function for generating new name/data. 
@@ -53,7 +55,7 @@ struct ldb_map_attribute
        } type;
        
        /* if set, will be called for expressions that contain this attribute */
-       struct ldb_parse_tree *(*convert_operator) (TALLOC_CTX *ctx, const struct ldb_parse_tree *);    
+       struct ldb_parse_tree *(*convert_operator) (struct ldb_map_context *, TALLOC_CTX *ctx, const struct ldb_parse_tree *);  
 
        union { 
                struct {
@@ -62,27 +64,21 @@ struct ldb_map_attribute
                
                struct {
                        const char *remote_name;
-
-                       struct ldb_message_element *(*convert_local) (
-                               TALLOC_CTX *ctx, 
-                               const char *remote_attr,
-                               const struct ldb_message_element *);
-
-                       struct ldb_message_element *(*convert_remote) (
-                               TALLOC_CTX *ctx,
-                               const char *local_attr,
-                               const struct ldb_message_element *);
+                       struct ldb_val (*convert_local) (struct ldb_map_context *, TALLOC_CTX *, const struct ldb_val *);
+                       struct ldb_val (*convert_remote) (struct ldb_map_context *, TALLOC_CTX *, const struct ldb_val *);
                } convert;
        
                struct {
                        /* Generate the local attribute from remote message */
                        struct ldb_message_element *(*generate_local) (
+                                       struct ldb_map_context *, 
                                        TALLOC_CTX *ctx, 
-                                       const char *attr, 
+                                       const char *attr,
                                        const struct ldb_message *remote);
 
                        /* Update remote message with information from local message */
                        void (*generate_remote) (
+                                       struct ldb_map_context *, 
                                        const char *local_attr,
                                        const struct ldb_message *local, 
                                        struct ldb_message *remote);
@@ -90,7 +86,8 @@ struct ldb_map_attribute
                        /* Name(s) for this attribute on the remote server. This is an array since 
                         * one local attribute's data can be split up into several attributes 
                         * remotely */
-                       const char *remote_names[];
+#define LDB_MAP_MAX_REMOTE_NAMES 10
+                       const char *remote_names[LDB_MAP_MAX_REMOTE_NAMES];
                } generate;
        } u;
 };
@@ -101,12 +98,11 @@ struct ldb_map_objectclass
        const char *remote_name;
 };
 
-/* Base ldb_map struct. Fill this in to create a mapping backend */
-struct ldb_map_mappings 
+struct ldb_map_context
 {
-       const char *name;
-       const struct ldb_map_attribute *attribute_maps[];
+       struct ldb_map_attribute *attribute_maps;
+       const struct ldb_map_objectclass *objectclass_maps;
+       struct ldb_context *mapped_ldb;
 };
 
-
 #endif /* __LDB_MAP_H__ */