Start on include/inn/confparse.h
Aidan Cully
aidan at panix.com
Mon Jul 3 23:43:01 UTC 2000
On Wed, Jun 28, 2000 at 07:31:32PM, Russ Allbery said:
> One thing I noticed when designing the interface is that the return of
> conf_parse is going to be minorly annoying to deal with for configuration
> files with nested groups. For example, with incoming.conf, all you really
> care about is the array of structs corresponding to peer groups; those may
> be grouped into other groups, though, and what you'll actually get out of
> conf_parse is a tree of conf_data structs, with pointers to the structs
> that you care about in the data members. Basically, the interesting part
> will be all the leaves. The best way of handling this may be to write a
> conf_collapse function that takes a conf_data tree and returns a list of
> just the leaves, freeing everything at a higher level.
You've got start and finish handlers... They can deal with storing
config info in a flat place somewhere, without needing to worry about
a conf_collapse()... It ends up meaning the returned conf_data are
useless for that application, though.
I'd advocate relying on 'finish' callbacks for committing conf data,
rather than returning and reading the conf_data structure from
conf_parse. I think it punts on the issues you raise...
> /* Parameters are collected into parameter groups, which are defined by the
> following struct. init and finish are callbacks used to do various
> initialization, cleanup, or programmatic defaults for the result struct
> of a parse of a configuration file. */
> struct conf_group {
> char * name;
> size_t struct_size;
> void * defaults;
> conf_callback_t init;
> conf_callback_t finish;
>
> struct conf_group * parent;
> struct conf_group ** subgroups;
> struct conf_parameter ** parameters;
> };
...
> /* The public parse function. Takes the name of a file to parse and a
> pointer to a conf_group tree that specifies the semantic structure of the
> file. Returns a pointer to a conf_data tree containing the results of
> the parse. */
> extern struct conf_data *conf_parse(const char *file,
> const struct conf_group *structure);
I'm not sure how you intend to specify arbitrarily nested 'group'
declarations, like in incoming.conf... The structure would look
something like (and in the interest of simplicity, the C-code is
incorrect):
conf_group example_conf_children[] = {
{
"group", 0, 0, 0, 0, /* just give it a name, for this example */
&example_conf, /* is this supposed to be filled in manually? */
&example_conf_children,
/* somehowe include a pointer to our own
* structure? does that work? the defaults change
* when we nest further... would a callback
* function fill this in? */
0
}
};
conf_group example_conf = {
0, 0, 0, 0, 0, /* top level node has no associated data, for this
* example */
0,
&example_conf_children, /* how to indicate size of array? */
0
};
I guess you can tell I'm a bit confused, for this case, if I
understand everything else correctly...
--aidan
--
Aidan Cully "You can lead a whore to culture, but you can't make her
Not Panix Staff think."
aidan at panix.com --Dorothy Parker
More information about the inn-workers
mailing list