3386a1716e5a65404ce7398a0d59378a6e712dd9
[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, $self->msg('showconf');
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         my $printall;
49         
50         $printall = 1 if @list && $list[0] =~ /^ALL/i;
51         
52         # build up the screen from the Node table
53         foreach $node (@nodes) {
54                 unless ($printall) {
55                         if (@list) {
56                                 next unless grep $node->call =~ /^$_/, @list;
57                         } else {
58                                 next unless grep $node->dxcc == $_, @main::my_cc;
59                         }
60                 }
61                 my $call = $node->call;
62                 @l = ();
63                 $call ||= '???';
64                 $call = "($call)" unless $node->here;
65                 push @l, $call;
66                 @val = sort $node->users;
67
68                 my $i = 0;
69                 if (@val == 0 && $node->usercount) {
70                         push @l, sprintf "(%d users)", $node->usercount;
71                 }
72                 foreach $call (@val) {
73                         if ($i >= 5) {
74                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
75                                 @l = ();
76                                 push @l, "";
77                                 $i = 0;
78                         }
79                         my $uref = Route::User::get($call);
80                         my $s = $call;
81                         if ($uref) {
82                                 $s = sprintf "(%s)", $call unless $uref->here;
83                         } else {
84                                 $s = "$call?";
85                         }
86                         push @l, $s;
87                         $i++;
88                 }
89                 push @l, "" while ($i++ < 5);
90                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
91         }
92 }
93
94
95
96 return (1, @out);