das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
das3
win_env.h
1
/* Replacements for setenv, unsetenv on windows */
2
3
/* Add #include <stdlib.h> to your function to then include this in your
4
module implementation file (*.c) not in a header */
5
6
int
setenv(
const
char
*name,
const
char
*value,
int
overwrite)
7
{
8
int
errcode = 0;
9
if
(!overwrite) {
10
size_t
envsize = 0;
11
errcode = getenv_s(&envsize, NULL, 0, name);
12
if
(errcode || envsize)
return
errcode;
13
}
14
return
_putenv_s(name, value);
15
}
16
17
int
unsetenv(
const
char
*name)
18
{
19
const
char
* value =
""
;
20
return
_putenv_s(name, value);
// empty string removes the value
21
}
Generated by
1.9.8