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[] = {
27 "ObjectClass not found",
28 "ObjectClass inappropriate SUPerior",
29 "ObjectClass operational",
30 "Duplicate objectClass",
31 "AttributeType not found",
32 "AttributeType inappropriate USAGE",
33 "AttributeType inappropriate SUPerior",
34 "AttributeType SYNTAX or SUPerior required",
35 "Duplicate attributeType",
36 "MatchingRule not found",
37 "Duplicate matchingRule",
40 "Duplicate ldapSyntax",
41 "OID or name required",
42 "Qualifier not supported",
44 "OID could not be expanded"
50 if ( code < 0 || SLAP_SCHERR_LAST < code ) {
51 return "Unknown error";
53 return err2text[code];
57 /* check schema descr validity */
58 int slap_valid_descr( const char *descr )
62 if( !DESC_LEADCHAR( descr[i] ) ) {
67 if( !DESC_CHAR( descr[i] ) ) {
78 /* String compare with delimiter check. Return 0 if not
79 * matched, otherwise return length matched.
82 dscompare(const char *s1, const char *s2, char delim)
84 const char *orig = s1;
85 while (*s1++ == *s2++)
89 if (!*s1 && (!*s2 || *s2 == delim))
107 oc = ldap_str2objectclass(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
109 fprintf( stderr, "%s: line %d: %s before %s\n",
110 fname, lineno, ldap_scherr2str(code), err );
115 if ( oc->oc_oid == NULL ) {
117 "%s: line %d: objectclass has no OID\n",
123 code = oc_add(oc,1,&err);
125 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
126 fname, lineno, scherr2str(code), err);
138 "ObjectClassDescription = \"(\" whsp\n"
139 " numericoid whsp ; ObjectClass identifier\n"
140 " [ \"NAME\" qdescrs ]\n"
141 " [ \"DESC\" qdstring ]\n"
142 " [ \"OBSOLETE\" whsp ]\n"
143 " [ \"SUP\" oids ] ; Superior ObjectClasses\n"
144 " [ ( \"ABSTRACT\" / \"STRUCTURAL\" / \"AUXILIARY\" ) whsp ]\n"
145 " ; default structural\n"
146 " [ \"MUST\" oids ] ; AttributeTypes\n"
147 " [ \"MAY\" oids ] ; AttributeTypes\n"
156 "AttributeTypeDescription = \"(\" whsp\n"
157 " numericoid whsp ; AttributeType identifier\n"
158 " [ \"NAME\" qdescrs ] ; name used in AttributeType\n"
159 " [ \"DESC\" qdstring ] ; description\n"
160 " [ \"OBSOLETE\" whsp ]\n"
161 " [ \"SUP\" woid ] ; derived from this other\n"
163 " [ \"EQUALITY\" woid ] ; Matching Rule name\n"
164 " [ \"ORDERING\" woid ] ; Matching Rule name\n"
165 " [ \"SUBSTR\" woid ] ; Matching Rule name\n"
166 " [ \"SYNTAX\" whsp noidlen whsp ] ; see section 4.3\n"
167 " [ \"SINGLE-VALUE\" whsp ] ; default multi-valued\n"
168 " [ \"COLLECTIVE\" whsp ] ; default not collective\n"
169 " [ \"NO-USER-MODIFICATION\" whsp ]; default user modifiable\n"
170 " [ \"USAGE\" whsp AttributeUsage ]; default userApplications\n"
171 " ; userApplications\n"
172 " ; directoryOperation\n"
173 " ; distributedOperation\n"
186 LDAPAttributeType *at;
190 at = ldap_str2attributetype( line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
192 fprintf( stderr, "%s: line %d: %s before %s\n",
193 fname, lineno, ldap_scherr2str(code), err );
198 if ( at->at_oid == NULL ) {
200 "%s: line %d: attributeType has no OID\n",
206 /* operational attributes should be defined internally */
207 if ( at->at_usage ) {
208 fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
209 fname, lineno, at->at_oid );
213 code = at_add(at,&err);
215 fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
216 fname, lineno, scherr2str(code), err);