1 /* $OpenLDAP: pkg/ldap/include/ldap_schema.h,v 1.36.2.3 2008/02/11 23:26:40 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2008 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 /* ldap-schema.h - Header for basic schema handling functions that can be
17 * used by both clients and servers.
18 * these routines should be renamed ldap_x_...
21 #ifndef _LDAP_SCHEMA_H
22 #define _LDAP_SCHEMA_H 1
24 #include <ldap_cdefs.h>
28 /* Codes for parsing errors */
30 #define LDAP_SCHERR_OUTOFMEM 1
31 #define LDAP_SCHERR_UNEXPTOKEN 2
32 #define LDAP_SCHERR_NOLEFTPAREN 3
33 #define LDAP_SCHERR_NORIGHTPAREN 4
34 #define LDAP_SCHERR_NODIGIT 5
35 #define LDAP_SCHERR_BADNAME 6
36 #define LDAP_SCHERR_BADDESC 7
37 #define LDAP_SCHERR_BADSUP 8
38 #define LDAP_SCHERR_DUPOPT 9
39 #define LDAP_SCHERR_EMPTY 10
40 #define LDAP_SCHERR_MISSING 11
41 #define LDAP_SCHERR_OUT_OF_ORDER 12
43 typedef struct ldap_schema_extension_item
{
46 } LDAPSchemaExtensionItem
;
48 typedef struct ldap_syntax
{
49 char *syn_oid
; /* REQUIRED */
50 char **syn_names
; /* OPTIONAL */
51 char *syn_desc
; /* OPTIONAL */
52 LDAPSchemaExtensionItem
**syn_extensions
; /* OPTIONAL */
55 typedef struct ldap_matchingrule
{
56 char *mr_oid
; /* REQUIRED */
57 char **mr_names
; /* OPTIONAL */
58 char *mr_desc
; /* OPTIONAL */
59 int mr_obsolete
; /* OPTIONAL */
60 char *mr_syntax_oid
; /* REQUIRED */
61 LDAPSchemaExtensionItem
**mr_extensions
; /* OPTIONAL */
64 typedef struct ldap_matchingruleuse
{
65 char *mru_oid
; /* REQUIRED */
66 char **mru_names
; /* OPTIONAL */
67 char *mru_desc
; /* OPTIONAL */
68 int mru_obsolete
; /* OPTIONAL */
69 char **mru_applies_oids
; /* REQUIRED */
70 LDAPSchemaExtensionItem
**mru_extensions
; /* OPTIONAL */
71 } LDAPMatchingRuleUse
;
73 typedef struct ldap_attributetype
{
74 char *at_oid
; /* REQUIRED */
75 char **at_names
; /* OPTIONAL */
76 char *at_desc
; /* OPTIONAL */
77 int at_obsolete
; /* 0=no, 1=yes */
78 char *at_sup_oid
; /* OPTIONAL */
79 char *at_equality_oid
; /* OPTIONAL */
80 char *at_ordering_oid
; /* OPTIONAL */
81 char *at_substr_oid
; /* OPTIONAL */
82 char *at_syntax_oid
; /* OPTIONAL */
83 int at_syntax_len
; /* OPTIONAL */
84 int at_single_value
; /* 0=no, 1=yes */
85 int at_collective
; /* 0=no, 1=yes */
86 int at_no_user_mod
; /* 0=no, 1=yes */
87 int at_usage
; /* 0=userApplications, 1=directoryOperation,
88 2=distributedOperation, 3=dSAOperation */
89 LDAPSchemaExtensionItem
**at_extensions
; /* OPTIONAL */
92 typedef struct ldap_objectclass
{
93 char *oc_oid
; /* REQUIRED */
94 char **oc_names
; /* OPTIONAL */
95 char *oc_desc
; /* OPTIONAL */
96 int oc_obsolete
; /* 0=no, 1=yes */
97 char **oc_sup_oids
; /* OPTIONAL */
98 int oc_kind
; /* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY */
99 char **oc_at_oids_must
; /* OPTIONAL */
100 char **oc_at_oids_may
; /* OPTIONAL */
101 LDAPSchemaExtensionItem
**oc_extensions
; /* OPTIONAL */
104 typedef struct ldap_contentrule
{
105 char *cr_oid
; /* REQUIRED */
106 char **cr_names
; /* OPTIONAL */
107 char *cr_desc
; /* OPTIONAL */
108 char **cr_sup_oids
; /* OPTIONAL */
109 int cr_obsolete
; /* 0=no, 1=yes */
110 char **cr_oc_oids_aux
; /* OPTIONAL */
111 char **cr_at_oids_must
; /* OPTIONAL */
112 char **cr_at_oids_may
; /* OPTIONAL */
113 char **cr_at_oids_not
; /* OPTIONAL */
114 LDAPSchemaExtensionItem
**cr_extensions
; /* OPTIONAL */
117 typedef struct ldap_nameform
{
118 char *nf_oid
; /* REQUIRED */
119 char **nf_names
; /* OPTIONAL */
120 char *nf_desc
; /* OPTIONAL */
121 int nf_obsolete
; /* 0=no, 1=yes */
122 char *nf_objectclass
; /* REQUIRED */
123 char **nf_at_oids_must
; /* REQUIRED */
124 char **nf_at_oids_may
; /* OPTIONAL */
125 LDAPSchemaExtensionItem
**nf_extensions
; /* OPTIONAL */
128 typedef struct ldap_structurerule
{
129 int sr_ruleid
; /* REQUIRED */
130 char **sr_names
; /* OPTIONAL */
131 char *sr_desc
; /* OPTIONAL */
132 int sr_obsolete
; /* 0=no, 1=yes */
133 char *sr_nameform
; /* REQUIRED */
134 int sr_nsup_ruleids
;/* number of sr_sup_ruleids */
135 int *sr_sup_ruleids
;/* OPTIONAL */
136 LDAPSchemaExtensionItem
**sr_extensions
; /* OPTIONAL */
142 #define LDAP_SCHEMA_NO 0
143 #define LDAP_SCHEMA_YES 1
145 #define LDAP_SCHEMA_USER_APPLICATIONS 0
146 #define LDAP_SCHEMA_DIRECTORY_OPERATION 1
147 #define LDAP_SCHEMA_DISTRIBUTED_OPERATION 2
148 #define LDAP_SCHEMA_DSA_OPERATION 3
150 #define LDAP_SCHEMA_ABSTRACT 0
151 #define LDAP_SCHEMA_STRUCTURAL 1
152 #define LDAP_SCHEMA_AUXILIARY 2
156 * Flags that control how liberal the parsing routines are.
158 #define LDAP_SCHEMA_ALLOW_NONE 0x00U /* Strict parsing */
159 #define LDAP_SCHEMA_ALLOW_NO_OID 0x01U /* Allow missing oid */
160 #define LDAP_SCHEMA_ALLOW_QUOTED 0x02U /* Allow bogus extra quotes */
161 #define LDAP_SCHEMA_ALLOW_DESCR 0x04U /* Allow descr instead of OID */
162 #define LDAP_SCHEMA_ALLOW_DESCR_PREFIX 0x08U /* Allow descr as OID prefix */
163 #define LDAP_SCHEMA_ALLOW_OID_MACRO 0x10U /* Allow OID macros in slapd */
164 #define LDAP_SCHEMA_ALLOW_OUT_OF_ORDER_FIELDS 0x20U /* Allow fields in most any order */
165 #define LDAP_SCHEMA_ALLOW_ALL 0x3fU /* Be very liberal in parsing */
166 #define LDAP_SCHEMA_SKIP 0x80U /* Don't malloc any result */
169 LDAP_F( LDAP_CONST
char * )
170 ldap_syntax2name
LDAP_P((
173 LDAP_F( LDAP_CONST
char * )
174 ldap_matchingrule2name
LDAP_P((
175 LDAPMatchingRule
* mr
));
177 LDAP_F( LDAP_CONST
char * )
178 ldap_matchingruleuse2name
LDAP_P((
179 LDAPMatchingRuleUse
* mru
));
181 LDAP_F( LDAP_CONST
char * )
182 ldap_attributetype2name
LDAP_P((
183 LDAPAttributeType
* at
));
185 LDAP_F( LDAP_CONST
char * )
186 ldap_objectclass2name
LDAP_P((
187 LDAPObjectClass
* oc
));
189 LDAP_F( LDAP_CONST
char * )
190 ldap_contentrule2name
LDAP_P((
191 LDAPContentRule
* cr
));
193 LDAP_F( LDAP_CONST
char * )
194 ldap_nameform2name
LDAP_P((
195 LDAPNameForm
* nf
));
197 LDAP_F( LDAP_CONST
char * )
198 ldap_structurerule2name
LDAP_P((
199 LDAPStructureRule
* sr
));
202 ldap_syntax_free
LDAP_P((
206 ldap_matchingrule_free
LDAP_P((
207 LDAPMatchingRule
* mr
));
210 ldap_matchingruleuse_free
LDAP_P((
211 LDAPMatchingRuleUse
* mr
));
214 ldap_attributetype_free
LDAP_P((
215 LDAPAttributeType
* at
));
218 ldap_objectclass_free
LDAP_P((
219 LDAPObjectClass
* oc
));
222 ldap_contentrule_free
LDAP_P((
223 LDAPContentRule
* cr
));
226 ldap_nameform_free
LDAP_P((
227 LDAPNameForm
* nf
));
230 ldap_structurerule_free
LDAP_P((
231 LDAPStructureRule
* sr
));
233 LDAP_F( LDAPStructureRule
* )
234 ldap_str2structurerule
LDAP_P((
237 LDAP_CONST
char ** errp
,
238 LDAP_CONST
unsigned flags
));
240 LDAP_F( LDAPNameForm
* )
241 ldap_str2nameform
LDAP_P((
244 LDAP_CONST
char ** errp
,
245 LDAP_CONST
unsigned flags
));
247 LDAP_F( LDAPContentRule
* )
248 ldap_str2contentrule
LDAP_P((
251 LDAP_CONST
char ** errp
,
252 LDAP_CONST
unsigned flags
));
254 LDAP_F( LDAPObjectClass
* )
255 ldap_str2objectclass
LDAP_P((
258 LDAP_CONST
char ** errp
,
259 LDAP_CONST
unsigned flags
));
261 LDAP_F( LDAPAttributeType
* )
262 ldap_str2attributetype
LDAP_P((
265 LDAP_CONST
char ** errp
,
266 LDAP_CONST
unsigned flags
));
268 LDAP_F( LDAPSyntax
* )
269 ldap_str2syntax
LDAP_P((
272 LDAP_CONST
char ** errp
,
273 LDAP_CONST
unsigned flags
));
275 LDAP_F( LDAPMatchingRule
* )
276 ldap_str2matchingrule
LDAP_P((
279 LDAP_CONST
char ** errp
,
280 LDAP_CONST
unsigned flags
));
282 LDAP_F( LDAPMatchingRuleUse
* )
283 ldap_str2matchingruleuse
LDAP_P((
286 LDAP_CONST
char ** errp
,
287 LDAP_CONST
unsigned flags
));
290 ldap_structurerule2str
LDAP_P((
291 LDAPStructureRule
* sr
));
293 LDAP_F( struct berval
* )
294 ldap_structurerule2bv
LDAP_P((
295 LDAPStructureRule
* sr
, struct berval
*bv
));
298 ldap_nameform2str
LDAP_P((
299 LDAPNameForm
* nf
));
301 LDAP_F( struct berval
* )
302 ldap_nameform2bv
LDAP_P((
303 LDAPNameForm
* nf
, struct berval
*bv
));
306 ldap_contentrule2str
LDAP_P((
307 LDAPContentRule
* cr
));
309 LDAP_F( struct berval
* )
310 ldap_contentrule2bv
LDAP_P((
311 LDAPContentRule
* cr
, struct berval
*bv
));
314 ldap_objectclass2str
LDAP_P((
315 LDAPObjectClass
* oc
));
317 LDAP_F( struct berval
* )
318 ldap_objectclass2bv
LDAP_P((
319 LDAPObjectClass
* oc
, struct berval
*bv
));
322 ldap_attributetype2str
LDAP_P((
323 LDAPAttributeType
* at
));
325 LDAP_F( struct berval
* )
326 ldap_attributetype2bv
LDAP_P((
327 LDAPAttributeType
* at
, struct berval
*bv
));
330 ldap_syntax2str
LDAP_P((
333 LDAP_F( struct berval
* )
334 ldap_syntax2bv
LDAP_P((
335 LDAPSyntax
* syn
, struct berval
*bv
));
338 ldap_matchingrule2str
LDAP_P((
339 LDAPMatchingRule
* mr
));
341 LDAP_F( struct berval
* )
342 ldap_matchingrule2bv
LDAP_P((
343 LDAPMatchingRule
* mr
, struct berval
*bv
));
346 ldap_matchingruleuse2str
LDAP_P((
347 LDAPMatchingRuleUse
* mru
));
349 LDAP_F( struct berval
* )
350 ldap_matchingruleuse2bv
LDAP_P((
351 LDAPMatchingRuleUse
* mru
, struct berval
*bv
));
354 ldap_scherr2str
LDAP_P((
355 int code
)) LDAP_GCCATTR((const));