ssl_expr_scan.l revision 031b91a62d25106ae69d4693475c79618dd5e884
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff/* Licensed to the Apache Software Foundation (ASF) under one or more
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * contributor license agreements. See the NOTICE file distributed with
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * this work for additional information regarding copyright ownership.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * The ASF licenses this file to You under the Apache License, Version 2.0
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * (the "License"); you may not use this file except in compliance with
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * the License. You may obtain a copy of the License at
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * Unless required by applicable law or agreed to in writing, software
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * distributed under the License is distributed on an "AS IS" BASIS,
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * See the License for the specific language governing permissions and
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff * limitations under the License.
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * _ __ ___ ___ __| | ___ ___| |
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * | '_ ` _ \ / _ \ / _` | / __/ __| |
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * | | | | | | (_) | (_| | \__ \__ \ | mod_ssl - Apache Interface to OpenSSL
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * |_| |_| |_|\___/ \__,_|___|___/___/_| http://www.modssl.org/
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * ssl_expr_scan.l
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * Expression Scanner
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff /* ``Killing for peace is
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff like fucking for virginity.''
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff -- Unknown */
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff/* _________________________________________________________________
64828244e04e86dfa40f0a4f0c05f27923da499dMichael Graff** Expression Scanner
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff** _________________________________________________________________
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff/* %option stack */
31fab17bcdbe302592a6c0dc5374ef56333ee879Michael Graff * Whitespaces
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff * C-style strings ("...")
ebdd11e84734e28ddd64562e82a7c646a58a04f4Michael Graff cpStr = caStr;
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff BEGIN(INITIAL);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff *cpStr = NUL;
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caStr);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff return T_STRING;
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff<str>\\[0-7]{1,3} {
66bd3b3c6b171271c705b897823dcdcf29464698Michael Graff if (result > 0xff)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff *cpStr++ = result;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff<str>\\[0-9]+ {
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff<str>\\n { *cpStr++ = '\n'; }
11efdeb076d65fa9f0c5fc067dc040e7c99dfba6Michael Graff<str>\\r { *cpStr++ = '\r'; }
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff<str>\\t { *cpStr++ = '\t'; }
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff<str>\\b { *cpStr++ = '\b'; }
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff<str>\\f { *cpStr++ = '\f'; }
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff<str>\\(.|\n) {
30251e07d1705d1a85b0e1d5a969496e1aed612eMichael Graff *cpStr++ = yytext[1];
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff<str>[^\\\n\"]+ {
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff char *cp = yytext;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff while (*cp != NUL)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff *cpStr++ = *cp++;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff *cpStr++ = yytext[1];
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff * Regular Expression
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff cRegexDel = yytext[1];
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff cpRegex = caRegex;
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff BEGIN(regex);
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff if (yytext[0] == cRegexDel) {
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff *cpRegex = NUL;
213973a334f92d4aef4ef62b4538fc2e4d0e8082Michael Graff BEGIN(regex_flags);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff *cpRegex++ = yytext[0];
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff<regex_flags>i {
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff BEGIN(INITIAL);
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff return T_REGEX_I;
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff<regex_flags>.|\n {
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff BEGIN(INITIAL);
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff return T_REGEX;
1f90c108282533a23b8362c34bcde4267c1eb4b1Michael Graff<regex_flags><<EOF>> {
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, caRegex);
a253e35c2451818fb39f9b808c7641adb5275fb3Michael Graff BEGIN(INITIAL);
ebdd11e84734e28ddd64562e82a7c646a58a04f4Michael Graff return T_REGEX;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff[Pp][Ee][Ee][Rr][Ee][Xx][Tt][Ll][Ii][Ss][Tt] { return T_OP_PEEREXTLIST; }
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, yytext);
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff return T_DIGIT;
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff * Identifiers
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff[a-zA-Z][a-zA-Z0-9_:-]* {
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff yylval.cpVal = apr_pstrdup(ssl_expr_info.pool, yytext);
439c0011e642fb1d26011116144af698125262dbMichael Graff * Anything else is returned as is...
f181f94ec8da8b1dbcc6353e8be965ea4a5ea282Michael Graff return yytext[0];
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graffint yyinput(char *buf, int max_size)
11fcc67616fac1bc6a28b3d4fed24641137888e7Michael Graff if ((n = MIN(max_size, ssl_expr_info.inputbuf
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff + ssl_expr_info.inputlen
ad3a5c4b7e21af04d1b872f933c2e19e5c0a135bMichael Graff - ssl_expr_info.inputptr)) <= 0)
d8590892d10fc9528b0dde7e2781935e7b8d7a87Michael Graff return YY_NULL;
439c0011e642fb1d26011116144af698125262dbMichael Graff memcpy(buf, ssl_expr_info.inputptr, n);
439c0011e642fb1d26011116144af698125262dbMichael Graff ssl_expr_info.inputptr += n;