FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
TestPathIsUNCEx.c
1
2#include <stdio.h>
3#include <winpr/crt.h>
4#include <winpr/path.h>
5#include <winpr/tchar.h>
6#include <winpr/winpr.h>
7
8static const TCHAR testServer[] = _T("server\\share\\path\\file");
9static const TCHAR testPathUNC[] = _T("\\\\server\\share\\path\\file");
10static const TCHAR testPathNotUNC[] = _T("C:\\share\\path\\file");
11
12int TestPathIsUNCEx(int argc, char* argv[])
13{
14 BOOL status = 0;
15 LPCTSTR Server = NULL;
16 TCHAR Path[PATHCCH_MAX_CCH] = { 0 };
17
18 WINPR_UNUSED(argc);
19 WINPR_UNUSED(argv);
20
21 /* Path is UNC */
22
23 _tcsncpy(Path, testPathUNC, ARRAYSIZE(Path));
24
25 status = PathIsUNCEx(Path, &Server);
26
27 if (!status)
28 {
29 _tprintf(_T("PathIsUNCEx status: 0x%d\n"), status);
30 return -1;
31 }
32
33 if (_tcsncmp(Server, testServer, ARRAYSIZE(testServer)) != 0)
34 {
35 _tprintf(_T("Server Name Mismatch: Actual: %s, Expected: %s\n"), Server, testServer);
36 return -1;
37 }
38
39 /* Path is not UNC */
40
41 _tcsncpy(Path, testPathNotUNC, ARRAYSIZE(Path));
42
43 status = PathIsUNCEx(Path, &Server);
44
45 if (status)
46 {
47 _tprintf(_T("PathIsUNCEx status: 0x%08") _T(PRIX32) _T("\n"), status);
48 return -1;
49 }
50
51 return 0;
52}