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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? zlib_how.html

?? ZIP壓縮算法源代碼,可以直接加入C++Project中編譯調(diào)用
?? HTML
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
until the state is reinitialized.
<p>
Some applications of <em>zlib</em> have two loops that call <tt>deflate()</tt>
instead of the single inner loop we have here.  The first loop would call
without flushing and feed all of the data to <tt>deflate()</tt>.  The second loop would call
<tt>deflate()</tt> with no more
data and the <tt>Z_FINISH</tt> parameter to complete the process.  As you can see from this
example, that can be avoided by simply keeping track of the current flush state.
<pre><b>
        } while (strm.avail_out == 0);
        assert(strm.avail_in == 0);     /* all input will be used */
</b></pre><!-- -->
Now we check to see if we have already processed all of the input file.  That information was
saved in the <tt>flush</tt> variable, so we see if that was set to <tt>Z_FINISH</tt>.  If so,
then we're done and we fall out of the outer loop.  We're guaranteed to get <tt>Z_STREAM_END</tt>
from the last <tt>deflate()</tt> call, since we ran it until the last chunk of input was
consumed and all of the output was generated.
<pre><b>
        /* done when last data in file processed */
    } while (flush != Z_FINISH);
    assert(ret == Z_STREAM_END);        /* stream will be complete */
</b></pre><!-- -->
The process is complete, but we still need to deallocate the state to avoid a memory leak
(or rather more like a memory hemorrhage if you didn't do this).  Then
finally we can return with a happy return value.
<pre><b>
    /* clean up and return */
    (void)deflateEnd(&amp;strm);
    return Z_OK;
}
</b></pre><!-- -->
Now we do the same thing for decompression in the <tt>inf()</tt> routine. <tt>inf()</tt>
decompresses what is hopefully a valid <em>zlib</em> stream from the input file and writes the
uncompressed data to the output file.  Much of the discussion above for <tt>def()</tt>
applies to <tt>inf()</tt> as well, so the discussion here will focus on the differences between
the two.
<pre><b>
/* Decompress from file source to file dest until stream ends or EOF.
   inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
   allocated for processing, Z_DATA_ERROR if the deflate data is
   invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
   the version of the library linked do not match, or Z_ERRNO if there
   is an error reading or writing the files. */
