亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产拍欧美日韩视频二区| 久久久久9999亚洲精品| av激情综合网| 国产一区二区福利视频| 热久久一区二区| 日韩精品免费视频人成| 婷婷六月综合亚洲| 天堂va蜜桃一区二区三区漫画版| 亚洲猫色日本管| 亚洲欧洲综合另类在线| 亚洲精品久久久蜜桃| 亚洲人成精品久久久久久| 18成人在线观看| 一区二区三区中文字幕在线观看| 1区2区3区国产精品| 一区二区成人在线| 亚洲一区二区av电影| 亚洲成人自拍一区| 麻豆91在线观看| 激情欧美日韩一区二区| 国产成人综合在线观看| 成人精品国产免费网站| 91尤物视频在线观看| 欧美午夜不卡在线观看免费| 欧美日韩国产123区| 精品女同一区二区| 欧美国产一区视频在线观看| 亚洲美女精品一区| 日本亚洲最大的色成网站www| 九九视频精品免费| 成人激情开心网| 欧美日韩国产bt| 精品久久国产字幕高潮| 中文字幕一区二区三区乱码在线 | 在线成人av网站| 欧美一激情一区二区三区| 欧美精品一区二区在线观看| 日本一区二区三级电影在线观看| 中文字幕高清一区| 三级成人在线视频| 岛国一区二区在线观看| 欧美三日本三级三级在线播放| 日韩美一区二区三区| 国产精品九色蝌蚪自拍| 婷婷成人综合网| 97久久精品人人做人人爽50路| 日韩欧美美女一区二区三区| 国产欧美一区在线| 日本va欧美va精品| 91视频在线观看| 精品国产乱码久久久久久久久| 亚洲视频一二三| 精品一区二区三区欧美| 欧美视频三区在线播放| 一区在线观看免费| 国产丶欧美丶日本不卡视频| 欧美日韩高清一区二区三区| 国产精品久久久久久福利一牛影视| 首页国产欧美日韩丝袜| 色综合久久66| 国产精品久久三| 国产剧情在线观看一区二区| 欧美肥胖老妇做爰| 伊人一区二区三区| 91蜜桃免费观看视频| 国产区在线观看成人精品 | 欧美一区二区三区思思人| ...中文天堂在线一区| 国产高清在线观看免费不卡| 亚洲免费观看高清完整版在线观看熊| 欧美在线观看18| 精品国产亚洲在线| 首页国产丝袜综合| 欧美在线小视频| 亚洲夂夂婷婷色拍ww47 | 国产精品成人在线观看| 国产一区二区精品久久99| 欧美电影免费观看完整版| 日本伊人色综合网| 日韩一区二区麻豆国产| 麻豆免费精品视频| 日韩一区二区精品| 精品一二线国产| 久久毛片高清国产| 高清不卡一二三区| 国产精品欧美一级免费| youjizz国产精品| 中文字幕一区二区三区色视频| 不卡一区在线观看| 亚洲免费观看视频| 欧美日韩一区三区| 裸体一区二区三区| 国产日韩在线不卡| 色系网站成人免费| 青青青伊人色综合久久| 久久这里只有精品首页| 风间由美一区二区av101| 国产精品久久看| 色哟哟一区二区在线观看| 五月婷婷综合激情| 久久一区二区视频| 99久久99精品久久久久久| 亚洲高清免费观看高清完整版在线观看 | 一区二区三区久久| 欧美精品丝袜久久久中文字幕| 免费高清在线视频一区·| 国产拍揄自揄精品视频麻豆| 91精品1区2区| 久久av资源站| 国产精品不卡一区二区三区| 欧美日韩国产一级片| 国产伦精品一区二区三区免费| 亚洲欧洲日韩综合一区二区| 欧美巨大另类极品videosbest| 久草精品在线观看| 一区二区三区欧美| 精品第一国产综合精品aⅴ| 成人性生交大片免费看中文网站| 亚洲欧美一区二区三区极速播放| 91精品婷婷国产综合久久| 波多野结衣亚洲一区| 日本亚洲免费观看| 日韩美女视频一区| 欧美videos中文字幕| 91久久国产最好的精华液| 激情图片小说一区| 午夜精品福利一区二区三区av| 国产欧美一区二区精品久导航 | 粉嫩13p一区二区三区| 午夜精品久久久久久不卡8050| 国产欧美一区二区精品秋霞影院 | 美女视频免费一区| 亚洲免费观看高清| 欧美激情一区在线| 亚洲精品一线二线三线| 欧美区视频在线观看| 99re热这里只有精品免费视频| 久久99精品久久久久久| 日韩综合小视频| 亚洲乱码国产乱码精品精可以看| 久久久久久久久岛国免费| 7777女厕盗摄久久久| 91成人看片片| 91社区在线播放| 99精品视频在线播放观看| 粉嫩13p一区二区三区| 国内精品久久久久影院一蜜桃| 日本vs亚洲vs韩国一区三区二区| 亚洲午夜电影在线| 一区二区高清在线| 亚洲一级片在线观看| 亚洲美女屁股眼交| 亚洲尤物视频在线| 亚洲精品久久7777| 亚洲综合一二三区| 亚洲综合色区另类av| 一区二区三区在线观看欧美 | 欧美日韩一区二区在线观看视频| 成人av电影在线观看| 成人a区在线观看| 国产成人av电影免费在线观看| 黄色小说综合网站| 成人一区二区视频| 成人黄色软件下载| 91视频一区二区三区| 欧美在线短视频| 欧美一区二区三区四区高清| 欧美一级黄色片| 久久综合久色欧美综合狠狠| 日本一区二区不卡视频| 亚洲欧洲日韩女同| 一区二区高清免费观看影视大全| 亚洲第一福利一区| 精东粉嫩av免费一区二区三区| 风间由美一区二区av101| 成人黄动漫网站免费app| 97久久人人超碰| 欧美三区在线观看| 精品国产乱码久久久久久牛牛| 国产偷国产偷亚洲高清人白洁| 国产精品久久福利| 午夜av区久久| 国产精品18久久久久久久久 | 欧美系列在线观看| 日韩一区二区三区视频在线| 久久久久国产免费免费| 亚洲乱码日产精品bd| 蜜桃av一区二区| 99久久精品99国产精品| 91麻豆精品国产91久久久资源速度| 日韩欧美在线影院| 最新欧美精品一区二区三区| 午夜伊人狠狠久久| 国产成人午夜精品影院观看视频 | 天天色综合成人网| 国产999精品久久久久久绿帽| 欧美天堂一区二区三区| 久久久久久久精| 日本在线播放一区二区三区| 97久久精品人人澡人人爽|