Merging upstream version 1.10.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
6e0e1539c4
commit
15bdbbe06a
24 changed files with 811 additions and 454 deletions
57
lzip.h
57
lzip.h
|
@ -1,5 +1,5 @@
|
|||
/* Clzip - LZMA lossless data compressor
|
||||
Copyright (C) 2010-2017 Antonio Diaz Diaz.
|
||||
Copyright (C) 2010-2018 Antonio Diaz Diaz.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,6 +22,8 @@
|
|||
#define min(x,y) ((x) <= (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
void * resize_buffer( void * buf, const unsigned min_size );
|
||||
|
||||
typedef int State;
|
||||
|
||||
enum { states = 12 };
|
||||
|
@ -114,9 +116,13 @@ static inline void Lm_init( struct Len_model * const lm )
|
|||
}
|
||||
|
||||
|
||||
/* defined in main.c */
|
||||
extern int verbosity;
|
||||
|
||||
struct Pretty_print
|
||||
{
|
||||
const char * name;
|
||||
char * padded_name;
|
||||
const char * stdin_name;
|
||||
unsigned longest_name;
|
||||
bool first_post;
|
||||
|
@ -124,11 +130,12 @@ struct Pretty_print
|
|||
|
||||
static inline void Pp_init( struct Pretty_print * const pp,
|
||||
const char * const filenames[],
|
||||
const int num_filenames, const int verbosity )
|
||||
const int num_filenames )
|
||||
{
|
||||
unsigned stdin_name_len;
|
||||
int i;
|
||||
pp->name = 0;
|
||||
pp->padded_name = 0;
|
||||
pp->stdin_name = "(stdin)";
|
||||
pp->longest_name = 0;
|
||||
pp->first_post = false;
|
||||
|
@ -147,9 +154,19 @@ static inline void Pp_init( struct Pretty_print * const pp,
|
|||
static inline void Pp_set_name( struct Pretty_print * const pp,
|
||||
const char * const filename )
|
||||
{
|
||||
unsigned name_len, padded_name_len, i = 0;
|
||||
|
||||
if( filename && filename[0] && strcmp( filename, "-" ) != 0 )
|
||||
pp->name = filename;
|
||||
else pp->name = pp->stdin_name;
|
||||
name_len = strlen( pp->name );
|
||||
padded_name_len = max( name_len, pp->longest_name ) + 4;
|
||||
pp->padded_name = resize_buffer( pp->padded_name, padded_name_len + 1 );
|
||||
while( i < 2 ) pp->padded_name[i++] = ' ';
|
||||
while( i < name_len + 2 ) { pp->padded_name[i] = pp->name[i-2]; ++i; }
|
||||
pp->padded_name[i++] = ':';
|
||||
while( i < padded_name_len ) pp->padded_name[i++] = ' ';
|
||||
pp->padded_name[i] = 0;
|
||||
pp->first_post = true;
|
||||
}
|
||||
|
||||
|
@ -216,12 +233,21 @@ static inline void Fh_set_magic( File_header data )
|
|||
static inline bool Fh_verify_magic( const File_header data )
|
||||
{ return ( memcmp( data, magic_string, 4 ) == 0 ); }
|
||||
|
||||
/* detect truncated header */
|
||||
static inline bool Fh_verify_prefix( const File_header data, const int size )
|
||||
/* detect (truncated) header */
|
||||
static inline bool Fh_verify_prefix( const File_header data, const int sz )
|
||||
{
|
||||
int i; for( i = 0; i < size && i < 4; ++i )
|
||||
int i; for( i = 0; i < sz && i < 4; ++i )
|
||||
if( data[i] != magic_string[i] ) return false;
|
||||
return ( size > 0 );
|
||||
return ( sz > 0 );
|
||||
}
|
||||
|
||||
/* detect corrupt header */
|
||||
static inline bool Fh_verify_corrupt( const File_header data )
|
||||
{
|
||||
int matches = 0;
|
||||
int i; for( i = 0; i < 4; ++i )
|
||||
if( data[i] == magic_string[i] ) ++matches;
|
||||
return ( matches > 1 && matches < 4 );
|
||||
}
|
||||
|
||||
static inline uint8_t Fh_version( const File_header data )
|
||||
|
@ -295,6 +321,7 @@ static inline void Ft_set_member_size( File_trailer data, unsigned long long sz
|
|||
|
||||
static const char * const bad_magic_msg = "Bad magic number (file not in lzip format).";
|
||||
static const char * const bad_dict_msg = "Invalid dictionary size in member header.";
|
||||
static const char * const corrupt_mm_msg = "Corrupt header in multimember file.";
|
||||
static const char * const trailing_msg = "Trailing data not allowed.";
|
||||
|
||||
/* defined in decoder.c */
|
||||
|
@ -303,23 +330,27 @@ int writeblock( const int fd, const uint8_t * const buf, const int size );
|
|||
|
||||
/* defined in list.c */
|
||||
int list_files( const char * const filenames[], const int num_filenames,
|
||||
const bool ignore_trailing );
|
||||
const bool ignore_trailing, const bool loose_trailing );
|
||||
|
||||
/* defined in main.c */
|
||||
extern int verbosity;
|
||||
struct stat;
|
||||
const char * bad_version( const unsigned version );
|
||||
const char * format_ds( const unsigned dictionary_size );
|
||||
void show_header( const unsigned dictionary_size );
|
||||
int open_instream( const char * const name, struct stat * const in_statsp,
|
||||
const bool no_ofile, const bool reg_only );
|
||||
void * resize_buffer( void * buf, const unsigned min_size );
|
||||
void cleanup_and_fail( const int retval );
|
||||
void show_error( const char * const msg, const int errcode, const bool help );
|
||||
void show_file_error( const char * const filename, const char * const msg,
|
||||
const int errcode );
|
||||
void internal_error( const char * const msg );
|
||||
struct Matchfinder_base;
|
||||
void show_progress( const unsigned long long partial_size,
|
||||
const struct Matchfinder_base * const m,
|
||||
struct Pretty_print * const p,
|
||||
const unsigned long long cfile_size );
|
||||
void show_cprogress( const unsigned long long cfile_size,
|
||||
const unsigned long long partial_size,
|
||||
const struct Matchfinder_base * const m,
|
||||
struct Pretty_print * const p );
|
||||
struct Range_decoder;
|
||||
void show_dprogress( const unsigned long long cfile_size,
|
||||
const unsigned long long partial_size,
|
||||
const struct Range_decoder * const d,
|
||||
struct Pretty_print * const p );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue