at != NULL;
at = attrs_find( at->a_next, ad ) )
{
- if ( value_find_ex( ad,
+ if ( attr_valfind( at,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- at->a_nvals,
- &op->o_ndn, op->o_tmpmemctx ) == 0 )
+ &op->o_ndn, NULL, op->o_tmpmemctx ) == 0 )
{
rc = 1;
break;
at != NULL;
at = attrs_find( at->a_next, bdn->a_at ) )
{
- if ( value_find_ex( bdn->a_at,
+ if ( attr_valfind( at,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- at->a_nvals,
- &bv, op->o_tmpmemctx ) == 0 )
+ &bv, NULL, op->o_tmpmemctx ) == 0 )
{
/* found it */
match = 1;
static void
attr_dup2( Attribute *tmp, Attribute *a )
{
+ tmp->a_flags = a->a_flags & SLAP_ATTR_PERSISTENT_FLAGS;
if ( a->a_vals != NULL ) {
int i;
void *ctx )
{
struct berval nval = BER_BVNULL, *cval;
- MatchingRule *mr = a->a_desc->ad_type->sat_equality;
+ MatchingRule *mr;
const char *text;
int match = -1, rc;
unsigned i;
+ if ( flags & SLAP_MR_ORDERING )
+ mr = a->a_desc->ad_type->sat_ordering;
+ else
+ mr = a->a_desc->ad_type->sat_equality;
+
if( !SLAP_IS_MR_ASSERTED_VALUE_NORMALIZED_MATCH( flags ) &&
mr->smr_normalize )
{
while ( 0 < n ) {
unsigned pivot = n >> 1;
i = base + pivot;
+ if ( i >= a->a_numvals ) {
+ i = a->a_numvals - 1;
+ break;
+ }
rc = value_match( &match, a->a_desc, mr, flags,
&a->a_nvals[i], cval, &text );
if ( rc == LDAP_SUCCESS && match == 0 )
break;
n = pivot;
- if ( match > 0 )
+ if ( match < 0 )
base = i+1;
}
- if ( match > 0 )
+ if ( match < 0 )
i++;
} else {
/* Linear search */
break;
}
}
- *slot = i;
+ if ( slot )
+ *slot = i;
if ( match )
rc = LDAP_NO_SUCH_ATTRIBUTE;
if ( nval.bv_val )
rc = LDAP_TYPE_OR_VALUE_EXISTS;
return rc;
}
- for ( j = a->a_numvals; j > slot; j-- ) {
+ for ( j = a->a_numvals; j >= slot; j-- ) {
a->a_vals[j+1] = a->a_vals[j];
if ( nvals )
a->a_nvals[j+1] = a->a_nvals[j];
}
- ber_dupbv( &a->a_nvals[j], &v2[i] );
+ ber_dupbv( &a->a_nvals[slot], &v2[i] );
if ( nvals )
- ber_dupbv( &a->a_vals[j], &vals[i] );
+ ber_dupbv( &a->a_vals[slot], &vals[i] );
a->a_numvals++;
}
BER_BVZERO( &a->a_vals[a->a_numvals] );
{
rs->sr_err = LDAP_COMPARE_FALSE;
- if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
+ if ( attr_valfind( a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a->a_nvals, &op->oq_compare.rs_ava->aa_value,
+ &op->oq_compare.rs_ava->aa_value, NULL,
op->o_tmpmemctx ) == 0 )
{
rs->sr_err = LDAP_COMPARE_TRUE;
a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc )) {
rs->sr_err = LDAP_COMPARE_FALSE;
- if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
+ if ( attr_valfind( a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a->a_nvals, &op->oq_compare.rs_ava->aa_value,
+ &op->oq_compare.rs_ava->aa_value, NULL,
op->o_tmpmemctx ) == 0 )
{
rs->sr_err = LDAP_COMPARE_TRUE;
a = attrs_find( a->a_next, op->oq_compare.rs_ava->aa_desc ) )
{
rs->sr_err = LDAP_COMPARE_FALSE;
- if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
+ if ( attr_valfind( a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a->a_nvals,
- &op->oq_compare.rs_ava->aa_value,
+ &op->oq_compare.rs_ava->aa_value, NULL,
op->o_tmpmemctx ) == 0 )
{
rs->sr_err = LDAP_COMPARE_TRUE;
op->o_bd = b2;
} else {
- rc = value_find_ex( group_at,
+ rc = attr_valfind( a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a->a_nvals, op_ndn, op->o_tmpmemctx );
+ op_ndn, NULL, op->o_tmpmemctx );
if ( rc == LDAP_NO_SUCH_ATTRIBUTE ) {
rc = LDAP_COMPARE_FALSE;
}
}
svtail = sv;
}
+ sv->al_next = NULL;
for ( sv = svnew; sv; sv = sv->al_next )
sv->al_desc->ad_type->sat_flags |= SLAP_AT_SORTED_VAL;
for ( sv = sortVals; sv && sv->al_next; sv = sv->al_next );
break;
}
- if ( value_find_ex( ava->aa_desc,
+ if ( attr_valfind( a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a->a_nvals, &ava->aa_value, op->o_tmpmemctx ) == 0 )
+ &ava->aa_value, NULL, op->o_tmpmemctx ) == 0 )
{
rc = LDAP_COMPARE_TRUE;
break;
continue;
}
+ if ( a->a_flags & SLAP_ATTR_SORTED_VALS ) {
+ unsigned slot;
+ rc = attr_valfind( a, use | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH |
+ SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+ &ava->aa_value, &slot, NULL );
+ if ( rc == LDAP_SUCCESS )
+ return LDAP_COMPARE_TRUE;
+ if ( rc == LDAP_NO_SUCH_ATTRIBUTE ) {
+ /* If insertion point is not the end of the list, there was
+ * at least one value greater than the assertion.
+ */
+ if ( type == LDAP_FILTER_GE && slot < a->a_numvals )
+ return LDAP_COMPARE_TRUE;
+ /* Likewise, if insertion point is not the head of the list,
+ * there was at least one value less than the assertion.
+ */
+ if ( type == LDAP_FILTER_LE && slot > 0 )
+ return LDAP_COMPARE_TRUE;
+ return LDAP_COMPARE_FALSE;
+ }
+ return rc;
+ }
+
#ifdef LDAP_COMP_MATCH
if ( nibble_mem_allocator && ava->aa_cf && !a->a_comp_data ) {
/* Component Matching */
}
for ( ; dli; dli = dli->dli_next ) {
- if ( value_find_ex( slap_schema.si_ad_objectClass,
+ if ( attr_valfind( a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a->a_nvals, &dli->dli_oc->soc_cname,
+ &dli->dli_oc->soc_cname, NULL,
op->o_tmpmemctx ) == 0 )
{
return dli;
/* if we're here, we got a match... */
rs->sr_err = LDAP_COMPARE_FALSE;
- if ( value_find_ex( op->orc_ava->aa_desc,
+ if ( attr_valfind( a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a->a_nvals, &op->orc_ava->aa_value, op->o_tmpmemctx ) == 0 )
+ &op->orc_ava->aa_value, NULL, op->o_tmpmemctx ) == 0 )
{
rs->sr_err = LDAP_COMPARE_TRUE;
break;
rs->sr_err = LDAP_COMPARE_FALSE;
- if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
+ if ( attr_valfind( &a,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
- a.a_nvals, &op->oq_compare.rs_ava->aa_value, op->o_tmpmemctx ) == 0 )
+ &op->oq_compare.rs_ava->aa_value, NULL, op->o_tmpmemctx ) == 0 )
{
rs->sr_err = LDAP_COMPARE_TRUE;
}
break;
}
- rc = value_find_ex( desc, SLAP_MR_VALUE_OF_ASSERTION_SYNTAX|
+ rc = attr_valfind( attr, SLAP_MR_VALUE_OF_ASSERTION_SYNTAX|
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
- attr->a_nvals, &ava->la_value, NULL );
+ &ava->la_value, NULL, NULL );
if( rc != 0 ) {
switch( rc ) {
#define SLAP_ATTR_DONT_FREE_DATA 0x4U
#define SLAP_ATTR_DONT_FREE_VALS 0x8U
#define SLAP_ATTR_SORTED_VALS 0x10U /* values are sorted */
+
+/* These flags persist across an attr_dup() */
+#define SLAP_ATTR_PERSISTENT_FLAGS \
+ SLAP_ATTR_SORTED_VALS
+
Attribute *a_next;
#ifdef LDAP_COMP_MATCH
ComponentData *a_comp_data; /* component values */
int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v )
{
- MatchingRule *mr;
- struct berval *bv;
- int j;
- const char *text;
int rc;
int ret;
if ( a ->a_vals == NULL ) {
return -1;
}
- mr = a->a_desc->ad_type->sat_equality;
- for ( bv = a->a_vals, j = 0; bv->bv_val != NULL; bv++, j++ ) {
- rc = value_match( &ret, a->a_desc, mr,
- SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, bv, v, &text );
- if ( rc != LDAP_SUCCESS ) {
- return -1;
- }
- if ( ret == 0 ) {
- return 0;
- }
- }
- return -1;
+ rc = attr_valfind( (Attribute *)a, SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, v,
+ NULL, NULL );
+ return rc == 0 ? 0 : -1;
}
int slapi_attr_type_cmp( const char *t1, const char *t2, int opt )
oldRDN.bv_len -= oldVal.bv_len + 2;
slap_bv2ad( &oldRDN, &ad, &rs->sr_text );
a = attr_find( dni->new_entry->e_attrs, ad );
- if ( !a || value_find_ex( ad,
+ if ( !a || attr_valfind( a,
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH |
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
- SLAP_MR_VALUE_OF_SYNTAX, a->a_nvals,
- &oldVal, op->o_tmpmemctx ) != LDAP_SUCCESS )
+ SLAP_MR_VALUE_OF_SYNTAX,
+ &oldVal, NULL, op->o_tmpmemctx ) != LDAP_SUCCESS )
{
dni->delOldRDN = 1;
}