-
Notifications
You must be signed in to change notification settings - Fork 4
/
Cmt2BlobLst.perl
executable file
·61 lines (48 loc) · 1.15 KB
/
Cmt2BlobLst.perl
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl
use lib ("$ENV{HOME}/lookup", "$ENV{HOME}/lib64/perl5", "/home/audris/lib64/perl5","$ENV{HOME}/lib/perl5", "$ENV{HOME}/lib/x86_64-linux-gnu/perl", "$ENV{HOME}/share/perl5");
use strict;
use warnings;
use Error qw(:try);
use TokyoCabinet;
use Compress::LZF;
sub toHex {
return unpack "H*", $_[0];
}
sub fromHex {
return pack "H*", $_[0];
}
sub safeDecomp {
my ($codeC, $n) = @_;
try {
my $code = decompress ($codeC);
return $code;
} catch Error with {
my $ex = shift;
print STDERR "Error: $ex; $n\n";
return "";
}
}
my $detail = 0;
$detail = $ARGV[1] if defined $ARGV[1];
my %p2c;
tie %p2c, "TokyoCabinet::HDB", "$ARGV[0]", TokyoCabinet::HDB::OREADER,
16777213, -1, -1, TokyoCabinet::TDB::TLARGE, 100000
or die "cant open $ARGV[0]\n";
while (my ($p, $v) = each %p2c){
list ($p, $v);
}
untie %p2c;
sub list {
my ($c, $v) = @_;
my $ns = length($v)/20;
#$ns = $ns/20 if ($ns >= 20 && ($ns%20) == 0);
my $c1 = toHex($c);
print "$c1;$ns";
if ($detail){
for my $i (0..($ns-1)){
my $c0 = substr ($v, 20*$i, 20);
print ";".(toHex($c0));
}
}
print "\n";
}