Botan  2.1.0
Crypto and TLS for C++11
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 }
Compression_Algorithm * make_compressor(const std::string &name)
Definition: compression.cpp:26
Decompression_Algorithm * make_decompressor(const std::string &name)
Definition: compression.cpp:51
#define BOTAN_UNUSED(v)
Definition: assert.h:92
Definition: alg_id.cpp:13