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 */
21 static void oc_usage(void);
22 static void at_usage(void);
24 static char *const err2text[] = {
27 "ObjectClass not found",
28 "user-defined ObjectClass includes operational attributes",
29 "user-defined ObjectClass has inappropriate SUPerior",
30 "Duplicate objectClass",
31 "AttributeType not found",
32 "AttributeType inappropriate matching rule",
33 "AttributeType inappropriate USAGE",
34 "AttributeType inappropriate SUPerior",
35 "AttributeType SYNTAX or SUPerior required",
36 "Duplicate attributeType",
37 "MatchingRule not found",
38 "MatchingRule incomplete",
39 "Duplicate matchingRule",
41 "Duplicate ldapSyntax",
42 "OID or name required",
43 "Qualifier not supported",
45 "OID could not be expanded",
46 "Duplicate Content Rule",
47 "Content Rule not for STRUCTURAL object class",
48 "Content Rule AUX contains inappropriate object class",
49 "Content Rule attribute type list contains duplicate"
55 if ( code < 0 || SLAP_SCHERR_LAST <= code ) {
56 return "Unknown error";
58 return err2text[code];
62 /* check schema descr validity */
63 int slap_valid_descr( const char *descr )
67 if( !DESC_LEADCHAR( descr[i] ) ) {
72 if( !DESC_CHAR( descr[i] ) ) {
83 /* String compare with delimiter check. Return 0 if not
84 * matched, otherwise return length matched.
87 dscompare(const char *s1, const char *s2, char delim)
89 const char *orig = s1;
90 while (*s1++ == *s2++)
94 if (!*s1 && (!*s2 || *s2 == delim))
103 "DITContentRuleDescription = \"(\" whsp\n"
104 " numericoid whsp ; StructuralObjectClass identifier\n"
105 " [ \"NAME\" qdescrs ]\n"
106 " [ \"DESC\" qdstring ]\n"
107 " [ \"OBSOLETE\" whsp ]\n"
108 " [ \"AUX\" oids ] ; Auxiliary ObjectClasses\n"
109 " [ \"MUST\" oids ] ; AttributeTypes\n"
110 " [ \"MAY\" oids ] ; AttributeTypes\n"
111 " [ \"NOT\" oids ] ; AttributeTypes\n"
127 cr = ldap_str2contentrule(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
129 fprintf( stderr, "%s: line %d: %s before %s\n",
130 fname, lineno, ldap_scherr2str(code), err );
135 if ( cr->cr_oid == NULL ) {
137 "%s: line %d: Content rule has no OID\n",
143 code = cr_add(cr,1,&err);
145 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
146 fname, lineno, scherr2str(code), err);
166 oc = ldap_str2objectclass(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
168 fprintf( stderr, "%s: line %d: %s before %s\n",
169 fname, lineno, ldap_scherr2str(code), err );
174 if ( oc->oc_oid == NULL ) {
176 "%s: line %d: objectclass has no OID\n",
182 code = oc_add(oc,1,&err);
184 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
185 fname, lineno, scherr2str(code), err);
197 "ObjectClassDescription = \"(\" whsp\n"
198 " numericoid whsp ; ObjectClass identifier\n"
199 " [ \"NAME\" qdescrs ]\n"
200 " [ \"DESC\" qdstring ]\n"
201 " [ \"OBSOLETE\" whsp ]\n"
202 " [ \"SUP\" oids ] ; Superior ObjectClasses\n"
203 " [ ( \"ABSTRACT\" / \"STRUCTURAL\" / \"AUXILIARY\" ) whsp ]\n"
204 " ; default structural\n"
205 " [ \"MUST\" oids ] ; AttributeTypes\n"
206 " [ \"MAY\" oids ] ; AttributeTypes\n"
213 fprintf( stderr, "%s%s%s",
214 "AttributeTypeDescription = \"(\" whsp\n"
215 " numericoid whsp ; AttributeType identifier\n"
216 " [ \"NAME\" qdescrs ] ; name used in AttributeType\n"
217 " [ \"DESC\" qdstring ] ; description\n"
218 " [ \"OBSOLETE\" whsp ]\n"
219 " [ \"SUP\" woid ] ; derived from this other\n"
220 " ; AttributeType\n",
221 " [ \"EQUALITY\" woid ] ; Matching Rule name\n"
222 " [ \"ORDERING\" woid ] ; Matching Rule name\n"
223 " [ \"SUBSTR\" woid ] ; Matching Rule name\n"
224 " [ \"SYNTAX\" whsp noidlen whsp ] ; see section 4.3\n"
225 " [ \"SINGLE-VALUE\" whsp ] ; default multi-valued\n"
226 " [ \"COLLECTIVE\" whsp ] ; default not collective\n",
227 " [ \"NO-USER-MODIFICATION\" whsp ]; default user modifiable\n"
228 " [ \"USAGE\" whsp AttributeUsage ]; default userApplications\n"
229 " ; userApplications\n"
230 " ; directoryOperation\n"
231 " ; distributedOperation\n"
244 LDAPAttributeType *at;
248 at = ldap_str2attributetype( line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
250 fprintf( stderr, "%s: line %d: %s before %s\n",
251 fname, lineno, ldap_scherr2str(code), err );
256 if ( at->at_oid == NULL ) {
258 "%s: line %d: attributeType has no OID\n",
264 /* operational attributes should be defined internally */
265 if ( at->at_usage ) {
266 fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
267 fname, lineno, at->at_oid );
271 code = at_add(at,&err);
273 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
274 fname, lineno, scherr2str(code), err);