Use accessor macros for SLAPI parameter blocks, should make it

easier to move into overlay private data
This commit is contained in:
Luke Howard 2005-07-22 05:26:15 +00:00
parent c477ad064f
commit de10624dc3
7 changed files with 67 additions and 49 deletions

View File

@ -97,8 +97,8 @@ slap_op_free( Operation *op )
}
#if defined( LDAP_SLAPI )
if ( op->o_pb != NULL ) {
slapi_pblock_destroy( (Slapi_PBlock *)op->o_pb );
if ( SLAPI_OPERATION_PBLOCK( op ) ) {
slapi_pblock_destroy( SLAPI_OPERATION_PBLOCK( op ) );
slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
}
#endif /* defined( LDAP_SLAPI ) */
@ -152,7 +152,7 @@ slap_op_alloc(
#if defined( LDAP_SLAPI )
if ( slapi_plugins_used ) {
op->o_pb = slapi_pblock_new();
SLAPI_OPERATION_PBLOCK( op ) = slapi_pblock_new();
slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op );
}
#endif /* defined( LDAP_SLAPI ) */

View File

@ -165,9 +165,9 @@ slapi_int_register_plugin(
assert( be != NULL );
pTmpPB = (Slapi_PBlock *)be->be_pb;
pTmpPB = SLAPI_BACKEND_PBLOCK( be );
if ( pTmpPB == NULL ) {
be->be_pb = (void *)pPB;
SLAPI_BACKEND_PBLOCK( be ) = pPB;
} else {
while ( pTmpPB != NULL && rc == LDAP_SUCCESS ) {
pSavePB = pTmpPB;
@ -217,7 +217,7 @@ slapi_int_get_plugins(
goto done;
}
pCurrentPB = (Slapi_PBlock *)be->be_pb;
pCurrentPB = SLAPI_BACKEND_PBLOCK( be );
while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) {
rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr );
@ -247,7 +247,7 @@ slapi_int_get_plugins(
goto done;
}
pCurrentPB = (Slapi_PBlock *)be->be_pb;
pCurrentPB = SLAPI_BACKEND_PBLOCK( be );
while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) {
rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr );
@ -732,7 +732,7 @@ slapi_int_plugin_unparse(
idx.bv_val = ibuf;
i = 0;
for ( pp = be->be_pb;
for ( pp = SLAPI_BACKEND_PBLOCK( be );
pp != NULL;
slapi_pblock_get( pp, SLAPI_IBM_PBLOCK, &pp ) )
{

View File

@ -55,6 +55,10 @@ typedef struct _Audit_record Audit_record;
#define SLAPI_OVERLAY_NAME "slapi"
#define SLAPI_OPERATION_PBLOCK(_op) ((op)->o_pb)
#define SLAPI_CONNECTION_PBLOCK(_conn) ((conn)->c_pb);
#define SLAPI_BACKEND_PBLOCK(_be) ((be)->be_pb)
#define SLAPI_CONTROL_MANAGEDSAIT_OID LDAP_CONTROL_MANAGEDSAIT
#define SLAPI_CONTROL_SORTEDSEARCH_OID LDAP_CONTROL_SORTREQUEST
#define SLAPI_CONTROL_PAGED_RESULTS_OID LDAP_CONTROL_PAGEDRESULTS

View File

@ -49,12 +49,13 @@ slapi_int_send_ldap_result_shim(
size_t i;
plugin_result_callback prc = NULL;
void *callback_data = NULL;
Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
assert( op->o_pb != NULL );
assert( pb != NULL );
slapi_pblock_get( op->o_pb, SLAPI_RESCONTROLS, (void **)&controls );
slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc );
slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&controls );
slapi_pblock_get( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc );
slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
assert( controls == NULL );
@ -72,8 +73,8 @@ slapi_int_send_ldap_result_shim(
controls[i] = NULL;
}
slapi_pblock_set( op->o_pb, SLAPI_RESCONTROLS, (void *)controls );
slapi_pblock_set( op->o_pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs->sr_err );
slapi_pblock_set( pb, SLAPI_RESCONTROLS, (void *)controls );
slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs->sr_err );
if ( prc != NULL ) {
(*prc)( rs->sr_err, callback_data );
@ -89,11 +90,12 @@ slapi_int_send_search_entry_shim(
{
plugin_search_entry_callback psec = NULL;
void *callback_data = NULL;
Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
assert( op->o_pb != NULL );
assert( pb != NULL );
slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void **)&psec );
slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
slapi_pblock_get( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void **)&psec );
slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
if ( psec != NULL ) {
return (*psec)( rs->sr_entry, callback_data );
@ -107,7 +109,7 @@ slapi_int_send_ldap_extended_shim(
Operation *op,
SlapReply *rs )
{
assert( op->o_pb != NULL );
assert( SLAPI_OPERATION_PBLOCK( op ) != NULL );
return;
}
@ -120,11 +122,12 @@ slapi_int_send_search_reference_shim(
int i, rc = LDAP_SUCCESS;
plugin_referral_entry_callback prec = NULL;
void *callback_data = NULL;
Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
assert( op->o_pb != NULL );
assert( pb != NULL );
slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void **)&prec );
slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
slapi_pblock_get( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void **)&prec );
slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
if ( prec != NULL ) {
for ( i = 0; rs->sr_ref[i].bv_val != NULL; i++ ) {
@ -395,8 +398,8 @@ slapi_int_init_connection( Slapi_PBlock *pb,
rc = slapi_int_pblock_get_operation( pb, op, rs );
slapi_pblock_set( op->o_pb, SLAPI_OPERATION, op );
slapi_pblock_set( op->o_pb, SLAPI_CONNECTION, conn );
slapi_pblock_set( pb, SLAPI_OPERATION, op );
slapi_pblock_set( pb, SLAPI_CONNECTION, conn );
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
@ -414,6 +417,7 @@ void slapi_int_connection_destroy( Connection **pConn )
{
Connection *conn = *pConn;
Operation *op;
Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
if ( conn == NULL ) {
return;
@ -434,8 +438,8 @@ void slapi_int_connection_destroy( Connection **pConn )
ber_sockbuf_free( conn->c_sb );
}
slapi_pblock_set( op->o_pb, SLAPI_OPERATION, NULL );
slapi_pblock_set( op->o_pb, SLAPI_CONNECTION, NULL );
slapi_pblock_set( pb, SLAPI_OPERATION, NULL );
slapi_pblock_set( pb, SLAPI_CONNECTION, NULL );
if ( op != NULL ) {
slapi_ch_free( (void **)&op );

View File

@ -96,7 +96,7 @@ slapi_over_aux_operational( Operation *op, SlapReply *rs )
AttributeName *anp;
AccessControlState acl_state = ACL_STATE_INIT;
ctx.cac_pb = op->o_pb;
ctx.cac_pb = SLAPI_OPERATION_PBLOCK( op );
ctx.cac_op = op;
ctx.cac_private = rs;
ctx.cac_acl_state = &acl_state;
@ -154,17 +154,17 @@ slapi_over_search( Operation *op, SlapReply *rs, int type )
static int
slapi_over_merge_controls( Operation *op, SlapReply *rs, Slapi_PBlock *pb)
{
LDAPControl **slapiControls = NULL, **resControls;
int nSlapiControls = 0;
int nResControls = 0;
int i;
LDAPControl **slapiControls = NULL, **resControls;
int nSlapiControls = 0;
int nResControls = 0;
int i;
/* merge in controls */
if ( rs->sr_ctrls != NULL ) {
for ( nResControls = 0; rs->sr_ctrls[nResControls] != NULL; nResControls++ )
;
}
slapi_pblock_get( op->o_pb, SLAPI_RESCONTROLS, (void **)&slapiControls );
slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&slapiControls );
if ( slapiControls != NULL ) {
for ( nSlapiControls = 0; slapiControls[nSlapiControls] != NULL; nSlapiControls++ )
;
@ -189,7 +189,7 @@ slapi_over_merge_controls( Operation *op, SlapReply *rs, Slapi_PBlock *pb)
if ( slapiControls != NULL ) {
slapi_ch_free( (void **)&slapiControls );
slapi_pblock_set( op->o_pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
slapi_pblock_set( pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
}
rs->sr_ctrls = resControls;
@ -200,22 +200,23 @@ slapi_over_merge_controls( Operation *op, SlapReply *rs, Slapi_PBlock *pb)
static int
slapi_over_result( Operation *op, SlapReply *rs, int type )
{
int rc;
int rc;
Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
assert( rs->sr_type == REP_RESULT );
slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
slapi_pblock_set( pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
slapi_pblock_set( pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
rc = slapi_int_call_plugins( op->o_bd, type, op->o_pb );
rc = slapi_int_call_plugins( op->o_bd, type, pb );
slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
slapi_pblock_get( op->o_pb, SLAPI_RESULT_TEXT, (void **)&rs->sr_text );
slapi_pblock_get( op->o_pb, SLAPI_RESULT_MATCHED, (void **)&rs->sr_matched );
slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
slapi_pblock_get( pb, SLAPI_RESULT_TEXT, (void **)&rs->sr_text );
slapi_pblock_get( pb, SLAPI_RESULT_MATCHED, (void **)&rs->sr_matched );
if ( type == SLAPI_PLUGIN_PRE_RESULT_FN ) {
rc = slapi_over_merge_controls( op, rs, op->o_pb );
rc = slapi_over_merge_controls( op, rs, pb );
}
return SLAP_CB_CONTINUE;
@ -642,7 +643,7 @@ slapi_over_cleanup( Operation *op, SlapReply *rs )
static int
slapi_op_func( Operation *op, SlapReply *rs )
{
Slapi_PBlock *pb = op->o_pb;
Slapi_PBlock *pb;
slap_operation_t which;
struct slapi_op_info *opinfo;
int rc, flags = 0;
@ -650,11 +651,13 @@ slapi_op_func( Operation *op, SlapReply *rs )
slap_overinst *on;
slap_callback cb;
pb = SLAPI_OPERATION_PBLOCK( op );
/*
* We check for op->o_extensions to verify that we are not
* processing a SLAPI internal operation. XXX
*/
if ( op->o_pb == NULL || op->o_extensions == NULL ) {
if ( pb == NULL || op->o_extensions == NULL ) {
return SLAP_CB_CONTINUE;
}
@ -749,12 +752,17 @@ cleanup:
static int
slapi_over_extended( Operation *op, SlapReply *rs )
{
Slapi_PBlock *pb = op->o_pb;
Slapi_PBlock *pb;
SLAPI_FUNC callback;
int sentResult = 0;
int rc;
struct berval reqdata = BER_BVNULL;
pb = SLAPI_OPERATION_PBLOCK( op );
if ( pb == NULL ) {
return SLAP_CB_CONTINUE;
}
slapi_int_get_extop_plugin( &op->ore_reqoid, &callback );
if ( callback == NULL ) {
return SLAP_CB_CONTINUE;
@ -821,7 +829,7 @@ slapi_over_acl_group(
{
Slapi_Entry *e;
int rc;
Slapi_PBlock *pb = op->o_pb;
Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
BackendDB *be = NULL;
BackendDB *be_orig = op->o_bd;

View File

@ -583,7 +583,7 @@ slapi_int_pblock_get_first( Backend *be, Slapi_PBlock **pb )
{
#if defined(LDAP_SLAPI)
assert( pb != NULL );
*pb = (Slapi_PBlock *)be->be_pb;
*pb = SLAPI_BACKEND_PBLOCK( be );
return (*pb == NULL ? LDAP_OTHER : LDAP_SUCCESS);
#else /* LDAP_SLAPI */
return LDAP_OTHER;

View File

@ -3964,8 +3964,10 @@ int slapi_int_access_allowed( Operation *op,
#ifdef LDAP_SLAPI
int rc, slap_access = 0;
slapi_acl_callback_t *pGetPlugin, *tmpPlugin;
Slapi_PBlock *pb;
if ( op->o_pb == NULL ) {
pb = SLAPI_OPERATION_PBLOCK( op );
if ( pb == NULL ) {
/* internal operation */
return 1;
}
@ -4006,8 +4008,8 @@ int slapi_int_access_allowed( Operation *op,
* 0 access denied
* 1 access granted
*/
rc = (*pGetPlugin)( op->o_pb, entry, desc->ad_cname.bv_val,
val, slap_access, (void *)state );
rc = (*pGetPlugin)( pb, entry, desc->ad_cname.bv_val,
val, slap_access, (void *)state );
if ( rc == 0 ) {
break;
}