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