Botan: Botan::Bzip_Compression Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
Botan::Bzip_Compression Class Reference

`#include <bzip2.h>`

Inheritance diagram for Botan::Bzip_Compression:

## Public Member Functions
virtual bool | attachable ()
| Bzip_Compression (size_t=9)
void | end_msg ()
void | flush ()
std::string | name () const
void | start_msg ()
void | write (const byte input[], size_t length)
| ~Bzip_Compression ()

## Protected Member Functions
void | send (const byte in[], size_t length)
void | send (byte in)
void | send (const MemoryRegion< byte > &in)
void | send (const MemoryRegion< byte > &in, size_t length)

## Detailed Description

Bzip Compression Filter

Definition at line 19 of file bzip2.h.

## Constructor & Destructor Documentation

Botan::Bzip_Compression::Bzip_Compression | ( | size_t | l = `9` | ) |

Definition at line 95 of file bzip2.cpp.

95 :
96 level((l >= 9) ? 9 : l), buffer(DEFAULT_BUFFERSIZE)
97 {
98 bz = 0;
99 }

Botan::Bzip_Compression::~Bzip_Compression | ( |  | ) |
| inline

Definition at line 31 of file bzip2.h.

31 { clear(); }

## Member Function Documentation

virtual bool Botan::Filter::attachable | ( |  | ) |
| inlinevirtualinherited

Check whether this filter is an attachable filter.

Returns
  true if this filter is attachable, false otherwise

Reimplemented in Botan::SecureQueue, and Botan::DataSink.

Definition at line 50 of file filter.h.

50 { return true; }

void Botan::Bzip_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 132 of file bzip2.cpp.

References Botan::MemoryRegion< T >::begin(), Botan::Filter::send(), and Botan::MemoryRegion< T >::size().

133 {
134 bz->stream.next_in = 0;
135 bz->stream.avail_in = 0;
136
137 int rc = BZ_OK;
138 while(rc != BZ_STREAM_END)
139 {
140 bz->stream.next_out = reinterpret_cast<char*>(buffer.begin());
141 bz->stream.avail_out = buffer.size();
142 rc = BZ2_bzCompress(&(bz->stream), BZ_FINISH);
143 send(buffer, buffer.size() - bz->stream.avail_out);
144 }
145 clear();
146 }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::MemoryRegion::begin
T * begin()
Definition: secmem.h:53

void Botan::Bzip_Compression::flush | ( |  | ) |

Definition at line 151 of file bzip2.cpp.

References Botan::MemoryRegion< T >::begin(), Botan::Filter::send(), Botan::MemoryRegion< T >::size(), and Botan::zeroise().

152 {
153 bz->stream.next_in = 0;
154 bz->stream.avail_in = 0;
155
156 int rc = BZ_OK;
157 while(rc != BZ_RUN_OK)
158 {
159 bz->stream.next_out = reinterpret_cast<char*>(buffer.begin());
160 bz->stream.avail_out = buffer.size();
161 rc = BZ2_bzCompress(&(bz->stream), BZ_FLUSH);
162 send(buffer, buffer.size() - bz->stream.avail_out);
163 }
164 }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::MemoryRegion::begin
T * begin()
Definition: secmem.h:53

std::string Botan::Bzip_Compression::name | ( |  | ) | const
| inlinevirtual

Returns
  descriptive name for this filter

Implements Botan::Filter.

Definition at line 22 of file bzip2.h.

22 { return "Bzip_Compression"; }

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.

References Botan::MemoryRegion< T >::clear(), Botan::Filter::end_msg(), Botan::MemoryRegion< T >::size(), Botan::Filter::start_msg(), and Botan::Filter::write().

Referenced by Botan::Base64_Encoder::Base64_Encoder(), Botan::EAX_Decryption::EAX_Decryption(), Botan::PK_Encryptor_Filter::end_msg(), end_msg(), Botan::Zlib_Compression::end_msg(), Botan::PBE_PKCS5v15::end_msg(), Botan::Hex_Encoder::end_msg(), Botan::Base64_Encoder::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::PK_Decryptor_Filter::end_msg(), Botan::Bzip_Decompression::end_msg(), Botan::Zlib_Decompression::end_msg(), Botan::PK_Signer_Filter::end_msg(), Botan::Hex_Decoder::end_msg(), Botan::Base64_Decoder::end_msg(), Botan::PK_Verifier_Filter::end_msg(), Botan::Hash_Filter::end_msg(), Botan::MAC_Filter::end_msg(), flush(), Botan::Zlib_Compression::flush(), Botan::Hex_Encoder::Hex_Encoder(), Botan::ECB_Encryption::name(), Botan::EAX_Base::name(), Botan::ECB_Decryption::name(), Botan::CTS_Encryption::set_iv(), Botan::CFB_Encryption::set_iv(), Botan::CBC_Encryption::set_iv(), Botan::CFB_Decryption::set_iv(), Botan::CTS_Decryption::set_iv(), Botan::CBC_Decryption::set_iv(), Botan::XTS_Encryption::set_key(), Botan::XTS_Decryption::set_key(), Botan::Zlib_Compression::write(), write(), Botan::StreamCipher_Filter::write(), Botan::Bzip_Decompression::write(), Botan::Zlib_Decompression::write(), Botan::Hex_Decoder::write(), and Botan::Base64_Decoder::write().

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 }
Botan::Filter::write
virtual void write(const byte input[], size_t length)=0
Botan::MemoryRegion::clear
void clear()
Definition: secmem.h:152
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

void Botan::Filter::send | ( | byte | in | ) |
| inlineprotectedinherited

Parameters

  in | some input for the filter

Definition at line 63 of file filter.h.

References Botan::Filter::send().

Referenced by Botan::Filter::send().

63 { send(&in, 1); }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28

void Botan::Filter::send | ( | const MemoryRegion< byte > & | in | ) |
| inlineprotectedinherited

Parameters

  in | some input for the filter

Definition at line 68 of file filter.h.

References Botan::Filter::send(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::Filter::send().

68 { send(&in[0], in.size()); }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29

void Botan::Filter::send | ( | const MemoryRegion< byte > & | in,
|  | size_t | length
| ) |  |
| inlineprotectedinherited

Parameters

  in | some input for the filter
  length | the number of bytes of in to send

Definition at line 74 of file filter.h.

75 {
76 send(&in[0], length);
77 }
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28

void Botan::Bzip_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 104 of file bzip2.cpp.

105 {
106 clear();
107 bz = new Bzip_Stream;
108 if(BZ2_bzCompressInit(&(bz->stream), level, 0, 0) != BZ_OK)
109 throw Memory_Exhaustion();
110 }

void Botan::Bzip_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 115 of file bzip2.cpp.

References Botan::MemoryRegion< T >::begin(), Botan::Filter::send(), and Botan::MemoryRegion< T >::size().

116 {
117 bz->stream.next_in = reinterpret_cast<char*>(const_cast<byte*>(input));
118 bz->stream.avail_in = length;
119
120 while(bz->stream.avail_in != 0)
121 {
122 bz->stream.next_out = reinterpret_cast<char*>(buffer.begin());
123 bz->stream.avail_out = buffer.size();
124 BZ2_bzCompress(&(bz->stream), BZ_RUN);
125 send(buffer, buffer.size() - bz->stream.avail_out);
126 }
127 }
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::Filter::send
void send(const byte in[], size_t length)
Definition: filter.cpp:28
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::MemoryRegion::begin
T * begin()
Definition: secmem.h:53

The documentation for this class was generated from the following files:

- src/filters/bzip2/bzip2.h
- src/filters/bzip2/bzip2.cpp