From 2535ba7006f22a6470f4c88ea7d30c343a1d8799 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 28 Sep 2017 17:17:45 +0200 Subject: src: get rid of printf This patch introduces nft_print()/nft_gmp_print() functions which have to be used instead of printf to output information that were previously send to stdout. These functions print to a FILE pointer defined in struct output_ctx. It is set by calling: | old_fp = nft_ctx_set_output(ctx, new_fp); Having an application-defined FILE pointer is actually quite flexible: Using fmemopen() or even fopencookie(), an application gains full control over what is printed and where it should go to. Signed-off-by: Eric Leblond Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- include/nftables.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/nftables.h') diff --git a/include/nftables.h b/include/nftables.h index 3429e4c1..01d72a87 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -30,6 +30,7 @@ struct output_ctx { unsigned int ip2name; unsigned int handle; unsigned int echo; + FILE *output_fp; }; struct nft_cache { @@ -148,4 +149,9 @@ void realm_table_meta_exit(void); void devgroup_table_exit(void); void realm_table_rt_exit(void); +int nft_print(struct output_ctx *octx, const char *fmt, ...) + __attribute__((format(printf, 2, 3))); +int nft_gmp_print(struct output_ctx *octx, const char *fmt, ...) + __attribute__((format(printf, 2, 0))); + #endif /* NFTABLES_NFTABLES_H */ -- cgit v1.2.3