]> mj.ucw.cz Git - libucw.git/blobdiff - lib/conf.c
Introduced obuck_get_pos(), converted gatherd limits to use it.
[libucw.git] / lib / conf.c
index 223ff666f77e222a1dc85f7482939338db506208..c96d9fb304cd71e029eab9353e4abdbde4baab8f 100644 (file)
@@ -24,6 +24,8 @@
 static struct cfitem *cfsection;
 static struct mempool *cfpool;
 
+byte *cfdeffile = DEFAULT_CONFIG;
+
 static void CONSTRUCTOR
 conf_init(void)
 {
@@ -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,6 +255,10 @@ int cf_getopt(int argc,char * const argv[],
 
                }else if(res=='C'){
                        cf_read(optarg);
+               }else if(res==-1){
+                       if(cfdeffile)
+                               cf_read(cfdeffile);
+                       return res;
                }else{  /* unhandled option */
                        return res;
                }