Browse Source

return a pointer to the uci_config struct in uci_load

Felix Fietkau 16 years ago
parent
commit
854f7c5d08
3 changed files with 7 additions and 3 deletions
  1. 2 1
      cli.c
  2. 4 1
      parse.c
  3. 1 1
      uci.h

+ 2 - 1
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);
 }
 

+ 4 - 1
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 */

+ 1 - 1
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