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
8d01b4c0
Commit
8d01b4c0
authored
Oct 23, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CHOICE XER support, draft
parent
ca47c29a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
174 additions
and
0 deletions
+174
-0
skeletons/constr_CHOICE.c
skeletons/constr_CHOICE.c
+173
-0
skeletons/constr_CHOICE.h
skeletons/constr_CHOICE.h
+1
-0
No files found.
skeletons/constr_CHOICE.c
View file @
8d01b4c0
...
@@ -539,6 +539,179 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -539,6 +539,179 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
}
}
}
}
#undef ADVANCE
/* Just in case */
#undef XER_ADVANCE
#define XER_ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
buf_ptr = ((char *)buf_ptr) + num; \
size -= num; \
consumed_myself += num; \
} while(0)
asn_dec_rval_t
CHOICE_decode_xer
(
asn_codec_ctx_t
*
opt_codec_ctx
,
asn_TYPE_descriptor_t
*
td
,
void
**
struct_ptr
,
const
char
*
opt_mname
,
void
*
buf_ptr
,
size_t
size
)
{
/*
* Bring closer parts of structure description.
*/
asn_CHOICE_specifics_t
*
specs
=
(
asn_CHOICE_specifics_t
*
)
td
->
specifics
;
const
char
*
xml_tag
=
opt_mname
?
opt_mname
:
td
->
xml_tag
;
/*
* Parts of the structure being constructed.
*/
void
*
st
=
*
struct_ptr
;
/* Target structure. */
asn_struct_ctx_t
*
ctx
;
/* Decoder context */
asn_dec_rval_t
rval
;
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
int
xer_state
;
/* XER low level parsing context */
int
edx
;
/* Element index */
/*
* Create the target structure if it is not present already.
*/
if
(
st
==
0
)
{
st
=
*
struct_ptr
=
CALLOC
(
1
,
specs
->
struct_size
);
if
(
st
==
0
)
RETURN
(
RC_FAIL
);
}
/*
* Restore parsing context.
*/
ctx
=
(
asn_struct_ctx_t
*
)((
char
*
)
st
+
specs
->
ctx_offset
);
/*
* Phases of XER/XML processing:
* Phase 0: Check that the opening tag matches our expectations.
* Phase 1: Processing body and reacting on closing tag.
* Phase 2: Processing inner type.
* Phase 3: Only waiting for closing tag
*/
if
(
ctx
->
phase
>
3
)
RETURN
(
RC_FAIL
);
for
(
xer_state
=
ctx
->
left
,
edx
=
ctx
->
step
;;)
{
pxer_chunk_type_e
ch_type
;
/* XER chunk type */
ssize_t
ch_size
;
/* Chunk size */
xer_check_tag_e
tcv
;
/* Tag check value */
asn_TYPE_member_t
*
elm
;
/*
* Go inside the member.
*/
if
(
ctx
->
phase
==
2
)
{
asn_dec_rval_t
tmprval
;
elm
=
&
td
->
elements
[
edx
];
void
*
memb_ptr
;
/* Pointer to the member */
void
**
memb_ptr2
;
/* Pointer to that pointer */
if
(
elm
->
flags
&
ATF_POINTER
)
{
/* Member is a pointer to another structure */
memb_ptr2
=
(
void
**
)((
char
*
)
st
+
elm
->
memb_offset
);
}
else
{
memb_ptr
=
(
char
*
)
st
+
elm
->
memb_offset
;
memb_ptr2
=
&
memb_ptr
;
}
tmprval
=
elm
->
type
->
xer_decoder
(
opt_codec_ctx
,
elm
->
type
,
memb_ptr2
,
elm
->
name
,
buf_ptr
,
size
);
XER_ADVANCE
(
tmprval
.
consumed
);
if
(
tmprval
.
code
!=
RC_OK
)
RETURN
(
tmprval
.
code
);
ctx
->
left
=
xer_state
=
0
;
/* New, clean state */
ctx
->
phase
=
3
;
/* Fall through */
}
/*
* Get the next part of the XML stream.
*/
ch_size
=
xer_next_token
(
&
xer_state
,
buf_ptr
,
size
,
&
ch_type
);
switch
(
ch_size
)
{
case
-
1
:
RETURN
(
RC_FAIL
);
case
0
:
ctx
->
left
=
xer_state
;
RETURN
(
RC_WMORE
);
default:
switch
(
ch_type
)
{
case
PXER_COMMENT
:
/* Got XML comment */
case
PXER_TEXT
:
/* Ignore free-standing text */
XER_ADVANCE
(
ch_size
);
/* Skip silently */
continue
;
case
PXER_TAG
:
break
;
/* Check the rest down there */
}
}
tcv
=
xer_check_tag
(
buf_ptr
,
size
,
xml_tag
);
switch
(
tcv
)
{
case
XCT_BOTH
:
if
(
ctx
->
phase
==
3
)
break
;
case
XCT_CLOSING
:
if
(
ctx
->
phase
==
0
)
break
;
XER_ADVANCE
(
ch_size
);
ctx
->
phase
=
4
;
RETURN
(
RC_OK
);
case
XCT_OPENING
:
if
(
ctx
->
phase
==
0
)
{
XER_ADVANCE
(
ch_size
);
ctx
->
phase
=
1
;
/* Processing body phase */
continue
;
}
else
if
(
ctx
->
phase
==
3
)
{
/* But we're waiting for closing! */
break
;
}
/* Fall through */
case
XCT_UNEXPECTED
:
if
(
ctx
->
phase
!=
1
)
break
;
/* Really unexpected */
/*
* Search which member corresponds to this tag.
*/
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
elm
=
&
td
->
elements
[
edx
];
tcv
=
xer_check_tag
(
buf_ptr
,
size
,
elm
->
name
);
switch
(
tcv
)
{
case
XCT_BOTH
:
case
XCT_OPENING
:
/*
* Process this member.
*/
ctx
->
step
=
edx
;
ctx
->
phase
=
2
;
break
;
case
XCT_UNEXPECTED
:
continue
;
/* or continue; */
case
XCT_CLOSING
:
default:
edx
=
td
->
elements_count
;
break
;
/* Phase out */
}
break
;
}
if
(
edx
==
td
->
elements_count
)
break
;
continue
;
default:
break
;
}
ASN_DEBUG
(
"Unexpected XML tag in SEQUENCE"
);
break
;
}
ctx
->
phase
=
4
;
/* Phase out, just in case */
RETURN
(
RC_FAIL
);
}
asn_enc_rval_t
asn_enc_rval_t
CHOICE_encode_xer
(
asn_TYPE_descriptor_t
*
td
,
void
*
sptr
,
CHOICE_encode_xer
(
asn_TYPE_descriptor_t
*
td
,
void
*
sptr
,
int
ilevel
,
enum
xer_encoder_flags_e
flags
,
int
ilevel
,
enum
xer_encoder_flags_e
flags
,
...
...
skeletons/constr_CHOICE.h
View file @
8d01b4c0
...
@@ -36,6 +36,7 @@ asn_struct_print_f CHOICE_print;
...
@@ -36,6 +36,7 @@ asn_struct_print_f CHOICE_print;
asn_constr_check_f
CHOICE_constraint
;
asn_constr_check_f
CHOICE_constraint
;
ber_type_decoder_f
CHOICE_decode_ber
;
ber_type_decoder_f
CHOICE_decode_ber
;
der_type_encoder_f
CHOICE_encode_der
;
der_type_encoder_f
CHOICE_encode_der
;
xer_type_decoder_f
CHOICE_decode_xer
;
xer_type_encoder_f
CHOICE_encode_xer
;
xer_type_encoder_f
CHOICE_encode_xer
;
asn_outmost_tag_f
CHOICE_outmost_tag
;
asn_outmost_tag_f
CHOICE_outmost_tag
;
...
...
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