From f95e8598af7e3a1641166b4e6be31b87d4690326 Mon Sep 17 00:00:00 2001 From: Giuseppe Longo Date: Fri, 5 Jul 2013 10:06:28 +0200 Subject: src: improve default text output This patch improves default plain text output by mimicing the default output of libnl-nft. While at it, several %lu has been translated to use %"PRIu64" for correctness. [ I have added the policy to string translation --pablo ] Signed-off-by: Giuseppe Longo Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index 64c34bd..5a4ae91 100644 --- a/src/rule.c +++ b/src/rule.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -745,18 +746,20 @@ static int nft_rule_snprintf_default(char *buf, size_t size, struct nft_rule *r, struct nft_rule_expr *expr; int ret, len = size, offset = 0; - ret = snprintf(buf, size, "family=%s table=%s chain=%s handle=%llu " - "flags=%x ", + ret = snprintf(buf, size, "%s %s %s %"PRIu64"\n", nft_family2str(r->family), r->table, r->chain, - (unsigned long long)r->handle, r->rule_flags); + r->handle); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); list_for_each_entry(expr, &r->expr_list, head) { - ret = snprintf(buf+offset, len, "%s ", expr->ops->name); + ret = snprintf(buf+offset, len, " [ %s ", expr->ops->name); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = nft_rule_expr_snprintf(buf+offset, size, expr, type, flags); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + + ret = snprintf(buf+offset, len, "]\n"); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } return offset; -- cgit v1.2.3