X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=cli.c;h=322d170d3a613e70c18483eb89ed0fb7fcf86378;hp=5e0697da2ed2f0f808092941fb9207ecc50ad22f;hb=508525c69e08a96031ed24f2d09e3bc2d1d33fca;hpb=854f7c5d08cd37aeb7414e26ed6666fad26f5f7a;ds=sidebyside diff --git a/cli.c b/cli.c index 5e0697d..322d170 100644 --- a/cli.c +++ b/cli.c @@ -28,16 +28,39 @@ static void uci_usage(int argc, char **argv) exit(255); } +static void uci_show_section(struct uci_section *p) +{ + struct uci_option *o; + const char *cname, *sname; + + cname = p->config->name; + sname = p->name; + printf("%s.%s=%s\n", cname, sname, p->type); + uci_foreach_entry(option, &p->options, o) { + printf("%s.%s.%s=%s\n", cname, sname, o->name, o->value); + } +} + static void uci_show_file(const char *name) { struct uci_config *cfg; - uci_load(ctx, name, &cfg); + struct uci_section *p; + + if (uci_load(ctx, name, &cfg) != UCI_OK) { + uci_perror(ctx, "uci_load"); + return; + } + + uci_list_empty(&cfg->sections); + uci_foreach_entry(section, &cfg->sections, p) { + uci_show_section(p); + } uci_unload(ctx, name); } static int uci_show(int argc, char **argv) { - char **configs = uci_list_configs(ctx); + char **configs = uci_list_configs(); char **p; if (!configs)