lib/util Split samba-modules library into public and private parts
[nivanova/samba-autobuild/.git] / lib / util / samba_module.c
1 /*
2    Unix SMB/CIFS implementation.
3    Samba utility functions
4    Copyright (C) Jelmer Vernooij 2002-2003,2005-2007
5    Copyright (C) Stefan (metze) Metzmacher 2003
6    Copyright (C) Andrew Bartlett 2011
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "dynconfig/dynconfig.h"
24 #include "lib/util/internal_module.h"
25 #include "system/filesys.h"
26 #include "system/dir.h"
27
28 /**
29  * Run the specified init functions.
30  *
31  * @return true if all functions ran successfully, false otherwise
32  */
33 bool samba_init_module_fns_run(samba_init_module_fn *fns)
34 {
35         int i;
36         bool ret = true;
37
38         if (fns == NULL)
39                 return true;
40
41         for (i = 0; fns[i]; i++) { ret &= (bool)NT_STATUS_IS_OK(fns[i]()); }
42
43         return ret;
44 }
45
46 /**
47  * Load the initialization functions from DSO files for a specific subsystem.
48  *
49  * Will return an array of function pointers to initialization functions
50  */
51
52 samba_init_module_fn *samba_modules_load(TALLOC_CTX *mem_ctx, const char *subsystem)
53 {
54         char *path = modules_path(mem_ctx, subsystem);
55         samba_init_module_fn *ret;
56
57         ret = load_modules(mem_ctx, path);
58
59         talloc_free(path);
60
61         return ret;
62 }