12 my ($self, $line) = @_;
15 $line =~ s/\{(.*?)\}/'{'. unpack('H*', $1) . '}'/eg;
16 dbg("sh/dx disguise any regex: '$line'") if isdbg('sh/dx');
18 # now space out brackets and !
19 $line =~ s/([\(\!\)])/ $1 /g;
21 my @list = split /\s+/, $line; # split the line up
23 # put back the regexes
24 @list = map { my $l = $_; $l =~ s/\{([0-9a-fA-F]+)\}/'{' . pack('H*', $1) . '}'/eg; $l } @list;
26 dbg("sh/dx after regex return: '" . join(' ', @list) . "'") if isdbg('sh/dx');
30 my $call = $self->call;
31 my $usesql = $main::dbh && $Spot::use_db_for_search;
32 my ($from, $to) = (0, 0);
33 my ($fromday, $today) = (0, 0);
43 dbg("sh/dx list: " . join(" ", @list)) if isdbg('sh/dx');
47 while (@list) { # next field
49 dbg("sh/dx arg: $f list: '" . join(',', @list) . "'") if isdbg('sh/dx');
50 if ($f && !$from && !$to) {
51 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$| || (0,0); # is it a from -> to count?
52 dbg("sh/dx from: $from to: $to") if isdbg('sh/dx');
53 next if $from && $to > $from;
56 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
58 dbg("sh/dx to: $to") if isdbg('sh/dx');
61 if (lc $f eq 'day' && $list[0]) {
62 ($fromday, $today) = split m|[-/]|, shift(@list);
63 dbg("sh/dx got day $fromday/$today") if isdbg('sh/dx');
66 if (lc $f eq 'exact') {
67 dbg("sh/dx exact") if isdbg('sh/dx');
71 if (lc $f eq 'rt' || $f =~ /^real/i) {
72 dbg("sh/dx real") if isdbg('sh/dx');
76 if (lc $f =~ /^filt/) {
77 dbg("sh/dx run spotfilter") if isdbg('sh/dx');
78 $dofilter = 1 if $self && $self->spotsfilter;
82 dbg("sh/dx qsl") if isdbg('sh/dx');
83 push @flist, "info {QSL|VIA}";
86 if (lc $f eq '<es>') {
87 dbg("sh/dx <es>") if isdbg('sh/dx');
88 push @flist, "info {<ES>}";
91 if (lc $f eq '<tr>') {
92 dbg("sh/dx <es>") if isdbg('sh/dx');
93 push @flist, "info {<TR>}";
96 if (lc $f eq '<ms>') {
97 dbg("sh/dx <ms>") if isdbg('sh/dx');
98 push @flist, "info {<ms>}";
102 if (lc $f eq 'iota') {
104 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)[-\s]?(\d\d?\d?)/i)) {
106 $doiota = "\\b$a\[\-\ \]\?$b\\b";
109 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[-\s]?\d?\d\d)\b' unless $doiota;
110 push @flist, 'info', "{$doiota}";
111 dbg("sh/dx iota info {$doiota}") if isdbg('sh/dx');
114 if (lc $f eq 'qra') {
115 my $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/i;
116 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
117 push @flist, 'info', "{$doqra}";
118 dbg("sh/dx qra info {$doqra}") if isdbg('sh/dx');
121 if (grep {lc $f eq $_} qw { ( or and not ) }) {
123 dbg("sh/dx operator $f") if isdbg('sh/dx');
126 if (grep {lc $f eq $_} qw(on freq call info spotter by dxcc call_dxcc by_dxcc bydxcc origin call_itu itu call_zone zone cq bycq byitu by_itu by_zone byzone call_state state bystate by_state ip) ) {
128 push @flist, shift @list if @list;
129 dbg("sh/dx function $flist[-2] $flist[-1]") if isdbg('sh/dx');
139 dbg("sh/dx: flist = '" . join(',', @flist). "'") if isdbg('sh/dx');
142 # someone (probably me) has forgotten the 'info' keyword
143 if ($pre =~ /^{.*}$/) {
144 push @flist, 'info', $pre;
146 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
147 $pre = shellregex($pre);
149 $pre .= '$' if $exact;
151 push @flist, 'call', $pre;
155 my $newline = join(' ', @flist);
156 dbg("sh/dx newline: '$newline'") if isdbg('sh/dx');
157 my ($r, $filter, $fno, $user, $expr) = $Spot::filterdef->parse($self, 'spots', $newline, 1);
159 return (0, "sh/dx parse error '$r' " . $filter) if $r;
163 dbg("sh/dx user: $user expr: $expr from: $from to: $to fromday: $fromday today: $today") if isdbg('sh/dx');
167 if ($self->{_nospawn} || ($Spot::spotcachedays && !$expr && $from == 0 && $fromday == 0 && $today == 0)) {
168 my @res = Spot::search($expr, $fromday, $today, $from, $to, $user, $dofilter, $self);
171 foreach $ref (@res) {
172 if ($self && $self->ve7cc) {
173 push @out, VE7CC::dx_spot($self, @$ref);
176 if ($self && $real) {
177 push @out, DXCommandmode::format_dx_spot($self, @$ref);
180 push @out, Spot::formatl($self->{width}, @$ref);
186 push @out, $self->spawn_cmd("sh/dx $line", \&Spot::search,
187 args => [$expr, $fromday, $today, $from, $to, $filter, $dofilter, $self],
189 my ($dxchan, @res) = @_;
193 foreach $ref (@res) {
195 push @out, VE7CC::dx_spot($self, @$ref);
199 push @out, DXCommandmode::format_dx_spot($self, @$ref);
202 push @out, Spot::formatl($self->{width}, @$ref);
206 push @out, $self->msg('e3', "sh/dx", "'$line'") unless @out;