]> git.sur5r.net Git - openldap/blob - contrib/slapd-modules/comp_match/componentlib.h
Component Indexing support for BDB
[openldap] / contrib / slapd-modules / comp_match / componentlib.h
1 /* Copyright 2004 IBM Corporation
2  * All rights reserved.
3  * Redisribution and use in source and binary forms, with or without
4  * modification, are permitted only as  authorizd by the OpenLADP
5  * Public License.
6  */
7 /* ACKNOWLEDGEMENTS
8  * This work originally developed by Sang Seok Lim
9  * 2004/06/18   03:20:00        slim@OpenLDAP.org
10  */
11
12 #ifndef _H_COMPONENT_MODULE
13 #define _H_COMPONENT_MODULE
14
15 #include "portable.h"
16 #include <ac/string.h>
17 #include <ac/socket.h>
18 #include <ldap_pvt.h>
19 #include "lutil.h"
20 #include <ldap.h>
21 #include <slap.h>
22 #include <component.h>
23
24 #include <asn-incl.h>
25 #include "asn.h"
26 #include <asn-gser.h>
27 #include <string.h>
28
29 #define MAX_IDENTIFIER_LEN      128
30 #define COMPONENTNOT_NULL(ptr)  ((ptr) != NULL)
31
32 typedef struct slap_component_type {
33         /*
34          * Don't change the order of following fields
35          * They are identical the first 9 fields of
36          * AttributeType
37          */
38         LDAPAttributeType               ct_atype;
39         struct berval                   ct_cname;
40         struct slap_attribute_type      *ct_sup;
41         struct slap_attribute_type      **ct_subtypes;
42         MatchingRule                    *ct_equality;
43         MatchingRule                    *ct_approx;
44         MatchingRule                    *ct_ordering;
45         MatchingRule                    *ct_substr;
46         Syntax                          *ct_syntax;
47 } ComponentType;
48
49
50 /*
51  * BIT STRING
52  */
53 typedef struct ComponentBits {
54         void* syntax;
55         ComponentDesc* comp_desc;
56         struct berval identifier;
57         char id_buf[MAX_IDENTIFIER_LEN];
58         AsnBits value;
59 } ComponentBits;
60
61 #define GASNBITS_PRESENT(abits) ((abits)->value.bits != NULL)
62 #define COMPONENTBITS_PRESENT(abits) ((abits)->value.bits != NULL)
63 int GEncComponentBits (GenBuf *b, ComponentBits* bits);
64 int GDecComponentBits (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
65 int BDecComponentBits (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
66 int MatchingComponentBits (char* oid, ComponentSyntaxInfo *bits1 , ComponentSyntaxInfo* bits2);
67 #define ExtractingComponentBits( mem_op, cr,data ) NULL
68
69 /*
70  * BMP String
71  */
72 typedef struct ComponentBMPString {
73         void* syntax;
74         ComponentDesc* comp_desc;
75         struct berval identifier;
76         char id_buf[MAX_IDENTIFIER_LEN];
77         BMPString value;
78 } ComponentBMPString;
79
80 int GEncComponentBMPString (GenBuf *b, ComponentBMPString* bmp);
81 int GDecComponentBMPString (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
82 int BDecComponentBMPString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
83 #define MatchingComponentBMPString MatchingComponentOcts
84 #define ExtractingComponentBMPString( mem_op, cr, data ) NULL
85 #define FreeComponentBMPString FreeComponentOcts
86
87 /*
88  * BOOLEAN
89  */
90 typedef struct ComponentBool {
91         void* syntax;
92         ComponentDesc* comp_desc;
93         struct berval identifier;
94         char id_buf[MAX_IDENTIFIER_LEN];
95         AsnBool value;
96 } ComponentBool;
97
98 int GEncComponentBool (GenBuf *b, ComponentBool * bool );
99 int GDecComponentBool ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
100 int BDecComponentBool ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
101 int MatchingComponentBool (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
102 #define ExtractingComponentBool( mem_op, cr, data ) NULL
103 #define FreeComponentBool(v) NULL
104
105 /*
106  * ENUMERTED
107  */
108 typedef struct ComponentEnum {
109         void* syntax;
110         ComponentDesc* comp_desc;
111         struct berval identifier;
112         char id_buf[MAX_IDENTIFIER_LEN];
113         AsnEnum value;
114         struct berval value_identifier;/*Why this value is defined here?*/
115 } ComponentEnum;
116
117 int GEncComponentEnum (GenBuf *b, ComponentEnum* comp_enum);
118 int GDecComponentEnum ( void* mem_op, GenBuf *a, void *result, AsnLen *bytesDecoded,int mode);
119 int BDecComponentEnum ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
120 int MatchingComponentEnum (char *oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo * b);
121 #define ExtractingComponentEnum( mem_op, cr, data ) NULL
122 #define FreeComponentEnum FreeComponentInt
123
124 /*
125  * IA5 String
126  */
127 typedef struct ComponentIA5String {
128         void* syntax;
129         ComponentDesc* comp_desc;
130         struct berval identifier;
131         char id_buf[MAX_IDENTIFIER_LEN];
132         IA5String value;
133 } ComponentIA5String;
134
135 #define GEncComponentIA5String GEncComponentUTF8String
136 #define GDecComponentIA5String GDecComponentUTF8String
137 int
138 BDecComponentIA5StringTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
139 int BDecComponentIA5String ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
140 #define MatchingComponentIA5String MatchingComponentOcts
141 #define ExtractingComponentIA5String(mem_op, cr,data)   NULL
142 #define FreeComponentIA5String FreeComponentOcts
143
144
145 /*
146  * INTEGER
147  */
148 typedef struct ComponentInt {
149         void* syntax;
150         ComponentDesc* comp_desc;
151         struct berval identifier;
152         char id_buf[MAX_IDENTIFIER_LEN];
153         int value;
154 } ComponentInt;
155
156 #define GNOT_NULL(ptr) ((ptr) != NULL)
157 int GEncComponentInt (GenBuf *b, ComponentInt *comp_int);
158 int GDecComponentInt ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
159 int BDecComponentInt ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
160 int MatchingComponentInt (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
161 #define ExtractingComponentInt(mem_op, cr,data) NULL
162 #define FreeComponentInt(v) NULL
163
164 /*
165  * LIST Data Structure for C_LIST
166  */
167 typedef struct ComponentList {
168         void* syntax;
169         ComponentDesc* comp_desc;
170         struct berval identifier;
171         char id_buf[MAX_IDENTIFIER_LEN];
172         AsnList comp_list;
173 } ComponentList;
174
175 /*
176  * NULL
177  */
178 typedef struct ComponentNull {
179         void* syntax;
180         ComponentDesc* comp_desc;
181         struct berval identifier;
182         char id_buf[MAX_IDENTIFIER_LEN];
183         AsnNull value;
184 } ComponentNull;
185
186 int GEncComponentNull (GenBuf *b, ComponentNull* comp_null);
187 int GDecComponentNull ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
188 int BDecComponentNull ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
189 int BDecComponentNullTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
190 int MatchingComponentNull (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
191 #define ExtractingComponentNull(mem_op, cr, data)       NULL
192 #define FreeComponentNull NULL
193
194 /*
195  * Numeric String
196  */
197 typedef struct ComponentNumericString {
198         void* syntax;
199         ComponentDesc* comp_desc;
200         struct berval identifier;
201         char id_buf[MAX_IDENTIFIER_LEN];
202         NumericString value;
203 } ComponentNumericString;
204
205 #define GEncComponentNumericString GEncComponentUTF8String
206 #define GDecComponentNumericString GDecComponentUTF8String
207 int BDecComponentNumericString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
208 #define MatchingComponentNumericString MatchingComponentOcts
209 #define ExtractingComponentNumericString(mem_op, cr,data)       NULL
210 #define FreeComponentNumericString FreeComponentOcts
211
212 /*
213  * OCTETS STRING
214  */
215 typedef struct ComponentOcts {
216         void* syntax;
217         ComponentDesc* comp_desc;
218         struct berval identifier;
219         char id_buf[MAX_IDENTIFIER_LEN];
220         AsnOcts value;
221 } ComponentOcts;
222
223 #define GASNOCTS_PRESENT(aocts) ((aocts)->value.octs != NULL)
224 int GEncComponentOcts (GenBuf *b, ComponentOcts *octs);
225 int GDecComponentOcts (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
226 int BDecComponentOctsTag ( void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
227 int BDecComponentOcts (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
228 int MatchingComponentOcts (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
229 #define ExtractingComponentOcts(mem_op,cr,data) NULL
230 void FreeComponentOcts( ComponentOcts* octs );
231
232 /*
233  * OID (Object Identifier)
234  */
235 typedef struct ComponentOid {
236         void* syntax;
237         ComponentDesc* comp_desc;
238         struct berval identifier;
239         char id_buf[MAX_IDENTIFIER_LEN];
240         AsnOid value;
241 } ComponentOid;
242
243 #define GASNOID_PRESENT(aoid) ASNOCTS_PRESENT(aoid)
244 int GEncComponentOid (GenBuf *b, ComponentOid *oid);
245 int GDecComponentOid (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
246 int BDecComponentOid (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
247 int MatchingComponentOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
248 #define ExtractingComponentOid(mem_op, cr, data)        NULL
249 #define FreeComponentOid FreeComponentOcts
250
251 /*
252  * Printable String
253  */
254 typedef struct ComponentPrintableString{
255         void* syntax;
256         ComponentDesc* comp_desc;
257         struct berval identifier;
258         char id_buf[MAX_IDENTIFIER_LEN];
259         PrintableString value;
260 } ComponentPrintableString;
261 #define GEncComponentPrintableString GEncComponentUTF8String
262 #define GDecComponentPrintableString GDecComponentUTF8String
263 int BDecComponentPrintableString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
264 int BDecComponentPrintableStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
265 #define MatchingComponentPrintableString MatchingComponentOcts
266 #define ExtractingComponentPrintableString(mem_op, cr, data)    NULL
267 #define FreeComponentPrintableString FreeComponentOcts
268
269 /*
270  * REAL
271  */
272 typedef struct ComponentReal{
273         void* syntax;
274         ComponentDesc* comp_desc;
275         struct berval identifier;
276         char id_buf[MAX_IDENTIFIER_LEN];
277         AsnReal value;
278 } ComponentReal;
279
280 int GEncComponentReal (GenBuf *b, ComponentReal* comp_real);
281 int GDecComponentReal (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
282 int BDecComponentReal (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
283 int MatchingComponentReal (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
284 #define ExtractingComponentReal( mem_op, cr, data )     NULL
285 #define FreeComponentReal(v) NULL
286
287 /*
288  * Relative OID
289  */
290
291 typedef struct ComponentRelativeOid {
292         void* syntax;
293         ComponentDesc* comp_desc;
294         struct berval identifier;
295         char id_buf[MAX_IDENTIFIER_LEN];
296         AsnRelativeOid value;
297 } ComponentRelativeOid;
298
299 int GEncComponentRelativeOid (GenBuf *b, ComponentRelativeOid *r_oid);
300 int GDecComponentRelativeOid ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
301 int BDecComponentRelativeOid ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
302 int MatchingComponentRelativeOid (char* oid, ComponentSyntaxInfo *a, ComponentSyntaxInfo *b);
303 #define ExtractingComponentRelativeOid( mem_op, cr, data ) NULL
304 #define FreeComponentRelativeOid FreeComponentOid
305
306 /*
307  * Teletex String
308  */
309 typedef struct ComponentTeletexString {
310         void* syntax;
311         ComponentDesc* comp_desc;
312         struct berval identifier;
313         char id_buf[MAX_IDENTIFIER_LEN];
314         TeletexString value;
315 } ComponentTeletexString;
316
317 int GEncComponentTeletexString (GenBuf *b, ComponentTeletexString * tel_str);
318 int GDecComponentTeletexString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode );
319 #define BDecComponentTeletexString BDecComponentOcts
320 #define MatchingComponentTeletexString MatchingComponentOcts
321 #define ExtractingComponentTeletexString(mem_op,cr,data)
322 #define FreeComponentTeletexString FreeComponentOcts
323
324
325 /*
326  * Universal String
327  */
328 typedef struct ComponentUniversalString{
329         void* syntax;
330         ComponentDesc* comp_desc;
331         struct berval identifier;
332         char id_buf[MAX_IDENTIFIER_LEN];
333         UniversalString value;
334 } ComponentUniversalString;
335
336 int GEncComponentUniversalString (GenBuf *b, ComponentUniversalString* uni_str);
337 int GDecComponentUniversalString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
338 int BDecComponentUniversalString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
339 #define MatchingComponentUniversalString MatchingComponentOcts
340 #define ExtractingComponentUniversalString(mem_op,cr,data)
341 #define FreeComponentUniversalString FreeComponentOcts
342
343 /*
344  * UTF8 String
345  */
346 typedef struct ComponentUTF8String{
347         void* syntax;
348         ComponentDesc* comp_desc;
349         struct berval identifier;
350         char id_buf[MAX_IDENTIFIER_LEN];
351         UTF8String value;
352 } ComponentUTF8String;
353
354 int GEncComponentUTF8String (GenBuf *b, ComponentUTF8String * utf_str);
355 int GDecComponentUTF8String (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
356 int BDecComponentUTF8String (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
357 #define MatchingComponentUTF8String MatchingComponentOcts
358 #define ExtractingComponentUTF8String(mem_op,cr,data)
359 #define FreeComponentUTF8String FreeComponentOcts
360
361 /*
362  * Visible String
363  */
364 typedef struct ComponentVisibleString{
365         void* syntax;
366         ComponentDesc* comp_desc;
367         struct berval identifier;
368         char id_buf[MAX_IDENTIFIER_LEN];
369         VisibleString value;
370 } ComponentVisibleString;
371
372 #define GEncComponentVisibleString GEncComponentUTF8String
373 #define GDecComponentVisibleString GDecComponentUTF8String
374 int BDecComponentVisibleString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
375 #define MatchingComponentVisibleString MatchingComponentOcts
376 #define ExtractingComponentVisibleString(mem_op,cr,data)
377 #define FreeComponentVisibleString FreeComponentOcts
378
379 /*
380  * ANY and ANY DEFINED BY
381  */
382
383 typedef int (*MatchFcn) (char*, void*, void*);
384 typedef void* (*ExtractFcn) (void*, ComponentReference*, void * );
385
386 typedef struct ComponentAnyInfo
387 {
388         int             anyId;
389         AsnOid          oid;
390         ComponentInt    intId;
391         unsigned int    size;
392         EncodeFcn       Encode;
393         gser_decoder_func* GSER_Decode;
394         ber_tag_decoder_func* BER_Decode;
395         ExtractFcn      Extract;
396         MatchFcn        Match;
397         FreeFcn         Free;
398         PrintFcn        Print;
399 } ComponentAnyInfo;
400
401 typedef struct ComponentAnyInfo OidDecoderMapping ;
402
403 typedef struct ComponentAny{
404         void*           syntax;
405         ComponentDesc   *comp_desc;
406         struct berval   identifier;
407         char id_buf[MAX_IDENTIFIER_LEN];
408         ComponentAnyInfo        *cai;
409         void            *value;
410 } ComponentAny;
411
412 typedef ComponentAny ComponentAnyDefinedBy;
413
414 #define BDecComponentAnyDefinedBy BDecComponentAny
415 #define GDecComponentAnyDefinedBy GDecComponentAny
416 #define MatchingComponentAnyDefinedBy MatchingComponentAny
417 #define FreeComponentAnyDefinedBy FreeComponentAny
418
419 int GEncComponentAny (GenBuf *b, ComponentAny *comp_any);
420 int BDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
421 int GDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
422 int MatchingComponentAny (char* oid, ComponentAny *a, ComponentAny *b);
423 void FreeComponentAny ( ComponentAny*);
424
425 void InstallAnyByComponentInt (int anyId, ComponentInt intId, unsigned int size, EncodeFcn encode, gser_decoder_func* G_decode, ber_tag_decoder_func B_decode, ExtractFcn extract, MatchFcn match, FreeFcn free, PrintFcn print);
426
427 void InstallAnyByComponentOid (int anyId, AsnOid *oid, unsigned int size, EncodeFcn encode, gser_decoder_func* G_decode, ber_tag_decoder_func* B_decode, ExtractFcn extract, MatchFcn match, FreeFcn free, PrintFcn print);
428
429 int CheckSelectTypeCorrect ( void* mem_op, ComponentAnyInfo *v, struct berval* select );
430
431 OidDecoderMapping* RetrieveOidDecoderMappingbyBV( struct berval* in );
432 OidDecoderMapping* RetrieveOidDecoderMappingbyOid( char* ch_oid, int oid_len );
433 OidDecoderMapping* RetrieveOidDecoderMappingbyDesc( char* desc, int desc_len );
434 /*
435  * UTCTime
436  */
437 typedef ComponentVisibleString ComponentUTCTime;
438 int GEncComponentUTCTime( GenBuf* b, ComponentUTCTime* utc_time);
439 #define GDecComponentUTCTime GDecComponentVisibleString
440 #define BDecComponentUTCTime BDecComponentOcts
441 #define MatchingComponentUTCTime MatchingComponentOcts
442 #define ExtractingComponentUTCTime(mem_op,cr,data) NULL
443 #define FreeComponentUTCTime FreeComponentOcts
444
445 /*
446  * GeneralizedTime
447  */
448 typedef ComponentVisibleString ComponentGeneralizedTime;
449 int GEncComponentGeneralizedTime (GenBuf *b, ComponentGeneralizedTime *gen_time);
450 #define GDecComponentGeneralizedTime GDecComponentVisibleString
451 #define BDecComponentGeneralizedTime BDecComponentOcts
452 #define MatchingComponentGeneralizedTime MatchingComponentOcts
453 #define ExtractingComponentGeneralizedTime(mem_op,cr,data) NULL
454 #define FreeComponentGeneralizedTime FreeComponentOcts
455
456 typedef int converter_func LDAP_P ((
457         struct berval* in ));
458
459 typedef struct asntype_to_syntax {
460         AsnTypeId       ats_typeId;
461         /* Syntax Descriptor */
462         char            *ats_syn_name;
463         /* Syntax OID */
464         char            *ats_syn_oid;
465         Syntax          *ats_syn;
466 } AsnTypetoSyntax;
467
468 typedef struct asntype_to_comp_matchingrule {
469         AsnTypeId       atc_typeId;
470         char*   atc_equality;
471         char*   atc_approx;
472         char*   atc_ordering;
473         char*   atc_substr;
474 } AsnTypetoCompMatchingRule;
475
476 typedef struct asntype_to_comp_desc {
477         AsnTypeId       atcd_typeId;
478         ComponentDesc   atcd_cd;
479 } AsnTypetoCompDesc;
480
481 typedef struct asntype_to_comp_type {
482         AsnTypeId       ac_asn_id;
483         ComponentType   ac_comp_type;
484 } AsnTypetoCompType;
485
486 /* refined matching purpose */
487 typedef struct asntype_to_matchingrule {
488         AsnTypeId       atmr_typeId;
489         char*           atmr_mr_name;
490         /*Implicitly corresponding LDAP syntax OID*/
491         char*           atmr_syn_oid;
492         MatchingRule    *atmr_mr;
493 } AsnTypetoMatchingRule;
494
495 typedef struct asntype_to_matchingrule_table {
496         char*   atmr_oid;
497         struct asntype_to_matchingrule atmr_table[ASNTYPE_END];
498         struct asntype_to_matchingrule_table* atmr_table_next;
499 } AsnTypetoMatchingRuleTable;
500
501 #define MAX_OID_LEN 256
502 #define MAX_OD_ENTRY 8
503
504 /*
505  * Object Identifier and corresponding Syntax Decoder Table
506  */
507 typedef struct OID_Decoder_entry {
508         char            oe_oid[MAX_OID_LEN];
509         gser_decoder_func*   oe_gser_decoder;
510         ber_decoder_func*   oe_ber_decoder;
511         converter_func* oe_converter;
512         struct OID_Decoder_entry*       oe_next;
513         struct OID_Decoder_entry*       oe_prev;
514 } OD_entry;
515
516 void
517 m_convert_asn_to_ldap ( ComponentSyntaxInfo* csi, struct berval* bv);
518 int
519 m_convert_assert_to_comp ( gser_decoder_func* decoder, struct berval* bv,
520                         ComponentSyntaxInfo** csi, int len, int mode );
521 void*
522 m_convert_attr_to_comp ( Attribute* a, struct berval* bv );
523
524 /*
525  * Decoder Modes
526  * Different operation is required to handle Decoding(2), Extracted Component
527  * decoding(0), ANY DEFINED TYPe(2)
528  * b0 : Component Alloc(yes)
529  *      Constructed type : Component Alloc (Yes)
530  *      Primitive type : Component Alloc (Yes)
531  *      set to mode 2 in inner decoders
532  * b1 : Component Alloc (No)
533  *      Constructed type : Component Alloc (No)
534  *      Primitive type : Component Alloc (No)
535  *      set to mode 2 in inner decoders
536  * b2 : Default Mode
537  *      Constructed type : Component Alloc (Yes)
538  *      Primitive type : Component Alloc (No)
539  * in addition to above modes, the 4th bit has special meaning,
540  * b4 : if the 4th bit is clear, DecxxxContent is called
541  * b4 : if the 4th bit is set, Decxxx is called, then it is cleared.
542  */
543 #define DEC_ALLOC_MODE_0        0x01
544 #define DEC_ALLOC_MODE_1        0x02
545 #define DEC_ALLOC_MODE_2        0x04
546 #define CALL_TAG_DECODER        0x08
547 #define CALL_CONTENT_DECODER    ~0x08
548
549 #define OID_ALL_COMP_MATCH "1.2.36.79672281.1.13.6"
550 #define OID_COMP_FILTER_MATCH "1.2.36.79672281.1.13.2"
551 #define MAX_LDAP_STR_LEN 128
552
553 MatchingRule*
554 retrieve_matching_rule( char* mr_oid, AsnTypeId type );
555
556 #define INITIAL_DN_SIZE 128
557 #define INITIAL_ATTR_SIZE 256
558 #define INCREMENT_SIZE 32
559 /*
560  * Followings are for conversion from ASN.1 RDN and DN to
561  * LDAP encodings
562  */
563 #define MAX_ALIASING_ENTRY 128
564 int increment_bv_mem ( struct berval* in );
565 int intToAscii ( int value, char* buf );
566 typedef ComponentList irRDNSequence;
567 typedef ComponentList irRelativeDistinguishedName;
568 typedef ComponentOid irAttributeType;
569 typedef struct comp_irAttributeTypeAndValue /* SEQUENCE */
570 {
571         Syntax* syntax;
572         ComponentDesc* comp_desc;
573         struct berval identifier;
574         char id_buf[MAX_IDENTIFIER_LEN];
575         irAttributeType type; /* AttributeType */
576         ComponentAnyDefinedBy value; /* ANY DEFINED BY type */
577 } irAttributeTypeAndValue;
578 #define RDN_MATCH_OID "1.2.36.79672281.1.13.3"
579 #define DN_MATCH_OID "2.5.13.1"
580
581 extern AsnTypetoSyntax asn_to_syntax_mapping_tbl[];
582 extern AsnTypetoCompMatchingRule asntype_to_compMR_mapping_tbl[];
583 extern AsnTypetoCompType asntype_to_compType_mapping_tbl[];
584 extern AsnTypetoCompDesc asntype_to_compdesc_mapping_tbl[];
585
586 int ConvertRDN2RFC2253 ( irRelativeDistinguishedName* in, struct berval *out );
587 int ConvertRDNSequence2RFC2253( irRDNSequence *in, struct berval* out );
588         
589 void* comp_nibble_memory_allocator ( int init_mem, int inc_mem );
590 #endif