| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | configuration parsing |
Hi,
I'm currently working on the configuration parsing. I noticed, that the
wheel is invented over and over again. So my suggestion is to create a
(kind of) protocol, how the lines are formatted. A tokenizer splits the
line and feeds them in an array to a helper function, which knows what to
do with them. Some little picture to illustrate my idea:
Name "Meikel Brandmeyer"
EchoArea "Foobar" foobar.frob /home/fido/msgbase/foobar -$
This will translate to the following entries in argtable:
ARGTABLE argtable[] = {
{ crcNAME, AddName, 1, " \t\n\r", "y", 0 },
{ crcECHOAREA, EchoArea, 3, " \t\n\r", "ynn", VARARGS}
};
What do we see? crc* is the checksum as already used by some options.
AddName and EchoArea are functionpointers to a helper function, which knows
what to do with the arguments. 1 resp. 3 are the (minimal) number of
arguments for this option. If the flag "VARARGS" is given, there
might be any number of optional arguments after the minimal number. "
\t\n\r" are the separators for the different tokens. Those should be
correct in most cases, but can adjusted if one has to (eg. ",").
"y" resp. "ynn" is a mapping, which controls wether a
argument is quoted or not. Optional arguments may not be quoted currently.
But this can be fixed. The line is parsed according to this information and
the arguments are packaged into a nice, NULL-terminated array. The helper
function can be sure, that there is at least the minimum number of
arguments in this array when it's called.
In this way adding a new option is really simple and one does not need to
do any line parsing. However.. this is a major change, so I'd like to hear
some feedback. I tried to design the new interface on the hand to be as
simple to use as possible and on the other to be as flexible as possible.
Also, it is intended to be 100% backward compatible. So it should parse
"old" configuration files without problems. (This should be
clear, since the syntax is still the same. Only the method of parsing
changes.)
The diff against the latest CVS snapshot can be downloaded from
http://www-user.rhrk.uni-kl.de/~brandmey/timedconfig.diff.gz
The adventurous can try to request it from me with the magic
"CONFDIFF". My node is reachable between 17 and 23 GMT under
ceres.homeunix.org. However requesting is not yet tested. :]
Ciao
Meikel
--- timEd/FreeBSD 1.11.a5
* Origin: -=[ Ceres/BSD (Kaiserslautern, Germany) ]=- (2:244/1165)SEEN-BY: 206/0 633/267 270 @PATH: 244/1165 1200 2432/200 774/605 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.