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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/* This is a kludge to get around the Microsoft C spawn functions' propensity
to remove the outermost set of double quotes from all arguements. */
#define index(s,c) strchr((s),(c))
extern char *xmalloc ();
const char * const *
fix_argv (argv)
char **argv;
{
static char sh_chars[] = "\"";
int i, len;
char *new_argv;
char *p, *ap;
for (i=1; argv[i]; i++)
{
len = strlen (argv[i]);
new_argv = xmalloc (2*len+3);
ap = new_argv;
*ap++ = '"';
for (p = argv[i]; *p != '\0'; ++p)
{
if (index (sh_chars, *p) != 0)
*ap++ = '\\';
*ap++ = *p;
}
*ap++ = '"';
*ap = '\0';
argv[i] = new_argv;
}
return (const char * const *) argv;
}
int spawnv (mode, cmdname, argv)
int mode;
const char *cmdname;
char **argv;
{
_spawnv (mode, cmdname, fix_argv (argv));
}
int spawnvp (mode, cmdname, argv)
int mode;
const char *cmdname;
char **argv;
{
_spawnvp (mode, cmdname, fix_argv (argv));
}
int spawnve (mode, cmdname, argv, envp)
int mode;
const char *cmdname;
char **argv;
const char *const *envp;
{
_spawnve (mode, cmdname, fix_argv (argv), envp);
}
int spawnvpe (mode, cmdname, argv, envp)
int mode;
const char *cmdname;
char **argv;
const char *const *envp;
{
_spawnvpe (mode, cmdname, fix_argv (argv), envp);
}
|