From 2fdbc553746c44df7ec15c88b73d608743bfa030 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 31 Mar 2003 06:41:30 +0000 Subject: [PATCH] SLAPI cleanup --- servers/slapd/add.c | 5 +-- servers/slapd/bind.c | 4 +-- servers/slapd/compare.c | 4 +-- servers/slapd/delete.c | 4 +-- servers/slapd/extended.c | 8 +---- servers/slapd/modify.c | 4 +-- servers/slapd/modrdn.c | 4 +-- servers/slapd/search.c | 4 +-- servers/slapd/slapi/proto-slapi.h | 4 +-- servers/slapd/slapi/slapi_utils.c | 54 +++++++++++++------------------ 10 files changed, 31 insertions(+), 64 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 6d9a89d9f6..1a9bf13c01 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -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 ); diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index b21354e05c..7a433c93ad 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -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 ); diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 09b977af3b..2bffeafbde 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -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 ); diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 3773fc3609..daade821c0 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -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 ); diff --git a/servers/slapd/extended.c b/servers/slapd/extended.c index 60e10e5024..935fcdc8a8 100644 --- a/servers/slapd/extended.c +++ b/servers/slapd/extended.c @@ -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; diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 9efcff7e45..cdac8cae2d 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -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 ); diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index a97995c9c4..c455445499 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -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, diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 0a19b3ba3c..a1bdbb5170 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -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 ); diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 11494570b4..1dc0c5b3a8 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -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 **); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index d5b768a61b..5a389fb053 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -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; -- 2.39.5