2. speeded up the show/node command by using the DB_File interface and
[spider.git] / cmd / show / node.pl
1 #
2 # show/node [<node> | <node> ] 
3
4 # This command either lists all nodes known about 
5 # or the ones specified on the command line together
6 # with some information that is relavent to them 
7 #
8 # This command isn't and never will be compatible with AK1A
9 #
10 # A special millenium treat just for G4PDQ
11 #
12 # Copyright (c) 2000 Dirk Koopman G1TLH
13 #
14 # $Id$
15 #
16
17 my ($self, $line) = @_;
18 return (1, $self->msg('e5')) unless $self->priv >= 1;
19
20 my @call = map {uc $_} split /\s+/, $line; 
21 my @out;
22
23 # search thru the user for nodes
24 unless (@call) {
25         use DB_File;
26         
27         my ($action, $count, $key, $data);
28         for ($action = R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = R_NEXT) {
29                 if ($data =~ m{sort => '[ACRSX]'}) {
30                     push @call, $key;
31                 }
32                 ++$count;
33         } 
34 }
35
36 my $call;
37 foreach $call (@call) {
38         my $clref = DXCluster->get_exact($call);
39         my $uref = DXUser->get_current($call);
40         my ($sort, $ver);
41         
42         my $pcall = sprintf "%-11s", $call;
43         push @out, $self->msg('snode1') unless @out > 0;
44         if ($uref) {
45                 $sort = "Unknwn";
46                 $sort = "Spider" if $uref->is_spider;
47                 $sort = "AK1A  " if $uref->is_ak1a;
48                 $sort = "Clx   " if $uref->is_clx;
49                 $sort = "User  " if $uref->is_user;
50                 $sort = "BBS   " if $uref->is_bbs;
51                 $sort = "DXNet " if $uref->is_dxnet;
52                 $sort = "ARClus" if $uref->is_arcluster;
53         } else {
54                 push @out, $self->msg('snode3', $call);
55                 next;
56         }
57         if ($call eq $main::mycall) {
58                 $sort = "Spider";
59                 $ver = $main::version;
60         } else {
61                 $ver = $clref->pcversion if $clref && $clref->pcversion;
62         }
63         
64         my ($major, $minor, $subs) = unpack("AAA*", $ver) if $ver;
65         if ($uref->is_spider) {
66                 push @out, $self->msg('snode2', $pcall, $sort, "$ver  ");
67         } else {
68                 push @out, $self->msg('snode2', $pcall, $sort, $ver ? "$major\-$minor.$subs" : "      ");
69         }
70 }
71
72 return (1, @out, $self->msg('rec', $count));
73
74
75
76