From: Dirk Koopman Date: Tue, 10 Sep 2019 16:02:53 +0000 (+0100) Subject: improve DXQsl handling and fix crashes? X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c3c40fa3708eb08ec5e81dbbff35deec6e2c44e4;p=spider.git improve DXQsl handling and fix crashes? --- diff --git a/Changes b/Changes index 9008e88e..2ebf4720 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,6 @@ -14Jul18======================================================================= +10Sep19======================================================================= +1. Improve DXSql database filtering to exclude most via type + reports. 16Jun18======================================================================= 1. add more modes to rbn.pl 23Jan18======================================================================= diff --git a/cmd/load/dxqsl.pl b/cmd/load/dxqsl.pl new file mode 100644 index 00000000..b1738229 --- /dev/null +++ b/cmd/load/dxqsl.pl @@ -0,0 +1,8 @@ +# +# load the QSL file after changing it +# +my $self = shift; +return (1, $self->msg('e5')) if $self->priv < 9; +QSL::finish(); +my $r = QSL::init(1); +return (1, $r ? $self->msg('ok') : $self->msg('e2', "$!")); diff --git a/cmd/load/qsl.pl b/cmd/load/qsl.pl deleted file mode 100644 index b1738229..00000000 --- a/cmd/load/qsl.pl +++ /dev/null @@ -1,8 +0,0 @@ -# -# load the QSL file after changing it -# -my $self = shift; -return (1, $self->msg('e5')) if $self->priv < 9; -QSL::finish(); -my $r = QSL::init(1); -return (1, $r ? $self->msg('ok') : $self->msg('e2', "$!")); diff --git a/cmd/load/qsl.pl b/cmd/load/qsl.pl new file mode 120000 index 00000000..1adfae50 --- /dev/null +++ b/cmd/load/qsl.pl @@ -0,0 +1 @@ +dxqsl.pl \ No newline at end of file diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index 3e47f6e9..bad92927 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -427,7 +427,8 @@ sub is_digits # does it look like a qra locator? sub is_qra { - return $_[0] =~ /^[A-Ra-r][A-Ra-r]\d\d[A-Xa-x][A-Xa-x]$/; + return unless length $_[0] == 4 || length $_[0] == 6; + return $_[0] =~ /^[A-Ra-r][A-Ra-r]\d\d(?:[A-Xa-x][A-Xa-x])?$/; } # does it look like a valid lat/long diff --git a/perl/QSL.pm b/perl/QSL.pm index 6649c7a7..0df7570b 100644 --- a/perl/QSL.pm +++ b/perl/QSL.pm @@ -14,9 +14,10 @@ use DB_File; use DXDebug; use Prefix; -use vars qw($qslfn $dbm); +use vars qw($qslfn $dbm $maxentries); $qslfn = 'qsl'; $dbm = undef; +$maxentries = 50; localdata_mv("$qslfn.v1"); @@ -39,6 +40,7 @@ sub init } import Storable qw(nfreeze freeze thaw); my %u; + undef $dbm; if ($mode) { $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)"; } else { @@ -69,19 +71,24 @@ sub update my $t = shift; my $by = shift; my $changed; - + + return unless length $line && $line =~ /\b(?:QSL|VIA)\b/i; foreach my $man (split /\b/, uc $line) { my $tok; - if (is_callsign($man)) { + if (is_callsign($man) && !is_qra($man)) { my @pre = Prefix::extract($man); $tok = $man if @pre && $pre[0] ne 'Q'; } elsif ($man =~ /^BUR/) { $tok = 'BUREAU'; + } elsif ($man =~ /^LOTW/) { + $tok = 'LOTW'; } elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) { $tok = 'HOME CALL'; } elsif ($man =~ /^QRZ/) { $tok = 'QRZ.com'; + } else { + next; } if ($tok) { my ($r) = grep {$_->[0] eq $tok} @{$self->[1]}; @@ -97,6 +104,8 @@ sub update unshift @{$self->[1]}, $r; $changed++; } + # prune the number of entries + pop @{$self->[1]} while (@{$self->[1]} > $maxentries); } } $self->put if $changed;