1 /* schemaparse.c - routines to parse config file objectclass definitions */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
17 #include "ldap_schema.h"
19 int global_schemacheck = 1; /* schemacheck ON is default */
20 int global_add_rdn_values = 0; /* bail out if rdn values do not match entry values is default */
22 static void oc_usage(void);
23 static void at_usage(void);
25 static char *const err2text[] = {
28 "ObjectClass not found",
29 "user-defined ObjectClass includes operational attributes",
30 "user-defined ObjectClass has inappropriate SUPerior",
31 "Duplicate objectClass",
32 "AttributeType not found",
33 "AttributeType inappropriate matching rule",
34 "AttributeType inappropriate USAGE",
35 "AttributeType inappropriate SUPerior",
36 "AttributeType SYNTAX or SUPerior required",
37 "Duplicate attributeType",
38 "MatchingRule not found",
39 "MatchingRule incomplete",
40 "Duplicate matchingRule",
42 "Duplicate ldapSyntax",
43 "OID or name required",
44 "Qualifier not supported",
46 "OID could not be expanded",
47 "Duplicate Content Rule",
48 "Content Rule not for STRUCTURAL object class",
49 "Content Rule AUX contains non-AUXILIARY object class"
50 "Content Rule attribute type list contains duplicate"
56 if ( code < 0 || SLAP_SCHERR_LAST <= code ) {
57 return "Unknown error";
59 return err2text[code];
63 /* check schema descr validity */
64 int slap_valid_descr( const char *descr )
68 if( !DESC_LEADCHAR( descr[i] ) ) {
73 if( !DESC_CHAR( descr[i] ) ) {
84 /* String compare with delimiter check. Return 0 if not
85 * matched, otherwise return length matched.
88 dscompare(const char *s1, const char *s2, char delim)
90 const char *orig = s1;
91 while (*s1++ == *s2++)
95 if (!*s1 && (!*s2 || *s2 == delim))
100 #ifdef SLAP_EXTENDED_SCHEMA
106 "DITContentRuleDescription = \"(\" whsp\n"
107 " numericoid whsp ; StructuralObjectClass identifier\n"
108 " [ \"NAME\" qdescrs ]\n"
109 " [ \"DESC\" qdstring ]\n"
110 " [ \"OBSOLETE\" whsp ]\n"
111 " [ \"AUX\" oids ] ; Auxiliary ObjectClasses\n"
112 " [ \"MUST\" oids ] ; AttributeTypes\n"
113 " [ \"MAY\" oids ] ; AttributeTypes\n"
114 " [ \"NOT\" oids ] ; AttributeTypes\n"
130 cr = ldap_str2contentrule(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
132 fprintf( stderr, "%s: line %d: %s before %s\n",
133 fname, lineno, ldap_scherr2str(code), err );
138 if ( cr->cr_oid == NULL ) {
140 "%s: line %d: Content rule has no OID\n",
146 code = cr_add(cr,1,&err);
148 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
149 fname, lineno, scherr2str(code), err);
171 oc = ldap_str2objectclass(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
173 fprintf( stderr, "%s: line %d: %s before %s\n",
174 fname, lineno, ldap_scherr2str(code), err );
179 if ( oc->oc_oid == NULL ) {
181 "%s: line %d: objectclass has no OID\n",
187 code = oc_add(oc,1,&err);
189 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
190 fname, lineno, scherr2str(code), err);
202 "ObjectClassDescription = \"(\" whsp\n"
203 " numericoid whsp ; ObjectClass identifier\n"
204 " [ \"NAME\" qdescrs ]\n"
205 " [ \"DESC\" qdstring ]\n"
206 " [ \"OBSOLETE\" whsp ]\n"
207 " [ \"SUP\" oids ] ; Superior ObjectClasses\n"
208 " [ ( \"ABSTRACT\" / \"STRUCTURAL\" / \"AUXILIARY\" ) whsp ]\n"
209 " ; default structural\n"
210 " [ \"MUST\" oids ] ; AttributeTypes\n"
211 " [ \"MAY\" oids ] ; AttributeTypes\n"
219 "AttributeTypeDescription = \"(\" whsp\n"
220 " numericoid whsp ; AttributeType identifier\n"
221 " [ \"NAME\" qdescrs ] ; name used in AttributeType\n"
222 " [ \"DESC\" qdstring ] ; description\n"
223 " [ \"OBSOLETE\" whsp ]\n"
224 " [ \"SUP\" woid ] ; derived from this other\n"
226 " [ \"EQUALITY\" woid ] ; Matching Rule name\n"
227 " [ \"ORDERING\" woid ] ; Matching Rule name\n"
228 " [ \"SUBSTR\" woid ] ; Matching Rule name\n"
229 " [ \"SYNTAX\" whsp noidlen whsp ] ; see section 4.3\n"
230 " [ \"SINGLE-VALUE\" whsp ] ; default multi-valued\n"
231 " [ \"COLLECTIVE\" whsp ] ; default not collective\n"
232 " [ \"NO-USER-MODIFICATION\" whsp ]; default user modifiable\n"
233 " [ \"USAGE\" whsp AttributeUsage ]; default userApplications\n"
234 " ; userApplications\n"
235 " ; directoryOperation\n"
236 " ; distributedOperation\n"
249 LDAPAttributeType *at;
253 at = ldap_str2attributetype( line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
255 fprintf( stderr, "%s: line %d: %s before %s\n",
256 fname, lineno, ldap_scherr2str(code), err );
261 if ( at->at_oid == NULL ) {
263 "%s: line %d: attributeType has no OID\n",
269 /* operational attributes should be defined internally */
270 if ( at->at_usage ) {
271 fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
272 fname, lineno, at->at_oid );
276 code = at_add(at,&err);
278 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
279 fname, lineno, scherr2str(code), err);