• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ BZ2_bzDecompressEnd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BZ2_bzDecompressEnd函数的典型用法代码示例。如果您正苦于以下问题:C++ BZ2_bzDecompressEnd函数的具体用法?C++ BZ2_bzDecompressEnd怎么用?C++ BZ2_bzDecompressEnd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BZ2_bzDecompressEnd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: larc_bzip2_decompress

/**
 * Inflate a string.
 * options:
 */
static int larc_bzip2_decompress(lua_State *L)
{
	size_t len;
	const char *str = luaL_checklstring(L, 1, &len);
	bz_userdata ud;

	ud.z.bzalloc = NULL;
	ud.z.bzfree = NULL;
	ud.z.opaque = NULL;
	ud.z.next_in = (char*)str;
	ud.z.avail_in = len;
	
	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;
	}
	
	ud.result = -1;
	if (0 != lua_cpcall(L, protected_decompress_to_buffer, &ud))
	{
		BZ2_bzDecompressEnd(&ud.z);
		return lua_error(L);
	}
	BZ2_bzDecompressEnd(&ud.z);
	
	if (ud.result != -1)
	{
		lua_rawgeti(L, LUA_REGISTRYINDEX, ud.result);
		luaL_unref(L, LUA_REGISTRYINDEX, ud.result);
		lua_pushinteger(L, len - ud.z.avail_in);
	}
	else
	{
		lua_pushnil(L);
		lua_pushstring(L, bz2_error(ud.status));
	}
	lua_pushinteger(L, ud.status);
	return 3;
}
开发者ID:rzel,项目名称:lua-larc,代码行数:47,代码来源:lbzip2.c


示例2: KBZipFileDestroy

/* Destroy
 *  destroy file
 */
static rc_t CC KBZipFileDestroy (KBZipFile *self)
{
    rc_t rc = 0, orc = 0;

    if (self)
    {
        if (self->file != NULL)
        {
            int zret = BZ_OK;

            if (self->dad.write_enabled)
            {
                /* flush out end of compressed data */
/*                 if (self->completed == false) */
/*                 { */
                    size_t ignored;
                    bz_stream* strm = &self->strm;

                    strm->avail_in = 0;
                    strm->next_in = NULL;
                    rc = KBZipFileWriteInt(self, BZ_FINISH, &ignored);
/*                     assert (zret == BZ_STREAM_END); */        /* stream will be complete */
/*                 } */

                zret = BZ2_bzCompressEnd(&self->strm);   /* clean up */

                self->completed = true;
            }
            else if (self->dad.read_enabled)
            {
                zret = BZ2_bzDecompressEnd (&self->strm);
            }
            else
            {
                rc = RC (rcFS, rcFile, rcDestroying, rcSelf, rcInvalid);
                LOGERR (klogInt, orc, "corrupt object "
                        "closing bzip file object");
            }
            if (zret != BZ_OK)
            {
                orc = RC (rcFS, rcFile, rcDestroying, rcParam, rcInvalid);
                LOGERR (klogInt, orc, "bad parameters - coding error on "
                        "closing bzip file object");
                if (rc == 0)
                    rc = orc;
            }

            orc = KFileRelease (self->file);
            if (rc == 0)
                rc = orc;
        }
        free (self);
    }
    return rc;
}
开发者ID:mariux,项目名称:sratoolkit,代码行数:58,代码来源:bzip.c


示例3: BZ2Decompress

