cb9f1946297d79179a720c10f675fb23016cc7ee
[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                 @l = ();
25                 my $call = $dxchan->call;
26                 $call ||= '???';
27                 $call = "($call)" unless $dxchan->here;
28                 push @l, $call;
29                 
30                 my $i = 0;
31                 foreach my $ref (@val) {
32                         if ($i >= 5) {
33                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
34                                 @l = ();
35                                 push @l, "";
36                                 $i = 0;
37                         }
38                         my $s = $ref->call;
39                         $s ||= '???';
40                         $s = sprintf "(%s)", $s unless $ref->here;
41                         push @l, $s;
42                         $i++;
43                 }
44                 push @l, "" while ($i++ < 5);
45                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
46         }
47 } else {
48         # build up the screen from the Node table
49         foreach $node (@nodes) {
50                 next if scalar @list && !grep $node->call =~ /^$_/, @list;
51                 my $call = $node->call;
52                 @l = ();
53                 $call ||= '???';
54                 $call = "($call)" unless $node->here;
55                 push @l, $call;
56                 @val = sort $node->users;
57
58                 my $i = 0;
59                 if (@val == 0 && $node->usercount) {
60                         push @l, sprintf "(%d users)", $node->usercount;
61                 }
62                 foreach $call (@val) {
63                         if ($i >= 5) {
64                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
65                                 @l = ();
66                                 push @l, "";
67                                 $i = 0;
68                         }
69                         my $uref = Route::User::get($call);
70                         my $s = $call;
71                         if ($uref) {
72                                 $s = sprintf "(%s)", $call unless $uref->here;
73                         } else {
74                                 $s = "$call?";
75                         }
76                         push @l, $s;
77                         $i++;
78                 }
79                 push @l, "" while ($i++ < 5);
80                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
81         }
82 }
83
84
85
86 return (1, @out);