allow load_extop to replace an existing handler (not by default, though)

This commit is contained in:
Pierangelo Masarati 2006-01-06 17:08:54 +00:00
parent 090945b89e
commit 45cda82eb1
3 changed files with 34 additions and 18 deletions

View File

@ -249,13 +249,15 @@ done:;
} }
int int
load_extop( load_extop2(
const struct berval *ext_oid, const struct berval *ext_oid,
slap_mask_t ext_flags, slap_mask_t ext_flags,
SLAP_EXTOP_MAIN_FN *ext_main ) SLAP_EXTOP_MAIN_FN *ext_main,
unsigned flags )
{ {
struct berval oidm = BER_BVNULL; struct berval oidm = BER_BVNULL;
struct extop_list *ext; struct extop_list *ext;
int insertme = 0;
if ( !ext_main ) { if ( !ext_main ) {
return -1; return -1;
@ -276,25 +278,34 @@ load_extop(
for ( ext = supp_ext_list; ext; ext = ext->next ) { for ( ext = supp_ext_list; ext; ext = ext->next ) {
if ( bvmatch( ext_oid, &ext->oid ) ) { if ( bvmatch( ext_oid, &ext->oid ) ) {
if ( flags == 1 ) {
break;
}
return -1; return -1;
} }
} }
ext = ch_calloc(1, sizeof(struct extop_list) + ext_oid->bv_len + 1); if ( flags == 0 || ext == NULL ) {
if (ext == NULL) ext = ch_calloc( 1, sizeof(struct extop_list) + ext_oid->bv_len + 1 );
return(-1); if ( ext == NULL ) {
return(-1);
}
ext->oid.bv_val = (char *)(ext + 1);
AC_MEMCPY( ext->oid.bv_val, ext_oid->bv_val, ext_oid->bv_len );
ext->oid.bv_len = ext_oid->bv_len;
ext->oid.bv_val[ext->oid.bv_len] = '\0';
insertme = 1;
}
ext->flags = ext_flags; ext->flags = ext_flags;
ext->oid.bv_val = (char *)(ext + 1);
AC_MEMCPY( ext->oid.bv_val, ext_oid->bv_val, ext_oid->bv_len );
ext->oid.bv_len = ext_oid->bv_len;
ext->oid.bv_val[ext->oid.bv_len] = '\0';
ext->ext_main = ext_main; ext->ext_main = ext_main;
ext->next = supp_ext_list;
supp_ext_list = ext; if ( insertme ) {
ext->next = supp_ext_list;
supp_ext_list = ext;
}
return(0); return(0);
} }
@ -304,10 +315,10 @@ extops_init (void)
{ {
int i; int i;
for (i = 0; builtin_extops[i].oid != NULL; i++) { for ( i = 0; builtin_extops[i].oid != NULL; i++ ) {
load_extop((struct berval *)builtin_extops[i].oid, load_extop( (struct berval *)builtin_extops[i].oid,
builtin_extops[i].flags, builtin_extops[i].flags,
builtin_extops[i].ext_main); builtin_extops[i].ext_main );
} }
return(0); return(0);
} }

View File

@ -298,6 +298,8 @@ load_extop_module (
return(-1); return(-1);
} }
/* FIXME: this is broken, and no longer needed,
* as a module can call load_extop() itself... */
rc = load_extop( &oid, ext_main ); rc = load_extop( &oid, ext_main );
return rc; return rc;
} }

View File

@ -875,10 +875,13 @@ typedef int (SLAP_EXTOP_MAIN_FN) LDAP_P(( Operation *op, SlapReply *rs ));
typedef int (SLAP_EXTOP_GETOID_FN) LDAP_P(( typedef int (SLAP_EXTOP_GETOID_FN) LDAP_P((
int index, struct berval *oid, int blen )); int index, struct berval *oid, int blen ));
LDAP_SLAPD_F (int) load_extop LDAP_P(( LDAP_SLAPD_F (int) load_extop2 LDAP_P((
const struct berval *ext_oid, const struct berval *ext_oid,
slap_mask_t flags, slap_mask_t flags,
SLAP_EXTOP_MAIN_FN *ext_main )); SLAP_EXTOP_MAIN_FN *ext_main,
unsigned tmpflags ));
#define load_extop(ext_oid, flags, ext_main) \
load_extop2((ext_oid), (flags), (ext_main), 0)
LDAP_SLAPD_F (int) extops_init LDAP_P(( void )); LDAP_SLAPD_F (int) extops_init LDAP_P(( void ));