diff options
author | venaas <venaas> | 2008-05-14 14:00:42 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2008-05-14 14:00:42 +0000 |
commit | 2c90b8f5573ed8dbc53bc610f5cb0d374d234a29 (patch) | |
tree | beecc838d6f62527cc00a1dd4e813258b91efa54 /catgconf.c | |
parent | 51a3073d2785d13b165c48b1b56816b15081fd36 (diff) |
release of 1.1-beta. merging from trunk to 1.1. updating readme, changelog etc for 1.1-beta release
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/branches/release-1.1@258 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'catgconf.c')
-rw-r--r-- | catgconf.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/catgconf.c b/catgconf.c new file mode 100644 index 0000000..f3d7b9c --- /dev/null +++ b/catgconf.c @@ -0,0 +1,69 @@ +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include "debug.h" +#include "gconfig.h" + +void listconfig(struct gconffile **cf, char *block, int compact) { + char *opt = NULL, *val = NULL; + int conftype; + + for (;;) { + free(opt); + free(val); + getconfigline(cf, block, &opt, &val, &conftype); + if (!opt) + return; + + if (conftype == CONF_STR && !strcasecmp(opt, "include")) { + if (!pushgconffiles(cf, val)) + debugx(1, DBG_ERR, "failed to include config file %s", val); + continue; + } + + switch (conftype) { + case CONF_STR: + if (block) + printf(compact ? "%s=%s;" : "\t%s=%s\n", opt, val); + else + printf("%s=%s\n", opt, val); + break; + case CONF_CBK: + printf("%s %s {%s", opt, val, compact ? "" : "\n"); + listconfig(cf, val, compact); + printf("}\n"); + break; + default: + printf("Unsupported config type\n"); + } + } +} + +int main(int argc, char **argv) { + int c, compact = 0; + struct gconffile *cfs; + + debug_init("catgconf"); + debug_set_level(DBG_WARN); + + while ((c = getopt(argc, argv, "c")) != -1) { + switch (c) { + case 'c': + compact = 1; + break; + default: + goto usage; + } + } + if (argc - optind != 1) + goto usage; + + cfs = openconfigfile(argv[optind]); + listconfig(&cfs, NULL, compact); + return 0; + +usage: + debug(DBG_ERR, "Usage:\n%s [ -c ] configfile", argv[0]); + exit(1); +} |