亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gzio.cpp

?? 一個C語言實現的壓縮解壓的工具代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:

    return (int)(len - s->stream.avail_out);
}


/* ===========================================================================
      Reads one byte from the compressed file. gzgetc returns this byte
   or -1 in case of end of file or error.
*/
int ZEXPORT gzgetc( gzFile file)
   
{
    unsigned char c;

    return gzread(file, &c, 1) == 1 ? c : -1;
}


/* ===========================================================================
      Reads bytes from the compressed file until len-1 characters are
   read, or a newline character is read and transferred to buf, or an
   end-of-file condition is encountered.  The string is then terminated
   with a null character.
      gzgets returns buf, or Z_NULL in case of error.

      The current implementation is not optimized at all.
*/
char * ZEXPORT gzgets(   gzFile file,
    char *buf,
    int len)
 
{
    char *b = buf;
    if (buf == Z_NULL || len <= 0) return Z_NULL;

    while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
    *buf = '\0';
    return b == buf && len > 0 ? Z_NULL : b;
}


#ifndef NO_DEFLATE
/* ===========================================================================
     Writes the given number of uncompressed bytes into the compressed file.
   gzwrite returns the number of bytes actually written (0 in case of error).
*/
int ZEXPORT gzwrite (  gzFile file,
    const voidp buf,
    unsigned len)
  
{
    gz_stream *s = (gz_stream*)file;

    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;

    s->stream.next_in = (Bytef*)buf;
    s->stream.avail_in = len;

    while (s->stream.avail_in != 0) {

        if (s->stream.avail_out == 0) {

            s->stream.next_out = s->outbuf;
            if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
                s->z_err = Z_ERRNO;
                break;
            }
            s->stream.avail_out = Z_BUFSIZE;
        }
        s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
        if (s->z_err != Z_OK) break;
    }
    s->crc = crc32(s->crc, (const Bytef *)buf, len);

    return (int)(len - s->stream.avail_in);
}

/* ===========================================================================
     Converts, formats, and writes the args to the compressed file under
   control of the format string, as in fprintf. gzprintf returns the number of
   uncompressed bytes actually written (0 in case of error).
*/
#ifdef STDC
#include <stdarg.h>

int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
{
    char buf[Z_PRINTF_BUFSIZE];
    va_list va;
    int len;

    va_start(va, format);
#ifdef HAS_vsnprintf
    (void)vsnprintf(buf, sizeof(buf), format, va);
#else
    (void)vsprintf(buf, format, va);
#endif
    va_end(va);
    len = strlen(buf); /* some *sprintf don't return the nb of bytes written */
    if (len <= 0) return 0;

    return gzwrite(file, buf, (unsigned)len);
}
#else /* not ANSI C */

int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
	               a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
    gzFile file;
    const char *format;
    int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
	a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
{
    char buf[Z_PRINTF_BUFSIZE];
    int len;

#ifdef HAS_snprintf
    snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
	     a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
#else
    sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
	    a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
#endif
    len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */
    if (len <= 0) return 0;

    return gzwrite(file, buf, len);
}
#endif

/* ===========================================================================
      Writes c, converted to an unsigned char, into the compressed file.
   gzputc returns the value that was written, or -1 in case of error.
*/
int ZEXPORT gzputc(   gzFile file,
    int c)
 
{
    unsigned char cc = (unsigned char) c; /* required for big endian systems */

    return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
}


/* ===========================================================================
      Writes the given null-terminated string to the compressed file, excluding
   the terminating null character.
      gzputs returns the number of characters written, or -1 in case of error.
*/
int ZEXPORT gzputs(    gzFile file,
    const char *s)

{
    return gzwrite(file, (char*)s, (unsigned)strlen(s));
}


/* ===========================================================================
     Flushes all pending output into the compressed file. The parameter
   flush is as in the deflate() function.
*/
local int do_flush (    gzFile file,
    int flush)

{
    uInt len;
    int done = 0;
    gz_stream *s = (gz_stream*)file;

    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;

    s->stream.avail_in = 0; /* should be zero already anyway */

    for (;;) {
        len = Z_BUFSIZE - s->stream.avail_out;

        if (len != 0) {
            if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
                s->z_err = Z_ERRNO;
                return Z_ERRNO;
            }
            s->stream.next_out = s->outbuf;
            s->stream.avail_out = Z_BUFSIZE;
        }
        if (done) break;
        s->z_err = deflate(&(s->stream), flush);

	/* Ignore the second of two consecutive flushes: */
	if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;

        /* deflate has finished flushing only when it hasn't used up
         * all the available space in the output buffer: 
         */
        done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
 
        if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
    }
    return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
}

