Return the resolved name in addition to the type when looking up sections
through `get()` - for example a `cursor:get("firewall", "@rule[0]")` will
now return two values in the form ("rule", "cfg0a92bd") instead of only
the type name.
This is mainly useful to resolve extended section names without having to
reimplement the section count logic in Lua code.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
struct uci_element *e = NULL;
struct uci_ptr ptr;
int offset = 0;
+ int nret = 1;
char *s = NULL;
int err = UCI_ERR_NOTFOUND;
uci_push_package(L, ptr.p);
break;
case UCI_TYPE_SECTION:
- if (all)
+ if (all) {
uci_push_section(L, ptr.s, -1);
- else
+ }
+ else {
lua_pushstring(L, ptr.s->type);
+ lua_pushstring(L, ptr.s->e.name);
+ nret++;
+ }
break;
case UCI_TYPE_OPTION:
uci_push_option(L, ptr.o);
if (s)
free(s);
if (!err)
- return 1;
+ return nret;
error:
if (s)