int inf(FILE *source, FILE *dest)
{
</b></pre>
The local variables have the same functionality as they do for <tt>def()</tt>.  The
only difference is that there is no <tt>flush</tt> variable, since <tt>inflate()</tt>
can tell from the <em>zlib</em> stream itself when the stream is complete.
<pre><b>
    int ret;
    unsigned have;
    z_stream strm;
    char in[CHUNK];
    char out[CHUNK];
</b></pre><!-- -->
The initialization of the state is the same, except that there is no compression level,
of course, and two more elements of the structure are initialized.  <tt>avail_in</tt>
and <tt>next_in</tt> must be initialized before calling <tt>inflateInit()</tt>.  This
is because the application has the option to provide the start of the zlib stream in
order for <tt>inflateInit()</tt> to have access to information about the compression
method to aid in memory allocation.  In the current implementation of <em>zlib</em>
(up through versions 1.2.x), the method-dependent memory allocations are deferred to the first call of
<tt>inflate()</tt> anyway.  However those fields must be initialized since later versions
of <em>zlib</em> that provide more compression methods may take advantage of this interface.
In any case, no decompression is performed by <tt>inflateInit()</tt>, so the
<tt>avail_out</tt> and <tt>next_out</tt> fields do not need to be initialized before calling.
<p>
Here <tt>avail_in</tt> is set to zero and <tt>next_in</tt> is set to <tt>Z_NULL</tt> to
indicate that no input data is being provided.
<pre><b>
    /* allocate inflate state */
    strm.zalloc = Z_NULL;
    strm.zfree = Z_NULL;
    strm.opaque = Z_NULL;
    strm.avail_in = 0;
    strm.next_in = Z_NULL;
    ret = inflateInit(&amp;strm);
    if (ret != Z_OK)
        return ret;
</b></pre><!-- -->
The outer <tt>do</tt>-loop decompresses input until <tt>inflate()</tt> indicates
that it has reached the end of the compressed data and has produced all of the uncompressed
output.  This is in contrast to <tt>def()</tt> which processes all of the input file.
If end-of-file is reached before the compressed data self-terminates, then the compressed
data is incomplete and an error is returned.
<pre><b>
    /* decompress until deflate stream ends or end of file */
    do {
</b></pre>
We read input data and set the <tt>strm</tt> structure accordingly.  If we've reached the
end of the input file, then we leave the outer loop and report an error, since the
compressed data is incomplete.  Note that we may read more data than is eventually consumed
by <tt>inflate()</tt>, if the input file continues past the <em>zlib</em> stream.
For applications where <em>zlib</em> streams are embedded in other data, this routine would
need to be modified to return the unused data, or at least indicate how much of the input
data was not used, so the application would know where to pick up after the <em>zlib</em> stream.
<pre><b>
        strm.avail_in = fread(in, 1, CHUNK, source);
        if (ferror(source)) {
            (void)inflateEnd(&amp;strm);
            return Z_ERRNO;
        }
        if (strm.avail_in == 0)
            break;
        strm.next_in = in;
</b></pre><!-- -->
The inner <tt>do</tt>-loop has the same function it did in <tt>def()</tt>, which is to
keep calling <tt>inflate()</tt> until has generated all of the output it can with the
provided input.
<pre><b>
        /* run inflate() on input until output buffer not full */
        do {
</b></pre>
Just like in <tt>def()</tt>, the same output space is provided for each call of <tt>inflate()</tt>.
<pre><b>
            strm.avail_out = CHUNK;
            strm.next_out = out;
</b></pre>
Now we run the decompression engine itself.  There is no need to adjust the flush parameter, since
the <em>zlib</em> format is self-terminating. The main difference here is that there are
return values that we need to pay attention to.  <tt>Z_DATA_ERROR</tt>
indicates that <tt>inflate()</tt> detected an error in the <em>zlib</em> compressed data format,
which means that either the data is not a <em>zlib</em> stream to begin with, or that the data was
corrupted somewhere along the way since it was compressed.  The other error to be processed is
<tt>Z_MEM_ERROR</tt>, which can occur since memory allocation is deferred until <tt>inflate()</tt>
needs it, unlike <tt>deflate()</tt>, whose memory is allocated at the start by <tt>deflateInit()</tt>.
<p>
Advanced applications may use
<tt>deflateSetDictionary()</tt> to prime <tt>deflate()</tt> with a set of likely data to improve the
first 32K or so of compression.  This is noted in the <em>zlib</em> header, so <tt>inflate()</tt>
requests that that dictionary be provided before it can start to decompress.  Without the dictionary,
correct decompression is not possible.  For this routine, we have no idea what the dictionary is,
so the <tt>Z_NEED_DICT</tt> indication is converted to a <tt>Z_DATA_ERROR</tt>.
<p>
<tt>inflate()</tt> can also return <tt>Z_STREAM_ERROR</tt>, which should not be possible here,
but could be checked for as noted above for <tt>def()</tt>.  <tt>Z_BUF_ERROR</tt> does not need to be
checked for here, for the same reasons noted for <tt>def()</tt>.  <tt>Z_STREAM_END</tt> will be
checked for later.
<pre><b>
            ret = inflate(&amp;strm, Z_NO_FLUSH);
            assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
            switch (ret) {
            case Z_NEED_DICT:
                ret = Z_DATA_ERROR;     /* and fall through */
            case Z_DATA_ERROR:
            case Z_MEM_ERROR:
                (void)inflateEnd(&amp;strm);
                return ret;
            }
</b></pre>
The output of <tt>inflate()</tt> is handled identically to that of <tt>deflate()</tt>.
<pre><b>
            have = CHUNK - strm.avail_out;
            if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
                (void)inflateEnd(&amp;strm);
                return Z_ERRNO;
            }
</b></pre>
The inner <tt>do</tt>-loop ends when <tt>inflate()</tt> has no more output as indicated
by not filling the output buffer, just as for <tt>deflate()</tt>.  In this case, we cannot
assert that <tt>strm.avail_in</tt> will be zero, since the deflate stream may end before the file
does.
<pre><b>
        } while (strm.avail_out == 0);
</b></pre><!-- -->
The outer <tt>do</tt>-loop ends when <tt>inflate()</tt> reports that it has reached the
end of the input <em>zlib</em> stream, has completed the decompression and integrity
check, and has provided all of the output.  This is indicated by the <tt>inflate()</tt>
return value <tt>Z_STREAM_END</tt>.  The inner loop is guaranteed to leave <tt>ret</tt>
equal to <tt>Z_STREAM_END</tt> if the last chunk of the input file read contained the end
of the <em>zlib</em> stream.  So if the return value is not <tt>Z_STREAM_END</tt>, the
loop continues to read more input.
<pre><b>
        /* done when inflate() says it's done */
    } while (ret != Z_STREAM_END);
</b></pre><!-- -->
At this point, decompression successfully completed, or we broke out of the loop due to no
more data being available from the input file.  If the last <tt>inflate()</tt> return value
is not <tt>Z_STREAM_END</tt>, then the <em>zlib</em> stream was incomplete and a data error
is returned.  Otherwise, we return with a happy return value.  Of course, <tt>inflateEnd()</tt>
is called first to avoid a memory leak.
<pre><b>
    /* clean up and return */
    (void)inflateEnd(&amp;strm);
    return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
