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 --- src/parser_bison.y | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 11f4716a..75a77358 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -37,7 +37,7 @@ void parser_init(struct mnl_socket *nf_sock, struct nft_cache *cache, struct parser_state *state, struct list_head *msgs, - unsigned int debug_mask) + unsigned int debug_mask, struct output_ctx *octx) { memset(state, 0, sizeof(*state)); init_list_head(&state->cmds); @@ -48,6 +48,7 @@ void parser_init(struct mnl_socket *nf_sock, struct nft_cache *cache, state->ectx.msgs = msgs; state->ectx.nf_sock = nf_sock; state->ectx.debug_mask = debug_mask; + state->ectx.octx = octx; } static void yyerror(struct location *loc, struct nft_ctx *nft, void *scanner, -- cgit v1.2.3