2006-06-26 00:48:02 +00:00
|
|
|
/*
|
2010-01-28 17:10:50 +00:00
|
|
|
* include/common/regex.h
|
|
|
|
* This file defines everything related to regular expressions.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
|
|
* exclusively.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2006-06-29 15:53:05 +00:00
|
|
|
#ifndef _COMMON_REGEX_H
|
|
|
|
#define _COMMON_REGEX_H
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2006-06-29 16:54:54 +00:00
|
|
|
#include <common/config.h>
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
#ifdef USE_PCRE
|
|
|
|
#include <pcre.h>
|
|
|
|
#include <pcreposix.h>
|
|
|
|
#else
|
|
|
|
#include <regex.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* what to do when a header matches a regex */
|
|
|
|
#define ACT_ALLOW 0 /* allow the request */
|
|
|
|
#define ACT_REPLACE 1 /* replace the matching header */
|
|
|
|
#define ACT_REMOVE 2 /* remove the matching header */
|
|
|
|
#define ACT_DENY 3 /* deny the request */
|
|
|
|
#define ACT_PASS 4 /* pass this header without allowing or denying the request */
|
2006-09-03 07:56:00 +00:00
|
|
|
#define ACT_TARPIT 5 /* tarpit the connection matching this request */
|
2006-12-17 22:15:24 +00:00
|
|
|
#define ACT_SETBE 6 /* switch the backend */
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
struct hdr_exp {
|
|
|
|
struct hdr_exp *next;
|
2006-10-15 13:17:57 +00:00
|
|
|
const regex_t *preg; /* expression to look for */
|
2006-06-26 00:48:02 +00:00
|
|
|
int action; /* ACT_ALLOW, ACT_REPLACE, ACT_REMOVE, ACT_DENY */
|
2006-10-15 13:17:57 +00:00
|
|
|
const char *replace; /* expression to set instead */
|
2010-01-28 17:10:50 +00:00
|
|
|
void *cond; /* a possible condition or NULL */
|
2006-06-26 00:48:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern regmatch_t pmatch[MAX_MATCH];
|
|
|
|
|
2006-10-15 13:17:57 +00:00
|
|
|
int exp_replace(char *dst, char *src, const char *str, const regmatch_t *matches);
|
|
|
|
const char *check_replace_string(const char *str);
|
|
|
|
const char *chain_regex(struct hdr_exp **head, const regex_t *preg,
|
2010-01-28 17:10:50 +00:00
|
|
|
int action, const char *replace, void *cond);
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2006-06-29 15:53:05 +00:00
|
|
|
#endif /* _COMMON_REGEX_H */
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-indent-level: 8
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|