2007-12-08 17:42:33 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2009-06-26 14:00:35 -04:00
|
|
|
/// \file coder.h
|
2007-12-08 17:42:33 -05:00
|
|
|
/// \brief Compresses or uncompresses a file
|
|
|
|
//
|
2023-07-17 12:51:48 -04:00
|
|
|
// Authors: Lasse Collin
|
|
|
|
// Jia Tan
|
2007-12-08 17:42:33 -05:00
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-11-19 13:46:52 -05:00
|
|
|
enum operation_mode {
|
|
|
|
MODE_COMPRESS,
|
|
|
|
MODE_DECOMPRESS,
|
|
|
|
MODE_TEST,
|
|
|
|
MODE_LIST,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: The order of these is significant in suffix.c.
|
|
|
|
enum format_type {
|
|
|
|
FORMAT_AUTO,
|
|
|
|
FORMAT_XZ,
|
|
|
|
FORMAT_LZMA,
|
2022-10-08 14:28:15 -04:00
|
|
|
#ifdef HAVE_LZIP_DECODER
|
|
|
|
FORMAT_LZIP,
|
|
|
|
#endif
|
2008-11-19 13:46:52 -05:00
|
|
|
FORMAT_RAW,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-04-18 08:29:09 -04:00
|
|
|
/// Simple struct to track Block metadata specified through the
|
|
|
|
/// --block-list option.
|
|
|
|
typedef struct {
|
|
|
|
/// Uncompressed size of the Block
|
|
|
|
uint64_t size;
|
|
|
|
|
|
|
|
/// Index into the filters[] representing the filter chain to use
|
|
|
|
/// for this Block.
|
|
|
|
uint32_t filters_index;
|
|
|
|
} block_list_entry;
|
|
|
|
|
|
|
|
|
2008-11-19 13:46:52 -05:00
|
|
|
/// Operation mode of the command line tool. This is set in args.c and read
|
|
|
|
/// in several files.
|
|
|
|
extern enum operation_mode opt_mode;
|
|
|
|
|
|
|
|
/// File format to use when encoding or what format(s) to accept when
|
|
|
|
/// decoding. This is a global because it's needed also in suffix.c.
|
|
|
|
/// This is set in args.c.
|
|
|
|
extern enum format_type opt_format;
|
|
|
|
|
2010-06-15 07:06:29 -04:00
|
|
|
/// If true, the compression settings are automatically adjusted down if
|
|
|
|
/// they exceed the memory usage limit.
|
|
|
|
extern bool opt_auto_adjust;
|
|
|
|
|
2011-03-18 12:19:19 -04:00
|
|
|
/// If true, stop after decoding the first stream.
|
|
|
|
extern bool opt_single_stream;
|
|
|
|
|
2011-03-18 13:10:30 -04:00
|
|
|
/// If non-zero, start a new .xz Block after every opt_block_size bytes
|
|
|
|
/// of input. This has an effect only when compressing to the .xz format.
|
|
|
|
extern uint64_t opt_block_size;
|
2008-11-19 13:46:52 -05:00
|
|
|
|
2023-04-18 08:29:09 -04:00
|
|
|
/// List of block size and filter chain pointer pairs.
|
|
|
|
extern block_list_entry *opt_block_list;
|
2012-07-03 14:16:39 -04:00
|
|
|
|
2008-11-19 13:46:52 -05:00
|
|
|
/// Set the integrity check type used when compressing
|
|
|
|
extern void coder_set_check(lzma_check check);
|
|
|
|
|
|
|
|
/// Set preset number
|
2011-04-08 10:53:05 -04:00
|
|
|
extern void coder_set_preset(uint32_t new_preset);
|
2008-11-19 13:46:52 -05:00
|
|
|
|
2008-12-27 12:30:19 -05:00
|
|
|
/// Enable extreme mode
|
|
|
|
extern void coder_set_extreme(void);
|
|
|
|
|
2008-11-19 13:46:52 -05:00
|
|
|
/// Add a filter to the custom filter chain
|
|
|
|
extern void coder_add_filter(lzma_vli id, void *options);
|
|
|
|
|
2023-01-16 08:35:45 -05:00
|
|
|
/// Set and partially validate compression settings. This can also be used
|
|
|
|
/// in decompression or test mode with the raw format.
|
2008-11-19 13:46:52 -05:00
|
|
|
extern void coder_set_compression_settings(void);
|
|
|
|
|
2009-06-26 13:43:36 -04:00
|
|
|
/// Compress or decompress the given file
|
|
|
|
extern void coder_run(const char *filename);
|
2011-04-05 08:13:29 -04:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
/// Free the memory allocated for the coder and kill the worker threads.
|
|
|
|
extern void coder_free(void);
|
|
|
|
#endif
|
2023-01-05 11:02:29 -05:00
|
|
|
|
|
|
|
/// Create filter chain from string
|
|
|
|
extern void coder_add_filters_from_str(const char *filter_str);
|
2023-04-18 08:29:09 -04:00
|
|
|
|
|
|
|
/// Add or overwrite a filter that can be used by the block-list.
|
|
|
|
extern void coder_add_block_filters(const char *str, size_t slot);
|