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/ct.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/expr/ct.c') diff --git a/src/expr/ct.c b/src/expr/ct.c index 8014314..13da036 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -192,26 +192,15 @@ static inline int str2ctkey(const char *ctkey) return -1; } -static int nft_rule_expr_ct_xml_parse(struct nft_rule_expr *e, char *xml) +static int nft_rule_expr_ct_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) { #ifdef XML_PARSING struct nft_expr_ct *ct = (struct nft_expr_ct *)e->data; - mxml_node_t *tree = NULL; mxml_node_t *node = NULL; uint64_t tmp; char *endptr; int key; - tree = mxmlLoadString(NULL, xml, MXML_OPAQUE_CALLBACK); - if (tree == NULL) - return -1; - - if (mxmlElementGetAttr(tree, "type") == NULL) - goto err; - - if (strcmp("ct", mxmlElementGetAttr(tree, "type")) != 0) - goto err; - node = mxmlFindElement(tree, tree, "dreg", NULL, NULL, MXML_DESCEND_FIRST); if (node == NULL) @@ -252,10 +241,8 @@ static int nft_rule_expr_ct_xml_parse(struct nft_rule_expr *e, char *xml) ct->dir = tmp; e->flags |= (1 << NFT_EXPR_CT_DIR); - mxmlDelete(tree); return 0; err: - mxmlDelete(tree); errno = EINVAL; return -1; #else -- cgit v1.2.3