implement X-SUBST substitute syntax extension (ITS#5663)

This commit is contained in:
Pierangelo Masarati 2008-09-08 00:10:18 +00:00
parent 1447d7fe17
commit 0009def716
3 changed files with 45 additions and 0 deletions

View 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",

View 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,

View 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;