From e1d1259191dd84bf6aff5be5d01f8019c0faf650 Mon Sep 17 00:00:00 2001 From: Mark Valence Date: Wed, 17 Nov 1999 18:55:01 +0000 Subject: [PATCH] Added get_supported_extension(int) accessor (replaces supportedExtensions extern). --- servers/slapd/extended.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 52eb15a7a7..0f0d3ed01b 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -49,12 +49,9 @@ typedef struct extensions_list_t { extensions_list_t *supp_ext_list = NULL; -#define MAX_SUPP_EXT_TRACKED 64 -int supp_ext_count = 0; -char *supportedExtensions[MAX_SUPP_EXT_TRACKED] = { NULL }; - extensions_list_t *find_extension (extensions_list_t *list, char *oid); int extensions_callback (extensions_cookie_t *cookie, int msg, int arg, void *argp); + #else char *supportedExtensions[] = { @@ -63,6 +60,24 @@ char *supportedExtensions[] = { #endif +char * +get_supported_extension (int index) +{ +#ifdef SLAPD_EXTERNAL_EXTENSIONS + extensions_list_t *ext; + + /* linear scan is slow, but this way doesn't force a + * big change on root_dse.c, where this routine is used. + */ + for (ext = supp_ext_list; ext != NULL && --index >= 0; ext = ext->next) ; + if (ext == NULL) + return(NULL); + return(ext->oid); +#else + return(supportedExtensions[index]); +#endif +} + int do_extended( Connection *conn, @@ -217,20 +232,6 @@ load_extension ( return(-1); } - /* supportedExtensions must be maintained for the root DSE. - * Unfortunately, this global var is declared extern char *[], - * which means it cannot grow dynamically. So, for now it is - * a char *[n], and only (n-1) oids are tracked. In the off - * chance that this is too few, the extensions will still be - * loaded, but not reported in root DSE info. To increase - * the maximum, change MAX_SUPP_EXT_TRACKED and recompile or - * fix root_dse.c to use something other than a static array. - */ - if (supp_ext_count < (MAX_SUPP_EXT_TRACKED - 1)) { - supportedExtensions[supp_ext_count++] = ch_strdup(ext->oid); - supportedExtensions[supp_ext_count] = NULL; - } - ext->next = supp_ext_list; supp_ext_list = ext; return(0); -- 2.39.5