remove 'recursion limit' message fromRoute.pm
[spider.git] / perl / RouteDB.pm
index 9a63d368f121cc5b896136cf56f96d587caf87a2..8059b08d5f92ee9ecf194ec87ef5172947af8fd4 100644 (file)
 #
 # Copyright (c) 2004 Dirk Koopman G1TLH
 #
-# $Id$
+#
 # 
 
 package RouteDB;
 
 use DXDebug;
 use DXChannel;
+use DXUtil;
 use Prefix;
 
 use strict;
 
-use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
-
 use vars qw(%list %valid $default);
 
+
 %list = ();
 $default = 99;                                 # the number of hops to use if we don't know
 %valid = (
                  call => "0,Callsign",
-                 items => "0,Interfaces,parray",
+                 item => "0,Interfaces,parray",
                  t => '0,Last Seen,atime',
                  hops => '0,Hops',
                  count => '0,Times Seen',
@@ -46,7 +42,7 @@ sub new
 {
        my $pkg = shift;
        my $call = shift;
-       return bless {call => $call, items => {}}, (ref $pkg || $pkg);
+       return bless {call => $call, list => {}}, (ref $pkg || $pkg);
 }
 
 # get the best one
@@ -76,7 +72,7 @@ sub _sorted
                } else {
                        $a->{hops} <=> $b->{hops};
                } 
-       } values %{$ref->{items}};
+       } values %{$ref->{item}};
 }
 
 
@@ -90,11 +86,12 @@ sub update
        my $interface = shift;
        my $hops = shift || $default;
        my $ref = $list{$call} || RouteDB->new($call);
-       my $iref = $ref->{list}->{$interface} ||= RouteDB::Item->new($call, $interface);
+       my $iref = $ref->{item}->{$interface} ||= RouteDB::Item->new($interface, $hops);
        $iref->{count}++;
        $iref->{hops} = $hops if $hops < $iref->{hops};
        $iref->{t} = shift || $main::systime;
-       $ref->{list}->{$interface} ||= $iref;
+       $ref->{item}->{$interface} ||= $iref;
+       $list{$call} ||= $ref;
 }
 
 sub delete
@@ -102,7 +99,15 @@ sub delete
        my $call = shift;
        my $interface = shift;
        my $ref = $list{$call};
-       delete $ref->{list}->{$interface} if $ref;
+       delete $ref->{item}->{$interface} if $ref;
+}
+
+sub delete_interface
+{
+       my $interface = shift;
+       foreach my $ref (values %list) {
+               delete $ref->{item}->{$interface};
+       }
 }
 
 #
@@ -133,7 +138,8 @@ sub new
 {
        my $pkg = shift;
        my $call = shift;
-       return bless {call => $call, hops => $RouteDB::default}, (ref $pkg || $pkg);
+       my $hops = shift || $RouteDB::default;
+       return bless {call => $call, hops => $hops}, (ref $pkg || $pkg);
 }
 
 1;