1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#!/usr/bin/perl -w
#
# dump_header
#
# Quick hack to satisfy my curiosity about the header files
# generated by strfile and used by fortune. (The Fortune
# module is essentially a puffed-up, glorified version
# of this, with the added ability to read actual fortune
# files based on the offsets from the header file.)
#
# by Greg Ward, 1999/02/20
#
# $Id: dump_header,v 1.1 1999/02/20 18:56:04 greg Exp $
#
die "usage: dump_header header_file\n" unless @ARGV == 1;
open (D, $ARGV[0]) || die "couldn't open $ARGV[0]: $!\n";
undef $/;
$d = <D>;
@d = unpack ("NNNNNaxxxN*", $d);
print <<HDR;
version = $d[0]
numstr = $d[1]
longlen = $d[2]
shortlen = $d[3]
flags = $d[4]
delim = $d[5]
HDR
@offsets = @d[6 .. $#d];
for $i (0 .. $#offsets)
{
printf "offset %3d: %d\n", $i, $offsets[$i];
}
|