AP_IMPLEMENT_HOOK_RUN_FIRST(int, expr_lookup, (ap_expr_lookup_parms *parms),
(parms), DECLINED)
-static const char *ap_expr_eval_string_func(ap_expr_eval_ctx *ctx, const ap_expr *info,
- const ap_expr *args);
-static const char *ap_expr_eval_re_backref(ap_expr_eval_ctx *ctx, int n);
-static const char *ap_expr_eval_var(ap_expr_eval_ctx *ctx,
+static const char *ap_expr_eval_string_func(ap_expr_eval_ctx_t *ctx,
+ const ap_expr_t *info,
+ const ap_expr_t *args);
+static const char *ap_expr_eval_re_backref(ap_expr_eval_ctx_t *ctx, int n);
+static const char *ap_expr_eval_var(ap_expr_eval_ctx_t *ctx,
const ap_expr_var_func_t *func,
const void *data);
/* define AP_EXPR_DEBUG to log the parse tree when parsing an expression */
#ifdef AP_EXPR_DEBUG
-static void expr_dump_tree(const ap_expr *e, const server_rec *s, int loglevel, int indent);
+static void expr_dump_tree(const ap_expr_t *e, const server_rec *s,
+ int loglevel, int indent);
#endif
-static const char *ap_expr_eval_word(ap_expr_eval_ctx *ctx, const ap_expr *node)
+static const char *ap_expr_eval_word(ap_expr_eval_ctx_t *ctx,
+ const ap_expr_t *node)
{
const char *result = "";
switch (node->node_op) {
break;
}
case op_StringFuncCall: {
- const ap_expr *info = node->node_arg1;
- const ap_expr *args = node->node_arg2;
+ const ap_expr_t *info = node->node_arg1;
+ const ap_expr_t *args = node->node_arg2;
result = ap_expr_eval_string_func(ctx, info, args);
break;
}
return result;
}
-static const char *ap_expr_eval_var(ap_expr_eval_ctx *ctx,
+static const char *ap_expr_eval_var(ap_expr_eval_ctx_t *ctx,
const ap_expr_var_func_t *func,
const void *data)
{
return (*func)(ctx, data);
}
-static const char *ap_expr_eval_re_backref(ap_expr_eval_ctx *ctx, int n)
+static const char *ap_expr_eval_re_backref(ap_expr_eval_ctx_t *ctx, int n)
{
int len;
return apr_pstrndup(ctx->p, *ctx->re_source + ctx->re_pmatch[n].rm_so, len);
}
-static const char *ap_expr_eval_string_func(ap_expr_eval_ctx *ctx, const ap_expr *info,
- const ap_expr *arg)
+static const char *ap_expr_eval_string_func(ap_expr_eval_ctx_t *ctx,
+ const ap_expr_t *info,
+ const ap_expr_t *arg)
{
ap_expr_string_func_t *func = (ap_expr_string_func_t *)info->node_arg1;
const void *data = info->node_arg2;
return 1;
}
-static int ap_expr_eval_comp(ap_expr_eval_ctx *ctx, const ap_expr *node)
+static int ap_expr_eval_comp(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
{
switch (node->node_op) {
case op_EQ: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (intstrcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) == 0);
}
case op_NE: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (intstrcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) != 0);
}
case op_LT: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (intstrcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) < 0);
}
case op_LE: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (intstrcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) <= 0);
}
case op_GT: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (intstrcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) > 0);
}
case op_GE: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (intstrcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) >= 0);
}
case op_STR_EQ: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (strcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) == 0);
}
case op_STR_NE: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (strcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) != 0);
}
case op_STR_LT: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (strcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) < 0);
}
case op_STR_LE: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (strcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) <= 0);
}
case op_STR_GT: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (strcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) > 0);
}
case op_STR_GE: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (strcmp(ap_expr_eval_word(ctx, e1), ap_expr_eval_word(ctx, e2)) >= 0);
}
case op_IN: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
const char *needle = ap_expr_eval_word(ctx, e1);
if (e2->node_op == op_ListElement) {
do {
- const ap_expr *val = e2->node_arg1;
+ const ap_expr_t *val = e2->node_arg1;
AP_DEBUG_ASSERT(e2->node_op == op_ListElement);
if (strcmp(needle, ap_expr_eval_word(ctx, val)) == 0) {
return 1;
} while (e2 != NULL);
}
else if (e2->node_op == op_ListFuncCall) {
- const ap_expr *info = e2->node_arg1;
- const ap_expr *arg = e2->node_arg2;
+ const ap_expr_t *info = e2->node_arg1;
+ const ap_expr_t *arg = e2->node_arg2;
ap_expr_list_func_t *func = (ap_expr_list_func_t *)info->node_arg1;
apr_array_header_t *haystack;
int i = 0;
}
case op_REG:
case op_NRE: {
- const ap_expr *e1;
- const ap_expr *e2;
+ const ap_expr_t *e1;
+ const ap_expr_t *e2;
const char *word;
const ap_regex_t *regex;
int result;
return 0;
}
-static int ssl_expr_eval_comp(ap_expr_eval_ctx *ctx, const ap_expr *node)
+static int ssl_expr_eval_comp(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
{
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
switch (node->node_op) {
case op_EQ:
case op_STR_EQ:
AP_DECLARE(const char *) ap_expr_parse(apr_pool_t *pool, apr_pool_t *ptemp,
ap_expr_info_t *info, const char *expr,
- ap_expr_lookup_fn *lookup_fn)
+ ap_expr_lookup_fn_t *lookup_fn)
{
- ap_expr_parse_ctx ctx;
+ ap_expr_parse_ctx_t ctx;
int rc;
ctx.pool = pool;
AP_DECLARE(ap_expr_info_t*) ap_expr_parse_cmd(const cmd_parms *cmd,
const char *expr,
const char **err,
- ap_expr_lookup_fn *lookup_fn)
+ ap_expr_lookup_fn_t *lookup_fn)
{
ap_expr_info_t *info = apr_pcalloc(cmd->pool, sizeof(ap_expr_info_t));
info->filename = cmd->directive->filename;
return info;
}
-ap_expr *ap_expr_make(ap_expr_node_op op, const void *a1, const void *a2,
- ap_expr_parse_ctx *ctx)
+ap_expr_t *ap_expr_make(ap_expr_node_op_e op, const void *a1, const void *a2,
+ ap_expr_parse_ctx_t *ctx)
{
- ap_expr *node = apr_palloc(ctx->pool, sizeof(ap_expr));
+ ap_expr_t *node = apr_palloc(ctx->pool, sizeof(ap_expr_t));
node->node_op = op;
node->node_arg1 = a1;
node->node_arg2 = a2;
return node;
}
-static ap_expr *ap_expr_info_make(int type, const char *name,
- ap_expr_parse_ctx *ctx,
- const ap_expr *arg)
+static ap_expr_t *ap_expr_info_make(int type, const char *name,
+ ap_expr_parse_ctx_t *ctx,
+ const ap_expr_t *arg)
{
- ap_expr *info = apr_palloc(ctx->pool, sizeof(ap_expr));
+ ap_expr_t *info = apr_palloc(ctx->pool, sizeof(ap_expr_t));
ap_expr_lookup_parms parms;
parms.type = type;
parms.flags = 0;
return info;
}
-ap_expr *ap_expr_str_func_make(const char *name, const ap_expr *arg,
- ap_expr_parse_ctx *ctx)
+ap_expr_t *ap_expr_str_func_make(const char *name, const ap_expr_t *arg,
+ ap_expr_parse_ctx_t *ctx)
{
- ap_expr *info = ap_expr_info_make(AP_EXPR_FUNC_STRING, name, ctx, arg);
+ ap_expr_t *info = ap_expr_info_make(AP_EXPR_FUNC_STRING, name, ctx, arg);
if (!info)
return NULL;
return ap_expr_make(op_StringFuncCall, info, arg, ctx);
}
-ap_expr *ap_expr_list_func_make(const char *name, const ap_expr *arg,
- ap_expr_parse_ctx *ctx)
+ap_expr_t *ap_expr_list_func_make(const char *name, const ap_expr_t *arg,
+ ap_expr_parse_ctx_t *ctx)
{
- ap_expr *info = ap_expr_info_make(AP_EXPR_FUNC_LIST, name, ctx, arg);
+ ap_expr_t *info = ap_expr_info_make(AP_EXPR_FUNC_LIST, name, ctx, arg);
if (!info)
return NULL;
return ap_expr_make(op_ListFuncCall, info, arg, ctx);
}
-ap_expr *ap_expr_unary_op_make(const char *name, const ap_expr *arg,
- ap_expr_parse_ctx *ctx)
+ap_expr_t *ap_expr_unary_op_make(const char *name, const ap_expr_t *arg,
+ ap_expr_parse_ctx_t *ctx)
{
- ap_expr *info = ap_expr_info_make(AP_EXPR_FUNC_OP_UNARY, name, ctx, arg);
+ ap_expr_t *info = ap_expr_info_make(AP_EXPR_FUNC_OP_UNARY, name, ctx, arg);
if (!info)
return NULL;
return ap_expr_make(op_UnaryOpCall, info, arg, ctx);
}
-ap_expr *ap_expr_binary_op_make(const char *name, const ap_expr *arg1,
- const ap_expr *arg2, ap_expr_parse_ctx *ctx)
+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 *args;
- ap_expr *info = ap_expr_info_make(AP_EXPR_FUNC_OP_BINARY, name, ctx, arg2);
+ ap_expr_t *args;
+ ap_expr_t *info = ap_expr_info_make(AP_EXPR_FUNC_OP_BINARY, name, ctx,
+ arg2);
if (!info)
return NULL;
}
-ap_expr *ap_expr_var_make(const char *name, ap_expr_parse_ctx *ctx)
+ap_expr_t *ap_expr_var_make(const char *name, ap_expr_parse_ctx_t *ctx)
{
- ap_expr *node = ap_expr_info_make(AP_EXPR_FUNC_VAR, name, ctx, NULL);
+ ap_expr_t *node = ap_expr_info_make(AP_EXPR_FUNC_VAR, name, ctx, NULL);
if (!node)
return NULL;
ap_log_error(MARK,"%*s%s: '%s' '%s'", indent, " ", op, (char *)s1, (char *)s2)
#define DUMP_P(op, p1) \
ap_log_error(MARK,"%*s%s: %pp", indent, " ", op, p1);
-#define DUMP_IP(op, p1) \
+#define DUMP_IP(op, p1) \
ap_log_error(MARK,"%*s%s: %d", indent, " ", op, *(int *)p1);
#define DUMP_S(op, s1) \
ap_log_error(MARK,"%*s%s: '%s'", indent, " ", op, (char *)s1)
#define CASE_OP(op) case op: name = #op ; break;
-static void expr_dump_tree(const ap_expr *e, const server_rec *s, int loglevel, int indent)
+static void expr_dump_tree(const ap_expr_t *e, const server_rec *s,
+ int loglevel, int indent)
{
switch (e->node_op) {
/* no arg */
}
#endif /* AP_EXPR_DEBUG */
-static int ap_expr_eval_unary_op(ap_expr_eval_ctx *ctx, const ap_expr *info,
- const ap_expr *arg)
+static int ap_expr_eval_unary_op(ap_expr_eval_ctx_t *ctx, const ap_expr_t *info,
+ const ap_expr_t *arg)
{
const ap_expr_op_unary_t *op_func = info->node_arg1;
const void *data = info->node_arg2;
return (*op_func)(ctx, data, ap_expr_eval_word(ctx, arg));
}
-static int ap_expr_eval_binary_op(ap_expr_eval_ctx *ctx, const ap_expr *info,
- const ap_expr *args)
+static int ap_expr_eval_binary_op(ap_expr_eval_ctx_t *ctx,
+ const ap_expr_t *info,
+ const ap_expr_t *args)
{
const ap_expr_op_binary_t *op_func = info->node_arg1;
const void *data = info->node_arg2;
- const ap_expr *a1 = args->node_arg1;
- const ap_expr *a2 = args->node_arg2;
+ const ap_expr_t *a1 = args->node_arg1;
+ const ap_expr_t *a2 = args->node_arg2;
AP_DEBUG_ASSERT(info->node_op == op_BinaryOpInfo);
AP_DEBUG_ASSERT(args->node_op == op_BinaryOpArgs);
}
-static int ap_expr_eval(ap_expr_eval_ctx *ctx, const ap_expr *node)
+static int ap_expr_eval(ap_expr_eval_ctx_t *ctx, const ap_expr_t *node)
{
switch (node->node_op) {
case op_True: {
return 0;
}
case op_Not: {
- const ap_expr *e = node->node_arg1;
+ const ap_expr_t *e = node->node_arg1;
return (!ap_expr_eval(ctx, e));
}
case op_Or: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (ap_expr_eval(ctx, e1) || ap_expr_eval(ctx, e2));
}
case op_And: {
- const ap_expr *e1 = node->node_arg1;
- const ap_expr *e2 = node->node_arg2;
+ const ap_expr_t *e1 = node->node_arg1;
+ const ap_expr_t *e2 = node->node_arg2;
return (ap_expr_eval(ctx, e1) && ap_expr_eval(ctx, e2));
}
case op_UnaryOpCall: {
- const ap_expr *info = node->node_arg1;
- const ap_expr *args = node->node_arg2;
+ const ap_expr_t *info = node->node_arg1;
+ const ap_expr_t *args = node->node_arg2;
return ap_expr_eval_unary_op(ctx, info, args);
}
case op_BinaryOpCall: {
- const ap_expr *info = node->node_arg1;
- const ap_expr *args = node->node_arg2;
+ const ap_expr_t *info = node->node_arg1;
+ const ap_expr_t *args = node->node_arg2;
return ap_expr_eval_binary_op(ctx, info, args);
}
case op_Comp: {
- const ap_expr *e = node->node_arg1;
+ const ap_expr_t *e = node->node_arg1;
if (ctx->info->flags & AP_EXPR_FLAGS_SSL_EXPR_COMPAT)
return ssl_expr_eval_comp(ctx, e);
else
}
}
-AP_DECLARE(int) ap_expr_exec(request_rec *r, const ap_expr_info_t *info, const char **err)
+AP_DECLARE(int) ap_expr_exec(request_rec *r, const ap_expr_info_t *info,
+ const char **err)
{
return ap_expr_exec_re(r, info, 0, NULL, NULL, err);
}
apr_size_t nmatch, ap_regmatch_t *pmatch,
const char **source, const char **err)
{
- ap_expr_eval_ctx ctx;
+ ap_expr_eval_ctx_t ctx;
int rc;
int dont_vary = (info->flags & AP_EXPR_FLAGS_DONT_VARY);
const char *tmp_source = NULL, *vary_this = NULL;
}
}
-static void add_vary(ap_expr_eval_ctx *ctx, const char *name)
+static void add_vary(ap_expr_eval_ctx_t *ctx, const char *name)
{
if (!ctx->vary_this)
return;
}
}
-static const char *req_table_func(ap_expr_eval_ctx *ctx, const void *data,
+static const char *req_table_func(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg)
{
const char *name = (const char *)data;
return apr_table_get(t, arg);
}
-static const char *env_func(ap_expr_eval_ctx *ctx, const void *data,
+static const char *env_func(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg)
{
const char *res;
return getenv(arg);
}
-static const char *osenv_func(ap_expr_eval_ctx *ctx, const void *data,
+static const char *osenv_func(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg)
{
return getenv(arg);
}
-static const char *tolower_func(ap_expr_eval_ctx *ctx, const void *data,
+static const char *tolower_func(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg)
{
char *result = apr_pstrdup(ctx->p, arg);
return result;
}
-static const char *toupper_func(ap_expr_eval_ctx *ctx, const void *data,
+static const char *toupper_func(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg)
{
char *p;
return result;
}
-static const char *escape_func(ap_expr_eval_ctx *ctx, const void *data,
+static const char *escape_func(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg)
{
return ap_escape_uri(ctx->p, arg);
}
#define MAX_FILE_SIZE 10*1024*1024
-static const char *file_func(ap_expr_eval_ctx *ctx, const void *data, char *arg)
+static const char *file_func(ap_expr_eval_ctx_t *ctx, const void *data,
+ char *arg)
{
apr_file_t *fp;
char *buf;
}
-static const char *unescape_func(ap_expr_eval_ctx *ctx, const void *data,
+static const char *unescape_func(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg)
{
char *result = apr_pstrdup(ctx->p, arg);
}
-static int op_nz(ap_expr_eval_ctx *ctx, const void *data, const char *arg)
+static int op_nz(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
{
const char *name = (const char *)data;
if (name[0] == 'z')
NULL
};
-static const char *conn_var_fn(ap_expr_eval_ctx *ctx, const void *data)
+static const char *conn_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
{
int index = ((const char **)data - conn_var_names);
conn_rec *c = ctx->c;
NULL
};
-static const char *request_var_fn(ap_expr_eval_ctx *ctx, const void *data)
+static const char *request_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
{
int index = ((const char **)data - request_var_names);
request_rec *r = ctx->r;
"Accept"
};
-static const char *req_header_var_fn(ap_expr_eval_ctx *ctx, const void *data)
+static const char *req_header_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
{
const char **varname = (const char **)data;
int index = (varname - req_header_var_names);
NULL
};
-static const char *misc_var_fn(ap_expr_eval_ctx *ctx, const void *data)
+static const char *misc_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
{
apr_time_exp_t tm;
int index = ((const char **)data - misc_var_names);
return OK;
}
-static int op_ipmatch(ap_expr_eval_ctx *ctx, const void *data, const char *arg1,
+static int op_ipmatch(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1,
const char *arg2)
{
apr_ipsubnet_t *subnet = (apr_ipsubnet_t *)data;
return apr_ipsubnet_test(subnet, saddr);
}
-static int op_R(ap_expr_eval_ctx *ctx, const void *data, const char *arg1)
+static int op_R(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1)
{
apr_ipsubnet_t *subnet = (apr_ipsubnet_t *)data;
return apr_ipsubnet_test(subnet, ctx->c->remote_addr);
}
-static int op_fnmatch(ap_expr_eval_ctx *ctx, const void *data, const char *arg1,
- const char *arg2)
+static int op_fnmatch(ap_expr_eval_ctx_t *ctx, const void *data,
+ const char *arg1, const char *arg2)
{
return (APR_SUCCESS == apr_fnmatch(arg2, arg1, APR_FNM_PATHNAME));
}
-static int op_strmatch(ap_expr_eval_ctx *ctx, const void *data, const char *arg1,
- const char *arg2)
+static int op_strmatch(ap_expr_eval_ctx_t *ctx, const void *data,
+ const char *arg1, const char *arg2)
{
return (APR_SUCCESS == apr_fnmatch(arg2, arg1, 0));
}
-static int op_strcmatch(ap_expr_eval_ctx *ctx, const void *data, const char *arg1,
- const char *arg2)
+static int op_strcmatch(ap_expr_eval_ctx_t *ctx, const void *data,
+ const char *arg1, const char *arg2)
{
return (APR_SUCCESS == apr_fnmatch(arg2, arg1, APR_FNM_CASE_BLIND));
}
struct expr_provider_single {
const void *func;
const char *name;
- ap_expr_lookup_fn *arg_parsing_func;
+ ap_expr_lookup_fn_t *arg_parsing_func;
};
struct expr_provider_multi {