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