parse the package keyword
authorFelix Fietkau <nbd@openwrt.org>
Tue, 22 Jan 2008 22:39:12 +0000 (23:39 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 22 Jan 2008 22:39:12 +0000 (23:39 +0100)
file.c

diff --git a/file.c b/file.c
index 580ca1881043718348f65c081fabc482c53f20ba..d044c0d5908281776e8e2403f21c41d2f0e1ec23 100644 (file)
--- a/file.c
+++ b/file.c
@@ -277,6 +277,30 @@ ignore:
        pctx->cfg = uci_alloc_config(ctx, name);
 }
 
+/*
+ * parse the 'package' uci command (next config package)
+ */
+static void uci_parse_package(struct uci_context *ctx, char **str)
+{
+       char *name = NULL;
+
+       /* command string null-terminated by strtok */
+       *str += strlen(*str) + 1;
+
+       UCI_TRAP_SAVE(ctx, error);
+       name = next_arg(ctx, str, true);
+       assert_eol(ctx, str);
+       ctx->pctx->name = name;
+       uci_switch_config(ctx);
+       UCI_TRAP_RESTORE(ctx);
+       return;
+
+error:
+       if (name)
+               free(name);
+       UCI_THROW(ctx, ctx->errno);
+}
+
 /*
  * parse the 'config' uci command (open a section)
  */
@@ -362,6 +386,10 @@ static void uci_parse_line(struct uci_context *ctx)
                word = strtok_r(word, " \t", &pbrk);
 
                switch(word[0]) {
+                       case 'p':
+                               if ((word[1] == 0) || !strcmp(word + 1, "ackage"))
+                                       uci_parse_package(ctx, &word);
+                               break;
                        case 'c':
                                if ((word[1] == 0) || !strcmp(word + 1, "onfig"))
                                        uci_parse_config(ctx, &word);