From 1006337e105ab06a0e468bc483332fd385dd5240 Mon Sep 17 00:00:00 2001 From: minima Date: Thu, 17 Oct 2002 02:43:02 +0000 Subject: [PATCH] remove traling spaces from non empty lines in command output --- Changes | 1 + cmd/set/sendpc16.pl | 28 ++++++++++++++++++++++++++++ cmd/set/wantpc16.pl | 28 ++++++++++++++++++++++++++++ cmd/unset/sendpc16.pl | 28 ++++++++++++++++++++++++++++ cmd/unset/wantpc16.pl | 28 ++++++++++++++++++++++++++++ perl/DXCommandmode.pm | 2 +- perl/DXProt.pm | 32 ++++++++++++++++++++++++-------- perl/DXUser.pm | 12 ++++++------ perl/Messages | 4 ++++ 9 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 cmd/set/sendpc16.pl create mode 100644 cmd/set/wantpc16.pl create mode 100644 cmd/unset/sendpc16.pl create mode 100644 cmd/unset/wantpc16.pl diff --git a/Changes b/Changes index 873cbd63..be2ae10a 100644 --- 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 index 00000000..342e99e7 --- /dev/null +++ b/cmd/set/sendpc16.pl @@ -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 index 00000000..de0a0ddd --- /dev/null +++ b/cmd/set/wantpc16.pl @@ -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 index 00000000..0531905f --- /dev/null +++ b/cmd/unset/sendpc16.pl @@ -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 index 00000000..c8536a96 --- /dev/null +++ b/cmd/unset/wantpc16.pl @@ -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); diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 60c7f108..42b2efbb 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -470,7 +470,7 @@ sub run_cmd return (); } } - return (@ans); + return map {s/[^\s]\s+$//; $_} @ans; } # diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 8437ff78..f0fe0c6e 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -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, @_); } diff --git a/perl/DXUser.pm b/perl/DXUser.pm index f31b79e6..2c562ac7 100644 --- a/perl/DXUser.pm +++ b/perl/DXUser.pm @@ -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 diff --git a/perl/Messages b/perl/Messages index bfe83a26..c32cd934 100644 --- a/perl/Messages +++ b/perl/Messages @@ -285,6 +285,10 @@ package DXM; unsethop1 => 'usage: unset/hops 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]', -- 2.34.1