X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=lib%2Fmsvcrt%2Fmisc%2Fenviron.c;h=6f83d190d1be57e2afeee9d218612215d5e9948d;hb=HEAD;hp=7dc8d437364a899b9ec207743be14570db5d3f70;hpb=e3ed2d773259cc445c7ff8181ebd934931365328;p=reactos.git diff --git a/lib/msvcrt/misc/environ.c b/lib/msvcrt/misc/environ.c index 7dc8d43..6f83d19 100644 --- a/lib/msvcrt/misc/environ.c +++ b/lib/msvcrt/misc/environ.c @@ -30,6 +30,9 @@ int __mb_cur_max = 1; int _commode = _IOCOMMIT; +/* + * @implemented + */ int *__p__commode(void) // not exported by NTDLL { return &_commode; @@ -42,11 +45,11 @@ int BlockEnvToEnviron(void) DPRINT("BlockEnvToEnviron()\n"); - if (_environ) { + if (_environ && _environ != __initenv) { FreeEnvironmentStringsA(_environ[0]); free(_environ); - _environ = NULL; } + _environ = NULL; ptr2 = ptr = (char*)GetEnvironmentStringsA(); if (ptr == NULL) { DPRINT("GetEnvironmentStringsA() returnd NULL\n"); @@ -55,7 +58,7 @@ int BlockEnvToEnviron(void) len = 0; while (*ptr2) { len++; - while (*ptr2++); + ptr2 += strlen(ptr2) + 1; } _environ = malloc((len + 1) * sizeof(char*)); if (_environ == NULL) { @@ -64,57 +67,91 @@ int BlockEnvToEnviron(void) } for (i = 0; i < len && *ptr; i++) { _environ[i] = ptr; - while (*ptr++); + ptr += strlen(ptr) + 1; } _environ[i] = NULL; + if (__initenv == NULL) + { + __initenv = _environ; + } return 0; } +/* + * @implemented + */ void __set_app_type(int app_type) { __app_type = app_type; } +/* + * @implemented + */ char **__p__acmdln(void) { return &_acmdln; } +/* + * @implemented + */ char ***__p__environ(void) { return _environ_dll; } +/* + * @implemented + */ char ***__p___initenv(void) { return &__initenv; } +/* + * @implemented + */ int *__p___mb_cur_max(void) { return &__mb_cur_max; } +/* + * @implemented + */ unsigned int *__p__osver(void) { return &_osver; } +/* + * @implemented + */ char **__p__pgmptr(void) { return &_pgmptr; } +/* + * @implemented + */ unsigned int *__p__winmajor(void) { return &_winmajor; } +/* + * @implemented + */ unsigned int *__p__winminor(void) { return &_winminor; } +/* + * @implemented + */ unsigned int *__p__winver(void) { return &_winver;