From: Felix Fietkau Date: Sun, 20 Jan 2008 22:15:02 +0000 (+0100) Subject: return a pointer to the uci_config struct in uci_load X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=854f7c5d08cd37aeb7414e26ed6666fad26f5f7a;p=uci.git return a pointer to the uci_config struct in uci_load --- diff --git a/cli.c b/cli.c index 7dece62..5e0697d 100644 --- a/cli.c +++ b/cli.c @@ -30,7 +30,8 @@ static void uci_usage(int argc, char **argv) static void uci_show_file(const char *name) { - uci_load(ctx, name); + struct uci_config *cfg; + uci_load(ctx, name, &cfg); uci_unload(ctx, name); } diff --git a/parse.c b/parse.c index 4394bf6..e63f900 100644 --- a/parse.c +++ b/parse.c @@ -304,7 +304,7 @@ static void uci_parse_line(struct uci_context *ctx) } } -int uci_load(struct uci_context *ctx, const char *name) +int uci_load(struct uci_context *ctx, const char *name, struct uci_config **cfg) { struct uci_parse_context *pctx; struct stat statbuf; @@ -360,6 +360,9 @@ ignore: /* add to main config file list */ uci_list_add(&ctx->root, &pctx->cfg->list); + if (cfg) + *cfg = pctx->cfg; + pctx->cfg = NULL; /* no error happened, we can get rid of the parser context now */ diff --git a/uci.h b/uci.h index 8784c43..6dc00f1 100644 --- a/uci.h +++ b/uci.h @@ -67,7 +67,7 @@ extern void uci_perror(struct uci_context *ctx, const char *str); * @ctx: uci context * @name: name of the config file (relative to the config directory) */ -extern int uci_load(struct uci_context *ctx, const char *name); +extern int uci_load(struct uci_context *ctx, const char *name, struct uci_config **cfg); /** * uci_unload: Unload a config file from the uci context