Deps: hexdump.php
#!/usr/bin/env php
<?php
require_once 'hexdump.php';
$seektable="";
while(!feof(STDIN)) {
$sz = fread(STDIN, 4);
$count = unpack('V', $sz);
$count = $count[1];
// printf("0x%08x => %u\n", $count, $count);
$seektable.= $sz;
$frame = fread(STDIN, $count);
$crc32 = unpack('V', substr($frame, -4, 4));
$crc32 = $crc32[1];
$frame = substr($frame, 0, strlen($frame) - 4);
// if ($crc32 != ($framecrc = crc32($frame))) {
// fwrite(STDERR, "Frame CRC mismatch! ");
// fwrite(STDERR, sprintf("0x%08x != 0x%08x\n", $crc32, $framecrc));
// fwrite(STDERR, hexdump($frame, false, false, true));
// }
if (!(strlen($seektable) / 1024))
fwrite(STDERR, '.');
}
$seektable.= pack('V', crc32($seektable));
fwrite(STDERR, hexdump($seektable, false, false, true));
echo $seektable;
?>
