fix include file case
[reactos.git] / rosapps / sysutils / regexpl / Pattern.cpp
1 /* $Id$
2 *
3 * regexpl - Console Registry Explorer
4 *
5 * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23 // Pattern.cpp: implementation of pattern functions
24
25 #include "ph.h"
26
27 // based on wstrcmpjoki() by Jason Filby (jasonfilby@yahoo.com)
28 // reactos kernel, services/fs/vfat/string.c
29 BOOL PatternMatch(const TCHAR *pszPattern, const TCHAR *pszTry)
30 {
31 while ((*pszPattern == _T('?'))||((_totlower(*pszTry)) == (_totlower(*pszPattern))))
32 {
33 if (((*pszTry) == 0) && ((*pszPattern) == 0))
34 return TRUE;
35
36 if (((*pszTry) == 0) || ((*pszPattern) == 0))
37 return FALSE;
38
39 pszTry++;
40 pszPattern++;
41 }
42
43 if (*pszPattern == _T('*'))
44 {
45 pszPattern++;
46 while (*pszTry)
47 {
48 if (PatternMatch(pszPattern,pszTry))
49 return TRUE;
50 else
51 pszTry++;
52 }
53 }
54
55 if (((*pszTry) == 0) && ((*pszPattern) == 0))
56 return TRUE;
57
58 return FALSE;
59 }