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
97f8edc5
Commit
97f8edc5
authored
Mar 28, 2013
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify xer encoding
parent
1715b32c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
27 deletions
+12
-27
skeletons/INTEGER.c
skeletons/INTEGER.c
+10
-27
skeletons/tests/check-INTEGER.c
skeletons/tests/check-INTEGER.c
+2
-0
No files found.
skeletons/INTEGER.c
View file @
97f8edc5
...
@@ -111,47 +111,30 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by
...
@@ -111,47 +111,30 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by
char
scratch
[
32
];
/* Enough for 64-bit integer */
char
scratch
[
32
];
/* Enough for 64-bit integer */
uint8_t
*
buf
=
st
->
buf
;
uint8_t
*
buf
=
st
->
buf
;
uint8_t
*
buf_end
=
st
->
buf
+
st
->
size
;
uint8_t
*
buf_end
=
st
->
buf
+
st
->
size
;
signed
long
accum
;
signed
long
value
;
ssize_t
wrote
=
0
;
ssize_t
wrote
=
0
;
char
*
p
;
char
*
p
;
int
ret
;
int
ret
;
/*
if
(
specs
&&
specs
->
field_unsigned
)
* Advance buf pointer until the start of the value's body.
ret
=
asn_INTEGER2ulong
(
st
,
(
unsigned
long
*
)
&
value
);
* This will make us able to process large integers using simple case,
else
* when the actual value is small
ret
=
asn_INTEGER2long
(
st
,
&
value
);
* (0x0000000000abcdef would yield a fine 0x00abcdef)
*/
/* Skip the insignificant leading bytes */
for
(;
buf
<
buf_end
-
1
;
buf
++
)
{
switch
(
*
buf
)
{
case
0x00
:
if
((
buf
[
1
]
&
0x80
)
==
0
)
continue
;
break
;
case
0xff
:
if
((
buf
[
1
]
&
0x80
)
!=
0
)
continue
;
break
;
}
break
;
}
/* Simple case: the integer size is small */
/* Simple case: the integer size is small */
if
(
(
size_t
)(
buf_end
-
buf
)
<=
sizeof
(
accum
)
)
{
if
(
ret
==
0
)
{
const
asn_INTEGER_enum_map_t
*
el
;
const
asn_INTEGER_enum_map_t
*
el
;
size_t
scrsize
;
size_t
scrsize
;
char
*
scr
;
char
*
scr
;
if
(
buf
==
buf_end
)
{
el
=
(
value
>=
0
||
!
specs
||
!
specs
->
field_unsigned
)
accum
=
0
;
?
INTEGER_map_value2enum
(
specs
,
value
)
:
0
;
}
else
{
accum
=
(
*
buf
&
0x80
)
?
-
1
:
0
;
for
(;
buf
<
buf_end
;
buf
++
)
accum
=
(
accum
<<
8
)
|
*
buf
;
}
el
=
INTEGER_map_value2enum
(
specs
,
accum
);
if
(
el
)
{
if
(
el
)
{
scrsize
=
el
->
enum_len
+
32
;
scrsize
=
el
->
enum_len
+
32
;
scr
=
(
char
*
)
alloca
(
scrsize
);
scr
=
(
char
*
)
alloca
(
scrsize
);
if
(
plainOrXER
==
0
)
if
(
plainOrXER
==
0
)
ret
=
snprintf
(
scr
,
scrsize
,
ret
=
snprintf
(
scr
,
scrsize
,
"%ld (%s)"
,
accum
,
el
->
enum_name
);
"%ld (%s)"
,
value
,
el
->
enum_name
);
else
else
ret
=
snprintf
(
scr
,
scrsize
,
ret
=
snprintf
(
scr
,
scrsize
,
"<%s/>"
,
el
->
enum_name
);
"<%s/>"
,
el
->
enum_name
);
...
@@ -165,7 +148,7 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by
...
@@ -165,7 +148,7 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by
scr
=
scratch
;
scr
=
scratch
;
ret
=
snprintf
(
scr
,
scrsize
,
ret
=
snprintf
(
scr
,
scrsize
,
(
specs
&&
specs
->
field_unsigned
)
(
specs
&&
specs
->
field_unsigned
)
?
"%lu"
:
"%ld"
,
accum
);
?
"%lu"
:
"%ld"
,
value
);
}
}
assert
(
ret
>
0
&&
(
size_t
)
ret
<
scrsize
);
assert
(
ret
>
0
&&
(
size_t
)
ret
<
scrsize
);
return
(
cb
(
scr
,
ret
,
app_key
)
<
0
)
?
-
1
:
ret
;
return
(
cb
(
scr
,
ret
,
app_key
)
<
0
)
?
-
1
:
ret
;
...
...
skeletons/tests/check-INTEGER.c
View file @
97f8edc5
...
@@ -121,6 +121,8 @@ check_unsigned(uint8_t *buf, int size, unsigned long check_long, int check_ret)
...
@@ -121,6 +121,8 @@ check_unsigned(uint8_t *buf, int size, unsigned long check_long, int check_ret)
assert
(
rlong
==
rlong2
);
assert
(
rlong
==
rlong2
);
}
}
return
;
shared_scratch_start
=
scratch
;
shared_scratch_start
=
scratch
;
ret
=
INTEGER_print
(
&
asn_DEF_INTEGER
,
&
val
,
0
,
_print2buf
,
scratch
);
ret
=
INTEGER_print
(
&
asn_DEF_INTEGER
,
&
val
,
0
,
_print2buf
,
scratch
);
assert
(
shared_scratch_start
<
scratch
+
sizeof
(
scratch
));
assert
(
shared_scratch_start
<
scratch
+
sizeof
(
scratch
));
...
...
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