8 my ($self, $line) = @_;
9 my @list = split /\s+/, $line; # split the line up
13 my $call = $self->call;
15 my ($fromday, $today);
33 my ($doqsl, $doiota, $doqra, $dofilter);
35 while ($f = shift @list) { # next field
36 # print "f: $f list: ", join(',', @list), "\n";
38 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
39 next if $from && $to > $from;
42 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
45 if (lc $f eq 'exact') {
49 if (lc $f eq 'dxcc') {
53 if (lc $f eq 'rt' || $f =~ /^real/i) {
57 if (lc $f eq 'on' && $list[0]) { # is it freq range?
59 if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) {
64 my @r = split '/', lc $list[0];
65 # print "r0: $r[0] r1: $r[1]\n";
66 my @fr = Bands::get_freq($r[0], $r[1]);
67 if (@fr) { # yup, get rid of extranous param
68 # print "freq: ", join(',', @fr), "\n";
69 push @freq, @fr; # add these to the list
75 if (lc $f eq 'day' && $list[0]) {
77 ($fromday, $today) = split m|[-/]|, shift(@list);
80 if (lc $f eq 'info' && $list[0]) {
85 if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) {
86 # print "got spotter\n";
87 $spotter = uc shift @list;
88 if ($list[0] && lc $list[0] eq 'dxcc') {
94 if (lc $f =~ /^filt/) {
95 $dofilter = 1 if $self && $self->spotsfilter;
102 if (lc $f eq 'iota') {
106 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
108 $doiota = "\\b$a\[\-\ \]\?$b\\b";
111 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
114 if (lc $f eq 'qra') {
115 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
116 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
119 if (lc $f eq 'zone') {
120 $zone = shift @list if @list;
123 if (lc $f =~ /^by_?zone/) {
124 $byzone = shift @list if @list;
127 if (lc $f eq 'itu') {
128 $itu = shift @list if @list;
131 if (lc $f =~ /^by_?itu/) {
132 $byitu = shift @list if @list;
135 if (lc $f eq 'state') {
136 $state = uc shift @list if @list;
139 if (lc $f =~ /^by_?state/) {
140 $bystate = uc shift @list if @list;
150 # first deal with the prefix
155 @ans = Prefix::extract($pre); # is it a callsign/prefix?
159 # first deal with the prefix
160 my $pre = shift @ans;
162 my $str = "Prefix: $pre";
167 # build up a search string for this dxcc country/countries
170 push @expr, "\$f5 == $n";
172 my $name = $a->name();
173 $str .= " Dxcc: $n ($name)";
177 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
178 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
182 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
183 $pre = shellregex($pre);
189 $pre .= '$' if $exact;
190 $expr = "\$f1 =~ m{$pre}";
196 # now deal with any frequencies specified
198 $expr .= ($expr) ? ' && (' : "(";
199 # $hint .= ($hint) ? ' && ' : "(";
200 # $hint .= ' && ' if $hint;
202 for ($i = 0; $i < @freq; $i += 2) {
203 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
204 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
205 # $hint .= "m{$r\\.} ||" if $r;
206 # $hint .= "m{\d+\.} ||";
209 chop $expr; chop $expr;
210 # chop $hint; chop $hint;
217 $expr .= ' && ' if $expr;
218 $info =~ s{(.)}{"\Q$1"}ge;
219 $expr .= "\$f3 =~ m{$info}i";
220 $hint .= ' && ' if $hint;
221 $hint .= "m{$info}i";
228 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
232 # first deal with the prefix
233 my $pre = shift @ans;
235 $expr .= ' && ' if $expr;
236 $hint .= ' && ' if $hint;
237 my $str = "Spotter: $pre";
242 # build up a search string for this dxcc country/countries
245 push @expr, "\$f6 == $n";
247 my $name = $a->name();
248 $str .= " Dxcc: $n ($name)";
252 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
253 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
257 $expr .= ' && ' if $expr;
258 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
259 $spotter = shellregex($spotter);
261 $spotter =~ s/\.\*/%/g;
263 $spotter =~ s/\.\*\$$//;
265 $expr .= "\$f4 =~ m{\U$spotter}";
266 $hint .= ' && ' if $hint;
267 $spotter =~ s/[\^\$]//g;
268 $hint .= "m{\U$spotter}";
276 $expr .= ' && ' if $expr;
277 $hint .= ' && ' if $hint;
278 for (split /[:,]/, $zone) {
279 push @expr, "\$f9==$_";
282 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
283 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
288 $expr .= ' && ' if $expr;
289 $hint .= ' && ' if $hint;
290 for (split /[:,]/, $byzone) {
291 push @expr, "\$f11==$_";
294 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
295 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
302 $expr .= ' && ' if $expr;
303 $hint .= ' && ' if $hint;
304 for (split /[:,]/, $itu) {
305 push @expr, "\$f8==$_";
308 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
309 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
314 $expr .= ' && ' if $expr;
315 $hint .= ' && ' if $hint;
316 for (split /[:,]/, $byitu) {
317 push @expr, "\$f10==$_";
320 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
321 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
328 $expr .= ' && ' if $expr;
329 $hint .= ' && ' if $hint;
330 for (split /[:,]/, $state) {
331 push @expr, "\$f12 eq '$_'";
335 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
337 $expr .= @expr > 1 ? '(\$f12 && (' . join(' || ', @expr) . '))' : "(\$f12 && $expr[0])";
339 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
344 $expr .= ' && ' if $expr;
345 $hint .= ' && ' if $hint;
346 for (split /[:,]/, $bystate) {
347 push @expr, "\$f13 eq '$_'";
351 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
353 $expr .= @expr > 1 ? '(\$f13 && (' . join(' || ', @expr) . '))' : "(\$f13 && $expr[0])";
355 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
360 $expr .= ' && ' if $expr;
361 $expr .= "\$f3 =~ m{QSL|VIA}i";
362 $hint .= ' && ' if $hint;
363 $hint .= "m{QSL|VIA}i";
368 $expr .= ' && ' if $expr;
369 $expr .= "\$f3 =~ m{$doiota}i";
370 $hint .= ' && ' if $hint;
371 $hint .= "m{$doiota}i";
376 $expr .= ' && ' if $expr;
377 $expr .= "\$f3 =~ m{$doqra}i";
378 $hint .= ' && ' if $hint;
379 $hint .= "m{$doqra}io";
382 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
386 push @out, $self->spawn_cmd(\&Spot::search,
387 args => [$expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef],
389 my ($dxchan, @res) = @_;
393 foreach $ref (@res) {
395 push @out, VE7CC::dx_spot($self, @$ref);
398 push @out, DXCommandmode::format_dx_spot($self, @$ref);
400 push @out, Spot::formatl(@$ref);
407 #my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef);
410 #foreach $ref (@res) {
411 # if ($self && $self->ve7cc) {
412 # push @out, VE7CC::dx_spot($self, @$ref);
414 # if ($self && $real) {
415 # push @out, DXCommandmode::format_dx_spot($self, @$ref);
417 # push @out, Spot::formatl(@$ref);