]> git.sur5r.net Git - openldap/commitdiff
Replace existing SLAP_MR_ matching flags with:
authorKurt Zeilenga <kurt@openldap.org>
Tue, 27 Nov 2001 21:59:56 +0000 (21:59 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 27 Nov 2001 21:59:56 +0000 (21:59 +0000)
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.

14 files changed:
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/compare.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-ldbm/compare.c
servers/slapd/back-ldbm/modify.c
servers/slapd/compare.c
servers/slapd/filterentry.c
servers/slapd/proto-slap.h
servers/slapd/schema_prep.c
servers/slapd/slap.h
servers/slapd/value.c

index d562196879f972da77eab3e014ebdcba299bb616..fff5f6534575e56ee52964e61b6c7d315cb3eb86 100644 (file)
@@ -56,7 +56,7 @@ bdb_add(
                goto return_results;
        }
 
-       if (0) {
+       if( 0 ) {
                /* transaction retry */
 retry: rc = txn_abort( ltid );
                ltid = NULL;
@@ -207,7 +207,8 @@ retry:      rc = txn_abort( ltid );
                                p = NULL;
 
                                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 );
                                        rc = LDAP_INSUFFICIENT_ACCESS;
                                        text = "no write access to parent";
@@ -287,6 +288,7 @@ retry:      rc = txn_abort( ltid );
                        db_strerror(rc), rc, 0 );
                rc = LDAP_OTHER;
                text = "commit failed";
+
        } else {
                Debug( LDAP_DEBUG_TRACE,
                        "bdb_add: added id=%08lx dn=\"%s\"\n",
@@ -299,7 +301,7 @@ return_results:
        send_ldap_result( conn, op, rc,
                NULL, text, NULL, NULL );
 
-       if(rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
+       if( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
                ldap_pvt_thread_yield();
                txn_checkpoint( bdb->bi_dbenv,
                        bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
index ef32a591c9a50a00866b94fb6fa02872a58d67db..35e150830497b6c1e955be103468effdc71804c3 100644 (file)
@@ -101,10 +101,7 @@ bdb_compare(
        {
                rc = LDAP_COMPARE_FALSE;
 
-               if ( value_find_ex( ava->aa_desc,
-                       SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
-                       a->a_vals, ava->aa_value ) == 0 )
-               {
+               if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) {
                        rc = LDAP_COMPARE_TRUE;
                        break;
                }
index 7cd603ef3595da7a393835b1f2afc9efd9a9aab8..22e67f6f67a404367ea7560294c449cad40c0683 100644 (file)
@@ -35,7 +35,7 @@ bdb_delete(
 
        Debug( LDAP_DEBUG_ARGS, "==> bdb_delete: %s\n", dn, 0, 0 );
 
-       if (0) {
+       if( 0 ) {
 retry: /* transaction retry */
                Debug( LDAP_DEBUG_TRACE, "==> bdb_delete: retrying...\n", 0, 0, 0 );
                rc = txn_abort( ltid );
index d1612cd6a7c2142b5e18ac38b50d1d9fcabf5193..42869b59a784b74b273be75d7d5f73ee3b81119d 100644 (file)
@@ -173,7 +173,7 @@ bdb_modify(
 
        Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n", dn, 0, 0 );
 
-       if (0) {
+       if( 0 ) {
 retry: /* transaction retry */
                Debug(LDAP_DEBUG_TRACE,
                        "bdb_modify: retrying...\n", 0, 0, 0);
@@ -314,6 +314,7 @@ retry:      /* transaction retry */
                        db_strerror(rc), rc, 0 );
                rc = LDAP_OTHER;
                text = "commit failed";
+
        } else {
                Debug( LDAP_DEBUG_TRACE,
                        "bdb_modify: updated id=%08lx dn=\"%s\"\n",
@@ -384,7 +385,7 @@ add_values(
                        for ( j = 0; a->a_vals[j] != NULL; j++ ) {
                                int match;
                                int rc = value_match( &match, mod->sm_desc, mr,
-                                       SLAP_MR_MODIFY_MATCHING,
+                                       SLAP_MR_VALUE_SYNTAX_MATCH,
                                        a->a_vals[j], asserted, &text );
 
                                if( rc == LDAP_SUCCESS && match == 0 ) {
@@ -460,7 +461,7 @@ delete_values(
                for ( j = 0; a->a_vals[j] != NULL; j++ ) {
                        int match;
                        int rc = value_match( &match, mod->sm_desc, mr,
-                               SLAP_MR_MODIFY_MATCHING,
+                               SLAP_MR_VALUE_SYNTAX_MATCH,
                                a->a_vals[j], asserted, &text );
 
                        if( rc == LDAP_SUCCESS && match != 0 ) {
index 260b917d99c3648d0117ea300bab90aa0fdf499b..6742f71b46f86c6a71c52f7c868df4e79c590777 100644 (file)
@@ -68,7 +68,7 @@ bdb_modrdn(
        }
 #endif
 
-       if (0) {
+       if( 0 ) {
 retry: /* transaction retry */
                Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
                rc = txn_abort( ltid );
@@ -81,7 +81,6 @@ retry:        /* transaction retry */
                }
        }
 
-
        if( bdb->bi_txn ) {
                /* begin transaction */
                rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 0 );
index 48be3bbf4e205b1495a83df31e360be794a4f520..96ea8dc6e387d2ea0d586e5b410f5a86d84a9012 100644 (file)
@@ -84,7 +84,7 @@ bdb_exop_passwd(
                goto done;
        }
 
-       if (0) {
+       if( 0 ) {
 retry: /* transaction retry */
                Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: retrying...\n", 0, 0, 0 );
                rc = txn_abort( ltid );
index 4134bb115fe5500ffca26344fe73d2e034255d52..3a7245ec7ece48944aafb70affc949b5a1b107ff 100644 (file)
@@ -99,10 +99,7 @@ ldbm_back_compare(
        {
                rc = LDAP_COMPARE_FALSE;
 
-               if ( value_find_ex( ava->aa_desc,
-                                   SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
-                                   a->a_vals, ava->aa_value ) == 0 )
-               {
+               if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) {
                        rc = LDAP_COMPARE_TRUE;
                        break;
                }
index 37fb844dd937ed23f0b5312ecb6792e6a3719570..5f771dbc81d05ef2cb5213e8c61a7c62d43df9c6 100644 (file)
@@ -387,7 +387,7 @@ add_values(
                        for ( j = 0; a->a_vals[j] != NULL; j++ ) {
                                int match;
                                int rc = value_match( &match, mod->sm_desc, mr,
-                                       SLAP_MR_MODIFY_MATCHING,
+                                       SLAP_MR_VALUE_SYNTAX_MATCH,
                                        a->a_vals[j], asserted, &text );
 
                                if( rc == LDAP_SUCCESS && match == 0 ) {
@@ -474,7 +474,7 @@ delete_values(
                for ( j = 0; a->a_vals[j] != NULL; j++ ) {
                        int match;
                        int rc = value_match( &match, mod->sm_desc, mr,
-                               SLAP_MR_MODIFY_MATCHING,
+                               SLAP_MR_VALUE_SYNTAX_MATCH,
                                a->a_vals[j], asserted, &text );
 
                        if( rc == LDAP_SUCCESS && match != 0 ) {
index 693eba8e097af5edfc2ab51aba67991be0f5f5c3..6c24393c00217d9100e7e5054a74207cd0913f13 100644 (file)
@@ -302,10 +302,7 @@ static int compare_entry(
        {
                rc = LDAP_COMPARE_FALSE;
 
-               if ( value_find_ex( ava->aa_desc,
-                       SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
-                       a->a_vals, ava->aa_value ) == 0 )
-               {
+               if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) {
                        rc = LDAP_COMPARE_TRUE;
                        break;
                }
index 3f5ec48ab916303531336256be802d506b300ec2..43fd3e84c93cbc18390e938ec0946bc7275ee5d7 100644 (file)
@@ -255,7 +255,7 @@ static int test_mra_filter(
                        const char *text;
 
                        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,
                                &text );
 
@@ -327,7 +327,7 @@ test_ava_filter(
                        const char *text;
 
                        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,
                                &text );
 
@@ -514,7 +514,7 @@ test_substrings_filter(
                        const char *text;
 
                        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,
                                &text );
 
index ab0999850e2ca1b1c7334872a2b55c89f797f69c..3a836707ed367e27a7f859959851c60f882ffbff 100644 (file)
@@ -783,13 +783,15 @@ LDAP_SLAPD_F (int) value_match LDAP_P((
        struct berval *v1,
        void *v2,
        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((
        AttributeDescription *ad,
        unsigned flags,
        struct berval **values,
        struct berval *value ));
-#define value_find(ad, values, value)  ( value_find_ex(ad,0,values,value ) )
-LDAP_SLAPD_F (int) value_add LDAP_P(( struct berval ***vals, struct berval **addvals ));
+LDAP_SLAPD_F (int) value_add LDAP_P((
+       struct berval ***vals,
+       struct berval **addvals ));
 
 /*
  * user.c
index 9ae8843b22799144f376a09e933a6d597ad88b09..e34914c15b371e6d043798006b6747b1420aacaf 100644 (file)
@@ -53,7 +53,7 @@ objectClassMatch(
                return SLAPD_COMPARE_UNDEFINED;
        }
 
-       if( flags & SLAP_MR_MODIFY_MATCHING ) {
+       if( SLAP_IS_MR_VALUE_SYNTAX_MATCH( flags ) ) {
                *matchp = ( asserted != oc );
        } else {
                *matchp = !is_object_subclass( asserted, oc );
index 84649445e271b5acb1aaa051b1b886f11b822d7a..29b3c0ced3c55aabb01cc24a963c32e42608ef2b 100644 (file)
@@ -343,10 +343,28 @@ typedef struct slap_matching_rule {
 #define SLAP_MR_SUBSTR_ANY             ( SLAP_MR_SUBSTR | 0x0020U )
 #define SLAP_MR_SUBSTR_FINAL   ( SLAP_MR_SUBSTR | 0x0040U )
 
-/* this is used to kludge objectClass testing */
-#define SLAP_MR_MODIFY_MATCHING 0x0001U
-/* are we matching from a mr asserted value or a real value */
-#define SLAP_MR_VALUE_IS_IN_MR_SYNTAX  0x0002U
+/*
+ * normally the provided value is expected to conform to
+ * assertion syntax specified in the matching rule, however
+ * 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;
        slap_mr_convert_func    *smr_convert;
index c73807cebfd886f867e06c713f70765b974c412c..88768204bd93005a6f42dcad654a17ca07f7d5c4 100644 (file)
@@ -148,12 +148,16 @@ value_match(
                }
        }
 
-       if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) &&
-            mr->smr_convert ) {
-               rc = (mr->smr_convert)(v2,&nv2);
+       if ( SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( flags ) &&
+               mr->smr_convert )
+       {
+               rc = (mr->smr_convert)( v2, &nv2 );
                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,
@@ -185,12 +189,16 @@ int value_find_ex(
        }
 
        /* Take care of this here or ssyn_normalize later will hurt */
-       if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) &&
-            mr->smr_convert ) {
-               rc = (mr->smr_convert)(val,&nval);
+       if ( SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( flags )
+               && mr->smr_convert )
+       {
+               rc = (mr->smr_convert)( val, &nval );
                if ( rc != LDAP_SUCCESS ) {
                        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 ) {
@@ -209,9 +217,7 @@ int value_find_ex(
                int match;
                const char *text;
 
-               /* We did convert, so keep value_match from trying */
-               rc = value_match( &match, ad, mr,
-                       flags & !SLAP_MR_VALUE_IS_IN_MR_SYNTAX,
+               rc = value_match( &match, ad, mr, flags,
                        vals[i], nval == NULL ? val : nval, &text );
 
                if( rc == LDAP_SUCCESS && match == 0 ) {