ReactOS 0.4.15-dev-8061-g57b775e
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 */
17char *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 */
35wchar_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}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
#define NULL
Definition: types.h:112
#define wcschr
Definition: compat.h:17
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
char * getenv(const char *name)
Definition: getenv.c:17
wchar_t * _wgetenv(const wchar_t *name)
Definition: getenv.c:35
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
_CRTIMP wchar_t ***__cdecl __p__wenviron()
Definition: environ.c:392
_CRTIMP char ***__cdecl __p__environ()
Definition: environ.c:384
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
_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)
Definition: name.c:39