#include <zlib.h>
Zlib Compression Filter
Definition at line 19 of file zlib.h.
◆ Zlib_Compression()
| Botan::Zlib_Compression::Zlib_Compression |
( |
size_t | level = 6 | ) |
|
- Parameters
-
| level | how much effort to use on compressing (0 to 9); higher levels are slower but tend to give better compression |
Definition at line 94 of file zlib.cpp.
94 :
95 level((l >= 9) ? 9 : l), buffer(DEFAULT_BUFFERSIZE)
96 {
97 zlib = 0;
98 }
◆ ~Zlib_Compression()
| Botan::Zlib_Compression::~Zlib_Compression |
( |
| ) |
|
|
inline |
◆ attachable()
| virtual bool Botan::Filter::attachable |
( |
| ) |
|
|
inlinevirtualinherited |
◆ end_msg()
| void Botan::Zlib_Compression::end_msg |
( |
| ) |
|
|
virtual |
Notify that the current message is finished; flush buffers and do end-of-message processing (if any).
Reimplemented from Botan::Filter.
Definition at line 131 of file zlib.cpp.
132 {
133 zlib->stream.next_in = 0;
134 zlib->stream.avail_in = 0;
135
136 int rc = Z_OK;
137 while(rc != Z_STREAM_END)
138 {
139 zlib->stream.next_out = reinterpret_cast<Bytef*>(buffer.begin());
140 zlib->stream.avail_out = buffer.size();
141
142 rc = deflate(&(zlib->stream), Z_FINISH);
143 send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
144 }
145
146 clear();
147 }
void send(const byte in[], size_t length)
References Botan::Filter::send().
◆ flush()
| void Botan::Zlib_Compression::flush |
( |
| ) |
|
Flush the compressor
Definition at line 152 of file zlib.cpp.
153 {
154 zlib->stream.next_in = 0;
155 zlib->stream.avail_in = 0;
156
157 while(true)
158 {
159 zlib->stream.avail_out = buffer.size();
160 zlib->stream.next_out = reinterpret_cast<Bytef*>(buffer.begin());
161
162 deflate(&(zlib->stream), Z_FULL_FLUSH);
163 send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
164
165 if(zlib->stream.avail_out == buffer.size())
166 break;
167 }
168 }
References Botan::Filter::send().
◆ name()
| std::string Botan::Zlib_Compression::name |
( |
| ) |
const |
|
inlinevirtual |
- Returns
- descriptive name for this filter
Implements Botan::Filter.
Definition at line 22 of file zlib.h.
22{ return "Zlib_Compression"; }
◆ send() [1/4]
| void Botan::Filter::send |
( |
byte | in | ) |
|
|
inlineprotectedinherited |
- Parameters
-
| in | some input for the filter |
Definition at line 63 of file filter.h.
References send().
Referenced by send().
◆ send() [2/4]
| void Botan::Filter::send |
( |
const byte | in[], |
|
|
size_t | length ) |
|
protectedinherited |
- Parameters
-
| in | some input for the filter |
| length | the length of in |
Definition at line 28 of file filter.cpp.
29 {
30 bool nothing_attached = true;
31 for(size_t j = 0; j != total_ports(); ++j)
32 if(next[j])
33 {
34 if(write_queue.size())
35 next[j]->write(&write_queue[0], write_queue.size());
36 next[j]->write(input, length);
37 nothing_attached = false;
38 }
39
40 if(nothing_attached)
41 write_queue += std::make_pair(input, length);
42 else
43 write_queue.clear();
44 }
Referenced by Botan::Base64_Decoder::end_msg(), Botan::Base64_Encoder::end_msg(), Botan::Bzip_Compression::end_msg(), Botan::Bzip_Decompression::end_msg(), Botan::Hash_Filter::end_msg(), Botan::Hex_Decoder::end_msg(), Botan::Hex_Encoder::end_msg(), Botan::MAC_Filter::end_msg(), Botan::PK_Decryptor_Filter::end_msg(), Botan::PK_Encryptor_Filter::end_msg(), Botan::PK_Signer_Filter::end_msg(), Botan::PK_Verifier_Filter::end_msg(), Botan::Zlib_Compression::end_msg(), Botan::Zlib_Decompression::end_msg(), Botan::Bzip_Compression::flush(), Botan::Zlib_Compression::flush(), send(), Botan::Base64_Decoder::write(), Botan::Bzip_Compression::write(), Botan::Bzip_Decompression::write(), Botan::Chain::write(), Botan::Fork::write(), Botan::Hex_Decoder::write(), Botan::StreamCipher_Filter::write(), Botan::Zlib_Compression::write(), and Botan::Zlib_Decompression::write().
◆ send() [3/4]
◆ send() [4/4]
- Parameters
-
| in | some input for the filter |
| length | the number of bytes of in to send |
Definition at line 74 of file filter.h.
References send().
◆ start_msg()
| void Botan::Zlib_Compression::start_msg |
( |
| ) |
|
|
virtual |
Start a new message. Must be closed by end_msg() before another message can be started.
Reimplemented from Botan::Filter.
Definition at line 103 of file zlib.cpp.
104 {
105 clear();
106 zlib = new Zlib_Stream;
107 if(deflateInit(&(zlib->stream), level) != Z_OK)
108 throw Memory_Exhaustion();
109 }
◆ write()
| void Botan::Zlib_Compression::write |
( |
const byte | input[], |
|
|
size_t | length ) |
|
virtual |
Write a portion of a message to this filter.
- Parameters
-
| input | the input as a byte array |
| length | the length of the byte array input |
Implements Botan::Filter.
Definition at line 114 of file zlib.cpp.
115 {
116 zlib->stream.next_in = static_cast<Bytef*>(const_cast<byte*>(input));
117 zlib->stream.avail_in = length;
118
119 while(zlib->stream.avail_in != 0)
120 {
121 zlib->stream.next_out = static_cast<Bytef*>(buffer.begin());
122 zlib->stream.avail_out = buffer.size();
123 deflate(&(zlib->stream), Z_NO_FLUSH);
124 send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
125 }
126 }
References Botan::Filter::send().
The documentation for this class was generated from the following files: