ReactOS 0.4.15-dev-7953-g1f49173
PathFindOnPath.c File Reference
#include <apitest.h>
#include <shlwapi.h>
#include <assert.h>
#include <pseh/pseh2.h>
Include dependency graph for PathFindOnPath.c:

Go to the source code of this file.

Classes

struct  ENTRY
 

Macros

#define EF_FULLPATH   1
 
#define EF_TESTDATA   2
 
#define EF_WIN_DIR   4
 
#define EF_SYS_DIR   8
 
#define EF_TYPE_MASK   0xF
 
#define EF_NAME_ONLY   16
 
#define BEEF   0xBEEF /* Error Code 48879 */
 
#define DEAD   0xDEAD /* Error Code 57005 */
 
#define IGNORE_ERR   0x7F7F7F7F /* Ignore Error Code */
 
#define RAISED   9999 /* exception raised */
 

Typedefs

typedef struct ENTRY ENTRY
 

Functions

static void DoEntry (INT EntryNumber, const ENTRY *pEntry, const WCHAR *PathVar)
 
static void Test_PathFindOnPathW (void)
 
 START_TEST (PathFindOnPath)
 

Variables

static WCHAR s_TestDataPath [MAX_PATH]
 
static LPWSTR s_Dirs [2]
 
static WCHAR s_WinDir [MAX_PATH]
 
static WCHAR s_SysDir [MAX_PATH]
 
static WCHAR s_FontsDir [MAX_PATH]
 
static WCHAR s_NotepadPath [MAX_PATH]
 
static const ENTRY s_Entries []
 

Macro Definition Documentation

◆ BEEF

#define BEEF   0xBEEF /* Error Code 48879 */

Definition at line 45 of file PathFindOnPath.c.

◆ DEAD

#define DEAD   0xDEAD /* Error Code 57005 */

Definition at line 46 of file PathFindOnPath.c.

◆ EF_FULLPATH

#define EF_FULLPATH   1

Definition at line 25 of file PathFindOnPath.c.

◆ EF_NAME_ONLY

#define EF_NAME_ONLY   16

Definition at line 31 of file PathFindOnPath.c.

◆ EF_SYS_DIR

#define EF_SYS_DIR   8

Definition at line 28 of file PathFindOnPath.c.

◆ EF_TESTDATA

#define EF_TESTDATA   2

Definition at line 26 of file PathFindOnPath.c.

◆ EF_TYPE_MASK

#define EF_TYPE_MASK   0xF

Definition at line 29 of file PathFindOnPath.c.

◆ EF_WIN_DIR

#define EF_WIN_DIR   4

Definition at line 27 of file PathFindOnPath.c.

◆ IGNORE_ERR

#define IGNORE_ERR   0x7F7F7F7F /* Ignore Error Code */

Definition at line 47 of file PathFindOnPath.c.

◆ RAISED

#define RAISED   9999 /* exception raised */

Definition at line 48 of file PathFindOnPath.c.

Typedef Documentation

◆ ENTRY

typedef struct ENTRY ENTRY

Function Documentation

◆ DoEntry()

static void DoEntry ( INT  EntryNumber,
const ENTRY pEntry,
const WCHAR PathVar 
)
static

Definition at line 160 of file PathFindOnPath.c.

161{
162 WCHAR Path[MAX_PATH], PathExpected[MAX_PATH], OldPathVar[256];
163 INT Ret;
164 DWORD Error;
165
166 if (pEntry->NameBefore == NULL)
167 {
168 assert(pEntry->NameExpected == NULL);
169 assert(pEntry->PathExpected == NULL);
170 }
171
172 switch (pEntry->EF_ & EF_TYPE_MASK)
173 {
174 case EF_FULLPATH:
175 if (pEntry->NameBefore)
176 {
177 lstrcpyW(Path, pEntry->NameBefore);
178 }
179 if (pEntry->NameExpected)
180 {
181 lstrcpyW(PathExpected, pEntry->NameExpected);
182 }
183 break;
184
185 case EF_TESTDATA:
186 if (pEntry->EF_ & EF_NAME_ONLY)
187 {
188 lstrcpyW(Path, pEntry->NameBefore);
189 }
190 else
191 {
193 lstrcatW(Path, L"\\");
194 lstrcatW(Path, pEntry->NameBefore);
195 }
196
197 if (pEntry->NameExpected)
198 {
199 lstrcpyW(PathExpected, s_TestDataPath);
200 lstrcatW(PathExpected, L"\\");
201 lstrcatW(PathExpected, pEntry->NameExpected);
202 }
203 break;
204
205 case EF_WIN_DIR:
206 if (pEntry->EF_ & EF_NAME_ONLY)
207 {
208 lstrcpyW(Path, pEntry->NameBefore);
209 }
210 else
211 {
213 lstrcatW(Path, L"\\");
214 lstrcatW(Path, pEntry->NameBefore);
215 }
216
217 if (pEntry->NameExpected)
218 {
219 GetWindowsDirectoryW(PathExpected, _countof(PathExpected));
220 lstrcatW(PathExpected, L"\\");
221 lstrcatW(PathExpected, pEntry->NameExpected);
222 }
223 break;
224
225 case EF_SYS_DIR:
226 if (pEntry->EF_ & EF_NAME_ONLY)
227 {
228 lstrcpyW(Path, pEntry->NameBefore);
229 }
230 else
231 {
233 lstrcatW(Path, L"\\");
234 lstrcatW(Path, pEntry->NameBefore);
235 }
236
237 if (pEntry->NameExpected)
238 {
239 GetSystemDirectoryW(PathExpected, _countof(PathExpected));
240 lstrcatW(PathExpected, L"\\");
241 lstrcatW(PathExpected, pEntry->NameExpected);
242 }
243 break;
244 }
245
246 if (PathVar)
247 {
248 if (!GetEnvironmentVariableW(L"PATH", OldPathVar, _countof(OldPathVar)))
249 {
250 skip("#%d: GetEnvironmentVariableW failed\n", EntryNumber);
251 return;
252 }
253 if (!SetEnvironmentVariableW(L"PATH", PathVar))
254 {
255 skip("#%d: SetEnvironmentVariableW failed\n", EntryNumber);
256 return;
257 }
258 }
259
261 {
263 if (pEntry->NameBefore)
264 {
265 Ret = PathFindOnPathW(Path, (LPCWSTR *)pEntry->Dirs);
266 }
267 else
268 {
269 Ret = PathFindOnPathW(NULL, (LPCWSTR *)pEntry->Dirs);
270 }
272 }
274 {
275 Ret = RAISED;
276 Error = DEAD;
277 }
278 _SEH2_END;
279
280 if (PathVar)
281 {
282 ok(SetEnvironmentVariableW(L"PATH", OldPathVar),
283 "#%d: SetEnvironmentVariableW failed\n", EntryNumber);
284 }
285
286 ok(Ret == pEntry->Ret, "#%d: Ret expected %d, was %d.\n",
287 EntryNumber, pEntry->Ret, Ret);
288
289 if (pEntry->Error != IGNORE_ERR)
290 {
291 ok(Error == pEntry->Error, "#%d: last error expected %ld, was %ld.\n",
292 EntryNumber, pEntry->Error, Error);
293 }
294
295 if (pEntry->PathExpected)
296 {
297 ok(lstrcmpiW(Path, pEntry->PathExpected) == 0, "#%d: Path expected %s, was %s.\n",
298 EntryNumber, wine_dbgstr_w(pEntry->PathExpected), wine_dbgstr_w(Path));
299 }
300 else if (pEntry->NameExpected)
301 {
302 ok(lstrcmpiW(Path, PathExpected) == 0, "#%d: Path expected %s, was %s.\n",
303 EntryNumber, wine_dbgstr_w(PathExpected), wine_dbgstr_w(Path));
304 }
305}
#define EF_FULLPATH
#define BEEF
#define EF_WIN_DIR
#define DEAD
#define IGNORE_ERR
#define EF_NAME_ONLY
#define EF_TYPE_MASK
#define EF_SYS_DIR
static WCHAR s_TestDataPath[MAX_PATH]
#define RAISED
#define EF_TESTDATA
PRTL_UNICODE_STRING_BUFFER Path
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
BOOL Error
Definition: chkdsk.c:66
#define NULL
Definition: types.h:112
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
BOOL WINAPI PathFindOnPathW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs)
Definition: path.c:1403
#define assert(x)
Definition: debug.h:53
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define wine_dbgstr_w
Definition: kernel32.h:34
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define L(x)
Definition: ntvdm.h:50
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _countof(array)
Definition: sndvol32.h:68
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by Test_PathFindOnPathW().

