FreeRDP/winpr/libwinpr/environment/test/TestEnvironmentMergeEnvironmentStrings.c
2024-02-15 11:49:16 +01:00

35 lines
804 B
C

#include <stdio.h>
#include <winpr/crt.h>
#include <winpr/tchar.h>
#include <winpr/environment.h>
int TestEnvironmentMergeEnvironmentStrings(int argc, char* argv[])
{
#ifndef _WIN32
TCHAR* p = NULL;
size_t length = 0;
LPTCH lpszEnvironmentBlock = NULL;
LPTCH lpsz2Merge = "SHELL=123\0test=1\0test1=2\0DISPLAY=:77\0\0";
LPTCH lpszMergedEnvironmentBlock = NULL;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
lpszEnvironmentBlock = GetEnvironmentStrings();
lpszMergedEnvironmentBlock = MergeEnvironmentStrings(lpszEnvironmentBlock, lpsz2Merge);
p = (TCHAR*)lpszMergedEnvironmentBlock;
while (p[0] && p[1])
{
printf("%s\n", p);
length = strlen(p);
p += (length + 1);
}
FreeEnvironmentStrings(lpszMergedEnvironmentBlock);
FreeEnvironmentStrings(lpszEnvironmentBlock);
#endif
return 0;
}