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
32706502
Unverified
Commit
32706502
authored
Jan 17, 2024
by
Mouse
Committed by
GitHub
Jan 17, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #170 from v0-e/prefix-optional-argument
parents
1b1e30a6
68723b6e
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 @
32706502
...
@@ -145,6 +145,9 @@ main(int ac, char **av) {
...
@@ -145,6 +145,9 @@ main(int ac, char **av) {
asn1_compiler_flags
&=
~
A1C_LINK_SKELETONS
;
asn1_compiler_flags
&=
~
A1C_LINK_SKELETONS
;
}
else
if
(
strcmp
(
optarg
,
"link-skeletons"
)
==
0
)
{
}
else
if
(
strcmp
(
optarg
,
"link-skeletons"
)
==
0
)
{
asn1_compiler_flags
|=
A1C_LINK_SKELETONS
;
asn1_compiler_flags
|=
A1C_LINK_SKELETONS
;
}
else
if
(
strncmp
(
optarg
,
"prefix="
,
7
)
==
0
)
{
char
*
prefix
=
optarg
+
7
;
asn1c_prefix_set
(
prefix
);
}
else
{
}
else
{
fprintf
(
stderr
,
"-f%s: Invalid argument
\n
"
,
optarg
);
fprintf
(
stderr
,
"-f%s: Invalid argument
\n
"
,
optarg
);
exit
(
EX_USAGE
);
exit
(
EX_USAGE
);
...
@@ -589,6 +592,7 @@ usage(const char *av0) {
...
@@ -589,6 +592,7 @@ usage(const char *av0) {
" -fno-include-deps Do not generate the courtesy #includes for dependencies
\n
"
" -fno-include-deps Do not generate the courtesy #includes for dependencies
\n
"
" -funnamed-unions Enable unnamed unions in structures
\n
"
" -funnamed-unions Enable unnamed unions in structures
\n
"
" -fwide-types Use INTEGER_t instead of
\"
long
\"
by default, etc.
\n
"
" -fwide-types Use INTEGER_t instead of
\"
long
\"
by default, etc.
\n
"
" -fprefix=<prefix> Add the specified prefix to generated types
\n
"
"
\n
"
"
\n
"
" -no-gen-BER Do not generate the Basic Encoding Rules (BER, X.690) support code
\n
"
" -no-gen-BER Do not generate the Basic Encoding Rules (BER, X.690) support code
\n
"
...
...
libasn1compiler/asn1c_misc.c
View file @
32706502
...
@@ -38,14 +38,28 @@ reserved_keyword(const char *str) {
...
@@ -38,14 +38,28 @@ reserved_keyword(const char *str) {
return
0
;
return
0
;
}
}
const
char
*
const
char
*
asn1c_prefix
=
NULL
;
asn1c_prefix
()
{
void
const
char
*
prefix
=
getenv
(
"ASN1C_PREFIX"
);
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, ...) {
...
@@ -68,7 +82,7 @@ asn1c_make_identifier(enum ami_flags_e flags, asn1p_expr_t *expr, ...) {
int
sptr_cnt
=
0
;
int
sptr_cnt
=
0
;
if
(
flags
&
AMI_USE_PREFIX
)
if
(
flags
&
AMI_USE_PREFIX
)
prefix
=
asn1c_prefix
();
prefix
=
asn1c_prefix
_get
();
if
(
expr
)
{
if
(
expr
)
{
/*
/*
...
@@ -348,7 +362,7 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
...
@@ -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
)
{
switch
(
_format
)
{
case
TNF_UNMODIFIED
:
case
TNF_UNMODIFIED
:
...
...
libasn1compiler/asn1c_misc.h
View file @
32706502
...
@@ -52,6 +52,5 @@ enum asn1c_fitsfloat_e {
...
@@ -52,6 +52,5 @@ enum asn1c_fitsfloat_e {
RL_FITS_DOUBLE64
RL_FITS_DOUBLE64
};
};
enum
asn1c_fitsfloat_e
asn1c_REAL_fits
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
);
enum
asn1c_fitsfloat_e
asn1c_REAL_fits
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
);
const
char
*
asn1c_prefix
(
void
);
#endif
/* ASN1_COMPILER_MISC_H */
#endif
/* ASN1_COMPILER_MISC_H */
libasn1compiler/asn1c_naming.c
View file @
32706502
...
@@ -193,7 +193,7 @@ c_name_impl(arg_t *arg, asn1p_expr_t *expr, int avoid_keywords) {
...
@@ -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
(
&
tmp_compoundable_part_name
,
expr
,
compound_names
,
0
,
0
);
construct_base_name
(
&
compound_part_name
,
expr
,
1
,
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
(
!
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
)
{
if
(
arg
->
embed
)
{
abuf_printf
(
&
b_short_name
,
"%s"
,
b_as_member
.
buffer
);
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) {
...
@@ -209,16 +209,16 @@ c_name_impl(arg_t *arg, asn1p_expr_t *expr, int avoid_keywords) {
}
else
{
}
else
{
if
(
!
expr
->
_anonymous_type
)
{
if
(
!
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
)
{
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
{
}
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_full_name
,
"struct %s%s"
,
asn1c_prefix
_get
(),
b_base_name
.
buffer
);
abuf_printf
(
&
b_presence_enum
,
"enum %s%s_PR"
,
asn1c_prefix
(),
tmp_compoundable_part_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
(),
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
(),
b_base_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
(),
tmp_compoundable_part_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
;
names
.
type
.
asn_name
=
b_type_asn_name
.
buffer
;
...
@@ -268,7 +268,7 @@ c_member_name(arg_t *arg, asn1p_expr_t *expr) {
...
@@ -268,7 +268,7 @@ c_member_name(arg_t *arg, asn1p_expr_t *expr) {
abuf_clear
(
&
ab
);
abuf_clear
(
&
ab
);
/* NB: do not use part_name, doesn't work for -fcompound-names */
/* 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
,
c_name_impl
(
arg
,
arg
->
expr
,
0
).
base_name
);
abuf_str
(
&
ab
,
"_"
);
abuf_str
(
&
ab
,
"_"
);
abuf_str
(
&
ab
,
asn1c_make_identifier
(
0
,
expr
,
0
));
abuf_str
(
&
ab
,
asn1c_make_identifier
(
0
,
expr
,
0
));
...
@@ -283,7 +283,7 @@ c_presence_name(arg_t *arg, asn1p_expr_t *expr) {
...
@@ -283,7 +283,7 @@ c_presence_name(arg_t *arg, asn1p_expr_t *expr) {
abuf_clear
(
&
ab
);
abuf_clear
(
&
ab
);
abuf_str
(
&
ab
,
asn1c_prefix
());
abuf_str
(
&
ab
,
asn1c_prefix
_get
());
if
(
expr
)
{
if
(
expr
)
{
/* NB: do not use part_name, doesn't work for -fcompound-names */
/* NB: do not use part_name, doesn't work for -fcompound-names */
abuf_str
(
&
ab
,
c_name_impl
(
arg
,
arg
->
expr
,
0
).
base_name
);
abuf_str
(
&
ab
,
c_name_impl
(
arg
,
arg
->
expr
,
0
).
base_name
);
...
...
libasn1compiler/asn1c_save.c
View file @
32706502
...
@@ -1021,7 +1021,7 @@ generate_constant_collection(arg_t *arg) {
...
@@ -1021,7 +1021,7 @@ generate_constant_collection(arg_t *arg) {
abuf_printf
(
buf
,
"/*
\n
* Generated by asn1c-"
VERSION
abuf_printf
(
buf
,
"/*
\n
* Generated by asn1c-"
VERSION
" (http://lionet.info/asn1c)
\n
*/
\n\n
"
);
" (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
"
);
abuf_printf
(
buf
,
"#ifdef __cplusplus
\n
extern
\"
C
\"
{
\n
#endif
\n\n
"
);
...
@@ -1054,7 +1054,7 @@ generate_constant_collection(arg_t *arg) {
...
@@ -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
)
{
if
(
empty_file
)
{
abuf_free
(
buf
);
abuf_free
(
buf
);
...
@@ -1071,9 +1071,9 @@ generate_constant_file(arg_t *arg, const char *destdir) {
...
@@ -1071,9 +1071,9 @@ generate_constant_file(arg_t *arg, const char *destdir) {
if
(
!
buf
)
return
0
;
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
);
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
)
{
if
(
arg
->
flags
&
A1C_PRINT_COMPILED
)
{
printf
(
"
\n
/*** <<< asn_constant.h >>> ***/
\n\n
"
);
printf
(
"
\n
/*** <<< asn_constant.h >>> ***/
\n\n
"
);
...
...
libasn1compiler/asn1compiler.h
View file @
32706502
...
@@ -141,6 +141,9 @@ void asn1c_debug_type_naming(asn1p_t *asn, enum asn1c_flags,
...
@@ -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__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
);
int
asn1c_attach_streams
(
asn1p_expr_t
*
expr
);
#endif
/* ASN1_COMPILER_H */
#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