blob: 09b036c0e0fa66a11ce06b662a9187309961b711 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/********************************************************/
/* ntapi: Native API core library */
/* Copyright (C) 2013--2021 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
/********************************************************/
#include <psxtypes/psxtypes.h>
#include <ntapi/ntapi.h>
#include "ntapi_impl.h"
int32_t __stdcall __ntapi_tt_get_env_var_meta_utf8(
__in char * env_var_name,
__in char ** envp,
__out nt_env_var_meta_utf8 * env_var_meta)
{
char ** penv;
char * ch;
/* lookup */
for (penv=envp; *penv; penv++) {
for (ch=penv[0]; *ch && (*ch != '='); )
ch++;
if (*ch != '=')
return NT_STATUS_INVALID_USER_BUFFER;
if ((ch > *penv) && !(__ntapi->tt_strncmp_multibyte(
*penv,
env_var_name,
ch - *penv))) {
/* match */
env_var_meta->name = *penv;
env_var_meta->value = ++ch;
env_var_meta->envp_index = penv - envp;
env_var_meta->flags = 0;
return NT_STATUS_SUCCESS;
}
}
return NT_STATUS_NOT_FOUND;
}
int32_t __stdcall __ntapi_tt_get_env_var_meta_utf16(
__in wchar16_t * env_var_name,
__in wchar16_t ** envp,
__out nt_env_var_meta_utf16 * env_var_meta)
{
wchar16_t ** penv;
wchar16_t * wch;
/* lookup */
for (penv=envp; *penv; penv++) {
for (wch=penv[0]; *wch && (*wch != '='); )
wch++;
if (*wch != '=')
return NT_STATUS_INVALID_USER_BUFFER;
if ((wch > *penv) && !(__ntapi->tt_strncmp_utf16(
*penv,
env_var_name,
wch - *penv))) {
/* match */
env_var_meta->name = *penv;
env_var_meta->value = ++wch;
env_var_meta->envp_index = penv - envp;
env_var_meta->flags = 0;
return NT_STATUS_SUCCESS;
}
}
return NT_STATUS_NOT_FOUND;
}
|