home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
gcc-2.7.2.1-base.tgz
/
gcc-2.7.2.1-base.tar
/
fsf
/
gcc
/
config
/
winnt
/
spawnv.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-12
|
1KB
|
72 lines
/* This is a kludge to get around the Microsoft C spawn functions' propensity
to remove the outermost set of double quotes from all arguments. */
#define index(s,c) strchr((s),(c))
extern char *malloc ();
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 = malloc (2*len+3);
ap = new_argv;
for (p = argv[i]; *p != '\0'; ++p)
{
if (index (sh_chars, *p) != 0)
*ap++ = '\\';
*ap++ = *p;
}
*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);
}