diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-04 14:50:22 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-04 16:47:38 +0200 |
commit | d844fa06e43bc80487acfe5647cef4d4994c95fd (patch) | |
tree | 2dd70dc1b8889da6f566e467eeebdd13feafeabb /src/rule.c | |
parent | 0dbe80fee352545f51bdc4fd71621223e8b62306 (diff) |
src: consolidate XML parsing of expressions via nft_mxml_expr_parse
Move common code for XML parsing of expressions to the new
nft_mxml_expr_parse function.
This patch reduces the XML parsing code in 300 LOC.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r-- | src/rule.c | 23 |
1 files changed, 2 insertions, 21 deletions
@@ -483,7 +483,6 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml) mxml_node_t *node = NULL; mxml_node_t *save = NULL; struct nft_rule_expr *e; - struct expr_ops *ops; char *endptr = NULL; uint64_t tmp; int family; @@ -608,30 +607,12 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml) node = mxmlFindElement(node, tree, "expr", "type", NULL, MXML_DESCEND)) { - if (mxmlElementGetAttr(node, "type") == NULL) { - mxmlDelete(tree); - return -1; - } - - ops = nft_expr_ops_lookup(mxmlElementGetAttr(node, "type")); - if (ops == NULL) { - mxmlDelete(tree); - return -1; - } - - e = nft_rule_expr_alloc(mxmlElementGetAttr(node, "type")); - if (e == NULL) { - mxmlDelete(tree); - return -1; - } - /* This is a hack for mxml to print just the current node */ save = node->next; node->next = NULL; - if (ops->xml_parse(e, - mxmlSaveAllocString(node, - MXML_NO_CALLBACK)) != 0) { + e = nft_mxml_expr_parse(node); + if (e == NULL) { mxmlDelete(tree); return -1; } |