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
7489807a
Commit
7489807a
authored
Sep 18, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of zer_* in favor of generic asn_encoder and asn_decoder
parent
a75b247f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
86 deletions
+39
-86
tests/tests-c-compiler/check-src/check-70.-fwide-types.c
tests/tests-c-compiler/check-src/check-70.-fwide-types.c
+22
-48
tests/tests-c-compiler/check-src/check-70.c
tests/tests-c-compiler/check-src/check-70.c
+17
-38
No files found.
tests/tests-c-compiler/check-src/check-70.-fwide-types.c
View file @
7489807a
...
...
@@ -56,59 +56,33 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
return
0
;
}
enum
der_or_xer
{
AS_DER
,
AS_XER
,
AS_CXER
,
};
static
void
save_object_as
(
PDU_t
*
st
,
enum
der_or_xer
how
)
{
asn_enc_rval_t
rval
;
/* Return value */
save_object_as
(
PDU_t
*
st
,
enum
asn_transfer_syntax
syntax
)
{
asn_enc_rval_t
rval
;
/* Return value */
buf_offset
=
0
;
buf_offset
=
0
;
/*
* Save object using specified method.
*/
switch
(
how
)
{
case
AS_DER
:
rval
=
der_encode
(
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
break
;
case
AS_XER
:
rval
=
xer_encode
(
&
asn_DEF_PDU
,
st
,
XER_F_BASIC
,
_buf_writer
,
0
);
break
;
case
AS_CXER
:
rval
=
xer_encode
(
&
asn_DEF_PDU
,
st
,
XER_F_CANONICAL
,
_buf_writer
,
0
);
break
;
}
if
(
rval
.
encoded
==
-
1
)
{
fprintf
(
stderr
,
"Cannot encode %s: %s
\n
"
,
rval
.
failed_type
->
name
,
strerror
(
errno
));
assert
(
rval
.
encoded
!=
-
1
);
return
;
}
rval
=
asn_encode
(
0
,
syntax
,
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d
\n
"
,
buf_offset
);
if
(
rval
.
encoded
==
-
1
)
{
fprintf
(
stderr
,
"Cannot encode %s: %s
\n
"
,
rval
.
failed_type
->
name
,
strerror
(
errno
));
assert
(
rval
.
encoded
!=
-
1
);
return
;
}
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d/%zd
\n
"
,
buf_offset
,
rval
.
encoded
);
// assert(buf_offset == rval.encoded);
}
static
PDU_t
*
load_object_from
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
der_or_xer
how
)
{
load_object_from
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
asn_transfer_syntax
syntax
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
(
*
zer_decode
)(
struct
asn_codec_ctx_s
*
,
asn_TYPE_descriptor_t
*
,
void
**
,
const
void
*
,
size_t
);
PDU_t
*
st
=
0
;
size_t
csize
=
1
;
if
(
how
==
AS_DER
)
zer_decode
=
ber_decode
;
else
zer_decode
=
xer_decode
;
if
(
getenv
(
"INITIAL_CHUNK_SIZE"
))
csize
=
atoi
(
getenv
(
"INITIAL_CHUNK_SIZE"
));
...
...
@@ -137,7 +111,7 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
fprintf
(
stderr
,
"=== end ===
\n
"
);
}
#endif
rval
=
zer_decode
(
0
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
rval
=
asn_decode
(
0
,
syntax
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
fbuf
+
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
);
...
...
@@ -151,7 +125,7 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
if
(
expectation
!=
EXP_BROKEN
)
{
assert
(
rval
.
code
==
RC_OK
);
if
(
how
==
AS_D
ER
)
{
if
(
syntax
==
ATS_B
ER
)
{
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
assert
((
fbuf_offset
+
1
/* "\n" */
==
(
ssize_t
)
size
...
...
@@ -211,18 +185,18 @@ static void
process_XER_data
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
)
{
PDU_t
*
st
;
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
A
S
_XER
);
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
A
TS_BASIC
_XER
);
if
(
!
st
)
return
;
/* Save and re-load as DER */
save_object_as
(
st
,
AS_DER
);
st
=
load_object_from
(
expectation
,
buf
,
buf_offset
,
A
S_D
ER
);
save_object_as
(
st
,
A
T
S_DER
);
st
=
load_object_from
(
expectation
,
buf
,
buf_offset
,
A
TS_B
ER
);
assert
(
st
);
save_object_as
(
st
,
(
expectation
==
EXP_CXER_EXACT
||
expectation
==
EXP_CXER_DIFF
)
?
A
S_CXER
:
AS
_XER
);
?
A
TS_CANONICAL_XER
:
ATS_BASIC
_XER
);
fprintf
(
stderr
,
"=== original ===
\n
"
);
fwrite
(
fbuf
,
1
,
size
,
stderr
);
fprintf
(
stderr
,
"=== re-encoded ===
\n
"
);
...
...
tests/tests-c-compiler/check-src/check-70.c
View file @
7489807a
...
...
@@ -50,54 +50,33 @@ _buf_writer(const void *buffer, size_t size, void *app_key) {
return
0
;
}
enum
der_or_xer
{
AS_DER
,
AS_XER
,
};
static
void
save_object_as
(
PDU_t
*
st
,
enum
der_or_xer
how
)
{
asn_enc_rval_t
rval
;
/* Return value */
save_object_as
(
PDU_t
*
st
,
enum
asn_transfer_syntax
syntax
)
{
asn_enc_rval_t
rval
;
/* Return value */
buf_offset
=
0
;
buf_offset
=
0
;
/*
* Save object using specified method.
*/
switch
(
how
)
{
case
AS_DER
:
rval
=
der_encode
(
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
break
;
case
AS_XER
:
rval
=
xer_encode
(
&
asn_DEF_PDU
,
st
,
XER_F_BASIC
,
_buf_writer
,
0
);
break
;
}
if
(
rval
.
encoded
==
-
1
)
{
rval
=
asn_encode
(
0
,
syntax
,
&
asn_DEF_PDU
,
st
,
_buf_writer
,
0
);
if
(
rval
.
encoded
==
-
1
)
{
fprintf
(
stderr
,
"Cannot encode %s: %s
\n
"
,
rval
.
failed_type
->
name
,
strerror
(
errno
));
assert
(
rval
.
encoded
!=
-
1
);
return
;
}
}
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d
\n
"
,
buf_offset
);
fprintf
(
stderr
,
"SAVED OBJECT IN SIZE %d
\n
"
,
buf_offset
);
// assert(buf_offset == rval.encoded);
}
static
PDU_t
*
load_object_from
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
der_or_xer
how
)
{
load_object_from
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
asn_transfer_syntax
syntax
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
(
*
zer_decode
)(
struct
asn_codec_ctx_s
*
,
asn_TYPE_descriptor_t
*
,
void
**
,
const
void
*
,
size_t
);
PDU_t
*
st
=
0
;
size_t
csize
=
1
;
if
(
how
==
AS_DER
)
zer_decode
=
ber_decode
;
else
zer_decode
=
xer_decode
;
if
(
getenv
(
"INITIAL_CHUNK_SIZE"
))
csize
=
atoi
(
getenv
(
"INITIAL_CHUNK_SIZE"
));
...
...
@@ -126,7 +105,7 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
fprintf
(
stderr
,
"=== end ===
\n
"
);
}
#endif
rval
=
zer_decode
(
0
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
rval
=
asn_decode
(
0
,
syntax
,
&
asn_DEF_PDU
,
(
void
**
)
&
st
,
fbuf
+
fbuf_offset
,
fbuf_chunk
<
fbuf_left
?
fbuf_chunk
:
fbuf_left
);
...
...
@@ -140,7 +119,7 @@ load_object_from(enum expectation expectation, unsigned char *fbuf, size_t size,
if
(
expectation
!=
EXP_BROKEN
)
{
assert
(
rval
.
code
==
RC_OK
);
if
(
how
==
AS_D
ER
)
{
if
(
syntax
==
ATS_B
ER
)
{
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
assert
((
fbuf_offset
+
1
/* "\n" */
==
(
ssize_t
)
size
...
...
@@ -200,15 +179,15 @@ static void
process_XER_data
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
)
{
PDU_t
*
st
;
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
A
S
_XER
);
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
A
TS_BASIC
_XER
);
if
(
!
st
)
return
;
/* Save and re-load as DER */
save_object_as
(
st
,
AS_DER
);
st
=
load_object_from
(
expectation
,
buf
,
buf_offset
,
A
S_D
ER
);
save_object_as
(
st
,
A
T
S_DER
);
st
=
load_object_from
(
expectation
,
buf
,
buf_offset
,
A
TS_B
ER
);
assert
(
st
);
save_object_as
(
st
,
A
S
_XER
);
save_object_as
(
st
,
A
TS_BASIC
_XER
);
fprintf
(
stderr
,
"=== original ===
\n
"
);
fwrite
(
fbuf
,
1
,
size
,
stderr
);
fprintf
(
stderr
,
"=== re-encoded ===
\n
"
);
...
...
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