当前位置: 首页>>代码示例>>C++>>正文


C++ deflateReset函数代码示例

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


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

示例1: alloca

int PtexWriterBase::writeZipBlock(FILE* fp, const void* data, int size, bool finish)
{
    if (!_ok) return 0;
    void* buff = alloca(BlockSize);
    _zstream.next_in = (Bytef*)data;
    _zstream.avail_in = size;

    while (1) {
	_zstream.next_out = (Bytef*)buff;
	_zstream.avail_out = BlockSize;
	int zresult = deflate(&_zstream, finish ? Z_FINISH : Z_NO_FLUSH);
	int size = BlockSize - _zstream.avail_out;
	if (size > 0) writeBlock(fp, buff, size);
	if (zresult == Z_STREAM_END) break;
	if (zresult != Z_OK) {
	    setError("PtexWriter error: data compression internal error");
	    break;
	}
	if (!finish && _zstream.avail_out != 0)
	    // waiting for more input
	    break;
    }

    if (!finish) return 0;

    int total = _zstream.total_out;
    deflateReset(&_zstream);
    return total;
}
开发者ID:400notout,项目名称:oiio,代码行数:29,代码来源:PtexWriter.cpp

示例2: deflateInit2

int GzipBuf::init( int type, int level )
{
    int ret;
    if ( type == GZIP_INFLATE )
        m_type = GZIP_INFLATE;
    else
        m_type = GZIP_DEFLATE;
    if ( m_type == GZIP_DEFLATE )
    {
        if ( !m_zstr.state )
            ret = deflateInit2 (&m_zstr, level, Z_DEFLATED, 15+16, 8,
                            Z_DEFAULT_STRATEGY);
        else
        {
            ret = deflateReset( &m_zstr );
        }
    }
    else
    {
        if ( !m_zstr.state )
            ret = inflateInit2( &m_zstr, 15+16 );
        else
        {
            ret = inflateReset( &m_zstr );
        }
    }
    return ret;
}
开发者ID:ewwink,项目名称:openlitespeed,代码行数:28,代码来源:gzipbuf.cpp

示例3: deflateReset

void WebSocketDeflater::reset()
{
    m_buffer.clear();
    m_isBytesAdded = false;
    if (m_contextTakeOverMode == DoNotTakeOverContext)
        deflateReset(m_stream.get());
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:7,代码来源:WebSocketDeflater.cpp

示例4: assert

int SpdyZlibFilter::init( int isInflator, int verSpdy )
{
    int ret;

    m_isInflator = isInflator;
    assert( (uint)verSpdy < sizeof( s_dicts ) / sizeof( char * ) );
    m_version = verSpdy;
    if ( isInflator )
    {
        if ( m_stream.state )
            ret = inflateReset( &m_stream );
        else
            ret = inflateInit2( &m_stream, 15 );
    }
    else
    {
        if ( m_stream.state )
            ret = deflateReset( &m_stream );
        else
            ret = deflateInit( &m_stream, -1 );

        ret = deflateSetDictionary( &m_stream, s_dicts[ m_version ],
                                    s_dictsLen[ m_version ] );
    }

    return ret;
}
开发者ID:ewwink,项目名称:openlitespeed,代码行数:27,代码来源:spdyzlibfilter.cpp

示例5: deflate

/* Compress whatever is at avail_in and next_in and write to the output file.
   Return -1 if there is an error writing to the output file, otherwise 0.
   flush is assumed to be a valid deflate() flush value.  If flush is Z_FINISH,
   then the deflate() state is reset to start a new gzip stream.  If gz->direct
   is true, then simply write to the output file without compressing, and
   ignore flush. */
static int gz_comp(gz_state *state,
                   int flush)
{
    int ret, got;
    unsigned int have;
    z_stream *strm = &state->strm;

    /* allocate memory if this is the first time through */
    if (state->size == 0 && gz_init(state) == -1)
        return -1;

    /* write directly if requested */
    if (state->direct) {
        got = write(state->fd, strm->next_in, strm->avail_in);
        if (got < 0 || (unsigned int)got != strm->avail_in) {
            gz_error(state, Z_ERRNO, strerror(errno));
            return -1;
        }
        strm->avail_in = 0;
        return 0;
    }

    /* run deflate() on provided input until it produces no more output */
    ret = Z_OK;
    do {
        /* write out current buffer contents if full, or if flushing, but if
           doing Z_FINISH then don't write until we get to Z_STREAM_END */
        if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
            (flush != Z_FINISH || ret == Z_STREAM_END))) {
            have = (unsigned int)(strm->next_out - state->x.next);
            if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
                         (unsigned int)got != have)) {
                gz_error(state, Z_ERRNO, strerror(errno));
                return -1;
            }
            if (strm->avail_out == 0) {
                strm->avail_out = state->size;
                strm->next_out = state->out;
            }
            state->x.next = strm->next_out;
        }

        /* compress */
        have = strm->avail_out;
        ret = deflate(strm, flush);
        if (ret == Z_STREAM_ERROR) {
            gz_error(state, Z_STREAM_ERROR,
                      "internal error: deflate stream corrupt");
            return -1;
        }
        have -= strm->avail_out;
    } while (have);

    /* if that completed a deflate stream, allow another to start */
    if (flush == Z_FINISH)
        deflateReset(strm);

    /* all done, no errors */
    return 0;
}
开发者ID:madd-games,项目名称:glidix,代码行数:66,代码来源:gzwrite.c

