]> scm.dxcluster.org Git - spider.git/blob - perl/DXXml/Text.pm
fix barf on encountering an empty lockfile
[spider.git] / perl / DXXml / Text.pm
1 #
2 # XML Text handler
3 #
4 #
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 DXLog;
16
17 use vars qw(@ISA);
18 @ISA = qw(DXXml);
19
20 sub handle_input
21 {
22         my $self = shift;
23         my $dxchan = shift;
24
25         if ($self->{to} eq $main::mycall) {
26                 my $tochan = DXChannel::get($self->{u} || $main::myalias);
27                 if ($tochan) {
28                         $tochan->send($self->tocmd);
29                 } else {
30                         dbg("no user or $main::myalias not online") if isdbg('chanerr');
31                 }
32         } else {        
33                 $self->route($dxchan);
34         }
35 }
36
37 sub topcxx
38 {
39         my $self = shift;
40         my $dxchan = shift;
41         my @out;
42
43         my $ref = DXUser::get_current($self->{to});
44         for (split /(?:%0D)?\%0A/, $self->{content}) {
45                 my $line = $_;
46                 $line =~ s/\s*$//;
47                 Log('rcmd', 'out', $self->{to}, $line);
48                 if ($self->{u} && $dxchan->is_clx && $ref->is_clx) {
49                         push @out, DXProt::pc85($main::mycall, $self->{to}, $self->{u}, "$main::mycall:$line");
50                 } else {
51                         push @out, DXProt::pc35($main::mycall, $self->{to}, "$main::mycall:$line");
52                 }
53         }
54
55         return $self->{'-pcxx'} = \@out;
56 }
57
58 sub tocmd
59 {
60         my $self = shift;
61
62         my @out = split /(?:%0D)?\%0A/, $self->{content};
63         return $self->{-cmd} = \@out;
64 }
65
66 1;