3 # Local 'autoqsl' module for DXSpider
5 # Copyright (c) 2003 Dirk Koopman G1TLH
17 use vars qw($qslfn $dbm $maxentries);
22 localdata_mv("$qslfn.v1");
27 my $ufn = localdata("$qslfn.v1");
29 Prefix::load() unless Prefix::loaded();
36 dbg("Storable appears to be missing");
37 dbg("In order to use the QSL feature you must");
38 dbg("load Storable from CPAN");
41 import Storable qw(nfreeze freeze thaw);
45 $dbm = tie (%u, 'DB_File', $ufn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
47 $dbm = tie (%u, 'DB_File', $ufn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open qsl file: $qslfn ($!)";
59 my ($pkg, $call) = @_;
60 return bless [uc $call, []], $pkg;
63 # called $self->update(comment, time, spotter)
64 # $self has the callsign as the first argument in an array of array references
65 # the format of each entry is [manager, times found, last time, last reporter]
75 return unless length $line && $line =~ /\b(?:QSL|VIA)\b/i;
76 foreach my $man (split /\b/, uc $line) {
79 if (is_callsign($man) && !is_qra($man)) {
80 my @pre = Prefix::extract($man);
81 $tok = $man if @pre && $pre[0] ne 'Q';
82 } elsif ($man =~ /^BUR/) {
84 } elsif ($man =~ /^LOTW/) {
86 } elsif ($man eq 'HC' || $man =~ /^HOM/ || $man =~ /^DIR/) {
88 } elsif ($man =~ /^QRZ/) {
94 my ($r) = grep {$_->[0] eq $tok} @{$self->[1]};
103 $r = [$tok, 1, $t, $by];
104 unshift @{$self->[1]}, $r;
107 # prune the number of entries
108 pop @{$self->[1]} while (@{$self->[1]} > $maxentries);
111 $self->put if $changed;
116 return undef unless $dbm;
120 my $r = $dbm->get($key, $value);
129 my $key = $self->[0];
130 my $value = nfreeze($self);
131 $dbm->put($key, $value);