confuse-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Confuse-devel] Some questions regarding the libConfuse


From: Kai Duncan
Subject: [Confuse-devel] Some questions regarding the libConfuse
Date: Tue, 1 Jun 2004 01:14:19 -0700 (PDT)

Hello,

First of all I would like to thank you for making such
a useful tool. I am using libConfuse 2.3 have a few
questions regarding its usage listed below. Keep in
mind that my configuration file consists of several
sections with identical fields (character strings,
integers, and 1 boolean type). Each section will be
loaded into a dynamically allocated data C structure
and woven into a linked list.

1. How can I make each option field REQUIRED so that
if the library is reading a section and it is missing
an option that is needed in the data structure it will
error and exit? Is this possible using the existing
code in the library?

2. I am using something along the lines of this:
   cfg_t *cfg, *section;
   num_sections = cfg_size(cfg, "section");
   for(counter = 0; counter < num_sections; counter++)
   {
      section = cfg_getnsec(cfg, "section", counter);
//do stuff in here.
   }
cfg is my initialized and parsed configuration file,
and section is a pointer to each individual section in
that configuration file. My question is, what is the
procedure for freeing memory associated with this file
in the event that the function must exit within that
for loop (for example, a failed malloc call)?
Currently I am calling cfg_free() on both pointers. Is
this necessary? If not what all needs to be
cfg_free()'d?

3. I have been operating under the assumption that
cfg_getstr() returns a malloc()'d string that must be
eventually free()'d. Is this assumption true? I did a
small test and free()'d one of the strings returned by
this function and it did not crash the program, but I
would just like to confirmation from the creators. :)

4. CFG_STR is defined as CFG_STR(name, def, flags).
What is the significance of the second paramater;
default value or what? Also, what kind of flags can be
passed to this function? Maybe some flag could be
passed to satisfy what I was asking about in question
#1?

5. Is there a comprehensive tutorial or usage guide
for libConfuse? It seems to be a very useful tool but
it is leaving me a li(l)b(it)Confuse(d) (sorry,
couldnt resist). If not I think this is the only
lacking element that is preventing the library from
being an outstanding piece of work. The Doxygen
generated help files seem to lack focus and direction.

Thanks so much for your reply and this wonderful
software.

-k


        
                
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]