mirror of https://gerrit.osmocom.org/asn1c
Merge pull request #46 from wiml/constify
Move as much data as possible into non-writable text by declaring it const
This commit is contained in:
commit
78d604fe9e
|
@ -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); \
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
/*
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
/*
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue