2013-09-23 22:44:59 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/tchar.h>
|
|
|
|
#include <winpr/environment.h>
|
|
|
|
|
|
|
|
int TestEnvironmentGetEnvironmentStrings(int argc, char* argv[])
|
|
|
|
{
|
2019-10-29 14:57:19 +03:00
|
|
|
int r = -1;
|
2013-09-23 22:44:59 +04:00
|
|
|
TCHAR* p;
|
2019-10-29 14:57:19 +03:00
|
|
|
size_t length;
|
2013-09-23 22:44:59 +04:00
|
|
|
LPTCH lpszEnvironmentBlock;
|
|
|
|
|
2019-10-29 14:57:19 +03:00
|
|
|
WINPR_UNUSED(argc);
|
|
|
|
WINPR_UNUSED(argv);
|
|
|
|
|
2013-09-23 22:44:59 +04:00
|
|
|
lpszEnvironmentBlock = GetEnvironmentStrings();
|
|
|
|
|
|
|
|
p = (TCHAR*) lpszEnvironmentBlock;
|
|
|
|
|
|
|
|
while (p[0] && p[1])
|
|
|
|
{
|
2019-10-29 14:57:19 +03:00
|
|
|
const int rc = _tprintf(_T("%s\n"), p);
|
|
|
|
if (rc < 1)
|
|
|
|
goto fail;
|
2013-10-23 05:38:16 +04:00
|
|
|
length = _tcslen(p);
|
2019-10-29 14:57:19 +03:00
|
|
|
if (length != (size_t)(rc - 1))
|
|
|
|
goto fail;
|
2013-09-23 22:44:59 +04:00
|
|
|
p += (length + 1);
|
|
|
|
}
|
|
|
|
|
2019-10-29 14:57:19 +03:00
|
|
|
r = 0;
|
|
|
|
fail:
|
2013-09-23 22:44:59 +04:00
|
|
|
FreeEnvironmentStrings(lpszEnvironmentBlock);
|
|
|
|
|
2019-10-29 14:57:19 +03:00
|
|
|
return r;
|
2013-09-23 22:44:59 +04:00
|
|
|
}
|
|
|
|
|