示例6: pdc_begin_compress

static void
pdc_begin_compress(pdc_output *out)
{
    pdc_core *pdc = out->pdc;

    if (!pdc_get_compresslevel(out)) {
	out->compressing = pdc_false;
	return;
    }

#ifdef HAVE_LIBZ
    if (out->compr_changed)
    {
	if (deflateEnd(&out->z) != Z_OK)
	    pdc_error(pdc, PDC_E_IO_COMPRESS, "deflateEnd", 0, 0, 0);

	if (deflateInit(&out->z, pdc_get_compresslevel(out)) != Z_OK)
	    pdc_error(pdc, PDC_E_IO_COMPRESS, "deflateInit", 0, 0, 0);

	out->compr_changed = pdc_false;
    }
    else
    {
	if (deflateReset(&out->z) != Z_OK)
	    pdc_error(pdc, PDC_E_IO_COMPRESS, "deflateReset", 0, 0, 0);
    }

    out->z.avail_in = 0;
#endif /* HAVE_LIBZ */

    out->compressing = pdc_true;
}
开发者ID:xharbour,项目名称:core,代码行数:32,代码来源:pc_output.c

示例7: deflate_compress

/*Compress Date on a zlib stream*/
CpaStatus deflate_compress(struct z_stream_s *stream,
        const Cpa8U *src,
        Cpa32U slen,
        Cpa8U *dst,
        Cpa32U dlen)
{
#ifdef USE_ZLIB
    int ret = 0;
    int inflate_type = Z_FINISH;

    ret = deflateReset(stream);
    if(ret != Z_OK)
    {
        PRINT_ERR("Error in deflateReset\n");
        return CPA_STATUS_FAIL;
    }

    stream->next_in = (Cpa8U *)src;
    stream->avail_in = slen;
    stream->next_out = (Cpa8U *)dst;
    stream->avail_out = dlen;

    ret = deflate(stream, inflate_type);
    if (ret != Z_STREAM_END)
    {
        PRINT_ERR("Error in zlib_deflate, ret = %d\n", ret);
        return CPA_STATUS_FAIL;
    }
#endif
    return CPA_STATUS_SUCCESS;
}
开发者ID:lecoq,项目名称:qat_c2xxx,代码行数:32,代码来源:cpa_sample_code_zlib.c

示例8: git_zstream_reset

void git_zstream_reset(git_zstream *zstream)
{
	deflateReset(&zstream->z);
	zstream->in = NULL;
	zstream->in_len = 0;
	zstream->zerr = Z_STREAM_END;
}
开发者ID:Darthholi,项目名称:WDX_GitCommander,代码行数:7,代码来源:zstream.c

示例9: z_comp_init

/*
 * z_comp_init()
 */
static int
z_comp_init(void *arg, uchar_t *options, int opt_len, int unit, int hdrlen,
	int debug)
{
	struct deflate_state *state = (struct deflate_state *)arg;

	if (opt_len < CILEN_DEFLATE ||
		(options[0] != CI_DEFLATE && options[0] != CI_DEFLATE_DRAFT) ||
		options[1] != CILEN_DEFLATE ||
		DEFLATE_METHOD(options[2]) != DEFLATE_METHOD_VAL ||
		DEFLATE_SIZE(options[2]) != state->w_size ||
		options[3] != DEFLATE_CHK_SEQUENCE) {

		return (0);
	}

	state->seqno = 0;
	state->unit = unit;
	state->hdrlen = hdrlen;
	if (debug)
		state->flags |= DS_DEBUG;
	else
		state->flags &= ~DS_DEBUG;

	(void) deflateReset(&state->strm);

	return (1);
}
开发者ID:andreiw,项目名称:polaris,代码行数:31,代码来源:deflate.c

示例10: deflate_reset

int deflate_reset(struct comp_ctx *comp_ctx)
{
	z_stream *strm = &comp_ctx->strm;

	if (deflateReset(strm) == Z_OK)
		return 0;
	return -1;
}
开发者ID:btorch,项目名称:haproxy,代码行数:8,代码来源:compression.c

示例11: Java_at_yawk_rjoin_zlib_NZlib_reset

void Java_at_yawk_rjoin_zlib_NZlib_reset(JNIEnv *env, jclass jc, jboolean inf, jlong stream) {
    int result;
    if (inf) {
        result = inflateReset((z_stream*) stream);
    } else {
        result = deflateReset((z_stream*) stream);
    }
}
开发者ID:yawkat,项目名称:rjoin-zlib,代码行数:8,代码来源:nzlib.c

示例12: zlib_encode

/* returns the total size of the encoded data */
int zlib_encode(ZlibEncoder *zlib, int level, int input_size,
                uint8_t *io_ptr, unsigned int num_io_bytes)
{
    int flush;
    int enc_size = 0;
    int out_size = 0;
    int z_ret;

    z_ret = deflateReset(&zlib->strm);

    if (z_ret != Z_OK) {
        red_error("deflateReset failed");
    }

    zlib->strm.next_out = io_ptr;
    zlib->strm.avail_out = num_io_bytes;

    if (level != zlib->last_level) {
        if (zlib->strm.avail_out == 0) {
            zlib->strm.avail_out = zlib->usr->more_space(zlib->usr, &zlib->strm.next_out);
            if (zlib->strm.avail_out == 0) {
                red_error("not enough space");
            }
        }
        z_ret = deflateParams(&zlib->strm, level, Z_DEFAULT_STRATEGY);
        if (z_ret != Z_OK) {
            red_error("deflateParams failed");
        }
        zlib->last_level = level;
    }


    do {
        zlib->strm.avail_in = zlib->usr->more_input(zlib->usr, &zlib->strm.next_in);
        if (zlib->strm.avail_in <= 0) {
            red_error("more input failed\n");
        }
        enc_size += zlib->strm.avail_in;
        flush = (enc_size == input_size) ?  Z_FINISH : Z_NO_FLUSH;
        while (1) {
            int deflate_size = zlib->strm.avail_out;
            z_ret = deflate(&zlib->strm, flush);
            ASSERT(z_ret != Z_STREAM_ERROR);
            out_size += deflate_size - zlib->strm.avail_out;
            if (zlib->strm.avail_out) {
                break;
            }

            zlib->strm.avail_out = zlib->usr->more_space(zlib->usr, &zlib->strm.next_out);
            if (zlib->strm.avail_out == 0) {
                red_error("not enough space");
            }
        }
    } while (flush != Z_FINISH);

    ASSERT(z_ret == Z_STREAM_END);
    return out_size;
}
开发者ID:colama,项目名称:colama-3rdparty-tools,代码行数:59,代码来源:zlib_encoder.c

示例13: Java_java_util_zip_Deflater_resetImpl

JNIEXPORT void JNICALL
Java_java_util_zip_Deflater_resetImpl (JNIEnv * env, jobject recv,
				       jlong handle)
{
  JCLZipStream *stream;

  stream = (JCLZipStream *) ((IDATA) handle);
  deflateReset (stream->stream);
}
开发者ID:dennis-xlc,项目名称:ORDER,代码行数:9,代码来源:deflater.c

示例14: flushGrain

static int
flushGrain(StreamOptimizedDiskInfo *sodi)
{
	int ret;
	uint32_t oldLoc;

	if (sodi->writer.grainBufferNr == ~0ULL) {
		return 0;
	}
	if (sodi->writer.grainBufferValidEnd == 0) {
		return 0;
	}
	ret = fillGrain(sodi);
	if (ret) {
		return ret;
	}

	oldLoc = __le32_to_cpu(sodi->writer.gtInfo.gt[sodi->writer.grainBufferNr]);
	if (oldLoc != 0) {
		fprintf(stderr, "Cannot update already written grain\n");
		return -1;
	}

	if (!isZeroed(sodi->writer.grainBuffer, sodi->writer.grainBufferValidEnd)) {
		size_t dataLen;
		uint32_t rem;
		SparseGrainLBAHeaderOnDisk *grainHdr = sodi->writer.zlibBuffer.grainHdr;

		sodi->writer.gtInfo.gt[sodi->writer.grainBufferNr] = __cpu_to_le32(sodi->writer.curSP);
		if (deflateReset(&sodi->writer.zstream) != Z_OK) {
			fprintf(stderr, "DeflateReset failed\n");
			return -1;
		}
		sodi->writer.zstream.next_in = sodi->writer.grainBuffer;
		sodi->writer.zstream.avail_in = sodi->writer.grainBufferValidEnd;
		sodi->writer.zstream.next_out = sodi->writer.zlibBuffer.data + sizeof *grainHdr;
		sodi->writer.zstream.avail_out = sodi->writer.zlibBufferSize - sizeof *grainHdr;
		if (deflate(&sodi->writer.zstream, Z_FINISH) != Z_STREAM_END) {
			fprintf(stderr, "Deflate failed\n");
			return -1;
		}
		dataLen = sodi->writer.zstream.next_out - sodi->writer.zlibBuffer.data;
		grainHdr->lba = sodi->writer.grainBufferNr * sodi->diskHdr.grainSize;
		grainHdr->cmpSize = __cpu_to_le32(dataLen - sizeof *grainHdr);
		rem = dataLen & (VMDK_SECTOR_SIZE - 1);
		if (rem != 0) {
			rem = VMDK_SECTOR_SIZE - rem;
			memset(sodi->writer.zstream.next_out, 0, rem);
			dataLen += rem;
		}
		if (!safeWrite(sodi->writer.fd, grainHdr, dataLen)) {
			return -1;
		}
		sodi->writer.curSP += dataLen / VMDK_SECTOR_SIZE;
	}
	return 0;
}
开发者ID:markpeek,项目名称:open-vmdk,代码行数:57,代码来源:sparse.c

示例15: resetEncoder

static void resetEncoder(Gzb64* gzb64)
{
    int zret = deflateReset(& gzb64->gz_encode_strm);
	if(zret < 0) zerr(zret);
	zret = BIO_reset(gzb64->encode_output_buffer);
	zret = BIO_reset(gzb64->b64_encoder);
	gzb64->encoded_last_chunk = false;
	if(DEBUG) printf("Encoder reset\n");
}
开发者ID:nfvproject,项目名称:TFM,代码行数:9,代码来源:compress.c


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