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

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

?? gzio.c

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* gzio.c -- IO on .gz files
 * Copyright (C) 1995-2002 Jean-loup Gailly.
 * Copyright (C) 2000-2002 Tenik Co.,Ltd.(for WindowsCE)
 * For conditions of distribution and use, see copyright notice in zlib.h
 *
 * Compile this file with -DNO_DEFLATE to avoid the compression code.
 */

/* @(#) $Id: gzio.c,v 1.1.1.1 2006/12/05 17:55:40 gazza Exp $ */

#ifdef _WIN32_WCE
#include <windows.h>
#else
#include <stdio.h>
#endif

#include "zutil.h"

struct internal_state {int dummy;}; /* for buggy compilers */

#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

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

static int 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 */
#ifdef _WIN32_WCE
    HANDLE   file;    /* .gz file */
#else
    FILE     *file;   /* .gz file */
#endif
    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' */
    long     startpos; /* start of compressed data in file (header skipped) */
} 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));
#ifdef _WIN32_WCE
local void   putLong      OF((HANDLE file, uLong x));
#else
local void   putLong      OF((FILE *file, uLong x));
#endif
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 return 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;
#ifdef _WIN32_WCE
    char cbuff[10];
    DWORD size;
    TCHAR file[MAX_PATH];
#endif

    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;
#ifdef _WIN32_WCE
    s->file = INVALID_HANDLE_VALUE;
#else
    s->file = NULL;
#endif
    s->z_err = Z_OK;
    s->z_eof = 0;
    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 {
	    *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_DEFLATE
        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;

#ifdef _WIN32_WCE
    SetLastError(NO_ERROR);
    if ((HANDLE)fd == INVALID_HANDLE_VALUE) {
        MultiByteToWideChar(CP_ACP, 0, path, -1, file, MAX_PATH);
        s->file = CreateFile(file, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
    } else {
        s->file = (HANDLE)fd;
    }
#else
    errno = 0;
    s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
#endif

#ifdef _WIN32_WCE
    if (s->file == INVALID_HANDLE_VALUE) {
#else
    if (s->file == NULL) {
#endif
        return destroy(s), (gzFile)Z_NULL;
    }
    if (s->mode == 'w') {
        /* Write a very simple .gz header:
         */
#ifdef _WIN32_WCE
        cbuff[0] = gz_magic[0];
        cbuff[1] = gz_magic[1];
        cbuff[2] = Z_DEFLATED;
        cbuff[3] = 0; /*flags*/
        cbuff[4] = 0;
        cbuff[5] = 0;
        cbuff[6] = 0;
        cbuff[7] = 0; /*time*/;
        cbuff[8] = 0; /*xflags*/;
        cbuff[9] = OS_CODE;
        WriteFile(s->file, cbuff, 10, &size, NULL);
#else
        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);
#endif
	s->startpos = 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
         * startpos anyway in write mode, so this initialization is not
         * necessary.
         */
    } else {
	check_header(s); /* skip the .gz header */
#ifdef _WIN32_WCE
        s->startpos = (SetFilePointer(s->file, 0, NULL, FILE_CURRENT) - s->stream.avail_in);
#else
	s->startpos = (ftell(s->file) - s->stream.avail_in);
#endif
    }
    
    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];

#ifdef _WIN32_WCE
    if ((HANDLE)fd == INVALID_HANDLE_VALUE) return (gzFile)Z_NULL;
    strcpy(name, "<gzdopen>"); /* for debugging */
#else
    if (fd < 0) return (gzFile)Z_NULL;
    sprintf(name, "<fd:%d>", fd); /* for debugging */
#endif

    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;
#ifdef _WIN32_WCE
    DWORD size;
#endif

    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;
#ifdef _WIN32_WCE
        if (!WriteFile(s->file, s->outbuf, Z_BUFSIZE, &size, NULL) || size != Z_BUFSIZE) {
#else
	if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
#endif
	    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) {
#ifdef _WIN32_WCE
        SetLastError(NO_ERROR);
        if (!ReadFile(s->file, s->inbuf, Z_BUFSIZE, &s->stream.avail_in, NULL)) {
            s->z_err = Z_ERRNO;
        }
        if (s->stream.avail_in == 0) {
            s->z_eof = 1;
            return -1;
        }
#else
	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;
	}
#endif
	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;

    /* Check the gzip magic header */
    for (len = 0; len < 2; len++) {
	c = get_byte(s);
	if (c != gz_magic[len]) {
	    if (len != 0) s->stream.avail_in++, s->stream.next_in--;
	    if (c != EOF) {
		s->stream.avail_in++, s->stream.next_in--;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合天天性综合| 日韩三级免费观看| 欧美在线观看一二区| 一本色道久久综合亚洲91| 在线观看国产一区二区| 欧美成人伊人久久综合网| 国产日韩欧美不卡在线| 亚洲一区二区视频在线| 精品一区二区三区蜜桃| 91麻豆国产自产在线观看| 色欧美88888久久久久久影院| 欧美日韩一区二区三区四区| 精品国产一区二区三区四区四 | 丝袜脚交一区二区| 亚洲成人免费电影| 国产精品影视在线| 在线观看av一区二区| 国产亚洲福利社区一区| 亚洲综合免费观看高清完整版在线| 国内精品免费在线观看| 色噜噜狠狠色综合中国| 国产亚洲一区二区三区在线观看| 亚洲国产aⅴ成人精品无吗| 国产91精品在线观看| 欧美日韩国产天堂| 亚洲欧美国产三级| 国内成人免费视频| 欧美喷水一区二区| 亚洲男人的天堂在线aⅴ视频| 久久精品国产99久久6| 日本国产一区二区| 国产精品乱码久久久久久| 蜜臀久久99精品久久久久久9| 在线观看一区不卡| 亚洲另类色综合网站| 高潮精品一区videoshd| 欧美mv日韩mv亚洲| 午夜精品视频一区| 在线视频你懂得一区二区三区| 国产视频亚洲色图| 国产一区在线视频| 欧美大胆一级视频| 日韩电影免费在线看| 欧美色图第一页| 亚洲色图一区二区| 色综合天天狠狠| 国产精品久久夜| 国产成人精品亚洲午夜麻豆| 欧美成人精品3d动漫h| 丝袜美腿亚洲综合| 欧美二区乱c少妇| 国产精品欧美久久久久一区二区| 久久99热国产| 精品久久免费看| 久久电影网站中文字幕| 欧美狂野另类xxxxoooo| 亚洲成av人影院在线观看网| 欧美日本在线一区| 男女男精品视频| 欧美丰满少妇xxxbbb| 日日摸夜夜添夜夜添亚洲女人| 在线视频国内自拍亚洲视频| 亚洲国产视频一区| 91亚洲男人天堂| 一区二区三区精品视频在线| 欧美综合久久久| 五月天亚洲精品| 欧美mv和日韩mv的网站| 国产黄色精品网站| 国产精品第五页| 欧美亚洲国产一区在线观看网站| 亚洲国产另类av| 欧美不卡一二三| 成人av午夜电影| 亚洲一区日韩精品中文字幕| 欧美一区二区黄| 丁香婷婷综合网| 一区二区久久久久久| 日韩一区二区麻豆国产| 久久国产欧美日韩精品| 欧美极品aⅴ影院| 在线观看视频一区| 久久se这里有精品| 中文字幕精品—区二区四季| gogo大胆日本视频一区| 亚洲国产一区二区视频| 久久欧美一区二区| 日本高清无吗v一区| 男人操女人的视频在线观看欧美| 欧美国产在线观看| 欧美日韩视频不卡| 国产1区2区3区精品美女| 国产精品三级电影| 欧美一区二区三区精品| proumb性欧美在线观看| 奇米四色…亚洲| 亚洲欧美在线视频观看| 6080午夜不卡| 7777精品伊人久久久大香线蕉 | 亚洲手机成人高清视频| 91精品国产aⅴ一区二区| thepron国产精品| 国产精品99久久久久久久女警 | 国产乱码字幕精品高清av| 视频一区国产视频| 亚洲一区在线播放| 亚洲影院在线观看| 一区二区三区四区av| 综合久久给合久久狠狠狠97色| 久久久精品欧美丰满| 久久毛片高清国产| 久久综合九色综合97婷婷女人 | 欧美三级电影在线看| 在线免费不卡视频| 91香蕉视频在线| 色综合色狠狠综合色| 色综合久久综合网97色综合| 91美女片黄在线观看91美女| 一本到不卡精品视频在线观看| 成人的网站免费观看| 99精品视频中文字幕| 在线精品视频免费观看| 欧美日韩亚洲综合一区二区三区| 91国产免费看| 欧美日韩久久一区| 欧美一区二区福利视频| 精品国产成人系列| 国产日产亚洲精品系列| 国产精品二三区| 亚洲午夜久久久久久久久久久 | 中文字幕永久在线不卡| 亚洲码国产岛国毛片在线| 亚洲激情av在线| 日本特黄久久久高潮| 麻豆freexxxx性91精品| 国产一区二区调教| aaa亚洲精品| 欧美视频在线观看一区| 91精品欧美久久久久久动漫 | 欧美视频一二三区| 欧美一级精品在线| 国产欧美日产一区| 亚洲国产中文字幕在线视频综合| 天堂资源在线中文精品| 国产一区二区三区美女| 91麻豆免费观看| 日韩精品一区在线| 国产精品第13页| 日韩和欧美一区二区三区| 国产经典欧美精品| 欧美日韩精品三区| 久久精子c满五个校花| 亚洲一区在线视频| 国产一区二区在线观看免费| 91在线观看下载| 精品嫩草影院久久| 伊人一区二区三区| 国产在线精品不卡| 精品视频在线免费看| 久久伊人中文字幕| 日韩精品国产欧美| 91视频.com| 久久久精品天堂| 日韩高清在线电影| 99精品视频在线观看| 精品人伦一区二区色婷婷| 亚洲国产欧美另类丝袜| 不卡高清视频专区| 欧美精品一区视频| 午夜电影网亚洲视频| 色综合久久天天| 国产欧美一区二区三区在线看蜜臀| 天天爽夜夜爽夜夜爽精品视频| www.久久精品| 国产三级一区二区| 久久精品国产精品亚洲红杏| 色综合久久天天| 国产精品久久久久影视| 国产自产v一区二区三区c| 欧美日韩国产综合久久 | 午夜精品久久久久久久蜜桃app| 成人一区二区三区视频在线观看| 正在播放亚洲一区| 亚洲电影激情视频网站| 色999日韩国产欧美一区二区| 2022国产精品视频| 蜜臀精品一区二区三区在线观看 | 国产人久久人人人人爽| 国产在线看一区| 精品国产一区二区三区av性色| 天堂蜜桃91精品| 在线播放欧美女士性生活| 亚洲成在线观看| 欧美女孩性生活视频| 亚洲福利一区二区| 欧美视频完全免费看| 天天射综合影视| 日韩亚洲欧美一区| 久久99久久久欧美国产| 久久先锋资源网|