37 #define XZ_FILE_INFO_INIT { NULL, 0, 0, true, 50000002 }
90 #define CHECKS_STR_SIZE 1024
112 }
totals = { 0, 0, 0, 0, 0, 0, 0, 0, 50000002,
true };
121 unsigned int major = ver / 10000000U;
122 ver -=
major * 10000000U;
124 unsigned int minor = ver / 10000U;
125 ver -=
minor * 10000U;
127 unsigned int patch = ver / 10U;
130 const char *stability = ver == 0 ?
"alpha" : ver == 1 ?
"beta" :
"";
152 if (pair->
src_st.st_size <= 0) {
222 }
while (
i >= 0 &&
buf.u32[
i] == 0);
226 ret = lzma_stream_footer_decode(&footer_flags,
buf.u8);
241 if (footer_flags.
version != 0) {
261 if (combined_index !=
NULL) {
262 memused = lzma_index_memused(combined_index);
329 if ((
lzma_vli)(
pos) < lzma_index_total_size(this_index)) {
335 pos -= lzma_index_total_size(this_index);
339 ret = lzma_stream_header_decode(&header_flags,
buf.u8);
346 ret = lzma_stream_flags_compare(&header_flags, &footer_flags);
356 ret = lzma_index_stream_flags(this_index, &footer_flags);
366 if (combined_index !=
NULL) {
369 ret = lzma_index_cat(
370 this_index, combined_index,
NULL);
378 combined_index = this_index;
388 xfi->
idx = combined_index;
394 lzma_index_end(combined_index,
NULL);
395 lzma_index_end(this_index,
NULL);
409 #if IO_BUFFER_SIZE < LZMA_BLOCK_HEADER_SIZE_MAX
410 # error IO_BUFFER_SIZE < LZMA_BLOCK_HEADER_SIZE_MAX
416 - lzma_check_size(
iter->stream.flags->check),
438 switch (lzma_block_header_decode(&block,
NULL,
buf.u8)) {
461 bhi->
flags[2] =
'\0';
470 switch (lzma_block_compressed_size(&block,
471 iter->block.unpadded_size)) {
481 ==
iter->block.uncompressed_size)
520 &&
iter->block.uncompressed_size == 0
572 for (
size_t i = 0;
i <
size; ++
i)
650 const char *sep = space_after_comma ?
", " :
",";
670 static bool headings_displayed =
false;
671 if (!headings_displayed) {
672 headings_displayed =
true;
677 puts(
_(
"Strms Blocks Compressed Uncompressed Ratio "
684 const char *cols[7] = {
692 lzma_index_uncompressed_size(xfi->
idx)),
696 printf(
"%*s %*s %*s %*s %*s %-*s %s\n",
721 printf(
_(
" Compressed size: %s\n"),
724 printf(
_(
" Uncompressed size: %s\n"),
729 printf(
_(
" Check: %s\n"), checks_str);
730 printf(
_(
" Stream padding: %s\n"),
742 lzma_index_block_count(xfi->
idx),
743 lzma_index_file_size(xfi->
idx),
744 lzma_index_uncompressed_size(xfi->
idx),
745 lzma_index_checks(xfi->
idx),
758 puts(
_(
" Streams:\n Stream Blocks"
759 " CompOffset UncompOffset"
760 " CompSize UncompSize Ratio"
764 lzma_index_iter_init(&
iter, xfi->
idx);
767 const char *cols1[4] = {
773 printf(
" %*s %*s %*s %*s ",
779 const char *cols2[5] = {
783 iter.stream.uncompressed_size),
787 printf(
"%*s %*s %*s %-*s %*s\n",
795 if (lzma_check_size(
iter.stream.flags->check) > check_max)
796 check_max = lzma_check_size(
iter.stream.flags->check);
807 if (lzma_index_block_count(xfi->
idx) > 0) {
809 const int checkval_width =
my_max(8, 2 * check_max);
813 printf(
_(
" Blocks:\n Stream Block"
814 " CompOffset UncompOffset"
815 " TotalSize UncompSize Ratio Check"));
825 printf(
_(
" CheckVal %*s Header Flags "
826 "CompSize MemUsage Filters"),
827 checkval_width - 8,
"");
832 lzma_index_iter_init(&
iter, xfi->
idx);
839 const char *cols1[4] = {
842 iter.block.number_in_stream, 1),
844 iter.block.compressed_file_offset, 2),
846 iter.block.uncompressed_file_offset, 3)
848 printf(
" %*s %*s %*s %*s ",
854 const char *cols2[4] = {
859 iter.block.uncompressed_size),
862 printf(
"%*s %*s %*s %-*s",
871 =
iter.block.unpadded_size
874 iter.stream.flags->check);
876 const char *cols3[6] = {
888 printf(
"%-*s %*s %-5s %*s %*s MiB %s",
889 checkval_width, cols3[0],
905 printf(
_(
" Sizes in headers: %s\n"),
907 printf(
_(
" Minimum XZ Utils version: %s\n"),
924 "\t%s\t%s\t%" PRIu64 "\n",
925 lzma_index_stream_count(xfi->
idx),
926 lzma_index_block_count(xfi->
idx),
927 lzma_index_file_size(xfi->
idx),
928 lzma_index_uncompressed_size(xfi->
idx),
930 lzma_index_uncompressed_size(xfi->
idx)),
936 lzma_index_iter_init(&
iter, xfi->
idx);
941 "\t%s\t%s\t%" PRIu64 "\n",
943 iter.stream.block_count,
944 iter.stream.compressed_offset,
945 iter.stream.uncompressed_offset,
946 iter.stream.compressed_size,
947 iter.stream.uncompressed_size,
949 iter.stream.uncompressed_size),
951 iter.stream.padding);
953 lzma_index_iter_rewind(&
iter);
959 pair, &
iter, &bhi, xfi))
966 iter.block.number_in_stream,
967 iter.block.number_in_file,
968 iter.block.compressed_file_offset,
969 iter.block.uncompressed_file_offset,
970 iter.block.total_size,
971 iter.block.uncompressed_size,
973 iter.block.uncompressed_size),
1005 totals.streams += lzma_index_stream_count(xfi->
idx);
1006 totals.blocks += lzma_index_block_count(xfi->
idx);
1007 totals.compressed_size += lzma_index_file_size(xfi->
idx);
1008 totals.uncompressed_size += lzma_index_uncompressed_size(xfi->
idx);
1010 totals.checks |= lzma_index_checks(xfi->
idx);
1039 printf(
"%5s %7s %11s %11s %5s %-7s ",
1047 totals.uncompressed_size),
1059 : (
totals.files % 1000000) + 1000000),
1071 printf(
_(
" Number of files: %s\n"),
1080 printf(
_(
" Sizes in headers: %s\n"),
1081 totals.all_have_sizes ?
_(
"Yes") :
_(
"No"));
1082 printf(
_(
" Minimum XZ Utils version: %s\n"),
1101 totals.uncompressed_size,
1103 totals.uncompressed_size),
1111 totals.all_have_sizes ?
"yes" :
"no",
1129 }
else if (
totals.files > 1) {
1147 "(--format=xz or --format=auto)"));
1187 lzma_index_end(xfi.
idx,
NULL);
#define LZMA_CHECK_SIZE_MAX
Maximum size of a Check field.
#define LZMA_CHECK_ID_MAX
Maximum valid Check ID.
@ LZMA_INDEX_ITER_BLOCK
Get the next Block.
@ LZMA_INDEX_ITER_STREAM
Get the next Stream.
const char stdin_filename[]
#define lzma_block_header_size_decode(b)
Decode the Block Header Size field.
#define LZMA_BLOCK_HEADER_SIZE_MAX
enum format_type opt_format
static lzma_vli index_size(lzma_vli count, lzma_vli index_list_size)
Calculate the size of the Index field including Index Padding.
const lzma_filter * filters
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
void io_close(file_pair *pair, bool success)
Closes the file descriptors and frees possible allocated memory.
file_pair * io_open_src(const char *src_name)
Open the source file.
bool io_pread(file_pair *pair, io_buf *buf, size_t size, off_t pos)
Read from source file from given offset to a buffer.
#define LZMA_FILTERS_MAX
Maximum number of filters in a chain.
uint64_t hardware_memlimit_get(enum operation_mode mode)
Get the current memory usage limit for compression or decompression.
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
static const char struct stat static buf struct stat static buf static vhangup int options
#define LZMA_FILTER_LZMA2
LZMA2 Filter ID.
void message_filename(const char *src_name)
Set the name of the current file and possibly print it too.
void message_mem_needed(enum message_verbosity v, uint64_t memusage)
Display how much memory was needed and how much the limit was.
void message_error(const char *fmt,...)
void message_filters_to_str(char buf[FILTERS_STR_SIZE], const lzma_filter *filters, bool all_known)
Get the filter chain as a string.
const char * message_strm(lzma_ret code)
Convert lzma_ret to a string.
void message_fatal(const char *fmt,...)
enum message_verbosity message_verbosity_get(void)
Get the current verbosity level.
@ V_WARNING
Errors and warnings.
@ V_VERBOSE
Errors, warnings, and verbose statistics.
@ V_ERROR
Only error messages.
#define FILTERS_STR_SIZE
Buffer size for message_filters_to_str()
static struct sockaddr static addrlen static backlog const void static flags void flags
#define LZMA_STREAM_HEADER_SIZE
Size of Stream Header and Stream Footer.
struct stat src_st
Stat of the source file.
Options for the Block and Block Header encoders and decoders.
lzma_vli uncompressed_size
Uncompressed Size in bytes.
lzma_filter * filters
Array of filters.
uint32_t header_size
Size of the Block Header field.
lzma_check check
Type of integrity Check.
lzma_vli compressed_size
Size of the Compressed Data in bytes.
uint32_t version
Block format version.
Iterator to get information about Blocks and Streams.
Options for encoding/decoding Stream Header and Stream Footer.
uint32_t version
Stream Flags format version.
lzma_vli backward_size
Backward Size.
Passing data to and from liblzma.
Information about a .xz file.
uint32_t min_version
Oldest XZ Utils version that will decompress the file.
uint64_t stream_padding
Total amount of Stream Padding.
lzma_index * idx
Combined Index of all Streams in the file.
uint64_t memusage_max
Highest memory usage so far.
static bool print_info_robot(xz_file_info *xfi, file_pair *pair)
void list_file(const char *filename)
List information about the given .xz file.
static const char * xz_ver_to_str(uint32_t ver)
Convert XZ Utils version number to a string.
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 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]
void list_totals(void)
Show the totals after all files have been listed.
static void update_totals(const xz_file_info *xfi)
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 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_adv(xz_file_info *xfi, file_pair *pair)
static bool parse_check_value(file_pair *pair, const lzma_index_iter *iter)
Parse the Check field and put it into check_value[].
static struct @659 totals
static void print_totals_basic(void)
static bool print_info_basic(const xz_file_info *xfi, file_pair *pair)
static void print_totals_robot(void)
#define XZ_FILE_INFO_INIT
static bool parse_indexes(xz_file_info *xfi, file_pair *pair)
Parse the Index(es) from the given .xz file.
static void print_totals_adv(void)
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 const char * get_ratio(uint64_t compressed_size, uint64_t uncompressed_size)
Get the compression ratio.
uint64_t uncompressed_size
Common includes, definitions, and prototypes.
const char * uint64_to_str(uint64_t value, uint32_t slot)
Convert uint64_t to a string.
const char * uint64_to_nicestr(uint64_t value, enum nicestr_unit unit_min, enum nicestr_unit unit_max, bool always_also_bytes, uint32_t slot)
Convert uint64_t to a nice human readable string.
void my_snprintf(char **pos, size_t *left, const char *fmt,...)
uint64_t round_up_to_mib(uint64_t n)
Round an integer up to the next full MiB and convert to MiB.
#define ngettext(msgid1, msgid2, n)
Various integer and bit operations.
void error(const char *msg)
uint64_t lzma_vli
Variable-length integer type.
#define LZMA_VLI_UNKNOWN
VLI value to denote that the value is unknown.
lzma_ret
Return values used by several functions in liblzma.
@ LZMA_DATA_ERROR
Data is corrupt.
@ LZMA_STREAM_END
End of stream was reached.
@ LZMA_BUF_ERROR
No progress is possible.
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
@ LZMA_OK
Operation completed successfully.
@ LZMA_RUN
Continue coding.
#define LZMA_STREAM_INIT
Initialization for lzma_stream.