int ZEXPORT gzflush (     gzFile file,
     int flush)

{
    gz_stream *s = (gz_stream*)file;
    int err = do_flush (file, flush);

    if (err) return err;
    fflush(s->file);
    return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
}
#endif /* NO_DEFLATE */

/* ===========================================================================
      Sets the starting position for the next gzread or gzwrite on the given
   compressed file. The offset represents a number of bytes in the
      gzseek returns the resulting offset location as measured in bytes from
   the beginning of the uncompressed stream, or -1 in case of error.
      SEEK_END is not implemented, returns error.
      In this version of the library, gzseek can be extremely slow.
*/
z_off_t ZEXPORT gzseek ( gzFile file,
    z_off_t offset,
    int whence)
   
{
    gz_stream *s = (gz_stream*)file;

    if (s == NULL || whence == SEEK_END ||
	s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
	return -1L;
    }
    
    if (s->mode == 'w') {
#ifdef NO_DEFLATE
	return -1L;
#else
	if (whence == SEEK_SET) {
	    offset -= s->stream.total_in;
	}
	if (offset < 0) return -1L;

	/* At this point, offset is the number of zero bytes to write. */
	if (s->inbuf == Z_NULL) {
	    s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
	    zmemzero(s->inbuf, Z_BUFSIZE);
	}
	while (offset > 0)  {
	    uInt size = Z_BUFSIZE;
	    if (offset < Z_BUFSIZE) size = (uInt)offset;

	    size = gzwrite(file, s->inbuf, size);
	    if (size == 0) return -1L;

	    offset -= size;
	}
	return (z_off_t)s->stream.total_in;
#endif
    }
    /* Rest of function is for reading only */

    /* compute absolute position */
    if (whence == SEEK_CUR) {
	offset += s->stream.total_out;
    }
    if (offset < 0) return -1L;

    if (s->transparent) {
	/* map to fseek */
	s->stream.avail_in = 0;
	s->stream.next_in = s->inbuf;
        if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;

	s->stream.total_in = s->stream.total_out = (uLong)offset;
	return offset;
    }

    /* For a negative seek, rewind and use positive seek */
    if ((uLong)offset >= s->stream.total_out) {
	offset -= s->stream.total_out;
    } else if (gzrewind(file) < 0) {
	return -1L;
    }
    /* offset is now the number of bytes to skip. */

    if (offset != 0 && s->outbuf == Z_NULL) {
	s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
    }
    while (offset > 0)  {
	int size = Z_BUFSIZE;
	if (offset < Z_BUFSIZE) size = (int)offset;

	size = gzread(file, s->outbuf, (uInt)size);
	if (size <= 0) return -1L;
	offset -= size;
    }
    return (z_off_t)s->stream.total_out;
}

/* ===========================================================================
     Rewinds input file. 
*/
int ZEXPORT gzrewind ( gzFile file)
   
{
    gz_stream *s = (gz_stream*)file;
    
    if (s == NULL || s->mode != 'r') return -1;

    s->z_err = Z_OK;
    s->z_eof = 0;
    s->stream.avail_in = 0;
    s->stream.next_in = s->inbuf;
    s->crc = crc32(0L, Z_NULL, 0);
	
    if (s->startpos == 0) { /* not a compressed file */
	rewind(s->file);
	return 0;
    }

    (void) inflateReset(&s->stream);
    return fseek(s->file, s->startpos, SEEK_SET);
}

/* ===========================================================================
     Returns the starting position for the next gzread or gzwrite on the
   given compressed file. This position represents a number of bytes in the
   uncompressed data stream.
*/
z_off_t ZEXPORT gztell (  gzFile file)
  
{
    return gzseek(file, 0L, SEEK_CUR);
}

/* ===========================================================================
     Returns 1 when EOF has previously been detected reading the given
   input stream, otherwise zero.
*/
int ZEXPORT gzeof (    gzFile file)

{
    gz_stream *s = (gz_stream*)file;
    
    return (s == NULL || s->mode != 'r') ? 0 : s->z_eof;
}

/* ===========================================================================
   Outputs a long in LSB order to the given file
*/
local void putLong (    FILE *file,
    uLong x)

