Mon, 16 Jan 2017 14:41:20 +0100
fixes cgi cleanup
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * THE BSD LICENSE |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * Redistribution and use in source and binary forms, with or without |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * modification, are permitted provided that the following conditions are met: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * Redistributions of source code must retain the above copyright notice, this |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * list of conditions and the following disclaimer. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * Redistributions in binary form must reproduce the above copyright notice, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * this list of conditions and the following disclaimer in the documentation |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * and/or other materials provided with the distribution. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * Neither the name of the nor the names of its contributors may be |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * used to endorse or promote products derived from this software without |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * specific prior written permission. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | /* |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | * shexp.c: shell-like wildcard match routines |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | * See shexp.h for public documentation. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | * Rob McCool |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | * |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | #include <ctype.h> /* isalpha, tolower */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | #include "shexp.h" |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | /* |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | * The observant engineer will notice 2 distinct sets of functions here. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | * All of the noicmp flavor of functions do case sensitive compares on all |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | * platforms. The other set (public set) does case insensitive compares on NT. |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | int _shexp_match_noicmp(const char *str, const char *exp) ; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | /* ----------------------------- shexp_valid ------------------------------ */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | int valid_subexp(const char *exp, char stop) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | register int x,y,t; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | int nsc,np,tld; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | x=0;nsc=0;tld=0; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | while(exp[x] && (exp[x] != stop)) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | switch(exp[x]) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | case '~': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | if(tld) return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | else ++tld; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | case '*': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | case '?': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | case '^': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | case '$': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | ++nsc; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | case '[': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | ++nsc; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | if((!exp[++x]) || (exp[x] == ']')) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | for(++x;exp[x] && (exp[x] != ']');++x) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | if(exp[x] == '\\') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | if(!exp[++x]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | if(!exp[x]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | case '(': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | ++nsc; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | while(1) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | if(exp[++x] == ')') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | for(y=x;(exp[y]) && (exp[y] != '|') && (exp[y] != ')');++y) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | if(exp[y] == '\\') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | if(!exp[++y]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | if(!exp[y]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | t = valid_subexp(&exp[x],exp[y]); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | if(t == INVALID_SXP) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | x+=t; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | if(exp[x] == ')') { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | case ')': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | case ']': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | case '\\': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | if(!exp[++x]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | return INVALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | ++x; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | if((!stop) && (!nsc)) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | return NON_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | return ((exp[x] == stop) ? x : INVALID_SXP); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | NSAPI_PUBLIC int shexp_valid(const char *exp) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | int x; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | x = valid_subexp(exp, '\0'); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | if (x < 0) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | if (x == INVALID_SXP) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | //NsprError::setError(PR_INVALID_ARGUMENT_ERROR, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | // XP_GetAdminStr(DBT_invalidshexp)); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | // TODO |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | return x; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | return VALID_SXP; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | /* ----------------------------- shexp_match ----------------------------- */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | #define MATCH 0 |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | #define NOMATCH 1 |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | #define ABORTED -1 |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | int _shexp_match(const char *str, const char *exp); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | int handle_union(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | char *e2 = (char *) MALLOC(sizeof(char)*strlen(exp)); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | register int t,p2,p1 = 1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | int cp; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | while(1) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | for(cp=1;exp[cp] != ')';cp++) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | if(exp[cp] == '\\') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | ++cp; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | for(p2 = 0;(exp[p1] != '|') && (p1 != cp);p1++,p2++) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | if(exp[p1] == '\\') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | e2[p2++] = exp[p1++]; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | e2[p2] = exp[p1]; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | for(t=cp+1;(e2[p2] = exp[t]);++t,++p2); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | if(_shexp_match(str,e2) == MATCH) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | FREE(e2); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | if(p1 == cp) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | FREE(e2); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | return NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
173 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | else ++p1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | int handle_union_noicmp(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | char *e2 = (char *) MALLOC(sizeof(char)*strlen(exp)); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | register int t,p2,p1 = 1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
182 | int cp; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | while(1) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | for(cp=1;exp[cp] != ')';cp++) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | if(exp[cp] == '\\') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | ++cp; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | for(p2 = 0;(exp[p1] != '|') && (p1 != cp);p1++,p2++) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | if(exp[p1] == '\\') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | e2[p2++] = exp[p1++]; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | e2[p2] = exp[p1]; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | for(t=cp+1;(e2[p2] = exp[t]);++t,++p2); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | if(_shexp_match_noicmp(str,e2) == MATCH) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | FREE(e2); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
197 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | if(p1 == cp) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | FREE(e2); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | return NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | else ++p1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | int _shexp_match(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | register int x,y; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | int ret,neg; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | ret = 0; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | for(x=0,y=0;exp[y];++y,++x) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | if((!str[x]) && (exp[y] != '(') && (exp[y] != '$') && (exp[y] != '*')) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | ret = ABORTED; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | else { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | switch(exp[y]) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | case '$': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | if( (str[x]) ) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | else |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | --x; /* we don't want loop to increment x */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
222 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
223 | case '*': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | while(exp[++y] == '*'); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | if(!exp[y]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | while(str[x]) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | switch(_shexp_match(&str[x++],&exp[y])) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
229 | case NOMATCH: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | continue; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
231 | case ABORTED: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
232 | ret = ABORTED; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
233 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
234 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
235 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
236 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
237 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
238 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
239 | if((exp[y] == '$') && (exp[y+1] == '\0') && (!str[x])) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
240 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
241 | else |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
242 | ret = ABORTED; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
243 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
244 | case '[': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
245 | if((neg = ((exp[++y] == '^') && (exp[y+1] != ']')))) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
246 | ++y; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
247 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
248 | if((isalnum(exp[y])) && (exp[y+1] == '-') && |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
249 | (isalnum(exp[y+2])) && (exp[y+3] == ']')) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
250 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
251 | int start = exp[y], end = exp[y+2]; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
252 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
253 | /* Droolproofing for pinheads not included */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
254 | if(neg ^ ((str[x] < start) || (str[x] > end))) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
255 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
256 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
257 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
258 | y+=3; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
259 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
260 | else { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
261 | int matched; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
262 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
263 | for(matched=0;exp[y] != ']';y++) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
264 | matched |= (str[x] == exp[y]); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
265 | if(neg ^ (!matched)) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
266 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
267 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
268 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
269 | case '(': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
270 | return handle_union(&str[x],&exp[y]); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
271 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
272 | case '?': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
273 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
274 | case '\\': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
275 | ++y; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
276 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
277 | #ifdef XP_UNIX |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
278 | if(str[x] != exp[y]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
279 | #else /* XP_WIN32 */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
280 | if(strnicmp(str + x, exp + y, 1)) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
281 | #endif /* XP_WIN32 */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
282 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
283 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
284 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
285 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
286 | if(ret) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
287 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
288 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
289 | return (ret ? ret : (str[x] ? NOMATCH : MATCH)); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
290 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
291 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
292 | int _shexp_match_noicmp(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
293 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
294 | register int x,y; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
295 | int ret,neg; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
296 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
297 | ret = 0; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
298 | for(x=0,y=0;exp[y];++y,++x) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
299 | if((!str[x]) && (exp[y] != '(') && (exp[y] != '$') && (exp[y] != '*')) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
300 | ret = ABORTED; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
301 | else { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
302 | switch(exp[y]) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
303 | case '$': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
304 | if( (str[x]) ) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
305 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
306 | else |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
307 | --x; /* we don't want loop to increment x */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
308 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
309 | case '*': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
310 | while(exp[++y] == '*'); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
311 | if(!exp[y]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
312 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
313 | while(str[x]) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
314 | switch(_shexp_match_noicmp(&str[x++],&exp[y])) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
315 | case NOMATCH: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
316 | continue; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
317 | case ABORTED: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
318 | ret = ABORTED; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
319 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
320 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
321 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
322 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
323 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
324 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
325 | if((exp[y] == '$') && (exp[y+1] == '\0') && (!str[x])) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
326 | return MATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
327 | else |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
328 | ret = ABORTED; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
329 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
330 | case '[': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
331 | if((neg = ((exp[++y] == '^') && (exp[y+1] != ']')))) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
332 | ++y; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
333 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
334 | if((isalnum(exp[y])) && (exp[y+1] == '-') && |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
335 | (isalnum(exp[y+2])) && (exp[y+3] == ']')) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
336 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
337 | int start = exp[y], end = exp[y+2]; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
338 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
339 | /* Droolproofing for pinheads not included */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
340 | if(neg ^ ((str[x] < start) || (str[x] > end))) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
341 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
342 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
343 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
344 | y+=3; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
345 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
346 | else { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
347 | int matched; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
348 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
349 | for(matched=0;exp[y] != ']';y++) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
350 | matched |= (str[x] == exp[y]); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
351 | if(neg ^ (!matched)) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
352 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
353 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
354 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
355 | case '(': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
356 | return handle_union_noicmp(&str[x],&exp[y]); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
357 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | case '?': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
359 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
360 | case '\\': |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
361 | ++y; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
362 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
363 | if(str[x] != exp[y]) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
364 | ret = NOMATCH; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
365 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
366 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
367 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
368 | if(ret) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
369 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
370 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
371 | return (ret ? ret : (str[x] ? NOMATCH : MATCH)); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
372 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
373 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
374 | NSAPI_PUBLIC int shexp_match(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
375 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
376 | register int x; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
377 | char *expbase = NULL; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
378 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
379 | for(x=strlen(exp)-1;x;--x) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
380 | if((exp[x] == '~') && (exp[x-1] != '\\')) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
381 | /* we're done if the negative subexp matches */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
382 | if(_shexp_match(str,&exp[x+1]) == MATCH) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
383 | return 1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
384 | /* we're done if the only thing in front of the subexp is '*' */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
385 | if (x == 1 && exp[0] == '*') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
386 | return 0; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
387 | /* create a copy so we can strip off the subexp */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
388 | expbase = STRDUP(exp); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
389 | expbase[x] = '\0'; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
390 | exp = expbase; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
391 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
392 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
393 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
394 | if(_shexp_match(str,exp) == MATCH) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
395 | if (expbase) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
396 | FREE(expbase); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
397 | return 0; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
398 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
399 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
400 | if (expbase) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
401 | FREE(expbase); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
402 | return 1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
403 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
404 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
405 | NSAPI_PUBLIC int shexp_match_noicmp(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
406 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
407 | register int x; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
408 | char *expbase = NULL; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
409 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
410 | for(x=strlen(exp)-1;x;--x) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
411 | if((exp[x] == '~') && (exp[x-1] != '\\')) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
412 | /* we're done if the negative subexp matches */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
413 | if(_shexp_match_noicmp(str,&exp[x+1]) == MATCH) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
414 | return 1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
415 | /* we're done if the only thing in front of the subexp is '*' */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
416 | if (x == 1 && exp[0] == '*') |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
417 | return 0; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
418 | /* create a copy so we can strip off the subexp */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
419 | expbase = STRDUP(exp); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
420 | expbase[x] = '\0'; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
421 | exp = expbase; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
422 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
423 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
424 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
425 | if(_shexp_match_noicmp(str,exp) == MATCH) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
426 | if (expbase) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
427 | FREE(expbase); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
428 | return 0; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
429 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
430 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
431 | if (expbase) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
432 | FREE(expbase); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
433 | return 1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
434 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
435 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
436 | /* ------------------------------ shexp_cmp ------------------------------- */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
437 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
438 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
439 | NSAPI_PUBLIC int shexp_cmp(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
440 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
441 | switch(shexp_valid(exp)) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
442 | case INVALID_SXP: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
443 | return -1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
444 | case NON_SXP: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
445 | #ifdef XP_UNIX |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
446 | return (strcmp(exp,str) ? 1 : 0); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
447 | #else /* XP_WIN32 */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
448 | return (stricmp(exp,str) ? 1 : 0); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
449 | #endif /* XP_WIN32 */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
450 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
451 | return shexp_match(str, exp); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
452 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
453 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
454 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
455 | /* ------------------------------ shexp_cmp ------------------------------- */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
456 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
457 | NSAPI_PUBLIC int shexp_noicmp(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
458 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
459 | switch(shexp_valid(exp)) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
460 | case INVALID_SXP: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
461 | return -1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
462 | case NON_SXP: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
463 | return (strcmp(exp,str) ? 1 : 0); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
464 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
465 | return shexp_match_noicmp(str, exp); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
466 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
467 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
468 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
469 | /* ---------------------------- shexp_casecmp ----------------------------- */ |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
470 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
471 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
472 | NSAPI_PUBLIC int shexp_casecmp(const char *str, const char *exp) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
473 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
474 | char *lstr = STRDUP(str), *lexp = STRDUP(exp), *t; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
475 | int ret; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
476 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
477 | for(t = lstr; *t; t++) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
478 | if(isalpha(*t)) *t = tolower(*t); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
479 | for(t = lexp; *t; t++) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
480 | if(isalpha(*t)) *t = tolower(*t); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
481 | |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
482 | switch(shexp_valid(lexp)) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
483 | case INVALID_SXP: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
484 | ret = -1; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
485 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
486 | case NON_SXP: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
487 | ret = (strcmp(lexp, lstr) ? 1 : 0); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
488 | break; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
489 | default: |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
490 | ret = shexp_match(lstr, lexp); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
491 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
492 | FREE(lstr); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
493 | FREE(lexp); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
494 | return ret; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
495 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
496 |