From d844fa06e43bc80487acfe5647cef4d4994c95fd Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 4 Jul 2013 14:50:22 +0200 Subject: 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 --- src/expr/byteorder.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/expr/byteorder.c') diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index bb47f10..e1a98e9 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -202,25 +202,14 @@ static char *expr_byteorder_str[] = { }; static int -nft_rule_expr_byteorder_xml_parse(struct nft_rule_expr *e, char *xml) +nft_rule_expr_byteorder_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) { #ifdef XML_PARSING struct nft_expr_byteorder *byteorder = (struct nft_expr_byteorder *)e; - mxml_node_t *tree = NULL; mxml_node_t *node = NULL; uint64_t tmp; char *endptr = NULL; - tree = mxmlLoadString(NULL, xml, MXML_OPAQUE_CALLBACK); - if (tree == NULL) - return -1; - - if (mxmlElementGetAttr(tree, "type") == NULL) - goto err; - - if (strcmp("byteorder", mxmlElementGetAttr(tree, "type")) != 0) - goto err; - node = mxmlFindElement(tree, tree, "sreg", NULL, NULL, MXML_DESCEND_FIRST); if (node == NULL) @@ -285,10 +274,8 @@ nft_rule_expr_byteorder_xml_parse(struct nft_rule_expr *e, char *xml) byteorder->size = tmp; e->flags |= (1 << NFT_EXPR_BYTEORDER_SIZE); - mxmlDelete(tree); return 0; err: - mxmlDelete(tree); errno = EINVAL; return -1; #else -- cgit v1.2.3