#include <corecrt_internal.h>
#include <corecrt_internal_traits.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
◆ _putenv()
Definition at line 222 of file putenv.cpp.
223{
225}
static int __cdecl common_putenv(Character const *const name, Character const *const value)
◆ _putenv_s()
Definition at line 234 of file putenv.cpp.
235{
238}
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
◆ _wputenv()
◆ _wputenv_s()
◆ common_putenv()
Definition at line 199 of file putenv.cpp.
203{
205
208 {
210 }
212 {
214 }
216
218}
void __cdecl __acrt_unlock(_In_ __acrt_lock_id lock)
@ __acrt_environment_lock
__acrt_lock(__acrt_heap_lock)
static int __cdecl common_putenv_nolock(Character const *const name, Character const *const value)
Referenced by _putenv(), _putenv_s(), _wputenv(), and _wputenv_s().
◆ common_putenv_nolock()
Definition at line 161 of file putenv.cpp.
165{
167
168
170 return -1;
171
172
173
174
175
177
179 if (!new_option)
180 return -1;
181
182 if (traits::set_variable_in_environment_nolock(new_option.detach(), 1) != 0)
183 return -1;
184
185
186
188 return 0;
189
191 return -1;
192
193 return 0;
194}
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
__crt_state_management::dual_state_global< wchar_t ** > _wenviron_table
__crt_state_management::dual_state_global< char ** > _environ_table
static bool __cdecl set_variable_in_other_environment(Character const *const name, Character const *const value)
static Character * create_environment_string(Character const *const name, Character const *const value)
static bool other_environment_exists(wchar_t)
Referenced by common_putenv().
◆ compute_required_transform_buffer_count()
Definition at line 25 of file putenv.cpp.
29{
30
33
35 return name_count_required;
36
39
40
41
42
43 return name_count_required + value_count_required;
44}
size_t __crt_compute_required_transform_buffer_count(unsigned const code_page, _In_z_ char const *const string)
#define _VALIDATE_RETURN_NOEXC(expr, errorcode, retexpr)
Referenced by set_variable_in_other_environment().
◆ create_environment_string()
static Character * create_environment_string |
( |
Character const *const |
name, |
|
|
Character const *const |
value |
|
) |
| |
throw | ( | |
| ) | | |
|
static |
Definition at line 52 of file putenv.cpp.
56{
58
60 {
61 size_t const name_length = traits::tcsnlen(
name,
_MAX_ENV);
63
66
67
68 size_t const buffer_count = name_length + 1 + value_length + 1;
69
72 return nullptr;
73
75 buffer.get()[name_length] =
'=';
76 traits::tcscpy_s(
buffer.get() + name_length + 1, value_length + 1,
value);
77
79 }
80 else
81 {
82 Character
const*
const equal_sign_it = traits::tcschr(
name,
'=');
83 if (equal_sign_it)
84 {
85
88 }
89
91
94 return nullptr;
95
97
99 }
100}
size_t const buffer_count
Referenced by common_putenv_nolock().
◆ other_environment_exists() [1/2]
static bool other_environment_exists |
( |
char |
| ) |
|
throw | ( | |
| ) | | |
|
static |
◆ other_environment_exists() [2/2]
static bool other_environment_exists |
( |
wchar_t |
| ) |
|
throw | ( | |
| ) | | |
|
static |
◆ set_variable_in_other_environment()
Definition at line 107 of file putenv.cpp.
111{
113 typedef typename traits::other_char_type other_char_type;
115
117
118 __crt_unique_heap_ptr<other_char_type>
buffer(_calloc_crt_t(other_char_type,
buffer_count));
120 return false;
121
124
126 {
127
128 buffer.get()[name_written_count - 1] =
'=';
129
130 size_t const value_written_count = __crt_transform_string(
133 buffer.get() + name_written_count,
136 }
137
138 return other_traits::set_variable_in_environment_nolock(
buffer.detach(), 0) == 0;
139}
static size_t compute_required_transform_buffer_count(Character const *const name, Character const *const value)
Referenced by common_putenv_nolock().