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');
47 if ($f && !$from && !$to) {
48 ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$| || (0,0); # 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?
55 dbg("sh/dx to: $to") if isdbg('sh/dx');
58 if (lc $f eq 'day' && $list[0]) {
59 ($fromday, $today) = split m|[-/]|, shift(@list);
60 dbg "sh/dx got day $fromday/$today" if isdbg('sh/dx');
63 if (lc $f eq 'exact') {
64 dbg("sh/dx exact") if isdbg('sh/dx');
68 if (lc $f eq 'rt' || $f =~ /^real/i) {
69 dbg("sh/dx real") if isdbg('sh/dx');
73 if (lc $f =~ /^filt/) {
74 dbg("sh/dx run spotfilter") if isdbg('sh/dx');
75 $dofilter = 1 if $self && $self->spotsfilter;
79 dbg("sh/dx qsl") if isdbg('sh/dx');
80 push @flist, "info {QSL|VIA}";
83 if (lc $f eq '<es>') {
84 dbg("sh/dx <es>") if isdbg('sh/dx');
85 push @flist, "info {<ES>}";
88 if (lc $f eq '<tr>') {
89 dbg("sh/dx <es>") if isdbg('sh/dx');
90 push @flist, "info {<TR>}";
93 if (lc $f eq '<ms>') {
94 dbg("sh/dx <ms>") if isdbg('sh/dx');
95 push @flist, "info {<ms>}";
99 if (lc $f eq 'iota') {
101 if (@list && $list[0] && (($a, $b) = $list[0] =~ /(AF|AN|NA|SA|EU|AS|OC)[-\s]?(\d\d?\d?)/i)) {
103 $doiota = "\\b$a\[\-\ \]\?$b\\b";
106 $doiota = '\b(IOTA|(AF|AN|NA|SA|EU|AS|OC)[-\s]?\d?\d\d)\b' unless $doiota;
107 push @flist, 'info', "{$doiota}";
108 dbg("sh/dx iota info {$doiota}") if isdbg('sh/dx');
111 if (lc $f eq 'qra') {
112 my $doqra = uc shift @list if @list && $list[0] =~ /[A-Z][A-Z]\d\d/i;
113 $doqra = '\b([A-Z][A-Z]\d\d|[A-Z][A-Z]\d\d[A-Z][A-Z])\b' unless $doqra;
114 push @flist, 'info', "{$doqra}";
115 dbg("sh/dx qra info {$doqra}") if isdbg('sh/dx');
118 if (grep {lc $f eq $_} qw { ( or and not ) }) {
120 dbg("sh/dx operator $f") if isdbg('sh/dx');
123 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) ) {
125 push @flist, shift @list if @list;
126 dbg("sh/dx function $flist[-2] $flist[-1]") if isdbg('sh/dx');
138 # someone (probably me) has forgotten the 'info' keyword
139 if ($pre =~ /^{.*}$/) {
140 push @flist, 'info', $pre;
142 $pre .= '*' unless $pre =~ /[\*\?\[]$/o;
143 $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;
162 dbg "sh/dx user: $user expr: $expr from: $from to: $to fromday: $fromday today: $today" if isdbg('sh/dx');
166 if ($self->{_nospawn}) {
167 my @res = Spot::search($expr, $fromday, $today, $from, $to, $user, $dofilter ? $self : undef);
170 foreach $ref (@res) {
171 if ($self && $self->ve7cc) {
172 push @out, VE7CC::dx_spot($self, @$ref);
175 if ($self && $real) {
176 push @out, DXCommandmode::format_dx_spot($self, @$ref);
179 push @out, Spot::formatl(@$ref);
185 push @out, $self->spawn_cmd("sh/dx $line", \&Spot::search,
186 args => [$expr, $fromday, $today, $from, $to, $filter, $dofilter ? $self : undef],
188 my ($dxchan, @res) = @_;
192 foreach $ref (@res) {
194 push @out, VE7CC::dx_spot($self, @$ref);
198 push @out, DXCommandmode::format_dx_spot($self, @$ref);
201 push @out, Spot::formatl(@$ref);
205 push @out, $self->msg('e3', "sh/dx", "'$line'") unless @out;