- struct uci_section *s;
- struct uci_option *o;
- char *section;
- char *option;
- char *str;
- int size = 0;
-
- UCI_HANDLE_ERR(ctx);
- UCI_ASSERT(ctx, (element != NULL) && (*element != NULL));
-
- /* what the 'value' of an element means depends on the type
- * for a section, the 'value' means its type
- * for an option, the 'value' means its value string
- * when changing the value, shrink the element to its actual size
- * (it may have been allocated with a bigger size, to include
- * its buffer)
- * then duplicate the string passed on the command line and
- * insert it into the structure.
- */
- e = *element;
- list = e->list.prev;
-
- switch(e->type) {
- case UCI_TYPE_SECTION:
- UCI_ASSERT(ctx, uci_validate_str(value, false));
- size = sizeof(struct uci_section);
- s = uci_to_section(e);
- section = e->name;
- option = NULL;
- /* matches the currently set value */
- if (!strcmp(value, s->type))
- return 0;
- break;
-
- case UCI_TYPE_OPTION:
- UCI_ASSERT(ctx, value != NULL);
- o = uci_to_option(e);
- s = o->section;
- section = s->e.name;
- option = o->e.name;
- switch(o->type) {
- case UCI_TYPE_STRING:
- size = sizeof(struct uci_option);
- /* matches the currently set value */
- if (!strcmp(value, o->v.string))
- return 0;
- break;
- default:
- /* default action for non-string datatypes is to delete
- * the existing entry, then re-create it as a string */
- break;
- }
- break;