3859933c1bd960f2cdabd46369f12797aec49fdd
[com/asn1c.git] / tests / tests-asn1c-compiler / 108-param-constr-3-OK.asn1.-Pfwide-types
1
2 /*** <<< INCLUDES [MinMax] >>> ***/
3
4 #include <INTEGER.h>
5
6 /*** <<< TYPE-DECLS [MinMax] >>> ***/
7
8 typedef INTEGER_t        MinMax_16P0_t;
9
10 /*** <<< FUNC-DECLS [MinMax] >>> ***/
11
12 extern asn_TYPE_descriptor_t asn_DEF_MinMax_16P0;
13 asn_struct_free_f MinMax_16P0_free;
14 asn_struct_print_f MinMax_16P0_print;
15 asn_constr_check_f MinMax_16P0_constraint;
16 ber_type_decoder_f MinMax_16P0_decode_ber;
17 der_type_encoder_f MinMax_16P0_encode_der;
18 xer_type_decoder_f MinMax_16P0_decode_xer;
19 xer_type_encoder_f MinMax_16P0_encode_xer;
20
21 /*** <<< CODE [MinMax] >>> ***/
22
23 int
24 MinMax_16P0_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
25                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
26         const INTEGER_t *st = (const INTEGER_t *)sptr;
27         long value;
28         
29         if(!sptr) {
30                 ASN__CTFAIL(app_key, td, sptr,
31                         "%s: value not given (%s:%d)",
32                         td->name, __FILE__, __LINE__);
33                 return -1;
34         }
35         
36         if(asn_INTEGER2long(st, &value)) {
37                 ASN__CTFAIL(app_key, td, sptr,
38                         "%s: value too large (%s:%d)",
39                         td->name, __FILE__, __LINE__);
40                 return -1;
41         }
42         
43         if((value >= 3)) {
44                 /* Constraint check succeeded */
45                 return 0;
46         } else {
47                 ASN__CTFAIL(app_key, td, sptr,
48                         "%s: constraint failed (%s:%d)",
49                         td->name, __FILE__, __LINE__);
50                 return -1;
51         }
52 }
53
54 /*
55  * This type is implemented using INTEGER,
56  * so here we adjust the DEF accordingly.
57  */
58
59 /*** <<< STAT-DEFS [MinMax] >>> ***/
60
61 static const ber_tlv_tag_t asn_DEF_MinMax_16P0_tags_1[] = {
62         (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
63 };
64 asn_TYPE_descriptor_t asn_DEF_MinMax_16P0 = {
65         "MinMax",
66         "MinMax",
67         &asn_OP_INTEGER,
68         asn_DEF_MinMax_16P0_tags_1,
69         sizeof(asn_DEF_MinMax_16P0_tags_1)
70                 /sizeof(asn_DEF_MinMax_16P0_tags_1[0]), /* 1 */
71         asn_DEF_MinMax_16P0_tags_1,     /* Same as above */
72         sizeof(asn_DEF_MinMax_16P0_tags_1)
73                 /sizeof(asn_DEF_MinMax_16P0_tags_1[0]), /* 1 */
74         { 0, 0, MinMax_16P0_constraint },
75         0, 0,   /* No members */
76         0       /* No specifics */
77 };
78
79
80 /*** <<< INCLUDES [ThreePlus] >>> ***/
81
82 #include "MinMax.h"
83
84 /*** <<< TYPE-DECLS [ThreePlus] >>> ***/
85
86 typedef MinMax_16P0_t    ThreePlus_t;
87
88 /*** <<< FUNC-DECLS [ThreePlus] >>> ***/
89
90 extern asn_TYPE_descriptor_t asn_DEF_ThreePlus;
91 asn_struct_free_f ThreePlus_free;
92 asn_struct_print_f ThreePlus_print;
93 asn_constr_check_f ThreePlus_constraint;
94 ber_type_decoder_f ThreePlus_decode_ber;
95 der_type_encoder_f ThreePlus_encode_der;
96 xer_type_decoder_f ThreePlus_decode_xer;
97 xer_type_encoder_f ThreePlus_encode_xer;
98
99 /*** <<< CODE [ThreePlus] >>> ***/
100
101 int
102 ThreePlus_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
103                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
104         const MinMax_16P0_t *st = (const MinMax_16P0_t *)sptr;
105         long value;
106         
107         if(!sptr) {
108                 ASN__CTFAIL(app_key, td, sptr,
109                         "%s: value not given (%s:%d)",
110                         td->name, __FILE__, __LINE__);
111                 return -1;
112         }
113         
114         if(asn_INTEGER2long(st, &value)) {
115                 ASN__CTFAIL(app_key, td, sptr,
116                         "%s: value too large (%s:%d)",
117                         td->name, __FILE__, __LINE__);
118                 return -1;
119         }
120         
121         if((value >= 3)) {
122                 /* Constraint check succeeded */
123                 return 0;
124         } else {
125                 ASN__CTFAIL(app_key, td, sptr,
126                         "%s: constraint failed (%s:%d)",
127                         td->name, __FILE__, __LINE__);
128                 return -1;
129         }
130 }
131
132 /*
133  * This type is implemented using MinMax_16P0,
134  * so here we adjust the DEF accordingly.
135  */
136
137 /*** <<< STAT-DEFS [ThreePlus] >>> ***/
138
139 static const ber_tlv_tag_t asn_DEF_ThreePlus_tags_1[] = {
140         (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
141 };
142 asn_TYPE_descriptor_t asn_DEF_ThreePlus = {
143         "ThreePlus",
144         "ThreePlus",
145         &asn_OP_INTEGER,
146         asn_DEF_ThreePlus_tags_1,
147         sizeof(asn_DEF_ThreePlus_tags_1)
148                 /sizeof(asn_DEF_ThreePlus_tags_1[0]), /* 1 */
149         asn_DEF_ThreePlus_tags_1,       /* Same as above */
150         sizeof(asn_DEF_ThreePlus_tags_1)
151                 /sizeof(asn_DEF_ThreePlus_tags_1[0]), /* 1 */
152         { 0, 0, ThreePlus_constraint },
153         0, 0,   /* No members */
154         0       /* No specifics */
155 };
156