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

C++ BZ2_bzDecompress函数代码示例

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

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



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

示例1: while

size_t wxBZipInputStream::OnSysRead(void* buffer, size_t bufsize)
{
    bz_stream* hZip = (bz_stream*)m_hZip;

	hZip->next_out = (char*)buffer;
	hZip->avail_out = bufsize;

	while (hZip->avail_out != 0)
	{
		if (m_nBufferPos == 0 || m_nBufferPos == WXBZBS)
		{
			ReadRaw(m_pBuffer, WXBZBS);
			
            m_nBufferPos = 0;
			hZip->next_in = m_pBuffer;
			hZip->avail_in = WXBZBS;

            if (m_parent_i_stream->LastRead() != WXBZBS)
			{
                // Full amount not read, so do a last
                // minute tidy up and decompress what is left
				hZip->avail_in = m_parent_i_stream->LastRead();

				int nRet = BZ2_bzDecompress(hZip);

				if (nRet == BZ_OK || nRet == BZ_STREAM_END)
					return bufsize - hZip->avail_out;
				else
					return 0;
			}
		}

        // Buffer full, decompress some bytes
        hZip->next_in = &m_pBuffer[m_nBufferPos];
		hZip->avail_in = WXBZBS - m_nBufferPos;

		int nRet = BZ2_bzDecompress(hZip);

		if (nRet == BZ_OK)	
		{
			m_nBufferPos = WXBZBS - hZip->avail_in;
		}
		else if(nRet == BZ_STREAM_END)
			return bufsize - hZip->avail_out;
		else
			return 0;	
	}
 
	return bufsize - hZip->avail_out;	
}
开发者ID:BlitzMaxModules,项目名称:wx.mod,代码行数:50,代码来源:bzipstream.cpp


示例2: while

size_t wxBZipInputStream::OnSysRead(void* buffer, size_t bufsize)
{
	wxInt32 nRead = 0;

	((bz_stream*&)hZip)->next_out = &(((char*&)buffer)[nRead]);
	((bz_stream*&)hZip)->avail_out = bufsize - nRead;

	while (((bz_stream*&)hZip)->avail_out != 0)
	{
		//wxMessageBox(wxString::Format("%i %i", nRead, ((bz_stream*&)hZip)->avail_out));

		if (nBufferPos == 0 || nBufferPos == WXBZBS)
		{
			ReadRaw(pBuffer, WXBZBS);
			nBufferPos = 0;
			((bz_stream*&)hZip)->next_in = &pBuffer[nBufferPos];
			((bz_stream*&)hZip)->avail_in = WXBZBS - nBufferPos;
			if (m_parent_i_stream->LastRead() != WXBZBS)
			{
				((bz_stream*&)hZip)->avail_in = m_parent_i_stream->LastRead();

				int nRet = BZ2_bzDecompress((bz_stream*&)hZip);

				if (nRet == BZ_OK || nRet == BZ_STREAM_END)
					return bufsize - ((bz_stream*&)hZip)->avail_out;
				else
					return 0;
			}
		}
		((bz_stream*&)hZip)->next_in = &pBuffer[nBufferPos];
		((bz_stream*&)hZip)->avail_in = WXBZBS - nBufferPos;

		int nRet = BZ2_bzDecompress((bz_stream*&)hZip);

		if (nRet == BZ_OK)	
		{
			nBufferPos += -(nRead - (
			nRead += (WXBZBS - nBufferPos - ((bz_stream*&)hZip)->avail_in)
			));
		}
		else if(nRet == BZ_STREAM_END)
			return bufsize - ((bz_stream*&)hZip)->avail_out;
		else
			return 0;	
	}
 
	return bufsize - ((bz_stream*&)hZip)->avail_out;	
}
开发者ID:DowerChest,项目名称:codeblocks,代码行数:48,代码来源:bzipstream.cpp


示例3: bzf_read

