asn1c/tests/66-ref-simple-OK.asn1.-P

190 lines
5.1 KiB
Plaintext
Raw Normal View History

2004-09-17 06:32:12 +00:00
/*** <<< INCLUDES [T] >>> ***/
#include <SimpleType.h>
#include <asn_SET_OF.h>
#include <constr_SET_OF.h>
/*** <<< DEPS [T] >>> ***/
2004-09-29 13:19:37 +00:00
extern asn_TYPE_descriptor_t asn_DEF_T;
2004-09-17 06:32:12 +00:00
/*** <<< TYPE-DECLS [T] >>> ***/
typedef struct T {
A_SET_OF(SimpleType_t) list;
/* Context for parsing across buffer boundaries */
2004-09-29 13:19:37 +00:00
asn_struct_ctx_t _asn_ctx;
2004-09-17 06:32:12 +00:00
} T_t;
/*** <<< STAT-DEFS [T] >>> ***/
2004-09-29 13:19:37 +00:00
static asn_TYPE_member_t asn_MBR_T[] = {
2004-09-17 06:32:12 +00:00
{ ATF_NOFLAGS, 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
.tag_mode = 0,
2004-09-29 13:19:37 +00:00
.type = (void *)&asn_DEF_SimpleType,
2004-09-17 06:32:12 +00:00
.memb_constraints = 0, /* Defer to actual type */
.name = ""
},
};
2004-09-29 13:19:37 +00:00
static ber_tlv_tag_t asn_DEF_T_tags[] = {
2004-09-17 06:32:12 +00:00
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
2004-09-29 13:19:37 +00:00
static asn_SET_OF_specifics_t asn_DEF_T_specs = {
2004-09-17 06:32:12 +00:00
sizeof(struct T),
2004-09-29 13:19:37 +00:00
offsetof(struct T, _asn_ctx),
2004-09-22 16:06:28 +00:00
1, /* XER encoding is XMLValueList */
2004-09-17 06:32:12 +00:00
};
2004-09-29 13:19:37 +00:00
asn_TYPE_descriptor_t asn_DEF_T = {
2004-10-20 15:50:55 +00:00
"T",
2004-09-17 06:32:12 +00:00
"T",
2004-09-22 16:06:28 +00:00
SET_OF_free,
SET_OF_print,
2004-09-17 06:32:12 +00:00
SET_OF_constraint,
SET_OF_decode_ber,
SET_OF_encode_der,
2004-09-22 16:06:28 +00:00
0, /* Not implemented yet */
SET_OF_encode_xer,
2004-09-17 06:32:12 +00:00
0, /* Use generic outmost tag fetcher */
2004-09-29 13:19:37 +00:00
asn_DEF_T_tags,
sizeof(asn_DEF_T_tags)
/sizeof(asn_DEF_T_tags[0]), /* 1 */
asn_DEF_T_tags, /* Same as above */
sizeof(asn_DEF_T_tags)
/sizeof(asn_DEF_T_tags[0]), /* 1 */
asn_MBR_T,
2004-09-17 06:32:12 +00:00
1, /* Single element */
2004-09-29 13:19:37 +00:00
&asn_DEF_T_specs /* Additional specs */
2004-09-17 06:32:12 +00:00
};
/*** <<< INCLUDES [SimpleType] >>> ***/
#include <ENUMERATED.h>
/*** <<< DEPS [SimpleType] >>> ***/
typedef enum SimpleType {
SimpleType_one = 0,
SimpleType_two = 1,
SimpleType_three = 2,
} SimpleType_e;
/*** <<< TYPE-DECLS [SimpleType] >>> ***/
typedef ENUMERATED_t SimpleType_t;
/*** <<< FUNC-DECLS [SimpleType] >>> ***/
2004-09-29 13:19:37 +00:00
extern asn_TYPE_descriptor_t asn_DEF_SimpleType;
2004-09-22 16:06:28 +00:00
asn_struct_free_f SimpleType_free;
asn_struct_print_f SimpleType_print;
2004-09-17 06:32:12 +00:00
asn_constr_check_f SimpleType_constraint;
ber_type_decoder_f SimpleType_decode_ber;
der_type_encoder_f SimpleType_encode_der;
2004-10-23 13:26:56 +00:00
xer_type_decoder_f SimpleType_decode_xer;
2004-09-22 16:06:28 +00:00
xer_type_encoder_f SimpleType_encode_xer;
2004-09-17 06:32:12 +00:00
/*** <<< CODE [SimpleType] >>> ***/
int
2004-09-29 13:19:37 +00:00
SimpleType_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
2004-09-17 06:32:12 +00:00
asn_app_consume_bytes_f *app_errlog, void *app_key) {
/* Replace with underlying type checker */
2004-09-29 13:19:37 +00:00
td->check_constraints = asn_DEF_ENUMERATED.check_constraints;
return td->check_constraints(td, sptr, app_errlog, app_key);
2004-09-17 06:32:12 +00:00
}
/*
* This type is implemented using ENUMERATED,
2004-09-23 22:14:58 +00:00
* so here we adjust the DEF accordingly.
2004-09-17 06:32:12 +00:00
*/
static void
2004-09-29 13:19:37 +00:00
SimpleType_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
td->free_struct = asn_DEF_ENUMERATED.free_struct;
td->print_struct = asn_DEF_ENUMERATED.print_struct;
td->ber_decoder = asn_DEF_ENUMERATED.ber_decoder;
td->der_encoder = asn_DEF_ENUMERATED.der_encoder;
td->xer_decoder = asn_DEF_ENUMERATED.xer_decoder;
td->xer_encoder = asn_DEF_ENUMERATED.xer_encoder;
td->elements = asn_DEF_ENUMERATED.elements;
td->elements_count = asn_DEF_ENUMERATED.elements_count;
td->specifics = asn_DEF_ENUMERATED.specifics;
2004-09-17 06:32:12 +00:00
}
2004-09-22 16:06:28 +00:00
void
2004-09-29 13:19:37 +00:00
SimpleType_free(asn_TYPE_descriptor_t *td,
2004-09-22 16:06:28 +00:00
void *struct_ptr, int contents_only) {
SimpleType_inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
int
2004-09-29 13:19:37 +00:00
SimpleType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
2004-09-22 16:06:28 +00:00
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
SimpleType_inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
2004-10-20 15:50:55 +00:00
asn_dec_rval_t
2004-09-29 13:19:37 +00:00
SimpleType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
2004-09-17 06:32:12 +00:00
void **structure, void *bufptr, size_t size, int tag_mode) {
SimpleType_inherit_TYPE_descriptor(td);
2004-09-29 13:19:37 +00:00
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
2004-09-17 06:32:12 +00:00
}
2004-09-22 16:06:28 +00:00
asn_enc_rval_t
2004-09-29 13:19:37 +00:00
SimpleType_encode_der(asn_TYPE_descriptor_t *td,
2004-09-17 06:32:12 +00:00
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
SimpleType_inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
2004-10-23 13:26:56 +00:00
asn_dec_rval_t
SimpleType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const char *opt_mname, void *bufptr, size_t size) {
SimpleType_inherit_TYPE_descriptor(td);
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
}
2004-09-22 16:06:28 +00:00
asn_enc_rval_t
2004-09-29 13:19:37 +00:00
SimpleType_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
2004-09-22 16:06:28 +00:00
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
2004-09-17 06:32:12 +00:00
SimpleType_inherit_TYPE_descriptor(td);
2004-09-22 16:06:28 +00:00
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
2004-09-17 06:32:12 +00:00
}
/*** <<< STAT-DEFS [SimpleType] >>> ***/
2004-09-29 13:19:37 +00:00
static ber_tlv_tag_t asn_DEF_SimpleType_tags[] = {
2004-09-17 06:32:12 +00:00
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
};
2004-09-29 13:19:37 +00:00
asn_TYPE_descriptor_t asn_DEF_SimpleType = {
2004-10-20 15:50:55 +00:00
"SimpleType",
2004-09-17 06:32:12 +00:00
"SimpleType",
2004-09-22 16:06:28 +00:00
SimpleType_free,
SimpleType_print,
2004-09-17 06:32:12 +00:00
SimpleType_constraint,
SimpleType_decode_ber,
SimpleType_encode_der,
2004-10-23 13:26:56 +00:00
SimpleType_decode_xer,
2004-09-22 16:06:28 +00:00
SimpleType_encode_xer,
2004-09-17 06:32:12 +00:00
0, /* Use generic outmost tag fetcher */
2004-09-29 13:19:37 +00:00
asn_DEF_SimpleType_tags,
sizeof(asn_DEF_SimpleType_tags)
/sizeof(asn_DEF_SimpleType_tags[0]), /* 1 */
asn_DEF_SimpleType_tags, /* Same as above */
sizeof(asn_DEF_SimpleType_tags)
/sizeof(asn_DEF_SimpleType_tags[0]), /* 1 */
2004-09-17 06:32:12 +00:00
0, 0, /* No members */
0 /* No specifics */
};