clean up various things and add the DXXml.pm module
[spider.git] / perl / DXUser.pm
index a349f6ab41f9d3c90629c3c1cb20f038e9ba2256..13c5ba8101f55a66213d17be199e69901800710d 100644 (file)
@@ -20,8 +20,10 @@ use LRU;
 use strict;
 
 use vars qw($VERSION $BRANCH);
-
-main::mkver($VERSION = q$Revision$);
+$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
+$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
+$main::build += $VERSION;
+$main::branch += $BRANCH;
 
 use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime $lru $lrusize $tooold $v3);
 
@@ -76,8 +78,6 @@ $v3 = 0;
                  wantlogininfo => '0,Login Info Req,yesno',
           wantgrid => '0,Show DX Grid,yesno',
                  wantann_talk => '0,Talklike Anns,yesno',
-                 wantpc90 => '1,Req PC90,yesno',
-                 wantnp => '1,Req New Proto,yesno',
                  wantpc16 => '9,Want Users from node,yesno',
                  wantsendpc16 => '9,Send PC16,yesno',
                  wantroutepc19 => '9,Route PC19,yesno',
@@ -210,17 +210,23 @@ sub finish
 # new - create a new user
 #
 
-sub new
+sub alloc
 {
        my $pkg = shift;
        my $call = uc shift;
+       my $self = bless {call => $call, 'sort'=>'U'}, $pkg;
+       return $self;
+}
+
+sub new
+{
+       my $pkg = shift;
+       my $call = shift;
        #  $call =~ s/-\d+$//o;
   
 #      confess "can't create existing call $call in User\n!" if $u{$call};
 
-       my $self = bless {}, $pkg;
-       $self->{call} = $call;
-       $self->{'sort'} = 'U';
+       my $self = $pkg->alloc($call);
        $self->put;
        return $self;
 }
@@ -262,7 +268,7 @@ sub get_current
        my $pkg = shift;
        my $call = uc shift;
   
-       my $dxchan = DXChannel->get($call);
+       my $dxchan = DXChannel::get($call);
        return $dxchan->user if $dxchan;
        my $rref = Route::get($call);
        return $rref->user if $rref && exists $rref->{user};
@@ -336,8 +342,7 @@ sub asc_decode
        my $ref;
        eval '$ref = ' . $s;
        if ($@) {
-               dbg($@);
-               Log('err', $@);
+               LogDbg('err', $@);
                $ref = undef;
        }
        return $ref;
@@ -480,20 +485,24 @@ print "There are $count user records and $err errors\n";
 
         for ($action = R_FIRST; !$dbm->seq($key, $val, $action); $action = R_NEXT) {
                        if (!is_callsign($key) || $key =~ /^0/) {
-                               Log('DXCommand', "Export Error1: $key\t$val");
+                               my $eval = $val;
+                               my $ekey = $key;
+                               $eval =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; 
+                               $ekey =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; 
+                               LogDbg('DXCommand', "Export Error1: $ekey\t$eval");
                                eval {$dbm->del($key)};
-                               dbg(carp("Export Error1: $key\t$val\n$@")) if $@;
+                               dbg(carp("Export Error1: $ekey\t$eval\n$@")) if $@;
                                ++$err;
                                next;
                        }
                        my $ref = decode($val);
                        if ($ref) {
                                my $t = $ref->{lastin} || 0;
-                               if ($main::systime > $t + $tooold) {
+                               if ($ref->{sort} eq 'U' && !$ref->{priv} && $main::systime > $t + $tooold) {
                                        unless ($ref->{lat} && $ref->{long} || $ref->{qth} || $ref->{qra}) {
                                                eval {$dbm->del($key)};
                                                dbg(carp("Export Error2: $key\t$val\n$@")) if $@;
-                                               Log('DXCommand', "$ref->{call} deleted, too old");
+                                               LogDbg('DXCommand', "$ref->{call} deleted, too old");
                                                $del++;
                                                next;
                                        }
@@ -502,7 +511,7 @@ print "There are $count user records and $err errors\n";
                                print $fh "$key\t" . $ref->asc_encode . "\n";
                                ++$count;
                        } else {
-                               Log('DXCommand', "Export Error3: $key\t$val");
+                               LogDbg('DXCommand', "Export Error3: $key\t$val");
                                eval {$dbm->del($key)};
                                dbg(carp("Export Error3: $key\t$val\n$@")) if $@;
                                ++$err;
@@ -675,11 +684,6 @@ sub wantpc16
        return _want('pc16', @_);
 }
 
-sub wantpc90
-{
-       return _wantnot('pc90', @_);
-}
-
 sub wantsendpc16
 {
        return _want('sendpc16', @_);
@@ -705,11 +709,6 @@ sub wantdxitu
        return _want('dxitu', @_);
 }
 
-sub wantnp
-{
-       return _wantnot('np', @_);
-}
-
 sub wantlogininfo
 {
        my $self = shift;
@@ -724,12 +723,6 @@ sub is_node
        return $self->{sort} =~ /[ACRSX]/;
 }
 
-sub is_aranea
-{
-       my $self = shift;
-       return $self->{sort} eq 'W';
-}
-
 sub is_user
 {
        my $self = shift;