diff options
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/internal_module.c (renamed from lib/util/modules.c) | 41 | ||||
-rw-r--r-- | lib/util/internal_module.h | 42 | ||||
-rw-r--r-- | lib/util/samba-module.pc.in | 11 | ||||
-rw-r--r-- | lib/util/samba_module.c | 62 | ||||
-rw-r--r-- | lib/util/samba_module.h (renamed from lib/util/samba_modules.h) | 10 | ||||
-rwxr-xr-x | lib/util/wscript_build | 14 |
6 files changed, 128 insertions, 52 deletions
diff --git a/lib/util/modules.c b/lib/util/internal_module.c index e9e6bf5dc83..04c02f07600 100644 --- a/lib/util/modules.c +++ b/lib/util/internal_module.c @@ -21,7 +21,7 @@ #include "includes.h" #include "dynconfig/dynconfig.h" -#include "lib/util/samba_modules.h" +#include "lib/util/internal_module.h" #include "system/filesys.h" #include "system/dir.h" @@ -82,7 +82,7 @@ samba_init_module_fn load_module(const char *path, bool is_probe, void **handle_ * Obtain list of init functions from the modules in the specified * directory */ -static samba_init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) +samba_init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) { DIR *dir; struct dirent *entry; @@ -119,43 +119,6 @@ static samba_init_module_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 samba_init_module_fns_run(samba_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 - */ - -samba_init_module_fn *samba_modules_load(TALLOC_CTX *mem_ctx, const char *subsystem) -{ - char *path = modules_path(mem_ctx, subsystem); - samba_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). */ diff --git a/lib/util/internal_module.h b/lib/util/internal_module.h new file mode 100644 index 00000000000..7d1acc52a34 --- /dev/null +++ b/lib/util/internal_module.h @@ -0,0 +1,42 @@ +/* + 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_init_module_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_init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path); + +#endif /* _INTERNAL_MODULES_H */ diff --git a/lib/util/samba-module.pc.in b/lib/util/samba-module.pc.in new file mode 100644 index 00000000000..8f22988cd03 --- /dev/null +++ b/lib/util/samba-module.pc.in @@ -0,0 +1,11 @@ +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 new file mode 100644 index 00000000000..f555eea8b64 --- /dev/null +++ b/lib/util/samba_module.c @@ -0,0 +1,62 @@ +/* + 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_init_module_fns_run(samba_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 + */ + +samba_init_module_fn *samba_modules_load(TALLOC_CTX *mem_ctx, const char *subsystem) +{ + char *path = modules_path(mem_ctx, subsystem); + samba_init_module_fn *ret; + + ret = load_modules(mem_ctx, path); + + talloc_free(path); + + return ret; +} diff --git a/lib/util/samba_modules.h b/lib/util/samba_module.h index a3d7609cb69..32b5c4b6ad0 100644 --- a/lib/util/samba_modules.h +++ b/lib/util/samba_module.h @@ -33,13 +33,6 @@ NTSTATUS samba_init_module(void); #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 - */ -samba_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 @@ -53,7 +46,4 @@ bool samba_init_module_fns_run(samba_init_module_fn *fns); */ samba_init_module_fn *samba_modules_load(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 1dc65fab5e9..990887aeab0 100755 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -17,11 +17,19 @@ bld.SAMBA_LIBRARY('samba-util', pc_files='samba-util.pc' ) -bld.SAMBA_LIBRARY('samba-modules', - source='modules.c', +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', + pc_files='samba-module.pc') + +bld.SAMBA_LIBRARY('samba-internal-module', + source='internal_module.c', deps='errors samba-util', local_include=False, - private_library=True) + private_library=True) bld.SAMBA_LIBRARY('asn1util', source='asn1.c', |