]> mj.ucw.cz Git - libucw.git/blobdiff - lib/conf.c
Added generic functions for IP address access lists.
[libucw.git] / lib / conf.c
index f6a5f0ee9ed5cfabbcf9ab185c9edb71334f7bfd..3f79fc22d3497d4c15c9de0dc524ac7f762ebf20 100644 (file)
@@ -24,7 +24,7 @@
 static struct cfitem *cfsection;
 static struct mempool *cfpool;
 
-static byte *cfdeffile = NULL;
+byte *cfdeffile = DEFAULT_CONFIG;
 
 static void CONSTRUCTOR
 conf_init(void)
@@ -60,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;
 }
@@ -215,18 +215,6 @@ void cf_read(byte *filename)
        cfdeffile = NULL;
 }
 
-void
-cf_default_init(byte *filename)
-{
-       cfdeffile = filename;
-}
-
-void cf_default_done(void)
-{
-       if (cfdeffile)
-               cf_read(cfdeffile);
-}
-
 int cf_getopt(int argc,char * const argv[],
                const char *shortopts,const struct option *longopts,
                int *longindex)
@@ -267,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);
 }
-