~ubuntu-branches/ubuntu/feisty/apache2/feisty-updates

« back to all changes in this revision

Viewing changes to modules/ssl/ssl_expr_scan.l

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Licensed to the Apache Software Foundation (ASF) under one or more
 
2
 * contributor license agreements.  See the NOTICE file distributed with
 
3
 * this work for additional information regarding copyright ownership.
 
4
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
5
 * (the "License"); you may not use this file except in compliance with
 
6
 * the License.  You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
/*                      _             _ 
 
18
 *  _ __ ___   ___   __| |    ___ ___| |  
 
19
 * | '_ ` _ \ / _ \ / _` |   / __/ __| |  
 
20
 * | | | | | | (_) | (_| |   \__ \__ \ | mod_ssl - Apache Interface to OpenSSL
 
21
 * |_| |_| |_|\___/ \__,_|___|___/___/_| http://www.modssl.org/
 
22
 *                      |_____|         
 
23
 *  ssl_expr_scan.l
 
24
 *  Expression Scanner
 
25
 */
 
26
                             /* ``Killing for peace is 
 
27
                                  like fucking for virginity.''
 
28
                                             -- Unknown  */
 
29
 
 
30
/*  _________________________________________________________________
 
31
**
 
32
**  Expression Scanner
 
33
**  _________________________________________________________________
 
34
*/
 
35
 
 
36
%{
 
37
#include "ssl_private.h"
 
38
 
 
39
#include "ssl_expr_parse.h"
 
40
 
 
41
#define YY_NO_UNPUT 1
 
42
int yyinput(char *buf, int max_size);
 
43
 
 
44
#undef  YY_INPUT
 
45
#define YY_INPUT(buf,result,max_size) \
 
46
    (result = yyinput(buf, max_size))
 
47
 
 
48
#define MAX_STR_LEN 2048
 
49
%}
 
50
 
 
51
%pointer
 
52
/* %option stack */
 
53
%option never-interactive
 
54
%option noyywrap
 
55
%x str
 
56
%x regex regex_flags
 
57
 
 
58
%%
 
59
  
 
60
  char  caStr[MAX_STR_LEN];
 
61
  char *cpStr = NULL;
 
62
  char  caRegex[MAX_STR_LEN];
 
63
  char *cpRegex = NULL;
 
64
  char  cRegexDel = NUL;
 
65
 
 
66
 /*
 
67
  * Whitespaces
 
68
  */
 
69
[ \t\n]+ { 
 
70
    /* NOP */
 
71
}
 
72
 
 
73
 /*
 
74
  * C-style strings ("...")
 
75
  */
 
76
\" {
 
77
    cpStr = caStr;
 
78
    BEGIN(str);
 
79
}
 
80
<str>\" {
 
81
    BEGIN(INITIAL);
 
82
    *cpStr = NUL;
 
83
    yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caStr);
 
84
    return T_STRING;
 
85
}
 
86
<str>\n {
 
87
    yyerror("Unterminated string");
 
88
}
 
89
<str>\\[0-7]{1,3} {
 
90
    int result;
 
91
 
 
92
    (void)sscanf(yytext+1, "%o", &result);
 
93
    if (result > 0xff)
 
94
        yyerror("Escape sequence out of bound");
 
95
    else
 
96
        *cpStr++ = result;
 
97
}
 
98
<str>\\[0-9]+ {
 
99
    yyerror("Bad escape sequence");
 
100
}
 
101
<str>\\n { *cpStr++ = '\n'; }
 
102
<str>\\r { *cpStr++ = '\r'; }
 
103
<str>\\t { *cpStr++ = '\t'; }
 
104
<str>\\b { *cpStr++ = '\b'; }
 
105
<str>\\f { *cpStr++ = '\f'; }
 
106
<str>\\(.|\n) {
 
107
    *cpStr++ = yytext[1];
 
108
}
 
109
<str>[^\\\n\"]+ {
 
110
    char *cp = yytext;
 
111
    while (*cp != NUL)
 
112
        *cpStr++ = *cp++;
 
113
}
 
