Commit | Line | Data |
a02d0f6f |
1 | package IO::Uncompress::Adapter::Identity; |
1a6a8453 |
2 | |
3 | use warnings; |
4 | use strict; |
a02d0f6f |
5 | use bytes; |
1a6a8453 |
6 | |
a02d0f6f |
7 | use IO::Compress::Base::Common qw(:Status); |
1a6a8453 |
8 | |
9 | our ($VERSION); |
10 | |
63ad731d |
11 | $VERSION = '2.001'; |
1a6a8453 |
12 | |
a02d0f6f |
13 | use Compress::Raw::Zlib (); |
1a6a8453 |
14 | |
15 | sub mkUncompObject |
16 | { |
17 | my $crc32 = 1; #shift ; |
18 | my $adler32 = shift; |
19 | |
20 | bless { 'CompSize' => 0, |
21 | 'UnCompSize' => 0, |
22 | 'wantCRC32' => $crc32, |
a02d0f6f |
23 | 'CRC32' => Compress::Raw::Zlib::crc32(''), |
1a6a8453 |
24 | 'wantADLER32'=> $adler32, |
a02d0f6f |
25 | 'ADLER32' => Compress::Raw::Zlib::adler32(''), |
1a6a8453 |
26 | } ; |
27 | } |
28 | |
29 | sub uncompr |
30 | { |
31 | my $self = shift; |
32 | my $eof = $_[2]; |
33 | |
34 | if (defined ${ $_[0] } && length ${ $_[0] }) { |
35 | $self->{CompSize} += length ${ $_[0] } ; |
36 | $self->{UnCompSize} = $self->{CompSize} ; |
37 | |
a02d0f6f |
38 | $self->{CRC32} = Compress::Raw::Zlib::crc32($_[0], $self->{CRC32}) |
1a6a8453 |
39 | if $self->{wantCRC32}; |
40 | |
41 | $self->{ADLER32} = Compress::Zlib::adler32($_[0], $self->{ADLER32}) |
42 | if $self->{wantADLER32}; |
43 | |
44 | ${ $_[1] } .= ${ $_[0] }; |
a02d0f6f |
45 | ${ $_[0] } = ""; |
1a6a8453 |
46 | } |
47 | |
48 | return STATUS_ENDSTREAM if $eof; |
49 | return STATUS_OK ; |
50 | } |
51 | |
52 | sub reset |
53 | { |
a02d0f6f |
54 | my $self = shift; |
55 | |
56 | $self->{CompSize} = 0; |
57 | $self->{UnCompSize} = 0; |
e7d45986 |
58 | $self->{CRC32} = Compress::Raw::Zlib::crc32(''); |
59 | $self->{ADLER32} = Compress::Raw::Zlib::adler32(''); |
a02d0f6f |
60 | |
1a6a8453 |
61 | return STATUS_OK ; |
62 | } |
63 | |
64 | |
a02d0f6f |
65 | #sub count |
66 | #{ |
67 | # my $self = shift ; |
68 | # return $self->{UnCompSize} ; |
69 | #} |
1a6a8453 |
70 | |
71 | sub compressedBytes |
72 | { |
73 | my $self = shift ; |
74 | return $self->{UnCompSize} ; |
75 | } |
76 | |
77 | sub uncompressedBytes |
78 | { |
79 | my $self = shift ; |
80 | return $self->{UnCompSize} ; |
81 | } |
82 | |
83 | sub sync |
84 | { |
85 | return STATUS_OK ; |
86 | } |
87 | |
88 | sub crc32 |
89 | { |
90 | my $self = shift ; |
91 | return $self->{CRC32}; |
92 | } |
93 | |
94 | sub adler32 |
95 | { |
96 | my $self = shift ; |
97 | return $self->{ADLER32}; |
98 | } |
99 | |
100 | 1; |
101 | |
102 | __END__ |