From 3f994836f6bb124a5c0185ab6659ef7f57ceac5f Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 25 Jul 2013 21:21:51 +0200 Subject: src: xml: consolidate common XML code via nft_mxml_str_parse This patch moves common XML string parsing code to nft_mxml_str_parse(). Signed-off-by: Pablo Neira Ayuso --- src/expr/byteorder.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/expr/byteorder.c') diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index a931ffa..523bae1 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -186,7 +186,7 @@ nft_rule_expr_byteorder_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) { #ifdef XML_PARSING struct nft_expr_byteorder *byteorder = nft_expr_data(e); - mxml_node_t *node = NULL; + const char *op; int32_t reg; reg = nft_mxml_reg_parse(tree, "sreg", MXML_DESCEND_FIRST); @@ -203,13 +203,13 @@ nft_rule_expr_byteorder_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) byteorder->dreg = reg; e->flags |= (1 << NFT_EXPR_BYTEORDER_DREG); - node = mxmlFindElement(tree, tree, "op", NULL, NULL, MXML_DESCEND); - if (node == NULL) - goto err; + op = nft_mxml_str_parse(tree, "op", MXML_DESCEND_FIRST); + if (op == NULL) + return -1; - if (strcmp(node->child->value.opaque, "ntoh") == 0) + if (strcmp(op, "ntoh") == 0) byteorder->op = NFT_BYTEORDER_NTOH; - else if (strcmp(node->child->value.opaque, "hton") == 0) + else if (strcmp(op, "hton") == 0) byteorder->op = NFT_BYTEORDER_HTON; else goto err; -- cgit v1.2.3