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
Snippets
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
qwebaby3
asn1c
Commits
02b137df
Commit
02b137df
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
refine
parent
d1e5494c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libasn1compiler/asn1c_constraint.c
+33
-23
33 additions, 23 deletions
libasn1compiler/asn1c_constraint.c
with
33 additions
and
23 deletions
libasn1compiler/asn1c_constraint.c
+
33
−
23
View file @
02b137df
...
@@ -70,6 +70,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
...
@@ -70,6 +70,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
if
(
!
(
arg
->
flags
&
A1C_USE_NATIVE_INTEGERS
))
if
(
!
(
arg
->
flags
&
A1C_USE_NATIVE_INTEGERS
))
produce_st
=
1
;
produce_st
=
1
;
break
;
break
;
case
ASN_BASIC_BIT_STRING
:
case
ASN_BASIC_OCTET_STRING
:
case
ASN_BASIC_OCTET_STRING
:
produce_st
=
1
;
produce_st
=
1
;
break
;
break
;
...
@@ -79,7 +80,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
...
@@ -79,7 +80,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
break
;
break
;
}
}
if
(
produce_st
)
if
(
produce_st
)
OUT
(
"const %s_t *st = sptr;
\n
"
,
MKID
(
arg
->
expr
->
Identifier
));
OUT
(
"const %s_t *st = sptr;
\n
"
,
asn1c_type_name
(
arg
,
arg
->
expr
,
TNF_SAFE
));
if
(
r_size
||
r_value
)
{
if
(
r_size
||
r_value
)
{
if
(
r_size
)
{
if
(
r_size
)
{
...
@@ -350,12 +352,13 @@ emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
...
@@ -350,12 +352,13 @@ emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
OUT
(
"/* The underlying type is %s */
\n
"
,
OUT
(
"/* The underlying type is %s */
\n
"
,
ASN_EXPR_TYPE2STR
(
etype
));
ASN_EXPR_TYPE2STR
(
etype
));
OUT
(
"const %s_t *st = sptr;
\n
"
,
MKID
(
arg
->
expr
->
Identifier
));
OUT
(
"const %s_t *st = sptr;
\n
"
,
asn1c_type_name
(
arg
,
arg
->
expr
,
TNF_SAFE
));
switch
(
etype
)
{
switch
(
etype
)
{
case
ASN_STRING_UTF8String
:
case
ASN_STRING_UTF8String
:
OUT
(
"uint8_t *ch = st->buf;
\n
"
);
OUT
(
"
const
uint8_t *ch = st->buf;
\n
"
);
OUT
(
"uint8_t *end = ch + st->size;
\n
"
);
OUT
(
"
const
uint8_t *end = ch + st->size;
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
INDENT
(
+
1
);
INDENT
(
+
1
);
...
@@ -364,35 +367,35 @@ emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
...
@@ -364,35 +367,35 @@ emit_alphabet_check_loop(arg_t *arg, asn1cnst_range_t *range) {
natural_stop
=
0xffffffffUL
;
natural_stop
=
0xffffffffUL
;
break
;
break
;
case
ASN_STRING_UniversalString
:
case
ASN_STRING_UniversalString
:
OUT
(
"uint32_t *ch = st->buf;
\n
"
);
OUT
(
"
const
uint32_t *ch = st->buf;
\n
"
);
OUT
(
"uint32_t *end = ch + st->size;
\n
"
);
OUT
(
"
const
uint32_t *end = ch + st->size;
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"if(st->size % 4) return 0; /* (size%4)! */
\n
"
);
OUT
(
"if(st->size % 4) return 0; /* (size%4)! */
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
INDENT
(
+
1
);
INDENT
(
+
1
);
OUT
(
"uint32_t cv = (((uint8_t *)ch)[0] << 24)
\n
"
);
OUT
(
"uint32_t cv = (((
const
uint8_t *)ch)[0] << 24)
\n
"
);
OUT
(
"
\t\t
| (((uint8_t *)ch)[1] << 16)
\n
"
);
OUT
(
"
\t\t
| (((
const
uint8_t *)ch)[1] << 16)
\n
"
);
OUT
(
"
\t\t
| (((uint8_t *)ch)[2] << 8)
\n
"
);
OUT
(
"
\t\t
| (((
const
uint8_t *)ch)[2] << 8)
\n
"
);
OUT
(
"
\t\t
| ((uint8_t *)ch)[3]
\n
"
);
OUT
(
"
\t\t
| ((
const
uint8_t *)ch)[3]
;
\n
"
);
if
(
!
range
)
OUT
(
"if(cv > 255) return 0;
\n
"
);
if
(
!
range
)
OUT
(
"if(cv > 255) return 0;
\n
"
);
natural_stop
=
0xffffffffUL
;
natural_stop
=
0xffffffffUL
;
break
;
break
;
case
ASN_STRING_BMPString
:
case
ASN_STRING_BMPString
:
OUT
(
"uint16_t *ch = st->buf;
\n
"
);
OUT
(
"
const
uint16_t *ch = st->buf;
\n
"
);
OUT
(
"uint16_t *end = ch + st->size;
\n
"
);
OUT
(
"
const
uint16_t *end = ch + st->size;
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"if(st->size % 2) return 0; /* (size%2)! */
\n
"
);
OUT
(
"if(st->size % 2) return 0; /* (size%2)! */
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
INDENT
(
+
1
);
INDENT
(
+
1
);
OUT
(
"uint16_t cv = (((uint8_t *)ch)[0] << 8)
\n
"
);
OUT
(
"uint16_t cv = (((
const
uint8_t *)ch)[0] << 8)
\n
"
);
OUT
(
"
\t\t
| ((uint8_t *)ch)[1];
\n
"
);
OUT
(
"
\t\t
| ((
const
uint8_t *)ch)[1];
\n
"
);
if
(
!
range
)
OUT
(
"if(cv > 255) return 0;
\n
"
);
if
(
!
range
)
OUT
(
"if(cv > 255) return 0;
\n
"
);
natural_stop
=
0xffff
;
natural_stop
=
0xffff
;
break
;
break
;
case
ASN_BASIC_OCTET_STRING
:
case
ASN_BASIC_OCTET_STRING
:
default:
default:
OUT
(
"uint8_t *ch = st->buf;
\n
"
);
OUT
(
"
const
uint8_t *ch = st->buf;
\n
"
);
OUT
(
"uint8_t *end = ch + st->size;
\n
"
);
OUT
(
"
const
uint8_t *end = ch + st->size;
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
OUT
(
"for(; ch < end; ch++) {
\n
"
);
INDENT
(
+
1
);
INDENT
(
+
1
);
...
@@ -531,7 +534,7 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype) {
...
@@ -531,7 +534,7 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype) {
case
ASN_BASIC_INTEGER
:
case
ASN_BASIC_INTEGER
:
case
ASN_BASIC_ENUMERATED
:
case
ASN_BASIC_ENUMERATED
:
if
(
arg
->
flags
&
A1C_USE_NATIVE_INTEGERS
)
{
if
(
arg
->
flags
&
A1C_USE_NATIVE_INTEGERS
)
{
OUT
(
"value = *(int *)sptr;
\n
"
);
OUT
(
"value = *(
const
int *)sptr;
\n
"
);
}
else
{
}
else
{
OUT
(
"if(asn1_INTEGER2long(st, &value)) {
\n
"
);
OUT
(
"if(asn1_INTEGER2long(st, &value)) {
\n
"
);
INDENT
(
+
1
);
INDENT
(
+
1
);
...
@@ -543,14 +546,21 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype) {
...
@@ -543,14 +546,21 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype) {
}
}
break
;
break
;
case
ASN_BASIC_BOOLEAN
:
case
ASN_BASIC_BOOLEAN
:
OUT
(
"value = (*(int *)sptr) ? 1 : 0;
\n
"
);
OUT
(
"value = (*(
const
int *)sptr) ? 1 : 0;
\n
"
);
break
;
break
;
default:
default:
WARNING
(
"Value cannot be determined "
WARNING
(
"%s:%d: Value cannot be determined "
"for constraint check for %s at line %d
\n
"
,
"for constraint check for %s"
,
arg
->
expr
->
Identifier
,
arg
->
expr
->
_lineno
);
arg
->
mod
->
source_file_name
,
OUT
(
"#error Value cannot be determined for %s at %d
\n
"
,
arg
->
expr
->
_lineno
,
arg
->
expr
->
Identifier
,
arg
->
expr
->
_lineno
);
arg
->
expr
->
Identifier
);
OUT_NOINDENT
(
"#error %s:%d: Value of %s cannot be determined
\n
"
,
arg
->
mod
->
source_file_name
,
arg
->
expr
->
_lineno
,
arg
->
expr
->
Identifier
);
break
;
break
;
}
}
...
...
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