]> git.sur5r.net Git - openldap/commitdiff
allow array of more generic syntaxes
authorPierangelo Masarati <ando@openldap.org>
Wed, 16 May 2007 09:13:14 +0000 (09:13 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 16 May 2007 09:13:14 +0000 (09:13 +0000)
servers/slapd/at.c
servers/slapd/proto-slap.h
servers/slapd/schema_init.c
servers/slapd/slap.h
servers/slapd/syntax.c

index afb34894c2391f5cc9da8366a118ce8af97b64ca..e70f10e969ba1eaaa5a1e59fec80366a3c6fdb82 100644 (file)
@@ -755,12 +755,8 @@ at_add(
                }
 
                if ( sat->sat_syntax != NULL && sat->sat_syntax != syn ) {
-                       Syntax *supsyn = syn->ssyn_sup;
-
-                       for ( ; supsyn && supsyn != sat->sat_syntax; 
-                               supsyn = supsyn->ssyn_sup )
-                               ;
-                       if ( supsyn == NULL ) {
+                       /* BEWARE: no loop detection! */
+                       if ( syn_is_sup( sat->sat_syntax, syn ) ) {
                                code = SLAP_SCHERR_ATTR_BAD_SUP;
                                goto error_return;
                        }
index 83f68c3a70231e5ffd9f200184ca6b006aac4f7b..db194b0ce655e84df566ba587513660f7b1515ff 100644 (file)
@@ -1674,6 +1674,9 @@ LDAP_SLAPD_F (int)  syncrepl_add_glue LDAP_P((
 LDAP_SLAPD_F (void) syncinfo_free LDAP_P(( struct syncinfo_s *, int all ));
 
 /* syntax.c */
+LDAP_SLAPD_F (int) syn_is_sup LDAP_P((
+       Syntax *syn,
+       Syntax *sup ));
 LDAP_SLAPD_F (Syntax *) syn_find LDAP_P((
        const char *synname ));
 LDAP_SLAPD_F (Syntax *) syn_find_desc LDAP_P((
index afa686eb1bc167b48b873d187e8f45d60f2a568c..12ec8a8e1d3cd8579908870f9ed9c4d757538a9e 100644 (file)
@@ -4005,6 +4005,12 @@ firstComponentNormalize(
        return rc;
 }
 
+static char *country_gen_syn[] = {
+       "1.3.6.1.4.1.1466.115.121.1.15",
+       "1.3.6.1.4.1.1466.115.121.1.26",
+       "1.3.6.1.4.1.1466.115.121.1.44",
+       NULL
+};
 
 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
@@ -4115,12 +4121,11 @@ static slap_syntax_defs_rec syntax_defs[] = {
        {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
-               0, "1.3.6.1.4.1.1466.115.121.1.15",
-               printableStringValidate, NULL},
-       /* moved here because now depends on printable string */
+               0, NULL, printableStringValidate, NULL},
+       /* moved here because now depends on Directory String, IA5 String 
+        * and Printable String */
        {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
-               0, "1.3.6.1.4.1.1466.115.121.1.44",
-               countryStringValidate, NULL},
+               0, country_gen_syn, countryStringValidate, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' )",
 #define subtreeSpecificationValidate UTF8StringValidate /* FIXME */
                0, NULL, subtreeSpecificationValidate, NULL},
index 0ba6f6bb65f5eb6c5a5aba6a52918ee11d97a6c8..4a37dd4d02dd4fce12f7bf720a164bb1ce75e17a 100644 (file)
@@ -409,7 +409,7 @@ struct Syntax {
 #define SLAP_SYNTAX_HIDE       0x8000U /* hide (do not publish) */
 #endif
 
-       Syntax                          *ssyn_sup;
+       Syntax                          **ssyn_sups;
 
        slap_syntax_validate_func       *ssyn_validate;
        slap_syntax_transform_func      *ssyn_pretty;
@@ -436,7 +436,7 @@ struct Syntax {
 typedef struct slap_syntax_defs_rec {
        char *sd_desc;
        int sd_flags;
-       char *sd_sup;
+       char **sd_sups;
        slap_syntax_validate_func *sd_validate;
        slap_syntax_transform_func *sd_pretty;
 #ifdef SLAPD_BINARY_CONVERSION
index ab18b18795a5611175f4c74f97ec43c1a1043390..b289dd1f65b8469b83833c70ca1d9a377412590a 100644 (file)
@@ -76,6 +76,35 @@ syn_find_desc( const char *syndesc, int *len )
        return( NULL );
 }
 
+int
+syn_is_sup( Syntax *syn, Syntax *sup )
+{
+       int     i;
+
+       assert( syn != NULL );
+       assert( sup != NULL );
+
+       if ( syn == sup ) {
+               return 1;
+       }
+
+       if ( syn->ssyn_sups == NULL ) {
+               return 0;
+       }
+
+       for ( i = 0; syn->ssyn_sups[i]; i++ ) {
+               if ( syn->ssyn_sups[i] == sup ) {
+                       return 1;
+               }
+
+               if ( syn_is_sup( syn->ssyn_sups[i], sup ) ) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
 void
 syn_destroy( void )
 {
@@ -156,16 +185,26 @@ syn_add(
        ssyn->ssyn_str2ber = def->sd_str2ber;
 #endif
 
-       if ( def->sd_sup != NULL ) {
-               ssyn->ssyn_sup = syn_find( def->sd_sup );
-               if ( ssyn->ssyn_sup == NULL ) {
-                       *err = def->sd_sup;
-                       code = SLAP_SCHERR_SYN_SUP_NOT_FOUND;
+       if ( def->sd_sups != NULL ) {
+               int     cnt;
+
+               for ( cnt = 0; def->sd_sups[cnt] != NULL; cnt++ )
+                       ;
+               
+               ssyn->ssyn_sups = (Syntax **)SLAP_CALLOC( cnt + 1,
+                       sizeof(Syntax) );
+
+               for ( cnt = 0; def->sd_sups[cnt] != NULL; cnt++ ) {
+                       ssyn->ssyn_sups[cnt] = syn_find( def->sd_sups[cnt] );
+                       if ( ssyn->ssyn_sups[cnt] == NULL ) {
+                               *err = def->sd_sups[cnt];
+                               code = SLAP_SCHERR_SYN_SUP_NOT_FOUND;
+                       }
                }
        }
 
        if ( code == 0 ) {
-               code = syn_insert(ssyn, err);
+               code = syn_insert( ssyn, err );
        }
 
        return code;