mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
allow load_extop to replace an existing handler (not by default, though)
This commit is contained in:
parent
090945b89e
commit
45cda82eb1
@ -249,13 +249,15 @@ done:;
|
||||
}
|
||||
|
||||
int
|
||||
load_extop(
|
||||
load_extop2(
|
||||
const struct berval *ext_oid,
|
||||
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 extop_list *ext;
|
||||
int insertme = 0;
|
||||
|
||||
if ( !ext_main ) {
|
||||
return -1;
|
||||
@ -276,25 +278,34 @@ load_extop(
|
||||
|
||||
for ( ext = supp_ext_list; ext; ext = ext->next ) {
|
||||
if ( bvmatch( ext_oid, &ext->oid ) ) {
|
||||
if ( flags == 1 ) {
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ext = ch_calloc(1, sizeof(struct extop_list) + ext_oid->bv_len + 1);
|
||||
if (ext == NULL)
|
||||
return(-1);
|
||||
if ( flags == 0 || ext == NULL ) {
|
||||
ext = ch_calloc( 1, sizeof(struct extop_list) + ext_oid->bv_len + 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->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->next = supp_ext_list;
|
||||
|
||||
supp_ext_list = ext;
|
||||
if ( insertme ) {
|
||||
ext->next = supp_ext_list;
|
||||
supp_ext_list = ext;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
@ -304,10 +315,10 @@ extops_init (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; builtin_extops[i].oid != NULL; i++) {
|
||||
load_extop((struct berval *)builtin_extops[i].oid,
|
||||
for ( i = 0; builtin_extops[i].oid != NULL; i++ ) {
|
||||
load_extop( (struct berval *)builtin_extops[i].oid,
|
||||
builtin_extops[i].flags,
|
||||
builtin_extops[i].ext_main);
|
||||
builtin_extops[i].ext_main );
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
@ -298,6 +298,8 @@ load_extop_module (
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* FIXME: this is broken, and no longer needed,
|
||||
* as a module can call load_extop() itself... */
|
||||
rc = load_extop( &oid, ext_main );
|
||||
return rc;
|
||||
}
|
||||
|
@ -875,10 +875,13 @@ typedef int (SLAP_EXTOP_MAIN_FN) LDAP_P(( Operation *op, SlapReply *rs ));
|
||||
typedef int (SLAP_EXTOP_GETOID_FN) LDAP_P((
|
||||
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,
|
||||
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 ));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user