From aa78a088dde9875ae3e31468ea5e4ca3bd349d2c Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 7 Aug 2013 22:31:52 +0200 Subject: src: xml: cleanup set element parsing Move nft_mxml_set_elem_parse to set_elem.c to improve readability, thus, we don't need to jump from set_elem.c to mxml.c to see how the parsing is done. I have also refactored some common parsing code in the new helper function nft_mxml_set_elem_parse, that avoids conversions from XML tree to text and then again back to tree. Signed-off-by: Pablo Neira Ayuso --- src/set.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index eb90426..97856b3 100644 --- a/src/set.c +++ b/src/set.c @@ -355,7 +355,6 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml) s->flags |= (1 << NFT_SET_ATTR_FLAGS); - if (nft_mxml_num_parse(tree, "key_type", MXML_DESCEND_FIRST, BASE_DEC, &s->key_type, NFT_TYPE_U32) != 0) goto err; @@ -380,17 +379,19 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml) s->flags |= (1 << NFT_SET_ATTR_DATA_LEN); - /* Iterate over each */ for (node = mxmlFindElement(tree, tree, "set_elem", NULL, NULL, MXML_DESCEND); node != NULL; node = mxmlFindElement(node, tree, "set_elem", NULL, NULL, MXML_DESCEND)) { - elem = nft_mxml_set_elem_parse(node); + elem = nft_set_elem_alloc(); if (elem == NULL) goto err; + if (nft_mxml_set_elem_parse(node, elem) < 0) + goto err; + list_add_tail(&elem->head, &s->element_list); } -- cgit v1.2.3