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 my $usesql = $main::dbh && $Spot::use_db_for_search;
37 while ($f = shift @list) { # next field
38 # print "f: $f list: ", join(',', @list), "\n";
40 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
41 next if $from && $to > $from;
44 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
47 if (lc $f eq 'exact') {
51 if (lc $f eq 'dxcc') {
55 if (lc $f eq 'rt' || $f =~ /^real/i) {
59 if (lc $f eq 'on' && $list[0]) { # is it freq range?
61 if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) {
66 my @r = split '/', lc $list[0];
67 # print "r0: $r[0] r1: $r[1]\n";
68 my @fr = Bands::get_freq($r[0], $r[1]);
69 if (@fr) { # yup, get rid of extranous param
70 # print "freq: ", join(',', @fr), "\n";
71 push @freq, @fr; # add these to the list
77 if (lc $f eq 'day' && $list[0]) {
79 ($fromday, $today) = split m|[-/]|, shift(@list);
82 if (lc $f eq 'info' && $list[0]) {
87 if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) {
88 # print "got spotter\n";
89 $spotter = uc shift @list;
90 if ($list[0] && lc $list[0] eq 'dxcc') {
96 if (lc $f =~ /^filt/) {
97 $dofilter = 1 if $self && $self->spotsfilter;
100 if (lc $f eq 'qsl') {
104 if (lc $f eq 'iota') {
108 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
110 $doiota = "\\b$a\[\-\ \]\?$b\\b";
113 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
116 if (lc $f eq 'qra') {
117 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
118 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
121 if (lc $f eq 'zone') {
122 $zone = shift @list if @list;
125 if (lc $f =~ /^by_?zone/) {
126 $byzone = shift @list if @list;
129 if (lc $f eq 'itu') {
130 $itu = shift @list if @list;
133 if (lc $f =~ /^by_?itu/) {
134 $byitu = shift @list if @list;
137 if (lc $f eq 'state') {
138 $state = uc shift @list if @list;
141 if (lc $f =~ /^by_?state/) {
142 $bystate = uc shift @list if @list;
152 # first deal with the prefix
157 @ans = Prefix::extract($pre); # is it a callsign/prefix?
161 # first deal with the prefix
162 my $pre = shift @ans;
164 my $str = "Prefix: $pre";
169 # build up a search string for this dxcc country/countries
172 push @expr, "\$f5 == $n";
174 my $name = $a->name();
175 $str .= " Dxcc: $n ($name)";
179 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
180 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
184 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
185 $pre = shellregex($pre);
191 $pre .= '$' if $exact;
192 $expr = "\$f1 =~ m{$pre}";
198 # now deal with any frequencies specified
200 $expr .= ($expr) ? ' && (' : "(";
201 # $hint .= ($hint) ? ' && ' : "(";
202 # $hint .= ' && ' if $hint;
204 for ($i = 0; $i < @freq; $i += 2) {
205 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
206 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
207 # $hint .= "m{$r\\.} ||" if $r;
208 # $hint .= "m{\d+\.} ||";
211 chop $expr; chop $expr;
212 # chop $hint; chop $hint;
219 $expr .= ' && ' if $expr;
220 $info =~ s{(.)}{"\Q$1"}ge;
221 $expr .= "\$f3 =~ m{$info}i";
222 $hint .= ' && ' if $hint;
223 $hint .= "m{$info}i";
230 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
234 # first deal with the prefix
235 my $pre = shift @ans;
237 $expr .= ' && ' if $expr;
238 $hint .= ' && ' if $hint;
239 my $str = "Spotter: $pre";
244 # build up a search string for this dxcc country/countries
247 push @expr, "\$f6 == $n";
249 my $name = $a->name();
250 $str .= " Dxcc: $n ($name)";
254 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
255 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
259 $expr .= ' && ' if $expr;
260 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
261 $spotter = shellregex($spotter);
263 $spotter =~ s/\.\*/%/g;
265 $spotter =~ s/\.\*\$$//;
267 $expr .= "\$f4 =~ m{\U$spotter}";
268 $hint .= ' && ' if $hint;
269 $spotter =~ s/[\^\$]//g;
270 $hint .= "m{\U$spotter}";
278 $expr .= ' && ' if $expr;
279 $hint .= ' && ' if $hint;
280 for (split /[:,]/, $zone) {
281 push @expr, "\$f9==$_";
284 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
285 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
290 $expr .= ' && ' if $expr;
291 $hint .= ' && ' if $hint;
292 for (split /[:,]/, $byzone) {
293 push @expr, "\$f11==$_";
296 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
297 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
304 $expr .= ' && ' if $expr;
305 $hint .= ' && ' if $hint;
306 for (split /[:,]/, $itu) {
307 push @expr, "\$f8==$_";
310 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
311 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
316 $expr .= ' && ' if $expr;
317 $hint .= ' && ' if $hint;
318 for (split /[:,]/, $byitu) {
319 push @expr, "\$f10==$_";
322 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
323 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
330 $expr .= ' && ' if $expr;
331 $hint .= ' && ' if $hint;
332 for (split /[:,]/, $state) {
333 push @expr, "\$f12 eq '$_'";
337 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
339 $expr .= @expr > 1 ? '(\$f12 && (' . join(' || ', @expr) . '))' : "(\$f12 && $expr[0])";
341 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
346 $expr .= ' && ' if $expr;
347 $hint .= ' && ' if $hint;
348 for (split /[:,]/, $bystate) {
349 push @expr, "\$f13 eq '$_'";
353 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
355 $expr .= @expr > 1 ? '(\$f13 && (' . join(' || ', @expr) . '))' : "(\$f13 && $expr[0])";
357 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
362 $expr .= ' && ' if $expr;
363 $expr .= "\$f3 =~ m{QSL|VIA}i";
364 $hint .= ' && ' if $hint;
365 $hint .= "m{QSL|VIA}i";
370 $expr .= ' && ' if $expr;
371 $expr .= "\$f3 =~ m{$doiota}i";
372 $hint .= ' && ' if $hint;
373 $hint .= "m{$doiota}i";
378 $expr .= ' && ' if $expr;
379 $expr .= "\$f3 =~ m{$doqra}i";
380 $hint .= ' && ' if $hint;
381 $hint .= "m{$doqra}io";
384 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
388 push @out, $self->spawn_cmd(\&Spot::search,
389 args => [$expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef],
391 my ($dxchan, @res) = @_;
395 foreach $ref (@res) {
397 push @out, VE7CC::dx_spot($self, @$ref);
400 push @out, DXCommandmode::format_dx_spot($self, @$ref);
402 push @out, Spot::formatl(@$ref);
409 #my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef);
412 #foreach $ref (@res) {
413 # if ($self && $self->ve7cc) {
414 # push @out, VE7CC::dx_spot($self, @$ref);
416 # if ($self && $real) {
417 # push @out, DXCommandmode::format_dx_spot($self, @$ref);
419 # push @out, Spot::formatl(@$ref);