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
6fec44d9
Commit
6fec44d9
authored
Aug 22, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring
parent
4ec3b4c0
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
73 additions
and
114 deletions
+73
-114
libasn1compiler/asn1c_out.h
libasn1compiler/asn1c_out.h
+2
-0
libasn1compiler/asn1compiler.c
libasn1compiler/asn1compiler.c
+8
-0
libasn1fix/asn1fix_bitstring.c
libasn1fix/asn1fix_bitstring.c
+1
-1
libasn1fix/asn1fix_class.c
libasn1fix/asn1fix_class.c
+2
-4
libasn1fix/asn1fix_class.h
libasn1fix/asn1fix_class.h
+2
-3
libasn1fix/asn1fix_constraint.c
libasn1fix/asn1fix_constraint.c
+10
-12
libasn1fix/asn1fix_constraint.h
libasn1fix/asn1fix_constraint.h
+2
-1
libasn1fix/asn1fix_dereft.c
libasn1fix/asn1fix_dereft.c
+1
-30
libasn1fix/asn1fix_export.c
libasn1fix/asn1fix_export.c
+7
-9
libasn1fix/asn1fix_export.h
libasn1fix/asn1fix_export.h
+3
-3
libasn1fix/asn1fix_integer.c
libasn1fix/asn1fix_integer.c
+3
-3
libasn1fix/asn1fix_param.c
libasn1fix/asn1fix_param.c
+3
-3
libasn1fix/asn1fix_retrieve.c
libasn1fix/asn1fix_retrieve.c
+18
-30
libasn1fix/asn1fix_retrieve.h
libasn1fix/asn1fix_retrieve.h
+5
-8
libasn1fix/asn1fix_tags.c
libasn1fix/asn1fix_tags.c
+2
-2
libasn1fix/asn1fix_value.c
libasn1fix/asn1fix_value.c
+4
-5
No files found.
libasn1compiler/asn1c_out.h
View file @
6fec44d9
...
...
@@ -69,6 +69,8 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
_tmp.default_cb(&_tmp); \
); \
arg->embed--; \
if(ev->expr_type != A1TC_EXTENSIBLE) \
OUT(";\n"); \
assert(arg->target->target == OT_TYPE_DECLS); \
REDIR(saved_target); \
} while(0)
...
...
libasn1compiler/asn1compiler.c
View file @
6fec44d9
...
...
@@ -84,6 +84,9 @@ asn1c_compile_expr(arg_t *arg) {
expr
->
_lineno
);
ret
=
type_cb
(
arg
);
if
(
arg
->
target
->
destination
[
OT_TYPE_DECLS
].
indent_level
==
0
)
OUT
(
";
\n
"
);
}
else
{
ret
=
-
1
;
/*
...
...
@@ -112,6 +115,11 @@ asn1c_compile_expr(arg_t *arg) {
}
if
(
ret
==
-
1
)
{
FATAL
(
"Cannot compile
\"
%s
\"
(%x:%x) at line %d"
,
arg
->
expr
->
Identifier
,
arg
->
expr
->
expr_type
,
arg
->
expr
->
meta_type
,
arg
->
expr
->
_lineno
);
OUT
(
"#error Cannot compile
\"
%s
\"
(%x/%x) at line %d
\n
"
,
arg
->
expr
->
Identifier
,
arg
->
expr
->
meta_type
,
...
...
libasn1fix/asn1fix_bitstring.c
View file @
6fec44d9
...
...
@@ -16,7 +16,7 @@ asn1f_fix_bit_string(arg_t *arg) {
DEBUG
(
"%s(%s) for line %d"
,
__func__
,
expr
->
Identifier
,
expr
->
_lineno
);
ttype
=
asn1f_find_terminal_type
(
arg
,
expr
,
0
);
ttype
=
asn1f_find_terminal_type
(
arg
,
expr
);
if
(
ttype
&&
ttype
->
expr_type
==
ASN_BASIC_BIT_STRING
)
{
ret
=
asn1f_fix_bit_string_value
(
arg
,
ttype
);
RET2RVAL
(
ret
,
r_value
);
...
...
libasn1fix/asn1fix_class.c
View file @
6fec44d9
...
...
@@ -23,15 +23,13 @@ static asn1p_expr_t *
asn1f_class_dot_lookup
(
arg_t
*
arg
,
asn1p_expr_t
*
obj
,
asn1p_ref_t
*
ref
);
asn1p_expr_t
*
asn1f_class_access
(
arg_t
*
arg
,
asn1p_
ref_t
*
ref
,
asn1p_module_t
**
mod_r
)
{
asn1f_class_access
(
arg_t
*
arg
,
asn1p_
module_t
*
mod
,
asn1p_ref_t
*
ref
)
{
asn1p_expr_t
*
obj
;
/* Information Object or Object Set */
object_category_e
obj_cat
;
/* Object category */
//field_category_e field_cat; /* Field category */
asn1p_expr_t
*
result
;
asn1p_ref_t
tmpref
;
(
void
)
mod_r
;
/* Unused argument */
assert
(
ref
->
comp_count
>
1
);
DEBUG
(
"%s(%s) for line %d"
,
__func__
,
...
...
@@ -47,7 +45,7 @@ asn1f_class_access(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **mod_r) {
tmpref
=
*
ref
;
tmpref
.
comp_count
=
1
;
obj
=
asn1f_lookup_symbol
(
arg
,
&
tmpref
,
0
);
obj
=
asn1f_lookup_symbol
(
arg
,
mod
,
&
tmpref
);
if
(
obj
==
NULL
)
{
errno
=
ESRCH
;
return
NULL
;
...
...
libasn1fix/asn1fix_class.h
View file @
6fec44d9
...
...
@@ -4,13 +4,12 @@
/*
* Fetch the element from the class-related stuff (thing) by its reference.
*/
asn1p_expr_t
*
asn1f_class_access
(
arg_t
*
,
asn1p_ref_t
*
,
asn1p_module_t
**
mod_r
);
asn1p_expr_t
*
asn1f_class_access
(
arg_t
*
,
asn1p_module_t
*
mod
,
asn1p_ref_t
*
);
/*
* Externally accessible version of above function.
*/
asn1p_expr_t
*
asn1f_class_access2
(
asn1p_t
*
asn
,
asn1p_module_t
*
mod
,
asn1p_expr_t
*
expr
,
asn1p_ref_t
*
,
asn1p_module_t
**
mod_r
);
asn1p_expr_t
*
expr
,
asn1p_ref_t
*
);
#endif
/* _ASN1FIX_CLASS_H_ */
libasn1fix/asn1fix_constraint.c
View file @
6fec44d9
...
...
@@ -3,7 +3,7 @@
#include <asn1fix_crange.h>
static
void
_remove_exceptions
(
arg_t
*
arg
,
asn1p_constraint_t
*
ct
);
static
int
_constraint_value_resolve
(
arg_t
*
arg
,
asn1p_value_t
**
value
);
static
int
_constraint_value_resolve
(
arg_t
*
arg
,
asn1p_
module_t
*
mod
,
asn1p_
value_t
**
value
);
int
asn1constraint_pullup
(
arg_t
*
arg
)
{
...
...
@@ -25,11 +25,10 @@ asn1constraint_pullup(arg_t *arg) {
if
(
expr
->
expr_type
==
A1TC_REFERENCE
)
{
asn1p_ref_t
*
ref
=
expr
->
reference
;
asn1p_module_t
*
mod_rw
=
arg
->
mod
;
asn1p_expr_t
*
parent_expr
;
assert
(
ref
);
parent_expr
=
asn1f_lookup_symbol
(
arg
,
ref
,
&
mod_rw
);
parent_expr
=
asn1f_lookup_symbol
(
arg
,
expr
->
module
,
ref
);
if
(
!
parent_expr
)
{
if
(
errno
!=
EEXIST
)
{
DEBUG
(
"
\t
While fetching parent constraints: "
...
...
@@ -120,7 +119,7 @@ asn1constraint_pullup(arg_t *arg) {
}
int
asn1constraint_resolve
(
arg_t
*
arg
,
asn1p_constraint_t
*
ct
,
asn1p_expr_type_e
etype
,
enum
asn1p_constraint_type_e
effective_type
)
{
asn1constraint_resolve
(
arg_t
*
arg
,
asn1p_
module_t
*
mod
,
asn1p_
constraint_t
*
ct
,
asn1p_expr_type_e
etype
,
enum
asn1p_constraint_type_e
effective_type
)
{
int
rvalue
=
0
;
int
ret
;
int
el
;
...
...
@@ -183,15 +182,15 @@ asn1constraint_resolve(arg_t *arg, asn1p_constraint_t *ct, asn1p_expr_type_e ety
* Resolve all possible references, wherever they occur.
*/
if
(
ct
->
value
&&
ct
->
value
->
type
==
ATV_REFERENCED
)
{
ret
=
_constraint_value_resolve
(
arg
,
&
ct
->
value
);
ret
=
_constraint_value_resolve
(
arg
,
mod
,
&
ct
->
value
);
RET2RVAL
(
ret
,
rvalue
);
}
if
(
ct
->
range_start
&&
ct
->
range_start
->
type
==
ATV_REFERENCED
)
{
ret
=
_constraint_value_resolve
(
arg
,
&
ct
->
range_start
);
ret
=
_constraint_value_resolve
(
arg
,
mod
,
&
ct
->
range_start
);
RET2RVAL
(
ret
,
rvalue
);
}
if
(
ct
->
range_stop
&&
ct
->
range_stop
->
type
==
ATV_REFERENCED
)
{
ret
=
_constraint_value_resolve
(
arg
,
&
ct
->
range_stop
);
ret
=
_constraint_value_resolve
(
arg
,
mod
,
&
ct
->
range_stop
);
RET2RVAL
(
ret
,
rvalue
);
}
...
...
@@ -199,7 +198,7 @@ asn1constraint_resolve(arg_t *arg, asn1p_constraint_t *ct, asn1p_expr_type_e ety
* Proceed recursively.
*/
for
(
el
=
0
;
el
<
ct
->
el_count
;
el
++
)
{
ret
=
asn1constraint_resolve
(
arg
,
ct
->
elements
[
el
],
ret
=
asn1constraint_resolve
(
arg
,
mod
,
ct
->
elements
[
el
],
etype
,
effective_type
);
RET2RVAL
(
ret
,
rvalue
);
}
...
...
@@ -230,15 +229,14 @@ _remove_exceptions(arg_t *arg, asn1p_constraint_t *ct) {
static
int
_constraint_value_resolve
(
arg_t
*
arg
,
asn1p_value_t
**
value
)
{
_constraint_value_resolve
(
arg_t
*
arg
,
asn1p_
module_t
*
mod
,
asn1p_
value_t
**
value
)
{
asn1p_expr_t
static_expr
;
asn1p_expr_t
*
tmp_expr
;
asn1p_module_t
*
mod_rw
=
arg
->
mod
;
arg_t
tmp_arg
;
int
rvalue
=
0
;
int
ret
;
tmp_expr
=
asn1f_lookup_symbol
(
arg
,
(
*
value
)
->
value
.
reference
,
&
mod_rw
);
tmp_expr
=
asn1f_lookup_symbol
(
arg
,
mod
,
(
*
value
)
->
value
.
reference
);
if
(
tmp_expr
==
NULL
)
{
FATAL
(
"Cannot find symbol %s "
"used in %s subtype constraint at line %d"
,
...
...
@@ -251,7 +249,7 @@ _constraint_value_resolve(arg_t *arg, asn1p_value_t **value) {
static_expr
=
*
tmp_expr
;
static_expr
.
value
=
*
value
;
tmp_arg
=
*
arg
;
tmp_arg
.
mod
=
mod_rw
;
tmp_arg
.
mod
=
tmp_expr
->
module
;
tmp_arg
.
expr
=
&
static_expr
;
ret
=
asn1f_fix_dereference_values
(
&
tmp_arg
);
RET2RVAL
(
ret
,
rvalue
);
...
...
libasn1fix/asn1fix_constraint.h
View file @
6fec44d9
...
...
@@ -4,7 +4,8 @@
/*
* Resolve referenced values inside constraints.
*/
int
asn1constraint_resolve
(
arg_t
*
arg
,
asn1p_constraint_t
*
ct
,
int
asn1constraint_resolve
(
arg_t
*
arg
,
asn1p_module_t
*
module
,
asn1p_constraint_t
*
ct
,
asn1p_expr_type_e
topmost_parent_expression_type
,
enum
asn1p_constraint_type_e
effective_constraint_type
);
...
...
libasn1fix/asn1fix_dereft.c
View file @
6fec44d9
...
...
@@ -26,7 +26,7 @@ asn1f_fix_dereference_types(arg_t *arg) {
/*
* Follow the reference.
*/
type_expr
=
asn1f_find_terminal_type
(
arg
,
expr
,
0
);
type_expr
=
asn1f_find_terminal_type
(
arg
,
expr
);
if
(
type_expr
==
NULL
)
{
const
char
*
type_name
;
...
...
@@ -44,35 +44,6 @@ asn1f_fix_dereference_types(arg_t *arg) {
return
-
1
;
}
/*
* Copying members of the source expression
* into the current expression.
*/
if
(
0
)
{
asn1p_expr_t
*
tmp_clone
;
tmp_clone
=
asn1p_expr_clone
(
type_expr
);
if
(
tmp_clone
==
NULL
)
{
FATAL
(
"Could not clone
\"
%s
\"
at line %d"
,
type_expr
->
Identifier
,
type_expr
->
_lineno
);
return
-
1
;
}
/*
* Replace the referenced type with its definition.
*/
DEBUG
(
"
\t
Changing type of
\"
%s
\"
:%x to %x for line %d"
,
expr
->
Identifier
,
expr
->
expr_type
,
type_expr
->
expr_type
,
expr
->
_lineno
);
expr
->
expr_type
=
type_expr
->
expr_type
;
expr
->
members
=
tmp_clone
->
members
;
memset
(
&
tmp_clone
->
members
,
0
,
sizeof
(
tmp_clone
->
members
));
asn1p_expr_free
(
tmp_clone
);
}
return
r_value
;
}
libasn1fix/asn1fix_export.c
View file @
6fec44d9
...
...
@@ -7,7 +7,7 @@ extern arg_t a1f_replace_me_with_proper_interface_arg;
asn1p_expr_t
*
asn1f_lookup_symbol_ex
(
asn1p_t
*
asn
,
asn1p_module_t
*
*
module_rw
,
asn1p_module_t
*
mod
,
asn1p_expr_t
*
expr
,
asn1p_ref_t
*
ref
)
{
arg_t
arg
;
...
...
@@ -15,21 +15,20 @@ asn1f_lookup_symbol_ex(
memset
(
&
arg
,
0
,
sizeof
(
arg
));
arg
.
asn
=
asn
;
arg
.
mod
=
*
module_rw
;
arg
.
mod
=
mod
;
arg
.
expr
=
expr
;
arg
.
eh
=
a1f_replace_me_with_proper_interface_arg
.
eh
;
arg
.
debug
=
a1f_replace_me_with_proper_interface_arg
.
debug
;
return
asn1f_lookup_symbol
(
&
arg
,
ref
,
module_rw
);
return
asn1f_lookup_symbol
(
&
arg
,
mod
,
ref
);
}
asn1p_expr_t
*
asn1f_class_access_ex
(
asn1p_t
*
asn
,
asn1p_module_t
*
mod
,
asn1p_expr_t
*
expr
,
asn1p_ref_t
*
ref
,
asn1p_module_t
**
mod_r
)
{
asn1p_ref_t
*
ref
)
{
arg_t
arg
;
memset
(
&
arg
,
0
,
sizeof
(
arg
));
...
...
@@ -40,14 +39,13 @@ asn1f_class_access_ex(asn1p_t *asn,
arg
.
eh
=
a1f_replace_me_with_proper_interface_arg
.
eh
;
arg
.
debug
=
a1f_replace_me_with_proper_interface_arg
.
debug
;
return
asn1f_class_access
(
&
arg
,
ref
,
mod_r
);
return
asn1f_class_access
(
&
arg
,
mod
,
ref
);
}
asn1p_expr_t
*
asn1f_find_terminal_type_ex
(
asn1p_t
*
asn
,
asn1p_module_t
*
mod
,
asn1p_expr_t
*
expr
,
asn1p_module_t
**
mod_r
)
{
asn1p_expr_t
*
expr
)
{
arg_t
arg
;
memset
(
&
arg
,
0
,
sizeof
(
arg
));
...
...
@@ -58,7 +56,7 @@ asn1f_find_terminal_type_ex(asn1p_t *asn,
arg
.
eh
=
a1f_replace_me_with_proper_interface_arg
.
eh
;
arg
.
debug
=
a1f_replace_me_with_proper_interface_arg
.
debug
;
return
asn1f_find_terminal_type
(
&
arg
,
expr
,
mod_r
);
return
asn1f_find_terminal_type
(
&
arg
,
expr
);
}
int
...
...
libasn1fix/asn1fix_export.h
View file @
6fec44d9
...
...
@@ -18,7 +18,7 @@ char const *asn1f_printable_value(asn1p_value_t *value);
*/
asn1p_expr_t
*
asn1f_lookup_symbol_ex
(
asn1p_t
*
asn
,
asn1p_module_t
*
*
module_rw
,
asn1p_module_t
*
mod
,
asn1p_expr_t
*
expr
,
asn1p_ref_t
*
ref
);
...
...
@@ -26,13 +26,13 @@ asn1p_expr_t *asn1f_lookup_symbol_ex(
* Exportable version of an asn1f_class_access().
*/
asn1p_expr_t
*
asn1f_class_access_ex
(
asn1p_t
*
asn
,
asn1p_module_t
*
mod
,
asn1p_expr_t
*
expr
,
asn1p_ref_t
*
,
asn1p_module_t
**
mod_r
);
asn1p_expr_t
*
expr
,
asn1p_ref_t
*
);
/*
* Exportable version of asn1f_find_terminal_type().
*/
asn1p_expr_t
*
asn1f_find_terminal_type_ex
(
asn1p_t
*
asn
,
asn1p_module_t
*
mod
,
asn1p_expr_t
*
tc
,
asn1p_module_t
**
opt_module_r
);
asn1p_expr_t
*
tc
);
/*
* Exportable version of asn1f_fix_dereference_values();
...
...
libasn1fix/asn1fix_integer.c
View file @
6fec44d9
...
...
@@ -112,7 +112,6 @@ asn1f_fix_integer(arg_t *arg) {
static
int
_asn1f_make_sure_type_is
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
asn1p_expr_type_e
type
)
{
asn1p_module_t
*
mod
=
NULL
;
asn1p_expr_t
*
next_expr
;
asn1p_expr_type_e
expr_type
;
int
ret
;
...
...
@@ -144,7 +143,7 @@ _asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type)
* Then, it is a reference. For a reference, try to resolve type
* and try again.
*/
next_expr
=
asn1f_lookup_symbol
(
arg
,
expr
->
reference
,
&
mod
);
next_expr
=
asn1f_lookup_symbol
(
arg
,
expr
->
module
,
expr
->
reference
);
if
(
next_expr
==
NULL
)
{
errno
=
ESRCH
;
return
-
1
;
...
...
@@ -153,7 +152,8 @@ _asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type)
/*
* If symbol is here, recursively check that it conforms to the type.
*/
WITH_MODULE
(
mod
,
ret
=
_asn1f_make_sure_type_is
(
arg
,
next_expr
,
type
));
WITH_MODULE
(
next_expr
->
module
,
ret
=
_asn1f_make_sure_type_is
(
arg
,
next_expr
,
type
));
return
ret
;
}
...
...
libasn1fix/asn1fix_param.c
View file @
6fec44d9
...
...
@@ -23,7 +23,7 @@ asn1f_fix_parametrized_assignment(arg_t *arg) {
*/
DEBUG
(
"Looking for parametrized type definition
\"
%s
\"
"
,
asn1f_printable_reference
(
expr
->
reference
));
ptype
=
asn1f_lookup_symbol
(
arg
,
expr
->
reference
,
0
);
ptype
=
asn1f_lookup_symbol
(
arg
,
expr
->
module
,
expr
->
reference
);
if
(
ptype
==
NULL
)
{
DEBUG
(
"%s: missing parametrized type declaration"
,
asn1f_printable_reference
(
expr
->
reference
));
...
...
@@ -81,7 +81,7 @@ asn1f_parametrize(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype) {
* with the actual values.
*/
nex
=
asn1p_expr_clone
(
ptype
);
nex
=
asn1p_expr_clone
(
ptype
,
0
);
if
(
nex
==
NULL
)
return
-
1
;
/*
...
...
@@ -131,7 +131,7 @@ asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptyp
assert
(
child
->
meta_type
==
AMT_TYPEREF
);
assert
(
child
->
expr_type
==
A1TC_REFERENCE
);
ne
=
asn1p_expr_clone
(
ra
);
ne
=
asn1p_expr_clone
(
ra
,
0
);
if
(
ne
==
NULL
)
return
-
1
;
assert
(
ne
->
Identifier
==
0
);
ne
->
Identifier
=
strdup
(
child
->
Identifier
);
...
...
libasn1fix/asn1fix_retrieve.c
View file @
6fec44d9
#include "asn1fix_internal.h"
static
asn1p_expr_t
*
asn1f_find_terminal_thing
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
asn1p_module_t
**
optm
,
int
type_or_value
);
static
asn1p_expr_t
*
asn1f_find_terminal_thing
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
int
type_or_value
);
static
int
asn1f_compatible_with_exports
(
arg_t
*
arg
,
asn1p_module_t
*
mod
,
const
char
*
name
);
...
...
@@ -135,7 +135,7 @@ asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) {
asn1p_expr_t
*
asn1f_lookup_symbol
(
arg_t
*
arg
,
asn1p_
ref_t
*
ref
,
asn1p_module_t
**
module_r
)
{
asn1f_lookup_symbol
(
arg_t
*
arg
,
asn1p_
module_t
*
mod
,
asn1p_ref_t
*
ref
)
{
asn1p_expr_t
*
ref_tc
;
/* Referenced tc */
asn1p_module_t
*
src_mod
;
char
*
modulename
;
...
...
@@ -155,7 +155,7 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
DEBUG
(
"%s(%s) in %s for line %d"
,
__func__
,
asn1f_printable_reference
(
ref
),
arg
->
mod
->
Identifier
,
mod
->
Identifier
,
ref
->
_lineno
);
if
(
ref
->
comp_count
==
1
)
{
...
...
@@ -173,7 +173,7 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
* This is a reference to a CLASS-related stuff.
* Employ a separate function for that.
*/
extract
=
asn1f_class_access
(
arg
,
ref
,
module_r
);
extract
=
asn1f_class_access
(
arg
,
mod
,
ref
);
return
extract
;
}
else
{
...
...
@@ -216,7 +216,7 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
}
}
if
(
src_mod
==
0
)
src_mod
=
arg
->
mod
;
if
(
src_mod
==
0
)
src_mod
=
mod
;
/*
* Now we know where to search for a value.
...
...
@@ -242,29 +242,22 @@ asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) {
return
NULL
;
}
if
(
module_r
)
*
module_r
=
src_mod
;
return
ref_tc
;
}
asn1p_expr_t
*
asn1f_find_terminal_type
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
asn1p_module_t
**
optm
)
{
return
asn1f_find_terminal_thing
(
arg
,
expr
,
optm
,
0
);
asn1f_find_terminal_type
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
return
asn1f_find_terminal_thing
(
arg
,
expr
,
0
);
}
asn1p_expr_t
*
asn1f_find_terminal_value
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
asn1p_module_t
**
optm
)
{
return
asn1f_find_terminal_thing
(
arg
,
expr
,
optm
,
1
);
asn1f_find_terminal_value
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
return
asn1f_find_terminal_thing
(
arg
,
expr
,
1
);
}
static
asn1p_expr_t
*
asn1f_find_terminal_thing
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
asn1p_module_t
**
optm
,
int
type_or_value
)
{
asn1p_module_t
*
mod
;
asn1f_find_terminal_thing
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
int
type_or_value
)
{
asn1p_ref_t
*
ref
;
asn1p_expr_t
*
tc
;
...
...
@@ -272,19 +265,15 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
/* VALUE */
assert
(
expr
->
meta_type
==
AMT_VALUE
);
assert
(
expr
->
value
);
if
(
expr
->
value
->
type
!=
ATV_REFERENCED
)
{
/* Expression is a terminal value itself */
if
(
optm
)
*
optm
=
arg
->
mod
;
/* Expression may be a terminal type itself */
if
(
expr
->
value
->
type
!=
ATV_REFERENCED
)
return
expr
;
}
ref
=
expr
->
value
->
value
.
reference
;
}
else
{
/* TYPE */
if
(
expr
->
expr_type
!=
A1TC_REFERENCE
)
{
/* Expression is a terminal type itself */
if
(
optm
)
*
optm
=
arg
->
mod
;
/* Expression may be a terminal type itself */
if
(
expr
->
expr_type
!=
A1TC_REFERENCE
)
return
expr
;
}
ref
=
expr
->
reference
;
}
...
...
@@ -300,12 +289,11 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
*/
if
(
type_or_value
)
{
asn1p_expr_t
*
val_type_tc
;
val_type_tc
=
asn1f_find_terminal_type
(
arg
,
expr
,
0
);
val_type_tc
=
asn1f_find_terminal_type
(
arg
,
expr
);
if
(
val_type_tc
&&
asn1f_look_value_in_type
(
arg
,
val_type_tc
,
expr
))
return
NULL
;
if
(
expr
->
value
->
type
!=
ATV_REFERENCED
)
{
if
(
optm
)
*
optm
=
arg
->
mod
;
return
expr
;
}
assert
(
ref
==
expr
->
value
->
value
.
reference
);
...
...
@@ -315,7 +303,7 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
/*
* Lookup inside the default module.
*/
tc
=
asn1f_lookup_symbol
(
arg
,
ref
,
&
mod
);
tc
=
asn1f_lookup_symbol
(
arg
,
expr
->
module
,
ref
);
if
(
tc
==
NULL
)
{
DEBUG
(
"
\t
Symbol
\"
%s
\"
not found: %s"
,
asn1f_printable_reference
(
ref
),
...
...
@@ -334,8 +322,8 @@ asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr,
}
tc
->
_mark
|=
TM_RECURSION
;
WITH_MODULE
(
mod
,
expr
=
asn1f_find_terminal_thing
(
arg
,
tc
,
optm
,
type_or_value
));
WITH_MODULE
(
tc
->
module
,
expr
=
asn1f_find_terminal_thing
(
arg
,
tc
,
type_or_value
));
tc
->
_mark
&=
~
TM_RECURSION
;
return
expr
;
...
...
libasn1fix/asn1fix_retrieve.h
View file @
6fec44d9
...
...
@@ -36,11 +36,10 @@ asn1p_module_t *asn1f_lookup_module(arg_t *arg,
/*
* Return the reference to a destination of the given reference,
* symbol lookup. Not a recursive function.
* Optional module reference may be assigned a module in which the
* particular expr was found.
*/
asn1p_expr_t
*
asn1f_lookup_symbol
(
arg_t
*
arg
,
asn1p_ref_t
*
ref
,
asn1p_module_t
**
opt_module_r
);
asn1p_expr_t
*
asn1f_lookup_symbol
(
arg_t
*
arg
,
asn1p_module_t
*
mod
,
asn1p_ref_t
*
ref
);
/*
* Recursively find the original type for the given expression.
...
...
@@ -54,8 +53,7 @@ asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref,
* would return an expression for Type4.
* WARNING: No attempts are made to honor constraints at this moment.
*/
asn1p_expr_t
*
asn1f_find_terminal_type
(
arg_t
*
arg
,
asn1p_expr_t
*
tc
,
asn1p_module_t
**
opt_module_r
);
asn1p_expr_t
*
asn1f_find_terminal_type
(
arg_t
*
arg
,
asn1p_expr_t
*
tc
);
/*
* Recursively find the original value for the given expression.
...
...
@@ -67,7 +65,6 @@ asn1p_expr_t *asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *tc,
* Then this function will return the expression for value2 if given
* the v as an argment.
*/
asn1p_expr_t
*
asn1f_find_terminal_value
(
arg_t
*
arg
,
asn1p_expr_t
*
tc
,
asn1p_module_t
**
opt_module_r
);
asn1p_expr_t
*
asn1f_find_terminal_value
(
arg_t
*
arg
,
asn1p_expr_t
*
tc
);
#endif
/* _ASN1FIX_RETRIEVE_H_ */
libasn1fix/asn1fix_tags.c
View file @
6fec44d9
...
...
@@ -30,14 +30,14 @@ asn1f_fetch_tag(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, struct as
arg
.
mod
=
mod
;
arg
.
expr
=
expr
;
expr
=
asn1f_lookup_symbol
(
&
arg
,
expr
->
reference
,
&
mod
);
expr
=
asn1f_lookup_symbol
(
&
arg
,
expr
->
module
,
expr
->
reference
);
if
(
expr
==
NULL
)
return
-
1
;
if
(
expr
->
_mark
&
TM_RECURSION
)
return
-
1
;
expr
->
_mark
|=
TM_RECURSION
;
ret
=
asn1f_fetch_tag
(
asn
,
mod
,
expr
,
tag
);
ret
=
asn1f_fetch_tag
(
asn
,
expr
->
module
,
expr
,
tag
);
expr
->
_mark
&=
~
TM_RECURSION
;
return
ret
;
}
...
...
libasn1fix/asn1fix_value.c
View file @
6fec44d9
...
...
@@ -4,7 +4,6 @@ static int _asn1f_copy_value(arg_t *arg, asn1p_expr_t *to,asn1p_expr_t *from);
int
asn1f_value_resolve
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
asn1p_module_t
*
val_mod
;
asn1p_expr_t
*
val_type_expr
;
asn1p_expr_t
*
value_expr
;
asn1p_expr_t
*
type_expr
;
...
...
@@ -20,7 +19,7 @@ asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) {
/*
* 1. Find the terminal type for this assignment.
*/
type_expr
=
asn1f_find_terminal_type
(
arg
,
expr
,
0
);
type_expr
=
asn1f_find_terminal_type
(
arg
,
expr
);
DEBUG
(
"%s(): terminal type %p"
,
__func__
,
type_expr
);
if
(
type_expr
==
0
)
{
DEBUG
(
"
\t
Terminal type for %s not found"
,
expr
->
Identifier
);
...
...
@@ -33,7 +32,7 @@ asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) {
/*
* 2. Find the terminal value also.
*/
value_expr
=
asn1f_find_terminal_value
(
arg
,
expr
,
&
val_mod
);
value_expr
=
asn1f_find_terminal_value
(
arg
,
expr
);
if
(
value_expr
)
{
DEBUG
(
"
\t
Terminal value for %s->%s is %s at line %d"
,
expr
->
Identifier
,
asn1f_printable_value
(
expr
->
value
),
...
...
@@ -47,8 +46,8 @@ asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) {
/*
* 3. Find the _type_ of a _terminal value_.
*/
WITH_MODULE
(
val
_mod
,
val_type_expr
=
asn1f_find_terminal_type
(
arg
,
value_expr
,
0
));
WITH_MODULE
(
val
ue_expr
->
module
,
val_type_expr
=
asn1f_find_terminal_type
(
arg
,
value_expr
));
if
(
val_type_expr
)
{
DEBUG
(
"
\t
Terminal type of value %s->%s is %s at line %d"
,
expr
->
Identifier
,
asn1f_printable_value
(
expr
->
value
),
...
...
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