Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_xslt_filter_module.c @ 2588:a6954ce88b80
use complex values in add_header, auth_basic_user_file,
sub_filter, and xslt_stylesheet parameters
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 22 Mar 2009 09:39:19 +0000 |
parents | 3e213fa0cbb3 |
children | 3daf68f2efe3 |
comparison
equal
deleted
inserted
replaced
2587:8afc4df77ee8 | 2588:a6954ce88b80 |
---|---|
36 ngx_array_t sheet_files; /* ngx_http_xslt_file_t */ | 36 ngx_array_t sheet_files; /* ngx_http_xslt_file_t */ |
37 } ngx_http_xslt_filter_main_conf_t; | 37 } ngx_http_xslt_filter_main_conf_t; |
38 | 38 |
39 | 39 |
40 typedef struct { | 40 typedef struct { |
41 ngx_array_t *lengths; | |
42 ngx_array_t *values; | |
43 } ngx_http_xslt_param_t; | |
44 | |
45 | |
46 typedef struct { | |
47 xsltStylesheetPtr stylesheet; | 41 xsltStylesheetPtr stylesheet; |
48 ngx_array_t params; /* ngx_http_xslt_param_t */ | 42 ngx_array_t params; /* ngx_http_complex_value_t */ |
49 } ngx_http_xslt_sheet_t; | 43 } ngx_http_xslt_sheet_t; |
50 | 44 |
51 | 45 |
52 typedef struct { | 46 typedef struct { |
53 xmlDtdPtr dtd; | 47 xmlDtdPtr dtd; |
865 | 859 |
866 static ngx_int_t | 860 static ngx_int_t |
867 ngx_http_xslt_params(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx, | 861 ngx_http_xslt_params(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx, |
868 ngx_array_t *params) | 862 ngx_array_t *params) |
869 { | 863 { |
870 u_char *p, *last, *value, *dst, *src, **s; | 864 u_char *p, *last, *value, *dst, *src, **s; |
871 size_t len; | 865 size_t len; |
872 ngx_uint_t i; | 866 ngx_uint_t i; |
873 ngx_str_t string; | 867 ngx_str_t string; |
874 ngx_http_xslt_param_t *param; | 868 ngx_http_complex_value_t *param; |
875 | 869 |
876 param = params->elts; | 870 param = params->elts; |
877 | 871 |
878 for (i = 0; i < params->nelts; i++) { | 872 for (i = 0; i < params->nelts; i++) { |
879 | 873 |
880 if (ngx_http_script_run(r, &string, param[i].lengths->elts, 1, | 874 if (ngx_http_complex_value(r, ¶m[i], &string) != NGX_OK) { |
881 param[i].values->elts) | |
882 == NULL) | |
883 { | |
884 return NGX_ERROR; | 875 return NGX_ERROR; |
885 } | 876 } |
886 | |
887 last = string.data + string.len - 1; | |
888 *last = '\0'; | |
889 | 877 |
890 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 878 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
891 "xslt filter param: \"%s\"", string.data); | 879 "xslt filter param: \"%s\"", string.data); |
892 | 880 |
893 p = string.data; | 881 p = string.data; |
882 last = string.data + string.len - 1; | |
894 | 883 |
895 while (p && *p) { | 884 while (p && *p) { |
896 | 885 |
897 value = p; | 886 value = p; |
898 p = (u_char *) ngx_strchr(p, '='); | 887 p = (u_char *) ngx_strchr(p, '='); |
1071 ngx_str_t *value; | 1060 ngx_str_t *value; |
1072 ngx_uint_t i, n; | 1061 ngx_uint_t i, n; |
1073 ngx_pool_cleanup_t *cln; | 1062 ngx_pool_cleanup_t *cln; |
1074 ngx_http_xslt_file_t *file; | 1063 ngx_http_xslt_file_t *file; |
1075 ngx_http_xslt_sheet_t *sheet; | 1064 ngx_http_xslt_sheet_t *sheet; |
1076 ngx_http_xslt_param_t *param; | 1065 ngx_http_complex_value_t *param; |
1077 ngx_http_script_compile_t sc; | 1066 ngx_http_compile_complex_value_t ccv; |
1078 ngx_http_xslt_filter_main_conf_t *xmcf; | 1067 ngx_http_xslt_filter_main_conf_t *xmcf; |
1079 | 1068 |
1080 value = cf->args->elts; | 1069 value = cf->args->elts; |
1081 | 1070 |
1082 if (xlcf->sheets.elts == NULL) { | 1071 if (xlcf->sheets.elts == NULL) { |
1140 if (n == 2) { | 1129 if (n == 2) { |
1141 return NGX_CONF_OK; | 1130 return NGX_CONF_OK; |
1142 } | 1131 } |
1143 | 1132 |
1144 if (ngx_array_init(&sheet->params, cf->pool, n - 2, | 1133 if (ngx_array_init(&sheet->params, cf->pool, n - 2, |
1145 sizeof(ngx_http_xslt_param_t)) | 1134 sizeof(ngx_http_complex_value_t)) |
1146 != NGX_OK) | 1135 != NGX_OK) |
1147 { | 1136 { |
1148 return NGX_CONF_ERROR; | 1137 return NGX_CONF_ERROR; |
1149 } | 1138 } |
1150 | 1139 |
1153 param = ngx_array_push(&sheet->params); | 1142 param = ngx_array_push(&sheet->params); |
1154 if (param == NULL) { | 1143 if (param == NULL) { |
1155 return NGX_CONF_ERROR; | 1144 return NGX_CONF_ERROR; |
1156 } | 1145 } |
1157 | 1146 |
1158 param->lengths = NULL; | 1147 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
1159 param->values = NULL; | 1148 |
1160 | 1149 ccv.cf = cf; |
1161 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | 1150 ccv.value = &value[i]; |
1162 | 1151 ccv.complex_value = param; |
1163 sc.cf = cf; | 1152 ccv.zero = 1; |
1164 sc.source = &value[i]; | 1153 |
1165 sc.lengths = ¶m->lengths; | 1154 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
1166 sc.values = ¶m->values; | |
1167 sc.variables = ngx_http_script_variables_count(&value[i]); | |
1168 sc.complete_lengths = 1; | |
1169 sc.complete_values = 1; | |
1170 | |
1171 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
1172 return NGX_CONF_ERROR; | 1155 return NGX_CONF_ERROR; |
1173 } | 1156 } |
1157 | |
1174 } | 1158 } |
1175 | 1159 |
1176 return NGX_CONF_OK; | 1160 return NGX_CONF_OK; |
1177 } | 1161 } |
1178 | 1162 |