My schedule, 2.3 schedules, and whatnot
Aidan Cully
aidan at panix.com
Wed Dec 8 01:30:15 UTC 1999
On Tue, Dec 07, 1999 at 04:58:54PM, Elena Samsonova said:
> On 6 Dec 1999, Russ Allbery wrote:
> > On the list of things I've got floating around to work on are:
>
> [snip most of the list]
>
> > - The universal configuration file parser.
>
> What do you mean by this exactly? I have quite a number of config file
> parsers hanging around (my own, that is), I may be able to put one
> together fairly quickly.
I think he's referring to a perl script I've been working (off and)
on, which is sort of YACC-like in design, but a) it makes more
assumptions about the lex'ing it'll have to do, and the format of
the file it wants to parse, and b) it doesn't have any reserved
symbol nastiness, and it doesn't have to deal with that screwed up
way YACC gets its input, both of which effectively prevent YACC
from being used to parse multiple files with different formats in a
single binary.
At present, it's basically working for my ACAP server, but it still
needs a bit more to work with the readers.conf, or incoming.conf
formats.
An example input file:
# Grand-Unified-Configuration-Syntax description file.
header_code {
#include "acap_server.h"
#include "acap_options.h"
}
export {
extern int acap_options_init(void);
}
declarations {
acap_options_t acap_options;
int acap_options_configed;
}
unit server {
attr string include {
/* open up the filename. */
%include($string);
}
attr realm server <name> {
# variables used at realm-parse time.
state {
acap_server_param_t *server;
char *spooldir;
}
# called when we enter a server realm declaration.
start_code {
server = acap_new_server_params(GUCS_pool, $name);
}
# called when we leave a server realm declaration.
finish_code {
spooldir = acap_server_get_spooldir(server);
if (spooldir == 0) {
%error("spooldir not set.");
}
acap_new_server(server);
}
attr string spooldir {
acap_server_set_spooldir(server, $string);
}
}
code {
int acap_options_init()
{
bzero((void*) &acap_options, sizeof(acap_options));
acap_options_configed = 0;
acap_options.directory = strdup(SYSCONFDIR);
GUCS_include_path(acap_options.directory);
acap_options.child_program = strdup(LIBEXECDIR "/acapconn");
acap_options.child_connections = FD_SETSIZE - 16;
acap_options.spare_connections = 16;
acap_options.start_child = 2;
return(0);
}
}
There are still a few architectural changes I've got to make, but this
bit should all stay the same... The code to parse the file looks like:
#include "acap_conf.h"
GUCS_cf_t *cf;
acap_options_init();
cf = GUCS_fopen(conf_fname, conf_pool);
if (!cf) {
log("parse", LOG_ERR, "Could not open conffile %s: %s",
conf_fname, strerror(errno));
exit(1);
}
conf_parse_server(cf);
The file it parses looks like:
server "kublai" {
spool "/var/spool/acap/kublai"
}
The 'pool' stuff, of course, won't be necessary in the INN port.
Don't ask me for a time estimate... I've got no idea.
--aidan
--
Aidan Cully "I saw Judas carryin' the body/ Of John Wilkes Booth..
Not Panix Staff Down there by the train..."
aidan at panix.com -Johnny Cash
More information about the inn-workers
mailing list