aboutsummaryrefslogtreecommitdiffstats
path: root/asn1c
diff options
context:
space:
mode:
Diffstat (limited to 'asn1c')
-rwxr-xr-xasn1c/check-xxber.sh4
-rw-r--r--asn1c/unber.15
-rw-r--r--asn1c/unber.c17
3 files changed, 18 insertions, 8 deletions
diff --git a/asn1c/check-xxber.sh b/asn1c/check-xxber.sh
index 44324126..cb8cdeec 100755
--- a/asn1c/check-xxber.sh
+++ b/asn1c/check-xxber.sh
@@ -15,7 +15,7 @@ cat<<EOM > $ORIG
</C O="14" T="[UNIVERSAL 16]" A="SEQUENCE" L="8">
EOM
-./enber < $ORIG - | ./unber -p -i 0 - > $TEST 2>&1
+./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
diff $diffArgs $ORIG $TEST >/dev/null 2>&1
diffExitCode=$?
@@ -28,7 +28,7 @@ fi
echo '</I O="14" T="[UNIVERSAL 0]" TL="2" L="16">' >> $ORIG
# Try trancoding again
-./enber < $ORIG - | ./unber -p -i 0 - > $TEST 2>&1
+./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
diff $diffArgs $ORIG $TEST
diffExitCode=$?
diff --git a/asn1c/unber.1 b/asn1c/unber.1
index 7b718b98..e219df91 100644
--- a/asn1c/unber.1
+++ b/asn1c/unber.1
@@ -12,7 +12,7 @@
.SH NAME
unber \- ASN.1 BER Decoder
.SH SYNOPSIS
-unber [\fB-1\fR] [\fB-i\fRindent] [\fB-p\fR] [\fB\-t\fR\fIdata-string\fR] [\fB-\fR] [\fIinfile\fR...]
+unber [\fB-1\fR] [\fB-i\fRindent] [\fB-m\fR] [\fB-p\fR] [\fB\-t\fR\fIdata-string\fR] [\fB-\fR] [\fIinfile\fR...]
.SH DESCRIPTION
unber takes the BER-encoded files and dumps their internal structure as human readable text.
A single dash represents the standard input.
@@ -28,6 +28,9 @@ By default, unber continues decoding until the end of file (input stream).
\fB\-i\fR \fIindent\fR
Use the specified number of spaces for output indentation. Default is 4 spaces.
.TP
+\fB\-m\fR
+Generate minimum amount of output while still preserving BER encoding information.
+.TP
\fB\-p\fR
Do \fInot\fR attempt pretty-printing of known ASN.1 types (OBJECT IDENTIFIER, INTEGER, BOOLEAN, etc). By default, some ASN.1 types are converted into
the text representation. This option is required for \&\fIenber\fR\|(1).
diff --git a/asn1c/unber.c b/asn1c/unber.c
index 03de104a..8758ca56 100644
--- a/asn1c/unber.c
+++ b/asn1c/unber.c
@@ -45,6 +45,7 @@ static int process(const char *fname); /* Perform the BER decoding */
static int decode_tlv_from_string(const char *datastring);
static int single_type_decoding = 0; /* -1 enables that */
+static int minimalistic = 0; /* -m enables that */
static int pretty_printing = 1; /* -p disables that */
static char *indent_buffer = " "; /* -i controls that */
@@ -56,7 +57,7 @@ main(int ac, char **av) {
/*
* Process command-line options.
*/
- while((ch = getopt(ac, av, "1hi:pt:v")) != -1)
+ while((ch = getopt(ac, av, "1hi:mpt:v")) != -1)
switch(ch) {
case '1':
single_type_decoding = 1;
@@ -65,6 +66,9 @@ main(int ac, char **av) {
if(decode_tlv_from_string(optarg))
exit(EX_DATAERR);
exit(0);
+ case 'm':
+ minimalistic = 1;
+ break;
case 'p':
pretty_printing = 0;
break;
@@ -124,6 +128,7 @@ usage(const char *av0) {
"Options:\n"
" -1 Decode only the first BER structure (otherwise, until EOF)\n"
" -i <indent> Amount of spaces for output indentation (default is 4)\n"
+" -m Minimalistic mode: print as little as possible\n"
" -p Do not attempt pretty-printing of known ASN.1 types\n"
" -t <data-string> Decode the given tag[/length] sequence (e.g. -t \"bf20\")\n"
"\n"
@@ -363,13 +368,14 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
printf(constr ? ((tlv_len == -1) ? "I" : "C") : "P");
/* Print out the offset of this boundary, even if closing tag */
- printf(" O=\"%" PRIdASN "\"", offset);
+ if(!minimalistic)
+ printf(" O=\"%" PRIdASN "\"", offset);
printf(" T=\"");
ber_tlv_tag_fwrite(tlv_tag, stdout);
printf("\"");
- if(!fin || tlv_len == -1)
+ if(!fin || (tlv_len == -1 && !minimalistic))
printf(" TL=\"%ld\"", (long)tlen);
if(!fin) {
if(tlv_len == -1)
@@ -378,7 +384,8 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
printf(" V=\"%ld\"", (long)tlv_len);
}
- if(BER_TAG_CLASS(tlv_tag) == ASN_TAG_CLASS_UNIVERSAL) {
+ if(!minimalistic
+ && BER_TAG_CLASS(tlv_tag) == ASN_TAG_CLASS_UNIVERSAL) {
const char *str;
ber_tlv_tag_t tvalue = BER_TAG_VALUE(tlv_tag);
str = ASN_UNIVERSAL_TAG2STR(tvalue);
@@ -386,7 +393,7 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
}
if(fin) {
- if(constr)
+ if(constr && !minimalistic)
printf(" L=\"%ld\"", (long)effective_size);
printf(">\n");
}