35c83191e504fe8a5909e77ad6bb433012c3d60f
[spider.git] / perl / DXXml / Text.pm
1 #
2 # XML Text handler
3 #
4 # $Id$
5 #
6 # Copyright (c) Dirk Koopman, G1TLH
7 #
8
9 use strict;
10
11 package DXXml::Text;
12
13 use DXDebug;
14 use DXProt;
15 use IsoTime;
16 use Investigate;
17 use Time::HiRes qw(gettimeofday tv_interval);
18
19 use vars qw($VERSION $BRANCH @ISA %pings);
20 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
21 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
22 $main::build += $VERSION;
23 $main::branch += $BRANCH;
24
25 @ISA = qw(DXXml);
26
27 sub handle_input
28 {
29         my $self = shift;
30         my $dxchan = shift;
31
32         # this is always routed
33         if ($self->{to} eq $main::mycall ) {
34                 my $r = DXChannel::get($main::myalias);
35                 $dxchan = $r if $r;
36         }
37         $self->route($dxchan);
38
39 }
40
41 sub topcxx
42 {
43         my $self = shift;
44         my $dxchan = shift;
45         my @out;
46
47         my $ref = DXUser->get_current($self->{to});
48         while (@_) {
49                 my $line = shift;
50                 $line =~ s/\s*$//;
51                 Log('rcmd', 'out', $self->{to}, $line);
52                 if ($self->{u} && $dxchan->is_clx && $ref->is_clx) {
53                         push @out, pc85($main::mycall, $self->{to}, $self->{u}, "$main::mycall:$line");
54                 } else {
55                         push @out, pc35($main::mycall, $self->{to}, "$main::mycall:$line");
56                 }
57         }
58
59         return $self->{'-pcxx'} = \@out;
60 }
61
62 sub tocmd
63 {
64         my $self = shift;
65
66         my @out = split /(?:%0D)?\%0A/, $self->{content};
67         return $self->{-cmd} = \@out;
68 }
69
70 1;