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[SLAP_SCHERR_LAST+1] = {
27 "ObjectClass not found",
28 "ObjectClass inappropriate SUPerior",
29 "AttributeType not found",
30 "AttributeType inappropriate USAGE",
31 "Duplicate objectClass",
32 "Duplicate attributeType",
33 "Duplicate ldapSyntax",
34 "Duplicate matchingRule",
35 "OID or name required",
36 "SYNTAX or SUPerior required",
37 "MatchingRule not found",
40 "Qualifier not supported",
42 "OID could not be expanded"
48 if ( code < 0 || code >= (sizeof(err2text)/sizeof(char *)) ) {
49 return "Unknown error";
51 return err2text[code];
55 /* check schema descr validity */
56 int slap_valid_descr( const char *descr )
60 if( !DESC_LEADCHAR( descr[i] ) ) {
65 if( !DESC_CHAR( descr[i] ) ) {
76 /* String compare with delimiter check. Return 0 if not
77 * matched, otherwise return length matched.
80 dscompare(const char *s1, const char *s2, char delim)
82 const char *orig = s1;
83 while (*s1++ == *s2++)
87 if (!*s1 && (!*s2 || *s2 == delim))
105 oc = ldap_str2objectclass(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
107 fprintf( stderr, "%s: line %d: %s before %s\n",
108 fname, lineno, ldap_scherr2str(code), err );
113 if ( oc->oc_oid == NULL ) {
115 "%s: line %d: objectclass has no OID\n",
121 code = oc_add(oc,&err);
123 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
124 fname, lineno, scherr2str(code), err);
136 "ObjectClassDescription = \"(\" whsp\n"
137 " numericoid whsp ; ObjectClass identifier\n"
138 " [ \"NAME\" qdescrs ]\n"
139 " [ \"DESC\" qdstring ]\n"
140 " [ \"OBSOLETE\" whsp ]\n"
141 " [ \"SUP\" oids ] ; Superior ObjectClasses\n"
142 " [ ( \"ABSTRACT\" / \"STRUCTURAL\" / \"AUXILIARY\" ) whsp ]\n"
143 " ; default structural\n"
144 " [ \"MUST\" oids ] ; AttributeTypes\n"
145 " [ \"MAY\" oids ] ; AttributeTypes\n"
154 "AttributeTypeDescription = \"(\" whsp\n"
155 " numericoid whsp ; AttributeType identifier\n"
156 " [ \"NAME\" qdescrs ] ; name used in AttributeType\n"
157 " [ \"DESC\" qdstring ] ; description\n"
158 " [ \"OBSOLETE\" whsp ]\n"
159 " [ \"SUP\" woid ] ; derived from this other\n"
161 " [ \"EQUALITY\" woid ] ; Matching Rule name\n"
162 " [ \"ORDERING\" woid ] ; Matching Rule name\n"
163 " [ \"SUBSTR\" woid ] ; Matching Rule name\n"
164 " [ \"SYNTAX\" whsp noidlen whsp ] ; see section 4.3\n"
165 " [ \"SINGLE-VALUE\" whsp ] ; default multi-valued\n"
166 " [ \"COLLECTIVE\" whsp ] ; default not collective\n"
167 " [ \"NO-USER-MODIFICATION\" whsp ]; default user modifiable\n"
168 " [ \"USAGE\" whsp AttributeUsage ]; default userApplications\n"
169 " ; userApplications\n"
170 " ; directoryOperation\n"
171 " ; distributedOperation\n"
184 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);