X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fconf.c;h=3f79fc22d3497d4c15c9de0dc524ac7f762ebf20;hb=04294f573be8073e305f70621e6e74e2440f7f24;hp=223ff666f77e222a1dc85f7482939338db506208;hpb=08d04bc5ad1096069facbea143c8172243ba2eba;p=libucw.git diff --git a/lib/conf.c b/lib/conf.c index 223ff666..3f79fc22 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -24,6 +24,8 @@ static struct cfitem *cfsection; static struct mempool *cfpool; +byte *cfdeffile = DEFAULT_CONFIG; + static void CONSTRUCTOR conf_init(void) { @@ -58,7 +60,7 @@ int cf_item_count(void) struct cfitem *sect, *item; int count = 0; for (sect = cfsection; sect; sect = sect->var) - for (item = sect+1; sect->type; sect++) + for (item = sect+1; item->type; item++) count++; return count; } @@ -210,6 +212,7 @@ void cf_read(byte *filename) { if(!cf_subread(filename,0)) die("Reading config file %s failed",filename); + cfdeffile = NULL; } int cf_getopt(int argc,char * const argv[], @@ -243,6 +246,8 @@ int cf_getopt(int argc,char * const argv[], name=c; } + if (cfdeffile) + cf_read(cfdeffile); msg=cf_set_item(sect,name,value); } if(msg) @@ -250,9 +255,11 @@ int cf_getopt(int argc,char * const argv[], }else if(res=='C'){ cf_read(optarg); - }else{ /* unhandled option */ + }else{ + /* unhandled option or end of options */ + if(cfdeffile) + cf_read(cfdeffile); return res; } }while(1); } -