summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-29 10:18:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:11 -0500
commit0e90afb4e7737d60d902aee1df4cbeb85a7b693d (patch)
treee260e503647667f32ee0b19f32071d92d25d5086 /source4/lib/ldb/common
parentb0a5e9126117b8e49a97f2c13c818f4a3c49cbc0 (diff)
downloadsamba-0e90afb4e7737d60d902aee1df4cbeb85a7b693d.tar.gz
samba-0e90afb4e7737d60d902aee1df4cbeb85a7b693d.tar.bz2
samba-0e90afb4e7737d60d902aee1df4cbeb85a7b693d.zip
r10603: neaten up the ldb module initialisation code
(This used to be commit 8e7c4c98a7b4fd814f298fba1b6b686cb58339f8)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_modules.c92
1 files changed, 29 insertions, 63 deletions
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 6802cc8955..9c536789b9 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -122,6 +122,20 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
{
char **modules = NULL;
int i;
+ struct {
+ const char *name;
+ ldb_module_init_t init;
+ } well_known_modules[] = {
+ { "schema", schema_module_init },
+ { "timestamps", timestamps_module_init },
+ { "rdn_name", rdn_name_module_init },
+#ifdef _SAMBA_BUILD_
+ { "objectguid", objectguid_module_init },
+ { "samldb", samldb_module_init },
+ { "samba3sam", ldb_samba3sam_module_init },
+#endif
+ { NULL, NULL }
+ };
/* find out which modules we are requested to activate */
@@ -161,7 +175,8 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
return -1;
}
- modules = ldb_modules_list_from_string(ldb, msg[0]->elements[0].values[0].data);
+ modules = ldb_modules_list_from_string(ldb,
+ (const char *)msg[0]->elements[0].values[0].data);
}
@@ -175,71 +190,22 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
for (i = 0; modules[i] != NULL; i++) {
struct ldb_module *current;
-
- if (strcmp(modules[i], "schema") == 0) {
- current = schema_module_init(ldb, options);
- if (!current) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
- return -1;
- }
- DLIST_ADD(ldb->modules, current);
- continue;
- }
-
- if (strcmp(modules[i], "timestamps") == 0) {
- current = timestamps_module_init(ldb, options);
- if (!current) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
- return -1;
+ int m;
+ for (m=0;well_known_modules[m].name;m++) {
+ if (strcmp(modules[i], well_known_modules[m].name) == 0) {
+ current = well_known_modules[m].init(ldb, options);
+ if (current == NULL) {
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
+ return -1;
+ }
+ DLIST_ADD(ldb->modules, current);
+ break;
}
- DLIST_ADD(ldb->modules, current);
- continue;
}
-
- if (strcmp(modules[i], "rdn_name") == 0) {
- current = rdn_name_module_init(ldb, options);
- if (!current) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
- return -1;
- }
- DLIST_ADD(ldb->modules, current);
- continue;
+ if (well_known_modules[m].name == NULL) {
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "WARNING: Module [%s] not found\n",
+ modules[i]);
}
-
-#ifdef _SAMBA_BUILD_
- if (strcmp(modules[i], "objectguid") == 0) {
- current = objectguid_module_init(ldb, options);
- if (!current) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
- return -1;
- }
- DLIST_ADD(ldb->modules, current);
- continue;
- }
-
- if (strcmp(modules[i], "samldb") == 0) {
- current = samldb_module_init(ldb, options);
- if (!current) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
- return -1;
- }
- DLIST_ADD(ldb->modules, current);
- continue;
- }
-
- if (strcmp(modules[i], "samba3sam") == 0) {
- current = ldb_samba3sam_module_init(ldb, options);
- if (!current) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
- return -1;
- }
- DLIST_ADD(ldb->modules, current);
- continue;
- }
-
-#endif
-
- ldb_debug(ldb, LDB_DEBUG_WARNING, "WARNING: Module [%s] not found\n", modules[i]);
}
talloc_free(modules);