static int 
bzf_read(struct open_file *f, void *buf, size_t size, size_t *resid)
{
    struct bz_file	*bzf = (struct bz_file *)f->f_fsdata;
    int			error;

    bzf->bzf_bzstream.next_out = buf;			/* where and how much */
    bzf->bzf_bzstream.avail_out = size;

    while (bzf->bzf_bzstream.avail_out && bzf->bzf_endseen == 0) {
	if ((bzf->bzf_bzstream.avail_in == 0) && (bzf_fill(bzf) == -1)) {
	    printf("bzf_read: fill error\n");
	    return(EIO);
	}
	if (bzf->bzf_bzstream.avail_in == 0) {		/* oops, unexpected EOF */
	    printf("bzf_read: unexpected EOF\n");
	    if (bzf->bzf_bzstream.avail_out == size)
		return(EIO);
	    break;
	}

	error = BZ2_bzDecompress(&bzf->bzf_bzstream);	/* decompression pass */
	if (error == BZ_STREAM_END) {			/* EOF, all done */
	    bzf->bzf_endseen = 1;
	    break;
	}
	if (error != BZ_OK) {				/* argh, decompression error */
	    printf("bzf_read: BZ2_bzDecompress returned %d\n", error);
	    return(EIO);
	}
    }
    if (resid != NULL)
	*resid = bzf->bzf_bzstream.avail_out;
    return(0);
}
开发者ID:Fneufneu,项目名称:zfs_read,代码行数:35,代码来源:bzipfs.c


示例4: FXASSERT

// Load from file
FXuval FXBZFileStream::readBuffer(FXuval){
  register FXival n; int bzerror;
  if(dir!=FXStreamLoad){fxerror("FXBZFileStream::readBuffer: wrong stream direction.\n");}
  FXASSERT(begptr<=rdptr);
  FXASSERT(rdptr<=wrptr);
  FXASSERT(wrptr<=endptr);
  if(rdptr<wrptr){memmove(begptr,rdptr,wrptr-rdptr);}
  wrptr=begptr+(wrptr-rdptr);
  rdptr=begptr;
  while(wrptr<endptr){
//    n=file.readBlock(bz->buffer,BUFFERSIZE);
//    if(n<=0) break;
//    bz->stream.next_in=bz->buffer;
//    bz->stream.avail_in=n;
    if(bz->stream.avail_in<=0){ // get more input if buffer is empty
      n=file.readBlock(bz->buffer,BUFFERSIZE);
      if(n<0) break;
      bz->stream.next_in=bz->buffer;
      bz->stream.avail_in=n;
      }
    bz->stream.next_out=(char*)wrptr;
    bz->stream.avail_out=endptr-wrptr;
    bzerror=BZ2_bzDecompress(&bz->stream);
//    if(bzerror!=BZ_OK) break;
    if(bzerror<0) break;  // break on error condition
    wrptr=(FXuchar*)bz->stream.next_out;
    if(bzerror==BZ_STREAM_END) break;
    }
  return wrptr-rdptr;
  }
开发者ID:gfphoenix,项目名称:tsiu,代码行数:31,代码来源:FXBZFileStream.cpp


示例5: BZ2_bzDecompress

long FileReaderBZ2::Read (void *buffer, long len)
{
	int err;

	Stream.next_out = (char *)buffer;
	Stream.avail_out = len;

	do
	{
		err = BZ2_bzDecompress(&Stream);
		if (Stream.avail_in == 0 && !SawEOF)
		{
			FillBuffer ();
		}
	} while (err == BZ_OK && Stream.avail_out != 0);

	if (err != BZ_OK && err != BZ_STREAM_END)
	{
		I_Error ("Corrupt bzip2 stream");
	}

	if (Stream.avail_out != 0)
	{
		I_Error ("Ran out of data in bzip2 stream");
	}

	return len - Stream.avail_out;
}
开发者ID:loismustdie555,项目名称:GZDoom-GPL,代码行数:28,代码来源:files.cpp


示例6: read

    std::string read() final {
        std::string output;

        if (m_buffer) {
            const size_t buffer_size = 10240;
            output.resize(buffer_size);
            m_bzstream.next_out = const_cast<char*>(output.data());
            m_bzstream.avail_out = buffer_size;
            int result = BZ2_bzDecompress(&m_bzstream);

            if (result != BZ_OK) {
                m_buffer = nullptr;
                m_buffer_size = 0;
            }

            if (result != BZ_OK && result != BZ_STREAM_END) {
                std::string message("bzip2 error: decompress failed: ");
                throw bzip2_error(message, result);
            }

            output.resize(static_cast<unsigned long>(m_bzstream.next_out - output.data()));
        }

        return output;
    }
开发者ID:Project-OSRM,项目名称:osrm-backend,代码行数:25,代码来源:bzip2_compression.hpp


示例7: 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


示例8: camlzip_bzDecompress

