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