From 26e06d838d6471f5233c1da3fee012bf113564a5 Mon Sep 17 00:00:00 2001 From: Arturo Borrero Gonzalez Date: Fri, 8 Feb 2013 17:51:56 +0100 Subject: src: add XML output support Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/table.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/table.c') diff --git a/src/table.c b/src/table.c index 48e9a6a..eb485b2 100644 --- a/src/table.c +++ b/src/table.c @@ -174,12 +174,37 @@ int nft_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_table *t) } EXPORT_SYMBOL(nft_table_nlmsg_parse); -int nft_table_snprintf(char *buf, size_t size, struct nft_table *t, - uint32_t type, uint32_t flags) +static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t) +{ + return snprintf(buf, size, + "\n" + "\t\n" + "\t\t\n" + "\t\t\n" + "\t\n" + "
\n" , + t->name, t->family, t->flags, t->table_flags); +} + +static int nft_table_snprintf_default(char *buf, size_t size, struct nft_table *t) { return snprintf(buf, size, "table=%s family=%u flags=%x\n", t->name, t->family, t->table_flags); } + +int nft_table_snprintf(char *buf, size_t size, struct nft_table *t, + uint32_t type, uint32_t flags) +{ + switch(type) { + case NFT_TABLE_O_XML: + return nft_table_snprintf_xml(buf, size, t); + case NFT_TABLE_O_DEFAULT: + return nft_table_snprintf_default(buf, size, t); + default: + break; + } + return -1; +} EXPORT_SYMBOL(nft_table_snprintf); struct nft_table_list { -- cgit v1.2.3