Blame server/util_expr_private.h

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#ifndef __AP_EXPR_PRIVATE_H__
Packit 90a5c9
#define __AP_EXPR_PRIVATE_H__
Packit 90a5c9
Packit 90a5c9
#include "httpd.h"
Packit 90a5c9
#include "apr_strings.h"
Packit 90a5c9
#include "apr_tables.h"
Packit 90a5c9
#include "ap_expr.h"
Packit 90a5c9
Packit 90a5c9
#ifndef YY_NULL
Packit 90a5c9
#define YY_NULL 0
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifndef MIN
Packit 90a5c9
#define MIN(a,b) (((a)<(b))?(a):(b))
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if !APR_HAVE_UNISTD_H
Packit 90a5c9
#define YY_NO_UNISTD_H
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef _MSC_VER
Packit 90a5c9
/* Avoid some warnings with Visual Studio (likely due to a bug in bison) */
Packit 90a5c9
#define YYMALLOC malloc
Packit 90a5c9
#define YYFREE   free
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifndef YYDEBUG
Packit 90a5c9
#define YYDEBUG 0
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/** The operations in a parse tree node */
Packit 90a5c9
typedef enum {
Packit 90a5c9
    op_NOP,
Packit 90a5c9
    op_True, op_False,
Packit 90a5c9
    op_Not, op_Or, op_And,
Packit 90a5c9
    op_Comp,
Packit 90a5c9
    op_EQ, op_NE, op_LT, op_LE, op_GT, op_GE, op_IN,
Packit 90a5c9
    op_REG, op_NRE,
Packit 90a5c9
    op_STR_EQ, op_STR_NE, op_STR_LT, op_STR_LE, op_STR_GT, op_STR_GE,
Packit 90a5c9
    op_Concat,
Packit 90a5c9
    op_Digit, op_String, op_Regex, op_RegexBackref,
Packit 90a5c9
    op_Var,
Packit 90a5c9
    op_ListElement,
Packit 90a5c9
    /*
Packit 90a5c9
     * call external functions/operators.
Packit 90a5c9
     * The info node contains the function pointer and some function specific
Packit 90a5c9
     * info.
Packit 90a5c9
     * For Binary operators, the Call node links to the Info node and the
Packit 90a5c9
     * Args node, which in turn links to the left and right operand.
Packit 90a5c9
     * For all other variants, the Call node links to the Info node and the
Packit 90a5c9
     * argument.
Packit 90a5c9
     */
Packit 90a5c9
    op_UnaryOpCall, op_UnaryOpInfo,
Packit 90a5c9
    op_BinaryOpCall, op_BinaryOpInfo, op_BinaryOpArgs,
Packit 90a5c9
    op_StringFuncCall, op_StringFuncInfo,
Packit 90a5c9
    op_ListFuncCall, op_ListFuncInfo
Packit 90a5c9
} ap_expr_node_op_e;
Packit 90a5c9
Packit 90a5c9
/** The basic parse tree node */
Packit 90a5c9
struct ap_expr_node {
Packit 90a5c9
    ap_expr_node_op_e node_op;
Packit 90a5c9
    const void *node_arg1;
Packit 90a5c9
    const void *node_arg2;
Packit 90a5c9
};
Packit 90a5c9
Packit 90a5c9
/** The context used by scanner and parser */
Packit 90a5c9
typedef struct {
Packit 90a5c9
    /* internal state of the scanner */
Packit 90a5c9
    const char        *inputbuf;
Packit 90a5c9
    int                inputlen;
Packit 90a5c9
    const char        *inputptr;
Packit 90a5c9
    void              *scanner;
Packit 90a5c9
    char              *scan_ptr;
Packit 90a5c9
    char               scan_buf[MAX_STRING_LEN];
Packit 90a5c9
    char               scan_del;
Packit 90a5c9
    int                at_start;
Packit 90a5c9
Packit 90a5c9
    /* pools for result and temporary usage */
Packit 90a5c9
    apr_pool_t        *pool;
Packit 90a5c9
    apr_pool_t        *ptemp;
Packit 90a5c9
Packit 90a5c9
    /* The created parse tree */
Packit 90a5c9
    ap_expr_t         *expr;
Packit 90a5c9
Packit 90a5c9
    const char        *error;
Packit 90a5c9
    const char        *error2;
Packit 90a5c9
    unsigned           flags;
Packit 90a5c9
Packit 90a5c9
    /*
Packit 90a5c9
     * The function to use to lookup provider functions for variables
Packit 90a5c9
     * and funtctions
Packit 90a5c9
     */
Packit 90a5c9
    ap_expr_lookup_fn_t *lookup_fn;
Packit 90a5c9
} ap_expr_parse_ctx_t;
Packit 90a5c9
Packit 90a5c9
/* flex/bison functions */
Packit 90a5c9
int  ap_expr_yyparse(ap_expr_parse_ctx_t *context);
Packit 90a5c9
void ap_expr_yyerror(ap_expr_parse_ctx_t *context, const char *err);
Packit 90a5c9
int  ap_expr_yylex_init(void **scanner);
Packit 90a5c9
int  ap_expr_yylex_destroy(void *scanner);
Packit 90a5c9
void ap_expr_yyset_extra(ap_expr_parse_ctx_t *context, void *scanner);
Packit 90a5c9
Packit 90a5c9
/* create a parse tree node */
Packit 90a5c9
ap_expr_t *ap_expr_make(ap_expr_node_op_e op, const void *arg1,
Packit 90a5c9
                        const void *arg2, ap_expr_parse_ctx_t *ctx);
Packit 90a5c9
/* create parse tree node for the string-returning function 'name' */
Packit 90a5c9
ap_expr_t *ap_expr_str_func_make(const char *name, const ap_expr_t *arg,
Packit 90a5c9
                               ap_expr_parse_ctx_t *ctx);
Packit 90a5c9
/* create parse tree node for the list-returning function 'name' */
Packit 90a5c9
ap_expr_t *ap_expr_list_func_make(const char *name, const ap_expr_t *arg,
Packit 90a5c9
                                ap_expr_parse_ctx_t *ctx);
Packit 90a5c9
/* create parse tree node for the variable 'name' */
Packit 90a5c9
ap_expr_t *ap_expr_var_make(const char *name, ap_expr_parse_ctx_t *ctx);
Packit 90a5c9
/* create parse tree node for the unary operator 'name' */
Packit 90a5c9
ap_expr_t *ap_expr_unary_op_make(const char *name, const ap_expr_t *arg,
Packit 90a5c9
                               ap_expr_parse_ctx_t *ctx);
Packit 90a5c9
/* create parse tree node for the binary operator 'name' */
Packit 90a5c9
ap_expr_t *ap_expr_binary_op_make(const char *name, const ap_expr_t *arg1,
Packit 90a5c9
                                  const ap_expr_t *arg2,
Packit 90a5c9
                                  ap_expr_parse_ctx_t *ctx);
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
#endif /* __AP_EXPR_PRIVATE_H__ */
Packit 90a5c9
/** @} */
Packit 90a5c9