5ccacf6d4b736a7f636ee7930038425da84a8614
[reactos.git] / lib / crtdll / process / execle.c
1 #include <msvcrt/process.h>
2 #include <msvcrt/stdlib.h>
3 #include <msvcrt/stdarg.h>
4
5
6 // fixme rewrite to pass the array variants to va_list variant
7
8 int _execle(const char *path, const char *szArgv0, ... /*, const char **envp */)
9 {
10   char *szArg[100];
11   const char *a;
12   char *ptr;
13   int i = 0;
14   va_list l = 0;
15   va_start(l,szArgv0);
16   do {
17         a = (const char *)va_arg(l,const char *);
18         szArg[i++] = (char *)a;
19   } while ( a != NULL && i < 100 );
20
21
22 // szArg0 is passed and not environment if there is only one parameter;
23
24   if ( i >=2 ) {
25         ptr = szArg[i-2];
26         szArg[i-2] = NULL;
27   }
28   else
29         ptr = NULL;
30
31
32   return _spawnve(P_OVERLAY, path, (char * const *)szArg, (char * const *)ptr);
33 }