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 ($f = shift @list) { # next field
46 dbg "sh/dx arg: $f list: " . join(',', @list) if isdbg('sh/dx');
48 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count?
49 dbg("sh/dx from: $from to: $to") if isdbg('sh/dx');
50 next if $from && $to > $from;
53 ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
54 dbg("sh/dx to: $to") if isdbg('sh/dx');
57 if (lc $f eq 'day' && $list[0]) {
58 ($fromday, $today) = split m|[-/]|, shift(@list);
59 dbg "sh/dx got day $fromday/$today" if isdbg('sh/dx');
62 if (lc $f eq 'exact') {
63 dbg("sh/dx exact") if isdbg('sh/dx');
67 if (lc $f eq 'rt' || $f =~ /^real/i) {
68 dbg("sh/dx real") if isdbg('sh/dx');
72 if (lc $f =~ /^filt/) {
73 dbg("sh/dx run spotfilter") if isdbg('sh/dx');
74 $dofilter = 1 if $self && $self->spotsfilter;
78 dbg("sh/dx qsl") if isdbg('sh/dx');
79 push @flist, "info {QSL|VIA}";
82 if (lc $f eq 'iota') {
84 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)[-\s]?(\d\d?\d?)/i)) {
86 $doiota = "\\b$a\[\-\ \]\?$b\\b";
89 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[-\s]?\d?\d\d)\b' unless $doiota;
90 push @flist, 'info', "{$doiota}";
91 dbg("sh/dx iota info {$doiota}") if isdbg('sh/dx');
95 my $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/i;
96 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
97 push @flist, 'info', "{$doqra}";
98 dbg("sh/dx qra info {$doqra}") if isdbg('sh/dx');
101 if (grep {lc $f eq $_} qw { ( or and not ) }) {
103 dbg("sh/dx operator $f") if isdbg('sh/dx');
106 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) ) {
108 push @flist, shift @list if @list;
109 dbg("sh/dx function $flist[-2] $flist[-1]") if isdbg('sh/dx');
121 # someone (probably me) has forgotten the 'info' keyword
122 if ($pre =~ /^{.*}$/) {
123 push @flist, 'info', $pre;
125 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
126 $pre = shellregex($pre);
132 $pre .= '$' if $exact;
134 push @flist, 'call', $pre;
138 my $newline = join(' ', @flist);
139 dbg("sh/dx newline: $newline") if isdbg('sh/dx');
140 my ($r, $filter, $fno, $user, $expr) = $Spot::filterdef->parse($self, 'spots', $newline, 1);
142 return (0, "sh/dx parse error '$r' " . $filter) if $r;
145 dbg "sh/dx user: $user expr: $expr from: $from to: $to fromday: $fromday today: $today" if isdbg('sh/dx');
149 if ($self->{_nospawn}) {
150 my @res = Spot::search($expr, $fromday, $today, $from, $to, $user, $dofilter ? $self : undef);
153 foreach $ref (@res) {
154 if ($self && $self->ve7cc) {
155 push @out, VE7CC::dx_spot($self, @$ref);
158 if ($self && $real) {
159 push @out, DXCommandmode::format_dx_spot($self, @$ref);
162 push @out, Spot::formatl(@$ref);
168 push @out, $self->spawn_cmd("sh/dx $line", \&Spot::search,
169 args => [$expr, $fromday, $today, $from, $to, $filter, $dofilter ? $self : undef],
171 my ($dxchan, @res) = @_;
175 foreach $ref (@res) {
177 push @out, VE7CC::dx_spot($self, @$ref);
181 push @out, DXCommandmode::format_dx_spot($self, @$ref);
184 push @out, Spot::formatl(@$ref);
188 push @out, $self->msg('e3', "sh/dx", "'$line'") unless @out;