1#include <stdlib.h>
2#include <stdio.h>
3#include <string.h>
4
5#ifdef _WIN32
6int setenv(const char *name, const char *value, int overwrite)
7{
8    int result = 0;
9    if (overwrite || !getenv(name)) {
10        size_t length = strlen(name) + strlen(value) + 2;
11        char *string = malloc(length);
12        snprintf(string, length, "%s=%s", name, value);
13        result = putenv(string);
14    }
15    return result;
16}
17
18#endif
19