]> dxcluster.org Git - spider.git/commitdiff
remove traling spaces from non empty lines in command output
authorminima <minima>
Thu, 17 Oct 2002 02:43:02 +0000 (02:43 +0000)
committerminima <minima>
Thu, 17 Oct 2002 02:43:02 +0000 (02:43 +0000)
Changes
cmd/set/sendpc16.pl [new file with mode: 0644]
cmd/set/wantpc16.pl [new file with mode: 0644]
cmd/unset/sendpc16.pl [new file with mode: 0644]
cmd/unset/wantpc16.pl [new file with mode: 0644]
perl/DXCommandmode.pm
perl/DXProt.pm
perl/DXUser.pm
perl/Messages

diff --git a/Changes b/Changes
index 873cbd63a799bc3c2d503563657145be334f8d65..be2ae10a12b0821f745fc9a79fb09f107029062e 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@
 1. decrease the default max length of PC16/19 to around 180 characters to be
 slightly friendlier to ARC, which seems to have a difficulty reconstructing
 lines from multiple packets. Also make the value settable via set/var.
+2. strip off blank spaces from the ends of lines of  command output.
 15Oct02=======================================================================
 1. made some detail changes to the raw USDB data and the routines that 
 generate and operate on them. There were some bugs involving a few 'missing'
diff --git a/cmd/set/sendpc16.pl b/cmd/set/sendpc16.pl
new file mode 100644 (file)
index 0000000..342e99e
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# set the send PC16 flag
+#
+# Copyright (c) 2002 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my @args = split /\s+/, uc $line;
+my $call;
+my @out;
+
+return (1, $self->msg('e5')) if $self->priv < 9;
+
+foreach $call (@args) {
+       return (1, $self->msg('e12')) unless is_callsign($call);
+
+       my $user = DXUser->get_current($call);
+       if ($user) {
+               $user->wantsendpc16(1);
+               $user->put;
+               push @out, $self->msg('wspc16s', $call);
+       } else {
+               push @out, $self->msg('e3', "set/sendpc16", $call);
+       }
+}
+return (1, @out);
diff --git a/cmd/set/wantpc16.pl b/cmd/set/wantpc16.pl
new file mode 100644 (file)
index 0000000..de0a0dd
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# set the want PC16 flag
+#
+# Copyright (c) 2002 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my @args = split /\s+/, uc $line;
+my $call;
+my @out;
+
+return (1, $self->msg('e5')) if $self->priv < 9;
+
+foreach $call (@args) {
+       return (1, $self->msg('e12')) unless is_callsign($call);
+
+       my $user = DXUser->get_current($call);
+       if ($user) {
+               $user->wantpc16(1);
+               $user->put;
+               push @out, $self->msg('wpc16s', $call);
+       } else {
+               push @out, $self->msg('e3', "set/wantpc16", $call);
+       }
+}
+return (1, @out);
diff --git a/cmd/unset/sendpc16.pl b/cmd/unset/sendpc16.pl
new file mode 100644 (file)
index 0000000..0531905
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# unset the send PC16 flag
+#
+# Copyright (c) 2002 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my @args = split /\s+/, uc $line;
+my $call;
+my @out;
+
+return (1, $self->msg('e5')) if $self->priv < 9;
+
+foreach $call (@args) {
+       return (1, $self->msg('e12')) unless is_callsign($call);
+
+       my $user = DXUser->get_current($call);
+       if ($user) {
+               $user->wantsendpc16(0);
+               $user->put;
+               push @out, $self->msg('wspc16u', $call);
+       } else {
+               push @out, $self->msg('e3', "unset/sendpc16", $call);
+       }
+}
+return (1, @out);
diff --git a/cmd/unset/wantpc16.pl b/cmd/unset/wantpc16.pl
new file mode 100644 (file)
index 0000000..c8536a9
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# unset the want PC16 flag
+#
+# Copyright (c) 2002 - Dirk Koopman
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my @args = split /\s+/, uc $line;
+my $call;
+my @out;
+
+return (1, $self->msg('e5')) if $self->priv < 9;
+
+foreach $call (@args) {
+       return (1, $self->msg('e12')) unless is_callsign($call);
+
+       my $user = DXUser->get_current($call);
+       if ($user) {
+               $user->wantpc16(0);
+               $user->put;
+               push @out, $self->msg('wpc16u', $call);
+       } else {
+               push @out, $self->msg('e3', "unset/wantpc16", $call);
+       }
+}
+return (1, @out);
index 60c7f1086d228ccc03c68f5364fe9ee71134803d..42b2efbb8ca93ea2234a32618a3afefd2d8e4343 100644 (file)
@@ -470,7 +470,7 @@ sub run_cmd
                        return ();
                }
        }
-       return (@ans);
+       return map {s/[^\s]\s+$//; $_} @ans;
 }
 
 #
index 8437ff78ee313ae95816e49f0af0333b4f15c66f..f0fe0c6e71b8a82e0813637969d70020997fec00 100644 (file)
@@ -625,6 +625,12 @@ sub normal
                        my $ncall = $field[1];
                        my $newline = "PC16^";
                        
