my $dxchan = DXChannel->get($call);
if ($dxchan) {
if ($dxchan->is_ak1a) {
- $dxchan->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1')));
+ $dxchan->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1', $self->call)));
} else {
$dxchan->send_now('D', $self->msg('disc1', $self->call));
}
my $valid = 0;
# first lets see if we think we have a callsign as the first argument
-if ($f[0] =~ /[A-Za-z]/) {
- $spotter = uc $f[0];
- $freq = $f[1];
- $spotted = uc $f[2];
- $line =~ s/^$f[0]\s+$f[1]\s+$f[2]\s*//;
-} else {
- $freq = $f[0];
- $spotted = uc $f[1];
- $line =~ s/^$f[0]\s+$f[1]\s*//;
+if (defined @f && @f >= 3 && $f[0] =~ /[A-Za-z]/) {
+ $spotter = uc $f[0];
+ $freq = $f[1];
+ $spotted = uc $f[2];
+ $line =~ s/^$f[0]\s+$f[1]\s+$f[2]\s*//;
+} elsif (defined @f && @f >= 2) {
+ $freq = $f[0];
+ $spotted = uc $f[1];
+ $line =~ s/^$f[0]\s+$f[1]\s*//;
+} elsif (!defined @f || @f < 2) {
+ return (1, $self->msg('dx2'));
}
# bash down the list of bands until a valid one is reached
# first in KHz
L1:
foreach $bandref (Bands::get_all()) {
- @bb = @{$bandref->band};
- for ($i = 0; $i < @bb; $i += 2) {
- if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
- $valid = 1;
- last L1;
+ @bb = @{$bandref->band};
+ for ($i = 0; $i < @bb; $i += 2) {
+ if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
+ $valid = 1;
+ last L1;
+ }
}
- }
}
if (!$valid) {
# try again in MHZ
$freq = $freq * 1000 if $freq;
-L2:
+ L2:
foreach $bandref (Bands::get_all()) {
@bb = @{$bandref->band};
for ($i = 0; $i < @bb; $i += 2) {
if ($spotted le ' ') {
push @out, $self->msg('dx2');
- $valid = 0;
+ $valid = 0;
}
return (1, @out) if !$valid;
# Store it here
if (Spot::add($freq, $spotted, $main::systime, $line, $spotter)) {
- # send orf to the users
- my $buf = Spot::formatb($freq, $spotted, $main::systime, $line, $spotter);
- DXProt::broadcast_users($buf);
+ # send orf to the users
+ my $buf = Spot::formatb($freq, $spotted, $main::systime, $line, $spotter);
+ DXProt::broadcast_users($buf);
- # send it orf to the cluster (hang onto your tin helmets)!
- DXProt::broadcast_ak1a(DXProt::pc11($spotter, $freq, $spotted, $line));
+ # send it orf to the cluster (hang onto your tin helmets)!
+ DXProt::broadcast_ak1a(DXProt::pc11($spotter, $freq, $spotted, $line));
}
return (1, @out);
#
my ($self, $line) = @_;
-my @list = split /\s+/, $line; # split the line up
+my @list = split /\s+/, $line; # split the line up
my @out;
my $f;
my @freq;
my @ans;
-while ($f = shift @list) { # next field
- print "f: $f list: ", join(',', @list), "\n";
- if (!$from && !$to) {
- ($from, $to) = $f =~ /^(\d+)-(\d+)$/o; # is it a from -> to count?
- next if $from && $to > $from;
- }
- if (!$to) {
- ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
- next if $to;
- }
- if (lc $f eq 'on' && $list[0]) { # is it freq range?
- print "yup freq\n";
- my @r = split '/', $list[0];
- print "r0: $r[0] r1: $r[1]\n";
- @freq = Bands::get_freq($r[0], $r[1]);
- if (@freq) { # yup, get rid of extranous param
- print "freq: ", join(',', @freq), "\n";
- shift @list;
- next;
+while ($f = shift @list) { # next field
+# print "f: $f list: ", join(',', @list), "\n";
+ if (!$from && !$to) {
+ ($from, $to) = $f =~ /^(\d+)-(\d+)$/o; # is it a from -> to count?
+ next if $from && $to > $from;
+ }
+ if (!$to) {
+ ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count?
+ next if $to;
+ }
+ if (lc $f eq 'on' && $list[0]) { # is it freq range?
+# print "yup freq\n";
+ my @r = split '/', $list[0];
+# print "r0: $r[0] r1: $r[1]\n";
+ @freq = Bands::get_freq($r[0], $r[1]);
+ if (@freq) { # yup, get rid of extranous param
+# print "freq: ", join(',', @freq), "\n";
+ shift @list;
+ next;
+ }
+ }
+ if (lc $f eq 'day' && $list[0]) {
+# print "got day\n";
+ ($fromday, $today) = split '-', $list[0];
+ shift @list;
+ next;
+ }
+ if (!@ans) {
+ @ans = Prefix::extract($f); # is it a callsign/prefix?
}
- }
- if (lc $f eq 'day' && $list[0]) {
- print "got day\n";
- ($fromday, $today) = split '-', $list[0];
- shift @list;
- next;
- }
- if (!@ans) {
- @ans = Prefix::extract($f); # is it a callsign/prefix?
- }
}
# no dxcc country, no answer!
-if (@ans) { # we have a valid prefix!
+if (@ans) { # we have a valid prefix!
- # first deal with the prefix
- my $pre = shift @ans;
- my $a;
- my $expr = "(";
- my $str = "Prefix: $pre";
- my $l = length $str;
+ # first deal with the prefix
+ my $pre = shift @ans;
+ my $a;
+ my $expr = "(";
+ my $str = "Prefix: $pre";
+ my $l = length $str;
- # build up a search string for this dxcc country/countries
- foreach $a (@ans) {
- $expr .= " || " if $expr ne "(";
- my $n = $a->dxcc();
- $expr .= "\$f5 == $n";
- my $name = $a->name();
- $str .= " Dxcc: $n ($name)";
+ # build up a search string for this dxcc country/countries
+ foreach $a (@ans) {
+ $expr .= " || " if $expr ne "(";
+ my $n = $a->dxcc();
+ $expr .= "\$f5 == $n";
+ my $name = $a->name();
+ $str .= " Dxcc: $n ($name)";
+ push @out, $str;
+ $str = pack "A$l", " ";
+ }
+ $expr .= ")";
push @out, $str;
- $str = pack "A$l", " ";
- }
- $expr .= ")";
- push @out, $str;
- # now deal with any frequencies specified
- if (@freq) {
- $expr .= " && (";
- my $i;
- for ($i; $i < @freq; $i += 2) {
- $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
+ # now deal with any frequencies specified
+ if (@freq) {
+ $expr .= " && (";
+ my $i;
+ for ($i = 0; $i < @freq; $i += 2) {
+ $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||";
+ }
+ chop $expr;
+ chop $expr;
+ $expr .= ")";
}
- chop $expr;
- chop $expr;
- $expr .= ")";
- }
- print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
+# print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n";
- # now do the search
- my @res = Spot::search($expr, $fromday, $today, $from, $to);
- my $ref;
- my @dx;
- foreach $ref (@res) {
- @dx = @$ref;
- push @out, Spot::formatl(@dx);
- }
+ # now do the search
+ my @res = Spot::search($expr, $fromday, $today, $from, $to);
+ my $ref;
+ my @dx;
+ foreach $ref (@res) {
+ @dx = @$ref;
+ push @out, Spot::formatl(@dx);
+ }
} else {
- @out = $self->msg('e4');
+ @out = $self->msg('e4');
}
return (1, @out);
{
my $self = shift;
my $count = shift;
- $users -= $self->{users};
+ $count = 0 unless $count;
+
+ $users -= $self->{users} if $self->{users};
if ((keys %{$self->{list}})) {
$self->{users} = (keys %{$self->{list}});
} else {
($path, $fcmd) = search($main::localcmd, $cmd, "pl");
($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
- dbg('command', "path: $cmd cmd: $fcmd");
+ if ($path && $cmd) {
+ dbg('command', "path: $cmd cmd: $fcmd");
- my $package = find_cmd_name($path, $fcmd);
- @ans = (0) if !$package ;
-
- if ($package) {
- dbg('command', "package: $package");
+ my $package = find_cmd_name($path, $fcmd);
+ @ans = (0) if !$package ;
- my $c = qq{ \@ans = $package(\$self, \$args) };
- dbg('eval', "cluster cmd = $c\n");
- eval $c;
- if ($@) {
- @ans = (0, "Syserr: Eval err cached $package\n$@");
+ if ($package) {
+ dbg('command', "package: $package");
+
+ my $c = qq{ \@ans = $package(\$self, \$args) };
+ dbg('eval', "cluster cmd = $c\n");
+ eval $c;
+ if ($@) {
+ @ans = (0, "Syserr: Eval err cached $package\n$@");
+ }
}
+ } else {
+ dbg('command', "cmd: $cmd not found");
+ @ans = (0);
}
}
}
# return if we can't find it
$errstr = undef;
- if (undef $mtime) {
+ unless (defined $mtime) {
$errstr = DXM::msg('e1');
return undef;
}
- if(defined $Cache{$package}{mtime} && $Cache{$package}{mtime } <= $mtime) {
+ if(defined $Cache{$package}->{mtime} && $Cache{$package}->{mtime } <= $mtime) {
#we have compiled this subroutine already,
#it has not been updated on disk, nothing left to do
#print STDERR "already compiled $package->handler\n";
delete_package($package);
} else {
#cache it unless we're cleaning out each time
- $Cache{$package}{mtime} = $mtime;
+ $Cache{$package}->{'mtime'} = $mtime;
}
}
if (defined $mode) {
my $dir = "$self->{prefix}/$year";
mkdir($dir, 0777) if ! -e $dir;
- $self->{mode} = $mode;
- } else {
- delete $self->{mode};
}
$self->{fn} = sprintf "$self->{prefix}/$year/%02d", $thing if $self->{'sort'} eq 'm';
$self->{fn} .= ".$self->{suffix}" if $self->{suffix};
$mode = 'r' if !$mode;
+ $self->{mode} = $mode;
+
my $fh = new FileHandle $self->{fn}, $mode;
return undef if !$fh;
$fh->autoflush(1) if $mode ne 'r'; # make it autoflushing if writable
my $self = shift;
undef $self->{fh}; # close the filehandle
delete $self->{fh};
- delete $self->{mode};
}
# log something in the system log
# Copyright (c) 1998 Dirk Koopman G1TLH
#
# $Id$
-#
+#
+#
+# Notes for implementors:-
+#
+# PC28 field 11 is the RR required flag
+# PC28 field 12 is a VIA routing (ie it is a node call)
package DXMsg;
my $hops = get_hops(11);
my $t = time;
$text = ' ' if !$text;
- return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$hops^~", $freq, cldate($t), ztime($t);
+ return sprintf "PC11^%.1f^$dxcall^%s^%s^$text^$mycall^$main::mycall^$hops^~", $freq, cldate($t), ztime($t);
}
# create an announce message
\$count++;
next if \$count < \$from;
push \@out, print_item(\$ref);
- last LOOP if \$count >= \$to; # stop after n
+ last if \$count >= \$to; # stop after n
}
}
);
}
eval $eval; # do the search on this file
return ("Spot search error", $@) if $@;
+ last if $count >= $to; # stop after n
}
$fh = $fp->openprev(); # get the next file
last if !$fh;