From ebc1b63c8776c87359714d75f44f4f7f3ac26161 Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Sun, 4 Feb 2001 15:29:15 +0000 Subject: [PATCH] cf_get_item added --- lib/conf.c | 17 ++++++++++++++--- lib/conf.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/conf.c b/lib/conf.c index b6cf5237..b899b55e 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -53,19 +53,30 @@ void cf_register(struct cfitem *items) cfsection=items; } -byte *cf_set_item(byte *sect, byte *name, byte *value) +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: { diff --git a/lib/conf.h b/lib/conf.h index 01974e5c..bc3c35de 100644 --- a/lib/conf.h +++ b/lib/conf.h @@ -39,6 +39,7 @@ void cf_register(struct cfitem *items); * Direct setting of configuration items and parsing the configuration file. */ +struct cfitem *cf_get_item(byte *sect, byte *name); byte *cf_set_item(byte *sect, byte *name, byte *value); void cf_read(byte *filename); -- 2.39.2