X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXXml.pm;h=f05f3d1c582d0b1fd9bb56eeb80908100c3490ee;hb=c1540ccd7990ec4bd151604dd63583d19fe4d0f6;hp=b990410127167ac19f8339126fb215be371888df;hpb=0dff8311e76fac314d73e64b4af1a8beabfe166d;p=spider.git diff --git a/perl/DXXml.pm b/perl/DXXml.pm index b9904101..f05f3d1c 100644 --- a/perl/DXXml.pm +++ b/perl/DXXml.pm @@ -1,7 +1,7 @@ # # XML handler # -# $Id$ +# # # Copyright (c) Dirk Koopman, G1TLH # @@ -21,12 +21,7 @@ use DXXml::IM; use DXXml::Text; use DXXml::Cmd; -use vars qw($VERSION $BRANCH $xs $id $max_old_age $max_future_age $dupeage); -$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($xs $id $max_old_age $max_future_age $dupeage); $xs = undef; # the XML::Simple parser instance $id = 0; # the next ID to be used $max_old_age = 3600; # how old a sentence we will accept @@ -59,16 +54,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 +77,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,17 +214,17 @@ 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}; unless ($via) { - dbg("XML: no route specified (" . $self->toxml . ")") if isdbg('chanerr'); + dbg("XML: no route specified (" . dd($self) . ")") if isdbg('chanerr'); return; } if (ref $fromdxchan && $via && $fromdxchan->call eq $via) { - dbg("XML: Trying to route back to source (" . $self->toxml . ")") if isdbg('chanerr'); + dbg("XML: Trying to route back to source (" . dd($self) . ")") if isdbg('chanerr'); return; } @@ -238,27 +238,18 @@ sub route dbg("route: $via -> $dxchan->{call} using normal route" ) if isdbg('route'); } - # try the backstop method - unless ($dxchan) { - my $rcall = RouteDB::get($via); - if ($rcall) { - $dxchan = DXChannel::get($rcall); - dbg("route: $via -> $rcall using RouteDB" ) if isdbg('route') && $dxchan; - } - } - unless ($dxchan) { dbg("XML: no route available to $via") if isdbg('chanerr'); return; } if ($fromdxchan->call eq $via) { - dbg("XML: Trying to route back to source (" . $self->toxml . ")") if isdbg('chanerr'); + dbg("XML: Trying to route back to source (" . dd($self) . ")") if isdbg('chanerr'); return; } if ($dxchan == $main::me) { - dbg("XML: Trying to route to me (" . $self->toxml . ")") if isdbg('chanerr'); + dbg("XML: Trying to route to me (" . dd($self) . ")") if isdbg('chanerr'); return; }