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

C++ BZ2_bzBuffToBuffDecompress函数代码示例

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

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



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

示例1: crm_ipcs_recv

xmlNode *
crm_ipcs_recv(crm_client_t * c, void *data, size_t size, uint32_t * id, uint32_t * flags)
{
    xmlNode *xml = NULL;
    char *uncompressed = NULL;
    char *text = ((char *)data) + sizeof(struct crm_ipc_response_header);
    struct crm_ipc_response_header *header = data;

    if (id) {
        *id = ((struct qb_ipc_response_header *)data)->id;
    }
    if (flags) {
        *flags = header->flags;
    }

    if (is_set(header->flags, crm_ipc_proxied)) {
        /* mark this client as being the endpoint of a proxy connection.
         * Proxy connections responses are sent on the event channel to avoid
         * blocking the proxy daemon (crmd) */
        c->flags |= crm_client_flag_ipc_proxied;
    }

    if(header->version > PCMK_IPC_VERSION) {
        crm_err("Filtering incompatible v%d IPC message, we only support versions <= %d",
                header->version, PCMK_IPC_VERSION);
        return NULL;
    }

    if (header->size_compressed) {
        int rc = 0;
        unsigned int size_u = 1 + header->size_uncompressed;
        uncompressed = calloc(1, size_u);

        crm_trace("Decompressing message data %d bytes into %d bytes",
                  header->size_compressed, size_u);

        rc = BZ2_bzBuffToBuffDecompress(uncompressed, &size_u, text, header->size_compressed, 1, 0);
        text = uncompressed;

        if (rc != BZ_OK) {
            crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
            free(uncompressed);
            return NULL;
        }
    }

    CRM_ASSERT(text[header->size_uncompressed - 1] == 0);

    crm_trace("Received %.200s", text);
    xml = string2xml(text);

    free(uncompressed);
    return xml;
}
开发者ID:KevenChang,项目名称:pacemaker,代码行数:54,代码来源:ipc.c


示例2: bz2_decompress

/*ARGSUSED*/
int
bz2_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
{
	ASSERT(d_len >= s_len);

	if (BZ2_bzBuffToBuffDecompress(d_start, (unsigned int *)&d_len, s_start,
			   s_len, 0, 0) != Z_OK)
		return (-1);

	return (0);
}
开发者ID:ElCoyote27,项目名称:zfs-fuse,代码行数:12,代码来源:bzip2.c


示例3: Read_compressed_record

static void Read_compressed_record()
{
  int bytes_to_read = 0;
  int bytes_read = 0;
  int error = 0;
  int size_of_record = Control_word;

  /* Byte-swap size flag so we can use it. */

  bytes_to_read = ntohl( size_of_record );

  P_debug( "Read_compressed_record: read %d", bytes_to_read );

  /* Negative size indicates this is the last record of the volume. */

  if( bytes_to_read < 0 )
  {
    P_debug( "Read_compressed_record: EOV" );
    bytes_to_read = -bytes_to_read;
    End_of_volume_flag = YES;
  }

  /* Read in compressed record according to expected size. If fewer
     bytes are read than expected, that's a problem. */

  bytes_read = Read_stdin( (char *)Read_buf, bytes_to_read );

  if( bytes_read != bytes_to_read )
  {
    P_err( "Read_compressed_record: Bytes read (%d) less than (%d)",
               bytes_read, bytes_to_read );
    Print_stats( INSUFFICIENT_STDIN_BYTES_READ );
  }

  /* Decompress the compressed record and put in different buffer. */

  Uncompressed_length = sizeof( Uncompressed_buf );

  error = BZ2_bzBuffToBuffDecompress( Uncompressed_buf, &Uncompressed_length,
                                      Read_buf, bytes_read,
                                      0, 1 );
  if( error )
  {
    P_err( "Read_compressed_record: Decompress error - %d", error );
    Print_stats( DECOMPRESS_ERROR );
  }

  Uncompressed_bytes += Uncompressed_length;
  Compressed_bytes += bytes_read;
  Compression_ratio = (float) Uncompressed_bytes / (float) Compressed_bytes;
  P_debug( "Radial size - Comp: %d Uncomp: %d Ratio: %f", Compressed_bytes, Uncompressed_bytes, Compression_ratio );
}
开发者ID:likev,项目名称:CodeOrpgPub,代码行数:52,代码来源:validate_ldm_file.c


示例4: throw

