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
29ef59bb
Unverified
Commit
29ef59bb
authored
Nov 11, 2023
by
Mouse
Committed by
GitHub
Nov 11, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #138 from v0-e/with-successors-support
WITH SUCCESSORS/DESCENDANTS support
parents
84d3a59c
6d97ce95
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
203 additions
and
32 deletions
+203
-32
libasn1fix/asn1fix_export.c
libasn1fix/asn1fix_export.c
+1
-1
libasn1fix/asn1fix_retrieve.c
libasn1fix/asn1fix_retrieve.c
+23
-18
libasn1fix/asn1fix_retrieve.h
libasn1fix/asn1fix_retrieve.h
+1
-1
libasn1parser/asn1p_l.l
libasn1parser/asn1p_l.l
+2
-1
libasn1parser/asn1p_oid.c
libasn1parser/asn1p_oid.c
+6
-9
libasn1parser/asn1p_oid.h
libasn1parser/asn1p_oid.h
+0
-1
libasn1parser/asn1p_xports.h
libasn1parser/asn1p_xports.h
+5
-0
libasn1parser/asn1p_y.y
libasn1parser/asn1p_y.y
+21
-1
tests/tests-asn1c-compiler/161-imports-with-successors-OK.asn1
.../tests-asn1c-compiler/161-imports-with-successors-OK.asn1
+36
-0
tests/tests-asn1c-compiler/161-imports-with-successors-SE.asn1
.../tests-asn1c-compiler/161-imports-with-successors-SE.asn1
+36
-0
tests/tests-asn1c-compiler/162-imports-with-successors-SE.asn1
.../tests-asn1c-compiler/162-imports-with-successors-SE.asn1
+36
-0
tests/tests-asn1c-compiler/163-imports-with-descendants-OK.asn1
...tests-asn1c-compiler/163-imports-with-descendants-OK.asn1
+36
-0
No files found.
libasn1fix/asn1fix_export.c
View file @
29ef59bb
...
...
@@ -42,7 +42,7 @@ asn1f_lookup_module_ex(asn1p_t *asn, const char *module_name,
arg
.
asn
=
asn
;
arg
.
eh
=
a1f_replace_me_with_proper_interface_arg
.
eh
;
arg
.
debug
=
a1f_replace_me_with_proper_interface_arg
.
debug
;
return
asn1f_lookup_module
(
&
arg
,
module_name
,
oid
);
return
asn1f_lookup_module
(
&
arg
,
module_name
,
oid
,
0
);
}
asn1p_expr_t
*
...
...
libasn1fix/asn1fix_retrieve.c
View file @
29ef59bb
...
...
@@ -53,7 +53,7 @@ asn1f_lookup_in_imports(arg_t *arg, asn1p_module_t *mod, const char *name) {
*/
TQ_FOR
(
xp
,
&
(
mod
->
imports
),
xp_next
)
{
asn1p_module_t
*
fromModule
=
asn1f_lookup_module
(
arg
,
xp
->
fromModuleName
,
NULL
);
asn1f_lookup_module
(
arg
,
xp
->
fromModuleName
,
NULL
,
0
);
asn1p_expr_t
*
tc
=
(
asn1p_expr_t
*
)
0
;
TQ_FOR
(
tc
,
&
(
xp
->
xp_members
),
next
)
{
...
...
@@ -78,7 +78,7 @@ asn1f_lookup_in_imports(arg_t *arg, asn1p_module_t *mod, const char *name) {
* Okay, right now we have a module name and, hopefully, an OID.
* Search the arg->asn for the specified module.
*/
mod
=
asn1f_lookup_module
(
arg
,
xp
->
fromModuleName
,
xp
->
identifier
.
oid
);
mod
=
asn1f_lookup_module
(
arg
,
xp
->
fromModuleName
,
xp
->
identifier
.
oid
,
xp
->
option
);
if
(
mod
==
NULL
)
{
/* Conditional debug */
if
(
!
(
arg
->
expr
->
_mark
&
TM_BROKEN
))
{
...
...
@@ -106,8 +106,8 @@ asn1f_lookup_in_imports(arg_t *arg, asn1p_module_t *mod, const char *name) {
}
asn1p_module_t
*
asn1f_lookup_module
(
arg_t
*
arg
,
const
char
*
module_name
,
const
asn1p_oid_t
*
oid
)
{
asn1p_module_t
*
mod
;
asn1f_lookup_module
(
arg_t
*
arg
,
const
char
*
module_name
,
const
asn1p_oid_t
*
oid
,
int
oid_option
)
{
asn1p_module_t
*
mod
,
*
ret
=
NULL
;
assert
(
module_name
);
...
...
@@ -149,27 +149,32 @@ asn1f_lookup_module(arg_t *arg, const char *module_name, const asn1p_oid_t *oid)
TQ_FOR
(
mod
,
&
(
arg
->
asn
->
modules
),
mod_next
)
{
if
(
oid
)
{
if
(
mod
->
module_oid
)
{
if
(
asn1p_oid_compare
(
oid
,
mod
->
module_oid
))
{
continue
;
}
else
{
int
r
=
asn1p_oid_compare
(
oid
,
mod
->
module_oid
);
if
(
oid_option
==
XPT_WITH_SUCCESSORS
)
{
if
(
r
==
oid
->
arcs_count
&&
r
==
mod
->
module_oid
->
arcs_count
)
/* positive and last arc */
r
=
0
;
}
else
if
(
oid_option
==
XPT_WITH_DESCENDANTS
)
{
if
(
oid
->
arcs_count
==
(
-
1
-
r
))
r
=
0
;
}
if
(
0
==
r
)
{
/* Match! Even if name doesn't. */
return
mod
;
oid
=
mod
->
module_oid
;
ret
=
mod
;
}
}
else
{
/* Not match, even if name is the same. */
continue
;
}
/* Not match, even if name is the same. */
continue
;
}
if
(
strcmp
(
module_name
,
mod
->
ModuleName
)
==
0
)
return
mod
;
}
DEBUG
(
"
\t
Module
\"
%s
\"
not found"
,
module_name
);
errno
=
ENOENT
;
return
NULL
;
if
(
ret
==
NULL
)
{
DEBUG
(
"
\t
Module
\"
%s
\"
not found"
,
module_name
);
errno
=
ENOENT
;
}
return
ret
;
}
static
asn1p_expr_t
*
...
...
@@ -268,7 +273,7 @@ asn1f_lookup_symbol_impl(arg_t *arg, asn1p_expr_t *rhs_pspecs, const asn1p_ref_t
* switch namespace to that module.
*/
if
(
modulename
)
{
imports_from
=
asn1f_lookup_module
(
arg
,
modulename
,
0
);
imports_from
=
asn1f_lookup_module
(
arg
,
modulename
,
0
,
0
);
if
(
imports_from
==
NULL
)
{
FATAL
(
"Module
\"
%s
\"
"
...
...
libasn1fix/asn1fix_retrieve.h
View file @
29ef59bb
...
...
@@ -31,7 +31,7 @@ asn1p_module_t *asn1f_lookup_in_imports(arg_t *arg, asn1p_module_t *mod, const c
*/
asn1p_module_t
*
asn1f_lookup_module
(
arg_t
*
arg
,
const
char
*
module_name
,
const
asn1p_oid_t
*
module_oid
);
const
asn1p_oid_t
*
module_oid
,
int
oid_option
);
/*
* Return the reference to a destination of the given reference,
...
...
libasn1parser/asn1p_l.l
View file @
29ef59bb
...
...
@@ -381,7 +381,8 @@ UTF8String {
VideotexString return TOK_VideotexString;
VisibleString return TOK_VisibleString;
WITH return TOK_WITH;
SUCCESSORS return TOK_SUCCESSORS;
DESCENDANTS return TOK_DESCENDANTS;
<INITIAL,with_syntax>&[A-Z][A-Za-z0-9]*([-][A-Za-z0-9]+)* {
asn1p_lval.tv_str = strdup(yytext);
...
...
libasn1parser/asn1p_oid.c
View file @
29ef59bb
...
...
@@ -89,26 +89,23 @@ asn1p_oid_compare(const asn1p_oid_t *a, const asn1p_oid_t *b) {
if
(
b
->
arcs_count
>
i
)
{
if
(
a
->
arcs_count
<=
i
)
return
-
1
;
return
-
1
-
i
;
}
else
if
(
a
->
arcs_count
>
i
)
{
if
(
b
->
arcs_count
<=
i
)
return
1
;
return
1
+
i
;
}
else
if
(
b
->
arcs_count
<=
i
&&
a
->
arcs_count
<=
i
)
{
cmp
=
b
->
arcs_count
-
a
->
arcs_count
;
if
(
cmp
<
0
)
return
-
1
;
return
-
1
-
i
;
else
if
(
cmp
>
0
)
return
1
;
return
1
+
i
;
return
0
;
}
cmp
=
b
->
arcs
[
i
].
number
-
a
->
arcs
[
i
].
number
;
if
(
cmp
<
0
)
return
-
1
;
return
-
1
-
i
;
else
if
(
cmp
>
0
)
return
1
;
return
1
+
i
;
}
}
libasn1parser/asn1p_oid.h
View file @
29ef59bb
...
...
@@ -63,5 +63,4 @@ void asn1p_oid_free(asn1p_oid_t *);
*/
int
asn1p_oid_compare
(
const
asn1p_oid_t
*
a
,
const
asn1p_oid_t
*
b
);
#endif
/* ASN1_PARSER_OID_H */
libasn1parser/asn1p_xports.h
View file @
29ef59bb
...
...
@@ -23,6 +23,11 @@ typedef struct asn1p_xports_s {
asn1p_value_t
*
value
;
/* DefinedValue */
}
identifier
;
enum
asn1p_import_option
{
XPT_WITH_SUCCESSORS
=
1
,
XPT_WITH_DESCENDANTS
}
option
;
/*
* Number of entities to import.
*/
...
...
libasn1parser/asn1p_y.y
View file @
29ef59bb
...
...
@@ -267,6 +267,8 @@ static asn1p_module_t *currentModule;
%token TOK_TwoDots ".."
%token TOK_ThreeDots "..."
%token TOK_SUCCESSORS
%token TOK_DESCENDANTS
/*
* Types defined herein.
...
...
@@ -286,6 +288,8 @@ static asn1p_module_t *currentModule;
%type <a_module> optImportsBundleSet
%type <a_module> ImportsBundleSet
%type <a_xports> ImportsBundle
%type <a_xports> ImportsBundleInt
%type <a_int> ImportSelectionOption
%type <a_xports> ImportsList
%type <a_xports> ExportsDefinition
%type <a_xports> ExportsBody
...
...
@@ -711,11 +715,19 @@ AssignedIdentifier:
| ObjectIdentifier { $$.oid = $1; };
/* | DefinedValue { $$.value = $1; }; // Handled through saved_aid */
ImportsBundle:
ImportsBundle:
ImportsBundleInt ImportSelectionOption {
$$ = $1;
$$->option = $2;
}
| ImportsBundleInt ;
ImportsBundleInt:
ImportsList TOK_FROM TypeRefName AssignedIdentifier {
$$ = $1;
$$->fromModuleName = $3;
$$->identifier = $4;
$$->option = 0;
/* This stupid thing is used for look-back hack. */
saved_aid = $$->identifier.oid ? 0 : &($$->identifier);
checkmem($$);
...
...
@@ -755,6 +767,14 @@ ImportsElement:
}
;
ImportSelectionOption:
TOK_WITH TOK_SUCCESSORS {
$$ = XPT_WITH_SUCCESSORS;
}
| TOK_WITH TOK_DESCENDANTS {
$$ = XPT_WITH_DESCENDANTS;
}
;
optExports:
{ $$ = 0; }
...
...
tests/tests-asn1c-compiler/161-imports-with-successors-OK.asn1
0 → 100755
View file @
29ef59bb
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .121
ModuleIMPORTS
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS ImportedType
FROM ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 minor-version-1(1) }
WITH SUCCESSORS
;
Type ::= ImportedType
END
ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 minor-version-5(5)}
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS -- nothing --;
ImportedType ::= INTEGER
END
tests/tests-asn1c-compiler/161-imports-with-successors-SE.asn1
0 → 100755
View file @
29ef59bb
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .121
ModuleIMPORTS
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS ImportedType
FROM ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 minor-version-3(3) }
WITH SUCCESSORS
;
Type ::= ImportedType
END
ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 minor-version-2(2)}
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS -- nothing --;
ImportedType ::= INTEGER
END
tests/tests-asn1c-compiler/162-imports-with-successors-SE.asn1
0 → 100755
View file @
29ef59bb
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .121
ModuleIMPORTS
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS ImportedType
FROM ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 minor-version-3(3) }
WITH SUCCESSORS
;
Type ::= ImportedType
END
ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 minor-version-3(3) super-minor-version(1)}
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS -- nothing --;
ImportedType ::= INTEGER
END
tests/tests-asn1c-compiler/163-imports-with-descendants-OK.asn1
0 → 100755
View file @
29ef59bb
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .121
ModuleIMPORTS
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 161 }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS ImportedType
FROM ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 163 major-version-1(1) }
WITH DESCENDANTS
;
Type ::= ImportedType
END
ImportedModule1
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 163 major-version-1(1) super-minor-version(1) super-minor-version(1)}
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS -- nothing --;
ImportedType ::= INTEGER
END
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