]> git.sur5r.net Git - openldap/commitdiff
SLAPD_SCHEMA_NOT_COMPAT: add framework for substr value normalization
authorKurt Zeilenga <kurt@openldap.org>
Wed, 17 May 2000 20:29:26 +0000 (20:29 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 17 May 2000 20:29:26 +0000 (20:29 +0000)
Calls value_normalize per substr component (like old code),
likely should have/call substr_normalize which takes all components
at once (to allow more sophisticated normalization)

servers/slapd/filter.c
servers/slapd/slap.h

index fac3aee18dfc5d1d34d0a86ab00fbff120c7da2f..7157aa3d9805f5fbfc116098a292f62fc6114c49 100644 (file)
@@ -429,6 +429,8 @@ get_substring_filter(
        for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
            tag = ber_next_element( ber, &len, last ) )
        {
+               unsigned usage;
+
                rc = ber_scanf( ber, "O", &val );
                if ( rc == LBER_ERROR ) {
                        rc = SLAPD_DISCONNECT;
@@ -441,15 +443,47 @@ get_substring_filter(
                        goto return_error;
                } 
 
-               rc = LDAP_PROTOCOL_ERROR;
+#ifdef SLAPD_SCHEMA_NOT_COMPAT
+               switch ( tag ) {
+               case LDAP_SUBSTRING_INITIAL:
+                       usage = SLAP_MR_SUBSTR_INITIAL;
+                       break;
+
+               case LDAP_SUBSTRING_ANY:
+                       usage = SLAP_MR_SUBSTR_ANY;
+                       break;
+
+               case LDAP_SUBSTRING_FINAL:
+                       usage = SLAP_MR_SUBSTR_FINAL;
+                       break;
+
+               default:
+                       rc = LDAP_PROTOCOL_ERROR;
+
+                       Debug( LDAP_DEBUG_FILTER,
+                               "  unknown substring choice=%ld\n",
+                               (long) tag, 0, 0 );
+
+                       ber_bvfree( val );
+                       goto return_error;
+               }
+
+               rc = value_normalize( f->f_sub_desc, usage, val, text );
+
+               if( rc != LDAP_SUCCESS ) {
+                       ber_bvfree( val );
+                       goto return_error;
+               }
+#else
 
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
                /* we should call a substring syntax normalization routine */
                value_normalize( val->bv_val, syntax );
                /* this is bogus, value_normalize should take a berval */
                val->bv_len = strlen( val->bv_val );
 #endif
 
+               rc = LDAP_PROTOCOL_ERROR;
+
                switch ( tag ) {
                case LDAP_SUBSTRING_INITIAL:
                        Debug( LDAP_DEBUG_FILTER, "  INITIAL\n", 0, 0, 0 );
@@ -457,6 +491,8 @@ get_substring_filter(
                                ber_bvfree( val );
                                goto return_error;
                        }
+
+
                        f->f_sub_initial = val;
 
                        if( fstr ) {
index 6c0637a213129ecc8957518ac5248e0bf7c18df1..69b541c53710b9957f54470329fa5434563ad562 100644 (file)
@@ -205,12 +205,21 @@ typedef int slap_mr_filter_func LDAP_P((
 typedef struct slap_matching_rule {
        LDAP_MATCHING_RULE              smr_mrule;
        unsigned                                smr_usage;
-#define SLAP_MR_NONE           0x00U
-#define SLAP_MR_EQUALITY       0x01U
-#define SLAP_MR_APPROX         0x02U
-#define SLAP_MR_ORDERING       0x04U
-#define SLAP_MR_SUBSTR         0x08U
-#define SLAP_MR_EXT                    0x10U
+
+#define SLAP_MR_TYPE_MASK              0xFF00U
+#define SLAP_MR_SUBTYPE_MASK   0x00FFU
+
+#define SLAP_MR_NONE                   0x0000U
+#define SLAP_MR_EQUALITY               0x0100U
+#define SLAP_MR_APPROX                 0x0200U
+#define SLAP_MR_ORDERING               0x0400U
+#define SLAP_MR_SUBSTR                 0x0800U
+#define SLAP_MR_EXT                            0x1000U
+
+#define SLAP_MR_SUBSTR_INITIAL (SLAP_MR_SUBSTR | 0x0001U )
+#define SLAP_MR_SUBSTR_ANY             (SLAP_MR_SUBSTR | 0x0002U )
+#define SLAP_MR_SUBSTR_FINAL   (SLAP_MR_SUBSTR | 0x0004U )
+
        Syntax                                  *smr_syntax;
        slap_mr_convert_func    *smr_convert;
        slap_mr_normalize_func  *smr_normalize;