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