◆ START_TEST()

START_TEST ( PathFindOnPath  )

Definition at line 317 of file PathFindOnPath.c.

318{
319 LPWSTR pch;
320
323
325 lstrcatW(s_FontsDir, L"\\Fonts");
326
328 lstrcatW(s_NotepadPath, L"\\notepad.exe");
329
331 pch = wcsrchr(s_TestDataPath, L'\\');
332 if (pch == NULL)
334 if (pch == NULL)
335 {
336 skip("GetModuleFileName and/or wcsrchr are insane.\n");
337 return;
338 }
339 lstrcpyW(pch, L"\\testdata");
341 {
342 skip("testdata is not found.\n");
343 return;
344 }
345
347 s_Dirs[1] = NULL;
348
350}
static WCHAR s_NotepadPath[MAX_PATH]
static WCHAR s_FontsDir[MAX_PATH]
static WCHAR s_SysDir[MAX_PATH]
static WCHAR s_WinDir[MAX_PATH]
static void Test_PathFindOnPathW(void)
static LPWSTR s_Dirs[2]
#define wcsrchr
Definition: compat.h:16
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
#define pch(ap)
Definition: match.c:418
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ Test_PathFindOnPathW()

static void Test_PathFindOnPathW ( void  )
static

Definition at line 307 of file PathFindOnPath.c.

308{
309 UINT i;
310
311 for (i = 0; i < _countof(s_Entries); ++i)
312 {
313 DoEntry(s_Entries[i].EntryNumber, &s_Entries[i], NULL);
314 }
315}
static const ENTRY s_Entries[]
static void DoEntry(INT EntryNumber, const ENTRY *pEntry, const WCHAR *PathVar)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

Variable Documentation

◆ s_Dirs

LPWSTR s_Dirs[2]
static

Definition at line 51 of file PathFindOnPath.c.

Referenced by START_TEST().

◆ s_Entries

const ENTRY s_Entries[]
static

Definition at line 57 of file PathFindOnPath.c.

Referenced by Test_PathFindOnPathW().

◆ s_FontsDir

WCHAR s_FontsDir[MAX_PATH]
static

Definition at line 54 of file PathFindOnPath.c.

Referenced by START_TEST().

◆ s_NotepadPath

WCHAR s_NotepadPath[MAX_PATH]
static

Definition at line 55 of file PathFindOnPath.c.

Referenced by START_TEST().

◆ s_SysDir

WCHAR s_SysDir[MAX_PATH]
static

Definition at line 53 of file PathFindOnPath.c.

Referenced by START_TEST().

◆ s_TestDataPath

WCHAR s_TestDataPath[MAX_PATH]
static

Definition at line 50 of file PathFindOnPath.c.

Referenced by DoEntry(), and START_TEST().

◆ s_WinDir

WCHAR s_WinDir[MAX_PATH]
static

Definition at line 52 of file PathFindOnPath.c.

Referenced by START_TEST().