From b3e73fda10db2b1aa2ef26690bf285839e4ea22a Mon Sep 17 00:00:00 2001 From: Arturo Borrero Gonzalez Date: Mon, 5 Aug 2013 14:01:28 +0200 Subject: src: xml: table/chain delete properties This patch deletes the node in chain and table XML objects. For this to work, the first tree search with MXML_DESCEND_FIRST flag is moved to the next node. Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/chain.c | 18 +++++------------- src/table.c | 17 +++++------------ tests/xmlfiles/01-table.xml | 6 ++---- tests/xmlfiles/02-table.xml | 6 ++---- tests/xmlfiles/10-chain.xml | 16 +++++++--------- tests/xmlfiles/11-chain.xml | 16 +++++++--------- tests/xmlfiles/12-chain.xml | 16 +++++++--------- 7 files changed, 35 insertions(+), 60 deletions(-) diff --git a/src/chain.c b/src/chain.c index c24aeb0..1964353 100644 --- a/src/chain.c +++ b/src/chain.c @@ -648,12 +648,9 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml) c->packets = utmp; c->flags |= (1 << NFT_CHAIN_ATTR_PACKETS); - /* Ignore node */ - node = mxmlFindElement(tree, tree, "properties", NULL, NULL, - MXML_DESCEND_FIRST); - /* Get and set */ - node = mxmlFindElement(tree, tree, "type", NULL, NULL, MXML_DESCEND); + node = mxmlFindElement(tree, tree, "type", NULL, NULL, + MXML_DESCEND_FIRST); if (node == NULL) { mxmlDelete(tree); return -1; @@ -820,12 +817,8 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c) ret = snprintf(buf, size, "" - "" - "%s" - "%s
" - "%d" - "%d" - "%s", + "%s%s
%d" + "%d%s", c->name, c->handle, c->bytes, c->packets, c->type, c->table, c->prio, c->use, hooknum2str_array[c->hooknum]); @@ -842,8 +835,7 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c) SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - ret = snprintf(buf+offset, size, "%s" - "
", + ret = snprintf(buf+offset, size, "%s", nft_family2str(c->family)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/table.c b/src/table.c index 402e8c1..76a1b4b 100644 --- a/src/table.c +++ b/src/table.c @@ -244,12 +244,9 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml) t->name = strdup(mxmlElementGetAttr(tree, "name")); t->flags |= (1 << NFT_TABLE_ATTR_NAME); - /* Ignore node */ - node = mxmlFindElement(tree, tree, "properties", NULL, NULL, - MXML_DESCEND_FIRST); - /* Get the and set node */ - node = mxmlFindElement(tree, tree, "family", NULL, NULL, MXML_DESCEND); + node = mxmlFindElement(tree, tree, "family", NULL, NULL, + MXML_DESCEND_FIRST); if (node == NULL) { mxmlDelete(tree); return -1; @@ -363,13 +360,9 @@ static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t) static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t) { - return snprintf(buf, size, "" - "" - "%s" - "%d" - "" - "
", - t->name, nft_family2str(t->family), t->table_flags); + return snprintf(buf, size, "%s" + "%d
", + t->name, nft_family2str(t->family), t->table_flags); } static int nft_table_snprintf_default(char *buf, size_t size, struct nft_table *t) diff --git a/tests/xmlfiles/01-table.xml b/tests/xmlfiles/01-table.xml index 133041d..2e33354 100644 --- a/tests/xmlfiles/01-table.xml +++ b/tests/xmlfiles/01-table.xml @@ -1,6 +1,4 @@ - - ip - 0 - + ip + 0
diff --git a/tests/xmlfiles/02-table.xml b/tests/xmlfiles/02-table.xml index 0aef342..27d0208 100644 --- a/tests/xmlfiles/02-table.xml +++ b/tests/xmlfiles/02-table.xml @@ -1,6 +1,4 @@ - - ip6 - 0 - + ip6 + 0
diff --git a/tests/xmlfiles/10-chain.xml b/tests/xmlfiles/10-chain.xml index 4de1020..6d1875e 100644 --- a/tests/xmlfiles/10-chain.xml +++ b/tests/xmlfiles/10-chain.xml @@ -1,11 +1,9 @@ - - filter - filter
- 0 - 1 - NF_INET_LOCAL_IN - accept - ip -
+ filter + filter
+ 0 + 1 + NF_INET_LOCAL_IN + accept + ip
diff --git a/tests/xmlfiles/11-chain.xml b/tests/xmlfiles/11-chain.xml index 310aeaa..986cd81 100644 --- a/tests/xmlfiles/11-chain.xml +++ b/tests/xmlfiles/11-chain.xml @@ -1,11 +1,9 @@ - - filter - filter
- 0 - 1 - NF_INET_FORWARD - drop - ip6 -
+ filter + filter
+ 0 + 1 + NF_INET_FORWARD + drop + ip6
diff --git a/tests/xmlfiles/12-chain.xml b/tests/xmlfiles/12-chain.xml index 20ee2a8..23fef8c 100644 --- a/tests/xmlfiles/12-chain.xml +++ b/tests/xmlfiles/12-chain.xml @@ -1,11 +1,9 @@ - - nat - nat
- 0 - 1 - NF_INET_POST_ROUTING - accept - ip -
+ nat + nat
+ 0 + 1 + NF_INET_POST_ROUTING + accept + ip
-- cgit v1.2.3