line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#############################################################################
|
2
|
|
|
|
|
|
|
## Name: IOScalar.pm
|
3
|
|
|
|
|
|
|
## Purpose: Mail::SendEasy::IOScalar
|
4
|
|
|
|
|
|
|
## Author: Graciliano M. P.
|
5
|
|
|
|
|
|
|
## Modified by:
|
6
|
|
|
|
|
|
|
## Created: 25/5/2003
|
7
|
|
|
|
|
|
|
## RCS-ID:
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2003 Graciliano M. P.
|
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or
|
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself
|
11
|
|
|
|
|
|
|
#############################################################################
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Mail::SendEasy::IOScalar ;
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use strict qw(vars) ;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION @ISA) ;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
810
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.01' ;
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new {
|
21
|
0
|
|
|
0
|
0
|
|
my $proto = shift;
|
22
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto ;
|
23
|
0
|
|
|
|
|
|
my $sref = shift ;
|
24
|
0
|
|
|
|
|
|
my $self = bless \do { local *FH }, $class ;
|
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
tie *$self, $class, $self ;
|
26
|
0
|
0
|
|
|
|
|
if (!defined $sref) { my $s ; $sref = \$s ;}
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
*$self->{Pos} = 0;
|
28
|
0
|
|
|
|
|
|
*$self->{SR} = $sref;
|
29
|
0
|
|
|
|
|
|
$self;
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub print {
|
33
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
34
|
0
|
|
|
|
|
|
*$self->{Pos} = length(${*$self->{SR}} .= join('', @_));
|
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
1;
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub write {
|
39
|
0
|
|
|
0
|
0
|
|
my $self = $_[0];
|
40
|
0
|
|
|
|
|
|
my $n = $_[2];
|
41
|
0
|
|
0
|
|
|
|
my $off = $_[3] || 0;
|
42
|
0
|
|
|
|
|
|
my $data = substr($_[1], $off, $n);
|
43
|
0
|
|
|
|
|
|
$n = length($data);
|
44
|
0
|
|
|
|
|
|
$self->print($data);
|
45
|
0
|
|
|
|
|
|
return $n;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub eof {
|
49
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
50
|
0
|
|
|
|
|
|
(*$self->{Pos} >= length(${*$self->{SR}}));
|
|
0
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub seek {
|
54
|
0
|
|
|
0
|
0
|
|
my ($self, $pos, $whence) = @_;
|
55
|
0
|
|
|
|
|
|
my $eofpos = length(${*$self->{SR}});
|
|
0
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
if ($whence == 0) { *$self->{Pos} = $pos } ### SEEK_SET
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
elsif ($whence == 1) { *$self->{Pos} += $pos } ### SEEK_CUR
|
58
|
0
|
|
|
|
|
|
elsif ($whence == 2) { *$self->{Pos} = $eofpos + $pos} ### SEEK_END
|
59
|
0
|
0
|
|
|
|
|
if (*$self->{Pos} < 0) { *$self->{Pos} = 0 }
|
|
0
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if (*$self->{Pos} > $eofpos) { *$self->{Pos} = $eofpos }
|
|
0
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
1;
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
0
|
|
sub tell { *{shift()}->{Pos} }
|
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
0
|
|
sub close { my $self = shift ; %{*$self} = () ; 1 ;}
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
0
|
|
sub syswrite { shift->write(@_) ;}
|
69
|
0
|
|
|
0
|
0
|
|
sub sysseek { shift->seek (@_) ;}
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
0
|
|
sub flush {}
|
72
|
0
|
|
|
0
|
0
|
|
sub autoflush {}
|
73
|
0
|
|
|
0
|
0
|
|
sub binmode {}
|
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
|
|
sub DESTROY { shift->close ;}
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub TIEHANDLE {
|
78
|
0
|
0
|
0
|
0
|
|
|
((defined($_[1]) && UNIVERSAL::isa($_[1],'Mail::SendEasy::IOScalar')) ? $_[1] : shift->new(@_)) ;
|
79
|
|
|
|
|
|
|
}
|
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
|
|
sub PRINT { shift->print(@_) }
|
82
|
0
|
|
|
0
|
|
|
sub PRINTF { shift->print(sprintf(shift, @_)) }
|
83
|
0
|
|
|
0
|
|
|
sub WRITE { shift->write(@_); }
|
84
|
0
|
|
|
0
|
|
|
sub CLOSE { shift->close(@_); }
|
85
|
0
|
|
|
0
|
|
|
sub SEEK { shift->seek(@_); }
|
86
|
0
|
|
|
0
|
|
|
sub TELL { shift->tell(@_); }
|
87
|
0
|
|
|
0
|
|
|
sub EOF { shift->eof(@_); }
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#######
|
90
|
|
|
|
|
|
|
# END #
|
91
|
|
|
|
|
|
|
#######
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1;
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|