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
6550fd59
Commit
6550fd59
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
pretty-print more
parent
1e3ccbb2
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
asn1c/unber.c
+19
-5
19 additions, 5 deletions
asn1c/unber.c
with
19 additions
and
5 deletions
asn1c/unber.c
+
19
−
5
View file @
6550fd59
...
...
@@ -439,6 +439,13 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
(
etype
&
ASN_STRING_MASK
)
||
(
etype
==
ASN_BASIC_OCTET_STRING
)
||
/*
* AUTOMATIC TAGS or IMPLICIT TAGS in effect,
* Treat this primitive type as OCTET_STRING.
*/
(
BER_TAG_CLASS
(
tlv_tag
)
!=
ASN_TAG_CLASS_UNIVERSAL
&&
pretty_printing
)
)
&&
(
tlv_len
>
0
&&
tlv_len
<
128
*
1024
))
{
vbuf
=
malloc
(
tlv_len
+
1
);
/* Not checking is intentional */
...
...
@@ -450,7 +457,8 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
if
(
!
vbuf
)
printf
(
special_format
?
" F>"
:
">"
);
/*
* Print the value in binary or text form.
* Print the value in binary or text form,
* or collect the bytes into vbuf.
*/
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
int
ch
=
fgetc
(
fp
);
...
...
@@ -479,7 +487,7 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
break
;
}
/* Fall through */
case
'<'
:
case
'>'
:
case
'&'
:
case
0x3c
:
case
0x3e
:
case
0x26
:
printf
(
"&#x%02x;"
,
ch
);
}
break
;
...
...
@@ -559,6 +567,8 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
/*
* If the buffer was not consumed, print it out.
* It might be an OCTET STRING or other primitive type,
* which might actually be printable, but we need to figure it out.
*/
if
(
vbuf
)
{
int
binary
;
...
...
@@ -566,13 +576,13 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
/*
* Check whether the data could be represented as text
*/
binary
=
-
1
*
(
tlv_len
>>
2
);
/* Threshold is
2
5% binary */
binary
=
-
1
*
(
tlv_len
>>
3
);
/* Threshold is
12.
5% binary */
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
switch
(
vbuf
[
i
])
{
case
0x1b
:
binary
=
1
;
break
;
case
0x09
:
case
0x0a
:
case
0x0d
:
continue
;
default:
if
(
vbuf
[
i
]
<
0x20
||
(
vbuf
[
i
]
&
0x
80
)
)
if
(
vbuf
[
i
]
<
0x20
||
vbuf
[
i
]
>=
0x
7f
)
if
(
++
binary
>
0
)
/* Way too many */
break
;
continue
;
...
...
@@ -581,7 +591,11 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
}
printf
(
">"
);
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
if
(
binary
>
0
||
vbuf
[
i
]
<
0x20
||
(
vbuf
[
i
]
&
0x80
))
if
(
binary
>
0
||
vbuf
[
i
]
<
0x20
||
vbuf
[
i
]
>=
0x7f
||
vbuf
[
i
]
==
0x26
/* '&' */
||
vbuf
[
i
]
==
0x3c
/* '<' */
||
vbuf
[
i
]
==
0x3e
/* '>' */
)
printf
(
"&#x%02x;"
,
vbuf
[
i
]);
else
printf
(
"%c"
,
vbuf
[
i
]);
...
...
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