7 my ($self, $line) = @_;
8 my @list = split /\s+/, $line; # split the line up
14 my ($fromday, $today);
32 my ($doqsl, $doiota, $doqra, $dofilter);
34 while ($f = shift @list) { # next field
35 # print "f: $f list: ", join(',', @list), "\n";
37 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
38 next if $from && $to > $from;
41 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
44 if (lc $f eq 'exact') {
48 if (lc $f eq 'dxcc') {
52 if (lc $f eq 'rt' || $f =~ /^real/i) {
56 if (lc $f eq 'on' && $list[0]) { # is it freq range?
58 if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) {
63 my @r = split '/', lc $list[0];
64 # print "r0: $r[0] r1: $r[1]\n";
65 my @fr = Bands::get_freq($r[0], $r[1]);
66 if (@fr) { # yup, get rid of extranous param
67 # print "freq: ", join(',', @fr), "\n";
68 push @freq, @fr; # add these to the list
74 if (lc $f eq 'day' && $list[0]) {
76 ($fromday, $today) = split m|[-/]|, shift(@list);
79 if (lc $f eq 'info' && $list[0]) {
84 if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) {
85 # print "got spotter\n";
86 $spotter = uc shift @list;
87 if ($list[0] && lc $list[0] eq 'dxcc') {
93 if (lc $f =~ /^filt/) {
94 $dofilter = 1 if $self && $self->spotsfilter;
101 if (lc $f eq 'iota') {
105 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
107 $doiota = "\\b$a\[\-\ \]\?$b\\b";
110 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
113 if (lc $f eq 'qra') {
114 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
115 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
118 if (lc $f eq 'zone') {
119 $zone = shift @list if @list;
122 if (lc $f =~ /^by_?zone/) {
123 $byzone = shift @list if @list;
126 if (lc $f eq 'itu') {
127 $itu = shift @list if @list;
130 if (lc $f =~ /^by_?itu/) {
131 $byitu = shift @list if @list;
134 if (lc $f eq 'state') {
135 $state = uc shift @list if @list;
138 if (lc $f =~ /^by_?state/) {
139 $bystate = uc shift @list if @list;
149 # first deal with the prefix
154 @ans = Prefix::extract($pre); # is it a callsign/prefix?
158 # first deal with the prefix
159 my $pre = shift @ans;
161 my $str = "Prefix: $pre";
166 # build up a search string for this dxcc country/countries
169 push @expr, "\$f5 == $n";
171 my $name = $a->name();
172 $str .= " Dxcc: $n ($name)";
176 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
177 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
181 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
182 $pre = shellregex($pre);
188 $pre .= '$' if $exact;
189 $expr = "\$f1 =~ m{$pre}";
195 # now deal with any frequencies specified
197 $expr .= ($expr) ? ' && (' : "(";
198 # $hint .= ($hint) ? ' && ' : "(";
199 # $hint .= ' && ' if $hint;
201 for ($i = 0; $i < @freq; $i += 2) {
202 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
203 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
204 # $hint .= "m{$r\\.} ||" if $r;
205 # $hint .= "m{\d+\.} ||";
208 chop $expr; chop $expr;
209 # chop $hint; chop $hint;
216 $expr .= ' && ' if $expr;
217 $info =~ s{(.)}{"\Q$1"}ge;
218 $expr .= "\$f3 =~ m{$info}i";
219 $hint .= ' && ' if $hint;
220 $hint .= "m{$info}i";
227 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
231 # first deal with the prefix
232 my $pre = shift @ans;
234 $expr .= ' && ' if $expr;
235 $hint .= ' && ' if $hint;
236 my $str = "Spotter: $pre";
241 # build up a search string for this dxcc country/countries
244 push @expr, "\$f6 == $n";
246 my $name = $a->name();
247 $str .= " Dxcc: $n ($name)";
251 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
252 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
256 $expr .= ' && ' if $expr;
257 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
258 $spotter = shellregex($spotter);
260 $spotter =~ s/\.\*/%/g;
262 $spotter =~ s/\.\*\$$//;
264 $expr .= "\$f4 =~ m{\U$spotter}";
265 $hint .= ' && ' if $hint;
266 $spotter =~ s/[\^\$]//g;
267 $hint .= "m{\U$spotter}";
275 $expr .= ' && ' if $expr;
276 $hint .= ' && ' if $hint;
277 for (split /[:,]/, $zone) {
278 push @expr, "\$f9==$_";
281 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
282 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
287 $expr .= ' && ' if $expr;
288 $hint .= ' && ' if $hint;
289 for (split /[:,]/, $byzone) {
290 push @expr, "\$f11==$_";
293 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
294 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
301 $expr .= ' && ' if $expr;
302 $hint .= ' && ' if $hint;
303 for (split /[:,]/, $itu) {
304 push @expr, "\$f8==$_";
307 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
308 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
313 $expr .= ' && ' if $expr;
314 $hint .= ' && ' if $hint;
315 for (split /[:,]/, $byitu) {
316 push @expr, "\$f10==$_";
319 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
320 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
327 $expr .= ' && ' if $expr;
328 $hint .= ' && ' if $hint;
329 for (split /[:,]/, $state) {
330 push @expr, "\$f12 eq '$_'";
334 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
336 $expr .= @expr > 1 ? '(\$f12 && (' . join(' || ', @expr) . '))' : "(\$f12 && $expr[0])";
338 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
343 $expr .= ' && ' if $expr;
344 $hint .= ' && ' if $hint;
345 for (split /[:,]/, $bystate) {
346 push @expr, "\$f13 eq '$_'";
350 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
352 $expr .= @expr > 1 ? '(\$f13 && (' . join(' || ', @expr) . '))' : "(\$f13 && $expr[0])";
354 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
359 $expr .= ' && ' if $expr;
360 $expr .= "\$f3 =~ m{QSL|VIA}i";
361 $hint .= ' && ' if $hint;
362 $hint .= "m{QSL|VIA}i";
367 $expr .= ' && ' if $expr;
368 $expr .= "\$f3 =~ m{$doiota}i";
369 $hint .= ' && ' if $hint;
370 $hint .= "m{$doiota}i";
375 $expr .= ' && ' if $expr;
376 $expr .= "\$f3 =~ m{$doqra}i";
377 $hint .= ' && ' if $hint;
378 $hint .= "m{$doqra}io";
381 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
384 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef);
387 foreach $ref (@res) {
388 if ($self && $self->ve7cc) {
389 push @out, VE7CC::dx_spot($self, @$ref);
391 if ($self && $real) {
392 push @out, DXCommandmode::format_dx_spot($self, @$ref);
394 push @out, Spot::formatl(@$ref);