您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ zlib_inflate函数代码示例

51自学网 2021-06-03 12:00:21
  C++
这篇教程C++ zlib_inflate函数代码示例写得很实用,希望能帮到您。

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

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

示例1: cramfs_uncompress_block_gzip

/* Returns length of decompressed data. */int cramfs_uncompress_block_gzip(void *dst, int dstlen, void *src, int srclen){	int err;	stream.next_in = src;	stream.avail_in = srclen;	stream.next_out = dst;	stream.avail_out = dstlen;	err = zlib_inflateReset(&stream);	if (err != Z_OK) {		printk("zlib_inflateReset error %d/n", err);		zlib_inflateEnd(&stream);		zlib_inflateInit(&stream);	}	err = zlib_inflate(&stream, Z_FINISH);	if (err != Z_STREAM_END)		goto err;	return stream.total_out;err:	printk("Error %d while decompressing!/n", err);	printk("%p(%d)->%p(%d)/n", src, srclen, dst, dstlen);	return 0;}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:28,


示例2: pstore_decompress

/* Derived from logfs_uncompress */static int pstore_decompress(void *in, void *out, size_t inlen, size_t outlen){    int err, ret;    ret = -EIO;    err = zlib_inflateInit2(&stream, WINDOW_BITS);    if (err != Z_OK)        goto error;    stream.next_in = in;    stream.avail_in = inlen;    stream.total_in = 0;    stream.next_out = out;    stream.avail_out = outlen;    stream.total_out = 0;    err = zlib_inflate(&stream, Z_FINISH);    if (err != Z_STREAM_END)        goto error;    err = zlib_inflateEnd(&stream);    if (err != Z_OK)        goto error;    ret = stream.total_out;error:    return ret;}
开发者ID:infidel,项目名称:linux,代码行数:29,


示例3: gztruncate

// There is no zlib gztruncate. Inflate it, truncate it, recompress it.static int gztruncate(const char *path, off_t length, int compression){	int ret=1;	char tmp[16];	char *dest=NULL;	char *dest2=NULL;	snprintf(tmp, sizeof(tmp), ".%d", getpid());	if(!(dest=prepend(path, tmp))	  || !(dest2=prepend(dest, "-2"))	  || zlib_inflate(NULL, path, dest, NULL))		goto end;	if(truncate(dest, length))	{		logp("truncate of %s failed in %s/n", dest, __func__);		goto end;	}	if(compress_file(dest, dest2, compression))		goto end;	unlink(dest);	ret=do_rename(dest2, path);end:	if(dest) unlink(dest);	if(dest2) unlink(dest2);	free_w(&dest);	free_w(&dest2);	return ret;}
开发者ID:vanElden,项目名称:burp,代码行数:28,


示例4: ctf_uncompress

int ctf_uncompress (char *dest, int *destLen, char *source, int sourceLen){	z_stream stream;	int err;	memset(&stream, 0, sizeof stream);	stream.next_in = source;	stream.avail_in = sourceLen;	/* Check for source > 64K on 16-bit machine: */	if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;	stream.next_out = dest;	stream.avail_out = (uInt)*destLen;	if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;	err = zlib_inflateInit(&stream);	if (err != Z_OK) return err;	err = zlib_inflate(&stream, Z_FINISH);	last_err = stream.msg;	if (err != Z_STREAM_END) {		zlib_inflateEnd(&stream);		if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))	        	return Z_DATA_ERROR;		return err;	}	*destLen = stream.total_out;	err = zlib_inflateEnd(&stream);	return err;}
开发者ID:pampanelson,项目名称:dtrace-for-linux,代码行数:32,


示例5: logfs_uncompress

int logfs_uncompress(void *in, void *out, size_t inlen, size_t outlen){	int err, ret;	ret = -EIO;	mutex_lock(&compr_mutex);	err = zlib_inflateInit(&stream);	if (err != Z_OK)		goto error;	stream.next_in = in;	stream.avail_in = inlen;	stream.total_in = 0;	stream.next_out = out;	stream.avail_out = outlen;	stream.total_out = 0;	err = zlib_inflate(&stream, Z_FINISH);	if (err != Z_STREAM_END)		goto error;	err = zlib_inflateEnd(&stream);	if (err != Z_OK)		goto error;	ret = 0;error:	mutex_unlock(&compr_mutex);	return ret;}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:30,


示例6: zlib_decompress_final

