Replace existing SLAP_MR_ matching flags with:

SLAP_MR_ASSERTION_SYNTAX_MATCH
	SLAP_MR_VALUE_SYNTAX_MATCH
	SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH,
add supporting evaluation macros, and update code as needed.
Misc other code cleanup included.
This commit is contained in:
Kurt Zeilenga 2001-11-27 21:59:56 +00:00
parent 5c7a7998a9
commit 2ac7c91cae
14 changed files with 63 additions and 44 deletions

View file

@ -207,7 +207,8 @@ retry: rc = txn_abort( ltid );
p = NULL; p = NULL;
if ( ! rc ) { if ( ! rc ) {
Debug( LDAP_DEBUG_TRACE, "bdb_add: no write access to parent\n", Debug( LDAP_DEBUG_TRACE,
"bdb_add: no write access to parent\n",
0, 0, 0 ); 0, 0, 0 );
rc = LDAP_INSUFFICIENT_ACCESS; rc = LDAP_INSUFFICIENT_ACCESS;
text = "no write access to parent"; text = "no write access to parent";
@ -287,6 +288,7 @@ retry: rc = txn_abort( ltid );
db_strerror(rc), rc, 0 ); db_strerror(rc), rc, 0 );
rc = LDAP_OTHER; rc = LDAP_OTHER;
text = "commit failed"; text = "commit failed";
} else { } else {
Debug( LDAP_DEBUG_TRACE, Debug( LDAP_DEBUG_TRACE,
"bdb_add: added id=%08lx dn=\"%s\"\n", "bdb_add: added id=%08lx dn=\"%s\"\n",

View file

@ -101,10 +101,7 @@ bdb_compare(
{ {
rc = LDAP_COMPARE_FALSE; rc = LDAP_COMPARE_FALSE;
if ( value_find_ex( ava->aa_desc, if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) {
SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
a->a_vals, ava->aa_value ) == 0 )
{
rc = LDAP_COMPARE_TRUE; rc = LDAP_COMPARE_TRUE;
break; break;
} }

View file

@ -314,6 +314,7 @@ retry: /* transaction retry */
db_strerror(rc), rc, 0 ); db_strerror(rc), rc, 0 );
rc = LDAP_OTHER; rc = LDAP_OTHER;
text = "commit failed"; text = "commit failed";
} else { } else {
Debug( LDAP_DEBUG_TRACE, Debug( LDAP_DEBUG_TRACE,
"bdb_modify: updated id=%08lx dn=\"%s\"\n", "bdb_modify: updated id=%08lx dn=\"%s\"\n",
@ -384,7 +385,7 @@ add_values(
for ( j = 0; a->a_vals[j] != NULL; j++ ) { for ( j = 0; a->a_vals[j] != NULL; j++ ) {
int match; int match;
int rc = value_match( &match, mod->sm_desc, mr, int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_MODIFY_MATCHING, SLAP_MR_VALUE_SYNTAX_MATCH,
a->a_vals[j], asserted, &text ); a->a_vals[j], asserted, &text );
if( rc == LDAP_SUCCESS && match == 0 ) { if( rc == LDAP_SUCCESS && match == 0 ) {
@ -460,7 +461,7 @@ delete_values(
for ( j = 0; a->a_vals[j] != NULL; j++ ) { for ( j = 0; a->a_vals[j] != NULL; j++ ) {
int match; int match;
int rc = value_match( &match, mod->sm_desc, mr, int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_MODIFY_MATCHING, SLAP_MR_VALUE_SYNTAX_MATCH,
a->a_vals[j], asserted, &text ); a->a_vals[j], asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) { if( rc == LDAP_SUCCESS && match != 0 ) {

View file

@ -81,7 +81,6 @@ retry: /* transaction retry */
} }
} }
if( bdb->bi_txn ) { if( bdb->bi_txn ) {
/* begin transaction */ /* begin transaction */
rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 0 ); rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 0 );

View file

@ -99,10 +99,7 @@ ldbm_back_compare(
{ {
rc = LDAP_COMPARE_FALSE; rc = LDAP_COMPARE_FALSE;
if ( value_find_ex( ava->aa_desc, if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) {
SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
a->a_vals, ava->aa_value ) == 0 )
{
rc = LDAP_COMPARE_TRUE; rc = LDAP_COMPARE_TRUE;
break; break;
} }

View file

@ -387,7 +387,7 @@ add_values(
for ( j = 0; a->a_vals[j] != NULL; j++ ) { for ( j = 0; a->a_vals[j] != NULL; j++ ) {
int match; int match;
int rc = value_match( &match, mod->sm_desc, mr, int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_MODIFY_MATCHING, SLAP_MR_VALUE_SYNTAX_MATCH,
a->a_vals[j], asserted, &text ); a->a_vals[j], asserted, &text );
if( rc == LDAP_SUCCESS && match == 0 ) { if( rc == LDAP_SUCCESS && match == 0 ) {
@ -474,7 +474,7 @@ delete_values(
for ( j = 0; a->a_vals[j] != NULL; j++ ) { for ( j = 0; a->a_vals[j] != NULL; j++ ) {
int match; int match;
int rc = value_match( &match, mod->sm_desc, mr, int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_MODIFY_MATCHING, SLAP_MR_VALUE_SYNTAX_MATCH,
a->a_vals[j], asserted, &text ); a->a_vals[j], asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) { if( rc == LDAP_SUCCESS && match != 0 ) {

View file

@ -302,10 +302,7 @@ static int compare_entry(
{ {
rc = LDAP_COMPARE_FALSE; rc = LDAP_COMPARE_FALSE;
if ( value_find_ex( ava->aa_desc, if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) {
SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
a->a_vals, ava->aa_value ) == 0 )
{
rc = LDAP_COMPARE_TRUE; rc = LDAP_COMPARE_TRUE;
break; break;
} }

View file

@ -255,7 +255,7 @@ static int test_mra_filter(
const char *text; const char *text;
rc = value_match( &ret, a->a_desc, mra->ma_rule, rc = value_match( &ret, a->a_desc, mra->ma_rule,
SLAP_MR_VALUE_IS_IN_MR_SYNTAX, SLAP_MR_ASSERTION_SYNTAX_MATCH,
a->a_vals[i], mra->ma_value, a->a_vals[i], mra->ma_value,
&text ); &text );
@ -327,7 +327,7 @@ test_ava_filter(
const char *text; const char *text;
rc = value_match( &ret, a->a_desc, mr, rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_VALUE_IS_IN_MR_SYNTAX, SLAP_MR_ASSERTION_SYNTAX_MATCH,
a->a_vals[i], ava->aa_value, a->a_vals[i], ava->aa_value,
&text ); &text );
@ -514,7 +514,7 @@ test_substrings_filter(
const char *text; const char *text;
rc = value_match( &ret, a->a_desc, mr, rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_VALUE_IS_IN_MR_SYNTAX, SLAP_MR_ASSERTION_SYNTAX_MATCH,
a->a_vals[i], f->f_sub, a->a_vals[i], f->f_sub,
&text ); &text );

View file

@ -783,13 +783,15 @@ LDAP_SLAPD_F (int) value_match LDAP_P((
struct berval *v1, struct berval *v1,
void *v2, void *v2,
const char ** text )); const char ** text ));
#define value_find(ad,values,value) (value_find_ex((ad),0,(values),(value)))
LDAP_SLAPD_F (int) value_find_ex LDAP_P(( LDAP_SLAPD_F (int) value_find_ex LDAP_P((
AttributeDescription *ad, AttributeDescription *ad,
unsigned flags, unsigned flags,
struct berval **values, struct berval **values,
struct berval *value )); struct berval *value ));
#define value_find(ad, values, value) ( value_find_ex(ad,0,values,value ) ) LDAP_SLAPD_F (int) value_add LDAP_P((
LDAP_SLAPD_F (int) value_add LDAP_P(( struct berval ***vals, struct berval **addvals )); struct berval ***vals,
struct berval **addvals ));
/* /*
* user.c * user.c

View file

@ -53,7 +53,7 @@ objectClassMatch(
return SLAPD_COMPARE_UNDEFINED; return SLAPD_COMPARE_UNDEFINED;
} }
if( flags & SLAP_MR_MODIFY_MATCHING ) { if( SLAP_IS_MR_VALUE_SYNTAX_MATCH( flags ) ) {
*matchp = ( asserted != oc ); *matchp = ( asserted != oc );
} else { } else {
*matchp = !is_object_subclass( asserted, oc ); *matchp = !is_object_subclass( asserted, oc );

View file

@ -343,10 +343,28 @@ typedef struct slap_matching_rule {
#define SLAP_MR_SUBSTR_ANY ( SLAP_MR_SUBSTR | 0x0020U ) #define SLAP_MR_SUBSTR_ANY ( SLAP_MR_SUBSTR | 0x0020U )
#define SLAP_MR_SUBSTR_FINAL ( SLAP_MR_SUBSTR | 0x0040U ) #define SLAP_MR_SUBSTR_FINAL ( SLAP_MR_SUBSTR | 0x0040U )
/* this is used to kludge objectClass testing */ /*
#define SLAP_MR_MODIFY_MATCHING 0x0001U * normally the provided value is expected to conform to
/* are we matching from a mr asserted value or a real value */ * assertion syntax specified in the matching rule, however
#define SLAP_MR_VALUE_IS_IN_MR_SYNTAX 0x0002U * at times (such as during individual value modification),
* the provided value is expected to conform to the
* attribute's value syntax.
*/
#define SLAP_MR_ASSERTION_SYNTAX_MATCH 0x0000U
#define SLAP_MR_VALUE_SYNTAX_MATCH 0x0001U
#define SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH 0x0003U
#define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \
(!((usage) & SLAP_MR_VALUE_SYNTAX_MATCH))
#define SLAP_IS_MR_VALUE_SYNTAX_MATCH( usage ) \
((usage) & SLAP_MR_VALUE_SYNTAX_MATCH)
#define SLAP_IS_MR_VALUE_SYNTAX_CONVERTED_MATCH( usage ) \
(((usage) & SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH) \
== SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH)
#define SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( usage ) \
(((usage) & SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH) \
== SLAP_MR_VALUE_SYNTAX_MATCH)
Syntax *smr_syntax; Syntax *smr_syntax;
slap_mr_convert_func *smr_convert; slap_mr_convert_func *smr_convert;

View file

@ -148,12 +148,16 @@ value_match(
} }
} }
if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) && if ( SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( flags ) &&
mr->smr_convert ) { mr->smr_convert )
{
rc = (mr->smr_convert)( v2, &nv2 ); rc = (mr->smr_convert)( v2, &nv2 );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
} }
/* let smr_match know we've converted the value */
flags |= SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH;
} }
rc = (mr->smr_match)( match, flags, rc = (mr->smr_match)( match, flags,
@ -185,12 +189,16 @@ int value_find_ex(
} }
/* Take care of this here or ssyn_normalize later will hurt */ /* Take care of this here or ssyn_normalize later will hurt */
if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) && if ( SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( flags )
mr->smr_convert ) { && mr->smr_convert )
{
rc = (mr->smr_convert)( val, &nval ); rc = (mr->smr_convert)( val, &nval );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
return LDAP_INVALID_SYNTAX; return LDAP_INVALID_SYNTAX;
} }
/* let value_match know we've done the version */
flags |= SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH;
} }
if( mr->smr_syntax->ssyn_normalize ) { if( mr->smr_syntax->ssyn_normalize ) {
@ -209,9 +217,7 @@ int value_find_ex(
int match; int match;
const char *text; const char *text;
/* We did convert, so keep value_match from trying */ rc = value_match( &match, ad, mr, flags,
rc = value_match( &match, ad, mr,
flags & !SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
vals[i], nval == NULL ? val : nval, &text ); vals[i], nval == NULL ? val : nval, &text );
if( rc == LDAP_SUCCESS && match == 0 ) { if( rc == LDAP_SUCCESS && match == 0 ) {