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
fb35e088
Commit
fb35e088
authored
Aug 04, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whitespace changes
parent
d19216f2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
752 additions
and
758 deletions
+752
-758
skeletons/converter-sample.c
skeletons/converter-sample.c
+752
-758
No files found.
skeletons/converter-sample.c
View file @
fb35e088
...
@@ -276,8 +276,8 @@ main(int ac, char *av[]) {
...
@@ -276,8 +276,8 @@ main(int ac, char *av[]) {
/*
/*
* Decode the encoded structure from file.
* Decode the encoded structure from file.
*/
*/
structure
=
data_decode_from_file
(
pduTyp
e
,
structure
=
data_decode_from_file
(
pduType
,
file
,
nam
e
,
file
,
name
,
suggested_bufsize
,
first_pdu
);
suggested_bufsize
,
first_pdu
);
if
(
!
structure
)
{
if
(
!
structure
)
{
if
(
errno
)
{
if
(
errno
)
{
/* Error message is already printed */
/* Error message is already printed */
...
@@ -292,10 +292,11 @@ main(int ac, char *av[]) {
...
@@ -292,10 +292,11 @@ main(int ac, char *av[]) {
if
(
opt_check
)
{
if
(
opt_check
)
{
char
errbuf
[
128
];
char
errbuf
[
128
];
size_t
errlen
=
sizeof
(
errbuf
);
size_t
errlen
=
sizeof
(
errbuf
);
if
(
asn_check_constraints
(
pduType
,
structure
,
if
(
asn_check_constraints
(
pduType
,
structure
,
errbuf
,
&
errlen
))
{
errbuf
,
&
errlen
))
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"%s: ASN.1 constraint "
"%s: ASN.1 constraint "
"check failed: %s
\n
"
,
name
,
errbuf
);
"check failed: %s
\n
"
,
name
,
errbuf
);
exit
(
EX_DATAERR
);
exit
(
EX_DATAERR
);
}
}
}
}
...
@@ -312,18 +313,16 @@ main(int ac, char *av[]) {
...
@@ -312,18 +313,16 @@ main(int ac, char *av[]) {
break
;
break
;
case
OUT_XER
:
/* -oxer */
case
OUT_XER
:
/* -oxer */
if
(
xer_fprint
(
stdout
,
pduType
,
structure
))
{
if
(
xer_fprint
(
stdout
,
pduType
,
structure
))
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"%s: Cannot convert %s into XML
\n
"
,
name
,
"%s: Cannot convert %s into XML
\n
"
,
pduType
->
name
);
name
,
pduType
->
name
);
exit
(
EX_UNAVAILABLE
);
exit
(
EX_UNAVAILABLE
);
}
}
break
;
break
;
case
OUT_DER
:
case
OUT_DER
:
erv
=
der_encode
(
pduType
,
structure
,
write_out
,
stdout
);
erv
=
der_encode
(
pduType
,
structure
,
write_out
,
stdout
);
if
(
erv
.
encoded
<
0
)
{
if
(
erv
.
encoded
<
0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"%s: Cannot convert %s into DER
\n
"
,
name
,
"%s: Cannot convert %s into DER
\n
"
,
pduType
->
name
);
name
,
pduType
->
name
);
exit
(
EX_UNAVAILABLE
);
exit
(
EX_UNAVAILABLE
);
}
}
DEBUG
(
"Encoded in %ld bytes of DER"
,
(
long
)
erv
.
encoded
);
DEBUG
(
"Encoded in %ld bytes of DER"
,
(
long
)
erv
.
encoded
);
...
@@ -331,9 +330,8 @@ main(int ac, char *av[]) {
...
@@ -331,9 +330,8 @@ main(int ac, char *av[]) {
case
OUT_OER
:
case
OUT_OER
:
erv
=
oer_encode
(
pduType
,
structure
,
write_out
,
stdout
);
erv
=
oer_encode
(
pduType
,
structure
,
write_out
,
stdout
);
if
(
erv
.
encoded
<
0
)
{
if
(
erv
.
encoded
<
0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"%s: Cannot convert %s into oER
\n
"
,
name
,
"%s: Cannot convert %s into oER
\n
"
,
pduType
->
name
);
name
,
pduType
->
name
);
exit
(
EX_UNAVAILABLE
);
exit
(
EX_UNAVAILABLE
);
}
}
DEBUG
(
"Encoded in %ld bytes of OER"
,
(
long
)
erv
.
encoded
);
DEBUG
(
"Encoded in %ld bytes of OER"
,
(
long
)
erv
.
encoded
);
...
@@ -342,8 +340,8 @@ main(int ac, char *av[]) {
...
@@ -342,8 +340,8 @@ main(int ac, char *av[]) {
erv
=
uper_encode
(
pduType
,
structure
,
write_out
,
stdout
);
erv
=
uper_encode
(
pduType
,
structure
,
write_out
,
stdout
);
if
(
erv
.
encoded
<
0
)
{
if
(
erv
.
encoded
<
0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"%s: Cannot convert %s into Unaligned PER
\n
"
,
"%s: Cannot convert %s into Unaligned PER
\n
"
,
name
,
name
,
pduType
->
name
);
pduType
->
name
);
exit
(
EX_UNAVAILABLE
);
exit
(
EX_UNAVAILABLE
);
}
}
DEBUG
(
"Encoded in %ld bits of UPER"
,
(
long
)
erv
.
encoded
);
DEBUG
(
"Encoded in %ld bits of UPER"
,
(
long
)
erv
.
encoded
);
...
@@ -353,10 +351,11 @@ main(int ac, char *av[]) {
...
@@ -353,10 +351,11 @@ main(int ac, char *av[]) {
ASN_STRUCT_FREE
(
*
pduType
,
structure
);
ASN_STRUCT_FREE
(
*
pduType
,
structure
);
}
}
if
(
file
&&
file
!=
stdin
)
if
(
file
&&
file
!=
stdin
)
{
fclose
(
file
);
fclose
(
file
);
}
}
}
}
}
#ifdef JUNKTEST
#ifdef JUNKTEST
if
(
opt_jprob
>
0
.
0
)
{
if
(
opt_jprob
>
0
.
0
)
{
...
@@ -816,15 +815,11 @@ static int argument_is_stdin(char *av[], int idx) {
...
@@ -816,15 +815,11 @@ static int argument_is_stdin(char *av[], int idx) {
}
}
static
FILE
*
argument_to_file
(
char
*
av
[],
int
idx
)
{
static
FILE
*
argument_to_file
(
char
*
av
[],
int
idx
)
{
return
argument_is_stdin
(
av
,
idx
)
return
argument_is_stdin
(
av
,
idx
)
?
stdin
:
fopen
(
av
[
idx
],
"rb"
);
?
stdin
:
fopen
(
av
[
idx
],
"rb"
);
}
}
static
char
*
argument_to_name
(
char
*
av
[],
int
idx
)
{
static
char
*
argument_to_name
(
char
*
av
[],
int
idx
)
{
return
argument_is_stdin
(
av
,
idx
)
return
argument_is_stdin
(
av
,
idx
)
?
"standard input"
:
av
[
idx
];
?
"standard input"
:
av
[
idx
];
}
}
#ifdef JUNKTEST
#ifdef JUNKTEST
...
@@ -854,8 +849,7 @@ junk_bytes_with_probability(uint8_t *buf, size_t size, double prob) {
...
@@ -854,8 +849,7 @@ junk_bytes_with_probability(uint8_t *buf, size_t size, double prob) {
byte
^=
BPROB
(
0x01
);
byte
^=
BPROB
(
0x01
);
}
}
if
(
byte
!=
*
ptr
)
{
if
(
byte
!=
*
ptr
)
{
DEBUG
(
"Junk buf[%d] %02x -> %02x"
,
DEBUG
(
"Junk buf[%d] %02x -> %02x"
,
ptr
-
buf
,
*
ptr
,
byte
);
ptr
-
buf
,
*
ptr
,
byte
);
*
ptr
=
byte
;
*
ptr
=
byte
;
}
}
}
}
...
...
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