return uci_del_element(ctx, e);
}
-int uci_set(struct uci_context *ctx, struct uci_package *p, char *section, char *option, char *value)
+int uci_set(struct uci_context *ctx, struct uci_package *p, char *section, char *option, char *value, struct uci_element **result)
{
/* NB: UCI_INTERNAL use means without history tracking */
bool internal = ctx->internal;
e = &o->e;
else
e = &s->e;
+ if (result)
+ *result = e;
+ else
+ result = &e;
ctx->internal = internal;
- return uci_set_element_value(ctx, &e, value);
+ return uci_set_element_value(ctx, result, value);
notfound:
/*
/* now add the missing entry */
if (!internal && p->confdir)
uci_add_history(ctx, &p->history, UCI_CMD_ADD, section, option, value);
- if (s)
- uci_alloc_option(s, option, value);
- else {
+ if (s) {
+ o = uci_alloc_option(s, option, value);
+ if (result)
+ *result = &o->e;
+ } else {
s = uci_alloc_section(p, value, section);
+ if (result)
+ *result = &s->e;
if (ctx->pctx && ctx->pctx->merge)
ctx->pctx->section = s;
}