]> scm.dxcluster.org Git - spider.git/blob - perl/IntMsg.pm
fix type for reqreg
[spider.git] / perl / IntMsg.pm
1 #
2 # This class is the internal subclass that deals with the internal port 27754
3 # communications for Msg.pm
4 #
5 # $Id$
6 #
7 # Copyright (c) 2001 - Dirk Koopman G1TLH
8 #
9
10 package IntMsg;
11
12 use strict;
13
14 use vars qw($VERSION $BRANCH);
15 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
16 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
17 $main::build += $VERSION;
18 $main::branch += $BRANCH;
19
20 use Msg;
21
22 use vars qw(@ISA);
23
24 @ISA = qw(Msg);
25
26 sub enqueue
27 {
28         my ($conn, $msg) = @_;
29         $msg =~ s/([\%\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; 
30     push (@{$conn->{outqueue}}, $msg . "\n");
31 }
32
33 sub dequeue
34 {
35         my $conn = shift;
36
37         if ($conn && $conn->{msg} =~ /\cJ/) {
38                 my @lines =  $conn->{msg} =~ /([^\cM\cJ]*)\cM?\cJ/g;
39                 if ($conn->{msg} =~ /\cJ$/) {
40                         delete $conn->{msg};
41                 } else {
42                         $conn->{msg} =~ s/([^\cM\cJ]*)\cM?\cJ//g;
43                 }
44                 for (@lines) {
45                         if (defined $_) {
46                                 s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
47                                 s/[\x00-\x08\x0a-\x19\x1b-\x1f\x80-\x9f]/./g;         # immutable CSI sequence + control characters
48                         } else {
49                                 $_ = '';
50                         }
51                         &{$conn->{rproc}}($conn, $_) if exists $conn->{rproc};
52                 }
53         }
54 }
55