mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-11-12 13:00:08 +00:00
Avoid using reserved identifiers in the SUPL library (clang-tidy check: bugprone-reserved-identifier)
This commit is contained in:
parent
abd1032ca2
commit
0cb64e86a5
@ -63,7 +63,7 @@ int BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *_bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101",
|
static char *bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101",
|
||||||
"0110", "0111", "1000", "1001", "1010", "1011",
|
"0110", "0111", "1000", "1001", "1010", "1011",
|
||||||
"1100", "1101", "1110", "1111"};
|
"1100", "1101", "1110", "1111"};
|
||||||
|
|
||||||
@ -107,8 +107,8 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
_i_ASN_TEXT_INDENT(1, ilevel);
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(p + 0, _bit_pattern[v >> 4], 4);
|
memcpy(p + 0, bit_pattern[v >> 4], 4);
|
||||||
memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
|
memcpy(p + 4, bit_pattern[v & 0x0f], 4);
|
||||||
p += 8;
|
p += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = {
|
|||||||
* necessity to demonstrate that acquired skill everywhere afterwards.
|
* necessity to demonstrate that acquired skill everywhere afterwards.
|
||||||
* No, I am not going to explain what the following stuff is.
|
* No, I am not going to explain what the following stuff is.
|
||||||
*/
|
*/
|
||||||
struct _stack_el
|
struct stack_el
|
||||||
{
|
{
|
||||||
ber_tlv_len_t left; /* What's left to read (or -1) */
|
ber_tlv_len_t left; /* What's left to read (or -1) */
|
||||||
ber_tlv_len_t got; /* What was actually processed */
|
ber_tlv_len_t got; /* What was actually processed */
|
||||||
@ -129,18 +129,18 @@ struct _stack_el
|
|||||||
int want_nulls; /* Want null "end of content" octets? */
|
int want_nulls; /* Want null "end of content" octets? */
|
||||||
int bits_chopped; /* Flag in BIT STRING mode */
|
int bits_chopped; /* Flag in BIT STRING mode */
|
||||||
ber_tlv_tag_t tag; /* For debugging purposes */
|
ber_tlv_tag_t tag; /* For debugging purposes */
|
||||||
struct _stack_el *prev;
|
struct stack_el *prev;
|
||||||
struct _stack_el *next;
|
struct stack_el *next;
|
||||||
};
|
};
|
||||||
struct _stack
|
struct stack
|
||||||
{
|
{
|
||||||
struct _stack_el *tail;
|
struct stack_el *tail;
|
||||||
struct _stack_el *cur_ptr;
|
struct stack_el *cur_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct _stack_el *OS__add_stack_el(struct _stack *st)
|
static struct stack_el *OS__add_stack_el(struct stack *st)
|
||||||
{
|
{
|
||||||
struct _stack_el *nel;
|
struct stack_el *nel;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reuse the old stack frame or allocate a new one.
|
* Reuse the old stack frame or allocate a new one.
|
||||||
@ -154,7 +154,7 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el));
|
nel = (struct stack_el *)CALLOC(1, sizeof(struct stack_el));
|
||||||
if (nel == NULL)
|
if (nel == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -175,9 +175,9 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st)
|
|||||||
return nel;
|
return nel;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct _stack *_new_stack()
|
static struct stack *new_stack()
|
||||||
{
|
{
|
||||||
return (struct _stack *)CALLOC(1, sizeof(struct _stack));
|
return (struct stack *)CALLOC(1, sizeof(struct stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -195,8 +195,8 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
asn_dec_rval_t rval;
|
asn_dec_rval_t rval;
|
||||||
asn_struct_ctx_t *ctx;
|
asn_struct_ctx_t *ctx;
|
||||||
ssize_t consumed_myself = 0;
|
ssize_t consumed_myself = 0;
|
||||||
struct _stack *stck; /* Expectations stack structure */
|
struct stack *stck; /* Expectations stack structure */
|
||||||
struct _stack_el *sel = 0; /* Stack element */
|
struct stack_el *sel = 0; /* Stack element */
|
||||||
int tlv_constr;
|
int tlv_constr;
|
||||||
enum asn_OS_Subvariant type_variant = specs->subvariant;
|
enum asn_OS_Subvariant type_variant = specs->subvariant;
|
||||||
|
|
||||||
@ -238,10 +238,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/*
|
/*
|
||||||
* Complex operation, requires stack of expectations.
|
* Complex operation, requires stack of expectations.
|
||||||
*/
|
*/
|
||||||
ctx->ptr = _new_stack();
|
ctx->ptr = new_stack();
|
||||||
if (ctx->ptr)
|
if (ctx->ptr)
|
||||||
{
|
{
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -269,7 +269,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/*
|
/*
|
||||||
* Fill the stack with expectations.
|
* Fill the stack with expectations.
|
||||||
*/
|
*/
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
sel = stck->cur_ptr;
|
sel = stck->cur_ptr;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -292,7 +292,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
if (sel->prev)
|
if (sel->prev)
|
||||||
{
|
{
|
||||||
struct _stack_el *prev = sel->prev;
|
struct stack_el *prev = sel->prev;
|
||||||
if (prev->left != -1)
|
if (prev->left != -1)
|
||||||
{
|
{
|
||||||
if (prev->left < sel->got)
|
if (prev->left < sel->got)
|
||||||
@ -500,7 +500,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
NEXT_PHASE(ctx);
|
NEXT_PHASE(ctx);
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case 2:
|
case 2:
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
sel = stck->cur_ptr;
|
sel = stck->cur_ptr;
|
||||||
ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d",
|
ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d",
|
||||||
(long)sel->left, (long)size, (long)sel->got,
|
(long)sel->left, (long)size, (long)sel->got,
|
||||||
@ -2207,7 +2207,7 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
|
|||||||
: &asn_DEF_OCTET_STRING_specs;
|
: &asn_DEF_OCTET_STRING_specs;
|
||||||
asn_struct_ctx_t *ctx =
|
asn_struct_ctx_t *ctx =
|
||||||
(asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
(asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
||||||
struct _stack *stck;
|
struct stack *stck;
|
||||||
|
|
||||||
if (!td || !st)
|
if (!td || !st)
|
||||||
{
|
{
|
||||||
@ -2225,12 +2225,12 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
|
|||||||
/*
|
/*
|
||||||
* Remove decode-time stack.
|
* Remove decode-time stack.
|
||||||
*/
|
*/
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
if (stck)
|
if (stck)
|
||||||
{
|
{
|
||||||
while (stck->tail)
|
while (stck->tail)
|
||||||
{
|
{
|
||||||
struct _stack_el *sel = stck->tail;
|
struct stack_el *sel = stck->tail;
|
||||||
stck->tail = sel->prev;
|
stck->tail = sel->prev;
|
||||||
FREEMEM(sel);
|
FREEMEM(sel);
|
||||||
}
|
}
|
||||||
|
@ -70,14 +70,14 @@
|
|||||||
/*
|
/*
|
||||||
* See the definitions.
|
* See the definitions.
|
||||||
*/
|
*/
|
||||||
static int _fetch_present_idx(const void *struct_ptr, int pres_offset,
|
static int fetch_present_idx(const void *struct_ptr, int pres_offset,
|
||||||
int size);
|
int size);
|
||||||
static void _set_present_idx(void *struct_ptr, int offset, int size, int pres);
|
static void set_present_idx(void *struct_ptr, int offset, int size, int pres);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tags are canonically sorted in the tag to member table.
|
* Tags are canonically sorted in the tag to member table.
|
||||||
*/
|
*/
|
||||||
static int _search4tag(const void *ap, const void *bp)
|
static int search4tag(const void *ap, const void *bp)
|
||||||
{
|
{
|
||||||
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
||||||
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
||||||
@ -224,7 +224,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
key.el_tag = tlv_tag;
|
key.el_tag = tlv_tag;
|
||||||
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
||||||
&key, specs->tag2el, specs->tag2el_count,
|
&key, specs->tag2el, specs->tag2el_count,
|
||||||
sizeof(specs->tag2el[0]), _search4tag);
|
sizeof(specs->tag2el[0]), search4tag);
|
||||||
if (t2m)
|
if (t2m)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -308,7 +308,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
/* Set presence to be able to free it properly at any
|
/* Set presence to be able to free it properly at any
|
||||||
* time */
|
* time */
|
||||||
_set_present_idx(st, specs->pres_offset,
|
set_present_idx(st, specs->pres_offset,
|
||||||
specs->pres_size, ctx->step + 1);
|
specs->pres_size, ctx->step + 1);
|
||||||
/*
|
/*
|
||||||
* Invoke the member fetch routine according to member's
|
* Invoke the member fetch routine according to member's
|
||||||
@ -448,7 +448,7 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
|
|
||||||
ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name);
|
ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name);
|
||||||
|
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the structure was not initialized, it cannot be encoded:
|
* If the structure was not initialized, it cannot be encoded:
|
||||||
@ -550,7 +550,7 @@ ber_tlv_tag_t CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
if (present > 0 || present <= td->elements_count)
|
if (present > 0 || present <= td->elements_count)
|
||||||
{
|
{
|
||||||
@ -593,7 +593,7 @@ int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
if (present > 0 && present <= td->elements_count)
|
if (present > 0 && present <= td->elements_count)
|
||||||
{
|
{
|
||||||
asn_TYPE_member_t *elm = &td->elements[present - 1];
|
asn_TYPE_member_t *elm = &td->elements[present - 1];
|
||||||
@ -758,7 +758,7 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
assert(_fetch_present_idx(st, specs->pres_offset,
|
assert(_fetch_present_idx(st, specs->pres_offset,
|
||||||
specs->pres_size) == 0);
|
specs->pres_size) == 0);
|
||||||
/* Record what we've got */
|
/* Record what we've got */
|
||||||
_set_present_idx(st, specs->pres_offset, specs->pres_size,
|
set_present_idx(st, specs->pres_offset, specs->pres_size,
|
||||||
edx + 1);
|
edx + 1);
|
||||||
ctx->phase = 3;
|
ctx->phase = 3;
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
@ -942,7 +942,7 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
if (present <= 0 || present > td->elements_count)
|
if (present <= 0 || present > td->elements_count)
|
||||||
{
|
{
|
||||||
@ -1095,7 +1095,7 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set presence to be able to free it later */
|
/* Set presence to be able to free it later */
|
||||||
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
|
set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
|
||||||
|
|
||||||
elm = &td->elements[value];
|
elm = &td->elements[value];
|
||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
@ -1159,7 +1159,7 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
ct = 0;
|
ct = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the structure was not initialized properly, it cannot be encoded:
|
* If the structure was not initialized properly, it cannot be encoded:
|
||||||
@ -1268,7 +1268,7 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print that element.
|
* Print that element.
|
||||||
@ -1327,7 +1327,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free that element.
|
* Free that element.
|
||||||
@ -1367,7 +1367,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
|||||||
* is guaranteed to be aligned properly. ASN.1 compiler itself does not
|
* is guaranteed to be aligned properly. ASN.1 compiler itself does not
|
||||||
* produce packed code.
|
* produce packed code.
|
||||||
*/
|
*/
|
||||||
static int _fetch_present_idx(const void *struct_ptr, int pres_offset,
|
static int fetch_present_idx(const void *struct_ptr, int pres_offset,
|
||||||
int pres_size)
|
int pres_size)
|
||||||
{
|
{
|
||||||
const void *present_ptr;
|
const void *present_ptr;
|
||||||
@ -1395,7 +1395,7 @@ static int _fetch_present_idx(const void *struct_ptr, int pres_offset,
|
|||||||
return present;
|
return present;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _set_present_idx(void *struct_ptr, int pres_offset, int pres_size,
|
static void set_present_idx(void *struct_ptr, int pres_offset, int pres_size,
|
||||||
int present)
|
int present)
|
||||||
{
|
{
|
||||||
void *present_ptr;
|
void *present_ptr;
|
||||||
|
@ -83,7 +83,7 @@
|
|||||||
/*
|
/*
|
||||||
* Tags are canonically sorted in the tag2element map.
|
* Tags are canonically sorted in the tag2element map.
|
||||||
*/
|
*/
|
||||||
static int _t2e_cmp(const void *ap, const void *bp)
|
static int t2e_cmp(const void *ap, const void *bp)
|
||||||
{
|
{
|
||||||
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
||||||
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
||||||
@ -375,7 +375,7 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
key.el_no = edx;
|
key.el_no = edx;
|
||||||
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
||||||
&key, specs->tag2el, specs->tag2el_count,
|
&key, 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;
|
asn_TYPE_tag2member_t *best = 0;
|
||||||
|
@ -331,16 +331,16 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/*
|
/*
|
||||||
* Internally visible buffer holding a single encoded element.
|
* Internally visible buffer holding a single encoded element.
|
||||||
*/
|
*/
|
||||||
struct _el_buffer
|
struct el_buffer
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
size_t length;
|
size_t length;
|
||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
/* Append bytes to the above structure */
|
/* Append bytes to the above structure */
|
||||||
static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr)
|
static int el_addbytes(const void *buffer, size_t size, void *el_buf_ptr)
|
||||||
{
|
{
|
||||||
struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr;
|
struct el_buffer *el_buf = (struct el_buffer *)el_buf_ptr;
|
||||||
|
|
||||||
if (el_buf->length + size > el_buf->size)
|
if (el_buf->length + size > el_buf->size)
|
||||||
{
|
{
|
||||||
@ -352,10 +352,10 @@ static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr)
|
|||||||
el_buf->length += size;
|
el_buf->length += size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int _el_buf_cmp(const void *ap, const void *bp)
|
static int el_buf_cmp(const void *ap, const void *bp)
|
||||||
{
|
{
|
||||||
const struct _el_buffer *a = (const struct _el_buffer *)ap;
|
const struct el_buffer *a = (const struct el_buffer *)ap;
|
||||||
const struct _el_buffer *b = (const struct _el_buffer *)bp;
|
const struct el_buffer *b = (const struct el_buffer *)bp;
|
||||||
int ret;
|
int ret;
|
||||||
size_t common_len;
|
size_t common_len;
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
|
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
|
||||||
size_t computed_size = 0;
|
size_t computed_size = 0;
|
||||||
ssize_t encoding_size = 0;
|
ssize_t encoding_size = 0;
|
||||||
struct _el_buffer *encoded_els;
|
struct el_buffer *encoded_els;
|
||||||
ssize_t eels_count = 0;
|
ssize_t eels_count = 0;
|
||||||
size_t max_encoded_len = 1;
|
size_t max_encoded_len = 1;
|
||||||
asn_enc_rval_t erval;
|
asn_enc_rval_t erval;
|
||||||
@ -456,7 +456,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
* encoded elements.
|
* encoded elements.
|
||||||
*/
|
*/
|
||||||
encoded_els =
|
encoded_els =
|
||||||
(struct _el_buffer *)MALLOC(list->count * sizeof(encoded_els[0]));
|
(struct el_buffer *)MALLOC(list->count * sizeof(encoded_els[0]));
|
||||||
if (encoded_els == NULL)
|
if (encoded_els == NULL)
|
||||||
{
|
{
|
||||||
erval.encoded = -1;
|
erval.encoded = -1;
|
||||||
@ -473,7 +473,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
for (edx = 0; edx < list->count; edx++)
|
for (edx = 0; edx < list->count; edx++)
|
||||||
{
|
{
|
||||||
void *memb_ptr = list->array[edx];
|
void *memb_ptr = list->array[edx];
|
||||||
struct _el_buffer *encoded_el = &encoded_els[eels_count];
|
struct el_buffer *encoded_el = &encoded_els[eels_count];
|
||||||
|
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
{
|
{
|
||||||
@ -505,7 +505,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
/*
|
/*
|
||||||
* Encode the member into the prepared space.
|
* Encode the member into the prepared space.
|
||||||
*/
|
*/
|
||||||
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, _el_addbytes,
|
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, el_addbytes,
|
||||||
encoded_el);
|
encoded_el);
|
||||||
if (erval.encoded == -1)
|
if (erval.encoded == -1)
|
||||||
{
|
{
|
||||||
@ -523,7 +523,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
/*
|
/*
|
||||||
* Sort the encoded elements according to their encoding.
|
* Sort the encoded elements according to their encoding.
|
||||||
*/
|
*/
|
||||||
qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp);
|
qsort(encoded_els, eels_count, sizeof(encoded_els[0]), el_buf_cmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report encoded elements to the application.
|
* Report encoded elements to the application.
|
||||||
@ -532,7 +532,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
for (edx = 0; edx < eels_count; edx++)
|
for (edx = 0; edx < eels_count; edx++)
|
||||||
{
|
{
|
||||||
struct _el_buffer *encoded_el = &encoded_els[edx];
|
struct el_buffer *encoded_el = &encoded_els[edx];
|
||||||
/* Report encoded chunks to the application */
|
/* Report encoded chunks to the application */
|
||||||
if (ret == 0 &&
|
if (ret == 0 &&
|
||||||
cb(encoded_el->buf, encoded_el->length, app_key) < 0)
|
cb(encoded_el->buf, encoded_el->length, app_key) < 0)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
|
int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
|
||||||
|
|
||||||
static asn_app_consume_bytes_f _print2fp;
|
static asn_app_consume_bytes_f print2fp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the outmost tag of the type.
|
* Return the outmost tag of the type.
|
||||||
@ -49,13 +49,13 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke type-specific printer */
|
/* Invoke type-specific printer */
|
||||||
if (td->print_struct(td, struct_ptr, 1, _print2fp, stream))
|
if (td->print_struct(td, struct_ptr, 1, print2fp, stream))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the output */
|
/* Terminate the output */
|
||||||
if (_print2fp("\n", 1, stream))
|
if (print2fp("\n", 1, stream))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Dump the data into the specified stdio stream */
|
/* Dump the data into the specified stdio stream */
|
||||||
static int _print2fp(const void *buffer, size_t size, void *app_key)
|
static int print2fp(const void *buffer, size_t size, void *app_key)
|
||||||
{
|
{
|
||||||
FILE *stream = (FILE *)app_key;
|
FILE *stream = (FILE *)app_key;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ struct errbufDesc
|
|||||||
size_t errlen;
|
size_t errlen;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td,
|
static void asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td,
|
||||||
const void *sptr, const char *fmt, ...)
|
const void *sptr, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct errbufDesc *arg = key;
|
struct errbufDesc *arg = key;
|
||||||
@ -98,7 +98,7 @@ int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor,
|
|||||||
arg.errlen = errlen ? *errlen : 0;
|
arg.errlen = errlen ? *errlen : 0;
|
||||||
|
|
||||||
ret = type_descriptor->check_constraints(type_descriptor, struct_ptr,
|
ret = type_descriptor->check_constraints(type_descriptor, struct_ptr,
|
||||||
_asn_i_ctfailcb, &arg);
|
asn_i_ctfailcb, &arg);
|
||||||
if (ret == -1 && errlen)
|
if (ret == -1 && errlen)
|
||||||
{
|
{
|
||||||
*errlen = arg.errlen;
|
*errlen = arg.errlen;
|
||||||
|
@ -123,7 +123,7 @@ ssize_t uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Flush partially filled buffer */
|
/* Flush partially filled buffer */
|
||||||
static int _uper_encode_flush_outp(asn_per_outp_t *po)
|
static int uper_encode_flush_outp(asn_per_outp_t *po)
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td,
|
|||||||
/* Set number of bits encoded to a firm value */
|
/* Set number of bits encoded to a firm value */
|
||||||
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
|
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
|
||||||
|
|
||||||
if (_uper_encode_flush_outp(&po))
|
if (uper_encode_flush_outp(&po))
|
||||||
{
|
{
|
||||||
_ASN_ENCODE_FAILED;
|
_ASN_ENCODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ int BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *_bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101",
|
static char *bit_pattern[16] = {"0000", "0001", "0010", "0011", "0100", "0101",
|
||||||
"0110", "0111", "1000", "1001", "1010", "1011",
|
"0110", "0111", "1000", "1001", "1010", "1011",
|
||||||
"1100", "1101", "1110", "1111"};
|
"1100", "1101", "1110", "1111"};
|
||||||
|
|
||||||
@ -107,8 +107,8 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
_i_ASN_TEXT_INDENT(1, ilevel);
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(p + 0, _bit_pattern[v >> 4], 4);
|
memcpy(p + 0, bit_pattern[v >> 4], 4);
|
||||||
memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
|
memcpy(p + 4, bit_pattern[v & 0x0f], 4);
|
||||||
p += 8;
|
p += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* SPDX-FileCopyrightText: (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
* SPDX-FileCopyrightText: (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||||
* SPDX-License-Identifier: BSD-1-Clause
|
* SPDX-License-Identifier: BSD-1-Clause
|
||||||
*/
|
*/
|
||||||
#define _POSIX_PTHREAD_SEMANTICS /* for Sun */
|
#define POSIX_PTHREAD_SEMANTICS /* for Sun */
|
||||||
#ifndef _REENTRANT
|
#ifndef _REENTRANT
|
||||||
#define _REENTRANT /* for Sun */
|
#define REENTRANT /* for Sun */
|
||||||
#endif
|
#endif
|
||||||
#include <GeneralizedTime.h>
|
#include <GeneralizedTime.h>
|
||||||
#include <asn_internal.h>
|
#include <asn_internal.h>
|
||||||
|
@ -121,7 +121,7 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = {
|
|||||||
* necessity to demonstrate that acquired skill everywhere afterwards.
|
* necessity to demonstrate that acquired skill everywhere afterwards.
|
||||||
* No, I am not going to explain what the following stuff is.
|
* No, I am not going to explain what the following stuff is.
|
||||||
*/
|
*/
|
||||||
struct _stack_el
|
struct stack_el
|
||||||
{
|
{
|
||||||
ber_tlv_len_t left; /* What's left to read (or -1) */
|
ber_tlv_len_t left; /* What's left to read (or -1) */
|
||||||
ber_tlv_len_t got; /* What was actually processed */
|
ber_tlv_len_t got; /* What was actually processed */
|
||||||
@ -129,18 +129,18 @@ struct _stack_el
|
|||||||
int want_nulls; /* Want null "end of content" octets? */
|
int want_nulls; /* Want null "end of content" octets? */
|
||||||
int bits_chopped; /* Flag in BIT STRING mode */
|
int bits_chopped; /* Flag in BIT STRING mode */
|
||||||
ber_tlv_tag_t tag; /* For debugging purposes */
|
ber_tlv_tag_t tag; /* For debugging purposes */
|
||||||
struct _stack_el *prev;
|
struct stack_el *prev;
|
||||||
struct _stack_el *next;
|
struct stack_el *next;
|
||||||
};
|
};
|
||||||
struct _stack
|
struct stack
|
||||||
{
|
{
|
||||||
struct _stack_el *tail;
|
struct stack_el *tail;
|
||||||
struct _stack_el *cur_ptr;
|
struct stack_el *cur_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct _stack_el *OS__add_stack_el(struct _stack *st)
|
static struct stack_el *OS__add_stack_el(struct stack *st)
|
||||||
{
|
{
|
||||||
struct _stack_el *nel;
|
struct stack_el *nel;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reuse the old stack frame or allocate a new one.
|
* Reuse the old stack frame or allocate a new one.
|
||||||
@ -154,7 +154,7 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el));
|
nel = (struct stack_el *)CALLOC(1, sizeof(struct stack_el));
|
||||||
if (nel == NULL)
|
if (nel == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -175,9 +175,9 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st)
|
|||||||
return nel;
|
return nel;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct _stack *_new_stack()
|
static struct stack *new_stack()
|
||||||
{
|
{
|
||||||
return (struct _stack *)CALLOC(1, sizeof(struct _stack));
|
return (struct stack *)CALLOC(1, sizeof(struct stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -195,8 +195,8 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
asn_dec_rval_t rval;
|
asn_dec_rval_t rval;
|
||||||
asn_struct_ctx_t *ctx;
|
asn_struct_ctx_t *ctx;
|
||||||
ssize_t consumed_myself = 0;
|
ssize_t consumed_myself = 0;
|
||||||
struct _stack *stck; /* Expectations stack structure */
|
struct stack *stck; /* Expectations stack structure */
|
||||||
struct _stack_el *sel = 0; /* Stack element */
|
struct stack_el *sel = 0; /* Stack element */
|
||||||
int tlv_constr;
|
int tlv_constr;
|
||||||
enum asn_OS_Subvariant type_variant = specs->subvariant;
|
enum asn_OS_Subvariant type_variant = specs->subvariant;
|
||||||
|
|
||||||
@ -238,10 +238,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/*
|
/*
|
||||||
* Complex operation, requires stack of expectations.
|
* Complex operation, requires stack of expectations.
|
||||||
*/
|
*/
|
||||||
ctx->ptr = _new_stack();
|
ctx->ptr = new_stack();
|
||||||
if (ctx->ptr)
|
if (ctx->ptr)
|
||||||
{
|
{
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -269,7 +269,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/*
|
/*
|
||||||
* Fill the stack with expectations.
|
* Fill the stack with expectations.
|
||||||
*/
|
*/
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
sel = stck->cur_ptr;
|
sel = stck->cur_ptr;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -292,7 +292,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
if (sel->prev)
|
if (sel->prev)
|
||||||
{
|
{
|
||||||
struct _stack_el *prev = sel->prev;
|
struct stack_el *prev = sel->prev;
|
||||||
if (prev->left != -1)
|
if (prev->left != -1)
|
||||||
{
|
{
|
||||||
if (prev->left < sel->got)
|
if (prev->left < sel->got)
|
||||||
@ -500,7 +500,7 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
NEXT_PHASE(ctx);
|
NEXT_PHASE(ctx);
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case 2:
|
case 2:
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
sel = stck->cur_ptr;
|
sel = stck->cur_ptr;
|
||||||
ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d",
|
ASN_DEBUG("Phase 2: Need %ld bytes, size=%ld, alrg=%ld, wn=%d",
|
||||||
(long)sel->left, (long)size, (long)sel->got,
|
(long)sel->left, (long)size, (long)sel->got,
|
||||||
@ -2207,7 +2207,7 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
|
|||||||
: &asn_DEF_OCTET_STRING_specs;
|
: &asn_DEF_OCTET_STRING_specs;
|
||||||
asn_struct_ctx_t *ctx =
|
asn_struct_ctx_t *ctx =
|
||||||
(asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
(asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
||||||
struct _stack *stck;
|
struct stack *stck;
|
||||||
|
|
||||||
if (!td || !st)
|
if (!td || !st)
|
||||||
{
|
{
|
||||||
@ -2225,12 +2225,12 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
|
|||||||
/*
|
/*
|
||||||
* Remove decode-time stack.
|
* Remove decode-time stack.
|
||||||
*/
|
*/
|
||||||
stck = (struct _stack *)ctx->ptr;
|
stck = (struct stack *)ctx->ptr;
|
||||||
if (stck)
|
if (stck)
|
||||||
{
|
{
|
||||||
while (stck->tail)
|
while (stck->tail)
|
||||||
{
|
{
|
||||||
struct _stack_el *sel = stck->tail;
|
struct stack_el *sel = stck->tail;
|
||||||
stck->tail = sel->prev;
|
stck->tail = sel->prev;
|
||||||
FREEMEM(sel);
|
FREEMEM(sel);
|
||||||
}
|
}
|
||||||
|
@ -70,14 +70,14 @@
|
|||||||
/*
|
/*
|
||||||
* See the definitions.
|
* See the definitions.
|
||||||
*/
|
*/
|
||||||
static int _fetch_present_idx(const void *struct_ptr, int pres_offset,
|
static int fetch_present_idx(const void *struct_ptr, int pres_offset,
|
||||||
int size);
|
int size);
|
||||||
static void _set_present_idx(void *struct_ptr, int offset, int size, int pres);
|
static void set_present_idx(void *struct_ptr, int offset, int size, int pres);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tags are canonically sorted in the tag to member table.
|
* Tags are canonically sorted in the tag to member table.
|
||||||
*/
|
*/
|
||||||
static int _search4tag(const void *ap, const void *bp)
|
static int search4tag(const void *ap, const void *bp)
|
||||||
{
|
{
|
||||||
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
||||||
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
||||||
@ -224,7 +224,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
key.el_tag = tlv_tag;
|
key.el_tag = tlv_tag;
|
||||||
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
||||||
&key, specs->tag2el, specs->tag2el_count,
|
&key, specs->tag2el, specs->tag2el_count,
|
||||||
sizeof(specs->tag2el[0]), _search4tag);
|
sizeof(specs->tag2el[0]), search4tag);
|
||||||
if (t2m)
|
if (t2m)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -308,7 +308,7 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
/* Set presence to be able to free it properly at any
|
/* Set presence to be able to free it properly at any
|
||||||
* time */
|
* time */
|
||||||
_set_present_idx(st, specs->pres_offset,
|
set_present_idx(st, specs->pres_offset,
|
||||||
specs->pres_size, ctx->step + 1);
|
specs->pres_size, ctx->step + 1);
|
||||||
/*
|
/*
|
||||||
* Invoke the member fetch routine according to member's
|
* Invoke the member fetch routine according to member's
|
||||||
@ -448,7 +448,7 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
|
|
||||||
ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name);
|
ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name);
|
||||||
|
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the structure was not initialized, it cannot be encoded:
|
* If the structure was not initialized, it cannot be encoded:
|
||||||
@ -550,7 +550,7 @@ ber_tlv_tag_t CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
if (present > 0 || present <= td->elements_count)
|
if (present > 0 || present <= td->elements_count)
|
||||||
{
|
{
|
||||||
@ -593,7 +593,7 @@ int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
if (present > 0 && present <= td->elements_count)
|
if (present > 0 && present <= td->elements_count)
|
||||||
{
|
{
|
||||||
asn_TYPE_member_t *elm = &td->elements[present - 1];
|
asn_TYPE_member_t *elm = &td->elements[present - 1];
|
||||||
@ -758,7 +758,7 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
assert(_fetch_present_idx(st, specs->pres_offset,
|
assert(_fetch_present_idx(st, specs->pres_offset,
|
||||||
specs->pres_size) == 0);
|
specs->pres_size) == 0);
|
||||||
/* Record what we've got */
|
/* Record what we've got */
|
||||||
_set_present_idx(st, specs->pres_offset, specs->pres_size,
|
set_present_idx(st, specs->pres_offset, specs->pres_size,
|
||||||
edx + 1);
|
edx + 1);
|
||||||
ctx->phase = 3;
|
ctx->phase = 3;
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
@ -942,7 +942,7 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
if (present <= 0 || present > td->elements_count)
|
if (present <= 0 || present > td->elements_count)
|
||||||
{
|
{
|
||||||
@ -1095,7 +1095,7 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set presence to be able to free it later */
|
/* Set presence to be able to free it later */
|
||||||
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
|
set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
|
||||||
|
|
||||||
elm = &td->elements[value];
|
elm = &td->elements[value];
|
||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
@ -1159,7 +1159,7 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
ct = 0;
|
ct = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the structure was not initialized properly, it cannot be encoded:
|
* If the structure was not initialized properly, it cannot be encoded:
|
||||||
@ -1268,7 +1268,7 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print that element.
|
* Print that element.
|
||||||
@ -1327,7 +1327,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
|||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
*/
|
*/
|
||||||
present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
present = fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free that element.
|
* Free that element.
|
||||||
@ -1367,7 +1367,7 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
|||||||
* is guaranteed to be aligned properly. ASN.1 compiler itself does not
|
* is guaranteed to be aligned properly. ASN.1 compiler itself does not
|
||||||
* produce packed code.
|
* produce packed code.
|
||||||
*/
|
*/
|
||||||
static int _fetch_present_idx(const void *struct_ptr, int pres_offset,
|
static int fetch_present_idx(const void *struct_ptr, int pres_offset,
|
||||||
int pres_size)
|
int pres_size)
|
||||||
{
|
{
|
||||||
const void *present_ptr;
|
const void *present_ptr;
|
||||||
@ -1395,7 +1395,7 @@ static int _fetch_present_idx(const void *struct_ptr, int pres_offset,
|
|||||||
return present;
|
return present;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _set_present_idx(void *struct_ptr, int pres_offset, int pres_size,
|
static void set_present_idx(void *struct_ptr, int pres_offset, int pres_size,
|
||||||
int present)
|
int present)
|
||||||
{
|
{
|
||||||
void *present_ptr;
|
void *present_ptr;
|
||||||
|
@ -83,7 +83,7 @@
|
|||||||
/*
|
/*
|
||||||
* Tags are canonically sorted in the tag2element map.
|
* Tags are canonically sorted in the tag2element map.
|
||||||
*/
|
*/
|
||||||
static int _t2e_cmp(const void *ap, const void *bp)
|
static int t2e_cmp(const void *ap, const void *bp)
|
||||||
{
|
{
|
||||||
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
|
||||||
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
|
||||||
@ -375,7 +375,7 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
key.el_no = edx;
|
key.el_no = edx;
|
||||||
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
t2m = (asn_TYPE_tag2member_t *)bsearch(
|
||||||
&key, specs->tag2el, specs->tag2el_count,
|
&key, 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;
|
asn_TYPE_tag2member_t *best = 0;
|
||||||
|
@ -331,16 +331,16 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/*
|
/*
|
||||||
* Internally visible buffer holding a single encoded element.
|
* Internally visible buffer holding a single encoded element.
|
||||||
*/
|
*/
|
||||||
struct _el_buffer
|
struct el_buffer
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
size_t length;
|
size_t length;
|
||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
/* Append bytes to the above structure */
|
/* Append bytes to the above structure */
|
||||||
static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr)
|
static int el_addbytes(const void *buffer, size_t size, void *el_buf_ptr)
|
||||||
{
|
{
|
||||||
struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr;
|
struct el_buffer *el_buf = (struct el_buffer *)el_buf_ptr;
|
||||||
|
|
||||||
if (el_buf->length + size > el_buf->size)
|
if (el_buf->length + size > el_buf->size)
|
||||||
{
|
{
|
||||||
@ -352,10 +352,10 @@ static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr)
|
|||||||
el_buf->length += size;
|
el_buf->length += size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int _el_buf_cmp(const void *ap, const void *bp)
|
static int el_buf_cmp(const void *ap, const void *bp)
|
||||||
{
|
{
|
||||||
const struct _el_buffer *a = (const struct _el_buffer *)ap;
|
const struct el_buffer *a = (const struct el_buffer *)ap;
|
||||||
const struct _el_buffer *b = (const struct _el_buffer *)bp;
|
const struct el_buffer *b = (const struct el_buffer *)bp;
|
||||||
int ret;
|
int ret;
|
||||||
size_t common_len;
|
size_t common_len;
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
|
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
|
||||||
size_t computed_size = 0;
|
size_t computed_size = 0;
|
||||||
ssize_t encoding_size = 0;
|
ssize_t encoding_size = 0;
|
||||||
struct _el_buffer *encoded_els;
|
struct el_buffer *encoded_els;
|
||||||
ssize_t eels_count = 0;
|
ssize_t eels_count = 0;
|
||||||
size_t max_encoded_len = 1;
|
size_t max_encoded_len = 1;
|
||||||
asn_enc_rval_t erval;
|
asn_enc_rval_t erval;
|
||||||
@ -456,7 +456,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
* encoded elements.
|
* encoded elements.
|
||||||
*/
|
*/
|
||||||
encoded_els =
|
encoded_els =
|
||||||
(struct _el_buffer *)MALLOC(list->count * sizeof(encoded_els[0]));
|
(struct el_buffer *)MALLOC(list->count * sizeof(encoded_els[0]));
|
||||||
if (encoded_els == NULL)
|
if (encoded_els == NULL)
|
||||||
{
|
{
|
||||||
erval.encoded = -1;
|
erval.encoded = -1;
|
||||||
@ -473,7 +473,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
for (edx = 0; edx < list->count; edx++)
|
for (edx = 0; edx < list->count; edx++)
|
||||||
{
|
{
|
||||||
void *memb_ptr = list->array[edx];
|
void *memb_ptr = list->array[edx];
|
||||||
struct _el_buffer *encoded_el = &encoded_els[eels_count];
|
struct el_buffer *encoded_el = &encoded_els[eels_count];
|
||||||
|
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
{
|
{
|
||||||
@ -505,7 +505,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
/*
|
/*
|
||||||
* Encode the member into the prepared space.
|
* Encode the member into the prepared space.
|
||||||
*/
|
*/
|
||||||
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, _el_addbytes,
|
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, el_addbytes,
|
||||||
encoded_el);
|
encoded_el);
|
||||||
if (erval.encoded == -1)
|
if (erval.encoded == -1)
|
||||||
{
|
{
|
||||||
@ -523,7 +523,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
/*
|
/*
|
||||||
* Sort the encoded elements according to their encoding.
|
* Sort the encoded elements according to their encoding.
|
||||||
*/
|
*/
|
||||||
qsort(encoded_els, eels_count, sizeof(encoded_els[0]), _el_buf_cmp);
|
qsort(encoded_els, eels_count, sizeof(encoded_els[0]), el_buf_cmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report encoded elements to the application.
|
* Report encoded elements to the application.
|
||||||
@ -532,7 +532,7 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
for (edx = 0; edx < eels_count; edx++)
|
for (edx = 0; edx < eels_count; edx++)
|
||||||
{
|
{
|
||||||
struct _el_buffer *encoded_el = &encoded_els[edx];
|
struct el_buffer *encoded_el = &encoded_els[edx];
|
||||||
/* Report encoded chunks to the application */
|
/* Report encoded chunks to the application */
|
||||||
if (ret == 0 &&
|
if (ret == 0 &&
|
||||||
cb(encoded_el->buf, encoded_el->length, app_key) < 0)
|
cb(encoded_el->buf, encoded_el->length, app_key) < 0)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
|
int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }
|
||||||
|
|
||||||
static asn_app_consume_bytes_f _print2fp;
|
static asn_app_consume_bytes_f print2fp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the outmost tag of the type.
|
* Return the outmost tag of the type.
|
||||||
@ -49,13 +49,13 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke type-specific printer */
|
/* Invoke type-specific printer */
|
||||||
if (td->print_struct(td, struct_ptr, 1, _print2fp, stream))
|
if (td->print_struct(td, struct_ptr, 1, print2fp, stream))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the output */
|
/* Terminate the output */
|
||||||
if (_print2fp("\n", 1, stream))
|
if (print2fp("\n", 1, stream))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Dump the data into the specified stdio stream */
|
/* Dump the data into the specified stdio stream */
|
||||||
static int _print2fp(const void *buffer, size_t size, void *app_key)
|
static int print2fp(const void *buffer, size_t size, void *app_key)
|
||||||
{
|
{
|
||||||
FILE *stream = (FILE *)app_key;
|
FILE *stream = (FILE *)app_key;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ struct errbufDesc
|
|||||||
size_t errlen;
|
size_t errlen;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td,
|
static void asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td,
|
||||||
const void *sptr, const char *fmt, ...)
|
const void *sptr, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct errbufDesc *arg = key;
|
struct errbufDesc *arg = key;
|
||||||
@ -98,7 +98,7 @@ int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor,
|
|||||||
arg.errlen = errlen ? *errlen : 0;
|
arg.errlen = errlen ? *errlen : 0;
|
||||||
|
|
||||||
ret = type_descriptor->check_constraints(type_descriptor, struct_ptr,
|
ret = type_descriptor->check_constraints(type_descriptor, struct_ptr,
|
||||||
_asn_i_ctfailcb, &arg);
|
asn_i_ctfailcb, &arg);
|
||||||
if (ret == -1 && errlen)
|
if (ret == -1 && errlen)
|
||||||
{
|
{
|
||||||
*errlen = arg.errlen;
|
*errlen = arg.errlen;
|
||||||
|
@ -123,7 +123,7 @@ ssize_t uper_encode_to_new_buffer(asn_TYPE_descriptor_t *td,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Flush partially filled buffer */
|
/* Flush partially filled buffer */
|
||||||
static int _uper_encode_flush_outp(asn_per_outp_t *po)
|
static int uper_encode_flush_outp(asn_per_outp_t *po)
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td,
|
|||||||
/* Set number of bits encoded to a firm value */
|
/* Set number of bits encoded to a firm value */
|
||||||
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
|
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
|
||||||
|
|
||||||
if (_uper_encode_flush_outp(&po))
|
if (uper_encode_flush_outp(&po))
|
||||||
{
|
{
|
||||||
_ASN_ENCODE_FAILED;
|
_ASN_ENCODE_FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user