From: Martin Mares Date: Mon, 10 May 2004 20:28:50 +0000 (+0000) Subject: When processing the `-S' option, work on a copy, so that the command X-Git-Tag: holmes-import~1061 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8e980d3d2841276a15dea2dfe4f7cd2b62e5a7dc;p=libucw.git When processing the `-S' option, work on a copy, so that the command line displayed by `ps' is undisturbed. --- diff --git a/lib/conf.c b/lib/conf.c index effdbd9c..b29b7682 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -331,6 +331,41 @@ void cf_read(byte *filename) cfdeffile = NULL; } +static void cf_opt_S(void) +{ + byte *sect,*name,*value; + byte *c; + byte *msg=NULL; + byte arg[strlen(optarg)+1]; + + strcpy(arg, optarg); + name = arg; + c=strchr(name,'='); + if(!c){ + msg="Missing argument"; + sect=value=""; + }else{ + *c++=0; + value=c; + + c=strchr(name,'.'); + if(!c) + sect=""; + else{ + sect=name; + *c++=0; + name=c; + } + + if (cfdeffile) + cf_read(cfdeffile); + msg=cf_set_item(sect,name,value); + } + if(msg) + die("Invalid command line argument -S%s.%s=%s: %s",sect,name,value,msg); + +} + int cf_getopt(int argc,char * const argv[], const char *shortopts,const struct option *longopts, int *longindex) @@ -345,35 +380,7 @@ int cf_getopt(int argc,char * const argv[], die("The -S and -C options must precede all other arguments"); } if(res=='S'){ - byte *sect,*name,*value; - byte *c; - byte *msg=NULL; - - name=optarg; - c=strchr(name,'='); - if(!c){ - msg="Missing argument"; - sect=value=""; - }else{ - *c++=0; - value=c; - - c=strchr(name,'.'); - if(!c) - sect=""; - else{ - sect=name; - *c++=0; - name=c; - } - - if (cfdeffile) - cf_read(cfdeffile); - msg=cf_set_item(sect,name,value); - } - if(msg) - die("Invalid command line argument -S%s.%s=%s: %s",sect,name,value,msg); - + cf_opt_S(); }else if(res=='C'){ cf_read(optarg); }else{