INN config file parsing infrastructure
rra at stanford.edu
Mon Jun 26 03:05:46 UTC 2000
Forrest J Cavalier <mibsoft at epix.net> writes:
> In order for there to be a programmatic interface to make changes, each
> configuration item has to be uniquely "addressable." Loading into a
> structure and writing out again is not going to work well.
Definitely true if one is going to be machine-editing and hand-editing the
same file a lot and want to be sure the machine-editing doesn't undo any
hand-edited non-semantic tweaks.
> - It requires that the configuration tool have an up to date
> compile against the structure. This like the fragile base class
> problem of C++. Let's avoid it if possible.
I avoid C++ as much as I possibly can and am therefore not already
familiar with this; could you elaborate a bit?
> - It will lose string encodings and ordering. Even if comments,
> formatting and whitespace are preserved as Fabien requires
> (difficult) it is significantly harder to preserve order,
> and particular string encodings.
> These two strings are equivalent.
> Trumped up example, but may be significant to some users.
> Ordering certainly is significant.
Loading and dumping the entire thing will always write things out in a
predefined order; it just won't preserve a different order. (So if you
load, dump, load, and dump again, the second result should be identical to
the first.) Similarly, for string encoding, the code that writes out a
string could replace particular special characters with encoded versions;
it may not generate the same encoding that a human did, but it should
generate an *acceptable* encoding....
> So, Russ, I'd just ask that you be thinking of including something in
> any API to just read/write one particular configuration file item. (And
> that means thinking about adressing schemes.)
> Full parse and loading into a structure is great for most uses, but does
> suffer when it comes to writing isolated changes or in the case there is
> the "fragile base class problem." Most of what INN uses from config
> files is localized, but there are occasionally cases where some program
> just wants to know one little detail from some other config file....
I'm definitely thinking about it, but I'm still figuring out how all the
pieces fit together.
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the inn-workers