3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
8 #ifndef _NGX_HTTP_SCRIPT_H_INCLUDED_
9 #define _NGX_HTTP_SCRIPT_H_INCLUDED_
12 #include <ngx_config.h>
20 ngx_http_variable_value_t
*sp
;
25 /* the start of the rewritten arguments */
35 ngx_http_request_t
*request
;
36 } ngx_http_script_engine_t
;
43 ngx_array_t
**flushes
;
44 ngx_array_t
**lengths
;
49 ngx_uint_t captures_mask
;
54 unsigned compile_args
:1;
55 unsigned complete_lengths
:1;
56 unsigned complete_values
:1;
58 unsigned conf_prefix
:1;
59 unsigned root_prefix
:1;
61 unsigned dup_capture
:1;
63 } ngx_http_script_compile_t
;
71 } ngx_http_complex_value_t
;
77 ngx_http_complex_value_t
*complex_value
;
80 unsigned conf_prefix
:1;
81 unsigned root_prefix
:1;
82 } ngx_http_compile_complex_value_t
;
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
);
90 ngx_http_script_code_pt code
;
92 } ngx_http_script_copy_code_t
;
96 ngx_http_script_code_pt code
;
98 } ngx_http_script_var_code_t
;
102 ngx_http_script_code_pt code
;
103 ngx_http_set_variable_pt handler
;
105 } ngx_http_script_var_handler_code_t
;
109 ngx_http_script_code_pt code
;
111 } ngx_http_script_copy_capture_code_t
;
117 ngx_http_script_code_pt code
;
118 ngx_http_regex_t
*regex
;
119 ngx_array_t
*lengths
;
125 uintptr_t negative_test
:1;
129 /* add the r->args to the new arguments */
130 uintptr_t add_args
:1;
132 uintptr_t redirect
:1;
133 uintptr_t break_cycle
:1;
136 } ngx_http_script_regex_code_t
;
140 ngx_http_script_code_pt code
;
145 /* add the r->args to the new arguments */
146 uintptr_t add_args
:1;
148 uintptr_t redirect
:1;
149 } ngx_http_script_regex_end_code_t
;
155 ngx_http_script_code_pt code
;
156 uintptr_t conf_prefix
;
157 } ngx_http_script_full_name_code_t
;
161 ngx_http_script_code_pt code
;
163 ngx_http_complex_value_t text
;
164 } ngx_http_script_return_code_t
;
168 ngx_http_script_file_plain
= 0,
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
176 } ngx_http_script_file_op_e
;
180 ngx_http_script_code_pt code
;
182 } ngx_http_script_file_code_t
;
186 ngx_http_script_code_pt code
;
189 } ngx_http_script_if_code_t
;
193 ngx_http_script_code_pt code
;
194 ngx_array_t
*lengths
;
195 } ngx_http_script_complex_value_code_t
;
199 ngx_http_script_code_pt code
;
203 } ngx_http_script_value_code_t
;
206 void ngx_http_script_flush_complex_value(ngx_http_request_t
*r
,
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
);
211 char *ngx_http_set_complex_value_slot(ngx_conf_t
*cf
, ngx_command_t
*cmd
,
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
,
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
);
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
);
224 void ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t
*r
,
225 ngx_array_t
*indices
);
227 void *ngx_http_script_start_code(ngx_pool_t
*pool
, ngx_array_t
**codes
,
229 void *ngx_http_script_add_code(ngx_array_t
*codes
, size_t size
, void *code
);
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
);
237 size_t ngx_http_script_mark_args_code(ngx_http_script_engine_t
*e
);
238 void ngx_http_script_start_args_code(ngx_http_script_engine_t
*e
);
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
);
243 void ngx_http_script_return_code(ngx_http_script_engine_t
*e
);
244 void ngx_http_script_break_code(ngx_http_script_engine_t
*e
);
245 void ngx_http_script_if_code(ngx_http_script_engine_t
*e
);
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
);
248 void ngx_http_script_file_code(ngx_http_script_engine_t
*e
);
249 void ngx_http_script_complex_value_code(ngx_http_script_engine_t
*e
);
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
);
252 void ngx_http_script_var_set_handler_code(ngx_http_script_engine_t
*e
);
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
);
257 #endif /* _NGX_HTTP_SCRIPT_H_INCLUDED_ */