12 my ($self, $line) = @_;
14 $line =~ s/([\(\!\)])/ $1 /g;
16 my @list = split /[\s]+/, $line; # split the line up
20 my $call = $self->call;
21 my $usesql = $main::dbh && $Spot::use_db_for_search;
22 my ($from, $to) = (0, 0);
23 my ($fromday, $today) = (0, 0);
33 dbg("sh/dx \@list: " . join(" ", @list)) if isdbg('sh/dx');
35 while ($f = shift @list) { # next field
36 dbg "sh/dx arg: $f list: " . join(',', @list) if isdbg('sh/dx');
38 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
39 dbg("sh/dx from: $from to: $to") if isdbg('sh/dx');
40 next if $from && $to > $from;
43 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
44 dbg("sh/dx to: $to") if isdbg('sh/dx');
47 if (lc $f eq 'day' && $list[0]) {
48 ($fromday, $today) = split m|[-/]|, shift(@list);
49 dbg "sh/dx got day $fromday/$today" if isdbg('sh/dx');
52 if (lc $f eq 'exact') {
53 dbg("sh/dx exact") if isdbg('sh/dx');
57 if (lc $f eq 'rt' || $f =~ /^real/i) {
58 dbg("sh/dx real") if isdbg('sh/dx');
62 if (lc $f =~ /^filt/) {
63 dbg("sh/dx run spotfilter") if isdbg('sh/dx');
64 $dofilter = 1 if $self && $self->spotsfilter;
68 dbg("sh/dx qsl") if isdbg('sh/dx');
69 push @flist, "info {QSL|VIA}";
72 if (lc $f eq 'iota') {
74 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)-?(\d?\d\d)/oi)) {
76 $doiota = "\\b$a\[\-\ \]\?$b\\b";
79 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[- ]?\d?\d\d)\b' unless $doiota;
80 push @flist, "info {$doiota}";
81 dbg("sh/dx iota") if isdbg('sh/dx');
85 my $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/oi;
86 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
87 push @flist, "info {$doqra}";
88 dbg("sh/dx qra") if isdbg('sh/dx');
91 if (grep {lc $f eq $_} qw { ( or and not ) }) {
93 dbg("sh/dx operator $f") if isdbg('sh/dx');
96 if (grep {lc $f eq $_} qw(zone byzone by_zone itu byitu by_itu state bystate by_state info on spotter by) ) {
97 $f =~ s/^by(\w)/by_$1/;
99 push @flist, shift @list if @list;
100 dbg("sh/dx function $flist[-2] $flist[-1]") if isdbg('sh/dx');
112 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
113 $pre = shellregex($pre);
119 $pre .= '$' if $exact;
122 push @flist, 'call', $pre;
125 my $newline = join(' ', @flist);
126 dbg("sh/dx newline: $newline") if isdbg('sh/dx');
127 my ($r, $filter, $fno, $user, $expr) = $Spot::filterdef->parse($self, 'spots', $newline, 1);
129 return (0, "sh/dx parse error '$r' " . $filter) if $r;
132 dbg "sh/dx user: $user expr: $expr from: $from to: $to fromday: $fromday today: $today" if isdbg('sh/dx');
136 if ($self->{_nospawn}) {
137 my @res = Spot::search($expr, $fromday, $today, $from, $to, $user, $dofilter ? $self : undef);
140 foreach $ref (@res) {
141 if ($self && $self->ve7cc) {
142 push @out, VE7CC::dx_spot($self, @$ref);
145 if ($self && $real) {
146 push @out, DXCommandmode::format_dx_spot($self, @$ref);
149 push @out, Spot::formatl(@$ref);
155 push @out, $self->spawn_cmd("sh/dx $line", \&Spot::search,
156 args => [$expr, $fromday, $today, $from, $to, $filter, $dofilter ? $self : undef],
158 my ($dxchan, @res) = @_;
162 foreach $ref (@res) {
164 push @out, VE7CC::dx_spot($self, @$ref);
168 push @out, DXCommandmode::format_dx_spot($self, @$ref);
171 push @out, Spot::formatl(@$ref);
175 push @out, $self->msg('e3', "sh/dx", "'$line'") unless @out;