value camlzip_bzDecompress(value vzs, value srcbuf, value srcpos, value srclen,
			   value dstbuf, value dstpos, value dstlen)
{
#ifdef USE_BZIP2
  bz_stream * zs = BZStream_val(vzs);
  int retcode;
  long used_in, used_out;
  value res;

  zs->next_in = &Byte(srcbuf, Long_val(srcpos));
  zs->avail_in = Long_val(srclen);
  zs->next_out = &Byte(dstbuf, Long_val(dstpos));
  zs->avail_out = Long_val(dstlen);
  retcode = BZ2_bzDecompress(zs);
  if (retcode < 0)
    camlzip_bzerror("Bzlib.decompress", retcode);
  used_in = Long_val(srclen) - zs->avail_in;
  used_out = Long_val(dstlen) - zs->avail_out;
  zs->next_in = NULL;           /* not required, but cleaner */
  zs->next_out = NULL;          /* (avoid dangling pointers into Caml heap) */
  res = alloc_small(3, 0);
  Field(res, 0) = Val_bool(retcode == BZ_STREAM_END);
  Field(res, 1) = Val_int(used_in);
  Field(res, 2) = Val_int(used_out);
  return res;
#else
  failwith("Bzip2 compression not supported");
#endif
}
开发者ID:ygrek,项目名称:mldonkey,代码行数:29,代码来源:zlibstubs.c


示例9: bz2_mem_read

// xmlInputReadCallback
static int bz2_mem_read(struct bz2_mem *bzmem, char *buffer, int len)
{
	if (len < 1) {
		// ensure that at least one byte of output space is available at each BZ2_bzDecompress call.
		return 0;
	}
	if (bzmem->eof) {
		// If we run BZ2_bzDecompress on processed buffer we will get -1 (SEQUENCE_ERROR)
		return 0;
	}
	// next_out should point to a buffer in which the uncompressed output is to be placed
	bzmem->stream->next_out = buffer;
	// with avail_out indicating how much output space is available.
	bzmem->stream->avail_out = len;
	int bzerror = BZ2_bzDecompress(bzmem->stream);
	if (bzerror == BZ_STREAM_END) {
		bzmem->eof = true;
	}
	if (bzerror == BZ_OK || bzerror == BZ_STREAM_END)
		return (len - bzmem->stream->avail_out);
	else {
		oscap_seterr(OSCAP_EFAMILY_OSCAP, "Could not read from bz_stream: BZ2_bzDecompress returns %d", bzerror);
		return -1;
	}
}
开发者ID:AxelNennker,项目名称:openscap,代码行数:26,代码来源:bz2.c


示例10: 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


示例11: BZ2_bzDecompressEnd

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


示例12: BZ_API