{
    int n;
    for (n = 0; n < 4; n++) {
        fputc((int)(x & 0xff), file);
        x >>= 8;
    }
}

/* ===========================================================================
   Reads a long in LSB order from the given gz_stream. Sets z_err in case
   of error.
*/
local uLong getLong ( gz_stream *s)
 
{
    uLong x = (uLong)get_byte(s);
    int c;

    x += ((uLong)get_byte(s))<<8;
    x += ((uLong)get_byte(s))<<16;
    c = get_byte(s);
    if (c == EOF) s->z_err = Z_DATA_ERROR;
    x += ((uLong)c)<<24;
    return x;
}

/* ===========================================================================
     Flushes all pending output if necessary, closes the compressed file
   and deallocates all the (de)compression state.
*/
int ZEXPORT gzclose (    gzFile file)

{
    int err;
    gz_stream *s = (gz_stream*)file;

    if (s == NULL) return Z_STREAM_ERROR;

    if (s->mode == 'w') {
#ifdef NO_DEFLATE
	return Z_STREAM_ERROR;
#else
        err = do_flush (file, Z_FINISH);
        if (err != Z_OK) return destroy((gz_stream*)file);

        putLong (s->file, s->crc);
        putLong (s->file, s->stream.total_in);
#endif
    }
    return destroy((gz_stream*)file);
}

/* ===========================================================================
     Returns the error message for the last error which occured on the
   given compressed file. errnum is set to zlib error number. If an
   error occured in the file system and not in the compression library,
   errnum is set to Z_ERRNO and the application may consult errno
   to get the exact error code.
*/
const char*  ZEXPORT gzerror (    gzFile file,
    int *errnum)

{
    char *m;
    gz_stream *s = (gz_stream*)file;

    if (s == NULL) {
        *errnum = Z_STREAM_ERROR;
        return (const char*)ERR_MSG(Z_STREAM_ERROR);
    }
    *errnum = s->z_err;
    if (*errnum == Z_OK) return (const char*)"";

    m =  (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);

    if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);

    TRYFREE(s->msg);
    s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
    strcpy(s->msg, s->path);
    strcat(s->msg, ": ");
    strcat(s->msg, m);
    return (const char*)s->msg;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
这里只有精品电影| 成人app软件下载大全免费| 日本国产一区二区| 极品瑜伽女神91| 亚洲综合免费观看高清完整版| 久久综合九色综合97婷婷女人| 欧美日韩国产综合一区二区 | 自拍偷拍亚洲欧美日韩| 欧美电影免费观看高清完整版在线 | 午夜视频一区二区三区| 国产精品乱码妇女bbbb| 日韩美女天天操| 69久久夜色精品国产69蝌蚪网| 在线视频一区二区免费| 91视视频在线直接观看在线看网页在线看| 久久超级碰视频| 天堂成人免费av电影一区| 91麻豆蜜桃一区二区三区| 日韩国产成人精品| 日韩有码一区二区三区| 三级久久三级久久久| 午夜电影一区二区| 日本一不卡视频| 视频一区二区国产| 美女mm1313爽爽久久久蜜臀| 免播放器亚洲一区| 激情六月婷婷久久| 国产在线不卡视频| 国产91精品一区二区麻豆网站| 国产黄色91视频| 丁香网亚洲国际| 97精品久久久午夜一区二区三区| 99这里只有久久精品视频| 91免费在线看| 日本福利一区二区| 6080日韩午夜伦伦午夜伦| 51精品久久久久久久蜜臀| 在线观看不卡视频| 欧美日韩你懂得| 91精品一区二区三区久久久久久| 91精品国产综合久久精品| 亚洲精品一区二区三区在线观看 | 日韩一区日韩二区| 香蕉影视欧美成人| 精品中文字幕一区二区| 国产一区二区三区四区五区入口| 国产精品99久久久久久似苏梦涵| 成人毛片老司机大片| 91在线视频官网| 欧美亚洲一区二区在线观看| 91福利在线观看| 日韩免费观看高清完整版 | 婷婷中文字幕一区三区| 韩国视频一区二区| 色哟哟国产精品免费观看| 日韩欧美激情在线| 亚洲欧美偷拍三级| 韩国成人精品a∨在线观看| 99久久久久久99| 91精品麻豆日日躁夜夜躁| 久久精品男人天堂av| 亚洲成人自拍网| 成人综合在线观看| 欧美一级在线视频| 国产精品不卡在线观看| 日本三级韩国三级欧美三级| 精品一区二区三区视频| 色综合中文综合网| 91精品国产综合久久久久久久久久| 国产午夜亚洲精品午夜鲁丝片| 亚洲午夜在线视频| 国产精品一区二区你懂的| 欧美亚洲自拍偷拍| 日韩一区欧美小说| 国产电影一区二区三区| 欧美va在线播放| 亚洲自拍偷拍九九九| 99视频一区二区| 国产欧美一区视频| 国产河南妇女毛片精品久久久| 91精品婷婷国产综合久久性色| 亚洲精品国产精品乱码不99| 韩国精品久久久| 7777精品伊人久久久大香线蕉的| 一区二区免费在线播放| 99视频一区二区| 中文字幕精品—区二区四季| 精品一区二区精品| 精品剧情在线观看| 美女爽到高潮91| 欧美高清性hdvideosex| 亚洲一区二区在线免费看| 欧美影院一区二区| 亚洲午夜羞羞片| www.亚洲免费av| 久久久国产精品麻豆| 美女在线一区二区| 日韩欧美精品三级| 久久精品国产99久久6| 91精品国产综合久久福利| 日本三级亚洲精品| 欧美不卡激情三级在线观看| 免费一区二区视频| 日韩欧美久久一区| 国产福利不卡视频| 亚洲欧洲精品一区二区精品久久久| 成人手机在线视频| 亚洲天堂av老司机| 欧美综合色免费| 天天影视涩香欲综合网| 日韩欧美专区在线| 国产乱子伦视频一区二区三区| 国产欧美视频一区二区| 99精品视频在线免费观看| 中文天堂在线一区| 一本色道亚洲精品aⅴ| 亚洲综合久久久久| 日韩一区二区免费在线电影| 国产麻豆午夜三级精品| 亚洲丝袜另类动漫二区| 在线观看视频一区二区欧美日韩| 亚洲综合免费观看高清完整版| 欧美日韩一区二区在线观看视频| 九一九一国产精品| 日韩毛片在线免费观看| 欧美区一区二区三区| 亚洲成人久久影院| 亚洲精品在线免费播放| 成人国产电影网| 亚洲电影在线免费观看| 久久久久9999亚洲精品| 91精品福利在线| 国产专区欧美精品| 亚洲综合久久av| 久久久精品免费网站| 欧美午夜视频网站| 国产91对白在线观看九色| 亚洲va在线va天堂| 国产午夜精品久久| 日韩一二在线观看| 91色九色蝌蚪| 国产精品自拍av| 亚洲v日本v欧美v久久精品| 国产精品乱码妇女bbbb| 日韩精品中午字幕| 色婷婷狠狠综合| 豆国产96在线|亚洲| 亚洲电影你懂得| 精品av久久707| 欧美特级限制片免费在线观看| 免费xxxx性欧美18vr| 亚洲精品国产无套在线观 | 免费欧美在线视频| 亚洲综合999| 亚洲欧美自拍偷拍| 国产丝袜美腿一区二区三区| 欧美一区二区女人| 欧美三级三级三级| 在线观看日产精品| av不卡一区二区三区| 国产高清精品久久久久| 美女网站一区二区| 亚洲国产一区视频| 亚洲精品视频在线看| 中文字幕在线观看不卡视频| 久久精品一二三| 久久伊99综合婷婷久久伊| 26uuu精品一区二区三区四区在线| 欧美日韩免费观看一区二区三区 | 亚洲欧美日韩人成在线播放| 777欧美精品| 欧美另类高清zo欧美| 日韩精品欧美成人高清一区二区| 亚洲国产成人va在线观看天堂 | 成人app在线| 色婷婷一区二区| 欧美日韩高清一区二区不卡| 精品国产一区二区在线观看| 日本一区二区三区四区| 一个色综合av| 久久精品国产秦先生| 99久久综合国产精品| 欧美猛男gaygay网站| 久久人人爽人人爽| 亚洲精品日韩一| 精品在线亚洲视频| 91日韩在线专区| 日韩欧美黄色影院| 有码一区二区三区| 久久超级碰视频| 色丁香久综合在线久综合在线观看| 日韩限制级电影在线观看| 一区在线观看免费| 九九精品一区二区| 欧美视频三区在线播放| 久久久久久一二三区| 午夜伊人狠狠久久| www.久久精品| 精品久久久久香蕉网| 亚洲一二三专区|