[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Confuse-devel] libconfuse help (several questions)
From: |
Ademar de Souza Reis Jr. |
Subject: |
[Confuse-devel] libconfuse help (several questions) |
Date: |
Sun, 27 Apr 2003 22:32:19 -0300 |
User-agent: |
Mutt/1.5.4i |
Hi.
[Please keep me in CC since I'm not subscribe to the list]
I'm trying to convert the config parser of one of my projects (sniffdet -
http://sniffdet.sf.net) to use libconfuse, but I'm having some problems (I'm
using libconfuse 2.0).
The new config system is basically finished (it works), but there are
some things that I just don't know if are possible to be done with libconfuse
or how to do them.
Here we go:
My config file has a syntax like:
"""
section1 {
var = value
...
}
section2 {
var = value
...
}
"""
1. In my config file, all sections are optional, but if, for ex.,
"sectionname" doesn't exist, I get an abort() when calling cfg_getsec(cfg,
"sectionname") because of a assertion at confuse.c:235. Is that a bug? Or
Is there another way to discover if a section is present in the config file?
When reading the docs, I understood cfg_getsec() should return 0 in this
case, but it returns this value only if I didn't defined "sectionname" as
CFG_SEC() for the main cfg_opt_t structure, which I did of course
("sectionname" is valid, it's just optional).
Getting a segfault just because you commented out some parts of your
config file is really annoying (I was stuck in this problem for some
time) :)
2. Is there a callback for values different than int? The docs/example
mention the callback to set int values (CFG_INT_CB), but what I need is a
callback to parse string values.
Ex.: I have statements like:
foobar {
fake_mac_address = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}
fake_dest_ip_addr = "192.168.1.200"
}
And I would like to set a callback to check if the values have valid syntax
and are inside the valid range.
3: Actually, my config file has a ";" at the end of every statement. I know
that ";" has no strong semantic value in my case, but I would like to stay
with it anyway (to keep compatibility with my old config file - before
libconfuse). Is there a way to accept/enforce it? Confuse is interpreting it
as part of the value being assigned, returning "syntax error" (this is
really minor :).
4. Is the CVS at savannah.nongnu.org the main one? I'm asking this because
all files there have the last change from 7 weeks ago.
That's it. Any help will be really appreciated. Thanks!
(BTW, It's my first contact with libconfuse, so please forgive me if I'm
doing something stupid... :)
--
Ademar de Souza Reis Jr. <address@hidden>
http://www.ademar.org
WYSIWYG editor? VI! I see text, I get text!
^[:wq!
- [Confuse-devel] libconfuse help (several questions),
Ademar de Souza Reis Jr. <=