]> git.sur5r.net Git - openldap/blob - servers/slapd/module.c
(re)introduce o_connid such that STATS doesn't need c_mutex (which it
[openldap] / servers / slapd / module.c
1 #include "portable.h"
2 #include <stdio.h>
3 #include "slap.h"
4
5 #ifdef SLAPD_MODULES
6
7 #include <glib.h>
8 #include <gmodule.h>
9
10 int load_module(const char* file_name, int argc, char *argv[]) {
11    GModule* module = NULL;
12    void (*initialize) LDAP_P((int argc, char *argv[]));
13
14    if (!g_module_supported()) {
15       Debug(LDAP_DEBUG_ANY, "loadable modules not supported on this platform\n", 0, 0, 0);
16       return FALSE;
17    }
18    
19    if ((module = g_module_open(file_name, G_MODULE_BIND_LAZY)) == NULL) {
20       Debug(LDAP_DEBUG_ANY, "failed to load module %s: %s\n", file_name, g_module_error(), 0);
21       return FALSE;
22    }
23
24    Debug(LDAP_DEBUG_CONFIG, "loaded module %s\n", file_name, 0, 0);
25    
26    if (g_module_symbol(module, "init_module", (gpointer *) &initialize)) {
27       initialize(argc, argv);
28    } else {
29       Debug(LDAP_DEBUG_CONFIG, "module %s: no init_module() function found\n", file_name, 0, 0);
30       return FALSE;
31    }
32
33    return TRUE;
34 }
35
36 #endif /* SLAPD_MODULES */
37