2e9ee7f2b932d5dcb89d29fa2b017eef937e795d
[com/asn1c.git] / tests / tests-asn1c-compiler / 19-param-OK.asn1.-Pfwide-types
1
2 /*** <<< INCLUDES [SIGNED] >>> ***/
3
4 #include <OBJECT_IDENTIFIER.h>
5 #include <BIT_STRING.h>
6 #include <INTEGER.h>
7 #include "Name.h"
8 #include <constr_SEQUENCE.h>
9
10 /*** <<< TYPE-DECLS [SIGNED] >>> ***/
11
12 typedef struct SIGNED_15P0 {
13         struct toBeSigned {
14                 INTEGER_t        version;
15                 OBJECT_IDENTIFIER_t      signature;
16                 Name_t   issuer;
17                 
18                 /* Context for parsing across buffer boundaries */
19                 asn_struct_ctx_t _asn_ctx;
20         } toBeSigned;
21         OBJECT_IDENTIFIER_t      algorithm;
22         BIT_STRING_t     signature;
23         
24         /* Context for parsing across buffer boundaries */
25         asn_struct_ctx_t _asn_ctx;
26 } SIGNED_15P0_t;
27
28 /*** <<< FUNC-DECLS [SIGNED] >>> ***/
29
30 extern asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0;
31 extern asn_SEQUENCE_specifics_t asn_SPC_SIGNED_15P0_specs_1;
32 extern asn_TYPE_member_t asn_MBR_SIGNED_15P0_1[3];
33
34 /*** <<< CODE [SIGNED] >>> ***/
35
36 static int
37 memb_signature_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
38                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
39         const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
40         size_t size;
41         
42         if(!sptr) {
43                 ASN__CTFAIL(app_key, td, sptr,
44                         "%s: value not given (%s:%d)",
45                         td->name, __FILE__, __LINE__);
46                 return -1;
47         }
48         
49         if(st->size > 0) {
50                 /* Size in bits */
51                 size = 8 * st->size - (st->bits_unused & 0x07);
52         } else {
53                 size = 0;
54         }
55         
56         if((size <= 256)) {
57                 /* Constraint check succeeded */
58                 return 0;
59         } else {
60                 ASN__CTFAIL(app_key, td, sptr,
61                         "%s: constraint failed (%s:%d)",
62                         td->name, __FILE__, __LINE__);
63                 return -1;
64         }
65 }
66
67
68 /*** <<< STAT-DEFS [SIGNED] >>> ***/
69
70 static asn_TYPE_member_t asn_MBR_toBeSigned_2[] = {
71         { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, version),
72                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
73                 .tag_mode = 0,
74                 .type = &asn_DEF_INTEGER,
75                 .type_selector = 0,
76                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
77                 0, 0, /* No default value */
78                 .name = "version"
79                 },
80         { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, signature),
81                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
82                 .tag_mode = 0,
83                 .type = &asn_DEF_OBJECT_IDENTIFIER,
84                 .type_selector = 0,
85                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
86                 0, 0, /* No default value */
87                 .name = "signature"
88                 },
89         { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, issuer),
90                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
91                 .tag_mode = 0,
92                 .type = &asn_DEF_Name,
93                 .type_selector = 0,
94                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
95                 0, 0, /* No default value */
96                 .name = "issuer"
97                 },
98 };
99 static const ber_tlv_tag_t asn_DEF_toBeSigned_tags_2[] = {
100         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
101 };
102 static const asn_TYPE_tag2member_t asn_MAP_toBeSigned_tag2el_2[] = {
103     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* version */
104     { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* signature */
105     { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 2, 0, 0 } /* issuer */
106 };
107 static asn_SEQUENCE_specifics_t asn_SPC_toBeSigned_specs_2 = {
108         sizeof(struct toBeSigned),
109         offsetof(struct toBeSigned, _asn_ctx),
110         .tag2el = asn_MAP_toBeSigned_tag2el_2,
111         .tag2el_count = 3,      /* Count of tags in the map */
112         0, 0, 0,        /* Optional elements (not needed) */
113         -1,     /* First extension addition */
114 };
115 static /* Use -fall-defs-global to expose */
116 asn_TYPE_descriptor_t asn_DEF_toBeSigned_2 = {
117         "toBeSigned",
118         "toBeSigned",
119         &asn_OP_SEQUENCE,
120         asn_DEF_toBeSigned_tags_2,
121         sizeof(asn_DEF_toBeSigned_tags_2)
122                 /sizeof(asn_DEF_toBeSigned_tags_2[0]), /* 1 */
123         asn_DEF_toBeSigned_tags_2,      /* Same as above */
124         sizeof(asn_DEF_toBeSigned_tags_2)
125                 /sizeof(asn_DEF_toBeSigned_tags_2[0]), /* 1 */
126         { 0, 0, SEQUENCE_constraint },
127         asn_MBR_toBeSigned_2,
128         3,      /* Elements count */
129         &asn_SPC_toBeSigned_specs_2     /* Additional specs */
130 };
131
132 asn_TYPE_member_t asn_MBR_SIGNED_15P0_1[] = {
133         { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, toBeSigned),
134                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
135                 .tag_mode = 0,
136                 .type = &asn_DEF_toBeSigned_2,
137                 .type_selector = 0,
138                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
139                 0, 0, /* No default value */
140                 .name = "toBeSigned"
141                 },
142         { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, algorithm),
143                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
144                 .tag_mode = 0,
145                 .type = &asn_DEF_OBJECT_IDENTIFIER,
146                 .type_selector = 0,
147                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
148                 0, 0, /* No default value */
149                 .name = "algorithm"
150                 },
151         { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, signature),
152                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
153                 .tag_mode = 0,
154                 .type = &asn_DEF_BIT_STRING,
155                 .type_selector = 0,
156                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_signature_constraint_1 },
157                 0, 0, /* No default value */
158                 .name = "signature"
159                 },
160 };
161 static const ber_tlv_tag_t asn_DEF_SIGNED_15P0_tags_1[] = {
162         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
163 };
164 static const asn_TYPE_tag2member_t asn_MAP_SIGNED_15P0_tag2el_1[] = {
165     { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 2, 0, 0 }, /* signature */
166     { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm */
167     { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* toBeSigned */
168 };
169 asn_SEQUENCE_specifics_t asn_SPC_SIGNED_15P0_specs_1 = {
170         sizeof(struct SIGNED_15P0),
171         offsetof(struct SIGNED_15P0, _asn_ctx),
172         .tag2el = asn_MAP_SIGNED_15P0_tag2el_1,
173         .tag2el_count = 3,      /* Count of tags in the map */
174         0, 0, 0,        /* Optional elements (not needed) */
175         -1,     /* First extension addition */
176 };
177 asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0 = {
178         "SIGNED",
179         "SIGNED",
180         &asn_OP_SEQUENCE,
181         asn_DEF_SIGNED_15P0_tags_1,
182         sizeof(asn_DEF_SIGNED_15P0_tags_1)
183                 /sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */
184         asn_DEF_SIGNED_15P0_tags_1,     /* Same as above */
185         sizeof(asn_DEF_SIGNED_15P0_tags_1)
186                 /sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */
187         { 0, 0, SEQUENCE_constraint },
188         asn_MBR_SIGNED_15P0_1,
189         3,      /* Elements count */
190         &asn_SPC_SIGNED_15P0_specs_1    /* Additional specs */
191 };
192
193
194 /*** <<< INCLUDES [Certificate] >>> ***/
195
196 #include "SIGNED.h"
197
198 /*** <<< TYPE-DECLS [Certificate] >>> ***/
199
200 typedef SIGNED_15P0_t    Certificate_t;
201
202 /*** <<< FUNC-DECLS [Certificate] >>> ***/
203
204 extern asn_TYPE_descriptor_t asn_DEF_Certificate;
205 asn_struct_free_f Certificate_free;
206 asn_struct_print_f Certificate_print;
207 asn_constr_check_f Certificate_constraint;
208 ber_type_decoder_f Certificate_decode_ber;
209 der_type_encoder_f Certificate_encode_der;
210 xer_type_decoder_f Certificate_decode_xer;
211 xer_type_encoder_f Certificate_encode_xer;
212
213 /*** <<< CODE [Certificate] >>> ***/
214
215 /*
216  * This type is implemented using SIGNED_15P0,
217  * so here we adjust the DEF accordingly.
218  */
219
220 /*** <<< STAT-DEFS [Certificate] >>> ***/
221
222 static const ber_tlv_tag_t asn_DEF_Certificate_tags_1[] = {
223         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
224 };
225 asn_TYPE_descriptor_t asn_DEF_Certificate = {
226         "Certificate",
227         "Certificate",
228         &asn_OP_SEQUENCE,
229         asn_DEF_Certificate_tags_1,
230         sizeof(asn_DEF_Certificate_tags_1)
231                 /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
232         asn_DEF_Certificate_tags_1,     /* Same as above */
233         sizeof(asn_DEF_Certificate_tags_1)
234                 /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
235         { 0, 0, SEQUENCE_constraint },
236         asn_MBR_SIGNED_15P0_1,
237         3,      /* Elements count */
238         &asn_SPC_SIGNED_15P0_specs_1    /* Additional specs */
239 };
240
241
242 /*** <<< INCLUDES [Name] >>> ***/
243
244 #include <asn_SEQUENCE_OF.h>
245 #include <constr_SEQUENCE_OF.h>
246
247 /*** <<< FWD-DECLS [Name] >>> ***/
248
249 struct RelativeDistinguishedName;
250
251 /*** <<< TYPE-DECLS [Name] >>> ***/
252
253 typedef struct Name {
254         A_SEQUENCE_OF(struct RelativeDistinguishedName) list;
255         
256         /* Context for parsing across buffer boundaries */
257         asn_struct_ctx_t _asn_ctx;
258 } Name_t;
259
260 /*** <<< FUNC-DECLS [Name] >>> ***/
261
262 extern asn_TYPE_descriptor_t asn_DEF_Name;
263 extern asn_SET_OF_specifics_t asn_SPC_Name_specs_1;
264 extern asn_TYPE_member_t asn_MBR_Name_1[1];
265
266 /*** <<< POST-INCLUDE [Name] >>> ***/
267
268 #include "RelativeDistinguishedName.h"
269
270 /*** <<< STAT-DEFS [Name] >>> ***/
271
272 asn_TYPE_member_t asn_MBR_Name_1[] = {
273         { ATF_POINTER, 0, 0,
274                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
275                 .tag_mode = 0,
276                 .type = &asn_DEF_RelativeDistinguishedName,
277                 .type_selector = 0,
278                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
279                 0, 0, /* No default value */
280                 .name = ""
281                 },
282 };
283 static const ber_tlv_tag_t asn_DEF_Name_tags_1[] = {
284         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
285 };
286 asn_SET_OF_specifics_t asn_SPC_Name_specs_1 = {
287         sizeof(struct Name),
288         offsetof(struct Name, _asn_ctx),
289         0,      /* XER encoding is XMLDelimitedItemList */
290 };
291 asn_TYPE_descriptor_t asn_DEF_Name = {
292         "Name",
293         "Name",
294         &asn_OP_SEQUENCE_OF,
295         asn_DEF_Name_tags_1,
296         sizeof(asn_DEF_Name_tags_1)
297                 /sizeof(asn_DEF_Name_tags_1[0]), /* 1 */
298         asn_DEF_Name_tags_1,    /* Same as above */
299         sizeof(asn_DEF_Name_tags_1)
300                 /sizeof(asn_DEF_Name_tags_1[0]), /* 1 */
301         { 0, 0, SEQUENCE_OF_constraint },
302         asn_MBR_Name_1,
303         1,      /* Single element */
304         &asn_SPC_Name_specs_1   /* Additional specs */
305 };
306
307
308 /*** <<< INCLUDES [RelativeDistinguishedName] >>> ***/
309
310 #include <IA5String.h>
311 #include <asn_SET_OF.h>
312 #include <constr_SET_OF.h>
313
314 /*** <<< TYPE-DECLS [RelativeDistinguishedName] >>> ***/
315
316 typedef struct RelativeDistinguishedName {
317         A_SET_OF(IA5String_t) list;
318         
319         /* Context for parsing across buffer boundaries */
320         asn_struct_ctx_t _asn_ctx;
321 } RelativeDistinguishedName_t;
322
323 /*** <<< FUNC-DECLS [RelativeDistinguishedName] >>> ***/
324
325 extern asn_TYPE_descriptor_t asn_DEF_RelativeDistinguishedName;
326 extern asn_SET_OF_specifics_t asn_SPC_RelativeDistinguishedName_specs_1;
327 extern asn_TYPE_member_t asn_MBR_RelativeDistinguishedName_1[1];
328
329 /*** <<< CTABLES [RelativeDistinguishedName] >>> ***/
330
331 static const int permitted_alphabet_table_2[256] = {
332  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        /*                  */
333  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        /*                  */
334  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0,        /*             ,-.  */
335  4, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0,        /* 0        9       */
336  0, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,        /*  ABCDEFGHIJKLMNO */
337 21,22,23,24,25,26,27,28,29,30,31, 0, 0, 0, 0, 0,        /* PQRSTUVWXYZ      */
338  0,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,        /*  abcdefghijklmno */
339 47,48,49,50,51,52,53,54,55,56,57, 0, 0, 0, 0, 0,        /* pqrstuvwxyz      */
340 };
341
342 static int check_permitted_alphabet_2(const void *sptr) {
343         const int *table = permitted_alphabet_table_2;
344         /* The underlying type is IA5String */
345         const IA5String_t *st = (const IA5String_t *)sptr;
346         const uint8_t *ch = st->buf;
347         const uint8_t *end = ch + st->size;
348         
349         for(; ch < end; ch++) {
350                 uint8_t cv = *ch;
351                 if(!table[cv]) return -1;
352         }
353         return 0;
354 }
355
356
357 /*** <<< CODE [RelativeDistinguishedName] >>> ***/
358
359 static int
360 memb_IA5String_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
361                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
362         const IA5String_t *st = (const IA5String_t *)sptr;
363         
364         if(!sptr) {
365                 ASN__CTFAIL(app_key, td, sptr,
366                         "%s: value not given (%s:%d)",
367                         td->name, __FILE__, __LINE__);
368                 return -1;
369         }
370         
371         
372         if(!check_permitted_alphabet_2(st)) {
373                 /* Constraint check succeeded */
374                 return 0;
375         } else {
376                 ASN__CTFAIL(app_key, td, sptr,
377                         "%s: constraint failed (%s:%d)",
378                         td->name, __FILE__, __LINE__);
379                 return -1;
380         }
381 }
382
383
384 /*** <<< STAT-DEFS [RelativeDistinguishedName] >>> ***/
385
386 asn_TYPE_member_t asn_MBR_RelativeDistinguishedName_1[] = {
387         { ATF_POINTER, 0, 0,
388                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
389                 .tag_mode = 0,
390                 .type = &asn_DEF_IA5String,
391                 .type_selector = 0,
392                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_IA5String_constraint_1 },
393                 0, 0, /* No default value */
394                 .name = ""
395                 },
396 };
397 static const ber_tlv_tag_t asn_DEF_RelativeDistinguishedName_tags_1[] = {
398         (ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
399 };
400 asn_SET_OF_specifics_t asn_SPC_RelativeDistinguishedName_specs_1 = {
401         sizeof(struct RelativeDistinguishedName),
402         offsetof(struct RelativeDistinguishedName, _asn_ctx),
403         0,      /* XER encoding is XMLDelimitedItemList */
404 };
405 asn_TYPE_descriptor_t asn_DEF_RelativeDistinguishedName = {
406         "RelativeDistinguishedName",
407         "RelativeDistinguishedName",
408         &asn_OP_SET_OF,
409         asn_DEF_RelativeDistinguishedName_tags_1,
410         sizeof(asn_DEF_RelativeDistinguishedName_tags_1)
411                 /sizeof(asn_DEF_RelativeDistinguishedName_tags_1[0]), /* 1 */
412         asn_DEF_RelativeDistinguishedName_tags_1,       /* Same as above */
413         sizeof(asn_DEF_RelativeDistinguishedName_tags_1)
414                 /sizeof(asn_DEF_RelativeDistinguishedName_tags_1[0]), /* 1 */
415         { 0, 0, SET_OF_constraint },
416         asn_MBR_RelativeDistinguishedName_1,
417         1,      /* Single element */
418         &asn_SPC_RelativeDistinguishedName_specs_1      /* Additional specs */
419 };
420