use Prefix;
use DXDupe;
use Data::Dumper;
+use QSL;
use strict;
$main::build += $VERSION;
$main::branch += $BRANCH;
-use vars qw($fp $statp $maxspots $defaultspots $maxdays $dirprefix $duplth $dupage $filterdef $totalspots $hfspots $vhfspots);
+use vars qw($fp $statp $maxspots $defaultspots $maxdays $dirprefix $duplth $dupage $filterdef $totalspots $hfspots $vhfspots );
$fp = undef;
$statp = undef;
mkdir "$dirprefix", 0777 if !-e "$dirprefix";
$fp = DXLog::new($dirprefix, "dat", 'd');
$statp = DXLog::new($dirprefix, "dys", 'd');
- system("rm -f $main::data/$dirprefix/200?/*.bys");
- system("rm -f $main::data/$dirprefix/200?/*.cys");
+ my $rm = $main::is_win ? 'del' : 'rm -f';
+ system("$rm $main::data/$dirprefix/*/*.bys");
+ system("$rm $main::data/$dirprefix/*/*.cys");
}
sub prefix
sub add
{
- my $buf = join("\^", @_[0..7]);
+ my $buf = join("\^", @_);
$fp->writeunix($_[2], $buf);
$totalspots++;
if ($_[0] <= 30000) {
} else {
$vhfspots++;
}
+ if ($_[3] =~ /(?:QSL|VIA)/i) {
+ my $q = QSL::get($_[1]) || new QSL $_[1];
+ $q->update($_[3], $_[2], $_[4]);
+ }
}
# search the spot database for records based on the field no and an expression
sub search
{
- my ($expr, $dayfrom, $dayto, $from, $to, $hint) = @_;
+ my ($expr, $dayfrom, $dayto, $from, $to, $hint, $dxchan) = @_;
my $eval;
my @out;
my $ref;
for (\$c = \$#spots; \$c >= 0; \$c--) {
\$ref = \$spots[\$c];
if ($expr) {
+ if (\$dxchan && \$dxchan->{spotsfilter}) {
+ if (\@\$ref < 9) {
+ my \@dxcc = Prefix::cty_data(\$ref->[1]);
+ if (\@dxcc) {
+ pop \@dxcc;
+ push \@\$ref, \@dxcc;
+ }
+ \@dxcc = Prefix::cty_data(\$ref->[4]);
+ if (\@dxcc) {
+ pop \@dxcc;
+ push \@\$ref, \@dxcc;
+ }
+ }
+ my (\$filter, \$hops) = \$dxchan->{spotsfilter}->it(\@\$ref);
+ next unless (\$filter);
+ }
\$count++;
next if \$count < \$from; # wait until from
push(\@out, \$ref);
}
}
);
+
+ dbg("Spot eval: $eval") if isdbg('searcheval');
+
$fp->close; # close any open files
$freq = sprintf "%.1f", $freq; # normalise frequency
$call = substr($call, 0, 12) if length $call > 12;
+
+ # quick test now for simple case
+ my $sdupkey = "X$freq|$call|$d|$by";
+ return 1 if DXDupe::find($sdupkey);
+
chomp $text;
$text =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
$text = substr($text, 0, $duplth) if length $text > $duplth;
return 1 if DXDupe::find($ldupkey) || DXDupe::find($sdupkey);
}
my $ldupkey = "X$freq|$call|$d|\L$text";
- my $sdupkey = "X$freq|$call|$d|$by";
+ $sdupkey = "X$freq|$call|$d|$by";
DXDupe::add($ldupkey, $main::systime+$dupage);
DXDupe::add($sdupkey, $main::systime+$dupage);
return 0;
my ($freq, $by, $dxcc) = (split /\^/)[0,4,6];
my $ref = $list{$by} || [0, $dxcc];
for (@freq) {
+ next unless defined $_;
if ($freq >= $_->[1] && $freq <= $_->[2]) {
$$ref[$_->[0]+2]++;
$tot[$_->[0]+2]++;