diff options
author | Arturo Borrero <arturo.borrero.glez@gmail.com> | 2013-07-25 18:46:35 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-25 20:03:21 +0200 |
commit | e13819c5f5b6138c4c7e01156d0fd9f58b11702d (patch) | |
tree | c4bbc0256f537099a8233915597419843359793b /src/internal.h | |
parent | 3ebc57b84c227fcfc55545af85e246ab4cad2041 (diff) |
src: xml: consolidate common XML code via nft_mxml_num_parse
This patch moves common XML parsing code to nft_mxml_num_parse().
To handle this, the nft_strtoi() helper fuction is included.
I've changed some MXML_DESCEND[_FIRST] flags to avoid match a nested node under
some circumstances, ie, matching two nodes with the same name that are descendant.
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/internal.h')
-rw-r--r-- | src/internal.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/internal.h b/src/internal.h index dc7d0c3..3bf57b6 100644 --- a/src/internal.h +++ b/src/internal.h @@ -13,12 +13,27 @@ #include <stdint.h> +#define BASE_DEC 10 +#define BASE_HEX 16 + +enum nft_type { + NFT_TYPE_U8, + NFT_TYPE_U16, + NFT_TYPE_U32, + NFT_TYPE_U64, + NFT_TYPE_S8, + NFT_TYPE_S16, + NFT_TYPE_S32, + NFT_TYPE_S64, +}; + #ifdef XML_PARSING #include <mxml.h> struct nft_rule_expr *nft_mxml_expr_parse(mxml_node_t *node); int nft_mxml_reg_parse(mxml_node_t *tree, const char *reg_name, uint32_t flags); union nft_data_reg; int nft_mxml_data_reg_parse(mxml_node_t *tree, const char *node_name, union nft_data_reg *data_reg); +int nft_mxml_num_parse(mxml_node_t *tree, const char *node_name, uint32_t mxml_flags, int base, void *number, enum nft_type type); #endif #define NFT_TABLE_XML_VERSION 0 @@ -32,6 +47,7 @@ int nft_mxml_data_reg_parse(mxml_node_t *tree, const char *node_name, union nft_ const char *nft_family2str(uint32_t family); int nft_str2family(const char *family); +int nft_strtoi(const char *string, int base, void *number, enum nft_type type); struct expr_ops; |