"Fossies" - the Fresh Open Source Software Archive 
Member "BackupPC-4.4.0/bin/BackupPC_poolCntPrint" (20 Jun 2020, 2716 Bytes) of package /linux/privat/BackupPC-4.4.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "BackupPC_poolCntPrint":
4.3.2_vs_4.4.0.
1 #!/usr/bin/perl
2 #============================================================= -*-perl-*-
3 #
4 # BackupPC_poolCntPrint: print the contents of pool count and
5 # pool count delta files.
6 #
7 # DESCRIPTION
8 #
9 # Usage: BackupPC_poolCntPrint poolCntFilePath
10 #
11 # AUTHOR
12 # Craig Barratt <cbarratt@users.sourceforge.net>
13 #
14 # COPYRIGHT
15 # Copyright (C) 2005-2020 Craig Barratt
16 #
17 # This program is free software: you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation, either version 3 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program. If not, see <http://www.gnu.org/licenses/>.
29 #
30 #========================================================================
31 #
32 # Version 4.4.0, released 20 Jun 2020.
33 #
34 # See http://backuppc.sourceforge.net.
35 #
36 #========================================================================
37
38 use strict;
39 no utf8;
40 use lib "__INSTALLDIR__/lib";
41
42 use BackupPC::Lib;
43 use BackupPC::XS;
44 use Data::Dumper;
45
46 die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
47
48 my $TopDir = $bpc->TopDir();
49 my $BinDir = $bpc->BinDir();
50 my %Conf = $bpc->Conf();
51 my $s = $bpc->{storage};
52 my $digest;
53
54 if ( @ARGV == 0 ) {
55 print STDERR "Usage: $0 [poolCntFilePath|hexDigest]...\n";
56 exit(1);
57 }
58 while ( my $poolCntFile = shift(@ARGV) ) {
59 if ( !-f $poolCntFile ) {
60 if ( $poolCntFile =~ /^[\da-f]{16,}$/i ) {
61 #
62 # Print a specific digest count instead
63 #
64 $digest = pack("H*", $poolCntFile);
65 $poolCntFile = sprintf("%s/%02x/poolCnt",
66 $Conf{CompressLevel} ? $bpc->{CPoolDir} : $bpc->{PoolDir},
67 vec($digest, 0, 8) & 0xfe);
68 }
69 if ( !-f $poolCntFile ) {
70 print STDERR "$poolCntFile does not exist\n";
71 exit(1);
72 }
73 }
74
75 my $count = BackupPC::XS::PoolRefCnt::new();
76
77 if ( $count->read($poolCntFile) ) {
78 print("Can't read ref count file $poolCntFile\n");
79 exit(1);
80 }
81 print("Pool Ref Count file $poolCntFile:\n");
82 my $idx = 0;
83 my($d, $c);
84 while ( 1 ) {
85 ($d, $c, $idx) = $count->iterate($idx);
86 last if ( !defined($d) );
87 next if ( defined($digest) && $d ne $digest );
88 printf(" %-20s => %d\n", unpack("H*", $d), $c);
89 }
90 }