#else
Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 );
#endif
+#if 0
+ char *subtree="SUBTREE";
+#endif
switch ( f->f_choice ) {
case SLAPD_FILTER_COMPUTED:
/* This technically is not the same as FALSE, but it
* certainly will produce no matches.
*/
- /* FALLTHRU */
+ /* FALL THRU */
case LDAP_COMPARE_FALSE:
BDB_IDL_ZERO( ids );
break;
BDB_IDL_ALL( bdb, ids );
} break;
case LDAP_SUCCESS:
- /* this is a pre-computed scope, leave it alone */
+ /* this is a pre-computed scope, leave it alone */
break;
}
break;
#if 0 /* Not used any more, search calls bdb_dn2idl directly */
case SLAPD_FILTER_DN_ONE:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
#endif
}
break;
+ case SLAPD_FILTER_DN_CHILDREN:
+ subtree="CHILDREN";
+ /* Fall Thru */
case SLAPD_FILTER_DN_SUBTREE:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN SUBTREE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN %s\n",
+ subtree, 0, 0 );
#else
- Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_FILTER, "\tDN %s\n",
+ subtree, 0, 0 );
#endif
rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids,
stack, op->o_tmpmemctx );
#endif
case LDAP_FILTER_PRESENT:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tPRESENT\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tPRESENT\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 );
#endif
case LDAP_FILTER_EQUALITY:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tEQUALITY\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tEQUALITY\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
#endif
case LDAP_FILTER_APPROX:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAPPROX\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAPPROX\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 );
#endif
case LDAP_FILTER_SUBSTRINGS:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tSUBSTRINGS\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tSUBSTRINGS\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 );
#endif
case LDAP_FILTER_GE:
/* no GE index, use pres */
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tGE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tGE\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 );
#endif
case LDAP_FILTER_LE:
/* no LE index, use pres */
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tLE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tLE\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 );
#endif
case LDAP_FILTER_NOT:
/* no indexing to support NOT filters */
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tNOT\n",0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tNOT\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 );
#endif
case LDAP_FILTER_AND:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAND\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAND\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 );
#endif
case LDAP_FILTER_OR:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tOR\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tOR\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 );
#endif
default:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tUNKNOWN\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tUNKNOWN\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %lu\n",
(unsigned long) f->f_choice, 0, 0 );
rs->sr_text = "maximum deref depth exceeded";
while (BDB_IDL_N(tmp) < op->o_bd->be_max_deref_depth) {
-
/* Remember the last entry we looked at, so we can
* report broken links
*/
rs->sr_err = bdb_dn2entry( op, NULL, &ndn, &ei,
0, locker, &lockr );
- if ( ei ) e = ei->bei_e;
- else e = NULL;
+ if ( ei ) {
+ e = ei->bei_e;
+ } else {
+ e = NULL;
+ }
if (!e) {
rs->sr_err = LDAP_ALIAS_PROBLEM;
u_int32_t locker,
ID *ids,
ID *scopes,
- ID *stack
-)
+ ID *stack )
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
ID *aliases, *curscop, *subscop, *visited, *newsubs, *oldsubs, *tmp;
*/
BDB_IDL_CPY( curscop, aliases );
rs->sr_err = bdb_dn2idl( op, e, subscop,
- subscop2+BDB_IDL_DB_SIZE );
+ subscop2+BDB_IDL_DB_SIZE );
if (first) {
first = 0;
} else {
/* If this is a OneLevel search, we're done; oldsubs only had one
* ID in it. For a Subtree search, oldsubs may be a list of scope IDs.
*/
- if (op->ors_scope != LDAP_SCOPE_SUBTREE) break;
+ if ( op->ors_scope == LDAP_SCOPE_ONELEVEL ) break;
nextido:
ido = bdb_idl_next( oldsubs, &cursoro );
return rs->sr_err;
}
-static
-int is_sync_protocol( Operation *op )
-{
- if ( op->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST )
- return 1;
- return 0;
-}
-
+#define is_sync_protocol(op) \
+ ((op)->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST)
+
#define IS_BDB_REPLACE(type) (( type == LDAP_PSEARCH_BY_DELETE ) || \
( type == LDAP_PSEARCH_BY_SCOPEOUT ))
#define IS_PSEARCH (op != sop)
id != NOID && !no_sync_state_change;
id = bdb_idl_next( candidates, &cursor ) )
{
- int scopeok = 0;
+ int scopeok = 0;
loop_begin:
/* check for abandon */
if ( ei->bei_parent->bei_id == base.e_id ) scopeok = 1;
break;
+ case LDAP_SCOPE_CHILDREN:
+ if ( id == base.e_id ) break;
+ /* Fall-thru */
case LDAP_SCOPE_SUBTREE: {
EntryInfo *tmp;
for ( tmp = BEI(e); tmp->bei_parent;
if ( !scopeok && BDB_IDL_N(scopes) ) {
unsigned x;
if ( sop->ors_scope == LDAP_SCOPE_ONELEVEL ) {
- x = bdb_idl_search( scopes,
- e->e_id );
- if ( scopes[x] == e->e_id )
- scopeok = 1;
+ x = bdb_idl_search( scopes, e->e_id );
+ if ( scopes[x] == e->e_id ) scopeok = 1;
} else {
- /* subtree, walk up the tree */
+ /* subtree, walk up the tree */
EntryInfo *tmp = BEI(e);
for (;tmp->bei_parent; tmp=tmp->bei_parent) {
x = bdb_idl_search( scopes, tmp->bei_id );
&& is_entry_referral( e ) )
{
BerVarray erefs = get_entry_referrals( sop, e );
- rs->sr_ref = referral_rewrite( erefs,
- &e->e_name, NULL,
- sop->oq_search.rs_scope == LDAP_SCOPE_SUBTREE
- ? LDAP_SCOPE_SUBTREE
- : LDAP_SCOPE_BASE );
+ rs->sr_ref = referral_rewrite( erefs, &e->e_name, NULL,
+ sop->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL
+ ? LDAP_SCOPE_BASE : LDAP_SCOPE_SUBTREE );
send_search_reference( sop, rs );
} else {
struct berval cookie;
slap_compose_sync_cookie( sop, &cookie,
- search_context_csn,
- sop->o_sync_state.sid,
- sop->o_sync_state.rid );
+ search_context_csn,
+ sop->o_sync_state.sid,
+ sop->o_sync_state.rid );
rs->sr_err = slap_build_sync_state_ctrl( sop,
rs, e, entry_sync_state, ctrls,
num_ctrls++, 1, &cookie );
rs->sr_attrs = attrs;
rs->sr_ctrls = ctrls;
result = send_search_entry( sop, rs );
- if ( cookie.bv_val )
- ch_free( cookie.bv_val );
+ if ( cookie.bv_val ) ch_free( cookie.bv_val );
sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
- sop->o_tmpmemctx );
+ sop->o_tmpmemctx );
sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
}
} else if ( ps_type == LDAP_PSEARCH_BY_PREMODIFY ) {
struct psid_entry* psid_e;
- psid_e = (struct psid_entry *) ch_calloc (1,
+ psid_e = (struct psid_entry *) ch_calloc(1,
sizeof(struct psid_entry));
psid_e->ps_op = sop;
LDAP_LIST_INSERT_HEAD( &op->o_pm_list,
}
} else {
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
-
if ( rc_sync == LDAP_COMPARE_TRUE ) { /* ADD */
rs->sr_err = slap_build_sync_state_ctrl( sop,
rs, e, entry_sync_state, ctrls,
rs->sr_attrs = sop->oq_search.rs_attrs;
result = send_search_entry( sop, rs );
sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
- sop->o_tmpmemctx );
+ sop->o_tmpmemctx );
sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
} else { /* PRESENT */
if ( sync_send_present_mode ) {
result = slap_build_syncUUID_set( sop,
- &syncUUID_set, e );
+ &syncUUID_set, e );
if ( result <= 0 ) {
result = -1;
} else {
syncUUID_set_cnt++;
- if ( syncUUID_set_cnt == SLAP_SYNCUUID_SET_SIZE ) {
+ if ( syncUUID_set_cnt ==
+ SLAP_SYNCUUID_SET_SIZE )
+ {
rs->sr_err = LDAP_SUCCESS;
rs->sr_rspoid = LDAP_SYNC_INFO;
rs->sr_ctrls = NULL;
result = slap_send_syncinfo( sop, rs,
- LDAP_TAG_SYNC_ID_SET,
- NULL, 0, syncUUID_set, 0 );
- if ( result != LDAP_SUCCESS )
+ LDAP_TAG_SYNC_ID_SET,
+ NULL, 0, syncUUID_set, 0 );
+ if ( result != LDAP_SUCCESS ) {
result = -1;
+ }
ber_bvarray_free_x( syncUUID_set,
- sop->o_tmpmemctx );
+ sop->o_tmpmemctx );
syncUUID_set = NULL;
syncUUID_set_cnt = 0;
}
rs->sr_rspoid = LDAP_SYNC_INFO;
rs->sr_ctrls = NULL;
slap_send_syncinfo( sop, rs, LDAP_TAG_SYNC_ID_SET,
- NULL, 0, syncUUID_set, 0 );
+ NULL, 0, syncUUID_set, 0 );
ber_bvarray_free_x( syncUUID_set, sop->o_tmpmemctx );
syncUUID_set_cnt = 0;
}
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
if ( sop->o_sync_mode & SLAP_SYNC_PERSIST ) {
struct berval cookie;
- slap_compose_sync_cookie( sop, &cookie,
- search_context_csn,
- sop->o_sync_state.sid,
- sop->o_sync_state.rid );
+ slap_compose_sync_cookie( sop, &cookie, search_context_csn,
+ sop->o_sync_state.sid, sop->o_sync_state.rid );
if ( sync_send_present_mode ) {
rs->sr_err = LDAP_SUCCESS;
if ( !no_sync_state_change ) {
int slog_found = 0;
ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
- LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
+ LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list,
+ o_ps_link )
+ {
if ( ps_list->o_sync_slog_size > 0 ) {
- if ( ps_list->o_sync_state.sid == sop->o_sync_state.sid ) {
+ if ( ps_list->o_sync_state.sid ==
+ sop->o_sync_state.sid ) {
slog_found = 1;
break;
}
} else {
/* refreshOnly mode */
struct berval cookie;
- slap_compose_sync_cookie( sop, &cookie,
- search_context_csn,
- sop->o_sync_state.sid,
- sop->o_sync_state.rid );
+ slap_compose_sync_cookie( sop, &cookie, search_context_csn,
+ sop->o_sync_state.sid, sop->o_sync_state.rid );
if ( sync_send_present_mode ) {
slap_build_sync_done_ctrl( sop, rs, ctrls,
int slog_found = 0;
ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list,
- o_ps_link ) {
+ o_ps_link )
+ {
if ( ps_list->o_sync_slog_size > 0 ) {
if ( ps_list->o_sync_state.sid ==
sop->o_sync_state.sid ) {
rs->sr_ctrls = ctrls;
rs->sr_ref = rs->sr_v2ref;
- rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
+ rs->sr_err = (rs->sr_v2ref == NULL)
+ ? LDAP_SUCCESS : LDAP_REFERRAL;
rs->sr_rspoid = NULL;
send_ldap_result( sop, rs );
if ( ctrls[num_ctrls-1]->ldctl_value.bv_val != NULL ) {
- sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, sop->o_tmpmemctx );
+ sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
+ sop->o_tmpmemctx );
}
sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
- if ( cookie.bv_val )
- ch_free( cookie.bv_val );
+ if ( cookie.bv_val ) ch_free( cookie.bv_val );
}
} else {
rs->sr_ctrls = NULL;
done:
if( !IS_PSEARCH && e != NULL ) {
/* free reader lock */
- bdb_cache_return_entry_r ( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
}
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
+ LOCK_ID_FREE( bdb->bi_dbenv, locker );
ber_bvfree( search_context_csn );
static int oc_filter(
Filter *f,
int cur,
- int *max
-)
+ int *max )
{
int rc = 0;
if( cur > *max ) *max = cur;
- switch(f->f_choice) {
+ switch( f->f_choice ) {
case LDAP_FILTER_PRESENT:
if (f->f_desc == slap_schema.si_ad_objectClass) {
rc = 1;
case LDAP_FILTER_AND:
case LDAP_FILTER_OR:
cur++;
- for (f=f->f_and; f; f=f->f_next) {
+ for ( f=f->f_and; f; f=f->f_next ) {
(void) oc_filter(f, cur, max);
}
break;
/* Dummy; we compute scope separately now */
nf.f_choice = SLAPD_FILTER_COMPUTED;
nf.f_result = LDAP_SUCCESS;
- nf.f_next = xf.f_or == op->oq_search.rs_filter
+ nf.f_next = ( xf.f_or == op->oq_search.rs_filter )
? op->oq_search.rs_filter : &xf ;
/* Filter depth increased again, adding dummy clause */
depth++;
lastid, rs->sr_nentries, NULL );
#else
Debug(LDAP_DEBUG_ARGS, "send_pagerequest_response: lastid: (0x%08lx) "
- "nentries: (0x%081x)\n", lastid, rs->sr_nentries, NULL );
+ "nentries: (0x%081x)\n", lastid, rs->sr_nentries, NULL );
#endif
ctrl.ldctl_value.bv_val = NULL;