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
8bb4a952
Commit
8bb4a952
authored
Feb 14, 2005
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SET OF XER support
parent
d5125645
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
173 additions
and
4 deletions
+173
-4
skeletons/constr_SEQUENCE_OF.h
skeletons/constr_SEQUENCE_OF.h
+3
-2
skeletons/constr_SET.c
skeletons/constr_SET.c
+2
-2
skeletons/constr_SET.h
skeletons/constr_SET.h
+1
-0
skeletons/constr_SET_OF.c
skeletons/constr_SET_OF.c
+166
-0
skeletons/constr_SET_OF.h
skeletons/constr_SET_OF.h
+1
-0
No files found.
skeletons/constr_SEQUENCE_OF.h
View file @
8bb4a952
/*-
/*-
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2003
, 2005
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
* Redistribution and modifications are permitted subject to BSD license.
*/
*/
#ifndef _CONSTR_SEQUENCE_OF_H_
#ifndef _CONSTR_SEQUENCE_OF_H_
...
@@ -10,12 +10,13 @@
...
@@ -10,12 +10,13 @@
/*
/*
* A set specialized functions dealing with the SEQUENCE OF type.
* A set specialized functions dealing with the SEQUENCE OF type.
*
I
mplemented using SET OF.
*
Generally i
mplemented using SET OF.
*/
*/
#define SEQUENCE_OF_free SET_OF_free
#define SEQUENCE_OF_free SET_OF_free
#define SEQUENCE_OF_print SET_OF_print
#define SEQUENCE_OF_print SET_OF_print
#define SEQUENCE_OF_constraint SET_OF_constraint
#define SEQUENCE_OF_constraint SET_OF_constraint
#define SEQUENCE_OF_decode_ber SET_OF_decode_ber
#define SEQUENCE_OF_decode_ber SET_OF_decode_ber
#define SEQUENCE_OF_decode_xer SET_OF_decode_xer
der_type_encoder_f
SEQUENCE_OF_encode_der
;
der_type_encoder_f
SEQUENCE_OF_encode_der
;
xer_type_encoder_f
SEQUENCE_OF_encode_xer
;
xer_type_encoder_f
SEQUENCE_OF_encode_xer
;
...
...
skeletons/constr_SET.c
View file @
8bb4a952
...
@@ -643,7 +643,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -643,7 +643,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
RETURN
(
RC_FAIL
);
RETURN
(
RC_FAIL
);
}
}
elm
=
&
td
->
elements
[
edx
];
elm
=
&
elements
[
edx
];
if
(
elm
->
flags
&
ATF_POINTER
)
{
if
(
elm
->
flags
&
ATF_POINTER
)
{
/* Member is a pointer to another structure */
/* Member is a pointer to another structure */
...
@@ -724,7 +724,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
...
@@ -724,7 +724,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* Search which member corresponds to this tag.
* Search which member corresponds to this tag.
*/
*/
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
for
(
edx
=
0
;
edx
<
td
->
elements_count
;
edx
++
)
{
elm
=
&
td
->
elements
[
edx
];
elm
=
&
elements
[
edx
];
tcv
=
xer_check_tag
(
buf_ptr
,
ch_size
,
elm
->
name
);
tcv
=
xer_check_tag
(
buf_ptr
,
ch_size
,
elm
->
name
);
switch
(
tcv
)
{
switch
(
tcv
)
{
case
XCT_BOTH
:
case
XCT_BOTH
:
...
...
skeletons/constr_SET.h
View file @
8bb4a952
...
@@ -47,6 +47,7 @@ asn_constr_check_f SET_constraint;
...
@@ -47,6 +47,7 @@ asn_constr_check_f SET_constraint;
ber_type_decoder_f
SET_decode_ber
;
ber_type_decoder_f
SET_decode_ber
;
der_type_encoder_f
SET_encode_der
;
der_type_encoder_f
SET_encode_der
;
xer_type_decoder_f
SET_decode_xer
;
xer_type_decoder_f
SET_decode_xer
;
xer_type_decoder_f
SET_decode_xer
;
xer_type_encoder_f
SET_encode_xer
;
xer_type_encoder_f
SET_encode_xer
;
/***********************
/***********************
...
...
skeletons/constr_SET_OF.c
View file @
8bb4a952
...
@@ -449,6 +449,172 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
...
@@ -449,6 +449,172 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
return
erval
;
return
erval
;
}
}
#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)
/*
* Decode the XER (XML) data.
*/
asn_dec_rval_t
SET_OF_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_SET_OF_specifics_t
*
specs
=
(
asn_SET_OF_specifics_t
*
)
td
->
specifics
;
asn_TYPE_member_t
*
element
=
td
->
elements
;
const
char
*
elm_tag
=
specs
->
as_XMLValueList
?
0
:
((
*
element
->
name
)
?
element
->
name
:
element
->
type
->
xml_tag
);
const
char
*
xml_tag
=
opt_mname
?
opt_mname
:
td
->
xml_tag
;
/*
* ... and parts of the structure being constructed.
*/
void
*
st
=
*
struct_ptr
;
/* Target structure. */
asn_struct_ctx_t
*
ctx
;
/* Decoder context */
asn_dec_rval_t
rval
;
/* Return value from a decoder */
ssize_t
consumed_myself
=
0
;
/* Consumed bytes from ptr */
int
xer_state
;
/* XER low level parsing context */
/*
* 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.
*/
for
(
xer_state
=
ctx
->
left
;
ctx
->
phase
<=
2
;)
{
pxer_chunk_type_e
ch_type
;
/* XER chunk type */
ssize_t
ch_size
;
/* Chunk size */
xer_check_tag_e
tcv
;
/* Tag check value */
/*
* Go inside the inner member of a set.
*/
if
(
ctx
->
phase
==
2
)
{
asn_dec_rval_t
tmprval
;
/* Invoke the inner type decoder, m.b. multiple times */
tmprval
=
element
->
type
->
xer_decoder
(
opt_codec_ctx
,
element
->
type
,
&
ctx
->
ptr
,
elm_tag
,
buf_ptr
,
size
);
if
(
tmprval
.
code
==
RC_OK
)
{
A_SET_OF
(
void
)
*
list
;
(
void
*
)
list
=
(
void
*
)
st
;
if
(
ASN_SET_ADD
(
list
,
ctx
->
ptr
)
!=
0
)
RETURN
(
RC_FAIL
);
ctx
->
ptr
=
0
;
XER_ADVANCE
(
tmprval
.
consumed
);
}
else
{
XER_ADVANCE
(
tmprval
.
consumed
);
RETURN
(
tmprval
.
code
);
}
ctx
->
phase
=
1
;
/* Back to body processing */
ctx
->
left
=
xer_state
=
0
;
/* New, clean state */
ASN_DEBUG
(
"XER/SET OF phase => %d"
,
ctx
->
phase
);
/* 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
,
ch_size
,
xml_tag
);
ASN_DEBUG
(
"XER/SET OF: tcv = %d, ph=%d"
,
tcv
,
ctx
->
phase
);
switch
(
tcv
)
{
case
XCT_CLOSING
:
if
(
ctx
->
phase
==
0
)
break
;
ctx
->
phase
=
0
;
/* Fall through */
case
XCT_BOTH
:
if
(
ctx
->
phase
==
0
)
{
/* No more things to decode */
XER_ADVANCE
(
ch_size
);
ctx
->
phase
=
3
;
/* Phase out */
RETURN
(
RC_OK
);
}
/* Fall through */
case
XCT_OPENING
:
if
(
ctx
->
phase
==
0
)
{
XER_ADVANCE
(
ch_size
);
ctx
->
phase
=
1
;
/* Processing body phase */
continue
;
}
/* Fall through */
case
XCT_UNEXPECTED
:
ASN_DEBUG
(
"XER/SET OF: tcv=%d, ph=%d"
,
tcv
,
ctx
->
phase
);
if
(
ctx
->
phase
!=
1
)
break
;
/* Really unexpected */
/*
* Search which member corresponds to this tag.
*/
tcv
=
xer_check_tag
(
buf_ptr
,
ch_size
,
elm_tag
);
switch
(
tcv
)
{
case
XCT_BOTH
:
case
XCT_OPENING
:
/*
* Process this member.
*/
ctx
->
phase
=
2
;
continue
;
case
XCT_UNEXPECTED
:
case
XCT_CLOSING
:
default:
break
;
/* Phase out */
}
/* Fall through */
default:
break
;
}
ASN_DEBUG
(
"Unexpected XML tag in SET OF"
);
break
;
}
ctx
->
phase
=
3
;
/* "Phase out" on hard failure */
RETURN
(
RC_FAIL
);
}
typedef
struct
xer_tmp_enc_s
{
typedef
struct
xer_tmp_enc_s
{
void
*
buffer
;
void
*
buffer
;
size_t
offset
;
size_t
offset
;
...
...
skeletons/constr_SET_OF.h
View file @
8bb4a952
...
@@ -26,6 +26,7 @@ asn_struct_print_f SET_OF_print;
...
@@ -26,6 +26,7 @@ asn_struct_print_f SET_OF_print;
asn_constr_check_f
SET_OF_constraint
;
asn_constr_check_f
SET_OF_constraint
;
ber_type_decoder_f
SET_OF_decode_ber
;
ber_type_decoder_f
SET_OF_decode_ber
;
der_type_encoder_f
SET_OF_encode_der
;
der_type_encoder_f
SET_OF_encode_der
;
xer_type_decoder_f
SET_OF_decode_xer
;
xer_type_encoder_f
SET_OF_encode_xer
;
xer_type_encoder_f
SET_OF_encode_xer
;
#endif
/* _CONSTR_SET_OF_H_ */
#endif
/* _CONSTR_SET_OF_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