You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lighttpd2/src/condition.h

129 lines
2.7 KiB

14 years ago
#ifndef _LIGHTTPD_CONDITION_H_
#define _LIGHTTPD_CONDITION_H_
#include "settings.h"
struct condition_rvalue;
typedef struct condition_rvalue condition_rvalue;
struct condition_lvalue;
typedef struct condition_lvalue condition_lvalue;
struct condition;
typedef struct condition condition;
14 years ago
/**
* possible compare ops in the configfile parser
*/
typedef enum {
14 years ago
/* everything */
14 years ago
CONFIG_COND_EQ, /** == */
CONFIG_COND_NE, /** != */
14 years ago
/* only with strings (including socket name) */
CONFIG_COND_MATCH, /** =~ */
14 years ago
CONFIG_COND_NOMATCH, /** !~ */
14 years ago
/* only with int */
14 years ago
CONFIG_COND_GT, /** > */
CONFIG_COND_GE, /** >= */
CONFIG_COND_LT, /** < */
CONFIG_COND_LE /** <= */
} comp_operator_t;
14 years ago
/**
* possible fields to match against
*/
typedef enum {
COMP_REQUEST_LOCALIP,
COMP_REQUEST_REMOTEIP,
14 years ago
COMP_REQUEST_PATH,
COMP_REQUEST_HOST,
COMP_REQUEST_SCHEME,
COMP_REQUEST_QUERY_STRING,
COMP_REQUEST_METHOD,
COMP_REQUEST_CONTENT_LENGTH,
14 years ago
COMP_PHYSICAL_PATH,
14 years ago
COMP_PHYSICAL_PATH_EXISTS,
COMP_PHYSICAL_SIZE,
/* needs a key */
COMP_REQUEST_HEADER
} cond_lvalue_t;
#define COND_LVALUE_FIRST_WITH_KEY COMP_REQUEST_HEADER
#define COND_LVALUE_END (1+COMP_REQUEST_HEADER)
struct condition_lvalue {
int refcount;
cond_lvalue_t type;
GString *key;
};
14 years ago
14 years ago
typedef enum {
COND_VALUE_INT,
COND_VALUE_STRING,
#ifdef HAVE_PCRE_H
COND_VALUE_REGEXP,
#endif
COND_VALUE_SOCKET_IPV4 /** only match ip/netmask */
#ifdef HAVE_IPV6
,COND_VALUE_SOCKET_IPV6 /** only match ip/netmask */
#endif
} cond_rvalue_t;
14 years ago
struct condition_rvalue {
cond_rvalue_t type;
GString *string;
#ifdef HAVE_PCRE_H
struct {
pcre *regex;
pcre_extra *regex_study;
};
#endif
gint64 i;
struct {
guint32 addr;
guint32 networkmask;
} ipv4;
#ifdef HAVE_IPV6
struct {
guint8 addr[16];
guint network;
} ipv6;
#endif
sock_addr addr;
};
14 years ago
#include "base.h"
struct condition {
int refcount;
comp_operator_t op;
condition_lvalue *lvalue;
condition_rvalue rvalue;
14 years ago
};
/* lvalue */
LI_API condition_lvalue* condition_lvalue_new(cond_lvalue_t type, GString *key);
LI_API void condition_lvalue_acquire(condition_lvalue *lvalue);
LI_API void condition_lvalue_release(condition_lvalue *lvalue);
14 years ago
LI_API condition* condition_new_string(server *srv, comp_operator_t op, condition_lvalue *lvalue, GString *str);
LI_API condition* condition_new_int(server *srv, comp_operator_t op, condition_lvalue *lvalue, gint i);
LI_API void condition_acquire(condition *c);
LI_API void condition_release(server *srv, condition* c);
14 years ago
LI_API const char* comp_op_to_string(comp_operator_t op);
LI_API const char* cond_lvalue_to_string(cond_lvalue_t t);
14 years ago
LI_API gboolean condition_check(server *srv, connection *con, condition *cond);
14 years ago
#endif