blob: 33d88a2eaf719b68baf101e363b3fb60e19c3e42 [file] [log] [blame]
Willy Tarreau7cd8b6e2020-06-02 17:32:26 +02001/*
2 * include/haproxy/regex-t.h
3 * Types and macros definitions for regular expressions
4 *
5 * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _HAPROXY_REGEX_T_H
23#define _HAPROXY_REGEX_T_H
24
25#include <stdlib.h>
26#include <string.h>
27
28#include <haproxy/api.h>
Willy Tarreau7cd8b6e2020-06-02 17:32:26 +020029
30#ifdef USE_PCRE
31#include <pcre.h>
32#include <pcreposix.h>
33
34/* For pre-8.20 PCRE compatibility */
35#ifndef PCRE_STUDY_JIT_COMPILE
36#define PCRE_STUDY_JIT_COMPILE 0
37#endif
38
Willy Tarreau6e816ec2021-08-28 12:49:58 +020039#elif defined(USE_PCRE2)
Willy Tarreau7cd8b6e2020-06-02 17:32:26 +020040#include <pcre2.h>
41#include <pcre2posix.h>
42
43#else /* no PCRE, nor PCRE2 */
44#include <regex.h>
45#endif
46
47struct my_regex {
48#ifdef USE_PCRE
49 pcre *reg;
50 pcre_extra *extra;
51#ifdef USE_PCRE_JIT
52#ifndef PCRE_CONFIG_JIT
53#error "The PCRE lib doesn't support JIT. Change your lib, or remove the option USE_PCRE_JIT."
54#endif
55#endif
Willy Tarreau6e816ec2021-08-28 12:49:58 +020056#elif defined(USE_PCRE2)
David Carlier7adf8f32020-08-13 14:53:41 +010057 int(*mfn)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, pcre2_match_data *, pcre2_match_context *);
Willy Tarreau7cd8b6e2020-06-02 17:32:26 +020058 pcre2_code *reg;
59#else /* no PCRE */
60 regex_t regex;
61#endif
62};
63
64struct hdr_exp {
65 struct hdr_exp *next;
66 struct my_regex *preg; /* expression to look for */
67 const char *replace; /* expression to set instead */
68 void *cond; /* a possible condition or NULL */
69};
70
71#endif /* _HAPROXY_REGEX_T_H */
72
73/*
74 * Local variables:
75 * c-indent-level: 8
76 * c-basic-offset: 8
77 * End:
78 */