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
30520ab3
Commit
30520ab3
authored
Sep 04, 2012
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tighten code according to tag invariant
parent
aed43c8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
skeletons/asn_codecs_prim.c
skeletons/asn_codecs_prim.c
+23
-11
No files found.
skeletons/asn_codecs_prim.c
View file @
30520ab3
...
...
@@ -143,20 +143,26 @@ struct xdp_arg_s {
int
want_more
;
};
/*
* Since some kinds of primitive values can be encoded using value-specific
* tags (<MINUS-INFINITY>, <enum-element>, etc), the primitive decoder must
* be supplied with such tags to parse them as needed.
*/
static
int
xer_decode__unexpected_tag
(
void
*
key
,
const
void
*
chunk_buf
,
size_t
chunk_size
)
{
struct
xdp_arg_s
*
arg
=
(
struct
xdp_arg_s
*
)
key
;
enum
xer_pbd_rval
bret
;
if
(
arg
->
decoded_something
)
{
if
(
xer_is_whitespace
(
chunk_buf
,
chunk_size
))
return
0
;
/* Skip it. */
/*
* Decoding was done once already. Prohibit doing it again.
*/
/*
* The chunk_buf is guaranteed to start at '<'.
*/
assert
(
chunk_size
&&
((
const
char
*
)
chunk_buf
)[
0
]
==
0x3c
);
/*
* Decoding was performed once already. Prohibit doing it again.
*/
if
(
arg
->
decoded_something
)
return
-
1
;
}
bret
=
arg
->
prim_body_decoder
(
arg
->
type_descriptor
,
arg
->
struct_key
,
chunk_buf
,
chunk_size
);
...
...
@@ -177,13 +183,19 @@ xer_decode__unexpected_tag(void *key, const void *chunk_buf, size_t chunk_size)
}
static
ssize_t
xer_decode__body
(
void
*
key
,
const
void
*
chunk_buf
,
size_t
chunk_size
,
int
have_more
)
{
xer_decode__
primitive_
body
(
void
*
key
,
const
void
*
chunk_buf
,
size_t
chunk_size
,
int
have_more
)
{
struct
xdp_arg_s
*
arg
=
(
struct
xdp_arg_s
*
)
key
;
enum
xer_pbd_rval
bret
;
if
(
arg
->
decoded_something
)
{
if
(
xer_is_whitespace
(
chunk_buf
,
chunk_size
))
if
(
xer_is_whitespace
(
chunk_buf
,
chunk_size
))
{
/*
* Example:
* "<INTEGER>123<!--/--> </INTEGER>"
* ^- chunk_buf position.
*/
return
chunk_size
;
}
/*
* Decoding was done once already. Prohibit doing it again.
*/
...
...
@@ -253,7 +265,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
rc
=
xer_decode_general
(
opt_codec_ctx
,
&
s_ctx
,
&
s_arg
,
xml_tag
,
buf_ptr
,
size
,
xer_decode__unexpected_tag
,
xer_decode__body
);
xer_decode__unexpected_tag
,
xer_decode__
primitive_
body
);
switch
(
rc
.
code
)
{
case
RC_OK
:
if
(
!
s_arg
.
decoded_something
)
{
...
...
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