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');
45 while (@list) { # next field
47 dbg("sh/dx arg: $f list: '" . join(',', @list) . "'") if isdbg('sh/dx');
48 if ($f && !$from && !$to) {
49 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$| || (0,0); # is it a from -> to count?
50 dbg("sh/dx from: $from to: $to") if isdbg('sh/dx');
51 next if $from && $to > $from;
54 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
56 dbg("sh/dx to: $to") if isdbg('sh/dx');
59 if (lc $f eq 'day' && $list[0]) {
60 ($fromday, $today) = split m|[-/]|, shift(@list);
61 dbg("sh/dx got day $fromday/$today") if isdbg('sh/dx');
64 if (lc $f eq 'exact') {
65 dbg("sh/dx exact") if isdbg('sh/dx');
69 if (lc $f eq 'rt' || $f =~ /^real/i) {
70 dbg("sh/dx real") if isdbg('sh/dx');
74 if (lc $f =~ /^filt/) {
75 dbg("sh/dx run spotfilter") if isdbg('sh/dx');
76 $dofilter = 1 if $self && $self->spotsfilter;
80 dbg("sh/dx qsl") if isdbg('sh/dx');
81 push @flist, "info {QSL|VIA}";
84 if (lc $f eq '<es>') {
85 dbg("sh/dx <es>") if isdbg('sh/dx');
86 push @flist, "info {<ES>}";
89 if (lc $f eq '<tr>') {
90 dbg("sh/dx <es>") if isdbg('sh/dx');
91 push @flist, "info {<TR>}";
94 if (lc $f eq '<ms>') {
95 dbg("sh/dx <ms>") if isdbg('sh/dx');
96 push @flist, "info {<ms>}";
100 if (lc $f eq 'iota') {
102 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)[-\s]?(\d\d?\d?)/i)) {
104 $doiota = "\\b$a\[\-\ \]\?$b\\b";
107 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[-\s]?\d?\d\d)\b' unless $doiota;
108 push @flist, 'info', "{$doiota}";
109 dbg("sh/dx iota info {$doiota}") if isdbg('sh/dx');
112 if (lc $f eq 'qra') {
113 my $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/i;
114 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
115 push @flist, 'info', "{$doqra}";
116 dbg("sh/dx qra info {$doqra}") if isdbg('sh/dx');
119 if (grep {lc $f eq $_} qw { ( or and not ) }) {
121 dbg("sh/dx operator $f") if isdbg('sh/dx');
124 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) ) {
126 push @flist, shift @list if @list;
127 dbg("sh/dx function $flist[-2] $flist[-1]") if isdbg('sh/dx');
137 dbg("sh/dx: flist = '" . join(',', @flist). "'") if isdbg('sh/dx');
140 # someone (probably me) has forgotten the 'info' keyword
141 if ($pre =~ /^{.*}$/) {
142 push @flist, 'info', $pre;
144 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
145 $pre = shellregex($pre);
147 $pre .= '$' if $exact;
149 push @flist, 'call', $pre;
153 my $newline = join(' ', @flist);
154 dbg("sh/dx newline: '$newline'") if isdbg('sh/dx');
155 my ($r, $filter, $fno, $user, $expr) = $Spot::filterdef->parse($self, 'spots', $newline, 1);
157 return (0, "sh/dx parse error '$r' " . $filter) if $r;
161 dbg("sh/dx user: $user expr: $expr from: $from to: $to fromday: $fromday today: $today") if isdbg('sh/dx');
165 if ($self->{_nospawn} || ($Spot::spotcachedays && !$expr && $from == 0 && $fromday == 0 && $today == 0)) {
166 my @res = Spot::search($expr, $fromday, $today, $from, $to, $user, $dofilter, $self);
169 foreach $ref (@res) {
170 if ($self && $self->ve7cc) {
171 push @out, VE7CC::dx_spot($self, @$ref);
174 if ($self && $real) {
175 push @out, DXCommandmode::format_dx_spot($self, @$ref);
178 push @out, Spot::formatl(@$ref);
184 push @out, $self->spawn_cmd("sh/dx $line", \&Spot::search,
185 args => [$expr, $fromday, $today, $from, $to, $filter, $dofilter, $self],
187 my ($dxchan, @res) = @_;
191 foreach $ref (@res) {
193 push @out, VE7CC::dx_spot($self, @$ref);
197 push @out, DXCommandmode::format_dx_spot($self, @$ref);
200 push @out, Spot::formatl(@$ref);
204 push @out, $self->msg('e3', "sh/dx", "'$line'") unless @out;