From b85ee0ca2b03ee2c5be20bd430cfa00757b7ebdb Mon Sep 17 00:00:00 2001 From: minima Date: Sat, 4 Nov 2000 00:08:08 +0000 Subject: [PATCH] fixed sh/filter --- Changes | 3 +++ cmd/show/filter.pl | 33 +++++++++++++++++++-------------- perl/DXUtil.pm | 9 --------- perl/Filter.pm | 18 ++++++++++++++---- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/Changes b/Changes index 12b4ea09..3de9f881 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +04Nov00======================================================================= +1. fix sh/filter so ity now works for any callsign (and not just connected +ones). 03Nov00======================================================================= 1. allow - in filter strings 2. store only the filter expression NOTE BENE: you will need to clear all diff --git a/cmd/show/filter.pl b/cmd/show/filter.pl index 3b01712a..7fd7923a 100644 --- a/cmd/show/filter.pl +++ b/cmd/show/filter.pl @@ -8,24 +8,29 @@ my ($self, $line) = @_; my @f = split /\s+/, $line; my @out; -my $dxchan = $self; -my $sort = ''; +my $call = $self->call; -my $f = lc shift @f if @f; -if ($self->priv >= 8) { - my $d = DXChannel->get(uc $f); - $dxchan = $d if $d; - $f = lc shift @f; +if (@f && $self->priv >= 8) { + if (is_callsign(uc $f[0])) { + $call = uc shift @f; + } elsif ($f[0] eq 'node_default' || $f[0] eq 'user_default') { + $call = shift @f; + } } -$sort = $f if $f; -$sort .= 'filter'; +my @in; +if (@f) { + push @in, @f; +} else { + push @in, qw(ann spots wcy wwv); +} my $key; -foreach $key (sort keys %$self) { - if ($key =~ /$sort$/) { - push @out, $self->{$key}->print if $self->{$key}; - } +foreach $key (@in) { + my $ref = Filter::read_in($key, $call, 1); + push @out, $ref->print($call, $key, "input") if $ref; + $ref = Filter::read_in($key, $call, 0); + push @out, $ref->print($call, $key, "") if $ref; } -push @out, $self->msg('filter3', $dxchan->call) unless @out; +push @out, $self->msg('filter3', $call) unless @out; return (1, @out); diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index db1c4c7d..b1d2b629 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -210,15 +210,6 @@ sub shellregex return '^' . $in . "\$"; } -# start an attempt at determining whether this string might be a callsign -sub iscallsign -{ - my $call = uc shift; - return 1 if $call =~ /^[A-Z]+\d+[A-Z]+/; - return 1 if $call =~ /^\d+[A-Z]\d+[A-Z]+/; - return undef; -} - # read in a file into a string and return it. # the filename can be split into a dir and file and the # file can be in upper or lower case. diff --git a/perl/Filter.pm b/perl/Filter.pm index 6359b319..8acce7f3 100644 --- a/perl/Filter.pm +++ b/perl/Filter.pm @@ -254,19 +254,21 @@ sub write sub print { my $self = shift; + my $name = shift || $self->{name}; + my $sort = shift || $self->{sort}; + my $flag = shift || ""; my @out; - my $name = $self->{name}; $name =~ s/.pl$//; - push @out, join(' ', $name , ':', $self->{sort}); + push @out, join(' ', $name , ':', $sort, $flag); my $filter; my $key; foreach $key (sort $self->getfilkeys) { my $filter = $self->{$key}; - if ($filter->{reject} && exists $filter->{reject}->{user}) { + if (exists $filter->{reject} && exists $filter->{reject}->{user}) { push @out, ' ' . join(' ', $key, 'reject', $filter->{reject}->{user}); } - if ($filter->{accept} && exists $filter->{accept}->{user}) { + if (exists $filter->{accept} && exists $filter->{accept}->{user}) { push @out, ' ' . join(' ', $key, 'accept', $filter->{accept}->{user}); } } @@ -588,6 +590,14 @@ sub it } } +sub print +{ + my $self = shift; + my $call = shift; + my $sort = shift; + my $flag = shift || ""; + return "$call: Old Style Filter $flag $sort"; +} 1; __END__ -- 2.43.0