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/payload.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/payload.c') diff --git a/src/payload.c b/src/payload.c index 7f94ff7f..aa8a95ad 100644 --- a/src/payload.c +++ b/src/payload.c @@ -46,11 +46,11 @@ static void payload_expr_print(const struct expr *expr, struct output_ctx *octx) desc = expr->payload.desc; tmpl = expr->payload.tmpl; if (payload_is_known(expr)) - printf("%s %s", desc->name, tmpl->token); + nft_print(octx, "%s %s", desc->name, tmpl->token); else - printf("payload @%s,%u,%u", - proto_base_tokens[expr->payload.base], - expr->payload.offset, expr->len); + nft_print(octx, "payload @%s,%u,%u", + proto_base_tokens[expr->payload.base], + expr->payload.offset, expr->len); } static bool payload_expr_cmp(const struct expr *e1, const struct expr *e2) @@ -187,7 +187,7 @@ unsigned int payload_hdr_field(const struct expr *expr) static void payload_stmt_print(const struct stmt *stmt, struct output_ctx *octx) { expr_print(stmt->payload.expr, octx); - printf(" set "); + nft_print(octx, " set "); expr_print(stmt->payload.val, octx); } -- cgit v1.2.3