2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Does `string' match `pattern'? '*' in pattern matches any sub-string
25 * (including the null string) '?' matches any single char. For use
26 * by filenameforall. Note that '*' matches across directory boundaries
28 * This code donated by Paul Hudson <paulh@harlequin.co.uk>
29 * It is public domain, no strings attached. No guarantees either.
32 int matchWildcards(const char *pattern
, const char *string
)
38 else if(strcmp(pattern
,"*")==0)
46 while (*string
&& *pattern
)
50 /* match any character */
54 else if (*pattern
== '*')
56 /* see if the rest of the pattern matches any trailing
57 * substring of the string. */
61 return 1; /* trailing * must match rest */
65 if (matchWildcards(pattern
,string
))
77 /* has strange, but harmless effects if the
78 * last character is a '\\' */
81 if (*pattern
++ != *string
++)
87 if((*pattern
== 0)&&(*string
== 0))
89 if((*string
== 0)&&(strcmp(pattern
,"*")==0))