From f21f292746ef4a2edc703e48542d1ed2d85d14cd Mon Sep 17 00:00:00 2001 From: minima Date: Wed, 1 Nov 2000 13:26:13 +0000 Subject: [PATCH] put field 2 check for PC11 back to 'm' --- Changes | 2 ++ perl/DXProt.pm | 2 +- perl/Filter.pm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ perl/Messages | 5 ++++ perl/Spot.pm | 45 ++++++++++++++++++++++++++++++++++- 5 files changed, 116 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 9b62c193..224afe82 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ +01Nov00======================================================================= +1. put PC11 field 2 check back to m for pc text. 31Oct00======================================================================= 1. add 0x8e to the list of characters we clobber (make xterm go into graphics mode). diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 6ee7e134..db342dfb 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -53,7 +53,7 @@ $baddxfn = "$main::data/baddx.pl"; @checklist = ( [ qw(c c m bp bc c) ], # pc10 - [ qw(f c d t m c c h) ], # pc11 + [ qw(f m d t m c c h) ], # pc11 [ qw(c bc m bp bm p h) ], # pc12 [ qw(c h) ], # [ qw(c h) ], # diff --git a/perl/Filter.pm b/perl/Filter.pm index 3d42fc34..060f7ea8 100644 --- a/perl/Filter.pm +++ b/perl/Filter.pm @@ -246,6 +246,70 @@ sub print return $self->{name}; } +package Filter::Cmd; + +use strict; +use vars qw(@ISA); +@ISA = qw(Filter); + +# the general purpose command processor +# this is called as a subroutine not as a method +sub process_cmd +{ + my ($self, $dxchan, $line) = @_; + my $ntoken = 0; + my $fno = 1; + my $filter; + my ($flag, $call); + + # check the line for non legal characters + return ('ill', $dxchan->msg('e19')) if $line =~ /[^\s\w,_\/]/; + + while (my @f = split /\s+/, $line) { + if ($ntoken == 0) { + + if (@f && $dxchan->priv >= 9 && DXUser->get($f[0])) { + $call = shift @f; + if ($f[0] eq 'input') { + shift @f; + $flag++; + } + } else { + $call = $dxchan->call; + } + + if (@f && $f[0] =~ /^\d+$/) { + $fno = shift @f; + } + + $filter = Filter::read_in('spots', $call, $flag) or new Filter ('spots', $call, $flag); + + $ntoken++; + next; + } + + # do the rest of the filter tokens + if (@f) { + my $tok = shift @f; + if (@f) { + my $val = shift @f; + + my $fref; + foreach $fref (@$self) { + if ($fref->[0] eq $tok) { + + } + } + } else { + return ('no', $dxchan->msg('filter2', $tok)); + } + } + + } + $flag = $flag ? "in_" : ""; + return (0, $dxchan->msg('filter1', $fno, "$flag$call")); +} + package Filter::Old; use strict; diff --git a/perl/Messages b/perl/Messages index 36168778..2b2ef763 100644 --- a/perl/Messages +++ b/perl/Messages @@ -37,6 +37,7 @@ package DXM; db9 => 'Database $_[0] removed', db10 => '$_[0] records imported into $_[1]', db11 => 'Sending your request(s) to $_[0], please stand by...', + dfreq1 => 'Invalid freq $_[0] need: eg 0/30000 or hf or hf/cw', dup => 'Sorry, this is a duplicate', dx1 => 'Frequency $_[0] not in band (see show/band); usage: DX [BY call] freq call comments', dx2 => 'Need a callsign; usage: DX [BY call] freq call comments', @@ -60,6 +61,8 @@ package DXM; e16 => 'File \"$_[0]\" exists', e17 => 'Please don\'t use the words: @_ on here', e18 => 'Cannot connect to $_[0] ($!)', + e19 => 'Invalid character in line', + e20 => 'token $_[0] not recognised', echoon => 'Echoing enabled', echooff => 'Echoing disabled', @@ -70,6 +73,8 @@ package DXM; export1 => 'usage: export ', export2 => '$_[3] has error exporting msg $_[0] to $_[1] ($_[2])', export3 => '$_[2 ] exported msg $_[0] to $_[1]', + filter1 => 'Filter $_[0] updated $_[1]', + filter2 => 'Need a value for $_[0]', grids => 'DX Grid flag set on $_[0]', gridu => 'DX Grid flag unset on $_[0]', helpe1 => 'Help system unavailable, tell sysop', diff --git a/perl/Spot.pm b/perl/Spot.pm index e2b5c7ef..c9178ddb 100644 --- a/perl/Spot.pm +++ b/perl/Spot.pm @@ -18,7 +18,7 @@ use Prefix; use DXDupe; use strict; -use vars qw($fp $maxspots $defaultspots $maxdays $dirprefix $duplth $dupage); +use vars qw($fp $maxspots $defaultspots $maxdays $dirprefix $duplth $dupage $filterdef); $fp = undef; $maxspots = 50; # maximum spots to return @@ -27,6 +27,49 @@ $maxdays = 35; # normal maximum no of days to go back $dirprefix = "spots"; $duplth = 20; # the length of text to use in the deduping $dupage = 3*3600; # the length of time to hold spot dups +$filterdef = bless ([ + # tag, sort, field, priv, special parser + ['freq', 'r', 0, 0, \&decodefreq], + ['call', 'c', 1], + ['info', 't', 3], + ['by', 'c', 4], + ['call_dxcc', 'n', 5], + ['by_dxcc', 'n', 6], + ['origin', 'c', 7, 9], + ['call_itu', 'n', 8], + ['call_zone', 'n', 9], + ['by_itu', 'n', 10], + ['by_zone', 'n', 11], + ['channel', 'n', 12, 9], + ], 'Filter::Cmd'); + + +sub decodefreq +{ + my $dxchan = shift; + my $l = shift; + my @f = split /,/, $l; + my @out; + my $f; + + foreach $f (@f) { + my ($a, $b) = $f =~ m{^(\d+)/(\d+)$}; + if ($a && $b) { + push @out, $a, $b; + } elsif (($a, $b) = $f =~ m{^(\w+)(?:/(\w+))?$}) { + $b = lc $b if $b; + my @fr = Bands::get_freq(lc $a, $b); + if (@fr) { + push @out, @fr; # add these to the list + } else { + return ('dfreq', $dxchan->msg('dfreq1', $f)); + } + } else { + return ('dfreq', $dxchan->msg('e20', $f)); + } + } + return (0, join(',', @out)); +} sub init { -- 2.43.0