aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2014-10-12 18:30:33 -0700
committerLev Walkin <vlm@lionet.info>2014-10-12 18:30:33 -0700
commit78d604fe9effde38b363c365f751298a0063d530 (patch)
tree91c4a741f7c1f20ddcf2635db901c24f60057e73
parent41bbf1cb4b2d6e4a080740c02f9cfb11179cfe16 (diff)
parent59e8d2847ef4e4681a83a1f22fc442ac3862aa7b (diff)
Merge pull request #46 from wiml/constify
Move as much data as possible into non-writable text by declaring it const
-rw-r--r--libasn1compiler/asn1c_C.c18
-rw-r--r--libasn1compiler/asn1c_constraint.c6
-rw-r--r--skeletons/BIT_STRING.c4
-rw-r--r--skeletons/BMPString.c2
-rw-r--r--skeletons/BOOLEAN.c2
-rw-r--r--skeletons/ENUMERATED.c2
-rw-r--r--skeletons/GeneralString.c2
-rw-r--r--skeletons/GeneralizedTime.c2
-rw-r--r--skeletons/GraphicString.c2
-rw-r--r--skeletons/IA5String.c2
-rw-r--r--skeletons/INTEGER.c12
-rw-r--r--skeletons/INTEGER.h6
-rw-r--r--skeletons/ISO646String.c2
-rw-r--r--skeletons/NULL.c2
-rw-r--r--skeletons/NativeEnumerated.c4
-rw-r--r--skeletons/NativeInteger.c2
-rw-r--r--skeletons/NativeReal.c2
-rw-r--r--skeletons/NumericString.c2
-rw-r--r--skeletons/OBJECT_IDENTIFIER.c12
-rw-r--r--skeletons/OBJECT_IDENTIFIER.h8
-rw-r--r--skeletons/OCTET_STRING.c16
-rw-r--r--skeletons/OCTET_STRING.h2
-rw-r--r--skeletons/ObjectDescriptor.c2
-rw-r--r--skeletons/PrintableString.c8
-rw-r--r--skeletons/REAL.c2
-rw-r--r--skeletons/RELATIVE-OID.c4
-rw-r--r--skeletons/RELATIVE-OID.h2
-rw-r--r--skeletons/T61String.c2
-rw-r--r--skeletons/TeletexString.c2
-rw-r--r--skeletons/UTCTime.c2
-rw-r--r--skeletons/UTF8String.c6
-rw-r--r--skeletons/UniversalString.c2
-rw-r--r--skeletons/VideotexString.c2
-rw-r--r--skeletons/VisibleString.c2
-rw-r--r--skeletons/constr_CHOICE.c8
-rw-r--r--skeletons/constr_CHOICE.h4
-rw-r--r--skeletons/constr_SEQUENCE.c8
-rw-r--r--skeletons/constr_SEQUENCE.h6
-rw-r--r--skeletons/constr_SET.c33
-rw-r--r--skeletons/constr_SET.h8
-rw-r--r--skeletons/constr_SET_OF.h2
-rw-r--r--skeletons/constr_TYPE.c2
-rw-r--r--skeletons/constr_TYPE.h18
-rw-r--r--skeletons/der_encoder.c14
-rw-r--r--skeletons/per_support.h8
-rw-r--r--skeletons/tests/check-PER-INTEGER.c4
-rw-r--r--skeletons/xer_support.c16
47 files changed, 139 insertions, 140 deletions
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index 6fa6ad30..d49fd3fe 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -175,7 +175,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
*/
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);
qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byValue);
for(eidx = 0; eidx < el_count; eidx++) {
@@ -189,7 +189,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
OUT("\t/* This list is extensible */\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);
qsort(v2e, el_count, sizeof(v2e[0]), compar_enumMap_byName);
for(eidx = 0; eidx < el_count; eidx++) {
@@ -202,7 +202,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
OUT("\t/* This list is extensible */\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);
INDENT(+1);
OUT("asn_MAP_%s_value2enum_%d,\t"
@@ -234,7 +234,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
if(expr->expr_type == ASN_BASIC_INTEGER
&& asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN) {
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);
INDENT(+1);
OUT("0,\t");
@@ -383,7 +383,7 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
int elm = 0;
int comma = 0;
comp_mode = 0;
- OUT("static int asn_MAP_%s_oms_%d[] = {",
+ OUT("static const int asn_MAP_%s_oms_%d[] = {",
MKID(expr),
expr->_type_unique_index);
TQ_FOR(v, &(expr->members), next) {
@@ -628,7 +628,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
/*
* 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);
p = MKID_safe(expr);
OUT("[(%d + (8 * sizeof(unsigned int)) - 1) / 8]", elements);
@@ -964,7 +964,7 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
int i;
cmap = compute_canonical_members_order(arg, elements);
if(cmap) {
- OUT("static int asn_MAP_%s_cmap_%d[] = {",
+ OUT("static const int asn_MAP_%s_cmap_%d[] = {",
MKID(expr),
expr->_type_unique_index);
for(i = 0; i < elements; i++) {
@@ -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 */
- 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:"",
expr->_type_unique_index);
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
}
#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, \
expr->_type_unique_index); \
INDENT(+1); \
diff --git a/libasn1compiler/asn1c_constraint.c b/libasn1compiler/asn1c_constraint.c
index bdabfff0..6fe896f9 100644
--- a/libasn1compiler/asn1c_constraint.c
+++ b/libasn1compiler/asn1c_constraint.c
@@ -315,7 +315,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
untl = (range_stop - range_start) + 1;
untl += (untl % 16)?16 - (untl % 16):0;
- OUT("static int permitted_alphabet_table_%d[%d] = {\n",
+ OUT("static const int permitted_alphabet_table_%d[%d] = {\n",
arg->expr->_type_unique_index, max_table_size);
for(n = 0; n < untl; n++) {
cardinal += table[n] ? 1 : 0;
@@ -347,7 +347,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
if((arg->flags & A1C_GEN_PER)
&& (etype & ASN_STRING_KM_MASK)) {
int c;
- OUT("static int permitted_alphabet_code2value_%d[%d] = {\n",
+ OUT("static const int permitted_alphabet_code2value_%d[%d] = {\n",
arg->expr->_type_unique_index, cardinal);
for(n = c = 0; c < max_table_size; c++) {
if(table[c]) {
@@ -396,7 +396,7 @@ asn1c_emit_constraint_tables(arg_t *arg, int got_size) {
OUT("\n");
} else {
if(use_table) {
- OUT("int *table = permitted_alphabet_table_%d;\n",
+ OUT("const int *table = permitted_alphabet_table_%d;\n",
arg->expr->_type_unique_index);
emit_alphabet_check_loop(arg, 0);
} else {
diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c
index 9b982712..9e0e50c6 100644
--- a/skeletons/BIT_STRING.c
+++ b/skeletons/BIT_STRING.c
@@ -9,7 +9,7 @@
/*
* BIT STRING basic type description.
*/
-static ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
+static const ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
};
static asn_OCTET_STRING_specifics_t asn_DEF_BIT_STRING_specs = {
@@ -140,7 +140,7 @@ cb_failed:
int
BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
- static const char *h2c = "0123456789ABCDEF";
+ const char * const h2c = "0123456789ABCDEF";
char scratch[64];
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
uint8_t *buf;
diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c
index 1aa8e511..458622cd 100644
--- a/skeletons/BMPString.c
+++ b/skeletons/BMPString.c
@@ -9,7 +9,7 @@
/*
* BMPString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_BMPString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_BMPString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (30 << 2)), /* [UNIVERSAL 30] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c
index 1b74ea1c..2ba07840 100644
--- a/skeletons/BOOLEAN.c
+++ b/skeletons/BOOLEAN.c
@@ -9,7 +9,7 @@
/*
* BOOLEAN basic type description.
*/
-static ber_tlv_tag_t asn_DEF_BOOLEAN_tags[] = {
+static const ber_tlv_tag_t asn_DEF_BOOLEAN_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (1 << 2))
};
asn_TYPE_descriptor_t asn_DEF_BOOLEAN = {
diff --git a/skeletons/ENUMERATED.c b/skeletons/ENUMERATED.c
index 90761a2d..045554bb 100644
--- a/skeletons/ENUMERATED.c
+++ b/skeletons/ENUMERATED.c
@@ -11,7 +11,7 @@
/*
* ENUMERATED basic type description.
*/
-static ber_tlv_tag_t asn_DEF_ENUMERATED_tags[] = {
+static const ber_tlv_tag_t asn_DEF_ENUMERATED_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
};
asn_TYPE_descriptor_t asn_DEF_ENUMERATED = {
diff --git a/skeletons/GeneralString.c b/skeletons/GeneralString.c
index 01b606be..c398d2b3 100644
--- a/skeletons/GeneralString.c
+++ b/skeletons/GeneralString.c
@@ -8,7 +8,7 @@
/*
* GeneralString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_GeneralString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_GeneralString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (27 << 2)), /* [UNIVERSAL 27] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index 9672c967..943ee459 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -147,7 +147,7 @@ static time_t timegm(struct tm *tm) {
/*
* GeneralizedTime basic type description.
*/
-static ber_tlv_tag_t asn_DEF_GeneralizedTime_tags[] = {
+static const ber_tlv_tag_t asn_DEF_GeneralizedTime_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (24 << 2)), /* [UNIVERSAL 24] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
diff --git a/skeletons/GraphicString.c b/skeletons/GraphicString.c
index 7d59d522..e572ccdf 100644
--- a/skeletons/GraphicString.c
+++ b/skeletons/GraphicString.c
@@ -8,7 +8,7 @@
/*
* GraphicString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_GraphicString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_GraphicString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (25 << 2)), /* [UNIVERSAL 25] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/IA5String.c b/skeletons/IA5String.c
index 02ecd3ee..0fdc0748 100644
--- a/skeletons/IA5String.c
+++ b/skeletons/IA5String.c
@@ -8,7 +8,7 @@
/*
* IA5String basic type description.
*/
-static ber_tlv_tag_t asn_DEF_IA5String_tags[] = {
+static const ber_tlv_tag_t asn_DEF_IA5String_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), /* [UNIVERSAL 22] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index 38ddb60b..8ead23d5 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -11,7 +11,7 @@
/*
* INTEGER basic type description.
*/
-static ber_tlv_tag_t asn_DEF_INTEGER_tags[] = {
+static const ber_tlv_tag_t asn_DEF_INTEGER_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_INTEGER = {
@@ -106,7 +106,7 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value(asn_INTEGER_specific
* INTEGER specific human-readable output.
*/
static ssize_t
-INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key, int plainOrXER) {
+INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key, int plainOrXER) {
asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics;
char scratch[32]; /* Enough for 64-bit integer */
uint8_t *buf = st->buf;
@@ -166,7 +166,7 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by
/* Output in the long xx:yy:zz... format */
/* TODO: replace with generic algorithm (Knuth TAOCP Vol 2, 4.3.1) */
for(p = scratch; buf < buf_end; buf++) {
- static const char *h2c = "0123456789ABCDEF";
+ const char * const h2c = "0123456789ABCDEF";
if((p - scratch) >= (ssize_t)(sizeof(scratch) - 4)) {
/* Flush buffer */
if(cb(scratch, p - scratch, app_key) < 0)
@@ -208,8 +208,8 @@ INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
struct e2v_key {
const char *start;
const char *stop;
- asn_INTEGER_enum_map_t *vemap;
- unsigned int *evmap;
+ const asn_INTEGER_enum_map_t *vemap;
+ const unsigned int *evmap;
};
static int
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 *
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;
struct e2v_key key;
const char *lp;
diff --git a/skeletons/INTEGER.h b/skeletons/INTEGER.h
index fe08b038..2813f0cb 100644
--- a/skeletons/INTEGER.h
+++ b/skeletons/INTEGER.h
@@ -24,9 +24,9 @@ typedef struct asn_INTEGER_enum_map_s {
} asn_INTEGER_enum_map_t;
/* This type describes an enumeration for INTEGER and ENUMERATED types */
-typedef struct asn_INTEGER_specifics_s {
- asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
- unsigned int *enum2value; /* "tag" => N; sorted by tag */
+typedef const struct asn_INTEGER_specifics_s {
+ const asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
+ const unsigned int *enum2value; /* "tag" => N; sorted by tag */
int map_count; /* Elements in either map */
int extension; /* This map is extensible */
int strict_enumeration; /* Enumeration set is fixed */
diff --git a/skeletons/ISO646String.c b/skeletons/ISO646String.c
index d6ded0ef..8d681c82 100644
--- a/skeletons/ISO646String.c
+++ b/skeletons/ISO646String.c
@@ -8,7 +8,7 @@
/*
* ISO646String basic type description.
*/
-static ber_tlv_tag_t asn_DEF_ISO646String_tags[] = {
+static const ber_tlv_tag_t asn_DEF_ISO646String_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/NULL.c b/skeletons/NULL.c
index 02c0de06..8dcb6aa9 100644
--- a/skeletons/NULL.c
+++ b/skeletons/NULL.c
@@ -10,7 +10,7 @@
/*
* NULL basic type description.
*/
-static ber_tlv_tag_t asn_DEF_NULL_tags[] = {
+static const ber_tlv_tag_t asn_DEF_NULL_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (5 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NULL = {
diff --git a/skeletons/NativeEnumerated.c b/skeletons/NativeEnumerated.c
index 1554220f..ecf66d1b 100644
--- a/skeletons/NativeEnumerated.c
+++ b/skeletons/NativeEnumerated.c
@@ -15,7 +15,7 @@
/*
* NativeEnumerated basic type description.
*/
-static ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = {
+static const ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = {
@@ -145,7 +145,7 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
asn_per_constraint_t *ct;
int inext = 0;
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(!specs) _ASN_ENCODE_FAILED;
diff --git a/skeletons/NativeInteger.c b/skeletons/NativeInteger.c
index cffd0be8..7f8e9276 100644
--- a/skeletons/NativeInteger.c
+++ b/skeletons/NativeInteger.c
@@ -16,7 +16,7 @@
/*
* NativeInteger basic type description.
*/
-static ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = {
+static const ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NativeInteger = {
diff --git a/skeletons/NativeReal.c b/skeletons/NativeReal.c
index 605ecb05..3fd51a4c 100644
--- a/skeletons/NativeReal.c
+++ b/skeletons/NativeReal.c
@@ -17,7 +17,7 @@
/*
* NativeReal basic type description.
*/
-static ber_tlv_tag_t asn_DEF_NativeReal_tags[] = {
+static const ber_tlv_tag_t asn_DEF_NativeReal_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (9 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NativeReal = {
diff --git a/skeletons/NumericString.c b/skeletons/NumericString.c
index 50fe4491..b669f571 100644
--- a/skeletons/NumericString.c
+++ b/skeletons/NumericString.c
@@ -8,7 +8,7 @@
/*
* NumericString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_NumericString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_NumericString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (18 << 2)), /* [UNIVERSAL 18] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c
index aece31b0..03bfc033 100644
--- a/skeletons/OBJECT_IDENTIFIER.c
+++ b/skeletons/OBJECT_IDENTIFIER.c
@@ -12,7 +12,7 @@
/*
* OBJECT IDENTIFIER basic type description.
*/
-static ber_tlv_tag_t asn_DEF_OBJECT_IDENTIFIER_tags[] = {
+static const ber_tlv_tag_t asn_DEF_OBJECT_IDENTIFIER_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (6 << 2))
};
asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = {
@@ -65,9 +65,9 @@ OBJECT_IDENTIFIER_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
int
-OBJECT_IDENTIFIER_get_single_arc(uint8_t *arcbuf, unsigned int arclen, signed int add, void *rvbufp, unsigned int rvsize) {
+OBJECT_IDENTIFIER_get_single_arc(const uint8_t *arcbuf, unsigned int arclen, signed int add, void *rvbufp, unsigned int rvsize) {
unsigned LE GCC_NOTUSED = 1; /* Little endian (x86) */
- uint8_t *arcend = arcbuf + arclen; /* End of arc */
+ const uint8_t *arcend = arcbuf + arclen; /* End of arc */
unsigned int cache = 0; /* No more than 14 significant bits */
unsigned char *rvbuf = (unsigned char *)rvbufp;
unsigned char *rvstart = rvbuf; /* Original start of the value buffer */
@@ -181,7 +181,7 @@ OBJECT_IDENTIFIER_get_single_arc(uint8_t *arcbuf, unsigned int arclen, signed in
}
ssize_t
-OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add,
+OBJECT_IDENTIFIER__dump_arc(const uint8_t *arcbuf, int arclen, int add,
asn_app_consume_bytes_f *cb, void *app_key) {
char scratch[64]; /* Conservative estimate */
unsigned long accum; /* Bits accumulator */
@@ -212,7 +212,7 @@ OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add,
}
int
-OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen, int add,
+OBJECT_IDENTIFIER_print_arc(const uint8_t *arcbuf, int arclen, int add,
asn_app_consume_bytes_f *cb, void *app_key) {
if(OBJECT_IDENTIFIER__dump_arc(arcbuf, arclen, add, cb, app_key) < 0)
@@ -360,7 +360,7 @@ OBJECT_IDENTIFIER_print(asn_TYPE_descriptor_t *td, const void *sptr,
}
int
-OBJECT_IDENTIFIER_get_arcs(OBJECT_IDENTIFIER_t *oid, void *arcs,
+OBJECT_IDENTIFIER_get_arcs(const OBJECT_IDENTIFIER_t *oid, void *arcs,
unsigned int arc_type_size, unsigned int arc_slots) {
void *arcs_end = (char *)arcs + (arc_type_size * arc_slots);
int num_arcs = 0;
diff --git a/skeletons/OBJECT_IDENTIFIER.h b/skeletons/OBJECT_IDENTIFIER.h
index 2bb5d032..c2c6373e 100644
--- a/skeletons/OBJECT_IDENTIFIER.h
+++ b/skeletons/OBJECT_IDENTIFIER.h
@@ -68,7 +68,7 @@ xer_type_encoder_f OBJECT_IDENTIFIER_encode_xer;
* WARNING: The function always returns the real number of arcs,
* even if there is no sufficient (_arc_slots) provided.
*/
-int OBJECT_IDENTIFIER_get_arcs(OBJECT_IDENTIFIER_t *_oid,
+int OBJECT_IDENTIFIER_get_arcs(const OBJECT_IDENTIFIER_t *_oid,
void *_arcs, /* e.g., unsigned int arcs[N] */
unsigned int _arc_type_size, /* e.g., sizeof(arcs[0]) */
unsigned int _arc_slots /* e.g., N */);
@@ -91,12 +91,12 @@ int OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *_oid,
/*
* Print the specified OBJECT IDENTIFIER arc.
*/
-int OBJECT_IDENTIFIER_print_arc(uint8_t *arcbuf, int arclen,
+int OBJECT_IDENTIFIER_print_arc(const uint8_t *arcbuf, int arclen,
int add, /* Arbitrary offset, required to process the first two arcs */
asn_app_consume_bytes_f *cb, void *app_key);
/* Same as above, but returns the number of written digits, instead of 0 */
-ssize_t OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add,
+ssize_t OBJECT_IDENTIFIER__dump_arc(const uint8_t *arcbuf, int arclen, int add,
asn_app_consume_bytes_f *cb, void *app_key);
/*
@@ -127,7 +127,7 @@ int OBJECT_IDENTIFIER_parse_arcs(const char *oid_text, ssize_t oid_txt_length,
* Internal functions.
* Used by RELATIVE-OID implementation in particular.
*/
-int OBJECT_IDENTIFIER_get_single_arc(uint8_t *arcbuf, unsigned int arclen,
+int OBJECT_IDENTIFIER_get_single_arc(const uint8_t *arcbuf, unsigned int arclen,
signed int add, void *value, unsigned int value_size);
int OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf,
const void *arcval, unsigned int arcval_size, int _prepared_order);
diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c
index f2eec13a..ece27a28 100644
--- a/skeletons/OCTET_STRING.c
+++ b/skeletons/OCTET_STRING.c
@@ -11,15 +11,15 @@
/*
* OCTET STRING basic type description.
*/
-static ber_tlv_tag_t asn_DEF_OCTET_STRING_tags[] = {
+static const ber_tlv_tag_t asn_DEF_OCTET_STRING_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
};
-static asn_OCTET_STRING_specifics_t asn_DEF_OCTET_STRING_specs = {
+static const asn_OCTET_STRING_specifics_t asn_DEF_OCTET_STRING_specs = {
sizeof(OCTET_STRING_t),
offsetof(OCTET_STRING_t, _asn_ctx),
ASN_OSUBV_STR
};
-static asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = {
+static const asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = {
{ APC_CONSTRAINED, 8, 8, 0, 255 },
{ APC_SEMI_CONSTRAINED, -1, -1, 0, 0 },
0, 0
@@ -580,7 +580,7 @@ asn_enc_rval_t
OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
- static const char *h2c = "0123456789ABCDEF";
+ const char * const h2c = "0123456789ABCDEF";
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
asn_enc_rval_t er;
char scratch[16 * 3 + 4];
@@ -639,8 +639,8 @@ cb_failed:
_ASN_ENCODE_FAILED;
}
-static struct OCTET_STRING__xer_escape_table_s {
- char *string;
+static const struct OCTET_STRING__xer_escape_table_s {
+ const char *string;
int size;
} OCTET_STRING__xer_escape_table[] = {
#define OSXET(s) { s, sizeof(s) - 1 }
@@ -702,7 +702,7 @@ OS__check_escaped_control_char(const void *buf, int size) {
* nested table lookups).
*/
for(i = 0; i < 32 /* Don't spend time on the bottom half */; i++) {
- struct OCTET_STRING__xer_escape_table_s *el;
+ const struct OCTET_STRING__xer_escape_table_s *el;
el = &OCTET_STRING__xer_escape_table[i];
if(el->size == size && memcmp(buf, el->string, size) == 0)
return i;
@@ -1655,7 +1655,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
int
OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
- static const char *h2c = "0123456789ABCDEF";
+ const char * const h2c = "0123456789ABCDEF";
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
char scratch[16 * 3 + 4];
char *p = scratch;
diff --git a/skeletons/OCTET_STRING.h b/skeletons/OCTET_STRING.h
index 8df9a182..013c7b13 100644
--- a/skeletons/OCTET_STRING.h
+++ b/skeletons/OCTET_STRING.h
@@ -63,7 +63,7 @@ OCTET_STRING_t *OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td,
* Internally useful stuff. *
****************************/
-typedef struct asn_OCTET_STRING_specifics_s {
+typedef const struct asn_OCTET_STRING_specifics_s {
/*
* Target structure description.
*/
diff --git a/skeletons/ObjectDescriptor.c b/skeletons/ObjectDescriptor.c
index cd8e8a38..31bc1b2c 100644
--- a/skeletons/ObjectDescriptor.c
+++ b/skeletons/ObjectDescriptor.c
@@ -8,7 +8,7 @@
/*
* ObjectDescriptor basic type description.
*/
-static ber_tlv_tag_t asn_DEF_ObjectDescriptor_tags[] = {
+static const ber_tlv_tag_t asn_DEF_ObjectDescriptor_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), /* [UNIVERSAL 7] IMPLICIT ... */
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/PrintableString.c b/skeletons/PrintableString.c
index c8ee3ae3..173d7758 100644
--- a/skeletons/PrintableString.c
+++ b/skeletons/PrintableString.c
@@ -9,7 +9,7 @@
/*
* ASN.1:1984 (X.409)
*/
-static int _PrintableString_alphabet[256] = {
+static const int _PrintableString_alphabet[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
1, 0, 0, 0, 0, 0, 0, 2, 3, 4, 0, 5, 6, 7, 8, 9, /* . '() +,-./ */
@@ -19,7 +19,7 @@ static int _PrintableString_alphabet[256] = {
0,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63, /* abcdefghijklmno */
64,65,66,67,68,69,70,71,72,73,74, 0, 0, 0, 0, 0, /* pqrstuvwxyz */
};
-static int _PrintableString_code2value[74] = {
+static const int _PrintableString_code2value[74] = {
32,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,
55,56,57,58,61,63,65,66,67,68,69,70,71,72,73,74,
75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,
@@ -29,7 +29,7 @@ static int _PrintableString_code2value[74] = {
/*
* PrintableString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_PrintableString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_PrintableString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (19 << 2)), /* [UNIVERSAL 19] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
@@ -41,7 +41,7 @@ static int asn_DEF_PrintableString_c2v(unsigned int code) {
return _PrintableString_code2value[code];
return -1;
}
-static asn_per_constraints_t asn_DEF_PrintableString_constraints = {
+static const asn_per_constraints_t asn_DEF_PrintableString_constraints = {
{ APC_CONSTRAINED, 4, 4, 0x20, 0x39 }, /* Value */
{ APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */
asn_DEF_PrintableString_v2c,
diff --git a/skeletons/REAL.c b/skeletons/REAL.c
index 1b8e30cf..1212050c 100644
--- a/skeletons/REAL.c
+++ b/skeletons/REAL.c
@@ -36,7 +36,7 @@ static volatile double real_zero GCC_NOTUSED = 0.0;
/*
* REAL basic type description.
*/
-static ber_tlv_tag_t asn_DEF_REAL_tags[] = {
+static const ber_tlv_tag_t asn_DEF_REAL_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (9 << 2))
};
asn_TYPE_descriptor_t asn_DEF_REAL = {
diff --git a/skeletons/RELATIVE-OID.c b/skeletons/RELATIVE-OID.c
index 4275c0ab..44f27587 100644
--- a/skeletons/RELATIVE-OID.c
+++ b/skeletons/RELATIVE-OID.c
@@ -13,7 +13,7 @@
/*
* RELATIVE-OID basic type description.
*/
-static ber_tlv_tag_t asn_DEF_RELATIVE_OID_tags[] = {
+static const ber_tlv_tag_t asn_DEF_RELATIVE_OID_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (13 << 2))
};
asn_TYPE_descriptor_t asn_DEF_RELATIVE_OID = {
@@ -162,7 +162,7 @@ RELATIVE_OID_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
}
int
-RELATIVE_OID_get_arcs(RELATIVE_OID_t *roid,
+RELATIVE_OID_get_arcs(const RELATIVE_OID_t *roid,
void *arcs, unsigned int arc_type_size, unsigned int arc_slots) {
void *arcs_end = (char *)arcs + (arc_slots * arc_type_size);
int num_arcs = 0;
diff --git a/skeletons/RELATIVE-OID.h b/skeletons/RELATIVE-OID.h
index 2235cfdd..65acaab4 100644
--- a/skeletons/RELATIVE-OID.h
+++ b/skeletons/RELATIVE-OID.h
@@ -25,7 +25,7 @@ xer_type_encoder_f RELATIVE_OID_encode_xer;
**********************************/
/* See OBJECT_IDENTIFIER_get_arcs() function in OBJECT_IDENTIFIER.h */
-int RELATIVE_OID_get_arcs(RELATIVE_OID_t *_roid,
+int RELATIVE_OID_get_arcs(const RELATIVE_OID_t *_roid,
void *arcs, unsigned int arc_type_size, unsigned int arc_slots);
/* See OBJECT_IDENTIFIER_set_arcs() function in OBJECT_IDENTIFIER.h */
diff --git a/skeletons/T61String.c b/skeletons/T61String.c
index 98461bbb..115d7d43 100644
--- a/skeletons/T61String.c
+++ b/skeletons/T61String.c
@@ -8,7 +8,7 @@
/*
* T61String basic type description.
*/
-static ber_tlv_tag_t asn_DEF_T61String_tags[] = {
+static const ber_tlv_tag_t asn_DEF_T61String_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (20 << 2)), /* [UNIVERSAL 20] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/TeletexString.c b/skeletons/TeletexString.c
index cc2acada..faad6973 100644
--- a/skeletons/TeletexString.c
+++ b/skeletons/TeletexString.c
@@ -8,7 +8,7 @@
/*
* TeletexString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_TeletexString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_TeletexString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (20 << 2)), /* [UNIVERSAL 20] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), /* ... OCTET STRING */
};
diff --git a/skeletons/UTCTime.c b/skeletons/UTCTime.c
index 0abe1db7..edcbaf19 100644
--- a/skeletons/UTCTime.c
+++ b/skeletons/UTCTime.c
@@ -18,7 +18,7 @@
/*
* UTCTime basic type description.
*/
-static ber_tlv_tag_t asn_DEF_UTCTime_tags[] = {
+static const ber_tlv_tag_t asn_DEF_UTCTime_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (23 << 2)), /* [UNIVERSAL 23] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
diff --git a/skeletons/UTF8String.c b/skeletons/UTF8String.c
index 7e73d775..5e4f2506 100644
--- a/skeletons/UTF8String.c
+++ b/skeletons/UTF8String.c
@@ -9,7 +9,7 @@
/*
* UTF8String basic type description.
*/
-static ber_tlv_tag_t asn_DEF_UTF8String_tags[] = {
+static const ber_tlv_tag_t asn_DEF_UTF8String_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), /* [UNIVERSAL 12] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), /* ... OCTET STRING */
};
@@ -41,7 +41,7 @@ asn_TYPE_descriptor_t asn_DEF_UTF8String = {
* This is the table of length expectations.
* The second half of this table is only applicable to the long sequences.
*/
-static int UTF8String_ht[2][16] = {
+static const int UTF8String_ht[2][16] = {
{ /* 0x0 ... 0x7 */
/* 0000..0111 */
1, 1, 1, 1, 1, 1, 1, 1,
@@ -52,7 +52,7 @@ static int UTF8String_ht[2][16] = {
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 6, 6, -1, -1 }
};
-static int32_t UTF8String_mv[7] = { 0, 0,
+static const int32_t UTF8String_mv[7] = { 0, 0,
0x00000080,
0x00000800,
0x00010000,
diff --git a/skeletons/UniversalString.c b/skeletons/UniversalString.c
index 7d16781f..b758be02 100644
--- a/skeletons/UniversalString.c
+++ b/skeletons/UniversalString.c
@@ -9,7 +9,7 @@
/*
* UniversalString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_UniversalString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_UniversalString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (28 << 2)), /* [UNIVERSAL 28] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/VideotexString.c b/skeletons/VideotexString.c
index df7233e5..09967db1 100644
--- a/skeletons/VideotexString.c
+++ b/skeletons/VideotexString.c
@@ -8,7 +8,7 @@
/*
* VideotexString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_VideotexString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_VideotexString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (21 << 2)), /* [UNIVERSAL 21] IMPLICIT */
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/VisibleString.c b/skeletons/VisibleString.c
index 3487b6f9..baf8d0c9 100644
--- a/skeletons/VisibleString.c
+++ b/skeletons/VisibleString.c
@@ -8,7 +8,7 @@
/*
* VisibleString basic type description.
*/
-static ber_tlv_tag_t asn_DEF_VisibleString_tags[] = {
+static const ber_tlv_tag_t asn_DEF_VisibleString_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
};
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index 5a1e0d38..f366f754 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -183,11 +183,11 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
}
do {
- asn_TYPE_tag2member_t *t2m;
+ const asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key;
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,
sizeof(specs->tag2el[0]), _search4tag);
if(t2m) {
@@ -445,7 +445,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
}
ber_tlv_tag_t
-CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
+CHOICE_outmost_tag(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
int present;
@@ -458,7 +458,7 @@ CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber
present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
if(present > 0 || present <= td->elements_count) {
- asn_TYPE_member_t *elm = &td->elements[present-1];
+ const asn_TYPE_member_t *elm = &td->elements[present-1];
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
diff --git a/skeletons/constr_CHOICE.h b/skeletons/constr_CHOICE.h
index 83404e6d..e824a220 100644
--- a/skeletons/constr_CHOICE.h
+++ b/skeletons/constr_CHOICE.h
@@ -12,7 +12,7 @@
extern "C" {
#endif
-typedef struct asn_CHOICE_specifics_s {
+typedef const struct asn_CHOICE_specifics_s {
/*
* Target structure description.
*/
@@ -24,7 +24,7 @@ typedef struct asn_CHOICE_specifics_s {
/*
* Tags to members mapping table.
*/
- asn_TYPE_tag2member_t *tag2el;
+ const asn_TYPE_tag2member_t *tag2el;
int tag2el_count;
/* Canonical ordering of CHOICE elements, for PER */
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index c405a18f..07dcedfb 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -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
* sorted array of tags.
*/
- asn_TYPE_tag2member_t *t2m;
+ const asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key;
key.el_tag = tlv_tag;
key.el_no = edx;
- t2m = (asn_TYPE_tag2member_t *)bsearch(&key,
+ t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
specs->tag2el, specs->tag2el_count,
sizeof(specs->tag2el[0]), _t2e_cmp);
if(t2m) {
- asn_TYPE_tag2member_t *best = 0;
- asn_TYPE_tag2member_t *t2m_f, *t2m_l;
+ const asn_TYPE_tag2member_t *best = 0;
+ const asn_TYPE_tag2member_t *t2m_f, *t2m_l;
int edx_max = edx + elements[edx].optional;
/*
* Rewind to the first element with that tag,
diff --git a/skeletons/constr_SEQUENCE.h b/skeletons/constr_SEQUENCE.h
index 5f589d5c..c2aeb667 100644
--- a/skeletons/constr_SEQUENCE.h
+++ b/skeletons/constr_SEQUENCE.h
@@ -11,7 +11,7 @@
extern "C" {
#endif
-typedef struct asn_SEQUENCE_specifics_s {
+typedef const struct asn_SEQUENCE_specifics_s {
/*
* Target structure description.
*/
@@ -21,14 +21,14 @@ typedef struct asn_SEQUENCE_specifics_s {
/*
* Tags to members mapping table (sorted).
*/
- asn_TYPE_tag2member_t *tag2el;
+ const asn_TYPE_tag2member_t *tag2el;
int tag2el_count;
/*
* Optional members of the extensions root (roms) or additions (aoms).
* Meaningful for PER.
*/
- int *oms; /* Optional MemberS */
+ const int *oms; /* Optional MemberS */
int roms_count; /* Root optional members count */
int aoms_count; /* Additions optional members count */
diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c
index e8410a88..1fcbc2e4 100644
--- a/skeletons/constr_SET.c
+++ b/skeletons/constr_SET.c
@@ -175,7 +175,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* for optimization.
*/
for(;; ctx->step = 0) {
- asn_TYPE_tag2member_t *t2m;
+ const asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key;
void *memb_ptr; /* Pointer to the member */
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,
}
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,
sizeof(specs->tag2el[0]), _t2e_cmp);
if(t2m) {
@@ -439,7 +439,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
size_t computed_size = 0;
asn_enc_rval_t er;
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;
ssize_t ret;
int edx;
@@ -448,17 +449,16 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
* Use existing, or build our own tags map.
*/
if(t2m_build_own) {
- t2m = (asn_TYPE_tag2member_t *)alloca(
- td->elements_count * sizeof(t2m[0]));
- if(!t2m) _ASN_ENCODE_FAILED; /* There are such platforms */
+ t2m_build = (asn_TYPE_tag2member_t *)alloca(
+ td->elements_count * sizeof(t2m_build[0]));
+ if(!t2m_build) _ASN_ENCODE_FAILED; /* There are such platforms */
t2m_count = 0;
} else {
+ t2m_build = NULL;
/*
* There is no untagged CHOICE in this SET.
* Employ existing table.
*/
- t2m = specs->tag2el;
- t2m_count = specs->tag2el_count;
}
/*
@@ -479,8 +479,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
/* Mandatory elements missing */
_ASN_ENCODE_FAILED;
if(t2m_build_own) {
- t2m[t2m_count].el_no = edx;
- t2m[t2m_count].el_tag = 0;
+ t2m_build[t2m_count].el_no = edx;
+ t2m_build[t2m_count].el_tag = 0;
t2m_count++;
}
continue;
@@ -499,8 +499,8 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
* Remember the outmost tag of this member.
*/
if(t2m_build_own) {
- t2m[t2m_count].el_no = edx;
- t2m[t2m_count].el_tag = asn_TYPE_outmost_tag(
+ t2m_build[t2m_count].el_no = edx;
+ t2m_build[t2m_count].el_tag = asn_TYPE_outmost_tag(
elm->type, memb_ptr, elm->tag_mode, elm->tag);
t2m_count++;
} else {
@@ -513,18 +513,21 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
/*
* Finalize order of the components.
*/
- assert(t2m_count == td->elements_count);
if(t2m_build_own) {
/*
* Sort the underlying members according to their
* 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 {
/*
* 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.
@@ -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_enc_rval_t er;
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 edx;
diff --git a/skeletons/constr_SET.h b/skeletons/constr_SET.h
index 0c78ed59..6a3a1aa9 100644
--- a/skeletons/constr_SET.h
+++ b/skeletons/constr_SET.h
@@ -12,7 +12,7 @@ extern "C" {
#endif
-typedef struct asn_SET_specifics_s {
+typedef const struct asn_SET_specifics_s {
/*
* Target structure description.
*/
@@ -25,21 +25,21 @@ typedef struct asn_SET_specifics_s {
* Sometimes suitable for DER encoding (untagged CHOICE is present);
* 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;
/*
* Tags to members mapping table, second edition.
* Suitable for CANONICAL-XER encoding.
*/
- asn_TYPE_tag2member_t *tag2el_cxer;
+ const asn_TYPE_tag2member_t *tag2el_cxer;
int tag2el_cxer_count;
/*
* Extensions-related stuff.
*/
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;
/*
diff --git a/skeletons/constr_SET_OF.h b/skeletons/constr_SET_OF.h
index bcd09662..75e18cfa 100644
--- a/skeletons/constr_SET_OF.h
+++ b/skeletons/constr_SET_OF.h
@@ -11,7 +11,7 @@
extern "C" {
#endif
-typedef struct asn_SET_OF_specifics_s {
+typedef const struct asn_SET_OF_specifics_s {
/*
* Target structure description.
*/
diff --git a/skeletons/constr_TYPE.c b/skeletons/constr_TYPE.c
index 4bc88d44..322f68c8 100644
--- a/skeletons/constr_TYPE.c
+++ b/skeletons/constr_TYPE.c
@@ -17,7 +17,7 @@ static asn_app_consume_bytes_f _print2fp;
* Return the outmost tag of the type.
*/
ber_tlv_tag_t
-asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor,
+asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor,
const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) {
if(tag_mode)
diff --git a/skeletons/constr_TYPE.h b/skeletons/constr_TYPE.h
index 95507c80..a9cd86dc 100644
--- a/skeletons/constr_TYPE.h
+++ b/skeletons/constr_TYPE.h
@@ -73,7 +73,7 @@ typedef int (asn_struct_print_f)(
* Do not use it in your application.
*/
typedef ber_tlv_tag_t (asn_outmost_tag_f)(
- struct asn_TYPE_descriptor_s *type_descriptor,
+ const struct asn_TYPE_descriptor_s *type_descriptor,
const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag);
/* The instance of the above function type; used internally. */
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.
*/
typedef struct asn_TYPE_descriptor_s {
- char *name; /* A name of the ASN.1 type. "" in some cases. */
- char *xml_tag; /* Name used in XML tag */
+ const char *name; /* A name of the ASN.1 type. "" in some cases. */
+ const char *xml_tag; /* Name used in XML tag */
/*
* Generalized functions for dealing with the specific type.
@@ -108,10 +108,10 @@ typedef struct asn_TYPE_descriptor_s {
* Tags that are expected to occur.
*/
asn_outmost_tag_f *outmost_tag; /* <optional, internal> */
- ber_tlv_tag_t *tags; /* Effective tags sequence for this type */
- int tags_count; /* Number of tags which are expected */
- ber_tlv_tag_t *all_tags;/* Every tag for BER/containment */
- int all_tags_count; /* Number of tags */
+ const ber_tlv_tag_t *tags; /* Effective tags sequence for this type */
+ int tags_count; /* Number of tags which are expected */
+ const ber_tlv_tag_t *all_tags; /* Every tag for BER/containment */
+ int all_tags_count; /* Number of tags */
asn_per_constraints_t *per_constraints; /* PER compiled constraints */
@@ -125,7 +125,7 @@ typedef struct asn_TYPE_descriptor_s {
* Additional information describing the type, used by appropriate
* functions above.
*/
- void *specifics;
+ const void *specifics;
} asn_TYPE_descriptor_t;
/*
@@ -147,7 +147,7 @@ typedef struct asn_TYPE_member_s {
asn_constr_check_f *memb_constraints; /* Constraints validator */
asn_per_constraints_t *per_constraints; /* PER compiled constraints */
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;
/*
diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c
index 6c859e1b..1c014802 100644
--- a/skeletons/der_encoder.c
+++ b/skeletons/der_encoder.c
@@ -80,8 +80,8 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */
asn_app_consume_bytes_f *cb,
void *app_key) {
- ber_tlv_tag_t *tags; /* Copy of tags stream */
- int tags_count; /* Number of tags */
+ const ber_tlv_tag_t *tags; /* Copy of tags stream */
+ int tags_count; /* Number of tags */
size_t overall_length;
ssize_t *lens;
int i;
@@ -102,8 +102,9 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
* and initialize it appropriately.
*/
int stag_offset;
- tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
- if(!tags) { /* Can fail on !x86 */
+ ber_tlv_tag_t *tags_buf;
+ 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;
return -1;
}
@@ -111,10 +112,11 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
+ 1 /* EXPLICIT or IMPLICIT tag is given */
- ((tag_mode == -1) && sd->tags_count);
/* Copy tags over */
- tags[0] = tag;
+ tags_buf[0] = tag;
stag_offset = -1 + ((tag_mode == -1) && sd->tags_count);
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 {
tags = sd->tags;
tags_count = sd->tags_count;
diff --git a/skeletons/per_support.h b/skeletons/per_support.h
index 10c84ed0..a75ac94f 100644
--- a/skeletons/per_support.h
+++ b/skeletons/per_support.h
@@ -15,7 +15,7 @@ extern "C" {
/*
* Pre-computed PER constraints.
*/
-typedef struct asn_per_constraint_s {
+typedef const struct asn_per_constraint_s {
enum asn_per_constraint_flags {
APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
@@ -27,9 +27,9 @@ typedef struct asn_per_constraint_s {
long lower_bound; /* "lb" value */
long upper_bound; /* "ub" value */
} asn_per_constraint_t;
-typedef struct asn_per_constraints_s {
- asn_per_constraint_t value;
- asn_per_constraint_t size;
+typedef const struct asn_per_constraints_s {
+ struct asn_per_constraint_s value;
+ struct asn_per_constraint_s size;
int (*value2code)(unsigned int value);
int (*code2value)(unsigned int code);
} asn_per_constraints_t;
diff --git a/skeletons/tests/check-PER-INTEGER.c b/skeletons/tests/check-PER-INTEGER.c
index 94f8280a..fc5106aa 100644
--- a/skeletons/tests/check-PER-INTEGER.c
+++ b/skeletons/tests/check-PER-INTEGER.c
@@ -23,8 +23,8 @@ static void
check_per_encode_constrained(int lineno, int unsigned_, long value, long lbound, unsigned long ubound, int bit_range) {
INTEGER_t st;
INTEGER_t *reconstructed_st = 0;
- asn_INTEGER_specifics_t specs;
- asn_per_constraints_t cts;
+ struct asn_INTEGER_specifics_s specs;
+ struct asn_per_constraints_s cts;
asn_enc_rval_t enc_rval;
asn_dec_rval_t dec_rval;
asn_per_outp_t po;
diff --git a/skeletons/xer_support.c b/skeletons/xer_support.c
index 9e34e692..36b4bfbf 100644
--- a/skeletons/xer_support.c
+++ b/skeletons/xer_support.c
@@ -22,16 +22,7 @@ typedef enum {
ST_COMMENT_CLO_RT /* "-->"[1] */
} pstate_e;
-static pxml_chunk_type_e final_chunk_type[] = {
- PXML_TEXT,
- PXML_TAG_END,
- PXML_COMMENT_END,
- PXML_TAG_END,
- PXML_COMMENT_END,
-};
-
-
-static int
+static const int
_charclass[256] = {
0,0,0,0,0,0,0,0, 0,1,1,0,1,1,0,0,
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
@@ -79,8 +70,11 @@ _charclass[256] = {
#define TOKEN_CB(_type, _ns, _current_too) \
TOKEN_CB_CALL(_type, _ns, _current_too, 0)
+#define PXML_TAG_FINAL_CHUNK_TYPE PXML_TAG_END
+#define PXML_COMMENT_FINAL_CHUNK_TYPE PXML_COMMENT_END
+
#define TOKEN_CB_FINAL(_type, _ns, _current_too) \
- TOKEN_CB_CALL(final_chunk_type[_type], _ns, _current_too, 1)
+ TOKEN_CB_CALL( _type ## _FINAL_CHUNK_TYPE , _ns, _current_too, 1)
/*
* Parser itself