Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | /* |
2 | * libdpkg - Debian packaging suite library routines | |
3 | * compress.h - compression support functions | |
4 | * | |
5 | * Copyright © 2004 Scott James Remnant <scott@netsplit.com> | |
6 | * Copyright © 2006-2014 Guillem Jover <guillem@debian.org> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
20 | */ | |
21 | ||
22 | #ifndef LIBDPKG_COMPRESS_H | |
23 | #define LIBDPKG_COMPRESS_H | |
24 | ||
25 | #include <dpkg/macros.h> | |
26 | #include <dpkg/error.h> | |
27 | ||
28 | #include <stdbool.h> | |
29 | ||
30 | DPKG_BEGIN_DECLS | |
31 | ||
32 | /** | |
33 | * @defgroup compress Compression | |
34 | * @ingroup dpkg-internal | |
35 | * @{ | |
36 | */ | |
37 | ||
38 | enum compressor_type { | |
39 | COMPRESSOR_TYPE_UNKNOWN = -1, | |
40 | COMPRESSOR_TYPE_NONE, | |
41 | COMPRESSOR_TYPE_GZIP, | |
42 | COMPRESSOR_TYPE_XZ, | |
43 | COMPRESSOR_TYPE_BZIP2, | |
44 | COMPRESSOR_TYPE_LZMA, | |
45 | }; | |
46 | ||
47 | enum compressor_strategy { | |
48 | COMPRESSOR_STRATEGY_UNKNOWN = -1, | |
49 | COMPRESSOR_STRATEGY_NONE, | |
50 | COMPRESSOR_STRATEGY_FILTERED, | |
51 | COMPRESSOR_STRATEGY_HUFFMAN, | |
52 | COMPRESSOR_STRATEGY_RLE, | |
53 | COMPRESSOR_STRATEGY_FIXED, | |
54 | COMPRESSOR_STRATEGY_EXTREME, | |
55 | }; | |
56 | ||
57 | struct compress_params { | |
58 | enum compressor_type type; | |
59 | enum compressor_strategy strategy; | |
60 | int level; | |
61 | }; | |
62 | ||
63 | enum compressor_type compressor_find_by_name(const char *name); | |
64 | enum compressor_type compressor_find_by_extension(const char *name); | |
65 | ||
66 | const char *compressor_get_name(enum compressor_type type); | |
67 | const char *compressor_get_extension(enum compressor_type type); | |
68 | ||
69 | enum compressor_strategy compressor_get_strategy(const char *name); | |
70 | ||
71 | bool compressor_check_params(struct compress_params *params, | |
72 | struct dpkg_error *err); | |
73 | ||
74 | void decompress_filter(enum compressor_type type, int fd_in, int fd_out, | |
75 | const char *desc, ...) | |
76 | DPKG_ATTR_PRINTF(4); | |
77 | void compress_filter(struct compress_params *params, int fd_in, int fd_out, | |
78 | const char *desc, ...) | |
79 | DPKG_ATTR_PRINTF(4); | |
80 | ||
81 | /** @} */ | |
82 | ||
83 | DPKG_END_DECLS | |
84 | ||
85 | #endif /* LIBDPKG_COMPRESS_H */ |