2007-03-14 20:24:57 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2015-09-19 13:50:57 +00:00
|
|
|
* FILE: lib/sdk/crt/stdlib/getenv.c
|
2007-03-14 20:24:57 +00:00
|
|
|
* PURPOSE: Unknown
|
|
|
|
* PROGRAMER: Unknown
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 25/11/05: Added license header
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <precomp.h>
|
2008-12-13 21:28:05 +00:00
|
|
|
//#undef environ
|
2007-03-14 20:24:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
char *getenv(const char *name)
|
|
|
|
{
|
2012-12-16 16:38:36 +00:00
|
|
|
char **env;
|
2011-09-15 17:11:53 +00:00
|
|
|
size_t length = strlen(name);
|
2007-03-14 20:24:57 +00:00
|
|
|
|
2012-12-16 16:38:36 +00:00
|
|
|
for (env = *__p__environ(); *env; env++)
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
2012-12-16 16:38:36 +00:00
|
|
|
char *str = *env;
|
2007-03-14 20:24:57 +00:00
|
|
|
char *pos = strchr(str,'=');
|
|
|
|
if (pos && ((unsigned int)(pos - str) == length) && !_strnicmp(str, name, length))
|
|
|
|
return pos + 1;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
wchar_t *_wgetenv(const wchar_t *name)
|
|
|
|
{
|
2012-12-16 16:38:36 +00:00
|
|
|
wchar_t **env;
|
2011-09-15 17:11:53 +00:00
|
|
|
size_t length = wcslen(name);
|
2007-03-14 20:24:57 +00:00
|
|
|
|
2012-12-16 16:38:36 +00:00
|
|
|
for (env = *__p__wenviron(); *env; env++)
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
2012-12-16 16:38:36 +00:00
|
|
|
wchar_t *str = *env;
|
2007-03-14 20:24:57 +00:00
|
|
|
wchar_t *pos = wcschr(str, L'=');
|
|
|
|
if (pos && ((unsigned int)(pos - str) == length) && !_wcsnicmp(str, name, length))
|
|
|
|
return pos + 1;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|