]> git.sur5r.net Git - openldap/blob - include/ldap_schema.h
d72c801c46a5619051eaade56f4080ad3faeef26
[openldap] / include / ldap_schema.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
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.
11  */
12 /*
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_...
16  */
17
18 #ifndef _LDAP_SCHEMA_H
19 #define _LDAP_SCHEMA_H 1
20
21 #include <ldap_cdefs.h>
22
23 LDAP_BEGIN_DECL
24
25 /* Codes for parsing errors */
26
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
38 typedef struct ldap_schema_extension_item {
39         char *lsei_name;
40         char **lsei_values;
41 } LDAPSchemaExtensionItem;
42
43 typedef struct ldap_syntax {
44         char *syn_oid;          /* REQUIRED */
45         char **syn_names;       /* OPTIONAL */
46         char *syn_desc;         /* OPTIONAL */
47         LDAPSchemaExtensionItem **syn_extensions; /* OPTIONAL */
48 } LDAPSyntax;
49
50 typedef struct ldap_matchingrule {
51         char *mr_oid;           /* REQUIRED */
52         char **mr_names;        /* OPTIONAL */
53         char *mr_desc;          /* OPTIONAL */
54         int  mr_obsolete;       /* OPTIONAL */
55         char *mr_syntax_oid;    /* REQUIRED */
56         LDAPSchemaExtensionItem **mr_extensions; /* OPTIONAL */
57 } LDAPMatchingRule;
58
59 typedef struct ldap_matchingruleuse {
60         char *mru_oid;          /* REQUIRED */
61         char **mru_names;       /* OPTIONAL */
62         char *mru_desc;         /* OPTIONAL */
63         int  mru_obsolete;      /* OPTIONAL */
64         char **mru_applies_oids;        /* REQUIRED */
65         LDAPSchemaExtensionItem **mru_extensions; /* OPTIONAL */
66 } LDAPMatchingRuleUse;
67
68 typedef struct ldap_attributetype {
69         char *at_oid;           /* REQUIRED */
70         char **at_names;        /* OPTIONAL */
71         char *at_desc;          /* OPTIONAL */
72         int  at_obsolete;       /* 0=no, 1=yes */
73         char *at_sup_oid;       /* OPTIONAL */
74         char *at_equality_oid;  /* OPTIONAL */
75         char *at_ordering_oid;  /* OPTIONAL */
76         char *at_substr_oid;    /* OPTIONAL */
77         char *at_syntax_oid;    /* OPTIONAL */
78         int  at_syntax_len;     /* OPTIONAL */
79         int  at_single_value;   /* 0=no, 1=yes */
80         int  at_collective;     /* 0=no, 1=yes */
81         int  at_no_user_mod;    /* 0=no, 1=yes */
82         int  at_usage;          /* 0=userApplications, 1=directoryOperation,
83                                    2=distributedOperation, 3=dSAOperation */
84         LDAPSchemaExtensionItem **at_extensions; /* OPTIONAL */
85 } LDAPAttributeType;
86
87 typedef struct ldap_objectclass {
88         char *oc_oid;           /* REQUIRED */
89         char **oc_names;        /* OPTIONAL */
90         char *oc_desc;          /* OPTIONAL */
91         int  oc_obsolete;       /* 0=no, 1=yes */
92         char **oc_sup_oids;     /* OPTIONAL */
93         int  oc_kind;           /* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY */
94         char **oc_at_oids_must; /* OPTIONAL */
95         char **oc_at_oids_may;  /* OPTIONAL */
96         LDAPSchemaExtensionItem **oc_extensions; /* OPTIONAL */
97 } LDAPObjectClass;
98
99 typedef struct ldap_contentrule {
100         char *cr_oid;           /* REQUIRED */
101         char **cr_names;        /* OPTIONAL */
102         char *cr_desc;          /* OPTIONAL */
103         char **cr_sup_oids;     /* OPTIONAL */
104         int  cr_obsolete;       /* 0=no, 1=yes */
105         char **cr_oc_oids_aux;  /* OPTIONAL */
106         char **cr_at_oids_must; /* OPTIONAL */
107         char **cr_at_oids_may;  /* OPTIONAL */
108         char **cr_at_oids_not;  /* OPTIONAL */
109         LDAPSchemaExtensionItem **cr_extensions; /* OPTIONAL */
110 } LDAPContentRule;
111
112
113 /*
114  * Misc macros
115  */
116 #define LDAP_SCHEMA_NO                          0
117 #define LDAP_SCHEMA_YES                         1
118
119 #define LDAP_SCHEMA_USER_APPLICATIONS           0
120 #define LDAP_SCHEMA_DIRECTORY_OPERATION         1
121 #define LDAP_SCHEMA_DISTRIBUTED_OPERATION       2
122 #define LDAP_SCHEMA_DSA_OPERATION               3
123
124 #define LDAP_SCHEMA_ABSTRACT                    0
125 #define LDAP_SCHEMA_STRUCTURAL                  1
126 #define LDAP_SCHEMA_AUXILIARY                   2
127
128
129 /*
130  * Flags that control how liberal the parsing routines are.
131  */
132 #define LDAP_SCHEMA_ALLOW_NONE          0x00 /* Strict parsing               */
133 #define LDAP_SCHEMA_ALLOW_NO_OID        0x01 /* Allow missing oid            */
134 #define LDAP_SCHEMA_ALLOW_QUOTED        0x02 /* Allow bogus extra quotes     */
135 #define LDAP_SCHEMA_ALLOW_DESCR         0x04 /* Allow descr instead of OID   */
136 #define LDAP_SCHEMA_ALLOW_DESCR_PREFIX  0x08 /* Allow descr as OID prefix    */
137 #define LDAP_SCHEMA_ALLOW_OID_MACRO     0x10 /* Allow OID macros in slapd    */
138 #define LDAP_SCHEMA_ALLOW_ALL           0x1f /* Be very liberal in parsing   */
139 #define LDAP_SCHEMA_SKIP                0x80 /* Don't malloc any result      */
140
141 LDAP_F( LDAP_CONST char * )
142 ldap_syntax2name LDAP_P((
143         LDAPSyntax * syn ));
144
145 LDAP_F( LDAP_CONST char * )
146 ldap_matchingrule2name LDAP_P((
147         LDAPMatchingRule * mr ));
148
149 LDAP_F( LDAP_CONST char * )
150 ldap_matchingruleuse2name LDAP_P((
151         LDAPMatchingRuleUse * mru ));
152
153 LDAP_F( LDAP_CONST char * )
154 ldap_attributetype2name LDAP_P((
155         LDAPAttributeType * at ));
156
157 LDAP_F( LDAP_CONST char * )
158 ldap_objectclass2name LDAP_P((
159         LDAPObjectClass * oc ));
160
161 LDAP_F( LDAP_CONST char * )
162 ldap_contentrule2name LDAP_P((
163         LDAPContentRule * cr ));
164
165 LDAP_F( void )
166 ldap_syntax_free LDAP_P((
167         LDAPSyntax * syn ));
168
169 LDAP_F( void )
170 ldap_matchingrule_free LDAP_P((
171         LDAPMatchingRule * mr ));
172
173 LDAP_F( void )
174 ldap_matchingruleuse_free LDAP_P((
175         LDAPMatchingRuleUse * mr ));
176
177 LDAP_F( void )
178 ldap_attributetype_free LDAP_P((
179         LDAPAttributeType * at ));
180
181 LDAP_F( void )
182 ldap_objectclass_free LDAP_P((
183         LDAPObjectClass * oc ));
184
185 LDAP_F( void )
186 ldap_contentrule_free LDAP_P((
187         LDAPContentRule * cr ));
188
189 LDAP_F( LDAPObjectClass * )
190 ldap_str2objectclass LDAP_P((
191         LDAP_CONST char * s,
192         int * code,
193         LDAP_CONST char ** errp,
194         LDAP_CONST int flags ));
195
196 LDAP_F( LDAPContentRule * )
197 ldap_str2contentrule LDAP_P((
198         LDAP_CONST char * s,
199         int * code,
200         LDAP_CONST char ** errp,
201         LDAP_CONST int flags ));
202
203 LDAP_F( LDAPAttributeType * )
204 ldap_str2attributetype LDAP_P((
205         LDAP_CONST char * s,
206         int * code,
207         LDAP_CONST char ** errp,
208         LDAP_CONST int flags ));
209
210 LDAP_F( LDAPSyntax * )
211 ldap_str2syntax LDAP_P((
212         LDAP_CONST char * s,
213         int * code,
214         LDAP_CONST char ** errp,
215         LDAP_CONST int flags ));
216
217 LDAP_F( LDAPMatchingRule * )
218 ldap_str2matchingrule LDAP_P((
219         LDAP_CONST char * s,
220         int * code,
221         LDAP_CONST char ** errp,
222         LDAP_CONST int flags ));
223
224 LDAP_F( LDAPMatchingRuleUse * )
225 ldap_str2matchingruleuse LDAP_P((
226         LDAP_CONST char * s,
227         int * code,
228         LDAP_CONST char ** errp,
229         LDAP_CONST int flags ));
230
231 LDAP_F( char * )
232 ldap_objectclass2str LDAP_P((
233         LDAPObjectClass * oc ));
234
235 LDAP_F( struct berval * )
236 ldap_objectclass2bv LDAP_P((
237         LDAPObjectClass * oc, struct berval *bv ));
238
239 LDAP_F( char * )
240 ldap_contentrule2str LDAP_P((
241         LDAPContentRule * cr ));
242
243 LDAP_F( struct berval * )
244 ldap_contentrule2bv LDAP_P((
245         LDAPContentRule * cr, struct berval *bv ));
246
247 LDAP_F( char * )
248 ldap_attributetype2str LDAP_P((
249         LDAPAttributeType * at ));
250
251 LDAP_F( struct berval * )
252 ldap_attributetype2bv LDAP_P((
253         LDAPAttributeType * at, struct berval *bv ));
254
255 LDAP_F( char * )
256 ldap_syntax2str LDAP_P((
257         LDAPSyntax * syn ));
258
259 LDAP_F( struct berval * )
260 ldap_syntax2bv LDAP_P((
261         LDAPSyntax * syn, struct berval *bv ));
262
263 LDAP_F( char * )
264 ldap_matchingrule2str LDAP_P((
265         LDAPMatchingRule * mr ));
266
267 LDAP_F( struct berval * )
268 ldap_matchingrule2bv LDAP_P((
269         LDAPMatchingRule * mr, struct berval *bv ));
270
271 LDAP_F( char * )
272 ldap_matchingruleuse2str LDAP_P((
273         LDAPMatchingRuleUse * mru ));
274
275 LDAP_F( struct berval * )
276 ldap_matchingruleuse2bv LDAP_P((
277         LDAPMatchingRuleUse * mru, struct berval *bv ));
278
279 LDAP_F( char * )
280 ldap_scherr2str LDAP_P((
281         int code )) LDAP_GCCATTR((const));
282
283 LDAP_END_DECL
284
285 #endif
286