X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fconf.c;h=35f0502b743b007e0591527aabef8a534a24bf08;hb=7093c3275e649ae60935fe07bb6b44398b3ca4c0;hp=844c51cb764300fadb60e59221056855e36f3684;hpb=9032f650148717ff68b03c55ecc4d466695c6e74;p=libucw.git diff --git a/lib/conf.c b/lib/conf.c index 844c51cb..35f0502b 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -93,6 +93,8 @@ struct unit { }; static const struct unit units[] = { + { 'd', 86400, 1 }, + { 'h', 3600, 1 }, { 'k', 1000, 1 }, { 'm', 1000000, 1 }, { 'g', 1000000000, 1 }, @@ -337,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; @@ -368,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); @@ -376,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);