+                       # do I want users from this channel?
+                       unless ($self->user->wantpc16) {
+                               dbg("PCPROT: don't send users to $self->{call}") if isdbg('chanerr');
+                               return;
+                       }
+                       # is it me?
                        if ($ncall eq $main::mycall) {
                                dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
                                return;
@@ -699,6 +705,11 @@ sub normal
 
                        eph_del_regex("^PC16\\^$ncall.*$ucall");
                        
+                       # do I want users from this channel?
+                       unless ($self->user->wantpc16) {
+                               dbg("PCPROT: don't send users to $self->{call}") if isdbg('chanerr');
+                               return;
+                       }
                        if ($ncall eq $main::mycall) {
                                dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
                                return;
@@ -1562,7 +1573,7 @@ sub announce
 sub send_local_config
 {
        my $self = shift;
-       my $n;
+       my $node;
        my @nodes;
        my @localnodes;
        my @remotenodes;
@@ -1581,19 +1592,21 @@ sub send_local_config
                my @intcalls = map { $_->nodes } @localnodes if @localnodes;
                my $ref = Route::Node::get($self->{call});
                my @rnodes = $ref->nodes;
-               for my $n (@intcalls) {
-                       push @remotenodes, Route::Node::get($n) unless grep $n eq $_, @rnodes;
+               for my $node (@intcalls) {
+                       push @remotenodes, Route::Node::get($node) unless grep $node eq $_, @rnodes;
                }
                unshift @localnodes, $main::routeroot;
        }
        
 
-       send_route($self, \&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
+       $self->send_route(\&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
        
        # get all the users connected on the above nodes and send them out
-       foreach $n (@localnodes, @remotenodes) {
-               if ($n) {
-                       send_route($self, \&pc16, 1, $n, map {my $r = Route::User::get($_); $r ? ($r) : ()} $n->users);
+       foreach $node (@localnodes, @remotenodes) {
+               if ($node) {
+                       $self->send_route(\&pc16, 1, $node, 
+                                                         map {my $r = Route::User::get($_); $r ? ($r) : ()} $node->users)
+                               if $self->user->wantsendpc16;
                } else {
                        dbg("sent a null value") if isdbg('chanerr');
                }
@@ -1918,7 +1931,8 @@ sub broadcast_route
                        next if $dxchan == $self;
                        next if $dxchan == $main::me;
                        next if $dxchan->user->wantnp;
-                       
+                       next if ($generate == \&pc16 || $generate==\&pc17) && !$dxchan->user->wantsendpc16;
                        $dxchan->send_route($generate, @_);
                }
        }
@@ -1927,12 +1941,14 @@ sub broadcast_route
 sub route_pc16
 {
        my $self = shift;
+       return unless $self->user->wantpc16;
        broadcast_route($self, \&pc16, 1, @_);
 }
 
 sub route_pc17
 {
        my $self = shift;
+       return unless $self->user->wantpc16;
        broadcast_route($self, \&pc17, 1, @_);
 }
 
index f31b79e6da0ee167b0bd83e9de92d73ccbad73ea..2c562ac70ed538d12373150fd08b2e15944a1b4f 100644 (file)
@@ -78,8 +78,8 @@ $lrusize = 2000;
                  wantann_talk => '0,Talklike Anns,yesno',
                  wantpc90 => '1,Req PC90,yesno',
                  wantnp => '1,Req New Protocol,yesno',
-                 wantusers => '9,Want Users from node,yesno',
-                 wantsendusers => '9,Send users to node,yesno',
+                 wantpc16 => '9,Want Users from node,yesno',
+                 wantsendpc16 => '9,Send users to node,yesno',
                  lastoper => '9,Last for/oper,cldatetime',
                  nothere => '0,Not Here Text',
                  registered => '9,Registered?,yesno',
@@ -585,14 +585,14 @@ sub wantann_talk
        return _want('ann_talk', @_);
 }
 
-sub wantusers
+sub wantpc16
 {
-       return _want('users', @_);
+       return _want('pc16', @_);
 }
 
-sub wantsendusers
+sub wantsendpc16
 {
-       return _want('annsendusers', @_);
+       return _want('sendpc16', @_);
 }
 
 sub wantlogininfo
index bfe83a2648c9e23ac8c68805505295e794b01a2e..c32cd934e353fba9684e60e2a54b3d961fc6a481 100644 (file)
@@ -285,6 +285,10 @@ package DXM;
                                unsethop1 => 'usage: unset/hops <call> ann|spots|wwv|wcy',
                                unsethop2 => 'hops unset on $_[1] for $_[0]', 
                                usernf => '*** User record for $_[0] not found ***',
+                wpc16s => 'Want PC16 enabled for $_[0]',
+                               wpc16u => 'Want PC16 disabled for $_[0]',
+                wspc16s => 'Send PC16 enabled for $_[0]',
+                               wspc16u => 'Send PC16 disabled for $_[0]',
                                wcy1 => '$_[0] is missing or out of range',
                                wcy2 => 'Duplicate WCY',
                 wcys => 'WCY enabled for $_[0]',