static int zlib_decompress_final(struct crypto_pcomp *tfm,				 struct comp_request *req){	int ret;	struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));	struct z_stream_s *stream = &dctx->decomp_stream;	pr_debug("avail_in %u, avail_out %u/n", req->avail_in, req->avail_out);	stream->next_in = req->next_in;	stream->avail_in = req->avail_in;	stream->next_out = req->next_out;	stream->avail_out = req->avail_out;	if (dctx->decomp_windowBits < 0) {		ret = zlib_inflate(stream, Z_SYNC_FLUSH);		/*		 * Work around a bug in zlib, which sometimes wants to taste an		 * extra byte when being used in the (undocumented) raw deflate		 * mode. (From USAGI).		 */		if (ret == Z_OK && !stream->avail_in && stream->avail_out) {			const void *saved_next_in = stream->next_in;			u8 zerostuff = 0;			stream->next_in = &zerostuff;			stream->avail_in = 1;			ret = zlib_inflate(stream, Z_FINISH);			stream->next_in = saved_next_in;			stream->avail_in = 0;		}	} else		ret = zlib_inflate(stream, Z_FINISH);	if (ret != Z_STREAM_END) {		pr_debug("zlib_inflate failed %d/n", ret);		return -EINVAL;	}	ret = req->avail_out - stream->avail_out;	pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)/n",		 stream->avail_in, stream->avail_out,		 req->avail_in - stream->avail_in, ret);	req->next_in = stream->next_in;	req->avail_in = stream->avail_in;	req->next_out = stream->next_out;	req->avail_out = stream->avail_out;	return ret;}
开发者ID:0x000000FF,项目名称:Linux4Edison,代码行数:47,


示例7: geDecompress

ge_Buffer* geDecompress(void* in, int insz, int mode){	ge_Buffer* out = (ge_Buffer*)geMalloc(sizeof(ge_Buffer));	if(mode == GE_COMPRESSION_ZLIB){		ge_Buffer b_in = { in, insz, 0 };		zlib_inflate(out, &b_in);	}	return out;}
开发者ID:drewet,项目名称:libge,代码行数:8,


示例8: inflate_or_link_oldfile

static int inflate_or_link_oldfile(const char *oldpath, const char *infpath){	int ret=0;	struct stat statp;	if(lstat(oldpath, &statp))	{		logp("could not lstat %s/n", oldpath);		return -1;	}	if(dpth_is_compressed(oldpath))	{		FILE *source=NULL;		FILE *dest=NULL;		//logp("inflating.../n");		if(!(dest=open_file(infpath, "wb")))		{			close_fp(&dest);			return -1;		}		if(!statp.st_size)		{			// Empty file - cannot inflate.			// just close the destination and we have duplicated a			// zero length file.			logp("asked to inflate zero length file: %s/n", oldpath);			close_fp(&dest);			return 0;		}		if(!(source=open_file(oldpath, "rb")))		{			close_fp(&dest);			return -1;		}		if((ret=zlib_inflate(source, dest))!=Z_OK)			logp("zlib_inflate returned: %d/n", ret);		close_fp(&source);		close_fp(&dest);	}	else	{		// Not compressed - just hard link it.		if(link(oldpath, infpath))		{			logp("hardlink %s to %s failed: %s/n",				infpath, oldpath, strerror(errno));			ret=-1;		}	}	return ret;}
开发者ID:fenio,项目名称:burp,代码行数:58,


示例9: zlib_decompress_final

static int zlib_decompress_final(struct crypto_pcomp *tfm,				 struct comp_request *req){	int ret;	struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));	struct z_stream_s *stream = &dctx->decomp_stream;	pr_debug("avail_in %u, avail_out %u/n", req->avail_in, req->avail_out);	stream->next_in = req->next_in;	stream->avail_in = req->avail_in;	stream->next_out = req->next_out;	stream->avail_out = req->avail_out;	if (dctx->decomp_windowBits < 0) {		ret = zlib_inflate(stream, Z_SYNC_FLUSH);		if (ret == Z_OK && !stream->avail_in && stream->avail_out) {			const void *saved_next_in = stream->next_in;			u8 zerostuff = 0;			stream->next_in = &zerostuff;			stream->avail_in = 1;			ret = zlib_inflate(stream, Z_FINISH);			stream->next_in = saved_next_in;			stream->avail_in = 0;		}	} else		ret = zlib_inflate(stream, Z_FINISH);	if (ret != Z_STREAM_END) {		pr_debug("zlib_inflate failed %d/n", ret);		return -EINVAL;	}	ret = req->avail_out - stream->avail_out;	pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)/n",		 stream->avail_in, stream->avail_out,		 req->avail_in - stream->avail_in, ret);	req->next_in = stream->next_in;	req->avail_in = stream->avail_in;	req->next_out = stream->next_out;	req->avail_out = stream->avail_out;	return ret;}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:42,


示例10: sqlzma_un

