Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | #!/usr/bin/perl |
2 | |||
3 | |||
4 | $file = $ARGV[0]; |
||
5 | |||
6 | |||
7 | open(IN,$file) || die print "Failed to open file: $file : $!"; |
||
8 | |||
9 | read(IN,$buffer,1); |
||
10 | read(IN,$buffer2,1); |
||
11 | if (ord($buffer) != 0x41 && ord($buffer2) != 0x50) { |
||
12 | print "bad header ". $buffer ." ".$buffer2. "\n"; |
||
13 | exit; |
||
14 | } |
||
15 | read(IN,$buffer,1); |
||
16 | if (ord($buffer) != 2) { |
||
17 | print "bad version"; |
||
18 | exit; |
||
19 | } |
||
20 | |||
21 | # spare |
||
22 | read(IN,$buffer,1); |
||
23 | |||
24 | $a = 0; |
||
25 | |||
26 | while (read(IN,$buffer,1)) { |
||
27 | $pos = (tell(IN) - 1); |
||
28 | |||
29 | $size = ((ord($buffer) & 63)); |
||
30 | |||
31 | read(IN,$buffer,1); |
||
32 | |||
33 | if (ord($buffer) == 0xff) { |
||
34 | printf("end sentinel at %u\n", $pos); |
||
35 | last; |
||
36 | } |
||
37 | |||
38 | printf("%04x: key %u size %d\n ", $pos, ord($buffer), $size + 1); |
||
39 | |||
40 | for ($i = 0; $i <= ($size); $i++) { |
||
41 | read(IN,$buffer,1); |
||
42 | printf(" %02x", ord($buffer)); |
||
43 | } |
||
44 | print "\n"; |
||
45 | } |
||
46 | |||
47 | close IN; |