本文整理汇总了C++中BZ2_bzDecompressInit函数的典型用法代码示例。如果您正苦于以下问题:C++ BZ2_bzDecompressInit函数的具体用法?C++ BZ2_bzDecompressInit怎么用?C++ BZ2_bzDecompressInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BZ2_bzDecompressInit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MojoInput_bzip2_seek
static boolean MojoInput_bzip2_seek(MojoInput *io, uint64 offset)
{
// This is all really expensive.
BZIP2info *info = (BZIP2info *) io->opaque;
/*
* If seeking backwards, we need to redecode the file
* from the start and throw away the compressed bits until we hit
* the offset we need. If seeking forward, we still need to
* decode, but we don't rewind first.
*/
if (offset < info->uncompressed_position)
{
#if 0
/* we do a copy so state is sane if inflateInit2() fails. */
bz_stream str;
initializeBZ2Stream(&str);
if (BZ2_bzDecompressInit(&str, 0, 0) != BZ_OK)
return false;
if (!info->origio->seek(info->origio, 0))
return false; // !!! FIXME: leaking (str)?
BZ2_bzDecompressEnd(&info->stream);
memcpy(&info->stream, &str, sizeof (bz_stream));
#endif
if (!info->origio->seek(info->origio, 0))
return false;
BZ2_bzDecompressEnd(&info->stream);
initializeBZ2Stream(&info->stream);
if (BZ2_bzDecompressInit(&info->stream, 0, 0) != BZ_OK)
return false;
info->uncompressed_position = 0;
} // if
while (info->uncompressed_position != offset)
{
uint8 buf[512];
uint32 maxread;
int64 br;
maxread = (uint32) (offset - info->uncompressed_position);
if (maxread > sizeof (buf))
maxread = sizeof (buf);
br = io->read(io, buf, maxread);
if (br != maxread)
return false;
} /* while */
return true;
} // MojoInput_bzip2_seek
开发者ID:fgouget,项目名称:mojosetup-fg,代码行数:53,代码来源:fileio.c
示例2: memzero
UnBZFilter::UnBZFilter() {
memzero(&zs, sizeof(zs));
if(BZ2_bzDecompressInit(&zs, 0, 0) != BZ_OK)
throw Exception(STRING(DECOMPRESSION_ERROR));
}
开发者ID:strogo,项目名称:StrongDC,代码行数:7,代码来源:BZUtils.cpp
示例3: BufFilePushBZIP2
_X_HIDDEN BufFilePtr
BufFilePushBZIP2 (BufFilePtr f)
{
xzip_buf *x;
x = malloc (sizeof (xzip_buf));
if (!x) return NULL;
bzero(&(x->z), sizeof(bz_stream));
x->f = f;
x->zstat = BZ2_bzDecompressInit(&(x->z),
0, /* verbosity: 0 silent, 4 max */
0); /* 0: go faster, 1: use less memory */
if (x->zstat != BZ_OK) {
free(x);
return NULL;
}
/* now that the history buffer is allocated, we provide the data buffer */
x->z.next_out = (char *) x->b;
x->z.avail_out = BUFFILESIZE;
x->z.next_in = (char *) x->b_in;
x->z.avail_in = 0;
return BufFileCreate((char *)x,
BufBzip2FileFill,
NULL,
BufBzip2FileSkip,
BufBzip2FileClose);
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-libxfont,代码行数:31,代码来源:bunzip2.c
示例4: ft_bzip2_file_reset
static FT_Error
ft_bzip2_file_reset( FT_BZip2File zip )
{
FT_Stream stream = zip->source;
FT_Error error;
if ( !FT_STREAM_SEEK( 0 ) )
{
bz_stream* bzstream = &zip->bzstream;
BZ2_bzDecompressEnd( bzstream );
bzstream->avail_in = 0;
bzstream->next_in = (char*)zip->input;
bzstream->avail_out = 0;
bzstream->next_out = (char*)zip->buffer;
zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE;
zip->cursor = zip->limit;
zip->pos = 0;
BZ2_bzDecompressInit( bzstream, 0, 0 );
}
return error;
}
开发者ID:03050903,项目名称:Urho3D,代码行数:28,代码来源:ftbzip2.c
示例5: squash_bz2_stream_new
static SquashBZ2Stream*
squash_bz2_stream_new (SquashCodec* codec, SquashStreamType stream_type, SquashOptions* options) {
int bz2_e = 0;
SquashBZ2Stream* stream;
assert (codec != NULL);
assert (stream_type == SQUASH_STREAM_COMPRESS || stream_type == SQUASH_STREAM_DECOMPRESS);
stream = squash_malloc (sizeof (SquashBZ2Stream));
squash_bz2_stream_init (stream, codec, stream_type, options, squash_bz2_stream_destroy);
if (stream_type == SQUASH_STREAM_COMPRESS) {
bz2_e = BZ2_bzCompressInit (&(stream->stream),
squash_codec_get_option_int_index (codec, options, SQUASH_BZ2_OPT_LEVEL),
0,
squash_codec_get_option_int_index (codec, options, SQUASH_BZ2_OPT_WORK_FACTOR));
} else if (stream_type == SQUASH_STREAM_DECOMPRESS) {
bz2_e = BZ2_bzDecompressInit (&(stream->stream),
0,
squash_codec_get_option_int_index (codec, options, SQUASH_BZ2_OPT_SMALL));
} else {
squash_assert_unreachable();
}
if (bz2_e != BZ_OK) {
/* We validate the params so OOM is really the only time this
should happen, and that really shouldn't be happening here. */
stream = squash_object_unref (stream);
}
return stream;
}
开发者ID:szabadka,项目名称:squash,代码行数:32,代码来源:squash-bzip2.c
示例6: malloc
io_t *bz_open(io_t *parent)
{
io_t *io;
if (!parent)
return NULL;
io = malloc(sizeof(io_t));
io->source = &bz_source;
io->data = malloc(sizeof(struct bz_t));
DATA(io)->parent = parent;
DATA(io)->strm.next_in = NULL;
DATA(io)->strm.avail_in = 0;
DATA(io)->strm.next_out = NULL;
DATA(io)->strm.avail_out = 0;
DATA(io)->strm.bzalloc = NULL;
DATA(io)->strm.bzfree = NULL;
DATA(io)->strm.opaque = NULL;
DATA(io)->err = ERR_OK;
BZ2_bzDecompressInit(&DATA(io)->strm,
0, /* Verbosity */
0); /* small */
return io;
}
开发者ID:rsanger,项目名称:libtrace,代码行数:26,代码来源:ior-bzip.c
示例7: squash_bz2_stream_new
static SquashBZ2Stream*
squash_bz2_stream_new (SquashCodec* codec, SquashStreamType stream_type, SquashBZ2Options* options) {
int bz2_e = 0;
SquashBZ2Stream* stream;
assert (codec != NULL);
assert (stream_type == SQUASH_STREAM_COMPRESS || stream_type == SQUASH_STREAM_DECOMPRESS);
stream = (SquashBZ2Stream*) malloc (sizeof (SquashBZ2Stream));
squash_bz2_stream_init (stream, codec, stream_type, options, squash_bz2_stream_free);
if (stream_type == SQUASH_STREAM_COMPRESS) {
bz2_e = BZ2_bzCompressInit (&(stream->stream),
squash_bz2_options_get_block_size_100k (options),
0,
squash_bz2_options_get_work_factor (options));
} else if (stream_type == SQUASH_STREAM_DECOMPRESS) {
bz2_e = BZ2_bzDecompressInit (&(stream->stream),
0,
squash_bz2_options_get_small (options) ? 1 : 0);
} else {
assert (false);
}
if (bz2_e != BZ_OK) {
/* We validate the params so OOM is really the only time this
should happen, and that really shouldn't be happening here. */
stream = squash_object_unref (stream);
}
return stream;
}
开发者ID:anthrotype,项目名称:squash,代码行数:32,代码来源:squash-bzip2.c
示例8: libmpq__decompress_bzip2
/* this function decompress a stream using bzip2 library. */
int32_t libmpq__decompress_bzip2(uint8_t *in_buf, uint32_t in_size, uint8_t *out_buf, uint32_t out_size) {
/* some common variables. */
int32_t result = 0;
int32_t tb = 0;
bz_stream strm;
/* initialize the bzlib decompression. */
strm.bzalloc = NULL;
strm.bzfree = NULL;
/* initialize the structure. */
if ((result = BZ2_bzDecompressInit(&strm, 0, 0)) != BZ_OK) {
/* something on bzlib initialization failed. */
return result;
}
/* fill the stream structure for bzlib. */
strm.next_in = (char *)in_buf;
strm.avail_in = in_size;
strm.next_out = (char *)out_buf;
strm.avail_out = out_size;
/* do the decompression. */
while (BZ2_bzDecompress(&strm) != BZ_STREAM_END);
/* save transferred bytes. */
tb = strm.total_out_lo32;
/* cleanup of bzip stream. */
BZ2_bzDecompressEnd(&strm);
/* return transferred bytes. */
return tb;
}
开发者ID:Blumfield,项目名称:TBCPvP,代码行数:35,代码来源:extract.c
示例9: BZ2_bzCompressInit
void bzip2_base::do_init
( bool compress,
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
bzip2::alloc_func alloc,
bzip2::free_func free,
#endif
void* derived )
{
bz_stream* s = static_cast<bz_stream*>(stream_);
// Current interface for customizing memory management
// is non-conforming and has been disabled:
//#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
// s->bzalloc = alloc;
// s->bzfree = free;
//#else
s->bzalloc = 0;
s->bzfree = 0;
//#endif
s->opaque = derived;
bzip2_error::check(
compress ?
BZ2_bzCompressInit( s,
params_.block_size,
0,
params_.work_factor ) :
BZ2_bzDecompressInit( s,
0,
params_.small )
);
ready_ = true;
}
开发者ID:rzymek,项目名称:cxxsp,代码行数:32,代码来源:bzip2.cpp
示例10: start
static bool
start(void *ud) {
struct ctx *ctx = (struct ctx *)ud;
int ret;
ctx->zstr.avail_in = 0;
ctx->zstr.next_in = NULL;
ctx->zstr.avail_out = 0;
ctx->zstr.next_out = NULL;
if (ctx->compress) {
ret = BZ2_bzCompressInit(&ctx->zstr, ctx->compression_flags, 0, 30);
}
else {
ret = BZ2_bzDecompressInit(&ctx->zstr, 0, 0);
}
if (ret != BZ_OK) {
zip_error_set(ctx->error, map_error(ret), 0);
return false;
}
return true;
}
开发者ID:newser,项目名称:TitanSDK,代码行数:25,代码来源:zip_algorithm_bzip2.c
示例11: xmalloc
static MojoInput *make_bzip2_input(MojoInput *origio)
{
MojoInput *io = NULL;
BZIP2info *info = (BZIP2info *) xmalloc(sizeof (BZIP2info));
initializeBZ2Stream(&info->stream);
if (BZ2_bzDecompressInit(&info->stream, 0, 0) != BZ_OK)
{
free(info);
return NULL;
} // if
info->origio = origio;
io = (MojoInput *) xmalloc(sizeof (MojoInput));
io->ready = MojoInput_bzip2_ready;
io->read = MojoInput_bzip2_read;
io->seek = MojoInput_bzip2_seek;
io->tell = MojoInput_bzip2_tell;
io->length = MojoInput_bzip2_length;
io->duplicate = MojoInput_bzip2_duplicate;
io->close = MojoInput_bzip2_close;
io->opaque = info;
return io;
} // make_bzip2_input
开发者ID:fgouget,项目名称:mojosetup-fg,代码行数:25,代码来源:fileio.c
示例12: open
// Try open file stream
bool FXBZFileStream::open(const FXString& filename,FXStreamDirection save_or_load,FXuval size){
if(FXFileStream::open(filename,save_or_load,size)){
if(FXCALLOC(&bz,BZBlock,1)){
int bzerror;
bz->stream.next_in=NULL;
bz->stream.avail_in=0;
bz->stream.next_out=NULL;
bz->stream.avail_out=0;
ac=BZ_RUN;
if(save_or_load==FXStreamLoad){
bzerror=BZ2_bzDecompressInit(&bz->stream,VERBOSITY,0);
if(bzerror==BZ_OK) return true;
code=FXStreamNoRead;
}
else{
bzerror=BZ2_bzCompressInit(&bz->stream,BLOCKSIZE100K,VERBOSITY,WORKFACTOR);
if(bzerror==BZ_OK) return true;
code=FXStreamNoWrite;
}
FXFREE(&bz);
}
FXFileStream::close();
}
return false;
}
开发者ID:gfphoenix,项目名称:tsiu,代码行数:26,代码来源:FXBZFileStream.cpp
示例13: larc_bzip2_decompressor
/**
* Create an decompress function.
* options:
*/
static int larc_bzip2_decompressor(lua_State *L)
{
bz_userdata *ud;
ud = (bz_userdata*)lua_newuserdata(L, sizeof(bz_userdata));
luaL_getmetatable(L, BZ2DECOMPRESS_MT);
lua_setmetatable(L, -2);
ud->z.bzalloc = NULL;
ud->z.bzfree = NULL;
ud->z.opaque = NULL;
ud->z.next_in = NULL;
ud->z.avail_in = 0;
ud->status = BZ2_bzDecompressInit(&ud->z, 0, USE_SMALL_DECOMPRESS);
if (ud->status != BZ_OK)
{
lua_pushnil(L);
lua_pushstring(L, bz2_error(ud->status));
lua_pushinteger(L, ud->status);
return 3;
}
lua_pushcclosure(L, decompress_call, 1);
return 1;
}
开发者ID:rzel,项目名称:lua-larc,代码行数:30,代码来源:lbzip2.c
示例14: BZ2_bzDecompressInit
JNIEXPORT jbyteArray JNICALL Java_cn_reactnative_modules_update_DownloadTask_bsdiffPatch
(JNIEnv *env, jobject self, jbyteArray origin, jbyteArray patch){
jclass newExcCls;
jbyte* outPtr;
struct bspatch_stream stream;
bz_stream zip;
jbyte* originPtr = (*env)->GetByteArrayElements(env, origin, NULL);
size_t originLength = (*env)->GetArrayLength(env, origin);
jbyte* patchPtr = (*env)->GetByteArrayElements(env, patch, NULL);
size_t patchLength = (*env)->GetArrayLength(env, patch);
jbyteArray ret = NULL;
if (patchLength < 32) {
newExcCls = (*env)->FindClass(env,"java/lang/Error");
if (newExcCls != NULL) /* Unable to find the new exception class, give up. */
(*env)->ThrowNew(env,newExcCls, "Corrupt patch");
(*env)->ReleaseByteArrayElements(env, origin, originPtr, JNI_ABORT);
(*env)->ReleaseByteArrayElements(env, patch, patchPtr, JNI_ABORT);
return NULL;
}
int64_t newsize=offtin((uint8_t*)patchPtr + 16);
if (memcmp(patchPtr, "ENDSLEY/BSDIFF43", 16) != 0 || newsize<0) {
newExcCls = (*env)->FindClass(env, "java/lang/Error");
if (newExcCls != NULL) /* Unable to find the new exception class, give up. */
(*env)->ThrowNew(env, newExcCls, "Corrupt patch");
(*env)->ReleaseByteArrayElements(env, origin, originPtr, JNI_ABORT);
(*env)->ReleaseByteArrayElements(env, patch, patchPtr, JNI_ABORT);
return NULL;
}
ret = (*env)->NewByteArray(env, newsize);
if (ret == NULL) {
return NULL; // out of memory error thrown
}
outPtr = (*env)->GetByteArrayElements(env, ret, NULL);
zip.bzalloc = NULL;
zip.bzfree = NULL;
zip.opaque = NULL;
BZ2_bzDecompressInit(&zip, 0, 1);
zip.next_in = (char*)patchPtr + 32;
zip.avail_in = patchLength - 32;
stream.read = bz2_read;
stream.opaque = &zip;
if (bspatch((const uint8_t*)originPtr, originLength, (uint8_t*)outPtr, newsize, &stream)) {
newExcCls = (*env)->FindClass(env, "java/lang/Error");
if (newExcCls != NULL) /* Unable to find the new exception class, give up. */
(*env)->ThrowNew(env, newExcCls, "bspatch");
}
BZ2_bzDecompressEnd(&zip);
(*env)->ReleaseByteArrayElements(env, ret, outPtr, 0);
(*env)->ReleaseByteArrayElements(env, origin, originPtr, JNI_ABORT);
(*env)->ReleaseByteArrayElements(env, patch, patchPtr, JNI_ABORT);
return ret;
}
开发者ID:reactnativecn,项目名称:react-native-pushy,代码行数:59,代码来源:DownloadTask.c
示例15: bz2_decompress_xml
bool bz2_decompress_xml(char *in_data, int in_data_length, BYTE **pDat, int *data_length) {
const int BLOCKSIZE = 1024 * 100;
bz_stream bzs = {0};
switch(BZ2_bzDecompressInit(&bzs, 0, 0)) {
case BZ_CONFIG_ERROR:
//MessageBox(0, "Configuration Error", "BZ2 Decompres Init", MB_OK | MB_ICONERROR);
ShowError(TranslateT("BZ2 Decompression, configuration error"));
return false;
case BZ_PARAM_ERROR:
//MessageBox(0, "Parameters Error", "BZ2 Decompres Init", MB_OK | MB_ICONERROR);
ShowError(TranslateT("BZ2 Decompression, parameter error"));
return false;
case BZ_MEM_ERROR:
//MessageBox(0, "Memory Error", "BZ2 Decompres Init", MB_OK | MB_ICONERROR);
ShowError(TranslateT("DB2 Decompression, memory error"));
return false;
}
bzs.avail_in = in_data_length;
bzs.next_in = in_data;
bzs.avail_out = BLOCKSIZE;
*pDat = (BYTE *)malloc(bzs.avail_out + 1); // allocate 100k (at present, xml data is about 87k) (1 byte extra for a terminating 0 for safety)
bzs.next_out = (char *)*pDat;
int blocknum = 0;
int ret;
while((ret = BZ2_bzDecompress(&bzs)) == BZ_OK && bzs.avail_in > 0) {
if(bzs.avail_out == 0) {
blocknum++;
*pDat = (BYTE *)realloc(*pDat, (blocknum + 1) * BLOCKSIZE + 1);
bzs.next_out = (char *)(*pDat + (blocknum * BLOCKSIZE));
bzs.avail_out = BLOCKSIZE;
}
}
BZ2_bzDecompressEnd(&bzs);
if(ret != BZ_STREAM_END) {
// char msg[512];
// sprintf(msg, "Error decompressing, code: %d", ret);
// MessageBox(0, msg, "Error Decompressing BZ2 XML data", MB_OK);
free(*pDat);
*pDat = 0;
*data_length = 0;
return false;
}
*data_length = bzs.total_out_lo32; // assume it's not too massive!
(*pDat)[*data_length] = 0; // for safety - last char shouldn't matter to us
//char msg[256];
//sprintf(msg, "Bytes decompressed: %d", data_length);
//MessageBox(0, msg, "msg", MB_OK);
return true;
}
开发者ID:darkscout,项目名称:sje-miranda-plugins,代码行数:59,代码来源:xmldata.cpp
示例16: while
static char *_qdbm_bzdecode_impl(const char *ptr, int size, int *sp) {
bz_stream zs;
char *buf, *swap, obuf[BZIPBUFSIZ];
int rv, asiz, bsiz, osiz;
zs.bzalloc = NULL;
zs.bzfree = NULL;
zs.opaque = NULL;
if(BZ2_bzDecompressInit(&zs, 0, 0) != BZ_OK) return NULL;
asiz = size * 2 + 16;
if(asiz < BZIPBUFSIZ) asiz = BZIPBUFSIZ;
if(!(buf = malloc(asiz))) {
BZ2_bzDecompressEnd(&zs);
return NULL;
}
bsiz = 0;
zs.next_in = (char *)ptr;
zs.avail_in = size;
zs.next_out = obuf;
zs.avail_out = BZIPBUFSIZ;
while((rv = BZ2_bzDecompress(&zs)) == BZ_OK) {
osiz = BZIPBUFSIZ - zs.avail_out;
if(bsiz + osiz >= asiz) {
asiz = asiz * 2 + osiz;
if(!(swap = realloc(buf, asiz))) {
free(buf);
BZ2_bzDecompressEnd(&zs);
return NULL;
}
buf = swap;
}
memcpy(buf + bsiz, obuf, osiz);
bsiz += osiz;
zs.next_out = obuf;
zs.avail_out = BZIPBUFSIZ;
}
if(rv != BZ_STREAM_END) {
free(buf);
BZ2_bzDecompressEnd(&zs);
return NULL;
}
osiz = BZIPBUFSIZ - zs.avail_out;
if(bsiz + osiz >= asiz) {
asiz = asiz * 2 + osiz;
if(!(swap = realloc(buf, asiz))) {
free(buf);
BZ2_bzDecompressEnd(&zs);
return NULL;
}
buf = swap;
}
memcpy(buf + bsiz, obuf, osiz);
bsiz += osiz;
buf[bsiz] = '\0';
if(sp) *sp = bsiz;
BZ2_bzDecompressEnd(&zs);
return buf;
}
开发者ID:naveen-raju,项目名称:key_value_stores,代码行数:57,代码来源:myconf.c
示例17: Bz2Private
Samurai::IO::BZip2Decompressor::BZip2Decompressor()
{
d = new Bz2Private();
if (BZ2_bzDecompressInit(d->stream, 0, 0) != BZ_OK)
{
delete d; d = 0;
}
}
开发者ID:janvidar,项目名称:samurai,代码行数:9,代码来源:compression.cpp
示例18: bzip2_decompress
int
bzip2_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen,
int level, uchar_t chdr, void *data)
{
bz_stream bzs;
int ret;
unsigned int slen, dlen;
uint64_t _srclen = srclen;
uint64_t _dstlen = *dstlen;
uchar_t *dst1 = dst;
uchar_t *src1 = src;
bzs.bzalloc = slab_alloc_i;
bzs.bzfree = slab_free;
bzs.opaque = NULL;
ret = BZ2_bzDecompressInit(&bzs, 0, 0);
if (ret != BZ_OK) {
bzerr(ret);
return (-1);
}
while (_srclen > 0) {
if (_srclen > SINGLE_CALL_MAX) {
slen = SINGLE_CALL_MAX;
} else {
slen = _srclen;
}
if (_dstlen > SINGLE_CALL_MAX) {
dlen = SINGLE_CALL_MAX;
} else {
dlen = _dstlen;
}
bzs.next_in = src1;
bzs.avail_in = slen;
bzs.next_out = dst1;
bzs.avail_out = dlen;
ret = BZ2_bzDecompress(&bzs);
if (ret != BZ_OK && ret != BZ_STREAM_END) {
BZ2_bzDecompressEnd(&bzs);
bzerr(ret);
return (-1);
}
dst1 += (dlen - bzs.avail_out);
_dstlen -= (dlen - bzs.avail_out);
src1 += (slen - bzs.avail_in);
_srclen -= (slen - bzs.avail_in);
}
/* normal termination */
*dstlen = *dstlen - _dstlen;
BZ2_bzDecompressEnd(&bzs);
return (0);
}
开发者ID:alepharchives,项目名称:pcompress,代码行数:56,代码来源:bzip2_compress.c
示例19: BZ2Decompress
void BZ2Decompress(Stream& out, Stream& in, Gate2<int, int> progress)
{
enum { BUF_SIZE = 65536 };
Buffer<char> input(BUF_SIZE), output(BUF_SIZE);
int avail = in.Get(input, BUF_SIZE);
if(avail == 0)
return;
bz_stream z;
Zero(z);
z.bzalloc = bzalloc_new;
z.bzfree = bzfree_new;
z.opaque = 0;
if(BZ2_bzDecompressInit(&z, 0, 0) != BZ_OK)
{
out.SetError();
return;
}
z.next_in = input;
z.avail_in = avail;
z.next_out = output;
z.avail_out = BUF_SIZE;
int code;
bool running = true;
int64 total = in.GetLeft();
int done = 0;
do
{
if(z.avail_in == 0 && running)
{
if((z.avail_in = in.Get(z.next_in = input, BUF_SIZE)) == 0)
running = false;
done += z.avail_in;
if(progress(done, (int)total) || in.IsError())
{
BZ2_bzDecompressEnd(&z);
out.SetError();
return;
}
}
code = BZ2_bzDecompress(&z);
if(z.avail_out == 0)
{
out.Put(z.next_out = output, z.avail_out = BUF_SIZE);
if(out.IsError())
{
BZ2_bzDecompressEnd(&z);
return;
}
}
}
while(code == BZ_OK);
if(z.avail_out < BUF_SIZE)
out.Put(output, BUF_SIZE - z.avail_out);
BZ2_bzDecompressEnd(&z);
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:55,代码来源:bz2upp.cpp
示例20: import_uncompress_detect
int import_uncompress_detect(ImportCompress *c, const void *data, size_t size) {
static const uint8_t xz_signature[] = {
0xfd, '7', 'z', 'X', 'Z', 0x00
};
static const uint8_t gzip_signature[] = {
0x1f, 0x8b
};
static const uint8_t bzip2_signature[] = {
'B', 'Z', 'h'
};
int r;
assert(c);
if (c->type != IMPORT_COMPRESS_UNKNOWN)
return 1;
if (size < MAX3(sizeof(xz_signature),
sizeof(gzip_signature),
sizeof(bzip2_signature)))
return 0;
assert(data);
if (memcmp(data, xz_signature, sizeof(xz_signature)) == 0) {
lzma_ret xzr;
xzr = lzma_stream_decoder(&c->xz, UINT64_MAX, LZMA_TELL_UNSUPPORTED_CHECK);
if (xzr != LZMA_OK)
return -EIO;
c->type = IMPORT_COMPRESS_XZ;
} else if (memcmp(data, gzip_signature, sizeof(gzip_signature)) == 0) {
r = inflateInit2(&c->gzip, 15+16);
if (r != Z_OK)
return -EIO;
c->type = IMPORT_COMPRESS_GZIP;
} else if (memcmp(data, bzip2_signature, sizeof(bzip2_signature)) == 0) {
r = BZ2_bzDecompressInit(&c->bzip2, 0, 0);
if (r != BZ_OK)
return -EIO;
c->type = IMPORT_COMPRESS_BZIP2;
} else
c->type = IMPORT_COMPRESS_UNCOMPRESSED;
c->encoding = false;
return 1;
}
开发者ID:AOSC-Dev,项目名称:systemd,代码行数:54,代码来源:import-compress.c
注:本文中的BZ2_bzDecompressInit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论