#include <xzcomprs.h>
Definition at line 34 of file xzcomprs.h.
XzCompress::~XzCompress |
( |
| ) |
|
|
virtual |
void XzCompress::decode |
( |
void |
| ) |
|
|
virtual |
Reimplemented from SWCompress.
Definition at line 131 of file xzcomprs.cpp.
136 char *
zbuf = (
char *)calloc(1, 1024);
137 char *chunkbuf =
zbuf;
139 unsigned long zlen = 0;
140 while((chunklen =
getChars(chunk, 1023))) {
141 memcpy(chunkbuf, chunk, chunklen);
145 else zbuf = (
char *)
realloc(zbuf, zlen + 1024);
146 chunkbuf = zbuf +
zlen;
151 unsigned long blen = zlen*20;
152 char *
buf =
new char[blen];
158 switch (lzma_stream_buffer_decode((uint64_t *)&
memlimit, 0,
NULL, (
const uint8_t*)zbuf, &zpos, (
size_t)zlen, (uint8_t*)buf, &bpos, (
size_t)&blen)){
160 case LZMA_FORMAT_ERROR: fprintf(stderr,
"ERROR: format error encountered during decompression.\n");
break;
161 case LZMA_OPTIONS_ERROR: fprintf(stderr,
"ERROR: options error encountered during decompression.\n");
break;
162 case LZMA_DATA_ERROR: fprintf(stderr,
"ERROR: corrupt data during decompression.\n");
break;
163 case LZMA_NO_CHECK: fprintf(stderr,
"ERROR: no_check error encountered during decompression.\n");
break;
164 case LZMA_UNSUPPORTED_CHECK: fprintf(stderr,
"ERROR: unsupported_check error encountered during decompression.\n");
break;
165 case LZMA_MEMLIMIT_ERROR: fprintf(stderr,
"ERROR: memlimit error encountered during decompression.\n");
break;
166 case LZMA_MEM_ERROR: fprintf(stderr,
"ERROR: not enough memory during decompression.\n");
break;
167 case LZMA_BUF_ERROR: fprintf(stderr,
"ERROR: not enough room in the out buffer during decompression.\n");
break;
168 case LZMA_PROG_ERROR: fprintf(stderr,
"ERROR: program error encountered during decompression.\n");
break;
169 default: fprintf(stderr,
"ERROR: an unknown error occurred during decompression.\n");
break;
174 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 XzCompress::encode |
( |
void |
| ) |
|
|
virtual |
Reimplemented from SWCompress.
Definition at line 79 of file xzcomprs.cpp.
85 char *
buf = (
char *)calloc(1, 1024);
87 unsigned long chunklen;
88 unsigned long len = 0;
89 while((chunklen =
getChars(chunk, 1023))) {
90 memcpy(chunkbuf, chunk, chunklen);
94 else buf = (
char *)
realloc(buf, len + 1024);
98 zlen = (long)lzma_stream_buffer_bound(len);
104 switch (lzma_easy_buffer_encode(
level | LZMA_PRESET_EXTREME, LZMA_CHECK_CRC64,
NULL, (
const uint8_t*)
buf, (size_t)len, (uint8_t*)zbuf, &zpos, (
size_t)
zlen)) {
105 case LZMA_OK:
sendChars(zbuf, zpos);
break;
106 case LZMA_BUF_ERROR: fprintf(stderr,
"ERROR: not enough room in the out buffer during compression.\n");
break;
107 case LZMA_UNSUPPORTED_CHECK: fprintf(stderr,
"ERROR: unsupported_check error encountered during decompression.\n");
break;
108 case LZMA_OPTIONS_ERROR: fprintf(stderr,
"ERROR: options error encountered during decompression.\n");
break;
109 case LZMA_MEM_ERROR: fprintf(stderr,
"ERROR: not enough memory during compression.\n");
break;
110 case LZMA_DATA_ERROR: fprintf(stderr,
"ERROR: corrupt data during compression.\n");
break;
111 case LZMA_PROG_ERROR: fprintf(stderr,
"ERROR: program error encountered during decompression.\n");
break;
112 default: fprintf(stderr,
"ERROR: an unknown error occurred during compression.\n");
break;
116 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 |
void XzCompress::setLevel |
( |
int |
l | ) |
|
|
virtual |
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: