summaryrefslogtreecommitdiff
path: root/bin/tibtoa
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-01-01 17:30:26 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-01-01 17:30:26 +0100
commitca1798f88fb40e3cfd25177626c8fec4707e9cde (patch)
treef00de6cf72e779c8e76ebd25baf924229d9aef7b /bin/tibtoa
parent30bc0df8db792db6897d9b20b0a46ae216ea5af4 (diff)
tibtoa: Added length information
Diffstat (limited to 'bin/tibtoa')
-rwxr-xr-xbin/tibtoa31
1 files changed, 26 insertions, 5 deletions
diff --git a/bin/tibtoa b/bin/tibtoa
index 42592b5..7511756 100755
--- a/bin/tibtoa
+++ b/bin/tibtoa
@@ -644,6 +644,22 @@ sub header_name($) {
return($name);
}
+sub header_size($) {
+ my $header = shift;
+ my $size;
+ $size->{full} = ord(substr($header, 70, 1)) + 255 * ord(substr($header, 71, 1));
+ given(header_type($header)) {
+ when('matrix') {
+ $size->{rows} = ord(substr($header, 72, 1));
+ $size->{cols} = ord(substr($header, 73, 1));
+ }
+ when('program') {
+ $size->{source} = ord(substr($header, 72, 1)) + 255 * ord(substr($header, 73, 1));
+ }
+ }
+ return($size);
+}
+
sub header_compat($) {
return(substr(shift, 2, 4));
}
@@ -666,11 +682,16 @@ $length = length($program);
$offset = 0;
# Parse the header
-print_header('Compatibility:', header_compat($header));
-print_header('Extracted at :', header_datestr($header));
-print_header('Type :', header_type($header));
-print_header('Name :', header_name($header));
-
+if ($opts{h}) {
+ print_header('Compatibility:', header_compat($header));
+ print_header('Extracted at :', header_datestr($header));
+ print_header('Type :', header_type($header));
+ print_header('Name :', header_name($header));
+ print_header('Length w/o header:', header_size($header)->{full});
+ if (header_type($header) eq 'matrix') {
+ print_header('Matrix dimensions:', join('x', @{header_size($header)}{'rows','cols'}));
+ }
+}
# And now, the actual file content