svn commit: samba r16574 - in branches/SOC/mkhl/ldb-map/modules: .
mkhl at samba.org
mkhl at samba.org
Tue Jun 27 23:27:53 GMT 2006
Author: mkhl
Date: 2006-06-27 23:27:53 +0000 (Tue, 27 Jun 2006)
New Revision: 16574
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16574
Log:
Adapt initialization so ldb_map can be used by other modules:
Split `ldb_map_init' into `ldb_map_init', to be called from a using
modules `init_context' op, and `ldb_map_get_ops', to be called from a
using modules initialization function.
Expose `ldb_map_init' and `ldb_map_get_ops' in the header.
Martin
Modified:
branches/SOC/mkhl/ldb-map/modules/ldb_map.c
branches/SOC/mkhl/ldb-map/modules/ldb_map.h
Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===================================================================
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-27 22:16:36 UTC (rev 16573)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c 2006-06-27 23:27:53 UTC (rev 16574)
@@ -2740,38 +2740,31 @@
}
-/* Initialize a module that performs the specified mappings.
+/* Get a copy of this modules ops. */
+struct ldb_module_ops
+ldb_map_get_ops(void)
+{
+ return map_ops;
+}
- Should be called from the init function of the module that defines
- these mappings. */
-struct ldb_module *
-ldb_map_init(struct ldb_context *ldb,
+/* Initialize private data. */
+int
+ldb_map_init(struct ldb_module *module,
const struct ldb_map_attribute *attrs,
const struct ldb_map_objectclass *ocls,
const char *name)
{
- struct ldb_module *module;
struct map_private *data;
int ret;
- /* prepare the module structure */
- module = talloc(ldb, struct ldb_module);
- if (module == NULL) {
- ldb_oom(ldb);
- return NULL;
- }
-
- /* and private data */
+ /* prepare private data */
data = talloc(module, struct map_private);
if (data == NULL) {
- ldb_oom(ldb);
+ ldb_oom(module->ldb);
goto failed;
}
module->private_data = data;
- module->ldb = ldb;
- module->prev = module->next = NULL;
- module->ops = &map_ops;
/* store local and remote baseDNs */
ret = map_init_dns(module, name);
@@ -2781,9 +2774,28 @@
/* store list of attribute and objectClass maps */
map_init_maps(module, attrs, ocls);
- return module;
+ return LDB_SUCCESS;
failed:
- talloc_free(module);
- return NULL;
+ talloc_free(data);
+ return LDB_ERR_OPERATIONS_ERROR;
}
+
+/* Ussage note for initialization of this module:
+
+ ldb_map is meant to be used from a different module that sets up
+ the mappings and gets registered in LDB.
+
+ 'ldb_map_init' initializes the private data of this module and
+ stores the attribute and objectClass maps in there. It also looks
+ up the '@MAP' special DN so requests can be redirected to the
+ remote partition.
+
+ This function should be called from the 'init_context' op of the
+ module using ldb_map.
+
+ 'ldb_map_get_ops' returns a copy of ldb_maps module operations.
+
+ It should be called from the initialize function of the using
+ module, which should then override the 'init_context' op with a
+ function making the appropriate calls to 'ldb_map_init'. */
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.h
===================================================================
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-06-27 22:16:36 UTC (rev 16573)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.h 2006-06-27 23:27:53 UTC (rev 16574)
@@ -146,5 +146,15 @@
const struct ldb_dn *remote_base_dn;
};
+/* initialization function */
+int
+ldb_map_init(struct ldb_module *module,
+ const struct ldb_map_attribute *attrs,
+ const struct ldb_map_objectclass *ocls,
+ const char *name);
+/* get copy of map_ops */
+struct ldb_module_ops
+ldb_map_get_ops(void);
+
#endif /* __LDB_MAP_H__ */
More information about the samba-cvs
mailing list