1 /* _ _
2 ** _ __ ___ ___ __| | ___ ___| | mod_ssl
3 ** | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
4 ** | | | | | | (_) | (_| | \__ \__ \ | www.modssl.org
5 ** |_| |_| |_|\___/ \__,_|___|___/___/_| ftp.modssl.org
6 ** |_____|
7 ** ssl_expr.c
8 ** Expression Handling
9 */
10
11 /* ====================================================================
12 * Copyright (c) 1998-2003 Ralf S. Engelschall. All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
25 *
26 * 3. All advertising materials mentioning features or use of this
27 * software must display the following acknowledgment:
28 * "This product includes software developed by
29 * Ralf S. Engelschall <rse@engelschall.com> for use in the
30 * mod_ssl project (http://www.modssl.org/)."
31 *
32 * 4. The names "mod_ssl" must not be used to endorse or promote
33 * products derived from this software without prior written
34 * permission. For written permission, please contact
35 * rse@engelschall.com.
36 *
37 * 5. Products derived from this software may not be called "mod_ssl"
38 * nor may "mod_ssl" appear in their names without prior
39 * written permission of Ralf S. Engelschall.
40 *
41 * 6. Redistributions of any form whatsoever must retain the following
42 * acknowledgment:
43 * "This product includes software developed by
44 * Ralf S. Engelschall <rse@engelschall.com> for use in the
45 * mod_ssl project (http://www.modssl.org/)."
46 *
47 * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
48 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
50 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR
51 * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
56 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
57 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58 * OF THE POSSIBILITY OF SUCH DAMAGE.
59 * ====================================================================
60 */
61 /* ``It is hard to fly with
62 the eagles when you work
63 with the turkeys.''
64 -- Unknown */
65 #include "mod_ssl.h"
66
67
68 /* _________________________________________________________________
69 **
70 ** Expression Handling
71 ** _________________________________________________________________
72 */
73
74 ssl_expr_info_type ssl_expr_info;
75 char *ssl_expr_error;
76
ssl_expr_comp(pool * p,char * expr)77 ssl_expr *ssl_expr_comp(pool *p, char *expr)
78 {
79 ssl_expr_info.pool = p;
80 ssl_expr_info.inputbuf = expr;
81 ssl_expr_info.inputlen = strlen(expr);
82 ssl_expr_info.inputptr = ssl_expr_info.inputbuf;
83 ssl_expr_info.expr = FALSE;
84
85 ssl_expr_error = NULL;
86 if (ssl_expr_yyparse())
87 return NULL;
88 return ssl_expr_info.expr;
89 }
90
ssl_expr_get_error(void)91 char *ssl_expr_get_error(void)
92 {
93 if (ssl_expr_error == NULL)
94 return "";
95 return ssl_expr_error;
96 }
97
ssl_expr_make(ssl_expr_node_op op,void * a1,void * a2)98 ssl_expr *ssl_expr_make(ssl_expr_node_op op, void *a1, void *a2)
99 {
100 ssl_expr *node;
101
102 node = (ssl_expr *)ap_palloc(ssl_expr_info.pool, sizeof(ssl_expr));
103 node->node_op = op;
104 node->node_arg1 = (char *)a1;
105 node->node_arg2 = (char *)a2;
106 return node;
107 }
108
ssl_expr_exec(request_rec * r,ssl_expr * expr)109 int ssl_expr_exec(request_rec *r, ssl_expr *expr)
110 {
111 BOOL rc;
112
113 rc = ssl_expr_eval(r, expr);
114 if (ssl_expr_error != NULL)
115 return (-1);
116 else
117 return (rc ? 1 : 0);
118 }
119
120