1999-06-25 01:06:34 +08:00
|
|
|
#include "portable.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "slap.h"
|
|
|
|
|
|
|
|
#ifdef SLAPD_MODULES
|
|
|
|
|
1999-08-07 15:58:11 +08:00
|
|
|
#include <ltdl.h>
|
1999-06-25 01:06:34 +08:00
|
|
|
|
|
|
|
int load_module(const char* file_name, int argc, char *argv[]) {
|
1999-08-07 15:58:11 +08:00
|
|
|
lt_dlhandle* module = NULL;
|
1999-06-25 01:06:34 +08:00
|
|
|
void (*initialize) LDAP_P((int argc, char *argv[]));
|
|
|
|
|
1999-08-07 15:58:11 +08:00
|
|
|
if (lt_dlinit()) {
|
|
|
|
Debug(LDAP_DEBUG_ANY, "lt_dlinit failed: %s\n", lt_dlerror(), 0, 0);
|
|
|
|
return -1;
|
1999-06-25 01:06:34 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 15:58:11 +08:00
|
|
|
if ((module = lt_dlopen(file_name)) == NULL) {
|
|
|
|
Debug(LDAP_DEBUG_ANY, "lt_dlopen failed: (%s) %s\n", file_name, lt_dlerror(), 0);
|
|
|
|
return -1;
|
1999-06-25 01:06:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Debug(LDAP_DEBUG_CONFIG, "loaded module %s\n", file_name, 0, 0);
|
|
|
|
|
1999-08-07 15:58:11 +08:00
|
|
|
if ((initialize = lt_dlsym(module, "init_module"))) {
|
1999-06-25 01:06:34 +08:00
|
|
|
initialize(argc, argv);
|
|
|
|
} else {
|
|
|
|
Debug(LDAP_DEBUG_CONFIG, "module %s: no init_module() function found\n", file_name, 0, 0);
|
1999-08-07 15:58:11 +08:00
|
|
|
return -1;
|
1999-06-25 01:06:34 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 15:58:11 +08:00
|
|
|
return 0;
|
1999-06-25 01:06:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SLAPD_MODULES */
|
|
|
|
|