added wxGet/Set/UnsetEnv() for Unix

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8837 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-11-26 22:46:35 +00:00
parent b855ef7757
commit 8fd0d89b7d
7 changed files with 327 additions and 187 deletions

View File

@@ -869,6 +869,33 @@ long wxGetFreeMemory()
return -1;
}
// ----------------------------------------------------------------------------
// env vars
// ----------------------------------------------------------------------------
bool wxSetEnv(const wxString& variable, const wxChar *value)
{
#if defined(HAVE_SETENV)
return setenv(variable.mb_str(), value ? wxString(value).mb_str().data()
: NULL, 1 /* overwrite */) == 0;
#elif defined(HAVE_PUTENV)
wxString s = variable;
if ( value )
s << _T('=') << value;
// transform to ANSI
const char *p = s.mb_str();
// the string will be free()d by libc
char *buf = (char *)malloc(strlen(p) + 1);
strcpy(buf, p);
return putenv(buf) == 0;
#else // no way to set an env var
return FALSE;
#endif
}
// ----------------------------------------------------------------------------
// signal handling
// ----------------------------------------------------------------------------