X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fconf.c;h=d2c08de23b5e0ded212290866de3a5675c82f8a5;hb=54eb231d1d8fcb8b02c56d437152699764bcda3e;hp=98c34b56b16d62eadaf222c04c618bf69c6a2a9d;hpb=50ac264bf0e983a5b009c6d11dcc4f0703edab4b;p=libucw.git diff --git a/lib/conf.c b/lib/conf.c index 98c34b56..d2c08de2 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -2,6 +2,9 @@ * Sherlock Library -- Reading configuration files * * (c) 2001 Robert Spalek + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #include "lib/lib.h" @@ -49,8 +52,8 @@ cfg_stralloc(byte *s) void cf_register(struct cfitem *items) { - if(items[0].type!=CT_SECTION) - die("Invalid configuration section, first item must be of type CT_SECTION"); + if(items[0].type!=CT_SECTION && items[0].type!=CT_INCOMPLETE_SECTION) + die("cf_register: Invalid section type"); items[0].var=cfsection; cfsection=items; } @@ -67,15 +70,18 @@ int cf_item_count(void) struct cfitem *cf_get_item(byte *sect, byte *name) { - struct cfitem *item; + struct cfitem *item, *section; item=cfsection; while(item && strcasecmp(item->name,sect)) item=item->var; if(!item) /* unknown section */ return NULL; + section = item; for(item++; item->type && strcasecmp(item->name,name); item++); + if (!item->type && section->type == CT_INCOMPLETE_SECTION) + return NULL; return item; /* item->type == 0 if not found */ }