diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-04-06 02:35:34 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-04-06 02:35:34 +0000 |
commit | 36a9415469571fa972b6ff9004401aee393d28ad (patch) | |
tree | 5381f9327b3a7f85e76a6eec1c1346f40908044d /contrib/lar/lar.pl | |
parent | 1c383dc244323f5c168ee16824cb5788fefc3667 (diff) |
contrib: add "lar" - initial work on lua archive format
Diffstat (limited to 'contrib/lar/lar.pl')
-rwxr-xr-x | contrib/lar/lar.pl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/contrib/lar/lar.pl b/contrib/lar/lar.pl new file mode 100755 index 0000000000..56e4897958 --- /dev/null +++ b/contrib/lar/lar.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +use strict; + +@ARGV || die "Usage: $0 <file1> <file2> ... <fileN>\n"; + +my @index; +my $offset = 0; + +foreach my $file ( @ARGV ) +{ + if( -f $file && open F, "< $file" ) + { + warn sprintf "Member at 0x%08X\n", $offset; + push @index, [ ]; + + my $size = length $file; + + print $file; + print "\0" x ( $size % 4 ); + + $index[-1][0] = $offset; + $index[-1][1] = $size; + $index[-1][2] = $offset + $size + ( $size % 4 ); + + + $size = 0; + while( read F, my $buffer, 4096 ) { + $size += length $buffer; + print $buffer; + } + print "\0" x ( $size % 4 ); + + $index[-1][3] = $size; + $offset = $index[-1][2] + $size + ( $size % 4 ); + + close F; + } +} + + +foreach my $file ( @index ) +{ + warn sprintf "Index: 0x%08X 0x%08X 0x%08X 0x%08X\n", $file->[0], $file->[1], $file->[2], $file->[3]; + print pack "NNNNnn", $file->[0], $file->[1], $file->[2], $file->[3], 0x0000, 0x0000; +} + +warn sprintf "Index at 0x%08X, length 0x%08X\n", $offset, @index * 20; +print pack "N", $offset; + |