NativeEnumerated.c vars NULL init and check
[com/asn1c.git] / tests / tests-asn1c-compiler / 69-reserved-words-OK.asn1.-Pfwide-types
1
2 /*** <<< INCLUDES [T] >>> ***/
3
4 #include <INTEGER.h>
5 #include <OCTET_STRING.h>
6 #include <REAL.h>
7 #include <constr_SET.h>
8 #include <constr_SEQUENCE.h>
9
10 /*** <<< DEPS [T] >>> ***/
11
12
13 /*
14  * Method of determining the components presence
15  */
16 typedef enum class_PR {
17 } class_PR;
18
19 /*** <<< TYPE-DECLS [T] >>> ***/
20
21 typedef struct T {
22         INTEGER_t        Int;
23         OCTET_STRING_t   Char;
24         struct Class {
25                 /*
26                  * This type is extensible,
27                  * possible extensions are below.
28                  */
29                 
30                 /* Presence bitmask: ASN_SET_ISPRESENT(pclass, class_PR_x) */
31                 unsigned int _presence_map
32                         [((0+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];
33                 
34                 /* Context for parsing across buffer boundaries */
35                 asn_struct_ctx_t _asn_ctx;
36         } Class;
37         REAL_t   Double;
38         
39         /* Context for parsing across buffer boundaries */
40         asn_struct_ctx_t _asn_ctx;
41 } T_t;
42
43 /*** <<< FUNC-DECLS [T] >>> ***/
44
45 extern asn_TYPE_descriptor_t asn_DEF_T;
46
47 /*** <<< CODE [T] >>> ***/
48
49 static int
50 memb_char_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
51                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
52         const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
53         size_t size;
54         
55         if(!sptr) {
56                 ASN__CTFAIL(app_key, td, sptr,
57                         "%s: value not given (%s:%d)",
58                         td->name, __FILE__, __LINE__);
59                 return -1;
60         }
61         
62         size = st->size;
63         
64         if((size == 1)) {
65                 /* Constraint check succeeded */
66                 return 0;
67         } else {
68                 ASN__CTFAIL(app_key, td, sptr,
69                         "%s: constraint failed (%s:%d)",
70                         td->name, __FILE__, __LINE__);
71                 return -1;
72         }
73 }
74
75
76 /*** <<< STAT-DEFS [T] >>> ***/
77
78 static const ber_tlv_tag_t asn_DEF_class_tags_4[] = {
79         (ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
80 };
81 static const uint8_t asn_MAP_class_mmap_4[(0 + (8 * sizeof(unsigned int)) - 1) / 8] = {
82         0
83 };
84 static 
85 asn_SET_specifics_t asn_SPC_class_specs_4 = {
86         sizeof(struct Class),
87         offsetof(struct Class, _asn_ctx),
88         offsetof(struct Class, _presence_map),
89         0,      /* No top level tags */
90         0,      /* No tags in the map */
91         asn_MAP_class_tag2el_4, /* Same as above */
92         0,      /* Count of tags in the CXER map */
93         1,      /* Whether extensible */
94         (const unsigned int *)asn_MAP_class_mmap_4      /* Mandatory elements map */
95 };
96 static /* Use -fall-defs-global to expose */
97 asn_TYPE_descriptor_t asn_DEF_class_4 = {
98         "class",
99         "class",
100         &asn_OP_SET,
101         asn_DEF_class_tags_4,
102         sizeof(asn_DEF_class_tags_4)
103                 /sizeof(asn_DEF_class_tags_4[0]), /* 1 */
104         asn_DEF_class_tags_4,   /* Same as above */
105         sizeof(asn_DEF_class_tags_4)
106                 /sizeof(asn_DEF_class_tags_4[0]), /* 1 */
107         { 0, 0, SET_constraint },
108         0, 0,   /* No members */
109         &asn_SPC_class_specs_4  /* Additional specs */
110 };
111
112 static asn_TYPE_member_t asn_MBR_T_1[] = {
113         { ATF_NOFLAGS, 0, offsetof(struct T, Int),
114                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
115                 .tag_mode = 0,
116                 .type = &asn_DEF_INTEGER,
117                 .type_selector = 0,
118                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
119                 0, 0, /* No default value */
120                 .name = "int"
121                 },
122         { ATF_NOFLAGS, 0, offsetof(struct T, Char),
123                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)),
124                 .tag_mode = 0,
125                 .type = &asn_DEF_OCTET_STRING,
126                 .type_selector = 0,
127                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints =  memb_char_constraint_1 },
128                 0, 0, /* No default value */
129                 .name = "char"
130                 },
131         { ATF_NOFLAGS, 0, offsetof(struct T, Class),
132                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
133                 .tag_mode = 0,
134                 .type = &asn_DEF_class_4,
135                 .type_selector = 0,
136                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
137                 0, 0, /* No default value */
138                 .name = "class"
139                 },
140         { ATF_NOFLAGS, 0, offsetof(struct T, Double),
141                 .tag = (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)),
142                 .tag_mode = 0,
143                 .type = &asn_DEF_REAL,
144                 .type_selector = 0,
145                 { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
146                 0, 0, /* No default value */
147                 .name = "double"
148                 },
149 };
150 static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
151         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
152 };
153 static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
154     { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* int */
155     { (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), 1, 0, 0 }, /* char */
156     { (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)), 3, 0, 0 }, /* double */
157     { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 2, 0, 0 } /* class */
158 };
159 static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
160         sizeof(struct T),
161         offsetof(struct T, _asn_ctx),
162         .tag2el = asn_MAP_T_tag2el_1,
163         .tag2el_count = 4,      /* Count of tags in the map */
164         0, 0, 0,        /* Optional elements (not needed) */
165         -1,     /* First extension addition */
166 };
167 asn_TYPE_descriptor_t asn_DEF_T = {
168         "T",
169         "T",
170         &asn_OP_SEQUENCE,
171         asn_DEF_T_tags_1,
172         sizeof(asn_DEF_T_tags_1)
173                 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
174         asn_DEF_T_tags_1,       /* Same as above */
175         sizeof(asn_DEF_T_tags_1)
176                 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
177         { 0, 0, SEQUENCE_constraint },
178         asn_MBR_T_1,
179         4,      /* Elements count */
180         &asn_SPC_T_specs_1      /* Additional specs */
181 };
182