Mercurial > hg > nginx
annotate src/core/ngx_regex.h @ 7982:fbbb5ce52995
PCRE2 and PCRE binary compatibility.
With this change, dynamic modules using nginx regex interface can be used
regardless of the variant of the PCRE library nginx was compiled with.
If a module is compiled with different PCRE library variant, in case of
ngx_regex_exec() errors it will report wrong function name in error
messages. This is believed to be tolerable, given that fixing this will
require interface changes.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 25 Dec 2021 01:07:16 +0300 |
parents | 0b5f12d5c531 |
children | d07456044b61 |
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 | |
23 typedef pcre2_code ngx_regex_t; | |
24 | |
25 #else | |
26 | |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 #include <pcre.h> |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
7981 | 29 #define NGX_REGEX_NO_MATCHED PCRE_ERROR_NOMATCH /* -1 */ |
4388
005fc2d5e84f
Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents:
3325
diff
changeset
|
30 |
005fc2d5e84f
Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents:
3325
diff
changeset
|
31 typedef struct { |
4638
6e1a48bcf915
Fixed the ngx_regex.h header file compatibility with C++.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
32 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
|
33 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
|
34 } ngx_regex_t; |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 |
7981 | 36 #endif |
37 | |
3325 | 38 |
7982
fbbb5ce52995
PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7981
diff
changeset
|
39 #define NGX_REGEX_CASELESS 0x00000001 |
fbbb5ce52995
PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7981
diff
changeset
|
40 |
fbbb5ce52995
PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7981
diff
changeset
|
41 |
1784 | 42 typedef struct { |
3325 | 43 ngx_str_t pattern; |
44 ngx_pool_t *pool; | |
7982
fbbb5ce52995
PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7981
diff
changeset
|
45 ngx_uint_t options; |
3325 | 46 |
47 ngx_regex_t *regex; | |
48 int captures; | |
49 int named_captures; | |
50 int name_size; | |
51 u_char *names; | |
52 ngx_str_t err; | |
53 } ngx_regex_compile_t; | |
54 | |
55 | |
56 typedef struct { | |
57 ngx_regex_t *regex; | |
58 u_char *name; | |
1784 | 59 } ngx_regex_elt_t; |
60 | |
61 | |
499 | 62 void ngx_regex_init(void); |
3325 | 63 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
|
64 |
7981 | 65 ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s, int *captures, |
66 ngx_uint_t size); | |
7982
fbbb5ce52995
PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7981
diff
changeset
|
67 |
fbbb5ce52995
PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7981
diff
changeset
|
68 #if (NGX_PCRE2) |
7981 | 69 #define ngx_regex_exec_n "pcre2_match()" |
70 #else | |
71 #define ngx_regex_exec_n "pcre_exec()" | |
72 #endif | |
3319
be47fe127f8c
ngx_regex_exec() calling optimiztion:
Igor Sysoev <igor@sysoev.ru>
parents:
1784
diff
changeset
|
73 |
1784 | 74 ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log); |
75 | |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 #endif /* _NGX_REGEX_H_INCLUDED_ */ |