#!/usr/bin/perl -w

use Fcntl;

if ($#ARGV != 0) {
    die("Syntax: $0 <output>\n");
}
$infile = $ARGV[0];

sysopen(FILE, $infile, O_CREAT | O_WRONLY)
    or die "failed to open $infile: $!\n";

while(<STDIN>) {
    chomp;
    # quick hack
    if (/^([0-9a-fA-F]+)$/) {
	$bits = $1;
	while($bits) {
	    $data = hex(substr($bits, 0, 2));
	    $bits = substr($bits, 2);
	}
	print FILE pack('C', $data);
    }
}

close(FILE) or die "failed to close $infile: $!\n";
