diff options
author | Arturo Borrero <arturo.borrero.glez@gmail.com> | 2014-01-09 12:19:06 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-01-09 17:17:37 +0100 |
commit | fc423ae81487e906141f700c7b3515328ff62b7c (patch) | |
tree | d55537396d2ccca278df628853f4febf8ed4e697 /src/mxml.c | |
parent | 2c21b41889abf93ff816b82b59e6bf2d4a084a61 (diff) |
src: rework and generalize the build/parse system
The intention behind this patch is to prepare the introduction of
the new API that will allow us to parse files that contain the rule-sets
expressed in XML/JSON format. This adds the NFT_PARSE_BUFFER that
indicates that the input is provided in a buffer, which is what we
currently support.
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/mxml.c')
-rw-r--r-- | src/mxml.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -22,12 +22,19 @@ #include <libnftables/set.h> #ifdef XML_PARSING -mxml_node_t *nft_mxml_build_tree(const char *xml, const char *treename, - struct nft_parse_err *err) +mxml_node_t *nft_mxml_build_tree(const void *data, const char *treename, + struct nft_parse_err *err, enum nft_parse_input input) { mxml_node_t *tree; - tree = mxmlLoadString(NULL, xml, MXML_OPAQUE_CALLBACK); + switch (input) { + case NFT_PARSE_BUFFER: + tree = mxmlLoadString(NULL, data, MXML_OPAQUE_CALLBACK); + break; + default: + goto err; + } + if (tree == NULL) { err->error = NFT_PARSE_EBADINPUT; goto err; |