[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: backend functions declaration



Pierangelo Masarati writes:
> As a consequence of looking at ITS#3387, I note that many backends declare
> the function handlers (usually in a dedicated external.h header).  This is
> not required, since all the frontend needs to know (for statically
> compiled backends) is the <backend>_initialize() function; runtime loaded
> backends don't even need it.  An exception are those backends that have
> cross-dependencies (e.g. back-ldap and back-meta, back-bdb and back-hdb).
> 
> I'd like to remove all of this, to avoid confusion and maintenance overhead.

Sounds good.  Just make sure that the .h file(s) which declare the
*_initialize() which backend.c uses, are also read by the backend .c
files that define the *_initialize() functions.


BTW, this is the kind of thing that I like to code as follows
(untested), though I don't know how others feel about such hacks:

/* backend.h - expand SLAPD_BACKEND(name, initializer) for static backends */

/* Default SLAPD_BACKEND: Declare the initializer */
#ifndef SLAPD_BACKEND
#define SLAPD_BACKEND(name, initializer) extern BI_init name;
#endif

#if SLAPD_BDB == SLAPD_MOD_STATIC
	SLAPD_BACKEND("bdb",    bdb_initialize)
#endif
...
	/* for any private backend */
#if SLAPD_PRIVATE == SLAPD_MOD_STATIC
	SLAPD_BACKEND("private",private_back_initialize)
#endif

#undef SLAPD_BACKEND

/* backend.c */
...
#include "backend.h"

static BackendInfo binfo[] = {
#	define  SLAPD_BACKEND(name, initializer) {name, initializer},
#	include "backend.h"
	{NULL}
};
...

(Nitpick: I don't know what kind of macros should be named SLAPD_* and
what kind should be named SLAP_*.)

-- 
Hallvard