blob: 903a5f77002852a0c58522496ce97d9efc91f30b (
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
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
* compressor.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "internal.h"
int fstream_compressor_id_from_name(const char *name)
{
if (strcmp(name, "gzip") == 0)
return FSTREAM_COMPRESSOR_GZIP;
if (strcmp(name, "xz") == 0)
return FSTREAM_COMPRESSOR_XZ;
if (strcmp(name, "zstd") == 0)
return FSTREAM_COMPRESSOR_ZSTD;
if (strcmp(name, "bzip2") == 0)
return FSTREAM_COMPRESSOR_BZIP2;
return -1;
}
const char *fstream_compressor_name_from_id(int id)
{
if (id == FSTREAM_COMPRESSOR_GZIP)
return "gzip";
if (id == FSTREAM_COMPRESSOR_XZ)
return "xz";
if (id == FSTREAM_COMPRESSOR_ZSTD)
return "zstd";
if (id == FSTREAM_COMPRESSOR_BZIP2)
return "bzip2";
return NULL;
}
bool fstream_compressor_exists(int id)
{
switch (id) {
#ifdef WITH_GZIP
case FSTREAM_COMPRESSOR_GZIP:
return true;
#endif
#ifdef WITH_XZ
case FSTREAM_COMPRESSOR_XZ:
return true;
#endif
#ifdef WITH_ZSTD
case FSTREAM_COMPRESSOR_ZSTD:
return true;
#endif
#ifdef WITH_BZIP2
case FSTREAM_COMPRESSOR_BZIP2:
return true;
#endif
default:
break;
}
return false;
}
|