Allow ldb backends without init function, use init function-less ldb modules.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 20 Feb 2008 00:37:53 +0000 (01:37 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 20 Feb 2008 00:37:53 +0000 (01:37 +0100)
source/lib/ldb/Makefile.in
source/lib/ldb/common/ldb.c
source/lib/ldb/common/ldb_modules.c
source/lib/ldb/ldb.mk
source/lib/ldb/tests/sample_module.c

index 756beb1fed63290f385861d2f3443050310a061c..d88f82b726fe738dd2d50cd1e3ee16c62cdd49b2 100644 (file)
@@ -125,7 +125,7 @@ realdistclean:: distclean
 
 check:: test @PYTHON_CHECK_TARGET@
 
-check-soloading: sample_module.$(SHLIBEXT)
+check-soloading: sample.$(SHLIBEXT)
        LDB_MODULES_PATH=$(builddir) $(srcdir)/tests/test-soloading.sh
 
 test:: all check-soloading
index 87f791cb38795879f9283a03502083476b33e79f..ffda705a0ba6e65d4290fbef3f25180827eb6fe3 100644 (file)
@@ -135,6 +135,15 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op
                }
        }
 
+       if (fn == NULL) {
+               char *symbol_name = talloc_asprintf(ldb, "ldb_%s_connect", backend);
+               if (symbol_name == NULL) {
+                       return LDB_ERR_OPERATIONS_ERROR;
+               }
+               fn = ldb_dso_load_symbol(ldb, backend, symbol_name);
+               talloc_free(symbol_name);
+       }
+
        talloc_free(backend);
 
        if (fn == NULL) {
index 18070bdb8633ba10f253871992196292739fd003..2dae40ddb00d3f3807244646ce1f4f0e4a761811 100644 (file)
@@ -257,8 +257,13 @@ int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, str
                }
 
                if (ops == NULL) {
-                       ops = ldb_dso_load_symbol(ldb, module_list[i], 
-                                                     "ldb_module_ops");
+                       char *symbol_name = talloc_asprintf(ldb, "ldb_%s_module_ops", 
+                                                                                               module_list[i]);
+                       if (symbol_name == NULL) {
+                               return LDB_ERR_OPERATIONS_ERROR;
+                       }
+                       ops = ldb_dso_load_symbol(ldb, module_list[i], symbol_name);
+                       talloc_free(symbol_name);
                }
                
                if (ops == NULL) {
index 6119f085d8515c0a63c8b6813911bdec6d83b919..cc920178bcfcf2e0501f9ec9fd3e578fed1a0b12 100644 (file)
@@ -31,7 +31,7 @@ lib/libldb.a: $(OBJS)
        ar -rv $@ $(OBJS)
        @-ranlib $@
 
-sample_module.$(SHLIBEXT): tests/sample_module.o
+sample.$(SHLIBEXT): tests/sample_module.o
        $(MDLD) $(MDLD_FLAGS) -o $@ tests/sample_module.o
 
 bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS)
index 8ab1d33146dbca59b92edfa2bcece9ce341406cd..1a9e72c907b23976a7cac2aa8de6bc5075012b06 100644 (file)
@@ -32,12 +32,7 @@ int sample_add(struct ldb_module *mod, struct ldb_request *req)
        return ldb_next_request(mod, req);
 }
 
-static const struct ldb_module_ops sample_ops = {
-       .name              = "sample_module",
+const struct ldb_module_ops ldb_sample_module_ops = {
+       .name              = "sample",
        .add               = sample_add,
 };
-
-int init_module(void)
-{
-       return ldb_register_module(&sample_ops);
-}