NativeEnumerated.c vars NULL init and check
[com/asn1c.git] / tests / tests-asn1c-compiler / 84-param-tags-OK.asn1.-Pfwide-types
1
2 /*** <<< INCLUDES [TestType] >>> ***/
3
4 #include <NativeInteger.h>
5 #include <constr_SEQUENCE.h>
6 #include <BOOLEAN.h>
7
8 /*** <<< TYPE-DECLS [TestType] >>> ***/
9
10 typedef struct TestType_16P0 {
11         long     common;        /* DEFAULT 0 */
12         
13         /* Context for parsing across buffer boundaries */
14         asn_struct_ctx_t _asn_ctx;
15 } TestType_16P0_t;
16 typedef struct TestType_16P1 {
17         BOOLEAN_t        common;        /* DEFAULT 0 */
18         
19         /* Context for parsing across buffer boundaries */
20         asn_struct_ctx_t _asn_ctx;
21 } TestType_16P1_t;
22
23 /*** <<< FUNC-DECLS [TestType] >>> ***/
24
25 extern asn_TYPE_descriptor_t asn_DEF_TestType_16P0;
26 extern asn_SEQUENCE_specifics_t asn_SPC_TestType_16P0_specs_1;
27 extern asn_TYPE_member_t asn_MBR_TestType_16P0_1[1];
28 extern asn_TYPE_descriptor_t asn_DEF_TestType_16P1;
29 extern asn_SEQUENCE_specifics_t asn_SPC_TestType_16P1_specs_3;
30 extern asn_TYPE_member_t asn_MBR_TestType_16P1_3[1];
31
32 /*** <<< CODE [TestType] >>> ***/
33
34 static int
35 memb_common_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
36                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
37         long value;
38         
39         if(!sptr) {
40                 ASN__CTFAIL(app_key, td, sptr,
41                         "%s: value not given (%s:%d)",
42                         td->name, __FILE__, __LINE__);
43                 return -1;
44         }
45         
46         value = *(const long *)sptr;
47         
48         if((value >= 1 && value <= 10)) {
49                 /* Constraint check succeeded */
50                 return 0;
51         } else {
52                 ASN__CTFAIL(app_key, td, sptr,
53                         "%s: constraint failed (%s:%d)",
54                         td->name, __FILE__, __LINE__);
55                 return -1;
56         }
57 }
58
59
60 /*** <<< STAT-DEFS [TestType] >>> ***/
61
62 static int asn_DFL_2_cmp_0(const void *sptr) {
63         const long *st = sptr;
64         
65         if(!st) {
66                 return -1; /* No value is not a default value */
67         }
68         
69         /* Test default value 0 */
70         return (*st != 0);
71 }
72 static int asn_DFL_2_set_0(void **sptr) {
73         long *st = *sptr;
74         
75         if(!st) {
76                 st = (*sptr = CALLOC(1, sizeof(*st)));
77                 if(!st) return -1;
78         }
79         
80         /* Install default value 0 */
81         *st = 0;
82         return 0;
83 }
84 asn_TYPE_member_t asn_MBR_TestType_16P0_1[] = {
85         { ATF_NOFLAGS, 1, offsetof(struct TestType_16P0, common),
86                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
87                 .tag_mode = 0,
88                 .type = &asn_DEF_NativeInteger,
89                 .type_selector = 0,
90                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_common_constraint_1 },
91                 .default_value_cmp = &asn_DFL_2_cmp_0,  /* Compare DEFAULT 0 */
92                 .default_value_set = &asn_DFL_2_set_0,  /* Set DEFAULT 0 */
93                 .name = "common"
94                 },
95 };
96 static const ber_tlv_tag_t asn_DEF_TestType_16P0_tags_1[] = {
97         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
98 };
99 static const asn_TYPE_tag2member_t asn_MAP_TestType_16P0_tag2el_1[] = {
100     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* common */
101 };
102 asn_SEQUENCE_specifics_t asn_SPC_TestType_16P0_specs_1 = {
103         sizeof(struct TestType_16P0),
104         offsetof(struct TestType_16P0, _asn_ctx),
105         .tag2el = asn_MAP_TestType_16P0_tag2el_1,
106         .tag2el_count = 1,      /* Count of tags in the map */
107         0, 0, 0,        /* Optional elements (not needed) */
108         -1,     /* First extension addition */
109 };
110 asn_TYPE_descriptor_t asn_DEF_TestType_16P0 = {
111         "TestType",
112         "TestType",
113         &asn_OP_SEQUENCE,
114         asn_DEF_TestType_16P0_tags_1,
115         sizeof(asn_DEF_TestType_16P0_tags_1)
116                 /sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */
117         asn_DEF_TestType_16P0_tags_1,   /* Same as above */
118         sizeof(asn_DEF_TestType_16P0_tags_1)
119                 /sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */
120         { 0, 0, SEQUENCE_constraint },
121         asn_MBR_TestType_16P0_1,
122         1,      /* Elements count */
123         &asn_SPC_TestType_16P0_specs_1  /* Additional specs */
124 };
125
126 static int asn_DFL_4_cmp_0(const void *sptr) {
127         const BOOLEAN_t *st = sptr;
128         
129         if(!st) {
130                 return -1; /* No value is not a default value */
131         }
132         
133         /* Test default value 0 */
134         return (*st != 0);
135 }
136 static int asn_DFL_4_set_0(void **sptr) {
137         BOOLEAN_t *st = *sptr;
138         
139         if(!st) {
140                 st = (*sptr = CALLOC(1, sizeof(*st)));
141                 if(!st) return -1;
142         }
143         
144         /* Install default value 0 */
145         *st = 0;
146         return 0;
147 }
148 asn_TYPE_member_t asn_MBR_TestType_16P1_3[] = {
149         { ATF_NOFLAGS, 1, offsetof(struct TestType_16P1, common),
150                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
151                 .tag_mode = 0,
152                 .type = &asn_DEF_BOOLEAN,
153                 .type_selector = 0,
154                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
155                 .default_value_cmp = &asn_DFL_4_cmp_0,  /* Compare DEFAULT 0 */
156                 .default_value_set = &asn_DFL_4_set_0,  /* Set DEFAULT 0 */
157                 .name = "common"
158                 },
159 };
160 static const ber_tlv_tag_t asn_DEF_TestType_16P1_tags_3[] = {
161         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
162 };
163 static const asn_TYPE_tag2member_t asn_MAP_TestType_16P1_tag2el_3[] = {
164     { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 0, 0, 0 } /* common */
165 };
166 asn_SEQUENCE_specifics_t asn_SPC_TestType_16P1_specs_3 = {
167         sizeof(struct TestType_16P1),
168         offsetof(struct TestType_16P1, _asn_ctx),
169         .tag2el = asn_MAP_TestType_16P1_tag2el_3,
170         .tag2el_count = 1,      /* Count of tags in the map */
171         0, 0, 0,        /* Optional elements (not needed) */
172         -1,     /* First extension addition */
173 };
174 asn_TYPE_descriptor_t asn_DEF_TestType_16P1 = {
175         "TestType",
176         "TestType",
177         &asn_OP_SEQUENCE,
178         asn_DEF_TestType_16P1_tags_3,
179         sizeof(asn_DEF_TestType_16P1_tags_3)
180                 /sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */
181         asn_DEF_TestType_16P1_tags_3,   /* Same as above */
182         sizeof(asn_DEF_TestType_16P1_tags_3)
183                 /sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */
184         { 0, 0, SEQUENCE_constraint },
185         asn_MBR_TestType_16P1_3,
186         1,      /* Elements count */
187         &asn_SPC_TestType_16P1_specs_3  /* Additional specs */
188 };
189
190
191 /*** <<< INCLUDES [TestChoice] >>> ***/
192
193 #include "TestType.h"
194 #include <constr_CHOICE.h>
195
196 /*** <<< DEPS [TestChoice] >>> ***/
197
198 typedef enum TestChoice_PR {
199         TestChoice_PR_NOTHING,  /* No components present */
200         TestChoice_PR_type1,
201         TestChoice_PR_type2
202 } TestChoice_PR;
203
204 /*** <<< TYPE-DECLS [TestChoice] >>> ***/
205
206 typedef struct TestChoice {
207         TestChoice_PR present;
208         union TestChoice_u {
209                 TestType_16P0_t  type1;
210                 TestType_16P1_t  type2;
211         } choice;
212         
213         /* Context for parsing across buffer boundaries */
214         asn_struct_ctx_t _asn_ctx;
215 } TestChoice_t;
216
217 /*** <<< FUNC-DECLS [TestChoice] >>> ***/
218
219 extern asn_TYPE_descriptor_t asn_DEF_TestChoice;
220
221 /*** <<< STAT-DEFS [TestChoice] >>> ***/
222
223 static asn_TYPE_member_t asn_MBR_TestChoice_1[] = {
224         { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type1),
225                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
226                 .tag_mode = 0,
227                 .type = &asn_DEF_TestType_16P0,
228                 .type_selector = 0,
229                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
230                 0, 0, /* No default value */
231                 .name = "type1"
232                 },
233         { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type2),
234                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
235                 .tag_mode = -1, /* IMPLICIT tag at current level */
236                 .type = &asn_DEF_TestType_16P1,
237                 .type_selector = 0,
238                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
239                 0, 0, /* No default value */
240                 .name = "type2"
241                 },
242 };
243 static const asn_TYPE_tag2member_t asn_MAP_TestChoice_tag2el_1[] = {
244     { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* type1 */
245     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* type2 */
246 };
247 static asn_CHOICE_specifics_t asn_SPC_TestChoice_specs_1 = {
248         sizeof(struct TestChoice),
249         offsetof(struct TestChoice, _asn_ctx),
250         offsetof(struct TestChoice, present),
251         sizeof(((struct TestChoice *)0)->present),
252         .tag2el = asn_MAP_TestChoice_tag2el_1,
253         .tag2el_count = 2,      /* Count of tags in the map */
254         0, 0,
255         .first_extension = -1   /* Extensions start */
256 };
257 asn_TYPE_descriptor_t asn_DEF_TestChoice = {
258         "TestChoice",
259         "TestChoice",
260         &asn_OP_CHOICE,
261         0,      /* No effective tags (pointer) */
262         0,      /* No effective tags (count) */
263         0,      /* No tags (pointer) */
264         0,      /* No tags (count) */
265         { 0, 0, CHOICE_constraint },
266         asn_MBR_TestChoice_1,
267         2,      /* Elements count */
268         &asn_SPC_TestChoice_specs_1     /* Additional specs */
269 };
270
271
272 /*** <<< INCLUDES [AutoType] >>> ***/
273
274 #include <NativeInteger.h>
275 #include <constr_SEQUENCE.h>
276 #include <BOOLEAN.h>
277
278 /*** <<< TYPE-DECLS [AutoType] >>> ***/
279
280 typedef struct AutoType_34P0 {
281         long     common;
282         
283         /* Context for parsing across buffer boundaries */
284         asn_struct_ctx_t _asn_ctx;
285 } AutoType_34P0_t;
286 typedef struct AutoType_34P1 {
287         BOOLEAN_t        common;
288         
289         /* Context for parsing across buffer boundaries */
290         asn_struct_ctx_t _asn_ctx;
291 } AutoType_34P1_t;
292
293 /*** <<< FUNC-DECLS [AutoType] >>> ***/
294
295 extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P0;
296 extern asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P0_specs_1;
297 extern asn_TYPE_member_t asn_MBR_AutoType_34P0_1[1];
298 extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P1;
299 extern asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P1_specs_3;
300 extern asn_TYPE_member_t asn_MBR_AutoType_34P1_3[1];
301
302 /*** <<< CODE [AutoType] >>> ***/
303
304 static int
305 memb_common_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
306                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
307         long value;
308         
309         if(!sptr) {
310                 ASN__CTFAIL(app_key, td, sptr,
311                         "%s: value not given (%s:%d)",
312                         td->name, __FILE__, __LINE__);
313                 return -1;
314         }
315         
316         value = *(const long *)sptr;
317         
318         if((value == 0)) {
319                 /* Constraint check succeeded */
320                 return 0;
321         } else {
322                 ASN__CTFAIL(app_key, td, sptr,
323                         "%s: constraint failed (%s:%d)",
324                         td->name, __FILE__, __LINE__);
325                 return -1;
326         }
327 }
328
329 static int
330 memb_common_constraint_3(const asn_TYPE_descriptor_t *td, const void *sptr,
331                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
332         BOOLEAN_t value;
333         
334         if(!sptr) {
335                 ASN__CTFAIL(app_key, td, sptr,
336                         "%s: value not given (%s:%d)",
337                         td->name, __FILE__, __LINE__);
338                 return -1;
339         }
340         
341         value = (*(const long *)sptr) ? 1 : 0;
342         
343         if((value <= 0)) {
344                 /* Constraint check succeeded */
345                 return 0;
346         } else {
347                 ASN__CTFAIL(app_key, td, sptr,
348                         "%s: constraint failed (%s:%d)",
349                         td->name, __FILE__, __LINE__);
350                 return -1;
351         }
352 }
353
354
355 /*** <<< STAT-DEFS [AutoType] >>> ***/
356
357 asn_TYPE_member_t asn_MBR_AutoType_34P0_1[] = {
358         { ATF_NOFLAGS, 0, offsetof(struct AutoType_34P0, common),
359                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
360                 .tag_mode = -1, /* IMPLICIT tag at current level */
361                 .type = &asn_DEF_NativeInteger,
362                 .type_selector = 0,
363                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_common_constraint_1 },
364                 0, 0, /* No default value */
365                 .name = "common"
366                 },
367 };
368 static const ber_tlv_tag_t asn_DEF_AutoType_34P0_tags_1[] = {
369         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
370 };
371 static const asn_TYPE_tag2member_t asn_MAP_AutoType_34P0_tag2el_1[] = {
372     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common */
373 };
374 asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P0_specs_1 = {
375         sizeof(struct AutoType_34P0),
376         offsetof(struct AutoType_34P0, _asn_ctx),
377         .tag2el = asn_MAP_AutoType_34P0_tag2el_1,
378         .tag2el_count = 1,      /* Count of tags in the map */
379         0, 0, 0,        /* Optional elements (not needed) */
380         -1,     /* First extension addition */
381 };
382 asn_TYPE_descriptor_t asn_DEF_AutoType_34P0 = {
383         "AutoType",
384         "AutoType",
385         &asn_OP_SEQUENCE,
386         asn_DEF_AutoType_34P0_tags_1,
387         sizeof(asn_DEF_AutoType_34P0_tags_1)
388                 /sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */
389         asn_DEF_AutoType_34P0_tags_1,   /* Same as above */
390         sizeof(asn_DEF_AutoType_34P0_tags_1)
391                 /sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */
392         { 0, 0, SEQUENCE_constraint },
393         asn_MBR_AutoType_34P0_1,
394         1,      /* Elements count */
395         &asn_SPC_AutoType_34P0_specs_1  /* Additional specs */
396 };
397
398 asn_TYPE_member_t asn_MBR_AutoType_34P1_3[] = {
399         { ATF_NOFLAGS, 0, offsetof(struct AutoType_34P1, common),
400                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
401                 .tag_mode = -1, /* IMPLICIT tag at current level */
402                 .type = &asn_DEF_BOOLEAN,
403                 .type_selector = 0,
404                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_common_constraint_3 },
405                 0, 0, /* No default value */
406                 .name = "common"
407                 },
408 };
409 static const ber_tlv_tag_t asn_DEF_AutoType_34P1_tags_3[] = {
410         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
411 };
412 static const asn_TYPE_tag2member_t asn_MAP_AutoType_34P1_tag2el_3[] = {
413     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common */
414 };
415 asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P1_specs_3 = {
416         sizeof(struct AutoType_34P1),
417         offsetof(struct AutoType_34P1, _asn_ctx),
418         .tag2el = asn_MAP_AutoType_34P1_tag2el_3,
419         .tag2el_count = 1,      /* Count of tags in the map */
420         0, 0, 0,        /* Optional elements (not needed) */
421         -1,     /* First extension addition */
422 };
423 asn_TYPE_descriptor_t asn_DEF_AutoType_34P1 = {
424         "AutoType",
425         "AutoType",
426         &asn_OP_SEQUENCE,
427         asn_DEF_AutoType_34P1_tags_3,
428         sizeof(asn_DEF_AutoType_34P1_tags_3)
429                 /sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */
430         asn_DEF_AutoType_34P1_tags_3,   /* Same as above */
431         sizeof(asn_DEF_AutoType_34P1_tags_3)
432                 /sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */
433         { 0, 0, SEQUENCE_constraint },
434         asn_MBR_AutoType_34P1_3,
435         1,      /* Elements count */
436         &asn_SPC_AutoType_34P1_specs_3  /* Additional specs */
437 };
438
439
440 /*** <<< INCLUDES [AutoChoice] >>> ***/
441
442 #include "AutoType.h"
443 #include <constr_CHOICE.h>
444
445 /*** <<< DEPS [AutoChoice] >>> ***/
446
447 typedef enum AutoChoice_PR {
448         AutoChoice_PR_NOTHING,  /* No components present */
449         AutoChoice_PR_type1,
450         AutoChoice_PR_type2
451 } AutoChoice_PR;
452
453 /*** <<< TYPE-DECLS [AutoChoice] >>> ***/
454
455 typedef struct AutoChoice {
456         AutoChoice_PR present;
457         union AutoChoice_u {
458                 AutoType_34P0_t  type1;
459                 AutoType_34P1_t  type2;
460         } choice;
461         
462         /* Context for parsing across buffer boundaries */
463         asn_struct_ctx_t _asn_ctx;
464 } AutoChoice_t;
465
466 /*** <<< FUNC-DECLS [AutoChoice] >>> ***/
467
468 extern asn_TYPE_descriptor_t asn_DEF_AutoChoice;
469
470 /*** <<< STAT-DEFS [AutoChoice] >>> ***/
471
472 static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = {
473         { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type1),
474                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
475                 .tag_mode = -1, /* IMPLICIT tag at current level */
476                 .type = &asn_DEF_AutoType_34P0,
477                 .type_selector = 0,
478                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
479                 0, 0, /* No default value */
480                 .name = "type1"
481                 },
482         { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type2),
483                 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
484                 .tag_mode = -1, /* IMPLICIT tag at current level */
485                 .type = &asn_DEF_AutoType_34P1,
486                 .type_selector = 0,
487                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
488                 0, 0, /* No default value */
489                 .name = "type2"
490                 },
491 };
492 static const asn_TYPE_tag2member_t asn_MAP_AutoChoice_tag2el_1[] = {
493     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type1 */
494     { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* type2 */
495 };
496 static asn_CHOICE_specifics_t asn_SPC_AutoChoice_specs_1 = {
497         sizeof(struct AutoChoice),
498         offsetof(struct AutoChoice, _asn_ctx),
499         offsetof(struct AutoChoice, present),
500         sizeof(((struct AutoChoice *)0)->present),
501         .tag2el = asn_MAP_AutoChoice_tag2el_1,
502         .tag2el_count = 2,      /* Count of tags in the map */
503         0, 0,
504         .first_extension = -1   /* Extensions start */
505 };
506 asn_TYPE_descriptor_t asn_DEF_AutoChoice = {
507         "AutoChoice",
508         "AutoChoice",
509         &asn_OP_CHOICE,
510         0,      /* No effective tags (pointer) */
511         0,      /* No effective tags (count) */
512         0,      /* No tags (pointer) */
513         0,      /* No tags (count) */
514         { 0, 0, CHOICE_constraint },
515         asn_MBR_AutoChoice_1,
516         2,      /* Elements count */
517         &asn_SPC_AutoChoice_specs_1     /* Additional specs */
518 };
519