⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gzip_8cpp-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: gzip.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><div class="tabs">  <ul>    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>    <li><a href="namespaces.html"><span>Namespaces</span></a></li>    <li><a href="classes.html"><span>Classes</span></a></li>    <li class="current"><a href="files.html"><span>Files</span></a></li>  </ul></div><div class="tabs">  <ul>    <li><a href="files.html"><span>File&nbsp;List</span></a></li>    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>  </ul></div><h1>gzip.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// gzip.cpp - written and placed in the public domain by Wei Dai</span><a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="preprocessor">#include "pch.h"</span><a name="l00004"></a>00004 <span class="preprocessor">#include "gzip.h"</span><a name="l00005"></a>00005 <a name="l00006"></a>00006 NAMESPACE_BEGIN(CryptoPP)<a name="l00007"></a>00007 <a name="l00008"></a><a class="code" href="class_gzip.html#d92840a92180cb616116ffbe235b0d7e">00008</a> void <a class="code" href="class_gzip.html" title="GZIP Compression (RFC 1952).">Gzip</a>::WritePrestreamHeader()<a name="l00009"></a>00009 {<a name="l00010"></a>00010         m_totalLen = 0;<a name="l00011"></a>00011         m_crc.Restart();<a name="l00012"></a>00012 <a name="l00013"></a>00013         AttachedTransformation()-&gt;Put(MAGIC1);<a name="l00014"></a>00014         AttachedTransformation()-&gt;Put(MAGIC2);<a name="l00015"></a>00015         AttachedTransformation()-&gt;Put(DEFLATED);<a name="l00016"></a>00016         AttachedTransformation()-&gt;Put(0);               <span class="comment">// general flag</span><a name="l00017"></a>00017         AttachedTransformation()-&gt;PutWord32(0); <span class="comment">// time stamp</span><a name="l00018"></a>00018         byte extra = (GetDeflateLevel() == 1) ? FAST : ((GetDeflateLevel() == 9) ? SLOW : 0);<a name="l00019"></a>00019         AttachedTransformation()-&gt;Put(extra);<a name="l00020"></a>00020         AttachedTransformation()-&gt;Put(GZIP_OS_CODE);<a name="l00021"></a>00021 }<a name="l00022"></a>00022 <a name="l00023"></a><a class="code" href="class_gzip.html#518a1747578e16c102ae8430e1dca659">00023</a> <span class="keywordtype">void</span> <a class="code" href="class_gzip.html#518a1747578e16c102ae8430e1dca659">Gzip::ProcessUncompressedData</a>(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length)<a name="l00024"></a>00024 {<a name="l00025"></a>00025         <a class="code" href="class_gzip.html#4f297733a60374b3f7a7d5ef2dc10c2a">m_crc</a>.<a class="code" href="class_c_r_c32.html#bd642abba82cf63edb025461bc1af8c0" title="process more input">Update</a>(inString, length);<a name="l00026"></a>00026         <a class="code" href="class_gzip.html#0020bd0aa27e3335993e4ea2836e5295">m_totalLen</a> += (word32)length;<a name="l00027"></a>00027 }<a name="l00028"></a>00028 <a name="l00029"></a><a class="code" href="class_gzip.html#48c4ba2a78f02326d8b244dfaddfa220">00029</a> <span class="keywordtype">void</span> <a class="code" href="class_gzip.html#48c4ba2a78f02326d8b244dfaddfa220">Gzip::WritePoststreamTail</a>()<a name="l00030"></a>00030 {<a name="l00031"></a>00031         <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> crc(4);<a name="l00032"></a>00032         <a class="code" href="class_gzip.html#4f297733a60374b3f7a7d5ef2dc10c2a">m_crc</a>.<a class="code" href="class_hash_transformation.html#a0b8c7a110d8968268fd02ec32b9a8e8" title="compute hash for current message, then restart for a new message">Final</a>(crc);<a name="l00033"></a>00033         <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-&gt;<a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(crc, 4);<a name="l00034"></a>00034         <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-&gt;<a class="code" href="class_buffered_transformation.html#ffcc574867d51528afe3c96721ded075" title="input a 32-bit word">PutWord32</a>(<a class="code" href="class_gzip.html#0020bd0aa27e3335993e4ea2836e5295">m_totalLen</a>, <a class="code" href="cryptlib_8h.html#aeb92d42f5a6e27b8ba19f18d69d142bccd5b3585bd07d6bdae383aa8271b9d2">LITTLE_ENDIAN_ORDER</a>);<a name="l00035"></a>00035 }<a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="comment">// *************************************************************</span><a name="l00038"></a>00038 <a name="l00039"></a><a class="code" href="class_gunzip.html#30ad6514a475206a6b60ccf81693323b">00039</a> <a class="code" href="class_gunzip.html#30ad6514a475206a6b60ccf81693323b">Gunzip::Gunzip</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment, <span class="keywordtype">bool</span> repeat, <span class="keywordtype">int</span> propagation)<a name="l00040"></a>00040         : <a class="code" href="class_inflator.html" title="DEFLATE (RFC 1951) decompressor.">Inflator</a>(attachment, repeat, propagation)<a name="l00041"></a>00041 {<a name="l00042"></a>00042 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -