- Cleanup the /lib directory, by putting more 3rd-party libs in /3rdparty, and by...
[reactos.git] / reactos / lib / sdk / crt / stdlib / getenv.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/crt/??????
5 * PURPOSE: Unknown
6 * PROGRAMER: Unknown
7 * UPDATE HISTORY:
8 * 25/11/05: Added license header
9 */
10
11 #include <precomp.h>
12
13 #define NDEBUG
14 #include <internal/debug.h>
15
16 #undef environ
17
18 /*
19 * @implemented
20 */
21 char *getenv(const char *name)
22 {
23 char **environ;
24 unsigned int length = strlen(name);
25
26 for (environ = *__p__environ(); *environ; environ++)
27 {
28 char *str = *environ;
29 char *pos = strchr(str,'=');
30 if (pos && ((unsigned int)(pos - str) == length) && !_strnicmp(str, name, length))
31 return pos + 1;
32 }
33 return NULL;
34 }
35
36 /*
37 * @implemented
38 */
39 wchar_t *_wgetenv(const wchar_t *name)
40 {
41 wchar_t **environ;
42 unsigned int length = wcslen(name);
43
44 for (environ = *__p__wenviron(); *environ; environ++)
45 {
46 wchar_t *str = *environ;
47 wchar_t *pos = wcschr(str, L'=');
48 if (pos && ((unsigned int)(pos - str) == length) && !_wcsnicmp(str, name, length))
49 return pos + 1;
50 }
51 return NULL;
52 }