當前位置: 首頁>>代碼示例>>C++>>正文


C++ BZ2_bzDecompressEnd函數代碼示例

本文整理匯總了C++中BZ2_bzDecompressEnd函數的典型用法代碼示例。如果您正苦於以下問題:C++ BZ2_bzDecompressEnd函數的具體用法?C++ BZ2_bzDecompressEnd怎麽用?C++ BZ2_bzDecompressEnd使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BZ2_bzDecompressEnd函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的BZ2_bzDecompressEnd函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。