+
+ UCI_HANDLE_ERR(ctx);
+
+ /* NB: p, section, option validated by uci_lookup */
+ UCI_INTERNAL(uci_lookup, ctx, &e, p, section, option);
+
+ if (!internal && p->has_history)
+ uci_add_history(ctx, &p->history, UCI_CMD_RENAME, section, option, name);
+
+ name = uci_strdup(ctx, name);
+ if (e->name)
+ free(e->name);
+ e->name = name;
+
+ return 0;
+}
+
+int uci_add_section(struct uci_context *ctx, struct uci_package *p, const char *type, struct uci_section **res)
+{
+ bool internal = ctx->internal;
+ struct uci_section *s;
+
+ UCI_HANDLE_ERR(ctx);
+ UCI_ASSERT(ctx, p != NULL);
+ s = uci_alloc_section(p, type, NULL);
+ uci_fixup_section(ctx, s);
+ *res = s;
+ if (!internal && p->has_history)
+ uci_add_history(ctx, &p->history, UCI_CMD_ADD, s->e.name, NULL, type);
+
+ return 0;
+}
+
+int uci_delete(struct uci_context *ctx, struct uci_package *p, const char *section, const char *option)
+{
+ /* NB: pass on internal flag to uci_del_element */
+ bool internal = ctx->internal;
+ struct uci_element *e;
+
+ UCI_HANDLE_ERR(ctx);
+
+ /* NB: p, section, option validated by uci_lookup */
+ UCI_INTERNAL(uci_lookup, ctx, &e, p, section, option);
+
+ ctx->internal = internal;
+ return uci_del_element(ctx, e);
+}
+
+int uci_set(struct uci_context *ctx, struct uci_package *p, const char *section, const char *option, const char *value, struct uci_element **result)
+{
+ /* NB: UCI_INTERNAL use means without history tracking */
+ bool internal = ctx->internal;
+ struct uci_element *e = NULL;