Hello,

I'm trying to use ucimap, and I'd like to see when a string option is present, e.g.


struct uci_test {
        struct ucimap_section_data map;
        char *test;
};

static int
test_init(struct uci_map *map, void *section, struct uci_section *s)
{
        return 0;
}

static int
test_add(struct uci_map *map, void *section)
{
        struct uci_test *a = section;

        if (a->test) {
                /* option present */
                do_something();
        } else {
                /* option absent */
                do_something_else();
        }
        return 0;
}

static struct uci_optmap test_uci_map[] =
{
        {
                UCIMAP_OPTION(struct uci_test, test),
                .type = UCIMAP_STRING,
                .name = "test",
        }
};

static struct uci_sectionmap test_sectionmap = {
        UCIMAP_SECTION(struct uci_test, map),
        .type = "testsection",
        .init = test_init,
        .add = test_add,
        .options = test_uci_map,
        .n_options = ARRAY_SIZE(test_uci_map),
        .options_size = sizeof(struct uci_optmap),
};


However it seem I cannot distinguish if the option was absent or it was
an empty string (i.e., in both cases a->test is NULL) and I need to treat both cases differently.
Is there a way to do it?

Bye
--
Luca



_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to