path: root/include/rule.h
diff options
authorPhil Sutter <>2017-09-28 17:17:45 +0200
committerPablo Neira Ayuso <>2017-09-29 12:37:51 +0200
commit2535ba7006f22a6470f4c88ea7d30c343a1d8799 (patch)
treee09697d8d9a59394170fa412276346d64b5b62e7 /include/rule.h
parent15a1f5bd55735f6f65a6fd9e2e86bb4a3f5ac815 (diff)
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 <>
Diffstat (limited to 'include/rule.h')
1 files changed, 5 insertions, 2 deletions
diff --git a/include/rule.h b/include/rule.h
index 6f52b17f..c59bcea7 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -172,7 +172,8 @@ extern struct chain *chain_lookup(const struct table *table,
extern const char *family2str(unsigned int family);
extern const char *hooknum2str(unsigned int family, unsigned int hooknum);
-extern void chain_print_plain(const struct chain *chain);
+extern void chain_print_plain(const struct chain *chain,
+ struct output_ctx *octx);
* struct rule - nftables rule
@@ -493,6 +494,7 @@ struct eval_ctx {
struct set *set;
struct stmt *stmt;
struct nft_cache *cache;
+ struct output_ctx *octx;
unsigned int debug_mask;
struct expr_ctx ectx;
struct proto_ctx pctx;
@@ -506,7 +508,8 @@ struct netlink_ctx;
extern int do_command(struct netlink_ctx *ctx, struct cmd *cmd);
extern int cache_update(struct mnl_socket *nf_sock, struct nft_cache *cache,
- enum cmd_ops cmd, struct list_head *msgs, bool debug);
+ enum cmd_ops cmd, struct list_head *msgs, bool debug,
+ struct output_ctx *octx);
extern void cache_flush(struct list_head *table_list);
extern void cache_release(struct nft_cache *cache);