String BZ2Decompress(String s, Gate2<int, int> progress)
{
	if(s.IsEmpty())
		return s;
	bz_stream z;
	Zero(z);
	z.bzalloc = bzalloc_new;
	z.bzfree = bzfree_new;
	z.opaque = 0;
	if(BZ2_bzDecompressInit(&z, 0, 0) != BZ_OK)
		return String::GetVoid();
	int buf_size = minmax(s.GetLength() / 2, 1024, 65536);
	Buffer<char> output(buf_size);
	z.next_in = (char *)s.Begin();
	z.avail_in = s.GetLength();
	z.next_out = output;
	z.avail_out = buf_size;

	String out;
	while(BZ2_bzDecompress(&z) == BZ_OK)
	{
		if(z.avail_out == (dword)buf_size)
		{ // no output generated - assume error
			BZ2_bzDecompressEnd(&z);
			return String::GetVoid();
		}
		out.Cat(output, buf_size - z.avail_out);
		z.next_out = output;
		z.avail_out = buf_size;
		if(progress((int)(uintptr_t)((const char *)z.next_in - ~s), s.GetLength()))
		{
			BZ2_bzDecompressEnd(&z);
			return String::GetVoid();
		}
	}
	if(z.avail_out < (unsigned)buf_size)
		out.Cat(output, buf_size - z.avail_out);

	BZ2_bzDecompressEnd(&z);

	return out;
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:42,代码来源:bz2upp.cpp


示例4: camlzip_bzDecompressEnd

value camlzip_bzDecompressEnd(value stream) {
#ifdef USE_BZIP2
  int err;
  if ((err = BZ2_bzDecompressEnd(BZStream_val(stream))) != BZ_OK)
    camlzip_bzerror("Bzlib.decompressEnd", err);
  free(BZStream_val(stream));
#else
  failwith("Bzip2 compression not supported");
#endif
  return Val_unit;
}
开发者ID:ygrek,项目名称:mldonkey,代码行数:11,代码来源:zlibstubs.c


示例5: gst_bz2dec_decompress_end

static void
gst_bz2dec_decompress_end (GstBz2dec * b)
{
  g_return_if_fail (GST_IS_BZ2DEC (b));

  if (b->ready) {
    BZ2_bzDecompressEnd (&b->stream);
    memset (&b->stream, 0, sizeof (b->stream));
    b->ready = FALSE;
  }
}
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:11,代码来源:gstbz2dec.c


示例6: free

void MemoryDecompressor::Clear(void)
{
	if (output)
	{
		free(output);
		output=0;
	}

	if (streamInited)
		BZ2_bzDecompressEnd( &stream );
}
开发者ID:0521guo,项目名称:RakNet,代码行数:11,代码来源:MemoryCompressor.cpp


示例7: memset

int
ArchiveReader::ExtractItemToStream(const MarItem *item, FILE *fp)
{
  /* decompress the data chunk by chunk */

  bz_stream strm;
  int offset, inlen, outlen, ret = OK;

  memset(&strm, 0, sizeof(strm));
  if (BZ2_bzDecompressInit(&strm, 0, 0) != BZ_OK)
    return UNEXPECTED_BZIP_ERROR;

  offset = 0;
  for (;;) {
    if (!item->length) {
      ret = UNEXPECTED_MAR_ERROR;
      break;
    }

    if (offset < (int) item->length && strm.avail_in == 0) {
      inlen = mar_read(mArchive, item, offset, inbuf, inbuf_size);
      if (inlen <= 0)
        return READ_ERROR;
      offset += inlen;
      strm.next_in = inbuf;
      strm.avail_in = inlen;
    }

    strm.next_out = outbuf;
    strm.avail_out = outbuf_size;

    ret = BZ2_bzDecompress(&strm);
    if (ret != BZ_OK && ret != BZ_STREAM_END) {
      ret = UNEXPECTED_BZIP_ERROR;
      break;
    }

    outlen = outbuf_size - strm.avail_out;
    if (outlen) {
      if (fwrite(outbuf, outlen, 1, fp) != 1) {
        ret = WRITE_ERROR_EXTRACT;
        break;
      }
    }

    if (ret == BZ_STREAM_END) {
      ret = OK;
      break;
    }
  }

  BZ2_bzDecompressEnd(&strm);
  return ret;
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:54,代码来源:archivereader.cpp


示例8: php_bz2_decompress_dtor

static void php_bz2_decompress_dtor(php_stream_filter *thisfilter)
{
	if (thisfilter && Z_PTR(thisfilter->abstract)) {
		php_bz2_filter_data *data = Z_PTR(thisfilter->abstract);
		if (data->status == PHP_BZ2_RUNNING) {
			BZ2_bzDecompressEnd(&(data->strm));
		}
		pefree(data->inbuf, data->persistent);
		pefree(data->outbuf, data->persistent);
		pefree(data, data->persistent);
	}
}
开发者ID:13572293130,项目名称:php-src,代码行数:12,代码来源:bz2_filter.c


示例9: i_stream_bzlib_close

static void i_stream_bzlib_close(struct iostream_private *stream,
				 bool close_parent)
{
	struct bzlib_istream *zstream = (struct bzlib_istream *)stream;

	if (!zstream->zs_closed) {
		(void)BZ2_bzDecompressEnd(&zstream->zs);
		zstream->zs_closed = TRUE;
	}
	if (close_parent)
		i_stream_close(zstream->istream.parent);
}
开发者ID:dhultin,项目名称:dovecot-pop-uidl-proxy,代码行数:12,代码来源:istream-bzlib.c


示例10: throw

void CryptoManager::decodeBZ2(const u_int8_t* is, size_t sz, string& os) throw (CryptoException) {
	bz_stream bs = { 0 };

	if(BZ2_bzDecompressInit(&bs, 0, 0) != BZ_OK)
		throw(CryptoException(STRING(DECOMPRESSION_ERROR)));

	// We assume that the files aren't compressed more than 2:1...if they are it'll work anyway,
	// but we'll have to do multiple passes...
	size_t bufsize = 2*sz;
	AutoArray<char> buf(bufsize);
	
	bs.avail_in = sz;
	bs.avail_out = bufsize;
	bs.next_in = (char*)(const_cast<u_int8_t*>(is));
	bs.next_out = buf;

	int err;

	os.clear();
	
	while((err = BZ2_bzDecompress(&bs)) == BZ_OK) { 
		if (bs.avail_in == 0 && bs.avail_out > 0) { // error: BZ_UNEXPECTED_EOF 
			BZ2_bzDecompressEnd(&bs); 
			throw CryptoException(STRING(DECOMPRESSION_ERROR)); 
		} 
		os.append(buf, bufsize-bs.avail_out); 
		bs.avail_out = bufsize; 
		bs.next_out = buf; 
	} 

	if(err == BZ_STREAM_END)
		os.append(buf, bufsize-bs.avail_out);
	
	BZ2_bzDecompressEnd(&bs);

	if(err < 0) {
		// This was a real error
		throw CryptoException(STRING(DECOMPRESSION_ERROR));	
	}
}
开发者ID:BackupTheBerlios,项目名称:linuxdcpp,代码行数:40,代码来源:CryptoManager.cpp


示例11: HHVM_FUNCTION

Variant HHVM_FUNCTION(bzdecompress, const String& source, int small /* = 0 */) {
  int source_len = source.length();
  int error;
  uint64_t size = 0;
  bz_stream bzs;

  bzs.bzalloc = nullptr;
  bzs.bzfree = nullptr;

  if (BZ2_bzDecompressInit(&bzs, 0, small) != BZ_OK) {
    return false;
  }

  bzs.next_in = (char *) source.c_str();
  bzs.avail_in = source_len;

  // in most cases bz2 offers at least 2:1 compression, so we use that as our
  // base
  bzs.avail_out = source_len * 2;
  String ret(bzs.avail_out, ReserveString);
  bzs.next_out = ret.bufferSlice().ptr;

  while ((error = BZ2_bzDecompress(&bzs)) == BZ_OK && bzs.avail_in > 0) {
    /* compression is better then 2:1, need to allocate more memory */
    bzs.avail_out = source_len;
    size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
    ret.setSize(size); // needs to be null-terminated before the reserve call
    bzs.next_out = ret.reserve(size + bzs.avail_out).ptr + size;
  }

  if (error == BZ_STREAM_END || error == BZ_OK) {
    size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
    BZ2_bzDecompressEnd(&bzs);
    ret.shrink(size);
    return ret;
  } else {
    BZ2_bzDecompressEnd(&bzs);
    return error;
  }
}
开发者ID:hmic,项目名称:hhvm,代码行数:40,代码来源:ext_bz2.cpp


示例12: squash_bz2_stream_destroy

static void
squash_bz2_stream_destroy (void* stream) {
  switch (((SquashStream*) stream)->stream_type) {
    case SQUASH_STREAM_COMPRESS:
      BZ2_bzCompressEnd (&(((SquashBZ2Stream*) stream)->stream));
      break;
    case SQUASH_STREAM_DECOMPRESS:
      BZ2_bzDecompressEnd (&(((SquashBZ2Stream*) stream)->stream));
      break;
  }

  squash_stream_destroy (stream);
}
开发者ID:anthrotype,项目名称:squash,代码行数:13,代码来源:squash-bzip2.c


示例13: BZ_API

/*---------------------------------------------------*/
void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
{
   bzFile* bzf = (bzFile*)b;

   BZ_SETERR(BZ_OK);
   if (bzf == NULL)
      { BZ_SETERR(BZ_OK); return; };

   if (bzf->writing)
      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };

   if (bzf->initialisedOk)
      (void)BZ2_bzDecompressEnd ( &(bzf->strm) );
   free ( bzf );
}
开发者ID:Requaos,项目名称:harvey,代码行数:16,代码来源:bzread.c


示例14: BZ2_bzDecompressEnd

// Close file stream
bool FXBZFileStream::close(){
  if(dir){
    if(dir==FXStreamLoad){
      FXFileStream::close();
      BZ2_bzDecompressEnd(&bz->stream);
      }
    else{
      ac=BZ_FINISH;
      FXFileStream::close();
      BZ2_bzCompressEnd(&bz->stream);
      }
    FXFREE(&bz);
    return true;
    }
  return false;
  }
开发者ID:gfphoenix,项目名称:tsiu,代码行数:17,代码来源:FXBZFileStream.cpp


示例15: tear_down_mode

static tsf_bool_t tear_down_mode(tsf_adpt_rdr_t *reader,
				 uint8_t **spillover,
				 uint32_t *spillover_len) {
    tsf_bool_t stillok=tsf_true;
    if (reader->mode==TSF_ZIP_ZLIB) {
#ifdef HAVE_ZLIB
	inflateEnd(Cz(reader));
#endif
    } else if (reader->mode==TSF_ZIP_BZIP2) {
#ifdef HAVE_BZIP2
	BZ2_bzDecompressEnd(Cbz(reader));
#endif
    }
    if (reader->mode==TSF_ZIP_ZLIB ||
	reader->mode==TSF_ZIP_BZIP2) {
	free(reader->stream);
	if (spillover!=NULL && spillover_len!=NULL) {
	    *spillover=malloc(reader->abstract.avail_in);
	    if (*spillover==NULL) {
		tsf_set_errno("Could not allocate spillover buffer");
		stillok=tsf_false;
	    } else {
		*spillover_len=reader->abstract.avail_in;
		memcpy(*spillover,reader->abstract.next_in,*spillover_len);
	    }
	}
    } else if (reader->mode==TSF_ZIP_NONE) {
	if (spillover!=NULL && spillover_len!=NULL) {
	    *spillover=malloc(reader->puti-reader->geti);
	    if (*spillover==NULL) {
		tsf_set_errno("Could not allocate spillover buffer");
		stillok=tsf_false;
	    } else {
		*spillover_len=reader->puti-reader->geti;
		memcpy(*spillover,reader->buf+reader->geti,*spillover_len);
	    }
	}
    }
    if (reader->mode!=TSF_ZIP_UNKNOWN) {
	free(reader->buf);
    }
    reader->stream=NULL;
    reader->buf=NULL;
    reader->buf_size=0;
    reader->mode=TSF_ZIP_UNKNOWN;
    return stillok;
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:47,代码来源:tsf_adaptive_reader.c


示例16: i_stream_bzlib_reset

static void i_stream_bzlib_reset(struct bzlib_istream *zstream)
{
	struct istream_private *stream = &zstream->istream;

	i_stream_seek(stream->parent, stream->parent_start_offset);
	zstream->eof_offset = (uoff_t)-1;
	zstream->zs.next_in = NULL;
	zstream->zs.avail_in = 0;

	stream->parent_expected_offset = stream->parent_start_offset;
	stream->skip = stream->pos = 0;
	stream->istream.v_offset = 0;
	zstream->high_pos = 0;

	(void)BZ2_bzDecompressEnd(&zstream->zs);
	i_stream_bzlib_init(zstream);
}
开发者ID:dhultin,项目名称:dovecot-pop-uidl-proxy,代码行数:17,代码来源:istream-bzlib.c


示例17: do_bunzip2

void
do_bunzip2 (void)
{
  int result;
  bz_stream strm;

  strm.bzalloc = NULL;
  strm.bzfree = NULL;
  strm.opaque = NULL;

  strm.avail_in  = 0;
  strm.next_out = outbuf;
  strm.avail_out = OUTBUFSIZ;

  result = BZ2_bzDecompressInit (&strm, 0, SMALL_MODE);

  while (result == BZ_OK)
  {
    if (strm.avail_in == 0)
    {
      strm.next_in = inbuf;
      strm.avail_in  = (*unzip_read)(strm.next_in, INBUFSIZ);

      if (strm.avail_in == 0)
        break;
    }

    result = BZ2_bzDecompress (&strm);

    if ((result != BZ_OK) && (result != BZ_STREAM_END))
      break;

    if ((strm.avail_out == 0) || (result == BZ_STREAM_END))
    {
      (*unzip_write) (outbuf, OUTBUFSIZ - strm.avail_out);
      strm.next_out = outbuf;
      strm.avail_out = OUTBUFSIZ;
    }
  }

  BZ2_bzDecompressEnd (&strm);

  if (result != BZ_STREAM_END)
    (*unzip_error) (NULL);
}
开发者ID:GNUHurdTR,项目名称:hurd,代码行数:45,代码来源:do-bunzip2.c


示例18: hb_bz2UncompressedSize

static HB_SIZE hb_bz2UncompressedSize( const char * szSrc, HB_SIZE nLen,
                                       int * piResult )
{
   char      buffer[ 1024 ];
   bz_stream stream;
   HB_SIZE   nDest = 0;

   memset( &stream, 0, sizeof( stream ) );

   stream.next_in  = ( char * ) szSrc;
   stream.avail_in = ( unsigned int ) nLen;

   stream.bzalloc = hb_bz2Alloc;
   stream.bzfree  = hb_bz2Free;
/* stream.opaque  = NULL; */

   *piResult = BZ2_bzDecompressInit( &stream, 0, 0 );
   if( *piResult == BZ_OK )
   {
      do
      {
         stream.next_out  = buffer;
         stream.avail_out = sizeof( buffer );
         *piResult        = BZ2_bzDecompress( &stream );
      }
      while( *piResult == BZ_OK );

      if( *piResult == BZ_STREAM_END )
      {
         *piResult = BZ_OK;
#if HB_SIZE_MAX <= UINT_MAX
         if( stream.total_out_hi32 != 0 )
            *piResult = BZ_MEM_ERROR;
         else
            nDest = ( HB_SIZE ) stream.total_out_lo32;
#else
         nDest = ( ( HB_SIZE ) stream.total_out_hi32 << 32 ) |
                 stream.total_out_lo32;
#endif
      }
      BZ2_bzDecompressEnd( &stream );
   }

   return nDest;
}
开发者ID:Andygon,项目名称:core,代码行数:45,代码来源:core.c


示例19: end

static bool
end(void *ud) {
    struct ctx *ctx = (struct ctx *)ud;
    int err;

    if (ctx->compress) {
	err = BZ2_bzCompressEnd(&ctx->zstr);
    }
    else {
	err = BZ2_bzDecompressEnd(&ctx->zstr);
    }

    if (err != BZ_OK) {
	zip_error_set(ctx->error, map_error(err), 0);
	return false;
    }

    return true;
}
开发者ID:newser,项目名称:TitanSDK,代码行数:19,代码来源:zip_algorithm_bzip2.c


示例20: import_compress_free

void import_compress_free(ImportCompress *c) {
        assert(c);

        if (c->type == IMPORT_COMPRESS_XZ)
                lzma_end(&c->xz);
        else if (c->type == IMPORT_COMPRESS_GZIP) {
                if (c->encoding)
                        deflateEnd(&c->gzip);
                else
                        inflateEnd(&c->gzip);
        } else if (c->type == IMPORT_COMPRESS_BZIP2) {
                if (c->encoding)
                        BZ2_bzCompressEnd(&c->bzip2);
                else
                        BZ2_bzDecompressEnd(&c->bzip2);
        }

        c->type = IMPORT_COMPRESS_UNKNOWN;
}
开发者ID:AOSC-Dev,项目名称:systemd,代码行数:19,代码来源:import-compress.c



注:本文中的BZ2_bzDecompressEnd函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BZ2_bzDecompressInit函数代码示例发布时间:2022-05-30
下一篇:
C++ BZ2_bzDecompress函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap