some detail changes to do with -w flags etc
authordjk <djk>
Tue, 22 Dec 1998 23:01:42 +0000 (23:01 +0000)
committerdjk <djk>
Tue, 22 Dec 1998 23:01:42 +0000 (23:01 +0000)
cmd/disconnect.pl
cmd/dx.pl
cmd/show/dxcc.pl
perl/DXCluster.pm
perl/DXCommandmode.pm
perl/DXLog.pm
perl/DXMsg.pm
perl/DXProtout.pm
perl/Geomag.pm

index 8bb48ccfd5ab5d975f6a6ffaf88fce153ea82f25..e8e83b89c4778f18f5c730e7c5c2d858dd9a1236 100644 (file)
@@ -16,7 +16,7 @@ foreach $call (@calls) {
   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));
        } 
index 394cb7ab6820495eaf71e72978147bdd741d9dd6..763bf9b0aace735bd8e7db629724c2c594fe15d6 100644 (file)
--- a/cmd/dx.pl
+++ b/cmd/dx.pl
@@ -17,15 +17,17 @@ my @out;
 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
@@ -36,13 +38,13 @@ my $i;
 # 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) {
@@ -50,7 +52,7 @@ 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) {
@@ -70,20 +72,20 @@ push @out, $self->msg('dx1', $freq) if !$valid;
 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);
index 3a2911c583e7bbd9a1904dba450e5cc6428e4269..f5826e47c9be561d208ca62123f35385d1b866c9 100644 (file)
@@ -5,7 +5,7 @@
 #
 
 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;
@@ -15,85 +15,85 @@ my ($fromday, $today);
 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);
index 153c70e9c80b5309ca0d0a8ffc19f31438288e96..8bd2c36ffb772eb5a24edab6b35d996dfc1c36f1 100644 (file)
@@ -261,7 +261,9 @@ sub update_users
 {
   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 {
index 0f802d89f6396a8fd031ea2323a8d41666c3131c..1c54424e0744e8457700fbc77634f74cac072445 100644 (file)
@@ -199,20 +199,25 @@ sub run_cmd
                        ($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);
                        }
                }
        }
@@ -467,12 +472,12 @@ sub find_cmd_name {
        
        # 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";
@@ -510,7 +515,7 @@ sub find_cmd_name {
                        delete_package($package);
                } else {
                        #cache it unless we're cleaning out each time
-                       $Cache{$package}{mtime} = $mtime;
+                       $Cache{$package}->{'mtime'} = $mtime;
                }
        }
        
index c699413717534370ae4ab60536f75b1b8427931a..dde723027f5b237afd735c4452eeafd1b7a42a02 100644 (file)
@@ -66,9 +66,6 @@ sub open
        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';
@@ -76,6 +73,8 @@ sub open
        $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
@@ -163,7 +162,6 @@ sub close
        my $self = shift;
        undef $self->{fh};                      # close the filehandle
        delete $self->{fh};
-       delete $self->{mode};
 }
 
 # log something in the system log 
index 262a4155c92cd4deab28b8f832cec1ac8e519cf4..80895a55fbfc0ae82966bdb91ffa26214b539d92 100644 (file)
@@ -5,7 +5,12 @@
 # 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;
 
index 9a782960827068a10265f69f84ab17044283749c..a1dca22391ace8c49b762d942b645bafbb1fe8f1 100644 (file)
@@ -41,7 +41,7 @@ sub pc11
        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
index 3ee013618f5554443d08c9bc64add9b647e4ff74..1a118fe07a869d5d60efb020556bda7180928092 100644 (file)
@@ -161,7 +161,7 @@ sub print
                                                \$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
                                        }
                                }
                          );
@@ -179,6 +179,7 @@ LOOP:
                        }
                        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;