Listing information about .xz files. More...
#include "private.h"
#include "tuklib_integer.h"
Data Structures | |
struct | xz_file_info |
Information about a .xz file. More... | |
struct | block_header_info |
Information about a .xz Block. More... | |
Defines | |
#define | XZ_FILE_INFO_INIT { NULL, 0, 0, true } |
#define | CHECKS_STR_SIZE 1024 |
Functions | |
static bool | parse_indexes (xz_file_info *xfi, file_pair *pair) |
Parse the Index(es) from the given .xz file. | |
static bool | parse_block_header (file_pair *pair, const lzma_index_iter *iter, block_header_info *bhi, xz_file_info *xfi) |
Parse the Block Header. | |
static bool | parse_check_value (file_pair *pair, const lzma_index_iter *iter) |
Parse the Check field and put it into check_value[]. | |
static bool | parse_details (file_pair *pair, const lzma_index_iter *iter, block_header_info *bhi, xz_file_info *xfi) |
Parse detailed information about a Block. | |
static const char * | get_ratio (uint64_t compressed_size, uint64_t uncompressed_size) |
Get the compression ratio. | |
static void | get_check_names (char buf[CHECKS_STR_SIZE], uint32_t checks, bool space_after_comma) |
Get a comma-separated list of Check names. | |
static bool | print_info_basic (const xz_file_info *xfi, file_pair *pair) |
static void | print_adv_helper (uint64_t stream_count, uint64_t block_count, uint64_t compressed_size, uint64_t uncompressed_size, uint32_t checks, uint64_t stream_padding) |
static bool | print_info_adv (xz_file_info *xfi, file_pair *pair) |
static bool | print_info_robot (xz_file_info *xfi, file_pair *pair) |
static void | update_totals (const xz_file_info *xfi) |
static void | print_totals_basic (void) |
static void | print_totals_adv (void) |
static void | print_totals_robot (void) |
void | list_totals (void) |
Show the totals after all files have been listed. | |
void | list_file (const char *filename) |
List information about the given .xz file. | |
Variables | |
static const char | check_names [LZMA_CHECK_ID_MAX+1][12] |
Check ID to string mapping. | |
static char | check_value [2 *LZMA_CHECK_SIZE_MAX+1] |
struct { | |
uint64_t files | |
uint64_t streams | |
uint64_t blocks | |
uint64_t compressed_size | |
uint64_t uncompressed_size | |
uint64_t stream_padding | |
uint64_t memusage_max | |
uint32_t checks | |
bool all_have_sizes | |
} | totals |
Listing information about .xz files.
#define CHECKS_STR_SIZE 1024 |
Buffer size for get_check_names(). This may be a bit ridiculous, but at least it's enough if some language needs many multibyte chars.
static bool parse_indexes | ( | xz_file_info * | xfi, | |
file_pair * | pair | |||
) | [static] |
Parse the Index(es) from the given .xz file.
xfi | Pointer to structure where the decoded information is stored. | |
pair | Input file |
References lzma_stream::avail_in, lzma_stream_flags::backward_size, hardware_memlimit_get(), xz_file_info::idx, io_pread(), LZMA_BUF_ERROR, lzma_code(), LZMA_DATA_ERROR, lzma_end(), lzma_index_cat(), lzma_index_decoder(), lzma_index_end(), lzma_index_memused(), lzma_index_stream_flags(), lzma_index_stream_padding(), lzma_index_total_size(), lzma_memusage(), LZMA_OK, LZMA_RUN, LZMA_STREAM_END, lzma_stream_flags_compare(), lzma_stream_footer_decode(), lzma_stream_header_decode(), LZMA_STREAM_HEADER_SIZE, message_bug(), message_error(), message_mem_needed(), message_strm(), lzma_stream::next_in, file_pair::src_name, file_pair::src_st, xz_file_info::stream_padding, strm, and V_ERROR.
Referenced by list_file().
static bool parse_block_header | ( | file_pair * | pair, | |
const lzma_index_iter * | iter, | |||
block_header_info * | bhi, | |||
xz_file_info * | xfi | |||
) | [static] |
Parse the Block Header.
The result is stored into *bhi. The caller takes care of initializing it.
References xz_file_info::all_have_sizes, lzma_block::check, lzma_stream_flags::check, lzma_index_iter::compressed_file_offset, block_header_info::compressed_size, lzma_block::compressed_size, block_header_info::filter_chain, lzma_block::filters, filters, block_header_info::flags, lzma_index_iter::flags, block_header_info::header_size, lzma_block::header_size, lzma_filter::id, io_pread(), lzma_block_compressed_size(), lzma_block_header_decode(), lzma_block_header_size_decode, lzma_check_size(), LZMA_DATA_ERROR, LZMA_FILTERS_MAX, LZMA_OK, LZMA_OPTIONS_ERROR, lzma_raw_decoder_memusage(), LZMA_VLI_UNKNOWN, block_header_info::memusage, xz_file_info::memusage_max, message_bug(), message_error(), message_filters_to_str(), message_strm(), file_pair::src_name, lzma_index_iter::total_size, lzma_block::uncompressed_size, lzma_index_iter::unpadded_size, and lzma_block::version.
Referenced by parse_details().
static bool parse_check_value | ( | file_pair * | pair, | |
const lzma_index_iter * | iter | |||
) | [static] |
Parse the Check field and put it into check_value[].
References lzma_stream_flags::check, check_value, lzma_index_iter::compressed_file_offset, lzma_index_iter::flags, io_pread(), LZMA_CHECK_NONE, lzma_check_size(), and lzma_index_iter::total_size.
Referenced by parse_details().
static bool parse_details | ( | file_pair * | pair, | |
const lzma_index_iter * | iter, | |||
block_header_info * | bhi, | |||
xz_file_info * | xfi | |||
) | [static] |
Parse detailed information about a Block.
Since this requires seek(s), listing information about all Blocks can be slow.
pair | Input file | |
iter | Location of the Block whose Check value should be printed. | |
bhi | Pointer to structure where to store the information about the Block Header field. |
References parse_block_header(), and parse_check_value().
static const char* get_ratio | ( | uint64_t | compressed_size, | |
uint64_t | uncompressed_size | |||
) | [static] |
Get the compression ratio.
This has slightly different format than that is used in message.c.
static void get_check_names | ( | char | buf[CHECKS_STR_SIZE], | |
uint32_t | checks, | |||
bool | space_after_comma | |||
) | [static] |
Get a comma-separated list of Check names.
The check names are translated with gettext except when in robot mode.
buf | Buffer to hold the resulting string | |
checks | Bit mask of Checks to print | |
space_after_comma | It's better to not use spaces in table-like listings, but in more verbose formats a space after a comma is good for readability. |
References check_names, and my_snprintf().
void list_totals | ( | void | ) |
Show the totals after all files have been listed.
References message_verbosity_get(), totals, and V_WARNING.
void list_file | ( | const char * | filename | ) |
List information about the given .xz file.
References xz_file_info::idx, io_close(), io_open_src(), lzma_index_end(), message_error(), message_fatal(), message_filename(), message_verbosity_get(), opt_format, parse_indexes(), and V_WARNING.
const char check_names[LZMA_CHECK_ID_MAX+1][12] [static] |
{ N_("None"), "CRC32", N_("Unknown-2"), N_("Unknown-3"), "CRC64", N_("Unknown-5"), N_("Unknown-6"), N_("Unknown-7"), N_("Unknown-8"), N_("Unknown-9"), "SHA-256", N_("Unknown-11"), N_("Unknown-12"), N_("Unknown-13"), N_("Unknown-14"), N_("Unknown-15"), }
Check ID to string mapping.
Referenced by get_check_names().
char check_value[2 *LZMA_CHECK_SIZE_MAX+1] [static] |
Value of the Check field as hexadecimal string. This is set by parse_check_value().
Referenced by parse_check_value().
struct { ... } totals [static] |
Totals that are displayed if there was more than one file. The "files" counter is also used in print_info_adv() to show the file number.
Referenced by list_totals().