]> dxcluster.org Git - spider.git/commitdiff
temporary commit for findroutes
authorDirk Koopman <djk@tobit.co.uk>
Sat, 23 Jun 2007 20:39:37 +0000 (21:39 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Sat, 23 Jun 2007 20:39:37 +0000 (21:39 +0100)
cmd/show/route.pl
perl/Route.pm

index d4120e0c484a5244774388a81ca3aba357e68c4f..6d1c194c2f65b27dfe0aa3ff558303f571b53992 100644 (file)
@@ -19,7 +19,7 @@ foreach $l (@list) {
        my $ref = Route::get($l);
        if ($ref) {
                my $parents = $ref->isa('Route::Node') ? $l : join(',', $ref->parents);
-               push @out, $self->msg('route', $l, $parents,  join(',', map {$_->call} $ref->alldxchan));
+               push @out, $self->msg('route', $l, $parents,  join(',', map {$_->call} Route::findroutes($l)));
        } else {
                push @out, $self->msg('e7', $l);
        }
index afce3a042d850200af3b9478d8e6b88cd8527403..1106892a167c8641147ac76fa02d9118a13057eb 100644 (file)
@@ -285,6 +285,34 @@ sub get
        return Route::Node::get($call) || Route::User::get($call);
 }
 
+sub findroutes
+{
+       my $call = shift;
+       my $level = shift || 0;
+       my $seen = shift || {};
+       my @out;
+
+       dbg("findroutes: $call level: $level calls: " . join(',', @_)) if isdbg('routec');
+
+       # recursion detector
+       return () if $seen->{$call};
+       if (my $dxchan = DXChannel::get($call)) {
+               $seen->{$call}++;
+               push @out, [$level, $dxchan];
+               return @out;
+       }
+
+       # deal with more nodes
+       my $nref = Route::Node::get($call);
+       foreach my $ncall (@{$nref->{nodes}}) {
+               dbg("recursing from $call -> $ncall") if isdbg('routec');
+               my @rout = findroute($ncall, $level+1, $seen);
+               push @out, @rout;
+       }
+
+       return $level == 0 ? map {$_->[1]} sort {$a->[0] <=> $b->[0]} @out : @out;
+}
+
 # find all the possible dxchannels which this object might be on
 sub alldxchan
 {