From d620793b6f208eaabcb460bc7ef95380beb8080f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 17 Aug 1999 00:28:01 +0000 Subject: [PATCH] Make init_module return a success/fail value. --- servers/slapd/back-bdb2/init.c | 13 ++++++----- servers/slapd/back-ldap/init.c | 13 ++++++----- servers/slapd/back-ldbm/init.c | 13 ++++++----- servers/slapd/back-passwd/init.c | 13 ++++++----- servers/slapd/back-perl/init.c | 13 ++++++----- servers/slapd/back-shell/init.c | 13 ++++++----- servers/slapd/module.c | 39 ++++++++++++++++---------------- 7 files changed, 61 insertions(+), 56 deletions(-) diff --git a/servers/slapd/back-bdb2/init.c b/servers/slapd/back-bdb2/init.c index a419d27f54..231994a595 100644 --- a/servers/slapd/back-bdb2/init.c +++ b/servers/slapd/back-bdb2/init.c @@ -12,14 +12,15 @@ #ifdef SLAPD_BDB2_DYNAMIC -void back_bdb2_LTX_init_module(int argc, char *argv[]) { - BackendInfo bi; +int back_bdb2_LTX_init_module(int argc, char *argv[]) { + BackendInfo bi; - memset( &bi, 0, sizeof(bi) ); - bi.bi_type = "bdb2"; - bi.bi_init = bdb2_back_initialize; + memset( &bi, 0, sizeof(bi) ); + bi.bi_type = "bdb2"; + bi.bi_init = bdb2_back_initialize; - backend_add(&bi); + backend_add(&bi); + return 0; } #endif /* SLAPD_BDB2_DYNAMIC */ diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c index 33888f6765..ce0c020fa3 100644 --- a/servers/slapd/back-ldap/init.c +++ b/servers/slapd/back-ldap/init.c @@ -32,14 +32,15 @@ #ifdef SLAPD_LDAP_DYNAMIC -void back_ldap_LTX_init_module(int argc, char *argv[]) { - BackendInfo bi; +int back_ldap_LTX_init_module(int argc, char *argv[]) { + BackendInfo bi; - memset( &bi, 0, sizeof(bi) ); - bi.bi_type = "ldap"; - bi.bi_init = ldap_back_initialize; + memset( &bi, 0, sizeof(bi) ); + bi.bi_type = "ldap"; + bi.bi_init = ldap_back_initialize; - backend_add(&bi); + backend_add(&bi); + return 0; } #endif /* SLAPD_LDAP_DYNAMIC */ diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index bc61fe9ccb..abfc3ec5cb 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -16,14 +16,15 @@ #ifdef SLAPD_LDBM_DYNAMIC -void back_ldbm_LTX_init_module(int argc, char *argv[]) { - BackendInfo bi; +int back_ldbm_LTX_init_module(int argc, char *argv[]) { + BackendInfo bi; - memset( &bi, 0, sizeof(bi) ); - bi.bi_type = "ldbm"; - bi.bi_init = ldbm_back_initialize; + memset( &bi, 0, sizeof(bi) ); + bi.bi_type = "ldbm"; + bi.bi_init = ldbm_back_initialize; - backend_add(&bi); + backend_add(&bi); + return 0; } #endif /* SLAPD_LDBM_DYNAMIC */ diff --git a/servers/slapd/back-passwd/init.c b/servers/slapd/back-passwd/init.c index 55a2cbad77..ea500d7b3c 100644 --- a/servers/slapd/back-passwd/init.c +++ b/servers/slapd/back-passwd/init.c @@ -11,14 +11,15 @@ #ifdef SLAPD_PASSWD_DYNAMIC -void back_passwd_LTX_init_module(int argc, char *argv[]) { - BackendInfo bi; +int back_passwd_LTX_init_module(int argc, char *argv[]) { + BackendInfo bi; - memset( &bi, 0, sizeof(bi) ); - bi.bi_type = "passwd"; - bi.bi_init = passwd_back_initialize; + memset( &bi, 0, sizeof(bi) ); + bi.bi_type = "passwd"; + bi.bi_init = passwd_back_initialize; - backend_add(&bi); + backend_add(&bi); + return 0; } #endif /* SLAPD_PASSWD_DYNAMIC */ diff --git a/servers/slapd/back-perl/init.c b/servers/slapd/back-perl/init.c index 0383850aac..c9f30913af 100644 --- a/servers/slapd/back-perl/init.c +++ b/servers/slapd/back-perl/init.c @@ -30,14 +30,15 @@ ldap_pvt_thread_mutex_t perl_interpreter_mutex; #ifdef SLAPD_PERL_DYNAMIC -void back_perl_LTX_init_module(int argc, char *argv[]) { - BackendInfo bi; +int back_perl_LTX_init_module(int argc, char *argv[]) { + BackendInfo bi; - memset( &bi, 0, sizeof(bi) ); - bi.bi_type = "perl"; - bi.bi_init = perl_back_initialize; + memset( &bi, 0, sizeof(bi) ); + bi.bi_type = "perl"; + bi.bi_init = perl_back_initialize; - backend_add(&bi); + backend_add(&bi); + return 0; } #endif /* SLAPD_PERL_DYNAMIC */ diff --git a/servers/slapd/back-shell/init.c b/servers/slapd/back-shell/init.c index 23b049ebbc..1b15c778c8 100644 --- a/servers/slapd/back-shell/init.c +++ b/servers/slapd/back-shell/init.c @@ -11,14 +11,15 @@ #ifdef SLAPD_SHELL_DYNAMIC -void back_shell_LTX_init_module(int argc, char *argv[]) { - BackendInfo bi; +int back_shell_LTX_init_module(int argc, char *argv[]) { + BackendInfo bi; - memset( &bi, 0, sizeof(bi) ); - bi.bi_type = "shell"; - bi.bi_init = shell_back_initialize; + memset( &bi, 0, sizeof(bi) ); + bi.bi_type = "shell"; + bi.bi_init = shell_back_initialize; - backend_add(&bi); + backend_add(&bi); + return 0; } #endif /* SLAPD_SHELL_DYNAMIC */ diff --git a/servers/slapd/module.c b/servers/slapd/module.c index 5b945e5b81..1a29c2ccd2 100644 --- a/servers/slapd/module.c +++ b/servers/slapd/module.c @@ -7,29 +7,28 @@ #include int load_module(const char* file_name, int argc, char *argv[]) { - lt_dlhandle* module = NULL; - void (*initialize) LDAP_P((int argc, char *argv[])); + lt_dlhandle* module = NULL; + int (*initialize) LDAP_P((int argc, char *argv[])); - if (lt_dlinit()) { - Debug(LDAP_DEBUG_ANY, "lt_dlinit failed: %s\n", lt_dlerror(), 0, 0); - return -1; - } - - if ((module = lt_dlopen(file_name)) == NULL) { - Debug(LDAP_DEBUG_ANY, "lt_dlopen failed: (%s) %s\n", file_name, lt_dlerror(), 0); - return -1; - } + if (lt_dlinit()) { + Debug(LDAP_DEBUG_ANY, "lt_dlinit failed: %s\n", lt_dlerror(), 0, 0); + return -1; + } + + if ((module = lt_dlopen(file_name)) == NULL) { + Debug(LDAP_DEBUG_ANY, "lt_dlopen failed: (%s) %s\n", file_name, + lt_dlerror(), 0); + return -1; + } - Debug(LDAP_DEBUG_CONFIG, "loaded module %s\n", file_name, 0, 0); + Debug(LDAP_DEBUG_CONFIG, "loaded module %s\n", file_name, 0, 0); - if ((initialize = lt_dlsym(module, "init_module"))) { - initialize(argc, argv); - } else { - Debug(LDAP_DEBUG_CONFIG, "module %s: no init_module() function found\n", file_name, 0, 0); - return -1; - } - - return 0; + if ((initialize = lt_dlsym(module, "init_module"))) + return initialize(argc, argv); + + Debug(LDAP_DEBUG_CONFIG, "module %s: no init_module() function found\n", + file_name, 0, 0); + return -1; } #endif /* SLAPD_MODULES */ -- 2.39.5