return a pointer to the uci_config struct in uci_load
authorFelix Fietkau <nbd@openwrt.org>
Sun, 20 Jan 2008 22:15:02 +0000 (23:15 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 20 Jan 2008 22:15:02 +0000 (23:15 +0100)
cli.c
parse.c
uci.h

diff --git a/cli.c b/cli.c
index 7dece62..5e0697d 100644 (file)
--- 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)
 {
 
 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);
 }
 
        uci_unload(ctx, name);
 }
 
diff --git a/parse.c b/parse.c
index 4394bf6..e63f900 100644 (file)
--- 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;
 {
        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);
 
        /* 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 */
        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 (file)
--- 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)
  */
  * @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
 
 /**
  * uci_unload: Unload a config file from the uci context