7 my ($self, $line) = @_;
8 my @list = split /\s+/, $line; # split the line up
14 my ($fromday, $today);
31 my ($doqsl, $doiota, $doqra, $dofilter);
33 while ($f = shift @list) { # next field
34 # print "f: $f list: ", join(',', @list), "\n";
36 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
37 next if $from && $to > $from;
40 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
43 if (lc $f eq 'dxcc') {
47 if (lc $f eq 'rt' || $f =~ /^real/i) {
51 if (lc $f eq 'on' && $list[0]) { # is it freq range?
53 if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) {
58 my @r = split '/', lc $list[0];
59 # print "r0: $r[0] r1: $r[1]\n";
60 my @fr = Bands::get_freq($r[0], $r[1]);
61 if (@fr) { # yup, get rid of extranous param
62 # print "freq: ", join(',', @fr), "\n";
63 push @freq, @fr; # add these to the list
69 if (lc $f eq 'day' && $list[0]) {
71 ($fromday, $today) = split m|[-/]|, shift(@list);
74 if (lc $f eq 'info' && $list[0]) {
79 if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) {
80 # print "got spotter\n";
81 $spotter = uc shift @list;
82 if ($list[0] && lc $list[0] eq 'dxcc') {
88 if (lc $f =~ /^filt/) {
89 $dofilter = 1 if $self && $self->spotsfilter;
96 if (lc $f eq 'iota') {
100 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
102 $doiota = "\\b$a\[\-\ \]\?$b\\b";
105 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
108 if (lc $f eq 'qra') {
109 $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
110 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
113 if (lc $f eq 'zone') {
114 $zone = shift @list if @list;
117 if (lc $f =~ /^by_?zone/) {
118 $byzone = shift @list if @list;
121 if (lc $f eq 'itu') {
122 $itu = shift @list if @list;
125 if (lc $f =~ /^by_?itu/) {
126 $byitu = shift @list if @list;
129 if (lc $f eq 'state') {
130 $state = uc shift @list if @list;
133 if (lc $f =~ /^by_?state/) {
134 $bystate = uc shift @list if @list;
144 # first deal with the prefix
149 @ans = Prefix::extract($pre); # is it a callsign/prefix?
153 # first deal with the prefix
154 my $pre = shift @ans;
156 my $str = "Prefix: $pre";
161 # build up a search string for this dxcc country/countries
164 push @expr, "\$f5 == $n";
166 my $name = $a->name();
167 $str .= " Dxcc: $n ($name)";
171 $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
172 $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
176 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
177 $pre = shellregex($pre);
183 $expr = "\$f1 =~ m{$pre}";
189 # now deal with any frequencies specified
191 $expr .= ($expr) ? ' && (' : "(";
192 # $hint .= ($hint) ? ' && ' : "(";
193 # $hint .= ' && ' if $hint;
195 for ($i = 0; $i < @freq; $i += 2) {
196 $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
197 my $r = Spot::ftor($freq[$i], $freq[$i+1]);
198 # $hint .= "m{$r\\.} ||" if $r;
199 # $hint .= "m{\d+\.} ||";
202 chop $expr; chop $expr;
203 # chop $hint; chop $hint;
210 $expr .= ' && ' if $expr;
211 $info =~ s{(.)}{"\Q$1"}ge;
212 $expr .= "\$f3 =~ m{$info}i";
213 $hint .= ' && ' if $hint;
214 $hint .= "m{$info}i";
221 @ans = Prefix::extract($spotter); # is it a callsign/prefix?
225 # first deal with the prefix
226 my $pre = shift @ans;
228 $expr .= ' && ' if $expr;
229 $hint .= ' && ' if $hint;
230 my $str = "Spotter: $pre";
235 # build up a search string for this dxcc country/countries
238 push @expr, "\$f6 == $n";
240 my $name = $a->name();
241 $str .= " Dxcc: $n ($name)";
245 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
246 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
250 $expr .= ' && ' if $expr;
251 $spotter .= '*' unless $spotter =~ /[\*\?\[]/o;
252 $spotter = shellregex($spotter);
254 $spotter =~ s/\.\*/%/g;
256 $spotter =~ s/\.\*\$$//;
258 $expr .= "\$f4 =~ m{\U$spotter}";
259 $hint .= ' && ' if $hint;
260 $spotter =~ s/[\^\$]//g;
261 $hint .= "m{\U$spotter}";
269 $expr .= ' && ' if $expr;
270 $hint .= ' && ' if $hint;
271 for (split /[:,]/, $zone) {
272 push @expr, "\$f9==$_";
275 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
276 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
281 $expr .= ' && ' if $expr;
282 $hint .= ' && ' if $hint;
283 for (split /[:,]/, $byzone) {
284 push @expr, "\$f11==$_";
287 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
288 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
295 $expr .= ' && ' if $expr;
296 $hint .= ' && ' if $hint;
297 for (split /[:,]/, $itu) {
298 push @expr, "\$f8==$_";
301 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
302 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
307 $expr .= ' && ' if $expr;
308 $hint .= ' && ' if $hint;
309 for (split /[:,]/, $byitu) {
310 push @expr, "\$f10==$_";
313 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0];
314 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
321 $expr .= ' && ' if $expr;
322 $hint .= ' && ' if $hint;
323 for (split /[:,]/, $state) {
324 push @expr, "\$f12 eq '$_'";
328 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
330 $expr .= @expr > 1 ? '(\$f12 && (' . join(' || ', @expr) . '))' : "(\$f12 && $expr[0])";
332 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
337 $expr .= ' && ' if $expr;
338 $hint .= ' && ' if $hint;
339 for (split /[:,]/, $bystate) {
340 push @expr, "\$f13 eq '$_'";
344 $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : "$expr[0]";
346 $expr .= @expr > 1 ? '(\$f13 && (' . join(' || ', @expr) . '))' : "(\$f13 && $expr[0])";
348 $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0];
353 $expr .= ' && ' if $expr;
354 $expr .= "\$f3 =~ m{QSL|VIA}i";
355 $hint .= ' && ' if $hint;
356 $hint .= "m{QSL|VIA}i";
361 $expr .= ' && ' if $expr;
362 $expr .= "\$f3 =~ m{$doiota}i";
363 $hint .= ' && ' if $hint;
364 $hint .= "m{$doiota}i";
369 $expr .= ' && ' if $expr;
370 $expr .= "\$f3 =~ m{$doqra}i";
371 $hint .= ' && ' if $hint;
372 $hint .= "m{$doqra}io";
375 #print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
378 my @res = Spot::search($expr, $fromday, $today, $from, $to, $hint, $dofilter ? $self : undef);
381 foreach $ref (@res) {
382 if ($self && $self->ve7cc) {
383 push @out, VE7CC::dx_spot($self, @$ref);
385 if ($self && $real) {
386 push @out, DXCommandmode::format_dx_spot($self, @$ref);
388 push @out, Spot::formatl(@$ref);