summaryrefslogtreecommitdiff
path: root/bin/tibtoa
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-01-01 21:27:58 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-01-01 21:27:58 +0100
commit87a5b085a8dc93244ccc3ce344ce411d0d23fdfb (patch)
tree672cfa45569355a87a4a80c020f5295a75dc9da4 /bin/tibtoa
parent59d3693d691260f7c5f3719bb1fdd547e9f14cc6 (diff)
tibtoa: Added list support
Diffstat (limited to 'bin/tibtoa')
-rwxr-xr-xbin/tibtoa16
1 files changed, 13 insertions, 3 deletions
diff --git a/bin/tibtoa b/bin/tibtoa
index fd7b74f..5f034e6 100755
--- a/bin/tibtoa
+++ b/bin/tibtoa
@@ -625,6 +625,7 @@ sub print_header {
sub header_type($) {
my $header = shift;
given (ord(substr($header, 0x3b, 1))) {
+ when(0x01) { return('list') }
when(0x02) { return('matrix') }
when(0x05) { return('program') }
default { return(sprintf('0x%02x', $_)) }
@@ -640,6 +641,10 @@ sub header_name($) {
$name = substr($header, 60, 10);
$name =~ s/\x00/ /g;
}
+ when('list') {
+ $name = ord(substr($header, 0x3e, 1));
+ $name &= 0x0f;
+ }
}
return($name);
}
@@ -649,6 +654,9 @@ sub header_size($) {
my $size;
$size->{full} = ord(substr($header, 70, 1)) + 255 * ord(substr($header, 71, 1));
given(header_type($header)) {
+ when('list') {
+ $size->{items} = ord(substr($header, 0x48, 1));
+ }
when('matrix') {
$size->{cols} = ord(substr($header, 72, 1));
$size->{rows} = ord(substr($header, 73, 1));
@@ -690,6 +698,8 @@ if ($opts{h}) {
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'}));
+ } elsif (header_type($header) eq 'list') {
+ print_header('List length :', header_size($header)->{items});
}
}
@@ -730,7 +740,7 @@ if (header_type($header) eq 'program') {
}
}
print $cache;
-} elsif (header_type($header) eq 'matrix') {
+} elsif (header_type($header) eq 'matrix' or header_type($header) eq 'list') {
my ($step, $exp, $digit);
my $i = 0;
while ($offset+9 <= $length) {
@@ -747,10 +757,10 @@ if (header_type($header) eq 'program') {
}
$offset++;
printf('%-8s', $digit * (10 ** $exp));
- if ($i == header_size($header)->{cols}) {
+ if (header_type($header) eq 'matrix' and $i == header_size($header)->{cols}) {
print "\n";
$i = 0;
- } else {
+ } elsif (header_type($header) eq 'matrix') {
print ' | ';
}
}