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

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

?? gzio.c

?? 一款最完整的工業組態軟源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* gzio.c -- IO on .gz files
 * Copyright (C) 1995-2003 Jean-loup Gailly.
 * For conditions of distribution and use, see copyright notice in zlib.h
 *
 * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
 */

/* @(#) $Id$ */

#include <stdio.h>

#include "zutil.h"

#ifdef NO_DEFLATE       /* for compatiblity with old definition */
#  define NO_GZCOMPRESS
#endif

#ifndef NO_DUMMY_DECL
struct internal_state {int dummy;}; /* for buggy compilers */
#endif

#ifndef Z_BUFSIZE
#  ifdef MAXSEG_64K
#    define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
#  else
#    define Z_BUFSIZE 16384
#  endif
#endif
#ifndef Z_PRINTF_BUFSIZE
#  define Z_PRINTF_BUFSIZE 4096
#endif

#ifdef __MVS__
#  pragma map (fdopen , "\174\174FDOPEN")
   FILE *fdopen(int, const char *);
#endif

#ifndef STDC
extern voidp  malloc OF((uInt size));
extern void   free   OF((voidpf ptr));
#endif

#define ALLOC(size) malloc(size)
#define TRYFREE(p) {if (p) free(p);}

static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */

/* gzip flag byte */
#define ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
#define HEAD_CRC     0x02 /* bit 1 set: header CRC present */
#define EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
#define ORIG_NAME    0x08 /* bit 3 set: original file name present */
#define COMMENT      0x10 /* bit 4 set: file comment present */
#define RESERVED     0xE0 /* bits 5..7: reserved */

typedef struct gz_stream {
    z_stream stream;
    int      z_err;   /* error code for last stream operation */
    int      z_eof;   /* set if end of input file */
    FILE     *file;   /* .gz file */
    Byte     *inbuf;  /* input buffer */
    Byte     *outbuf; /* output buffer */
    uLong    crc;     /* crc32 of uncompressed data */
    char     *msg;    /* error message */
    char     *path;   /* path name for debugging only */
    int      transparent; /* 1 if input file is not a .gz file */
    char     mode;    /* 'w' or 'r' */
    z_off_t  start;   /* start of compressed data in file (header skipped) */
    z_off_t  in;      /* bytes into deflate or inflate */
    z_off_t  out;     /* bytes out of deflate or inflate */
    int      back;    /* one character push-back */
    int      last;    /* true if push-back is last character */
} gz_stream;


local gzFile gz_open      OF((const char *path, const char *mode, int  fd));
local int do_flush        OF((gzFile file, int flush));
local int    get_byte     OF((gz_stream *s));
local void   check_header OF((gz_stream *s));
local int    destroy      OF((gz_stream *s));
local void   putLong      OF((FILE *file, uLong x));
local uLong  getLong      OF((gz_stream *s));

/* ===========================================================================
     Opens a gzip (.gz) file for reading or writing. The mode parameter
   is as in fopen ("rb" or "wb"). The file is given either by file descriptor
   or path name (if fd == -1).
     gz_open returns NULL if the file could not be opened or if there was
   insufficient memory to allocate the (de)compression state; errno
   can be checked to distinguish the two cases (if errno is zero, the
   zlib error is Z_MEM_ERROR).
*/
local gzFile gz_open (path, mode, fd)
    const char *path;
    const char *mode;
    int  fd;
{
    int err;
    int level = Z_DEFAULT_COMPRESSION; /* compression level */
    int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
    char *p = (char*)mode;
    gz_stream *s;
    char fmode[80]; /* copy of mode, without the compression level */
    char *m = fmode;

    if (!path || !mode) return Z_NULL;

    s = (gz_stream *)ALLOC(sizeof(gz_stream));
    if (!s) return Z_NULL;

    s->stream.zalloc = (alloc_func)0;
    s->stream.zfree = (free_func)0;
    s->stream.opaque = (voidpf)0;
    s->stream.next_in = s->inbuf = Z_NULL;
    s->stream.next_out = s->outbuf = Z_NULL;
    s->stream.avail_in = s->stream.avail_out = 0;
    s->file = NULL;
    s->z_err = Z_OK;
    s->z_eof = 0;
    s->in = 0;
    s->out = 0;
    s->back = EOF;
    s->crc = crc32(0L, Z_NULL, 0);
    s->msg = NULL;
    s->transparent = 0;

    s->path = (char*)ALLOC(strlen(path)+1);
    if (s->path == NULL) {
        return destroy(s), (gzFile)Z_NULL;
    }
    strcpy(s->path, path); /* do this early for debugging */

    s->mode = '\0';
    do {
        if (*p == 'r') s->mode = 'r';
        if (*p == 'w' || *p == 'a') s->mode = 'w';
        if (*p >= '0' && *p <= '9') {
            level = *p - '0';
        } else if (*p == 'f') {
          strategy = Z_FILTERED;
        } else if (*p == 'h') {
          strategy = Z_HUFFMAN_ONLY;
        } else if (*p == 'R') {
          strategy = Z_RLE;
        } else {
            *m++ = *p; /* copy the mode */
        }
    } while (*p++ && m != fmode + sizeof(fmode));
    if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;

    if (s->mode == 'w') {
#ifdef NO_GZCOMPRESS
        err = Z_STREAM_ERROR;
#else
        err = deflateInit2(&(s->stream), level,
                           Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
        /* windowBits is passed < 0 to suppress zlib header */

        s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
#endif
        if (err != Z_OK || s->outbuf == Z_NULL) {
            return destroy(s), (gzFile)Z_NULL;
        }
    } else {
        s->stream.next_in  = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);

        err = inflateInit2(&(s->stream), -MAX_WBITS);
        /* windowBits is passed < 0 to tell that there is no zlib header.
         * Note that in this case inflate *requires* an extra "dummy" byte
         * after the compressed stream in order to complete decompression and
         * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
         * present after the compressed stream.
         */
        if (err != Z_OK || s->inbuf == Z_NULL) {
            return destroy(s), (gzFile)Z_NULL;
        }
    }
    s->stream.avail_out = Z_BUFSIZE;

    errno = 0;
    s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);

    if (s->file == NULL) {
        return destroy(s), (gzFile)Z_NULL;
    }
    if (s->mode == 'w') {
        /* Write a very simple .gz header:
         */
        fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
             Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
        s->start = 10L;
        /* We use 10L instead of ftell(s->file) to because ftell causes an
         * fflush on some systems. This version of the library doesn't use
         * start anyway in write mode, so this initialization is not
         * necessary.
         */
    } else {
        check_header(s); /* skip the .gz header */
        s->start = ftell(s->file) - s->stream.avail_in;
    }

    return (gzFile)s;
}

/* ===========================================================================
     Opens a gzip (.gz) file for reading or writing.
*/
gzFile ZEXPORT gzopen (path, mode)
    const char *path;
    const char *mode;
{
    return gz_open (path, mode, -1);
}

/* ===========================================================================
     Associate a gzFile with the file descriptor fd. fd is not dup'ed here
   to mimic the behavio(u)r of fdopen.
*/
gzFile ZEXPORT gzdopen (fd, mode)
    int fd;
    const char *mode;
{
    char name[20];

    if (fd < 0) return (gzFile)Z_NULL;
    sprintf(name, "<fd:%d>", fd); /* for debugging */

    return gz_open (name, mode, fd);
}

/* ===========================================================================
 * Update the compression level and strategy
 */
int ZEXPORT gzsetparams (file, level, strategy)
    gzFile file;
    int level;
    int strategy;
{
    gz_stream *s = (gz_stream*)file;

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

    /* Make room to allow flushing */
    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;
        }
        s->stream.avail_out = Z_BUFSIZE;
    }

    return deflateParams (&(s->stream), level, strategy);
}

/* ===========================================================================
     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
   for end of file.
   IN assertion: the stream s has been sucessfully opened for reading.
*/
local int get_byte(s)
    gz_stream *s;
{
    if (s->z_eof) return EOF;
    if (s->stream.avail_in == 0) {
        errno = 0;
        s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
        if (s->stream.avail_in == 0) {
            s->z_eof = 1;
            if (ferror(s->file)) s->z_err = Z_ERRNO;
            return EOF;
        }
        s->stream.next_in = s->inbuf;
    }
    s->stream.avail_in--;
    return *(s->stream.next_in)++;
}

/* ===========================================================================
      Check the gzip header of a gz_stream opened for reading. Set the stream
    mode to transparent if the gzip magic header is not present; set s->err
    to Z_DATA_ERROR if the magic header is present but the rest of the header
    is incorrect.
    IN assertion: the stream s has already been created sucessfully;
       s->stream.avail_in is zero for the first time, but may be non-zero
       for concatenated .gz files.
*/
local void check_header(s)
    gz_stream *s;
{
    int method; /* method byte */
    int flags;  /* flags byte */
    uInt len;
    int c;

    /* Assure two bytes in the buffer so we can peek ahead -- handle case
       where first byte of header is at the end of the buffer after the last
       gzip segment */
    len = s->stream.avail_in;
    if (len < 2) {
        if (len) s->inbuf[0] = s->stream.next_in[0];
        errno = 0;
        len = fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
        if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
        s->stream.avail_in += len;
        s->stream.next_in = s->inbuf;
        if (s->stream.avail_in < 2) {
            s->transparent = s->stream.avail_in;
            return;
        }
    }

    /* Peek ahead to check the gzip magic header */
    if (s->stream.next_in[0] != gz_magic[0] ||
        s->stream.next_in[1] != gz_magic[1]) {
        s->transparent = 1;
        return;
    }
    s->stream.avail_in -= 2;
    s->stream.next_in += 2;

    /* Check the rest of the gzip header */
    method = get_byte(s);
    flags = get_byte(s);
    if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
        s->z_err = Z_DATA_ERROR;
        return;
    }

    /* Discard time, xflags and OS code: */
    for (len = 0; len < 6; len++) (void)get_byte(s);

    if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
        len  =  (uInt)get_byte(s);
        len += ((uInt)get_byte(s))<<8;
        /* len is garbage if EOF but the loop below will quit anyway */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线看国产一区| 美日韩一区二区三区| 成人久久视频在线观看| 久久精品一区蜜桃臀影院| 成人黄色软件下载| 日韩毛片高清在线播放| 欧美午夜不卡视频| 日本少妇一区二区| 久久精品人人爽人人爽| 色综合久久中文综合久久97| 一区二区高清免费观看影视大全 | 香蕉成人伊视频在线观看| 7777精品伊人久久久大香线蕉最新版 | 亚洲欧美视频在线观看视频| 91黄视频在线观看| 美女一区二区视频| 国产女人aaa级久久久级| 日本高清不卡一区| 美女网站视频久久| 一色屋精品亚洲香蕉网站| 欧美猛男gaygay网站| 激情文学综合丁香| 亚洲美女屁股眼交| 日韩三级在线免费观看| 不卡欧美aaaaa| 日本午夜精品一区二区三区电影| 久久久久一区二区三区四区| 色综合久久中文字幕| 激情五月婷婷综合| 亚洲欧美激情小说另类| 欧美mv日韩mv| 91国偷自产一区二区三区观看| 久久精品99国产精品日本| 国产精品成人一区二区三区夜夜夜 | 91在线观看高清| 另类的小说在线视频另类成人小视频在线 | 亚洲va韩国va欧美va精品| 国产欧美一区二区三区沐欲| 欧美精品第1页| 99久久精品国产精品久久| 日精品一区二区| 亚洲精品一二三| 国产欧美日韩亚州综合 | 欧美性猛片xxxx免费看久爱| 国产精品一区二区男女羞羞无遮挡| 亚洲综合视频网| 国产精品久久777777| 精品理论电影在线| 91精品国产综合久久香蕉的特点| 9i看片成人免费高清| 精品一区二区影视| 日韩电影在线观看一区| 一区二区三区在线观看欧美| 国产清纯美女被跳蛋高潮一区二区久久w| 精品视频一区二区三区免费| av一区二区三区四区| 国精产品一区一区三区mba桃花 | 日韩一区二区三区免费观看| 日本精品视频一区二区三区| 东方欧美亚洲色图在线| 久久成人久久鬼色| 日本中文字幕一区二区视频 | 午夜一区二区三区在线观看| 亚洲婷婷综合色高清在线| 国产女主播一区| 久久精品一区二区三区四区| 日韩精品一区二区三区视频 | 国产成人在线电影| 极品少妇xxxx精品少妇| 婷婷国产在线综合| 亚洲一二三区视频在线观看| 亚洲日本在线a| 一区二区三区中文字幕精品精品 | 美女诱惑一区二区| 日本欧美一区二区| 蜜臀av一级做a爰片久久| 日韩精品免费视频人成| 日韩成人一级片| 美女在线视频一区| 国产在线观看一区二区| 国产乱理伦片在线观看夜一区| 久久国产麻豆精品| 国产在线看一区| 国产成人亚洲精品青草天美| 国产老肥熟一区二区三区| 国产精品一区二区黑丝| 粉嫩蜜臀av国产精品网站| 成人精品一区二区三区四区| 成人av电影在线| 色激情天天射综合网| 欧美日韩国产另类不卡| 欧美一区二区三区视频在线观看| 日韩欧美国产午夜精品| 久久九九久精品国产免费直播| 久久久噜噜噜久噜久久综合| 国产精品久久久久久久久免费樱桃 | 色狠狠桃花综合| 91麻豆精品国产自产在线 | 91精品国产综合久久久蜜臀图片| 91精品福利在线一区二区三区| 欧美xxxxxxxx| 中文字幕一区二区三区不卡在线| 亚洲欧美偷拍卡通变态| 视频一区欧美日韩| 国产精品亚洲а∨天堂免在线| av亚洲精华国产精华精华| 欧美亚洲国产一区二区三区va| 日韩一本二本av| 国产精品色眯眯| 亚洲成人高清在线| 国产成人av自拍| 欧美日韩一区二区三区在线 | 成人精品一区二区三区中文字幕| 欧美综合久久久| 久久久久久久久蜜桃| 亚洲欧洲日韩一区二区三区| 天堂在线一区二区| 成人综合婷婷国产精品久久蜜臀 | 欧美精品一区二区久久婷婷| 国产精品欧美综合在线| 亚洲成人1区2区| 成人短视频下载| 日韩欧美在线影院| 亚洲精品国产第一综合99久久| 免费在线成人网| 在线观看国产91| 国产精品三级电影| 日韩有码一区二区三区| 不卡影院免费观看| 日韩欧美高清一区| 亚洲午夜电影网| av欧美精品.com| 精品精品欲导航| 亚洲午夜久久久久| 99在线热播精品免费| 欧美哺乳videos| 香蕉乱码成人久久天堂爱免费| 成人午夜视频福利| 精品卡一卡二卡三卡四在线| 亚洲福利一二三区| 成人精品免费看| 26uuu久久天堂性欧美| 丝袜诱惑亚洲看片| 色老头久久综合| 成人欧美一区二区三区1314| 美国毛片一区二区三区| 精品视频在线看| 一区二区三区四区视频精品免费 | 久久这里都是精品| 免费成人美女在线观看| 欧美日韩情趣电影| 亚洲精品va在线观看| 91免费精品国自产拍在线不卡 | 日韩三级伦理片妻子的秘密按摩| 亚洲永久精品国产| 91麻豆免费视频| 中文字幕一区视频| 懂色av一区二区三区免费观看| 久久精品一区二区三区不卡| 国产一区二区三区四区五区美女| 777午夜精品免费视频| 日日欢夜夜爽一区| 欧美一区二区免费| 日韩av一区二区三区四区| 欧美精品xxxxbbbb| 日本女优在线视频一区二区| 欧美日韩不卡一区| 无码av免费一区二区三区试看| 精品1区2区3区| 亚洲va欧美va国产va天堂影院| 欧美麻豆精品久久久久久| 天天av天天翘天天综合网色鬼国产| 欧美亚洲国产一区二区三区| 午夜精品久久久久久久蜜桃app | 日韩精品一区二区三区视频| 另类成人小视频在线| 精品处破学生在线二十三| 国内久久精品视频| 中文字幕精品三区| 91网站最新地址| 亚洲狠狠爱一区二区三区| 欧美日韩成人综合| 麻豆精品一区二区综合av| 亚洲精品一线二线三线| 成人一区二区三区在线观看| 中文字幕日韩欧美一区二区三区| 色综合久久88色综合天天6| 一区二区免费看| 91麻豆精品国产自产在线| 国产一区二区三区免费| 中文字幕一区二区在线播放 | 美女久久久精品| 国产午夜三级一区二区三| 97se亚洲国产综合在线| 亚洲r级在线视频| 国产视频在线观看一区二区三区| 成人精品国产免费网站| 亚洲一区二区三区四区在线免费观看 | 精品久久久久99| 成人av在线影院|