/*** *execl.c - execute a file with a list of arguments * * Copyright (c) Microsoft Corporation. All rights reserved. * *Purpose: * defines _execl() - execute a file with a list of arguments * *******************************************************************************/ #include #include #include #include #include #include #include /*** *int _execl(filename, arglist) - execute a file with arg list * *Purpose: * Transform the argument list so it is a vector, then pass its address * to execve. Use a pointer to the default environment vector. * *Entry: * _TSCHAR *filename - file to execute * _TSCHAR *arglist - list of arguments * call as _execl(path, arg0, arg1, ..., argn, NULL); * *Exit: * destroys the calling process, hopefully * returns -1 if fails * *Exceptions: * *******************************************************************************/ intptr_t __cdecl _texecl ( const _TSCHAR *filename, const _TSCHAR *arglist, ... ) { #ifdef _M_IX86 /* validation section */ _VALIDATE_RETURN(filename != NULL, EINVAL, -1); _VALIDATE_RETURN(*filename != _T('\0'), EINVAL, -1); _VALIDATE_RETURN(arglist != NULL, EINVAL, -1); _VALIDATE_RETURN(*arglist != _T('\0'), EINVAL, -1); return(_texecve(filename,&arglist,NULL)); #else /* _M_IX86 */ va_list vargs; _TSCHAR * argbuf[64]; _TSCHAR ** argv; intptr_t result; /* validation section */ _VALIDATE_RETURN(filename != NULL, EINVAL, -1); _VALIDATE_RETURN(*filename != _T('\0'), EINVAL, -1); _VALIDATE_RETURN(arglist != NULL, EINVAL, -1); _VALIDATE_RETURN(*arglist != _T('\0'), EINVAL, -1); va_start(vargs, arglist); #ifdef WPRFLAG argv = _wcapture_argv(&vargs, arglist, argbuf, 64); #else /* WPRFLAG */ argv = _capture_argv(&vargs, arglist, argbuf, 64); #endif /* WPRFLAG */ va_end(vargs); result = _texecve(filename,argv,NULL); if (argv && argv != argbuf) _free_crt(argv); return result; #endif /* _M_IX86 */ }