Commit 2f3b2ec5 authored by Mike Bond's avatar Mike Bond Committed by Alexandre Julliard

Implementation of spawnl and spawnlp.

parent 6d3e81b9
......@@ -442,9 +442,9 @@ debug_channels (msvcrt)
@ varargs _snprintf(str long str) snprintf
@ forward -noimport _snwprintf ntdll._snwprintf
@ cdecl _sopen(str long long) MSVCRT__sopen
@ stub _spawnl #(str str) varargs
@ varargs _spawnl(str str) _spawnl
@ stub _spawnle #(str str) varargs
@ stub _spawnlp #(str str) varargs
@ varargs _spawnlp(str str) _spawnlp
@ stub _spawnlpe #(str str) varargs
@ cdecl _spawnv(long str ptr) _spawnv
@ cdecl _spawnve(long str ptr ptr) _spawnve
......
......@@ -109,6 +109,45 @@ static char* msvcrt_argvtos(const char* const* arg, char delim)
return ret;
}
/* INTERNAL: Convert va_list to a single 'delim'-separated string */
static char* msvcrt_valisttos(const char* arg0, va_list ap, char delim)
{
va_list search = ap;
long size;
char *arg;
char *ret;
int strsize;
if (!arg0 && !delim)
return NULL;
/* get length */
size = strlen(arg0) + 1;
while((arg = va_arg(search, char *)) != NULL)
{
size += strlen(arg) + 1;
}
if (!(ret = (char *)MSVCRT_calloc(size + 1, 1)))
return NULL;
/* fill string */
search = ap;
size = 0;
strsize = strlen(arg0);
memcpy(ret+size,arg0,strsize);
ret[size+strsize] = delim;
size += strsize + 1;
while((arg = va_arg(search, char *)) != NULL)
{
strsize = strlen(search);
memcpy(ret+size,search,strsize);
ret[size+strsize] = delim;
size += strsize + 1;
}
return ret;
}
/*********************************************************************
* _cwait (MSVCRT.@)
*/
......@@ -143,6 +182,47 @@ int _cwait(int *status, int pid, int action)
}
/*********************************************************************
* _spawnl (MSVCRT.@)
*/
int _spawnl(int flags, const char* name, const char* arg0, ...)
{
va_list ap;
char * args;
int ret;
va_start(ap, arg0);
args = msvcrt_valisttos(arg0, ap, ' ');
va_end(ap);
ret = msvcrt_spawn(flags, name, args, NULL);
MSVCRT_free(args);
return ret;
}
/*********************************************************************
* _spawnl (MSVCRT.@)
*/
int _spawnlp(int flags, const char* name, const char* arg0, ...)
{
va_list ap;
char * args;
int ret;
char fullname[MAX_PATH];
_searchenv(name, "PATH", fullname);
va_start(ap, arg0);
args = msvcrt_valisttos(arg0, ap, ' ');
va_end(ap);
ret = msvcrt_spawn(flags, name, args, NULL);
MSVCRT_free(args);
return ret;
}
/*********************************************************************
* _spawnve (MSVCRT.@)
*/
int _spawnve(int flags, const char* name, const char* const* argv,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment