mirror of https://gerrit.osmocom.org/asn1c
more words on circular references
This commit is contained in:
parent
8eb4b572fd
commit
da9a3b8a39
|
@ -1,4 +1,9 @@
|
|||
|
||||
0.9.19: 2005-Aug-16
|
||||
|
||||
* asn1c's -findirect-choice flag generates less dependent code.
|
||||
* Test cases 73 & 92 keep track of various circular references.
|
||||
|
||||
0.9.18: 2005-Aug-14
|
||||
|
||||
* The obsolete X.208 syntax is handled gracefully now (compound types'
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#undef NDEBUG
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <Name.h>
|
||||
|
||||
int
|
||||
main(int ac, char **av) {
|
||||
Name_t t;
|
||||
|
||||
(void)ac; /* Unused argument */
|
||||
(void)av; /* Unused argument */
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
/*
|
||||
* No plans to fill it up: just checking whether it compiles or not.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#undef NDEBUG
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <T.h>
|
||||
|
||||
int
|
||||
main(int ac, char **av) {
|
||||
T_t t;
|
||||
|
||||
(void)ac; /* Unused argument */
|
||||
(void)av; /* Unused argument */
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
/*
|
||||
* No plans to fill it up: just checking whether it compiles or not.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#undef NDEBUG
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <Choice.h>
|
||||
|
||||
int
|
||||
main(int ac, char **av) {
|
||||
Choice_t t;
|
||||
|
||||
(void)ac; /* Unused argument */
|
||||
(void)av; /* Unused argument */
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
/*
|
||||
* No plans to fill it up: just checking whether it compiles or not.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#undef NDEBUG
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <Everything.h>
|
||||
|
||||
int
|
||||
main(int ac, char **av) {
|
||||
Everything_t t;
|
||||
|
||||
(void)ac; /* Unused argument */
|
||||
(void)av; /* Unused argument */
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
/*
|
||||
* No plans to fill it up: just checking whether it compiles or not.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1881,7 +1881,7 @@ fi
|
|||
|
||||
# Define the identity of the package.
|
||||
PACKAGE=asn1c
|
||||
VERSION=0.9.18
|
||||
VERSION=0.9.19
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
|
|
|
@ -3,7 +3,7 @@ AC_INIT(libasn1parser/asn1p_y.y)
|
|||
AC_CANONICAL_BUILD
|
||||
AC_CANONICAL_TARGET
|
||||
AC_PREREQ(2.53)
|
||||
AM_INIT_AUTOMAKE(asn1c, 0.9.18)
|
||||
AM_INIT_AUTOMAKE(asn1c, 0.9.19)
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static int asn1c_lang_C_type_CHOICE_def(arg_t *arg);
|
|||
static int asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of);
|
||||
static int _print_tag(arg_t *arg, struct asn1p_type_tag_s *tag_p);
|
||||
static int check_if_extensible(asn1p_expr_t *expr);
|
||||
static int expr_better_indirect(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int expr_break_recursion(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int expr_as_xmlvaluelist(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int expr_elements_count(arg_t *arg, asn1p_expr_t *expr);
|
||||
static int emit_member_table(arg_t *arg, asn1p_expr_t *expr);
|
||||
|
@ -271,11 +271,9 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
|
|||
}
|
||||
|
||||
TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE)
|
||||
if(comp_mode < 3) comp_mode++;
|
||||
}
|
||||
if(comp_mode == 1
|
||||
|| expr_better_indirect(arg, v))
|
||||
if(comp_mode == 1)
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
EMBED(v);
|
||||
}
|
||||
|
@ -336,8 +334,10 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
|
|||
ext_stop = elements - 1;
|
||||
continue;
|
||||
}
|
||||
elements++;
|
||||
if(comp_mode == 1)
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
emit_member_table(arg, v);
|
||||
elements++;
|
||||
});
|
||||
OUT("};\n");
|
||||
} else {
|
||||
|
@ -434,8 +434,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
|
|||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if(comp_mode < 3) comp_mode++;
|
||||
}
|
||||
if(comp_mode == 1
|
||||
|| expr_better_indirect(arg, v))
|
||||
if(comp_mode == 1)
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
EMBED(v);
|
||||
}
|
||||
|
@ -509,11 +508,10 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
|
|||
if(v->expr_type == A1TC_EXTENSIBLE) {
|
||||
if(comp_mode < 3) comp_mode++;
|
||||
} else {
|
||||
if(comp_mode == 1
|
||||
|| expr_better_indirect(arg, v))
|
||||
if(comp_mode == 1)
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
elements++;
|
||||
}
|
||||
});
|
||||
OUT("};\n");
|
||||
|
@ -627,6 +625,13 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
|
|||
OUT("A_%s_OF(",
|
||||
(arg->expr->expr_type == ASN_CONSTR_SET_OF)
|
||||
? "SET" : "SEQUENCE");
|
||||
|
||||
/*
|
||||
* README README
|
||||
* The implementation of the A_SET_OF() macro is already indirect.
|
||||
*/
|
||||
memb->marker.flags |= EM_INDIRECT;
|
||||
|
||||
if(memb->expr_type & ASN_CONSTR_MASK
|
||||
|| ((memb->expr_type == ASN_BASIC_ENUMERATED
|
||||
|| (0 /* -- prohibited by X.693:8.3.4 */
|
||||
|
@ -638,6 +643,7 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
|
|||
tmp = *arg;
|
||||
tmp.expr = &tmp_memb;
|
||||
tmp_memb = *memb;
|
||||
tmp_memb.marker.flags &= ~EM_INDIRECT;
|
||||
tmp_memb._anonymous_type = 1;
|
||||
if(tmp_memb.Identifier == 0) {
|
||||
tmp_memb.Identifier = "Member";
|
||||
|
@ -657,6 +663,9 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
|
|||
(memb->marker.flags & EM_UNRECURSE)
|
||||
? TNF_RSAFE : TNF_CTYPE));
|
||||
}
|
||||
/* README README (above) */
|
||||
if(0 && (memb->marker.flags & EM_INDIRECT))
|
||||
OUT(" *");
|
||||
OUT(") list;\n");
|
||||
INDENT(-1);
|
||||
|
||||
|
@ -791,8 +800,6 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
|
|||
}
|
||||
OUT("{\n");
|
||||
TQ_FOR(v, &(expr->members), next) {
|
||||
if(expr_better_indirect(arg, v))
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
EMBED(v);
|
||||
}
|
||||
if(UNNAMED_UNIONS) OUT("};\n");
|
||||
|
@ -847,10 +854,8 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
|
|||
INDENTED(TQ_FOR(v, &(expr->members), next) {
|
||||
if(v->expr_type == A1TC_EXTENSIBLE)
|
||||
continue;
|
||||
if(expr_better_indirect(arg, v))
|
||||
v->marker.flags |= EM_INDIRECT;
|
||||
elements++;
|
||||
emit_member_table(arg, v);
|
||||
elements++;
|
||||
});
|
||||
OUT("};\n");
|
||||
} else {
|
||||
|
@ -1614,21 +1619,20 @@ emit_include_dependencies(arg_t *arg) {
|
|||
|
||||
TQ_FOR(memb, &(expr->members), next) {
|
||||
|
||||
if((memb->meta_type == AMT_TYPEREF
|
||||
&& (memb->marker.flags & EM_INDIRECT))
|
||||
|| expr->expr_type == ASN_CONSTR_SET_OF
|
||||
|| expr->expr_type == ASN_CONSTR_SEQUENCE_OF
|
||||
) {
|
||||
/* Avoid recursive definitions. */
|
||||
expr_break_recursion(arg, memb);
|
||||
|
||||
if(memb->marker.flags & (EM_INDIRECT | EM_UNRECURSE)) {
|
||||
asn1p_expr_t *terminal;
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, memb);
|
||||
if(terminal && !terminal->parent_expr
|
||||
&& (terminal->expr_type & ASN_CONSTR_MASK)) {
|
||||
if(terminal
|
||||
&& !terminal->parent_expr
|
||||
&& (terminal->expr_type & ASN_CONSTR_MASK)) {
|
||||
int saved_target = arg->target->target;
|
||||
REDIR(OT_FWD_DECLS);
|
||||
OUT("%s;\n",
|
||||
asn1c_type_name(arg, memb, TNF_RSAFE));
|
||||
REDIR(saved_target);
|
||||
memb->marker.flags |= EM_UNRECURSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1648,6 +1652,66 @@ emit_include_dependencies(arg_t *arg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if it is better to make this type indirectly accessed via
|
||||
* a pointer.
|
||||
* This may be the case for the following recursive definition:
|
||||
* Type ::= CHOICE { member Type };
|
||||
*/
|
||||
static int
|
||||
expr_break_recursion(arg_t *arg, asn1p_expr_t *expr) {
|
||||
asn1p_expr_t *top_parent;
|
||||
asn1p_expr_t *terminal;
|
||||
|
||||
if(expr->marker.flags & EM_UNRECURSE)
|
||||
return 1; /* Already broken */
|
||||
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
|
||||
/* -findirect-choice compiles members of CHOICE as indirect pointers */
|
||||
if((arg->flags & A1C_INDIRECT_CHOICE)
|
||||
&& arg->expr->expr_type == ASN_CONSTR_CHOICE
|
||||
&& terminal
|
||||
&& (terminal->expr_type & ASN_CONSTR_MASK)
|
||||
) {
|
||||
/* Break cross-reference */
|
||||
expr->marker.flags |= EM_INDIRECT | EM_UNRECURSE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((expr->marker.flags & EM_INDIRECT)
|
||||
|| arg->expr->expr_type == ASN_CONSTR_SET_OF
|
||||
|| arg->expr->expr_type == ASN_CONSTR_SEQUENCE_OF) {
|
||||
if(terminal
|
||||
&& !terminal->parent_expr
|
||||
&& (terminal->expr_type & ASN_CONSTR_MASK)) {
|
||||
expr->marker.flags |= EM_UNRECURSE;
|
||||
|
||||
if(arg->expr->expr_type == ASN_CONSTR_SET_OF
|
||||
|| arg->expr->expr_type == ASN_CONSTR_SEQUENCE_OF) {
|
||||
/* Don't put EM_INDIRECT even if recursion */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Fall through */
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for recursive back-references */
|
||||
top_parent = expr->parent_expr;
|
||||
if(top_parent) {
|
||||
while(top_parent->parent_expr)
|
||||
top_parent = top_parent->parent_expr;
|
||||
if(top_parent == terminal) {
|
||||
/* Explicitly break the recursion */
|
||||
expr->marker.flags |= EM_INDIRECT | EM_UNRECURSE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
|
||||
int save_target;
|
||||
|
@ -1901,38 +1965,6 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if it is better to make this type indirectly accessed via
|
||||
* a pointer.
|
||||
* This may be the case for the following recursive definition:
|
||||
* Type ::= CHOICE { member Type };
|
||||
*/
|
||||
static int
|
||||
expr_better_indirect(arg_t *arg, asn1p_expr_t *expr) {
|
||||
asn1p_expr_t *top_parent;
|
||||
asn1p_expr_t *terminal;
|
||||
|
||||
if(expr->expr_type != A1TC_REFERENCE)
|
||||
return 0;
|
||||
|
||||
/* -findirect-choice compiles members of CHOICE as indirect pointers */
|
||||
if((arg->flags & A1C_INDIRECT_CHOICE)
|
||||
&& arg->expr->expr_type == ASN_CONSTR_CHOICE)
|
||||
return 1;
|
||||
|
||||
/* Rewind to the topmost parent expression */
|
||||
if((top_parent = expr->parent_expr)) {
|
||||
while(top_parent->parent_expr)
|
||||
top_parent = top_parent->parent_expr;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
terminal = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
|
||||
return (terminal == top_parent);
|
||||
}
|
||||
|
||||
static int
|
||||
expr_as_xmlvaluelist(arg_t *arg, asn1p_expr_t *expr) {
|
||||
expr = asn1f_find_terminal_type_ex(arg->asn, expr);
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ASN1C_ENVIRONMENT_VERSION 98 /* Compile-time version */
|
||||
/* Environment version might be used to avoid running with the old library */
|
||||
#define ASN1C_ENVIRONMENT_VERSION 919 /* Compile-time version */
|
||||
int get_asn1c_environment_version(void); /* Run-time version */
|
||||
|
||||
#define CALLOC(nmemb, size) calloc(nmemb, size)
|
||||
|
|
|
@ -27,6 +27,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
*/
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
if(!memb_ptr) continue;
|
||||
erval = elm->type->der_encoder(elm->type, memb_ptr,
|
||||
0, elm->tag,
|
||||
0, 0);
|
||||
|
@ -60,6 +61,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
*/
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
if(!memb_ptr) continue;
|
||||
erval = elm->type->der_encoder(elm->type, memb_ptr,
|
||||
0, elm->tag,
|
||||
cb, app_key);
|
||||
|
@ -88,11 +90,10 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *element = td->elements;
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(sptr);
|
||||
const char *mname = specs->as_XMLValueList
|
||||
? 0 : ((*element->name)
|
||||
? element->name : element->type->xml_tag);
|
||||
? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag);
|
||||
unsigned int mlen = mname ? strlen(mname) : 0;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
int i;
|
||||
|
@ -103,7 +104,6 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
|
||||
for(i = 0; i < list->count; i++) {
|
||||
asn_enc_rval_t tmper;
|
||||
|
||||
void *memb_ptr = list->array[i];
|
||||
if(!memb_ptr) continue;
|
||||
|
||||
|
@ -112,12 +112,12 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
}
|
||||
|
||||
tmper = element->type->xer_encoder(element->type, memb_ptr,
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
if(tmper.encoded == 0 && specs->as_XMLValueList) {
|
||||
const char *name = (*element->name)
|
||||
? element->name : element->type->xml_tag;
|
||||
const char *name = (*elm->name)
|
||||
? elm->name : elm->type->xml_tag;
|
||||
size_t len = strlen(name);
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel + 1);
|
||||
_ASN_CALLBACK3("<", 1, name, len, "/>", 2);
|
||||
|
|
|
@ -71,7 +71,7 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
* Bring closer parts of structure description.
|
||||
*/
|
||||
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *element = td->elements; /* Single one */
|
||||
asn_TYPE_member_t *elm = td->elements; /* Single one */
|
||||
|
||||
/*
|
||||
* Parts of the structure being constructed.
|
||||
|
@ -181,8 +181,8 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
/* Outmost tag may be unknown and cannot be fetched/compared */
|
||||
if(element->tag != (ber_tlv_tag_t)-1) {
|
||||
if(BER_TAGS_EQUAL(tlv_tag, element->tag)) {
|
||||
if(elm->tag != (ber_tlv_tag_t)-1) {
|
||||
if(BER_TAGS_EQUAL(tlv_tag, elm->tag)) {
|
||||
/*
|
||||
* The new list member of expected type has arrived.
|
||||
*/
|
||||
|
@ -190,7 +190,7 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
ASN_DEBUG("Unexpected tag %s fixed SET OF %s",
|
||||
ber_tlv_tag_string(tlv_tag), td->name);
|
||||
ASN_DEBUG("%s SET OF has tag %s",
|
||||
td->name, ber_tlv_tag_string(element->tag));
|
||||
td->name, ber_tlv_tag_string(elm->tag));
|
||||
RETURN(RC_FAIL);
|
||||
}
|
||||
}
|
||||
|
@ -204,10 +204,10 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
/*
|
||||
* Invoke the member fetch routine according to member's type
|
||||
*/
|
||||
rval = element->type->ber_decoder(opt_codec_ctx,
|
||||
element->type, &ctx->ptr, ptr, LEFT, 0);
|
||||
rval = elm->type->ber_decoder(opt_codec_ctx,
|
||||
elm->type, &ctx->ptr, ptr, LEFT, 0);
|
||||
ASN_DEBUG("In %s SET OF %s code %d consumed %d",
|
||||
td->name, element->type->name,
|
||||
td->name, elm->type->name,
|
||||
rval.code, (int)rval.consumed);
|
||||
switch(rval.code) {
|
||||
case RC_OK:
|
||||
|
@ -317,6 +317,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
size_t computed_size = 0;
|
||||
ssize_t encoding_size = 0;
|
||||
struct _el_buffer *encoded_els;
|
||||
ssize_t eels_count = 0;
|
||||
size_t max_encoded_len = 1;
|
||||
asn_enc_rval_t erval;
|
||||
int ret;
|
||||
|
@ -329,6 +330,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
*/
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
if(!memb_ptr) continue;
|
||||
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
|
||||
if(erval.encoded == -1)
|
||||
return erval;
|
||||
|
@ -378,7 +380,9 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
*/
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
struct _el_buffer *encoded_el = &encoded_els[edx];
|
||||
struct _el_buffer *encoded_el = &encoded_els[eels_count];
|
||||
|
||||
if(!memb_ptr) continue;
|
||||
|
||||
/*
|
||||
* Prepare space for encoding.
|
||||
|
@ -409,19 +413,20 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
return erval;
|
||||
}
|
||||
encoding_size += erval.encoded;
|
||||
eels_count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sort the encoded elements according to their encoding.
|
||||
*/
|
||||
qsort(encoded_els, list->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.
|
||||
* Dispose of temporary sorted members table.
|
||||
*/
|
||||
ret = 0;
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
for(edx = 0; edx < eels_count; edx++) {
|
||||
struct _el_buffer *encoded_el = &encoded_els[edx];
|
||||
/* Report encoded chunks to the application */
|
||||
if(ret == 0
|
||||
|
@ -638,11 +643,10 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *element = td->elements;
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr);
|
||||
const char *mname = specs->as_XMLValueList
|
||||
? 0 : ((*element->name)
|
||||
? element->name : element->type->xml_tag);
|
||||
? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag);
|
||||
size_t mlen = mname ? strlen(mname) : 0;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
xer_tmp_enc_t *encs = 0;
|
||||
|
@ -680,7 +684,7 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
|
||||
if(!xcan && specs->as_XMLValueList)
|
||||
_i_ASN_TEXT_INDENT(1, ilevel + 1);
|
||||
tmper = element->type->xer_encoder(element->type, memb_ptr,
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) {
|
||||
td = tmper.failed_type;
|
||||
|
@ -688,8 +692,8 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
goto cb_failed;
|
||||
}
|
||||
if(tmper.encoded == 0 && specs->as_XMLValueList) {
|
||||
const char *name = (*element->name)
|
||||
? element->name : element->type->xml_tag;
|
||||
const char *name = (*elm->name)
|
||||
? elm->name : elm->type->xml_tag;
|
||||
size_t len = strlen(name);
|
||||
_ASN_CALLBACK3("<", 1, name, len, "/>", 2);
|
||||
}
|
||||
|
@ -741,7 +745,7 @@ cleanup:
|
|||
int
|
||||
SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_TYPE_member_t *element = td->elements;
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
|
||||
int ret;
|
||||
int i;
|
||||
|
@ -759,7 +763,7 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
|
||||
_i_INDENT(1);
|
||||
|
||||
ret = element->type->print_struct(element->type, memb_ptr,
|
||||
ret = elm->type->print_struct(elm->type, memb_ptr,
|
||||
ilevel + 1, cb, app_key);
|
||||
if(ret) return ret;
|
||||
}
|
||||
|
@ -773,7 +777,7 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
void
|
||||
SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
||||
if(td && ptr) {
|
||||
asn_TYPE_member_t *element = td->elements;
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
|
||||
int i;
|
||||
|
||||
|
@ -784,7 +788,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
|||
for(i = 0; i < list->count; i++) {
|
||||
void *memb_ptr = list->array[i];
|
||||
if(memb_ptr)
|
||||
element->type->free_struct(element->type, memb_ptr, 0);
|
||||
elm->type->free_struct(elm->type, memb_ptr, 0);
|
||||
}
|
||||
list->count = 0; /* No meaningful elements left */
|
||||
|
||||
|
@ -799,7 +803,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
|
|||
int
|
||||
SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *app_errlog, void *app_key) {
|
||||
asn_TYPE_member_t *element = td->elements;
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_constr_check_f *constr;
|
||||
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
|
||||
int i;
|
||||
|
@ -811,8 +815,8 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
return -1;
|
||||
}
|
||||
|
||||
constr = element->memb_constraints;
|
||||
if(!constr) constr = element->type->check_constraints;
|
||||
constr = elm->memb_constraints;
|
||||
if(!constr) constr = elm->type->check_constraints;
|
||||
|
||||
/*
|
||||
* Iterate over the members of an array.
|
||||
|
@ -824,7 +828,7 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
|
||||
if(!memb_ptr) continue;
|
||||
|
||||
ret = constr(element->type, memb_ptr, app_errlog, app_key);
|
||||
ret = constr(elm->type, memb_ptr, app_errlog, app_key);
|
||||
if(ret) return ret;
|
||||
}
|
||||
|
||||
|
@ -832,8 +836,8 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
* Cannot inherit it eralier:
|
||||
* need to make sure we get the updated version.
|
||||
*/
|
||||
if(!element->memb_constraints)
|
||||
element->memb_constraints = element->type->check_constraints;
|
||||
if(!elm->memb_constraints)
|
||||
elm->memb_constraints = elm->type->check_constraints;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue