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

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

?? zran.c

?? StormLib是對MPQ文件進行處理的庫 MPQ是暴雪公司的私有的一種壓縮格式
?? C
字號:
/* zran.c -- example of zlib/gzip stream indexing and random access * Copyright (C) 2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h   Version 1.0  29 May 2005  Mark Adler *//* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()   for random access of a compressed file.  A file containing a zlib or gzip   stream is provided on the command line.  The compressed stream is decoded in   its entirety, and an index built with access points about every SPAN bytes   in the uncompressed output.  The compressed file is left open, and can then   be read randomly, having to decompress on the average SPAN/2 uncompressed   bytes before getting to the desired block of data.   An access point can be created at the start of any deflate block, by saving   the starting file offset and bit of that block, and the 32K bytes of   uncompressed data that precede that block.  Also the uncompressed offset of   that block is saved to provide a referece for locating a desired starting   point in the uncompressed stream.  build_index() works by decompressing the   input zlib or gzip stream a block at a time, and at the end of each block   deciding if enough uncompressed data has gone by to justify the creation of   a new access point.  If so, that point is saved in a data structure that   grows as needed to accommodate the points.   To use the index, an offset in the uncompressed data is provided, for which   the latest accees point at or preceding that offset is located in the index.   The input file is positioned to the specified location in the index, and if   necessary the first few bits of the compressed data is read from the file.   inflate is initialized with those bits and the 32K of uncompressed data, and   the decompression then proceeds until the desired offset in the file is   reached.  Then the decompression continues to read the desired uncompressed   data from the file.   Another approach would be to generate the index on demand.  In that case,   requests for random access reads from the compressed data would try to use   the index, but if a read far enough past the end of the index is required,   then further index entries would be generated and added.   There is some fair bit of overhead to starting inflation for the random   access, mainly copying the 32K byte dictionary.  So if small pieces of the   file are being accessed, it would make sense to implement a cache to hold   some lookahead and avoid many calls to extract() for small lengths.   Another way to build an index would be to use inflateCopy().  That would   not be constrained to have access points at block boundaries, but requires   more memory per access point, and also cannot be saved to file due to the   use of pointers in the state.  The approach here allows for storage of the   index in a file. */#include <stdio.h>#include <stdlib.h>#include <string.h>#include "zlib.h"#define local static#define SPAN 1048576L       /* desired distance between access points */#define WINSIZE 32768U      /* sliding window size */#define CHUNK 16384         /* file input buffer size *//* access point entry */struct point {    off_t out;          /* corresponding offset in uncompressed data */    off_t in;           /* offset in input file of first full byte */    int bits;           /* number of bits (1-7) from byte at in - 1, or 0 */    unsigned char window[WINSIZE];  /* preceding 32K of uncompressed data */};/* access point list */struct access {    int have;           /* number of list entries filled in */    int size;           /* number of list entries allocated */    struct point *list; /* allocated list */};/* Deallocate an index built by build_index() */local void free_index(struct access *index){    if (index != NULL) {        free(index->list);        free(index);    }}/* Add an entry to the access point list.  If out of memory, deallocate the   existing list and return NULL. */local struct access *addpoint(struct access *index, int bits,    off_t in, off_t out, unsigned left, unsigned char *window){    struct point *next;    /* if list is empty, create it (start with eight points) */    if (index == NULL) {        index = malloc(sizeof(struct access));        if (index == NULL) return NULL;        index->list = malloc(sizeof(struct point) << 3);        if (index->list == NULL) {            free(index);            return NULL;        }        index->size = 8;        index->have = 0;    }    /* if list is full, make it bigger */    else if (index->have == index->size) {        index->size <<= 1;        next = realloc(index->list, sizeof(struct point) * index->size);        if (next == NULL) {            free_index(index);            return NULL;        }        index->list = next;    }    /* fill in entry and increment how many we have */    next = index->list + index->have;    next->bits = bits;    next->in = in;    next->out = out;    if (left)        memcpy(next->window, window + WINSIZE - left, left);    if (left < WINSIZE)        memcpy(next->window + left, window, WINSIZE - left);    index->have++;    /* return list, possibly reallocated */    return index;}/* Make one entire pass through the compressed stream and build an index, with   access points about every span bytes of uncompressed output -- span is   chosen to balance the speed of random access against the memory requirements   of the list, about 32K bytes per access point.  Note that data after the end   of the first zlib or gzip stream in the file is ignored.  build_index()   returns the number of access points on success (>= 1), Z_MEM_ERROR for out   of memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a   file read error.  On success, *built points to the resulting index. */local int build_index(FILE *in, off_t span, struct access **built){    int ret;    off_t totin, totout;        /* our own total counters to avoid 4GB limit */    off_t last;                 /* totout value of last access point */    struct access *index;       /* access points being generated */    z_stream strm;    unsigned char input[CHUNK];    unsigned char window[WINSIZE];    /* initialize inflate */    strm.zalloc = Z_NULL;    strm.zfree = Z_NULL;    strm.opaque = Z_NULL;    strm.avail_in = 0;    strm.next_in = Z_NULL;    ret = inflateInit2(&strm, 47);      /* automatic zlib or gzip decoding */    if (ret != Z_OK)        return ret;    /* inflate the input, maintain a sliding window, and build an index -- this       also validates the integrity of the compressed data using the check       information at the end of the gzip or zlib stream */    totin = totout = last = 0;    index = NULL;               /* will be allocated by first addpoint() */    strm.avail_out = 0;    do {        /* get some compressed data from input file */        strm.avail_in = fread(input, 1, CHUNK, in);        if (ferror(in)) {            ret = Z_ERRNO;            goto build_index_error;        }        if (strm.avail_in == 0) {            ret = Z_DATA_ERROR;            goto build_index_error;        }        strm.next_in = input;        /* process all of that, or until end of stream */        do {            /* reset sliding window if necessary */            if (strm.avail_out == 0) {                strm.avail_out = WINSIZE;                strm.next_out = window;            }            /* inflate until out of input, output, or at end of block --               update the total input and output counters */            totin += strm.avail_in;            totout += strm.avail_out;            ret = inflate(&strm, Z_BLOCK);      /* return at end of block */            totin -= strm.avail_in;            totout -= strm.avail_out;            if (ret == Z_NEED_DICT)                ret = Z_DATA_ERROR;            if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)                goto build_index_error;            if (ret == Z_STREAM_END)                break;            /* if at end of block, consider adding an index entry (note that if               data_type indicates an end-of-block, then all of the               uncompressed data from that block has been delivered, and none               of the compressed data after that block has been consumed,               except for up to seven bits) -- the totout == 0 provides an               entry point after the zlib or gzip header, and assures that the               index always has at least one access point; we avoid creating an               access point after the last block by checking bit 6 of data_type             */            if ((strm.data_type & 128) && !(strm.data_type & 64) &&                (totout == 0 || totout - last > span)) {                index = addpoint(index, strm.data_type & 7, totin,                                 totout, strm.avail_out, window);                if (index == NULL) {                    ret = Z_MEM_ERROR;                    goto build_index_error;                }                last = totout;            }        } while (strm.avail_in != 0);    } while (ret != Z_STREAM_END);    /* clean up and return index (release unused entries in list) */    (void)inflateEnd(&strm);    index = realloc(index, sizeof(struct point) * index->have);    index->size = index->have;    *built = index;    return index->size;    /* return error */  build_index_error:    (void)inflateEnd(&strm);    if (index != NULL)        free_index(index);    return ret;}/* Use the index to read len bytes from offset into buf, return bytes read or   negative for error (Z_DATA_ERROR or Z_MEM_ERROR).  If data is requested past   the end of the uncompressed data, then extract() will return a value less   than len, indicating how much as actually read into buf.  This function   should not return a data error unless the file was modified since the index   was generated.  extract() may also return Z_ERRNO if there is an error on   reading or seeking the input file. */local int extract(FILE *in, struct access *index, off_t offset,                  unsigned char *buf, int len){    int ret, skip;    z_stream strm;    struct point *here;    unsigned char input[CHUNK];    unsigned char discard[WINSIZE];    /* proceed only if something reasonable to do */    if (len < 0)        return 0;    /* find where in stream to start */    here = index->list;    ret = index->have;    while (--ret && here[1].out <= offset)        here++;    /* initialize file and inflate state to start there */    strm.zalloc = Z_NULL;    strm.zfree = Z_NULL;    strm.opaque = Z_NULL;    strm.avail_in = 0;    strm.next_in = Z_NULL;    ret = inflateInit2(&strm, -15);         /* raw inflate */    if (ret != Z_OK)        return ret;    ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET);    if (ret == -1)        goto extract_ret;    if (here->bits) {        ret = getc(in);        if (ret == -1) {            ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR;            goto extract_ret;        }        (void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits));    }    (void)inflateSetDictionary(&strm, here->window, WINSIZE);    /* skip uncompressed bytes until offset reached, then satisfy request */    offset -= here->out;    strm.avail_in = 0;    skip = 1;                               /* while skipping to offset */    do {        /* define where to put uncompressed data, and how much */        if (offset == 0 && skip) {          /* at offset now */            strm.avail_out = len;            strm.next_out = buf;            skip = 0;                       /* only do this once */        }        if (offset > WINSIZE) {             /* skip WINSIZE bytes */            strm.avail_out = WINSIZE;            strm.next_out = discard;            offset -= WINSIZE;        }        else if (offset != 0) {             /* last skip */            strm.avail_out = (unsigned)offset;            strm.next_out = discard;            offset = 0;        }        /* uncompress until avail_out filled, or end of stream */        do {            if (strm.avail_in == 0) {                strm.avail_in = fread(input, 1, CHUNK, in);                if (ferror(in)) {                    ret = Z_ERRNO;                    goto extract_ret;                }                if (strm.avail_in == 0) {                    ret = Z_DATA_ERROR;                    goto extract_ret;                }                strm.next_in = input;            }            ret = inflate(&strm, Z_NO_FLUSH);       /* normal inflate */            if (ret == Z_NEED_DICT)                ret = Z_DATA_ERROR;            if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)                goto extract_ret;            if (ret == Z_STREAM_END)                break;        } while (strm.avail_out != 0);        /* if reach end of stream, then don't keep trying to get more */        if (ret == Z_STREAM_END)            break;        /* do until offset reached and requested data read, or stream ends */    } while (skip);    /* compute number of uncompressed bytes read after offset */    ret = skip ? 0 : len - strm.avail_out;    /* clean up and return bytes read or error */  extract_ret:    (void)inflateEnd(&strm);    return ret;}/* Demonstrate the use of build_index() and extract() by processing the file   provided on the command line, and the extracting 16K from about 2/3rds of   the way through the uncompressed output, and writing that to stdout. */int main(int argc, char **argv){    int len;    off_t offset;    FILE *in;    struct access *index;    unsigned char buf[CHUNK];    /* open input file */    if (argc != 2) {        fprintf(stderr, "usage: zran file.gz\n");        return 1;    }    in = fopen(argv[1], "rb");    if (in == NULL) {        fprintf(stderr, "zran: could not open %s for reading\n", argv[1]);        return 1;    }    /* build index */    len = build_index(in, SPAN, &index);    if (len < 0) {        fclose(in);        switch (len) {        case Z_MEM_ERROR:            fprintf(stderr, "zran: out of memory\n");            break;        case Z_DATA_ERROR:            fprintf(stderr, "zran: compressed data error in %s\n", argv[1]);            break;        case Z_ERRNO:            fprintf(stderr, "zran: read error on %s\n", argv[1]);            break;        default:            fprintf(stderr, "zran: error %d while building index\n", len);        }        return 1;    }    fprintf(stderr, "zran: built index with %d access points\n", len);    /* use index by reading some bytes from an arbitrary offset */    offset = (index->list[index->have - 1].out << 1) / 3;    len = extract(in, index, offset, buf, CHUNK);    if (len < 0)        fprintf(stderr, "zran: extraction failed: %s error\n",                len == Z_MEM_ERROR ? "out of memory" : "input corrupted");    else {        fwrite(buf, 1, len, stdout);        fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset);    }    /* clean up and exit */    free_index(index);    fclose(in);    return 0;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲va欧美va天堂v国产综合| 亚洲欧美国产三级| 欧美激情综合在线| 亚洲国产日产av| 国产成人福利片| 3d成人h动漫网站入口| 国产视频一区在线播放| 日韩电影在线看| 色视频成人在线观看免| 国产欧美一区二区精品性| 视频精品一区二区| 日本高清不卡aⅴ免费网站| 精品va天堂亚洲国产| 亚洲伊人伊色伊影伊综合网| 粉嫩av一区二区三区| 日韩女同互慰一区二区| 亚洲国产精品嫩草影院| 91理论电影在线观看| 久久精品视频免费| 久久99精品久久只有精品| 欧美日韩精品欧美日韩精品一 | 久久精品国产久精国产爱| 色天天综合久久久久综合片| 精品少妇一区二区三区在线播放| 亚洲高清三级视频| 欧美日免费三级在线| 亚洲精品伦理在线| 91麻豆.com| 亚洲日韩欧美一区二区在线| 国产91精品欧美| 国产婷婷色一区二区三区 | 婷婷六月综合亚洲| 欧美亚洲丝袜传媒另类| 亚洲女子a中天字幕| 99re8在线精品视频免费播放| 国产色综合一区| 懂色中文一区二区在线播放| 欧美精品一区二区三区蜜桃视频 | 欧美成人一区二区| 婷婷成人激情在线网| 8x福利精品第一导航| 日本中文在线一区| 日韩你懂的在线观看| 国产精品18久久久久| 国产欧美日韩中文久久| 丁香婷婷综合激情五月色| 国产亚洲欧美色| 成人激情免费电影网址| 亚洲精选视频在线| 欧美日韩免费视频| 免费的成人av| 中文欧美字幕免费| 97se亚洲国产综合自在线不卡| 亚洲天堂福利av| 欧美日韩国产美| 久久爱www久久做| 国产亚洲婷婷免费| 91久久人澡人人添人人爽欧美| 亚洲综合色在线| 日韩欧美亚洲国产另类| 成人一级视频在线观看| 亚洲男人天堂一区| 3d成人动漫网站| 国产成人精品免费| 亚洲成人av在线电影| 日韩精品一区二区三区视频| 丰满放荡岳乱妇91ww| 亚洲一区在线观看免费| 欧美成人艳星乳罩| 99久久精品国产精品久久| 亚洲午夜久久久久久久久久久| 日韩欧美区一区二| 97se狠狠狠综合亚洲狠狠| 日av在线不卡| 亚洲人成7777| 欧美mv和日韩mv的网站| 色综合久久66| 青青国产91久久久久久| 国产精品不卡在线| 日韩精品综合一本久道在线视频| 成人av在线电影| 日本不卡123| 亚洲一区二区三区小说| 国产色一区二区| 日韩一区二区在线观看| 91在线精品一区二区| 国产一区视频在线看| 香蕉久久夜色精品国产使用方法| 国产亚洲午夜高清国产拍精品| 欧美高清视频在线高清观看mv色露露十八 | 麻豆国产91在线播放| 亚洲美女淫视频| 久久精品一区二区三区不卡牛牛| 欧美私人免费视频| 99久久精品99国产精品| 国产精品一区二区黑丝| 蜜桃av噜噜一区| 亚洲高清视频在线| 亚洲男女毛片无遮挡| 国产日韩欧美一区二区三区综合| 91麻豆精品国产91久久久久久| 91美女福利视频| 91小宝寻花一区二区三区| 国产成人欧美日韩在线电影 | 亚洲国产精品视频| 亚洲美女视频在线| 欧美激情在线免费观看| 亚洲精品一区二区在线观看| 日韩一区二区精品在线观看| 欧美日韩综合色| 欧美亚洲一区三区| 91搞黄在线观看| 91精品福利视频| 91毛片在线观看| 91福利在线播放| 在线观看日韩国产| 色哟哟国产精品| 欧美亚洲丝袜传媒另类| 在线视频一区二区免费| 91极品美女在线| 在线亚洲欧美专区二区| 91久久精品一区二区二区| 91色porny在线视频| jvid福利写真一区二区三区| 粉嫩高潮美女一区二区三区| 高清成人免费视频| 成人av影院在线| 一本一道综合狠狠老| 日本高清无吗v一区| 日本精品一区二区三区高清| 欧美日韩中文字幕一区| 91麻豆精品国产91久久久久久 | 色偷偷一区二区三区| 色偷偷成人一区二区三区91| 在线看国产一区| 欧美日韩激情在线| 欧美久久久久中文字幕| 91麻豆精品国产91久久久更新时间| 3d动漫精品啪啪1区2区免费| 日韩精品一区国产麻豆| 欧美国产综合色视频| 亚洲欧美福利一区二区| 婷婷一区二区三区| 国产一区二区不卡| 91在线云播放| 欧美一区二区在线免费播放| 精品国产不卡一区二区三区| 国产精品污污网站在线观看| 亚洲男人的天堂av| 美女脱光内衣内裤视频久久网站| 国产在线视频不卡二| 99热在这里有精品免费| 欧美精品色综合| 国产日本欧洲亚洲| 亚洲成人福利片| 国产**成人网毛片九色 | 精品久久免费看| 亚洲视频在线一区| 麻豆久久一区二区| 91小视频在线免费看| 日韩欧美国产一二三区| 亚洲欧美aⅴ...| 国产福利一区二区| 欧美精品一卡二卡| 最新欧美精品一区二区三区| 奇米影视一区二区三区| 97se亚洲国产综合在线| 久久综合九色综合久久久精品综合 | 加勒比av一区二区| 欧美午夜精品久久久久久超碰| 26uuuu精品一区二区| 亚洲成国产人片在线观看| 成人h动漫精品| 精品国产乱码久久久久久1区2区 | 亚洲成人三级小说| 亚洲精品v日韩精品| 五月激情综合色| av一二三不卡影片| 91精品国产手机| 亚洲精品国产无套在线观| 青娱乐精品视频| 一本久久综合亚洲鲁鲁五月天| 国产.欧美.日韩| 精品粉嫩超白一线天av| 亚洲精品伦理在线| 国产乱子轮精品视频| 欧美电视剧免费观看| 一区二区三区不卡在线观看| 国产精品一级片在线观看| 日韩欧美电影一区| 亚洲综合精品久久| 成人动漫在线一区| 欧美综合一区二区| 亚洲精品免费一二三区| 成人免费看的视频| 精品蜜桃在线看| 偷窥国产亚洲免费视频| 日本精品免费观看高清观看| 国产精品全国免费观看高清| 奇米精品一区二区三区在线观看|