Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

compression.cpp
Go to the documentation of this file.
1 /*
2 * Compression Factory
3 * (C) 2014,2016 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #include <botan/compression.h>
9 #include <botan/mem_ops.h>
10 #include <cstdlib>
11
12 #if defined(BOTAN_HAS_ZLIB)
13 #include <botan/zlib.h>
14 #endif
15
16 #if defined(BOTAN_HAS_BZIP2)
17 #include <botan/bzip2.h>
18 #endif
19
20 #if defined(BOTAN_HAS_LZMA)
21 #include <botan/lzma.h>
22 #endif
23
24 namespace Botan {
25
26 Compression_Algorithm* make_compressor(const std::string& name)
27 {
28 #if defined(BOTAN_HAS_ZLIB)
29 if(name == "Zlib" || name == "zlib")
30 return new Zlib_Compression;
31 if(name == "Gzip" || name == "gzip" || name == "gz")
32 return new Gzip_Compression;
33 if(name == "Deflate" || name == "deflate")
34 return new Deflate_Compression;
35 #endif
36
37 #if defined(BOTAN_HAS_BZIP2)
38 if(name == "bzip2" || name == "bz2" || name == "Bzip2")
39 return new Bzip2_Compression;
40 #endif
41
42 #if defined(BOTAN_HAS_LZMA)
43 if(name == "lzma" || name == "xz" || name == "LZMA")
44 return new LZMA_Compression;
45 #endif
46
47 BOTAN_UNUSED(name);
48 return nullptr;
49 }
50
51 Decompression_Algorithm* make_decompressor(const std::string& name)
52 {
53 #if defined(BOTAN_HAS_ZLIB)
54 if(name == "Zlib" || name == "zlib")
55 return new Zlib_Decompression;
56 if(name == "Gzip" || name == "gzip" || name == "gz")
57 return new Gzip_Decompression;
58 if(name == "Deflate" || name == "deflate")
59 return new Deflate_Decompression;
60 #endif
61
62 #if defined(BOTAN_HAS_BZIP2)
63 if(name == "bzip2" || name == "bz2" || name == "Bzip2")
64 return new Bzip2_Decompression;
65 #endif
66
67 #if defined(BOTAN_HAS_LZMA)
68 if(name == "lzma" || name == "xz" || name == "LZMA")
69 return new LZMA_Decompression;
70 #endif
71
72 BOTAN_UNUSED(name);
73 return nullptr;
74 }
75
76
77 }
Botan::Bzip2_Decompression
Definition: bzip2.h:30
Botan::Gzip_Decompression
Definition: zlib.h:77
Botan::Zlib_Compression
Definition: zlib.h:19
Botan::Zlib_Decompression
Definition: zlib.h:30
Botan::Deflate_Compression
Definition: zlib.h:41
Botan::make_compressor
Compression_Algorithm * make_compressor(const std::string &name)
Definition: compression.cpp:26
Botan::Decompression_Algorithm
Definition: compression.h:65
Botan::make_decompressor
Decompression_Algorithm * make_decompressor(const std::string &name)
Definition: compression.cpp:51
Botan::Deflate_Decompression
Definition: zlib.h:52
BOTAN_UNUSED
#define BOTAN_UNUSED(v)
Definition: assert.h:92
Botan::LZMA_Decompression
Definition: lzma.h:32
Botan
Definition: alg_id.cpp:13
Botan::LZMA_Compression
Definition: lzma.h:20
Botan::Bzip2_Compression
Definition: bzip2.h:19
Botan::Compression_Algorithm
Definition: compression.h:19
Botan::Gzip_Compression
Definition: zlib.h:63