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
6431b1c9
Commit
6431b1c9
authored
Nov 15, 2017
by
Jon Ringle
Committed by
Lev Walkin
Nov 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add '-D destdir' option for generated files
parent
7871abf7
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
81 deletions
+98
-81
asn1c/asn1c.c
asn1c/asn1c.c
+13
-4
libasn1compiler/asn1c_compat.c
libasn1compiler/asn1c_compat.c
+15
-7
libasn1compiler/asn1c_compat.h
libasn1compiler/asn1c_compat.h
+2
-2
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+64
-64
libasn1compiler/asn1c_save.h
libasn1compiler/asn1c_save.h
+1
-1
libasn1compiler/asn1compiler.c
libasn1compiler/asn1compiler.c
+2
-2
libasn1compiler/asn1compiler.h
libasn1compiler/asn1compiler.h
+1
-1
No files found.
asn1c/asn1c.c
View file @
6431b1c9
...
...
@@ -63,16 +63,19 @@ main(int ac, char **av) {
int
print_arg__fix_n_print
=
0
;
/* Fix and print */
int
warnings_as_errors
=
0
;
/* Treat warnings as errors */
char
*
skeletons_dir
=
NULL
;
/* Directory with supplementary stuff */
char
destdir
[
PATH_MAX
];
/* Destination directory for generated files */
asn1p_t
*
asn
=
0
;
/* An ASN.1 parsed tree */
int
ret
;
/* Return value from misc functions */
int
ch
;
/* Command line character */
int
i
;
/* Index in some loops */
int
exit_code
=
0
;
/* Exit code */
destdir
[
0
]
=
'\0'
;
/*
* Process command-line options.
*/
while
((
ch
=
getopt
(
ac
,
av
,
"EFf:g:hn:LPp:RS:vW:X"
))
!=
-
1
)
switch
(
ch
)
{
while
((
ch
=
getopt
(
ac
,
av
,
"EFf:g:hn:LPp:RS:
D:
vW:X"
))
!=
-
1
)
switch
(
ch
)
{
case
'E'
:
print_arg__print_out
=
1
;
break
;
...
...
@@ -179,6 +182,11 @@ main(int ac, char **av) {
case
'S'
:
skeletons_dir
=
optarg
;
break
;
case
'D'
:
strncat
(
destdir
,
optarg
,
PATH_MAX
-
2
);
/* leave room for possible trailing '/' */
if
(
destdir
[
strlen
(
destdir
)
-
1
]
!=
'/'
)
strcat
(
destdir
,
"/"
);
break
;
case
'v'
:
fprintf
(
stderr
,
"ASN.1 Compiler, v"
VERSION
"
\n
"
COPYRIGHT
);
exit
(
0
);
...
...
@@ -241,7 +249,7 @@ main(int ac, char **av) {
ac
-=
optind
;
av
+=
optind
;
}
else
{
const
char
*
bin_name
=
a1c_basename
(
av
[
0
]);
const
char
*
bin_name
=
a1c_basename
(
av
[
0
]
,
NULL
);
fprintf
(
stderr
,
"%s: No input files specified. "
"Try '%s -h' for more information
\n
"
,
...
...
@@ -370,7 +378,7 @@ main(int ac, char **av) {
* Compile the ASN.1 tree into a set of source files
* of another language.
*/
if
(
asn1_compile
(
asn
,
skeletons_dir
,
asn1_compiler_flags
,
ac
+
optind
,
if
(
asn1_compile
(
asn
,
skeletons_dir
,
destdir
,
asn1_compiler_flags
,
ac
+
optind
,
optind
,
av
-
optind
))
{
exit_code
=
EX_SOFTWARE
;
}
...
...
@@ -499,6 +507,7 @@ usage(const char *av0) {
" -R Restrict output (tables only, no support code)
\n
"
" -S <dir> Directory with support (skeleton?) files
\n
"
" (Default is
\"
%s
\"
)
\n
"
" -D <dir> Destination directory for generated files (default current dir)
\n
"
" -X Generate and print the XML DTD
\n
"
"
\n
"
...
...
@@ -532,7 +541,7 @@ usage(const char *av0) {
" -print-lines Generate
\"
-- #line
\"
comments in -E output
\n
"
,
a1c_basename
(
av0
),
DATADIR
);
a1c_basename
(
av0
,
NULL
),
DATADIR
);
/* clang-format on */
exit
(
EX_USAGE
);
}
libasn1compiler/asn1c_compat.c
View file @
6431b1c9
...
...
@@ -36,7 +36,7 @@ int mkstemp(char *template) {
#endif
FILE
*
asn1c_open_file
(
const
char
*
name
,
const
char
*
ext
,
char
**
opt_tmpname
)
{
asn1c_open_file
(
const
char
*
destdir
,
const
char
*
name
,
const
char
*
ext
,
char
**
opt_tmpname
)
{
char
fname
[
PATH_MAX
];
int
created
=
1
;
#ifndef _WIN32
...
...
@@ -49,7 +49,9 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
/*
* Compute filenames.
*/
ret
=
snprintf
(
fname
,
sizeof
(
fname
),
"%s%s%s"
,
name
,
ext
,
ret
=
snprintf
(
fname
,
sizeof
(
fname
),
"%s%s%s%s"
,
opt_tmpname
?
""
:
destdir
,
name
,
ext
,
opt_tmpname
?
".XXXXXX"
:
""
);
assert
(
ret
>
0
&&
ret
<
(
ssize_t
)
sizeof
(
fname
));
...
...
@@ -124,14 +126,20 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
}
const
char
*
a1c_basename
(
const
char
*
path
)
{
a1c_basename
(
const
char
*
path
,
const
char
*
destdir
)
{
static
char
strbuf
[
PATH_MAX
];
const
char
*
pend
;
const
char
*
name
;
char
*
sbuf
=
strbuf
;
if
(
destdir
)
{
strncpy
(
strbuf
,
destdir
,
PATH_MAX
-
1
);
strbuf
[
PATH_MAX
-
1
]
=
'\0'
;
sbuf
=
strbuf
+
strlen
(
strbuf
);
}
pend
=
path
+
strlen
(
path
);
if
(
pend
==
path
)
{
strcpy
(
s
tr
buf
,
"."
);
strcpy
(
sbuf
,
"."
);
return
strbuf
;
}
...
...
@@ -139,7 +147,7 @@ a1c_basename(const char *path) {
for
(
pend
--
;
pend
>
path
&&
*
pend
==
'/'
;
pend
--
);
if
(
pend
==
path
&&
*
path
==
'/'
)
{
strcpy
(
s
tr
buf
,
"/"
);
strcpy
(
sbuf
,
"/"
);
return
strbuf
;
}
...
...
@@ -150,8 +158,8 @@ a1c_basename(const char *path) {
return
0
;
}
memcpy
(
s
tr
buf
,
name
,
pend
-
name
+
1
);
s
tr
buf
[
pend
-
name
+
1
]
=
'\0'
;
memcpy
(
sbuf
,
name
,
pend
-
name
+
1
);
sbuf
[
pend
-
name
+
1
]
=
'\0'
;
return
strbuf
;
}
...
...
libasn1compiler/asn1c_compat.h
View file @
6431b1c9
...
...
@@ -7,14 +7,14 @@
* its name returned in (*opt_tmpname).
* The (*opt_tmpname) should then be subsequently freed by free(3).
*/
FILE
*
asn1c_open_file
(
const
char
*
base_part
,
const
char
*
extension
,
FILE
*
asn1c_open_file
(
const
char
*
destdir
,
const
char
*
base_part
,
const
char
*
extension
,
char
**
opt_tmpname
);
/*
* Obtain base name and directory name of a path.
* Some systems have them in <libgen.h> as dirname(3) and basename(3).
*/
const
char
*
a1c_basename
(
const
char
*
path
);
const
char
*
a1c_basename
(
const
char
*
path
,
const
char
*
destdir
);
const
char
*
a1c_dirname
(
const
char
*
path
);
#endif
/* ASN1C_COMPAT_H */
libasn1compiler/asn1c_save.c
View file @
6431b1c9
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_save.h
View file @
6431b1c9
#ifndef ASN1C_SAVE_H
#define ASN1C_SAVE_H
int
asn1c_save_compiled_output
(
arg_t
*
arg
,
const
char
*
datadir
,
int
asn1c_save_compiled_output
(
arg_t
*
arg
,
const
char
*
datadir
,
const
char
*
destdir
,
int
argc
,
int
optc
,
char
**
argv
);
#endif
/* ASN1C_SAVE_H */
libasn1compiler/asn1compiler.c
View file @
6431b1c9
...
...
@@ -11,7 +11,7 @@ static int asn1c_attach_streams(asn1p_expr_t *expr);
static
int
asn1c_detach_streams
(
asn1p_expr_t
*
expr
);
int
asn1_compile
(
asn1p_t
*
asn
,
const
char
*
datadir
,
enum
asn1c_flags
flags
,
asn1_compile
(
asn1p_t
*
asn
,
const
char
*
datadir
,
const
char
*
destdir
,
enum
asn1c_flags
flags
,
int
argc
,
int
optc
,
char
**
argv
)
{
arg_t
arg_s
;
arg_t
*
arg
=
&
arg_s
;
...
...
@@ -84,7 +84,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
/*
* Save or print out the compiled result.
*/
if
(
asn1c_save_compiled_output
(
arg
,
datadir
,
argc
,
optc
,
argv
))
if
(
asn1c_save_compiled_output
(
arg
,
datadir
,
destdir
,
argc
,
optc
,
argv
))
return
-
1
;
TQ_FOR
(
mod
,
&
(
asn
->
modules
),
mod_next
)
{
...
...
libasn1compiler/asn1compiler.h
View file @
6431b1c9
...
...
@@ -93,7 +93,7 @@ enum asn1c_flags {
/*
* Compile the ASN.1 specification.
*/
int
asn1_compile
(
asn1p_t
*
asn
,
const
char
*
datadir
,
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__add_pdu_type
(
const
char
*
typename
);
...
...
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