/** \brief uncompress the \ref datum_t and return the uncompressed result
 * 
 * @param datum		the data \ref datum_t to uncompress
 * @param max_len	the maximum length of the result
 * @return		a \ref datum_t containing the uncompressed data. the \ref datum_t
 * 			is null if the result is larger than \ref max_len.
 */
datum_t	compress_bzip_t::uncompress(const datum_t &datum, size_t max_len)	throw()
{
	unsigned int	outlen	= max_len;
	// allocate the output buffer
	char	*outbuf = (char *)nipmem_alloca(max_len);
	// try to uncompress the data and put them in the output buffer
	int	err	= BZ2_bzBuffToBuffDecompress(outbuf, &outlen, (char *)datum.get_data()
							, datum.get_len(), 1, 0);
	// if the decompression failed, return a NULL datum_t()
	if( err != BZ_OK )	return	datum_t();
	// copy the decompressed data into a datum_t
	return datum_t(outbuf, outlen);
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:20,代码来源:neoip_compress_bzip.cpp


示例5: BZ2_bzBuffToBuffDecompress

extern int
bzip2_decode
(const unsigned char *in_start, size_t in_len, unsigned char *out_start, size_t *pout_len, size_t out_max)
{
	int	small      = 1;
	int verbosity  = 0;
	size_t destlen = n;

	int x = BZ2_bzBuffToBuffDecompress( (char*)out_start, &destlen, (char*)in_start, in_len,
                               small, verbosity);
	*pout_len = destlen;
	return x == BZ_OK;
}
开发者ID:B4dT0bi,项目名称:JniChessEngines,代码行数:13,代码来源:wrap.c


示例6: while

void NetChannel::CopyNormalFragments()
{
	fragbuf_t *p, *n;
	int totalSize;

	if (!m_incomingbufs[FRAG_NORMAL_STREAM]) {
		m_System->DPrintf("WARNING! NetChannel::CopyNormalFragments: called with no fragments readied.\n");
		return;
	}

	totalSize = 0;
	p = m_incomingbufs[FRAG_NORMAL_STREAM];
	while (p)
	{
		totalSize += p->size;
		p = p->next;
	}

	NetPacket *packet = new NetPacket;
	packet->seqnr = m_incoming_sequence;
	packet->connectionless = false;
	packet->time = m_System->GetTime();
	packet->address.FromNetAddress(&m_remote_address);
	packet->data.Resize(totalSize);

	p = m_incomingbufs[FRAG_NORMAL_STREAM];
	while (p)
	{
		n = p->next;
		packet->data.WriteBuf(p->data, p->size);

		Mem_Free(p);
		p = n;
	}

	if (*(uint32 *)packet->data.GetData() == MAKEID('B', 'Z', '2', '\0'))
	{
		char uncompressed[65536];
		unsigned int uncompressedSize = 65536;

		BZ2_bzBuffToBuffDecompress(uncompressed, &uncompressedSize, (char *)packet->data.GetData() + 4, totalSize - 4, 1, 0);

		packet->data.Resize(uncompressedSize);
		packet->data.WriteBuf(uncompressed, uncompressedSize);
	}

	packet->data.Reset();

	m_incomingPackets.AddHead(packet);
	m_incomingbufs[FRAG_NORMAL_STREAM] = nullptr;
}
开发者ID:theAsmodai,项目名称:rehlds,代码行数:51,代码来源:NetChannel.cpp


示例7: uncompress_using_bzip2

static int uncompress_using_bzip2(void *in, unsigned long in_size,
				  void *out, unsigned long out_max,
				  unsigned long *out_size)
{
	int ret;
	unsigned int inout_size = out_max;

	ret = BZ2_bzBuffToBuffDecompress(out, &inout_size, in, in_size,
			CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0);
	if (out_size)
		*out_size = inout_size;

	return (ret != BZ_OK);
}
开发者ID:AeroGirl,项目名称:u-boot-VAR-SOM-AM33-SDK7,代码行数:14,代码来源:compression.c


示例8: convert_xml_child

static void
convert_xml_child(HA_Message * msg, xmlNode * xml)
{
    int orig = 0;
    int rc = BZ_OK;
    unsigned int len = 0;

    char *buffer = NULL;
    char *compressed = NULL;
    const char *name = NULL;

    name = (const char *)xml->name;
    buffer = dump_xml_unformatted(xml);
    orig = strlen(buffer);
    if (orig < CRM_BZ2_THRESHOLD) {
        ha_msg_add(msg, name, buffer);
        goto done;
    }

    len = (orig * 1.1) + 600;   /* recomended size */

    compressed = malloc(len);
    rc = BZ2_bzBuffToBuffCompress(compressed, &len, buffer, orig, CRM_BZ2_BLOCKS, 0, CRM_BZ2_WORK);

    if (rc != BZ_OK) {
        crm_err("Compression failed: %d", rc);
        free(compressed);
        convert_xml_message_struct(msg, xml, name);
        goto done;
    }

    free(buffer);
    buffer = compressed;
    crm_trace("Compression details: %d -> %d", orig, len);
    ha_msg_addbin(msg, name, buffer, len);
  done:
    free(buffer);

#  if 0
    {
        unsigned int used = orig;
        char *uncompressed = NULL;

        crm_debug("Trying to decompress %d bytes", len);
        uncompressed = calloc(1, orig);
        rc = BZ2_bzBuffToBuffDecompress(uncompressed, &used, compressed, len, 1, 0);
        CRM_CHECK(rc == BZ_OK,;
            );
        CRM_CHECK(used == orig,;
            );
开发者ID:bubble75,项目名称:pacemaker,代码行数:50,代码来源:heartbeat.c


示例9: BZ2_bzBuffToBuffDecompress

void BZ2Stream::decompress(uint8_t* dest, unsigned int dest_len, uint8_t* source, unsigned int source_len) {
    int result = BZ2_bzBuffToBuffDecompress((char*) dest, &dest_len, (char*) source, source_len, 0, verbosity_);

    switch (result) {
    case BZ_OK:               break;
    case BZ_CONFIG_ERROR:     throw BagException("library has been mis-compiled"); break;
    case BZ_PARAM_ERROR:      throw BagException("dest is NULL or destLen is NULL or small != 0 && small != 1 or verbosity < 0 or verbosity > 4"); break;
    case BZ_MEM_ERROR:        throw BagException("insufficient memory is available"); break;
    case BZ_OUTBUFF_FULL:     throw BagException("size of the compressed data exceeds *destLen"); break;
    case BZ_DATA_ERROR:       throw BagException("data integrity error was detected in the compressed data"); break;
    case BZ_DATA_ERROR_MAGIC: throw BagException("compressed data doesn't begin with the right magic bytes"); break;
    case BZ_UNEXPECTED_EOF:   throw BagException("compressed data ends unexpectedly"); break;
    }
}
开发者ID:OSUrobotics,项目名称:palantir_backup,代码行数:14,代码来源:bz2_stream.cpp


示例10: runtime_error

void CIszImageStream::ReadBz2Block(uint32 compressedBlockSize)
{
	m_baseStream->Read(m_readBuffer, compressedBlockSize);
	//Force BZ2 header
	m_readBuffer[0] = 'B';
	m_readBuffer[1] = 'Z';
	m_readBuffer[2] = 'h';
	unsigned int destLength = m_header.blockSize;
	if(BZ2_bzBuffToBuffDecompress(
								  reinterpret_cast<char*>(m_cachedBlock), &destLength,
								  reinterpret_cast<char*>(m_readBuffer), compressedBlockSize, 0, 0) != BZ_OK)
	{
		throw std::runtime_error("Error decompressing bz2 block.");
	}
}
开发者ID:bigianb,项目名称:Play-,代码行数:15,代码来源:IszImageStream.cpp


示例11: ZIP_Decompress

static void ZIP_Decompress( DaoProcess *proc, DaoValue *p[], int N )
{
	DString *source = p[0]->xString.value;
	DString *res = DaoProcess_PutChars( proc, "" );
	unsigned int resLen;

	/* TODO: get decompressed size from the compressed data? */
	DString_Reserve( res, source->size );
	resLen = res->bufSize;
	while( resLen == res->bufSize ){
		DString_Reserve( res, 2*resLen );
		resLen = res->bufSize;
		BZ2_bzBuffToBuffDecompress( res->chars, & resLen, source->chars, source->size, 0, 0 );
	}
	DString_Reset( res, resLen );
}
开发者ID:DawidvC,项目名称:dao-modules,代码行数:16,代码来源:dao_zip.c


示例12: bz2decompress

EXPORT BOOL WINAPI bz2decompress(HSPEXINFO *hei)
{
	char* dest = (char *)hei->HspFunc_prm_getv();
	unsigned int destBufSize = hei->HspFunc_prm_geti();
	char* source = (char *)hei->HspFunc_prm_getv();
	unsigned int sourceLen = hei->HspFunc_prm_geti();
	unsigned int* destLen = &destBufSize;
	int ret;

	if (*hei->er) return *hei->er;
	ret = BZ2_bzBuffToBuffDecompress(dest, destLen, source, sourceLen, 0, 0);
	if (ret == BZ_OK) *hei->strsize = *destLen;

	return -abs(ret);

	return 0;
}
开发者ID:MihailJP,项目名称:HSPBZ2,代码行数:17,代码来源:hspbz2.cpp


示例13: uncompress_block_bzip2

int uncompress_block_bzip2(u64 compsize, u64 *origsize, u8 *origbuf, u64 origbufsize, u8 *compbuf)
{
    unsigned int destsize=origbufsize;
    int res;

    switch ((res=BZ2_bzBuffToBuffDecompress((char*)origbuf, &destsize, (char*)compbuf, compsize, 0, 0)))
    {
    case BZ_OK:
        *origsize=(u64)destsize;
        return FSAERR_SUCCESS;
    default:
        errprintf("BZ2_bzBuffToBuffDecompress() failed, res=%d\n", res);
        return FSAERR_UNKNOWN;
    }

    return FSAERR_UNKNOWN;
}
开发者ID:philip-wernersbach,项目名称:fsarchiver-plus,代码行数:17,代码来源:comp_bzip2.c


示例14: crm_ipc_decompress

static int
crm_ipc_decompress(crm_ipc_t * client)
{
    struct crm_ipc_response_header *header = (struct crm_ipc_response_header *)(void*)client->buffer;

    if (header->size_compressed) {
        int rc = 0;
        unsigned int size_u = 1 + header->size_uncompressed;
        /* never let buf size fall below our max size required for ipc reads. */
        unsigned int new_buf_size = QB_MAX((hdr_offset + size_u), client->max_buf_size);
        char *uncompressed = calloc(1, new_buf_size);

        crm_trace("Decompressing message data %u bytes into %u bytes",
                 header->size_compressed, size_u);

        rc = BZ2_bzBuffToBuffDecompress(uncompressed + hdr_offset, &size_u,
                                        client->buffer + hdr_offset, header->size_compressed, 1, 0);

        if (rc != BZ_OK) {
            crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
            free(uncompressed);
            return -EILSEQ;
        }

        /*
         * This assert no longer holds true.  For an identical msg, some clients may
         * require compression, and others may not. If that same msg (event) is sent
         * to multiple clients, it could result in some clients receiving a compressed
         * msg even though compression was not explicitly required for them.
         *
         * CRM_ASSERT((header->size_uncompressed + hdr_offset) >= ipc_buffer_max);
         */
        CRM_ASSERT(size_u == header->size_uncompressed);

        memcpy(uncompressed, client->buffer, hdr_offset);       /* Preserve the header */
        header = (struct crm_ipc_response_header *)(void*)uncompressed;

        free(client->buffer);
        client->buf_size = new_buf_size;
        client->buffer = uncompressed;
    }

    CRM_ASSERT(client->buffer[hdr_offset + header->size_uncompressed - 1] == 0);
    return pcmk_ok;
}
开发者ID:credativ,项目名称:pacemaker,代码行数:45,代码来源:ipc.c


示例15: bz2_decompress

int bz2_decompress(shared_ptr<FileBuffer> pbz, FileBuffer *p, vector<bz2_blk> * pblk, size_t start, size_t skip)
{
	for (int i = start; i < pblk->size(); i += skip)
	{
		unsigned int len;
		if (i) /*skip first dummy one*/
		{
			(*pblk)[i].error = BZ2_bzBuffToBuffDecompress((char*)p->data() + pblk->at(i).decompress_offset,
				&len,
				(char*)pbz->data() + pblk->at(i).start,
				pblk->at(i).size,
				0,
				0);
			(*pblk)[i].actual_size = len;
		}
	}
	return 0;
}
开发者ID:NXPmicro,项目名称:mfgtools,代码行数:18,代码来源:buffer.cpp


示例16: squash_bz2_decompress_buffer

static SquashStatus
squash_bz2_decompress_buffer (SquashCodec* codec,
                              uint8_t* uncompressed, size_t* uncompressed_length,
                              const uint8_t* compressed, size_t compressed_length,
                              SquashOptions* options) {
  int small = (options != NULL) ? ((SquashBZ2Options*) options)->small : SQUASH_BZ2_DEFAULT_SMALL;
  unsigned int uncompressed_length_ui = (unsigned int) *uncompressed_length;
  int bz2_res;

  bz2_res = BZ2_bzBuffToBuffDecompress ((char*) uncompressed, &uncompressed_length_ui,
                                        (char*) compressed, (unsigned int) compressed_length,
                                        small, 0);
  if (bz2_res == BZ_OK) {
    *uncompressed_length = uncompressed_length_ui;
  }

  return squash_bz2_status_to_squash_status (bz2_res);
}
开发者ID:anthrotype,项目名称:squash,代码行数:18,代码来源:squash-bzip2.c


示例17: Netchan_CopyNormalFragments

/* <66786> ../engine/net_chan.c:1723 */
qboolean Netchan_CopyNormalFragments(netchan_t *chan)
{
	fragbuf_t *p, *n;

	if (!chan->incomingready[FRAG_NORMAL_STREAM])
		return FALSE;

	if (!chan->incomingbufs[FRAG_NORMAL_STREAM])
	{
		Con_Printf("Netchan_CopyNormalFragments:  Called with no fragments readied\n");
		chan->incomingready[FRAG_NORMAL_STREAM] = FALSE;
		return FALSE;
	}

	p = chan->incomingbufs[FRAG_NORMAL_STREAM];

	SZ_Clear(&net_message);
	MSG_BeginReading();

	while (p)
	{
		n = p->next;

		SZ_Write(&net_message, p->frag_message.data, p->frag_message.cursize);

		Mem_Free(p);
		p = n;
	}

	if (*(uint32 *)net_message.data == MAKEID('B', 'Z', '2', '\0'))
	{
		char uncompressed[65536];
		unsigned int uncompressedSize = 65536;
		BZ2_bzBuffToBuffDecompress(uncompressed, &uncompressedSize, (char*)net_message.data + 4, net_message.cursize - 4, 1, 0);
		Q_memcpy(net_message.data, uncompressed, uncompressedSize);
		net_message.cursize = uncompressedSize;
	}

	chan->incomingbufs[FRAG_NORMAL_STREAM] = NULL;
	chan->incomingready[FRAG_NORMAL_STREAM] = false;

	return TRUE;
}
开发者ID:omertelli,项目名称:rehlds,代码行数:44,代码来源:net_chan.cpp


示例18: BZ2Decompress

bool BZ2Decompress(Buffer &dst, const void *src, size_t src_len)
{
    const size_t initial_buffer_size = 1024 * 1024;
    if (dst.empty()) { dst.resize(initial_buffer_size); }

    int ret = 0;
    for (;;) {
        uint32_t dst_len = (uint32_t)dst.size();
        BZ2_bzBuffToBuffDecompress(&dst[0], &dst_len, (char*)src, (uint32_t)src_len, 0, 0);
        if (ret == BZ_OUTBUFF_FULL) {
            dst.resize(dst.size() * 2);
        }
        else {
            dst.resize(dst_len);
            break;
        }
    }
    return ret == BZ_OK;
}
开发者ID:unity3d-jp,项目名称:FrameCapturer,代码行数:19,代码来源:Compression.cpp


示例19: squash_bz2_decompress_buffer

static SquashStatus
squash_bz2_decompress_buffer (SquashCodec* codec,
                              size_t* decompressed_length,
                              uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)],
                              size_t compressed_length,
                              const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)],
                              SquashOptions* options) {
  int small = squash_codec_get_option_bool_index (codec, options, SQUASH_BZ2_OPT_SMALL) ? 1 : 0;
  unsigned int decompressed_length_ui = (unsigned int) *decompressed_length;
  int bz2_res;

  bz2_res = BZ2_bzBuffToBuffDecompress ((char*) decompressed, &decompressed_length_ui,
                                        (char*) compressed, (unsigned int) compressed_length,
                                        small, 0);
  if (bz2_res == BZ_OK) {
    *decompressed_length = decompressed_length_ui;
  }

  return squash_bz2_status_to_squash_status (bz2_res);
}
开发者ID:Bulat-Ziganshin,项目名称:squash,代码行数:20,代码来源:squash-bzip2.c


示例20: LLVMFuzzerTestOneInput

int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
    int r, small;
    unsigned int nZ, nOut;

    // See: https://github.com/google/bzip2-rpc/blob/master/unzcrash.c#L39
    nOut = size*2;
    char *outbuf = malloc(nOut);
    small = size % 2;
    r = BZ2_bzBuffToBuffDecompress(outbuf, &nOut, (char *)data, size,
            small, /*verbosity=*/0);

    if (r != BZ_OK) {
#ifdef __DEBUG__
        fprintf(stdout, "Decompression error: %d\n", r);
#endif
    }
    free(outbuf);
    return 0;
}
开发者ID:google,项目名称:oss-fuzz,代码行数:21,代码来源:bzip2_decompress_target.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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