]> git.sur5r.net Git - openldap/blob - include/ldap_schema.h
Happy New Year
[openldap] / include / ldap_schema.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2018 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
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>.
14  */
15
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_...
19  */
20
21 #ifndef _LDAP_SCHEMA_H
22 #define _LDAP_SCHEMA_H 1
23
24 #include <ldap_cdefs.h>
25
26 LDAP_BEGIN_DECL
27
28 /* Codes for parsing errors */
29
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
42
43 typedef struct ldap_schema_extension_item {
44         char *lsei_name;
45         char **lsei_values;
46 } LDAPSchemaExtensionItem;
47
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 */
53 } LDAPSyntax;
54
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 */
62 } LDAPMatchingRule;
63
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;
72
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 */
90 } LDAPAttributeType;
91
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 */
102 } LDAPObjectClass;
103
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 */
115 } LDAPContentRule;
116
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 */
126 } LDAPNameForm;
127
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 */
137 } LDAPStructureRule;
138
139 /*
140  * Misc macros
141  */
142 #define LDAP_SCHEMA_NO                          0
143 #define LDAP_SCHEMA_YES                         1
144
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
149
150 #define LDAP_SCHEMA_ABSTRACT                    0
151 #define LDAP_SCHEMA_STRUCTURAL                  1
152 #define LDAP_SCHEMA_AUXILIARY                   2
153
154
155 /*
156  * Flags that control how liberal the parsing routines are.
157  */
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      */
167
168
169 LDAP_F( LDAP_CONST char * )
170 ldap_syntax2name LDAP_P((
171         LDAPSyntax * syn ));
172
173 LDAP_F( LDAP_CONST char * )
174 ldap_matchingrule2name LDAP_P((
175         LDAPMatchingRule * mr ));
176
177 LDAP_F( LDAP_CONST char * )
178 ldap_matchingruleuse2name LDAP_P((
179         LDAPMatchingRuleUse * mru ));
180
181 LDAP_F( LDAP_CONST char * )
182 ldap_attributetype2name LDAP_P((
183         LDAPAttributeType * at ));
184
185 LDAP_F( LDAP_CONST char * )
186 ldap_objectclass2name LDAP_P((
187         LDAPObjectClass * oc ));
188
189 LDAP_F( LDAP_CONST char * )
190 ldap_contentrule2name LDAP_P((
191         LDAPContentRule * cr ));
192
193 LDAP_F( LDAP_CONST char * )
194 ldap_nameform2name LDAP_P((
195         LDAPNameForm * nf ));
196
197 LDAP_F( LDAP_CONST char * )
198 ldap_structurerule2name LDAP_P((
199         LDAPStructureRule * sr ));
200
201 LDAP_F( void )
202 ldap_syntax_free LDAP_P((
203         LDAPSyntax * syn ));
204
205 LDAP_F( void )
206 ldap_matchingrule_free LDAP_P((
207         LDAPMatchingRule * mr ));
208
209 LDAP_F( void )
210 ldap_matchingruleuse_free LDAP_P((
211         LDAPMatchingRuleUse * mr ));
212
213 LDAP_F( void )
214 ldap_attributetype_free LDAP_P((
215         LDAPAttributeType * at ));
216
217 LDAP_F( void )
218 ldap_objectclass_free LDAP_P((
219         LDAPObjectClass * oc ));
220
221 LDAP_F( void )
222 ldap_contentrule_free LDAP_P((
223         LDAPContentRule * cr ));
224
225 LDAP_F( void )
226 ldap_nameform_free LDAP_P((
227         LDAPNameForm * nf ));
228
229 LDAP_F( void )
230 ldap_structurerule_free LDAP_P((
231         LDAPStructureRule * sr ));
232
233 LDAP_F( LDAPStructureRule * )
234 ldap_str2structurerule LDAP_P((
235         LDAP_CONST char * s,
236         int * code,
237         LDAP_CONST char ** errp,
238         LDAP_CONST unsigned flags ));
239
240 LDAP_F( LDAPNameForm * )
241 ldap_str2nameform LDAP_P((
242         LDAP_CONST char * s,
243         int * code,
244         LDAP_CONST char ** errp,
245         LDAP_CONST unsigned flags ));
246
247 LDAP_F( LDAPContentRule * )
248 ldap_str2contentrule LDAP_P((
249         LDAP_CONST char * s,
250         int * code,
251         LDAP_CONST char ** errp,
252         LDAP_CONST unsigned flags ));
253
254 LDAP_F( LDAPObjectClass * )
255 ldap_str2objectclass LDAP_P((
256         LDAP_CONST char * s,
257         int * code,
258         LDAP_CONST char ** errp,
259         LDAP_CONST unsigned flags ));
260
261 LDAP_F( LDAPAttributeType * )
262 ldap_str2attributetype LDAP_P((
263         LDAP_CONST char * s,
264         int * code,
265         LDAP_CONST char ** errp,
266         LDAP_CONST unsigned flags ));
267
268 LDAP_F( LDAPSyntax * )
269 ldap_str2syntax LDAP_P((
270         LDAP_CONST char * s,
271         int * code,
272         LDAP_CONST char ** errp,
273         LDAP_CONST unsigned flags ));
274
275 LDAP_F( LDAPMatchingRule * )
276 ldap_str2matchingrule LDAP_P((
277         LDAP_CONST char * s,
278         int * code,
279         LDAP_CONST char ** errp,
280         LDAP_CONST unsigned flags ));
281
282 LDAP_F( LDAPMatchingRuleUse * )
283 ldap_str2matchingruleuse LDAP_P((
284         LDAP_CONST char * s,
285         int * code,
286         LDAP_CONST char ** errp,
287         LDAP_CONST unsigned flags ));
288
289 LDAP_F( char * )
290 ldap_structurerule2str LDAP_P((
291         LDAPStructureRule * sr ));
292
293 LDAP_F( struct berval * )
294 ldap_structurerule2bv LDAP_P((
295         LDAPStructureRule * sr, struct berval *bv ));
296
297 LDAP_F( char * )
298 ldap_nameform2str LDAP_P((
299         LDAPNameForm * nf ));
300
301 LDAP_F( struct berval * )
302 ldap_nameform2bv LDAP_P((
303         LDAPNameForm * nf, struct berval *bv ));
304
305 LDAP_F( char * )
306 ldap_contentrule2str LDAP_P((
307         LDAPContentRule * cr ));
308
309 LDAP_F( struct berval * )
310 ldap_contentrule2bv LDAP_P((
311         LDAPContentRule * cr, struct berval *bv ));
312
313 LDAP_F( char * )
314 ldap_objectclass2str LDAP_P((
315         LDAPObjectClass * oc ));
316
317 LDAP_F( struct berval * )
318 ldap_objectclass2bv LDAP_P((
319         LDAPObjectClass * oc, struct berval *bv ));
320
321 LDAP_F( char * )
322 ldap_attributetype2str LDAP_P((
323         LDAPAttributeType * at ));
324
325 LDAP_F( struct berval * )
326 ldap_attributetype2bv LDAP_P((
327         LDAPAttributeType * at, struct berval *bv ));
328
329 LDAP_F( char * )
330 ldap_syntax2str LDAP_P((
331         LDAPSyntax * syn ));
332
333 LDAP_F( struct berval * )
334 ldap_syntax2bv LDAP_P((
335         LDAPSyntax * syn, struct berval *bv ));
336
337 LDAP_F( char * )
338 ldap_matchingrule2str LDAP_P((
339         LDAPMatchingRule * mr ));
340
341 LDAP_F( struct berval * )
342 ldap_matchingrule2bv LDAP_P((
343         LDAPMatchingRule * mr, struct berval *bv ));
344
345 LDAP_F( char * )
346 ldap_matchingruleuse2str LDAP_P((
347         LDAPMatchingRuleUse * mru ));
348
349 LDAP_F( struct berval * )
350 ldap_matchingruleuse2bv LDAP_P((
351         LDAPMatchingRuleUse * mru, struct berval *bv ));
352
353 LDAP_F( char * )
354 ldap_scherr2str LDAP_P((
355         int code )) LDAP_GCCATTR((const));
356
357 LDAP_END_DECL
358
359 #endif
360