2 Unix SMB/CIFS implementation.
5 Copyright (C) Jelmer Vernooij 2002
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 NTSTATUS smb_load_module(const char *module_name)
28 init_module_function *init;
31 /* Always try to use LAZY symbol resolving; if the plugin has
32 * backwards compatibility, there might be symbols in the
33 * plugin referencing to old (removed) functions
35 handle = sys_dlopen(module_name, RTLD_LAZY);
38 DEBUG(0, ("Error loading module '%s': %s\n", module_name, sys_dlerror()));
39 return NT_STATUS_UNSUCCESSFUL;
42 init = sys_dlsym(handle, "init_module");
45 DEBUG(0, ("Error trying to resolve symbol 'init_module' in %s: %s\n", module_name, sys_dlerror()));
46 return NT_STATUS_UNSUCCESSFUL;
51 DEBUG(2, ("Module '%s' loaded\n", module_name));
56 /* Load all modules in list and return number of
57 * modules that has been successfully loaded */
58 int smb_load_modules(const char **modules)
63 for(i = 0; modules[i]; i++){
64 if(NT_STATUS_IS_OK(smb_load_module(modules[i]))) {
69 DEBUG(2, ("%d modules successfully loaded\n", success));
74 #else /* HAVE_DLOPEN */
76 NTSTATUS smb_load_module(const char *module_name)
78 DEBUG(0,("This samba executable has not been build with plugin support"));
79 return NT_STATUS_NOT_SUPPORTED;
82 int smb_load_modules(const char **modules)
84 DEBUG(0,("This samba executable has not been build with plugin support"));
88 #endif /* HAVE_DLOPEN */