</b></pre><!-- -->
That ends the routines that directly use <em>zlib</em>.  The following routines make this
a command-line program by running data through the above routines from <tt>stdin</tt> to
<tt>stdout</tt>, and handling any errors reported by <tt>def()</tt> or <tt>inf()</tt>.
<p>
<tt>zerr()</tt> is used to interpret the possible error codes from <tt>def()</tt>
and <tt>inf()</tt>, as detailed in their comments above, and print out an error message.
Note that these are only a subset of the possible return values from <tt>deflate()</tt>
and <tt>inflate()</tt>.
<pre><b>
/* report a zlib or i/o error */
void zerr(int ret)
{
    fputs("zpipe: ", stderr);
    switch (ret) {
    case Z_ERRNO:
        if (ferror(stdin))
            fputs("error reading stdin\n", stderr);
        if (ferror(stdout))
            fputs("error writing stdout\n", stderr);
        break;
    case Z_STREAM_ERROR:
        fputs("invalid compression level\n", stderr);
        break;
    case Z_DATA_ERROR:
        fputs("invalid or incomplete deflate data\n", stderr);
        break;
    case Z_MEM_ERROR:
        fputs("out of memory\n", stderr);
        break;
    case Z_VERSION_ERROR:
        fputs("zlib version mismatch!\n", stderr);
    }
}
</b></pre><!-- -->
Here is the <tt>main()</tt> routine used to test <tt>def()</tt> and <tt>inf()</tt>.  The
<tt>zpipe</tt> command is simply a compression pipe from <tt>stdin</tt> to <tt>stdout</tt>, if
no arguments are given, or it is a decompression pipe if <tt>zpipe -d</tt> is used.  If any other
arguments are provided, no compression or decompression is performed.  Instead a usage
message is displayed.  Examples are <tt>zpipe < foo.txt > foo.txt.z</tt> to compress, and
<tt>zpipe -d < foo.txt.z > foo.txt</tt> to decompress.
<pre><b>
/* compress or decompress from stdin to stdout */
int main(int argc, char **argv)
{
    int ret;

    /* do compression if no arguments */
    if (argc == 1) {
        ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* do decompression if -d specified */
    else if (argc == 2 &amp;&amp; strcmp(argv[1], "-d") == 0) {
        ret = inf(stdin, stdout);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* otherwise, report usage */
    else {
        fputs("zpipe usage: zpipe [-d] &lt; source &gt; dest\n", stderr);
        return 1;
    }
}
</b></pre>
<hr>
<i>Copyright (c) 2004 by Mark Adler<br>Last modified 13 November 2004</i>
</body>
</html>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区免费在线观看| 欧美精品久久99久久在免费线 | 亚洲免费av高清| av亚洲精华国产精华| 一区二区三区中文字幕精品精品 | 亚洲福利视频一区二区| 欧美亚洲综合另类| 日本一区中文字幕| 欧美精品一区二区久久婷婷| 高潮精品一区videoshd| 一区二区三区不卡视频在线观看 | 亚洲在线一区二区三区| 91麻豆精品91久久久久同性| 国产一区在线看| 国产精品久久久久久妇女6080| 99亚偷拍自图区亚洲| 亚洲第一成年网| 久久综合成人精品亚洲另类欧美| 成人a区在线观看| 午夜精品久久久久久久| 久久综合色婷婷| 91久久精品一区二区| 激情五月婷婷综合| 日韩久久一区二区| 精品少妇一区二区三区视频免付费 | 亚洲另类在线一区| 欧美日高清视频| 国内久久精品视频| 一区二区三区欧美激情| 精品电影一区二区| 欧美三区免费完整视频在线观看| 久久国产夜色精品鲁鲁99| 亚洲色图视频免费播放| 欧美成人一区二区三区片免费 | 欧美精品亚洲二区| 成人美女视频在线观看18| 丝袜脚交一区二区| 综合分类小说区另类春色亚洲小说欧美 | 欧美丰满少妇xxxbbb| 成人av电影免费观看| 美女看a上一区| 亚洲一区二区五区| 国产精品乱码久久久久久| 这里只有精品视频在线观看| 91亚洲精品久久久蜜桃| 国产精品91一区二区| 日本成人在线看| 一区二区在线免费观看| 国产日韩欧美高清在线| 欧美日韩成人在线| 日本黄色一区二区| 成人毛片在线观看| 国产精品亚洲а∨天堂免在线| 午夜欧美在线一二页| 亚洲精品一二三| 中文字幕在线免费不卡| 久久久精品国产免大香伊| 日韩一区二区在线免费观看| 欧美性欧美巨大黑白大战| 播五月开心婷婷综合| 国产成人亚洲综合色影视| 久草这里只有精品视频| 日韩二区三区四区| 丝袜亚洲精品中文字幕一区| 亚洲一二三区不卡| 亚洲成人资源网| 亚洲国产aⅴ成人精品无吗| 怡红院av一区二区三区| 亚洲欧美日韩在线| 亚洲精品va在线观看| 亚洲久草在线视频| 一区二区三区在线视频免费| 亚洲老妇xxxxxx| 亚洲午夜在线视频| 日韩高清在线观看| 免费精品视频在线| 国模少妇一区二区三区| 精品一区二区三区香蕉蜜桃| 麻豆国产精品777777在线| 美女视频黄免费的久久| 精品一区二区三区在线播放 | 国产精品99久久久久久久女警 | 欧美aa在线视频| 日本一区中文字幕| 久久66热re国产| 国产成人午夜电影网| 成人福利电影精品一区二区在线观看| 丁香婷婷综合色啪| av高清久久久| 欧美午夜精品一区| 欧美一区二区精美| 久久久美女毛片| 国产精品成人午夜| 性感美女极品91精品| 麻豆久久久久久| 国产91综合网| 在线观看亚洲精品视频| 日韩一区二区三区三四区视频在线观看| 欧美一二三区在线| 欧美激情一区二区三区蜜桃视频| 亚洲视频图片小说| 天堂成人免费av电影一区| 国精产品一区一区三区mba桃花| 国产91精品在线观看| 色久优优欧美色久优优| 日韩欧美中文字幕一区| 国产精品视频一二三| 亚洲尤物在线视频观看| 久草热8精品视频在线观看| 99v久久综合狠狠综合久久| 欧美日本视频在线| 久久久精品tv| 亚洲成av人片www| 成人性生交大合| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲美女偷拍久久| 久久成人免费网站| 91福利精品视频| 久久久久久久久久电影| 亚洲一区二区不卡免费| 国产精品羞羞答答xxdd| 欧美人成免费网站| 国产精品久久久久桃色tv| 奇米影视在线99精品| 波多野结衣一区二区三区| 欧美一区午夜视频在线观看| 国产精品国产成人国产三级| 男女激情视频一区| 色婷婷精品大视频在线蜜桃视频| 欧美mv和日韩mv的网站| 亚洲一区二区在线观看视频| 国产69精品久久久久777| 欧美一二三在线| 亚洲一区二区三区四区五区黄| 国产精品456露脸| 日韩欧美一二三四区| 亚洲图片欧美视频| 91免费看片在线观看| 国产蜜臀av在线一区二区三区| 欧美a一区二区| 欧美视频在线播放| **网站欧美大片在线观看| 国产专区综合网| 日韩视频在线一区二区| 亚洲成人精品一区二区| 色999日韩国产欧美一区二区| 国产三级三级三级精品8ⅰ区| 日本美女一区二区三区视频| 91精品91久久久中77777| 中文字幕一区在线观看| 国产成人99久久亚洲综合精品| 精品乱码亚洲一区二区不卡| 五月天久久比比资源色| 欧美午夜免费电影| 亚洲综合免费观看高清完整版在线 | 国产精品一区不卡| 久久中文娱乐网| 狠狠色丁香婷婷综合| 精品美女在线播放| 久久不见久久见免费视频1| 日韩美女一区二区三区| 蜜桃av一区二区| 日韩美女视频一区二区在线观看| 五月天视频一区| 日韩视频免费观看高清在线视频| 免费成人在线影院| 精品国产免费一区二区三区香蕉| 免费一区二区视频| 日韩免费高清av| 国产精品综合一区二区| 国产亚洲综合性久久久影院| 国产成人在线视频免费播放| 亚洲国产成人自拍| 99视频超级精品| 亚洲男女一区二区三区| 欧美在线色视频| 天天操天天干天天综合网| 欧美一级片免费看| 国产一区二区精品久久99| 国产欧美日韩激情| 91天堂素人约啪| 亚洲福利电影网| 欧美大片在线观看| 粉嫩在线一区二区三区视频| 日韩一区中文字幕| 欧美少妇一区二区| 美女精品自拍一二三四| 国产日韩精品视频一区| 色综合激情久久| 日本91福利区| 欧美国产1区2区| 欧美午夜精品一区| 国产尤物一区二区| 亚洲欧美日韩国产一区二区三区| 欧美日韩在线直播| 狠狠色丁香久久婷婷综| 亚洲人xxxx| www激情久久| 在线欧美日韩精品| 国产在线播放一区|