Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
da9a3b8a
Commit
da9a3b8a
authored
Aug 16, 2005
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more words on circular references
parent
8eb4b572
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
230 additions
and
92 deletions
+230
-92
ChangeLog
ChangeLog
+5
-0
asn1c/tests/check-19.c
asn1c/tests/check-19.c
+24
-0
asn1c/tests/check-39.c
asn1c/tests/check-39.c
+24
-0
asn1c/tests/check-59.c
asn1c/tests/check-59.c
+24
-0
asn1c/tests/check-92.-findirect-choice.c
asn1c/tests/check-92.-findirect-choice.c
+24
-0
configure
configure
+1
-1
configure.in
configure.in
+1
-1
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+88
-56
skeletons/asn_internal.h
skeletons/asn_internal.h
+2
-1
skeletons/constr_SEQUENCE_OF.c
skeletons/constr_SEQUENCE_OF.c
+7
-7
skeletons/constr_SET_OF.c
skeletons/constr_SET_OF.c
+30
-26
No files found.
ChangeLog
View file @
da9a3b8a
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
0.9.18: 2005-Aug-14
* The obsolete X.208 syntax is handled gracefully now (compound types'
* The obsolete X.208 syntax is handled gracefully now (compound types'
...
...
asn1c/tests/check-19.c
0 → 100644
View file @
da9a3b8a
#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
;
}
asn1c/tests/check-39.c
0 → 100644
View file @
da9a3b8a
#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
;
}
asn1c/tests/check-59.c
0 → 100644
View file @
da9a3b8a
#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
;
}
asn1c/tests/check-92.-findirect-choice.c
0 → 100644
View file @
da9a3b8a
#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
;
}
configure
View file @
da9a3b8a
...
@@ -1881,7 +1881,7 @@ fi
...
@@ -1881,7 +1881,7 @@ fi
# Define the identity of the package.
# Define the identity of the package.
PACKAGE
=
asn1c
PACKAGE
=
asn1c
VERSION
=
0.9.1
8
VERSION
=
0.9.1
9
cat
>>
confdefs.h
<<
_ACEOF
cat
>>
confdefs.h
<<
_ACEOF
...
...
configure.in
View file @
da9a3b8a
...
@@ -3,7 +3,7 @@ AC_INIT(libasn1parser/asn1p_y.y)
...
@@ -3,7 +3,7 @@ AC_INIT(libasn1parser/asn1p_y.y)
AC_CANONICAL_BUILD
AC_CANONICAL_BUILD
AC_CANONICAL_TARGET
AC_CANONICAL_TARGET
AC_PREREQ(2.53)
AC_PREREQ(2.53)
AM_INIT_AUTOMAKE(asn1c, 0.9.1
8
)
AM_INIT_AUTOMAKE(asn1c, 0.9.1
9
)
AM_MAINTAINER_MODE
AM_MAINTAINER_MODE
...
...
libasn1compiler/asn1c_C.c
View file @
da9a3b8a
...
@@ -36,7 +36,7 @@ static int asn1c_lang_C_type_CHOICE_def(arg_t *arg);
...
@@ -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
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
_print_tag
(
arg_t
*
arg
,
struct
asn1p_type_tag_s
*
tag_p
);
static
int
check_if_extensible
(
asn1p_expr_t
*
expr
);
static
int
check_if_extensible
(
asn1p_expr_t
*
expr
);
static
int
expr_b
etter_indirect
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
);
static
int
expr_b
reak_recursion
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
);
static
int
expr_as_xmlvaluelist
(
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
expr_elements_count
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
);
static
int
emit_member_table
(
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) {
...
@@ -271,11 +271,9 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
}
}
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
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
<
3
)
comp_mode
++
;
}
if
(
comp_mode
==
1
)
if
(
comp_mode
==
1
||
expr_better_indirect
(
arg
,
v
))
v
->
marker
.
flags
|=
EM_INDIRECT
;
v
->
marker
.
flags
|=
EM_INDIRECT
;
EMBED
(
v
);
EMBED
(
v
);
}
}
...
@@ -336,8 +334,10 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
...
@@ -336,8 +334,10 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
ext_stop
=
elements
-
1
;
ext_stop
=
elements
-
1
;
continue
;
continue
;
}
}
elements
++
;
if
(
comp_mode
==
1
)
v
->
marker
.
flags
|=
EM_INDIRECT
;
emit_member_table
(
arg
,
v
);
emit_member_table
(
arg
,
v
);
elements
++
;
});
});
OUT
(
"};
\n
"
);
OUT
(
"};
\n
"
);
}
else
{
}
else
{
...
@@ -434,8 +434,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
...
@@ -434,8 +434,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
{
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
{
if
(
comp_mode
<
3
)
comp_mode
++
;
if
(
comp_mode
<
3
)
comp_mode
++
;
}
}
if
(
comp_mode
==
1
if
(
comp_mode
==
1
)
||
expr_better_indirect
(
arg
,
v
))
v
->
marker
.
flags
|=
EM_INDIRECT
;
v
->
marker
.
flags
|=
EM_INDIRECT
;
EMBED
(
v
);
EMBED
(
v
);
}
}
...
@@ -509,11 +508,10 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
...
@@ -509,11 +508,10 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
{
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
{
if
(
comp_mode
<
3
)
comp_mode
++
;
if
(
comp_mode
<
3
)
comp_mode
++
;
}
else
{
}
else
{
if
(
comp_mode
==
1
if
(
comp_mode
==
1
)
||
expr_better_indirect
(
arg
,
v
))
v
->
marker
.
flags
|=
EM_INDIRECT
;
v
->
marker
.
flags
|=
EM_INDIRECT
;
elements
++
;
emit_member_table
(
arg
,
v
);
emit_member_table
(
arg
,
v
);
elements
++
;
}
}
});
});
OUT
(
"};
\n
"
);
OUT
(
"};
\n
"
);
...
@@ -627,6 +625,13 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
...
@@ -627,6 +625,13 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
OUT
(
"A_%s_OF("
,
OUT
(
"A_%s_OF("
,
(
arg
->
expr
->
expr_type
==
ASN_CONSTR_SET_OF
)
(
arg
->
expr
->
expr_type
==
ASN_CONSTR_SET_OF
)
?
"SET"
:
"SEQUENCE"
);
?
"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
if
(
memb
->
expr_type
&
ASN_CONSTR_MASK
||
((
memb
->
expr_type
==
ASN_BASIC_ENUMERATED
||
((
memb
->
expr_type
==
ASN_BASIC_ENUMERATED
||
(
0
/* -- prohibited by X.693:8.3.4 */
||
(
0
/* -- prohibited by X.693:8.3.4 */
...
@@ -638,6 +643,7 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
...
@@ -638,6 +643,7 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
tmp
=
*
arg
;
tmp
=
*
arg
;
tmp
.
expr
=
&
tmp_memb
;
tmp
.
expr
=
&
tmp_memb
;
tmp_memb
=
*
memb
;
tmp_memb
=
*
memb
;
tmp_memb
.
marker
.
flags
&=
~
EM_INDIRECT
;
tmp_memb
.
_anonymous_type
=
1
;
tmp_memb
.
_anonymous_type
=
1
;
if
(
tmp_memb
.
Identifier
==
0
)
{
if
(
tmp_memb
.
Identifier
==
0
)
{
tmp_memb
.
Identifier
=
"Member"
;
tmp_memb
.
Identifier
=
"Member"
;
...
@@ -657,6 +663,9 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
...
@@ -657,6 +663,9 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
(
memb
->
marker
.
flags
&
EM_UNRECURSE
)
(
memb
->
marker
.
flags
&
EM_UNRECURSE
)
?
TNF_RSAFE
:
TNF_CTYPE
));
?
TNF_RSAFE
:
TNF_CTYPE
));
}
}
/* README README (above) */
if
(
0
&&
(
memb
->
marker
.
flags
&
EM_INDIRECT
))
OUT
(
" *"
);
OUT
(
") list;
\n
"
);
OUT
(
") list;
\n
"
);
INDENT
(
-
1
);
INDENT
(
-
1
);
...
@@ -791,8 +800,6 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
...
@@ -791,8 +800,6 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
}
}
OUT
(
"{
\n
"
);
OUT
(
"{
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
expr_better_indirect
(
arg
,
v
))
v
->
marker
.
flags
|=
EM_INDIRECT
;
EMBED
(
v
);
EMBED
(
v
);
}
}
if
(
UNNAMED_UNIONS
)
OUT
(
"};
\n
"
);
if
(
UNNAMED_UNIONS
)
OUT
(
"};
\n
"
);
...
@@ -847,10 +854,8 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
...
@@ -847,10 +854,8 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
INDENTED
(
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
INDENTED
(
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
continue
;
continue
;
if
(
expr_better_indirect
(
arg
,
v
))
v
->
marker
.
flags
|=
EM_INDIRECT
;
elements
++
;
emit_member_table
(
arg
,
v
);
emit_member_table
(
arg
,
v
);
elements
++
;
});
});
OUT
(
"};
\n
"
);
OUT
(
"};
\n
"
);
}
else
{
}
else
{
...
@@ -1614,21 +1619,20 @@ emit_include_dependencies(arg_t *arg) {
...
@@ -1614,21 +1619,20 @@ emit_include_dependencies(arg_t *arg) {
TQ_FOR
(
memb
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
memb
,
&
(
expr
->
members
),
next
)
{
if
((
memb
->
meta_type
==
AMT_TYPEREF
/* Avoid recursive definitions. */
&&
(
memb
->
marker
.
flags
&
EM_INDIRECT
))
expr_break_recursion
(
arg
,
memb
);
||
expr
->
expr_type
==
ASN_CONSTR_SET_OF
||
expr
->
expr_type
==
ASN_CONSTR_SEQUENCE_OF
if
(
memb
->
marker
.
flags
&
(
EM_INDIRECT
|
EM_UNRECURSE
))
{
)
{
asn1p_expr_t
*
terminal
;
asn1p_expr_t
*
terminal
;
terminal
=
asn1f_find_terminal_type_ex
(
arg
->
asn
,
memb
);
terminal
=
asn1f_find_terminal_type_ex
(
arg
->
asn
,
memb
);
if
(
terminal
&&
!
terminal
->
parent_expr
if
(
terminal
&&
!
terminal
->
parent_expr
&&
(
terminal
->
expr_type
&
ASN_CONSTR_MASK
))
{
&&
(
terminal
->
expr_type
&
ASN_CONSTR_MASK
))
{
int
saved_target
=
arg
->
target
->
target
;
int
saved_target
=
arg
->
target
->
target
;
REDIR
(
OT_FWD_DECLS
);
REDIR
(
OT_FWD_DECLS
);
OUT
(
"%s;
\n
"
,
OUT
(
"%s;
\n
"
,
asn1c_type_name
(
arg
,
memb
,
TNF_RSAFE
));
asn1c_type_name
(
arg
,
memb
,
TNF_RSAFE
));
REDIR
(
saved_target
);
REDIR
(
saved_target
);
memb
->
marker
.
flags
|=
EM_UNRECURSE
;
}
}
}
}
...
@@ -1648,6 +1652,66 @@ emit_include_dependencies(arg_t *arg) {
...
@@ -1648,6 +1652,66 @@ emit_include_dependencies(arg_t *arg) {
return
0
;
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
static
int
emit_member_table
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
emit_member_table
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
int
save_target
;
int
save_target
;
...
@@ -1901,38 +1965,6 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
...
@@ -1901,38 +1965,6 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
return
0
;
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
static
int
expr_as_xmlvaluelist
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
expr_as_xmlvaluelist
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
expr
=
asn1f_find_terminal_type_ex
(
arg
->
asn
,
expr
);
expr
=
asn1f_find_terminal_type_ex
(
arg
->
asn
,
expr
);
...
...
skeletons/asn_internal.h
View file @
da9a3b8a
...
@@ -19,7 +19,8 @@
...
@@ -19,7 +19,8 @@
extern
"C"
{
extern
"C"
{
#endif
#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 */
int
get_asn1c_environment_version
(
void
);
/* Run-time version */
#define CALLOC(nmemb, size) calloc(nmemb, size)
#define CALLOC(nmemb, size) calloc(nmemb, size)
...
...
skeletons/constr_SEQUENCE_OF.c
View file @
da9a3b8a
...
@@ -27,6 +27,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -27,6 +27,7 @@ SEQUENCE_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
];
if
(
!
memb_ptr
)
continue
;
erval
=
elm
->
type
->
der_encoder
(
elm
->
type
,
memb_ptr
,
erval
=
elm
->
type
->
der_encoder
(
elm
->
type
,
memb_ptr
,
0
,
elm
->
tag
,
0
,
elm
->
tag
,
0
,
0
);
0
,
0
);
...
@@ -60,6 +61,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -60,6 +61,7 @@ SEQUENCE_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
];
if
(
!
memb_ptr
)
continue
;
erval
=
elm
->
type
->
der_encoder
(
elm
->
type
,
memb_ptr
,
erval
=
elm
->
type
->
der_encoder
(
elm
->
type
,
memb_ptr
,
0
,
elm
->
tag
,
0
,
elm
->
tag
,
cb
,
app_key
);
cb
,
app_key
);
...
@@ -88,11 +90,10 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
...
@@ -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_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_enc_rval_t
er
;
asn_enc_rval_t
er
;
asn_SET_OF_specifics_t
*
specs
=
(
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
asn_SET_OF_specifics_t
*
specs
=
(
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
asn_TYPE_member_t
*
el
ement
=
td
->
elements
;
asn_TYPE_member_t
*
el
m
=
td
->
elements
;
asn_anonymous_sequence_
*
list
=
_A_SEQUENCE_FROM_VOID
(
sptr
);
asn_anonymous_sequence_
*
list
=
_A_SEQUENCE_FROM_VOID
(
sptr
);
const
char
*
mname
=
specs
->
as_XMLValueList
const
char
*
mname
=
specs
->
as_XMLValueList
?
0
:
((
*
element
->
name
)
?
0
:
((
*
elm
->
name
)
?
elm
->
name
:
elm
->
type
->
xml_tag
);
?
element
->
name
:
element
->
type
->
xml_tag
);
unsigned
int
mlen
=
mname
?
strlen
(
mname
)
:
0
;
unsigned
int
mlen
=
mname
?
strlen
(
mname
)
:
0
;
int
xcan
=
(
flags
&
XER_F_CANONICAL
);
int
xcan
=
(
flags
&
XER_F_CANONICAL
);
int
i
;
int
i
;
...
@@ -103,7 +104,6 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
...
@@ -103,7 +104,6 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
for
(
i
=
0
;
i
<
list
->
count
;
i
++
)
{
for
(
i
=
0
;
i
<
list
->
count
;
i
++
)
{
asn_enc_rval_t
tmper
;
asn_enc_rval_t
tmper
;
void
*
memb_ptr
=
list
->
array
[
i
];
void
*
memb_ptr
=
list
->
array
[
i
];
if
(
!
memb_ptr
)
continue
;
if
(
!
memb_ptr
)
continue
;
...
@@ -112,12 +112,12 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
...
@@ -112,12 +112,12 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
_ASN_CALLBACK3
(
"<"
,
1
,
mname
,
mlen
,
">"
,
1
);
_ASN_CALLBACK3
(
"<"
,
1
,
mname
,
mlen
,
">"
,
1
);
}
}
tmper
=
el
ement
->
type
->
xer_encoder
(
element
->
type
,
memb_ptr
,
tmper
=
el
m
->
type
->
xer_encoder
(
elm
->
type
,
memb_ptr
,
ilevel
+
1
,
flags
,
cb
,
app_key
);
ilevel
+
1
,
flags
,
cb
,
app_key
);
if
(
tmper
.
encoded
==
-
1
)
return
tmper
;
if
(
tmper
.
encoded
==
-
1
)
return
tmper
;
if
(
tmper
.
encoded
==
0
&&
specs
->
as_XMLValueList
)
{
if
(
tmper
.
encoded
==
0
&&
specs
->
as_XMLValueList
)
{
const
char
*
name
=
(
*
el
ement
->
name
)
const
char
*
name
=
(
*
el
m
->
name
)
?
el
ement
->
name
:
element
->
type
->
xml_tag
;
?
el
m
->
name
:
elm
->
type
->
xml_tag
;
size_t
len
=
strlen
(
name
);
size_t
len
=
strlen
(
name
);
if
(
!
xcan
)
_i_ASN_TEXT_INDENT
(
1
,
ilevel
+
1
);
if
(
!
xcan
)
_i_ASN_TEXT_INDENT
(
1
,
ilevel
+
1
);
_ASN_CALLBACK3
(
"<"
,
1
,
name
,
len
,
"/>"
,
2
);
_ASN_CALLBACK3
(
"<"
,
1
,
name
,
len
,
"/>"
,
2
);
...
...
skeletons/constr_SET_OF.c
View file @
da9a3b8a
...
@@ -71,7 +71,7 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -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.
* Bring closer parts of structure description.
*/
*/
asn_SET_OF_specifics_t
*
specs
=
(
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
asn_SET_OF_specifics_t
*
specs
=
(
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
asn_TYPE_member_t
*
el
ement
=
td
->
elements
;
/* Single one */
asn_TYPE_member_t
*
el
m
=
td
->
elements
;
/* Single one */
/*
/*
* Parts of the structure being constructed.
* 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,
...
@@ -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 */
/* Outmost tag may be unknown and cannot be fetched/compared */
if
(
el
ement
->
tag
!=
(
ber_tlv_tag_t
)
-
1
)
{
if
(
el
m
->
tag
!=
(
ber_tlv_tag_t
)
-
1
)
{
if
(
BER_TAGS_EQUAL
(
tlv_tag
,
el
ement
->
tag
))
{
if
(
BER_TAGS_EQUAL
(
tlv_tag
,
el
m
->
tag
))
{
/*
/*
* The new list member of expected type has arrived.
* 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,
...
@@ -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"
,
ASN_DEBUG
(
"Unexpected tag %s fixed SET OF %s"
,
ber_tlv_tag_string
(
tlv_tag
),
td
->
name
);
ber_tlv_tag_string
(
tlv_tag
),
td
->
name
);
ASN_DEBUG
(
"%s SET OF has tag %s"
,
ASN_DEBUG
(
"%s SET OF has tag %s"
,
td
->
name
,
ber_tlv_tag_string
(
el
ement
->
tag
));
td
->
name
,
ber_tlv_tag_string
(
el
m
->
tag
));
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
}
}
...
@@ -204,10 +204,10 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -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
* Invoke the member fetch routine according to member's type
*/
*/
rval
=
el
ement
->
type
->
ber_decoder
(
opt_codec_ctx
,
rval
=
el
m
->
type
->
ber_decoder
(
opt_codec_ctx
,
el
ement
->
type
,
&
ctx
->
ptr
,
ptr
,
LEFT
,
0
);
el
m
->
type
,
&
ctx
->
ptr
,
ptr
,
LEFT
,
0
);
ASN_DEBUG
(
"In %s SET OF %s code %d consumed %d"
,
ASN_DEBUG
(
"In %s SET OF %s code %d consumed %d"
,
td
->
name
,
el
ement
->
type
->
name
,
td
->
name
,
el
m
->
type
->
name
,
rval
.
code
,
(
int
)
rval
.
consumed
);
rval
.
code
,
(
int
)
rval
.
consumed
);
switch
(
rval
.
code
)
{
switch
(
rval
.
code
)
{
case
RC_OK
:
case
RC_OK
:
...
@@ -317,6 +317,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -317,6 +317,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, 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
;
size_t
max_encoded_len
=
1
;
size_t
max_encoded_len
=
1
;
asn_enc_rval_t
erval
;
asn_enc_rval_t
erval
;
int
ret
;
int
ret
;
...
@@ -329,6 +330,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -329,6 +330,7 @@ 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
];
if
(
!
memb_ptr
)
continue
;
erval
=
der_encoder
(
elm_type
,
memb_ptr
,
0
,
elm
->
tag
,
0
,
0
);
erval
=
der_encoder
(
elm_type
,
memb_ptr
,
0
,
elm
->
tag
,
0
,
0
);
if
(
erval
.
encoded
==
-
1
)
if
(
erval
.
encoded
==
-
1
)
return
erval
;
return
erval
;
...
@@ -378,7 +380,9 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -378,7 +380,9 @@ 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
[
edx
];
struct
_el_buffer
*
encoded_el
=
&
encoded_els
[
eels_count
];
if
(
!
memb_ptr
)
continue
;
/*
/*
* Prepare space for encoding.
* Prepare space for encoding.
...
@@ -409,19 +413,20 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -409,19 +413,20 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
return
erval
;
return
erval
;
}
}
encoding_size
+=
erval
.
encoded
;
encoding_size
+=
erval
.
encoded
;
eels_count
++
;
}
}
/*
/*
* Sort the encoded elements according to their encoding.
* 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.
* Report encoded elements to the application.
* Dispose of temporary sorted members table.
* Dispose of temporary sorted members table.
*/
*/
ret
=
0
;
ret
=
0
;
for
(
edx
=
0
;
edx
<
list
->
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
...
@@ -638,11 +643,10 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
...
@@ -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_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_enc_rval_t
er
;
asn_enc_rval_t
er
;
asn_SET_OF_specifics_t
*
specs
=
(
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
asn_SET_OF_specifics_t
*
specs
=
(
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
asn_TYPE_member_t
*
el
ement
=
td
->
elements
;
asn_TYPE_member_t
*
el
m
=
td
->
elements
;
asn_anonymous_set_
*
list
=
_A_SET_FROM_VOID
(
sptr
);
asn_anonymous_set_
*
list
=
_A_SET_FROM_VOID
(
sptr
);
const
char
*
mname
=
specs
->
as_XMLValueList
const
char
*
mname
=
specs
->
as_XMLValueList
?
0
:
((
*
element
->
name
)
?
0
:
((
*
elm
->
name
)
?
elm
->
name
:
elm
->
type
->
xml_tag
);
?
element
->
name
:
element
->
type
->
xml_tag
);
size_t
mlen
=
mname
?
strlen
(
mname
)
:
0
;
size_t
mlen
=
mname
?
strlen
(
mname
)
:
0
;
int
xcan
=
(
flags
&
XER_F_CANONICAL
);
int
xcan
=
(
flags
&
XER_F_CANONICAL
);
xer_tmp_enc_t
*
encs
=
0
;
xer_tmp_enc_t
*
encs
=
0
;
...
@@ -680,7 +684,7 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
...
@@ -680,7 +684,7 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
if
(
!
xcan
&&
specs
->
as_XMLValueList
)
if
(
!
xcan
&&
specs
->
as_XMLValueList
)
_i_ASN_TEXT_INDENT
(
1
,
ilevel
+
1
);
_i_ASN_TEXT_INDENT
(
1
,
ilevel
+
1
);
tmper
=
el
ement
->
type
->
xer_encoder
(
element
->
type
,
memb_ptr
,
tmper
=
el
m
->
type
->
xer_encoder
(
elm
->
type
,
memb_ptr
,
ilevel
+
1
,
flags
,
cb
,
app_key
);
ilevel
+
1
,
flags
,
cb
,
app_key
);
if
(
tmper
.
encoded
==
-
1
)
{
if
(
tmper
.
encoded
==
-
1
)
{
td
=
tmper
.
failed_type
;
td
=
tmper
.
failed_type
;
...
@@ -688,8 +692,8 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
...
@@ -688,8 +692,8 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
goto
cb_failed
;
goto
cb_failed
;
}
}
if
(
tmper
.
encoded
==
0
&&
specs
->
as_XMLValueList
)
{
if
(
tmper
.
encoded
==
0
&&
specs
->
as_XMLValueList
)
{
const
char
*
name
=
(
*
el
ement
->
name
)
const
char
*
name
=
(
*
el
m
->
name
)
?
el
ement
->
name
:
element
->
type
->
xml_tag
;
?
el
m
->
name
:
elm
->
type
->
xml_tag
;
size_t
len
=
strlen
(
name
);
size_t
len
=
strlen
(
name
);
_ASN_CALLBACK3
(
"<"
,
1
,
name
,
len
,
"/>"
,
2
);
_ASN_CALLBACK3
(
"<"
,
1
,
name
,
len
,
"/>"
,
2
);
}
}
...
@@ -741,7 +745,7 @@ cleanup:
...
@@ -741,7 +745,7 @@ cleanup:
int
int
SET_OF_print
(
asn_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
int
ilevel
,
SET_OF_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_TYPE_member_t
*
el
ement
=
td
->
elements
;
asn_TYPE_member_t
*
el
m
=
td
->
elements
;
const
asn_anonymous_set_
*
list
=
_A_CSET_FROM_VOID
(
sptr
);
const
asn_anonymous_set_
*
list
=
_A_CSET_FROM_VOID
(
sptr
);
int
ret
;
int
ret
;
int
i
;
int
i
;
...
@@ -759,7 +763,7 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
...
@@ -759,7 +763,7 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
_i_INDENT
(
1
);
_i_INDENT
(
1
);
ret
=
el
ement
->
type
->
print_struct
(
element
->
type
,
memb_ptr
,
ret
=
el
m
->
type
->
print_struct
(
elm
->
type
,
memb_ptr
,
ilevel
+
1
,
cb
,
app_key
);
ilevel
+
1
,
cb
,
app_key
);
if
(
ret
)
return
ret
;
if
(
ret
)
return
ret
;
}
}
...
@@ -773,7 +777,7 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
...
@@ -773,7 +777,7 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
void
void
SET_OF_free
(
asn_TYPE_descriptor_t
*
td
,
void
*
ptr
,
int
contents_only
)
{
SET_OF_free
(
asn_TYPE_descriptor_t
*
td
,
void
*
ptr
,
int
contents_only
)
{
if
(
td
&&
ptr
)
{
if
(
td
&&
ptr
)
{
asn_TYPE_member_t
*
el
ement
=
td
->
elements
;
asn_TYPE_member_t
*
el
m
=
td
->
elements
;
asn_anonymous_set_
*
list
=
_A_SET_FROM_VOID
(
ptr
);
asn_anonymous_set_
*
list
=
_A_SET_FROM_VOID
(
ptr
);
int
i
;
int
i
;
...
@@ -784,7 +788,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
...
@@ -784,7 +788,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
for
(
i
=
0
;
i
<
list
->
count
;
i
++
)
{
for
(
i
=
0
;
i
<
list
->
count
;
i
++
)
{
void
*
memb_ptr
=
list
->
array
[
i
];
void
*
memb_ptr
=
list
->
array
[
i
];
if
(
memb_ptr
)
if
(
memb_ptr
)
el
ement
->
type
->
free_struct
(
element
->
type
,
memb_ptr
,
0
);
el
m
->
type
->
free_struct
(
elm
->
type
,
memb_ptr
,
0
);
}
}
list
->
count
=
0
;
/* No meaningful elements left */
list
->
count
=
0
;
/* No meaningful elements left */
...
@@ -799,7 +803,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
...
@@ -799,7 +803,7 @@ SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
int
int
SET_OF_constraint
(
asn_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
SET_OF_constraint
(
asn_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
asn_app_consume_bytes_f
*
app_errlog
,
void
*
app_key
)
{
asn_app_consume_bytes_f
*
app_errlog
,
void
*
app_key
)
{
asn_TYPE_member_t
*
el
ement
=
td
->
elements
;
asn_TYPE_member_t
*
el
m
=
td
->
elements
;
asn_constr_check_f
*
constr
;
asn_constr_check_f
*
constr
;
const
asn_anonymous_set_
*
list
=
_A_CSET_FROM_VOID
(
sptr
);
const
asn_anonymous_set_
*
list
=
_A_CSET_FROM_VOID
(
sptr
);
int
i
;
int
i
;
...
@@ -811,8 +815,8 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -811,8 +815,8 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return
-
1
;
return
-
1
;
}
}
constr
=
el
ement
->
memb_constraints
;
constr
=
el
m
->
memb_constraints
;
if
(
!
constr
)
constr
=
el
ement
->
type
->
check_constraints
;
if
(
!
constr
)
constr
=
el
m
->
type
->
check_constraints
;
/*
/*
* Iterate over the members of an array.
* Iterate over the members of an array.
...
@@ -824,7 +828,7 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -824,7 +828,7 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
if
(
!
memb_ptr
)
continue
;
if
(
!
memb_ptr
)
continue
;
ret
=
constr
(
el
ement
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
ret
=
constr
(
el
m
->
type
,
memb_ptr
,
app_errlog
,
app_key
);
if
(
ret
)
return
ret
;
if
(
ret
)
return
ret
;
}
}
...
@@ -832,8 +836,8 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -832,8 +836,8 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
* Cannot inherit it eralier:
* Cannot inherit it eralier:
* need to make sure we get the updated version.
* need to make sure we get the updated version.
*/
*/
if
(
!
el
ement
->
memb_constraints
)
if
(
!
el
m
->
memb_constraints
)
el
ement
->
memb_constraints
=
element
->
type
->
check_constraints
;
el
m
->
memb_constraints
=
elm
->
type
->
check_constraints
;
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment