summaryrefslogtreecommitdiffstats
path: root/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'main.cc')
-rw-r--r--main.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/main.cc b/main.cc
index 974a268..4ec73df 100644
--- a/main.cc
+++ b/main.cc
@@ -16,7 +16,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 plzip to panic.
@@ -135,6 +135,10 @@ void show_help( const long num_online )
"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 plzip to panic.\n"
"\nReport bugs to lzip-bug@nongnu.org\n"
"Plzip home page: http://www.nongnu.org/lzip/plzip.html\n" );
}
@@ -156,8 +160,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 )
{
@@ -231,7 +235,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 )
{
@@ -240,17 +244,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
{
@@ -263,7 +266,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 );
@@ -555,8 +558,8 @@ int main( const int argc, const char * const argv[] )
case 'm': encoder_options.match_len_limit =
getnum( arg, LZ_min_match_len_limit(),
LZ_max_match_len_limit() ); break;
- case 'o': default_output_filename = arg; break;
case 'n': num_workers = getnum( arg, 1, max_workers ); break;
+ case 'o': default_output_filename = arg; break;
case 'q': verbosity = -1; break;
case 's': encoder_options.dictionary_size = get_dict_size( arg );
break;
@@ -633,7 +636,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 )