path: root/src/table.c
diff options
authorArturo Borrero <>2013-10-29 23:44:25 +0100
committerPablo Neira Ayuso <>2013-11-03 22:11:56 +0100
commitbd28075ee0bf121ef4fe50e34146efe14acee07b (patch)
treedeb218fce40f0bdf877b249160145adb0de5b5f8 /src/table.c
parentdc4c1e1ded43875d082f0ef5ed794b5bf9eb8f58 (diff)
src: add fprintf API functions
Now it's possible to print directly from libnftables to a file or other stream. The caller must explicitly print the trailing '\n' in this call. The error reporting of fprintf (< 0) is respected. However, we have already print some information in case that the default (plain text) output is used, that output is mostly intended for debugging so it should not be a problem. Signed-off-by: Arturo Borrero Gonzalez <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'src/table.c')
1 files changed, 13 insertions, 0 deletions
diff --git a/src/table.c b/src/table.c
index d3ff188..d1acc7c 100644
--- a/src/table.c
+++ b/src/table.c
@@ -388,6 +388,19 @@ int nft_table_snprintf(char *buf, size_t size, struct nft_table *t,
+static inline int nft_table_do_snprintf(char *buf, size_t size, void *t,
+ uint32_t type, uint32_t flags)
+ return nft_table_snprintf(buf, size, t, type, flags);
+int nft_table_fprintf(FILE *fp, struct nft_table *t, uint32_t type,
+ uint32_t flags)
+ return nft_fprintf(fp, t, type, flags, nft_table_do_snprintf);
struct nft_table_list {
struct list_head list;