int sqlzma_un(struct sqlzma_un *un, struct sized_buf *src,	      struct sized_buf *dst){	int err, by_lzma = 1;	if (un->un_lzma && is_lzma(*src->buf)) {		un->un_cmbuf = src->buf;		un->un_cmlen = src->sz;		un->un_resbuf = dst->buf;		un->un_reslen = dst->sz;		/* this library is thread-safe */		err = LzmaUncompress(un);		goto out;	}	by_lzma = 0;//#if defined(CONFIG_MIPS_BRCM)#if 1//disable zlib inflate    /* The FS is compressed with LZMA for BRCM: do not use zlib */    printk("%s: ZLIB decompression is not supported/n", __func__);    err = -EINVAL;#else	err = zlib_inflateReset(&un->un_stream);	if (unlikely(err != Z_OK))		goto out;	un->un_stream.next_in = src->buf;	un->un_stream.avail_in = src->sz;	un->un_stream.next_out = dst->buf;	un->un_stream.avail_out = dst->sz;	err = zlib_inflate(&un->un_stream, Z_FINISH);	if (err == Z_STREAM_END)		err = 0;#endif  out:	if (unlikely(err)) {#ifdef __KERNEL__		WARN_ON_ONCE(1);#else		char a[64] = "ZLIB ";		if (by_lzma) {			strcpy(a, "LZMA ");#ifdef _REENTRANT			strerror_r(err, a + 5, sizeof(a) - 5);#else			strncat(a, strerror(err), sizeof(a) - 5);#endif		} else			strncat(a, zError(err), sizeof(a) - 5);		fprintf(stderr, "%s: %.*s/n", __func__, sizeof(a), a);#endif	}	return err;}
开发者ID:fr34k8,项目名称:DT_Hybrid_GPL_1.00.053,代码行数:54,


示例11: deflate_decompress

static int deflate_decompress(struct crypto_tfm *tfm, const u8 *src,                              unsigned int slen, u8 *dst, unsigned int *dlen){    int ret = 0;    struct deflate_ctx *dctx = crypto_tfm_ctx(tfm);    struct z_stream_s *stream = &dctx->decomp_stream;    ret = zlib_inflateReset(stream);    if (ret != Z_OK) {        ret = -EINVAL;        goto out;    }    stream->next_in = (u8 *)src;    stream->avail_in = slen;    stream->next_out = (u8 *)dst;    stream->avail_out = *dlen;    ret = zlib_inflate(stream, Z_SYNC_FLUSH);    /*     * Work around a bug in zlib, which sometimes wants to taste an extra     * byte when being used in the (undocumented) raw deflate mode.     * (From USAGI).     */    if (ret == Z_OK && !stream->avail_in && stream->avail_out) {        u8 zerostuff = 0;        stream->next_in = &zerostuff;        stream->avail_in = 1;        ret = zlib_inflate(stream, Z_FINISH);    }    if (ret != Z_STREAM_END) {        ret = -EINVAL;        goto out;    }    ret = 0;    *dlen = stream->total_out;out:    return ret;}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:40,


示例12: gunzip

static void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp){	z_stream s;	int r, i, flags;	/* skip header */	i = 10;	flags = src[3];	if (src[2] != Z_DEFLATED || (flags & RESERVED) != 0) {		printf("bad gzipped data/n/r");		exit();	}	if ((flags & EXTRA_FIELD) != 0)		i = 12 + src[10] + (src[11] << 8);	if ((flags & ORIG_NAME) != 0)		while (src[i++] != 0)			;	if ((flags & COMMENT) != 0)		while (src[i++] != 0)			;	if ((flags & HEAD_CRC) != 0)		i += 2;	if (i >= *lenp) {		printf("gunzip: ran out of data in header/n/r");		exit();	}	if (zlib_inflate_workspacesize() > sizeof(scratch)) {		printf("gunzip needs more mem/n");		exit();	}	memset(&s, 0, sizeof(s));	s.workspace = scratch;	r = zlib_inflateInit2(&s, -MAX_WBITS);	if (r != Z_OK) {		printf("inflateInit2 returned %d/n/r", r);		exit();	}	s.next_in = src + i;	s.avail_in = *lenp - i;	s.next_out = dst;	s.avail_out = dstlen;	r = zlib_inflate(&s, Z_FULL_FLUSH);	if (r != Z_OK && r != Z_STREAM_END) {		printf("inflate returned %d msg: %s/n/r", r, s.msg);		exit();	}	*lenp = s.next_out - (unsigned char *) dst;	zlib_inflateEnd(&s);}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:50,


示例13: sqlzma_un

