Merging upstream version 1.11.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
777972d75a
commit
6e5a5a3424
23 changed files with 560 additions and 480 deletions
106
lzip.h
106
lzip.h
|
@ -1,36 +1,31 @@
|
|||
/* Pdlzip - LZMA lossless data compressor
|
||||
Copyright (C) 2010-2019 Antonio Diaz Diaz.
|
||||
/* Pdlzip - LZMA lossless data compressor
|
||||
Copyright (C) 2010-2021 Antonio Diaz Diaz.
|
||||
|
||||
This program is free software. Redistribution and use in source and
|
||||
binary forms, with or without modification, are permitted provided
|
||||
that the following conditions are met:
|
||||
This program is free software. Redistribution and use in source and
|
||||
binary forms, with or without modification, are permitted provided
|
||||
that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions, and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef max
|
||||
#define max(x,y) ((x) >= (y) ? (x) : (y))
|
||||
#endif
|
||||
#ifndef min
|
||||
#define min(x,y) ((x) <= (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
void * resize_buffer( void * buf, const unsigned min_size );
|
||||
|
||||
typedef int State;
|
||||
|
||||
enum {
|
||||
min_dictionary_bits = 12,
|
||||
min_dictionary_size = 1 << min_dictionary_bits,
|
||||
min_dictionary_size = 1 << min_dictionary_bits, /* >= modeled_distances */
|
||||
max_dictionary_bits = 29,
|
||||
max_dictionary_size = 1 << max_dictionary_bits,
|
||||
max_dictionary_bits_c = 27, /* kDicLogSizeMaxCompress */
|
||||
|
@ -52,65 +47,6 @@ enum {
|
|||
min_match_len_limit = 5 };
|
||||
|
||||
|
||||
/* defined in main.c */
|
||||
extern int verbosity;
|
||||
|
||||
struct Pretty_print /* requires global var 'int verbosity' */
|
||||
{
|
||||
const char * name;
|
||||
char * padded_name;
|
||||
const char * stdin_name;
|
||||
unsigned longest_name;
|
||||
bool first_post;
|
||||
};
|
||||
|
||||
static inline void Pp_init( struct Pretty_print * const pp,
|
||||
const char * const filenames[],
|
||||
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;
|
||||
|
||||
if( verbosity <= 0 ) return;
|
||||
stdin_name_len = strlen( pp->stdin_name );
|
||||
for( i = 0; i < num_filenames; ++i )
|
||||
{
|
||||
const char * const s = filenames[i];
|
||||
const unsigned len = (strcmp( s, "-" ) == 0) ? stdin_name_len : strlen( s );
|
||||
if( pp->longest_name < len ) pp->longest_name = len;
|
||||
}
|
||||
if( pp->longest_name == 0 ) pp->longest_name = stdin_name_len;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static inline void Pp_reset( struct Pretty_print * const pp )
|
||||
{ if( pp->name && pp->name[0] ) pp->first_post = true; }
|
||||
void Pp_show_msg( struct Pretty_print * const pp, const char * const msg );
|
||||
|
||||
|
||||
typedef uint32_t CRC32[256]; /* Table of CRCs of all 8-bit messages. */
|
||||
|
||||
extern CRC32 crc32;
|
||||
|
@ -157,7 +93,7 @@ static const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
|
|||
|
||||
typedef uint8_t Lzip_header[6]; /* 0-3 magic bytes */
|
||||
/* 4 version */
|
||||
/* 5 coded_dict_size */
|
||||
/* 5 coded dictionary size */
|
||||
enum { Lh_size = 6 };
|
||||
|
||||
static inline void Lh_set_magic( Lzip_header data )
|
||||
|
@ -251,19 +187,17 @@ static inline void Lt_set_member_size( Lzip_trailer data, unsigned long long sz
|
|||
{ int i; for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
|
||||
|
||||
|
||||
static inline void set_retval( int * retval, const int new_val )
|
||||
{ if( *retval < new_val ) *retval = new_val; }
|
||||
|
||||
static const char * const trailing_msg = "Trailing data not allowed.";
|
||||
static const char * const mem_msg = "Not enough memory.";
|
||||
|
||||
/* defined in main.c */
|
||||
extern int verbosity;
|
||||
int readblock( const int fd, uint8_t * const buf, const int size );
|
||||
int writeblock( const int fd, const uint8_t * const buf, const int size );
|
||||
|
||||
/* defined in main.c */
|
||||
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 );
|
||||
|
||||
#define SZ_OK 0
|
||||
|
||||
#define SZ_ERROR_READ 8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue