Mercurial > hg > nginx
annotate src/core/ngx_regex.h @ 7981:0b5f12d5c531
PCRE2 library support.
The PCRE2 library is now used by default if found, instead of the
original PCRE library. If needed for some reason, this can be disabled
with the --without-pcre2 configure option.
To make it possible to specify paths to the library and include files
via --with-cc-opt / --with-ld-opt, the library is first tested without
any additional paths and options. If this fails, the pcre2-config script
is used.
Similarly to the original PCRE library, it is now possible to build PCRE2
from sources with nginx configure, by using the --with-pcre= option.
It automatically detects if PCRE or PCRE2 sources are provided.
Note that compiling PCRE2 10.33 and later requires inttypes.h. When
compiling on Windows with MSVC, inttypes.h is only available starting
with MSVC 2013. In older versions some replacement needs to be provided
("echo '#include <stdint.h>' > pcre2-10.xx/src/inttypes.h" is good enough
for MSVC 2010).
The interface on nginx side remains unchanged.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 25 Dec 2021 01:07:15 +0300 |
parents | 6e1a48bcf915 |
children | fbbb5ce52995 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
216
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
216
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
216
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
216
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
216
diff
changeset
|
7 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #ifndef _NGX_REGEX_H_INCLUDED_ |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #define _NGX_REGEX_H_INCLUDED_ |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 #include <ngx_config.h> |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 #include <ngx_core.h> |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
7981 | 15 |
16 #if (NGX_PCRE2) | |
17 | |
18 #define PCRE2_CODE_UNIT_WIDTH 8 | |
19 #include <pcre2.h> | |
20 | |
21 #define NGX_REGEX_NO_MATCHED PCRE2_ERROR_NOMATCH /* -1 */ | |
22 #define NGX_REGEX_CASELESS PCRE2_CASELESS | |
23 | |
24 typedef pcre2_code ngx_regex_t; | |
25 | |
26 #else | |
27 | |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 #include <pcre.h> |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 |
7981 | 30 #define NGX_REGEX_NO_MATCHED PCRE_ERROR_NOMATCH /* -1 */ |
31 #define NGX_REGEX_CASELESS PCRE_CASELESS | |
4388
005fc2d5e84f
Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents:
3325
diff
changeset
|
32 |
005fc2d5e84f
Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents:
3325
diff
changeset
|
33 typedef struct { |
4638
6e1a48bcf915
Fixed the ngx_regex.h header file compatibility with C++.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
34 pcre *code; |
4388
005fc2d5e84f
Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents:
3325
diff
changeset
|
35 pcre_extra *extra; |
005fc2d5e84f
Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents:
3325
diff
changeset
|
36 } ngx_regex_t; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
7981 | 38 #endif |
39 | |
3325 | 40 |
1784 | 41 typedef struct { |
3325 | 42 ngx_str_t pattern; |
43 ngx_pool_t *pool; | |
44 ngx_int_t options; | |
45 | |
46 ngx_regex_t *regex; | |
47 int captures; | |
48 int named_captures; | |
49 int name_size; | |
50 u_char *names; | |
51 ngx_str_t err; | |
52 } ngx_regex_compile_t; | |
53 | |
54 | |
55 typedef struct { | |
56 ngx_regex_t *regex; | |
57 u_char *name; | |
1784 | 58 } ngx_regex_elt_t; |
59 | |
60 | |
499 | 61 void ngx_regex_init(void); |
3325 | 62 ngx_int_t ngx_regex_compile(ngx_regex_compile_t *rc); |
3319
be47fe127f8c
ngx_regex_exec() calling optimiztion:
Igor Sysoev <igor@sysoev.ru>
parents:
1784
diff
changeset
|
63 |
7981 | 64 #if (NGX_PCRE2) |
65 | |
66 ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s, int *captures, | |
67 ngx_uint_t size); | |
68 #define ngx_regex_exec_n "pcre2_match()" | |
69 | |
70 #else | |
71 | |
3319
be47fe127f8c
ngx_regex_exec() calling optimiztion:
Igor Sysoev <igor@sysoev.ru>
parents:
1784
diff
changeset
|
72 #define ngx_regex_exec(re, s, captures, size) \ |
4638
6e1a48bcf915
Fixed the ngx_regex.h header file compatibility with C++.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
73 pcre_exec(re->code, re->extra, (const char *) (s)->data, (s)->len, 0, 0, \ |
3319
be47fe127f8c
ngx_regex_exec() calling optimiztion:
Igor Sysoev <igor@sysoev.ru>
parents:
1784
diff
changeset
|
74 captures, size) |
7981 | 75 #define ngx_regex_exec_n "pcre_exec()" |
76 | |
77 #endif | |
3319
be47fe127f8c
ngx_regex_exec() calling optimiztion:
Igor Sysoev <igor@sysoev.ru>
parents:
1784
diff
changeset
|
78 |
1784 | 79 ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log); |
80 | |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 #endif /* _NGX_REGEX_H_INCLUDED_ */ |