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/log.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/expr/log.c') diff --git a/src/expr/log.c b/src/expr/log.c index 8dc5201..b2b3ca1 100644 --- a/src/expr/log.c +++ b/src/expr/log.c @@ -170,25 +170,14 @@ nft_rule_expr_log_parse(struct nft_rule_expr *e, struct nlattr *attr) return 0; } -static int nft_rule_expr_log_xml_parse(struct nft_rule_expr *e, char *xml) +static int nft_rule_expr_log_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) { #ifdef XML_PARSING struct nft_expr_log *log = (struct nft_expr_log *)e->data; - mxml_node_t *tree = NULL; mxml_node_t *node = NULL; uint64_t tmp; char *endptr; - tree = mxmlLoadString(NULL, xml, MXML_OPAQUE_CALLBACK); - if (tree == NULL) - return -1; - - if (mxmlElementGetAttr(tree, "type") == NULL) - goto err; - - if (strcmp("log", mxmlElementGetAttr(tree, "type")) != 0) - goto err; - node = mxmlFindElement(tree, tree, "prefix", NULL, NULL, MXML_DESCEND_FIRST); if (node == NULL) @@ -232,11 +221,9 @@ static int nft_rule_expr_log_xml_parse(struct nft_rule_expr *e, char *xml) log->qthreshold = tmp; e->flags |= (1 << NFT_EXPR_LOG_QTHRESHOLD); - mxmlDelete(tree); return 0; err: errno = EINVAL; - mxmlDelete(tree); return -1; #else errno = EOPNOTSUPP; -- cgit v1.2.3