]> git.sur5r.net Git - openldap/commitdiff
ITS#2836 add SLAPI_ADD_RESCONTROL support, fix SLAPI_RES_CONTROLS def
authorHoward Chu <hyc@openldap.org>
Thu, 4 Dec 2003 00:52:03 +0000 (00:52 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 4 Dec 2003 00:52:03 +0000 (00:52 +0000)
servers/slapd/slapi/slapi.h
servers/slapd/slapi/slapi_pblock.c

index 2fffb7e1da6e3f88572b12d401f6d59be4d5957a..9bbaeb81953aebde0f10521e1d4809dd2def1ac4 100644 (file)
@@ -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
index 4e9156ee8c7011d72db2f5251e3005ed14df16e6..c97880c5f60f8f61c2ed59a50b1e54021998bdb0 100644 (file)
@@ -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;