From 9cfd279c11e6c5a48d9616e561e053d95e914148 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 22 Jan 2008 23:39:12 +0100 Subject: [PATCH] parse the package keyword --- file.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/file.c b/file.c index 580ca18..d044c0d 100644 --- 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); -- 2.41.1