uci: expose section ordering index when dumping complete packages
This commit is contained in:
parent
1b829f936d
commit
51458f4ece
1 changed files with 9 additions and 3 deletions
12
uci.c
12
uci.c
|
@ -352,7 +352,7 @@ rpc_uci_dump_option(struct uci_option *o, const char *name)
|
||||||
* corresponding section properties.
|
* corresponding section properties.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rpc_uci_dump_section(struct uci_section *s, const char *name)
|
rpc_uci_dump_section(struct uci_section *s, const char *name, int index)
|
||||||
{
|
{
|
||||||
void *c;
|
void *c;
|
||||||
struct uci_option *o;
|
struct uci_option *o;
|
||||||
|
@ -364,6 +364,9 @@ rpc_uci_dump_section(struct uci_section *s, const char *name)
|
||||||
blobmsg_add_string(&buf, ".type", s->type);
|
blobmsg_add_string(&buf, ".type", s->type);
|
||||||
blobmsg_add_string(&buf, ".name", s->e.name);
|
blobmsg_add_string(&buf, ".name", s->e.name);
|
||||||
|
|
||||||
|
if (index >= 0)
|
||||||
|
blobmsg_add_u32(&buf, ".index", index);
|
||||||
|
|
||||||
uci_foreach_element(&s->options, e)
|
uci_foreach_element(&s->options, e)
|
||||||
{
|
{
|
||||||
o = uci_to_option(e);
|
o = uci_to_option(e);
|
||||||
|
@ -387,15 +390,18 @@ rpc_uci_dump_package(struct uci_package *p, const char *name,
|
||||||
{
|
{
|
||||||
void *c;
|
void *c;
|
||||||
struct uci_element *e;
|
struct uci_element *e;
|
||||||
|
int i = -1;
|
||||||
|
|
||||||
c = blobmsg_open_table(&buf, name);
|
c = blobmsg_open_table(&buf, name);
|
||||||
|
|
||||||
uci_foreach_element(&p->sections, e)
|
uci_foreach_element(&p->sections, e)
|
||||||
{
|
{
|
||||||
|
i++;
|
||||||
|
|
||||||
if (!rpc_uci_match_section(uci_to_section(e), type, matches))
|
if (!rpc_uci_match_section(uci_to_section(e), type, matches))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rpc_uci_dump_section(uci_to_section(e), e->name);
|
rpc_uci_dump_section(uci_to_section(e), e->name, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
blobmsg_close_table(&buf, c);
|
blobmsg_close_table(&buf, c);
|
||||||
|
@ -443,7 +449,7 @@ rpc_uci_get(struct ubus_context *ctx, struct ubus_object *obj,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UCI_TYPE_SECTION:
|
case UCI_TYPE_SECTION:
|
||||||
rpc_uci_dump_section(ptr.s, "values");
|
rpc_uci_dump_section(ptr.s, "values", -1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UCI_TYPE_OPTION:
|
case UCI_TYPE_OPTION:
|
||||||
|
|
Loading…
Reference in a new issue