2 * Sherlock Library -- Shell Interface to Configuration Files
4 * (c) 2002 Martin Mares <mj@ucw.cz>
6 * Once we were using this beautiful Shell version, but it turned out
7 * that it doesn't work with nested config files:
9 * eval `sed <cf/sherlock '/^#/d;/^ *$/d;s/ \+$//;
10 * h;s@[^ ]*@@;x;s@[ ].*@@;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;G;s/\n//;
11 * /^\[SECTION\]/,/^\[/ {; /^[A-Z]/ { s/^\([^ ]\+\)[ ]*\(.*\)$/SH_\1="\2"/; p; }; };
25 die("Usage: config [-C<configfile>] [-S<section>.<option>=<value>] <section> <item>[=<default>] <item2> ... [*]");
28 int main(int argc, char **argv)
32 struct cfitem *items, *c;
36 while (i < argc && argv[i][0] == '-')
41 c = items = alloca(sizeof(struct cfitem) * (argc-i+1));
42 vars = alloca(sizeof(byte *) * argc);
49 if (!strcmp(argv[i], "*"))
50 items->type = CT_INCOMPLETE_SECTION;
53 byte *e = strchr(argv[i], '=');
67 if (cf_getopt(start, argv, CF_SHORT_OPTS, CF_NO_LONG_OPTS, NULL) != -1)
73 printf("CF_%s=\"%s\"\n", c->name, *(byte **)c->var);