From e13819c5f5b6138c4c7e01156d0fd9f58b11702d Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Thu, 25 Jul 2013 18:46:35 +0200 Subject: src: xml: consolidate common XML code via nft_mxml_num_parse This patch moves common XML parsing code to nft_mxml_num_parse(). To handle this, the nft_strtoi() helper fuction is included. I've changed some MXML_DESCEND[_FIRST] flags to avoid match a nested node under some circumstances, ie, matching two nodes with the same name that are descendant. Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/chain.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/chain.c') diff --git a/src/chain.c b/src/chain.c index 4f9741a..1e07044 100644 --- a/src/chain.c +++ b/src/chain.c @@ -576,18 +576,12 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml) c->flags |= (1 << NFT_CHAIN_ATTR_TABLE); /* Get and set */ - node = mxmlFindElement(tree, tree, "prio", NULL, NULL, MXML_DESCEND); - if (node == NULL) { - mxmlDelete(tree); - return -1; - } - tmp = strtoll(node->child->value.opaque, &endptr, 10); - if (tmp > INT32_MAX || tmp < INT32_MIN || *endptr) { + if (nft_mxml_num_parse(tree, "prio", MXML_DESCEND, BASE_DEC, &c->prio, + NFT_TYPE_S32) != 0) { mxmlDelete(tree); return -1; } - memcpy(&c->prio, &tmp, sizeof(c->prio)); c->flags |= (1 << NFT_CHAIN_ATTR_PRIO); /* Ignore (cannot be set)*/ -- cgit v1.2.3