vlm | c1a0ee5 | 2006-10-27 05:38:20 +0000 | [diff] [blame] | 1 | |
| 2 | /*** <<< INCLUDES [T] >>> ***/ |
| 3 | |
| 4 | #include <BIT_STRING.h> |
| 5 | |
| 6 | /*** <<< DEPS [T] >>> ***/ |
| 7 | |
| 8 | typedef enum T { |
| 9 | T_flag1 = 0, |
| 10 | T_flag2 = 1, |
| 11 | T_flag3 = 2 |
| 12 | } e_T; |
| 13 | |
| 14 | /*** <<< TYPE-DECLS [T] >>> ***/ |
| 15 | |
| 16 | typedef BIT_STRING_t T_t; |
| 17 | |
| 18 | /*** <<< FUNC-DECLS [T] >>> ***/ |
| 19 | |
| 20 | extern asn_TYPE_descriptor_t asn_DEF_T; |
| 21 | asn_struct_free_f T_free; |
| 22 | asn_struct_print_f T_print; |
| 23 | asn_constr_check_f T_constraint; |
| 24 | ber_type_decoder_f T_decode_ber; |
| 25 | der_type_encoder_f T_encode_der; |
| 26 | xer_type_decoder_f T_decode_xer; |
| 27 | xer_type_encoder_f T_encode_xer; |
| 28 | |
| 29 | /*** <<< CODE [T] >>> ***/ |
| 30 | |
| 31 | int |
| 32 | T_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
| 33 | asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
| 34 | const BIT_STRING_t *st = (const BIT_STRING_t *)sptr; |
| 35 | |
| 36 | if(!sptr) { |
| 37 | _ASN_CTFAIL(app_key, td, sptr, |
| 38 | "%s: value not given (%s:%d)", |
| 39 | td->name, __FILE__, __LINE__); |
| 40 | return -1; |
| 41 | } |
| 42 | |
| 43 | |
| 44 | if(1 /* No applicable constraints whatsoever */) { |
| 45 | /* Nothing is here. See below */ |
| 46 | } |
| 47 | |
| 48 | /* Replace with underlying type checker */ |
| 49 | td->check_constraints = asn_DEF_BIT_STRING.check_constraints; |
| 50 | return td->check_constraints(td, sptr, ctfailcb, app_key); |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * This type is implemented using BIT_STRING, |
| 55 | * so here we adjust the DEF accordingly. |
| 56 | */ |
| 57 | static void |
| 58 | T_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
| 59 | td->free_struct = asn_DEF_BIT_STRING.free_struct; |
| 60 | td->print_struct = asn_DEF_BIT_STRING.print_struct; |
| 61 | td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder; |
| 62 | td->der_encoder = asn_DEF_BIT_STRING.der_encoder; |
| 63 | td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder; |
| 64 | td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder; |
| 65 | td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder; |
| 66 | td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder; |
| 67 | if(!td->per_constraints) |
| 68 | td->per_constraints = asn_DEF_BIT_STRING.per_constraints; |
| 69 | td->elements = asn_DEF_BIT_STRING.elements; |
| 70 | td->elements_count = asn_DEF_BIT_STRING.elements_count; |
| 71 | td->specifics = asn_DEF_BIT_STRING.specifics; |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | T_free(asn_TYPE_descriptor_t *td, |
| 76 | void *struct_ptr, int contents_only) { |
| 77 | T_1_inherit_TYPE_descriptor(td); |
| 78 | td->free_struct(td, struct_ptr, contents_only); |
| 79 | } |
| 80 | |
| 81 | int |
| 82 | T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
| 83 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 84 | T_1_inherit_TYPE_descriptor(td); |
| 85 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 86 | } |
| 87 | |
| 88 | asn_dec_rval_t |
| 89 | T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 90 | void **structure, const void *bufptr, size_t size, int tag_mode) { |
| 91 | T_1_inherit_TYPE_descriptor(td); |
| 92 | return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
| 93 | } |
| 94 | |
| 95 | asn_enc_rval_t |
| 96 | T_encode_der(asn_TYPE_descriptor_t *td, |
| 97 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 98 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 99 | T_1_inherit_TYPE_descriptor(td); |
| 100 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 101 | } |
| 102 | |
| 103 | asn_dec_rval_t |
| 104 | T_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 105 | void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
| 106 | T_1_inherit_TYPE_descriptor(td); |
| 107 | return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
| 108 | } |
| 109 | |
| 110 | asn_enc_rval_t |
| 111 | T_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
| 112 | int ilevel, enum xer_encoder_flags_e flags, |
| 113 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 114 | T_1_inherit_TYPE_descriptor(td); |
| 115 | return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | /*** <<< STAT-DEFS [T] >>> ***/ |
| 120 | |
| 121 | static ber_tlv_tag_t asn_DEF_T_tags_1[] = { |
| 122 | (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)) |
| 123 | }; |
| 124 | asn_TYPE_descriptor_t asn_DEF_T = { |
| 125 | "T", |
| 126 | "T", |
| 127 | T_free, |
| 128 | T_print, |
| 129 | T_constraint, |
| 130 | T_decode_ber, |
| 131 | T_encode_der, |
| 132 | T_decode_xer, |
| 133 | T_encode_xer, |
| 134 | 0, 0, /* No PER support, use "-gen-PER" to enable */ |
| 135 | 0, /* Use generic outmost tag fetcher */ |
| 136 | asn_DEF_T_tags_1, |
| 137 | sizeof(asn_DEF_T_tags_1) |
| 138 | /sizeof(asn_DEF_T_tags_1[0]), /* 1 */ |
| 139 | asn_DEF_T_tags_1, /* Same as above */ |
| 140 | sizeof(asn_DEF_T_tags_1) |
| 141 | /sizeof(asn_DEF_T_tags_1[0]), /* 1 */ |
| 142 | 0, /* No PER visible constraints */ |
| 143 | 0, 0, /* Defined elsewhere */ |
| 144 | 0 /* No specifics */ |
| 145 | }; |
| 146 | |