summaryrefslogtreecommitdiffstats
path: root/src/set.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/set.c')
-rw-r--r--src/set.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/set.c b/src/set.c
index 9317b9c..1c9caf8 100644
--- a/src/set.c
+++ b/src/set.c
@@ -375,14 +375,14 @@ err:
}
#endif
-static int nft_set_json_parse(struct nft_set *s, const char *json,
- struct nft_parse_err *err)
+static int nft_set_json_parse(struct nft_set *s, 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;
@@ -483,12 +483,12 @@ int nft_mxml_set_parse(mxml_node_t *tree, struct nft_set *s,
}
#endif
-static int nft_set_xml_parse(struct nft_set *s, const char *xml,
- struct nft_parse_err *err)
+static int nft_set_xml_parse(struct nft_set *s, 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, "set", err);
+ mxml_node_t *tree = nft_mxml_build_tree(xml, "set", err, input);
if (tree == NULL)
return -1;
@@ -501,18 +501,19 @@ static int nft_set_xml_parse(struct nft_set *s, const char *xml,
#endif
}
-int nft_set_parse(struct nft_set *s, enum nft_parse_type type,
- const char *data, struct nft_parse_err *err)
+static int nft_set_do_parse(struct nft_set *s, 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_set_xml_parse(s, data, &perr);
+ ret = nft_set_xml_parse(s, data, &perr, input);
break;
case NFT_PARSE_JSON:
- ret = nft_set_json_parse(s, data, &perr);
+ ret = nft_set_json_parse(s, data, &perr, input);
break;
default:
ret = -1;
@@ -525,6 +526,11 @@ int nft_set_parse(struct nft_set *s, enum nft_parse_type type,
return ret;
}
+int nft_set_parse(struct nft_set *s, enum nft_parse_type type,
+ const char *data, struct nft_parse_err *err)
+{
+ return nft_set_do_parse(s, type, data, err, NFT_PARSE_BUFFER);
+}
EXPORT_SYMBOL(nft_set_parse);
static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s,