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)[-\s]?(\d\d?\d?)/i)) {
76 $doiota = "\\b$a\[\-\ \]\?$b\\b";
79 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[-\s]?\d?\d\d)\b' unless $doiota;
80 push @flist, 'info', "{$doiota}";
81 dbg("sh/dx iota info {$doiota}") if isdbg('sh/dx');
85 my $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/i;
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 info {$doqra}") 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(on freq call info spotter by call_dxcc by_dxcc bydxcc origin call_itu itu call_zone zone byitu by_itu by_zone byzone call_state state bystate by_state ip) ) {
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 # someone (probably me) has forgotten the 'info' keyword
113 if ($pre =~ /^{.*}$/) {
114 push @flist, 'info', $pre;
116 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
117 $pre = shellregex($pre);
123 $pre .= '$' if $exact;
125 push @flist, 'call', $pre;
129 my $newline = join(' ', @flist);
130 dbg("sh/dx newline: $newline") if isdbg('sh/dx');
131 my ($r, $filter, $fno, $user, $expr) = $Spot::filterdef->parse($self, 'spots', $newline, 1);
133 return (0, "sh/dx parse error '$r' " . $filter) if $r;
136 dbg "sh/dx user: $user expr: $expr from: $from to: $to fromday: $fromday today: $today" if isdbg('sh/dx');
140 if ($self->{_nospawn}) {
141 my @res = Spot::search($expr, $fromday, $today, $from, $to, $user, $dofilter ? $self : undef);
144 foreach $ref (@res) {
145 if ($self && $self->ve7cc) {
146 push @out, VE7CC::dx_spot($self, @$ref);
149 if ($self && $real) {
150 push @out, DXCommandmode::format_dx_spot($self, @$ref);
153 push @out, Spot::formatl(@$ref);
159 push @out, $self->spawn_cmd("sh/dx $line", \&Spot::search,
160 args => [$expr, $fromday, $today, $from, $to, $filter, $dofilter ? $self : undef],
162 my ($dxchan, @res) = @_;
166 foreach $ref (@res) {
168 push @out, VE7CC::dx_spot($self, @$ref);
172 push @out, DXCommandmode::format_dx_spot($self, @$ref);
175 push @out, Spot::formatl(@$ref);
179 push @out, $self->msg('e3', "sh/dx", "'$line'") unless @out;