From bd28075ee0bf121ef4fe50e34146efe14acee07b Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Tue, 29 Oct 2013 23:44:25 +0100 Subject: src: add fprintf API functions Now it's possible to print directly from libnftables to a file or other stream. The caller must explicitly print the trailing '\n' in this call. The error reporting of fprintf (< 0) is respected. However, we have already print some information in case that the default (plain text) output is used, that output is mostly intended for debugging so it should not be a problem. Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/set.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index 2c6e6a6..9620006 100644 --- a/src/set.c +++ b/src/set.c @@ -668,6 +668,19 @@ int nft_set_snprintf(char *buf, size_t size, struct nft_set *s, } EXPORT_SYMBOL(nft_set_snprintf); +static inline int nft_set_do_snprintf(char *buf, size_t size, void *s, + uint32_t type, uint32_t flags) +{ + return nft_set_snprintf(buf, size, s, type, flags); +} + +int nft_set_fprintf(FILE *fp, struct nft_set *s, uint32_t type, + uint32_t flags) +{ + return nft_fprintf(fp, s, type, flags, nft_set_do_snprintf); +} +EXPORT_SYMBOL(nft_set_fprintf); + void nft_set_elem_add(struct nft_set *s, struct nft_set_elem *elem) { list_add_tail(&elem->head, &s->element_list); -- cgit v1.2.3