mirror of https://gerrit.osmocom.org/asn1c
presence unsigned
This commit is contained in:
parent
6aae7c62c1
commit
63a35237b1
|
@ -67,7 +67,7 @@ static signed _fetch_present_idx(const void *struct_ptr, int off, int size);
|
||||||
static void _set_present_idx(void *sptr, int offset, int size, int pres);
|
static void _set_present_idx(void *sptr, int offset, int size, int pres);
|
||||||
static const void *_get_member_ptr(const asn_TYPE_descriptor_t *,
|
static const void *_get_member_ptr(const asn_TYPE_descriptor_t *,
|
||||||
const void *sptr, asn_TYPE_member_t **elm,
|
const void *sptr, asn_TYPE_member_t **elm,
|
||||||
signed *present);
|
unsigned *present);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tags are canonically sorted in the tag to member table.
|
* Tags are canonically sorted in the tag to member table.
|
||||||
|
@ -365,7 +365,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||||
asn_enc_rval_t erval;
|
asn_enc_rval_t erval;
|
||||||
void *memb_ptr;
|
void *memb_ptr;
|
||||||
size_t computed_size = 0;
|
size_t computed_size = 0;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
if(!sptr) ASN__ENCODE_FAILED;
|
if(!sptr) ASN__ENCODE_FAILED;
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||||
* If the structure was not initialized, it cannot be encoded:
|
* If the structure was not initialized, it cannot be encoded:
|
||||||
* can't deduce what to encode in the choice type.
|
* can't deduce what to encode in the choice type.
|
||||||
*/
|
*/
|
||||||
if(present <= 0 || (unsigned)present > td->elements_count) {
|
if(present == 0 || present > td->elements_count) {
|
||||||
if(present == 0 && td->elements_count == 0) {
|
if(present == 0 && td->elements_count == 0) {
|
||||||
/* The CHOICE is empty?! */
|
/* The CHOICE is empty?! */
|
||||||
erval.encoded = 0;
|
erval.encoded = 0;
|
||||||
|
@ -450,7 +450,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||||
ber_tlv_tag_t
|
ber_tlv_tag_t
|
||||||
CHOICE_outmost_tag(const 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;
|
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
assert(tag_mode == 0); (void)tag_mode;
|
assert(tag_mode == 0); (void)tag_mode;
|
||||||
assert(tag == 0); (void)tag;
|
assert(tag == 0); (void)tag;
|
||||||
|
@ -460,7 +460,7 @@ CHOICE_outmost_tag(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mod
|
||||||
*/
|
*/
|
||||||
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 && (unsigned)present <= td->elements_count) {
|
if(present > 0 && present <= td->elements_count) {
|
||||||
const asn_TYPE_member_t *elm = &td->elements[present-1];
|
const asn_TYPE_member_t *elm = &td->elements[present-1];
|
||||||
const void *memb_ptr;
|
const void *memb_ptr;
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ int
|
||||||
CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||||
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
if(!sptr) {
|
if(!sptr) {
|
||||||
ASN__CTFAIL(app_key, td, sptr,
|
ASN__CTFAIL(app_key, td, sptr,
|
||||||
|
@ -496,7 +496,7 @@ 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 && (unsigned)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];
|
||||||
const void *memb_ptr;
|
const void *memb_ptr;
|
||||||
|
|
||||||
|
@ -780,7 +780,7 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||||
asn_CHOICE_specifics_t *specs=(asn_CHOICE_specifics_t *)td->specifics;
|
asn_CHOICE_specifics_t *specs=(asn_CHOICE_specifics_t *)td->specifics;
|
||||||
asn_enc_rval_t er;
|
asn_enc_rval_t er;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
if(!sptr)
|
if(!sptr)
|
||||||
ASN__ENCODE_FAILED;
|
ASN__ENCODE_FAILED;
|
||||||
|
@ -790,7 +790,7 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||||
*/
|
*/
|
||||||
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 || (unsigned)present > td->elements_count) {
|
if(present == 0 || present > td->elements_count) {
|
||||||
ASN__ENCODE_FAILED;
|
ASN__ENCODE_FAILED;
|
||||||
} else {
|
} else {
|
||||||
asn_enc_rval_t tmper;
|
asn_enc_rval_t tmper;
|
||||||
|
@ -917,7 +917,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||||
asn_TYPE_member_t *elm; /* CHOICE's element */
|
asn_TYPE_member_t *elm; /* CHOICE's element */
|
||||||
const asn_per_constraint_t *ct;
|
const asn_per_constraint_t *ct;
|
||||||
void *memb_ptr;
|
void *memb_ptr;
|
||||||
signed present;
|
unsigned present;
|
||||||
int present_enc;
|
int present_enc;
|
||||||
|
|
||||||
if(!sptr) ASN__ENCODE_FAILED;
|
if(!sptr) ASN__ENCODE_FAILED;
|
||||||
|
@ -928,14 +928,13 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||||
else if(td->per_constraints) ct = &td->per_constraints->value;
|
else if(td->per_constraints) ct = &td->per_constraints->value;
|
||||||
else ct = 0;
|
else ct = 0;
|
||||||
|
|
||||||
present = _fetch_present_idx(sptr,
|
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
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:
|
||||||
* can't deduce what to encode in the choice type.
|
* can't deduce what to encode in the choice type.
|
||||||
*/
|
*/
|
||||||
if(present <= 0 || (unsigned)present > td->elements_count)
|
if(present == 0 || present > td->elements_count)
|
||||||
ASN__ENCODE_FAILED;
|
ASN__ENCODE_FAILED;
|
||||||
else
|
else
|
||||||
present--;
|
present--;
|
||||||
|
@ -998,7 +997,7 @@ int
|
||||||
CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||||
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||||
|
|
||||||
|
@ -1010,7 +1009,7 @@ CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||||
/*
|
/*
|
||||||
* Print that element.
|
* Print that element.
|
||||||
*/
|
*/
|
||||||
if(present > 0 && (unsigned)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];
|
||||||
const void *memb_ptr;
|
const void *memb_ptr;
|
||||||
|
|
||||||
|
@ -1038,7 +1037,7 @@ CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||||
void
|
void
|
||||||
CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||||
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
if(!td || !ptr)
|
if(!td || !ptr)
|
||||||
return;
|
return;
|
||||||
|
@ -1053,7 +1052,7 @@ CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||||
/*
|
/*
|
||||||
* Free that element.
|
* Free that element.
|
||||||
*/
|
*/
|
||||||
if(present > 0 && (unsigned)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];
|
||||||
void *memb_ptr;
|
void *memb_ptr;
|
||||||
|
|
||||||
|
@ -1085,7 +1084,7 @@ CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||||
static signed
|
static signed
|
||||||
_fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) {
|
_fetch_present_idx(const void *struct_ptr, int pres_offset, int pres_size) {
|
||||||
const void *present_ptr;
|
const void *present_ptr;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
present_ptr = ((const char *)struct_ptr) + pres_offset;
|
present_ptr = ((const char *)struct_ptr) + pres_offset;
|
||||||
|
|
||||||
|
@ -1119,9 +1118,9 @@ _set_present_idx(void *struct_ptr, int pres_offset, int pres_size, int present)
|
||||||
|
|
||||||
static const void *
|
static const void *
|
||||||
_get_member_ptr(const asn_TYPE_descriptor_t *td, const void *sptr,
|
_get_member_ptr(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||||
asn_TYPE_member_t **elm_ptr, signed *present_out) {
|
asn_TYPE_member_t **elm_ptr, unsigned *present_out) {
|
||||||
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||||
signed present;
|
unsigned present;
|
||||||
|
|
||||||
if(!sptr) {
|
if(!sptr) {
|
||||||
*elm_ptr = NULL;
|
*elm_ptr = NULL;
|
||||||
|
@ -1139,7 +1138,7 @@ _get_member_ptr(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||||
* The presence index is intentionally 1-based to avoid
|
* The presence index is intentionally 1-based to avoid
|
||||||
* treating zeroed structure as a valid one.
|
* treating zeroed structure as a valid one.
|
||||||
*/
|
*/
|
||||||
if(present > 0 && (unsigned)present <= td->elements_count) {
|
if(present > 0 && present <= td->elements_count) {
|
||||||
asn_TYPE_member_t *const elm = &td->elements[present - 1];
|
asn_TYPE_member_t *const elm = &td->elements[present - 1];
|
||||||
const void *memb_ptr;
|
const void *memb_ptr;
|
||||||
|
|
||||||
|
@ -1162,8 +1161,8 @@ int
|
||||||
CHOICE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) {
|
CHOICE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) {
|
||||||
asn_TYPE_member_t *aelm;
|
asn_TYPE_member_t *aelm;
|
||||||
asn_TYPE_member_t *belm;
|
asn_TYPE_member_t *belm;
|
||||||
signed apresent = 0;
|
unsigned apresent = 0;
|
||||||
signed bpresent = 0;
|
unsigned bpresent = 0;
|
||||||
const void *amember = _get_member_ptr(td, aptr, &aelm, &apresent);
|
const void *amember = _get_member_ptr(td, aptr, &aelm, &apresent);
|
||||||
const void *bmember = _get_member_ptr(td, bptr, &belm, &apresent);
|
const void *bmember = _get_member_ptr(td, bptr, &belm, &apresent);
|
||||||
|
|
||||||
|
|
|
@ -13,27 +13,27 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef const struct asn_CHOICE_specifics_s {
|
typedef const struct asn_CHOICE_specifics_s {
|
||||||
/*
|
/*
|
||||||
* Target structure description.
|
* Target structure description.
|
||||||
*/
|
*/
|
||||||
int struct_size; /* Size of the target structure. */
|
unsigned struct_size; /* Size of the target structure. */
|
||||||
int ctx_offset; /* Offset of the asn_codec_ctx_t member */
|
unsigned ctx_offset; /* Offset of the asn_codec_ctx_t member */
|
||||||
int pres_offset; /* Identifier of the present member */
|
unsigned pres_offset; /* Identifier of the present member */
|
||||||
int pres_size; /* Size of the identifier (enum) */
|
unsigned pres_size; /* Size of the identifier (enum) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tags to members mapping table.
|
* Tags to members mapping table.
|
||||||
*/
|
*/
|
||||||
const asn_TYPE_tag2member_t *tag2el;
|
const asn_TYPE_tag2member_t *tag2el;
|
||||||
unsigned tag2el_count;
|
unsigned tag2el_count;
|
||||||
|
|
||||||
/* Canonical ordering of CHOICE elements, for PER */
|
/* Canonical ordering of CHOICE elements, for PER */
|
||||||
int *canonical_order;
|
const int *canonical_order;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extensions-related stuff.
|
* Extensions-related stuff.
|
||||||
*/
|
*/
|
||||||
signed ext_start; /* First member of extensions, or -1 */
|
signed ext_start; /* First member of extensions, or -1 */
|
||||||
} asn_CHOICE_specifics_t;
|
} asn_CHOICE_specifics_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue