fixed sh/c/n
[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 = (DXNode::get_all());
13 my $node;
14 my @l;
15 my @val;
16
17 push @out, "Node         Callsigns";
18 if ($list[0] =~ /^NOD/) {
19         my @ch = DXProt::get_all_ak1a();
20         my $dxchan;
21         
22         foreach $dxchan (@ch) {
23                 @val = 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 if $call->{here} == 0;
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 eq $_, @list;
48                 my $call = $node->call;
49                 $call = "($call)" if $node->here == 0;
50                 @l = ();
51                 push @l, $call;
52                 my $nlist = $node->list;
53                 @val = values %{$nlist};
54
55                 my $i = 0;
56                 foreach $call (@val) {
57                         if ($i >= 5) {
58                                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
59                                 @l = ();
60                                 push @l, "";
61                                 $i = 0;
62                         }
63                         my $s = $call->{call};
64                         $s = sprintf "(%s)", $s if $call->{here} == 0;
65                         push @l, $s;
66                         $i++;
67                 }
68                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s %-12s", @l;
69         }
70 }
71
72
73
74 return (1, @out);