Commit fb6344ef authored by Wim Lewis's avatar Wim Lewis

Declare most internal, constant tables as const, particularly the

"specifics" structures and the tables they point to.
parent 14e6b161
...@@ -175,7 +175,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) { ...@@ -175,7 +175,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
*/ */
REDIR(OT_STAT_DEFS); REDIR(OT_STAT_DEFS);
OUT("static asn_INTEGER_enum_map_t asn_MAP_%s_value2enum_%d[] = {\n", OUT("static const asn_INTEGER_enum_map_t asn_MAP_%s_value2enum_%d[] = {\n",
MKID(expr), expr->_type_unique_index); MKID(expr), expr->_type_unique_index);
qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byValue); qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byValue);
for(eidx = 0; eidx < el_count; eidx++) { for(eidx = 0; eidx < el_count; eidx++) {
...@@ -189,7 +189,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) { ...@@ -189,7 +189,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
OUT("\t/* This list is extensible */\n"); OUT("\t/* This list is extensible */\n");
OUT("};\n"); OUT("};\n");
OUT("static unsigned int asn_MAP_%s_enum2value_%d[] = {\n", OUT("static const unsigned int asn_MAP_%s_enum2value_%d[] = {\n",
MKID(expr), expr->_type_unique_index); MKID(expr), expr->_type_unique_index);
qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byName); qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byName);
for(eidx = 0; eidx < el_count; eidx++) { for(eidx = 0; eidx < el_count; eidx++) {
...@@ -202,7 +202,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) { ...@@ -202,7 +202,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
OUT("\t/* This list is extensible */\n"); OUT("\t/* This list is extensible */\n");
OUT("};\n"); OUT("};\n");
OUT("static asn_INTEGER_specifics_t asn_SPC_%s_specs_%d = {\n", OUT("static const asn_INTEGER_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr), expr->_type_unique_index); MKID(expr), expr->_type_unique_index);
INDENT(+1); INDENT(+1);
OUT("asn_MAP_%s_value2enum_%d,\t" OUT("asn_MAP_%s_value2enum_%d,\t"
...@@ -234,7 +234,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) { ...@@ -234,7 +234,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
if(expr->expr_type == ASN_BASIC_INTEGER if(expr->expr_type == ASN_BASIC_INTEGER
&& asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN) { && asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN) {
REDIR(OT_STAT_DEFS); REDIR(OT_STAT_DEFS);
OUT("static asn_INTEGER_specifics_t asn_SPC_%s_specs_%d = {\n", OUT("static const asn_INTEGER_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr), expr->_type_unique_index); MKID(expr), expr->_type_unique_index);
INDENT(+1); INDENT(+1);
OUT("0,\t"); OUT("0,\t");
...@@ -383,7 +383,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) { ...@@ -383,7 +383,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
int elm = 0; int elm = 0;
int comma = 0; int comma = 0;
comp_mode = 0; comp_mode = 0;
OUT("static int asn_MAP_%s_oms_%d[] = {", OUT("static const int asn_MAP_%s_oms_%d[] = {",
MKID(expr), MKID(expr),
expr->_type_unique_index); expr->_type_unique_index);
TQ_FOR(v, &(expr->members), next) { TQ_FOR(v, &(expr->members), next) {
...@@ -628,7 +628,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) { ...@@ -628,7 +628,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
/* /*
* Emit a map of mandatory elements. * Emit a map of mandatory elements.
*/ */
OUT("static uint8_t asn_MAP_%s_mmap_%d", OUT("static const uint8_t asn_MAP_%s_mmap_%d",
MKID(expr), expr->_type_unique_index); MKID(expr), expr->_type_unique_index);
p = MKID_safe(expr); p = MKID_safe(expr);
OUT("[(%d + (8 * sizeof(unsigned int)) - 1) / 8]", elements); OUT("[(%d + (8 * sizeof(unsigned int)) - 1) / 8]", elements);
...@@ -964,7 +964,7 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) { ...@@ -964,7 +964,7 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
int i; int i;
cmap = compute_canonical_members_order(arg, elements); cmap = compute_canonical_members_order(arg, elements);
if(cmap) { if(cmap) {
OUT("static int asn_MAP_%s_cmap_%d[] = {", OUT("static const int asn_MAP_%s_cmap_%d[] = {",
MKID(expr), MKID(expr),
expr->_type_unique_index); expr->_type_unique_index);
for(i = 0; i < elements; i++) { for(i = 0; i < elements; i++) {
...@@ -1661,7 +1661,7 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count, const char * ...@@ -1661,7 +1661,7 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count, const char *
if(!tag2el_count) return 0; /* No top level tags */ if(!tag2el_count) return 0; /* No top level tags */
OUT("static asn_TYPE_tag2member_t asn_MAP_%s_tag2el%s_%d[] = {\n", OUT("static const asn_TYPE_tag2member_t asn_MAP_%s_tag2el%s_%d[] = {\n",
MKID(expr), opt_modifier?opt_modifier:"", MKID(expr), opt_modifier?opt_modifier:"",
expr->_type_unique_index); expr->_type_unique_index);
for(i = 0; i < tag2el_count; i++) { for(i = 0; i < tag2el_count; i++) {
...@@ -1730,7 +1730,7 @@ emit_tags_vectors(arg_t *arg, asn1p_expr_t *expr, int *tags_count_r, int *all_ta ...@@ -1730,7 +1730,7 @@ emit_tags_vectors(arg_t *arg, asn1p_expr_t *expr, int *tags_count_r, int *all_ta
} }
#define EMIT_TAGS_TABLE(name, tags, tags_count) do { \ #define EMIT_TAGS_TABLE(name, tags, tags_count) do { \
OUT("static ber_tlv_tag_t asn_DEF_%s%s_tags_%d[] = {\n",\ OUT("static const ber_tlv_tag_t asn_DEF_%s%s_tags_%d[] = {\n",\
MKID(expr), name, \ MKID(expr), name, \
expr->_type_unique_index); \ expr->_type_unique_index); \
INDENT(+1); \ INDENT(+1); \
......
...@@ -208,8 +208,8 @@ INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, ...@@ -208,8 +208,8 @@ INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
struct e2v_key { struct e2v_key {
const char *start; const char *start;
const char *stop; const char *stop;
asn_INTEGER_enum_map_t *vemap; const asn_INTEGER_enum_map_t *vemap;
unsigned int *evmap; const unsigned int *evmap;
}; };
static int static int
INTEGER__compar_enum2value(const void *kp, const void *am) { INTEGER__compar_enum2value(const void *kp, const void *am) {
...@@ -232,7 +232,7 @@ INTEGER__compar_enum2value(const void *kp, const void *am) { ...@@ -232,7 +232,7 @@ INTEGER__compar_enum2value(const void *kp, const void *am) {
static const asn_INTEGER_enum_map_t * static const asn_INTEGER_enum_map_t *
INTEGER_map_enum2value(asn_INTEGER_specifics_t *specs, const char *lstart, const char *lstop) { INTEGER_map_enum2value(asn_INTEGER_specifics_t *specs, const char *lstart, const char *lstop) {
asn_INTEGER_enum_map_t *el_found; const asn_INTEGER_enum_map_t *el_found;
int count = specs ? specs->map_count : 0; int count = specs ? specs->map_count : 0;
struct e2v_key key; struct e2v_key key;
const char *lp; const char *lp;
......
...@@ -24,9 +24,9 @@ typedef struct asn_INTEGER_enum_map_s { ...@@ -24,9 +24,9 @@ typedef struct asn_INTEGER_enum_map_s {
} asn_INTEGER_enum_map_t; } asn_INTEGER_enum_map_t;
/* This type describes an enumeration for INTEGER and ENUMERATED types */ /* This type describes an enumeration for INTEGER and ENUMERATED types */
typedef struct asn_INTEGER_specifics_s { typedef const struct asn_INTEGER_specifics_s {
asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */ const asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
unsigned int *enum2value; /* "tag" => N; sorted by tag */ const unsigned int *enum2value; /* "tag" => N; sorted by tag */
int map_count; /* Elements in either map */ int map_count; /* Elements in either map */
int extension; /* This map is extensible */ int extension; /* This map is extensible */
int strict_enumeration; /* Enumeration set is fixed */ int strict_enumeration; /* Enumeration set is fixed */
......
...@@ -145,7 +145,7 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, ...@@ -145,7 +145,7 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
asn_per_constraint_t *ct; asn_per_constraint_t *ct;
int inext = 0; int inext = 0;
asn_INTEGER_enum_map_t key; asn_INTEGER_enum_map_t key;
asn_INTEGER_enum_map_t *kf; const asn_INTEGER_enum_map_t *kf;
if(!sptr) _ASN_ENCODE_FAILED; if(!sptr) _ASN_ENCODE_FAILED;
if(!specs) _ASN_ENCODE_FAILED; if(!specs) _ASN_ENCODE_FAILED;
......
...@@ -63,7 +63,7 @@ OCTET_STRING_t *OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td, ...@@ -63,7 +63,7 @@ OCTET_STRING_t *OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td,
* Internally useful stuff. * * Internally useful stuff. *
****************************/ ****************************/
typedef struct asn_OCTET_STRING_specifics_s { typedef const struct asn_OCTET_STRING_specifics_s {
/* /*
* Target structure description. * Target structure description.
*/ */
......
...@@ -183,11 +183,11 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -183,11 +183,11 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
} }
do { do {
asn_TYPE_tag2member_t *t2m; const asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key; asn_TYPE_tag2member_t key;
key.el_tag = tlv_tag; key.el_tag = tlv_tag;
t2m = (asn_TYPE_tag2member_t *)bsearch(&key, t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
specs->tag2el, specs->tag2el_count, specs->tag2el, specs->tag2el_count,
sizeof(specs->tag2el[0]), _search4tag); sizeof(specs->tag2el[0]), _search4tag);
if(t2m) { if(t2m) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct asn_CHOICE_specifics_s { typedef const struct asn_CHOICE_specifics_s {
/* /*
* Target structure description. * Target structure description.
*/ */
...@@ -24,7 +24,7 @@ typedef struct asn_CHOICE_specifics_s { ...@@ -24,7 +24,7 @@ typedef struct asn_CHOICE_specifics_s {
/* /*
* Tags to members mapping table. * Tags to members mapping table.
*/ */
asn_TYPE_tag2member_t *tag2el; const asn_TYPE_tag2member_t *tag2el;
int tag2el_count; int tag2el_count;
/* Canonical ordering of CHOICE elements, for PER */ /* Canonical ordering of CHOICE elements, for PER */
......
...@@ -310,16 +310,16 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -310,16 +310,16 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* Resort to a binary search over * Resort to a binary search over
* sorted array of tags. * sorted array of tags.
*/ */
asn_TYPE_tag2member_t *t2m; const asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key; asn_TYPE_tag2member_t key;
key.el_tag = tlv_tag; key.el_tag = tlv_tag;
key.el_no = edx; key.el_no = edx;
t2m = (asn_TYPE_tag2member_t *)bsearch(&key, t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
specs->tag2el, specs->tag2el_count, specs->tag2el, specs->tag2el_count,
sizeof(specs->tag2el[0]), _t2e_cmp); sizeof(specs->tag2el[0]), _t2e_cmp);
if(t2m) { if(t2m) {
asn_TYPE_tag2member_t *best = 0; const asn_TYPE_tag2member_t *best = 0;
asn_TYPE_tag2member_t *t2m_f, *t2m_l; const asn_TYPE_tag2member_t *t2m_f, *t2m_l;
int edx_max = edx + elements[edx].optional; int edx_max = edx + elements[edx].optional;
/* /*
* Rewind to the first element with that tag, * Rewind to the first element with that tag,
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct asn_SEQUENCE_specifics_s { typedef const struct asn_SEQUENCE_specifics_s {
/* /*
* Target structure description. * Target structure description.
*/ */
...@@ -21,14 +21,14 @@ typedef struct asn_SEQUENCE_specifics_s { ...@@ -21,14 +21,14 @@ typedef struct asn_SEQUENCE_specifics_s {
/* /*
* Tags to members mapping table (sorted). * Tags to members mapping table (sorted).
*/ */
asn_TYPE_tag2member_t *tag2el; const asn_TYPE_tag2member_t *tag2el;
int tag2el_count; int tag2el_count;
/* /*
* Optional members of the extensions root (roms) or additions (aoms). * Optional members of the extensions root (roms) or additions (aoms).
* Meaningful for PER. * Meaningful for PER.
*/ */
int *oms; /* Optional MemberS */ const int *oms; /* Optional MemberS */
int roms_count; /* Root optional members count */ int roms_count; /* Root optional members count */
int aoms_count; /* Additions optional members count */ int aoms_count; /* Additions optional members count */
......
...@@ -175,7 +175,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -175,7 +175,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* for optimization. * for optimization.
*/ */
for(;; ctx->step = 0) { for(;; ctx->step = 0) {
asn_TYPE_tag2member_t *t2m; const asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key; asn_TYPE_tag2member_t key;
void *memb_ptr; /* Pointer to the member */ void *memb_ptr; /* Pointer to the member */
void **memb_ptr2; /* Pointer to that pointer */ void **memb_ptr2; /* Pointer to that pointer */
...@@ -225,7 +225,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -225,7 +225,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
} }
key.el_tag = tlv_tag; key.el_tag = tlv_tag;
t2m = (asn_TYPE_tag2member_t *)bsearch(&key, t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
specs->tag2el, specs->tag2el_count, specs->tag2el, specs->tag2el_count,
sizeof(specs->tag2el[0]), _t2e_cmp); sizeof(specs->tag2el[0]), _t2e_cmp);
if(t2m) { if(t2m) {
...@@ -439,7 +439,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td, ...@@ -439,7 +439,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
size_t computed_size = 0; size_t computed_size = 0;
asn_enc_rval_t er; asn_enc_rval_t er;
int t2m_build_own = (specs->tag2el_count != td->elements_count); int t2m_build_own = (specs->tag2el_count != td->elements_count);
asn_TYPE_tag2member_t *t2m; const asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t *t2m_build;
int t2m_count; int t2m_count;
ssize_t ret; ssize_t ret;
int edx; int edx;
...@@ -448,17 +449,16 @@ SET_encode_der(asn_TYPE_descriptor_t *td, ...@@ -448,17 +449,16 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
* Use existing, or build our own tags map. * Use existing, or build our own tags map.
*/ */
if(t2m_build_own) { if(t2m_build_own) {
t2m = (asn_TYPE_tag2member_t *)alloca( t2m_build = (asn_TYPE_tag2member_t *)alloca(
td->elements_count * sizeof(t2m[0])); td->elements_count * sizeof(t2m_build[0]));
if(!t2m) _ASN_ENCODE_FAILED; /* There are such platforms */ if(!t2m_build) _ASN_ENCODE_FAILED; /* There are such platforms */
t2m_count = 0; t2m_count = 0;
} else { } else {
t2m_build = NULL;
/* /*
* There is no untagged CHOICE in this SET. * There is no untagged CHOICE in this SET.
* Employ existing table. * Employ existing table.
*/ */
t2m = specs->tag2el;
t2m_count = specs->tag2el_count;
} }
/* /*
...@@ -479,8 +479,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td, ...@@ -479,8 +479,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
/* Mandatory elements missing */ /* Mandatory elements missing */
_ASN_ENCODE_FAILED; _ASN_ENCODE_FAILED;
if(t2m_build_own) { if(t2m_build_own) {
t2m[t2m_count].el_no = edx; t2m_build[t2m_count].el_no = edx;
t2m[t2m_count].el_tag = 0; t2m_build[t2m_count].el_tag = 0;
t2m_count++; t2m_count++;
} }
continue; continue;
...@@ -499,8 +499,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td, ...@@ -499,8 +499,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
* Remember the outmost tag of this member. * Remember the outmost tag of this member.
*/ */
if(t2m_build_own) { if(t2m_build_own) {
t2m[t2m_count].el_no = edx; t2m_build[t2m_count].el_no = edx;
t2m[t2m_count].el_tag = asn_TYPE_outmost_tag( t2m_build[t2m_count].el_tag = asn_TYPE_outmost_tag(
elm->type, memb_ptr, elm->tag_mode, elm->tag); elm->type, memb_ptr, elm->tag_mode, elm->tag);
t2m_count++; t2m_count++;
} else { } else {
...@@ -513,18 +513,21 @@ SET_encode_der(asn_TYPE_descriptor_t *td, ...@@ -513,18 +513,21 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
/* /*
* Finalize order of the components. * Finalize order of the components.
*/ */
assert(t2m_count == td->elements_count);
if(t2m_build_own) { if(t2m_build_own) {
/* /*
* Sort the underlying members according to their * Sort the underlying members according to their
* canonical tags order. DER encoding mandates it. * canonical tags order. DER encoding mandates it.
*/ */
qsort(t2m, t2m_count, sizeof(specs->tag2el[0]), _t2e_cmp); qsort(t2m_build, t2m_count, sizeof(specs->tag2el[0]), _t2e_cmp);
t2m = t2m_build;
} else { } else {
/* /*
* Tags are already sorted by the compiler. * Tags are already sorted by the compiler.
*/ */
t2m = specs->tag2el;
t2m_count = specs->tag2el_count;
} }
assert(t2m_count == td->elements_count);
/* /*
* Encode the TLV for the sequence itself. * Encode the TLV for the sequence itself.
...@@ -803,7 +806,7 @@ SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, ...@@ -803,7 +806,7 @@ SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics; asn_SET_specifics_t *specs = (asn_SET_specifics_t *)td->specifics;
asn_enc_rval_t er; asn_enc_rval_t er;
int xcan = (flags & XER_F_CANONICAL); int xcan = (flags & XER_F_CANONICAL);
asn_TYPE_tag2member_t *t2m = specs->tag2el_cxer; const asn_TYPE_tag2member_t *t2m = specs->tag2el_cxer;
int t2m_count = specs->tag2el_cxer_count; int t2m_count = specs->tag2el_cxer_count;
int edx; int edx;
......
...@@ -12,7 +12,7 @@ extern "C" { ...@@ -12,7 +12,7 @@ extern "C" {
#endif #endif
typedef struct asn_SET_specifics_s { typedef const struct asn_SET_specifics_s {
/* /*
* Target structure description. * Target structure description.
*/ */
...@@ -25,21 +25,21 @@ typedef struct asn_SET_specifics_s { ...@@ -25,21 +25,21 @@ typedef struct asn_SET_specifics_s {
* Sometimes suitable for DER encoding (untagged CHOICE is present); * Sometimes suitable for DER encoding (untagged CHOICE is present);
* if so, tag2el_count will be greater than td->elements_count. * if so, tag2el_count will be greater than td->elements_count.
*/ */
asn_TYPE_tag2member_t *tag2el; const asn_TYPE_tag2member_t *tag2el;
int tag2el_count; int tag2el_count;
/* /*
* Tags to members mapping table, second edition. * Tags to members mapping table, second edition.
* Suitable for CANONICAL-XER encoding. * Suitable for CANONICAL-XER encoding.
*/ */
asn_TYPE_tag2member_t *tag2el_cxer; const asn_TYPE_tag2member_t *tag2el_cxer;
int tag2el_cxer_count; int tag2el_cxer_count;
/* /*
* Extensions-related stuff. * Extensions-related stuff.
*/ */
int extensible; /* Whether SET is extensible */ int extensible; /* Whether SET is extensible */
unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */ const unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */
} asn_SET_specifics_t; } asn_SET_specifics_t;
/* /*
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct asn_SET_OF_specifics_s { typedef const struct asn_SET_OF_specifics_s {
/* /*
* Target structure description. * Target structure description.
*/ */
......
...@@ -83,8 +83,8 @@ asn_outmost_tag_f asn_TYPE_outmost_tag; ...@@ -83,8 +83,8 @@ asn_outmost_tag_f asn_TYPE_outmost_tag;
* The definitive description of the destination language's structure. * The definitive description of the destination language's structure.
*/ */
typedef struct asn_TYPE_descriptor_s { typedef struct asn_TYPE_descriptor_s {
char *name; /* A name of the ASN.1 type. "" in some cases. */ const char *name; /* A name of the ASN.1 type. "" in some cases. */
char *xml_tag; /* Name used in XML tag */ const char *xml_tag; /* Name used in XML tag */
/* /*
* Generalized functions for dealing with the specific type. * Generalized functions for dealing with the specific type.
...@@ -108,10 +108,10 @@ typedef struct asn_TYPE_descriptor_s { ...@@ -108,10 +108,10 @@ typedef struct asn_TYPE_descriptor_s {
* Tags that are expected to occur. * Tags that are expected to occur.
*/ */
asn_outmost_tag_f *outmost_tag; /* <optional, internal> */ asn_outmost_tag_f *outmost_tag; /* <optional, internal> */
ber_tlv_tag_t *tags; /* Effective tags sequence for this type */ const ber_tlv_tag_t *tags; /* Effective tags sequence for this type */
int tags_count; /* Number of tags which are expected */ int tags_count; /* Number of tags which are expected */
ber_tlv_tag_t *all_tags;/* Every tag for BER/containment */ const ber_tlv_tag_t *all_tags; /* Every tag for BER/containment */
int all_tags_count; /* Number of tags */ int all_tags_count; /* Number of tags */
asn_per_constraints_t *per_constraints; /* PER compiled constraints */ asn_per_constraints_t *per_constraints; /* PER compiled constraints */
...@@ -125,7 +125,7 @@ typedef struct asn_TYPE_descriptor_s { ...@@ -125,7 +125,7 @@ typedef struct asn_TYPE_descriptor_s {
* Additional information describing the type, used by appropriate * Additional information describing the type, used by appropriate
* functions above. * functions above.
*/ */
void *specifics; const void *specifics;
} asn_TYPE_descriptor_t; } asn_TYPE_descriptor_t;
/* /*
...@@ -147,7 +147,7 @@ typedef struct asn_TYPE_member_s { ...@@ -147,7 +147,7 @@ typedef struct asn_TYPE_member_s {
asn_constr_check_f *memb_constraints; /* Constraints validator */ asn_constr_check_f *memb_constraints; /* Constraints validator */
asn_per_constraints_t *per_constraints; /* PER compiled constraints */ asn_per_constraints_t *per_constraints; /* PER compiled constraints */
int (*default_value)(int setval, void **sptr); /* DEFAULT <value> */ int (*default_value)(int setval, void **sptr); /* DEFAULT <value> */
char *name; /* ASN.1 identifier of the element */ const char *name; /* ASN.1 identifier of the element */
} asn_TYPE_member_t; } asn_TYPE_member_t;
/* /*
......
...@@ -80,8 +80,8 @@ der_write_tags(asn_TYPE_descriptor_t *sd, ...@@ -80,8 +80,8 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */ ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */
asn_app_consume_bytes_f *cb, asn_app_consume_bytes_f *cb,
void *app_key) { void *app_key) {
ber_tlv_tag_t *tags; /* Copy of tags stream */ const ber_tlv_tag_t *tags; /* Copy of tags stream */
int tags_count; /* Number of tags */ int tags_count; /* Number of tags */
size_t overall_length; size_t overall_length;
ssize_t *lens; ssize_t *lens;
int i; int i;
...@@ -102,8 +102,9 @@ der_write_tags(asn_TYPE_descriptor_t *sd, ...@@ -102,8 +102,9 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
* and initialize it appropriately. * and initialize it appropriately.
*/ */
int stag_offset; int stag_offset;
tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t)); ber_tlv_tag_t *tags_buf;
if(!tags) { /* Can fail on !x86 */ tags_buf = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
if(!tags_buf) { /* Can fail on !x86 */
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
...@@ -111,10 +112,11 @@ der_write_tags(asn_TYPE_descriptor_t *sd, ...@@ -111,10 +112,11 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
+ 1 /* EXPLICIT or IMPLICIT tag is given */ + 1 /* EXPLICIT or IMPLICIT tag is given */
- ((tag_mode == -1) && sd->tags_count); - ((tag_mode == -1) && sd->tags_count);
/* Copy tags over */ /* Copy tags over */
tags[0] = tag; tags_buf[0] = tag;
stag_offset = -1 + ((tag_mode == -1) && sd->tags_count); stag_offset = -1 + ((tag_mode == -1) && sd->tags_count);
for(i = 1; i < tags_count; i++) for(i = 1; i < tags_count; i++)
tags[i] = sd->tags[i + stag_offset]; tags_buf[i] = sd->tags[i + stag_offset];
tags = tags_buf;
} else { } else {
tags = sd->tags; tags = sd->tags;
tags_count = sd->tags_count; tags_count = sd->tags_count;
......
...@@ -24,7 +24,7 @@ static void ...@@ -24,7 +24,7 @@ static void
check_per_encode_constrained(int lineno, int unsigned_, long value, long lbound, unsigned long ubound, int bit_range) { check_per_encode_constrained(int lineno, int unsigned_, long value, long lbound, unsigned long ubound, int bit_range) {
INTEGER_t st; INTEGER_t st;
INTEGER_t *reconstructed_st = 0; INTEGER_t *reconstructed_st = 0;
asn_INTEGER_specifics_t specs; struct asn_INTEGER_specifics_s specs;
asn_per_constraints_t cts; asn_per_constraints_t cts;
asn_enc_rval_t enc_rval; asn_enc_rval_t enc_rval;
asn_dec_rval_t dec_rval; asn_dec_rval_t dec_rval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment