From: minima Date: Sun, 4 Jun 2006 17:04:08 +0000 (+0000) Subject: fix xml ambiqueties. X-Git-Tag: 1.53~39 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=edfc15583881f720a65516d975d26cdb6b7c8469;p=spider.git fix xml ambiqueties. --- diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 127f3a06..efaffb6c 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -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 { diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 143b71e4..b1631628 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -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+$/; diff --git a/perl/DXProtout.pm b/perl/DXProtout.pm index 657057c9..522352e4 100644 --- a/perl/DXProtout.pm +++ b/perl/DXProtout.pm @@ -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^"; } diff --git a/perl/DXXml.pm b/perl/DXXml.pm index b9904101..21a2c165 100644 --- a/perl/DXXml.pm +++ b/perl/DXXml.pm @@ -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};