Use cpp_process func from cpp.c module to invoke
C preprocessor.
Signed-off-by: Vadim Kochan <[email protected]>
---
bpf_parser.y | 18 ++++++------------
bpfc/Makefile | 1 +
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/bpf_parser.y b/bpf_parser.y
index 8c09639..7b4fdc9 100644
--- a/bpf_parser.y
+++ b/bpf_parser.y
@@ -25,6 +25,7 @@
#include "bpf_parser.tab.h"
#include "built_in.h"
#include "die.h"
+#include "cpp.h"
int compile_filter(char *file, int verbose, int bypass, int format,
bool invoke_cpp);
@@ -744,20 +745,13 @@ int compile_filter(char *file, int verbose, int bypass,
int format,
memset(tmp_file, 0, sizeof(tmp_file));
if (invoke_cpp) {
- char cmd[256], *dir, *base, *a, *b;
-
- dir = dirname((a = xstrdup(file)));
- base = basename((b = xstrdup(file)));
-
- slprintf(tmp_file, sizeof(tmp_file), "%s/.tmp-%u-%s", dir,
rand(), base);
- slprintf(cmd, sizeof(cmd), "cpp -I" ETCDIRE_STRING " %s > %s",
- file, tmp_file);
- if (system(cmd) != 0)
- panic("Failed to invoke C preprocessor!\n");
+ ret = cpp_process(file, tmp_file, sizeof(tmp_file));
+ if (ret) {
+ fprintf(stderr, "Failed to invoke C preprocessor!\n");
+ goto exit;
+ }
file = tmp_file;
- xfree(a);
- xfree(b);
}
if (!strncmp("-", file, strlen("-")))
diff --git a/bpfc/Makefile b/bpfc/Makefile
index b687bd1..f011706 100644
--- a/bpfc/Makefile
+++ b/bpfc/Makefile
@@ -7,6 +7,7 @@ bpfc-objs = xmalloc.o \
bpf_parser.tab.o \
die.o \
sysctl.o \
+ cpp.o \
bpfc.o
bpfc-lex = bpf_lexer.yy.o
--
2.6.2
--
You received this message because you are subscribed to the Google Groups
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.