30 #define ngx_http_script_exit (u_char *) &ngx_http_script_exit_code
32 static uintptr_t ngx_http_script_exit_code = (uintptr_t) NULL;
81 while (*(uintptr_t *) e.
ip) {
88 if (value->
data == NULL) {
96 while (*(uintptr_t *) e.
ip) {
112 ngx_array_t flushes, lengths, values, *pf, *pl, *pv;
120 for (i = 0; i < v->
len; i++) {
121 if (v->
data[i] ==
'$') {
122 if (v->
data[i + 1] >=
'1' && v->
data[i + 1] <=
'9') {
131 if ((v->
len == 0 || v->
data[0] !=
'$')
147 if (nv == 0 && nc == 0) {
163 if (ngx_array_init(&lengths, ccv->
cf->
pool, n, 1) !=
NGX_OK) {
171 +
sizeof(uintptr_t) - 1)
172 & ~(
sizeof(uintptr_t) - 1);
174 if (ngx_array_init(&values, ccv->
cf->
pool, n, 1) !=
NGX_OK) {
236 ccv.
value = &value[1];
254 if (predicates == NULL) {
258 cv = predicates->
elts;
260 for (i = 0; i < predicates->
nelts; i++) {
265 if (val.
len && (val.
len != 1 || val.
data[0] !=
'0')) {
322 for (n = 0, i = 0; i < value->
len; i++) {
323 if (value->
data[i] ==
'$') {
339 if (ngx_http_script_init_arrays(sc) !=
NGX_OK) {
350 goto invalid_variable;
367 if (ngx_http_script_add_capture_code(sc, n) !=
NGX_OK) {
382 goto invalid_variable;
395 if (ch ==
'}' && bracket) {
401 if ((ch >=
'A' && ch <=
'Z')
402 || (ch >=
'a' && ch <=
'z')
403 || (ch >=
'0' && ch <=
'9')
414 "the closing bracket in \"%V\" "
415 "variable is missing", &name);
420 goto invalid_variable;
425 if (ngx_http_script_add_var_code(sc, &name) !=
NGX_OK) {
436 if (ngx_http_script_add_args_code(sc) !=
NGX_OK) {
447 while (i < sc->source->len) {
468 if (ngx_http_script_add_copy_code(sc, &name, (i == sc->
source->
len))
475 return ngx_http_script_done(sc);
487 void *code_lengths,
size_t len,
void *code_values)
510 while (*(uintptr_t *) e.
ip) {
518 if (value->
data == NULL) {
525 while (*(uintptr_t *) e.
ip) {
541 index = indices->
elts;
542 for (n = 0; n < indices->
nelts; n++) {
576 if (*sc->
values == NULL) {
581 +
sizeof(uintptr_t) - 1)
582 & ~(
sizeof(uintptr_t) - 1);
585 if (*sc->
values == NULL) {
605 zero.
data = (u_char *)
"\0";
607 if (ngx_http_script_add_copy_code(sc, &zero, 0) !=
NGX_OK) {
613 if (ngx_http_script_add_full_name_code(sc) !=
NGX_OK) {
624 *code = (uintptr_t) NULL;
634 *code = (uintptr_t) NULL;
644 if (*codes == NULL) {
646 if (*codes == NULL) {
669 if (elts != codes->
elts) {
671 *p += (u_char *) codes->
elts - elts;
684 size_t size, len, zero;
687 zero = (sc->
zero && last);
688 len = value->
len + zero;
700 & ~(
sizeof(uintptr_t) - 1);
751 + ((code->
len +
sizeof(uintptr_t) - 1) & ~(
sizeof(uintptr_t) - 1));
754 "http script copy: \"%*s\"", e->
pos - p, p);
786 code->
index = (uintptr_t) index;
796 code->
index = (uintptr_t) index;
853 "http script var: \"%*s\"", e->
pos - p, p);
886 e->
ip +=
sizeof(uintptr_t);
900 e->
ip +=
sizeof(uintptr_t);
915 ngx_http_script_regex_code_t *code;
917 code = (ngx_http_script_regex_code_t *) e->
ip;
922 "http script regex: \"%V\"", &code->name);
932 rc = ngx_http_regex_exec(r, code->regex, &e->
line);
937 "\"%V\" does not match \"%V\"",
938 &code->name, &e->
line);
944 if (code->negative_test) {
946 e->
sp->
data = (u_char *)
"1";
950 e->
sp->
data = (u_char *)
"";
955 e->
ip +=
sizeof(ngx_http_script_regex_code_t);
971 "\"%V\" matches \"%V\"", &code->name, &e->
line);
975 if (code->negative_test) {
977 e->
sp->
data = (u_char *)
"";
981 e->
sp->
data = (u_char *)
"1";
986 e->
ip +=
sizeof(ngx_http_script_regex_code_t);
993 if (!code->redirect) {
1003 if (code->break_cycle) {
1012 if (code->lengths == NULL) {
1022 for (n = 2; n < r->ncaptures; n += 2) {
1023 e->
buf.
len += r->captures[n + 1] - r->captures[n];
1029 le.
ip = code->lengths->elts;
1032 le.
quote = code->redirect;
1036 while (*(uintptr_t *) le.
ip) {
1044 if (code->add_args && r->
args.
len) {
1055 e->
quote = code->redirect;
1059 e->
ip +=
sizeof(ngx_http_script_regex_code_t);
1068 ngx_http_script_regex_end_code_t *code;
1070 code = (ngx_http_script_regex_end_code_t *) e->
ip;
1077 "http script regex end");
1079 if (code->redirect) {
1093 if (code->add_args && r->
args.
len) {
1094 *e->
pos++ = (u_char) (code->args ?
'&' :
'?');
1102 "rewritten redirect: \"%V\"", &e->
buf);
1118 e->
ip +=
sizeof(ngx_http_script_regex_end_code_t);
1125 if (code->add_args && r->
args.
len) {
1138 if (!code->add_args) {
1145 "rewritten data: \"%V\", args: \"%V\"",
1154 "the rewritten URI has a zero length");
1163 e->
ip +=
sizeof(ngx_http_script_regex_end_code_t);
1219 if (n < r->ncaptures) {
1226 p = r->captures_data;
1228 return cap[n + 1] - cap[n]
1232 return cap[n + 1] - cap[n];
1259 if (n < r->ncaptures) {
1262 p = r->captures_data;
1268 cap[n + 1] - cap[n],
1271 e->
pos =
ngx_copy(pos, &p[cap[n]], cap[n + 1] - cap[n]);
1276 "http script capture: \"%*s\"", e->
pos - pos, pos);
1304 code->
code = ngx_http_script_full_name_code;
1348 "http script fullname: \"%V\"", &value);
1407 "http script if: false");
1419 "http script equal");
1425 e->
ip +=
sizeof(uintptr_t);
1435 "http script equal: no");
1447 "http script not equal");
1453 e->
ip +=
sizeof(uintptr_t);
1459 "http script not equal: no");
1484 path.
len = value->
len - 1;
1490 "http script file op %p \"%V\"", code->
op, &path);
1592 "http script file op false");
1617 "http script complex value");
1626 for (len = 0; *(uintptr_t *) le.
ip; len += lcode(&le)) {
1659 "http script value: \"%v\"", e->
sp);
1695 "http script set $%V", &v[code->
index].
name);
1707 "http script set var handler");
1736 "http script var: \"%v\"", value);
1752 e->
ip +=
sizeof(uintptr_t);