wmail: parse command-line arguments before reading config-file.

Fixes warnings about config and check-sum files when using --help and --version.
This commit is contained in:
Jeremy Sowden 2019-06-12 21:37:20 +01:00 committed by Carlos R. Mafra
parent 8f7f9881a0
commit 7590c32f82

View file

@ -332,28 +332,8 @@ int main( int argc, char **argv )
DACallbacks callbacks = { NULL, &ButtonPressed, &ButtonReleased, DACallbacks callbacks = { NULL, &ButtonPressed, &ButtonReleased,
NULL, NULL, NULL, &TimedOut }; NULL, NULL, NULL, &TimedOut };
// read the config file and override the default-settings // parse cmdline-args
ReadConfigFile( false ); DAParseArguments( argc, argv, options, sizeof options / sizeof *options,
if( config.checksumFileName == NULL ) {
if(( usersHome = getenv( "HOME" )) == NULL ) {
WARNING( "HOME environment-variable is not set, placing %s in current directory!\n", WMAIL_CHECKSUM_FILE );
config.checksumFileName = strdup( WMAIL_CHECKSUM_FILE );
} else
config.checksumFileName = MakePathName( usersHome, WMAIL_CHECKSUM_FILE );
}
if( config.checksumFileName == NULL )
{
WARNING( "Cannot allocate checksum file-name.\n");
exit( EXIT_FAILURE );
}
TRACE( "using checksum-file \"%s\"\n", config.checksumFileName );
// parse cmdline-args and override defaults and cfg-file settings
DAParseArguments( argc, argv, options,
sizeof(options) / sizeof(DAProgramOption),
PACKAGE_NAME, PACKAGE_STRING ); PACKAGE_NAME, PACKAGE_STRING );
if( options[OPT_INDEX_DISPLAY].used ) if( options[OPT_INDEX_DISPLAY].used )
@ -403,6 +383,25 @@ int main( int argc, char **argv )
if( options[OPT_INDEX_TICKER_FONT].used ) if( options[OPT_INDEX_TICKER_FONT].used )
config.givenOptions |= CL_USEX11FONT; config.givenOptions |= CL_USEX11FONT;
// read the config file
ReadConfigFile( false );
if( config.checksumFileName == NULL ) {
if(( usersHome = getenv( "HOME" )) == NULL ) {
WARNING( "HOME environment-variable is not set, placing %s in current directory!\n", WMAIL_CHECKSUM_FILE );
config.checksumFileName = strdup( WMAIL_CHECKSUM_FILE );
} else
config.checksumFileName = MakePathName( usersHome, WMAIL_CHECKSUM_FILE );
}
if( config.checksumFileName == NULL )
{
WARNING( "Cannot allocate checksum file-name.\n");
exit( EXIT_FAILURE );
}
TRACE( "using checksum-file \"%s\"\n", config.checksumFileName );
if( config.mailBox == NULL ) if( config.mailBox == NULL )
ABORT( "no mailbox specified - please define at least your $MAIL environment-variable!\n" ); ABORT( "no mailbox specified - please define at least your $MAIL environment-variable!\n" );
else if( stat( config.mailBox, &fileStat ) == 0 ) else if( stat( config.mailBox, &fileStat ) == 0 )