/********************************************************/
/* ntapi: Native API core library */
/* Copyright (C) 2013--2016 Z. Gilboa */
/* 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_utf16(
__in wchar16_t * env_var_name,
__in wchar16_t ** envp,
__out nt_env_var_meta_utf16 * env_var_meta)
{
int idx;
wchar16_t * wch;
#define EQUAL_SIGN 0x3D
/* init */
env_var_meta->name = 0;
env_var_meta->value = 0;
env_var_meta->envp_index = 0;
env_var_meta->flags = 0;
/* lookup */
for (idx=0; envp[idx] && !env_var_meta->value; idx++) {
wch = envp[idx];
while (*wch && (*wch != EQUAL_SIGN))
wch++;
if (*wch != EQUAL_SIGN)
return NT_STATUS_ILLEGAL_CHARACTER;
if (!(__ntapi->tt_strncmp_utf16(
envp[idx],
env_var_name,
wch - envp[idx]))) {
wch++;
env_var_meta->name = envp[idx];
env_var_meta->value = wch;
env_var_meta->envp_index = idx;
}
}
return NT_STATUS_SUCCESS;
}