ReactOS 0.4.16-dev-959-g2ec3a19
spawnlp.cpp File Reference
#include <corecrt_internal.h>
#include <corecrt_internal_traits.h>
#include <stddef.h>
#include <process.h>
#include <stdarg.h>
Include dependency graph for spawnlp.cpp:

Go to the source code of this file.

Functions

template<typename Character >
static intptr_t __cdecl common_spawnlp (bool const pass_environment, int const mode, Character const *const file_name, Character const *const arguments, va_list varargs) throw ()
 
intptr_t _execlp (char const *const file_name, char const *const arguments,...)
 
intptr_t _execlpe (char const *const file_name, char const *const arguments,...)
 
intptr_t _spawnlp (int const mode, char const *const file_name, char const *const arguments,...)
 
intptr_t _spawnlpe (int const mode, char const *const file_name, char const *const arguments,...)
 
intptr_t _wexeclp (wchar_t const *const file_name, wchar_t const *const arguments,...)
 
intptr_t _wexeclpe (wchar_t const *const file_name, wchar_t const *const arguments,...)
 
intptr_t _wspawnlp (int const mode, wchar_t const *const file_name, wchar_t const *const arguments,...)
 
intptr_t _wspawnlpe (int const mode, wchar_t const *const file_name, wchar_t const *const arguments,...)
 

Function Documentation

◆ _execlp()

intptr_t _execlp ( char const *const  file_name,
char const *const  arguments,
  ... 
)

Definition at line 55 of file spawnlp.cpp.

59{
60 va_list varargs;
61 va_start(varargs, arguments);
62 return common_spawnlp(false, _P_OVERLAY, file_name, arguments, varargs);
63}
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91
static LPCWSTR file_name
Definition: protocol.c:147
#define _P_OVERLAY
Definition: port.h:372
static intptr_t __cdecl common_spawnlp(bool const pass_environment, int const mode, Character const *const file_name, Character const *const arguments, va_list varargs)
Definition: spawnlp.cpp:19

◆ _execlpe()

intptr_t _execlpe ( char const *const  file_name,
char const *const  arguments,
  ... 
)

Definition at line 65 of file spawnlp.cpp.

69{
70 va_list varargs;
71 va_start(varargs, arguments);
72 return common_spawnlp(true, _P_OVERLAY, file_name, arguments, varargs);
73}

◆ _spawnlp()

intptr_t _spawnlp ( int const  mode,
char const *const  file_name,
char const *const  arguments,
  ... 
)

Definition at line 75 of file spawnlp.cpp.

80{
81 va_list varargs;
82 va_start(varargs, arguments);
83 return common_spawnlp(false, mode, file_name, arguments, varargs);
84}
GLenum mode
Definition: glext.h:6217

◆ _spawnlpe()

intptr_t _spawnlpe ( int const  mode,
char const *const  file_name,
char const *const  arguments,
  ... 
)

Definition at line 86 of file spawnlp.cpp.

91{
92 va_list varargs;
93 va_start(varargs, arguments);
94 return common_spawnlp(true, mode, file_name, arguments, varargs);
95}

◆ _wexeclp()

intptr_t _wexeclp ( wchar_t const *const  file_name,
wchar_t const *const  arguments,
  ... 
)

Definition at line 99 of file spawnlp.cpp.

103{
104 va_list varargs;
105 va_start(varargs, arguments);
106 return common_spawnlp(false, _P_OVERLAY, file_name, arguments, varargs);
107}

◆ _wexeclpe()

intptr_t _wexeclpe ( wchar_t const *const  file_name,
wchar_t const *const  arguments,
  ... 
)

Definition at line 109 of file spawnlp.cpp.

113{
114 va_list varargs;
115 va_start(varargs, arguments);
116 return common_spawnlp(true, _P_OVERLAY, file_name, arguments, varargs);
117}

◆ _wspawnlp()

intptr_t _wspawnlp ( int const  mode,
wchar_t const *const  file_name,
wchar_t const *const  arguments,
  ... 
)

Definition at line 119 of file spawnlp.cpp.

124{
125 va_list varargs;
126 va_start(varargs, arguments);
127 return common_spawnlp(false, mode, file_name, arguments, varargs);
128}

◆ _wspawnlpe()

intptr_t _wspawnlpe ( int const  mode,
wchar_t const *const  file_name,
wchar_t const *const  arguments,
  ... 
)

Definition at line 130 of file spawnlp.cpp.

135{
136 va_list varargs;
137 va_start(varargs, arguments);
138 return common_spawnlp(true, mode, file_name, arguments, varargs);
139}

◆ common_spawnlp()

template<typename Character >
static intptr_t __cdecl common_spawnlp ( bool const  pass_environment,
int const  mode,
Character const *const  file_name,
Character const *const  arguments,
va_list  varargs 
)
throw (
)
static

Definition at line 19 of file spawnlp.cpp.

26{
27 typedef __crt_char_traits<Character> traits;
28
29 _VALIDATE_RETURN(file_name != nullptr, EINVAL, -1);
30 _VALIDATE_RETURN(file_name[0] != '\0', EINVAL, -1);
31 _VALIDATE_RETURN(arguments != nullptr, EINVAL, -1);
32 _VALIDATE_RETURN(arguments[0] != '\0', EINVAL, -1);
33
34 Character* arguments_buffer[64];
35 Character** const captured_arguments = traits::capture_argv(
36 &varargs,
37 arguments,
38 &arguments_buffer[0],
39 64);
40
41 _VALIDATE_RETURN_NOEXC(captured_arguments != nullptr, ENOMEM, -1);
42
43 __crt_unique_heap_ptr<Character*> const captured_arguments_cleanup(
44 captured_arguments == arguments_buffer ? nullptr : captured_arguments);
45
46 Character const* const* const environment = pass_environment
47 ? va_arg(varargs, Character const* const*)
48 : nullptr;
49
50 return traits::tspawnvpe(mode, file_name, captured_arguments, environment);
51}
#define EINVAL
Definition: acclib.h:90
#define ENOMEM
Definition: acclib.h:84
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
return nullptr
Definition: expand.cpp:78
#define _VALIDATE_RETURN_NOEXC(expr, errorcode, retexpr)

Referenced by _execlp(), _execlpe(), _spawnlp(), _spawnlpe(), _wexeclp(), _wexeclpe(), _wspawnlp(), and _wspawnlpe().