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/hash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/hash.c') diff --git a/src/hash.c b/src/hash.c index 1a4bfb30..9cd3c8cf 100644 --- a/src/hash.c +++ b/src/hash.c @@ -19,19 +19,19 @@ static void hash_expr_print(const struct expr *expr, struct output_ctx *octx) { switch (expr->hash.type) { case NFT_HASH_SYM: - printf("symhash"); + nft_print(octx, "symhash"); break; case NFT_HASH_JENKINS: default: - printf("jhash "); + nft_print(octx, "jhash "); expr_print(expr->hash.expr, octx); } - printf(" mod %u", expr->hash.mod); + nft_print(octx, " mod %u", expr->hash.mod); if (expr->hash.seed_set) - printf(" seed 0x%x", expr->hash.seed); + nft_print(octx, " seed 0x%x", expr->hash.seed); if (expr->hash.offset) - printf(" offset %u", expr->hash.offset); + nft_print(octx, " offset %u", expr->hash.offset); } static bool hash_expr_cmp(const struct expr *e1, const struct expr *e2) -- cgit v1.2.3