+ UCI_HANDLE_ERR(ctx);
+ UCI_ASSERT(ctx, p != NULL);
+ UCI_ASSERT(ctx, section != NULL);
+
+ UCI_INTERNAL(uci_lookup, ctx, &e, p, section, option);
+
+ if (!internal)
+ return uci_del_element(ctx, e);
+ UCI_INTERNAL(uci_del_element, ctx, e);
+
+ return 0;
+}
+
+int uci_set(struct uci_context *ctx, struct uci_package *p, char *section, char *option, char *value)
+{
+ /* NB: UCI_INTERNAL use means without history tracking */
+ bool internal = ctx->internal;
+ struct uci_element *e = NULL;
+ struct uci_section *s = NULL;
+ struct uci_option *o = NULL;
+
+ UCI_HANDLE_ERR(ctx);
+ UCI_ASSERT(ctx, p != NULL);
+ UCI_ASSERT(ctx, section != NULL);
+ UCI_ASSERT(ctx, value != NULL);
+
+ /*
+ * look up the package, section and option (if set)
+ * if the section/option is to be modified and it is not found
+ * create a new element in the appropriate list
+ */
+ e = uci_lookup_list(ctx, &p->sections, section);
+ if (!e)
+ goto notfound;
+
+ s = uci_to_section(e);
+ if (ctx->pctx)
+ ctx->pctx->section = s;
+
+ if (option) {
+ e = uci_lookup_list(ctx, &s->options, option);
+ if (!e)
+ goto notfound;
+ o = uci_to_option(e);