summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/main.c b/main.c
index cda4327..c2f3319 100644
--- a/main.c
+++ b/main.c
@@ -118,6 +118,10 @@ static void show_help( void )
"scale optimal for all files. If your files are large, very repetitive,\n"
"etc, you may need to use the --match-length and --dictionary-size\n"
"options directly to achieve optimal performance.\n"
+ "\nReturn values: 0 for a normal exit, 1 for environmental problems (file\n"
+ "not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or\n"
+ "invalid input file, 3 for an internal consistency error (eg, bug) which\n"
+ "caused pdlzip to panic.\n"
"\nReport bugs to lzip-bug@nongnu.org\n"
"Pdlzip home page: http://www.nongnu.org/lzip/pdlzip.html\n" );
}
@@ -163,8 +167,9 @@ void show_header( const File_header header )
for( i = 0; i < 8 && ( num > 9999 || ( exact && num >= factor ) ); ++i )
{ num /= factor; if( num % factor != 0 ) exact = false;
p = prefix[i]; np = ""; }
- fprintf( stderr, "version %d, dictionary size %s%4u %sB. ",
- Fh_version( header ), np, num, p );
+ if( verbosity >= 4 )
+ fprintf( stderr, "version %d, ", Fh_version( header ) );
+ fprintf( stderr, "dictionary size %s%4u %sB. ", np, num, p );
}
@@ -502,7 +507,7 @@ static int lzma_decode( uint64_t unpackSize, CLzmaDec *decoder, const int infd,
if( !LzmaDec_DecodeToBuf( decoder, outBuf + outPos, &outProcessed,
inBuf + *inPos, &inProcessed, finishMode, &status ) )
- { show_error( "Data error.", 0, false ); return 1; }
+ { show_error( "Data error.", 0, false ); return 2; }
*inPos += inProcessed;
total_in += inProcessed;
outPos += outProcessed;
@@ -519,7 +524,7 @@ static int lzma_decode( uint64_t unpackSize, CLzmaDec *decoder, const int infd,
{
if( ( thereIsSize && unpackSize != 0 ) ||
( !thereIsSize && status != LZMA_STATUS_FINISHED_WITH_MARK ) )
- { show_error( "Data error.", 0, false ); return 1; }
+ { show_error( "Data error.", 0, false ); return 2; }
if( verbosity >= 2 )
fprintf( stderr, "lzma-alone, dictionary size %7sB. ",
format_num( decoder->dicBufSize ) );
@@ -527,8 +532,7 @@ static int lzma_decode( uint64_t unpackSize, CLzmaDec *decoder, const int infd,
fprintf( stderr, "uncompressed size %9llu, compressed size %8llu. ",
total_out, total_in );
if( verbosity >= 1 )
- { if( testing ) fprintf( stderr, "(apparently) ok\n" );
- else fprintf( stderr, "(apparently) done\n" ); }
+ fprintf( stderr, testing ? "(apparently) ok\n" : "(apparently) done\n" );
return 0;
}
}
@@ -554,12 +558,12 @@ static int lzip_decode( CLzmaDec *decoder, const int infd, uint8_t inBuf[],
if( *inPos >= *inSize && !read_inbuf( infd, inBuf, inPos, inSize ) )
return 1;
if( *inPos >= *inSize )
- { show_error( "Unexpected EOF.", 0, false ); return 1; }
+ { show_error( "Unexpected EOF.", 0, false ); return 2; }
inProcessed = *inSize - *inPos;
if( !LzmaDec_DecodeToBuf( decoder, outBuf + outPos, &outProcessed,
inBuf + *inPos, &inProcessed, finishMode, &status ) )
- { show_error( "Data error.", 0, false ); return 1; }
+ { show_error( "Data error.", 0, false ); return 2; }
*inPos += inProcessed;
total_in += inProcessed;
outPos += outProcessed;
@@ -579,7 +583,7 @@ static int lzip_decode( CLzmaDec *decoder, const int infd, uint8_t inBuf[],
bool error = false;
if( status != LZMA_STATUS_FINISHED_WITH_MARK )
- { show_error( "Data error.", 0, false ); return 1; }
+ { show_error( "Data error.", 0, false ); return 2; }
if( *inSize - *inPos < trailer_size &&
!read_inbuf( infd, inBuf, inPos, inSize ) ) return 1;
if( *inSize - *inPos < trailer_size )
@@ -617,7 +621,7 @@ static int lzip_decode( CLzmaDec *decoder, const int infd, uint8_t inBuf[],
fprintf( stderr, "Member size mismatch; trailer says %llu, member size is %llu (0x%llX).\n",
Ft_get_member_size( trailer ), total_in, total_in );
}
- if( !error && verbosity >= 3 && total_out > 0 && total_in > 0 )
+ if( !error && verbosity >= 2 && total_out > 0 && total_in > 0 )
fprintf( stderr, "%6.3f:1, %6.3f bits/byte, %5.2f%% saved. ",
(double)total_out / total_in,
( 8.0 * total_in ) / total_out,
@@ -701,7 +705,7 @@ static int decompress( const int infd, struct Pretty_print * const pp,
if( verbosity >= 2 || ( verbosity == 1 && first_member ) )
{
Pp_show_msg( pp, 0 );
- if( lzip_mode && verbosity >= 2 ) show_header( header );
+ if( lzip_mode && verbosity >= 3 ) show_header( header );
}
if( !LzmaDec_Init( &decoder, raw_props ) )
@@ -718,12 +722,10 @@ static int decompress( const int infd, struct Pretty_print * const pp,
LzmaDec_Free(&decoder);
if( retval != 0 || !lzip_mode ) break;
if( verbosity >= 2 )
- { if( testing ) fprintf( stderr, "ok\n" );
- else fprintf( stderr, "done\n" ); Pp_reset( pp ); }
+ { fprintf( stderr, testing ? "ok\n" : "done\n" ); Pp_reset( pp ); }
}
if( lzip_mode && verbosity == 1 && retval == 0 )
- { if( testing ) fprintf( stderr, "ok\n" );
- else fprintf( stderr, "done\n" ); }
+ fprintf( stderr, testing ? "ok\n" : "done\n" );
return retval;
}
@@ -862,6 +864,7 @@ int main( const int argc, const char * const argv[] )
{ 'h', "help", ap_no },
{ 'k', "keep", ap_no },
{ 'm', "match-length", ap_yes },
+ { 'n', "threads", ap_yes },
{ 'o', "output", ap_yes },
{ 'q', "quiet", ap_no },
{ 's', "dictionary-size", ap_yes },
@@ -901,6 +904,7 @@ int main( const int argc, const char * const argv[] )
case 'k': keep_input_files = true; break;
case 'm': encoder_options.match_len_limit =
getnum( arg, min_match_len_limit, max_match_len ); break;
+ case 'n': break;
case 'o': default_output_filename = arg; break;
case 'q': verbosity = -1; break;
case 's': encoder_options.dictionary_size = get_dict_size( arg );