ReactOS  0.4.14-dev-323-g6fe6a88
getenv.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS system libraries
4  * FILE: lib/sdk/crt/stdlib/getenv.c
5  * PURPOSE: Unknown
6  * PROGRAMER: Unknown
7  * UPDATE HISTORY:
8  * 25/11/05: Added license header
9  */
10 
11 #include <precomp.h>
12 //#undef environ
13 
14 /*
15  * @implemented
16  */
17 char *getenv(const char *name)
18 {
19  char **env;
20  size_t length = strlen(name);
21 
22  for (env = *__p__environ(); *env; env++)
23  {
24  char *str = *env;
25  char *pos = strchr(str,'=');
26  if (pos && ((unsigned int)(pos - str) == length) && !_strnicmp(str, name, length))
27  return pos + 1;
28  }
29  return NULL;
30 }
31 
32 /*
33  * @implemented
34  */
35 wchar_t *_wgetenv(const wchar_t *name)
36 {
37  wchar_t **env;
38  size_t length = wcslen(name);
39 
40  for (env = *__p__wenviron(); *env; env++)
41  {
42  wchar_t *str = *env;
43  wchar_t *pos = wcschr(str, L'=');
44  if (pos && ((unsigned int)(pos - str) == length) && !_wcsnicmp(str, name, length))
45  return pos + 1;
46  }
47  return NULL;
48 }
_CRTIMP wchar_t ***__cdecl __p__wenviron()
Definition: environ.c:392
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static const WCHAR L[]
Definition: oid.c:1250
char * getenv(const char *name)
Definition: getenv.c:17
_CRTIMP char ***__cdecl __p__environ()
Definition: environ.c:384
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:168
char * strchr(const char *String, int ch)
Definition: utclib.c:501
Definition: name.c:36
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
wchar_t * _wgetenv(const wchar_t *name)
Definition: getenv.c:35