projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
a pretty nearly working gtkconsole...
[spider.git]
/
perl
/
DXXml.pm
diff --git
a/perl/DXXml.pm
b/perl/DXXml.pm
index a9072d467d4fcc3ea8e3ea150be2174c3cd749af..6bf1fa5967a5bbb4bc248312355899a2b9407e59 100644
(file)
--- a/
perl/DXXml.pm
+++ b/
perl/DXXml.pm
@@
-39,7
+39,7
@@
sub new
{
my $pkg = shift;
my $class = ref $pkg || $pkg;
{
my $pkg = shift;
my $class = ref $pkg || $pkg;
- my $self = bless{
@_
}, $class;
+ my $self = bless{}, $class;
while (@_) {
my $key = shift;
my $val = shift;
while (@_) {
my $key = shift;
my $val = shift;
@@
-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 ($@)");
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;
} else {
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
import XML::Simple;
- $DXProt::handle_xml = 1;
- $xs = new XML::Simple(Cache=>[]);
+ $xs = new XML::Simple(ContentKey=>'content', ForceArray=>1);
}
undef $@;
}
}
undef $@;
}
+# is XML avaiable and active
+sub available
+{
+ return $main::do_xml && $xs;
+}
+
#
# note that this a function not a method
#
#
# note that this a function not a method
#
@@
-77,7
+82,7
@@
sub normal
my $dxchan = shift;
my $line = shift;
my $dxchan = shift;
my $line = shift;
- unless (
$main::do_xml
) {
+ unless (
available()
) {
dbg("xml not enabled, IGNORED") if isdbg('chanerr');
return;
}
dbg("xml not enabled, IGNORED") if isdbg('chanerr');
return;
}
@@
-125,9
+130,9
@@
sub normal
$xref->{'-timet'} = $t;
return if DXDupe::check("xml,$o,$t,$id", $dupeage);
$xref->{'-timet'} = $t;
return if DXDupe::check("xml,$o,$t,$id", $dupeage);
-
$xref
= bless $xref, $pkg;
- $
xref
->{'-xml'} = $line;
- $
xref
->handle_input($dxchan);
+
my $r
= bless $xref, $pkg;
+ $
r
->{'-xml'} = $line;
+ $
r
->handle_input($dxchan);
}
#
}
#
@@
-156,7
+161,6
@@
sub process
DXXml::Ping::add($main::me, $dxchan->call);
$dxchan->{nopings} -= 1;
$dxchan->{lastping} = $t;
DXXml::Ping::add($main::me, $dxchan->call);
$dxchan->{nopings} -= 1;
$dxchan->{lastping} = $t;
- $dxchan->{lastping} += $dxchan->{pingint} / 2 unless @{$dxchan->{pingtime}};
}
}
}
}
}
}
@@
-215,17
+219,17
@@
sub route
my $via = $to;
my $dxchan;
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) {
$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) {
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;
}
return;
}
@@
-254,12
+258,12
@@
sub route
}
if ($fromdxchan->call eq $via) {
}
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) {
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;
}
return;
}
@@
-269,24
+273,12
@@
sub route
if ($dxchan->handle_xml) {
$dxchan->send($self->toxml);
if ($dxchan->handle_xml) {
$dxchan->send($self->toxml);
- } elsif ($dxchan->isnode) {
+ } elsif ($dxchan->is
_
node) {
my $ref = $self->topcxx($dxchan);
my $ref = $self->topcxx($dxchan);
- if (ref $ref) {
- for (@$ref) {
- $dxchan->send($_);
- }
- } else {
- $dxchan->send($ref);
- }
+ $dxchan->send($ref);
} else {
my $ref = $self->tocmd($dxchan);
} else {
my $ref = $self->tocmd($dxchan);
- if (ref $ref) {
- for (@$ref) {
- $dxchan->send($_);
- }
- } else {
- $dxchan->send($ref);
- }
+ $dxchan->send($ref);
}
}
}
}