114
<str>. {
 
115
    *cpStr++ = yytext[1];
 
116
}
 
117
 
 
118
 /*
 
119
  * Regular Expression
 
120
  */
 
121
"m". {
 
122
    cRegexDel = yytext[1];
 
123
    cpRegex = caRegex;
 
124
    BEGIN(regex);
 
125
}
 
126
<regex>.|\n {
 
127
    if (yytext[0] == cRegexDel) {
 
128
        *cpRegex = NUL;
 
129
        BEGIN(regex_flags);
 
130
    }
 
131
    else {
 
132
        *cpRegex++ = yytext[0];
 
133
    }
 
134
}
 
135
<regex_flags>i {
 
136
    yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
 
137
    BEGIN(INITIAL);
 
138
    return T_REGEX_I;
 
139
}
 
140
<regex_flags>.|\n {
 
141
    yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
 
142
    yyless(0);
 
143
    BEGIN(INITIAL);
 
144
    return T_REGEX;
 
145
}
 
146
<regex_flags><<EOF>> {
 
147
    yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
 
148
    BEGIN(INITIAL);
 
149
    return T_REGEX;
 
150
}
 
151
 
 
152
 /*
 
153
  * Operators
 
154
  */
 
155
"eq"  { return T_OP_EQ; }
 
156
"=="  { return T_OP_EQ; }
 
157
"ne"  { return T_OP_NE; }
 
158
"!="  { return T_OP_NE; }
 
159
"lt"  { return T_OP_LT; }
 
160
"<"   { return T_OP_LT; }
 
161
"le"  { return T_OP_LE; }
 
162
"<="  { return T_OP_LE; }
 
163
"gt"  { return T_OP_GT; }
 
164
">"   { return T_OP_GT; }
 
165
"ge"  { return T_OP_GE; }
 
166
">="  { return T_OP_GE; }
 
167
"=~"  { return T_OP_REG; }
 
168
"!~"  { return T_OP_NRE; }
 
169
"and" { return T_OP_AND; }
 
170
"&&"  { return T_OP_AND; }
 
171
"or"  { return T_OP_OR; }
 
172
"||"  { return T_OP_OR; }
 
173
"not" { return T_OP_NOT; }
 
174
"!"   { return T_OP_NOT; }
 
175
"in"  { return T_OP_IN; }
 
176
[Oo][Ii][Dd] { return T_OP_OID; }
 
177
 
 
178
 /*
 
179
  * Functions
 
180
  */
 
181
"file" { return T_FUNC_FILE; }
 
182
 
 
183
 /*
 
184
  * Specials
 
185
  */
 
186
"true"  { return T_TRUE; }
 
187
"false" { return T_FALSE; }
 
188
 
 
189
 /*
 
190
  * Digits
 
191
  */
 
192
[0-9]+ {
 
193
    yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, yytext);
 
194
    return T_DIGIT;
 
195
}
 
196
 
 
197
 /*
 
198
  * Identifiers
 
199
  */
 
200
[a-zA-Z][a-zA-Z0-9_:-]* {
 
201
    yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, yytext);
 
202
    return T_ID;
 
203
}
 
204
 
 
205
 /*
 
206
  * Anything else is returned as is...
 
207
  */
 
208
.|\n { 
 
209
    return yytext[0];
 
210
}
 
211
 
 
212
%%
 
213
 
 
214
int yyinput(char *buf, int max_size)
 
215
{
 
216
    int n;
 
217
 
 
218
    if ((n = MIN(max_size, ssl_expr_info.inputbuf
 
219
                         + ssl_expr_info.inputlen 
 
220
                         - ssl_expr_info.inputptr)) <= 0)
 
221
        return YY_NULL;
 
222
    memcpy(buf, ssl_expr_info.inputptr, n);
 
223
    ssl_expr_info.inputptr += n;
 
224
    return n;
 
225
}
 
226