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' || lc $f eq 'by_dxcc') && $list[0]) {
85 # print "got spotter\n";
86 $spotter = uc shift @list;
87 if ($f eq 'by_dxcc') {
89 } elsif ($list[0] && lc $list[0] eq 'dxcc') {
95 if (lc $f =~ /^filt/) {
96 $dofilter = 1 if $self && $self->spotsfilter;
103 if (lc $f eq 'iota') {
107 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
109 $doiota = "\\b$a\[\-\ \]\?$b\\b";
112 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
115 if (lc $f eq 'qra') {
116 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
117 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
120 if (lc $f eq 'zone') {
121 $zone = shift @list if @list;
124 if (lc $f =~ /^by_?zone/) {
125 $byzone = shift @list if @list;
128 if (lc $f eq 'itu') {
129 $itu = shift @list if @list;
132 if (lc $f =~ /^by_?itu/) {
133 $byitu = shift @list if @list;
136 if (lc $f eq 'state') {
137 $state = uc shift @list if @list;
140 if (lc $f =~ /^by_?state/) {
141 $bystate = uc shift @list if @list;
151 # first deal with the prefix
156 @ans = Prefix::extract($pre); # is it a callsign/prefix?
160 # first deal with the prefix
161 my $pre = shift @ans;
163 my $str = "Prefix: $pre";
168 # build up a search string for this dxcc country/countries
171 push @expr, "\$f5 == $n";
173 my $name = $a->name();
174 $str .= " Dxcc: $n ($name)";
178 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
179 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
183 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
184 $pre = shellregex($pre);
190 $pre .= '$' if $exact;
191 $expr = "\$f1 =~ m{$pre}";
197 # now deal with any frequencies specified
199 $expr .= ($expr) ? ' && (' : "(";
200 # $hint .= ($hint) ? ' && ' : "(";
201 # $hint .= ' && ' if $hint;
203 for ($i = 0; $i < @freq; $i += 2) {
204 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
205 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
206 # $hint .= "m{$r\\.} ||" if $r;
207 # $hint .= "m{\d+\.} ||";
210 chop $expr; chop $expr;
211 # chop $hint; chop $hint;
218 $expr .= ' && ' if $expr;
219 $info =~ s{(.)}{"\Q$1"}ge;
220 $expr .= "\$f3 =~ m{$info}i";
221 $hint .= ' && ' if $hint;
222 $hint .= "m{$info}i";
229 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
233 # first deal with the prefix
234 my $pre = shift @ans;
236 $expr .= ' && ' if $expr;
237 $hint .= ' && ' if $hint;
238 my $str = "Spotter: $pre";
243 # build up a search string for this dxcc country/countries
246 push @expr, "\$f6 == $n";
248 my $name = $a->name();
249 $str .= " Dxcc: $n ($name)";
253 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
254 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
258 $expr .= ' && ' if $expr;
259 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
260 $spotter = shellregex($spotter);
262 $spotter =~ s/\.\*/%/g;
264 $spotter =~ s/\.\*\$$//;
266 $expr .= "\$f4 =~ m{\U$spotter}";
267 $hint .= ' && ' if $hint;
268 $spotter =~ s/[\^\$]//g;
269 $hint .= "m{\U$spotter}";
277 $expr .= ' && ' if $expr;
278 $hint .= ' && ' if $hint;
279 for (split /[:,]/, $zone) {
280 push @expr, "\$f9==$_";
283 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
284 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
289 $expr .= ' && ' if $expr;
290 $hint .= ' && ' if $hint;
291 for (split /[:,]/, $byzone) {
292 push @expr, "\$f11==$_";
295 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
296 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
303 $expr .= ' && ' if $expr;
304 $hint .= ' && ' if $hint;
305 for (split /[:,]/, $itu) {
306 push @expr, "\$f8==$_";
309 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
310 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
315 $expr .= ' && ' if $expr;
316 $hint .= ' && ' if $hint;
317 for (split /[:,]/, $byitu) {
318 push @expr, "\$f10==$_";
321 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
322 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
329 $expr .= ' && ' if $expr;
330 $hint .= ' && ' if $hint;
331 for (split /[:,]/, $state) {
332 push @expr, "\$f12 eq '$_'";
336 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
338 $expr .= @expr > 1 ? '(\$f12 && (' . join(' || ', @expr) . '))' : "(\$f12 && $expr[0])";
340 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
345 $expr .= ' && ' if $expr;
346 $hint .= ' && ' if $hint;
347 for (split /[:,]/, $bystate) {
348 push @expr, "\$f13 eq '$_'";
352 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
354 $expr .= @expr > 1 ? '(\$f13 && (' . join(' || ', @expr) . '))' : "(\$f13 && $expr[0])";
356 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
361 $expr .= ' && ' if $expr;
362 $expr .= "\$f3 =~ m{QSL|VIA}i";
363 $hint .= ' && ' if $hint;
364 $hint .= "m{QSL|VIA}i";
369 $expr .= ' && ' if $expr;
370 $expr .= "\$f3 =~ m{$doiota}i";
371 $hint .= ' && ' if $hint;
372 $hint .= "m{$doiota}i";
377 $expr .= ' && ' if $expr;
378 $expr .= "\$f3 =~ m{$doqra}i";
379 $hint .= ' && ' if $hint;
380 $hint .= "m{$doqra}io";
383 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
386 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef);
389 foreach $ref (@res) {
390 if ($self && $self->ve7cc) {
391 push @out, VE7CC::dx_spot($self, @$ref);
393 if ($self && $real) {
394 push @out, DXCommandmode::format_dx_spot($self, @$ref);
396 push @out, Spot::formatl(@$ref);