Chris Turner wrote:
[some ini parsers]
thoughts?
could we PLEASE get over this? nobody needs sections for now! so this is the
code we can use directly in vkernel (untested, off head):
FILE *conff;
char line[1000];
conff = fopen(confname, "r");
if (conff == NULL)
err(1, "open config `%s'", confname);
while (fgets(line, sizeof(line), conff) != NULL) {
char *key, *val;
key = line + strspn(line, " \t");
if (*key == '#')
continue;
val = strchr(key, '=');
if (val == NULL)
val = "1"; /* or error out */
else
*val = 0;
/* Eat whitespace */
val = val + strspn(val, " \t");
while (*key != 0 && strchr(" \t", key[strlen(key) - 1]) != NULL)
key[strlen(key) - 1] = 0;
while (*val != 0 && strchr(" \t", val[strlen(val) - 1]) != NULL)
val[strlen(val) - 1] = 0;
if (*key == NULL)
continue;
if (strcmp(key, "memory") == 0) {
/* ... */
} /* etc */
}
fclose(conff);
cheers
simon
--
Serve - BSD +++ RENT this banner advert +++ ASCII Ribbon /"\
Work - Mac +++ space for low €€€ NOW!1 +++ Campaign \ /
Party Enjoy Relax | http://dragonflybsd.org Against HTML \
Dude 2c 2 the max ! http://golden-apple.biz Mail + News / \