netsniff-ng: nlmsg: Print genl ops & mcast groups attributes
[netsniff-ng.git] / cpp.c
blob6734eac3509dfe313f27e19de277446299a45bc5
1 #include <stdio.h>
2 #include <libgen.h>
4 #include "str.h"
5 #include "xmalloc.h"
7 int cpp_exec(char *in_file, char *out_file, size_t out_len)
9 char *tmp = xstrdup(in_file);
10 char cmd[256], *base;
11 int ret = 0;
13 base = basename(tmp);
15 slprintf(out_file, out_len, "/tmp/.tmp-%u-%s", rand(), base);
16 slprintf(cmd, sizeof(cmd), "cpp -I" ETCDIRE_STRING " %s > %s",
17 in_file, out_file);
19 if (system(cmd) != 0)
20 ret = -1;
22 xfree(tmp);
23 return ret;