New configuration parser ready

Russ Allbery rra at stanford.edu
Sun Sep 1 22:11:01 UTC 2002


I've finally finished up (I think) the new configuration parser, including
the code to parse inn.conf.  I'm about to commit that code to the
repository, but not enable it yet.

As previously mentioned, the new parser requires some minor changes to the
syntax of the file.  Values that contain whitespace have to be quoted with
double quotes, and empty keys (keys with no values) are no longer valid
syntax.  Existing inn.conf files will therefore have to be transformed to
parse correctly with the new parser, and due to the quoting, would not be
compatible with the old parser (since the old parser would include the
quote marks in the value).

Existing inn.conf files will therefore have to be updated to comment out
the empty keys (so they're still there for reference) and to quote values
with whitespace.  I've written a Perl script called innupgrade to do that
that would be installed and run as part of make update.

My plan on finishing this conversion is to commit the new code to the
repository but not enable it.  I'll then work on writing a new version of
innconfval that also uses the new parser.  Once that's done, I'll prepare
a patch that will switch all of the programs in INN over to using the new
code to parse inn.conf.  Then, at the same time as committing that patch,
I'll enable running of innupgrade during make update.

Does this sound reasonable to everyone?

I've confirmed that the new parser and the old parser produce the same
results by using a modified inn.conf with no parsing ambiguities and
parsing it with both parsers and then comparing the resulting structure.
I've verified that the new code knows about all of the same keys for the
innconf structure as the old code.  I've also ran innupgrade on the
inn.conf file that comes with INN and parsed the old version with the old
parser and the new version with the new parser and the results match.  And
finally, I've run the new parser on a stripped inn.conf file that contains
only the required settings and compared it against the results of the old
parser on the same file, to make sure that all the defaults are correct.

The code that I've been using to test follows (this will be more useful in
a moment when I've committed the new parser).

#include "config.h"
#include "clibrary.h"

#include "inn/innconf.h"
#include "inn/messages.h"
#include "libinn.h"

int
main(int argc, char *argv[])
{
    struct conf_vars *original;

    message_program_name = "conftest";

    setenv("INNCONF", argv[1], 1);
    if (ReadInnConf() < 0)
        die("cannot read inn.conf using the old library");
    original = innconf;
    innconf = NULL;
    if (!innconf_read(argc > 1 ? argv[2] : argv[1]))
        die("cannot read inn.conf using the new library");
    innconf_compare(original, innconf);

    return 0;
}

Note that the new code will always do type checking of inn.conf when
parsing it and therefore won't let you get away with type errors like the
old one will.  It also won't let you get away with duplicate keys.  The
whole configuration file is parsed fully when read, so errors will be
reported even on keys that aren't used directly by a given program.  I
think this is a feature.  :)

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.


More information about the inn-workers mailing list