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
68723b6e
Commit
68723b6e
authored
Jan 16, 2024
by
v0-e
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -fprefix as an option
parent
1b1e30a6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
23 deletions
+43
-23
asn1c/asn1c.c
asn1c/asn1c.c
+4
-0
libasn1compiler/asn1c_misc.c
libasn1compiler/asn1c_misc.c
+22
-8
libasn1compiler/asn1c_misc.h
libasn1compiler/asn1c_misc.h
+0
-1
libasn1compiler/asn1c_naming.c
libasn1compiler/asn1c_naming.c
+10
-10
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+4
-4
libasn1compiler/asn1compiler.h
libasn1compiler/asn1compiler.h
+3
-0
No files found.
asn1c/asn1c.c
View file @
68723b6e
...
...
@@ -145,6 +145,9 @@ main(int ac, char **av) {
asn1_compiler_flags
&=
~
A1C_LINK_SKELETONS
;
}
else
if
(
strcmp
(
optarg
,
"link-skeletons"
)
==
0
)
{
asn1_compiler_flags
|=
A1C_LINK_SKELETONS
;
}
else
if
(
strncmp
(
optarg
,
"prefix="
,
7
)
==
0
)
{
char
*
prefix
=
optarg
+
7
;
asn1c_prefix_set
(
prefix
);
}
else
{
fprintf
(
stderr
,
"-f%s: Invalid argument
\n
"
,
optarg
);
exit
(
EX_USAGE
);
...
...
@@ -589,6 +592,7 @@ usage(const char *av0) {
" -fno-include-deps Do not generate the courtesy #includes for dependencies
\n
"
" -funnamed-unions Enable unnamed unions in structures
\n
"
" -fwide-types Use INTEGER_t instead of
\"
long
\"
by default, etc.
\n
"
" -fprefix=<prefix> Add the specified prefix to generated types
\n
"
"
\n
"
" -no-gen-BER Do not generate the Basic Encoding Rules (BER, X.690) support code
\n
"
...
...
libasn1compiler/asn1c_misc.c
View file @
68723b6e
...
...
@@ -38,14 +38,28 @@ reserved_keyword(const char *str) {
return
0
;
}
const
char
*
asn1c_prefix
()
{
const
char
*
prefix
=
getenv
(
"ASN1C_PREFIX"
);
const
char
*
asn1c_prefix
=
NULL
;
void
asn1c_prefix_set
(
const
char
*
prefix
)
{
asn1c_prefix
=
prefix
;
}
const
char
*
asn1c_prefix_get
()
{
const
char
*
prefix
;
prefix
=
asn1c_prefix
;
if
(
prefix
)
return
prefix
;
prefix
=
getenv
(
"ASN1C_PREFIX"
);
if
(
prefix
)
return
prefix
;
if
(
!
prefix
)
prefix
=
""
;
prefix
=
""
;
return
prefix
;
return
prefix
;
}
/*
...
...
@@ -68,7 +82,7 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
int
sptr_cnt
=
0
;
if
(
flags
&
AMI_USE_PREFIX
)
prefix
=
asn1c_prefix
();
prefix
=
asn1c_prefix
_get
();
if
(
expr
)
{
/*
...
...
@@ -348,7 +362,7 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
}
}
prefix
=
stdname
?
""
:
asn1c_prefix
();
prefix
=
stdname
?
""
:
asn1c_prefix
_get
();
switch
(
_format
)
{
case
TNF_UNMODIFIED
:
...
...
libasn1compiler/asn1c_misc.h
View file @
68723b6e
...
...
@@ -52,6 +52,5 @@ enum asn1c_fitsfloat_e {
RL_FITS_DOUBLE64
};
enum
asn1c_fitsfloat_e
asn1c_REAL_fits
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
);
const
char
*
asn1c_prefix
(
void
);
#endif
/* ASN1_COMPILER_MISC_H */
libasn1compiler/asn1c_naming.c
View file @
68723b6e
...
...
@@ -193,7 +193,7 @@ c_name_impl(arg_t *arg, asn1p_expr_t *expr, int avoid_keywords) {
construct_base_name
(
&
tmp_compoundable_part_name
,
expr
,
compound_names
,
0
,
0
);
construct_base_name
(
&
compound_part_name
,
expr
,
1
,
0
,
0
);
if
(
strlen
(
asn1c_prefix
())
==
0
)
{
if
(
strlen
(
asn1c_prefix
_get
())
==
0
)
{
if
(
!
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
)
{
abuf_printf
(
&
b_short_name
,
"%s"
,
b_as_member
.
buffer
);
...
...
@@ -209,16 +209,16 @@ c_name_impl(arg_t *arg, asn1p_expr_t *expr, int avoid_keywords) {
}
else
{
if
(
!
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
)
{
abuf_printf
(
&
b_short_name
,
"%s%s"
,
asn1c_prefix
(),
b_as_member
.
buffer
);
abuf_printf
(
&
b_short_name
,
"%s%s"
,
asn1c_prefix
_get
(),
b_as_member
.
buffer
);
}
else
{
abuf_printf
(
&
b_short_name
,
"%s%s_t"
,
asn1c_prefix
(),
b_as_member
.
buffer
);
abuf_printf
(
&
b_short_name
,
"%s%s_t"
,
asn1c_prefix
_get
(),
b_as_member
.
buffer
);
}
}
abuf_printf
(
&
b_full_name
,
"struct %s%s"
,
asn1c_prefix
(),
b_base_name
.
buffer
);
abuf_printf
(
&
b_presence_enum
,
"enum %s%s_PR"
,
asn1c_prefix
(),
tmp_compoundable_part_name
.
buffer
);
abuf_printf
(
&
b_presence_name
,
"%s%s_PR"
,
asn1c_prefix
(),
tmp_compoundable_part_name
.
buffer
);
abuf_printf
(
&
b_members_enum
,
"enum %s%s"
,
asn1c_prefix
(),
b_base_name
.
buffer
);
abuf_printf
(
&
b_members_name
,
"e_%s%s"
,
asn1c_prefix
(),
tmp_compoundable_part_name
.
buffer
);
abuf_printf
(
&
b_full_name
,
"struct %s%s"
,
asn1c_prefix
_get
(),
b_base_name
.
buffer
);
abuf_printf
(
&
b_presence_enum
,
"enum %s%s_PR"
,
asn1c_prefix
_get
(),
tmp_compoundable_part_name
.
buffer
);
abuf_printf
(
&
b_presence_name
,
"%s%s_PR"
,
asn1c_prefix
_get
(),
tmp_compoundable_part_name
.
buffer
);
abuf_printf
(
&
b_members_enum
,
"enum %s%s"
,
asn1c_prefix
_get
(),
b_base_name
.
buffer
);
abuf_printf
(
&
b_members_name
,
"e_%s%s"
,
asn1c_prefix
_get
(),
tmp_compoundable_part_name
.
buffer
);
}
names
.
type
.
asn_name
=
b_type_asn_name
.
buffer
;
...
...
@@ -268,7 +268,7 @@ c_member_name(arg_t *arg, asn1p_expr_t *expr) {
abuf_clear
(
&
ab
);
/* NB: do not use part_name, doesn't work for -fcompound-names */
abuf_str
(
&
ab
,
asn1c_prefix
());
abuf_str
(
&
ab
,
asn1c_prefix
_get
());
abuf_str
(
&
ab
,
c_name_impl
(
arg
,
arg
->
expr
,
0
).
base_name
);
abuf_str
(
&
ab
,
"_"
);
abuf_str
(
&
ab
,
asn1c_make_identifier
(
0
,
expr
,
0
));
...
...
@@ -283,7 +283,7 @@ c_presence_name(arg_t *arg, asn1p_expr_t *expr) {
abuf_clear
(
&
ab
);
abuf_str
(
&
ab
,
asn1c_prefix
());
abuf_str
(
&
ab
,
asn1c_prefix
_get
());
if
(
expr
)
{
/* NB: do not use part_name, doesn't work for -fcompound-names */
abuf_str
(
&
ab
,
c_name_impl
(
arg
,
arg
->
expr
,
0
).
base_name
);
...
...
libasn1compiler/asn1c_save.c
View file @
68723b6e
...
...
@@ -1021,7 +1021,7 @@ generate_constant_collection(arg_t *arg) {
abuf_printf
(
buf
,
"/*
\n
* Generated by asn1c-"
VERSION
" (http://lionet.info/asn1c)
\n
*/
\n\n
"
);
abuf_printf
(
buf
,
"#ifndef _%sASN_CONSTANT_H
\n
#define _%sASN_CONSTANT_H
\n\n
"
,
asn1c_prefix
(),
asn1c_prefix
());
abuf_printf
(
buf
,
"#ifndef _%sASN_CONSTANT_H
\n
#define _%sASN_CONSTANT_H
\n\n
"
,
asn1c_prefix
_get
(),
asn1c_prefix_get
());
abuf_printf
(
buf
,
"#ifdef __cplusplus
\n
extern
\"
C
\"
{
\n
#endif
\n\n
"
);
...
...
@@ -1054,7 +1054,7 @@ generate_constant_collection(arg_t *arg) {
}
}
abuf_printf
(
buf
,
"
\n\n
#ifdef __cplusplus
\n
}
\n
#endif
\n\n
#endif /* _%sASN_CONSTANT_H */
\n
"
,
asn1c_prefix
());
abuf_printf
(
buf
,
"
\n\n
#ifdef __cplusplus
\n
}
\n
#endif
\n\n
#endif /* _%sASN_CONSTANT_H */
\n
"
,
asn1c_prefix
_get
());
if
(
empty_file
)
{
abuf_free
(
buf
);
...
...
@@ -1071,9 +1071,9 @@ generate_constant_file(arg_t *arg, const char *destdir) {
if
(
!
buf
)
return
0
;
filename_len
=
strlen
(
asn1c_prefix
())
+
strlen
(
"asn_constant"
);
filename_len
=
strlen
(
asn1c_prefix
_get
())
+
strlen
(
"asn_constant"
);
filename
=
calloc
(
filename_len
+
1
,
1
);
snprintf
(
filename
,
filename_len
+
1
,
"%sasn_constant"
,
asn1c_prefix
());
snprintf
(
filename
,
filename_len
+
1
,
"%sasn_constant"
,
asn1c_prefix
_get
());
if
(
arg
->
flags
&
A1C_PRINT_COMPILED
)
{
printf
(
"
\n
/*** <<< asn_constant.h >>> ***/
\n\n
"
);
...
...
libasn1compiler/asn1compiler.h
View file @
68723b6e
...
...
@@ -141,6 +141,9 @@ void asn1c_debug_type_naming(asn1p_t *asn, enum asn1c_flags,
void
asn1c__add_pdu_type
(
const
char
*
typename
);
void
asn1c_prefix_set
(
const
char
*
prefix
);
const
char
*
asn1c_prefix_get
(
void
);
int
asn1c_attach_streams
(
asn1p_expr_t
*
expr
);
#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