]> scm.dxcluster.org Git - spider.git/blob - cmd/show/station.pl
adding missing regex handling
[spider.git] / cmd / show / station.pl
1 #
2 # show the station details
3 #
4 # Copyright (c) 1998 - Dirk Koopman G1TLH
5 #
6 # Modifications by Iain Philipps G0RDI, 07-Dec-1998
7 #
8
9 my ($self, $line) = @_;
10 my @f = split /\s+/, uc $line;
11 my @out;
12 my $call;
13 my $seek;
14 push @f, $self->call unless @f;
15
16 if (@f <= 2 && uc $f[0] eq 'ALL') {
17         return (1, $self->msg('e6')) if ($self->priv < 6); 
18         shift @f;
19         my $exp = shellregex(uc shift @f) if @f; 
20         my @calls;
21         if ($exp) {
22                 @calls = grep {m{$exp}} DXUser::get_all_calls();
23     } else {
24                 @calls = DXUser::get_all_calls();
25         }
26         
27         foreach $call (@calls) {
28                 my $ref = DXUser->get_current($call);
29                 next if !$ref;
30                 my $lat = $ref->lat;
31                 my $long = $ref->long;
32                 my $sort = $ref->sort || "";
33                 my $name = $ref->name || "";
34                 my $qth = $ref->qth || "";
35                 my $homenode = $ref->homenode || "";
36                 my $qra = $ref->qra || "";
37                 my $latlong = DXBearing::lltos($lat, $long) if $lat && $long;
38                 $latlong = "" unless $latlong;
39                 
40                 push @out, sprintf "%-9s %s %-12.12s %-27.27s %-9s %s %s", $call, $sort, $name, $qth, $homenode, $latlong, $qra;
41         }
42 } else {
43         foreach $call (@f) {
44                 my $ref = DXUser->get_current($call);
45                 if ($ref) {
46                         my $name = $ref->name;  
47                         my $qth = $ref->qth;
48                         my $lat = $ref->lat;
49                         my $long = $ref->long;
50                         my $node = $ref->node;
51                         my $homenode = $ref->homenode;
52                         my $lastin = $ref->lastin;
53                         my $latlong = DXBearing::lltos($lat, $long) if $lat || $long;
54                         my $last = DXUtil::cldatetime($lastin) if $ref->lastin;
55                         my $qra = $ref->qra;
56                         $qra = DXBearing::lltoqra($lat, $long) if !$qra && ($lat || $long);
57                         my $from;
58                         my ($dx, $bearing, $miles);
59                         if ($latlong) {
60                                 my ($hlat, $hlong) = ($self->user->lat, $self->user->long);
61                                 ($hlat, $hlong) = DXBearing::qratoll($self->user->qra) if $self->user->qra && !$hlat && !$hlong;
62                                 if (!$hlat && !$hlong) {
63                                         $from = "From $main::mycall";
64                                         $hlat = $main::mylatitude;
65                                         $hlong = $main::mylongitude;
66                                 }
67                                 ($bearing, $dx) = DXBearing::bdist($hlat, $hlong, $lat, $long);
68                                 $miles = $dx * 0.62133785;
69                         }
70                         
71                         my $cref = Route::get($call);
72                         my $seek = join(',', $cref->parents) if $cref;
73
74                         if ($seek) {
75                                 push @out, "User         : $call (at $seek)";
76                         } else {
77                                 push @out, "User         : $call";
78                         }
79                         push @out, "Name         : $name" if $name;
80                         push @out, "Last Connect : $last" if $last;
81                         push @out, "QTH          : $qth" if $qth;
82                         push @out, "Location     : $latlong ($qra)" if $latlong || $qra ;
83                         push @out, sprintf("Heading      : %.0f Deg %.0f Mi. %.0f Km.", $bearing, $miles, $dx) if $latlong;
84                         push @out, "Home Node    : $homenode" if $homenode;
85                 } else {
86                         push @out, $self->msg('usernf', $call);
87                 }
88         }
89 }
90
91 return (1, @out);