line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::OpenPGP::Plaintext; |
2
|
1
|
|
|
1
|
|
694
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
657
|
use Crypt::OpenPGP::Buffer; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Crypt::OpenPGP::ErrorHandler; |
6
|
|
|
|
|
|
|
use base qw( Crypt::OpenPGP::ErrorHandler ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
|
|
|
|
|
|
my $class = shift; |
10
|
|
|
|
|
|
|
my $pt = bless { }, $class; |
11
|
|
|
|
|
|
|
$pt->init(@_); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub data { $_[0]->{data} } |
15
|
|
|
|
|
|
|
sub mode { $_[0]->{mode} } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
|
|
|
|
|
|
my $pt = shift; |
19
|
|
|
|
|
|
|
my %param = @_; |
20
|
|
|
|
|
|
|
if (my $data = $param{Data}) { |
21
|
|
|
|
|
|
|
$pt->{data} = $data; |
22
|
|
|
|
|
|
|
$pt->{mode} = $param{Mode} || 'b'; |
23
|
|
|
|
|
|
|
$pt->{timestamp} = time; |
24
|
|
|
|
|
|
|
$pt->{filename} = $param{Filename} || ''; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
$pt; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub parse { |
30
|
|
|
|
|
|
|
my $class = shift; |
31
|
|
|
|
|
|
|
my($buf) = @_; |
32
|
|
|
|
|
|
|
my $pt = $class->new; |
33
|
|
|
|
|
|
|
$pt->{mode} = $buf->get_char; |
34
|
|
|
|
|
|
|
$pt->{filename} = $buf->get_bytes($buf->get_int8); |
35
|
|
|
|
|
|
|
$pt->{timestamp} = $buf->get_int32; |
36
|
|
|
|
|
|
|
$pt->{data} = $buf->get_bytes( $buf->length - $buf->offset ); |
37
|
|
|
|
|
|
|
$pt; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub save { |
41
|
|
|
|
|
|
|
my $pt = shift; |
42
|
|
|
|
|
|
|
my $buf = Crypt::OpenPGP::Buffer->new; |
43
|
|
|
|
|
|
|
$buf->put_char($pt->{mode}); |
44
|
|
|
|
|
|
|
$buf->put_int8(length $pt->{filename}); |
45
|
|
|
|
|
|
|
$buf->put_bytes($pt->{filename}); |
46
|
|
|
|
|
|
|
$buf->put_int32($pt->{timestamp}); |
47
|
|
|
|
|
|
|
$buf->put_bytes($pt->{data}); |
48
|
|
|
|
|
|
|
$buf->bytes; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |