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

Re: backend functions declaration

Hallvard B Furuseth wrote:

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.

I must have misunderstood the first message. If we're just talking about eliminating "external.h" because the frontend doesn't need it and the backend declares its functions in a separate file already (such as proto-bdb.h) then yes, I agree.

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:

I like them when they're harmless and save typing. In this case, I don't see much savings.

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

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

	SLAPD_BACKEND("bdb",    bdb_initialize)
	/* for any private backend */


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

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

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

 -- Howard Chu
 Chief Architect, Symas Corp.       Director, Highland Sun
 http://www.symas.com               http://highlandsun.com/hyc
 Symas: Premier OpenSource Development and Support