]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: reallocate definition of nft_print() and nft_gmp_print()
authorArturo Borrero Gonzalez <arturo@netfilter.org>
Mon, 1 Jul 2019 10:53:10 +0000 (12:53 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 1 Jul 2019 18:43:46 +0000 (20:43 +0200)
They are not part of the libnftables library API, they are not public symbols,
so it doesn't not make sense to have them there. Move the two functions to a
different source file so libnftables.c only has the API functions.

I think copyright belongs to Phil Sutter since he introduced this code back in
commit 2535ba7006f22a6470f4c88ea7d30c343a1d8799 (src: get rid of printf).

Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/Makefile.am
src/libnftables.c
src/print.c [new file with mode: 0644]

index fd641755b7a44e4d5037ad257e5cfa0f8275b7cf..a1c18fe26037b6461e72ed45e77947c51f808c08 100644 (file)
@@ -62,6 +62,7 @@ libnftables_la_SOURCES =                      \
                nfnl_osf.c                      \
                tcpopt.c                        \
                socket.c                        \
+               print.c                         \
                libnftables.c
 
 # yacc and lex generate dirty code
index dccb8ab4da42ae60828e07c92b3d281ef320717e..f2cd267db0fe9ea3a54b0ad155bdbc78c26508a7 100644 (file)
@@ -507,30 +507,3 @@ err:
                cache_release(&nft->cache);
        return rc;
 }
-
-int nft_print(struct output_ctx *octx, const char *fmt, ...)
-{
-       int ret;
-       va_list arg;
-
-       va_start(arg, fmt);
-       ret = vfprintf(octx->output_fp, fmt, arg);
-       va_end(arg);
-       fflush(octx->output_fp);
-
-       return ret;
-}
-
-int nft_gmp_print(struct output_ctx *octx, const char *fmt, ...)
-{
-       int ret;
-       va_list arg;
-
-       va_start(arg, fmt);
-       ret = gmp_vfprintf(octx->output_fp, fmt, arg);
-       va_end(arg);
-       fflush(octx->output_fp);
-
-       return ret;
-}
-
diff --git a/src/print.c b/src/print.c
new file mode 100644 (file)
index 0000000..d1b25e8
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Phil Sutter <phil@nwl.cc>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <stdarg.h>
+#include <nftables.h>
+#include <utils.h>
+
+int nft_print(struct output_ctx *octx, const char *fmt, ...)
+{
+       int ret;
+       va_list arg;
+
+       va_start(arg, fmt);
+       ret = vfprintf(octx->output_fp, fmt, arg);
+       va_end(arg);
+       fflush(octx->output_fp);
+
+       return ret;
+}
+
+int nft_gmp_print(struct output_ctx *octx, const char *fmt, ...)
+{
+       int ret;
+       va_list arg;
+
+       va_start(arg, fmt);
+       ret = gmp_vfprintf(octx->output_fp, fmt, arg);
+       va_end(arg);
+       fflush(octx->output_fp);
+
+       return ret;
+}