]> git.sur5r.net Git - openldap/commitdiff
implement X-SUBST substitute syntax extension (ITS#5663)
authorPierangelo Masarati <ando@openldap.org>
Mon, 8 Sep 2008 00:10:18 +0000 (00:10 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 8 Sep 2008 00:10:18 +0000 (00:10 +0000)
servers/slapd/schemaparse.c
servers/slapd/slap.h
servers/slapd/syntax.c

index c02fdea215f2e38c16e84f3475f0bc8df79640d0..fa9cb2ee076cdf76875c099842a2333fd0e5f7c5 100644 (file)
@@ -50,6 +50,8 @@ static char *const err2text[] = {
        "Syntax not found",
        "Duplicate ldapSyntax",
        "Superior syntax not found",
+       "Substitute syntax not specified",
+       "Substitute syntax not found",
        "OID or name required",
        "Qualifier not supported",
        "Invalid NAME",
index 95c4e898ac109f7a92885d54341f2b928e95c37f..4b5e84dfd772cd9b885dd3ee4c275c54d720cbf2 100644 (file)
@@ -300,6 +300,8 @@ enum {
        SLAP_SCHERR_SYN_NOT_FOUND,
        SLAP_SCHERR_SYN_DUP,
        SLAP_SCHERR_SYN_SUP_NOT_FOUND,
+       SLAP_SCHERR_SYN_SUBST_NOT_SPECIFIED,
+       SLAP_SCHERR_SYN_SUBST_NOT_FOUND,
        SLAP_SCHERR_NO_NAME,
        SLAP_SCHERR_NOT_SUPPORTED,
        SLAP_SCHERR_BAD_DESCR,
index 85025683ecc652998ec38f94043c65f92345a400..c7089acc4597d4919597c6fc80a59cd177d67367 100644 (file)
@@ -190,6 +190,47 @@ syn_add(
        ssyn->ssyn_str2ber = def->sd_str2ber;
 #endif
 
+       if ( def->sd_validate == NULL && def->sd_pretty == NULL && syn->syn_extensions != NULL ) {
+               LDAPSchemaExtensionItem **lsei;
+               Syntax *subst = NULL;
+
+               for ( lsei = syn->syn_extensions; *lsei != NULL; lsei++) {
+                       if ( strcmp( (*lsei)->lsei_name, "X-SUBST" ) != 0 ) {
+                               continue;
+                       }
+
+                       assert( (*lsei)->lsei_values != NULL );
+                       if ( (*lsei)->lsei_values[0] == '\0'
+                               || (*lsei)->lsei_values[1] != '\0' )
+                       {
+                               Debug( LDAP_DEBUG_ANY, "syn_add(%s): exactly one substitute syntax must be present\n",
+                                       ssyn->ssyn_syn.syn_oid, 0, 0 );
+                               return SLAP_SCHERR_SYN_SUBST_NOT_SPECIFIED;
+                       }
+
+                       subst = syn_find( (*lsei)->lsei_values[0] );
+                       if ( subst == NULL ) {
+                               Debug( LDAP_DEBUG_ANY, "syn_add(%s): substitute syntax %s not found\n",
+                                       ssyn->ssyn_syn.syn_oid, (*lsei)->lsei_values[0], 0 );
+                               return SLAP_SCHERR_SYN_SUBST_NOT_FOUND;
+                       }
+                       break;
+               }
+
+               if ( subst != NULL ) {
+                       ssyn->ssyn_flags = subst->ssyn_flags;
+                       ssyn->ssyn_validate = subst->ssyn_validate;
+                       ssyn->ssyn_pretty = subst->ssyn_pretty;
+
+                       ssyn->ssyn_sups = NULL;
+
+#ifdef SLAPD_BINARY_CONVERSION
+                       ssyn->ssyn_ber2str = subst->ssyn_ber2str;
+                       ssyn->ssyn_str2ber = subst->ssyn_str2ber;
+#endif
+               }
+       }
+
        if ( def->sd_sups != NULL ) {
                int     cnt;