58e79d31a18d4e2117bba26f12d560b198b6ac74
[reactos.git] / rosapps / sysutils / regexpl / Pattern.cpp
1 /* $Id: Pattern.cpp,v 1.1 2001/01/10 01:25:29 narnaoud Exp $
2 *
3 * regexpl - Console Registry Explorer
4 *
5 * Copyright (C) 2000 Nedko Arnaoudov <nedkohome@atia.com>
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 pszTry++;
36 pszPattern++;
37 }
38
39 if(*pszPattern == _T('*'))
40 {
41 pszPattern++;
42 while (*pszTry)
43 {
44 if (PatternMatch(pszPattern,pszTry))
45 return TRUE;
46 else
47 pszTry++;
48 }
49 }
50
51 if (((*pszTry) == 0) && ((*pszPattern) == 0))
52 return TRUE;
53
54 return FALSE;
55 }