Apache2
util_expr_private.h
Go to the documentation of this file.
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 #ifndef __AP_EXPR_PRIVATE_H__
18 #define __AP_EXPR_PRIVATE_H__
19 
20 #include "httpd.h"
21 #include "apr_strings.h"
22 #include "apr_tables.h"
23 #include "ap_expr.h"
24 
25 #ifndef YY_NULL
26 #define YY_NULL 0
27 #endif
28 
29 #ifndef MIN
30 #define MIN(a,b) (((a)<(b))?(a):(b))
31 #endif
32 
33 #if !APR_HAVE_UNISTD_H
34 #define YY_NO_UNISTD_H
35 #endif
36 
37 #ifdef _MSC_VER
38 /* Avoid some warnings with Visual Studio (likely due to a bug in bison) */
39 #define YYMALLOC malloc
40 #define YYFREE free
41 #endif
42 
43 #ifndef YYDEBUG
44 #define YYDEBUG 0
45 #endif
46 
48 typedef enum {
61  /*
62  * call external functions/operators.
63  * The info node contains the function pointer and some function specific
64  * info.
65  * For Binary operators, the Call node links to the Info node and the
66  * Args node, which in turn links to the left and right operand.
67  * For all other variants, the Call node links to the Info node and the
68  * argument.
69  */
75 
77 struct ap_expr_node {
79  const void *node_arg1;
80  const void *node_arg2;
81 };
82 
84 typedef struct ap_expr_parser_stack {
85  char *scan_ptr;
87  int scan_stop;
88  int scan_flag;
91 
93 typedef struct {
94  /* internal state of the scanner */
95  const char *inputbuf;
96  int inputlen;
97  const char *inputptr;
98  void *scanner;
101  int at_start;
102 
103  /* pools for result and temporary usage */
106 
107  /* The created parse tree */
109 
110  const char *error;
111  const char *error2;
112  unsigned flags;
113 
114  /*
115  * The function to use to lookup provider functions for variables
116  * and funtctions
117  */
120 
121 /* flex/bison functions */
123 void ap_expr_yyerror(ap_expr_parse_ctx_t *context, const char *err);
124 int ap_expr_yylex_init(void **scanner);
125 int ap_expr_yylex_destroy(void *scanner);
126 void ap_expr_yyset_extra(ap_expr_parse_ctx_t *context, void *scanner);
127 
128 /* create a parse tree node */
130  const void *arg2, ap_expr_parse_ctx_t *ctx);
131 ap_expr_t *ap_expr_concat_make(const void *a1, const void *a2,
132  ap_expr_parse_ctx_t *ctx);
133 ap_expr_t *ap_expr_regex_make(const char *pattern, const ap_expr_t *subst,
134  const char *flags, ap_expr_parse_ctx_t *ctx);
135 /* create parse tree node for the string-returning function 'name' */
137  ap_expr_parse_ctx_t *ctx);
138 /* create parse tree node for the list-returning function 'name' */
140  ap_expr_parse_ctx_t *ctx);
141 /* create parse tree node for the variable 'name' */
143 /* create parse tree node for the back reference 'num' */
145 /* create parse tree node for the unary operator 'name' */
147  ap_expr_parse_ctx_t *ctx);
148 /* create parse tree node for the binary operator 'name' */
149 ap_expr_t *ap_expr_binary_op_make(const char *name, const ap_expr_t *arg1,
150  const ap_expr_t *arg2,
151  ap_expr_parse_ctx_t *ctx);
152 
153 
154 #endif /* __AP_EXPR_PRIVATE_H__ */
Expression parser.
APR Strings library.
APR Table library.
#define MAX_STRING_LEN
Definition: httpd.h:305
int() ap_expr_lookup_fn_t(ap_expr_lookup_parms *parms)
Definition: ap_expr.h:304
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1458
dav_error * err
Definition: mod_dav.h:203
const char * name
Definition: mod_dav.h:805
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
HTTP Daemon routines.
Definition: util_expr_private.h:77
ap_expr_node_op_e node_op
Definition: util_expr_private.h:78
const void * node_arg2
Definition: util_expr_private.h:80
const void * node_arg1
Definition: util_expr_private.h:79
Definition: util_expr_private.h:93
ap_expr_lookup_fn_t * lookup_fn
Definition: util_expr_private.h:118
int inputlen
Definition: util_expr_private.h:96
ap_expr_parser_stack_t * spares
Definition: util_expr_private.h:100
unsigned flags
Definition: util_expr_private.h:112
apr_pool_t * ptemp
Definition: util_expr_private.h:105
const char * inputbuf
Definition: util_expr_private.h:95
void * scanner
Definition: util_expr_private.h:98
const char * error
Definition: util_expr_private.h:110
apr_pool_t * pool
Definition: util_expr_private.h:104
const char * error2
Definition: util_expr_private.h:111
int at_start
Definition: util_expr_private.h:101
const char * inputptr
Definition: util_expr_private.h:97
ap_expr_parser_stack_t * current
Definition: util_expr_private.h:99
ap_expr_t * expr
Definition: util_expr_private.h:108
Definition: util_expr_private.h:84
char scan_buf[MAX_STRING_LEN]
Definition: util_expr_private.h:86
char * scan_ptr
Definition: util_expr_private.h:85
int scan_stop
Definition: util_expr_private.h:87
struct ap_expr_parser_stack * next
Definition: util_expr_private.h:89
int scan_flag
Definition: util_expr_private.h:88
int ap_expr_yyparse(ap_expr_parse_ctx_t *context)
ap_expr_t * ap_expr_unary_op_make(const char *name, const ap_expr_t *arg, ap_expr_parse_ctx_t *ctx)
struct ap_expr_parser_stack ap_expr_parser_stack_t
ap_expr_node_op_e
Definition: util_expr_private.h:48
@ op_StringFuncInfo
Definition: util_expr_private.h:72
@ op_Split
Definition: util_expr_private.h:59
@ op_False
Definition: util_expr_private.h:50
@ op_Digit
Definition: util_expr_private.h:58
@ op_STR_EQ
Definition: util_expr_private.h:55
@ op_BinaryOpCall
Definition: util_expr_private.h:71
@ op_UnaryOpInfo
Definition: util_expr_private.h:70
@ op_True
Definition: util_expr_private.h:50
@ op_Comp
Definition: util_expr_private.h:52
@ op_Regex
Definition: util_expr_private.h:60
@ op_GT
Definition: util_expr_private.h:53
@ op_NRE
Definition: util_expr_private.h:54
@ op_STR_LE
Definition: util_expr_private.h:55
@ op_NE
Definition: util_expr_private.h:53
@ op_ListElement
Definition: util_expr_private.h:58
@ op_Join
Definition: util_expr_private.h:59
@ op_STR_LT
Definition: util_expr_private.h:55
@ op_Word
Definition: util_expr_private.h:57
@ op_LT
Definition: util_expr_private.h:53
@ op_LE
Definition: util_expr_private.h:53
@ op_Concat
Definition: util_expr_private.h:56
@ op_GE
Definition: util_expr_private.h:53
@ op_STR_NE
Definition: util_expr_private.h:55
@ op_REG
Definition: util_expr_private.h:54
@ op_String
Definition: util_expr_private.h:57
@ op_And
Definition: util_expr_private.h:51
@ op_IN
Definition: util_expr_private.h:53
@ op_Sub
Definition: util_expr_private.h:59
@ op_NOP
Definition: util_expr_private.h:49
@ op_Not
Definition: util_expr_private.h:51
@ op_STR_GE
Definition: util_expr_private.h:55
@ op_ListFuncCall
Definition: util_expr_private.h:73
@ op_EQ
Definition: util_expr_private.h:53
@ op_Bool
Definition: util_expr_private.h:58
@ op_Backref
Definition: util_expr_private.h:60
@ op_Var
Definition: util_expr_private.h:58
@ op_StringFuncCall
Definition: util_expr_private.h:72
@ op_UnaryOpCall
Definition: util_expr_private.h:70
@ op_STR_GT
Definition: util_expr_private.h:55
@ op_Or
Definition: util_expr_private.h:51
@ op_ListFuncInfo
Definition: util_expr_private.h:73
@ op_BinaryOpArgs
Definition: util_expr_private.h:71
@ op_BinaryOpInfo
Definition: util_expr_private.h:71
ap_expr_t * ap_expr_regex_make(const char *pattern, const ap_expr_t *subst, const char *flags, ap_expr_parse_ctx_t *ctx)
void ap_expr_yyset_extra(ap_expr_parse_ctx_t *context, void *scanner)
ap_expr_t * ap_expr_str_func_make(const char *name, const ap_expr_t *arg, ap_expr_parse_ctx_t *ctx)
int ap_expr_yylex_destroy(void *scanner)
int ap_expr_yylex_init(void **scanner)
ap_expr_t * ap_expr_list_func_make(const char *name, const ap_expr_t *arg, ap_expr_parse_ctx_t *ctx)
ap_expr_t * ap_expr_var_make(const char *name, ap_expr_parse_ctx_t *ctx)
ap_expr_t * ap_expr_make(ap_expr_node_op_e op, const void *arg1, const void *arg2, ap_expr_parse_ctx_t *ctx)
ap_expr_t * ap_expr_backref_make(int num, ap_expr_parse_ctx_t *ctx)
void ap_expr_yyerror(ap_expr_parse_ctx_t *context, const char *err)
ap_expr_t * ap_expr_binary_op_make(const char *name, const ap_expr_t *arg1, const ap_expr_t *arg2, ap_expr_parse_ctx_t *ctx)
ap_expr_t * ap_expr_concat_make(const void *a1, const void *a2, ap_expr_parse_ctx_t *ctx)