]> git.sur5r.net Git - openldap/commitdiff
Use new SLAPI API for setting associated parameters associated with the
authorLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 15:30:10 +0000 (15:30 +0000)
committerLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 15:30:10 +0000 (15:30 +0000)
Connection, Operation and Backend structures.

Ensure that SLAPI_MODIFY_MODS is set to an array of LDAPMods.

servers/slapd/add.c
servers/slapd/backend.c
servers/slapd/bind.c
servers/slapd/compare.c
servers/slapd/delete.c
servers/slapd/extended.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/search.c

index 703fb508cbb7e00898d1c975f037ff268c1c5e44..46de08c9351dc46bfa03d725e0fafb431ed9701f 100644 (file)
@@ -226,13 +226,12 @@ do_add( Connection *conn, Operation *op )
        }
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
+       slapi_backend_set_pb( pb, be );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
        slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
        slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
-       slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
 
        rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_ADD_FN, pb );
        if ( rc != 0 && rc != LDAP_OTHER ) {
index f2568537d78f0ef3c92ab24eb1f0e2a21360e40b..f38b8c75392532519dc104b8eb1734f377facb57 100644 (file)
@@ -693,8 +693,8 @@ backend_unbind(
        Slapi_PBlock *pb = op->o_pb;
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
 #endif /* defined( LDAP_SLAPI ) */
 
        for ( i = 0; i < nbackends; i++ ) {
index 7c078dc7bc96e9dcc0941fcda943a814b85bcf80..24de0218e8feab775c6153e7fcfb9c14e571ebb7 100644 (file)
@@ -531,9 +531,9 @@ do_bind(
        }
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
+       slapi_backend_set_pb( pb, be );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
        slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
index 0eba5c92d25a484de1acdbfa9f265deab6c492d8..c1f3db3f9ca161ae8663fbf8371d9af86cd7ea6c 100644 (file)
@@ -272,12 +272,11 @@ do_compare(
        suffix_alias( be, &ndn );
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
-       slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+       slapi_backend_set_pb( pb, be );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
+       slapi_pblock_set( pb, SLAPI_COMPARE_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
-       slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
        slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)desc.bv_val );
        slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
 
index 8b00c39b71b67c0c13435479343a0242067b5f7d..acab86bba69a198d16b17280ec9b1dde16206b07 100644 (file)
@@ -158,12 +158,11 @@ do_delete(
        suffix_alias( be, &ndn );
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
-       slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+       slapi_backend_set_pb( pb, be );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
+       slapi_pblock_set( pb, SLAPI_DELETE_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
-       slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
 
        rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_DELETE_FN, pb );
        if ( rc != 0 && rc != LDAP_OTHER ) {
index fdc0c0fca71b590d7340b55821c5d8ef23689ee7..481e22b962a685d3b761a4066812af6b7ef23e6c 100644 (file)
@@ -267,13 +267,13 @@ do_extended(
                        goto done;
                }
 
-               rc = slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
+               rc = slapi_connection_set_pb( pb, conn );
                if ( rc != LDAP_SUCCESS ) {
                        rc = LDAP_OPERATIONS_ERROR;
                        goto done;
                }
 
-               rc = slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op);
+               rc = slapi_operation_set_pb( pb, op );
                if ( rc != LDAP_SUCCESS ) {
                        rc = LDAP_OPERATIONS_ERROR;
                        goto done;
index 7cb5b6f4524a8fe67c17a84a04e4a6a89a0ece1f..418110180063d945d282f9009856a37ec3a9d511 100644 (file)
 #include "slap.h"
 #include "slapi.h"
 
+#ifdef LDAP_SLAPI
+static LDAPMod **Modifications2LDAPMods (Modifications *modlist);
+static void FreeLDAPMods (LDAPMod **);
+#endif /* LDAP_SLAPI */
+
 int
 do_modify(
     Connection *conn,
@@ -43,6 +48,9 @@ do_modify(
        ber_len_t       len;
        Modifications   *modlist = NULL;
        Modifications   **modtail = &modlist;
+#ifdef LDAP_SLAPI
+       LDAPMod         **modv = NULL;
+#endif
 #ifdef LDAP_DEBUG
        Modifications *tmp;
 #endif
@@ -50,7 +58,6 @@ do_modify(
        int rc;
        const char      *text;
        int manageDSAit;
-
        Slapi_PBlock *pb = op->o_pb;
 
 #ifdef NEW_LOGGING
@@ -332,12 +339,13 @@ do_modify(
        suffix_alias( be, &ndn );
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
-       slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
-       slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
+       slapi_backend_set_pb( pb, be );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
+       slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
+       modv = Modifications2LDAPMods(modlist);
+       slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv);
 
        rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
        if ( rc != 0 && rc != LDAP_OTHER ) {
@@ -458,6 +466,8 @@ cleanup:
        free( ndn.bv_val );
        if ( modlist != NULL )
                slap_mods_free( modlist );
+       if ( modv != NULL )
+               FreeLDAPMods( modv );
        return rc;
 }
 
@@ -752,3 +762,72 @@ int slap_mods_opattrs(
        *modtail = NULL;
        return LDAP_SUCCESS;
 }
+
+#ifdef LDAP_SLAPI
+/*
+ * Synthesise an LDAPMod array from a Modifications list to pass
+ * to SLAPI.
+ */
+static LDAPMod **Modifications2LDAPMods(Modifications *modlist)
+{
+       LDAPMod *mods, **modv;
+       int i, j;
+       Modifications *ml;
+
+       /* based on back-ldap/modify.c */
+       for (i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next)
+               ;
+
+       mods = (LDAPMod *)ch_malloc(i * sizeof(LDAPMod));
+       if (mods == NULL) {
+               return NULL;
+       }
+
+       modv = (LDAPMod **)ch_malloc((i + 1) * sizeof(LDAPMod *));
+       if (modv == NULL) {
+               ch_free(mods);
+               return NULL;
+       }
+
+       for (i = 0, ml = modlist; ml != NULL; ml = ml->sml_next) {
+               if (ml->sml_desc->ad_type->sat_no_user_mod) {
+                       continue;
+               }
+               modv[i] = &mods[i];
+               mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
+               mods[i].mod_type = ml->sml_desc->ad_cname.bv_val;
+               if (ml->sml_bvalues != NULL) {
+                       for (j = 0; ml->sml_bvalues[j].bv_val != NULL; j++)
+                               ;
+                       mods[i].mod_bvalues = (struct berval **)ch_malloc((j + 1) *
+                               sizeof(struct berval *));
+                       for (j = 0; ml->sml_bvalues[j].bv_val != NULL; j++)
+                               mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
+               } else {
+                       mods[i].mod_bvalues = NULL;
+               }
+               i++;
+       }
+       modv[i] = NULL;
+
+       return modv;
+}
+
+/*
+ * Free a contiguous block of LDAP modifications.
+ */
+void FreeLDAPMods(LDAPMod **modv)
+{
+       int i;
+       LDAPMod *mods;
+
+       mods = modv[0];
+
+       for (i = 0; modv[i] != NULL; i++) {
+               ch_free(modv[i]->mod_bvalues);
+       }
+       ch_free(mods);
+       ch_free(modv);
+}
+#endif /* LDAP_SLAPI */
+
index 7e865a584df52b91f441b210746b966f55558fd1..1238050cb1baa8653dc357bb7ae0b5d12cdd55fc 100644 (file)
@@ -329,15 +329,14 @@ do_modrdn(
        suffix_alias( be, &ndn );
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
-       slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+       slapi_backend_set_pb( pb, be );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
+       slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn.bv_val );
        slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR,
                        (void *)newSuperior.bv_val );
        slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
-       slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
 
        rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
index d03975634d87ef46b32a21247f59121a77d1e60f..8a1cac660ba1bca78359b88639d087ff470de3f2 100644 (file)
@@ -340,10 +340,10 @@ do_search(
        suffix_alias( be, &nbase );
 
 #if defined( LDAP_SLAPI )
-       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
-       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
-       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
-       slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)base.bv_val );
+       slapi_backend_set_pb( pb, be );
+       slapi_connection_set_pb( pb, conn );
+       slapi_operation_set_pb( pb, op );
+       slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base.bv_val );
        slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
        slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)deref );
        slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)sizelimit );
@@ -351,7 +351,6 @@ do_search(
        slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)filter );
        slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)fstr.bv_val );
        slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
-       slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
 
        rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_SEARCH_FN, pb );