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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * _ __ ___ ___ __| | ___ ___| |
19 * | '_ ` _ \ / _ \ / _` | / __/ __| |
20 * | | | | | | (_) | (_| | \__ \__ \ | mod_ssl - Apache Interface to OpenSSL
21 * |_| |_| |_|\___/ \__,_|___|___/___/_| http://www.modssl.org/
26 /* ``Killing for peace is
27 like fucking for virginity.''
30 /* _________________________________________________________________
33 ** _________________________________________________________________
39 #include "ssl_expr_parse.h"
42 int yyinput(char *buf, int max_size);
45 #define YY_INPUT(buf,result,max_size) \
46 (result = yyinput(buf, max_size))
48 #define MAX_STR_LEN 2048
53 %option never-interactive
60 char caStr[MAX_STR_LEN];
62 char caRegex[MAX_STR_LEN];
74 * C-style strings ("...")
83 yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caStr);
87 yyerror("Unterminated string");
92 (void)sscanf(yytext+1, "%o", &result);
94 yyerror("Escape sequence out of bound");
99 yyerror("Bad escape sequence");
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'; }
107 *cpStr++ = yytext[1];
115 *cpStr++ = yytext[1];
122 cRegexDel = yytext[1];
127 if (yytext[0] == cRegexDel) {
132 *cpRegex++ = yytext[0];
136 yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
141 yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
146 <regex_flags><<EOF>> {
147 yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
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; }
180 "file" { return T_FUNC_FILE; }
185 "true" { return T_TRUE; }
186 "false" { return T_FALSE; }
192 yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, yytext);
199 [a-zA-Z][a-zA-Z0-9_:-]* {
200 yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, yytext);
205 * Anything else is returned as is...
213 int yyinput(char *buf, int max_size)
217 if ((n = MIN(max_size, ssl_expr_info.inputbuf
218 + ssl_expr_info.inputlen
219 - ssl_expr_info.inputptr)) <= 0)
221 memcpy(buf, ssl_expr_info.inputptr, n);
222 ssl_expr_info.inputptr += n;