"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "lha-114i/src/patmatch.c" of archive lha-114i.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /* ------------------------------------------------------------------------ */
2 /* LHa for UNIX */
3 /* patmatch.c -- path check */
4 /* */
5 /* Modified Nobutaka Watazaki */
6 /* */
7 /* Ver. 1.14 Source All chagned 1995.01.14 N.Watazaki */
8 /* ------------------------------------------------------------------------ */
9
10 #include <stdio.h>
11 #include <ctype.h>
12 /*
13 * Returns true if string s matches pattern p.
14 */
15 int
16 patmatch(p, s, f)
17 register char *p; /* pattern */
18 register char *s; /* string to match */
19 int f; /* flag for case force */
20 {
21 char pc; /* a single character from pattern */
22
23 while (pc = ((f && islower(*p)) ? toupper(*p++) : *p++)) {
24 if (pc == '*') {
25 do { /* look for match till s exhausted */
26 if (patmatch(p, s, f))
27 return (1);
28 } while (*s++);
29 return (0);
30 }
31 else if (*s == 0)
32 return (0); /* s exhausted, p not */
33 else if (pc == '?')
34 s++; /* matches all, just bump */
35 else if (pc != ((f && islower(*s)) ? toupper(*s++) : *s++))
36 return (0);
37 }
38 return (!*s); /* p exhausted, ret true if s exhausted */
39 }