X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=catgconf.c;h=c2be20634a93eb071a509f8dfdd5feeb7c5aab04;hb=refs%2Fheads%2Flicensing;hp=650a0e9a9ce543b81710eab78799e7bd84d9b414;hpb=eff1f8d633fa2b07396e1d1f82043823d6916ba2;p=radsecproxy.git diff --git a/catgconf.c b/catgconf.c index 650a0e9..c2be206 100644 --- a/catgconf.c +++ b/catgconf.c @@ -1,3 +1,7 @@ +/* Copyright (c) 2006-2010, UNINETT AS + * Copyright (c) 2010-2012, NORDUnet A/S */ +/* See LICENSE for licensing information. */ + #include #include #include @@ -5,16 +9,17 @@ #include "debug.h" #include "gconfig.h" -void listconfig(struct gconffile **cf, char *block, int compact) { +int 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 (!getconfigline(cf, block, &opt, &val, &conftype)) + return -1; + if (!opt) + return 0; /* Success. */ if (conftype == CONF_STR && !strcasecmp(opt, "include")) { if (!pushgconfpaths(cf, val)) @@ -31,20 +36,24 @@ void listconfig(struct gconffile **cf, char *block, int compact) { break; case CONF_CBK: printf("%s %s {%s", opt, val, compact ? "" : "\n"); - listconfig(cf, val, compact); + if (listconfig(cf, val, compact)) + return -1; printf("}\n"); break; default: printf("Unsupported config type\n"); + return -1; } } + + return 0; /* Success. */ } int main(int argc, char **argv) { int c, compact = 0; struct gconffile *cfs; - debug_init("catgconf"); + debug_init("radsecproxy-conf"); debug_set_level(DBG_WARN); while ((c = getopt(argc, argv, "c")) != -1) { @@ -60,8 +69,7 @@ int main(int argc, char **argv) { goto usage; cfs = openconfigfile(argv[optind]); - listconfig(&cfs, NULL, compact); - return 0; + return listconfig(&cfs, NULL, compact); usage: debug(DBG_ERR, "Usage:\n%s [ -c ] configfile", argv[0]);