儲存庫 vbox 的更動 50408
- 時間撮記:
- 2014-2-11 上午02:21:39 (11 年 以前)
- 位置:
- trunk
- 檔案:
-
- 修改 5 筆資料
- 複製 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/include/iprt/env.h
r44528 r50408 90 90 * 91 91 * @param Env Environment block handle. 92 * @todo This needs to change to return a copy of the env vars like 93 * RTEnvQueryUtf16Block does! 92 94 */ 93 95 RTDECL(char const * const *) RTEnvGetExecEnvP(RTENV Env); … … 121 123 */ 122 124 RTDECL(bool) RTEnvExist(const char *pszVar); 125 RTDECL(bool) RTEnvExistsBad(const char *pszVar); 126 RTDECL(bool) RTEnvExistsUtf8(const char *pszVar); 123 127 124 128 /** … … 146 150 */ 147 151 RTDECL(const char *) RTEnvGet(const char *pszVar); 152 RTDECL(const char *) RTEnvGetBad(const char *pszVar); 153 RTDECL(int) RTEnvGetUtf8(const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual); 148 154 149 155 /** … … 174 180 */ 175 181 RTDECL(int) RTEnvPut(const char *pszVarEqualValue); 182 RTDECL(int) RTEnvPutBad(const char *pszVarEqualValue); 183 RTDECL(int) RTEnvPutUtf8(const char *pszVarEqualValue); 176 184 177 185 /** … … 198 206 */ 199 207 RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue); 208 RTDECL(int) RTEnvSetBad(const char *pszVar, const char *pszValue); 209 RTDECL(int) RTEnvSetUtf8(const char *pszVar, const char *pszValue); 200 210 201 211 /** … … 222 232 */ 223 233 RTDECL(int) RTEnvUnset(const char *pszVar); 234 RTDECL(int) RTEnvUnsetBad(const char *pszVar); 235 RTDECL(int) RTEnvUnsetUtf8(const char *pszVar); 224 236 225 237 /** -
trunk/include/iprt/mangling.h
r50205 r50408 495 495 # define RTEnvDupEx RT_MANGLER(RTEnvDupEx) 496 496 # define RTEnvExist RT_MANGLER(RTEnvExist) 497 # define RTEnvExistsBad RT_MANGLER(RTEnvExistsBad) 498 # define RTEnvExistsUtf8 RT_MANGLER(RTEnvExistsUtf8) 497 499 # define RTEnvExistEx RT_MANGLER(RTEnvExistEx) 498 500 # define RTEnvFreeUtf16Block RT_MANGLER(RTEnvFreeUtf16Block) 499 501 # define RTEnvGet RT_MANGLER(RTEnvGet) 502 # define RTEnvGetBad RT_MANGLER(RTEnvGetBad) 503 # define RTEnvGetUtf8 RT_MANGLER(RTEnvGetUtf8) 500 504 # define RTEnvGetEx RT_MANGLER(RTEnvGetEx) 501 505 # define RTEnvGetExecEnvP RT_MANGLER(RTEnvGetExecEnvP) 502 506 # define RTEnvPut RT_MANGLER(RTEnvPut) 507 # define RTEnvPutBad RT_MANGLER(RTEnvPutBad) 508 # define RTEnvPutUtf8 RT_MANGLER(RTEnvPutUtf8) 503 509 # define RTEnvPutEx RT_MANGLER(RTEnvPutEx) 504 510 # define RTEnvQueryUtf16Block RT_MANGLER(RTEnvQueryUtf16Block) 505 511 # define RTEnvSet RT_MANGLER(RTEnvSet) 512 # define RTEnvSetBad RT_MANGLER(RTEnvSetBad) 513 # define RTEnvSetUtf8 RT_MANGLER(RTEnvSetUtf8) 506 514 # define RTEnvSetEx RT_MANGLER(RTEnvSetEx) 507 515 # define RTEnvUnset RT_MANGLER(RTEnvUnset) 516 # define RTEnvUnsetBad RT_MANGLER(RTEnvUnsetBad) 517 # define RTEnvUnsetUtf8 RT_MANGLER(RTEnvUnsetUtf8) 508 518 # define RTEnvUnsetEx RT_MANGLER(RTEnvUnsetEx) 509 519 # define RTErrCOMGet RT_MANGLER(RTErrCOMGet) -
trunk/src/VBox/Runtime/Makefile.kmk
r49845 r50408 604 604 r3/nt/fs-nt.cpp \ 605 605 r3/nt/pathint-nt.cpp \ 606 r3/ posix/env-posix.cpp \606 r3/win/env-win.cpp \ 607 607 r3/win/RTHandleGetStandard-win.cpp \ 608 608 r3/win/RTSystemQueryOSInfo-win.cpp \ -
trunk/src/VBox/Runtime/generic/env-generic.cpp
r46035 r50408 57 57 * Defined Constants And Macros * 58 58 *******************************************************************************/ 59 /** The allocation granularity of the RTENVINTERNAL::papszEnv memory. */ 60 #define RTENV_GROW_SIZE 16 61 59 62 /** Macro that unlocks the specified environment block. */ 60 63 #define RTENV_LOCK(pEnvInt) do { } while (0) 61 64 /** Macro that unlocks the specified environment block. */ 62 65 #define RTENV_UNLOCK(pEnvInt) do { } while (0) 66 67 /** @def RTENV_HAVE_WENVIRON 68 * Indicates that we have a _wenviron variable with UTF-16 strings that we 69 * better use instead of the current-cp strings in environ. */ 70 #if defined(RT_OS_WINDOWS) || defined(DOXYGEN_RUNNING) 71 # define RTENV_HAVE_WENVIRON 1 72 #endif 73 74 /** @def RTENV_IMPLEMENTS_UTF8_DEFAULT_ENV_API 75 * Indicates the RTEnv*Utf8 APIs are implemented. */ 76 #if defined(RT_OS_WINDOWS) || defined(DOXYGEN_RUNNING) 77 # define RTENV_IMPLEMENTS_UTF8_DEFAULT_ENV_API 1 78 #endif 63 79 64 80 … … 85 101 * This get (re-)constructed when RTEnvGetExecEnvP method is called. */ 86 102 char **papszEnvOtherCP; 103 104 /** The compare function we're using. */ 105 DECLCALLBACKMEMBER(int, pfnCompare)(const char *psz1, const char *psz2, size_t cchMax); 87 106 } RTENVINTERNAL, *PRTENVINTERNAL; 88 89 /** The allocation granularity of the RTENVINTERNAL::papszEnv memory. */90 #define RTENV_GROW_SIZE 1691 107 92 108 … … 112 128 * 113 129 * @returns IPRT status code. 114 * @param ppIntEnv Where to store the result. 115 * @param cAllocated The initial array size. 130 * @param ppIntEnv Where to store the result. 131 * @param cAllocated The initial array size. 132 * @param fCaseSensitive Whether the environment block is case sensitive or 133 * not. 116 134 */ 117 static int rtEnvCreate(PRTENVINTERNAL *ppIntEnv, size_t cAllocated )135 static int rtEnvCreate(PRTENVINTERNAL *ppIntEnv, size_t cAllocated, bool fCaseSensitive) 118 136 { 119 137 /* … … 127 145 */ 128 146 pIntEnv->u32Magic = RTENV_MAGIC; 147 pIntEnv->pfnCompare = fCaseSensitive ? RTStrNCmp : RTStrNICmp; 129 148 pIntEnv->papszEnvOtherCP = NULL; 130 149 pIntEnv->cVars = 0; … … 147 166 { 148 167 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); 149 return rtEnvCreate(pEnv, RTENV_GROW_SIZE );168 return rtEnvCreate(pEnv, RTENV_GROW_SIZE, false /*fCaseSensitive*/); 150 169 } 151 170 RT_EXPORT_SYMBOL(RTEnvCreate); … … 201 220 * Validate input and figure out how many variable to clone and where to get them. 202 221 */ 222 bool fCaseSensitive = true; 203 223 size_t cVars; 204 224 const char * const *papszEnv; 225 #ifdef RTENV_HAVE_WENVIRON 226 PCRTUTF16 const * papwszEnv; 227 #endif 205 228 PRTENVINTERNAL pIntEnvToClone; 206 229 AssertPtrReturn(pEnv, VERR_INVALID_POINTER); 207 230 if (EnvToClone == RTENV_DEFAULT) 208 231 { 232 cVars = 0; 209 233 pIntEnvToClone = NULL; 234 #ifdef RTENV_HAVE_WENVIRON 235 papszEnv = NULL; 236 papwszEnv = (PCRTUTF16 * const )_wenviron; 237 if (papwszEnv) 238 while (papwszEnv[cVars]) 239 cVars++; 240 #else 210 241 papszEnv = rtEnvDefault(); 211 cVars = 0;212 242 if (papszEnv) 213 243 while (papszEnv[cVars]) 214 244 cVars++; 245 #endif 246 247 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS) 248 /* DOS systems was case insensitive. A prime example is the 'Path' 249 variable on windows which turns into the 'PATH' variable. */ 250 fCaseSensitive = false; 251 #endif 215 252 } 216 253 else … … 229 266 */ 230 267 PRTENVINTERNAL pIntEnv; 231 int rc = rtEnvCreate(&pIntEnv, cVars + 1 /* NULL */ );268 int rc = rtEnvCreate(&pIntEnv, cVars + 1 /* NULL */, fCaseSensitive); 232 269 if (RT_SUCCESS(rc)) 233 270 { … … 240 277 for (size_t iSrc = 0; iSrc < cVars; iSrc++) 241 278 { 279 #ifdef RTENV_HAVE_WENVIRON 280 int rc2 = RTUtf16ToUtf8(papwszEnv[iSrc], &pIntEnv->papszEnv[iDst]); 281 #else 242 282 int rc2 = RTStrCurrentCPToUtf8(&pIntEnv->papszEnv[iDst], papszEnv[iSrc]); 283 #endif 243 284 if (RT_SUCCESS(rc2)) 244 285 iDst++; … … 319 360 if (Env == RTENV_DEFAULT) 320 361 { 362 #ifdef RT_OS_WINDOWS 363 rc = RTEnvSetUtf8(pszVar, pszValue); 364 #else 321 365 /* 322 366 * Since RTEnvPut isn't UTF-8 clean and actually expects the strings … … 337 381 RTStrFree(pszVarOtherCP); 338 382 } 383 #endif 339 384 } 340 385 else … … 364 409 size_t iVar; 365 410 for (iVar = 0; iVar < pIntEnv->cVars; iVar++) 366 if ( ! strncmp(pIntEnv->papszEnv[iVar], pszVar, cchVar)411 if ( !pIntEnv->pfnCompare(pIntEnv->papszEnv[iVar], pszVar, cchVar) 367 412 && pIntEnv->papszEnv[iVar][cchVar] == '=') 368 413 break; … … 424 469 if (Env == RTENV_DEFAULT) 425 470 { 471 #ifdef RTENV_IMPLEMENTS_UTF8_DEFAULT_ENV_API 472 rc = RTEnvUnsetUtf8(pszVar); 473 #else 426 474 /* 427 475 * Since RTEnvUnset isn't UTF-8 clean and actually expects the strings … … 436 484 RTStrFree(pszVarOtherCP); 437 485 } 486 #endif 438 487 } 439 488 else … … 452 501 size_t iVar; 453 502 for (iVar = 0; iVar < pIntEnv->cVars; iVar++) 454 if ( ! strncmp(pIntEnv->papszEnv[iVar], pszVar, cchVar)503 if ( !pIntEnv->pfnCompare(pIntEnv->papszEnv[iVar], pszVar, cchVar) 455 504 && pIntEnv->papszEnv[iVar][cchVar] == '=') 456 505 { … … 484 533 if (Env == RTENV_DEFAULT) 485 534 { 535 #ifdef RTENV_IMPLEMENTS_UTF8_DEFAULT_ENV_API 536 rc = RTEnvGetUtf8(pszVar, pszValue, cbValue, pcchActual); 537 #else 486 538 /* 487 539 * Since RTEnvGet isn't UTF-8 clean and actually expects the strings … … 518 570 rc = VERR_ENV_VAR_NOT_FOUND; 519 571 } 572 #endif 520 573 } 521 574 else … … 534 587 size_t iVar; 535 588 for (iVar = 0; iVar < pIntEnv->cVars; iVar++) 536 if ( ! strncmp(pIntEnv->papszEnv[iVar], pszVar, cchVar)589 if ( !pIntEnv->pfnCompare(pIntEnv->papszEnv[iVar], pszVar, cchVar) 537 590 && pIntEnv->papszEnv[iVar][cchVar] == '=') 538 591 { … … 555 608 } 556 609 return rc; 557 558 610 } 559 611 RT_EXPORT_SYMBOL(RTEnvGetEx); … … 564 616 AssertPtrReturn(pszVar, false); 565 617 566 bool fExist = false;618 bool fExists = false; 567 619 if (Env == RTENV_DEFAULT) 568 620 { 621 #ifdef RTENV_IMPLEMENTS_UTF8_DEFAULT_ENV_API 622 fExists = RTEnvExistsUtf8(pszVar); 623 #else 569 624 /* 570 625 * Since RTEnvExist isn't UTF-8 clean and actually expects the strings … … 576 631 if (RT_SUCCESS(rc)) 577 632 { 578 fExist = RTEnvExist(pszVarOtherCP);633 fExists = RTEnvExist(pszVarOtherCP); 579 634 RTStrFree(pszVarOtherCP); 580 635 } 636 #endif 581 637 } 582 638 else … … 593 649 const size_t cchVar = strlen(pszVar); 594 650 for (size_t iVar = 0; iVar < pIntEnv->cVars; iVar++) 595 if ( ! strncmp(pIntEnv->papszEnv[iVar], pszVar, cchVar)651 if ( !pIntEnv->pfnCompare(pIntEnv->papszEnv[iVar], pszVar, cchVar) 596 652 && pIntEnv->papszEnv[iVar][cchVar] == '=') 597 653 { 598 fExist = true;654 fExists = true; 599 655 break; 600 656 } … … 602 658 RTENV_UNLOCK(pIntEnv); 603 659 } 604 return fExist ;660 return fExists; 605 661 } 606 662 RT_EXPORT_SYMBOL(RTEnvExistEx); … … 612 668 if (Env == RTENV_DEFAULT) 613 669 { 670 /** @todo fix this API it's fundamentally wrong! */ 614 671 papszRet = rtEnvDefault(); 615 672 if (!papszRet) -
trunk/src/VBox/Runtime/r3/posix/env-posix.cpp
r48935 r50408 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 48 48 49 RTDECL(bool) RTEnvExist (const char *pszVar)49 RTDECL(bool) RTEnvExistsBad(const char *pszVar) 50 50 { 51 return RTEnvGet (pszVar) != NULL;51 return RTEnvGetBad(pszVar) != NULL; 52 52 } 53 53 54 54 55 RTDECL(const char *) RTEnvGet(const char *pszVar) 55 RTDECL(bool) RTEnvExist(const char *pszVar) 56 { 57 return RTEnvExistsBad(pszVar); 58 } 59 60 61 RTDECL(const char *) RTEnvGetBad(const char *pszVar) 56 62 { 57 63 IPRT_ALIGNMENT_CHECKS_DISABLE(); /* glibc causes trouble */ … … 62 68 63 69 64 RTDECL(int) RTEnvPut(const char *pszVarEqualValue) 70 RTDECL(const char *) RTEnvGet(const char *pszVar) 71 { 72 return RTEnvGetBad(pszVar); 73 } 74 75 76 RTDECL(int) RTEnvPutBad(const char *pszVarEqualValue) 65 77 { 66 78 /** @todo putenv is a source memory leaks. deal with this on a per system basis. */ … … 70 82 } 71 83 72 RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue) 84 85 RTDECL(int) RTEnvPut(const char *pszVarEqualValue) 86 { 87 return RTEnvPutBad(pszVarEqualValue); 88 } 89 90 91 RTDECL(int) RTEnvSetBad(const char *pszVar, const char *pszValue) 73 92 { 74 93 #if defined(_MSC_VER) … … 99 118 100 119 101 RTDECL(int) RTEnvUnset(const char *pszVar) 120 RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue) 121 { 122 return RTEnvSetBad(pszVar, pszValue); 123 } 124 125 RTDECL(int) RTEnvUnsetBad(const char *pszVar) 102 126 { 103 127 AssertReturn(!strchr(pszVar, '='), VERR_INVALID_PARAMETER); … … 132 156 } 133 157 158 RTDECL(int) RTEnvUnset(const char *pszVar) 159 { 160 return RTEnvUnsetBad(pszVar); 161 } 162 -
trunk/src/VBox/Runtime/r3/win/env-win.cpp
r50388 r50408 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #ifdef RT_OS_DARWIN32 /* pick the correct prototype for unsetenv. */33 # define _POSIX_C_SOURCE 134 #endif35 31 #include <iprt/env.h> 36 #include <iprt/string.h> 32 37 33 #include <iprt/alloca.h> 38 34 #include <iprt/assert.h> 39 #if defined(DEBUG) && defined(RT_OS_LINUX) 40 # include <iprt/asm.h> 41 #endif 35 #include <iprt/string.h> 36 #include <iprt/mem.h> 42 37 43 38 #include <stdlib.h> 44 39 #include <errno.h> 45 40 46 #include "internal/alignmentchecks.h" 41 42 RTDECL(bool) RTEnvExistsBad(const char *pszVar) 43 { 44 return RTEnvGetBad(pszVar) != NULL; 45 } 47 46 48 47 49 48 RTDECL(bool) RTEnvExist(const char *pszVar) 50 49 { 51 return RTEnvGet(pszVar) != NULL; 50 return RTEnvExistsBad(pszVar); 51 } 52 53 54 RTDECL(bool) RTEnvExistsUtf8(const char *pszVar) 55 { 56 PRTUTF16 pwszVar; 57 int rc = RTStrToUtf16(pszVar, &pwszVar); 58 AssertRCReturn(rc, false); 59 bool fRet = _wgetenv(pwszVar) != NULL; 60 RTUtf16Free(pwszVar); 61 return fRet; 62 } 63 64 65 RTDECL(const char *) RTEnvGetBad(const char *pszVar) 66 { 67 return getenv(pszVar); 52 68 } 53 69 … … 55 71 RTDECL(const char *) RTEnvGet(const char *pszVar) 56 72 { 57 IPRT_ALIGNMENT_CHECKS_DISABLE(); /* glibc causes trouble */ 58 const char *pszValue = getenv(pszVar); 59 IPRT_ALIGNMENT_CHECKS_ENABLE(); 60 return pszValue; 61 } 62 63 64 RTDECL(int) RTEnvPut(const char *pszVarEqualValue) 73 return RTEnvGetBad(pszVar); 74 } 75 76 RTDECL(int) RTEnvGetUtf8(const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual) 77 { 78 AssertPtrReturn(pszVar, VERR_INVALID_POINTER); 79 AssertPtrNullReturn(pszValue, VERR_INVALID_POINTER); 80 AssertReturn(pszValue || !cbValue, VERR_INVALID_PARAMETER); 81 AssertPtrNullReturn(pcchActual, VERR_INVALID_POINTER); 82 AssertReturn(pcchActual || (pszValue && cbValue), VERR_INVALID_PARAMETER); 83 84 if (pcchActual) 85 *pcchActual = 0; 86 87 PRTUTF16 pwszVar; 88 int rc = RTStrToUtf16(pszVar, &pwszVar); 89 AssertRCReturn(rc, false); 90 91 /** @todo Consider _wgetenv_s or GetEnvironmentVariableW here to avoid the 92 * potential race with a concurrent _wputenv/_putenv. */ 93 PCRTUTF16 pwszValue = _wgetenv(pwszVar); 94 RTUtf16Free(pwszVar); 95 if (pwszValue) 96 { 97 if (cbValue) 98 rc = RTUtf16ToUtf8Ex(pwszValue, RTSTR_MAX, &pszValue, cbValue, pcchActual); 99 else 100 rc = RTUtf16CalcUtf8LenEx(pwszValue, RTSTR_MAX, pcchActual); 101 } 102 else 103 rc = VERR_ENV_VAR_NOT_FOUND; 104 return rc; 105 } 106 107 108 RTDECL(int) RTEnvPutBad(const char *pszVarEqualValue) 65 109 { 66 110 /** @todo putenv is a source memory leaks. deal with this on a per system basis. */ … … 70 114 } 71 115 72 RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue) 73 { 74 #if defined(_MSC_VER) 116 117 RTDECL(int) RTEnvPut(const char *pszVarEqualValue) 118 { 119 return RTEnvPutBad(pszVarEqualValue); 120 } 121 122 123 RTDECL(int) RTEnvPutUtf8(const char *pszVarEqualValue) 124 { 125 PRTUTF16 pwszVarEqualValue; 126 int rc = RTStrToUtf16(pszVarEqualValue, &pwszVarEqualValue); 127 if (RT_SUCCESS(rc)) 128 { 129 if (!_wputenv(pwszVarEqualValue)) 130 rc = VINF_SUCCESS; 131 else 132 rc = RTErrConvertFromErrno(errno); 133 RTUtf16Free(pwszVarEqualValue); 134 } 135 return rc; 136 } 137 138 139 140 RTDECL(int) RTEnvSetBad(const char *pszVar, const char *pszValue) 141 { 75 142 /* make a local copy and feed it to putenv. */ 76 143 const size_t cchVar = strlen(pszVar); … … 90 157 return 0; 91 158 return RTErrConvertFromErrno(errno); 92 93 #else 94 if (!setenv(pszVar, pszValue, 1)) 95 return VINF_SUCCESS; 96 return RTErrConvertFromErrno(errno); 97 #endif 98 } 99 100 101 RTDECL(int) RTEnvUnset(const char *pszVar) 159 } 160 161 162 RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue) 163 { 164 return RTEnvSetBad(pszVar, pszValue); 165 } 166 167 RTDECL(int) RTEnvSetUtf8(const char *pszVar, const char *pszValue) 168 { 169 size_t cwcVar; 170 int rc = RTStrCalcUtf16LenEx(pszVar, RTSTR_MAX, &cwcVar); 171 if (RT_SUCCESS(rc)) 172 { 173 size_t cwcValue; 174 rc = RTStrCalcUtf16LenEx(pszVar, RTSTR_MAX, &cwcValue); 175 if (RT_SUCCESS(rc)) 176 { 177 PRTUTF16 pwszTmp = (PRTUTF16)RTMemTmpAlloc((cwcVar + 1 + cwcValue + 1) * sizeof(RTUTF16)); 178 if (pwszTmp) 179 { 180 rc = RTStrToUtf16Ex(pszVar, RTSTR_MAX, &pwszTmp, cwcVar + 1, NULL); 181 if (RT_SUCCESS(rc)) 182 { 183 PRTUTF16 pwszTmpValue = &pwszTmp[cwcVar]; 184 *pwszTmpValue++ = '='; 185 rc = RTStrToUtf16Ex(pszValue, RTSTR_MAX, &pwszTmpValue, cwcValue + 1, NULL); 186 if (RT_SUCCESS(rc)) 187 { 188 if (!_wputenv(pwszTmp)) 189 rc = VINF_SUCCESS; 190 else 191 rc = RTErrConvertFromErrno(errno); 192 } 193 } 194 RTMemTmpFree(pwszTmp); 195 } 196 else 197 rc = VERR_NO_TMP_MEMORY; 198 } 199 } 200 return rc; 201 } 202 203 204 RTDECL(int) RTEnvUnsetBad(const char *pszVar) 102 205 { 103 206 AssertReturn(!strchr(pszVar, '='), VERR_INVALID_PARAMETER); … … 132 235 } 133 236 237 238 RTDECL(int) RTEnvUnset(const char *pszVar) 239 { 240 return RTEnvUnsetBad(pszVar); 241 } 242 243 244 RTDECL(int) RTEnvUnsetUtf8(const char *pszVar) 245 { 246 size_t cwcVar; 247 int rc = RTStrCalcUtf16LenEx(pszVar, RTSTR_MAX, &cwcVar); 248 if (RT_SUCCESS(rc)) 249 { 250 PRTUTF16 pwszTmp = (PRTUTF16)RTMemTmpAlloc((cwcVar + 1 + 1) * sizeof(RTUTF16)); 251 if (pwszTmp) 252 { 253 rc = RTStrToUtf16Ex(pszVar, RTSTR_MAX, &pwszTmp, cwcVar + 1, NULL); 254 if (RT_SUCCESS(rc)) 255 { 256 pwszTmp[cwcVar] = '='; 257 pwszTmp[cwcVar + 1] = '\0'; 258 if (!_wputenv(pwszTmp)) 259 rc = VINF_SUCCESS; 260 else 261 rc = RTErrConvertFromErrno(errno); 262 } 263 RTMemTmpFree(pwszTmp); 264 } 265 } 266 return rc; 267 } 268
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器