From bd28075ee0bf121ef4fe50e34146efe14acee07b Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Tue, 29 Oct 2013 23:44:25 +0100 Subject: 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 --- src/internal.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/internal.h') diff --git a/src/internal.h b/src/internal.h index b29288a..6449a9f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -17,6 +17,8 @@ #define BASE_DEC 10 #define BASE_HEX 16 +#define NFT_SNPRINTF_BUFSIZ 4096 + enum nft_type { NFT_TYPE_U8, NFT_TYPE_U16, @@ -88,6 +90,8 @@ const char *nft_verdict2str(uint32_t verdict); int nft_str2verdict(const char *verdict); int nft_get_value(enum nft_type type, void *val, void *out); +int nft_fprintf(FILE *fp, void *obj, uint32_t type, uint32_t flags, int (*snprintf_cb)(char *buf, size_t bufsiz, void *obj, uint32_t type, uint32_t flags)); + void xfree(const void *ptr); struct expr_ops; -- cgit v1.2.3