XZ Utils
5.1.0alpha
|
Compresses or uncompresses a file. More...
#include "private.h"
Enumerations | |
enum | coder_init_ret { CODER_INIT_NORMAL, CODER_INIT_PASSTHRU, CODER_INIT_ERROR } |
Return value type for coder_init(). More... | |
Functions | |
void | coder_set_check (lzma_check new_check) |
Set the integrity check type used when compressing. More... | |
void | coder_set_preset (uint32_t new_preset) |
Set preset number. More... | |
void | coder_set_extreme (void) |
Enable extreme mode. More... | |
void | coder_add_filter (lzma_vli id, void *options) |
Add a filter to the custom filter chain. More... | |
static void | lzma_attribute ((__noreturn__)) |
void | coder_set_compression_settings (void) |
static bool | is_format_xz (void) |
Return true if the data in in_buf seems to be in the .xz format. More... | |
static bool | is_format_lzma (void) |
Return true if the data in in_buf seems to be in the .lzma format. More... | |
static enum coder_init_ret | coder_init (file_pair *pair) |
static bool | coder_normal (file_pair *pair) |
Compress or decompress using liblzma. More... | |
static bool | coder_passthru (file_pair *pair) |
void | coder_run (const char *filename) |
Compress or decompress the given file. More... | |
void | coder_free (void) |
Free the memory allocated for the coder and kill the worker threads. More... | |
Variables | |
enum operation_mode | opt_mode = MODE_COMPRESS |
enum format_type | opt_format = FORMAT_AUTO |
bool | opt_auto_adjust = true |
bool | opt_single_stream = false |
If true, stop after decoding the first stream. More... | |
uint64_t | opt_block_size = 0 |
static lzma_stream | strm = LZMA_STREAM_INIT |
Stream used to communicate with liblzma. More... | |
static lzma_filter | filters [LZMA_FILTERS_MAX+1] |
Filters needed for all encoding all formats, and also decoding in raw data. More... | |
static io_buf | in_buf |
Input and output buffers. More... | |
static io_buf | out_buf |
static uint32_t | filters_count = 0 |
Number of filters. Zero indicates that we are using a preset. More... | |
static uint32_t | preset_number = 6 |
Number of the preset (0-9) More... | |
static bool | preset_extreme = false |
static lzma_check | check |
Integrity check type. More... | |
static bool | check_default = true |
This becomes false if the –check=CHECK option is used. More... | |
Compresses or uncompresses a file.
enum coder_init_ret |
Return value type for coder_init().
void coder_set_check | ( | lzma_check | new_check | ) |
Set the integrity check type used when compressing.
References check, and check_default.
Referenced by parse_memlimit().
void coder_set_preset | ( | uint32_t | new_preset | ) |
Set preset number.
References filters_count, lzma_filter::options, and preset_number.
Referenced by parse_memlimit().
void coder_set_extreme | ( | void | ) |
void coder_add_filter | ( | lzma_vli | id, |
void * | options | ||
) |
Add a filter to the custom filter chain.
References check, check_default, lzma_options_lzma::dict_size, filters_count, hardware_memlimit_get(), id, lzma_filter::id, LZMA_CHECK_CRC32, LZMA_CHECK_CRC64, lzma_check_is_supported(), LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA2, LZMA_FILTERS_MAX, lzma_lzma_preset(), LZMA_PRESET_EXTREME, lzma_raw_decoder_memusage(), lzma_raw_encoder_memusage(), LZMA_VLI_UNKNOWN, message(), message_bug(), message_fatal(), message_filters_show(), message_mem_needed(), opt_auto_adjust, opt_format, opt_mode, lzma_filter::options, preset_extreme, preset_number, round_up_to_mib(), uint64_to_str(), V_DEBUG, V_ERROR, and V_WARNING.
Referenced by parse_memlimit().
|
static |
Return true if the data in in_buf seems to be in the .xz format.
References lzma_stream::avail_in.
Referenced by coder_init().
|
static |
Return true if the data in in_buf seems to be in the .lzma format.
References lzma_stream::avail_in, lzma_options_lzma::dict_size, lzma_filter::id, LZMA_FILTER_LZMA1, LZMA_OK, lzma_properties_decode(), and lzma_filter::options.
Referenced by coder_init().
|
static |
Detect the input file type (for now, this done only when decompressing), and initialize an appropriate coder. Return value indicates if a normal liblzma-based coder was initialized (CODER_INIT_NORMAL), if passthru mode should be used (CODER_INIT_PASSTHRU), or if an error occurred (CODER_INIT_ERROR).
References lzma_stream::avail_out, check, hardware_memlimit_get(), is_format_lzma(), is_format_xz(), lzma_alone_decoder(), lzma_alone_encoder(), lzma_code(), LZMA_CONCATENATED, LZMA_FORMAT_ERROR, lzma_memusage(), LZMA_OK, LZMA_PROG_ERROR, lzma_raw_decoder(), lzma_raw_encoder(), LZMA_RUN, lzma_stream_decoder(), lzma_stream_encoder(), LZMA_TELL_UNSUPPORTED_CHECK, message_error(), message_mem_needed(), message_strm(), lzma_stream::next_out, opt_format, opt_mode, opt_single_stream, file_pair::src_name, and V_ERROR.
Referenced by coder_run().
|
static |
Compress or decompress using liblzma.
References lzma_stream::avail_in, lzma_stream::avail_out, io_fix_src_pos(), io_read(), io_write(), lzma_code(), LZMA_DATA_ERROR, LZMA_FINISH, LZMA_FULL_FLUSH, lzma_memusage(), LZMA_NO_CHECK, LZMA_OK, LZMA_RUN, LZMA_STREAM_END, LZMA_UNSUPPORTED_CHECK, message_error(), message_mem_needed(), message_progress_update(), message_strm(), message_warning(), lzma_stream::next_in, lzma_stream::next_out, opt_block_size, opt_format, opt_mode, opt_single_stream, file_pair::src_eof, file_pair::src_name, user_abort, and V_ERROR.
Referenced by coder_run().
|
static |
Copy from input file to output file without processing the data in any way. This is used only when trying to decompress unrecognized files with –decompress –stdout –force, so the output is always stdout.
References lzma_stream::avail_in, io_read(), io_write(), message_progress_update(), lzma_stream::total_in, lzma_stream::total_out, and user_abort.
Referenced by coder_run().
void coder_run | ( | const char * | filename | ) |
Compress or decompress the given file.
References lzma_stream::avail_in, coder_init(), coder_normal(), coder_passthru(), io_close(), io_open_dest(), io_open_src(), io_read(), message_filename(), message_progress_end(), message_progress_start(), lzma_stream::next_in, opt_mode, file_pair::src_st, and user_abort.
Referenced by set_exit_no_warn().
void coder_free | ( | void | ) |
Free the memory allocated for the coder and kill the worker threads.
References lzma_end().
Referenced by set_exit_no_warn().
enum operation_mode opt_mode = MODE_COMPRESS |
Operation mode of the command line tool. This is set in args.c and read in several files.
Referenced by coder_add_filter(), coder_init(), coder_normal(), coder_run(), io_close_src(), message_filename(), message_mem_needed(), parse_memlimit(), print_filename(), progress_pos(), set_exit_no_warn(), and suffix_get_dest_name().
enum format_type opt_format = FORMAT_AUTO |
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.
Referenced by coder_add_filter(), coder_init(), coder_normal(), compressed_name(), list_file(), parse_memlimit(), and uncompressed_name().
bool opt_auto_adjust = true |
If true, the compression settings are automatically adjusted down if they exceed the memory usage limit.
Referenced by coder_add_filter(), and parse_memlimit().
bool opt_single_stream = false |
If true, stop after decoding the first stream.
Referenced by coder_init(), coder_normal(), and parse_memlimit().
uint64_t opt_block_size = 0 |
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.
Referenced by coder_normal(), and parse_memlimit().
|
static |
Stream used to communicate with liblzma.
Referenced by lzma_block_decoder(), lzma_filters_update(), lzma_next_end(), lzma_raw_decoder(), lzma_raw_encoder(), lzma_stream_decoder(), lzma_stream_encoder(), message_progress_start(), parse_indexes(), and parse_options().
|
static |
Filters needed for all encoding all formats, and also decoding in raw data.
Referenced by copy_or_code(), encode_in_place(), lzma_block_buffer_bound(), lzma_filters_copy(), lzma_filters_update(), lzma_raw_decoder_memusage(), lzma_raw_encoder_memusage(), lzma_stream_buffer_encode(), mf_read(), and parse_block_header().
|
static |
Input and output buffers.
Referenced by parse_options().
|
static |
Number of filters. Zero indicates that we are using a preset.
Referenced by coder_add_filter(), and coder_set_preset().
|
static |
Number of the preset (0-9)
Referenced by coder_add_filter(), and coder_set_preset().
|
static |
If a preset is used (no custom filter chain) and preset_extreme is true, a significantly slower compression is used to achieve slightly better compression ratio.
Referenced by coder_add_filter(), and coder_set_extreme().
|
static |
Integrity check type.
Referenced by coder_add_filter(), coder_init(), coder_set_check(), lzma_block_buffer_encode(), lzma_stream_buffer_encode(), and parse_memlimit().
|
static |
This becomes false if the –check=CHECK option is used.
Referenced by coder_add_filter(), and coder_set_check().