2 # showtoken - decode SM tokens
3 # Olaf Titz, 1999. Marco d'Itri, 2000. Public domain.
4 # Takes tokens on stdin and write them along with a decoded form on stdout.
10 my @types = ('trash', '', 'timehash', 'cnfs', 'timecaf', 'tradspool');
13 $pathspool = $ARGV[0];
14 if (open(MAP, "$pathspool/tradspool.map")) {
16 my ($ng, $gnum) = split;
36 my ($type, $class, $token, $index, $offset, $overlen, $cancelled) =
37 unpack('C C a16 CLnc', $t);
39 if (not $types[$type]) {
40 print "type=$type unknown!\n";
43 print "type=$types[$type] class=$class ";
45 if ($type == 0) { # trash
46 } elsif ($type == 2) { # timehash
47 my ($time, $seq) = unpack('Nn', $token);
48 my ($a, $b, $c, $d) = unpack('CCCC', $token);
49 printf 'time=%08lX seq=%04X file=time-%02x/%02x/%02x/%04x-%02x%02x',
50 $time, $seq, $class, $b, $c, $seq, $a, $d;
51 } elsif ($type == 3) { # cnfs
52 my ($buffn, $offset, $cnum) = unpack('A8NN', $token);
53 printf 'buffer=%s offset=%x cycnum=%x', $buffn, $offset * 512, $cnum;
54 } elsif ($type == 4) { # timecaf
55 my ($time, $seq) = unpack('Nn', $token);
56 my (undef, $b, $c, $d) = unpack('CCCC', $token);
57 printf 'time=%06lX seq=%04X caf=timecaf-%02x/%02x/%02x%02x.CF',
58 $time, $seq, $class, $c, $b, $d;
59 } elsif ($type == 5) { # tradspool
60 my ($gnum, $art) = unpack('NN', $token);
61 printf 'ng=%08X art=%d', $gnum, $art;
62 print "file=articles/$NG{$gnum}/$art" if $NG{$gnum};
64 die "invalid type $type";
66 print " over=$index offset=$offset overlen=$overlen cancelled=$cancelled"
79 # The fields "index" and following are not available with OV3 (INN 2.3 up)
81 # the "token" field is:
82 # for type=0 (trash) ignored
83 # for type=2 (timehash)
90 # for type=4 (timecaf)
93 # for type=5 (tradspool)