int c = UCI_CMD_CHANGE;
switch(**buf) {
+ case '^':
+ c = UCI_CMD_REORDER;
+ break;
case '-':
c = UCI_CMD_REMOVE;
break;
goto error;
switch(c) {
+ case UCI_CMD_REORDER:
+ if (!ptr->value || ptr->option)
+ goto error;
+ break;
case UCI_CMD_RENAME:
if (!ptr->value || !uci_validate_name(ptr->value))
goto error;
uci_add_history(ctx, &p->saved_history, cmd, ptr.section, ptr.option, ptr.value);
switch(cmd) {
+ case UCI_CMD_REORDER:
+ expand_ptr(ctx, &ptr, true);
+ if (!ptr.s)
+ UCI_THROW(ctx, UCI_ERR_NOTFOUND);
+ UCI_INTERNAL(uci_reorder_section, ctx, ptr.s, strtoul(ptr.value, NULL, 10));
+ break;
case UCI_CMD_RENAME:
UCI_INTERNAL(uci_rename, ctx, &ptr);
break;
if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename)
UCI_THROW(ctx, UCI_ERR_MEM);
+ uci_foreach_element(&ctx->hooks, tmp) {
+ struct uci_hook *hook = uci_to_hook(tmp);
+
+ if (!hook->ops->set)
+ continue;
+
+ uci_foreach_element(&p->history, e) {
+ hook->ops->set(hook->ops, p, uci_to_history(e));
+ }
+ }
+
ctx->err = 0;
UCI_TRAP_SAVE(ctx, done);
f = uci_open_stream(ctx, filename, SEEK_END, true, true);
case UCI_CMD_ADD:
prefix = "+";
break;
+ case UCI_CMD_REORDER:
+ prefix = "^";
+ break;
case UCI_CMD_LIST_ADD:
prefix = "|";
break;