#define LDAP_SCHERR_DUPOPT 9
#define LDAP_SCHERR_EMPTY 10
+typedef struct ldap_schema_extension_item {
+ char *lsei_name;
+ char **lsei_values;
+} LDAP_SCHEMA_EXTENSION_ITEM;
+
typedef struct ldap_syntax {
char *syn_oid; /* REQUIRED */
char *syn_desc; /* OPTIONAL */
+ LDAP_SCHEMA_EXTENSION_ITEM **syn_extensions; /* OPTIONAL */
} LDAP_SYNTAX;
typedef struct ldap_matchingrule {
char *mr_desc; /* OPTIONAL */
int mr_obsolete; /* OPTIONAL */
char *mr_syntax_oid; /* REQUIRED */
+ LDAP_SCHEMA_EXTENSION_ITEM **mr_extensions; /* OPTIONAL */
} LDAP_MATCHING_RULE;
typedef struct ldap_attributetype {
int at_no_user_mod; /* 0=no, 1=yes */
int at_usage; /* 0=userApplications, 1=directoryOperation,
2=distributedOperation, 3=dSAOperation */
+ LDAP_SCHEMA_EXTENSION_ITEM **at_extensions; /* OPTIONAL */
} LDAP_ATTRIBUTE_TYPE;
typedef struct ldap_objectclass {
int oc_kind; /* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY */
char **oc_at_oids_must; /* OPTIONAL */
char **oc_at_oids_may; /* OPTIONAL */
+ LDAP_SCHEMA_EXTENSION_ITEM **oc_extensions; /* OPTIONAL */
} LDAP_OBJECT_CLASS;
#define LDAP_SCHEMA_NO 0
return(ret);
}
+static int
+print_extensions(safe_string *ss, LDAP_SCHEMA_EXTENSION_ITEM **extensions)
+{
+ LDAP_SCHEMA_EXTENSION_ITEM **ext;
+
+ if ( extensions ) {
+ print_whsp(ss);
+ for ( ext = extensions; *ext != NULL; ext++ ) {
+ print_literal(ss, (*ext)->lsei_name);
+ print_whsp(ss);
+ print_qdescrs(ss, (*ext)->lsei_values);
+ print_whsp(ss);
+ }
+ }
+}
+
char *
ldap_syntax2str( const LDAP_SYNTAX * syn )
{
}
print_whsp(ss);
+
+ print_extensions(ss, syn->syn_extensions);
+
print_literal(ss,")");
retstring = LDAP_STRDUP(safe_string_val(ss));
}
print_whsp(ss);
+
+ print_extensions(ss, mr->mr_extensions);
+
print_literal(ss,")");
retstring = LDAP_STRDUP(safe_string_val(ss));
}
print_whsp(ss);
+
+ print_extensions(ss, oc->oc_extensions);
+
print_literal(ss,")");
retstring = LDAP_STRDUP(safe_string_val(ss));
}
print_whsp(ss);
+
+ print_extensions(ss, at->at_extensions);
+
print_literal(ss,")");
retstring = LDAP_STRDUP(safe_string_val(ss));
}
}
+static int
+add_extension(LDAP_SCHEMA_EXTENSION_ITEM ***extensions,
+ char * name, char ** values)
+{
+ int n;
+ LDAP_SCHEMA_EXTENSION_ITEM **tmp, *ext;
+
+ ext = LDAP_CALLOC(1, sizeof(LDAP_SCHEMA_EXTENSION_ITEM));
+ if ( !ext )
+ return 1;
+ ext->lsei_name = name;
+ ext->lsei_values = values;
+
+ if ( !*extensions ) {
+ *extensions =
+ LDAP_CALLOC(2, sizeof(LDAP_SCHEMA_EXTENSION_ITEM *));
+ if ( !*extensions )
+ return 1;
+ n = 0;
+ } else {
+ for ( n=0; (*extensions)[n] != NULL; n++ )
+ ;
+ tmp = LDAP_REALLOC(*extensions,
+ (n+2)*sizeof(LDAP_SCHEMA_EXTENSION_ITEM *));
+ if ( !tmp )
+ return 1;
+ *extensions = tmp;
+ }
+ (*extensions)[n] = ext;
+ (*extensions)[n+1] = NULL;
+ return 0;
+}
+
+static void
+free_extensions(LDAP_SCHEMA_EXTENSION_ITEM **extensions)
+{
+ LDAP_SCHEMA_EXTENSION_ITEM **ext;
+
+ if ( extensions ) {
+ for ( ext = extensions; *ext != NULL; ext++ ) {
+ LDAP_FREE((*ext)->lsei_name);
+ LDAP_VFREE((*ext)->lsei_values);
+ LDAP_FREE(*ext);
+ }
+ LDAP_FREE(extensions);
+ }
+}
+
void
ldap_syntax_free( LDAP_SYNTAX * syn )
{
LDAP_FREE(syn->syn_oid);
LDAP_FREE(syn->syn_desc);
+ free_extensions(syn->syn_extensions);
LDAP_FREE(syn);
}
LDAP_VFREE(mr->mr_names);
LDAP_FREE(mr->mr_desc);
LDAP_FREE(mr->mr_syntax_oid);
+ free_extensions(mr->mr_extensions);
LDAP_FREE(mr);
}
LDAP_FREE(at->at_ordering_oid);
LDAP_FREE(at->at_substr_oid);
LDAP_FREE(at->at_syntax_oid);
+ free_extensions(at->at_extensions);
LDAP_FREE(at);
}
int seen_syntax = 0;
int seen_usage = 0;
LDAP_ATTRIBUTE_TYPE * at;
- char ** ssdummy;
+ char ** ext_vals;
const char * savepos;
if ( !s ) {
LDAP_FREE(sval);
parse_whsp(&ss);
} else if ( sval[0] == 'X' && sval[1] == '-' ) {
- LDAP_FREE(sval);
/* Should be parse_qdstrings */
- ssdummy = parse_qdescrs(&ss, code);
- if ( !ssdummy ) {
+ ext_vals = parse_qdescrs(&ss, code);
+ if ( !ext_vals ) {
*errp = ss;
ldap_attributetype_free(at);
return NULL;
}
+ if ( add_extension(&at->at_extensions,
+ sval, ext_vals) ) {
+ *code = LDAP_SCHERR_OUTOFMEM;
+ *errp = ss;
+ LDAP_FREE(sval);
+ ldap_attributetype_free(at);
+ return NULL;
+ }
} else {
*code = LDAP_SCHERR_UNEXPTOKEN;
*errp = ss;
LDAP_VFREE(oc->oc_sup_oids);
LDAP_VFREE(oc->oc_at_oids_must);
LDAP_VFREE(oc->oc_at_oids_may);
+ free_extensions(oc->oc_extensions);
LDAP_FREE(oc);
}