aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/compression/bzip2/bzip2.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-12-09 01:53:06 +0000
committerlloyd <[email protected]>2014-12-09 01:53:06 +0000
commit0bc9c6b170bd2c52a2fccfda12f767700bb40968 (patch)
tree5c1328b44da71c512332442e3d36989df70ef7c7 /src/lib/compression/bzip2/bzip2.cpp
parente14d04baf0261d5250285fcb6486950078b2c6e7 (diff)
Figure out which decompressor to use based on the input file extension.
Rename Bzip to Bzip2, and split Zlib and Deflate compressors into two completely distinct types rather than using a bool flag to the Zlib constructor. Ignore null pointers to our free implementation (LZMA does this).
Diffstat (limited to 'src/lib/compression/bzip2/bzip2.cpp')
-rw-r--r--src/lib/compression/bzip2/bzip2.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/lib/compression/bzip2/bzip2.cpp b/src/lib/compression/bzip2/bzip2.cpp
index 313b1ed46..ed464d332 100644
--- a/src/lib/compression/bzip2/bzip2.cpp
+++ b/src/lib/compression/bzip2/bzip2.cpp
@@ -1,5 +1,5 @@
/*
-* Bzip Compressor
+* Bzip2 Compressor
* (C) 2001 Peter J Jones
* 2001-2007,2014 Jack Lloyd
* 2006 Matt Johnston
@@ -17,10 +17,10 @@ namespace Botan {
namespace {
-class Bzip_Stream : public Zlib_Style_Stream<bz_stream, char>
+class Bzip2_Stream : public Zlib_Style_Stream<bz_stream, char>
{
public:
- Bzip_Stream()
+ Bzip2_Stream()
{
streamp()->opaque = alloc();
streamp()->bzalloc = Compression_Alloc_Info::malloc<int>;
@@ -32,12 +32,12 @@ class Bzip_Stream : public Zlib_Style_Stream<bz_stream, char>
u32bit finish_flag() const override { return BZ_FINISH; }
};
-class Bzip_Compression_Stream : public Bzip_Stream
+class Bzip2_Compression_Stream : public Bzip2_Stream
{
public:
- Bzip_Compression_Stream(size_t level)
+ Bzip2_Compression_Stream(size_t block_size)
{
- int rc = BZ2_bzCompressInit(streamp(), level, 0, 0);
+ int rc = BZ2_bzCompressInit(streamp(), block_size, 0, 0);
if(rc == BZ_MEM_ERROR)
throw std::bad_alloc();
@@ -45,7 +45,7 @@ class Bzip_Compression_Stream : public Bzip_Stream
throw std::runtime_error("bzip compress initialization failed");
}
- ~Bzip_Compression_Stream()
+ ~Bzip2_Compression_Stream()
{
BZ2_bzCompressEnd(streamp());
}
@@ -61,15 +61,12 @@ class Bzip_Compression_Stream : public Bzip_Stream
return (rc == BZ_STREAM_END);
}
-
- private:
- size_t m_level;
};
-class Bzip_Decompression_Stream : public Bzip_Stream
+class Bzip2_Decompression_Stream : public Bzip2_Stream
{
public:
- Bzip_Decompression_Stream()
+ Bzip2_Decompression_Stream()
{
int rc = BZ2_bzDecompressInit(streamp(), 0, 0);
@@ -79,7 +76,7 @@ class Bzip_Decompression_Stream : public Bzip_Stream
throw std::runtime_error("bzip decompress initialization failed");
}
- ~Bzip_Decompression_Stream()
+ ~Bzip2_Decompression_Stream()
{
BZ2_bzDecompressEnd(streamp());
}
@@ -99,14 +96,14 @@ class Bzip_Decompression_Stream : public Bzip_Stream
}
-Compression_Stream* Bzip_Compression::make_stream() const
+Compression_Stream* Bzip2_Compression::make_stream() const
{
- return new Bzip_Compression_Stream(m_level);
+ return new Bzip2_Compression_Stream(m_block_size);
}
-Compression_Stream* Bzip_Decompression::make_stream() const
+Compression_Stream* Bzip2_Decompression::make_stream() const
{
- return new Bzip_Decompression_Stream;
+ return new Bzip2_Decompression_Stream;
}
}