]> mj.ucw.cz Git - libucw.git/commitdiff
cf_get_item added
authorRobert Spalek <robert@ucw.cz>
Sun, 4 Feb 2001 15:29:15 +0000 (15:29 +0000)
committerRobert Spalek <robert@ucw.cz>
Sun, 4 Feb 2001 15:29:15 +0000 (15:29 +0000)
lib/conf.c
lib/conf.h

index b6cf5237297953fe2a6b04ab133e0815aff8639d..b899b55e98bc19b1c75271b4ccba2e5fe0e83887 100644 (file)
@@ -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:
                        {
index 01974e5c105c5412b520c5e910cfe270d66fde2e..bc3c35deac92d7a7dc16d60e5eb2cff63e253eeb 100644 (file)
@@ -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);