From ebbe325acb6e18437ae01cb1b32e615c83e24641 Mon Sep 17 00:00:00 2001 From: minima Date: Sat, 4 Nov 2000 01:04:41 +0000 Subject: [PATCH] added set/hops and show/hops commands --- Changes | 1 + cmd/Commands_en.hlp | 18 ++++++++++++++++++ cmd/set/hops.pl | 35 +++++++++++++++++++++++++++++++++++ cmd/show/filter.pl | 12 ++++++------ cmd/show/hops.pl | 35 +++++++++++++++++++++++++++++++++++ perl/Filter.pm | 18 ++++-------------- perl/Messages | 4 ++++ 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 cmd/set/hops.pl create mode 100644 cmd/show/hops.pl diff --git a/Changes b/Changes index 81382122..d559575c 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ 1. fix sh/filter so ity now works for any callsign (and not just connected ones). 2. Have only one is_callsign and not an iscallsign as well. +3. Add set/hops and show/hops commands. 03Nov00======================================================================= 1. allow - in filter strings 2. store only the filter expression NOTE BENE: you will need to clear all diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 158990c3..92389a36 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -840,6 +840,19 @@ to you will normally find their way there should you not be connected. eg:- SET/HOMENODE gb7djk +=== 8^SET/HOPS ann|spots|wwv|wcy ^Set hop count +Set the hop count for a particular type of broadcast for a node. + +This command allows you to set up special hop counts for a node +for currently: announce, spots, wwv and wcy broadcasts. + +eg: + set/hops gb7djk ann 10 + set/hops gb7mbc spots 20 + +Set SHOW/HOPS for information on what is already set. This command +creates a filter and works in conjunction with the filter system. + === 9^SET/ISOLATE^Isolate a node from the rest of the network Connect a node to your system in such a way that you are a full protocol member of its network and can see all spots on it, but nothing either leaks @@ -1047,6 +1060,11 @@ See also TYPE - to see the contents of a file. Show the contents of all the filters that are set. This command displays all the filters set - for all the various categories. +=== 8^SHOW/HOPS [ann|spots|wcy|wwv]^Show the hop counts for a node +This command shows the hop counts set up for a node. You can specify +which category you want to see. If you leave the category out then +all the categories will be listed. + === 1^SHOW/ISOLATE^Show list of ISOLATED nodes === 9^SHOW/LOCKOUT^Show the list of locked out or excluded callsigns diff --git a/cmd/set/hops.pl b/cmd/set/hops.pl new file mode 100644 index 00000000..5f4edbdb --- /dev/null +++ b/cmd/set/hops.pl @@ -0,0 +1,35 @@ +# +# set/hops commands +# +# Copyright (c) 2000 Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +return (0, $self->msg('e5')) if $self->priv < 8; + +my @f = split /\s+/, $line; +my @out; +my $call; + +if (is_callsign(uc $f[0])) { + $call = uc shift @f; +} elsif ($f[0] eq 'node_default' || $f[0] eq 'user_default') { + $call = shift @f; +} + +my $sort = lc shift @f if $f[0] =~ /^ann|spots|wwv|wcy$/i; +my $hops = shift @f if $f[0] =~ /^\d+$/; + +return (0, $self->msg('sethop1')) unless $call && $sort && $hops; + +my $ref = Filter::read_in($sort, $call, 0); +$ref = Filter->new($sort, $call, 0) if !$ref || $ref->isa('Filter::Old'); +return (0, $self->msg('filter5', '', $sort, $call)) unless $ref; + +delete $ref->{hops}; +$ref->{hops} = $hops if $hops; +$ref->write; +$ref->install; + +return (0, $self->msg('sethop2', $hops, '', $sort, $call)); diff --git a/cmd/show/filter.pl b/cmd/show/filter.pl index 7fd7923a..345603b8 100644 --- a/cmd/show/filter.pl +++ b/cmd/show/filter.pl @@ -25,12 +25,12 @@ if (@f) { push @in, qw(ann spots wcy wwv); } -my $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; +my $sort; +foreach $sort (@in) { + my $ref = Filter::read_in($sort, $call, 1); + push @out, $ref->print($call, $sort, "input") if $ref; + $ref = Filter::read_in($sort, $call, 0); + push @out, $ref->print($call, $sort, "") if $ref; } push @out, $self->msg('filter3', $call) unless @out; return (1, @out); diff --git a/cmd/show/hops.pl b/cmd/show/hops.pl new file mode 100644 index 00000000..448d93dc --- /dev/null +++ b/cmd/show/hops.pl @@ -0,0 +1,35 @@ +# +# show hops commands +# +# Copyright (c) 2000 Dirk Koopman G1TLH +# +# $Id$ +# +my ($self, $line) = @_; +my @f = split /\s+/, $line; +my @out; +my $call = $self->call; + +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; + } +} + +my @in; +if (@f) { + push @in, @f; +} else { + push @in, qw(ann spots wcy wwv); +} + +my $sort; +foreach $sort (@in) { + my $ref = Filter::read_in($sort, $call, 0); + my $hops = $ref ? $ref->{hops} : undef; + push @out, $self->msg('sethop2', $hops, '', $sort, $call) if $hops; +} +push @out, $self->msg('sethop3', $call) unless @out; +return (1, @out); diff --git a/perl/Filter.pm b/perl/Filter.pm index 8acce7f3..59ace8af 100644 --- a/perl/Filter.pm +++ b/perl/Filter.pm @@ -184,8 +184,6 @@ sub it { my $self = shift; - my $hops = undef; - my $filter; my @keys = sort $self->getfilkeys; my $key; @@ -210,17 +208,9 @@ sub it } } - # hops are done differently - if ($self->{hops}) { - my ($comp, $ref); - while (($comp, $ref) = each %{$self->{hops}}) { - my ($field, $h) = @$ref; - if ($_[$field] =~ m{$comp}) { - $hops = $h; - last; - } - } - } + # hops are done differently (simply) + my $hops = $self->{hops} if exists $self->{hops}; + return ($r, $hops); } @@ -369,7 +359,7 @@ sub parse } $filter = Filter::read_in($sort, $call, $flag); - $filter = Filter->new($sort, $call, $flag) unless $filter; + $filter = Filter->new($sort, $call, $flag) if !$filter || $filter->isa('Filter::Old'); $ntoken++; next; diff --git a/perl/Messages b/perl/Messages index 09c6b4eb..0840c93f 100644 --- a/perl/Messages +++ b/perl/Messages @@ -81,6 +81,7 @@ package DXM; filter3 => 'No filters defined for $_[0]', filter4 => '$_[0]$_[1] Filter $_[2] deleted for $_[3]', filter5 => 'need some filter commands...', + filter6 => '$_[0]$_[1] Filter for $[2] not found', grids => 'DX Grid flag set on $_[0]', gridu => 'DX Grid flag unset on $_[0]', helpe1 => 'Help system unavailable, tell sysop', @@ -184,6 +185,9 @@ package DXM; sat4 => 'Satellites available:-', satnf => 'Satellite $_[0] unknown', satdisc => '-----', + sethop1 => 'usage: set/hops ann|spots|wwv|wcy ', + sethop2 => '$_[0] hops set on $_[1]$_[2] for $_[3]', + sethop3 => 'No hops set for $_[0]', shutting => '$main::mycall shutting down...', sloc => 'Cluster lat $_[0] long $_[1], DON\'T FORGET TO CHANGE YOUR DXVars.pm', snode1 => 'Node Call Sort Version', -- 2.34.1