diff options
Diffstat (limited to 'src/chain.c')
-rw-r--r-- | src/chain.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/chain.c b/src/chain.c index a4ddb06..8f40ede 100644 --- a/src/chain.c +++ b/src/chain.c @@ -591,14 +591,15 @@ err: } #endif -static int nft_chain_json_parse(struct nft_chain *c, const char *json, - struct nft_parse_err *err) +static int nft_chain_json_parse(struct nft_chain *c, const void *json, + struct nft_parse_err *err, + enum nft_parse_input input) { #ifdef JSON_PARSING json_t *tree; json_error_t error; - tree = nft_jansson_create_root(json, &error, err); + tree = nft_jansson_create_root(json, &error, err, input); if (tree == NULL) return -1; @@ -708,12 +709,13 @@ int nft_mxml_chain_parse(mxml_node_t *tree, struct nft_chain *c, } #endif -static int nft_chain_xml_parse(struct nft_chain *c, const char *xml, - struct nft_parse_err *err) +static int nft_chain_xml_parse(struct nft_chain *c, const void *xml, + struct nft_parse_err *err, + enum nft_parse_input input) { #ifdef XML_PARSING int ret; - mxml_node_t *tree = nft_mxml_build_tree(xml, "chain", err); + mxml_node_t *tree = nft_mxml_build_tree(xml, "chain", err, input); if (tree == NULL) return -1; @@ -726,18 +728,19 @@ static int nft_chain_xml_parse(struct nft_chain *c, const char *xml, #endif } -int nft_chain_parse(struct nft_chain *c, enum nft_parse_type type, - const char *data, struct nft_parse_err *err) +static int nft_chain_do_parse(struct nft_chain *c, enum nft_parse_type type, + const void *data, struct nft_parse_err *err, + enum nft_parse_input input) { int ret; struct nft_parse_err perr; switch (type) { case NFT_PARSE_XML: - ret = nft_chain_xml_parse(c, data, &perr); + ret = nft_chain_xml_parse(c, data, &perr, input); break; case NFT_PARSE_JSON: - ret = nft_chain_json_parse(c, data, &perr); + ret = nft_chain_json_parse(c, data, &perr, input); break; default: ret = -1; @@ -750,6 +753,12 @@ int nft_chain_parse(struct nft_chain *c, enum nft_parse_type type, return ret; } + +int nft_chain_parse(struct nft_chain *c, enum nft_parse_type type, + const char *data, struct nft_parse_err *err) +{ + return nft_chain_do_parse(c, type, data, err, NFT_PARSE_BUFFER); +} EXPORT_SYMBOL(nft_chain_parse); static int nft_chain_snprintf_json(char *buf, size_t size, struct nft_chain *c) |