]> git.sur5r.net Git - openldap/commitdiff
SLAPI cleanup
authorLuke Howard <lukeh@openldap.org>
Mon, 31 Mar 2003 06:41:30 +0000 (06:41 +0000)
committerLuke Howard <lukeh@openldap.org>
Mon, 31 Mar 2003 06:41:30 +0000 (06:41 +0000)
servers/slapd/add.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
servers/slapd/slapi/proto-slapi.h
servers/slapd/slapi/slapi_utils.c

index 6d9a89d9f647b7eb306d15ad345fe2a2ec0b9d4e..1a9bf13c01668ef86fd4acee6b250f968cf03f0e 100644 (file)
@@ -524,10 +524,7 @@ slap_mods2entry(
 static void initAddPlugin( Operation *op,
        struct berval *dn, Entry *e, int manageDSAit )
 {
-       slapi_x_backend_set_pb( op->o_pb, op->o_bd );
-       slapi_x_connection_set_pb( op->o_pb, op->o_conn );
-       slapi_x_operation_set_pb( op->o_pb, op );
-
+       slapi_x_pblock_set_operation( op->o_pb, op );
        slapi_pblock_set( op->o_pb, SLAPI_ADD_TARGET, (void *)dn->bv_val );
        slapi_pblock_set( op->o_pb, SLAPI_ADD_ENTRY, (void *)e );
        slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
index b21354e05c13ced9e80451c8ad5f7b567e011135..7a433c93ad5cc8f93b237f2c4ea720225a1ac83f 100644 (file)
@@ -514,9 +514,7 @@ do_bind(
        }
 
 #if defined( LDAP_SLAPI )
-       slapi_x_backend_set_pb( pb, op->o_bd );
-       slapi_x_connection_set_pb( pb, op->o_conn );
-       slapi_x_operation_set_pb( pb, op );
+       slapi_x_pblock_set_operation( 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_BIND_CREDENTIALS, (void *)&op->oq_bind.rb_cred );
index 09b977af3bc491b8a39dc4fc36206bdfb949b2e7..2bffeafbde6fbdcab0c0c31239cbec94b0fde696 100644 (file)
@@ -263,9 +263,7 @@ do_compare(
                ava.aa_desc->ad_cname.bv_val, 0 );
 
 #if defined( LDAP_SLAPI )
-       slapi_x_backend_set_pb( pb, op->o_bd );
-       slapi_x_connection_set_pb( pb, op->o_conn );
-       slapi_x_operation_set_pb( pb, op );
+       slapi_x_pblock_set_operation( pb, op );
        slapi_pblock_set( pb, SLAPI_COMPARE_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
        slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)desc.bv_val );
index 3773fc3609613d194d3e012ab9e7486c1ddb00b8..daade821c01217927de76e0857b3846d150fa7e7 100644 (file)
@@ -151,9 +151,7 @@ do_delete(
        }
 
 #if defined( LDAP_SLAPI )
-       slapi_x_backend_set_pb( pb, op->o_bd );
-       slapi_x_connection_set_pb( pb, op->o_conn );
-       slapi_x_operation_set_pb( pb, op );
+       slapi_x_pblock_set_operation( pb, op );
        slapi_pblock_set( pb, SLAPI_DELETE_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
 
index 60e10e502497a781ea9877544760a8ee85f26d78..935fcdc8a8ffb41c4ac8e96dfe9785acf7bbfa6b 100644 (file)
@@ -253,13 +253,7 @@ do_extended(
                        goto done;
                }
 
-               rs->sr_err = slapi_x_connection_set_pb( pb, op->o_conn );
-               if ( rs->sr_err != LDAP_SUCCESS ) {
-                       rs->sr_err = LDAP_OTHER;
-                       goto done;
-               }
-
-               rs->sr_err = slapi_x_operation_set_pb( pb, op );
+               rs->sr_err = slapi_x_pblock_set_operation( pb, op );
                if ( rs->sr_err != LDAP_SUCCESS ) {
                        rs->sr_err = LDAP_OTHER;
                        goto done;
index 9efcff7e459f14501dbfb867e69678d18b415ddb..cdac8cae2db2b02f8faf7ab02201f9863d5d7d30 100644 (file)
@@ -324,9 +324,7 @@ do_modify(
        }
 
 #if defined( LDAP_SLAPI )
-       slapi_x_backend_set_pb( pb, op->o_bd );
-       slapi_x_connection_set_pb( pb, op->o_conn );
-       slapi_x_operation_set_pb( pb, op );
+       slapi_x_pblock_set_operation( pb, op );
        slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
        slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
        modv = slapi_x_modifications2ldapmods( &modlist );
index a97995c9c4839a32d62a4fe438fe76dd48b5a858..c455445499a7dbcad074f8c5d02fa8f55154c1d0 100644 (file)
@@ -310,9 +310,7 @@ do_modrdn(
        }
 
 #if defined( LDAP_SLAPI )
-       slapi_x_backend_set_pb( pb, op->o_bd );
-       slapi_x_connection_set_pb( pb, op->o_conn );
-       slapi_x_operation_set_pb( pb, op );
+       slapi_x_pblock_set_operation( 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,
index 0a19b3ba3cd102401c5f77a8c949a4296932f3c8..a1bdbb5170704c8b8e023020915e386eae6a0427 100644 (file)
@@ -431,9 +431,7 @@ static char **anlist2charray( AttributeName *an )
 static void initSearchPlugin( Operation *op,
        char **attrs, int managedsait )
 {
-       slapi_x_backend_set_pb( op->o_pb, op->o_bd );
-       slapi_x_connection_set_pb( op->o_pb, op->o_conn );
-       slapi_x_operation_set_pb( op->o_pb, op );
+       slapi_x_pblock_set_operation( op->o_pb, op );
        slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TARGET, (void *)op->o_req_dn.bv_val );
        slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SCOPE, (void *)op->oq_search.rs_scope );
        slapi_pblock_set( op->o_pb, SLAPI_SEARCH_DEREF, (void *)op->oq_search.rs_deref );
index 11494570b438b8a225b3be8698a8f434c07da776..1dc0c5b3a8a2f9ce5c7d40476eb91e6ff05514db 100644 (file)
@@ -204,9 +204,7 @@ extern int slapi_audit_init_header( Connection *conn, Operation *op,
 extern int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn, 
                                                Operation *op, int rc);
 
-extern int slapi_x_backend_set_pb( Slapi_PBlock *pb, Backend *be );
-extern int slapi_x_connection_set_pb( Slapi_PBlock *pb, Connection *conn );
-extern int slapi_x_operation_set_pb( Slapi_PBlock *pb, Operation *op );
+extern int slapi_x_pblock_set_operation( Slapi_PBlock *pb, Operation *op );
 
 extern LDAPMod **slapi_x_modifications2ldapmods(Modifications **);
 extern Modifications *slapi_x_ldapmods2modifications(LDAPMod **);
index d5b768a61b08775ace87921bd432d1d7bc506144..5a389fb0534f207a0f80019cb02eb6a28b437afe 100644 (file)
@@ -1353,7 +1353,7 @@ slapi_send_ldap_result(
        char            *extOID = NULL;
        struct berval   *extValue = NULL;
        int             rc;
-       SlapReply       rs;
+       SlapReply       rs = { REP_RESULT };
 
        slapi_pblock_get( pb, SLAPI_OPERATION, &op );
 
@@ -1396,11 +1396,8 @@ slapi_send_ldap_search_entry(
        int             attrsonly )
 {
 #ifdef LDAP_SLAPI
-       Backend         *be;
-       Connection      *pConn;
        Operation       *pOp;
-       int             rc;
-       SlapReply       rs;
+       SlapReply       rs = { REP_RESULT };
        int             i;
        AttributeName   *an = NULL;
        const char      *text;
@@ -1432,14 +1429,11 @@ slapi_send_ldap_search_entry(
        rs.sr_entry = e;
        rs.sr_v2ref = NULL;
 
-       if ( rc = slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp) != 0 ) {
-               rc = LDAP_OTHER;
-       } else {
-               rc = send_search_entry( pOp, &rs );
+       if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp ) != 0 ) {
+               return LDAP_OTHER;
        }
 
-       return rc;
-
+       return send_search_entry( pOp, &rs );
 #else /* LDAP_SLAPI */
        return -1;
 #endif /* LDAP_SLAPI */
@@ -2085,12 +2079,12 @@ slapi_free_search_results_internal( Slapi_PBlock *pb )
 #endif /* LDAP_SLAPI */
 }
 
+#ifdef LDAP_SLAPI
 /*
  * Internal API to prime a Slapi_PBlock with a Backend.
  */
-int slapi_x_backend_set_pb( Slapi_PBlock *pb, Backend *be )
+static int initBackendPB( Slapi_PBlock *pb, Backend *be )
 {
-#ifdef LDAP_SLAPI
        int rc;
        
        rc = slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
@@ -2104,12 +2098,8 @@ int slapi_x_backend_set_pb( Slapi_PBlock *pb, Backend *be )
        }
 
        return LDAP_SUCCESS;
-#else
-       return -1;
-#endif /* LDAP_SLAPI */
 }
 
-#ifdef LDAP_SLAPI
 /*
  * If oldStyle is TRUE, then a value suitable for setting to
  * the deprecated SLAPI_CONN_AUTHTYPE value is returned 
@@ -2151,14 +2141,12 @@ static char *Authorization2AuthType( AuthorizationInformation *authz, int is_tls
 
        return authType;
 }
-#endif
 
 /*
  * Internal API to prime a Slapi_PBlock with a Connection.
  */
-int slapi_x_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
+static int initConnectionPB( Slapi_PBlock *pb, Connection *conn )
 {
-#ifdef LDAP_SLAPI
        char *connAuthType;
        int rc;
 
@@ -2220,31 +2208,33 @@ int slapi_x_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
        }
 
        return rc;
-#else
-       return -1;
-#endif /* LDAP_SLAPI */
 }
+#endif /* LDAP_SLAPI */
 
 /*
  * Internal API to prime a Slapi_PBlock with an Operation.
  */
-int slapi_x_operation_set_pb( Slapi_PBlock *pb, Operation *op )
+int slapi_x_pblock_set_operation( Slapi_PBlock *pb, Operation *op )
 {
 #ifdef LDAP_SLAPI
        int isRoot = 0;
        int isUpdateDn = 0;
        int rc;
-       Backend *be;
        char *opAuthType;
 
-       if ( slapi_pblock_get(pb, SLAPI_BACKEND, (void *)&be ) != 0 ) {
-               be = NULL;
+       if ( op->o_bd != NULL ) {
+               isRoot = be_isroot( op->o_bd, &op->o_ndn );
+               isUpdateDn = be_isupdate( op->o_bd, &op->o_ndn );
        }
-       if (be != NULL) {
-               isRoot = be_isroot( be, &op->o_ndn );
-               isUpdateDn = be_isupdate( be, &op->o_ndn );
-       }
-               
+
+       rc = initBackendPB( pb, op->o_bd );
+       if ( rc != LDAP_SUCCESS )
+               return rc;
+
+       rc = initConnectionPB( pb, op->o_conn );
+       if ( rc != LDAP_SUCCESS )
+               return rc;
+
        rc = slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
        if ( rc != LDAP_SUCCESS )
                return rc;