1 /*                      _             _
2 **  _ __ ___   ___   __| |    ___ ___| |  mod_ssl
3 ** | '_ ` _ \ / _ \ / _` |   / __/ __| |  Apache Interface to OpenSSL
4 ** | | | | | | (_) | (_| |   \__ \__ \ |  www.modssl.org
5 ** |_| |_| |_|\___/ \__,_|___|___/___/_|  ftp.modssl.org
6 **                      |_____|
7 **  ssl_expr.h
8 **  Expression Handling (Header)
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 
62                              /* ``May all your PUSHes be POPed.'' */
63 
64 #ifndef SSL_EXPR_H
65 #define SSL_EXPR_H
66 
67 #ifndef FALSE
68 #define FALSE 0
69 #endif
70 
71 #ifndef TRUE
72 #define TRUE !FALSE
73 #endif
74 
75 #ifndef YY_NULL
76 #define YY_NULL 0
77 #endif
78 
79 #ifndef MIN
80 #define MIN(a,b) (((a)<(b))?(a):(b))
81 #endif
82 
83 #ifndef BOOL
84 #define BOOL unsigned int
85 #endif
86 
87 #ifndef NULL
88 #define NULL (void *)0
89 #endif
90 
91 #ifndef NUL
92 #define NUL '\0'
93 #endif
94 
95 #ifndef YYDEBUG
96 #define YYDEBUG 0
97 #endif
98 
99 typedef enum {
100     op_NOP, op_ListElement,
101     op_True, op_False, op_Not, op_Or, op_And, op_Comp,
102     op_EQ, op_NE, op_LT, op_LE, op_GT, op_GE, op_IN, op_REG, op_NRE,
103     op_Digit, op_String, op_Regex, op_Var, op_Func
104 } ssl_expr_node_op;
105 
106 typedef struct {
107     ssl_expr_node_op node_op;
108     void *node_arg1;
109     void *node_arg2;
110 } ssl_expr_node;
111 
112 typedef ssl_expr_node ssl_expr;
113 
114 typedef struct {
115 	pool     *pool;
116     char     *inputbuf;
117     int       inputlen;
118     char     *inputptr;
119     ssl_expr *expr;
120 } ssl_expr_info_type;
121 
122 extern ssl_expr_info_type ssl_expr_info;
123 extern char *ssl_expr_error;
124 
125 #define yylval  ssl_expr_yylval
126 #define yyerror ssl_expr_yyerror
127 #define yyinput ssl_expr_yyinput
128 
129 extern int ssl_expr_yyparse(void);
130 extern int ssl_expr_yyerror(char *);
131 extern int ssl_expr_yylex(void);
132 
133 extern ssl_expr *ssl_expr_comp(pool *, char *);
134 extern int       ssl_expr_exec(request_rec *, ssl_expr *);
135 extern char     *ssl_expr_get_error(void);
136 extern ssl_expr *ssl_expr_make(ssl_expr_node_op, void *, void *);
137 extern BOOL      ssl_expr_eval(request_rec *, ssl_expr *);
138 
139 #endif /* SSL_EXPR_H */
140