}
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;
}
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((
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' "
{"( 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},
#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;
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
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 )
{
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;