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;
|
|
30 unsigned log:1;
|
58
|
31
|
122
|
32 int *captures;
|
|
33 ngx_uint_t ncaptures;
|
|
34
|
|
35 ngx_int_t status;
|
|
36 ngx_http_request_t *request;
|
56
|
37 } ngx_http_script_engine_t;
|
|
38
|
|
39
|
58
|
40 typedef struct {
|
122
|
41 ngx_conf_t *cf;
|
|
42 ngx_str_t *source;
|
58
|
43
|
122
|
44 ngx_array_t **flushes;
|
|
45 ngx_array_t **lengths;
|
|
46 ngx_array_t **values;
|
58
|
47
|
122
|
48 ngx_uint_t variables;
|
|
49 ngx_uint_t ncaptures;
|
|
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;
|
58
|
57
|
122
|
58 unsigned args:1;
|
58
|
59 } ngx_http_script_compile_t;
|
|
60
|
|
61
|
|
62 typedef void (*ngx_http_script_code_pt) (ngx_http_script_engine_t *e);
|
|
63 typedef size_t (*ngx_http_script_len_code_pt) (ngx_http_script_engine_t *e);
|
56
|
64
|
|
65
|
|
66 typedef struct {
|
|
67 ngx_http_script_code_pt code;
|
|
68 uintptr_t len;
|
|
69 } ngx_http_script_copy_code_t;
|
|
70
|
|
71
|
|
72 typedef struct {
|
|
73 ngx_http_script_code_pt code;
|
|
74 uintptr_t index;
|
|
75 } ngx_http_script_var_code_t;
|
|
76
|
|
77
|
58
|
78 typedef struct {
|
186
|
79 ngx_http_script_code_pt code;
|
|
80 ngx_http_set_variable_pt handler;
|
|
81 uintptr_t data;
|
|
82 } ngx_http_script_var_handler_code_t;
|
|
83
|
|
84
|
|
85 typedef struct {
|
58
|
86 ngx_http_script_code_pt code;
|
|
87 uintptr_t n;
|
|
88 } ngx_http_script_copy_capture_code_t;
|
|
89
|
|
90
|
66
|
91 #if (NGX_PCRE)
|
|
92
|
58
|
93 typedef struct {
|
|
94 ngx_http_script_code_pt code;
|
|
95 ngx_regex_t *regex;
|
|
96 ngx_array_t *lengths;
|
|
97 uintptr_t size;
|
|
98 uintptr_t ncaptures;
|
|
99 uintptr_t status;
|
|
100 uintptr_t next;
|
|
101
|
|
102 uintptr_t test:1;
|
180
|
103 uintptr_t negative_test:1;
|
58
|
104 uintptr_t uri:1;
|
|
105 uintptr_t args:1;
|
|
106
|
|
107 /* add the r->args to the new arguments */
|
|
108 uintptr_t add_args:1;
|
126
|
109
|
58
|
110 uintptr_t redirect:1;
|
|
111 uintptr_t break_cycle:1;
|
|
112
|
|
113 ngx_str_t name;
|
|
114 } ngx_http_script_regex_code_t;
|
|
115
|
|
116
|
|
117 typedef struct {
|
|
118 ngx_http_script_code_pt code;
|
|
119
|
|
120 uintptr_t uri:1;
|
|
121 uintptr_t args:1;
|
|
122
|
|
123 /* add the r->args to the new arguments */
|
|
124 uintptr_t add_args:1;
|
|
125
|
|
126 uintptr_t redirect:1;
|
|
127 } ngx_http_script_regex_end_code_t;
|
56
|
128
|
66
|
129 #endif
|
|
130
|
56
|
131
|
58
|
132 typedef struct {
|
|
133 ngx_http_script_code_pt code;
|
|
134 uintptr_t status;
|
|
135 uintptr_t null;
|
|
136 } ngx_http_script_return_code_t;
|
|
137
|
|
138
|
180
|
139 typedef enum {
|
|
140 ngx_http_script_file_plain = 0,
|
|
141 ngx_http_script_file_not_plain
|
|
142 } ngx_http_script_file_op_e;
|
|
143
|
|
144
|
|
145 typedef struct {
|
|
146 ngx_http_script_code_pt code;
|
|
147 uintptr_t op;
|
|
148 } ngx_http_script_file_code_t;
|
|
149
|
|
150
|
58
|
151 typedef struct {
|
|
152 ngx_http_script_code_pt code;
|
|
153 uintptr_t next;
|
|
154 void **loc_conf;
|
|
155 } ngx_http_script_if_code_t;
|
|
156
|
|
157
|
|
158 typedef struct {
|
|
159 ngx_http_script_code_pt code;
|
64
|
160 ngx_array_t *lengths;
|
|
161 } ngx_http_script_complex_value_code_t;
|
|
162
|
|
163
|
|
164 typedef struct {
|
|
165 ngx_http_script_code_pt code;
|
58
|
166 uintptr_t value;
|
|
167 uintptr_t text_len;
|
|
168 uintptr_t text_data;
|
|
169 } ngx_http_script_value_code_t;
|
|
170
|
56
|
171
|
58
|
172 ngx_uint_t ngx_http_script_variables_count(ngx_str_t *value);
|
|
173 ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
|
172
|
174 u_char *ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
|
|
175 void *code_lengths, size_t reserved, void *code_values);
|
122
|
176 void ngx_http_script_flush_no_cachable_variables(ngx_http_request_t *r,
|
|
177 ngx_array_t *indices);
|
58
|
178
|
|
179 void *ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes,
|
|
180 size_t size);
|
|
181 void *ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code);
|
56
|
182
|
58
|
183 size_t ngx_http_script_copy_len_code(ngx_http_script_engine_t *e);
|
|
184 void ngx_http_script_copy_code(ngx_http_script_engine_t *e);
|
|
185 size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e);
|
|
186 void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e);
|
|
187 size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e);
|
|
188 void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e);
|
66
|
189 void ngx_http_script_start_args_code(ngx_http_script_engine_t *e);
|
|
190 #if (NGX_PCRE)
|
58
|
191 void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e);
|
|
192 void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e);
|
66
|
193 #endif
|
58
|
194 void ngx_http_script_return_code(ngx_http_script_engine_t *e);
|
76
|
195 void ngx_http_script_break_code(ngx_http_script_engine_t *e);
|
58
|
196 void ngx_http_script_if_code(ngx_http_script_engine_t *e);
|
126
|
197 void ngx_http_script_equal_code(ngx_http_script_engine_t *e);
|
|
198 void ngx_http_script_not_equal_code(ngx_http_script_engine_t *e);
|
180
|
199 void ngx_http_script_file_code(ngx_http_script_engine_t *e);
|
64
|
200 void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
|
58
|
201 void ngx_http_script_value_code(ngx_http_script_engine_t *e);
|
|
202 void ngx_http_script_set_var_code(ngx_http_script_engine_t *e);
|
186
|
203 void ngx_http_script_var_set_handler_code(ngx_http_script_engine_t *e);
|
58
|
204 void ngx_http_script_var_code(ngx_http_script_engine_t *e);
|
|
205 void ngx_http_script_nop_code(ngx_http_script_engine_t *e);
|
56
|
206
|
|
207
|
|
208 #endif /* _NGX_HTTP_SCRIPT_H_INCLUDED_ */
|