diff --git a/servers/slapd/back-bdb/external.h b/servers/slapd/back-bdb/external.h
deleted file mode 100644
index 7a80427ec9..0000000000
--- a/servers/slapd/back-bdb/external.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 2000-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-
-#ifndef _BDB_EXTERNAL_H
-#define _BDB_EXTERNAL_H
-
-#ifndef _PROTO_BDB_H
-#error "\"proto-bdb.h\" must be included first"
-#endif /* _PROTO_BDB_H */
-
-/*
-
-#include "proto-bdb.h"
-
- * must be included first
- */
-
-LDAP_BEGIN_DECL
-
-#define bdb_back_initialize BDB_SYMBOL(back_initialize)
-
-extern BI_init bdb_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _BDB_EXTERNAL_H */
-
diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c
index b453c0266f..5042bfa3d5 100644
--- a/servers/slapd/back-bdb/init.c
+++ b/servers/slapd/back-bdb/init.c
@@ -22,7 +22,6 @@
#include
#include "back-bdb.h"
-#include "external.h"
#include
static const struct bdbi_database {
@@ -659,21 +658,13 @@ bdb_back_initialize(
#if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
(SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
- memset( &bi, '\0', sizeof( bi ) );
+/* conditionally define the init_module() function */
#ifdef BDB_HIER
- bi.bi_type = "hdb";
-#else
- bi.bi_type = "bdb";
-#endif
- bi.bi_init = bdb_back_initialize;
+SLAP_BACKEND_INIT_MODULE( hdb )
+#else /* !BDB_HIER */
+SLAP_BACKEND_INIT_MODULE( bdb )
+#endif /* !BDB_HIER */
- backend_add( &bi );
- return 0;
-}
-#endif /* SLAPD_BDB */
+#endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h
index cb2db5644a..980de38dbd 100644
--- a/servers/slapd/back-bdb/proto-bdb.h
+++ b/servers/slapd/back-bdb/proto-bdb.h
@@ -576,14 +576,7 @@ bdb_trans_backoff( int num_retries );
* former external.h
*/
-#ifndef BDB_SYMBOL
-#ifdef BDB_HIER
-#define BDB_SYMBOL(x) LDAP_CONCAT(hdb_,x)
-#else
-#define BDB_SYMBOL(x) LDAP_CONCAT(bdb_,x)
-#endif
-#endif
-
+#define bdb_back_initialize BDB_SYMBOL(back_initialize)
#define bdb_db_config BDB_SYMBOL(db_config)
#define bdb_add BDB_SYMBOL(add)
#define bdb_bind BDB_SYMBOL(bind)
@@ -606,6 +599,8 @@ bdb_trans_backoff( int num_retries );
#define bdb_tool_id2entry_get BDB_SYMBOL(tool_id2entry_get)
#define bdb_tool_entry_modify BDB_SYMBOL(tool_entry_modify)
+extern BI_init bdb_back_initialize;
+
extern BI_db_config bdb_db_config;
extern BI_op_add bdb_add;
diff --git a/servers/slapd/back-dnssrv/external.h b/servers/slapd/back-dnssrv/external.h
deleted file mode 100644
index 5f7ebb94b6..0000000000
--- a/servers/slapd/back-dnssrv/external.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 2000-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was originally developed by Kurt D. Zeilenga for inclusion
- * in OpenLDAP Software.
- */
-
-#ifndef _DNSSRV_EXTERNAL_H
-#define _DNSSRV_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init dnssrv_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _DNSSRV_EXTERNAL_H */
diff --git a/servers/slapd/back-dnssrv/init.c b/servers/slapd/back-dnssrv/init.c
index 2d36c332ce..097b495569 100644
--- a/servers/slapd/back-dnssrv/init.c
+++ b/servers/slapd/back-dnssrv/init.c
@@ -27,7 +27,6 @@
#include "slap.h"
#include "proto-dnssrv.h"
-#include "external.h"
int
dnssrv_back_initialize(
@@ -88,19 +87,8 @@ dnssrv_back_db_destroy(
#if SLAPD_DNSSRV == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( dnssrv )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "dnssrv";
- bi.bi_init = dnssrv_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_DNSSRV */
+#endif /* SLAPD_DNSSRV == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-dnssrv/proto-dnssrv.h b/servers/slapd/back-dnssrv/proto-dnssrv.h
index 7b01eee39b..8aefa5fff3 100644
--- a/servers/slapd/back-dnssrv/proto-dnssrv.h
+++ b/servers/slapd/back-dnssrv/proto-dnssrv.h
@@ -22,6 +22,8 @@
LDAP_BEGIN_DECL
+extern BI_init dnssrv_back_initialize;
+
extern BI_open dnssrv_back_open;
extern BI_close dnssrv_back_close;
extern BI_destroy dnssrv_back_destroy;
diff --git a/servers/slapd/back-hdb/external.h b/servers/slapd/back-hdb/external.h
deleted file mode 100644
index e1bec3ae7e..0000000000
--- a/servers/slapd/back-hdb/external.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 2000-2004 The OpenLDAP Foundation.
- * Portions Copyright 2003 Howard Chu @ Symas Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was originally developed by Howard Chu for inclusion
- * in OpenLDAP Software.
- */
-
-#ifndef _HDB_EXTERNAL_H
-#define _HDB_EXTERNAL_H
-
-#ifndef BDB_HIER
-#define BDB_HIER
-#endif
-
-extern BI_init hdb_back_initialize;
-
-#include "../back-bdb/external.h"
-
-#endif /* _HDB_EXTERNAL_H */
-
diff --git a/servers/slapd/back-ldap/external.h b/servers/slapd/back-ldap/external.h
deleted file mode 100644
index f4e4d9b712..0000000000
--- a/servers/slapd/back-ldap/external.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 2003-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Howard Chu for inclusion
- * in OpenLDAP Software and subsequently enhanced by Pierangelo
- * Masarati.
- */
-
-#ifndef _LDAP_EXTERNAL_H
-#define _LDAP_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init ldap_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _LDAP_EXTERNAL_H */
diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c
index b975c1cda7..5a06904f11 100644
--- a/servers/slapd/back-ldap/init.c
+++ b/servers/slapd/back-ldap/init.c
@@ -30,7 +30,6 @@
#include "slap.h"
#include "back-ldap.h"
-#include "external.h"
int
ldap_back_open( BackendInfo *bi )
@@ -258,19 +257,8 @@ ldap_back_db_destroy(
#if SLAPD_LDAP == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( ldap )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "ldap";
- bi.bi_init = ldap_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_LDAP */
+#endif /* SLAPD_LDAP == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-ldap/proto-ldap.h b/servers/slapd/back-ldap/proto-ldap.h
index 32e7e284af..e5f3321b66 100644
--- a/servers/slapd/back-ldap/proto-ldap.h
+++ b/servers/slapd/back-ldap/proto-ldap.h
@@ -23,6 +23,8 @@
LDAP_BEGIN_DECL
+extern BI_init ldap_back_initialize;
+
extern BI_open ldap_back_open;
extern BI_close ldap_back_close;
extern BI_destroy ldap_back_destroy;
diff --git a/servers/slapd/back-ldbm/external.h b/servers/slapd/back-ldbm/external.h
deleted file mode 100644
index 1ced099a26..0000000000
--- a/servers/slapd/back-ldbm/external.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 1998-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-
-#ifndef _LDBM_EXTERNAL_H
-#define _LDBM_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init ldbm_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _LDBM_EXTERNAL_H */
diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c
index 120362b6a9..466fc32e11 100644
--- a/servers/slapd/back-ldbm/init.c
+++ b/servers/slapd/back-ldbm/init.c
@@ -23,7 +23,6 @@
#include "slap.h"
#include "back-ldbm.h"
-#include "external.h"
int
ldbm_back_initialize(
@@ -241,20 +240,9 @@ ldbm_back_db_destroy(
#if SLAPD_LDBM == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( ldbm )
- memset( &bi, '\0', sizeof(bi) );
- bi.bi_type = "ldbm";
- bi.bi_init = ldbm_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_LDBM */
+#endif /* SLAPD_LDBM == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h
index 88685dd123..f35dea9749 100644
--- a/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -221,6 +221,8 @@ int next_id_write LDAP_P(( Backend *be, ID id ));
* former external.h
*/
+extern BI_init ldbm_back_initialize;
+
extern BI_open ldbm_back_open;
extern BI_close ldbm_back_close;
extern BI_destroy ldbm_back_destroy;
diff --git a/servers/slapd/back-meta/external.h b/servers/slapd/back-meta/external.h
deleted file mode 100644
index 4fb791759a..0000000000
--- a/servers/slapd/back-meta/external.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 1999-2004 The OpenLDAP Foundation.
- * Portions Copyright 2001-2003 Pierangelo Masarati.
- * Portions Copyright 1999-2003 Howard Chu.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by the Howard Chu for inclusion
- * in OpenLDAP Software and subsequently enhanced by Pierangelo
- * Masarati.
- */
-
-#ifndef META_EXTERNAL_H
-#define META_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init meta_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* META_EXTERNAL_H */
diff --git a/servers/slapd/back-meta/init.c b/servers/slapd/back-meta/init.c
index d173e6e1de..40196421d5 100644
--- a/servers/slapd/back-meta/init.c
+++ b/servers/slapd/back-meta/init.c
@@ -25,7 +25,6 @@
#include "slap.h"
#include "../back-ldap/back-ldap.h"
#include "back-meta.h"
-#include "external.h"
int
meta_back_open(
@@ -224,20 +223,9 @@ meta_back_db_destroy(
#if SLAPD_META == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( meta )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "meta";
- bi.bi_init = meta_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_META */
+#endif /* SLAPD_META == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-meta/proto-meta.h b/servers/slapd/back-meta/proto-meta.h
index f789cbb170..9538223ad6 100644
--- a/servers/slapd/back-meta/proto-meta.h
+++ b/servers/slapd/back-meta/proto-meta.h
@@ -25,6 +25,8 @@
LDAP_BEGIN_DECL
+extern BI_init meta_back_initialize;
+
extern BI_open meta_back_open;
extern BI_close meta_back_close;
extern BI_destroy meta_back_destroy;
diff --git a/servers/slapd/back-monitor/external.h b/servers/slapd/back-monitor/external.h
deleted file mode 100644
index edcd0a8753..0000000000
--- a/servers/slapd/back-monitor/external.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 2001-2004 The OpenLDAP Foundation.
- * Portions Copyright 2001-2003 Pierangelo Masarati.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by Pierangelo Masarati for inclusion
- * in OpenLDAP Software.
- */
-
-#ifndef _MONITOR_EXTERNAL_H
-#define _MONITOR_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init monitor_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _MONITOR_EXTERNAL_H */
diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c
index 8f768f1648..03a233ad7a 100644
--- a/servers/slapd/back-monitor/init.c
+++ b/servers/slapd/back-monitor/init.c
@@ -1457,20 +1457,8 @@ monitor_back_db_destroy(
#if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
-
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "monitor";
- bi.bi_init = monitor_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_MONITOR */
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( monitor )
+#endif /* SLAPD_MONITOR == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h
index 35fe52fd3e..b1fc59293e 100644
--- a/servers/slapd/back-monitor/proto-back-monitor.h
+++ b/servers/slapd/back-monitor/proto-back-monitor.h
@@ -178,6 +178,8 @@ int monitor_subsys_rww_update LDAP_P(( Operation *op, Entry *e ));
* former external.h
*/
+extern BI_init monitor_back_initialize;
+
extern BI_db_init monitor_back_db_init;
extern BI_db_open monitor_back_db_open;
extern BI_config monitor_back_config;
diff --git a/servers/slapd/back-null/external.h b/servers/slapd/back-null/external.h
deleted file mode 100644
index 158779286e..0000000000
--- a/servers/slapd/back-null/external.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 2002-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was originally developed by Howard Chu for inclusion
- * in OpenLDAP Software.
- */
-
-#ifndef _NULL_EXTERNAL_H
-#define _NULL_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init null_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _NULL_EXTERNAL_H */
diff --git a/servers/slapd/back-null/null.c b/servers/slapd/back-null/null.c
index 977e892456..2b3a12612c 100644
--- a/servers/slapd/back-null/null.c
+++ b/servers/slapd/back-null/null.c
@@ -24,12 +24,13 @@
#include
#include "slap.h"
-#include "external.h"
/*
* former external.h
*/
+extern BI_init null_back_initialize;
+
extern BI_db_init null_back_db_init;
extern BI_db_destroy null_back_db_destroy;
extern BI_db_config null_back_db_config;
@@ -174,18 +175,7 @@ null_back_initialize(
#if SLAPD_NULL == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( null )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "null";
- bi.bi_init = null_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_NULL */
+#endif /* SLAPD_NULL == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-passwd/external.h b/servers/slapd/back-passwd/external.h
deleted file mode 100644
index eb32b9b156..0000000000
--- a/servers/slapd/back-passwd/external.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 1998-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-
-#ifndef _PASSWD_EXTERNAL_H
-#define _PASSWD_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init passwd_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _PASSWD_EXTERNAL_H */
diff --git a/servers/slapd/back-passwd/init.c b/servers/slapd/back-passwd/init.c
index ee40e72a93..11401770a6 100644
--- a/servers/slapd/back-passwd/init.c
+++ b/servers/slapd/back-passwd/init.c
@@ -22,7 +22,6 @@
#include "slap.h"
#include "back-passwd.h"
-#include "external.h"
ldap_pvt_thread_mutex_t passwd_mutex;
@@ -75,19 +74,8 @@ passwd_back_destroy(
#if SLAPD_PASSWD == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( passwd )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "passwd";
- bi.bi_init = passwd_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_PASSWD */
+#endif /* SLAPD_PASSWD == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-passwd/proto-passwd.h b/servers/slapd/back-passwd/proto-passwd.h
index e43f1b9458..7c62a22fe8 100644
--- a/servers/slapd/back-passwd/proto-passwd.h
+++ b/servers/slapd/back-passwd/proto-passwd.h
@@ -18,6 +18,8 @@
LDAP_BEGIN_DECL
+extern BI_init passwd_back_initialize;
+
extern BI_destroy passwd_back_destroy;
extern BI_db_config passwd_back_db_config;
diff --git a/servers/slapd/back-perl/external.h b/servers/slapd/back-perl/external.h
deleted file mode 100644
index 166f839753..0000000000
--- a/servers/slapd/back-perl/external.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 1999-2004 The OpenLDAP Foundation.
- * Portions Copyright 1999 John C. Quillan.
- * Portions Copyright 2002 myinternet Limited.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-
-#ifndef _PERL_EXTERNAL_H
-#define _PERL_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init perl_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _PERL_EXTERNAL_H */
diff --git a/servers/slapd/back-perl/init.c b/servers/slapd/back-perl/init.c
index ff3b589ab9..2100744022 100644
--- a/servers/slapd/back-perl/init.c
+++ b/servers/slapd/back-perl/init.c
@@ -16,7 +16,6 @@
*/
#include "perl_back.h"
-#include "external.h"
static void perl_back_xs_init LDAP_P((PERL_BACK_XS_INIT_PARAMS));
EXT void boot_DynaLoader LDAP_P((PERL_BACK_BOOT_DYNALOADER_PARAMS));
@@ -159,20 +158,9 @@ perl_back_xs_init(PERL_BACK_XS_INIT_PARAMS)
#if SLAPD_PERL == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( perl )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "perl";
- bi.bi_init = perl_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_PERL */
+#endif /* SLAPD_PERL == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-perl/proto-perl.h b/servers/slapd/back-perl/proto-perl.h
index 8fe2a1f2d5..55c6e233a4 100644
--- a/servers/slapd/back-perl/proto-perl.h
+++ b/servers/slapd/back-perl/proto-perl.h
@@ -20,6 +20,8 @@
LDAP_BEGIN_DECL
+extern BI_init perl_back_initialize;
+
extern BI_open perl_back_open;
extern BI_close perl_back_close;
extern BI_destroy perl_back_destroy;
diff --git a/servers/slapd/back-relay/external.h b/servers/slapd/back-relay/external.h
deleted file mode 100644
index 71eb4e335b..0000000000
--- a/servers/slapd/back-relay/external.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 2001-2004 The OpenLDAP Foundation.
- * Portions Copyright 2004 Pierangelo Masarati.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by Pierangelo Masarati for inclusion
- * in OpenLDAP Software.
- */
-
-#ifndef RELAY_EXTERNAL_H
-#define RELAY_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init relay_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _MONITOR_EXTERNAL_H */
-
diff --git a/servers/slapd/back-relay/init.c b/servers/slapd/back-relay/init.c
index 66213427d7..b397a33d5d 100644
--- a/servers/slapd/back-relay/init.c
+++ b/servers/slapd/back-relay/init.c
@@ -24,7 +24,6 @@
#include "slap.h"
#include "back-relay.h"
-#include "external.h"
int
relay_back_initialize( BackendInfo *bi )
@@ -126,19 +125,8 @@ relay_back_db_destroy( Backend *be )
#if SLAPD_RELAY == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( relay )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "relay";
- bi.bi_init = relay_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_RELAY */
+#endif /* SLAPD_RELAY == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-relay/proto-back-relay.h b/servers/slapd/back-relay/proto-back-relay.h
index 5d2d8ba388..729b3c8d2c 100644
--- a/servers/slapd/back-relay/proto-back-relay.h
+++ b/servers/slapd/back-relay/proto-back-relay.h
@@ -24,6 +24,8 @@
LDAP_BEGIN_DECL
+extern BI_init relay_back_initialize;
+
extern BI_db_init relay_back_db_init;
extern BI_db_config relay_back_db_config;
extern BI_db_open relay_back_db_open;
diff --git a/servers/slapd/back-shell/external.h b/servers/slapd/back-shell/external.h
deleted file mode 100644
index 103c323aa7..0000000000
--- a/servers/slapd/back-shell/external.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 1998-2004 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* Portions Copyright (c) 1995 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-/* ACKNOWLEDGEMENTS:
- * This work was originally developed by the University of Michigan
- * (as part of U-MICH LDAP).
- */
-
-#ifndef _SHELL_EXTERNAL_H
-#define _SHELL_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init shell_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _SHELL_EXTERNAL_H */
diff --git a/servers/slapd/back-shell/init.c b/servers/slapd/back-shell/init.c
index 2441be162e..ed146897d8 100644
--- a/servers/slapd/back-shell/init.c
+++ b/servers/slapd/back-shell/init.c
@@ -37,7 +37,6 @@
#include "slap.h"
#include "shell.h"
-#include "external.h"
int
shell_back_initialize(
@@ -100,19 +99,8 @@ shell_back_db_destroy(
#if SLAPD_SHELL == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( shell )
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "shell";
- bi.bi_init = shell_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
-
-#endif /* SLAPD_SHELL */
+#endif /* SLAPD_SHELL == SLAPD_MOD_DYNAMIC */
diff --git a/servers/slapd/back-shell/proto-shell.h b/servers/slapd/back-shell/proto-shell.h
index f2a1279622..632ffba056 100644
--- a/servers/slapd/back-shell/proto-shell.h
+++ b/servers/slapd/back-shell/proto-shell.h
@@ -32,6 +32,8 @@
LDAP_BEGIN_DECL
+extern BI_init shell_back_initialize;
+
extern BI_open shell_back_open;
extern BI_close shell_back_close;
extern BI_destroy shell_back_destroy;
diff --git a/servers/slapd/back-sql/external.h b/servers/slapd/back-sql/external.h
deleted file mode 100644
index f9d90c86e4..0000000000
--- a/servers/slapd/back-sql/external.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* $OpenLDAP$ */
-/* This work is part of OpenLDAP Software .
- *
- * Copyright 1999-2004 The OpenLDAP Foundation.
- * Portions Copyright 1999 Dmitry Kovalev.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * .
- */
-/* ACKNOWLEDGEMENTS:
- * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
- */
-
-#ifndef _SQL_EXTERNAL_H
-#define _SQL_EXTERNAL_H
-
-LDAP_BEGIN_DECL
-
-extern BI_init sql_back_initialize;
-
-LDAP_END_DECL
-
-#endif /* _SQL_EXTERNAL_H */
diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c
index 468ffc7068..dbefc8c54e 100644
--- a/servers/slapd/back-sql/init.c
+++ b/servers/slapd/back-sql/init.c
@@ -20,22 +20,19 @@
#include "portable.h"
-#ifdef SLAPD_SQL
-
#include
#include
#include "ac/string.h"
#include "slap.h"
#include "proto-sql.h"
-#include "external.h"
int
sql_back_initialize(
BackendInfo *bi )
{
static char *controls[] = {
-#if 0 /* needs updating */
+#if 0 /* needs improvements */
#ifdef LDAP_CONTROL_NOOP
LDAP_CONTROL_NOOP,
#endif /* LDAP_CONTROL_NOOP */
@@ -485,21 +482,8 @@ backsql_connection_destroy( Backend *bd, Connection *c )
#if SLAPD_SQL == SLAPD_MOD_DYNAMIC
-int
-init_module( int argc, char *argv[] )
-{
- BackendInfo bi;
-
- memset( &bi, '\0', sizeof( bi ) );
- bi.bi_type = "sql";
- bi.bi_init = sql_back_initialize;
-
- backend_add( &bi );
-
- return 0;
-}
+/* conditionally define the init_module() function */
+SLAP_BACKEND_INIT_MODULE( sql )
#endif /* SLAPD_SQL == SLAPD_MOD_DYNAMIC */
-#endif /* SLAPD_SQL */
-
diff --git a/servers/slapd/back-sql/proto-sql.h b/servers/slapd/back-sql/proto-sql.h
index cd6d0107e6..5f6dd8965f 100644
--- a/servers/slapd/back-sql/proto-sql.h
+++ b/servers/slapd/back-sql/proto-sql.h
@@ -259,6 +259,9 @@ int backsql_entryUUID_decode( struct berval *entryUUID, unsigned long *oc_id,
/*
* former external.h
*/
+
+extern BI_init sql_back_initialize;
+
extern BI_destroy backsql_destroy;
extern BI_db_init backsql_db_init;
diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h
index e5c00e9c66..5375d2ec2d 100644
--- a/servers/slapd/slap.h
+++ b/servers/slapd/slap.h
@@ -2680,6 +2680,19 @@ typedef struct slap_component_syntax_info {
} ComponentSyntaxInfo;
#endif
+
+#define SLAP_BACKEND_INIT_MODULE(b) \
+ int \
+ init_module( int argc, char *argv[] ) \
+ { \
+ BackendInfo bi; \
+ memset( &bi, '\0', sizeof( bi ) ); \
+ bi.bi_type = #b ; \
+ bi.bi_init = b ## _back_initialize; \
+ backend_add( &bi ); \
+ return 0; \
+ }
+
LDAP_END_DECL
#include "proto-slap.h"