3 * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted only as authorized by the OpenLDAP
8 * Public License. A copy of this license is available at
9 * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10 * top-level directory of the distribution.
13 * ldap-schema.h - Header for basic schema handling functions that can be
14 * used by both clients and servers.
15 * these routines should be renamed ldap_x_...
18 #ifndef _LDAP_SCHEMA_H
19 #define _LDAP_SCHEMA_H 1
21 #include <ldap_cdefs.h>
25 /* Codes for parsing errors */
27 #define LDAP_SCHERR_OUTOFMEM 1
28 #define LDAP_SCHERR_UNEXPTOKEN 2
29 #define LDAP_SCHERR_NOLEFTPAREN 3
30 #define LDAP_SCHERR_NORIGHTPAREN 4
31 #define LDAP_SCHERR_NODIGIT 5
32 #define LDAP_SCHERR_BADNAME 6
33 #define LDAP_SCHERR_BADDESC 7
34 #define LDAP_SCHERR_BADSUP 8
35 #define LDAP_SCHERR_DUPOPT 9
36 #define LDAP_SCHERR_EMPTY 10
37 #define LDAP_SCHERR_MISSING 11
38 #define LDAP_SCHERR_OUT_OF_ORDER 12
40 typedef struct ldap_schema_extension_item {
43 } LDAPSchemaExtensionItem;
45 typedef struct ldap_syntax {
46 char *syn_oid; /* REQUIRED */
47 char **syn_names; /* OPTIONAL */
48 char *syn_desc; /* OPTIONAL */
49 LDAPSchemaExtensionItem **syn_extensions; /* OPTIONAL */
52 typedef struct ldap_matchingrule {
53 char *mr_oid; /* REQUIRED */
54 char **mr_names; /* OPTIONAL */
55 char *mr_desc; /* OPTIONAL */
56 int mr_obsolete; /* OPTIONAL */
57 char *mr_syntax_oid; /* REQUIRED */
58 LDAPSchemaExtensionItem **mr_extensions; /* OPTIONAL */
61 typedef struct ldap_matchingruleuse {
62 char *mru_oid; /* REQUIRED */
63 char **mru_names; /* OPTIONAL */
64 char *mru_desc; /* OPTIONAL */
65 int mru_obsolete; /* OPTIONAL */
66 char **mru_applies_oids; /* REQUIRED */
67 LDAPSchemaExtensionItem **mru_extensions; /* OPTIONAL */
68 } LDAPMatchingRuleUse;
70 typedef struct ldap_attributetype {
71 char *at_oid; /* REQUIRED */
72 char **at_names; /* OPTIONAL */
73 char *at_desc; /* OPTIONAL */
74 int at_obsolete; /* 0=no, 1=yes */
75 char *at_sup_oid; /* OPTIONAL */
76 char *at_equality_oid; /* OPTIONAL */
77 char *at_ordering_oid; /* OPTIONAL */
78 char *at_substr_oid; /* OPTIONAL */
79 char *at_syntax_oid; /* OPTIONAL */
80 int at_syntax_len; /* OPTIONAL */
81 int at_single_value; /* 0=no, 1=yes */
82 int at_collective; /* 0=no, 1=yes */
83 int at_no_user_mod; /* 0=no, 1=yes */
84 int at_usage; /* 0=userApplications, 1=directoryOperation,
85 2=distributedOperation, 3=dSAOperation */
86 LDAPSchemaExtensionItem **at_extensions; /* OPTIONAL */
89 typedef struct ldap_objectclass {
90 char *oc_oid; /* REQUIRED */
91 char **oc_names; /* OPTIONAL */
92 char *oc_desc; /* OPTIONAL */
93 int oc_obsolete; /* 0=no, 1=yes */
94 char **oc_sup_oids; /* OPTIONAL */
95 int oc_kind; /* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY */
96 char **oc_at_oids_must; /* OPTIONAL */
97 char **oc_at_oids_may; /* OPTIONAL */
98 LDAPSchemaExtensionItem **oc_extensions; /* OPTIONAL */
101 typedef struct ldap_contentrule {
102 char *cr_oid; /* REQUIRED */
103 char **cr_names; /* OPTIONAL */
104 char *cr_desc; /* OPTIONAL */
105 char **cr_sup_oids; /* OPTIONAL */
106 int cr_obsolete; /* 0=no, 1=yes */
107 char **cr_oc_oids_aux; /* OPTIONAL */
108 char **cr_at_oids_must; /* OPTIONAL */
109 char **cr_at_oids_may; /* OPTIONAL */
110 char **cr_at_oids_not; /* OPTIONAL */
111 LDAPSchemaExtensionItem **cr_extensions; /* OPTIONAL */
114 typedef struct ldap_nameform {
115 char *nf_oid; /* REQUIRED */
116 char **nf_names; /* OPTIONAL */
117 char *nf_desc; /* OPTIONAL */
118 int nf_obsolete; /* 0=no, 1=yes */
119 char *nf_objectclass; /* REQUIRED */
120 char **nf_at_oids_must; /* REQUIRED */
121 char **nf_at_oids_may; /* OPTIONAL */
122 LDAPSchemaExtensionItem **nf_extensions; /* OPTIONAL */
125 typedef struct ldap_structurerule {
126 int sr_ruleid; /* REQUIRED */
127 char **sr_names; /* OPTIONAL */
128 char *sr_desc; /* OPTIONAL */
129 int sr_obsolete; /* 0=no, 1=yes */
130 char *sr_nameform; /* REQUIRED */
131 int sr_nsup_ruleids;/* number of sr_sup_ruleids */
132 int *sr_sup_ruleids;/* OPTIONAL */
133 LDAPSchemaExtensionItem **sr_extensions; /* OPTIONAL */
139 #define LDAP_SCHEMA_NO 0
140 #define LDAP_SCHEMA_YES 1
142 #define LDAP_SCHEMA_USER_APPLICATIONS 0
143 #define LDAP_SCHEMA_DIRECTORY_OPERATION 1
144 #define LDAP_SCHEMA_DISTRIBUTED_OPERATION 2
145 #define LDAP_SCHEMA_DSA_OPERATION 3
147 #define LDAP_SCHEMA_ABSTRACT 0
148 #define LDAP_SCHEMA_STRUCTURAL 1
149 #define LDAP_SCHEMA_AUXILIARY 2
153 * Flags that control how liberal the parsing routines are.
155 #define LDAP_SCHEMA_ALLOW_NONE 0x00U /* Strict parsing */
156 #define LDAP_SCHEMA_ALLOW_NO_OID 0x01U /* Allow missing oid */
157 #define LDAP_SCHEMA_ALLOW_QUOTED 0x02U /* Allow bogus extra quotes */
158 #define LDAP_SCHEMA_ALLOW_DESCR 0x04U /* Allow descr instead of OID */
159 #define LDAP_SCHEMA_ALLOW_DESCR_PREFIX 0x08U /* Allow descr as OID prefix */
160 #define LDAP_SCHEMA_ALLOW_OID_MACRO 0x10U /* Allow OID macros in slapd */
161 #define LDAP_SCHEMA_ALLOW_OUT_OF_ORDER_FIELDS 0x20U /* Allow fields in most any order */
162 #define LDAP_SCHEMA_ALLOW_ALL 0x3fU /* Be very liberal in parsing */
163 #define LDAP_SCHEMA_SKIP 0x80U /* Don't malloc any result */
166 LDAP_F( LDAP_CONST char * )
167 ldap_syntax2name LDAP_P((
170 LDAP_F( LDAP_CONST char * )
171 ldap_matchingrule2name LDAP_P((
172 LDAPMatchingRule * mr ));
174 LDAP_F( LDAP_CONST char * )
175 ldap_matchingruleuse2name LDAP_P((
176 LDAPMatchingRuleUse * mru ));
178 LDAP_F( LDAP_CONST char * )
179 ldap_attributetype2name LDAP_P((
180 LDAPAttributeType * at ));
182 LDAP_F( LDAP_CONST char * )
183 ldap_objectclass2name LDAP_P((
184 LDAPObjectClass * oc ));
186 LDAP_F( LDAP_CONST char * )
187 ldap_contentrule2name LDAP_P((
188 LDAPContentRule * cr ));
190 LDAP_F( LDAP_CONST char * )
191 ldap_nameform2name LDAP_P((
192 LDAPNameForm * nf ));
194 LDAP_F( LDAP_CONST char * )
195 ldap_structurerule2name LDAP_P((
196 LDAPStructureRule * sr ));
199 ldap_syntax_free LDAP_P((
203 ldap_matchingrule_free LDAP_P((
204 LDAPMatchingRule * mr ));
207 ldap_matchingruleuse_free LDAP_P((
208 LDAPMatchingRuleUse * mr ));
211 ldap_attributetype_free LDAP_P((
212 LDAPAttributeType * at ));
215 ldap_objectclass_free LDAP_P((
216 LDAPObjectClass * oc ));
219 ldap_contentrule_free LDAP_P((
220 LDAPContentRule * cr ));
223 ldap_nameform_free LDAP_P((
224 LDAPNameForm * nf ));
227 ldap_structurerule_free LDAP_P((
228 LDAPStructureRule * sr ));
230 LDAP_F( LDAPStructureRule * )
231 ldap_str2structurerule LDAP_P((
234 LDAP_CONST char ** errp,
235 LDAP_CONST unsigned flags ));
237 LDAP_F( LDAPNameForm * )
238 ldap_str2nameform LDAP_P((
241 LDAP_CONST char ** errp,
242 LDAP_CONST unsigned flags ));
244 LDAP_F( LDAPContentRule * )
245 ldap_str2contentrule LDAP_P((
248 LDAP_CONST char ** errp,
249 LDAP_CONST unsigned flags ));
251 LDAP_F( LDAPObjectClass * )
252 ldap_str2objectclass LDAP_P((
255 LDAP_CONST char ** errp,
256 LDAP_CONST unsigned flags ));
258 LDAP_F( LDAPAttributeType * )
259 ldap_str2attributetype LDAP_P((
262 LDAP_CONST char ** errp,
263 LDAP_CONST unsigned flags ));
265 LDAP_F( LDAPSyntax * )
266 ldap_str2syntax LDAP_P((
269 LDAP_CONST char ** errp,
270 LDAP_CONST unsigned flags ));
272 LDAP_F( LDAPMatchingRule * )
273 ldap_str2matchingrule LDAP_P((
276 LDAP_CONST char ** errp,
277 LDAP_CONST unsigned flags ));
279 LDAP_F( LDAPMatchingRuleUse * )
280 ldap_str2matchingruleuse LDAP_P((
283 LDAP_CONST char ** errp,
284 LDAP_CONST unsigned flags ));
287 ldap_structurerule2str LDAP_P((
288 LDAPStructureRule * sr ));
290 LDAP_F( struct berval * )
291 ldap_structurerule2bv LDAP_P((
292 LDAPStructureRule * sr, struct berval *bv ));
295 ldap_nameform2str LDAP_P((
296 LDAPNameForm * nf ));
298 LDAP_F( struct berval * )
299 ldap_nameform2bv LDAP_P((
300 LDAPNameForm * nf, struct berval *bv ));
303 ldap_contentrule2str LDAP_P((
304 LDAPContentRule * cr ));
306 LDAP_F( struct berval * )
307 ldap_contentrule2bv LDAP_P((
308 LDAPContentRule * cr, struct berval *bv ));
311 ldap_objectclass2str LDAP_P((
312 LDAPObjectClass * oc ));
314 LDAP_F( struct berval * )
315 ldap_objectclass2bv LDAP_P((
316 LDAPObjectClass * oc, struct berval *bv ));
319 ldap_attributetype2str LDAP_P((
320 LDAPAttributeType * at ));
322 LDAP_F( struct berval * )
323 ldap_attributetype2bv LDAP_P((
324 LDAPAttributeType * at, struct berval *bv ));
327 ldap_syntax2str LDAP_P((
330 LDAP_F( struct berval * )
331 ldap_syntax2bv LDAP_P((
332 LDAPSyntax * syn, struct berval *bv ));
335 ldap_matchingrule2str LDAP_P((
336 LDAPMatchingRule * mr ));
338 LDAP_F( struct berval * )
339 ldap_matchingrule2bv LDAP_P((
340 LDAPMatchingRule * mr, struct berval *bv ));
343 ldap_matchingruleuse2str LDAP_P((
344 LDAPMatchingRuleUse * mru ));
346 LDAP_F( struct berval * )
347 ldap_matchingruleuse2bv LDAP_P((
348 LDAPMatchingRuleUse * mru, struct berval *bv ));
351 ldap_scherr2str LDAP_P((
352 int code )) LDAP_GCCATTR((const));