56
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
660
|
4 * Copyright (C) Nginx, Inc.
|
56
|
5 */
|
|
6
|
|
7
|
|
8 #ifndef _NGX_HTTP_SCRIPT_H_INCLUDED_
|
|
9 #define _NGX_HTTP_SCRIPT_H_INCLUDED_
|
|
10
|
|
11
|
|
12 #include <ngx_config.h>
|
|
13 #include <ngx_core.h>
|
|
14 #include <ngx_http.h>
|
|
15
|
|
16
|
|
17 typedef struct {
|
122
|
18 u_char *ip;
|
|
19 u_char *pos;
|
|
20 ngx_http_variable_value_t *sp;
|
58
|
21
|
122
|
22 ngx_str_t buf;
|
|
23 ngx_str_t line;
|
58
|
24
|
|
25 /* the start of the rewritten arguments */
|
122
|
26 u_char *args;
|
56
|
27
|
122
|
28 unsigned flushed:1;
|
|
29 unsigned skip:1;
|
|
30 unsigned quote:1;
|
366
|
31 unsigned is_args:1;
|
122
|
32 unsigned log:1;
|
58
|
33
|
122
|
34 ngx_int_t status;
|
|
35 ngx_http_request_t *request;
|
56
|
36 } ngx_http_script_engine_t;
|
|
37
|
|
38
|
58
|
39 typedef struct {
|
122
|
40 ngx_conf_t *cf;
|
|
41 ngx_str_t *source;
|
58
|
42
|
122
|
43 ngx_array_t **flushes;
|
|
44 ngx_array_t **lengths;
|
|
45 ngx_array_t **values;
|
58
|
46
|
122
|
47 ngx_uint_t variables;
|
|
48 ngx_uint_t ncaptures;
|
190
|
49 ngx_uint_t captures_mask;
|
122
|
50 ngx_uint_t size;
|
|
51
|
|
52 void *main;
|
56
|
53
|
122
|
54 unsigned compile_args:1;
|
|
55 unsigned complete_lengths:1;
|
|
56 unsigned complete_values:1;
|
464
|
57 unsigned zero:1;
|
|
58 unsigned conf_prefix:1;
|
|
59 unsigned root_prefix:1;
|
|
60
|
190
|
61 unsigned dup_capture:1;
|
122
|
62 unsigned args:1;
|
58
|
63 } ngx_http_script_compile_t;
|
|
64
|
|
65
|
464
|
66 typedef struct {
|
|
67 ngx_str_t value;
|
|
68 ngx_uint_t *flushes;
|
|
69 void *lengths;
|
|
70 void *values;
|
|
71 } ngx_http_complex_value_t;
|
|
72
|
|
73
|
|
74 typedef struct {
|
|
75 ngx_conf_t *cf;
|
|
76 ngx_str_t *value;
|
|
77 ngx_http_complex_value_t *complex_value;
|
|
78
|
|
79 unsigned zero:1;
|
|
80 unsigned conf_prefix:1;
|
|
81 unsigned root_prefix:1;
|
|
82 } ngx_http_compile_complex_value_t;
|
|
83
|
|
84
|
58
|
85 typedef void (*ngx_http_script_code_pt) (ngx_http_script_engine_t *e);
|
|
86 typedef size_t (*ngx_http_script_len_code_pt) (ngx_http_script_engine_t *e);
|
56
|
87
|
|
88
|
|
89 typedef struct {
|
464
|
90 ngx_http_script_code_pt code;
|
|
91 uintptr_t len;
|
56
|
92 } ngx_http_script_copy_code_t;
|
|
93
|
|
94
|
|
95 typedef struct {
|
464
|
96 ngx_http_script_code_pt code;
|
|
97 uintptr_t index;
|
56
|
98 } ngx_http_script_var_code_t;
|
|
99
|
|
100
|
58
|
101 typedef struct {
|
464
|
102 ngx_http_script_code_pt code;
|
|
103 ngx_http_set_variable_pt handler;
|
|
104 uintptr_t data;
|
186
|
105 } ngx_http_script_var_handler_code_t;
|
|
106
|
|
107
|
|
108 typedef struct {
|
464
|
109 ngx_http_script_code_pt code;
|
|
110 uintptr_t n;
|
58
|
111 } ngx_http_script_copy_capture_code_t;
|
|
112
|
|
113
|
66
|
114 #if (NGX_PCRE)
|
|
115
|
58
|
116 typedef struct {
|
464
|
117 ngx_http_script_code_pt code;
|
546
|
118 ngx_http_regex_t *regex;
|
464
|
119 ngx_array_t *lengths;
|
|
120 uintptr_t size;
|
|
121 uintptr_t status;
|
|
122 uintptr_t next;
|
58
|
123
|
464
|
124 uintptr_t test:1;
|
|
125 uintptr_t negative_test:1;
|
|
126 uintptr_t uri:1;
|
|
127 uintptr_t args:1;
|
58
|
128
|
|
129 /* add the r->args to the new arguments */
|
464
|
130 uintptr_t add_args:1;
|
126
|
131
|
464
|
132 uintptr_t redirect:1;
|
|
133 uintptr_t break_cycle:1;
|
58
|
134
|
464
|
135 ngx_str_t name;
|
58
|
136 } ngx_http_script_regex_code_t;
|
|
137
|
|
138
|
|
139 typedef struct {
|
464
|
140 ngx_http_script_code_pt code;
|
58
|
141
|
464
|
142 uintptr_t uri:1;
|
|
143 uintptr_t args:1;
|
58
|
144
|
|
145 /* add the r->args to the new arguments */
|
464
|
146 uintptr_t add_args:1;
|
58
|
147
|
464
|
148 uintptr_t redirect:1;
|
58
|
149 } ngx_http_script_regex_end_code_t;
|
56
|
150
|
66
|
151 #endif
|
|
152
|
56
|
153
|
58
|
154 typedef struct {
|
464
|
155 ngx_http_script_code_pt code;
|
482
|
156 uintptr_t conf_prefix;
|
464
|
157 } ngx_http_script_full_name_code_t;
|
|
158
|
|
159
|
|
160 typedef struct {
|
|
161 ngx_http_script_code_pt code;
|
|
162 uintptr_t status;
|
580
|
163 ngx_http_complex_value_t text;
|
58
|
164 } ngx_http_script_return_code_t;
|
|
165
|
|
166
|
180
|
167 typedef enum {
|
|
168 ngx_http_script_file_plain = 0,
|
218
|
169 ngx_http_script_file_not_plain,
|
|
170 ngx_http_script_file_dir,
|
|
171 ngx_http_script_file_not_dir,
|
|
172 ngx_http_script_file_exists,
|
|
173 ngx_http_script_file_not_exists,
|
|
174 ngx_http_script_file_exec,
|
|
175 ngx_http_script_file_not_exec
|
180
|
176 } ngx_http_script_file_op_e;
|
|
177
|
|
178
|
|
179 typedef struct {
|
464
|
180 ngx_http_script_code_pt code;
|
|
181 uintptr_t op;
|
180
|
182 } ngx_http_script_file_code_t;
|
|
183
|
|
184
|
58
|
185 typedef struct {
|
464
|
186 ngx_http_script_code_pt code;
|
|
187 uintptr_t next;
|
|
188 void **loc_conf;
|
58
|
189 } ngx_http_script_if_code_t;
|
|
190
|
|
191
|
|
192 typedef struct {
|
464
|
193 ngx_http_script_code_pt code;
|
|
194 ngx_array_t *lengths;
|
64
|
195 } ngx_http_script_complex_value_code_t;
|
|
196
|
|
197
|
|
198 typedef struct {
|
464
|
199 ngx_http_script_code_pt code;
|
|
200 uintptr_t value;
|
|
201 uintptr_t text_len;
|
|
202 uintptr_t text_data;
|
58
|
203 } ngx_http_script_value_code_t;
|
|
204
|
56
|
205
|
468
|
206 void ngx_http_script_flush_complex_value(ngx_http_request_t *r,
|
464
|
207 ngx_http_complex_value_t *val);
|
|
208 ngx_int_t ngx_http_complex_value(ngx_http_request_t *r,
|
|
209 ngx_http_complex_value_t *val, ngx_str_t *value);
|
|
210 ngx_int_t ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv);
|
598
|
211 char *ngx_http_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
596
|
212 void *conf);
|
|
213
|
464
|
214
|
588
|
215 ngx_int_t ngx_http_test_predicates(ngx_http_request_t *r,
|
|
216 ngx_array_t *predicates);
|
|
217 char *ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
218 void *conf);
|
|
219
|
58
|
220 ngx_uint_t ngx_http_script_variables_count(ngx_str_t *value);
|
|
221 ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
|
172
|
222 u_char *ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
|
|
223 void *code_lengths, size_t reserved, void *code_values);
|
340
|
224 void ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r,
|
122
|
225 ngx_array_t *indices);
|
58
|
226
|
|
227 void *ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes,
|
|
228 size_t size);
|
|
229 void *ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code);
|
56
|
230
|
58
|
231 size_t ngx_http_script_copy_len_code(ngx_http_script_engine_t *e);
|
|
232 void ngx_http_script_copy_code(ngx_http_script_engine_t *e);
|
|
233 size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e);
|
|
234 void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e);
|
|
235 size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e);
|
|
236 void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e);
|
366
|
237 size_t ngx_http_script_mark_args_code(ngx_http_script_engine_t *e);
|
66
|
238 void ngx_http_script_start_args_code(ngx_http_script_engine_t *e);
|
|
239 #if (NGX_PCRE)
|
58
|
240 void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e);
|
|
241 void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e);
|
66
|
242 #endif
|
58
|
243 void ngx_http_script_return_code(ngx_http_script_engine_t *e);
|
76
|
244 void ngx_http_script_break_code(ngx_http_script_engine_t *e);
|
58
|
245 void ngx_http_script_if_code(ngx_http_script_engine_t *e);
|
126
|
246 void ngx_http_script_equal_code(ngx_http_script_engine_t *e);
|
|
247 void ngx_http_script_not_equal_code(ngx_http_script_engine_t *e);
|
180
|
248 void ngx_http_script_file_code(ngx_http_script_engine_t *e);
|
64
|
249 void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
|
58
|
250 void ngx_http_script_value_code(ngx_http_script_engine_t *e);
|
|
251 void ngx_http_script_set_var_code(ngx_http_script_engine_t *e);
|
186
|
252 void ngx_http_script_var_set_handler_code(ngx_http_script_engine_t *e);
|
58
|
253 void ngx_http_script_var_code(ngx_http_script_engine_t *e);
|
|
254 void ngx_http_script_nop_code(ngx_http_script_engine_t *e);
|
56
|
255
|
|
256
|
|
257 #endif /* _NGX_HTTP_SCRIPT_H_INCLUDED_ */
|