#include <bz2comprs.h>
Definition at line 33 of file bz2comprs.h.
Bzip2Compress::~Bzip2Compress |
( |
| ) |
|
|
virtual |
void Bzip2Compress::decode |
( |
void |
| ) |
|
|
virtual |
Reimplemented from SWCompress.
Definition at line 110 of file bz2comprs.cpp.
115 char *
zbuf = (
char *)calloc(1, 1024);
116 char *chunkbuf =
zbuf;
118 unsigned long zlen = 0;
119 while((chunklen = (
int)
getChars(chunk, 1023))) {
120 memcpy(chunkbuf, chunk, chunklen);
124 else zbuf = (
char *)
realloc(zbuf, zlen + 1024);
125 chunkbuf = zbuf +
zlen;
130 unsigned int blen = (
unsigned int)(zlen*20);
131 char *
buf =
new char[blen];
134 switch (BZ2_bzBuffToBuffDecompress(buf, &blen, zbuf, (
unsigned int)
zlen, 0, 0)){
136 case BZ_MEM_ERROR: fprintf(stderr,
"ERROR: not enough memory during decompression.\n");
break;
137 case BZ_OUTBUFF_FULL: fprintf(stderr,
"ERROR: not enough room in the out buffer during decompression.\n");
break;
138 case BZ_DATA_ERROR: fprintf(stderr,
"ERROR: corrupt data during decompression.\n");
break;
139 default: fprintf(stderr,
"ERROR: an unknown error occurred during decompression.\n");
break;
144 fprintf(stderr,
"ERROR: no buffer to decompress!\n");
virtual unsigned long getChars(char *buf, unsigned long len)
virtual unsigned long sendChars(char *buf, unsigned long len)
void Bzip2Compress::encode |
( |
void |
| ) |
|
|
virtual |
Reimplemented from SWCompress.
Definition at line 61 of file bz2comprs.cpp.
66 char *
buf = (
char *)calloc(1, 1024);
68 unsigned long chunklen;
69 unsigned long len = 0;
70 while((chunklen =
getChars(chunk, 1023))) {
71 memcpy(chunkbuf, chunk, chunklen);
75 else buf = (
char *)
realloc(buf, len + 1024);
80 zlen = (long) (len*1.01)+600;
85 if (BZ2_bzBuffToBuffCompress(zbuf, (
unsigned int*)&
zlen,
buf, (
unsigned int)len,
level, 0, 0) != BZ_OK)
87 printf(
"ERROR in compression\n");
95 fprintf(stderr,
"ERROR: no buffer to compress\n");
virtual unsigned long getChars(char *buf, unsigned long len)
virtual unsigned long sendChars(char *buf, unsigned long len)
unsigned long SWCompress::getChars |
( |
char * |
buf, |
|
|
unsigned long |
len |
|
) |
| |
|
virtualinherited |
char * SWCompress::getCompressedBuf |
( |
unsigned long * |
len = 0 | ) |
|
|
virtualinherited |
Definition at line 111 of file swcomprs.cpp.
116 if (len) *len =
zlen;
virtual void encode(void)
virtual int SWCompress::getLevel |
( |
| ) |
|
|
inlinevirtualinherited |
char * SWCompress::getUncompressedBuf |
( |
unsigned long * |
len = 0 | ) |
|
|
virtualinherited |
Definition at line 90 of file swcomprs.cpp.
92 buf = (
char *)calloc(1,1);
virtual void decode(void)
unsigned long SWCompress::sendChars |
( |
char * |
buf, |
|
|
unsigned long |
len |
|
) |
| |
|
virtualinherited |
Definition at line 141 of file swcomprs.cpp.
145 if ((
pos + len) > (
unsigned)
slen) {
147 memset(&
buf[
pos], 0, len + 1024);
150 else buf = (
char *)calloc(1, len + 1024);
151 memmove(&
buf[
pos], ibuf, len);
162 zbuf = (
char *)calloc(1, len + 1024);
void SWCompress::setCompressedBuf |
( |
unsigned long * |
len, |
|
|
char * |
buf = 0 |
|
) |
| |
|
virtualinherited |
virtual void SWCompress::setLevel |
( |
int |
l | ) |
|
|
inlinevirtualinherited |
void SWCompress::setUncompressedBuf |
( |
const char * |
buf = 0 , |
|
|
unsigned long * |
len = 0 |
|
) |
| |
|
virtualinherited |
Definition at line 75 of file swcomprs.cpp.
78 slen = (len) ? *len : strlen(ibuf);
79 buf = (
char *) calloc(
slen + 1, 1);
83 buf = (
char *)calloc(1,1);
virtual void decode(void)
|
mutableprotectedinherited |
|
mutableprotectedinherited |
unsigned long SWCompress::pos |
|
protectedinherited |
unsigned long SWCompress::slen |
|
protectedinherited |
|
mutableprotectedinherited |
unsigned long SWCompress::zlen |
|
protectedinherited |
unsigned long SWCompress::zpos |
|
protectedinherited |
The documentation for this class was generated from the following files: