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

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

?? gun.c

?? ZIP壓縮算法源代碼,可以直接加入C++Project中編譯調用
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* gun.c -- simple gunzip to give an example of the use of inflateBack()
 * Copyright (C) 2003, 2005 Mark Adler
 * For conditions of distribution and use, see copyright notice in zlib.h
   Version 1.3  12 June 2005  Mark Adler */

/* Version history:
   1.0  16 Feb 2003  First version for testing of inflateBack()
   1.1  21 Feb 2005  Decompress concatenated gzip streams
                     Remove use of "this" variable (C++ keyword)
                     Fix return value for in()
                     Improve allocation failure checking
                     Add typecasting for void * structures
                     Add -h option for command version and usage
                     Add a bunch of comments
   1.2  20 Mar 2005  Add Unix compress (LZW) decompression
                     Copy file attributes from input file to output file
   1.3  12 Jun 2005  Add casts for error messages [Oberhumer]
 */

/*
   gun [ -t ] [ name ... ]

   decompresses the data in the named gzip files.  If no arguments are given,
   gun will decompress from stdin to stdout.  The names must end in .gz, -gz,
   .z, -z, _z, or .Z.  The uncompressed data will be written to a file name
   with the suffix stripped.  On success, the original file is deleted.  On
   failure, the output file is deleted.  For most failures, the command will
   continue to process the remaining names on the command line.  A memory
   allocation failure will abort the command.  If -t is specified, then the
   listed files or stdin will be tested as gzip files for integrity (without
   checking for a proper suffix), no output will be written, and no files
   will be deleted.

   Like gzip, gun allows concatenated gzip streams and will decompress them,
   writing all of the uncompressed data to the output.  Unlike gzip, gun allows
   an empty file on input, and will produce no error writing an empty output
   file.

   gun will also decompress files made by Unix compress, which uses LZW
   compression.  These files are automatically detected by virtue of their
   magic header bytes.  Since the end of Unix compress stream is marked by the
   end-of-file, they cannot be concantenated.  If a Unix compress stream is
   encountered in an input file, it is the last stream in that file.

   Like gunzip and uncompress, the file attributes of the orignal compressed
   file are maintained in the final uncompressed file, to the extent that the
   user permissions allow it.

   On my Mac OS X PowerPC G4, gun is almost twice as fast as gunzip (version
   1.2.4) is on the same file, when gun is linked with zlib 1.2.2.  Also the
   LZW decompression provided by gun is about twice as fast as the standard
   Unix uncompress command.
 */

/* external functions and related types and constants */
#include <stdio.h>          /* fprintf() */
#include <stdlib.h>         /* malloc(), free() */
#include <string.h>         /* strerror(), strcmp(), strlen(), memcpy() */
#include <errno.h>          /* errno */
#include <fcntl.h>          /* open() */
#include <unistd.h>         /* read(), write(), close(), chown(), unlink() */
#include <sys/types.h>
#include <sys/stat.h>       /* stat(), chmod() */
#include <utime.h>          /* utime() */
#include "zlib.h"           /* inflateBackInit(), inflateBack(), */
                            /* inflateBackEnd(), crc32() */

/* function declaration */
#define local static

/* buffer constants */
#define SIZE 32768U         /* input and output buffer sizes */
#define PIECE 16384         /* limits i/o chunks for 16-bit int case */

/* structure for infback() to pass to input function in() -- it maintains the
   input file and a buffer of size SIZE */
struct ind {
    int infile;
    unsigned char *inbuf;
};

/* Load input buffer, assumed to be empty, and return bytes loaded and a
   pointer to them.  read() is called until the buffer is full, or until it
   returns end-of-file or error.  Return 0 on error. */
local unsigned in(void *in_desc, unsigned char **buf)
{
    int ret;
    unsigned len;
    unsigned char *next;
    struct ind *me = (struct ind *)in_desc;

    next = me->inbuf;
    *buf = next;
    len = 0;
    do {
        ret = PIECE;
        if ((unsigned)ret > SIZE - len)
            ret = (int)(SIZE - len);
        ret = (int)read(me->infile, next, ret);
        if (ret == -1) {
            len = 0;
            break;
        }
        next += ret;
        len += ret;
    } while (ret != 0 && len < SIZE);
    return len;
}

/* structure for infback() to pass to output function out() -- it maintains the
   output file, a running CRC-32 check on the output and the total number of
   bytes output, both for checking against the gzip trailer.  (The length in
   the gzip trailer is stored modulo 2^32, so it's ok if a long is 32 bits and
   the output is greater than 4 GB.) */
struct outd {
    int outfile;
    int check;                  /* true if checking crc and total */
    unsigned long crc;
    unsigned long total;
};

/* Write output buffer and update the CRC-32 and total bytes written.  write()
   is called until all of the output is written or an error is encountered.
   On success out() returns 0.  For a write failure, out() returns 1.  If the
   output file descriptor is -1, then nothing is written.
 */
local int out(void *out_desc, unsigned char *buf, unsigned len)
{
    int ret;
    struct outd *me = (struct outd *)out_desc;

    if (me->check) {
        me->crc = crc32(me->crc, buf, len);
        me->total += len;
    }
    if (me->outfile != -1)
        do {
            ret = PIECE;
            if ((unsigned)ret > len)
                ret = (int)len;
            ret = (int)write(me->outfile, buf, ret);
            if (ret == -1)
                return 1;
            buf += ret;
            len -= ret;
        } while (len != 0);
    return 0;
}

/* next input byte macro for use inside lunpipe() and gunpipe() */
#define NEXT() (have ? 0 : (have = in(indp, &next)), \
                last = have ? (have--, (int)(*next++)) : -1)

/* memory for gunpipe() and lunpipe() --
   the first 256 entries of prefix[] and suffix[] are never used, could
   have offset the index, but it's faster to waste the memory */
unsigned char inbuf[SIZE];              /* input buffer */
unsigned char outbuf[SIZE];             /* output buffer */
unsigned short prefix[65536];           /* index to LZW prefix string */
unsigned char suffix[65536];            /* one-character LZW suffix */
unsigned char match[65280 + 2];         /* buffer for reversed match or gzip
                                           32K sliding window */

/* throw out what's left in the current bits byte buffer (this is a vestigial
   aspect of the compressed data format derived from an implementation that
   made use of a special VAX machine instruction!) */
#define FLUSHCODE() \
    do { \
        left = 0; \
        rem = 0; \
        if (chunk > have) { \
            chunk -= have; \
            have = 0; \
            if (NEXT() == -1) \
                break; \
            chunk--; \
            if (chunk > have) { \
                chunk = have = 0; \
                break; \
            } \
        } \
        have -= chunk; \
        next += chunk; \
        chunk = 0; \
    } while (0)

/* Decompress a compress (LZW) file from indp to outfile.  The compress magic
   header (two bytes) has already been read and verified.  There are have bytes
   of buffered input at next.  strm is used for passing error information back
   to gunpipe().

   lunpipe() will return Z_OK on success, Z_BUF_ERROR for an unexpected end of
   file, read error, or write error (a write error indicated by strm->next_in
   not equal to Z_NULL), or Z_DATA_ERROR for invalid input.
 */
local int lunpipe(unsigned have, unsigned char *next, struct ind *indp,
                  int outfile, z_stream *strm)
{
    int last;                   /* last byte read by NEXT(), or -1 if EOF */
    int chunk;                  /* bytes left in current chunk */
    int left;                   /* bits left in rem */
    unsigned rem;               /* unused bits from input */
    int bits;                   /* current bits per code */
    unsigned code;              /* code, table traversal index */
    unsigned mask;              /* mask for current bits codes */
    int max;                    /* maximum bits per code for this stream */
    int flags;                  /* compress flags, then block compress flag */
    unsigned end;               /* last valid entry in prefix/suffix tables */
    unsigned temp;              /* current code */
    unsigned prev;              /* previous code */
    unsigned final;             /* last character written for previous code */
    unsigned stack;             /* next position for reversed string */
    unsigned outcnt;            /* bytes in output buffer */
    struct outd outd;           /* output structure */

    /* set up output */
    outd.outfile = outfile;
    outd.check = 0;

    /* process remainder of compress header -- a flags byte */
    flags = NEXT();
    if (last == -1)
        return Z_BUF_ERROR;
    if (flags & 0x60) {
        strm->msg = (char *)"unknown lzw flags set";
        return Z_DATA_ERROR;
    }
    max = flags & 0x1f;
    if (max < 9 || max > 16) {
        strm->msg = (char *)"lzw bits out of range";
        return Z_DATA_ERROR;
    }
    if (max == 9)                           /* 9 doesn't really mean 9 */
        max = 10;
    flags &= 0x80;                          /* true if block compress */

    /* clear table */
    bits = 9;
    mask = 0x1ff;
    end = flags ? 256 : 255;

    /* set up: get first 9-bit code, which is the first decompressed byte, but
       don't create a table entry until the next code */
    if (NEXT() == -1)                       /* no compressed data is ok */
        return Z_OK;
    final = prev = (unsigned)last;          /* low 8 bits of code */
    if (NEXT() == -1)                       /* missing a bit */
        return Z_BUF_ERROR;
    if (last & 1) {                         /* code must be < 256 */
        strm->msg = (char *)"invalid lzw code";
        return Z_DATA_ERROR;
    }
    rem = (unsigned)last >> 1;              /* remaining 7 bits */
    left = 7;
    chunk = bits - 2;                       /* 7 bytes left in this chunk */
    outbuf[0] = (unsigned char)final;       /* write first decompressed byte */
    outcnt = 1;

    /* decode codes */
    stack = 0;
    for (;;) {
        /* if the table will be full after this, increment the code size */
        if (end >= mask && bits < max) {
            FLUSHCODE();
            bits++;
            mask <<= 1;
            mask++;
        }

        /* get a code of length bits */
        if (chunk == 0)                     /* decrement chunk modulo bits */
            chunk = bits;
        code = rem;                         /* low bits of code */
        if (NEXT() == -1) {                 /* EOF is end of compressed data */
            /* write remaining buffered output */
            if (outcnt && out(&outd, outbuf, outcnt)) {
                strm->next_in = outbuf;     /* signal write error */
                return Z_BUF_ERROR;
            }
            return Z_OK;
        }
        code += (unsigned)last << left;     /* middle (or high) bits of code */
        left += 8;
        chunk--;
        if (bits > left) {                  /* need more bits */
            if (NEXT() == -1)               /* can't end in middle of code */
                return Z_BUF_ERROR;
            code += (unsigned)last << left; /* high bits of code */
            left += 8;
            chunk--;
        }
        code &= mask;                       /* mask to current code length */
        left -= bits;                       /* number of unused bits */
        rem = (unsigned)last >> (8 - left); /* unused bits from last byte */

        /* process clear code (256) */
        if (code == 256 && flags) {
            FLUSHCODE();
            bits = 9;                       /* initialize bits and mask */
            mask = 0x1ff;
            end = 255;                      /* empty table */
            continue;                       /* get next code */
        }

        /* special code to reuse last match */
        temp = code;                        /* save the current code */
        if (code > end) {
            /* Be picky on the allowed code here, and make sure that the code
               we drop through (prev) will be a valid index so that random
               input does not cause an exception.  The code != end + 1 check is
               empirically derived, and not checked in the original uncompress
               code.  If this ever causes a problem, that check could be safely
               removed.  Leaving this check in greatly improves gun's ability
               to detect random or corrupted input after a compress header.
               In any case, the prev > end check must be retained. */
            if (code != end + 1 || prev > end) {
                strm->msg = (char *)"invalid lzw code";
                return Z_DATA_ERROR;
            }
            match[stack++] = (unsigned char)final;
            code = prev;
        }

        /* walk through linked list to generate output in reverse order */
        while (code >= 256) {
            match[stack++] = suffix[code];
            code = prefix[code];
        }
        match[stack++] = (unsigned char)code;
        final = code;

        /* link new table entry */
        if (end < mask) {
            end++;
            prefix[end] = (unsigned short)prev;
            suffix[end] = (unsigned char)final;
        }

        /* set previous code for next iteration */
        prev = temp;

        /* write output in forward order */
        while (stack > SIZE - outcnt) {
            while (outcnt < SIZE)
                outbuf[outcnt++] = match[--stack];
            if (out(&outd, outbuf, outcnt)) {
                strm->next_in = outbuf; /* signal write error */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国模一区二区三区白浆| 国产一区91精品张津瑜| 久久蜜桃av一区二区天堂| www.日韩av| 日韩黄色免费网站| 一个色妞综合视频在线观看| 精品欧美一区二区久久| 在线欧美小视频| 国产福利一区二区三区视频| 午夜不卡av免费| 国产精品九色蝌蚪自拍| 精品成人a区在线观看| 欧美精品在线观看一区二区| 99久久精品国产导航| 国产成人亚洲综合色影视| 日韩和欧美的一区| 亚洲一区二区在线免费看| 中文字幕一区二区在线观看| 久久久高清一区二区三区| 欧美一级理论性理论a| 欧美性高清videossexo| 91麻豆文化传媒在线观看| 国产aⅴ综合色| 久久狠狠亚洲综合| 蜜臀精品一区二区三区在线观看| 亚洲国产sm捆绑调教视频 | 欧美高清一级片在线| 成人免费视频caoporn| 国产在线不卡视频| 免费精品99久久国产综合精品| 亚洲国产乱码最新视频| 亚洲青青青在线视频| 亚洲欧洲日产国产综合网| 中文字幕不卡在线观看| 久久免费电影网| 久久先锋影音av鲁色资源 | 亚洲欧美视频一区| 国产精品色一区二区三区| 国产视频在线观看一区二区三区| 精品粉嫩aⅴ一区二区三区四区 | 亚洲精品欧美专区| 亚洲精品久久久蜜桃| 亚洲精品视频在线观看网站| 亚洲精品视频观看| 亚洲一区影音先锋| 亚洲一区二区三区三| 亚洲h动漫在线| 日韩av一二三| 国产一区啦啦啦在线观看| 国产高清不卡二三区| 波多野结衣亚洲一区| 色88888久久久久久影院野外| 色88888久久久久久影院按摩| 欧美三级在线播放| 日韩一区二区影院| 国产亚洲一区二区在线观看| 中文字幕一区视频| 亚洲精品第一国产综合野| 亚洲成人你懂的| 九九九精品视频| 不卡视频一二三| 欧美日韩在线观看一区二区 | 日韩毛片视频在线看| 亚洲综合色视频| 麻豆精品久久精品色综合| 激情综合五月天| 91影院在线观看| 欧美日免费三级在线| 国产亚洲女人久久久久毛片| 亚洲人xxxx| 蜜臂av日日欢夜夜爽一区| 国产精品18久久久久久久久| 色综合天天综合网天天狠天天| 欧美日韩在线亚洲一区蜜芽| 亚洲精品在线观| 亚洲日本护士毛茸茸| 麻豆成人av在线| 成人久久视频在线观看| 777xxx欧美| 国产精品久久久久久久久搜平片| 亚洲一二三四久久| 国产一区中文字幕| 欧美性极品少妇| 欧美国产丝袜视频| 日本成人中文字幕在线视频| 成人精品小蝌蚪| 欧美一级专区免费大片| 综合av第一页| 激情综合色播五月| 欧美丝袜第三区| 国产欧美一区二区三区网站| 五月婷婷色综合| 99re8在线精品视频免费播放| 欧美一区二区三区四区在线观看 | 色婷婷综合激情| 久久影院电视剧免费观看| 亚洲综合色区另类av| 国产suv精品一区二区6| 欧美一区二区网站| 亚洲图片欧美一区| 成人av动漫网站| 久久蜜臀中文字幕| 看片网站欧美日韩| 欧美偷拍一区二区| 国产精品久久久久久久久快鸭 | 欧美成人性战久久| 午夜婷婷国产麻豆精品| 91在线你懂得| 国产调教视频一区| 蜜桃免费网站一区二区三区| 欧美亚洲丝袜传媒另类| 国产精品短视频| 成人做爰69片免费看网站| 日韩精品中文字幕在线不卡尤物 | 激情久久久久久久久久久久久久久久| 在线免费亚洲电影| 亚洲欧美经典视频| 懂色av一区二区三区免费观看| 欧美精品一区二区高清在线观看| 亚洲www啪成人一区二区麻豆| av成人动漫在线观看| 欧美激情自拍偷拍| 国产一区二区三区在线观看免费视频| 欧美一级欧美三级| 美女一区二区三区在线观看| 91精品国产入口| 日韩精品国产欧美| 在线成人小视频| 日韩福利电影在线观看| 欧美美女一区二区在线观看| 一区二区三区日韩| 91久久线看在观草草青青| 1000部国产精品成人观看| 波波电影院一区二区三区| 中文字幕一区二区三区乱码在线 | 精品欧美黑人一区二区三区| 视频在线观看一区| 欧美老人xxxx18| 亚欧色一区w666天堂| 欧美少妇一区二区| 天天综合网 天天综合色| 欧美高清视频一二三区| 蜜臀久久久99精品久久久久久| 日韩精品一区二区三区中文精品| 精久久久久久久久久久| 中日韩免费视频中文字幕| 99re热这里只有精品视频| 亚洲精选免费视频| 欧美精品v日韩精品v韩国精品v| 五月婷婷激情综合网| 精品国产一区二区在线观看| 国产91精品免费| 一区二区免费在线播放| 欧美乱熟臀69xxxxxx| 国产在线看一区| 国产精品三级av在线播放| 色婷婷激情综合| 奇米色一区二区| 国产精品欧美一级免费| 色嗨嗨av一区二区三区| 日本在线不卡一区| 国产亚洲美州欧州综合国| 色爱区综合激月婷婷| 蜜桃av一区二区三区| 国产精品萝li| 在线观看91av| 成人污污视频在线观看| 亚洲综合一区二区三区| 日韩欧美一区二区三区在线| 成人精品视频.| 婷婷一区二区三区| 国产拍欧美日韩视频二区| 在线亚洲高清视频| 精彩视频一区二区三区| 亚洲三级在线看| 欧美大肚乱孕交hd孕妇| 91偷拍与自偷拍精品| 蜜桃一区二区三区在线观看| 日韩伦理av电影| 日韩精品专区在线| 色成年激情久久综合| 精品一区二区三区免费观看| 亚洲毛片av在线| 久久久久久麻豆| 欧美日韩激情一区| 国产91精品精华液一区二区三区| 亚洲成a人v欧美综合天堂下载| 中文字幕精品一区二区三区精品| 欧美绝品在线观看成人午夜影视 | 欧美酷刑日本凌虐凌虐| 国产精品1区2区| 日本美女一区二区三区视频| 综合电影一区二区三区 | 在线播放中文字幕一区| 波多野结衣精品在线| 国产一区二区三区在线看麻豆| 天天影视涩香欲综合网| 亚洲色图都市小说| 国产色爱av资源综合区| 日韩视频一区二区三区在线播放|