/*---------------------------------------------------*/
int BZ_API(BZ2_bzRead) 
           ( int*    bzerror, 
             BZFILE* b, 
             void*   buf, 
             int     len )
{
   Int32   n, ret;
   bzFile* bzf = (bzFile*)b;

   BZ_SETERR(BZ_OK);

   if (bzf == NULL || buf == NULL || len < 0)
      { BZ_SETERR(BZ_PARAM_ERROR); return 0; };

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

   if (len == 0)
      { BZ_SETERR(BZ_OK); return 0; };

   bzf->strm.avail_out = len;
   bzf->strm.next_out = buf;

   while (True) {

      if (ferror(bzf->handle)) 
         { BZ_SETERR(BZ_IO_ERROR); return 0; };

      if (bzf->strm.avail_in == 0 && !bz_feof(bzf->handle)) {
         n = fread ( bzf->buf, sizeof(UChar), 
                     BZ_MAX_UNUSED, bzf->handle );
         if (ferror(bzf->handle))
            { BZ_SETERR(BZ_IO_ERROR); return 0; };
         bzf->bufN = n;
         bzf->strm.avail_in = bzf->bufN;
         bzf->strm.next_in = bzf->buf;
      }

      ret = BZ2_bzDecompress ( &(bzf->strm) );

      if (ret != BZ_OK && ret != BZ_STREAM_END)
         { BZ_SETERR(ret); return 0; };

      if (ret == BZ_OK && bz_feof(bzf->handle) && 
          bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
         { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };

      if (ret == BZ_STREAM_END)
         { BZ_SETERR(BZ_STREAM_END);
           return len - bzf->strm.avail_out; };
      if (bzf->strm.avail_out == 0)
         { BZ_SETERR(BZ_OK); return len; };
      
   }

}
开发者ID:Requaos,项目名称:harvey,代码行数:57,代码来源:bzread.c


示例13: 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


示例14: 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


示例15: do_uncompress

static int
do_uncompress( compress_filter_context_t *zfx, bz_stream *bzs,
	       IOBUF a, size_t *ret_len )
{
  int zrc;
  int rc=0;
  size_t n;
  int nread, count;
  int refill = !bzs->avail_in;

  if( DBG_FILTER )
    log_debug("begin bzDecompress: avail_in=%u, avail_out=%u, inbuf=%u\n",
	      (unsigned)bzs->avail_in, (unsigned)bzs->avail_out,
	      (unsigned)zfx->inbufsize );
  do
    {
      if( bzs->avail_in < zfx->inbufsize && refill )
	{
	  n = bzs->avail_in;
	  if( !n )
	    bzs->next_in = zfx->inbuf;
	  count = zfx->inbufsize - n;
	  nread = iobuf_read( a, zfx->inbuf + n, count );
	  if( nread == -1 ) nread = 0;
	  n += nread;
	  bzs->avail_in = n;
	}

      refill = 1;

      if( DBG_FILTER )
	log_debug("enter bzDecompress: avail_in=%u, avail_out=%u\n",
		  (unsigned)bzs->avail_in, (unsigned)bzs->avail_out);

      zrc=BZ2_bzDecompress(bzs);
      if( DBG_FILTER )
	log_debug("leave bzDecompress: avail_in=%u, avail_out=%u, zrc=%d\n",
		  (unsigned)bzs->avail_in, (unsigned)bzs->avail_out, zrc);
      if( zrc == BZ_STREAM_END )
	rc = -1; /* eof */
      else if( zrc != BZ_OK && zrc != BZ_PARAM_ERROR )
	log_fatal("bz2lib inflate problem: rc=%d\n", zrc );
    }
  while( bzs->avail_out && zrc != BZ_STREAM_END && zrc != BZ_PARAM_ERROR );

  /* I'm not completely happy with the two uses of BZ_PARAM_ERROR
     here.  The corresponding zlib function is Z_BUF_ERROR, which
     covers a narrower scope than BZ_PARAM_ERROR. -dshaw */

  *ret_len = zfx->outbufsize - bzs->avail_out;
  if( DBG_FILTER )
    log_debug("do_uncompress: returning %u bytes\n", (unsigned)*ret_len );
  return rc;
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-gnupg,代码行数:54,代码来源:compress-bz2.c


示例16: 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


示例17: BZ_API

/*---------------------------------------------------*/
int BZ_API(BZ2_bzBuffToBuffDecompress) 
                           ( char*         dest, 
                             unsigned int* destLen,
                             char*         source, 
                             unsigned int  sourceLen,
                             int           small,
                             int           verbosity )
{
   bz_stream strm;
   int ret;

   if (dest == NULL || destLen == NULL || 
       source == NULL ||
       (small != 0 && small != 1) ||
       verbosity < 0 || verbosity > 4) 
          return BZ_PARAM_ERROR;

   strm.bzalloc = NULL;
   strm.bzfree = NULL;
   strm.opaque = NULL;
   ret = BZ2_bzDecompressInit ( &strm, verbosity, small );
   if (ret != BZ_OK) return ret;

   strm.next_in = source;
   strm.next_out = dest;
   strm.avail_in = sourceLen;
   strm.avail_out = *destLen;

   ret = BZ2_bzDecompress ( &strm );
   if (ret == BZ_OK) goto output_overflow_or_eof;
   if (ret != BZ_STREAM_END) goto errhandler;

   /* normal termination */
   *destLen -= strm.avail_out;
   BZ2_bzDecompressEnd ( &strm );
   return BZ_OK;

   output_overflow_or_eof:
   if (strm.avail_out > 0) {
      BZ2_bzDecompressEnd ( &strm );
      return BZ_UNEXPECTED_EOF;
   } else {
      BZ2_bzDecompressEnd ( &strm );
      return BZ_OUTBUFF_FULL;
   };      

   errhandler:
   BZ2_bzDecompressEnd ( &strm );
   return ret; 
}
开发者ID:00001,项目名称:plan9port,代码行数:51,代码来源:buffdecompress.c


示例18: bzRead

size_t bzRead(int *bzerr, BZStream* stream, unsigned char* out, size_t len) {
	size_t toRead;
	size_t haveRead;
	size_t total;
	
	total = len;
	
	*bzerr = BZ_OK;
	
	while(total > 0) {
		if(!stream->ended) {
			memmove(stream->inBuffer, stream->bz2.next_in, stream->bz2.avail_in);
			stream->file->seek(stream->file, stream->offset);
			haveRead = stream->file->read(stream->file, stream->inBuffer + stream->bz2.avail_in, stream->bufferLen - stream->bz2.avail_in);
			stream->offset += haveRead;
			stream->bz2.avail_in += haveRead;
			stream->bz2.next_in = (char*) stream->inBuffer;
			
			*bzerr = BZ2_bzDecompress(&(stream->bz2));
			
			if(*bzerr == BZ_STREAM_END) {
				stream->ended = TRUE;
			} else {
				if(*bzerr != BZ_OK) {
					return 0;
				}
			}
		}
		
		if(total > (stream->bufferLen - stream->bz2.avail_out)) {
			toRead = stream->bufferLen - stream->bz2.avail_out;
		} else {
			toRead = total;
		}
		
		memcpy(out, stream->outBuffer, toRead);
		memmove(stream->outBuffer, stream->outBuffer + toRead, stream->bufferLen - toRead);
		stream->bz2.next_out -= toRead;
		stream->bz2.avail_out += toRead;
		out += toRead;
		total -= toRead;
		
		if(total > 0 && stream->ended) {
			return (len - total);
		}
	}
	
	return len;
}
开发者ID:1butler1,项目名称:xpwn,代码行数:49,代码来源:bspatch.c


示例19: bz_read

static off_t bz_read(io_t *io, void *buffer, off_t len)
{
	if (DATA(io)->err == ERR_EOF)
		return 0; /* EOF */
	if (DATA(io)->err == ERR_ERROR) {
		errno=EIO;
		return -1; /* ERROR! */
	}

	DATA(io)->strm.avail_out = len;
	DATA(io)->strm.next_out = buffer;

	while (DATA(io)->err == ERR_OK && DATA(io)->strm.avail_out > 0) {
		while (DATA(io)->strm.avail_in <= 0) {
			int bytes_read = wandio_read(DATA(io)->parent, 
				DATA(io)->inbuff,
				sizeof(DATA(io)->inbuff));
			if (bytes_read == 0) /* EOF */
				return len-DATA(io)->strm.avail_out;
			if (bytes_read < 0) { /* Error */
				/* Errno should already be set */
				DATA(io)->err = ERR_ERROR;
				/* Return how much data we managed to read ok */
				if (DATA(io)->strm.avail_out != (uint32_t)len) {
					return len-DATA(io)->strm.avail_out;
				}
				/* Now return error */
				return -1;
			}
			DATA(io)->strm.next_in = DATA(io)->inbuff;
			DATA(io)->strm.avail_in = bytes_read;
		}
		/* Decompress some data into the output buffer */
		int err=BZ2_bzDecompress(&DATA(io)->strm);
		switch(err) {
			case BZ_OK:
				DATA(io)->err = ERR_OK;
				break;
			case BZ_STREAM_END:
				DATA(io)->err = ERR_EOF;
				break;
			default:
				errno=EIO;
				DATA(io)->err = ERR_ERROR;
		}
	}
	/* Return the number of bytes decompressed */
	return len-DATA(io)->strm.avail_out;
}
开发者ID:rsanger,项目名称:libtrace,代码行数:49,代码来源:ior-bzip.c


示例20: FillBuffer

int FillBuffer(unsigned char* buffer, int size, bz_stream* stream) {
    stream->next_out = (char*)buffer;
    stream->avail_out = size;
    while (stream->avail_out > 0) {
        int bzerr = BZ2_bzDecompress(stream);
        if (bzerr != BZ_OK && bzerr != BZ_STREAM_END) {
            printf("bz error %d decompressing\n", bzerr);
            return -1;
        }
        if (stream->avail_out > 0) {
            printf("need %d more bytes\n", stream->avail_out);
        }
    }
    return 0;
}
开发者ID:APAR1992,项目名称:cwm_recovery_dual_language-1,代码行数:15,代码来源:bspatch.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ BZ2_bzDecompressEnd函数代码示例发布时间:2022-05-30
下一篇:
C++ BZ2_bzBuffToBuffDecompress函数代码示例发布时间: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