home *** CD-ROM | disk | FTP | other *** search
- /***
- *execl.c - execute a file with a list of arguments
- *
- * Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
- *
- *Purpose:
- * defines _execl() - execute a file with a list of arguments
- *
- *******************************************************************************/
-
- #include <cruntime.h>
- #include <stdlib.h>
- #include <process.h>
- #include <stdarg.h>
- #include <internal.h>
- #include <tchar.h>
- #include <dbgint.h>
-
- /***
- *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:
- *
- *******************************************************************************/
-
- int __cdecl _texecl (
- const _TSCHAR *filename,
- const _TSCHAR *arglist,
- ...
- )
- {
- #ifdef _M_IX86
-
- _ASSERTE(filename != NULL);
- _ASSERTE(*filename != _T('\0'));
- _ASSERTE(arglist != NULL);
- _ASSERTE(*arglist != _T('\0'));
-
- return(_texecve(filename,&arglist,NULL));
-
- #else /* _M_IX86 */
-
- va_list vargs;
- _TSCHAR * argbuf[64];
- _TSCHAR ** argv;
- int result;
-
- _ASSERTE(filename != NULL);
- _ASSERTE(*filename != _T('\0'));
- _ASSERTE(arglist != NULL);
- _ASSERTE(*arglist != _T('\0'));
-
- 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 */
- }
-