1 /* schemaparse.c - routines to parse config file objectclass definitions */
4 * Copyright 1998-2002 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[] = {
26 "ObjectClass not found",
27 "ObjectClass inappropriate SUPerior",
28 "ObjectClass operational",
29 "Duplicate objectClass",
30 "AttributeType not found",
31 "AttributeType inappropriate USAGE",
32 "AttributeType inappropriate SUPerior",
33 "AttributeType SYNTAX or SUPerior required",
34 "Duplicate attributeType",
35 "MatchingRule not found",
36 "Duplicate matchingRule",
39 "Duplicate ldapSyntax",
40 "OID or name required",
41 "Qualifier not supported",
43 "OID could not be expanded"
49 if ( code < 0 || SLAP_SCHERR_LAST < code ) {
50 return "Unknown error";
52 return err2text[code];
56 /* check schema descr validity */
57 int slap_valid_descr( const char *descr )
61 if( !DESC_LEADCHAR( descr[i] ) ) {
66 if( !DESC_CHAR( descr[i] ) ) {
77 /* String compare with delimiter check. Return 0 if not
78 * matched, otherwise return length matched.
81 dscompare(const char *s1, const char *s2, char delim)
83 const char *orig = s1;
84 while (*s1++ == *s2++)
88 if (!*s1 && (!*s2 || *s2 == delim))
106 oc = ldap_str2objectclass(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
108 fprintf( stderr, "%s: line %d: %s before %s\n",
109 fname, lineno, ldap_scherr2str(code), err );
114 if ( oc->oc_oid == NULL ) {
116 "%s: line %d: objectclass has no OID\n",
122 code = oc_add(oc,1,&err);
124 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
125 fname, lineno, scherr2str(code), err);
137 "ObjectClassDescription = \"(\" whsp\n"
138 " numericoid whsp ; ObjectClass identifier\n"
139 " [ \"NAME\" qdescrs ]\n"
140 " [ \"DESC\" qdstring ]\n"
141 " [ \"OBSOLETE\" whsp ]\n"
142 " [ \"SUP\" oids ] ; Superior ObjectClasses\n"
143 " [ ( \"ABSTRACT\" / \"STRUCTURAL\" / \"AUXILIARY\" ) whsp ]\n"
144 " ; default structural\n"
145 " [ \"MUST\" oids ] ; AttributeTypes\n"
146 " [ \"MAY\" oids ] ; AttributeTypes\n"
155 "AttributeTypeDescription = \"(\" whsp\n"
156 " numericoid whsp ; AttributeType identifier\n"
157 " [ \"NAME\" qdescrs ] ; name used in AttributeType\n"
158 " [ \"DESC\" qdstring ] ; description\n"
159 " [ \"OBSOLETE\" whsp ]\n"
160 " [ \"SUP\" woid ] ; derived from this other\n"
162 " [ \"EQUALITY\" woid ] ; Matching Rule name\n"
163 " [ \"ORDERING\" woid ] ; Matching Rule name\n"
164 " [ \"SUBSTR\" woid ] ; Matching Rule name\n"
165 " [ \"SYNTAX\" whsp noidlen whsp ] ; see section 4.3\n"
166 " [ \"SINGLE-VALUE\" whsp ] ; default multi-valued\n"
167 " [ \"COLLECTIVE\" whsp ] ; default not collective\n"
168 " [ \"NO-USER-MODIFICATION\" whsp ]; default user modifiable\n"
169 " [ \"USAGE\" whsp AttributeUsage ]; default userApplications\n"
170 " ; userApplications\n"
171 " ; directoryOperation\n"
172 " ; distributedOperation\n"
185 LDAPAttributeType *at;
189 at = ldap_str2attributetype( line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
191 fprintf( stderr, "%s: line %d: %s before %s\n",
192 fname, lineno, ldap_scherr2str(code), err );
197 if ( at->at_oid == NULL ) {
199 "%s: line %d: attributeType has no OID\n",
205 /* operational attributes should be defined internally */
206 if ( at->at_usage ) {
207 fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
208 fname, lineno, at->at_oid );
212 code = at_add(at,&err);
214 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
215 fname, lineno, scherr2str(code), err);