X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fconf.c;h=223ff666f77e222a1dc85f7482939338db506208;hb=c806248e561584362a7a562f22c20e7013ac3bb1;hp=b6cf5237297953fe2a6b04ab133e0815aff8639d;hpb=ddd63d22bcda367a5fad4941bd1c96334de9367d;p=libucw.git diff --git a/lib/conf.c b/lib/conf.c index b6cf5237..223ff666 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -53,19 +53,40 @@ void cf_register(struct cfitem *items) cfsection=items; } -byte *cf_set_item(byte *sect, byte *name, byte *value) +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++) + count++; + return count; +} + +struct cfitem *cf_get_item(byte *sect, byte *name) { struct cfitem *item; - byte *msg=NULL; item=cfsection; while(item && strcasecmp(item->name,sect)) item=item->var; - if(!item) /* ignore unknown section */ + if(!item) /* unknown section */ return NULL; for(item++; item->type && strcasecmp(item->name,name); item++); + return item; /* item->type == 0 if not found */ +} + +byte *cf_set_item(byte *sect, byte *name, byte *value) +{ + struct cfitem *item; + byte *msg=NULL; + + item=cf_get_item(sect,name); + if(!item) /* ignore unknown section */ + return NULL; + switch(item->type){ case CT_INT: {