summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-12-03 07:03:35 +0100
committerJelmer Vernooij <jelmer@samba.org>2011-12-03 08:36:30 +0100
commit05bc4de083b993e3db06fdb2a3e1198021526a71 (patch)
tree48c86581142760ca89e6c851d271367d77ae0d05 /lib
parentd74b3f941f5e28bf4a98dab6d4be25fbaab200b7 (diff)
downloadsamba-05bc4de083b993e3db06fdb2a3e1198021526a71.tar.gz
samba-05bc4de083b993e3db06fdb2a3e1198021526a71.tar.bz2
samba-05bc4de083b993e3db06fdb2a3e1198021526a71.zip
Revert making public of the samba-module library.
This library was tiny - containing just two public functions than were themselves trivial. The amount of overhead this causes isn't really worth the benefits of sharing the code with other projects like OpenChange. In addition, this code isn't really generically useful anyway, as it can only load from the module path set for Samba at configure time. Adding a new library was breaking the API/ABI anyway, so OpenChange had to be updated to cope with the new situation one way or another. I've added a simpler (compatible) routine for loading modules to OpenChange, which is less than 100 lines of code. Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sat Dec 3 08:36:33 CET 2011 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r--lib/util/ABI/samba-module-0.0.1.sigs2
-rw-r--r--lib/util/internal_module.h42
-rw-r--r--lib/util/modules.c (renamed from lib/util/internal_module.c)55
-rw-r--r--lib/util/samba-module.pc.in11
-rw-r--r--lib/util/samba_module.c62
-rw-r--r--lib/util/samba_modules.h (renamed from lib/util/samba_module.h)20
-rwxr-xr-xlib/util/wscript_build16
7 files changed, 64 insertions, 144 deletions
diff --git a/lib/util/ABI/samba-module-0.0.1.sigs b/lib/util/ABI/samba-module-0.0.1.sigs
deleted file mode 100644
index ee728d4eed..0000000000
--- a/lib/util/ABI/samba-module-0.0.1.sigs
+++ /dev/null
@@ -1,2 +0,0 @@
-samba_module_init_fns_for_subsystem: samba_module_init_fn *(TALLOC_CTX *, const char *)
-samba_module_init_fns_run: bool (samba_module_init_fn *)
diff --git a/lib/util/internal_module.h b/lib/util/internal_module.h
deleted file mode 100644
index 9cbddeae03..0000000000
--- a/lib/util/internal_module.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Handling of idle/exit events
- Copyright (C) Stefan (metze) Metzmacher 2003
- Copyright (C) Andrew Bartlett 2011
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _INTERNAL_MODULES_H
-#define _INTERNAL_MODULES_H
-
-#include "lib/util/samba_module.h"
-
-/**
- * Obtain the init function from a shared library file.
- *
- * The handle to dlclose() in case of error is returns in *handle if handle is not NULL
- */
-samba_module_init_fn load_module(const char *path, bool is_probe, void **handle);
-
-int smb_load_modules(const char **modules);
-NTSTATUS smb_probe_module(const char *subsystem, const char *module);
-
-/**
- * Obtain list of init functions from the modules in the specified
- * directory
- */
-samba_module_init_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path);
-
-#endif /* _INTERNAL_MODULES_H */
diff --git a/lib/util/internal_module.c b/lib/util/modules.c
index a10d1f3a3b..52a04be457 100644
--- a/lib/util/internal_module.c
+++ b/lib/util/modules.c
@@ -21,14 +21,14 @@
#include "includes.h"
#include "dynconfig/dynconfig.h"
-#include "lib/util/internal_module.h"
+#include "lib/util/samba_modules.h"
#include "system/filesys.h"
#include "system/dir.h"
/**
* Obtain the init function from a shared library file
*/
-samba_module_init_fn load_module(const char *path, bool is_probe, void **handle_out)
+init_module_fn load_module(const char *path, bool is_probe, void **handle_out)
{
void *handle;
void *init_fn;
@@ -57,7 +57,7 @@ samba_module_init_fn load_module(const char *path, bool is_probe, void **handle_
return NULL;
}
- init_fn = (samba_module_init_fn)dlsym(handle, SAMBA_MODULE_INIT);
+ init_fn = (init_module_fn)dlsym(handle, SAMBA_INIT_MODULE);
/* we could check dlerror() to determine if it worked, because
dlsym() can validly return NULL, but what would we do with
@@ -65,7 +65,7 @@ samba_module_init_fn load_module(const char *path, bool is_probe, void **handle_
if (init_fn == NULL) {
DEBUG(0, ("Unable to find %s() in %s: %s\n",
- SAMBA_MODULE_INIT, path, dlerror()));
+ SAMBA_INIT_MODULE, path, dlerror()));
DEBUG(1, ("Loading module '%s' failed\n", path));
dlclose(handle);
return NULL;
@@ -75,20 +75,20 @@ samba_module_init_fn load_module(const char *path, bool is_probe, void **handle_
*handle_out = handle;
}
- return (samba_module_init_fn)init_fn;
+ return (init_module_fn)init_fn;
}
/**
* Obtain list of init functions from the modules in the specified
* directory
*/
-samba_module_init_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path)
+static init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path)
{
DIR *dir;
struct dirent *entry;
char *filename;
int success = 0;
- samba_module_init_fn *ret = talloc_array(mem_ctx, samba_module_init_fn, 2);
+ init_module_fn *ret = talloc_array(mem_ctx, init_module_fn, 2);
ret[0] = NULL;
@@ -106,7 +106,7 @@ samba_module_init_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path)
ret[success] = load_module(filename, true, NULL);
if (ret[success]) {
- ret = talloc_realloc(mem_ctx, ret, samba_module_init_fn, success+2);
+ ret = talloc_realloc(mem_ctx, ret, init_module_fn, success+2);
success++;
ret[success] = NULL;
}
@@ -119,13 +119,50 @@ samba_module_init_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path)
return ret;
}
+/**
+ * Run the specified init functions.
+ *
+ * @return true if all functions ran successfully, false otherwise
+ */
+bool run_init_functions(init_module_fn *fns)
+{
+ int i;
+ bool ret = true;
+
+ if (fns == NULL)
+ return true;
+
+ for (i = 0; fns[i]; i++) { ret &= (bool)NT_STATUS_IS_OK(fns[i]()); }
+
+ return ret;
+}
+
+/**
+ * Load the initialization functions from DSO files for a specific subsystem.
+ *
+ * Will return an array of function pointers to initialization functions
+ */
+
+init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem)
+{
+ char *path = modules_path(mem_ctx, subsystem);
+ init_module_fn *ret;
+
+ ret = load_modules(mem_ctx, path);
+
+ talloc_free(path);
+
+ return ret;
+}
+
+
/* Load a dynamic module. Only log a level 0 error if we are not checking
for the existence of a module (probling). */
static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
{
void *handle;
- samba_module_init_fn init;
+ init_module_fn init;
NTSTATUS status;
init = load_module(module_name, is_probe, &handle);
diff --git a/lib/util/samba-module.pc.in b/lib/util/samba-module.pc.in
deleted file mode 100644
index 8f22988cd0..0000000000
--- a/lib/util/samba-module.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: samba-modules
-Description: Samba module loading utility functions
-Requires: talloc
-Version: 0.0.1
-Libs: @LIB_RPATH@ -L${libdir} -lsamba-modules
-Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1
diff --git a/lib/util/samba_module.c b/lib/util/samba_module.c
deleted file mode 100644
index b15885be03..0000000000
--- a/lib/util/samba_module.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Jelmer Vernooij 2002-2003,2005-2007
- Copyright (C) Stefan (metze) Metzmacher 2003
- Copyright (C) Andrew Bartlett 2011
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "dynconfig/dynconfig.h"
-#include "lib/util/internal_module.h"
-#include "system/filesys.h"
-#include "system/dir.h"
-
-/**
- * Run the specified init functions.
- *
- * @return true if all functions ran successfully, false otherwise
- */
-bool samba_module_init_fns_run(samba_module_init_fn *fns)
-{
- int i;
- bool ret = true;
-
- if (fns == NULL)
- return true;
-
- for (i = 0; fns[i]; i++) { ret &= (bool)NT_STATUS_IS_OK(fns[i]()); }
-
- return ret;
-}
-
-/**
- * Load the initialization functions from DSO files for a specific subsystem.
- *
- * Will return an array of function pointers to initialization functions
- */
-
-samba_module_init_fn *samba_module_init_fns_for_subsystem(TALLOC_CTX *mem_ctx, const char *subsystem)
-{
- char *path = modules_path(mem_ctx, subsystem);
- samba_module_init_fn *ret;
-
- ret = load_modules(mem_ctx, path);
-
- talloc_free(path);
-
- return ret;
-}
diff --git a/lib/util/samba_module.h b/lib/util/samba_modules.h
index fa9a6b905d..5eb2a0dd1c 100644
--- a/lib/util/samba_module.h
+++ b/lib/util/samba_modules.h
@@ -22,28 +22,38 @@
#define _SAMBA_MODULES_H
/* Module support */
-typedef NTSTATUS (*samba_module_init_fn) (void);
+typedef NTSTATUS (*init_module_fn) (void);
-NTSTATUS samba_module_init(void);
+NTSTATUS samba_init_module(void);
/* this needs to be a string which is not in the C library. We
previously used "init_module", but that meant that modules which
did not define this function ended up calling the C library
function init_module() which makes a system call */
-#define SAMBA_MODULE_INIT "samba_module_init"
+#define SAMBA_INIT_MODULE "samba_init_module"
+
+/**
+ * Obtain the init function from a shared library file.
+ *
+ * The handle to dlclose() in case of error is returns in *handle if handle is not NULL
+ */
+init_module_fn load_module(const char *path, bool is_probe, void **handle);
/**
* Run the specified init functions.
*
* @return true if all functions ran successfully, false otherwise
*/
-bool samba_module_init_fns_run(samba_module_init_fn *fns);
+bool run_init_functions(init_module_fn *fns);
/**
* Load the initialization functions from DSO files for a specific subsystem.
*
* Will return an array of function pointers to initialization functions
*/
-samba_module_init_fn *samba_module_init_fns_for_subsystem(TALLOC_CTX *mem_ctx, const char *subsystem);
+init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem);
+
+int smb_load_modules(const char **modules);
+NTSTATUS smb_probe_module(const char *subsystem, const char *module);
#endif /* _SAMBA_MODULES_H */
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 63a898ab72..1dc65fab5e 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -17,21 +17,11 @@ bld.SAMBA_LIBRARY('samba-util',
pc_files='samba-util.pc'
)
-bld.SAMBA_LIBRARY('samba-module',
- source='samba_module.c',
- deps='errors samba-util samba-internal-module',
- local_include=False,
- public_headers='samba_module.h',
- vnum='0.0.1',
- abi_directory='ABI',
- abi_match='samba_module_*',
- pc_files='samba-module.pc')
-
-bld.SAMBA_LIBRARY('samba-internal-module',
- source='internal_module.c',
+bld.SAMBA_LIBRARY('samba-modules',
+ source='modules.c',
deps='errors samba-util',
local_include=False,
- private_library=True)
+ private_library=True)
bld.SAMBA_LIBRARY('asn1util',
source='asn1.c',