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 {
|
|
17 u_char *ip;
|
|
18 u_char *pos;
|
58
|
19 ngx_http_variable_value_t *sp;
|
|
20
|
|
21 ngx_str_t buf;
|
64
|
22 ngx_str_t line;
|
58
|
23
|
|
24 /* the start of the rewritten arguments */
|
|
25 u_char *args;
|
56
|
26
|
58
|
27 unsigned skip:1;
|
|
28 unsigned quote:1;
|
|
29 unsigned log:1;
|
56
|
30
|
58
|
31 int *captures;
|
64
|
32 ngx_uint_t ncaptures;
|
58
|
33
|
|
34 ngx_int_t status;
|
|
35 ngx_http_request_t *request;
|
56
|
36 } ngx_http_script_engine_t;
|
|
37
|
|
38
|
58
|
39 typedef struct {
|
|
40 ngx_conf_t *cf;
|
|
41 ngx_str_t *source;
|
|
42 ngx_array_t **lengths;
|
|
43 ngx_array_t **values;
|
|
44
|
|
45 ngx_uint_t variables;
|
|
46 ngx_uint_t ncaptures;
|
|
47 ngx_uint_t size;
|
|
48
|
|
49 void *main;
|
56
|
50
|
58
|
51 unsigned compile_args:1;
|
|
52 unsigned compile_null:1;
|
|
53 unsigned complete_lengths:1;
|
|
54 unsigned complete_values:1;
|
|
55
|
|
56 unsigned args:1;
|
|
57 } ngx_http_script_compile_t;
|
|
58
|
|
59
|
|
60 typedef void (*ngx_http_script_code_pt) (ngx_http_script_engine_t *e);
|
|
61 typedef size_t (*ngx_http_script_len_code_pt) (ngx_http_script_engine_t *e);
|
56
|
62
|
|
63
|
|
64 typedef struct {
|
|
65 ngx_http_script_code_pt code;
|
|
66 uintptr_t len;
|
|
67 } ngx_http_script_copy_code_t;
|
|
68
|
|
69
|
|
70 typedef struct {
|
|
71 ngx_http_script_code_pt code;
|
|
72 uintptr_t index;
|
|
73 } ngx_http_script_var_code_t;
|
|
74
|
|
75
|
58
|
76 typedef struct {
|
|
77 ngx_http_script_code_pt code;
|
|
78 uintptr_t n;
|
|
79 } ngx_http_script_copy_capture_code_t;
|
|
80
|
|
81
|
|
82 typedef struct {
|
|
83 ngx_http_script_code_pt code;
|
|
84 ngx_regex_t *regex;
|
|
85 ngx_array_t *lengths;
|
|
86 uintptr_t size;
|
|
87 uintptr_t ncaptures;
|
|
88 uintptr_t status;
|
|
89 uintptr_t next;
|
|
90
|
|
91 uintptr_t test:1;
|
|
92 uintptr_t uri:1;
|
|
93 uintptr_t args:1;
|
|
94
|
|
95 /* add the r->args to the new arguments */
|
|
96 uintptr_t add_args:1;
|
|
97
|
|
98 uintptr_t redirect:1;
|
|
99 uintptr_t break_cycle:1;
|
|
100
|
|
101 ngx_str_t name;
|
|
102 } ngx_http_script_regex_code_t;
|
|
103
|
|
104
|
|
105 typedef struct {
|
|
106 ngx_http_script_code_pt code;
|
|
107
|
|
108 uintptr_t uri:1;
|
|
109 uintptr_t args:1;
|
|
110
|
|
111 /* add the r->args to the new arguments */
|
|
112 uintptr_t add_args:1;
|
|
113
|
|
114 uintptr_t redirect:1;
|
|
115 } ngx_http_script_regex_end_code_t;
|
56
|
116
|
|
117
|
58
|
118 typedef struct {
|
|
119 ngx_http_script_code_pt code;
|
|
120 uintptr_t status;
|
|
121 uintptr_t null;
|
|
122 } ngx_http_script_return_code_t;
|
|
123
|
|
124
|
|
125 typedef struct {
|
|
126 ngx_http_script_code_pt code;
|
|
127 uintptr_t next;
|
|
128 void **loc_conf;
|
|
129 } ngx_http_script_if_code_t;
|
|
130
|
|
131
|
|
132 typedef struct {
|
|
133 ngx_http_script_code_pt code;
|
64
|
134 ngx_array_t *lengths;
|
|
135 } ngx_http_script_complex_value_code_t;
|
|
136
|
|
137
|
|
138 typedef struct {
|
|
139 ngx_http_script_code_pt code;
|
58
|
140 uintptr_t value;
|
|
141 uintptr_t text_len;
|
|
142 uintptr_t text_data;
|
|
143 } ngx_http_script_value_code_t;
|
|
144
|
56
|
145
|
58
|
146 ngx_uint_t ngx_http_script_variables_count(ngx_str_t *value);
|
|
147 ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
|
|
148
|
|
149 void *ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes,
|
|
150 size_t size);
|
|
151 void *ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code);
|
56
|
152
|
58
|
153 size_t ngx_http_script_copy_len_code(ngx_http_script_engine_t *e);
|
|
154 void ngx_http_script_copy_code(ngx_http_script_engine_t *e);
|
|
155 size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e);
|
|
156 void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e);
|
|
157 size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e);
|
|
158 void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e);
|
|
159 void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e);
|
|
160 void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e);
|
|
161 void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e);
|
|
162 void ngx_http_script_start_args_code(ngx_http_script_engine_t *e);
|
|
163 void ngx_http_script_return_code(ngx_http_script_engine_t *e);
|
|
164 void ngx_http_script_if_code(ngx_http_script_engine_t *e);
|
64
|
165 void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e);
|
58
|
166 void ngx_http_script_value_code(ngx_http_script_engine_t *e);
|
|
167 void ngx_http_script_set_var_code(ngx_http_script_engine_t *e);
|
|
168 void ngx_http_script_var_code(ngx_http_script_engine_t *e);
|
|
169 void ngx_http_script_nop_code(ngx_http_script_engine_t *e);
|
56
|
170
|
|
171
|
|
172 #endif /* _NGX_HTTP_SCRIPT_H_INCLUDED_ */
|