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
d9ce1d51
Commit
d9ce1d51
authored
Feb 06, 2024
by
v0-e
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aper: INTEGER longs to intmaxs
parent
4cfcd4f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
skeletons/INTEGER_aper.c
skeletons/INTEGER_aper.c
+23
-23
No files found.
skeletons/INTEGER_aper.c
View file @
d9ce1d51
...
...
@@ -57,7 +57,7 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
int
max_range_bytes
=
(
ct
->
range_bits
>>
3
)
+
(((
ct
->
range_bits
%
8
)
>
0
)
?
1
:
0
);
int
length
=
0
,
i
;
long
value
=
0
;
intmax_t
value
=
0
;
for
(
i
=
1
;
;
i
++
)
{
int
upper
=
1
<<
i
;
...
...
@@ -79,18 +79,18 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
int
buf
=
per_get_few_bits
(
pd
,
8
);
if
(
buf
<
0
)
ASN__DECODE_FAILED
;
value
+=
(((
long
)
buf
)
<<
(
8
*
length
));
value
+=
(((
intmax_t
)
buf
)
<<
(
8
*
length
));
}
value
+=
ct
->
lower_bound
;
if
((
specs
&&
specs
->
field_unsigned
)
?
asn_u
int642INTEGER
(
st
,
(
unsigned
long
)
value
)
:
asn_i
nt64
2INTEGER
(
st
,
value
))
?
asn_u
max2INTEGER
(
st
,
(
uintmax_t
)
value
)
:
asn_i
max
2INTEGER
(
st
,
value
))
ASN__DECODE_FAILED
;
ASN_DEBUG
(
"Got value %ld + low %lld"
,
value
,
(
long
long
in
t
)
ct
->
lower_bound
);
value
,
(
intmax_
t
)
ct
->
lower_bound
);
}
else
{
long
value
=
0
;
intmax_t
value
=
0
;
if
(
ct
->
range_bits
<
8
)
{
value
=
per_get_few_bits
(
pd
,
ct
->
range_bits
);
if
(
value
<
0
)
ASN__DECODE_STARVED
;
...
...
@@ -108,11 +108,11 @@ INTEGER_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
}
value
+=
ct
->
lower_bound
;
if
((
specs
&&
specs
->
field_unsigned
)
?
asn_u
long2INTEGER
(
st
,
value
)
:
asn_
long
2INTEGER
(
st
,
value
))
?
asn_u
max2INTEGER
(
st
,
(
uintmax_t
)
value
)
:
asn_
imax
2INTEGER
(
st
,
value
))
ASN__DECODE_FAILED
;
ASN_DEBUG
(
"Got value %ld + low %lld"
,
value
,
(
long
long
in
t
)
ct
->
lower_bound
);
value
,
(
intmax_
t
)
ct
->
lower_bound
);
}
return
rval
;
}
else
{
...
...
@@ -167,7 +167,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
const
uint8_t
*
buf
;
const
uint8_t
*
end
;
const
asn_per_constraint_t
*
ct
;
long
value
=
0
;
intmax_t
value
=
0
;
if
(
!
st
||
st
->
size
==
0
)
ASN__ENCODE_FAILED
;
...
...
@@ -179,26 +179,26 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
if
(
ct
)
{
int
inext
=
0
;
if
(
specs
&&
specs
->
field_unsigned
)
{
u
nsigned
long
uval
;
if
(
asn_INTEGER2u
long
(
st
,
&
uval
))
u
intmax_t
uval
;
if
(
asn_INTEGER2u
max
(
st
,
&
uval
))
ASN__ENCODE_FAILED
;
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
uval
<
(
u
nsigned
long
)
ct
->
lower_bound
)
if
(
uval
<
(
u
intmax_t
)
ct
->
lower_bound
)
inext
=
1
;
}
else
if
(
ct
->
range_bits
>=
0
)
{
if
(
uval
<
(
u
nsigned
long
)
ct
->
lower_bound
||
uval
>
(
u
nsigned
long
)
ct
->
upper_bound
)
if
(
uval
<
(
u
intmax_t
)
ct
->
lower_bound
||
uval
>
(
u
intmax_t
)
ct
->
upper_bound
)
inext
=
1
;
}
ASN_DEBUG
(
"Value %lu (%02x/%zu) lb %lld ub %lld %s"
,
uval
,
st
->
buf
[
0
],
st
->
size
,
(
long
long
in
t
)
ct
->
lower_bound
,
(
long
long
in
t
)
ct
->
upper_bound
,
(
intmax_
t
)
ct
->
lower_bound
,
(
intmax_
t
)
ct
->
upper_bound
,
inext
?
"ext"
:
"fix"
);
value
=
uval
;
}
else
{
if
(
asn_INTEGER2
long
(
st
,
&
value
))
ASN__ENCODE_FAILED
;
if
(
asn_INTEGER2
imax
(
st
,
&
value
))
ASN__ENCODE_FAILED
;
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
value
<
ct
->
lower_bound
)
...
...
@@ -210,8 +210,8 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}
ASN_DEBUG
(
"Value %lu (%02x/%zu) lb %lld ub %lld %s"
,
value
,
st
->
buf
[
0
],
st
->
size
,
(
long
long
in
t
)
ct
->
lower_bound
,
(
long
long
in
t
)
ct
->
upper_bound
,
(
intmax_
t
)
ct
->
lower_bound
,
(
intmax_
t
)
ct
->
upper_bound
,
inext
?
"ext"
:
"fix"
);
}
if
(
ct
->
flags
&
APC_EXTENSIBLE
)
{
...
...
@@ -225,11 +225,11 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
/* X.691, #12.2.2 */
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
u
nsigned
long
v
;
u
intmax_t
v
;
/* #10.5.6 */
ASN_DEBUG
(
"Encoding integer %ld (%lld) with range %d bits"
,
value
,
(
long
long
in
t
)(
value
-
ct
->
lower_bound
),
value
,
(
intmax_
t
)(
value
-
ct
->
lower_bound
),
ct
->
range_bits
);
v
=
value
-
ct
->
lower_bound
;
...
...
@@ -287,7 +287,7 @@ INTEGER_encode_aper(const asn_TYPE_descriptor_t *td,
}
if
(
ct
&&
ct
->
lower_bound
)
{
ASN_DEBUG
(
"Adjust lower bound to %lld"
,
(
long
long
in
t
)
ct
->
lower_bound
);
ASN_DEBUG
(
"Adjust lower bound to %lld"
,
(
intmax_
t
)
ct
->
lower_bound
);
/* TODO: adjust lower bound */
ASN__ENCODE_FAILED
;
}
...
...
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