Debian Codegraph @

dump_header

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