FreeRDP
TestEnvironmentMergeEnvironmentStrings.c
1 
2 #include <stdio.h>
3 #include <winpr/crt.h>
4 #include <winpr/tchar.h>
5 #include <winpr/environment.h>
6 
7 int TestEnvironmentMergeEnvironmentStrings(int argc, char* argv[])
8 {
9 #ifndef _WIN32
10  TCHAR* p = NULL;
11  size_t length = 0;
12  LPTCH lpszEnvironmentBlock = NULL;
13  LPTCH lpsz2Merge = "SHELL=123\0test=1\0test1=2\0DISPLAY=:77\0\0";
14  LPTCH lpszMergedEnvironmentBlock = NULL;
15 
16  WINPR_UNUSED(argc);
17  WINPR_UNUSED(argv);
18 
19  lpszEnvironmentBlock = GetEnvironmentStrings();
20  lpszMergedEnvironmentBlock = MergeEnvironmentStrings(lpszEnvironmentBlock, lpsz2Merge);
21  p = (TCHAR*)lpszMergedEnvironmentBlock;
22 
23  while (p[0] && p[1])
24  {
25  printf("%s\n", p);
26  length = strlen(p);
27  p += (length + 1);
28  }
29 
30  FreeEnvironmentStrings(lpszMergedEnvironmentBlock);
31  FreeEnvironmentStrings(lpszEnvironmentBlock);
32 #endif
33  return 0;
34 }