3 Implement setenv and friends for MinGW
6 http://www.hmug.org/man/3/setenv.php
7 MSDN SetEnvironmentVariable
8 http://msdn2.microsoft.com/en-us/library/ms686206.aspx
11 getenv(const char *name);
14 setenv(const char *name, const char *value, int overwrite);
17 putenv(const char *string);
20 unsetenv(const char *name);
25 /*char * getenv(const char *name);*/
26 int setenv(const char *name
, const char *value
, int overwrite
);
27 /*int putenv(const char *string);*/
28 void unsetenv(const char *name
);
32 /* inserts or resets the environment variable name in the current environment
35 If the variable name does not exist in the list, it is inserted with the
38 If the variable does exist, the argument overwrite is tested;
39 if overwrite is zero, the variable is not reset,
40 otherwise it is reset to the given value.
42 return the value 0 if successful;
43 otherwise the value -1 is returned and the global variable errno is set
44 to indicate the error.
46 int setenv(const char *name
, const char *value
, int overwrite
) {
47 /* bug: ALWAYS OVERWRITE */
48 return SetEnvironmentVariable(name
, value
) != 0 ? 0 /* OK */ : -1 /* FAIL */;
51 void unsetenv(const char *name
) {
52 SetEnvironmentVariable(name
, NULL
);