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


C++ zerr函数代码示例

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


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

示例1: stuff

int
stuff(char *fn)
{
    FILE *in;
    char *buf;
    off_t len;

    if (!(in = fopen(unmeta(fn), "r"))) {
	zerr("can't open %s", fn);
	return 1;
    }
    fseek(in, 0, 2);
    len = ftell(in);
    fseek(in, 0, 0);
    buf = (char *)zalloc(len + 1);
    if (!(fread(buf, len, 1, in))) {
	zerr("read error on %s", fn);
	fclose(in);
	zfree(buf, len + 1);
	return 1;
    }
    fclose(in);
    buf[len] = '\0';
    fwrite(buf, len, 1, stderr);
    fflush(stderr);
    inputsetline(metafy(buf, len, META_REALLOC), INP_FREE);
    return 0;
}
开发者ID:netroby,项目名称:zsh,代码行数:28,代码来源:input.c

示例2: main

/* compress or decompress from stdin to stdout */
int main(int argc, char **argv)
{
	jlg_log("Start...");
	int ret;

    /* avoid end-of-line conversions */
    SET_BINARY_MODE(stdin);
    SET_BINARY_MODE(stdout);

    /* do compression if no arguments */
    if (argc == 1) {
    	jlg_log("Compressing...");
        ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* do decompression if -d specified */
    else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
    	jlg_log("Decompressing...");
        ret = inf(stdin, stdout);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* otherwise, report usage */
    else {
        fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
        return 1;
    }
}
开发者ID:jlguenego,项目名称:sandbox,代码行数:34,代码来源:main.c

示例3: main

/* compress or decompress from stdin to stdout */
int main(int argc, char **argv)
{
    int ret;

    /* do compression if no arguments */
    if (argc == 1) {
        ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* do decompression if -d specified */
    else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
        ret = inf(stdin, stdout);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* otherwise, report usage */
    else {
        fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
        return 1;
    }
}
开发者ID:tombibsd,项目名称:netbsd-src,代码行数:27,代码来源:zpipe.c

示例4: main

int
main(int argc, char *argv[])
{
	elf_object *elf;

	add_fixup_anchor_list(zlib_anchors);

	elf = elf_dlopen("/lib/x86_64-linux-gnu/libz.so.1.2.7");
	if (elf == NULL)
		return -1;

	deflateInit = (deflateInit_fn)elf_dlsym(elf, "deflateInit_");
	if (deflateInit == NULL)
		goto out;

	deflateEnd = (deflateEnd_fn)elf_dlsym(elf, "deflateEnd");
	if (deflateEnd == NULL)
		goto out;

	deflate = (deflate_fn)elf_dlsym(elf, "deflate");
	if (deflate == NULL)
		goto out;

	inflateInit = (inflateInit_fn)elf_dlsym(elf, "inflateInit_");
	if (inflateInit == NULL)
		goto out;

	inflateEnd = (inflateEnd_fn)elf_dlsym(elf, "inflateEnd");
	if (inflateEnd == NULL)
		goto out;

	inflate = (inflate_fn)elf_dlsym(elf, "inflate");
	if (inflate == NULL)
		goto out;

	if (argc == 1) {
		int ret;
		ret = def(stdin, stdout, -1);
		if (ret != 0)
			zerr(ret);
		return ret;
	}

	if (argc == 2 && !strcmp(argv[1], "-d")) {
		int ret = inf(stdin, stdout);
		if (ret != 0)
			zerr(ret);
		return ret;
	}

	fprintf(stderr, "usage: a.out [-d] <source> dest\n");

	elf_dlclose(elf);
	return 0;

out:
	elf_dlclose(elf);
	return -2;
}
开发者ID:cquaid,项目名称:lib_loader,代码行数:59,代码来源:libz_loader.c

示例5: zlib_decompress

int
zlib_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen,
		int level, uchar_t chdr, int btype, void *data)
{
	int err;
	unsigned int slen, dlen;
	uint64_t _srclen = srclen;
	uint64_t _dstlen = *dstlen;
	uchar_t *dst1 = (uchar_t *)dst;
	uchar_t *src1 = (uchar_t *)src;
	z_stream *zs = (z_stream *)data;

	while (_srclen > 0) {
		if (_srclen > SINGLE_CALL_MAX) {
			slen = SINGLE_CALL_MAX;
		} else {
			slen = _srclen;
		}
		if (_dstlen > SINGLE_CALL_MAX) {
			dlen = SINGLE_CALL_MAX;
		} else {
			dlen = _dstlen;
		}

		zs->next_in = src1;
		zs->avail_in = slen;
		zs->next_out = dst1;
		zs->avail_out = dlen;

		err = inflate(zs, Z_NO_FLUSH);
		if (err != Z_OK && err != Z_STREAM_END) {
			zerr(err, 0);
			return (-1);
		}

		dst1 += (dlen - zs->avail_out);
		_dstlen -= (dlen - zs->avail_out);
		src1 += (slen - zs->avail_in);
		_srclen -= (slen - zs->avail_in);

		if (err == Z_STREAM_END) {
			if (_srclen > 0) {
				zerr(Z_DATA_ERROR, 0);
				return (-1);
			} else {
				break;
			}
		}
	}

	*dstlen = *dstlen - _dstlen;
	err = inflateReset(zs);
	if (err != Z_OK) {
		zerr(err, 1);
		return (-1);
	}
	return (0);
}
开发者ID:muyu,项目名称:pcompress,代码行数:58,代码来源:zlib_compress.c

示例6: def

/* Compress from file source to file dest until EOF on source.
   def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
   allocated for processing, Z_STREAM_ERROR if an invalid compression
   level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
   version of the library linked do not match, or Z_ERRNO if there is
   an error reading or writing the files. */
bool Misc::deflate(const uint8_t* in, size_t inlen, std::ostream& dest, string& err, int CHUNK, int level)
{
  int ret, flush;
  unsigned have;
  z_stream strm;
  if ( level == -1 ) level = Z_BEST_COMPRESSION;
  if ( CHUNK == -1 ) CHUNK = CL_Z_DEFAULT_CHUNK;
  uint8_t* out = (uint8_t*)malloc(CHUNK);

  /* allocate deflate state */
  strm.zalloc = Z_NULL;
  strm.zfree = Z_NULL;
  strm.opaque = Z_NULL;
  ret = deflateInit(&strm, level);
  if (ret != Z_OK){
    free(out);
    zerr(ret, err);
    return false;
  }

  /* compress until end of file */
  do {
    strm.avail_in = inlen;
    strm.next_in = (uint8_t*)in;
    flush = Z_FINISH;

    /* run deflate() on input until output buffer not full, finish
       compression if all of source has been read in */
    do {
      strm.avail_out = CHUNK;
      strm.next_out = out;
      ret = ::deflate(&strm, flush);  /* no bad return value */
      assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
      have = CHUNK - strm.avail_out;
      dest.write( (char*)out,have);
      if ( dest.fail() ) {
        (void)deflateEnd(&strm);
        free(out);
        zerr(Z_ERRNO, err);
        return false;
      }
    } while (strm.avail_out == 0);
    assert(strm.avail_in == 0);   /* all input will be used */

    /* done when last data in file processed */
  } while (flush != Z_FINISH);
  assert(ret == Z_STREAM_END);    /* stream will be complete */

  /* clean up and return */
  (void)deflateEnd(&strm);
  free(out);
  return true;
}
开发者ID:zipang29,项目名称:rss,代码行数:59,代码来源:Misc.cpp

示例7: main

/* compress or decompress from stdin to stdout */
int main(int argc, char **argv)
{
    int ret;

    /* avoid end-of-line conversions */

    /* do compression if no arguments */
    if (argc == 3) {
           char *addr;
           int fdr, fdw;
           struct stat sb;
           size_t out_len =6000*1000;
           out_len*=1000 ;
           char *outbuff= (char*)malloc(out_len );
           off_t offset, pa_offset;
           size_t length;
           fdr = open( argv[1], O_RDONLY);
           fstat(fdr, &sb);
           length = sb.st_size;
           addr = mmap(NULL, length, PROT_READ,
                       MAP_PRIVATE, fdr, 0);
           printf("input length = %lld\n",  length);
           length = deflate_mmap(addr, length , outbuff, out_len, 7 );
           printf("output length = %lld\n",  length);
           size_t len;
           fdw = open( argv[2], O_CREAT | O_WRONLY, 0666);
           
           while ( len = write(fdw, outbuff, length)){
                length -=len;
                outbuff +=len;
            }
           //ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
           if (ret != Z_OK)
               zerr(ret);
           return ret;
    }

    /* do decompression if -d specified */
    else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
        ret = inf(stdin, stdout);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* otherwise, report usage */
    else {
        fputs("zpipe usage: zpipe [-d] source dest\n", stderr);
        return 1;
    }
}
开发者ID:mostlybrainless,项目名称:acroparallels2015,代码行数:52,代码来源:zpipe_with_mmap.c

示例8: parsestr

mod_export int
parsestr(char *s)
{
    int err;

    if ((err = parsestrnoerr(s))) {
	untokenize(s);
	if (err > 32 && err < 127)
	    zerr("parse error near `%c'", NULL, err);
	else
	    zerr("parse error", NULL, 0);
    }
    return err;
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:14,代码来源:lex.c

示例9: squeeze

    void squeeze(disk_stream *inflight, unsigned long superp)
    {
      z_stream *zlib_stream =  inflight->zlib_streams[superp];
      int ret;
      unsigned long disk_buffer_pos;
      while(zlib_stream->avail_in) {
	ret = deflate(zlib_stream, Z_NO_FLUSH);
	if(ret != Z_OK) {
	  BOOST_LOG_TRIVIAL(fatal) << "Compression failure:("
				   << ret << ")"
				   << zerr(ret);
	  exit(-1);
	}
	if(zlib_stream->avail_out == 0) {
	  disk_buffer_pos = inflight->disk_pos[superp];
	  inflight->disk_pos[superp]   += stream_unit;
	  inflight->disk_bytes[superp] += stream_unit;
	  do_flip_IO(inflight->flip_buffers[superp],
		     disk_buffer_pos,
		     stream_unit,
		     false);
	  zlib_stream->avail_out = stream_unit;
	  zlib_stream->next_out = inflight->flip_buffers[superp]->ready;
	}
      }
    }
开发者ID:Junyaozhao,项目名称:x-stream,代码行数:26,代码来源:disk_io.hpp

示例10: setmathvar

static mnumber
setmathvar(struct mathvalue *mvp, mnumber v)
{
    if (mvp->pval) {
	/*
	 * This value may have been hanging around for a while.
	 * Be ultra-paranoid in checking the variable is still valid.
	 */
	char *s = mvp->lval, *ptr;
	Param pm;
	DPUTS(!mvp->lval, "no variable name but variable value in math");
	if ((ptr = strchr(s, '[')))
	    s = dupstrpfx(s, ptr - s);
	pm = (Param) paramtab->getnode(paramtab, s);
	if (pm == mvp->pval->pm) {
	    if (noeval)
		return v;
	    setnumvalue(mvp->pval, v);
	    return v;
	}
	/* Different parameter, start again from scratch */
	mvp->pval = NULL;
    }
    if (!mvp->lval) {
	zerr("lvalue required");
	v.type = MN_INTEGER;
	v.u.l = 0;
	return v;
    }
    if (noeval)
	return v;
    untokenize(mvp->lval);
    setnparam(mvp->lval, v);
    return v;
}
开发者ID:brandt,项目名称:zsh,代码行数:35,代码来源:math.c

示例11: modentry

int
modentry(int boot, Module m, void *ptr)
{
    switch (boot) {
    case 0:
	return setup_(m);
	break;

    case 1:
	return boot_(m);
	break;

    case 2:
	return cleanup_(m);
	break;

    case 3:
	return finish_(m);
	break;

    case 4:
	return features_(m, (char ***)ptr);
	break;

    case 5:
	return enables_(m, (int **)ptr);
	break;

    default:
	zerr("bad call to modentry");
	return 1;
	break;
    }
}
开发者ID:AMDmi3,项目名称:zsh,代码行数:34,代码来源:modentry.c

示例12: decode_out

int decode_out(Gzb64* gzb64, unsigned char* buf, const size_t length)
{
	int zret, ret;

	/* should be guaranteed at least length after inflate */
	int gz_in_bytes = evbuffer_get_contiguous_space(gzb64->decode_output_buffer);
	unsigned char* gzin_buf = evbuffer_pullup(gzb64->decode_output_buffer, gz_in_bytes );

	if(DEBUG) hex_debug(gzin_buf, gz_in_bytes);
	
	gzb64->gz_decode_strm.next_in = gzin_buf;
	gzb64->gz_decode_strm.avail_in = gz_in_bytes;
	gzb64->gz_decode_strm.next_out = buf;
    gzb64->gz_decode_strm.avail_out = length;
	zret = inflate (& gzb64->gz_decode_strm, Z_NO_FLUSH);
	if(zret < 0) zerr(zret);

	evbuffer_drain(gzb64->decode_output_buffer, gz_in_bytes - gzb64->gz_decode_strm.avail_in);

	ret = length - gzb64->gz_decode_strm.avail_out;
	
	if(gzb64->decoded_last_chunk && 0 == ret) {
		resetDecoder(gzb64);
	}

	return ret;
}
开发者ID:nfvproject,项目名称:TFM,代码行数:27,代码来源:compress.c

示例13: __compress__

int __compress__(struct strbuf *src, struct strbuf *dest, int level)
{
    z_stream stream;
    z_stream_init(&stream);
    int ret, flush;
    unsigned have;
    ret = deflateInit(&stream, Z_DEFAULT_COMPRESSION);
    if (ret != Z_OK)
        zerr(ret);
    char buffer[CHUNK_LENGTH];
    stream.avail_in = src->len;
    stream.next_in = (Bytef *)src->buf;
    do {
        flush = (stream.avail_in < CHUNK_LENGTH) ? Z_FINISH : Z_NO_FLUSH;
        do {
            stream.avail_out = CHUNK_LENGTH;
            stream.next_out = (Bytef *)buffer;
            ret = deflate(&stream, flush);
            have = CHUNK_LENGTH - stream.avail_out;
            strbuf_add(dest, buffer, have);
        } while (stream.avail_out == 0);

        assert(stream.avail_in == 0);

    } while (flush != Z_FINISH);
    assert(ret == Z_STREAM_END);
    deflateEnd(&stream);
    return ret;
}
开发者ID:crypton3535,项目名称:pegit,代码行数:29,代码来源:mz.c

示例14: zlib_init

int
zlib_init(void **data, int *level, int nthreads, uint64_t chunksize,
	  int file_version, compress_op_t op)
{
	z_stream *zs;
	int ret;

	zs = (z_stream *)slab_alloc(NULL, sizeof (z_stream));
	zs->zalloc = slab_alloc_ui;
	zs->zfree = slab_free;
	zs->opaque = NULL;

	if (*level > 9) *level = 9;
	if (op == COMPRESS) {
		ret = deflateInit2(zs, *level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
	} else {
		if (file_version < 5) {
			ret = inflateInit(zs);
		} else {
			ret = inflateInit2(zs, -15);
		}
	}
	if (ret != Z_OK) {
		zerr(ret, 0);
		return (-1);
	}

	*data = zs;
	return (0);
}
开发者ID:muyu,项目名称:pcompress,代码行数:30,代码来源:zlib_compress.c

示例15: parsestr

mod_export int
parsestr(char **s)
{
    int err;

    if ((err = parsestrnoerr(s))) {
	untokenize(*s);
	if (!(errflag & ERRFLAG_INT)) {
	    if (err > 32 && err < 127)
		zerr("parse error near `%c'", err);
	    else
		zerr("parse error");
	}
    }
    return err;
}
开发者ID:AMDmi3,项目名称:zsh,代码行数:16,代码来源:lex.c


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