4 #include <winpr/tchar.h>
5 #include <winpr/environment.h>
7 int TestEnvironmentGetSetEB(
int argc,
char* argv[])
14 LPTCH lpszEnvironmentBlock =
"SHELL=123\0test=1\0test1=2\0DISPLAY=WINPR_TEST_VALUE\0\0";
15 LPTCH lpszEnvironmentBlockNew = NULL;
22 length = GetEnvironmentVariableEBA(lpszEnvironmentBlock,
"DISPLAY", NULL, 0);
28 p = (LPSTR)malloc(length);
33 if (GetEnvironmentVariableEBA(lpszEnvironmentBlock,
"DISPLAY", p, length) != length - 1)
36 printf(
"GetEnvironmentVariableA(WINPR_TEST_VARIABLE) = %s\n", p);
38 if (strcmp(p,
"WINPR_TEST_VALUE") != 0)
42 length = GetEnvironmentVariableEBA(lpszEnvironmentBlock,
"BLA", NULL, 0);
46 printf(
"Unset variable returned\n");
51 length = GetEnvironmentVariableEBA(lpszEnvironmentBlock,
"XDISPLAY", NULL, 0);
55 printf(
"Similar named variable returned (XDISPLAY, length %d)\n", length);
59 length = GetEnvironmentVariableEBA(lpszEnvironmentBlock,
"DISPLAYX", NULL, 0);
63 printf(
"Similar named variable returned (DISPLAYX, length %d)\n", length);
67 length = GetEnvironmentVariableEBA(lpszEnvironmentBlock,
"DISPLA", NULL, 0);
71 printf(
"Similar named variable returned (DISPLA, length %d)\n", length);
75 length = GetEnvironmentVariableEBA(lpszEnvironmentBlock,
"ISPLAY", NULL, 0);
79 printf(
"Similar named variable returned (ISPLAY, length %d)\n", length);
84 if (SetEnvironmentVariableEBA(&lpszEnvironmentBlockNew,
"test",
"5"))
86 if (GetEnvironmentVariableEBA(lpszEnvironmentBlockNew,
"test", test, 1023))
88 if (strcmp(test,
"5") != 0)
96 if (SetEnvironmentVariableEBA(&lpszEnvironmentBlockNew,
"test", NULL))
98 if (GetEnvironmentVariableEBA(lpszEnvironmentBlockNew,
"test", test, 1023))
106 free(lpszEnvironmentBlockNew);
107 lpszEnvironmentBlockNew = (LPTCH)calloc(1024,
sizeof(TCHAR));
109 if (!lpszEnvironmentBlockNew)
112 memcpy(lpszEnvironmentBlockNew, lpszEnvironmentBlock, length);
115 if (SetEnvironmentVariableEBA(&lpszEnvironmentBlockNew,
"test",
"5"))
117 if (0 != GetEnvironmentVariableEBA(lpszEnvironmentBlockNew,
"testr", test, 1023))
119 printf(
"GetEnvironmentVariableEBA returned unset variable\n");
123 if (GetEnvironmentVariableEBA(lpszEnvironmentBlockNew,
"test", test, 1023))
125 if (strcmp(test,
"5") != 0)
135 free(lpszEnvironmentBlockNew);