NativeEnumerated.c vars NULL init and check
[com/asn1c.git] / tests / tests-asn1c-compiler / 134-per-long-OK.asn1.-Pgen-PER
1
2 /*** <<< INCLUDES [T] >>> ***/
3
4 #include <INTEGER.h>
5 #include <constr_SEQUENCE.h>
6
7 /*** <<< TYPE-DECLS [T] >>> ***/
8
9 typedef struct T {
10         INTEGER_t        unsigned33;
11         INTEGER_t        unsigned42;
12         INTEGER_t        signed33;
13         INTEGER_t        signed33ext;
14         
15         /* Context for parsing across buffer boundaries */
16         asn_struct_ctx_t _asn_ctx;
17 } T_t;
18
19 /*** <<< FUNC-DECLS [T] >>> ***/
20
21 extern asn_TYPE_descriptor_t asn_DEF_T;
22
23 /*** <<< CODE [T] >>> ***/
24
25 static int
26 memb_unsigned33_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
27                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
28         const INTEGER_t *st = (const INTEGER_t *)sptr;
29         long value;
30         
31         if(!sptr) {
32                 ASN__CTFAIL(app_key, td, sptr,
33                         "%s: value not given (%s:%d)",
34                         td->name, __FILE__, __LINE__);
35                 return -1;
36         }
37         
38         if(asn_INTEGER2long(st, &value)) {
39                 ASN__CTFAIL(app_key, td, sptr,
40                         "%s: value too large (%s:%d)",
41                         td->name, __FILE__, __LINE__);
42                 return -1;
43         }
44         
45         if((value >= 0 && value <= 5000000000)) {
46                 /* Constraint check succeeded */
47                 return 0;
48         } else {
49                 ASN__CTFAIL(app_key, td, sptr,
50                         "%s: constraint failed (%s:%d)",
51                         td->name, __FILE__, __LINE__);
52                 return -1;
53         }
54 }
55
56 static int
57 memb_unsigned42_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
58                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
59         const INTEGER_t *st = (const INTEGER_t *)sptr;
60         long value;
61         
62         if(!sptr) {
63                 ASN__CTFAIL(app_key, td, sptr,
64                         "%s: value not given (%s:%d)",
65                         td->name, __FILE__, __LINE__);
66                 return -1;
67         }
68         
69         if(asn_INTEGER2long(st, &value)) {
70                 ASN__CTFAIL(app_key, td, sptr,
71                         "%s: value too large (%s:%d)",
72                         td->name, __FILE__, __LINE__);
73                 return -1;
74         }
75         
76         if((value >= 0 && value <= 3153600000000)) {
77                 /* Constraint check succeeded */
78                 return 0;
79         } else {
80                 ASN__CTFAIL(app_key, td, sptr,
81                         "%s: constraint failed (%s:%d)",
82                         td->name, __FILE__, __LINE__);
83                 return -1;
84         }
85 }
86
87 static int
88 memb_signed33_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
89                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
90         const INTEGER_t *st = (const INTEGER_t *)sptr;
91         long value;
92         
93         if(!sptr) {
94                 ASN__CTFAIL(app_key, td, sptr,
95                         "%s: value not given (%s:%d)",
96                         td->name, __FILE__, __LINE__);
97                 return -1;
98         }
99         
100         if(asn_INTEGER2long(st, &value)) {
101                 ASN__CTFAIL(app_key, td, sptr,
102                         "%s: value too large (%s:%d)",
103                         td->name, __FILE__, __LINE__);
104                 return -1;
105         }
106         
107         if((value >= -4000000000 && value <= 4000000000)) {
108                 /* Constraint check succeeded */
109                 return 0;
110         } else {
111                 ASN__CTFAIL(app_key, td, sptr,
112                         "%s: constraint failed (%s:%d)",
113                         td->name, __FILE__, __LINE__);
114                 return -1;
115         }
116 }
117
118 static int
119 memb_signed33ext_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
120                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
121         const INTEGER_t *st = (const INTEGER_t *)sptr;
122         long value;
123         
124         if(!sptr) {
125                 ASN__CTFAIL(app_key, td, sptr,
126                         "%s: value not given (%s:%d)",
127                         td->name, __FILE__, __LINE__);
128                 return -1;
129         }
130         
131         if(asn_INTEGER2long(st, &value)) {
132                 ASN__CTFAIL(app_key, td, sptr,
133                         "%s: value too large (%s:%d)",
134                         td->name, __FILE__, __LINE__);
135                 return -1;
136         }
137         
138         if((value >= -4000000000 && value <= 4000000000)) {
139                 /* Constraint check succeeded */
140                 return 0;
141         } else {
142                 ASN__CTFAIL(app_key, td, sptr,
143                         "%s: constraint failed (%s:%d)",
144                         td->name, __FILE__, __LINE__);
145                 return -1;
146         }
147 }
148
149
150 /*** <<< CTDEFS [T] >>> ***/
151
152 static asn_per_constraints_t asn_PER_memb_unsigned33_constr_2 CC_NOTUSED = {
153         { APC_CONSTRAINED,       33, -1,  0,  5000000000 }      /* (0..5000000000) */,
154         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
155         0, 0    /* No PER value map */
156 };
157 static asn_per_constraints_t asn_PER_memb_unsigned42_constr_3 CC_NOTUSED = {
158         { APC_CONSTRAINED,       42, -1,  0,  3153600000000 }   /* (0..3153600000000) */,
159         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
160         0, 0    /* No PER value map */
161 };
162 static asn_per_constraints_t asn_PER_memb_signed33_constr_4 CC_NOTUSED = {
163         { APC_CONSTRAINED,       33, -1, -4000000000,  4000000000 }     /* (-4000000000..4000000000) */,
164         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
165         0, 0    /* No PER value map */
166 };
167 static asn_per_constraints_t asn_PER_memb_signed33ext_constr_5 CC_NOTUSED = {
168         { APC_CONSTRAINED | APC_EXTENSIBLE,  33, -1, -4000000000,  4000000000 } /* (-4000000000..4000000000,...) */,
169         { APC_UNCONSTRAINED,    -1, -1,  0,  0 },
170         0, 0    /* No PER value map */
171 };
172
173 /*** <<< STAT-DEFS [T] >>> ***/
174
175 static asn_TYPE_member_t asn_MBR_T_1[] = {
176         { ATF_NOFLAGS, 0, offsetof(struct T, unsigned33),
177                 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
178                 .tag_mode = -1, /* IMPLICIT tag at current level */
179                 .type = &asn_DEF_INTEGER,
180                 .type_selector = 0,
181                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_unsigned33_constr_2, .general_constraints =  memb_unsigned33_constraint_1 },
182                 0, 0, /* No default value */
183                 .name = "unsigned33"
184                 },
185         { ATF_NOFLAGS, 0, offsetof(struct T, unsigned42),
186                 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
187                 .tag_mode = -1, /* IMPLICIT tag at current level */
188                 .type = &asn_DEF_INTEGER,
189                 .type_selector = 0,
190                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_unsigned42_constr_3, .general_constraints =  memb_unsigned42_constraint_1 },
191                 0, 0, /* No default value */
192                 .name = "unsigned42"
193                 },
194         { ATF_NOFLAGS, 0, offsetof(struct T, signed33),
195                 .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
196                 .tag_mode = -1, /* IMPLICIT tag at current level */
197                 .type = &asn_DEF_INTEGER,
198                 .type_selector = 0,
199                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_signed33_constr_4, .general_constraints =  memb_signed33_constraint_1 },
200                 0, 0, /* No default value */
201                 .name = "signed33"
202                 },
203         { ATF_NOFLAGS, 0, offsetof(struct T, signed33ext),
204                 .tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
205                 .tag_mode = -1, /* IMPLICIT tag at current level */
206                 .type = &asn_DEF_INTEGER,
207                 .type_selector = 0,
208                 { .oer_constraints = 0, .per_constraints = &asn_PER_memb_signed33ext_constr_5, .general_constraints =  memb_signed33ext_constraint_1 },
209                 0, 0, /* No default value */
210                 .name = "signed33ext"
211                 },
212 };
213 static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
214         (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
215 };
216 static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
217     { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* unsigned33 */
218     { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* unsigned42 */
219     { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* signed33 */
220     { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 } /* signed33ext */
221 };
222 static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
223         sizeof(struct T),
224         offsetof(struct T, _asn_ctx),
225         .tag2el = asn_MAP_T_tag2el_1,
226         .tag2el_count = 4,      /* Count of tags in the map */
227         0, 0, 0,        /* Optional elements (not needed) */
228         -1,     /* First extension addition */
229 };
230 asn_TYPE_descriptor_t asn_DEF_T = {
231         "T",
232         "T",
233         &asn_OP_SEQUENCE,
234         asn_DEF_T_tags_1,
235         sizeof(asn_DEF_T_tags_1)
236                 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
237         asn_DEF_T_tags_1,       /* Same as above */
238         sizeof(asn_DEF_T_tags_1)
239                 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
240         { 0, 0, SEQUENCE_constraint },
241         asn_MBR_T_1,
242         4,      /* Elements count */
243         &asn_SPC_T_specs_1      /* Additional specs */
244 };
245