summaryrefslogtreecommitdiffstats
path: root/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'main.cc')
-rw-r--r--main.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/main.cc b/main.cc
index bd9bda0..2c4e594 100644
--- a/main.cc
+++ b/main.cc
@@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
- Return values: 0 for a normal exit, 1 for environmental problems
+ Exit status: 0 for a normal exit, 1 for environmental problems
(file not found, invalid flags, I/O errors, etc), 2 to indicate a
corrupt or invalid input file, 3 for an internal consistency error
(eg, bug) which caused lzip to panic.
@@ -132,6 +132,10 @@ void show_help()
"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"
+ "\nExit status: 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 lzip to panic.\n"
"\nReport bugs to lzip-bug@nongnu.org\n"
"Lzip home page: http://www.nongnu.org/lzip/lzip.html\n" );
}
@@ -170,8 +174,8 @@ unsigned long long getnum( const char * const ptr,
const unsigned long long llimit,
const unsigned long long ulimit )
{
- errno = 0;
char * tail;
+ errno = 0;
unsigned long long result = strtoull( ptr, &tail, 0 );
if( tail == ptr )
{
@@ -245,7 +249,7 @@ int extension_index( const std::string & name )
}
-int open_instream( const std::string & name, struct stat * const in_statsp,
+int open_instream( const char * const name, struct stat * const in_statsp,
const Mode program_mode, const int eindex,
const bool recompress, const bool to_stdout )
{
@@ -254,17 +258,16 @@ int open_instream( const std::string & name, struct stat * const in_statsp,
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Input file '%s' already has '%s' suffix.\n",
- program_name, name.c_str(),
- known_extensions[eindex].from );
+ program_name, name, known_extensions[eindex].from );
}
else
{
- infd = open( name.c_str(), O_RDONLY | o_binary );
+ infd = open( name, O_RDONLY | o_binary );
if( infd < 0 )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't open input file '%s': %s.\n",
- program_name, name.c_str(), std::strerror( errno ) );
+ program_name, name, std::strerror( errno ) );
}
else
{
@@ -277,7 +280,7 @@ int open_instream( const std::string & name, struct stat * const in_statsp,
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Input file '%s' is not a regular file%s.\n",
- program_name, name.c_str(),
+ program_name, name,
( can_read && !to_stdout ) ?
" and '--stdout' was not specified" : "" );
close( infd );
@@ -624,7 +627,7 @@ int decompress( const int infd, const Pretty_print & pp, const bool testing )
{ pp( "Invalid dictionary size in member header" ); retval = 2; break; }
if( verbosity >= 2 || ( verbosity == 1 && first_member ) )
- { pp(); if( verbosity >= 2 ) show_header( header ); }
+ { pp(); if( verbosity >= 3 ) show_header( header ); }
LZ_decoder decoder( header, rdec, outfd );
const int result = decoder.decode_member( pp );
@@ -644,8 +647,7 @@ int decompress( const int infd, const Pretty_print & pp, const bool testing )
retval = 2; break;
}
if( verbosity >= 2 )
- { if( testing ) std::fprintf( stderr, "ok\n" );
- else std::fprintf( stderr, "done\n" ); pp.reset(); }
+ { std::fprintf( stderr, testing ? "ok\n" : "done\n" ); pp.reset(); }
}
}
catch( std::bad_alloc )
@@ -655,8 +657,7 @@ int decompress( const int infd, const Pretty_print & pp, const bool testing )
}
catch( Error e ) { pp(); show_error( e.msg, errno ); retval = 1; }
if( verbosity == 1 && retval == 0 )
- { if( testing ) std::fprintf( stderr, "ok\n" );
- else std::fprintf( stderr, "done\n" ); }
+ std::fprintf( stderr, testing ? "ok\n" : "done\n" );
return retval;
}
@@ -865,7 +866,7 @@ int main( const int argc, const char * const argv[] )
{
input_filename = filenames[i];
const int eindex = extension_index( input_filename );
- infd = open_instream( input_filename, &in_stats, program_mode,
+ infd = open_instream( input_filename.c_str(), &in_stats, program_mode,
eindex, recompress, to_stdout );
if( infd < 0 ) { if( retval < 1 ) retval = 1; continue; }
if( program_mode != m_test )