blob: a8a7762ce7000674563ebb927ba77f535fb0bbc0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
package IO::Compress::Adapter::Bzip2 ;
use strict;
use warnings;
use bytes;
use IO::Compress::Base::Common 2.093 qw(:Status);
use Compress::Raw::Bzip2 2.093 ;
our ($VERSION);
$VERSION = '2.093';
sub mkCompObject
{
my $BlockSize100K = shift ;
my $WorkFactor = shift ;
my $Verbosity = shift ;
$BlockSize100K = 1 if ! defined $BlockSize100K ;
$WorkFactor = 0 if ! defined $WorkFactor ;
$Verbosity = 0 if ! defined $Verbosity ;
my ($def, $status) = new Compress::Raw::Bzip2(1, $BlockSize100K,
$WorkFactor, $Verbosity);
return (undef, "Could not create Deflate object: $status", $status)
if $status != BZ_OK ;
return bless {'Def' => $def,
'Error' => '',
'ErrorNo' => 0,
} ;
}
sub compr
{
my $self = shift ;
my $def = $self->{Def};
my $status = $def->bzdeflate($_[0], $_[1]) ;
$self->{ErrorNo} = $status;
if ($status != BZ_RUN_OK)
{
$self->{Error} = "Deflate Error: $status";
return STATUS_ERROR;
}
return STATUS_OK;
}
sub flush
{
my $self = shift ;
my $def = $self->{Def};
my $status = $def->bzflush($_[0]);
$self->{ErrorNo} = $status;
if ($status != BZ_RUN_OK)
{
$self->{Error} = "Deflate Error: $status";
return STATUS_ERROR;
}
return STATUS_OK;
}
sub close
{
my $self = shift ;
my $def = $self->{Def};
my $status = $def->bzclose($_[0]);
$self->{ErrorNo} = $status;
if ($status != BZ_STREAM_END)
{
$self->{Error} = "Deflate Error: $status";
return STATUS_ERROR;
}
return STATUS_OK;
}
sub reset
{
my $self = shift ;
my $outer = $self->{Outer};
my ($def, $status) = new Compress::Raw::Bzip2();
$self->{ErrorNo} = ($status == BZ_OK) ? 0 : $status ;
if ($status != BZ_OK)
{
$self->{Error} = "Cannot create Deflate object: $status";
return STATUS_ERROR;
}
$self->{Def} = $def;
return STATUS_OK;
}
sub compressedBytes
{
my $self = shift ;
$self->{Def}->compressedBytes();
}
sub uncompressedBytes
{
my $self = shift ;
$self->{Def}->uncompressedBytes();
}
#sub total_out
#{
# my $self = shift ;
# 0;
#}
#
#sub total_in
#{
# my $self = shift ;
# $self->{Def}->total_in();
#}
#
#sub crc32
#{
# my $self = shift ;
# $self->{Def}->crc32();
#}
#
#sub adler32
#{
# my $self = shift ;
# $self->{Def}->adler32();
#}
1;
__END__
|