fix xml ambiqueties.
authorminima <minima>
Sun, 4 Jun 2006 17:04:08 +0000 (17:04 +0000)
committerminima <minima>
Sun, 4 Jun 2006 17:04:08 +0000 (17:04 +0000)
perl/DXChannel.pm
perl/DXProt.pm
perl/DXProtout.pm
perl/DXXml.pm

index 127f3a0604665e6631784dbc8a871253f72cfb95..efaffb6c04d80be433ac080fd2470c53ea340185 100644 (file)
@@ -724,6 +724,19 @@ sub process
        }
 }
 
+sub handle_xml
+{
+       my $self = shift;
+       my $r = 0;
+       
+       if (DXXml::available()) {
+               $r = $self->{handle_xml} || 0;
+       } else {
+               delete $self->{handle_xml} if exists $self->{handle_xml};
+       }
+       return $r;
+}
+
 #no strict;
 sub AUTOLOAD
 {
index 143b71e48e4a98c0ff141479aa76f1b73efb96a9..b1631628986c9013cec9df9c20772fb3847c85e0 100644 (file)
@@ -50,7 +50,7 @@ use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restim
                        $investigation_int $pc19_version $myprot_version
                        %nodehops $baddx $badspotter $badnode $censorpc $rspfcheck
                        $allowzero $decode_dk0wcy $send_opernam @checklist
-                       $handle_xml);
+                  );
 
 $pc11_max_age = 1*3600;                        # the maximum age for an incoming 'real-time' pc11
 $pc23_max_age = 1*3600;                        # the maximum age for an incoming 'real-time' pc23
@@ -77,7 +77,6 @@ $chatdupeage = 20 * 60 * 60;
 $chatimportfn = "$main::root/chat_import";
 $investigation_int = 12*60*60; # time between checks to see if we can see this node
 $pc19_version = 5466;                  # the visible version no for outgoing PC19s generated from pc59
-$handle_xml = 0;                               # handle XML sentences
 
 @checklist = 
 (
@@ -952,7 +951,7 @@ sub handle_18
                        $self->user->put;
                        $self->sort('S');
                }
-               $self->{handle_xml}++ if $main::do_xml && $_[1] =~ /\bxml\b/;
+               $self->{handle_xml}++ if DXXml::available() && $_[1] =~ /\bxml\b/;
        } else {
                $self->version(50.0);
                $self->version($_[2] / 100) if $_[2] && $_[2] =~ /^\d+$/;
index 657057c9e03cbb99f056457018714bdc050af177..522352e48d97cc35b61020e33b10c2cdd1aa092e 100644 (file)
@@ -25,7 +25,7 @@ $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0))
 $main::build += $VERSION;
 $main::branch += $BRANCH;
 
-use vars qw($sentencelth $handle_xml);
+use vars qw($sentencelth);
 
 $sentencelth = 180;
 
@@ -124,7 +124,7 @@ sub pc17
 sub pc18
 {
        my $flags = "";
-       $flags .= " xml" if $handle_xml
+       $flags .= " xml" if DXXml::available()
        return "PC18^DXSpider Version: $main::version Build: $main::build$flags^$DXProt::myprot_version^";
 }
 
index b990410127167ac19f8339126fb215be371888df..21a2c1653d97fd71bb06853cbb046b049e03b1be 100644 (file)
@@ -59,16 +59,21 @@ sub init
        eval { require XML::Parser } unless $@;
        if ($@) {
                LogDbg('err', "do_xml was set to 1 and the XML routines failed to load ($@)");
-               $main::do_xml = 0;
+               $main::do_xml = $xs = 0;
        } else {
                $XML::Simple::PREFERRED_PARSER = 'XML::Parser';
                import XML::Simple;
-               $DXProt::handle_xml = 1;
                $xs = new XML::Simple(ContentKey=>'content', ForceArray=>1);
        }
        undef $@;
 }
 
+# is XML avaiable and active
+sub available
+{
+       return $main::do_xml && $xs;
+}
+
 #
 # note that this a function not a method
 #
@@ -77,7 +82,7 @@ sub normal
        my $dxchan = shift;
        my $line = shift;
 
-       unless ($main::do_xml) {
+       unless (available()) {
                dbg("xml not enabled, IGNORED") if isdbg('chanerr');
                return;
        }
@@ -214,7 +219,7 @@ sub route
        my $via = $to;
        my $dxchan;
        
-       if (my $u = $self->{u}) {
+       if (my $u = $self->{u} && $self->{to} eq $main::mycall) {
                $via ||= $u if ($dxchan = DXChannel::get($u));
        }
        $via ||= $self->{'-via'} || $self->{to};