remove $Id$ strings from everywhere that I can find
[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 #
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;
20         my $dxchan;
21         
22         foreach my $n (@nodes) {
23                 $dxchan = $n->dxchan;
24                 push @{$ch{$dxchan->call}}, $n;
25         }
26
27         foreach my $call (sort keys %ch) {
28                 @val = sort {$a->call cmp $b->call} @{$ch{$call}};
29                 @l = ();
30                 $call = "($call)" unless DXChannel::get($call)->here;
31                 push @l, $call;
32                 
33                 foreach my $ref (@val) {
34                         if (@l >= 6) {
35                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
36                                 @l = ();
37                                 push @l, "";
38                         }
39                         my $s = $ref->call;
40                         $s ||= '???';
41                         $s = sprintf "(%s)", $s unless $ref->here;
42                         push @l, $s;
43                 }
44                 push @l, "" while @l < 6;
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                 if (@val == 0 && $node->usercount) {
69                         push @l, sprintf "(%d users)", $node->usercount;
70                 }
71                 foreach $call (@val) {
72                         if (@l >= 6) {
73                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
74                                 @l = ();
75                                 push @l, "";
76                         }
77                         my $uref = Route::User::get($call);
78                         my $s = $call;
79                         if ($uref) {
80                                 $s = sprintf "(%s)", $call unless $uref->here;
81                         } else {
82                                 $s = "$call?";
83                         }
84                         push @l, $s;
85                 }
86                 push @l, "" while @l < 6;
87                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
88         }
89 }
90
91
92
93 return (1, @out);