<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Crypto++: gzip.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Crypto++</div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">gzip.h</div> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_GZIP_H</span> <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_GZIP_H</span> <a name="l00003"></a>00003 <span class="preprocessor"></span> <a name="l00004"></a>00004 <span class="preprocessor">#include "zdeflate.h"</span> <a name="l00005"></a>00005 <span class="preprocessor">#include "zinflate.h"</span> <a name="l00006"></a>00006 <span class="preprocessor">#include "crc.h"</span> <a name="l00007"></a>00007 <a name="l00008"></a>00008 NAMESPACE_BEGIN(CryptoPP) <a name="l00009"></a>00009 <a name="l00010"></a>00010 <span class="comment">/// GZIP Compression (RFC 1952)</span> <a name="l00011"></a><a class="code" href="class_gzip.html">00011</a> <span class="comment"></span>class <a class="code" href="class_gzip.html" title="GZIP Compression (RFC 1952)">Gzip</a> : public <a class="code" href="class_deflator.html" title="DEFLATE (RFC 1951) compressor.">Deflator</a> <a name="l00012"></a>00012 { <a name="l00013"></a>00013 <span class="keyword">public</span>: <a name="l00014"></a>00014 <a class="code" href="class_gzip.html" title="GZIP Compression (RFC 1952)">Gzip</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment=NULL, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> deflateLevel=DEFAULT_DEFLATE_LEVEL, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, <span class="keywordtype">bool</span> detectUncompressible=<span class="keyword">true</span>) <a name="l00015"></a>00015 : Deflator(attachment, deflateLevel, log2WindowSize, detectUncompressible) {} <a name="l00016"></a>00016 <a class="code" href="class_gzip.html" title="GZIP Compression (RFC 1952)">Gzip</a>(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &parameters, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment=NULL) <a name="l00017"></a>00017 : Deflator(parameters, attachment) {} <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="keyword">protected</span>: <a name="l00020"></a>00020 <span class="keyword">enum</span> {MAGIC1=0x1f, MAGIC2=0x8b, <span class="comment">// flags for the header</span> <a name="l00021"></a>00021 DEFLATED=8, FAST=4, SLOW=2}; <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="keywordtype">void</span> WritePrestreamHeader(); <a name="l00024"></a>00024 <span class="keywordtype">void</span> ProcessUncompressedData(<span class="keyword">const</span> byte *<span class="keywordtype">string</span>, <span class="keywordtype">size_t</span> length); <a name="l00025"></a>00025 <span class="keywordtype">void</span> WritePoststreamTail(); <a name="l00026"></a>00026 <a name="l00027"></a>00027 word32 m_totalLen; <a name="l00028"></a>00028 <a class="code" href="class_c_r_c32.html" title="CRC Checksum Calculation.">CRC32</a> m_crc; <a name="l00029"></a>00029 }; <a name="l00030"></a>00030 <span class="comment"></span> <a name="l00031"></a>00031 <span class="comment">/// GZIP Decompression (RFC 1952)</span> <a name="l00032"></a><a class="code" href="class_gunzip.html">00032</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_gunzip.html" title="GZIP Decompression (RFC 1952)">Gunzip</a> : <span class="keyword">public</span> <a class="code" href="class_inflator.html" title="DEFLATE (RFC 1951) decompressor.">Inflator</a> <a name="l00033"></a>00033 { <a name="l00034"></a>00034 <span class="keyword">public</span>: <a name="l00035"></a>00035 <span class="keyword">typedef</span> <a class="code" href="class_inflator_1_1_err.html">Inflator::Err</a> <a class="code" href="class_inflator_1_1_err.html">Err</a>; <a name="l00036"></a><a class="code" href="class_gunzip_1_1_header_err.html">00036</a> <span class="keyword">class </span><a class="code" href="class_gunzip_1_1_header_err.html">HeaderErr</a> : <span class="keyword">public</span> <a class="code" href="class_inflator_1_1_err.html">Err</a> {<span class="keyword">public</span>: <a class="code" href="class_gunzip_1_1_header_err.html">HeaderErr</a>() : <a class="code" href="class_inflator_1_1_err.html">Err</a>(<a class="code" href="class_exception.html#a8e53909d979479380e0274807c074c0aa3a0352964781e7712b21dbb70ffbe646" title="received input data that doesn't conform to expected format">INVALID_DATA_FORMAT</a>, <span class="stringliteral">"Gunzip: header decoding error"</span>) {}}; <a name="l00037"></a><a class="code" href="class_gunzip_1_1_tail_err.html">00037</a> <span class="keyword">class </span><a class="code" href="class_gunzip_1_1_tail_err.html">TailErr</a> : <span class="keyword">public</span> <a class="code" href="class_inflator_1_1_err.html">Err</a> {<span class="keyword">public</span>: <a class="code" href="class_gunzip_1_1_tail_err.html">TailErr</a>() : <a class="code" href="class_inflator_1_1_err.html">Err</a>(<a class="code" href="class_exception.html#a8e53909d979479380e0274807c074c0aa3a0352964781e7712b21dbb70ffbe646" title="received input data that doesn't conform to expected format">INVALID_DATA_FORMAT</a>, <span class="stringliteral">"Gunzip: tail too short"</span>) {}}; <a name="l00038"></a><a class="code" href="class_gunzip_1_1_crc_err.html">00038</a> <span class="keyword">class </span><a class="code" href="class_gunzip_1_1_crc_err.html">CrcErr</a> : <span class="keyword">public</span> <a class="code" href="class_inflator_1_1_err.html">Err</a> {<span class="keyword">public</span>: <a class="code" href="class_gunzip_1_1_crc_err.html">CrcErr</a>() : <a class="code" href="class_inflator_1_1_err.html">Err</a>(<a class="code" href="class_exception.html#a8e53909d979479380e0274807c074c0aa77a639a803cf53052f9c76a0354247e6" title="data integerity check (such as CRC or MAC) failed">DATA_INTEGRITY_CHECK_FAILED</a>, <span class="stringliteral">"Gunzip: CRC check error"</span>) {}}; <a name="l00039"></a><a class="code" href="class_gunzip_1_1_length_err.html">00039</a> <span class="keyword">class </span><a class="code" href="class_gunzip_1_1_length_err.html">LengthErr</a> : <span class="keyword">public</span> <a class="code" href="class_inflator_1_1_err.html">Err</a> {<span class="keyword">public</span>: <a class="code" href="class_gunzip_1_1_length_err.html">LengthErr</a>() : <a class="code" href="class_inflator_1_1_err.html">Err</a>(<a class="code" href="class_exception.html#a8e53909d979479380e0274807c074c0aa77a639a803cf53052f9c76a0354247e6" title="data integerity check (such as CRC or MAC) failed">DATA_INTEGRITY_CHECK_FAILED</a>, <span class="stringliteral">"Gunzip: length check error"</span>) {}}; <a name="l00040"></a>00040 <span class="comment"></span> <a name="l00041"></a>00041 <span class="comment"> /*! \param repeat decompress multiple compressed streams in series</span> <a name="l00042"></a>00042 <span class="comment"> \param autoSignalPropagation 0 to turn off MessageEnd signal</span> <a name="l00043"></a>00043 <span class="comment"> */</span> <a name="l00044"></a>00044 <a class="code" href="class_gunzip.html#a30ad6514a475206a6b60ccf81693323b">Gunzip</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL, <span class="keywordtype">bool</span> repeat = <span class="keyword">false</span>, <span class="keywordtype">int</span> autoSignalPropagation = -1); <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keyword">protected</span>: <a name="l00047"></a>00047 <span class="keyword">enum</span> {MAGIC1=0x1f, MAGIC2=0x8b, <span class="comment">// flags for the header</span> <a name="l00048"></a>00048 DEFLATED=8}; <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">enum</span> FLAG_MASKS { <a name="l00051"></a>00051 CONTINUED=2, EXTRA_FIELDS=4, FILENAME=8, COMMENTS=16, ENCRYPTED=32}; <a name="l00052"></a>00052 <a name="l00053"></a>00053 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MaxPrestreamHeaderSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 1024;} <a name="l00054"></a>00054 <span class="keywordtype">void</span> ProcessPrestreamHeader(); <a name="l00055"></a>00055 <span class="keywordtype">void</span> ProcessDecompressedData(<span class="keyword">const</span> byte *<span class="keywordtype">string</span>, <span class="keywordtype">size_t</span> length); <a name="l00056"></a>00056 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MaxPoststreamTailSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 8;} <a name="l00057"></a>00057 <span class="keywordtype">void</span> ProcessPoststreamTail(); <a name="l00058"></a>00058 <a name="l00059"></a>00059 word32 m_length; <a name="l00060"></a>00060 <a class="code" href="class_c_r_c32.html" title="CRC Checksum Calculation.">CRC32</a> m_crc; <a name="l00061"></a>00061 }; <a name="l00062"></a>00062 <a name="l00063"></a>00063 NAMESPACE_END <a name="l00064"></a>00064 <a name="l00065"></a>00065 <span class="preprocessor">#endif</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Sun Oct 16 2011 for Crypto++ by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>