From: Martin Mares Date: Sun, 25 Jan 2004 12:45:00 +0000 (+0000) Subject: If `-S' or `-C' is given after some other options (i.e., the config file X-Git-Tag: holmes-import~1125 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=3f852dbf02d4a71de5470885e57b11726ad5ac77;p=libucw.git If `-S' or `-C' is given after some other options (i.e., the config file has been already loaded automatically), complain loudly. Also improved the error message for invalid `-S'. Robert, could you please check this? --- diff --git a/lib/conf.c b/lib/conf.c index 21a28b24..35f0502b 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -339,9 +339,14 @@ int cf_getopt(int argc,char * const argv[], int *longindex) { int res; + static int other_options; do{ res=getopt_long(argc,argv,shortopts,longopts,longindex); + if(res == 'S' || res == 'C') { + if(other_options) + die("The -S and -C options must precede all other arguments"); + } if(res=='S'){ byte *sect,*name,*value; byte *c; @@ -370,7 +375,7 @@ int cf_getopt(int argc,char * const argv[], msg=cf_set_item(sect,name,value); } if(msg) - die("Invalid command line argument %s.%s=%s: %s",sect,name,value,msg); + die("Invalid command line argument -S%s.%s=%s: %s",sect,name,value,msg); }else if(res=='C'){ cf_read(optarg); @@ -378,6 +383,7 @@ int cf_getopt(int argc,char * const argv[], /* unhandled option or end of options */ if(cfdeffile) cf_read(cfdeffile); + other_options++; return res; } }while(1);