X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=catgconf.c;h=42b1d40c78c377d9591db691567b772515853f18;hb=refs%2Fheads%2Fmaint-1.6;hp=5cdec681a521507e4471348d8d2f4357795324a9;hpb=ed56d62fc2a90fccae235dc3775a83c609a172b6;p=libradsec.git diff --git a/catgconf.c b/catgconf.c index 5cdec68..42b1d40 100644 --- a/catgconf.c +++ b/catgconf.c @@ -1,3 +1,12 @@ +/* + * Copyright (C) 2008 Stig Venaas + * Copyright (C) 2010,2011,2012 NORDUnet A/S + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + #include #include #include @@ -5,16 +14,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,13 +41,17 @@ 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) { @@ -60,8 +74,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]);