[Aggregator] Look for -h before the main options
The options -f and -h are now parsed before the other options (instead of just -f).
This commit is contained in:
parent
52c3b34170
commit
7a95851795
|
@ -188,19 +188,27 @@ void parse_config_file(int argc, char **argv)
|
||||||
CFG_END()
|
CFG_END()
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
char *config_file ;
|
char *config_file = NULL ; // Configuration file name
|
||||||
|
|
||||||
// Option -f specifies a config file, so we search for it first
|
// Option -f specifies a config file, -h exits the
|
||||||
|
// program, so we search for them first
|
||||||
int opt ;
|
int opt ;
|
||||||
do
|
while ((opt = getopt(argc, argv, OPTIONS)) != -1)
|
||||||
opt = getopt(argc, argv, OPTIONS) ;
|
|
||||||
while (opt != 'f' && opt != -1) ;
|
|
||||||
if (opt == 'f')
|
|
||||||
{
|
{
|
||||||
config_file = malloc((strlen(optarg) + 1) * sizeof(char)) ;
|
switch (opt)
|
||||||
strcpy(config_file, optarg) ;
|
{
|
||||||
|
case 'f' :
|
||||||
|
config_file = malloc((strlen(optarg) + 1) * sizeof(char)) ;
|
||||||
|
strcpy(config_file, optarg) ;
|
||||||
|
break ;
|
||||||
|
case 'h' :
|
||||||
|
print_usage() ;
|
||||||
|
exit(0) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // If -f isn't found, we use the default config file
|
|
||||||
|
// If -f isn't found, we use the default config file
|
||||||
|
if (config_file == NULL)
|
||||||
{
|
{
|
||||||
config_file =
|
config_file =
|
||||||
malloc((strlen(DEFAULT_CONFIG_FILE) + 1) * sizeof(char)) ;
|
malloc((strlen(DEFAULT_CONFIG_FILE) + 1) * sizeof(char)) ;
|
||||||
|
|
Loading…
Reference in New Issue