xref: /netbsd-src/external/bsd/openldap/dist/contrib/slapd-modules/comp_match/componentlib.h (revision c8da0e5fefd3800856b306200a18b2315c7fbb9f)
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	32
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 int BDecComponentTeletexStringTag (void* mem_op, GenBuf *b, void *v, AsnLen *bytesDecoded, int mode );
320 int BDecComponentTeletexString( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *v, AsnLen *bytesDecoded, int mode );
321 #define MatchingComponentTeletexString MatchingComponentOcts
322 #define ExtractingComponentTeletexString(mem_op,cr,data)
323 #define FreeComponentTeletexString FreeComponentOcts
324 
325 
326 /*
327  * Universal String
328  */
329 typedef struct ComponentUniversalString{
330 	void* syntax;
331 	ComponentDesc* comp_desc;
332 	struct berval identifier;
333 	char id_buf[MAX_IDENTIFIER_LEN];
334 	UniversalString value;
335 } ComponentUniversalString;
336 
337 int GEncComponentUniversalString (GenBuf *b, ComponentUniversalString* uni_str);
338 int GDecComponentUniversalString ( void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
339 int BDecComponentUniversalString ( void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
340 #define MatchingComponentUniversalString MatchingComponentOcts
341 #define ExtractingComponentUniversalString(mem_op,cr,data)
342 #define FreeComponentUniversalString FreeComponentOcts
343 
344 /*
345  * UTF8 String
346  */
347 typedef struct ComponentUTF8String{
348 	void* syntax;
349 	ComponentDesc* comp_desc;
350 	struct berval identifier;
351 	char id_buf[MAX_IDENTIFIER_LEN];
352 	UTF8String value;
353 } ComponentUTF8String;
354 
355 int GEncComponentUTF8String (GenBuf *b, ComponentUTF8String * utf_str);
356 int GDecComponentUTF8String (void* mem_op, GenBuf *b, void *result, AsnLen *bytesDecoded, int mode);
357 int BDecComponentUTF8String (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
358 #define MatchingComponentUTF8String MatchingComponentOcts
359 #define ExtractingComponentUTF8String(mem_op,cr,data)
360 #define FreeComponentUTF8String FreeComponentOcts
361 
362 /*
363  * Visible String
364  */
365 typedef struct ComponentVisibleString{
366 	void* syntax;
367 	ComponentDesc* comp_desc;
368 	struct berval identifier;
369 	char id_buf[MAX_IDENTIFIER_LEN];
370 	VisibleString value;
371 } ComponentVisibleString;
372 
373 #define GEncComponentVisibleString GEncComponentUTF8String
374 #define GDecComponentVisibleString GDecComponentUTF8String
375 int BDecComponentVisibleString (void* mem_op, GenBuf *b, AsnTag tagId, AsnLen len, void *result, AsnLen *bytesDecoded, int mode);
376 #define MatchingComponentVisibleString MatchingComponentOcts
377 #define ExtractingComponentVisibleString(mem_op,cr,data)
378 #define FreeComponentVisibleString FreeComponentOcts
379 
380 /*
381  * ANY and ANY DEFINED BY
382  */
383 
384 typedef int (*MatchFcn) (char*, void*, void*);
385 typedef void* (*ExtractFcn) (void*, ComponentReference*, void * );
386 
387 typedef struct ComponentAnyInfo
388 {
389 	int		anyId;
390 	AsnOid		oid;
391 	ComponentInt	intId;
392 	unsigned int	size;
393 	EncodeFcn	Encode;
394 	gser_decoder_func* GSER_Decode;
395 	ber_tag_decoder_func* BER_Decode;
396 	ExtractFcn	Extract;
397 	MatchFcn	Match;
398 	FreeFcn		Free;
399 	PrintFcn	Print;
400 } ComponentAnyInfo;
401 
402 typedef struct ComponentAnyInfo OidDecoderMapping ;
403 
404 typedef struct ComponentAny{
405 	void*		syntax;
406 	ComponentDesc	*comp_desc;
407 	struct berval	identifier;
408 	char id_buf[MAX_IDENTIFIER_LEN];
409 	ComponentAnyInfo	*cai;
410 	void		*value;
411 } ComponentAny;
412 
413 typedef ComponentAny ComponentAnyDefinedBy;
414 
415 #define BDecComponentAnyDefinedBy BDecComponentAny
416 #define GDecComponentAnyDefinedBy GDecComponentAny
417 #define MatchingComponentAnyDefinedBy MatchingComponentAny
418 #define FreeComponentAnyDefinedBy FreeComponentAny
419 
420 int GEncComponentAny (GenBuf *b, ComponentAny *comp_any);
421 int BDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
422 int GDecComponentAny ( void* mem_op, GenBuf *b, ComponentAny *result, AsnLen *bytesDecoded, int mode);
423 int MatchingComponentAny (char* oid, ComponentAny *a, ComponentAny *b);
424 void FreeComponentAny ( ComponentAny*);
425 
426 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);
427 
428 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);
429 
430 int CheckSelectTypeCorrect ( void* mem_op, ComponentAnyInfo *v, struct berval* select );
431 
432 OidDecoderMapping* RetrieveOidDecoderMappingbyBV( struct berval* in );
433 OidDecoderMapping* RetrieveOidDecoderMappingbyOid( char* ch_oid, int oid_len );
434 OidDecoderMapping* RetrieveOidDecoderMappingbyDesc( char* desc, int desc_len );
435 /*
436  * UTCTime
437  */
438 typedef ComponentVisibleString ComponentUTCTime;
439 #define GEncComponentUTCTime GEncComponentUTF8String
440 #define GDecComponentUTCTime GDecComponentVisibleString
441 #define BDecComponentUTCTime BDecComponentOcts
442 #define MatchingComponentUTCTime MatchingComponentOcts
443 #define ExtractingComponentUTCTime(mem_op,cr,data) NULL
444 #define FreeComponentUTCTime FreeComponentOcts
445 
446 /*
447  * GeneralizedTime
448  */
449 typedef ComponentVisibleString ComponentGeneralizedTime;
450 int GEncComponentGeneralizedTime (GenBuf *b, ComponentGeneralizedTime *gen_time);
451 #define GDecComponentGeneralizedTime GDecComponentVisibleString
452 #define BDecComponentGeneralizedTime BDecComponentOcts
453 #define MatchingComponentGeneralizedTime MatchingComponentOcts
454 #define ExtractingComponentGeneralizedTime(mem_op,cr,data) NULL
455 #define FreeComponentGeneralizedTime FreeComponentOcts
456 
457 typedef int converter_func LDAP_P ((
458 	struct berval* in ));
459 
460 typedef struct asntype_to_syntax {
461 	AsnTypeId	ats_typeId;
462 	/* Syntax Descriptor */
463 	char		*ats_syn_name;
464 	/* Syntax OID */
465 	char		*ats_syn_oid;
466 	Syntax		*ats_syn;
467 } AsnTypetoSyntax;
468 
469 typedef struct asntype_to_comp_matchingrule {
470 	AsnTypeId	atc_typeId;
471 	char*	atc_equality;
472 	char*	atc_approx;
473 	char*	atc_ordering;
474 	char*	atc_substr;
475 } AsnTypetoCompMatchingRule;
476 
477 typedef struct asntype_to_comp_desc {
478 	AsnTypeId	atcd_typeId;
479 	ComponentDesc	atcd_cd;
480 } AsnTypetoCompDesc;
481 
482 typedef struct asntype_to_comp_type {
483 	AsnTypeId	ac_asn_id;
484 	ComponentType   ac_comp_type;
485 } AsnTypetoCompType;
486 
487 /* refined matching purpose */
488 typedef struct asntype_to_matchingrule {
489 	AsnTypeId	atmr_typeId;
490 	char*		atmr_mr_name;
491 	/*Implicitly corresponding LDAP syntax OID*/
492 	char*		atmr_syn_oid;
493 	MatchingRule	*atmr_mr;
494 } AsnTypetoMatchingRule;
495 
496 typedef struct asntype_to_matchingrule_table {
497 	char*	atmr_oid;
498 	struct asntype_to_matchingrule atmr_table[ASNTYPE_END];
499 	struct asntype_to_matchingrule_table* atmr_table_next;
500 } AsnTypetoMatchingRuleTable;
501 
502 #define MAX_OID_LEN 256
503 #define MAX_OD_ENTRY 8
504 
505 /*
506  * Object Identifier and corresponding Syntax Decoder Table
507  */
508 typedef struct OID_Decoder_entry {
509         char            oe_oid[MAX_OID_LEN];
510         gser_decoder_func*   oe_gser_decoder;
511         ber_decoder_func*   oe_ber_decoder;
512 	converter_func* oe_converter;
513         struct OID_Decoder_entry*       oe_next;
514         struct OID_Decoder_entry*       oe_prev;
515 } OD_entry;
516 
517 void
518 m_convert_asn_to_ldap ( ComponentSyntaxInfo* csi, struct berval* bv);
519 int
520 m_convert_assert_to_comp ( gser_decoder_func* decoder, struct berval* bv,
521                         ComponentSyntaxInfo** csi, int len, int mode );
522 void*
523 m_convert_attr_to_comp ( Attribute* a, struct berval* bv );
524 
525 /*
526  * Decoder Modes
527  * Different operation is required to handle Decoding(2), Extracted Component
528  * decoding(0), ANY DEFINED TYPe(2)
529  * b0 : Component Alloc(yes)
530  *	Constructed type : Component Alloc (Yes)
531  *	Primitive type : Component Alloc (Yes)
532  * 	set to mode 2 in inner decoders
533  * b1 : Component Alloc (No)
534  *	Constructed type : Component Alloc (No)
535  *	Primitive type : Component Alloc (No)
536  *	set to mode 2 in inner decoders
537  * b2 : Default Mode
538  *	Constructed type : Component Alloc (Yes)
539  *	Primitive type : Component Alloc (No)
540  * in addition to above modes, the 4th bit has special meaning,
541  * b4 : if the 4th bit is clear, DecxxxContent is called
542  * b4 : if the 4th bit is set, Decxxx is called, then it is cleared.
543  */
544 #define DEC_ALLOC_MODE_0	0x01
545 #define DEC_ALLOC_MODE_1	0x02
546 #define DEC_ALLOC_MODE_2	0x04
547 #define CALL_TAG_DECODER	0x08
548 #define CALL_CONTENT_DECODER	~0x08
549 
550 #define OID_ALL_COMP_MATCH "1.2.36.79672281.1.13.6"
551 #define OID_COMP_FILTER_MATCH "1.2.36.79672281.1.13.2"
552 #define MAX_LDAP_STR_LEN 128
553 
554 MatchingRule*
555 retrieve_matching_rule( char* mr_oid, AsnTypeId type );
556 
557 #define INITIAL_DN_SIZE 128
558 #define INITIAL_ATTR_SIZE 256
559 #define INCREMENT_SIZE 32
560 /*
561  * Followings are for conversion from ASN.1 RDN and DN to
562  * LDAP encodings
563  */
564 #define MAX_ALIASING_ENTRY 128
565 int increment_bv_mem ( struct berval* in );
566 int intToAscii ( int value, char* buf );
567 typedef ComponentList irRDNSequence;
568 typedef ComponentList irRelativeDistinguishedName;
569 typedef ComponentOid irAttributeType;
570 typedef struct comp_irAttributeTypeAndValue /* SEQUENCE */
571 {
572 	Syntax* syntax;
573 	ComponentDesc* comp_desc;
574 	struct berval identifier;
575 	char id_buf[MAX_IDENTIFIER_LEN];
576 	irAttributeType type; /* AttributeType */
577 	ComponentAnyDefinedBy value; /* ANY DEFINED BY type */
578 } irAttributeTypeAndValue;
579 #define RDN_MATCH_OID "1.2.36.79672281.1.13.3"
580 #define DN_MATCH_OID "2.5.13.1"
581 
582 extern AsnTypetoSyntax asn_to_syntax_mapping_tbl[];
583 extern AsnTypetoCompMatchingRule asntype_to_compMR_mapping_tbl[];
584 extern AsnTypetoCompType asntype_to_compType_mapping_tbl[];
585 extern AsnTypetoCompDesc asntype_to_compdesc_mapping_tbl[];
586 
587 int ConvertRDN2RFC2253 ( irRelativeDistinguishedName* in, struct berval *out );
588 int ConvertRDNSequence2RFC2253( irRDNSequence *in, struct berval* out );
589 
590 void* comp_nibble_memory_allocator ( int init_mem, int inc_mem );
591 
592 ComponentDesc* get_ComponentDesc( int id );
593 #endif
594