util_expr_eval.c revision c1ea0100af157a0d4e4a3de323f32dbfac4e5b6e
356N/A * ap_expr_eval.c, based on ssl_expr_eval.c from mod_ssl
356N/A#include "http_log.h"
2516N/A#include "http_core.h"
356N/A#include "http_protocol.h"
356N/A#include "http_request.h"
356N/A#include "ap_provider.h"
2516N/A#include "util_expr_private.h"
356N/A#include "apr_fnmatch.h"
2516N/A#ifdef AP_EXPR_DEBUG
case op_Var:
case op_Concat: {
if (!*s1)
else if (!*s2)
case op_StringFuncCall: {
case op_RegexBackref: {
if (!result)
return result;
const void *data)
int len;
if (len == 0)
case op_EQ:
case op_NE:
case op_LT:
case op_LE:
case op_GT:
case op_GE:
case op_STR_EQ:
case op_STR_NE:
case op_STR_LT:
case op_STR_LE:
case op_STR_GT:
case op_STR_GE:
case op_IN: {
case op_REG:
case op_NRE: {
int result;
return result;
return !result;
for (i = 0; i < n1; i++) {
case op_EQ:
case op_STR_EQ:
case op_NE:
case op_STR_NE:
case op_LT:
case op_STR_LT:
case op_LE:
case op_STR_LE:
case op_GT:
case op_STR_GT:
case op_GE:
case op_STR_GE:
int rc;
#ifdef AP_EXPR_DEBUG
return NULL;
const char *expr,
const char **err,
if (*err)
return NULL;
return info;
return node;
return NULL;
return info;
if (!info)
return NULL;
if (!info)
return NULL;
if (!info)
return NULL;
arg2);
if (!info)
return NULL;
if (!node)
return NULL;
return node;
#ifdef AP_EXPR_DEBUG
switch (e->node_op) {
case op_NOP:
case op_True:
case op_False:
char *name;
switch (e->node_op) {
ap_assert(0);
case op_UnaryOpCall:
case op_BinaryOpCall:
case op_BinaryOpArgs:
char *name;
switch (e->node_op) {
ap_assert(0);
case op_Comp:
case op_Not:
case op_Or:
case op_And:
case op_EQ:
case op_NE:
case op_LT:
case op_LE:
case op_GT:
case op_GE:
case op_STR_EQ:
case op_STR_NE:
case op_STR_LT:
case op_STR_LE:
case op_STR_GT:
case op_STR_GE:
case op_IN:
case op_REG:
case op_NRE:
case op_Concat:
case op_StringFuncCall:
case op_ListFuncCall:
case op_ListElement:
char *name;
switch (e->node_op) {
ap_assert(0);
case op_Digit:
case op_String:
char *name;
switch (e->node_op) {
ap_assert(0);
case op_Var:
case op_StringFuncInfo:
case op_UnaryOpInfo:
case op_BinaryOpInfo:
case op_ListFuncInfo:
char *name;
switch (e->node_op) {
ap_assert(0);
case op_Regex:
case op_RegexBackref:
case op_True:
case op_False:
case op_Not:
case op_Or:
case op_And:
case op_UnaryOpCall:
case op_BinaryOpCall:
case op_Comp:
return FALSE;
const char **err)
int rc;
return rc;
ctx.r = r;
if (!pmatch) {
NULL);
const char *arg)
apr_table_t *t;
if (!ctx->r)
const char *arg)
const char *res;
if (ctx->r) {
return res;
return res;
const char *arg)
const char *arg)
return result;
const char *arg)
for (p = result; *p; ++p) {
*p = apr_toupper(*p);
return result;
const char *arg)
char *arg)
char *buf;
if (len == 0) {
offset = 0;
return buf;
char *arg)
const char *arg)
return result;
return FALSE;
switch (name[0]) {
return TRUE;
ap_assert(0);
return FALSE;
#if !defined(OS2)
return TRUE;
return FALSE;
return TRUE;
return FALSE;
return FALSE;
return FALSE;
return rc;
return FALSE;
return rc;
static const char *conn_var_names[] = {
switch (index) {
return c->remote_ip;
#if APR_HAVE_IPV6
return c->log_id;
ap_assert(0);
return NULL;
static const char *request_var_names[] = {
switch (index) {
return r->method;
return ap_http_scheme(r);
return r->uri;
return r->filename;
return ap_get_remote_logname(r);
return r->user;
return ap_get_server_name(r);
return r->protocol;
return r->filename;
return r->path_info;
return r->args;
return ap_document_root(r);
return r->ap_auth_type;
return r->the_request;
return r->content_type;
return r->handler;
return r->log_id;
return result;
return result;
return r->uri;
ap_assert(0);
return NULL;
static const char *req_header_var_names[] = {
static const char *req_header_header_names[] = {
const char *name;
if (!ctx->r)
static const char *misc_var_names[] = {
switch (index) {
return ap_get_server_banner();
ap_assert(0);
return NULL;
const char *mask;
return !OK;
if (mask) {
mask++;
return !OK;
return OK;
const char *arg2)
return FALSE;
if (!ctx->c)
return FALSE;
switch (arg[0]) {
return FALSE;
return TRUE;
struct expr_provider_single {
const void *func;
const char *name;
int restricted;
struct expr_provider_multi {
const void *func;
const char **names;
case AP_EXPR_FUNC_VAR: {
while (*name) {
return OK;
name++;
prov++;
case AP_EXPR_FUNC_STRING:
case AP_EXPR_FUNC_OP_UNARY:
case AP_EXPR_FUNC_OP_BINARY: {
case AP_EXPR_FUNC_STRING:
case AP_EXPR_FUNC_OP_UNARY:
case AP_EXPR_FUNC_OP_BINARY:
ap_assert(0);
return !OK;
return OK;
prov++;
return DECLINED;
const char *type;
case AP_EXPR_FUNC_VAR:
case AP_EXPR_FUNC_STRING:
case AP_EXPR_FUNC_LIST:
case AP_EXPR_FUNC_OP_UNARY:
case AP_EXPR_FUNC_OP_BINARY:
return !OK;
return !OK;
return OK;