- # build up eval to execute
- $eval = qq(my \$c;
- for (\$c = \$#spots; \$c >= 0; \$c--) {
- \$ref = \$spots[\$c];
- if ($expr) {
- \$count++;
- next if \$count < \$from; # wait until from
- push(\@out, \$ref);
- last LOOP if \$count >= \$to; # stop after to
- }
- });
-
-LOOP:
- for ($i = 0; $i < 60; ++$i) {
- my @now = Julian::sub(@fromdate, $i);
- last if Julian::cmp(@now, @todate) <= 0;
+ # build up eval to execute
+ $eval = qq(
+ while (<\$fh>) {
+ $hint;
+ chomp;
+ my \@s = split /\\^/;
+ $checkfilter;
+ push \@spots, \\\@s;
+ }
+ my \$c;
+ my \$ref;
+ for (\$c = \$#spots; \$c >= 0; \$c--) {
+ \$ref = \$spots[\$c];
+ if ($expr) {
+ \$count++;
+ next if \$count < \$from; # wait until from
+ push(\@out, \$ref);
+ last if \$count >= \$to; # stop after to
+ }
+ }
+ );
+
+ dbg("Spot eval: $eval") if isdbg('searcheval');
+
+
+ $fp->close; # close any open files
+
+ for ($i = $count = 0; $i < $maxdays; ++$i) { # look thru $maxdays worth of files only
+ my $now = $fromdate->sub($i); # but you can pick which $maxdays worth
+ last if $now->cmp($todate) <= 0;
+
+ my @spots = ();
+ my $fh = $fp->open($now); # get the next file
+ if ($fh) {
+ my $in;
+ eval $eval; # do the search on this file
+ last if $count >= $to; # stop after to
+ return ("Spot search error", $@) if $@;
+ }
+ }
+
+ return @out;
+}
+
+# change a freq range->regular expression
+sub ftor
+{
+ my ($a, $b) = @_;
+ return undef unless $a < $b;
+ $b--;
+ my $d = $b - $a;
+ my @a = split //, $a;
+ my @b = split //, $b;
+ my $out;
+ while (@b > @a) {
+ $out .= shift @b;
+ }
+ while (@b) {
+ my $aa = shift @a;
+ my $bb = shift @b;
+ if (@b < (length $d)) {
+ $out .= '\\d';
+ } elsif ($aa eq $bb) {
+ $out .= $aa;
+ } elsif ($aa < $bb) {
+ $out .= "[$aa-$bb]";
+ } else {
+ $out .= "[0-$bb$aa-9]";
+ }
+ }
+ return $out;
+}
+
+# format a spot for user output in list mode
+sub formatl
+{
+ my $t = ztime($_[2]);
+ my $d = cldate($_[2]);
+ return sprintf "%8.1f %-11s %s %s %-28.28s%7s>", $_[0], $_[1], $d, $t, ($_[3]||''), "<$_[4]" ;
+}
+
+#
+# return all the spots from a day's file as an array of references
+# the parameter passed is a julian day
+sub readfile($)
+{
+ my @spots;
+
+ my $fh = $fp->open(shift);
+ if ($fh) {
+ my $in;
+ while (<$fh>) {
+ chomp;
+ push @spots, [ split '\^' ];
+ }
+ }
+ return @spots;
+}
+
+# enter the spot for dup checking and return true if it is already a dup
+sub dup
+{
+ my ($freq, $call, $d, $text, $by, $cty) = @_;
+
+ # dump if too old
+ return 2 if $d < $main::systime - $dupage;
+
+ # turn the time into minutes (should be already but...)
+ $d = int ($d / 60);
+ $d *= 60;
+
+ # remove SSID or area
+ $by =~ s|[-/]\d+$||;