added a forward/latlong command
authorminima <minima>
Sat, 29 Jul 2000 16:01:28 +0000 (16:01 +0000)
committerminima <minima>
Sat, 29 Jul 2000 16:01:28 +0000 (16:01 +0000)
Changes
cmd/forward/latlong.pl [new file with mode: 0644]
cmd/show/node.pl
perl/DXUser.pm

diff --git a/Changes b/Changes
index 96457c081130f43625db75faaa658aa6e1c57a73..03561b0c2ca83092e7b399412a09bdeeda7204c0 100644 (file)
--- 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 (file)
index 0000000..15712f0
--- /dev/null
@@ -0,0 +1,49 @@
+#
+# merge_qra <node>
+#
+# 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");
index 37db1dc8d1e21f77a4773af97f575c1fbd58a484..c18d8fb9376dc8d71e18c48ac68243dfd5dcd8a0 100644 (file)
@@ -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" : "      ");
index ad1b890cb7e7bbf34cabb150a3dffcd2fa51fc5a..49745722ffd29ae51badd4e665a9f192853a8d00 100644 (file)
@@ -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;
 }