From 32752fb3961afa40dc2eefdcd8589f1b0ed02a40 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 4 Dec 2003 00:52:03 +0000 Subject: [PATCH] ITS#2836 add SLAPI_ADD_RESCONTROL support, fix SLAPI_RES_CONTROLS def --- servers/slapd/slapi/slapi.h | 2 ++ servers/slapd/slapi/slapi_pblock.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/servers/slapd/slapi/slapi.h b/servers/slapd/slapi/slapi.h index 2fffb7e1da..9bbaeb8195 100644 --- a/servers/slapd/slapi/slapi.h +++ b/servers/slapd/slapi/slapi.h @@ -446,6 +446,8 @@ extern Backend * slapi_cl_get_be(char *dn); #define SLAPI_ENTRY_POST_OP 53 #define SLAPI_RESCONTROLS 55 +/* This is the spelling in the SunOne 5.2 docs */ +#define SLAPI_RES_CONTROLS SLAPI_RESCONTROLS #define SLAPI_ADD_RESCONTROL 56 #define SLAPI_ADD_TARGET SLAPI_TARGET_DN diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index 4e9156ee8c..c97880c5f6 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -278,6 +278,7 @@ set( Slapi_PBlock *pb, int param, void *val ) { #if defined(LDAP_SLAPI) int i, freeit; + int addcon = 0; if ( isValidParam( pb, param ) == INVALID_PARAM ) { return PBLOCK_ERROR; @@ -290,6 +291,11 @@ set( Slapi_PBlock *pb, int param, void *val ) return PBLOCK_ERROR; } + if ( param == SLAPI_ADD_RESCONTROL ) { + addcon = 1; + param = SLAPI_RES_CONTROLS; + } + switch ( param ) { case SLAPI_CONN_DN: case SLAPI_CONN_AUTHMETHOD: @@ -311,8 +317,19 @@ set( Slapi_PBlock *pb, int param, void *val ) pb->curParams[i] = param; pb->numParams++; } - if ( freeit ) ch_free( pb->curVals[i] ); - pb->curVals[i] = val; + if ( addcon ) { + LDAPControl **ctrls = pb->curVals[i]; + int j; + + for (j=0; ctrls[j]; j++); + ctrls = ch_realloc( ctrls, (j+2)*sizeof(LDAPControl *) ); + ctrls[j] = val; + ctrls[j+1] = NULL; + pb->curVals[i] = ctrls; + } else { + if ( freeit ) ch_free( pb->curVals[i] ); + pb->curVals[i] = val; + } unLock( pb ); return LDAP_SUCCESS; -- 2.39.5