]> dxcluster.org Git - spider.git/blob - perl/IntMsg.pm
Link the filtering manual from the admin and user manuals (g0vgs)
[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,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                         } else {
48                                 $_ = '';
49                         }
50                         &{$conn->{rproc}}($conn, $_) if exists $conn->{rproc};
51                 }
52         }
53 }
54