00001 /* 00002 * Copyright 2009 DreamLab Onet.pl Sp. z o.o. 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 * 00015 * 00016 * Authors: 00017 * Piotr Janik, email: janik.piotrek(malpa)gmail.com 00018 * Przemyslaw Gajda, email: quermit(malpa)gmail.com 00019 * malpa = @ 00020 */ 00021 00022 #ifndef NGX_HTTP_XXSLT_PARSE_H_ 00023 #define NGX_HTTP_XXSLT_PARSE_H_ 00024 00025 #include <ngx_config.h> 00026 #include <ngx_core.h> 00027 #include <ngx_http.h> 00028 00029 #include <libxml/tree.h> 00030 #include <libxml/parser.h> 00031 #include <libxslt/xsltInternals.h> 00032 #include <libxslt/transform.h> 00033 #include <libxslt/xsltutils.h> 00034 #include <libxslt/xslt.h> 00035 00036 #include <download/ngx_http_download_module.h> 00037 #include <download/ngx_http_filesync.h> 00038 #include <mxcache/ngx_http_mxcache_module.h> 00039 00040 #define PARSE_GENERAL_ERR 1 00041 #define PARSE_STYLESHEET_ERR 2 00042 #define PARSE_NO_STYLESHEETS 3 00043 00044 #define PARSE_XML 11 00045 #define PARSE_XSL 12 00046 #define PARSE_UNKNOWN 13 00047 00048 #define ERR_CONTINUE 0 00049 #define ERR_FAIL 1 00050 00051 #define PARSE_DUMMY_NODE "as123hazx12xz12" 00052 00053 00054 00055 typedef struct ngx_http_xxslt_include_s ngx_http_xxslt_include_t; 00056 00058 typedef struct { 00059 ngx_int_t id; 00061 ngx_http_request_t *r; 00062 00064 xmlDocPtr doc; 00066 xmlParserCtxtPtr ctxt; 00068 xmlSAXHandler *sax; 00070 xsltStylesheetPtr stylesheet; 00072 xmlDocPtr includes; 00073 00075 ngx_http_xxslt_include_t *inc_list; 00076 ngx_http_xxslt_include_t *inc_act; 00077 ngx_http_xxslt_include_t *inc_list_tail; 00078 ngx_int_t inc_list_n; 00079 00081 ngx_flag_t preffix_added; 00083 ngx_flag_t xslt_ready; 00085 ngx_flag_t stylesheet_declared; 00086 00088 ngx_int_t dl_in_progress; 00089 00091 ngx_chain_t *buffer_chain; 00092 ngx_chain_t *buffer_chain_tail; 00093 ngx_int_t res_len; 00094 00096 ngx_int_t include_err; 00097 u_char *include_err_msg; 00098 00100 char *libxml_error; 00102 ngx_int_t done; 00103 } ngx_http_xxslt_parse_data_t; 00104 00106 struct ngx_http_xxslt_include_s { 00107 00108 ngx_int_t id; 00109 00111 ngx_chain_t *buffer_chain; 00112 00114 u_char *name; 00116 u_char *src; 00118 u_char *alt; 00120 u_char *stylesheet; 00121 00123 ngx_flag_t data_type; 00125 ngx_flag_t paste; 00127 ngx_uint_t dl_timeout; 00129 ngx_uint_t cache_timeout; 00131 ngx_uint_t ttl; 00133 ngx_int_t onerror; 00134 00136 ngx_flag_t ready; 00138 ngx_flag_t error; 00139 00141 ngx_http_download_conn_t *download; 00143 ngx_http_mxcache_conn_t *xcache_get; 00144 00146 ngx_http_xxslt_parse_data_t *parent_parse; 00148 ngx_http_xxslt_include_t *next; 00149 }; 00150 00151 ngx_http_xxslt_parse_data_t * 00152 ngx_http_xxslt_parse_create_new(ngx_http_request_t *r); 00153 00154 ngx_int_t 00155 ngx_http_xxslt_parse_add_data_chunk(ngx_http_xxslt_parse_data_t *data, ngx_chain_t *in); 00156 00157 ngx_int_t 00158 ngx_http_xxslt_parse_apply(ngx_http_xxslt_parse_data_t *data); 00159 00160 void 00161 ngx_http_xxslt_parse_cleanup(ngx_http_xxslt_parse_data_t *parse_data); 00162 00163 extern ngx_module_t ngx_http_xxslt_filter_module; 00164 #endif /* NGX_HTTP_XXSLT_PARSE_H_ */ 00165 00166