int sqlzma_un(struct sqlzma_un *un, struct sized_buf *src,	      struct sized_buf *dst){	int err, by_lzma = 0;	if (un->un_lzma && is_lzma(*src->buf)) {		by_lzma = 1;		un->un_cmbuf = src->buf;		un->un_cmlen = src->sz;		un->un_resbuf = dst->buf;		un->un_reslen = dst->sz;		/* this library is thread-safe */		err = LzmaUncompress(un);		goto out;	}	err = zlib_inflateReset(&un->un_stream);	if (unlikely(err != Z_OK))		goto out;	un->un_stream.next_in = src->buf;	un->un_stream.avail_in = src->sz;	un->un_stream.next_out = dst->buf;	un->un_stream.avail_out = dst->sz;	err = zlib_inflate(&un->un_stream, Z_FINISH);	if (err == Z_STREAM_END)		err = 0; out:	if (err) {#ifdef __KERNEL__		WARN_ON_ONCE(1);#else		char a[64] = "ZLIB ";		if (by_lzma) {			strcpy(a, "LZMA ");#ifdef _REENTRANT			strerror_r(err, a + 5, sizeof(a) - 5);#else			strncat(a, strerror(err), sizeof(a) - 5);#endif		} else			strncat(a, zError(err), sizeof(a) - 5);		fprintf(stderr, "%s: %.*s/n", __func__, sizeof(a), a);#endif	}	return err;}
开发者ID:hrulez,项目名称:Actiontec-V1000H,代码行数:47,


示例14: gunzip

void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp){	z_stream s;	int r, i, flags;	/* skip header */	i = 10;	flags = src[3];	if (src[2] != Z_DEFLATED || (flags & RESERVED) != 0) {		puts("bad gzipped data/n");		exit();	}	if ((flags & EXTRA_FIELD) != 0)		i = 12 + src[10] + (src[11] << 8);	if ((flags & ORIG_NAME) != 0)		while (src[i++] != 0)			;	if ((flags & COMMENT) != 0)		while (src[i++] != 0)			;	if ((flags & HEAD_CRC) != 0)		i += 2;	if (i >= *lenp) {		puts("gunzip: ran out of data in header/n");		exit();	}	/* Initialize ourself. */	s.workspace = zalloc(zlib_inflate_workspacesize());	r = zlib_inflateInit2(&s, -MAX_WBITS);	if (r != Z_OK) {		puts("zlib_inflateInit2 returned "); puthex(r); puts("/n");		exit();	}	s.next_in = src + i;	s.avail_in = *lenp - i;	s.next_out = dst;	s.avail_out = dstlen;	r = zlib_inflate(&s, Z_FINISH);	if (r != Z_OK && r != Z_STREAM_END) {		puts("inflate returned "); puthex(r); puts("/n");		exit();	}	*lenp = s.next_out - (unsigned char *) dst;	zlib_inflateEnd(&s);}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:46,


示例15: gunzip

void gunzip (void *dst, int dstlen, unsigned char *src, int *lenp){	z_stream s;	int r, i, flags;                i = 10;        flags = src[3];        if (src[2] != DEFLATED || (flags & RESERVED) != 0) {                                exit();        }        if ((flags & EXTRA_FIELD) != 0)                i = 12 + src[10] + (src[11] << 8);        if ((flags & ORIG_NAME) != 0)                while (src[i++] != 0)                        ;        if ((flags & COMMENT) != 0)                while (src[i++] != 0)                        ;        if ((flags & HEAD_CRC) != 0)                i += 2;        if (i >= *lenp) {                                exit();        }	s.workspace = zalloc(zlib_inflate_workspacesize());        r = zlib_inflateInit2(&s, -MAX_WBITS);        if (r != Z_OK) {                                exit();        }        s.next_in = src + i;        s.avail_in = *lenp - i;        s.next_out = dst;        s.avail_out = dstlen;        r = zlib_inflate(&s, Z_FINISH);        if (r != Z_OK && r != Z_STREAM_END) {                                exit();        }        *lenp = s.next_out - (unsigned char *) dst;        zlib_inflateEnd(&s);}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:45,


示例16: zlib_inflate_blob

/* _VMKLNX_CODECHECK_: zlib_inflate_blob */int zlib_inflate_blob(void *gunzip_buf, unsigned int sz,                      const void *buf, unsigned int len){        const u8 *zbuf = buf;        struct z_stream_s *strm;        int rc;        #if defined(__VMKLNX__)	VMK_ASSERT(vmk_PreemptionIsEnabled() == VMK_FALSE);#endif        rc = -ENOMEM;        strm = kmalloc(sizeof(*strm), GFP_KERNEL);        if (strm == NULL)                goto gunzip_nomem1;        strm->workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);        if (strm->workspace == NULL)                goto gunzip_nomem2;                /* gzip header (1f,8b,08... 10 bytes total + possible asciz filename)         * expected to be stripped from input         */        strm->next_in = zbuf;        strm->avail_in = len;        strm->next_out = gunzip_buf;        strm->avail_out = sz;                rc = zlib_inflateInit2(strm, -MAX_WBITS);        if (rc == Z_OK) {                rc = zlib_inflate(strm, Z_FINISH);                /* after Z_FINISH, only Z_STREAM_END is "we unpacked it all" */                if (rc == Z_STREAM_END)                        rc = sz - strm->avail_out;                else                        rc = -EINVAL;                zlib_inflateEnd(strm);        } else                rc = -EINVAL;                kfree(strm->workspace); gunzip_nomem2:        kfree(strm); gunzip_nomem1:        return rc; /* returns Z_OK (0) if successful */}
开发者ID:pombredanne,项目名称:https-git.sfconservancy.org-vmkdrivers,代码行数:45,


示例17: z_uncompress

/* * Decompresses the source buffer into the destination buffer.  sourceLen is * the byte length of the source buffer. Upon entry, destLen is the total * size of the destination buffer, which must be large enough to hold the * entire uncompressed data. (The size of the uncompressed data must have * been saved previously by the compressor and transmitted to the decompressor * by some mechanism outside the scope of this compression library.) * Upon exit, destLen is the actual size of the compressed buffer. * This function can be used to decompress a whole file at once if the * input file is mmap'ed. * * uncompress returns Z_OK if success, Z_MEM_ERROR if there was not * enough memory, Z_BUF_ERROR if there was not enough room in the output * buffer, or Z_DATA_ERROR if the input data was corrupted. */intz_uncompress(void *dest, size_t *destLen, const void *source, size_t sourceLen){	z_stream stream;	int err;	stream.next_in = (Byte *)source;	stream.avail_in = (uInt)sourceLen;	stream.next_out = dest;	stream.avail_out = (uInt)*destLen;	if ((size_t)stream.avail_out != *destLen)		return Z_BUF_ERROR;	stream.workspace = zlib_workspace_alloc(KM_SLEEP);	if (!stream.workspace)		return Z_MEM_ERROR;	err = zlib_inflateInit(&stream);	if (err != Z_OK) {		zlib_workspace_free(stream.workspace);		return err;	}	err = zlib_inflate(&stream, Z_FINISH);	if (err != Z_STREAM_END) {		zlib_inflateEnd(&stream);		zlib_workspace_free(stream.workspace);		if (err == Z_NEED_DICT ||		   (err == Z_BUF_ERROR && stream.avail_in == 0))			return Z_DATA_ERROR;		return err;	}	*destLen = stream.total_out;	err = zlib_inflateEnd(&stream);	zlib_workspace_free(stream.workspace);	return err;}
开发者ID:dunecn,项目名称:spl,代码行数:57,


示例18: zlib_inflate_blob

/* Utility function: initialize zlib, unpack binary blob, clean up zlib, * return len or negative error code. */int zlib_inflate_blob(void *gunzip_buf, unsigned int sz,		      const void *buf, unsigned int len){	const u8 *zbuf = buf;	struct z_stream_s *strm;	int rc;	rc = -ENOMEM;	strm = MALLOC(sizeof(*strm));	if (strm == NULL)		goto gunzip_nomem1;	strm->workspace = MALLOC(zlib_inflate_workspacesize());	if (strm->workspace == NULL)		goto gunzip_nomem2;	/* gzip header (1f,8b,08... 10 bytes total + possible asciz filename)	 * expected to be stripped from input	 */	strm->next_in = zbuf;	strm->avail_in = len;	strm->next_out = gunzip_buf;	strm->avail_out = sz;	rc = zlib_inflateInit2(strm, -MAX_WBITS);	if (rc == Z_OK) {		rc = zlib_inflate(strm, Z_FINISH);		/* after Z_FINISH, only Z_STREAM_END is "we unpacked it all" */		if (rc == Z_STREAM_END)			rc = sz - strm->avail_out;		else			rc = -EINVAL;		zlib_inflateEnd(strm);	} else		rc = -EINVAL;	FREE(strm->workspace);gunzip_nomem2:	FREE(strm);gunzip_nomem1:	return rc; /* returns Z_OK (0) if successful */}
开发者ID:MinimumLaw,项目名称:ravion-barebox,代码行数:44,


示例19: _decompress

static int _decompress(FILE *in, FILE *out){	CISO_H header;	fread(&header,1,sizeof(header),in);	if(memcmp(header.magic,"CISO",4)||(header.header_size&&header.header_size!=sizeof(header))){fprintf(stderr,"not CISO/n");return 1;}	int total_block=align2p(header.block_size,header.total_bytes)/header.block_size;	fread(buf,4,total_block+1,in);	int i=0;	int counter=sizeof(header)+4*(total_block+1);	//void* coder=NULL;	//lzmaCreateCoder(&coder,0x040108,0,0);	for(;i<total_block;i++){		u32 index=read32(buf+4*i);		u32 plain=index&0x80000000;		index&=0x7fffffff;		u32 pos=index<<header.align;		if(pos>counter)fread(buf+BUFLEN-(pos-counter),1,pos-counter,in); //discard		u32 size=((read32(buf+4*(i+1))&0x7fffffff)<<header.align) - index;		if(plain){			fread(__decompbuf,1,size,in);counter+=size;			fwrite(__decompbuf,1,size,out);		}else{			fread(__compbuf,1,size,in);counter+=size;			size_t decompsize=header.block_size;			int r=zlib_inflate(__decompbuf,&decompsize,__compbuf,size);			if(r){				fprintf(stderr,"inflate %d/n",r);				return 1;			}			fwrite(__decompbuf,1,decompsize,out);		}		if((i+1)%256==0)fprintf(stderr,"%d / %d/r",i+1,total_block);	}	fprintf(stderr,"%d / %d done./n",i,total_block);	//lzmaDestroyCoder(&coder);	return 0;}
开发者ID:cielavenir,项目名称:7razf,代码行数:40,


示例20: zlib_decompress_update

static int zlib_decompress_update(struct crypto_pcomp *tfm,				  struct comp_request *req){	int ret;	struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));	struct z_stream_s *stream = &dctx->decomp_stream;	pr_debug("avail_in %u, avail_out %u/n", req->avail_in, req->avail_out);	stream->next_in = req->next_in;	stream->avail_in = req->avail_in;	stream->next_out = req->next_out;	stream->avail_out = req->avail_out;	ret = zlib_inflate(stream, Z_SYNC_FLUSH);	switch (ret) {	case Z_OK:	case Z_STREAM_END:		break;	case Z_BUF_ERROR:		pr_debug("zlib_inflate could not make progress/n");		return -EAGAIN;	default:		pr_debug("zlib_inflate failed %d/n", ret);		return -EINVAL;	}	ret = req->avail_out - stream->avail_out;	pr_debug("avail_in %u, avail_out %u (consumed %u, produced %u)/n",		 stream->avail_in, stream->avail_out,		 req->avail_in - stream->avail_in, ret);	req->next_in = stream->next_in;	req->avail_in = stream->avail_in;	req->next_out = stream->next_out;	req->avail_out = stream->avail_out;	return ret;}
开发者ID:0x000000FF,项目名称:Linux4Edison,代码行数:38,


示例21: gunzip_partial

int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen){	int len;	if (state->s.workspace) {		/* gunzipping */		int r;		state->s.next_out = dst;		state->s.avail_out = dstlen;		r = zlib_inflate(&state->s, Z_FULL_FLUSH);		if (r != Z_OK && r != Z_STREAM_END)			fatal("inflate returned %d msg: %s/n/r", r, state->s.msg);		len = state->s.next_out - (unsigned char *)dst;	} else {		/* uncompressed image */		len = min(state->s.avail_in, (unsigned)dstlen);		memcpy(dst, state->s.next_in, len);		state->s.next_in += len;		state->s.avail_in -= len;	}	return len;}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:23,


