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
1550e5c9
Commit
1550e5c9
authored
Feb 10, 2014
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change type width detection logic
parent
334d5cc7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
33 deletions
+53
-33
asn1c/tests/check-134.-gen-PER.c
asn1c/tests/check-134.-gen-PER.c
+44
-29
tests/134-per-long-OK.asn1.-Pgen-PER
tests/134-per-long-OK.asn1.-Pgen-PER
+9
-4
No files found.
asn1c/tests/check-134.-gen-PER.c
View file @
1550e5c9
...
...
@@ -26,11 +26,23 @@ static unsigned long i2ul(const INTEGER_t *i) {
return
l
;
}
static
long
i2l
(
const
INTEGER_t
*
i
)
{
long
l
;
int
ret
=
asn_INTEGER2long
(
i
,
&
l
);
assert
(
ret
==
0
);
return
l
;
}
static
void
ul2i
(
INTEGER_t
*
i
,
unsigned
long
l
)
{
int
ret
=
asn_ulong2INTEGER
(
i
,
l
);
assert
(
ret
==
0
);
}
static
void
l2i
(
INTEGER_t
*
i
,
long
l
)
{
int
ret
=
asn_long2INTEGER
(
i
,
l
);
assert
(
ret
==
0
);
}
static
void
verify
(
int
testNo
,
T_t
*
ti
)
{
asn_enc_rval_t
er
;
...
...
@@ -40,7 +52,7 @@ verify(int testNo, T_t *ti) {
fprintf
(
stderr
,
"%d IN: { %lu, %lu, %ld, %ld }
\n
"
,
testNo
,
i2ul
(
&
ti
->
unsigned33
),
i2ul
(
&
ti
->
unsigned42
),
i2
ul
(
&
ti
->
signed33
),
ti
->
signed33ext
i2
l
(
&
ti
->
signed33
),
i2l
(
&
ti
->
signed33ext
)
);
er
=
uper_encode_to_buffer
(
&
asn_DEF_T
,
ti
,
buf
,
sizeof
buf
);
...
...
@@ -55,13 +67,13 @@ verify(int testNo, T_t *ti) {
fprintf
(
stderr
,
"%d OUT: { %lu, %lu, %ld, %ld } vs { %lu, %lu, %ld, %ld }
\n
"
,
testNo
,
i2ul
(
&
ti
->
unsigned33
),
i2ul
(
&
ti
->
unsigned42
),
i2
ul
(
&
ti
->
signed33
),
ti
->
signed33ext
,
i2
l
(
&
ti
->
signed33
),
i2l
(
&
ti
->
signed33ext
)
,
i2ul
(
&
to
->
unsigned33
),
i2ul
(
&
to
->
unsigned42
),
i2
ul
(
&
to
->
signed33
),
to
->
signed33ext
);
i2
l
(
&
to
->
signed33
),
i2l
(
&
to
->
signed33ext
)
);
assert
(
i2ul
(
&
ti
->
unsigned33
)
==
i2ul
(
&
to
->
unsigned33
));
assert
(
i2ul
(
&
ti
->
unsigned42
)
==
i2ul
(
&
to
->
unsigned42
));
assert
(
i2
ul
(
&
ti
->
signed33
)
==
i2u
l
(
&
to
->
signed33
));
assert
(
ti
->
signed33ext
==
to
->
signed33ext
);
assert
(
i2
l
(
&
ti
->
signed33
)
==
i2
l
(
&
to
->
signed33
));
assert
(
i2l
(
&
ti
->
signed33ext
)
==
i2l
(
&
to
->
signed33ext
)
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
ti
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
to
);
...
...
@@ -72,8 +84,10 @@ NO_encode(int testNo, T_t *ti) {
asn_enc_rval_t
er
;
unsigned
char
buf
[
16
];
fprintf
(
stderr
,
"%d IN: { %lu, %lu }
\n
"
,
testNo
,
i2ul
(
&
ti
->
unsigned33
),
i2ul
(
&
ti
->
unsigned42
));
fprintf
(
stderr
,
"%d IN: { %lu, %lu, %ld, %ld }
\n
"
,
testNo
,
i2ul
(
&
ti
->
unsigned33
),
i2ul
(
&
ti
->
unsigned42
),
i2l
(
&
ti
->
signed33
),
i2l
(
&
ti
->
signed33ext
)
);
er
=
uper_encode_to_buffer
(
&
asn_DEF_T
,
ti
,
buf
,
sizeof
buf
);
assert
(
er
.
encoded
==
-
1
);
...
...
@@ -85,68 +99,69 @@ int main() {
memset
(
&
ti
,
0
,
sizeof
(
ti
));
ul2i
(
&
ti
.
unsigned33
,
0
);
ul2i
(
&
ti
.
unsigned42
,
0
);
u
l2i
(
&
ti
.
signed33
,
0
);
ti
.
signed33ext
=
0
;
l2i
(
&
ti
.
signed33
,
0
);
l2i
(
&
ti
.
signed33ext
,
0
)
;
verify
(
1
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
1
);
ul2i
(
&
ti
.
unsigned42
,
1
);
u
l2i
(
&
ti
.
signed33
,
1
);
ti
.
signed33ext
=
1
;
l2i
(
&
ti
.
signed33
,
1
);
l2i
(
&
ti
.
signed33ext
,
1
)
;
verify
(
2
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
5000000000
);
ul2i
(
&
ti
.
unsigned42
,
3153600000000
);
u
l2i
(
&
ti
.
signed33
,
4000000000
);
ti
.
signed33ext
=
4000000000
;
l2i
(
&
ti
.
signed33
,
4000000000
);
l2i
(
&
ti
.
signed33ext
,
4000000000
)
;
verify
(
3
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
-
1
);
ul2i
(
&
ti
.
unsigned42
,
0
);
u
l2i
(
&
ti
.
signed33
,
0
);
ti
.
signed33ext
=
0
;
l2i
(
&
ti
.
signed33
,
0
);
l2i
(
&
ti
.
signed33ext
,
0
)
;
NO_encode
(
4
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
0
);
ul2i
(
&
ti
.
unsigned42
,
-
1
);
u
l2i
(
&
ti
.
signed33
,
0
);
ti
.
signed33ext
=
0
;
l2i
(
&
ti
.
signed33
,
0
);
l2i
(
&
ti
.
signed33ext
,
0
)
;
NO_encode
(
5
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
0
);
ul2i
(
&
ti
.
unsigned42
,
0
);
u
l2i
(
&
ti
.
signed33
,
-
4000000000
-
1
);
ti
.
signed33ext
=
0
;
l2i
(
&
ti
.
signed33
,
-
4000000000
-
1
);
l2i
(
&
ti
.
signed33ext
,
0
)
;
NO_encode
(
6
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
0
);
ul2i
(
&
ti
.
unsigned42
,
0
);
ul2i
(
&
ti
.
signed33
,
0
);
ti
.
signed33ext
=
-
4000000000
-
1
;
l2i
(
&
ti
.
signed33
,
0
);
l2i
(
&
ti
.
signed33ext
,
-
4000000000
-
1
);
assert
(
ti
.
signed33ext
.
size
==
5
);
verify
(
7
,
&
ti
);
/* signed33ext is extensible */
ul2i
(
&
ti
.
unsigned33
,
5000000000
+
1
);
ul2i
(
&
ti
.
unsigned42
,
0
);
u
l2i
(
&
ti
.
signed33
,
0
);
ti
.
signed33ext
=
0
;
l2i
(
&
ti
.
signed33
,
0
);
l2i
(
&
ti
.
signed33ext
,
0
)
;
NO_encode
(
8
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
0
);
ul2i
(
&
ti
.
unsigned42
,
3153600000000
+
1
);
u
l2i
(
&
ti
.
signed33
,
0
);
ti
.
signed33ext
=
0
;
l2i
(
&
ti
.
signed33
,
0
);
l2i
(
&
ti
.
signed33ext
,
0
)
;
NO_encode
(
9
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
5000000000
-
1
);
ul2i
(
&
ti
.
unsigned42
,
3153600000000
-
1
);
u
l2i
(
&
ti
.
signed33
,
4000000000
-
1
);
ti
.
signed33ext
=
4000000000
-
1
;
l2i
(
&
ti
.
signed33
,
4000000000
-
1
);
l2i
(
&
ti
.
signed33ext
,
4000000000
-
1
)
;
verify
(
10
,
&
ti
);
ul2i
(
&
ti
.
unsigned33
,
0
);
ul2i
(
&
ti
.
unsigned42
,
0
);
u
l2i
(
&
ti
.
signed33
,
0
);
ti
.
signed33ext
=
4000000000
+
1
;
l2i
(
&
ti
.
signed33
,
0
);
l2i
(
&
ti
.
signed33ext
,
4000000000
+
1
)
;
verify
(
11
,
&
ti
);
return
0
;
...
...
tests/134-per-long-OK.asn1.-Pgen-PER
View file @
1550e5c9
...
...
@@ -2,7 +2,6 @@
/*** <<< INCLUDES [T] >>> ***/
#include <INTEGER.h>
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [T] >>> ***/
...
...
@@ -11,7 +10,7 @@ typedef struct T {
INTEGER_t unsigned33;
INTEGER_t unsigned42;
INTEGER_t signed33;
long
signed33ext;
INTEGER_t
signed33ext;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
...
...
@@ -119,6 +118,7 @@ memb_signed33_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
static int
memb_signed33ext_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const INTEGER_t *st = (const INTEGER_t *)sptr;
long value;
if(!sptr) {
...
...
@@ -128,7 +128,12 @@ memb_signed33ext_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
return -1;
}
value = *(const long *)sptr;
if(asn_INTEGER2long(st, &value)) {
_ASN_CTFAIL(app_key, td, sptr,
"%s: value too large (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if((value >= -4000000000 && value <= 4000000000)) {
/* Constraint check succeeded */
...
...
@@ -198,7 +203,7 @@ static asn_TYPE_member_t asn_MBR_T_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct T, signed33ext),
.tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_
NativeInteger
,
.type = &asn_DEF_
INTEGER
,
.memb_constraints = memb_signed33ext_constraint_1,
.per_constraints = &asn_PER_memb_signed33ext_constr_5,
.default_value = 0,
...
...
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