3 # Implement a 'GO' database list
5 # Copyright (c) 2003 Dirk Koopman G1TLH
10 # search local then perl directories
14 # root of directory tree for this system
16 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
18 unshift @INC, "$root/perl"; # this IS the right way round!
19 unshift @INC, "$root/local";
31 $SIG{TERM} = $SIG{INT} = sub { $end++ };
33 my $qslfn = "localqsl";
35 $main::systime = time;
38 my $db = DXDb::getdesc($qslfn);
42 $db = DXDb::getdesc($qslfn);
45 die "cannot load $qslfn $!" unless $db;
47 my $base = "$root/data/spots";
49 opendir YEAR, $base or die "$base $!";
50 foreach my $year (sort readdir YEAR) {
51 next if $year =~ /^\./;
52 my $baseyear = "$base/$year";
53 opendir DAY, $baseyear or die "$baseyear $!";
54 foreach my $day (sort readdir DAY) {
55 next unless $day =~ /dat$/;
56 my $fn = "$baseyear/$day";
57 my $f = new IO::File $fn or die "$fn ($!)";
61 my ($freq, $call, $t, $comment, $by, @rest) = split /\^/;
62 my $value = $db->getkey($call) || "";
63 my $newvalue = update($value, $call, $t, $comment, $by);
64 if ($newvalue ne $value) {
65 $db->putkey($call, $newvalue);
78 my ($line, $call, $t, $comment, $by) = @_;
79 my @lines = split /\n/, $line;
83 foreach my $l (@lines) {
84 my ($date, $time, $oby, $ocom) = $l =~ /^(\s?\S+)\s+(\s?\S+)\s+by\s+(\S+):\s+(.*)$/;
86 my $ot = cltounix($date, $time);
87 push @in, [$ot, $oby, $ocom];
89 print "Cannot decode $call: $l\n";
95 # is this newer than the earliest one?
96 if (@in && $in[0]->[0] < $t) {
97 @in = grep {$_->[1] ne $by} @in;
99 unshift @in, [$t, $by, $comment];
101 return join "\n", (map {(cldatetime($_->[0]) . " by $_->[1]: $_->[2]")} @in);