upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / modules / ssl / ssl_expr.c
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  *  _ __ ___   ___   __| |    ___ ___| |  mod_ssl
19  * | '_ ` _ \ / _ \ / _` |   / __/ __| |  Apache Interface to OpenSSL
20  * | | | | | | (_) | (_| |   \__ \__ \ |
21  * |_| |_| |_|\___/ \__,_|___|___/___/_|
22  *                      |_____|
23  *  ssl_expr.c
24  *  Expression Handling
25  */
26                              /* ``It is hard to fly with
27                                   the eagles when you work
28                                   with the turkeys.''
29                                           -- Unknown  */
30 #include "mod_ssl.h"
31
32 /*  _________________________________________________________________
33 **
34 **  Expression Handling
35 **  _________________________________________________________________
36 */
37
38 ssl_expr_info_type ssl_expr_info;
39 char              *ssl_expr_error;
40
41 ssl_expr *ssl_expr_comp(apr_pool_t *p, char *expr)
42 {
43     ssl_expr_info.pool       = p;
44     ssl_expr_info.inputbuf   = expr;
45     ssl_expr_info.inputlen   = strlen(expr);
46     ssl_expr_info.inputptr   = ssl_expr_info.inputbuf;
47     ssl_expr_info.expr       = FALSE;
48
49     ssl_expr_error = NULL;
50     if (ssl_expr_yyparse())
51         return NULL;
52     return ssl_expr_info.expr;
53 }
54
55 char *ssl_expr_get_error(void)
56 {
57     if (ssl_expr_error == NULL)
58         return "";
59     return ssl_expr_error;
60 }
61
62 ssl_expr *ssl_expr_make(ssl_expr_node_op op, void *a1, void *a2)
63 {
64     ssl_expr *node;
65
66     node = (ssl_expr *)apr_palloc(ssl_expr_info.pool, sizeof(ssl_expr));
67     node->node_op   = op;
68     node->node_arg1 = (char *)a1;
69     node->node_arg2 = (char *)a2;
70     return node;
71 }
72
73 int ssl_expr_exec(request_rec *r, ssl_expr *expr)
74 {
75     BOOL rc;
76
77     rc = ssl_expr_eval(r, expr);
78     if (ssl_expr_error != NULL)
79         return (-1);
80     else
81         return (rc ? 1 : 0);
82 }