Rizin
unix-like reverse engineering framework and cli tools
|
Compresses or uncompresses a file. More...
#include "private.h"
Go to the source code of this file.
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... | |
static void | forget_filter_chain (void) |
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 enum coder_init_ret | coder_init (file_pair *pair) |
static void | split_block (uint64_t *block_remaining, uint64_t *next_block_remaining, size_t *list_pos) |
static bool | coder_write_output (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 |
uint64_t * | opt_block_list = NULL |
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 = LZMA_PRESET_DEFAULT |
Number of the preset (0-9) More... | |
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.
Definition in file coder.c.
enum coder_init_ret |
Return value type for coder_init().
Enumerator | |
---|---|
CODER_INIT_NORMAL | |
CODER_INIT_PASSTHRU | |
CODER_INIT_ERROR |
Definition at line 17 of file coder.c.
void coder_add_filter | ( | lzma_vli | id, |
void * | options | ||
) |
Add a filter to the custom filter chain.
Definition at line 107 of file coder.c.
References _, filters, filters_count, id, lzma_filter::id, LZMA_FILTERS_MAX, LZMA_PRESET_DEFAULT, message_fatal(), options, lzma_filter::options, and preset_number.
Referenced by parse_real().
void coder_free | ( | void | ) |
|
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).
Definition at line 137 of file coder.c.
References _, assert(), lzma_mt::block_size, lzma_mt::check, check, check_default, lzma_options_lzma::dict_size, filters, filters_count, FORMAT_LZMA, FORMAT_RAW, FORMAT_XZ, hardware_memlimit_get(), hardware_threads_get(), hardware_threads_set(), i, lzma_filter::id, LZMA_CHECK_CRC32, LZMA_CHECK_CRC64, LZMA_FILTER_DELTA, LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA2, LZMA_VLI_UNKNOWN, message, message_bug(), message_fatal(), message_filters_show(), message_mem_needed(), MODE_COMPRESS, opt_auto_adjust, opt_block_size, opt_flush_timeout, opt_format, opt_lzma, opt_mode, lzma_filter::options, preset_number, PRIu32, round_up_to_mib(), lzma_mt::threads, UINT32_C, UINT64_MAX, uint64_to_str(), V_DEBUG, and V_WARNING.
Referenced by coder_run().
Compress or decompress using liblzma.
Definition at line 631 of file coder.c.
References test-lz4-speed::action, assert(), lzma_stream::avail_in, lzma_stream::avail_out, coder_write_output(), file_pair::flush_needed, FORMAT_XZ, hardware_threads_get(), in_buf, IO_BUFFER_SIZE, io_fix_src_pos(), io_read(), LZMA_DATA_ERROR, LZMA_FINISH, LZMA_FULL_BARRIER, LZMA_MEMLIMIT_ERROR, LZMA_NO_CHECK, LZMA_OK, LZMA_RUN, LZMA_STREAM_END, LZMA_SYNC_FLUSH, LZMA_UNSUPPORTED_CHECK, message_error(), message_mem_needed(), message_progress_update(), message_strm(), message_warning(), MODE_COMPRESS, my_min, lzma_stream::next_in, lzma_stream::next_out, NULL, opt_block_list, opt_block_size, opt_format, opt_mode, opt_single_stream, out_buf, SIZE_MAX, split_block(), file_pair::src_eof, file_pair::src_has_seen_input, file_pair::src_name, strm, io_buf::u8, UINT64_MAX, user_abort, and V_ERROR.
Referenced by coder_run().
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.
Definition at line 846 of file coder.c.
References lzma_stream::avail_in, in_buf, IO_BUFFER_SIZE, io_read(), io_write(), message_progress_update(), SIZE_MAX, strm, 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.
Definition at line 869 of file coder.c.
References lzma_stream::avail_in, coder_init(), CODER_INIT_ERROR, CODER_INIT_PASSTHRU, coder_normal(), coder_passthru(), in_buf, in_size, IO_BUFFER_SIZE, io_close(), io_open_dest(), io_open_src(), io_read(), message_filename(), message_progress_end(), message_progress_start(), MODE_COMPRESS, MODE_TEST, mytime_set_start_time(), lzma_stream::next_in, NULL, opt_mode, SIZE_MAX, file_pair::src_st, strm, io_buf::u8, and user_abort.
Referenced by main().
void coder_set_check | ( | lzma_check | new_check | ) |
Set the integrity check type used when compressing.
Definition at line 64 of file coder.c.
References check, and check_default.
Referenced by parse_real().
void coder_set_compression_settings | ( | void | ) |
Definition at line 137 of file coder.c.
Referenced by args_parse().
void coder_set_extreme | ( | void | ) |
Enable extreme mode.
Definition at line 98 of file coder.c.
References forget_filter_chain(), LZMA_PRESET_EXTREME, and preset_number.
Referenced by parse_real().
void coder_set_preset | ( | uint32_t | new_preset | ) |
Set preset number.
Definition at line 88 of file coder.c.
References forget_filter_chain(), LZMA_PRESET_LEVEL_MASK, and preset_number.
Referenced by parse_real().
Definition at line 616 of file coder.c.
References lzma_stream::avail_out, IO_BUFFER_SIZE, io_write(), MODE_TEST, lzma_stream::next_out, opt_mode, out_buf, strm, and io_buf::u8.
Referenced by coder_normal().
|
static |
Definition at line 73 of file coder.c.
References filters, filters_count, free(), NULL, options, and lzma_filter::options.
Referenced by coder_set_extreme(), and coder_set_preset().
|
static |
Definition at line 126 of file coder.c.
References _, E_ERROR, message, message_mem_needed(), tuklib_exit, and V_ERROR.
|
static |
Resolve conflicts between opt_block_size and opt_block_list in single threaded mode. We want to default to opt_block_list, except when it is larger than opt_block_size. If this is the case for the current Block at *list_pos, then we break into smaller Blocks. Otherwise advance to the next Block in opt_block_list, and break apart if needed.
Definition at line 571 of file coder.c.
References assert(), hardware_threads_get(), NULL, opt_block_list, and opt_block_size.
Referenced by coder_normal().
|
static |
Integrity check type.
Definition at line 49 of file coder.c.
Referenced by coder_init(), and coder_set_check().
This becomes false if the –check=CHECK option is used.
Definition at line 52 of file coder.c.
Referenced by coder_init(), and coder_set_check().
|
static |
Filters needed for all encoding all formats, and also decoding in raw data.
Definition at line 36 of file coder.c.
Referenced by coder_add_filter(), coder_init(), and forget_filter_chain().
|
static |
Number of filters. Zero indicates that we are using a preset.
Definition at line 43 of file coder.c.
Referenced by coder_add_filter(), coder_init(), and forget_filter_chain().
|
static |
Input and output buffers.
Definition at line 39 of file coder.c.
Referenced by coder_normal(), coder_passthru(), coder_run(), on_rebase_pointer(), rebase_buffer(), rebase_bytes_v1(), rebase_bytes_v2(), rebase_bytes_v3(), uncompress(), xz_compress(), and xz_decompress().
If true, the compression settings are automatically adjusted down if they exceed the memory usage limit.
Definition at line 26 of file coder.c.
Referenced by coder_init(), and parse_real().
This is non-NULL if –block-list was used. This contains the Block sizes as an array that is terminated with 0.
Definition at line 29 of file coder.c.
Referenced by args_free(), coder_normal(), parse_block_list(), and split_block().
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.
Definition at line 28 of file coder.c.
Referenced by coder_init(), coder_normal(), parse_real(), and split_block().
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.
Definition at line 1 of file coder.c.
Referenced by args_parse(), coder_init(), coder_normal(), compressed_name(), list_file(), parse_real(), and uncompressed_name().
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.
Definition at line 1 of file coder.c.
Referenced by args_parse(), coder_init(), coder_normal(), coder_run(), coder_write_output(), io_open_dest_real(), io_open_src_real(), main(), message_filename(), message_mem_needed(), mytime_get_flush_timeout(), parse_real(), print_filename(), progress_pos(), and suffix_get_dest_name().
If true, stop after decoding the first stream.
Definition at line 27 of file coder.c.
Referenced by coder_normal(), and parse_real().
|
static |
Definition at line 40 of file coder.c.
Referenced by coder_normal(), coder_write_output(), handle_tmp_desc(), rz_core_rtr_gdb_cb(), uncompress(), xz_compress(), and xz_decompress().
|
static |
Number of the preset (0-9)
Definition at line 46 of file coder.c.
Referenced by coder_add_filter(), coder_init(), coder_set_extreme(), and coder_set_preset().
|
static |
Stream used to communicate with liblzma.
Definition at line 33 of file coder.c.
Referenced by coder_free(), coder_normal(), coder_passthru(), coder_run(), and coder_write_output().