summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorArturo Borrero <arturo.borrero.glez@gmail.com>2013-10-29 23:44:25 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2013-11-03 22:11:56 +0100
commitbd28075ee0bf121ef4fe50e34146efe14acee07b (patch)
treedeb218fce40f0bdf877b249160145adb0de5b5f8 /include
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 <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r--include/libnftables/chain.h2
-rw-r--r--include/libnftables/rule.h2
-rw-r--r--include/libnftables/ruleset.h3
-rw-r--r--include/libnftables/set.h3
-rw-r--r--include/libnftables/table.h2
5 files changed, 12 insertions, 0 deletions
diff --git a/include/libnftables/chain.h b/include/libnftables/chain.h
index d85a2a2..66f19c0 100644
--- a/include/libnftables/chain.h
+++ b/include/libnftables/chain.h
@@ -1,6 +1,7 @@
#ifndef _CHAIN_H_
#define _CHAIN_H_
+#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
@@ -60,6 +61,7 @@ enum nft_chain_parse_type {
int nft_chain_parse(struct nft_chain *c, enum nft_chain_parse_type type, const char *data);
int nft_chain_snprintf(char *buf, size_t size, struct nft_chain *t, uint32_t type, uint32_t flags);
+int nft_chain_fprintf(FILE *fp, struct nft_chain *c, uint32_t type, uint32_t flags);
struct nlmsghdr *nft_chain_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq);
int nft_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_chain *t);
diff --git a/include/libnftables/rule.h b/include/libnftables/rule.h
index a501d2d..cdbd8d2 100644
--- a/include/libnftables/rule.h
+++ b/include/libnftables/rule.h
@@ -1,6 +1,7 @@
#ifndef _RULE_H_
#define _RULE_H_
+#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
@@ -58,6 +59,7 @@ enum nft_rule_parse_type {
int nft_rule_parse(struct nft_rule *r, enum nft_rule_parse_type type, const char *data);
int nft_rule_snprintf(char *buf, size_t size, struct nft_rule *t, uint32_t type, uint32_t flags);
+int nft_rule_fprintf(FILE *fp, struct nft_rule *r, uint32_t type, uint32_t flags);
struct nlmsghdr *nft_rule_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq);
int nft_rule_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_rule *t);
diff --git a/include/libnftables/ruleset.h b/include/libnftables/ruleset.h
index a4a1279..35e4d71 100644
--- a/include/libnftables/ruleset.h
+++ b/include/libnftables/ruleset.h
@@ -1,6 +1,8 @@
#ifndef _RULESET_H_
#define _RULESET_H_
+#include <stdio.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -37,6 +39,7 @@ enum nft_ruleset_parse_type {
int nft_ruleset_parse(struct nft_ruleset *rs, enum nft_ruleset_parse_type type, const char *data);
int nft_ruleset_snprintf(char *buf, size_t size, const struct nft_ruleset *rs, uint32_t type, uint32_t flags);
+int nft_ruleset_fprintf(FILE *fp, const struct nft_ruleset *rs, uint32_t type, uint32_t flags);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/libnftables/set.h b/include/libnftables/set.h
index 14a6327..a087009 100644
--- a/include/libnftables/set.h
+++ b/include/libnftables/set.h
@@ -1,6 +1,7 @@
#ifndef _NFT_SET_H_
#define _NFT_SET_H_
+#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
@@ -38,6 +39,7 @@ int nft_set_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set *s);
int nft_set_elems_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set *s);
int nft_set_snprintf(char *buf, size_t size, struct nft_set *s, uint32_t type, uint32_t flags);
+int nft_set_fprintf(FILE *fp, struct nft_set *s, uint32_t type, uint32_t flags);
struct nft_set_list;
@@ -108,6 +110,7 @@ int nft_set_elem_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set_elem *s)
int nft_set_elem_parse(struct nft_set_elem *e, enum nft_set_parse_type type, const char *data);
int nft_set_elem_snprintf(char *buf, size_t size, struct nft_set_elem *s, uint32_t type, uint32_t flags);
+int nft_set_elem_fprintf(FILE *fp, struct nft_set_elem *se, uint32_t type, uint32_t flags);
int nft_set_elem_foreach(struct nft_set *s, int (*cb)(struct nft_set_elem *e, void *data), void *data);
diff --git a/include/libnftables/table.h b/include/libnftables/table.h
index 42a4aa7..4a323bd 100644
--- a/include/libnftables/table.h
+++ b/include/libnftables/table.h
@@ -1,6 +1,7 @@
#ifndef _TABLE_H_
#define _TABLE_H_
+#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
@@ -48,6 +49,7 @@ enum nft_table_parse_type {
int nft_table_parse(struct nft_table *t, enum nft_table_parse_type type, const char *data);
int nft_table_snprintf(char *buf, size_t size, struct nft_table *t, uint32_t type, uint32_t flags);
+int nft_table_fprintf(FILE *fp, struct nft_table *t, uint32_t type, uint32_t flags);
struct nlmsghdr *nft_table_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq);
int nft_table_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_table *t);