summaryrefslogtreecommitdiff
path: root/cpp.c
blob: 8e03209604f61468a33a50c1d7315be723a2e9a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <libgen.h>

#include "str.h"
#include "proc.h"
#include "xmalloc.h"

static size_t argv_len(char **argv)
{
	size_t len = 0;

	for (; argv && *argv; argv++)
		len++;

	return len;
}

int cpp_exec(char *in_file, char *out_file, size_t out_len, char **argv)
{
	size_t argc = 7 + argv_len(argv);
	char *tmp = xstrdup(in_file);
	char **cpp_argv;
	int ret = 0;
	char *base;
	unsigned int i = 0;

	base = basename(tmp);
	slprintf(out_file, out_len, "/tmp/.tmp-%u-%s", rand(), base);

	cpp_argv = xmalloc(argc * sizeof(char *));

	cpp_argv[i++] = "cpp";

	for (; argv && *argv; argv++, i++)
		cpp_argv[i] = *argv;

	cpp_argv[i++] = "-I";
	cpp_argv[i++] = ETCDIRE_STRING;
	cpp_argv[i++] = "-o";
	cpp_argv[i++] = out_file;
	cpp_argv[i++] = in_file;
	cpp_argv[i++] = NULL;

	if (proc_exec("cpp", cpp_argv))
		ret = -1;

	xfree(cpp_argv);
	xfree(tmp);
	return ret;
}
8df5'>diff)parentce1ca7d2d140a1f4aaffd297ac487f246963dd2f (diff)
Merge tag 'nfsd-4.10-1' of git://linux-nfs.org/~bfields/linux
Pull nfsd fixes from Bruce Fields: "Miscellaneous nfsd bugfixes, one for a 4.10 regression, three for older bugs" * tag 'nfsd-4.10-1' of git://linux-nfs.org/~bfields/linux: svcrdma: avoid duplicate dma unmapping during error recovery sunrpc: don't call sleeping functions from the notifier block callbacks svcrpc: don't leak contexts on PROC_DESTROY nfsd: fix supported attributes for acl & labels
Diffstat (limited to 'sound/usb/hiface')