Commit 978c3609 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

allow array of more generic syntaxes

parent eb5d285a
......@@ -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;
}
......
......@@ -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((
......
......@@ -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},
......
......@@ -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
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment