本文整理汇总了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;
}
示例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;
}
示例3: deflateReset
void WebSocketDeflater::reset()
{
m_buffer.clear();
m_isBytesAdded = false;
if (m_contextTakeOverMode == DoNotTakeOverContext)
deflateReset(m_stream.get());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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");
}