Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asn1c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
oai
asn1c
Commits
c2350118
Commit
c2350118
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
proper XER encoding of native enumerated type
parent
84109519
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
skeletons/INTEGER.c
+6
-8
6 additions, 8 deletions
skeletons/INTEGER.c
skeletons/NativeEnumerated.c
+33
-1
33 additions, 1 deletion
skeletons/NativeEnumerated.c
skeletons/NativeEnumerated.h
+3
-1
3 additions, 1 deletion
skeletons/NativeEnumerated.h
with
42 additions
and
10 deletions
skeletons/INTEGER.c
+
6
−
8
View file @
c2350118
...
...
@@ -6,7 +6,6 @@
#include
<asn_internal.h>
#include
<INTEGER.h>
#include
<asn_codecs_prim.h>
/* Encoder and decoder of a primitive type */
#include
<assert.h>
#include
<errno.h>
/*
...
...
@@ -93,8 +92,7 @@ INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
return
der_encode_primitive
(
td
,
sptr
,
tag_mode
,
tag
,
cb
,
app_key
);
}
static
const
asn_INTEGER_enum_map_t
*
INTEGER__map_value2enum
(
asn_INTEGER_specifics_t
*
specs
,
long
value
);
static
const
asn_INTEGER_enum_map_t
*
INTEGER__map_enum2value
(
asn_INTEGER_specifics_t
*
specs
,
const
char
*
lstart
,
const
char
*
lstop
);
static
const
asn_INTEGER_enum_map_t
*
INTEGER_map_enum2value
(
asn_INTEGER_specifics_t
*
specs
,
const
char
*
lstart
,
const
char
*
lstop
);
/*
* INTEGER specific human-readable output.
...
...
@@ -139,7 +137,7 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by
accum
=
(
accum
<<
8
)
|
*
buf
;
}
el
=
INTEGER_
_
map_value2enum
(
specs
,
accum
);
el
=
INTEGER_map_value2enum
(
specs
,
accum
);
if
(
el
)
{
scrsize
=
el
->
enum_len
+
32
;
scr
=
(
char
*
)
alloca
(
scrsize
);
...
...
@@ -240,7 +238,7 @@ INTEGER__compar_enum2value(const void *kp, const void *am) {
}
static
const
asn_INTEGER_enum_map_t
*
INTEGER_
_
map_enum2value
(
asn_INTEGER_specifics_t
*
specs
,
const
char
*
lstart
,
const
char
*
lstop
)
{
INTEGER_map_enum2value
(
asn_INTEGER_specifics_t
*
specs
,
const
char
*
lstart
,
const
char
*
lstop
)
{
asn_INTEGER_enum_map_t
*
el_found
;
int
count
=
specs
?
specs
->
map_count
:
0
;
struct
e2v_key
key
;
...
...
@@ -287,8 +285,8 @@ INTEGER__compar_value2enum(const void *kp, const void *am) {
else
return
1
;
}
static
const
asn_INTEGER_enum_map_t
*
INTEGER_
_
map_value2enum
(
asn_INTEGER_specifics_t
*
specs
,
long
value
)
{
const
asn_INTEGER_enum_map_t
*
INTEGER_map_value2enum
(
asn_INTEGER_specifics_t
*
specs
,
long
value
)
{
int
count
=
specs
?
specs
->
map_count
:
0
;
if
(
!
count
)
return
0
;
return
(
asn_INTEGER_enum_map_t
*
)
bsearch
(
&
value
,
specs
->
value2enum
,
...
...
@@ -366,7 +364,7 @@ INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun
case
0x3c
:
/* '<' */
if
(
state
==
ST_SKIPSPACE
)
{
const
asn_INTEGER_enum_map_t
*
el
;
el
=
INTEGER_
_
map_enum2value
(
el
=
INTEGER_map_enum2value
(
(
asn_INTEGER_specifics_t
*
)
td
->
specifics
,
lstart
,
lstop
);
if
(
el
)
{
...
...
This diff is collapsed.
Click to expand it.
skeletons/NativeEnumerated.c
+
33
−
1
View file @
c2350118
...
...
@@ -27,7 +27,7 @@ asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = {
NativeInteger_decode_ber
,
NativeInteger_encode_der
,
NativeInteger_decode_xer
,
Native
Integer
_encode_xer
,
Native
Enumerated
_encode_xer
,
0
,
/* Use generic outmost tag fetcher */
asn_DEF_NativeEnumerated_tags
,
sizeof
(
asn_DEF_NativeEnumerated_tags
)
/
sizeof
(
asn_DEF_NativeEnumerated_tags
[
0
]),
...
...
@@ -37,3 +37,35 @@ asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = {
0
/* No specifics */
};
asn_enc_rval_t
NativeEnumerated_encode_xer
(
asn_TYPE_descriptor_t
*
td
,
void
*
sptr
,
int
ilevel
,
enum
xer_encoder_flags_e
flags
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
asn_INTEGER_specifics_t
*
specs
=
(
asn_INTEGER_specifics_t
*
)
td
->
specifics
;
asn_enc_rval_t
er
;
const
long
*
native
=
(
const
long
*
)
sptr
;
const
asn_INTEGER_enum_map_t
*
el
;
(
void
)
ilevel
;
(
void
)
flags
;
if
(
!
native
)
_ASN_ENCODE_FAILED
;
el
=
INTEGER_map_value2enum
(
specs
,
*
native
);
if
(
el
)
{
size_t
srcsize
=
el
->
enum_len
+
5
;
char
*
src
=
(
char
*
)
alloca
(
srcsize
);
er
.
encoded
=
snprintf
(
src
,
srcsize
,
"<%s/>"
,
el
->
enum_name
);
assert
(
er
.
encoded
>
0
&&
(
size_t
)
er
.
encoded
<
srcsize
);
if
(
cb
(
src
,
er
.
encoded
,
app_key
)
<
0
)
_ASN_ENCODE_FAILED
;
return
er
;
}
else
{
ASN_DEBUG
(
"ASN.1 forbids dealing with "
"unknown value of ENUMERATED type"
);
_ASN_ENCODE_FAILED
;
}
return
er
;
}
This diff is collapsed.
Click to expand it.
skeletons/NativeEnumerated.h
+
3
−
1
View file @
c2350118
/*-
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2004
, 2005
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
/*
...
...
@@ -16,4 +16,6 @@
extern
asn_TYPE_descriptor_t
asn_DEF_NativeEnumerated
;
xer_type_encoder_f
NativeEnumerated_encode_xer
;
#endif
/* _NativeEnumerated_H_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment