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

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

?? zran.c

?? ZIP壓縮算法源代碼,可以直接加入C++Project中編譯調用
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* 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,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产尤物一区二区| 精品久久免费看| 日韩网站在线看片你懂的| 欧美国产国产综合| 日产国产欧美视频一区精品| 成人永久aaa| 宅男噜噜噜66一区二区66| 中文在线一区二区| 日韩电影免费一区| av资源站一区| 久久精品视频网| 卡一卡二国产精品 | 日韩电影在线一区二区三区| 高清国产午夜精品久久久久久| 9191久久久久久久久久久| 亚洲免费在线看| 成人性生交大合| 日韩精品一区二区三区swag| 亚洲高清不卡在线观看| 色狠狠桃花综合| 中文字幕一区二区三区蜜月| 国产一区二区视频在线| 日韩欧美精品在线视频| 另类小说视频一区二区| 在线观看区一区二| 亚洲精品水蜜桃| a级高清视频欧美日韩| 日本一区二区三区四区| 国产福利视频一区二区三区| 久久精品在这里| 国产一区二区三区美女| www成人在线观看| 国内精品伊人久久久久av一坑 | 亚洲精品伦理在线| 99精品1区2区| 亚洲美女免费在线| 91麻豆自制传媒国产之光| 国产精品乱码人人做人人爱| 91小视频在线免费看| 亚洲精品免费播放| 欧美精品123区| 精久久久久久久久久久| 久久精品亚洲麻豆av一区二区 | 国产日韩欧美精品电影三级在线| 国产高清精品久久久久| 中文字幕精品三区| 色综合色狠狠天天综合色| 天堂在线亚洲视频| 欧美日本乱大交xxxxx| 奇米影视7777精品一区二区| 久久综合资源网| thepron国产精品| 亚洲最大色网站| 欧美一级二级三级蜜桃| 国产成人午夜视频| 亚洲欧美一区二区三区孕妇| 欧美日韩免费不卡视频一区二区三区| 午夜视频一区二区| 久久尤物电影视频在线观看| 99久久99久久久精品齐齐| 亚洲福利视频三区| 久久综合资源网| 日本精品视频一区二区三区| 美女一区二区久久| 国产精品人人做人人爽人人添| 91浏览器入口在线观看| 免费观看在线色综合| 国产女人水真多18毛片18精品视频| 91视视频在线直接观看在线看网页在线看| 亚洲444eee在线观看| 久久综合五月天婷婷伊人| 色欧美日韩亚洲| 国产一区999| 亚洲成人动漫在线观看| 久久久美女毛片| 欧美影片第一页| 粉嫩久久99精品久久久久久夜| 亚洲五月六月丁香激情| 亚洲国产精品成人综合| 欧美久久免费观看| 99在线热播精品免费| 午夜精品一区二区三区三上悠亚| 国产精品麻豆久久久| 日韩亚洲欧美中文三级| 91高清在线观看| 丰满岳乱妇一区二区三区| 日本视频中文字幕一区二区三区| 中文字幕欧美日本乱码一线二线| 日韩一区二区精品葵司在线| 欧美影院一区二区| 国产成人av电影免费在线观看| 青青草97国产精品免费观看无弹窗版 | 成人夜色视频网站在线观看| 日本va欧美va欧美va精品| 亚洲美女视频一区| 久久久久久久久久久久久夜| 这里只有精品99re| 精品视频在线视频| 日本高清不卡aⅴ免费网站| 成人av网站免费观看| 韩日欧美一区二区三区| 久久精品国产精品亚洲红杏 | 欧美精品1区2区| 欧美午夜片在线看| 色综合久久六月婷婷中文字幕| 99久久精品免费| 丁香五精品蜜臀久久久久99网站 | 欧美久久久久久蜜桃| 色94色欧美sute亚洲13| 成+人+亚洲+综合天堂| 国产精品系列在线观看| 精品一区二区国语对白| 美国av一区二区| 天天综合色天天综合色h| 亚洲一区二区视频在线观看| 亚洲黄色免费电影| 亚洲一区二区三区四区五区黄 | 激情文学综合丁香| 九九在线精品视频| 狠狠色综合播放一区二区| 久久机这里只有精品| 国内成人精品2018免费看| 国产乱码精品一区二区三| 国产激情91久久精品导航 | 欧美日韩三级一区二区| 欧美视频一区二区三区| 欧美日韩免费高清一区色橹橹| 欧美精品乱码久久久久久| 欧美一区二区三区小说| 欧美tickling挠脚心丨vk| 国产亚洲一区二区三区四区| 国产精品国产三级国产aⅴ原创 | 欧美中文字幕久久| 欧美精品久久99久久在免费线| 91精品国产综合久久小美女| 精品国产精品一区二区夜夜嗨| 久久久国产精品不卡| 中文字幕在线一区| 亚洲国产欧美日韩另类综合| 免费人成在线不卡| 成人小视频免费观看| 欧美网站大全在线观看| 日韩欧美一二三| 成人欧美一区二区三区1314| 五月婷婷综合激情| 国产精品99久久久久久有的能看| 99九九99九九九视频精品| 欧美美女网站色| 国产精品视频你懂的| 亚洲自拍偷拍网站| 国产精品综合一区二区三区| 在线视频国内一区二区| 欧美xxxxx牲另类人与| 亚洲视频资源在线| 久久精品国产澳门| 色香蕉久久蜜桃| 精品日韩成人av| 夜夜嗨av一区二区三区中文字幕| 蜜桃精品视频在线| 91成人免费在线| 国产亚洲成aⅴ人片在线观看| 亚洲欧美偷拍三级| 国产伦精一区二区三区| 欧美日韩国产免费一区二区| 国产午夜精品一区二区三区视频| 亚洲成人先锋电影| 99国产精品久久久久久久久久| 日韩一区二区在线观看视频播放| 中文字幕日本不卡| 国产精品一区不卡| 日韩视频免费观看高清完整版在线观看| 国产精品网站一区| 狠狠色狠狠色综合| 91精品国产色综合久久久蜜香臀| 中文字幕欧美一区| 国产成a人亚洲| 亚洲精品在线免费播放| 亚洲动漫第一页| 色哟哟国产精品| 国产精品国产三级国产aⅴ原创| 狠狠色丁香久久婷婷综合丁香| 777xxx欧美| 午夜精品影院在线观看| 欧美日韩综合在线免费观看| 亚洲伦理在线免费看| 成人精品小蝌蚪| 国产欧美精品一区aⅴ影院| 看片网站欧美日韩| 欧美一级黄色片| 国产福利电影一区二区三区| 日韩精品专区在线影院观看| 午夜精品爽啪视频| 精品视频全国免费看| 亚洲综合色丁香婷婷六月图片| av高清不卡在线| 中文字幕永久在线不卡| 成人性色生活片| 亚洲日本护士毛茸茸| www.66久久| 亚洲精品国产一区二区精华液|