- uci_foreach_entry(option, &p->options, o) {
- printf("%s.%s.%s=%s\n", cname, sname, o->name, o->value);
+ uci_foreach_element(&p->options, e) {
+ printf("%s.%s.%s=%s\n", cname, sname, e->name, uci_to_option(e)->value);
+ }
+}
+
+static void uci_show_package(struct uci_package *p)
+{
+ struct uci_element *e;
+
+ uci_foreach_element( &p->sections, e) {
+ uci_show_section(uci_to_section(e));
+ }
+}
+
+
+static int package_cmd(int cmd, char *package)
+{
+ struct uci_package *p = NULL;
+
+ if (uci_load(ctx, package, &p) != UCI_OK) {
+ uci_perror(ctx, appname);
+ return 1;
+ }
+ switch(cmd) {
+ case CMD_COMMIT:
+ if (uci_commit(ctx, &p, false) != UCI_OK)
+ uci_perror(ctx, appname);
+ break;
+ case CMD_EXPORT:
+ uci_export(ctx, stdout, p, true);
+ break;
+ case CMD_SHOW:
+ uci_show_package(p);
+ break;