]> git.sur5r.net Git - openldap/commitdiff
SLAPD_SCHEMA_NOT_COMPAT:
authorKurt Zeilenga <kurt@openldap.org>
Wed, 24 May 2000 22:20:03 +0000 (22:20 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 24 May 2000 22:20:03 +0000 (22:20 +0000)
Add syntax normalizer, separate from matching rule normalizer.
with mr normalizer defaulting to syntax normalizer.  This allows
for more consistent handling of some syntaxes, such as directoryString
(where all matches should ignore leading, trailing, and other extra
spaces).

servers/slapd/proto-slap.h
servers/slapd/schema_init.c
servers/slapd/syntax.c
servers/slapd/value.c

index 31a4d13573fe697e5052ceb4ce2906d65c1b9bc2..63a24f7cda70ff8582bdfbd5d9bd4994eed5c0e4 100644 (file)
@@ -572,13 +572,25 @@ LIBSLAPD_F (int) oc_add LDAP_P((LDAP_OBJECT_CLASS *oc, const char **err));
 
 LIBSLAPD_F (Syntax *) syn_find LDAP_P((const char *synname));
 LIBSLAPD_F (Syntax *) syn_find_desc LDAP_P((const char *syndesc, int *slen));
+#ifdef SLAPD_BINARY_CONVERSION
 LIBSLAPD_F (int) syn_add LDAP_P((
        LDAP_SYNTAX *syn,
        unsigned flags,
        slap_syntax_validate_func *validate,
+       slap_syntax_transform_func *normalize,
+       slap_syntax_transform_func *pretty,
        slap_syntax_transform_func *ber2str,
        slap_syntax_transform_func *str2ber,
        const char **err));
+#else
+LIBSLAPD_F (int) syn_add LDAP_P((
+       LDAP_SYNTAX *syn,
+       unsigned flags,
+       slap_syntax_validate_func *validate,
+       slap_syntax_transform_func *normalize,
+       slap_syntax_transform_func *pretty,
+       const char **err));
+#endif
 
 LIBSLAPD_F (MatchingRule *) mr_find LDAP_P((const char *mrname));
 LIBSLAPD_F (int) mr_add LDAP_P((LDAP_MATCHING_RULE *mr,
index ad9bf48a5e7e35a5566caf4868fcd38d5e87caf8..bc9b601afb594b92c319bf25dbb2e58149ffd160 100644 (file)
@@ -54,9 +54,7 @@ UTF8StringValidate(
 
 static int
 UTF8StringNormalize(
-       unsigned use,
        Syntax *syntax,
-       MatchingRule *mr,
        struct berval *val,
        struct berval **normalized )
 {
@@ -237,9 +235,7 @@ IA5StringConvert(
 
 static int
 IA5StringNormalize(
-       unsigned use,
        Syntax *syntax,
-       MatchingRule *mr,
        struct berval *val,
        struct berval **normalized )
 {
@@ -353,8 +349,12 @@ struct syntax_defs_rec {
        char *sd_desc;
        int sd_flags;
        slap_syntax_validate_func *sd_validate;
+       slap_syntax_transform_func *sd_normalize;
+       slap_syntax_transform_func *sd_pretty;
+#ifdef SLAPD_BINARY_CONVERSION
        slap_syntax_transform_func *sd_ber2str;
        slap_syntax_transform_func *sd_str2ber;
+#endif
 };
 
 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
@@ -393,7 +393,7 @@ struct syntax_defs_rec syntax_defs[] = {
        {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
-               0, UTF8StringValidate, NULL, NULL},
+               0, UTF8StringValidate, UTF8StringNormalize, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
@@ -413,7 +413,7 @@ struct syntax_defs_rec syntax_defs[] = {
        {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
-               0, IA5StringValidate, NULL, NULL},
+               0, IA5StringValidate, IA5StringNormalize, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
                0, integerValidate, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
@@ -558,33 +558,33 @@ struct mrule_defs_rec mrule_defs[] = {
        {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
                SLAP_MR_EQUALITY | SLAP_MR_EXT,
-               NULL, UTF8StringNormalize, caseIgnoreMatch, NULL, NULL},
+               NULL, NULL, caseIgnoreMatch, NULL, NULL},
 
        {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
                SLAP_MR_ORDERING,
-               NULL, UTF8StringNormalize, caseIgnoreOrderingMatch, NULL, NULL},
+               NULL, NULL, caseIgnoreOrderingMatch, NULL, NULL},
 
        {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
                SLAP_MR_SUBSTR | SLAP_MR_EXT,
-               NULL, UTF8StringNormalize, caseIgnoreSubstringsMatch, NULL, NULL},
+               NULL, NULL, caseIgnoreSubstringsMatch, NULL, NULL},
 
        /* Next three are not in the RFC's, but are needed for compatibility */
        {"( 2.5.13.5 NAME 'caseExactMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
                SLAP_MR_EQUALITY | SLAP_MR_EXT,
-               NULL, UTF8StringNormalize, caseExactMatch, NULL, NULL},
+               NULL, NULL, caseExactMatch, NULL, NULL},
 
        {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
                SLAP_MR_ORDERING,
-               NULL, UTF8StringNormalize, caseExactOrderingMatch, NULL, NULL},
+               NULL, NULL, caseExactOrderingMatch, NULL, NULL},
 
        {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
                SLAP_MR_SUBSTR | SLAP_MR_EXT,
-               NULL, UTF8StringNormalize, caseExactSubstringsMatch, NULL, NULL},
+               NULL, NULL, caseExactSubstringsMatch, NULL, NULL},
 
        {"( 2.5.13.8 NAME 'numericStringMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
@@ -669,17 +669,17 @@ struct mrule_defs_rec mrule_defs[] = {
        {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
                SLAP_MR_EQUALITY | SLAP_MR_EXT,
-               NULL, IA5StringNormalize, caseExactIA5Match, NULL, NULL},
+               NULL, NULL, caseExactIA5Match, NULL, NULL},
 
        {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
                SLAP_MR_EQUALITY | SLAP_MR_EXT,
-               NULL, IA5StringNormalize, caseIgnoreIA5Match, NULL, NULL},
+               NULL, NULL, caseIgnoreIA5Match, NULL, NULL},
 
        {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
                SLAP_MR_SUBSTR,
-               NULL, IA5StringNormalize, caseIgnoreIA5SubstringsMatch, NULL, NULL},
+               NULL, NULL, caseIgnoreIA5SubstringsMatch, NULL, NULL},
 
        {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
 };
@@ -699,8 +699,14 @@ schema_init( void )
                res = register_syntax( syntax_defs[i].sd_desc,
                    syntax_defs[i].sd_flags,
                    syntax_defs[i].sd_validate,
+                   syntax_defs[i].sd_normalize,
+                       syntax_defs[i].sd_pretty
+#ifdef SLAPD_BINARY_CONVERSION
+                       ,
                    syntax_defs[i].sd_ber2str,
-                       syntax_defs[i].sd_str2ber );
+                       syntax_defs[i].sd_str2ber
+#endif
+               );
 
                if ( res ) {
                        fprintf( stderr, "schema_init: Error registering syntax %s\n",
index 51c503acc21c22c977aea3f9e33a9687a40ee363..b38de39055153fced36fa478341c8f32b2875a4e 100644 (file)
@@ -104,8 +104,12 @@ syn_add(
     LDAP_SYNTAX                *syn,
        unsigned flags,
     slap_syntax_validate_func  *validate,
+    slap_syntax_transform_func *normalize,
+    slap_syntax_transform_func *pretty,
+#ifdef SLAPD_BINARY_CONVERSION
     slap_syntax_transform_func *ber2str,
     slap_syntax_transform_func *str2ber,
+#endif
     const char         **err
 )
 {
@@ -120,6 +124,8 @@ syn_add(
 
        ssyn->ssyn_flags = flags;
        ssyn->ssyn_validate = validate;
+       ssyn->ssyn_normalize = normalize;
+       ssyn->ssyn_pretty = pretty;
 
 #ifdef SLAPD_BINARY_CONVERSION
        ssyn->ssyn_ber2str = ber2str;
index 21ec4e067e39df46b91ddbb7fd13ac49ec8e1029..b90141434099c27a6787e3a5fbfc36ea102a2aa7 100644 (file)
@@ -138,6 +138,16 @@ value_normalize(
                        return LDAP_INVALID_SYNTAX;
                }
 
+       } else if ( mr->smr_syntax->ssyn_normalize ) {
+               rc = (mr->smr_syntax->ssyn_normalize)(
+                       ad->ad_type->sat_syntax,
+                       in, out );
+
+               if( rc != LDAP_SUCCESS ) {
+                       *text = "unable to normalize value";
+                       return LDAP_INVALID_SYNTAX;
+               }
+
        } else {
                *out = ber_bvdup( in );
        }