aboutsummaryrefslogtreecommitdiffstats
path: root/tests/46-redefine-OK.asn1.-PR
diff options
context:
space:
mode:
authorvlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2004-06-28 21:13:22 +0000
committervlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2004-06-28 21:13:22 +0000
commit3df796640acc97d4bb312b089d93079d8290fc5d (patch)
tree42f22d353e1b0da0627d19637293b6fc55d375cd /tests/46-redefine-OK.asn1.-PR
parentd315be55669cfeb1c6de071bffd26eae669ae7ac (diff)
removed -N command-line argument
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@36 59561ff5-6e30-0410-9f3c-9617f08c8826
Diffstat (limited to 'tests/46-redefine-OK.asn1.-PR')
-rw-r--r--tests/46-redefine-OK.asn1.-PR254
1 files changed, 254 insertions, 0 deletions
diff --git a/tests/46-redefine-OK.asn1.-PR b/tests/46-redefine-OK.asn1.-PR
new file mode 100644
index 00000000..2fc1e4dd
--- /dev/null
+++ b/tests/46-redefine-OK.asn1.-PR
@@ -0,0 +1,254 @@
+
+/*** <<< DEPS [PrimitiveType] >>> ***/
+
+#include <OCTET_STRING.h>
+
+/*** <<< TYPE-DECLS [PrimitiveType] >>> ***/
+
+
+typedef OCTET_STRING_t PrimitiveType_t;
+
+
+/*** <<< FUNC-DECLS [PrimitiveType] >>> ***/
+
+extern asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType;
+asn_constr_check_f PrimitiveType_constraint;
+ber_type_decoder_f PrimitiveType_decode_ber;
+der_type_encoder_f PrimitiveType_encode_der;
+asn_struct_print_f PrimitiveType_print;
+asn_struct_free_f PrimitiveType_free;
+
+/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
+
+static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = {
+ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
+};
+asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = {
+ "PrimitiveType",
+ PrimitiveType_constraint,
+ PrimitiveType_decode_ber,
+ PrimitiveType_encode_der,
+ PrimitiveType_print,
+ PrimitiveType_free,
+ 0, /* Use generic outmost tag fetcher */
+ asn1_DEF_PrimitiveType_tags,
+ sizeof(asn1_DEF_PrimitiveType_tags)
+ /sizeof(asn1_DEF_PrimitiveType_tags[0]),
+ 1, /* Tags to skip */
+ -0, /* Unknown yet */
+ 0 /* No specifics */
+};
+
+int
+PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
+ asn_app_consume_bytes_f *app_errlog, void *app_key) {
+
+ /* Make the underlying type checker permanent */
+ td->check_constraints = asn1_DEF_OCTET_STRING.check_constraints;
+ return td->check_constraints
+ (td, sptr, app_errlog, app_key);
+}
+
+/*
+ * This type is implemented using OCTET_STRING,
+ * so adjust the DEF appropriately.
+ */
+static void
+inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
+ td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder;
+ td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
+ td->free_struct = asn1_DEF_OCTET_STRING.free_struct;
+ td->print_struct = asn1_DEF_OCTET_STRING.print_struct;
+ td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form;
+ td->specifics = asn1_DEF_OCTET_STRING.specifics;
+}
+
+ber_dec_rval_t
+PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
+ void **structure, void *bufptr, size_t size, int tag_mode) {
+ inherit_TYPE_descriptor(td);
+ return td->ber_decoder(td, structure,
+ bufptr, size, tag_mode);
+}
+
+der_enc_rval_t
+PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
+ void *structure, int tag_mode, ber_tlv_tag_t tag,
+ asn_app_consume_bytes_f *cb, void *app_key) {
+ inherit_TYPE_descriptor(td);
+ return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
+}
+
+int
+PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
+ int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+ inherit_TYPE_descriptor(td);
+ return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
+}
+
+void
+PrimitiveType_free(asn1_TYPE_descriptor_t *td,
+ void *struct_ptr, int contents_only) {
+ inherit_TYPE_descriptor(td);
+ td->free_struct(td, struct_ptr, contents_only);
+}
+
+
+/*** <<< DEPS [ConstructedType] >>> ***/
+
+/* Dependencies for ConstructedType */
+#include <PrimitiveType.h>
+
+#include <constr_SEQUENCE.h>
+
+extern asn1_TYPE_descriptor_t asn1_DEF_ConstructedType;
+
+/*** <<< TYPE-DECLS [ConstructedType] >>> ***/
+
+
+typedef struct ConstructedType {
+ PrimitiveType_t field;
+
+ /* Context for parsing across buffer boundaries */
+ ber_dec_ctx_t _ber_dec_ctx;
+} ConstructedType_t;
+
+/*** <<< STAT-DEFS [ConstructedType] >>> ***/
+
+#include <constr_SEQUENCE.h>
+
+static asn1_SEQUENCE_element_t asn1_DEF_ConstructedType_elements[] = {
+ { offsetof(struct ConstructedType, field), 0,
+ (ASN_TAG_CLASS_CONTEXT | (5 << 2)),
+ -1, /* IMPLICIT tag at current level */
+ (void *)&asn1_DEF_PrimitiveType,
+ "field"
+ },
+};
+static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = {
+ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
+};
+static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = {
+ { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 }, /* field at 18 */
+};
+static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
+ sizeof(struct ConstructedType),
+ offsetof(struct ConstructedType, _ber_dec_ctx),
+ asn1_DEF_ConstructedType_elements,
+ 1, /* Elements count */
+ asn1_DEF_ConstructedType_tag2el,
+ 1, /* Count of tags in the map */
+ -1, /* Start extensions */
+ -1 /* Stop extensions */
+};
+asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = {
+ "ConstructedType",
+ SEQUENCE_constraint,
+ SEQUENCE_decode_ber,
+ SEQUENCE_encode_der,
+ SEQUENCE_print,
+ SEQUENCE_free,
+ 0, /* Use generic outmost tag fetcher */
+ asn1_DEF_ConstructedType_tags,
+ sizeof(asn1_DEF_ConstructedType_tags)
+ /sizeof(asn1_DEF_ConstructedType_tags[0]),
+ 1, /* Tags to skip */
+ 1, /* Whether CONSTRUCTED */
+ &asn1_DEF_ConstructedType_specs /* Additional specs */
+};
+
+
+/*** <<< DEPS [T] >>> ***/
+
+#include <ConstructedType.h>
+
+/*** <<< TYPE-DECLS [T] >>> ***/
+
+
+typedef ConstructedType_t T_t;
+
+
+/*** <<< FUNC-DECLS [T] >>> ***/
+
+extern asn1_TYPE_descriptor_t asn1_DEF_T;
+asn_constr_check_f T_constraint;
+ber_type_decoder_f T_decode_ber;
+der_type_encoder_f T_encode_der;
+asn_struct_print_f T_print;
+asn_struct_free_f T_free;
+
+/*** <<< STAT-DEFS [T] >>> ***/
+
+static ber_tlv_tag_t asn1_DEF_T_tags[] = {
+ (ASN_TAG_CLASS_CONTEXT | (3 << 2))
+};
+asn1_TYPE_descriptor_t asn1_DEF_T = {
+ "T",
+ T_constraint,
+ T_decode_ber,
+ T_encode_der,
+ T_print,
+ T_free,
+ 0, /* Use generic outmost tag fetcher */
+ asn1_DEF_T_tags,
+ sizeof(asn1_DEF_T_tags)
+ /sizeof(asn1_DEF_T_tags[0]),
+ 1, /* Tags to skip */
+ -0, /* Unknown yet */
+ 0 /* No specifics */
+};
+
+int
+T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
+ asn_app_consume_bytes_f *app_errlog, void *app_key) {
+
+ /* Make the underlying type checker permanent */
+ td->check_constraints = asn1_DEF_ConstructedType.check_constraints;
+ return td->check_constraints
+ (td, sptr, app_errlog, app_key);
+}
+
+/*
+ * This type is implemented using ConstructedType,
+ * so adjust the DEF appropriately.
+ */
+static void
+inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
+ td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
+ td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
+ td->free_struct = asn1_DEF_ConstructedType.free_struct;
+ td->print_struct = asn1_DEF_ConstructedType.print_struct;
+ td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
+ td->specifics = asn1_DEF_ConstructedType.specifics;
+}
+
+ber_dec_rval_t
+T_decode_ber(asn1_TYPE_descriptor_t *td,
+ void **structure, void *bufptr, size_t size, int tag_mode) {
+ inherit_TYPE_descriptor(td);
+ return td->ber_decoder(td, structure,
+ bufptr, size, tag_mode);
+}
+
+der_enc_rval_t
+T_encode_der(asn1_TYPE_descriptor_t *td,
+ void *structure, int tag_mode, ber_tlv_tag_t tag,
+ asn_app_consume_bytes_f *cb, void *app_key) {
+ inherit_TYPE_descriptor(td);
+ return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
+}
+
+int
+T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
+ int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+ inherit_TYPE_descriptor(td);
+ return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
+}
+
+void
+T_free(asn1_TYPE_descriptor_t *td,
+ void *struct_ptr, int contents_only) {
+ inherit_TYPE_descriptor(td);
+ td->free_struct(td, struct_ptr, contents_only);
+}
+