示例22: main

int main(int argc, char **argv){	FILE *fin, *fout;	int result;	if (argc != 3)	{		usage(argv[0]);		exit(1);	}	fin = fopen(argv[1], "r");	if (fin == NULL)	{		fprintf(stderr, "couldn't open input file '%s'/n", argv[1]);		exit(1);	}	fout = fopen(argv[2], "w");	if (fin == NULL)	{		fprintf(stderr, "couldn't open output file '%s'/n", argv[2]);		exit(1);	}	result = zlib_inflate(fin, fout);	if (result != Z_OK)	{		fprintf(stderr, "zlib error %s/n", zlib_error2str(result));		exit(1);	}	fclose(fin);	fclose(fout);	exit(0);}
开发者ID:MatChung,项目名称:allps3tools,代码行数:37,


示例23: inflate_or_link_oldfile

static int inflate_or_link_oldfile(struct asfd *asfd, const char *oldpath,	const char *infpath, struct conf **cconfs, int compression){	int ret=0;	struct stat statp;	if(lstat(oldpath, &statp))	{		logp("could not lstat %s/n", oldpath);		return -1;	}	if(dpth_protocol1_is_compressed(compression, oldpath))	{		//logp("inflating.../n");		if(!statp.st_size)		{			// Empty file - cannot inflate.			logp("asked to inflate zero length file: %s/n",				oldpath);			return create_zero_length_file(infpath);		}		if((ret=zlib_inflate(asfd, oldpath, infpath, get_cntr(cconfs))))			logp("zlib_inflate returned: %d/n", ret);	}	else	{		// Not compressed - just hard link it.		if(do_link(oldpath, infpath, &statp, cconfs,			1 /* allow overwrite of infpath */))				return -1;	}	return ret;}
开发者ID:pkdevbox,项目名称:burp,代码行数:36,


示例24: g_return_val_if_fail

static guchar *fb_gunzip(const guchar *gzip_data, ssize_t *len_ptr){	gsize gzip_data_len	= *len_ptr;	z_stream zstr;	int gzip_err = 0;	guchar *output_data;	gulong gzip_len = G_MAXUINT16;	g_return_val_if_fail(zlib_inflate != NULL, NULL);	output_data = g_new0(guchar, gzip_len);	zstr.next_in = gzip_data;	zstr.avail_in = gzip_data_len;	zstr.zalloc = Z_NULL;	zstr.zfree = Z_NULL;	zstr.opaque = Z_NULL;	int flags = gzip_data[3];	int offset = 4;	/* if (flags & 0x04) offset += *tmp[] */	zstr.next_in += offset;	zstr.avail_in -= offset;	zlib_inflateInit2_(&zstr, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream));	zstr.next_out = output_data;	zstr.avail_out = gzip_len;	gzip_err = zlib_inflate(&zstr, Z_FINISH);	zlib_inflateEnd(&zstr);	purple_debug_info("facebook", "gzip len: %ld, len: %ld/n", gzip_len,			gzip_data_len);	purple_debug_info("facebook", "gzip flags: %d/n", flags);	purple_debug_info("facebook", "gzip error: %d/n", gzip_err);	*len_ptr = gzip_len;	return output_data;}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:36,


示例25: inflate_oldfile

static int inflate_oldfile(const char *opath, const char *infpath,	struct stat *statp, struct conf *conf){	int ret=0;	if(!statp->st_size)	{		FILE *dest;		// Empty file - cannot inflate.		// just close the destination and we have duplicated a		// zero length file.		if(!(dest=open_file(infpath, "wb"))) goto end;		logp("asked to inflate zero length file: %s/n", opath);		if(close_fp(&dest))			logp("error closing %s in %s/n", infpath, __func__);	}	else if(zlib_inflate(NULL, opath, infpath, conf))	{		logp("zlib_inflate returned error/n");		ret=-1;	}end:	return ret;}
开发者ID:Sherlock221B,项目名称:burp,代码行数:24,


示例26: zisofs_uncompress_block

/* * Read data of @inode from @block_start to @block_end and uncompress * to one zisofs block. Store the data in the @pages array with @pcount * entries. Start storing at offset @poffset of the first page. */static loff_t zisofs_uncompress_block(struct inode *inode, loff_t block_start,				      loff_t block_end, int pcount,				      struct page **pages, unsigned poffset,				      int *errp){	unsigned int zisofs_block_shift = ISOFS_I(inode)->i_format_parm[1];	unsigned int bufsize = ISOFS_BUFFER_SIZE(inode);	unsigned int bufshift = ISOFS_BUFFER_BITS(inode);	unsigned int bufmask = bufsize - 1;	int i, block_size = block_end - block_start;	z_stream stream = { .total_out = 0,			    .avail_in = 0,			    .avail_out = 0, };	int zerr;	int needblocks = (block_size + (block_start & bufmask) + bufmask)				>> bufshift;	int haveblocks;	blkcnt_t blocknum;	struct buffer_head *bhs[needblocks + 1];	int curbh, curpage;	if (block_size > deflateBound(1UL << zisofs_block_shift)) {		*errp = -EIO;		return 0;	}	/* Empty block? */	if (block_size == 0) {		for ( i = 0 ; i < pcount ; i++ ) {			if (!pages[i])				continue;			memset(page_address(pages[i]), 0, PAGE_SIZE);			flush_dcache_page(pages[i]);			SetPageUptodate(pages[i]);		}		return ((loff_t)pcount) << PAGE_SHIFT;	}	/* Because zlib is not thread-safe, do all the I/O at the top. */	blocknum = block_start >> bufshift;	memset(bhs, 0, (needblocks + 1) * sizeof(struct buffer_head *));	haveblocks = isofs_get_blocks(inode, blocknum, bhs, needblocks);	ll_rw_block(REQ_OP_READ, 0, haveblocks, bhs);	curbh = 0;	curpage = 0;	/*	 * First block is special since it may be fractional.  We also wait for	 * it before grabbing the zlib mutex; odds are that the subsequent	 * blocks are going to come in in short order so we don't hold the zlib	 * mutex longer than necessary.	 */	if (!bhs[0])		goto b_eio;	wait_on_buffer(bhs[0]);	if (!buffer_uptodate(bhs[0])) {		*errp = -EIO;		goto b_eio;	}	stream.workspace = zisofs_zlib_workspace;	mutex_lock(&zisofs_zlib_lock);			zerr = zlib_inflateInit(&stream);	if (zerr != Z_OK) {		if (zerr == Z_MEM_ERROR)			*errp = -ENOMEM;		else			*errp = -EIO;		printk(KERN_DEBUG "zisofs: zisofs_inflateInit returned %d/n",			       zerr);		goto z_eio;	}	while (curpage < pcount && curbh < haveblocks &&	       zerr != Z_STREAM_END) {		if (!stream.avail_out) {			if (pages[curpage]) {				stream.next_out = page_address(pages[curpage])						+ poffset;				stream.avail_out = PAGE_SIZE - poffset;				poffset = 0;			} else {				stream.next_out = (void *)&zisofs_sink_page;				stream.avail_out = PAGE_SIZE;			}		}		if (!stream.avail_in) {			wait_on_buffer(bhs[curbh]);			if (!buffer_uptodate(bhs[curbh])) {				*errp = -EIO;				break;			}			stream.next_in  = bhs[curbh]->b_data +//.........这里部分代码省略.........
开发者ID:AshishNamdev,项目名称:linux,代码行数:101,


示例27: zlib_uncompress

static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,	struct buffer_head **bh, int b, int offset, int length, int srclength,	int pages){	int zlib_err = 0, zlib_init = 0;	int avail, bytes, k = 0, page = 0;	z_stream *stream = msblk->stream;	mutex_lock(&msblk->read_data_mutex);	stream->avail_out = 0;	stream->avail_in = 0;	bytes = length;	do {		if (stream->avail_in == 0 && k < b) {			avail = min(bytes, msblk->devblksize - offset);			bytes -= avail;			wait_on_buffer(bh[k]);			if (!buffer_uptodate(bh[k]))				goto release_mutex;			if (avail == 0) {				offset = 0;				put_bh(bh[k++]);				continue;			}			stream->next_in = bh[k]->b_data + offset;			stream->avail_in = avail;			offset = 0;		}		if (stream->avail_out == 0 && page < pages) {			stream->next_out = buffer[page++];			stream->avail_out = PAGE_CACHE_SIZE;		}		if (!zlib_init) {			zlib_err = zlib_inflateInit(stream);			if (zlib_err != Z_OK) {				ERROR("zlib_inflateInit returned unexpected "					"result 0x%x, srclength %d/n",					zlib_err, srclength);				goto release_mutex;			}			zlib_init = 1;		}		zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH);		if (stream->avail_in == 0 && k < b)			put_bh(bh[k++]);	} while (zlib_err == Z_OK);	if (zlib_err != Z_STREAM_END) {		ERROR("zlib_inflate error, data probably corrupt/n");		goto release_mutex;	}	zlib_err = zlib_inflateEnd(stream);	if (zlib_err != Z_OK) {		ERROR("zlib_inflate error, data probably corrupt/n");		goto release_mutex;	}	length = stream->total_out;	mutex_unlock(&msblk->read_data_mutex);	return length;release_mutex:	mutex_unlock(&msblk->read_data_mutex);	for (; k < b; k++)		put_bh(bh[k]);	return -EIO;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:78,


示例28: qDebug

voidQcOsmPbfReader::read_blob(){  // size of the following blob  int32_t data_size = m_blob_header.datasize();  qDebug().nospace() << "  datasize = " << data_size;  // ensure the blob is smaller then MAX_BLOB_SIZE  if (data_size > OSMPBF::max_uncompressed_blob_size)    qCritical() << "blob-size is bigger then allowed (" << data_size << " > " << OSMPBF::max_uncompressed_blob_size << ")";  // read the blob from the file  if (m_data_stream.readRawData(m_buffer, data_size) == -1)    qCritical() << "unable to read blob from file";  // parse the blob from the read-buffer  if (!m_blob.ParseFromArray(m_buffer, data_size))    qCritical() << "unable to parse blob";  // tell about the blob-header  qDebug().nospace() << "Blob (" << data_size << " bytes)";  // set when we find at least one data stream  bool found_data = false;  // if the blob has uncompressed data  if (m_blob.has_raw()) {    // we have at least one datastream    found_data = true;    // size of the blob-data    m_buffer_size = m_blob.raw().size();    // check that raw_size is set correctly    if (m_buffer_size != m_blob.raw_size())      qWarning() << "  reports wrong raw_size: " << m_blob.raw_size() << " bytes";    // tell about the blob-data    qDebug().nospace() << "  contains uncompressed data: " << m_buffer_size << " bytes";    // copy the uncompressed data over to the unpack_buffer    memcpy(m_unpack_buffer, m_buffer, m_buffer_size);  }  // if the blob has zlib-compressed data  if (m_blob.has_zlib_data()) {    // issue a warning if there is more than one data steam, a blob may only contain one data stream    if (found_data)      qWarning() << "  contains several data streams";    // we have at least one datastream    found_data = true;    // unpacked size    zlib_inflate();  }  // if the blob has lzma-compressed data  if (m_blob.has_lzma_data()) {    // issue a warning if there is more than one data steam, a blob may only contain one data stream    if (found_data)      qWarning() << "  contains several data streams";    // we have at least one datastream    found_data = true;    // unpacked size    lzma_inflate();  }  // check we have at least one data-stream  if (!found_data)    qCritical() << "  does not contain any known data stream";  // switch between different blob-types  auto blob_type = m_blob_header.type();  if (blob_type == "OSMHeader")    // The Blob contains a serialized HeaderBlock message.    // Every fileblock must have one of these blocks before the first 'OSMData' block.    read_osm_header();  else if (blob_type == "OSMData")    // The Blob contains a serialized PrimitiveBlock message.    read_osm_data();  else    // unknown blob type    qWarning() << "  unknown blob type: " << m_blob_header.type().c_str();}
开发者ID:bleausard,项目名称:meije-carto,代码行数:87,



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


C++ zlist_append函数代码示例
C++ zlib_error函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。