svn commit: samba r10603 - in branches/SAMBA_4_0/source/lib/ldb:
common include
tridge at samba.org
tridge at samba.org
Thu Sep 29 10:18:27 GMT 2005
Author: tridge
Date: 2005-09-29 10:18:26 +0000 (Thu, 29 Sep 2005)
New Revision: 10603
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10603
Log:
neaten up the ldb module initialisation code
Modified:
branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c
branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c 2005-09-29 05:48:32 UTC (rev 10602)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c 2005-09-29 10:18:26 UTC (rev 10603)
@@ -122,6 +122,20 @@
{
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 @@
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 @@
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;
+ 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], "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;
- }
- 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]);
}
-
- 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;
- }
-
-#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);
Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2005-09-29 05:48:32 UTC (rev 10602)
+++ branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2005-09-29 10:18:26 UTC (rev 10603)
@@ -143,6 +143,10 @@
struct ldb_module;
+/* module initialisation function */
+typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **);
+
+
/* debugging uses one of the following levels */
enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR,
LDB_DEBUG_WARNING, LDB_DEBUG_TRACE};
More information about the samba-cvs
mailing list