summaryrefslogtreecommitdiffstats
path: root/lzip.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2017-05-07 15:50:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2017-05-07 15:50:41 +0000
commitc3bc07039aef7d65e309400a1ed304e6ee6ea070 (patch)
tree5974ec53352123e53a8ec06839e855e5828619c2 /lzip.h
parentReleasing debian version 1.8-5. (diff)
downloadlunzip-c3bc07039aef7d65e309400a1ed304e6ee6ea070.tar.xz
lunzip-c3bc07039aef7d65e309400a1ed304e6ee6ea070.zip
Merging upstream version 1.9.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lzip.h')
-rw-r--r--lzip.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/lzip.h b/lzip.h
index 2970cb3..1e6cdd2 100644
--- a/lzip.h
+++ b/lzip.h
@@ -1,5 +1,5 @@
/* Lunzip - Decompressor for the lzip format
- Copyright (C) 2010-2016 Antonio Diaz Diaz.
+ Copyright (C) 2010-2017 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
@@ -49,6 +49,7 @@ enum {
min_dictionary_size = 1 << min_dictionary_bits, /* >= modeled_distances */
max_dictionary_bits = 29,
max_dictionary_size = 1 << max_dictionary_bits,
+ min_member_size = 36,
literal_context_bits = 3,
literal_pos_state_bits = 0, /* not used */
pos_state_bits = 2,
@@ -131,9 +132,9 @@ static inline void Pp_init( struct Pretty_print * const pp,
pp->stdin_name = "(stdin)";
pp->longest_name = 0;
pp->first_post = false;
- stdin_name_len = strlen( pp->stdin_name );
if( verbosity <= 0 ) return;
+ stdin_name_len = strlen( pp->stdin_name );
for( i = 0; i < num_filenames; ++i )
{
const char * const s = filenames[i];
@@ -179,11 +180,18 @@ static inline void CRC32_update_buf( uint32_t * const crc,
const int size )
{
int i;
+ uint32_t c = *crc;
for( i = 0; i < size; ++i )
- *crc = crc32[(*crc^buffer[i])&0xFF] ^ ( *crc >> 8 );
+ c = crc32[(c^buffer[i])&0xFF] ^ ( c >> 8 );
+ *crc = c;
}
+static inline bool isvalid_ds( const unsigned dictionary_size )
+ { return ( dictionary_size >= min_dictionary_size &&
+ dictionary_size <= max_dictionary_size ); }
+
+
static const uint8_t magic_string[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
typedef uint8_t File_header[6]; /* 0-3 magic bytes */
@@ -246,7 +254,26 @@ static inline unsigned long long Ft_get_member_size( const File_trailer data )
}
+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 trailing_msg = "Trailing data not allowed.";
+
+/* defined in decoder.c */
+int readblock( const int fd, 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 );
+
/* defined in main.c */
extern int verbosity;
+struct stat;
+const char * bad_version( const unsigned version );
+const char * format_ds( 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 );