remove unused argument
[project/uci.git] / cli.c
diff --git a/cli.c b/cli.c
index d83e257..ab0f9b8 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -28,9 +28,38 @@ 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;
+       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;
+       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)
@@ -38,6 +67,7 @@ static int uci_show(int argc, char **argv)
 
        for (p = configs; *p; p++) {
                fprintf(stderr, "# config: %s\n", *p);
+               uci_show_file(*p);
        }
 
        return 0;