1 kumpf 1.2 /*
|
2 martin 1.4 //%LICENSE////////////////////////////////////////////////////////////////
|
3 martin 1.5 //
|
4 martin 1.4 // Licensed to The Open Group (TOG) under one or more contributor license
5 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
6 // this work for additional information regarding copyright ownership.
7 // Each contributor licenses this file to you under the OpenPegasus Open
8 // Source License; you may not use this file except in compliance with the
9 // License.
|
10 martin 1.5 //
|
11 martin 1.4 // Permission is hereby granted, free of charge, to any person obtaining a
12 // copy of this software and associated documentation files (the "Software"),
13 // to deal in the Software without restriction, including without limitation
14 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 // and/or sell copies of the Software, and to permit persons to whom the
16 // Software is furnished to do so, subject to the following conditions:
|
17 martin 1.5 //
|
18 martin 1.4 // The above copyright notice and this permission notice shall be included
19 // in all copies or substantial portions of the Software.
|
20 martin 1.5 //
|
21 martin 1.4 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
22 martin 1.5 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23 martin 1.4 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28 martin 1.5 //
|
29 martin 1.4 //////////////////////////////////////////////////////////////////////////
|
30 kumpf 1.2 */
31
32 #ifndef _Executor_Match_h
33 #define _Executor_Match_h
34
35 #include "Defines.h"
36
|
37 mike 1.3 static int Match(const char* pattern, const char* str)
38 {
39 const char* p;
40 const char* q;
41
42 /* Now match expression to str. */
43
44 for (p = pattern, q = str; *p && *q; )
45 {
46 if (*p == '*')
47 {
48 const char* r;
49
50 p++;
51
52 /* Recursively call to find the shortest match. */
53
54 for (r = q; *r; r++)
55 {
56 if (Match(p, r) == 0)
57 break;
58 mike 1.3 }
59
60 q = r;
61
62 }
63 else if (*p == *q)
64 {
65 p++;
66 q++;
67 }
68 else
69 return -1;
70 }
71
72 /* If src was exhausted but pattern has a single '*' remaining charcters,
73 * then match the result.
74 */
75
76 if (p[0] == '*' && p[1] == '\0')
77 return 0;
78
79 mike 1.3 /* If anything left over, then they do not match. */
80
81 if (*p || *q)
82 return -1;
83
84 return 0;
85 }
|
86 kumpf 1.2
87 #endif /* _Executor_Match_h */
|