]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/controls.c
Merged in preliminary support for Cyrus SASL library;
[openldap] / libraries / libldap / controls.c
index b609b7bc5660cd0c180fe2df01663248bda74c69..cab753e8810a00b3d20ccf2de46a485d66b16e5b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  * ldap_int_put_controls
  */
 
-int ldap_int_put_controls(
+int
+ldap_int_put_controls(
        LDAP *ld,
-       LDAPControl **ctrls,
+       LDAPControl *const *ctrls,
        BerElement *ber )
 {
-       LDAPControl **c;
+       LDAPControl *const *c;
 
        assert( ld != NULL );
        assert( ber != NULL );
@@ -117,8 +119,10 @@ int ldap_int_get_controls(
        char *opaque;
 
        assert( ber != NULL );
-       assert( ctrls != NULL );
 
+       if( ctrls == NULL ) {
+               return LDAP_SUCCESS;
+       }
        *ctrls = NULL;
 
        len = ber_pvt_ber_remaining(ber);
@@ -128,6 +132,7 @@ int ldap_int_get_controls(
                return LDAP_SUCCESS;
        }
 
+
        if(( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) {
                if( tag == LBER_ERROR ) {
                        /* decoding error */
@@ -146,7 +151,7 @@ int ldap_int_get_controls(
                return LDAP_NO_MEMORY;
        }
 
-       ctrls[nctrls] = NULL;
+       *ctrls[nctrls] = NULL;
 
        for( tag = ber_first_element( ber, &len, &opaque );
                tag != LBER_ERROR;
@@ -245,10 +250,10 @@ ldap_controls_free( LDAPControl **controls )
        assert( controls != NULL );
 
        if ( controls != NULL ) {
-               LDAPControl *c;
+               int i;
 
-               for(c = *controls; c != NULL; c++) {
-                       ldap_control_free( c );
+               for( i=0; controls[i] != NULL; i++) {
+                       ldap_control_free( controls[i] );
                }
 
                LDAP_FREE( controls );
@@ -258,7 +263,8 @@ ldap_controls_free( LDAPControl **controls )
 /*
  * Duplicate an array of LDAPControl
  */
-LDAPControl **ldap_controls_dup( LDAPControl **controls )
+LDAPControl **
+ldap_controls_dup( LDAPControl *const *controls )
 {
        LDAPControl **new;
        int i;
@@ -300,7 +306,8 @@ LDAPControl **ldap_controls_dup( LDAPControl **controls )
 /*
  * Duplicate a LDAPControl
  */
-LDAPControl *ldap_control_dup( LDAPControl *c )
+LDAPControl *
+ldap_control_dup( const LDAPControl *c )
 {
        LDAPControl *new;