uci_foreach_element(&p->saved_history, e) {
struct uci_history *h = uci_to_history(e);
+ char *prefix = "";
+ char *op = "=";
- if (h->cmd == UCI_CMD_REMOVE)
- printf("-");
- printf("%s.%s", p->e.name, h->section);
+ switch(h->cmd) {
+ case UCI_CMD_REMOVE:
+ prefix = "-";
+ break;
+ case UCI_CMD_LIST_ADD:
+ op = "+=";
+ break;
+ default:
+ break;
+ }
+ printf("%s%s.%s", prefix, p->e.name, h->section);
if (e->name)
printf(".%s", e->name);
if (h->cmd != UCI_CMD_REMOVE)
- printf("=%s", h->value);
+ printf("%s%s", op, h->value);
printf("\n");
}
}
struct uci_section *s = NULL;
struct uci_element *e = NULL;
struct uci_option *o = NULL;
+ char *package = NULL;
char *section = NULL;
char *option = NULL;
char *value = NULL;
int ret = UCI_OK;
+ char *str;
if (argc != 2)
return 255;
return 1;
}
+ str = strdup(argv[1]);
+ if (!str)
+ return 1;
+
if (value && (cmd != CMD_SET) && (cmd != CMD_ADD_LIST) && (cmd != CMD_RENAME))
return 1;
+ if (uci_parse_tuple(ctx, str, &package, §ion, &option, NULL) != UCI_OK) {
+ cli_perror();
+ return 1;
+ }
+ sprintf(argv[1], "%s.%s", package, section);
+ free(str);
+
if (uci_lookup_ext(ctx, &e, argv[1]) != UCI_OK) {
cli_perror();
return 1;