From: minima Date: Sat, 29 Jul 2000 16:01:28 +0000 (+0000) Subject: added a forward/latlong command X-Git-Tag: R_1_43~21 X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=91cb091ed723c5650202345ae9c4f0277e36f0a8;p=spider.git added a forward/latlong command --- diff --git a/Changes b/Changes index 96457c08..03561b0c 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +29Jul00======================================================================= +1. added forward/latlong which will forward ALL the users that have a latitude +and longitude set on them to one or more locally connected nodes - with a hop +count of 1. 28Jul00======================================================================= 1. fixed watchdbg midnight rollover loop and removed the date part of the date/time translation to leave just the time. diff --git a/cmd/forward/latlong.pl b/cmd/forward/latlong.pl new file mode 100644 index 00000000..15712f00 --- /dev/null +++ b/cmd/forward/latlong.pl @@ -0,0 +1,49 @@ +# +# merge_qra +# +# send out PC41s toward a node for every user that has a lat/long +# +# Copyright (c) 2000 Dirk Koopman G1TLH +# +# $Id$ +# + +my ($self, $line) = @_; +return (1, $self->msg('e5')) unless $self->priv >= 6; + +my @dxchan; +my @out; +my $dxchan; + +for ( map {uc $_ } split /\s+/, $line ) { + if (($dxchan = DXChannel->get($_)) && $dxchan->is_node) { + push @dxchan, $dxchan; + } else { + push @out, $self->msg('e10', $_); + } +} +return (1, @out) if @out; + +use DB_File; + +my ($action, $count, $key, $data); +for ($action = R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = R_NEXT) { + if ($data =~ m{(?:lat|long) =>}) { + my $u = DXUser->get_current($key); + if ($u) { + my $lat = $u->lat; + my $long = $u->long; + my $latlong = DXBearing::lltos($lat, $long) if $lat && $long; + if ($latlong) { + #push @out, $key; + for (@dxchan) { + my $s = DXProt::pc41($key, 3, $latlong); + $s =~ s{H\d+\^~$}{H1^~}; + $dxchan->send($s); + } + ++$count; + } + } + } +} +return(1, @out, "$count records sent"); diff --git a/cmd/show/node.pl b/cmd/show/node.pl index 37db1dc8..c18d8fb9 100644 --- a/cmd/show/node.pl +++ b/cmd/show/node.pl @@ -22,7 +22,17 @@ my @out; # search thru the user for nodes unless (@call) { - @call = sort map { my $ref; (($ref = DXUser->get_current($_)) && $ref->sort ne 'U') ? $_ : () } DXUser::get_all_calls; +# the official way +# @call = sort map { my $ref; (($ref = DXUser->get_current($_)) && $ref->sort ne 'U') ? $_ : () } DXUser::get_all_calls; + use DB_File; + + my ($action, $count, $key, $data); + for ($action = R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = R_NEXT) { + if ($data =~ m{sort => '[ACRSX]'}) { + push @call, $key; + } + ++$count; + } } my $call; @@ -34,6 +44,7 @@ foreach $call (@call) { my $pcall = sprintf "%-11s", $call; push @out, $self->msg('snode1') unless @out > 0; if ($uref) { + $sort = "Unknwn"; $sort = "Spider" if $uref->is_spider; $sort = "AK1A " if $uref->is_ak1a; $sort = "Clx " if $uref->is_clx; @@ -53,7 +64,7 @@ foreach $call (@call) { } my ($major, $minor, $subs) = unpack("AAA*", $ver) if $ver; - if ($sort eq 'Spider') { + if ($uref->is_spider) { push @out, $self->msg('snode2', $pcall, $sort, "$ver "); } else { push @out, $self->msg('snode2', $pcall, $sort, $ver ? "$major\-$minor.$subs" : " "); diff --git a/perl/DXUser.pm b/perl/DXUser.pm index ad1b890c..49745722 100644 --- a/perl/DXUser.pm +++ b/perl/DXUser.pm @@ -155,18 +155,11 @@ sub get { my $pkg = shift; my $call = uc shift; - # $call =~ s/-\d+$//o; # strip ssid - my $s = $u{$call}; - return $s ? decode($s) : undef; -} - -# -# get all callsigns in the database -# - -sub get_all_calls -{ - return (sort keys %u); + my $data; + unless ($dbm->get($call, $data)) { + return decode($data); + } + return undef; } # @@ -181,11 +174,23 @@ sub get_current { my $pkg = shift; my $call = uc shift; - # $call =~ s/-\d+$//o; # strip ssid my $dxchan = DXChannel->get($call); return $dxchan->user if $dxchan; - return get($pkg, $call); + my $data; + unless ($dbm->get($call, $data)) { + return decode($data); + } + return undef; +} + +# +# get all callsigns in the database +# + +sub get_all_calls +{ + return (sort keys %u); } # @@ -203,7 +208,7 @@ sub put } delete $self->{annok} if $self->{annok}; delete $self->{dxok} if $self->{dxok}; - $u{$call} = $self->encode(); + $dbm->put($call, $self->encode); } # @@ -226,10 +231,12 @@ sub decode { my $s = shift; my $ref; - $s = '$ref = ' . $s; - eval $s; - Log('DXUser', $@) if $@; - $ref = undef if $@; + eval '$ref = ' . $s; + if ($@) { + dbg('err', $@) if $@; + Log('err', $@) if $@; + $ref = undef; + } return $ref; }