merged back NEW_ROUTE into trunk
[spider.git] / cmd / show / configuration.pl
1 #
2 # show the cluster routing tables to the user
3 #
4 # Copyright (c) 1998 Dirk Koopman G1TLH
5 #
6 # $Id$
7 #
8
9 my ($self, $line) = @_;
10 my @list = map { uc } split /\s+/, $line;           # list of callsigns of nodes
11 my @out;
12 my @nodes = sort {$a->call cmp $b->call} (Route::Node::get_all());
13 my $node;
14 my @l;
15 my @val;
16
17 push @out, "Node         Callsigns";
18 if ($list[0] && $list[0] =~ /^NOD/) {
19         my @ch = sort {$a->call cmp $b->call} DXChannel::get_all_nodes();
20         my $dxchan;
21         
22         foreach $dxchan (@ch) {
23                 @val = sort {$a->call cmp $b->call} grep { $_->dxchan == $dxchan } @nodes;
24                 my $call = $dxchan->call;
25                 $call = "($call)" if $dxchan->here == 0;
26                 @l = ();
27                 push @l, $call;
28                 
29                 my $i = 0;
30                 foreach $call (@val) {
31                         if ($i >= 5) {
32                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
33                                 @l = ();
34                                 push @l, "";
35                                 $i = 0;
36                         }
37                         my $s = $call->call;
38                         $s = sprintf "(%s)", $s unless $call->here;
39                         push @l, $s;
40                         $i++;
41                 }
42                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
43         }
44 } else {
45         # build up the screen from the Node table
46         foreach $node (@nodes) {
47                 next if scalar @list && !grep $node->call =~ /^$_/, @list;
48                 my $call = $node->call;
49                 $call = "($call)" unless $node->here;
50                 @l = ();
51                 push @l, $call;
52                 @val = sort $node->users;
53
54                 my $i = 0;
55                 if (@val == 0 && $node->usercount) {
56                         push @l, sprintf "(%d users)", $node->usercount;
57                 }
58                 foreach $call (@val) {
59                         if ($i >= 5) {
60                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
61                                 @l = ();
62                                 push @l, "";
63                                 $i = 0;
64                         }
65                         my $uref = Route::User::get($call);
66                         my $s = $call;
67                         if ($uref) {
68                                 $s = sprintf "(%s)", $call unless $uref->here;
69                         } else {
70                                 $s = "$call?";
71                         }
72                         push @l, $s;
73                         $i++;
74                 }
75                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
76         }
77 }
78
79
80
81 return (1, @out);