/*--------------------------------------------------------------------------*/ BOOL Set_HOME_PATH(char *DefaultPath) { wchar_t *wHOME = _wgetenv(L"HOME"); if (wHOME == NULL) { wchar_t *wUserProfile = _wgetenv(L"USERPROFILE"); if (wUserProfile) { return SetEnvironmentVariableW(L"HOME", wUserProfile); } else { /* if USERPROFILE is not defined , we use default profile */ wchar_t *wAllUsersProfile = _wgetenv(L"ALLUSERSPROFILE"); if (wAllUsersProfile) { return SetEnvironmentVariableW(L"HOME", wUserProfile); } else { BOOL bRes = FALSE; wchar_t *wDefault = to_wide_string(DefaultPath); if (wDefault) { bRes = SetEnvironmentVariableW(L"HOME", wDefault); FREE(wDefault); wDefault = NULL; } return bRes; } } } return TRUE; }
std::wstring FindPython() { #pragma warning(suppress:4996) PCWSTR const pytwoseven = _wgetenv( L"python27" ); //Some people, like me, (Alexander Riccio) have an environment variable //that specifically points to Python 2.7. //As a workaround for issue #13, we'll use that version of Python. //See the issue: https://github.com/google/UIforETW/issues/13 if ( pytwoseven ) { return pytwoseven; } #pragma warning(suppress:4996) const wchar_t* path = _wgetenv(L"path"); if (path) { std::vector<std::wstring> pathParts = split(path, ';'); for (const auto& part : pathParts) { std::wstring pythonPath = part + L"\\python.exe"; if (PathFileExists(pythonPath.c_str())) { return pythonPath; } } } // No python found. return L""; }
int setenv(const char* name, const char* value, int overwrite) { if (overwrite == 0 && getenv(name) != nullptr) { return 0; } if (*value != '\0') { auto e = _putenv_s(name, value); if (e != 0) { errno = e; return -1; } return 0; } // We are trying to set the value to an empty string, but // _putenv_s deletes entries if the value is an empty string, // and just calling SetEnvironmentVariableA doesn't update // _environ, so we have to do these terrible things. if (_putenv_s(name, " ") != 0) { errno = EINVAL; return -1; } // Here lies the documentation we blatently ignore to make // this work >_>... *getenv(name) = '\0'; // This would result in a double null termination, which // normally signifies the end of the environment variable // list, so we stick a completely empty environment variable // into the list instead. *(getenv(name) + 1) = '='; // If _wenviron is null, the wide environment has not been initialized // yet, and we don't need to try to update it. // We have to do this otherwise we'd be forcing the initialization and // maintenance of the wide environment even though it's never actually // used in most programs. if (_wenviron != nullptr) { wchar_t buf[_MAX_ENV + 1]; size_t len; if (mbstowcs_s(&len, buf, _MAX_ENV + 1, name, _MAX_ENV) != 0) { errno = EINVAL; return -1; } *_wgetenv(buf) = u'\0'; *(_wgetenv(buf) + 1) = u'='; } // And now, we have to update the outer environment to have // a proper empty value. if (!SetEnvironmentVariableA(name, value)) { errno = EINVAL; return -1; } return 0; }
std::string FileUtils::system_temporary_dir() { #ifdef _WIN32 const wchar_t *value; std::wstring w_path; std::string path; if ((value = _wgetenv(L"TMP")) && directory_exists(value)) { w_path = value; goto done; } if ((value = _wgetenv(L"TEMP")) && directory_exists(value)) { w_path = value; goto done; } if ((value = _wgetenv(L"LOCALAPPDATA"))) { w_path = value; w_path += L"\\Temp"; if (directory_exists(w_path.c_str())) { goto done; } } if ((value = _wgetenv(L"USERPROFILE"))) { w_path = value; w_path += L"\\Temp"; if (directory_exists(w_path.c_str())) { goto done; } } done: auto result = wcs_to_utf8(w_path); return result ? std::move(result.value()) : std::string(); #else const char *value; if ((value = getenv("TMPDIR")) && directory_exists(value)) { return value; } if ((value = getenv("TMP")) && directory_exists(value)) { return value; } if ((value = getenv("TEMP")) && directory_exists(value)) { return value; } if ((value = getenv("TEMPDIR")) && directory_exists(value)) { return value; } return "/tmp"; #endif }
HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */) { QStringList searchOrder; #if !defined(QT_BOOTSTRAPPED) if (!onlySystemDirectory) searchOrder << QFileInfo(qAppFileName()).path(); #endif searchOrder << qSystemDirectory(); if (!onlySystemDirectory) { const QString PATH = QString::fromWCharArray((const wchar_t *)_wgetenv(L"PATH")); searchOrder << PATH.split(QLatin1Char(';'), QString::SkipEmptyParts); } const QString fileName = QString::fromWCharArray(libraryName) + QLatin1String(".dll"); // Start looking in the order specified for (int i = 0; i < searchOrder.count(); ++i) { QString fullPathAttempt = searchOrder.at(i); if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) fullPathAttempt.append(QLatin1Char('\\')); fullPathAttempt.append(fileName); HINSTANCE inst = ::LoadLibrary((const wchar_t *)fullPathAttempt.utf16()); if (inst != 0) return inst; } return 0; }
void ResourceFinder::includeHomeDir(const char* filename) { #ifdef _WIN32 // %AppData%/Aseprite/filename wchar_t* env = _wgetenv(L"AppData"); if (env) { std::string path = base::join_path(base::to_utf8(env), "Aseprite"); path = base::join_path(path, filename); addPath(path); m_default = path; } #else char* env = std::getenv("HOME"); char buf[4096]; if ((env) && (*env)) { // $HOME/filename sprintf(buf, "%s/%s", env, filename); addPath(buf); } else { LOG("You don't have set $HOME variable\n"); addPath(filename); } #endif }
static const wchar_t *_getopt_initialize_w ( const wchar_t *optstring, struct _getopt_data_w *d, int posixly_correct ) { d->__first_nonopt = d->__last_nonopt = d->optind; d->__nextchar = NULL; d->__posixly_correct = posixly_correct | !!_wgetenv ( L"POSIXLY_CORRECT" ); if ( optstring[0] == L'-' ) { d->__ordering = RETURN_IN_ORDER; ++optstring; } else if ( optstring[0] == L'+' ) { d->__ordering = REQUIRE_ORDER; ++optstring; } else if ( d->__posixly_correct ) { d->__ordering = REQUIRE_ORDER; } else { d->__ordering = PERMUTE; } return optstring; }
static int win32_find_git_in_path(git_buf *buf, const wchar_t *gitexe, const wchar_t *subdir) { wchar_t *env = _wgetenv(L"PATH"), lastch; _findfile_path root; size_t gitexe_len = wcslen(gitexe); if (!env) return -1; while ((env = win32_walkpath(env, root.path, MAX_PATH-1)) && *root.path) { root.len = (DWORD)wcslen(root.path); lastch = root.path[root.len - 1]; /* ensure trailing slash (MAX_PATH-1 to walkpath guarantees space) */ if (lastch != L'/' && lastch != L'\\') { root.path[root.len++] = L'\\'; root.path[root.len] = L'\0'; } if (root.len + gitexe_len >= MAX_PATH) continue; wcscpy(&root.path[root.len], gitexe); if (_waccess(root.path, F_OK) == 0 && root.len > 5) { /* replace "bin\\" or "cmd\\" with subdir */ wcscpy(&root.path[root.len - 4], subdir); win32_path_to_8(buf, root.path); return 0; } } return GIT_ENOTFOUND; }
GetEnvironmentString (/*[in]*/ const char * lpszName, /*[in]*/ string & value) { #if defined(MIKTEX_WINDOWS) wchar_t * lpszValue = _wgetenv(UW_(lpszName)); if (lpszValue == 0) { return (false); } else { value = WU_(lpszValue); return (true); } #else const char * lpszValue = getenv(lpszName); if (lpszValue == 0) { return (false); } else { value = lpszValue; return (true); } #endif }
void ReadALConfig(void) { WCHAR buffer[PATH_MAX]; const WCHAR *str; FILE *f; if(SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE) { size_t p = lstrlenW(buffer); _snwprintf(buffer+p, PATH_MAX-p, L"\\alsoft.ini"); TRACE("Loading config %ls...\n", buffer); f = _wfopen(buffer, L"rt"); if(f) { LoadConfigFromFile(f); fclose(f); } } if((str=_wgetenv(L"ALSOFT_CONF")) != NULL && *str) { TRACE("Loading config %ls...\n", str); f = _wfopen(str, L"rt"); if(f) { LoadConfigFromFile(f); fclose(f); } } }
/* utf8 version of getenv, needed to get win32 filename paths */ char * getenv_utf8(const char *varname) { char *envvar; wchar_t *envvarw; wchar_t *varnamew; envvar = getenv(varname); /* since GLib 2.6 we need an utf8 version of the filename */ /* using the wide char version of getenv should work under all circumstances */ /* convert given varname to utf16, needed by _wgetenv */ varnamew = g_utf8_to_utf16(varname, -1, NULL, NULL, NULL); if (varnamew == NULL) { return envvar; } /* use wide char version of getenv */ envvarw = _wgetenv(varnamew); g_free(varnamew); if (envvarw == NULL) { return envvar; } /* convert value to utf8 */ envvar = g_utf16_to_utf8(envvarw, -1, NULL, NULL, NULL); /* XXX - memleak */ return envvar; }
RTDECL(int) RTEnvGetUtf8(const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual) { AssertPtrReturn(pszVar, VERR_INVALID_POINTER); AssertPtrNullReturn(pszValue, VERR_INVALID_POINTER); AssertReturn(pszValue || !cbValue, VERR_INVALID_PARAMETER); AssertPtrNullReturn(pcchActual, VERR_INVALID_POINTER); AssertReturn(pcchActual || (pszValue && cbValue), VERR_INVALID_PARAMETER); AssertReturn(strchr(pszVar, '=') == NULL, VERR_ENV_INVALID_VAR_NAME); if (pcchActual) *pcchActual = 0; PRTUTF16 pwszVar; int rc = RTStrToUtf16(pszVar, &pwszVar); AssertRCReturn(rc, rc); /** @todo Consider _wgetenv_s or GetEnvironmentVariableW here to avoid the * potential race with a concurrent _wputenv/_putenv. */ PCRTUTF16 pwszValue = _wgetenv(pwszVar); RTUtf16Free(pwszVar); if (pwszValue) { if (cbValue) rc = RTUtf16ToUtf8Ex(pwszValue, RTSTR_MAX, &pszValue, cbValue, pcchActual); else rc = RTUtf16CalcUtf8LenEx(pwszValue, RTSTR_MAX, pcchActual); } else rc = VERR_ENV_VAR_NOT_FOUND; return rc; }
static void calculate_init(PyCalculatePath *calculate, const _PyCoreConfig *core_config) { calculate->home = core_config->home; calculate->path_env = _wgetenv(L"PATH"); }
int win32_find_system_file_using_path(git_buf *path, const char *filename) { wchar_t * env = NULL; struct win32_path root; env = _wgetenv(L"PATH"); if (!env) return -1; // search in all paths defined in PATH while ((env = win32_nextpath(env, root.path, MAX_PATH - 1)) != NULL && *root.path) { wchar_t * pfin = root.path + wcslen(root.path) - 1; // last char of the current path entry // ensure trailing slash if (*pfin != L'/' && *pfin != L'\\') wcscpy(++pfin, L"\\"); // we have enough space left, MAX_PATH - 1 is used in nextpath above root.len = (DWORD)wcslen(root.path) + 1; if (win32_find_file(path, &root, "git.cmd") == 0 || win32_find_file(path, &root, "git.exe") == 0) { // we found the cmd or bin directory of a git installaton if (root.len > 5) { wcscpy(root.path + wcslen(root.path) - 4, L"etc\\"); if (win32_find_file(path, &root, filename) == 0) return 0; } } } return GIT_ENOTFOUND; }
/* used by shell.exec() with rhome=FALSE. 2.13.0 and earlier were like rhome=TRUE, but without fixing the path */ static void internal_shellexecW(const wchar_t * file, Rboolean rhome) { const wchar_t *home; wchar_t home2[10000], *p; uintptr_t ret; if (rhome) { home = _wgetenv(L"R_HOME"); if (home == NULL) error(_("R_HOME not set")); wcsncpy(home2, home, 10000); for(p = home2; *p; p++) if(*p == L'/') *p = L'\\'; home = home2; } else home = NULL; ret = (uintptr_t) ShellExecuteW(NULL, L"open", file, NULL, home, SW_SHOW); if(ret <= 32) { /* an error condition */ if(ret == ERROR_FILE_NOT_FOUND || ret == ERROR_PATH_NOT_FOUND || ret == SE_ERR_FNF || ret == SE_ERR_PNF) error(_("'%ls' not found"), file); if(ret == SE_ERR_ASSOCINCOMPLETE || ret == SE_ERR_NOASSOC) error(_("file association for '%ls' not available or invalid"), file); if(ret == SE_ERR_ACCESSDENIED || ret == SE_ERR_SHARE) error(_("access to '%ls' denied"), file); error(_("problem in displaying '%ls'"), file); } }
BOOL CSpecialApp::ScanXunleiSearch(int iType) { KSearchSoftwareStruct sss; std::vector<std::wstring>::iterator it; WCHAR szPath[MAX_PATH] = {0}; sss.pszMainFileName = TEXT( "Program\\thunder.exe" ); sss.hRegRootKey = HKEY_LOCAL_MACHINE; sss.pszRegSubKey = TEXT( "SOFTWARE\\Thunder Network\\ThunderOem\\thunder_backwnd" ); sss.pszPathValue = TEXT( "dir" ); sss.bFolder = TRUE; BOOL bRet = FALSE; std::wstring str; std::wstring strPath; std::wstring strTemp; bRet = SearchSoftwarePath( &sss, strPath); wcscpy_s(szPath, MAX_PATH - 1, strPath.c_str()); PathRemoveFileSpec(szPath); PathRemoveFileSpec(szPath); PathAppend(szPath, L"Profiles\\GougouSearch\\history.history"); strPath = szPath; if (GetFileAttributes(strPath.c_str()) == INVALID_FILE_ATTRIBUTES) { WCHAR* pEnv = NULL; WCHAR szPath[MAX_PATH] = {0}; pEnv = _wgetenv(_T("public")); if (pEnv != NULL) { wcscpy(szPath, pEnv); PathAppend(szPath, L"Documents\\Thunder Network\\Thunder\\Profiles\\GougouSearch\\history.history"); strPath = szPath; } else { return TRUE; } } g_fnScanFile(g_pMain, BEGINPROC(XUNLEI7_DOWNLOADER), 0, 0, 0); for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ ) { str = *it; transform(str.begin(), str.end(), str.begin(), towlower); if (str == L"thunder.exe") { str = L"正在运行,跳过"; goto clean0; } } str = L""; if (m_bScan) { ModifyTxtData(iType, strPath.c_str()); // m_appHistory.CommfunFile(KUWOMUSIC_PLAYER, strPath.c_str(), vec_file); } clean0: g_fnScanFile(g_pMain, ENDPROC(XUNLEI7_DOWNLOADER), str.c_str(), 0, 0); return TRUE; }
bool Renderer::initializeCompiler() { TRACE_EVENT0("gpu", "initializeCompiler"); #if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES) // Find a D3DCompiler module that had already been loaded based on a predefined list of versions. static TCHAR* d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES; for (size_t i = 0; i < ArraySize(d3dCompilerNames); ++i) { if (GetModuleHandleEx(0, d3dCompilerNames[i], &mD3dCompilerModule)) { break; } } #endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES // Load the compiler DLL specified by the environment, or default to QT_D3DCOMPILER_DLL #if !defined(ANGLE_OS_WINRT) const wchar_t *defaultCompiler = _wgetenv(L"QT_D3DCOMPILER_DLL"); if (!defaultCompiler) defaultCompiler = QT_D3DCOMPILER_DLL; #else // !ANGLE_OS_WINRT # ifdef _DEBUG const wchar_t *defaultCompiler = L"d3dcompiler_qtd.dll"; # else const wchar_t *defaultCompiler = L"d3dcompiler_qt.dll"; # endif #endif // ANGLE_OS_WINRT const wchar_t *compilerDlls[] = { defaultCompiler, L"d3dcompiler_47.dll", L"d3dcompiler_46.dll", L"d3dcompiler_45.dll", L"d3dcompiler_44.dll", L"d3dcompiler_43.dll", 0 }; // Load the first available known compiler DLL for (int i = 0; compilerDlls[i]; ++i) { // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with. mD3dCompilerModule = LoadLibrary(compilerDlls[i]); if (mD3dCompilerModule) break; } if (!mD3dCompilerModule) { ERR("No D3D compiler module found - aborting!\n"); return false; } mD3DCompileFunc = reinterpret_cast<pCompileFunc>(GetProcAddress(mD3dCompilerModule, "D3DCompile")); ASSERT(mD3DCompileFunc); return mD3DCompileFunc != NULL; }
void CMirageManager::WriteDiagnostics(const std::wstring& data) { std::wstring sFileName(_wgetenv(_T("APPDATA"))); sFileName.append(_T("\\Dimdim\\DriverDiagnostics.info")); FILE* fout = _wfopen(sFileName.c_str(), _T("a+")); fwprintf(fout, _T("%s\n"), data.c_str()); fclose(fout); }
std::string FileUtils::systemTemporaryDir() { #ifdef _WIN32 const wchar_t *value; if ((value = _wgetenv(L"TMP")) && directoryExists(value)) { return utf8::utf16ToUtf8(value); } if ((value = _wgetenv(L"TEMP")) && directoryExists(value)) { return utf8::utf16ToUtf8(value); } if ((value = _wgetenv(L"LOCALAPPDATA"))) { std::wstring path(value); path += L"\\Temp"; if (directoryExists(path.c_str())) { return utf8::utf16ToUtf8(path); } } if ((value = _wgetenv(L"USERPROFILE"))) { std::wstring path(value); path += L"\\Temp"; if (directoryExists(path.c_str())) { return utf8::utf16ToUtf8(path); } } return std::string(); #else const char *value; if ((value = getenv("TMPDIR")) && directoryExists(value)) { return value; } if ((value = getenv("TMP")) && directoryExists(value)) { return value; } if ((value = getenv("TEMP")) && directoryExists(value)) { return value; } if ((value = getenv("TEMPDIR")) && directoryExists(value)) { return value; } return "/tmp"; #endif }
std::string home_dir() { const wchar_t * const appdata = _wgetenv(L"APPDATA"); if (appdata) return from_windows_path(appdata); return std::string(); }
static const std::unordered_set<std::wstring> & hidden_dirs() { static std::unordered_set<std::wstring> hidden_dirs; static std::once_flag flag; std::call_once(flag, [] { const wchar_t *dir = _wgetenv(L"SystemDrive"); if (dir == nullptr) dir = L"c:"; hidden_dirs.insert(to_lower(clean_path(dir) + L"\\program files")); hidden_dirs.insert(to_lower(clean_path(dir) + L"\\program files (x86)")); hidden_dirs.insert(to_lower(clean_path(dir) + L"\\windows")); hidden_dirs.insert(to_lower(clean_path(dir) + L"\\temp")); hidden_dirs.insert(to_lower(clean_path(dir) + L"\\recycler")); dir = _wgetenv(L"ProgramFiles"); if (dir) hidden_dirs.insert(to_lower(clean_path(dir))); dir = _wgetenv(L"ProgramFiles(x86)"); if (dir) hidden_dirs.insert(to_lower(clean_path(dir))); dir = _wgetenv(L"SystemRoot"); if (dir) hidden_dirs.insert(to_lower(clean_path(dir))); dir = _wgetenv(L"TEMP"); if (dir) hidden_dirs.insert(to_lower(clean_path(dir))); dir = _wgetenv(L"TMP"); if (dir) hidden_dirs.insert(to_lower(clean_path(dir))); dir = _wgetenv(L"windir"); if (dir) hidden_dirs.insert(to_lower(clean_path(dir))); wchar_t temp_path[MAX_PATH]; if (GetTempPath(sizeof(temp_path) / sizeof(*temp_path), temp_path) > 0) hidden_dirs.insert(to_lower(clean_path(temp_path))); }); return hidden_dirs; }
inline T getpath() { #if _WIN32 // Handle Unicode, just remove if you don't want/need this. convert_to_utf8 // uses WideCharToMultiByte in the Win32 API return convert_to_utf8( _wgetenv(L"PATH") ); #else return ::getenv("PATH"); #endif }
NAMESPACE_UPP #ifdef PLATFORM_WIN32 String GetEnv(const char *id) { return WString(_wgetenv(WString(id))).ToString(); }
static void setpath (lua_State *L, const char *fieldname, const wchar_t *envname1, const wchar_t *envname2, const wchar_t *def) { const wchar_t *path = _wgetenv(envname1); if (path == NULL) /* no environment variable? */ path = _wgetenv(envname2); /* try alternative name */ if (path == NULL || noenv(L)) /* no environment variable? */ lua_pushlstring(L, (const char*)def, sizeof(wchar_t)*(1+wcslen(def))); /* use default */ else { /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ path = LF_Gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP, LUA_PATH_SEP AUXMARK LUA_PATH_SEP); LF_Gsub(L, path, AUXMARK, def); lua_remove(L, -2); } setprogdir(L); push_utf8_string(L, (const wchar_t*)lua_tostring(L, -1), -1); lua_remove(L, -2); lua_setfield(L, -2, fieldname); }
std::string digidoc::util::File::env(const std::string &varname) { f_string _varname = encodeName( varname ); #ifdef _WIN32 if( wchar_t *var = _wgetenv( _varname.c_str() ) ) #else if( char *var = getenv( _varname.c_str() ) ) #endif return decodeName( var ); return std::string(); }
RTDECL(bool) RTEnvExistsUtf8(const char *pszVar) { AssertReturn(strchr(pszVar, '=') == NULL, false); PRTUTF16 pwszVar; int rc = RTStrToUtf16(pszVar, &pwszVar); AssertRCReturn(rc, false); bool fRet = _wgetenv(pwszVar) != NULL; RTUtf16Free(pwszVar); return fRet; }
void ReadALConfig(void) { al_string ppath = AL_STRING_INIT_STATIC(); WCHAR buffer[MAX_PATH]; const WCHAR *str; FILE *f; if(SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE) { al_string filepath = AL_STRING_INIT_STATIC(); alstr_copy_wcstr(&filepath, buffer); alstr_append_cstr(&filepath, "\\alsoft.ini"); TRACE("Loading config %s...\n", alstr_get_cstr(filepath)); f = al_fopen(alstr_get_cstr(filepath), "rt"); if(f) { LoadConfigFromFile(f); fclose(f); } alstr_reset(&filepath); } GetProcBinary(&ppath, NULL); if(!alstr_empty(ppath)) { alstr_append_cstr(&ppath, "\\alsoft.ini"); TRACE("Loading config %s...\n", alstr_get_cstr(ppath)); f = al_fopen(alstr_get_cstr(ppath), "r"); if(f) { LoadConfigFromFile(f); fclose(f); } } if((str=_wgetenv(L"ALSOFT_CONF")) != NULL && *str) { al_string filepath = AL_STRING_INIT_STATIC(); alstr_copy_wcstr(&filepath, str); TRACE("Loading config %s...\n", alstr_get_cstr(filepath)); f = al_fopen(alstr_get_cstr(filepath), "rt"); if(f) { LoadConfigFromFile(f); fclose(f); } alstr_reset(&filepath); } alstr_reset(&ppath); }
umstring UMPath::get_env(const umstring& env) { #ifdef WITH_EMSCRIPTEN return env; #else if (wchar_t* val = _wgetenv(UMStringUtil::utf16_to_wstring(env).c_str())) { return UMStringUtil::wstring_to_utf16(val); } umstring none; return none; #endif // WITH_EMSCRIPTEN }
char * u_alloc_getenv(const char *varname) { char * r = 0; wchar_t * str; UTF16_ENCODE(varname); if (varname_16) { str = _wgetenv(varname_16); r = alloc_utf_8_from_16(str, 0); } UTF16_UN_ENCODE(varname); return r; }
char* lame_getenv(char const* var) { char* str = 0; wchar_t* wvar = utf8ToUnicode(var); wchar_t* wstr = 0; if (wvar != 0) { wstr = _wgetenv(wvar); str = unicodeToUtf8(wstr); } free(wvar); free(wstr); return str; }