Initial version of asn1c
[com/asn1c.git] / tests / tests-asn1c-compiler / 125-bitstring-constraint-OK.asn1.-P
diff --git a/tests/tests-asn1c-compiler/125-bitstring-constraint-OK.asn1.-P b/tests/tests-asn1c-compiler/125-bitstring-constraint-OK.asn1.-P
new file mode 100644 (file)
index 0000000..627c271
--- /dev/null
@@ -0,0 +1,76 @@
+
+/*** <<< INCLUDES [T] >>> ***/
+
+#include <BIT_STRING.h>
+
+/*** <<< DEPS [T] >>> ***/
+
+typedef enum T {
+       T_flag1 = 0,
+       T_flag2 = 1,
+       T_flag3 = 2
+} e_T;
+
+/*** <<< TYPE-DECLS [T] >>> ***/
+
+typedef BIT_STRING_t    T_t;
+
+/*** <<< FUNC-DECLS [T] >>> ***/
+
+extern asn_TYPE_descriptor_t asn_DEF_T;
+asn_struct_free_f T_free;
+asn_struct_print_f T_print;
+asn_constr_check_f T_constraint;
+ber_type_decoder_f T_decode_ber;
+der_type_encoder_f T_encode_der;
+xer_type_decoder_f T_decode_xer;
+xer_type_encoder_f T_encode_xer;
+
+/*** <<< CODE [T] >>> ***/
+
+int
+T_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
+                       asn_app_constraint_failed_f *ctfailcb, void *app_key) {
+       const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
+       
+       if(!sptr) {
+               ASN__CTFAIL(app_key, td, sptr,
+                       "%s: value not given (%s:%d)",
+                       td->name, __FILE__, __LINE__);
+               return -1;
+       }
+       
+       
+       if(1 /* No applicable constraints whatsoever */) {
+               (void)st; /* Unused variable */
+               /* Nothing is here. See below */
+       }
+       
+       return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
+}
+
+/*
+ * This type is implemented using BIT_STRING,
+ * so here we adjust the DEF accordingly.
+ */
+
+/*** <<< STAT-DEFS [T] >>> ***/
+
+static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
+       (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
+};
+asn_TYPE_descriptor_t asn_DEF_T = {
+       "T",
+       "T",
+       &asn_OP_BIT_STRING,
+       asn_DEF_T_tags_1,
+       sizeof(asn_DEF_T_tags_1)
+               /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
+       asn_DEF_T_tags_1,       /* Same as above */
+       sizeof(asn_DEF_T_tags_1)
+               /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
+       { 0, 0, T_constraint },
+       0, 0,   /* Defined elsewhere */
+       &asn_SPC_BIT_STRING_specs       /* Additional specs */
+};
+