mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 23:04:20 +01:00
324c278a31
git-svn-id: file:///svn/toku/tokudb@16673 c7de825b-a66e-492c-adef-691d508d4ae1
33 lines
757 B
C
33 lines
757 B
C
#include <toku_portability.h>
|
|
#include <windows.h>
|
|
#include <toku_stdlib.h>
|
|
#include <toku_assert.h>
|
|
|
|
int
|
|
setenv(const char *name, const char *value, int overwrite) {
|
|
char * current = getenv(name);
|
|
BOOL exists = current!=NULL;
|
|
|
|
int r;
|
|
if (overwrite || !exists) {
|
|
char setstring[sizeof("=") + strlen(name) + strlen(value)];
|
|
int bytes = snprintf(setstring, sizeof(setstring), "%s=%s", name, value);
|
|
assert(bytes>=0);
|
|
assert((size_t)bytes < sizeof(setstring));
|
|
r = _putenv(setstring);
|
|
if (r==-1) {
|
|
errno = GetLastError();
|
|
goto cleanup;
|
|
}
|
|
}
|
|
r = 0;
|
|
cleanup:
|
|
return r;
|
|
}
|
|
|
|
int
|
|
unsetenv(const char *name) {
|
|
int r = setenv(name, "", 1);
|
|
return r;
|
|
}
|
|
|