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
4215c51c
Commit
4215c51c
authored
Nov 19, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add hidden -debug-type-naming option
parent
da672c41
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
16 deletions
+93
-16
asn1c/asn1c.c
asn1c/asn1c.c
+38
-16
libasn1compiler/asn1compiler.c
libasn1compiler/asn1compiler.c
+52
-0
libasn1compiler/asn1compiler.h
libasn1compiler/asn1compiler.h
+3
-0
No files found.
asn1c/asn1c.c
View file @
4215c51c
...
...
@@ -64,6 +64,8 @@ main(int ac, char **av) {
int
warnings_as_errors
=
0
;
/* Treat warnings as errors */
char
*
skeletons_dir
=
NULL
;
/* Directory with supplementary stuff */
char
*
destdir
=
NULL
;
/* Destination for generated files */
char
**
debug_type_names
=
0
;
/* Debug stuff */
size_t
debug_type_names_count
=
0
;
asn1p_t
*
asn
=
0
;
/* An ASN.1 parsed tree */
int
ret
;
/* Return value from misc functions */
int
ch
;
/* Command line character */
...
...
@@ -73,7 +75,34 @@ main(int ac, char **av) {
/*
* Process command-line options.
*/
while
((
ch
=
getopt
(
ac
,
av
,
"EFf:g:hn:LPp:RS:D:vW:X"
))
!=
-
1
)
switch
(
ch
)
{
while
((
ch
=
getopt
(
ac
,
av
,
"D:d:EFf:g:hn:LPp:RS:vW:X"
))
!=
-
1
)
switch
(
ch
)
{
case
'D'
:
if
(
optarg
&&
*
optarg
)
{
size_t
optarg_len
=
strlen
(
optarg
);
free
(
destdir
);
destdir
=
calloc
(
1
,
optarg_len
+
2
);
/* + "/\0" */
assert
(
destdir
);
strcpy
(
destdir
,
optarg
);
if
(
destdir
[
optarg_len
-
1
]
!=
'/'
)
{
destdir
[
optarg_len
]
=
'/'
;
}
}
else
{
free
(
destdir
);
destdir
=
NULL
;
}
break
;
case
'd'
:
if
(
strncmp
(
optarg
,
"ebug-type-naming="
,
17
)
==
0
)
{
char
**
p
=
realloc
(
debug_type_names
,
(
debug_type_names_count
+
2
)
*
sizeof
(
*
p
));
assert
(
p
);
debug_type_names
=
p
;
debug_type_names
[
debug_type_names_count
++
]
=
strdup
(
optarg
+
17
);
debug_type_names
[
debug_type_names_count
]
=
NULL
;
break
;
}
usage
(
av
[
0
]);
case
'E'
:
print_arg__print_out
=
1
;
break
;
...
...
@@ -184,21 +213,6 @@ main(int ac, char **av) {
case
'S'
:
skeletons_dir
=
optarg
;
break
;
case
'D'
:
if
(
optarg
&&
*
optarg
)
{
size_t
optarg_len
=
strlen
(
optarg
);
free
(
destdir
);
destdir
=
calloc
(
1
,
optarg_len
+
2
);
/* + "/\0" */
assert
(
destdir
);
strcpy
(
destdir
,
optarg
);
if
(
destdir
[
optarg_len
-
1
]
!=
'/'
)
{
destdir
[
optarg_len
]
=
'/'
;
}
}
else
{
free
(
destdir
);
destdir
=
NULL
;
}
break
;
case
'v'
:
fprintf
(
stderr
,
"ASN.1 Compiler, v"
VERSION
"
\n
"
COPYRIGHT
);
exit
(
0
);
...
...
@@ -386,6 +400,14 @@ main(int ac, char **av) {
return
0
;
}
/*
* -debug-type-naming=Type
*/
if
(
debug_type_names
)
{
asn1c_debug_type_naming
(
asn
,
asn1_compiler_flags
,
debug_type_names
);
return
0
;
}
/*
* Compile the ASN.1 tree into a set of source files
* of another language.
...
...
libasn1compiler/asn1compiler.c
View file @
4215c51c
...
...
@@ -232,3 +232,55 @@ default_logger_cb(int _severity, const char *fmt, ...) {
fprintf
(
stderr
,
"
\n
"
);
}
static
void
asn1c_debug_expr_naming
(
arg_t
*
arg
)
{
asn1p_expr_t
*
expr
=
arg
->
expr
;
printf
(
"%s: "
,
expr
->
Identifier
);
printf
(
"%s
\n
"
,
c_names_format
(
c_name
(
arg
)));
printf
(
"
\n
"
);
}
void
asn1c_debug_type_naming
(
asn1p_t
*
asn
,
enum
asn1c_flags
flags
,
char
**
asn_type_names
)
{
arg_t
arg_s
;
arg_t
*
arg
=
&
arg_s
;
asn1p_module_t
*
mod
;
memset
(
arg
,
0
,
sizeof
(
*
arg
));
arg
->
logger_cb
=
default_logger_cb
;
arg
->
flags
=
flags
;
arg
->
asn
=
asn
;
c_name_clash_finder_init
();
/*
* Compile each individual top level structure.
*/
TQ_FOR
(
mod
,
&
(
asn
->
modules
),
mod_next
)
{
int
namespace_shown
=
0
;
TQ_FOR
(
arg
->
expr
,
&
(
mod
->
members
),
next
)
{
arg
->
ns
=
asn1_namespace_new_from_module
(
mod
,
0
);
for
(
char
**
t
=
asn_type_names
;
*
t
;
t
++
)
{
if
(
strcmp
(
*
t
,
arg
->
expr
->
Identifier
)
==
0
)
{
if
(
!
namespace_shown
)
{
namespace_shown
=
1
;
printf
(
"Namespace %s
\n
"
,
asn1_namespace_string
(
arg
->
ns
));
}
asn1c_debug_expr_naming
(
arg
);
}
}
asn1_namespace_free
(
arg
->
ns
);
arg
->
ns
=
0
;
}
}
c_name_clash_finder_destroy
();
}
libasn1compiler/asn1compiler.h
View file @
4215c51c
...
...
@@ -100,6 +100,9 @@ enum asn1c_flags {
int
asn1_compile
(
asn1p_t
*
asn
,
const
char
*
datadir
,
const
char
*
destdir
,
enum
asn1c_flags
,
int
argc
,
int
optc
,
char
**
argv
);
void
asn1c_debug_type_naming
(
asn1p_t
*
asn
,
enum
asn1c_flags
,
char
**
asn_type_names
);
void
asn1c__add_pdu_type
(
const
char
*
typename
);
#endif
/* ASN1_COMPILER_H */
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