added set/hops and show/hops commands
authorminima <minima>
Sat, 4 Nov 2000 01:04:41 +0000 (01:04 +0000)
committerminima <minima>
Sat, 4 Nov 2000 01:04:41 +0000 (01:04 +0000)
Changes
cmd/Commands_en.hlp
cmd/set/hops.pl [new file with mode: 0644]
cmd/show/filter.pl
cmd/show/hops.pl [new file with mode: 0644]
perl/Filter.pm
perl/Messages

diff --git a/Changes b/Changes
index 81382122264760a88ef92ad3e18d9ad1ce95df07..d559575ca0e42031f92ed87fee2a8e0eb969895e 100644 (file)
--- 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 
index 158990c36b5cef02928adbe38b2fb5f6f1da9fd7..92389a364459afa8f92d6b7eb709ccfd44cdc173 100644 (file)
@@ -840,6 +840,19 @@ to you will normally find their way there should you not be connected.
 eg:-
   SET/HOMENODE gb7djk
 
+=== 8^SET/HOPS <call> ann|spots|wwv|wcy <n>^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 <call> [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 (file)
index 0000000..5f4edbd
--- /dev/null
@@ -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));
index 7fd7923a5093b23f96d87f42e2c795671704de22..345603b847456060293214f153246e4ad3f02b45 100644 (file)
@@ -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 (file)
index 0000000..448d93d
--- /dev/null
@@ -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);
index 8acce7f383bdca5b235433509f94e1e4e98fcc7f..59ace8af8edb2986827d2258760644eac290ee02 100644 (file)
@@ -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;
index 09c6b4eb654613b86c315b324fc07114f9e2675d..0840c93f5822328830441e329151d7de9c7180a2 100644 (file)
@@ -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 <call> ann|spots|wwv|wcy <no of hops>',
+                               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',