improve simple callsign checking
[spider.git] / perl / Geomag.pm
index 1a1a8a40110905579d6b603c672a0701df4bfffe..037dcc50be74637e6d4721f962066789dd3b6106 100644 (file)
@@ -15,10 +15,13 @@ use DXUtil;
 use DXLog;
 use Julian;
 use IO::File;
-use Carp;
+use DXDebug;
+use DXDupe;
 
 use strict;
-use vars qw($date $sfi $k $a $r $forecast @allowed @denied $fp $node $from);
+use vars qw($date $sfi $k $a $r $forecast @allowed @denied $fp $node $from 
+            $dirprefix $param
+            $duplth $dupage);
 
 $fp = 0;                                               # the DXLog fcb
 $date = 0;                                             # the unix time of the WWV (notional)
@@ -31,13 +34,15 @@ $node = "";                                         # originating node
 $from = "";                                            # who this came from
 @allowed = ();                                 # if present only these callsigns are regarded as valid WWV updators
 @denied = ();                                  # if present ignore any wwv from these callsigns
-my $dirprefix = "$main::data/wwv";
-my $param = "$dirprefix/param";
+$duplth = 20;                                  # the length of text to use in the deduping
+$dupage = 12*3600;                             # the length of time to hold spot dups
+
+$dirprefix = "$main::data/wwv";
+$param = "$dirprefix/param";
 
 sub init
 {
        $fp = DXLog::new('wwv', 'dat', 'm');
-       mkdir $dirprefix, 0777 if !-e $dirprefix; # now unnecessary DXLog will create it
        do "$param" if -e "$param";
        confess $@ if $@;
 }
@@ -238,5 +243,23 @@ sub readfile
        }
        return @in;
 }
+
+# enter the spot for dup checking and return true if it is already a dup
+sub dup
+{
+       my ($d, $sfi, $k, $a, $text) = @_; 
+
+       # dump if too old
+       return 2 if $d < $main::systime - $dupage;
+       my $dupkey = "W$d|$sfi|$k|$a";
+       return DXDupe::check($dupkey, $main::systime+$dupage);
+}
+
+sub listdups
+{
+       return DXDupe::listdups('W', $dupage, @_);
+}
 1;
 __END__;
+