2 * Copyright (C) 2005-2011 Atsushi Konno All rights reserved.
3 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include "chxj_chtml20.h"
18 #include "chxj_hdml.h"
19 #include "chxj_str_util.h"
20 #include "chxj_dump.h"
21 #include "chxj_img_conv.h"
22 #include "chxj_qr_code.h"
23 #include "chxj_encoding.h"
24 #include "chxj_buffered_write.h"
26 #include "chxj_header_inf.h"
27 #include "chxj_conv_z2h.h"
28 #include "chxj_google.h"
31 #define GET_CHTML20(X) ((chtml20_t*)(X))
34 #define W_L(X) do { chtml20->out = BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, (X)); } while(0)
35 #define W_V(X) do { chtml20->out = (X) ? BUFFERED_WRITE_VALUE(chtml20->out, &doc->buf, (X)) \
36 : BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, ""); } while(0)
38 #define W_NLCODE() do { char *nlcode = TO_NLCODE(chtml20->conf); W_V(nlcode); } while (0)
40 #define CHTML20_START_OF_TAG_WITH_CSS_FONT_COLOR(tagname) \
45 char *attr_style = NULL; \
46 char *attr_color = NULL; \
48 chtml20 = GET_CHTML20(pdoc); \
50 for (attr = qs_get_attr(doc,node); \
52 attr = qs_get_next_attr(doc,attr)) { \
53 char *nm = qs_get_attr_name(doc,attr); \
54 char *val = qs_get_attr_value(doc,attr); \
55 if (val && STRCASEEQ('s','S',"style", nm)) { \
59 if (IS_CSS_ON(chtml20->entryp)) { \
60 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style); \
62 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color"); \
63 css_property_t *cur; \
64 for (cur = color_prop->next; cur != color_prop; cur = cur->next) { \
65 if (cur->value && *cur->value) { \
66 attr_color = apr_pstrdup(doc->pool, cur->value); \
72 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t)); \
73 memset(flg, 0, sizeof(*flg)); \
75 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color); \
76 W_L("<font color=\""); \
79 flg->with_font_flag = 1; \
81 node->userData = (void *)flg; \
82 return chtml20->out; \
85 #define CHTML20_END_OF_NO_CLOSE_TAG_WITH_FONT_TAG() \
87 chtml20_t *chtml20 = GET_CHTML20(pdoc); \
88 Doc *doc = chtml20->doc; \
89 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData; \
90 if (flg && flg->with_font_flag) { \
93 if (IS_CSS_ON(chtml20->entryp)) { \
94 chxj_css_pop_prop_list(chtml20->css_prop_stack); \
96 return chtml20->out; \
99 #define CHTML20_END_OF_CLOSE_TAG_WITH_FONT_TAG(tagname) \
101 chtml20_t *chtml20 = GET_CHTML20(pdoc); \
102 Doc *doc = chtml20->doc; \
103 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData; \
104 if (flg && flg->with_font_flag) { \
108 if (IS_CSS_ON(chtml20->entryp)) { \
109 chxj_css_pop_prop_list(chtml20->css_prop_stack); \
111 return chtml20->out; \
114 static char *s_chtml20_start_html_tag (void *pdoc, Node *node);
115 static char *s_chtml20_end_html_tag (void *pdoc, Node *node);
116 static char *s_chtml20_start_meta_tag (void *pdoc, Node *node);
117 static char *s_chtml20_end_meta_tag (void *pdoc, Node *node);
118 static char *s_chtml20_start_textarea_tag(void *pdoc, Node *node);
119 static char *s_chtml20_end_textarea_tag (void *pdoc, Node *node);
120 static char *s_chtml20_start_p_tag (void *pdoc, Node *node);
121 static char *s_chtml20_end_p_tag (void *pdoc, Node *node);
122 static char *s_chtml20_start_pre_tag (void *pdoc, Node *node);
123 static char *s_chtml20_end_pre_tag (void *pdoc, Node *node);
124 static char *s_chtml20_start_h1_tag (void *pdoc, Node *node);
125 static char *s_chtml20_end_h1_tag (void *pdoc, Node *node);
126 static char *s_chtml20_start_h2_tag (void *pdoc, Node *node);
127 static char *s_chtml20_end_h2_tag (void *pdoc, Node *node);
128 static char *s_chtml20_start_h3_tag (void *pdoc, Node *node);
129 static char *s_chtml20_end_h3_tag (void *pdoc, Node *node);
130 static char *s_chtml20_start_h4_tag (void *pdoc, Node *node);
131 static char *s_chtml20_end_h4_tag (void *pdoc, Node *node);
132 static char *s_chtml20_start_h5_tag (void *pdoc, Node *node);
133 static char *s_chtml20_end_h5_tag (void *pdoc, Node *node);
134 static char *s_chtml20_start_h6_tag (void *pdoc, Node *node);
135 static char *s_chtml20_end_h6_tag (void *pdoc, Node *node);
136 static char *s_chtml20_start_ul_tag (void *pdoc, Node *node);
137 static char *s_chtml20_end_ul_tag (void *pdoc, Node *node);
138 static char *s_chtml20_start_ol_tag (void *pdoc, Node *node);
139 static char *s_chtml20_end_ol_tag (void *pdoc, Node *node);
140 static char *s_chtml20_start_li_tag (void *pdoc, Node *node);
141 static char *s_chtml20_end_li_tag (void *pdoc, Node *node);
142 static char *s_chtml20_start_head_tag (void *pdoc, Node *node);
143 static char *s_chtml20_end_head_tag (void *pdoc, Node *node);
144 static char *s_chtml20_start_title_tag (void *pdoc, Node *node);
145 static char *s_chtml20_end_title_tag (void *pdoc, Node *node);
146 static char *s_chtml20_start_base_tag (void *pdoc, Node *node);
147 static char *s_chtml20_end_base_tag (void *pdoc, Node *node);
148 static char *s_chtml20_start_body_tag (void *pdoc, Node *node);
149 static char *s_chtml20_end_body_tag (void *pdoc, Node *node);
150 static char *s_chtml20_start_a_tag (void *pdoc, Node *node);
151 static char *s_chtml20_end_a_tag (void *pdoc, Node *node);
152 static char *s_chtml20_start_br_tag (void *pdoc, Node *node);
153 static char *s_chtml20_end_br_tag (void *pdoc, Node *node);
154 static char *s_chtml20_start_tr_tag (void *pdoc, Node *node);
155 static char *s_chtml20_end_tr_tag (void *pdoc, Node *node);
156 static char *s_chtml20_start_font_tag (void *pdoc, Node *node);
157 static char *s_chtml20_end_font_tag (void *pdoc, Node *node);
158 static char *s_chtml20_start_form_tag (void *pdoc, Node *node);
159 static char *s_chtml20_end_form_tag (void *pdoc, Node *node);
160 static char *s_chtml20_start_input_tag (void *pdoc, Node *node);
161 static char *s_chtml20_end_input_tag (void *pdoc, Node *node);
162 static char *s_chtml20_start_center_tag (void *pdoc, Node *node);
163 static char *s_chtml20_end_center_tag (void *pdoc, Node *node);
164 static char *s_chtml20_start_hr_tag (void *pdoc, Node *node);
165 static char *s_chtml20_end_hr_tag (void *pdoc, Node *node);
166 static char *s_chtml20_start_img_tag (void *pdoc, Node *node);
167 static char *s_chtml20_end_img_tag (void *pdoc, Node *node);
168 static char *s_chtml20_start_select_tag (void *pdoc, Node *node);
169 static char *s_chtml20_end_select_tag (void *pdoc, Node *node);
170 static char *s_chtml20_start_option_tag (void *pdoc, Node *node);
171 static char *s_chtml20_end_option_tag (void *pdoc, Node *node);
172 static char *s_chtml20_start_div_tag (void *pdoc, Node *node);
173 static char *s_chtml20_end_div_tag (void *pdoc, Node *node);
174 static char *s_chtml20_start_blockquote_tag(void *pdoc, Node *node);
175 static char *s_chtml20_end_blockquote_tag (void *pdoc, Node *node);
176 static char *s_chtml20_start_dir_tag (void *pdoc, Node *node);
177 static char *s_chtml20_end_dir_tag (void *pdoc, Node *node);
178 static char *s_chtml20_start_dl_tag (void *pdoc, Node *node);
179 static char *s_chtml20_end_dl_tag (void *pdoc, Node *node);
180 static char *s_chtml20_start_dt_tag (void *pdoc, Node *node);
181 static char *s_chtml20_end_dt_tag (void *pdoc, Node *node);
182 static char *s_chtml20_start_dd_tag (void *pdoc, Node *node);
183 static char *s_chtml20_end_dd_tag (void *pdoc, Node *node);
184 static char *s_chtml20_start_menu_tag (void *pdoc, Node *node);
185 static char *s_chtml20_end_menu_tag (void *pdoc, Node *node);
186 static char *s_chtml20_start_plaintext_tag (void *pdoc, Node *node);
187 static char *s_chtml20_start_plaintext_tag_inner (void *pdoc, Node *node);
188 static char *s_chtml20_end_plaintext_tag (void *pdoc, Node *node);
189 static char *s_chtml20_start_blink_tag (void *pdoc, Node *node);
190 static char *s_chtml20_end_blink_tag (void *pdoc, Node *node);
191 static char *s_chtml20_start_marquee_tag (void *pdoc, Node *node);
192 static char *s_chtml20_end_marquee_tag (void *pdoc, Node *node);
193 static char *s_chtml20_newline_mark (void *pdoc, Node *node);
194 static char *s_chtml20_style_tag (void *pdoc, Node *node);
195 static char *s_chtml20_link_tag (void *pdoc, Node *node);
196 static char *s_chtml20_start_span_tag (void *pdoc, Node *node);
197 static char *s_chtml20_end_span_tag (void *pdoc, Node *node);
199 static void s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
201 static int s_chtml20_search_emoji(chtml20_t *chtml, char *txt, char **rslt, Node *node);
203 static char *s_chtml20_chxjif_tag(void *pdoc, Node *node);
204 static char *s_chtml20_text_tag(void *pdoc, Node *node);
205 static css_prop_list_t *s_chtml20_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
206 static css_prop_list_t *s_chtml20_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
210 tag_handler chtml20_handler[] = {
213 s_chtml20_start_html_tag,
214 s_chtml20_end_html_tag,
218 s_chtml20_start_meta_tag,
219 s_chtml20_end_meta_tag,
223 s_chtml20_start_textarea_tag,
224 s_chtml20_end_textarea_tag,
228 s_chtml20_start_p_tag,
233 s_chtml20_start_pre_tag,
234 s_chtml20_end_pre_tag,
238 s_chtml20_start_ul_tag,
239 s_chtml20_end_ul_tag,
243 s_chtml20_start_li_tag,
244 s_chtml20_end_li_tag,
248 s_chtml20_start_ol_tag,
249 s_chtml20_end_ol_tag,
253 s_chtml20_start_h1_tag,
254 s_chtml20_end_h1_tag,
258 s_chtml20_start_h2_tag,
259 s_chtml20_end_h2_tag,
263 s_chtml20_start_h3_tag,
264 s_chtml20_end_h3_tag,
268 s_chtml20_start_h4_tag,
269 s_chtml20_end_h4_tag,
273 s_chtml20_start_h5_tag,
274 s_chtml20_end_h5_tag,
278 s_chtml20_start_h6_tag,
279 s_chtml20_end_h6_tag,
283 s_chtml20_start_head_tag,
284 s_chtml20_end_head_tag,
288 s_chtml20_start_title_tag,
289 s_chtml20_end_title_tag,
293 s_chtml20_start_base_tag,
294 s_chtml20_end_base_tag,
298 s_chtml20_start_body_tag,
299 s_chtml20_end_body_tag,
303 s_chtml20_start_a_tag,
308 s_chtml20_start_br_tag,
309 s_chtml20_end_br_tag,
318 s_chtml20_start_tr_tag,
319 s_chtml20_end_tr_tag,
333 s_chtml20_start_font_tag,
334 s_chtml20_end_font_tag,
338 s_chtml20_start_form_tag,
339 s_chtml20_end_form_tag,
343 s_chtml20_start_input_tag,
344 s_chtml20_end_input_tag,
348 s_chtml20_start_center_tag,
349 s_chtml20_end_center_tag,
353 s_chtml20_start_hr_tag,
354 s_chtml20_end_hr_tag,
358 s_chtml20_start_img_tag,
359 s_chtml20_end_img_tag,
363 s_chtml20_start_select_tag,
364 s_chtml20_end_select_tag,
368 s_chtml20_start_option_tag,
369 s_chtml20_end_option_tag,
373 s_chtml20_start_div_tag,
374 s_chtml20_end_div_tag,
378 s_chtml20_chxjif_tag,
383 s_chtml20_chxjif_tag,
403 s_chtml20_start_span_tag,
404 s_chtml20_end_span_tag,
428 s_chtml20_start_dt_tag,
429 s_chtml20_end_dt_tag,
443 s_chtml20_start_blockquote_tag,
444 s_chtml20_end_blockquote_tag,
448 s_chtml20_start_dir_tag,
449 s_chtml20_end_dir_tag,
453 s_chtml20_start_dl_tag,
454 s_chtml20_end_dl_tag,
458 s_chtml20_start_dd_tag,
459 s_chtml20_end_dd_tag,
463 s_chtml20_start_menu_tag,
464 s_chtml20_end_menu_tag,
468 s_chtml20_start_plaintext_tag,
469 s_chtml20_end_plaintext_tag,
473 s_chtml20_start_blink_tag,
474 s_chtml20_end_blink_tag,
478 s_chtml20_start_marquee_tag,
479 s_chtml20_end_marquee_tag,
488 s_chtml20_newline_mark,
509 * converts from CHTML5.0 to CHTML2.0.
511 * @param r [i] Requet_rec is appointed.
512 * @param spec [i] The result of the device specification processing which
513 * was done in advance is appointed.
514 * @param src [i] The character string before the converting is appointed.
515 * @return The character string after the converting is returned.
518 chxj_convert_chtml20(
524 chxjconvrule_entry *entryp,
533 /*--------------------------------------------------------------------------*/
535 /*--------------------------------------------------------------------------*/
537 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
539 DBG(r,"REQ[%X] found qrcode xml",TO_ADDR(r));
543 /*--------------------------------------------------------------------------*/
544 /* The CHTML structure is initialized. */
545 /*--------------------------------------------------------------------------*/
546 s_init_chtml20(&chtml20, &doc, r, spec);
548 chtml20.entryp = entryp;
549 chtml20.cookie = cookie;
551 chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
553 /*--------------------------------------------------------------------------*/
554 /* The character string of the input is analyzed. */
555 /*--------------------------------------------------------------------------*/
556 qs_init_malloc(&doc);
557 qs_init_root_node(&doc);
559 ss = apr_pcalloc(r->pool, srclen + 1);
560 memset(ss, 0, srclen + 1);
561 memcpy(ss, src, srclen);
564 chxj_dump_out("[src] CHTML -> CHTML2.0", ss, srclen);
567 if (IS_CSS_ON(chtml20.entryp)) {
568 /* current property list */
569 chtml20.css_prop_stack = chxj_new_prop_list_stack(&doc);
572 qs_parse_string(&doc,ss, strlen(ss));
574 chxj_buffered_write_init(r->pool, &doc.buf);
575 /*--------------------------------------------------------------------------*/
576 /* It converts it from CHTML to CHTML. */
577 /*--------------------------------------------------------------------------*/
578 chxj_node_convert(spec,r,(void *)&chtml20, &doc, qs_get_root(&doc), 0);
579 chtml20.out = chxj_buffered_write_flush(chtml20.out, &doc.buf);
580 dst = apr_pstrdup(r->pool, chtml20.out);
581 chxj_buffered_write_terminate(&doc.buf);
583 qs_all_free(&doc,QX_LOGMARK);
586 return apr_pstrdup(r->pool,ss);
589 if (strlen(dst) == 0) {
590 dst = apr_psprintf(r->pool, "\n");
593 *dstlen = strlen(dst);
596 chxj_dump_out("[dst] CHTML -> CHTML2.0", dst, *dstlen);
603 * The CHTML structure is initialized.
605 * @param chtml20 [i/o] The pointer to the HDML structure that wants to be
606 * initialized is specified.
607 * @param doc [i] The Doc structure that should be set to the initialized
608 * HDML structure is specified.
609 * @param r [i] To use POOL, the pointer to request_rec is specified.
610 * @param spec [i] The pointer to the device_table
613 s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
615 memset(doc, 0, sizeof(Doc));
616 memset(chtml20, 0, sizeof(chtml20_t));
620 chtml20->spec = spec;
621 chtml20->out = qs_alloc_zero_byte_string(r->pool);
622 chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
624 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
629 * Corresponding EMOJI to a current character-code is retrieved.
630 * The substitution character string is stored in the rslt pointer if agreeing.
632 * @param chtml20 [i] The pointer to the CHTML structure is specified.
633 * @param txt [i] The character string to want to examine whether it is
634 * EMOJI is specified.
635 * @param rslt [o] The pointer to the pointer that stores the result is
637 * @param node [i] The current node to check whether tag is span/font for CHXJ_IMODE_EMOJI_COLOR_AUTO.
638 * @return When corresponding EMOJI exists, it returns it excluding 0.
641 s_chtml20_search_emoji(chtml20_t *chtml20, char *txt, char **rslt, Node *node)
648 spec = chtml20->spec;
654 DBG(r,"REQ[%X] spec is NULL",TO_ADDR(r));
656 for (ee = chtml20->conf->emoji;
660 if (ee->imode == NULL) {
661 DBG(r,"REQ[%X] emoji->imode is NULL",TO_ADDR(r));
665 if (ee->imode->string != NULL
666 && strlen(ee->imode->string) > 0
667 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
668 if (spec == NULL || spec->emoji_type == NULL) {
669 *rslt = apr_palloc(r->pool, 3);
670 (*rslt)[0] = ee->imode->hex1byte & 0xff;
671 (*rslt)[1] = ee->imode->hex2byte & 0xff;
674 if(chtml20->conf->imode_emoji_color >= CHXJ_IMODE_EMOJI_COLOR_AUTO ){
675 if(ee->imode->color != NULL){
676 if(chtml20->conf->imode_emoji_color == CHXJ_IMODE_EMOJI_COLOR_AUTO && node != NULL ){
677 if(strcasecmp(node->parent->name, "span") == 0 ||
678 strcasecmp(node->parent->name, "font") == 0 ){
679 return strlen(ee->imode->string);
682 char *tmp = apr_pstrdup(r->pool,*rslt);
683 *rslt = apr_psprintf(r->pool,
684 "<font color=\"%s\">%s</font>",ee->imode->color,tmp);
687 return strlen(ee->imode->string);
698 chxj_chtml20_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
709 chtml20 = &__chtml20;
712 DBG(r,"REQ[%X] start %s()",TO_ADDR(r),__func__);
713 memset(doc, 0, sizeof(Doc));
714 memset(chtml20, 0, sizeof(chtml20_t));
718 chtml20->spec = spec;
719 chtml20->out = qs_alloc_zero_byte_string(r->pool);
720 chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
721 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
723 apr_pool_create(&pool, r->pool);
725 chxj_buffered_write_init(pool, &doc->buf);
727 for (ii=0; ii<len; ii++) {
731 rtn = s_chtml20_search_emoji(chtml20, (char *)&src[ii], &out, NULL);
738 if (is_sjis_kanji(src[ii])) {
739 two_byte[0] = src[ii+0];
740 two_byte[1] = src[ii+1];
746 one_byte[0] = src[ii+0];
751 chtml20->out = chxj_buffered_write_flush(chtml20->out, &doc->buf);
753 DBG(r,"REQ[%X] end %s()",TO_ADDR(r),__func__);
759 * It is a handler who processes the HTML tag.
761 * @param pdoc [i/o] The pointer to the CHTML structure at the output
762 * destination is specified.
763 * @param node [i] The HTML tag node is specified.
764 * @return The conversion result is returned.
767 s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
773 chtml20 = GET_CHTML20(pdoc);
777 /*--------------------------------------------------------------------------*/
779 /*--------------------------------------------------------------------------*/
786 * It is a handler who processes the HTML tag.
788 * @param pdoc [i/o] The pointer to the CHTML structure at the output
789 * destination is specified.
790 * @param node [i] The HTML tag node is specified.
791 * @return The conversion result is returned.
794 s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child))
800 chtml20 = GET_CHTML20(pdoc);
810 * It is a handler who processes the META tag.
812 * @param pdoc [i/o] The pointer to the CHTML structure at the output
813 * destination is specified.
814 * @param node [i] The META tag node is specified.
815 * @return The conversion result is returned.
818 s_chtml20_start_meta_tag(void *pdoc, Node *node)
824 int content_type_flag;
827 chtml20 = GET_CHTML20(pdoc);
831 content_type_flag = 0;
835 /*--------------------------------------------------------------------------*/
837 /*--------------------------------------------------------------------------*/
838 for (attr = qs_get_attr(doc,node);
840 attr = qs_get_next_attr(doc,attr)) {
841 char *name = qs_get_attr_name(doc,attr);
842 char *value = qs_get_attr_value(doc,attr);
846 if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
847 /*----------------------------------------------------------------------*/
849 /*----------------------------------------------------------------------*/
850 W_L(" http-equiv=\"");
853 if (STRCASEEQ('c','C',"content-type", value)) {
854 content_type_flag = 1;
856 if (STRCASEEQ('r','R',"refresh", value)) {
864 if (strcasecmp(name, "content") == 0 && value && *value) {
865 if (content_type_flag) {
869 W_V(chxj_header_inf_set_content_type(r, "text/html; charset=SHIFT_JIS"));
872 else if (refresh_flag) {
873 char *buf = apr_pstrdup(r->pool, value);
877 url = strchr(buf, ';');
879 sec = apr_pstrdup(r->pool, buf);
882 url = chxj_encoding_parameter(r, url, 0);
883 url = chxj_add_cookie_parameter(r, url, chtml20->cookie);
914 * It is a handler who processes the META tag.
916 * @param pdoc [i/o] The pointer to the CHTML structure at the output
917 * destination is specified.
918 * @param node [i] The META tag node is specified.
919 * @return The conversion result is returned.
922 s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child))
924 chtml20_t *chtml20 = GET_CHTML20(pdoc);
931 * It is a handler who processes the HEAD tag.
933 * @param pdoc [i/o] The pointer to the CHTML structure at the output
934 * destination is specified.
935 * @param node [i] The HEAD tag node is specified.
936 * @return The conversion result is returned.
939 s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node))
944 chtml20 = GET_CHTML20(pdoc);
954 * It is a handler who processes the HEAD tag.
956 * @param pdoc [i/o] The pointer to the CHTML structure at the output
957 * destination is specified.
958 * @param node [i] The HEAD tag node is specified.
959 * @return The conversion result is returned.
962 s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child))
968 chtml20 = GET_CHTML20(pdoc);
979 * It is a handler who processes the TITLE tag.
981 * @param pdoc [i/o] The pointer to the CHTML structure at the output
982 * destination is specified.
983 * @param node [i] The TITLE tag node is specified.
984 * @return The conversion result is returned.
987 s_chtml20_start_title_tag(void *pdoc, Node *node)
993 chtml20 = GET_CHTML20(pdoc);
999 if (chtml20->conf->use_google_analytics) {
1000 chtml20->pagetitle = "";
1002 for (child = qs_get_child_node(doc,node);
1004 child = qs_get_next_node(doc,child)) {
1005 char *textval = qs_get_node_value(doc,child);
1006 chtml20->pagetitle = apr_pstrcat(doc->r->pool, chtml20->pagetitle, textval, NULL);
1010 return chtml20->out;
1015 * It is a handler who processes the TITLE tag.
1017 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1018 * destination is specified.
1019 * @param node [i] The TITLE tag node is specified.
1020 * @return The conversion result is returned.
1023 s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
1029 chtml20 = GET_CHTML20(pdoc);
1035 return chtml20->out;
1040 * It is a handler who processes the BASE tag.
1042 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1043 * destination is specified.
1044 * @param node [i] The BASE tag node is specified.
1045 * @return The conversion result is returned.
1048 s_chtml20_start_base_tag(void *pdoc, Node *node)
1055 chtml20 = GET_CHTML20(pdoc);
1060 /*--------------------------------------------------------------------------*/
1061 /* Get Attributes */
1062 /*--------------------------------------------------------------------------*/
1063 for (attr = qs_get_attr(doc,node);
1065 attr = qs_get_next_attr(doc,attr)) {
1066 char *name = qs_get_attr_name(doc,attr);
1067 char *value = qs_get_attr_value(doc,attr);
1068 if (STRCASEEQ('h','H',"href", name)) {
1076 return chtml20->out;
1081 * It is a handler who processes the BASE tag.
1083 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1084 * destination is specified.
1085 * @param node [i] The BASE tag node is specified.
1086 * @return The conversion result is returned.
1089 s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child))
1095 chtml20 = GET_CHTML20(pdoc);
1099 return chtml20->out;
1104 * It is a handler who processes the BODY tag.
1106 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1107 * destination is specified.
1108 * @param node [i] The BODY tag node is specified.
1109 * @return The conversion result is returned.
1112 s_chtml20_start_body_tag(void *pdoc, Node *node)
1118 char *attr_bgcolor = NULL;
1119 char *attr_text = NULL;
1120 char *attr_link = NULL;
1121 char *attr_style = NULL;
1123 chtml20 = GET_CHTML20(pdoc);
1127 /*--------------------------------------------------------------------------*/
1128 /* Get Attributes */
1129 /*--------------------------------------------------------------------------*/
1130 for (attr = qs_get_attr(doc,node);
1132 attr = qs_get_next_attr(doc,attr)) {
1133 char *name = qs_get_attr_name(doc,attr);
1134 char *value = qs_get_attr_value(doc,attr);
1138 if (strcasecmp(name, "bgcolor") == 0 && value && *value != 0) {
1139 /*----------------------------------------------------------------------*/
1141 /*----------------------------------------------------------------------*/
1142 attr_bgcolor = value;
1148 if (strcasecmp(name, "text") == 0 && value && *value != 0) {
1149 /*----------------------------------------------------------------------*/
1151 /*----------------------------------------------------------------------*/
1158 if (strcasecmp(name, "style") == 0 && value && *value != 0) {
1165 if (strcasecmp(name, "link") == 0 && value && *value != 0) {
1166 /*----------------------------------------------------------------------*/
1168 /*----------------------------------------------------------------------*/
1175 if (strcasecmp(name, "alink") == 0) {
1176 /*----------------------------------------------------------------------*/
1178 /*----------------------------------------------------------------------*/
1185 if (strcasecmp(name, "vlink") == 0) {
1186 /*----------------------------------------------------------------------*/
1188 /*----------------------------------------------------------------------*/
1197 if (IS_CSS_ON(chtml20->entryp)) {
1198 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
1200 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1201 css_property_t *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
1202 css_property_t *cur;
1203 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1204 if (cur->value && *cur->value) {
1205 attr_text = apr_pstrdup(doc->pool, cur->value);
1208 for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
1209 if (cur->value && *cur->value) {
1210 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
1214 if (chtml20->style) {
1215 css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, chtml20->style);
1216 css_selector_t *cur_sel;
1217 for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
1218 if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
1219 css_property_t *cur;
1220 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1221 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1222 attr_link = apr_pstrdup(doc->pool, cur->value);
1231 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
1237 attr_text = chxj_css_rgb_func_to_value(doc->pool, attr_text);
1243 attr_link = chxj_css_rgb_func_to_value(doc->pool, attr_link);
1250 return chtml20->out;
1255 * It is a handler who processes the BODY tag.
1257 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1258 * destination is specified.
1259 * @param node [i] The BODY tag node is specified.
1260 * @return The conversion result is returned.
1263 s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child))
1269 chtml20 = GET_CHTML20(pdoc);
1273 if (chtml20->conf->use_google_analytics) {
1274 char *src = chxj_google_analytics_get_image_url(r, chtml20->pagetitle);
1281 if (IS_CSS_ON(chtml20->entryp)) {
1282 chxj_css_pop_prop_list(chtml20->css_prop_stack);
1285 return chtml20->out;
1290 * It is a handler who processes the A tag.
1292 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1293 * destination is specified.
1294 * @param node [i] The A tag node is specified.
1295 * @return The conversion result is returned.
1298 s_chtml20_start_a_tag(void *pdoc, Node *node)
1304 char *attr_style = NULL;
1306 chtml20 = GET_CHTML20(pdoc);
1311 /*--------------------------------------------------------------------------*/
1312 /* Get Attributes */
1313 /*--------------------------------------------------------------------------*/
1314 for (attr = qs_get_attr(doc,node);
1316 attr = qs_get_next_attr(doc,attr)) {
1317 char *name = qs_get_attr_name(doc,attr);
1318 char *value = qs_get_attr_value(doc,attr);
1322 if (strcasecmp(name, "name") == 0) {
1323 /*--------------------------------------------------------------------*/
1325 /*--------------------------------------------------------------------*/
1334 if (strcasecmp(name, "href") == 0) {
1335 /*--------------------------------------------------------------------*/
1337 /*--------------------------------------------------------------------*/
1338 value = chxj_encoding_parameter(r, value, 0);
1339 if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
1340 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1350 if (strcasecmp(name, "accesskey") == 0) {
1351 /*--------------------------------------------------------------------*/
1353 /*--------------------------------------------------------------------*/
1354 W_L(" accesskey=\"");
1362 if (strcasecmp(name, "cti") == 0) {
1363 /*--------------------------------------------------------------------*/
1365 /*--------------------------------------------------------------------*/
1374 if (strcasecmp(name, "ijam") == 0) {
1375 /*--------------------------------------------------------------------*/
1377 /*--------------------------------------------------------------------*/
1381 if (strcasecmp(name, "ista") == 0) {
1382 /*--------------------------------------------------------------------*/
1384 /*--------------------------------------------------------------------*/
1388 if (strcasecmp(name, "ilet") == 0) {
1389 /*--------------------------------------------------------------------*/
1391 /*--------------------------------------------------------------------*/
1395 if (strcasecmp(name, "iswf") == 0) {
1396 /*--------------------------------------------------------------------*/
1398 /*--------------------------------------------------------------------*/
1402 if (strcasecmp(name, "irst") == 0) {
1403 /*--------------------------------------------------------------------*/
1405 /*--------------------------------------------------------------------*/
1412 if (strcasecmp(name, "utn") == 0) {
1413 /*--------------------------------------------------------------------*/
1415 /*--------------------------------------------------------------------*/
1422 if (strcasecmp(name, "telbook") == 0) {
1423 /*--------------------------------------------------------------------*/
1425 /*--------------------------------------------------------------------*/
1432 if (strcasecmp(name, "kana") == 0) {
1433 /*--------------------------------------------------------------------*/
1435 /*--------------------------------------------------------------------*/
1442 if (strcasecmp(name, "email") == 0) {
1443 /*--------------------------------------------------------------------*/
1445 /*--------------------------------------------------------------------*/
1452 if (strcasecmp(name, "style") == 0 && value && *value) {
1463 if (IS_CSS_ON(chtml20->entryp)) {
1464 s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
1467 return chtml20->out;
1472 * It is a handler who processes the A tag.
1474 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1475 * destination is specified.
1476 * @param node [i] The A tag node is specified.
1477 * @return The conversion result is returned.
1480 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
1486 chtml20 = GET_CHTML20(pdoc);
1491 if (IS_CSS_ON(chtml20->entryp)) {
1492 chxj_css_pop_prop_list(chtml20->css_prop_stack);
1495 return chtml20->out;
1500 * It is a handler who processes the BR tag.
1502 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1503 * destination is specified.
1504 * @param node [i] The BR tag node is specified.
1505 * @return The conversion result is returned.
1508 s_chtml20_start_br_tag(void *pdoc, Node *node)
1515 chtml20 = GET_CHTML20(pdoc);
1520 /*--------------------------------------------------------------------------*/
1521 /* Get Attributes */
1522 /*--------------------------------------------------------------------------*/
1523 for (attr = qs_get_attr(doc,node);
1525 attr = qs_get_next_attr(doc,attr)) {
1526 char *name = qs_get_attr_name(doc,attr);
1527 char *value = qs_get_attr_value(doc,attr);
1528 if (STRCASEEQ('c','C',"clear",name)) {
1529 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1538 return chtml20->out;
1543 * It is a handler who processes the BR tag.
1545 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1546 * destination is specified.
1547 * @param node [i] The BR tag node is specified.
1548 * @return The conversion result is returned.
1551 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
1557 chtml20 = GET_CHTML20(pdoc);
1561 return chtml20->out;
1566 * It is a handler who processes the TR tag.
1568 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1569 * destination is specified.
1570 * @param node [i] The TR tag node is specified.
1571 * @return The conversion result is returned.
1574 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
1580 chtml20 = GET_CHTML20(pdoc);
1584 return chtml20->out;
1589 * It is a handler who processes the TR tag.
1591 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1592 * destination is specified.
1593 * @param node [i] The TR tag node is specified.
1594 * @return The conversion result is returned.
1597 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
1603 chtml20 = GET_CHTML20(pdoc);
1609 return chtml20->out;
1614 * It is a handler who processes the FONT tag.
1616 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1617 * destination is specified.
1618 * @param node [i] The FONT tag node is specified.
1619 * @return The conversion result is returned.
1622 s_chtml20_start_font_tag(void *pdoc, Node *node)
1628 char *attr_color = NULL;
1629 char *attr_style = NULL;
1631 chtml20 = GET_CHTML20(pdoc);
1636 /*--------------------------------------------------------------------------*/
1637 /* Get Attributes */
1638 /*--------------------------------------------------------------------------*/
1639 for (attr = qs_get_attr(doc,node);
1641 attr = qs_get_next_attr(doc,attr)) {
1642 char *name = qs_get_attr_name(doc,attr);
1643 char *value = qs_get_attr_value(doc,attr);
1647 if (strcasecmp(name, "color") == 0 && value && *value) {
1648 attr_color = apr_pstrdup(doc->buf.pool, value);
1654 if (strcasecmp(name, "size") == 0) {
1655 /*--------------------------------------------------------------------*/
1657 /*--------------------------------------------------------------------*/
1660 else if (strcasecmp(name, "style") == 0 && value && *value) {
1669 if (IS_CSS_ON(chtml20->entryp)) {
1670 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
1672 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1673 css_property_t *cur;
1674 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1675 if (cur->value && *cur->value) {
1676 attr_color = apr_pstrdup(doc->pool, cur->value);
1682 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1683 W_L("<font color=\"");
1686 chtml20_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
1687 memset(flg, 0, sizeof(*flg));
1688 flg->with_font_flag = 1;
1689 node->userData = flg;
1692 node->userData = NULL;
1694 return chtml20->out;
1699 * It is a handler who processes the FONT tag.
1701 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1702 * destination is specified.
1703 * @param node [i] The FONT tag node is specified.
1704 * @return The conversion result is returned.
1707 s_chtml20_end_font_tag(void *pdoc, Node *node)
1713 chtml20 = GET_CHTML20(pdoc);
1717 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
1718 if (flg && flg->with_font_flag) {
1721 if (IS_CSS_ON(chtml20->entryp)) {
1722 chxj_css_pop_prop_list(chtml20->css_prop_stack);
1724 return chtml20->out;
1729 * It is a handler who processes the FORM tag.
1731 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1732 * destination is specified.
1733 * @param node [i] The FORM tag node is specified.
1734 * @return The conversion result is returned.
1737 s_chtml20_start_form_tag(void *pdoc, Node *node)
1743 char *attr_action = NULL;
1744 char *attr_method = NULL;
1745 char *attr_style = NULL;
1746 char *attr_color = NULL;
1747 char *attr_align = NULL;
1748 char *new_hidden_tag = NULL;
1750 chtml20 = GET_CHTML20(pdoc);
1754 /*--------------------------------------------------------------------------*/
1755 /* Get Attributes */
1756 /*--------------------------------------------------------------------------*/
1757 for (attr = qs_get_attr(doc,node);
1759 attr = qs_get_next_attr(doc,attr)) {
1762 name = qs_get_attr_name(doc,attr);
1763 value = qs_get_attr_value(doc,attr);
1768 if (strcasecmp(name, "action") == 0) {
1769 /*--------------------------------------------------------------------*/
1771 /*--------------------------------------------------------------------*/
1772 attr_action = value;
1778 if (strcasecmp(name, "method") == 0) {
1779 /*--------------------------------------------------------------------*/
1781 /*--------------------------------------------------------------------*/
1782 attr_method = value;
1788 if (strcasecmp(name, "utn") == 0) {
1789 /*--------------------------------------------------------------------*/
1791 /*--------------------------------------------------------------------*/
1798 if (strcasecmp(name, "style") == 0) {
1807 if (IS_CSS_ON(chtml20->entryp)) {
1808 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
1810 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
1811 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1812 css_property_t *cur;
1813 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
1814 if (STRCASEEQ('l','L',"left", cur->value)) {
1815 attr_align = apr_pstrdup(doc->pool, "left");
1817 else if (STRCASEEQ('c','C',"center",cur->value)) {
1818 attr_align = apr_pstrdup(doc->pool, "center");
1820 else if (STRCASEEQ('r','R',"right",cur->value)) {
1821 attr_align = apr_pstrdup(doc->pool, "right");
1824 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1825 attr_color = apr_pstrdup(doc->pool, cur->value);
1830 int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1834 attr_action = chxj_encoding_parameter(r, attr_action, 0);
1835 attr_action = chxj_add_cookie_parameter(r, attr_action, chtml20->cookie);
1837 char *new_query_string = NULL;
1838 q = strchr(attr_action, '?');
1840 new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE, CHXJ_FALSE, chtml20->entryp);
1841 if (new_hidden_tag || new_query_string) {
1847 if (new_query_string) {
1849 W_V(new_query_string);
1859 if (new_hidden_tag) {
1860 W_V(new_hidden_tag);
1863 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
1864 memset(flg, 0, sizeof(*flg));
1866 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1867 W_L("<font color=\"");
1870 flg->with_font_flag = 1;
1873 W_L("<div align=\"");
1876 flg->with_div_flag = 1;
1878 node->userData = flg;
1880 return chtml20->out;
1885 * It is a handler who processes the FORM tag.
1887 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1888 * destination is specified.
1889 * @param node [i] The FORM tag node is specified.
1890 * @return The conversion result is returned.
1893 s_chtml20_end_form_tag(void *pdoc, Node *node)
1899 chtml20 = GET_CHTML20(pdoc);
1903 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
1904 if (flg && flg->with_div_flag) {
1907 if (flg && flg->with_font_flag) {
1911 if (IS_CSS_ON(chtml20->entryp)) {
1912 chxj_css_pop_prop_list(chtml20->css_prop_stack);
1915 return chtml20->out;
1920 * It is a handler who processes the INPUT tag.
1922 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1923 * destination is specified.
1924 * @param node [i] The INPUT tag node is specified.
1925 * @return The conversion result is returned.
1928 s_chtml20_start_input_tag(void *pdoc, Node *node)
1934 char *attr_accesskey = NULL;
1935 char *attr_max_length = NULL;
1936 char *attr_type = NULL;
1937 char *attr_name = NULL;
1938 char *attr_value = NULL;
1939 char *attr_istyle = NULL;
1940 char *attr_size = NULL;
1941 char *attr_checked = NULL;
1942 char *attr_style = NULL;
1944 chtml20 = GET_CHTML20(pdoc);
1948 /*--------------------------------------------------------------------------*/
1949 /* Get Attributes */
1950 /*--------------------------------------------------------------------------*/
1951 for (attr = qs_get_attr(doc,node);
1953 attr = qs_get_next_attr(doc,attr)) {
1954 char *name = qs_get_attr_name(doc,attr);
1955 char *value = qs_get_attr_value(doc,attr);
1956 if (STRCASEEQ('t','T',"type",name) && value && *value) {
1957 char *tmp_type = qs_trim_string(doc->buf.pool, value);
1958 if (tmp_type && (STRCASEEQ('t','T',"text", tmp_type) ||
1959 STRCASEEQ('p','P',"password",tmp_type) ||
1960 STRCASEEQ('c','C',"checkbox",tmp_type) ||
1961 STRCASEEQ('r','R',"radio", tmp_type) ||
1962 STRCASEEQ('h','H',"hidden", tmp_type) ||
1963 STRCASEEQ('s','S',"submit", tmp_type) ||
1964 STRCASEEQ('r','R',"reset", tmp_type))) {
1965 attr_type = tmp_type;
1968 else if (STRCASEEQ('n','N',"name",name) && value && *value) {
1971 else if (STRCASEEQ('v','V',"value",name) && value && *value) {
1974 else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
1975 attr_istyle = value;
1977 else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
1978 attr_max_length = value;
1980 else if (STRCASEEQ('c','C',"checked", name)) {
1981 attr_checked = value;
1983 else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
1984 attr_accesskey = value;
1986 else if (STRCASEEQ('s','S',"size", name) && value && *value) {
1989 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1994 if (IS_CSS_ON(chtml20->entryp)) {
1995 css_prop_list_t *style = s_chtml20_nopush_and_get_now_style(pdoc, node, attr_style);
1997 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
1998 css_property_t *cur;
1999 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
2000 if (strcasestr(cur->value, "<ja:n>")) {
2003 else if (strcasestr(cur->value, "<ja:en>")) {
2006 else if (strcasestr(cur->value, "<ja:hk>")) {
2009 else if (strcasestr(cur->value, "<ja:h>")) {
2033 if (attr_type && (STRCASEEQ('s','S',"submit",attr_type) || STRCASEEQ('r','R',"reset",attr_type))) {
2034 apr_size_t value_len = strlen(attr_value);
2035 attr_value = chxj_conv_z2h(r, attr_value, &value_len, chtml20->entryp);
2039 W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
2042 if (attr_accesskey) {
2043 W_L(" accesskey=\"");
2044 W_V(attr_accesskey);
2048 if (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4') {
2054 /*--------------------------------------------------------------------------*/
2055 /* The figure is default for the password. */
2056 /*--------------------------------------------------------------------------*/
2057 if (attr_max_length) {
2058 if (chxj_chk_numeric(attr_max_length) != 0) {
2059 attr_max_length = apr_psprintf(doc->buf.pool, "0");
2061 if (attr_istyle && *attr_istyle == '1') {
2062 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length) * 2);
2066 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length));
2075 return chtml20->out;
2080 * It is a handler who processes the INPUT tag.
2082 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2083 * destination is specified.
2084 * @param node [i] The INPUT tag node is specified.
2085 * @return The conversion result is returned.
2088 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(node))
2094 chtml20 = GET_CHTML20(pdoc);
2098 return chtml20->out;
2103 * It is a handler who processes the CENTER tag.
2105 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2106 * destination is specified.
2107 * @param node [i] The CENTER tag node is specified.
2108 * @return The conversion result is returned.
2111 s_chtml20_start_center_tag(void *pdoc, Node *node)
2117 char *attr_style = NULL;
2118 char *attr_color = NULL;
2120 chtml20 = GET_CHTML20(pdoc);
2124 for (attr = qs_get_attr(doc,node);
2126 attr = qs_get_next_attr(doc,attr)) {
2127 char *name = qs_get_attr_name(doc,attr);
2128 char *value = qs_get_attr_value(doc,attr);
2129 if (STRCASEEQ('s','S',"style",name) && value && *value) {
2134 if (IS_CSS_ON(chtml20->entryp)) {
2135 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
2137 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
2138 css_property_t *cur;
2139 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2140 if (cur->value && *cur->value) {
2141 attr_color = apr_pstrdup(doc->pool, cur->value);
2148 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
2149 memset(flg, 0, sizeof(*flg));
2151 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2152 W_L("<font color=\"");
2155 flg->with_font_flag = 1;
2157 node->userData = flg;
2159 return chtml20->out;
2164 * It is a handler who processes the CENTER tag.
2166 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2167 * destination is specified.
2168 * @param node [i] The CENTER tag node is specified.
2169 * @return The conversion result is returned.
2172 s_chtml20_end_center_tag(void *pdoc, Node *node)
2178 chtml20 = GET_CHTML20(pdoc);
2182 if (IS_CSS_ON(chtml20->entryp)) {
2183 chxj_css_pop_prop_list(chtml20->css_prop_stack);
2185 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
2186 if (flg && flg->with_font_flag) {
2191 return chtml20->out;
2196 * It is a handler who processes the UL tag.
2198 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2199 * destination is specified.
2200 * @param node [i] The UL tag node is specified.
2201 * @return The conversion result is returned.
2204 s_chtml20_start_ul_tag(void *pdoc, Node *node)
2210 char *attr_style = NULL;
2212 chtml20 = GET_CHTML20(pdoc);
2216 for (attr = qs_get_attr(doc,node);
2218 attr = qs_get_next_attr(doc,attr)) {
2219 char *nm = qs_get_attr_name(doc,attr);
2220 char *val = qs_get_attr_value(doc,attr);
2221 if (val && STRCASEEQ('s','S',"style", nm)) {
2226 if (IS_CSS_ON(chtml20->entryp)) {
2227 s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
2232 return chtml20->out;
2237 * It is a handler who processes the UL tag.
2239 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2240 * destination is specified.
2241 * @param node [i] The UL tag node is specified.
2242 * @return The conversion result is returned.
2245 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
2251 chtml20 = GET_CHTML20(pdoc);
2255 if (IS_CSS_ON(chtml20->entryp)) {
2256 chxj_css_pop_prop_list(chtml20->css_prop_stack);
2260 return chtml20->out;
2265 * It is a handler who processes the OL tag.
2267 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2268 * destination is specified.
2269 * @param node [i] The OL tag node is specified.
2270 * @return The conversion result is returned.
2273 s_chtml20_start_ol_tag(void *pdoc, Node *node)
2279 char *attr_style = NULL;
2280 char *attr_start = NULL;
2281 char *attr_type = NULL;
2283 chtml20 = GET_CHTML20(pdoc);
2288 /*--------------------------------------------------------------------------*/
2289 /* Get Attributes */
2290 /*--------------------------------------------------------------------------*/
2291 for (attr = qs_get_attr(doc,node);
2293 attr = qs_get_next_attr(doc,attr)) {
2294 char *name = qs_get_attr_name(doc,attr);
2295 char *value = qs_get_attr_value(doc,attr);
2296 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2299 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
2302 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
2306 if (IS_CSS_ON(chtml20->entryp)) {
2307 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
2309 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2310 css_property_t *cur;
2311 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2312 if (STRCASEEQ('d','D',"decimal", cur->value)) {
2313 attr_type = apr_pstrdup(doc->pool, "1");
2315 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
2316 attr_type = apr_pstrdup(doc->pool, "A");
2318 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
2319 attr_type = apr_pstrdup(doc->pool, "a");
2337 return chtml20->out;
2342 * It is a handler who processes the OL tag.
2344 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2345 * destination is specified.
2346 * @param node [i] The OL tag node is specified.
2347 * @return The conversion result is returned.
2350 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
2356 chtml20 = GET_CHTML20(pdoc);
2361 if (IS_CSS_ON(chtml20->entryp)) {
2362 chxj_css_pop_prop_list(chtml20->css_prop_stack);
2365 return chtml20->out;
2370 * It is a handler who processes the LI tag.
2372 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2373 * destination is specified.
2374 * @param node [i] The LI tag node is specified.
2375 * @return The conversion result is returned.
2378 s_chtml20_start_li_tag(void *pdoc, Node *node)
2384 char *attr_type = NULL;
2385 char *attr_value = NULL;
2386 char *attr_style = NULL;
2388 chtml20 = GET_CHTML20(pdoc);
2392 /*--------------------------------------------------------------------------*/
2393 /* Get Attributes */
2394 /*--------------------------------------------------------------------------*/
2395 for (attr = qs_get_attr(doc,node);
2397 attr = qs_get_next_attr(doc,attr)) {
2398 char *name = qs_get_attr_name(doc,attr);
2399 char *value = qs_get_attr_value(doc,attr);
2400 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
2403 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
2406 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
2410 if (IS_CSS_ON(chtml20->entryp)) {
2411 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
2413 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2414 css_property_t *cur;
2415 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2416 if (STRCASEEQ('d','D',"decimal", cur->value)) {
2417 attr_type = apr_pstrdup(doc->pool, "1");
2419 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
2420 attr_type = apr_pstrdup(doc->pool, "A");
2422 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
2423 attr_type = apr_pstrdup(doc->pool, "a");
2440 return chtml20->out;
2445 * It is a handler who processes the LI tag.
2447 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2448 * destination is specified.
2449 * @param node [i] The LI tag node is specified.
2450 * @return The conversion result is returned.
2453 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
2455 chtml20_t *chtml20 = GET_CHTML20(pdoc);
2456 if (IS_CSS_ON(chtml20->entryp)) {
2457 chxj_css_pop_prop_list(chtml20->css_prop_stack);
2459 return chtml20->out;
2464 * It is a handler who processes the HR tag.
2466 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2467 * destination is specified.
2468 * @param node [i] The HR tag node is specified.
2469 * @return The conversion result is returned.
2472 s_chtml20_start_hr_tag(void *pdoc, Node *node)
2478 char *attr_align = NULL;
2479 char *attr_size = NULL;
2480 char *attr_width = NULL;
2481 char *attr_noshade = NULL;
2482 char *attr_style = NULL;
2484 chtml20 = GET_CHTML20(pdoc);
2488 for (attr = qs_get_attr(doc,node);
2490 attr = qs_get_next_attr(doc,attr)) {
2491 char *name = qs_get_attr_name (doc,attr);
2492 char *value = qs_get_attr_value(doc,attr);
2496 if (strcasecmp(name, "align") == 0) {
2497 /*--------------------------------------------------------------------*/
2499 /*--------------------------------------------------------------------*/
2500 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2508 if (strcasecmp(name, "size") == 0) {
2509 /*--------------------------------------------------------------------*/
2511 /*--------------------------------------------------------------------*/
2512 if (value && *value) {
2516 else if (strcasecmp(name, "style") == 0) {
2517 if (value && *value) {
2525 if (strcasecmp(name, "width") == 0) {
2526 /*--------------------------------------------------------------------*/
2528 /*--------------------------------------------------------------------*/
2529 if (value && *value) {
2537 if (strcasecmp(name, "noshade") == 0) {
2538 /*--------------------------------------------------------------------*/
2540 /*--------------------------------------------------------------------*/
2541 attr_noshade = apr_pstrdup(doc->pool, "noshade");
2547 if (strcasecmp(name, "color") == 0) {
2548 /*--------------------------------------------------------------------*/
2550 /*--------------------------------------------------------------------*/
2559 if (IS_CSS_ON(chtml20->entryp)) {
2560 css_prop_list_t *style = s_chtml20_nopush_and_get_now_style(pdoc, node, attr_style);
2562 css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2563 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2564 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2565 css_property_t *cur;
2566 for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2567 if (STRCASEEQ('s','S',"solid",cur->value)) {
2568 attr_noshade = "noshade";
2571 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2572 char *tmp = apr_pstrdup(doc->pool, cur->value);
2573 char *tmpp = strstr(tmp, "px");
2576 attr_size = apr_pstrdup(doc->pool, tmp);
2579 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2580 char *tmp = apr_pstrdup(doc->pool, cur->value);
2581 char *tmpp = strstr(tmp, "px");
2584 attr_width = apr_pstrdup(doc->pool, tmp);
2587 tmpp = strstr(tmp, "%");
2589 attr_width = apr_pstrdup(doc->pool, tmp);
2615 return chtml20->out;
2620 * It is a handler who processes the HR tag.
2622 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2623 * destination is specified.
2624 * @param node [i] The HR tag node is specified.
2625 * @return The conversion result is returned.
2628 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
2630 chtml20_t *chtml20 = GET_CHTML20(pdoc);
2631 return chtml20->out;
2636 * It is a handler who processes the IMG tag.
2638 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2639 * destination is specified.
2640 * @param node [i] The IMG tag node is specified.
2641 * @return The conversion result is returned.
2644 s_chtml20_start_img_tag(void *pdoc, Node *node)
2650 char *attr_src = NULL;
2651 char *attr_align = NULL;
2652 char *attr_style = NULL;
2653 char *attr_alt = NULL;
2654 char *attr_width = NULL;
2655 char *attr_height = NULL;
2656 char *attr_hspace = NULL;
2657 char *attr_vspace = NULL;
2658 #ifndef IMG_NOT_CONVERT_FILENAME
2662 chtml20 = GET_CHTML20(pdoc);
2663 #ifndef IMG_NOT_CONVERT_FILENAME
2664 spec = chtml20->spec;
2669 /*--------------------------------------------------------------------------*/
2670 /* Get Attributes */
2671 /*--------------------------------------------------------------------------*/
2672 for (attr = qs_get_attr(doc,node);
2674 attr = qs_get_next_attr(doc,attr)) {
2675 char *name = qs_get_attr_name (doc,attr);
2676 char *value = qs_get_attr_value(doc,attr);
2680 if (strcasecmp(name, "src") == 0) {
2681 /*--------------------------------------------------------------------*/
2683 /*--------------------------------------------------------------------*/
2684 #ifdef IMG_NOT_CONVERT_FILENAME
2685 value = chxj_encoding_parameter(r, value, 0);
2686 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2687 value = chxj_add_cookie_no_update_parameter(r, value, 0);
2688 value = chxj_img_rewrite_parameter(r,chtml20->conf,value);
2691 value = chxj_img_conv(r, spec, value);
2692 value = chxj_encoding_parameter(r, value, 0);
2693 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2694 value = chxj_add_cookie_no_update_parameter(r, value);
2695 value = chxj_img_rewrite_parameter(r,chtml20->conf,value);
2699 else if (strcasecmp(name,"style") == 0 && value && *value) {
2706 if (strcasecmp(name, "align" ) == 0) {
2707 /*--------------------------------------------------------------------*/
2709 /*--------------------------------------------------------------------*/
2710 /*--------------------------------------------------------------------*/
2712 /*--------------------------------------------------------------------*/
2714 if (STRCASEEQ('t','T',"top", value) ||
2715 STRCASEEQ('m','M',"middle",value) ||
2716 STRCASEEQ('b','B',"bottom",value) ||
2717 STRCASEEQ('l','L',"left", value) ||
2718 STRCASEEQ('r','R',"right", value)) {
2721 else if (STRCASEEQ('c','C',"center", value)) {
2722 attr_align = apr_pstrdup(doc->pool, "middle");
2726 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2727 /*--------------------------------------------------------------------*/
2729 /*--------------------------------------------------------------------*/
2736 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2737 /*--------------------------------------------------------------------*/
2739 /*--------------------------------------------------------------------*/
2746 if (strcasecmp(name, "height") == 0 && value && *value) {
2747 /*--------------------------------------------------------------------*/
2749 /*--------------------------------------------------------------------*/
2750 attr_height = value;
2753 if (strcasecmp(name, "hspace") == 0 && value && *value) {
2754 /*--------------------------------------------------------------------*/
2756 /*--------------------------------------------------------------------*/
2757 attr_hspace = value;
2763 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2764 /*--------------------------------------------------------------------*/
2766 /*--------------------------------------------------------------------*/
2767 attr_vspace = value;
2776 if (IS_CSS_ON(chtml20->entryp)) {
2777 css_prop_list_t *style = s_chtml20_nopush_and_get_now_style(pdoc, node, attr_style);
2779 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2780 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2781 css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
2782 css_property_t *cur;
2783 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2784 attr_height = apr_pstrdup(doc->pool, cur->value);
2786 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2787 attr_width = apr_pstrdup(doc->pool, cur->value);
2789 for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
2790 attr_align = apr_pstrdup(doc->pool, cur->value);
2832 return chtml20->out;
2837 * It is a handler who processes the IMG tag.
2839 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2840 * destination is specified.
2841 * @param node [i] The IMG tag node is specified.
2842 * @return The conversion result is returned.
2845 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
2847 chtml20_t *chtml20 = GET_CHTML20(pdoc);
2849 return chtml20->out;
2854 * It is a handler who processes the SELECT tag.
2856 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2857 * destination is specified.
2858 * @param node [i] The SELECT tag node is specified.
2859 * @return The conversion result is returned.
2862 s_chtml20_start_select_tag(void *pdoc, Node *node)
2868 char *attr_style = NULL;
2870 chtml20 = GET_CHTML20(pdoc);
2876 char *multiple = NULL;
2879 for (attr = qs_get_attr(doc,node);
2881 attr = qs_get_next_attr(doc,attr)) {
2882 char *nm = qs_get_attr_name(doc,attr);
2883 char *val = qs_get_attr_value(doc,attr);
2887 if (strcasecmp(nm, "size") == 0) {
2888 /*--------------------------------------------------------------------*/
2889 /* CHTML 1.0 version 2.0 */
2890 /*--------------------------------------------------------------------*/
2891 size = apr_pstrdup(doc->buf.pool, val);
2893 else if (strcasecmp(nm, "style") == 0 && val && *val) {
2894 /*--------------------------------------------------------------------*/
2895 /* CHTML 1.0 version 2.0 */
2896 /*--------------------------------------------------------------------*/
2897 attr_style = apr_pstrdup(doc->buf.pool, val);
2903 if (strcasecmp(nm, "name") == 0) {
2904 /*--------------------------------------------------------------------*/
2905 /* CHTML 1.0 version 2.0 */
2906 /*--------------------------------------------------------------------*/
2907 name = apr_pstrdup(doc->buf.pool, val);
2913 if (strcasecmp(nm, "multiple") == 0) {
2914 /*--------------------------------------------------------------------*/
2915 /* CHTML 1.0 version 2.0 */
2916 /*--------------------------------------------------------------------*/
2917 multiple = apr_pstrdup(doc->buf.pool, val);
2925 if (size && *size) {
2930 if (name && *name) {
2939 if (IS_CSS_ON(chtml20->entryp)) {
2940 s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
2942 return chtml20->out;
2947 * It is a handler who processes the SELECT tag.
2949 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2950 * destination is specified.
2951 * @param node [i] The SELECT tag node is specified.
2952 * @return The conversion result is returned.
2955 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2960 chtml20 = GET_CHTML20(pdoc);
2964 if (IS_CSS_ON(chtml20->entryp)) {
2965 chxj_css_pop_prop_list(chtml20->css_prop_stack);
2967 return chtml20->out;
2972 * It is a handler who processes the OPTION tag.
2974 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2975 * destination is specified.
2976 * @param node [i] The OPTION tag node is specified.
2977 * @return The conversion result is returned.
2980 s_chtml20_start_option_tag(void *pdoc, Node *node)
2986 char *attr_style = NULL;
2988 chtml20 = GET_CHTML20(pdoc);
2992 char *selected = NULL;
2996 for (attr = qs_get_attr(doc,node);
2998 attr = qs_get_next_attr(doc,attr)) {
2999 char *nm = qs_get_attr_name(doc,attr);
3000 char *val = qs_get_attr_value(doc,attr);
3004 if (strcasecmp(nm, "selected") == 0) {
3005 /*--------------------------------------------------------------------*/
3006 /* CHTML 1.0 version 2.0 */
3007 /*--------------------------------------------------------------------*/
3008 selected = apr_pstrdup(doc->buf.pool, val);
3010 else if (strcasecmp(nm, "style") == 0 && val && *val) {
3011 /*--------------------------------------------------------------------*/
3012 /* CHTML 1.0 version 2.0 */
3013 /*--------------------------------------------------------------------*/
3014 attr_style = apr_pstrdup(doc->buf.pool, val);
3020 if (strcasecmp(nm, "value") == 0) {
3021 /*--------------------------------------------------------------------*/
3022 /* CHTML 1.0 version 2.0 */
3023 /*--------------------------------------------------------------------*/
3024 value = apr_pstrdup(doc->buf.pool, val);
3043 if (IS_CSS_ON(chtml20->entryp)) {
3044 s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3046 return chtml20->out;
3051 * It is a handler who processes the OPTION tag.
3053 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3054 * destination is specified.
3055 * @param node [i] The OPTION tag node is specified.
3056 * @return The conversion result is returned.
3059 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
3061 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3064 if (IS_CSS_ON(chtml20->entryp)) {
3065 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3068 return chtml20->out;
3073 * It is a handler who processes the DIV tag.
3075 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3076 * destination is specified.
3077 * @param node [i] The DIV tag node is specified.
3078 * @return The conversion result is returned.
3081 s_chtml20_start_div_tag(void *pdoc, Node *node)
3087 char *attr_style = NULL;
3088 char *attr_align = NULL;
3089 char *attr_display = NULL;
3090 char *attr_decoration = NULL;
3091 char *attr_wap_marquee_style = NULL;
3092 char *attr_wap_marquee_dir = NULL;
3093 char *attr_wap_marquee_loop = NULL;
3094 char *attr_color = NULL;
3095 char *attr_bgcolor = NULL;
3097 chtml20 = GET_CHTML20(pdoc);
3101 for (attr = qs_get_attr(doc,node);
3103 attr = qs_get_next_attr(doc,attr)) {
3104 char *nm = qs_get_attr_name(doc,attr);
3105 char *val = qs_get_attr_value(doc,attr);
3106 if (STRCASEEQ('a','A', "align", nm)) {
3107 /*----------------------------------------------------------------------*/
3108 /* CHTML 1.0 (W3C version 3.2) */
3109 /*----------------------------------------------------------------------*/
3110 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
3111 attr_align = apr_pstrdup(doc->buf.pool, val);
3114 else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
3115 attr_style = apr_pstrdup(doc->buf.pool, val);
3119 if (IS_CSS_ON(chtml20->entryp)) {
3120 css_prop_list_t *style = s_chtml20_nopush_and_get_now_style(pdoc, node, attr_style);
3122 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
3123 css_property_t *text_decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
3124 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
3125 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
3126 css_property_t *background_color_prop = chxj_css_get_property_value(doc, style, "background-color");
3127 css_property_t *background_prop = chxj_css_get_property_value(doc, style, "background");
3129 css_property_t *cur;
3130 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
3131 if (strcasecmp("-wap-marquee", cur->value) == 0) {
3132 attr_display = apr_pstrdup(doc->pool, cur->value);
3135 for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
3136 if (STRCASEEQ('b','B',"blink", cur->value)) {
3137 attr_decoration = apr_pstrdup(doc->pool, cur->value);
3140 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3141 attr_color = apr_pstrdup(doc->pool, cur->value);
3143 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
3144 attr_align = apr_pstrdup(doc->pool, cur->value);
3146 for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
3147 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3148 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3150 for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
3151 char *ss = strchr(cur->value, '#');
3153 ss = strstr(cur->value, "rgb");
3156 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
3157 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
3161 css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
3162 css_property_t *wap_marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
3163 css_property_t *wap_marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
3164 for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
3165 if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
3166 attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
3169 for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
3170 if (STRCASEEQ('l','L',"ltr",cur->value)) {
3171 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "right");
3173 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
3174 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "left");
3177 for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
3178 if (STRCASEEQ('i','I',"infinite",cur->value)) {
3179 attr_wap_marquee_loop = apr_pstrdup(doc->pool, "16");
3182 attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
3188 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
3189 memset(flg, 0, sizeof(*flg));
3196 flg->with_div_flag = 1;
3200 flg->with_div_flag = 1;
3203 if (attr_bgcolor && (STRCASEEQ('w','W',"white",attr_color) || STRCASEEQ('#','#',"#ffffff",attr_color))) {
3207 W_L("<font color=\"");
3210 flg->with_font_flag = 1;
3213 if (attr_decoration) {
3215 flg->with_blink_flag = 1;
3219 if (attr_wap_marquee_style) {
3220 W_L(" behavior=\"");
3221 W_V(attr_wap_marquee_style);
3224 if (attr_wap_marquee_dir) {
3225 W_L(" direction=\"");
3226 W_V(attr_wap_marquee_dir);
3229 if (attr_wap_marquee_loop) {
3231 W_V(attr_wap_marquee_loop);
3235 flg->with_marquee_flag = 1;
3237 node->userData = flg;
3239 return chtml20->out;
3244 * It is a handler who processes the DIV tag.
3246 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3247 * destination is specified.
3248 * @param node [i] The DIV tag node is specified.
3249 * @return The conversion result is returned.
3252 s_chtml20_end_div_tag(void *pdoc, Node *node)
3254 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3255 Doc *doc = chtml20->doc;
3257 chtml20_flags_t *flg = node->userData;
3258 if (flg && flg->with_marquee_flag) {
3261 if (flg && flg->with_blink_flag) {
3264 if (flg && flg->with_font_flag) {
3267 if (flg && flg->with_div_flag) {
3270 if (IS_CSS_ON(chtml20->entryp)) {
3271 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3273 node->userData = NULL;
3275 return chtml20->out;
3280 * It is a handler who processes the H1 tag.
3282 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3283 * destination is specified.
3284 * @param node [i] The H1 tag node is specified.
3285 * @return The conversion result is returned.
3288 s_chtml20_start_h1_tag(void *pdoc, Node *node)
3294 char *attr_style = NULL;
3295 char *attr_align = NULL;
3298 chtml20 = GET_CHTML20(pdoc);
3302 for (attr = qs_get_attr(doc,node);
3304 attr = qs_get_next_attr(doc,attr)) {
3305 char *name = qs_get_attr_name(doc,attr);
3306 char *value = qs_get_attr_value(doc,attr);
3307 if (STRCASEEQ('a','A',"align", name)) {
3308 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3312 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3316 if (IS_CSS_ON(chtml20->entryp)) {
3317 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3319 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3320 css_property_t *cur;
3321 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3322 if (STRCASEEQ('l','L',"left", cur->value)) {
3323 attr_align = apr_pstrdup(doc->pool, "left");
3325 else if (STRCASEEQ('c','C',"center",cur->value)) {
3326 attr_align = apr_pstrdup(doc->pool, "center");
3328 else if (STRCASEEQ('r','R',"right",cur->value)) {
3329 attr_align = apr_pstrdup(doc->pool, "right");
3342 return chtml20->out;
3347 * It is a handler who processes the H1 tag.
3349 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3350 * destination is specified.
3351 * @param node [i] The H1 tag node is specified.
3352 * @return The conversion result is returned.
3355 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
3360 chtml20 = GET_CHTML20(pdoc);
3364 if (IS_CSS_ON(chtml20->entryp)) {
3365 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3368 return chtml20->out;
3373 * It is a handler who processes the H2 tag.
3375 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3376 * destination is specified.
3377 * @param node [i] The H2 tag node is specified.
3378 * @return The conversion result is returned.
3381 s_chtml20_start_h2_tag(void *pdoc, Node *node)
3387 char *attr_style = NULL;
3388 char *attr_align = NULL;
3390 chtml20 = GET_CHTML20(pdoc);
3394 for (attr = qs_get_attr(doc,node);
3396 attr = qs_get_next_attr(doc,attr)) {
3397 char *name = qs_get_attr_name(doc,attr);
3398 char *value = qs_get_attr_value(doc,attr);
3399 if (STRCASEEQ('a','A',"align", name)) {
3400 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3404 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3408 if (IS_CSS_ON(chtml20->entryp)) {
3409 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3411 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3412 css_property_t *cur;
3413 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3414 if (STRCASEEQ('l','L',"left", cur->value)) {
3415 attr_align = apr_pstrdup(doc->pool, "left");
3417 else if (STRCASEEQ('c','C',"center",cur->value)) {
3418 attr_align = apr_pstrdup(doc->pool, "center");
3420 else if (STRCASEEQ('r','R',"right",cur->value)) {
3421 attr_align = apr_pstrdup(doc->pool, "right");
3434 return chtml20->out;
3439 * It is a handler who processes the H2 tag.
3441 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3442 * destination is specified.
3443 * @param node [i] The H2 tag node is specified.
3444 * @return The conversion result is returned.
3447 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
3449 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3450 Doc *doc = chtml20->doc;
3453 if (IS_CSS_ON(chtml20->entryp)) {
3454 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3457 return chtml20->out;
3462 * It is a handler who processes the H3 tag.
3464 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3465 * destination is specified.
3466 * @param node [i] The H3 tag node is specified.
3467 * @return The conversion result is returned.
3470 s_chtml20_start_h3_tag(void *pdoc, Node *node)
3476 char *attr_style = NULL;
3477 char *attr_align = NULL;
3479 chtml20 = GET_CHTML20(pdoc);
3483 for (attr = qs_get_attr(doc,node);
3485 attr = qs_get_next_attr(doc,attr)) {
3486 char *name = qs_get_attr_name(doc,attr);
3487 char *value = qs_get_attr_value(doc,attr);
3488 if (STRCASEEQ('a','A',"align", name)) {
3489 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3493 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3497 if (IS_CSS_ON(chtml20->entryp)) {
3498 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3500 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3501 css_property_t *cur;
3502 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3503 if (STRCASEEQ('l','L',"left", cur->value)) {
3504 attr_align = apr_pstrdup(doc->pool, "left");
3506 else if (STRCASEEQ('c','C',"center",cur->value)) {
3507 attr_align = apr_pstrdup(doc->pool, "center");
3509 else if (STRCASEEQ('r','R',"right",cur->value)) {
3510 attr_align = apr_pstrdup(doc->pool, "right");
3523 return chtml20->out;
3528 * It is a handler who processes the H3 tag.
3530 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3531 * destination is specified.
3532 * @param node [i] The H3 tag node is specified.
3533 * @return The conversion result is returned.
3536 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
3538 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3539 Doc *doc = chtml20->doc;
3542 if (IS_CSS_ON(chtml20->entryp)) {
3543 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3546 return chtml20->out;
3551 * It is a handler who processes the H4 tag.
3553 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3554 * destination is specified.
3555 * @param node [i] The H4 tag node is specified.
3556 * @return The conversion result is returned.
3559 s_chtml20_start_h4_tag(void *pdoc, Node *node)
3565 char *attr_style = NULL;
3566 char *attr_align = NULL;
3568 chtml20 = GET_CHTML20(pdoc);
3572 for (attr = qs_get_attr(doc,node);
3574 attr = qs_get_next_attr(doc,attr)) {
3575 char *name = qs_get_attr_name(doc,attr);
3576 char *value = qs_get_attr_value(doc,attr);
3577 if (STRCASEEQ('a','A',"align", name)) {
3578 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3582 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3586 if (IS_CSS_ON(chtml20->entryp)) {
3587 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3589 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3590 css_property_t *cur;
3591 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3592 if (STRCASEEQ('l','L',"left", cur->value)) {
3593 attr_align = apr_pstrdup(doc->pool, "left");
3595 else if (STRCASEEQ('c','C',"center",cur->value)) {
3596 attr_align = apr_pstrdup(doc->pool, "center");
3598 else if (STRCASEEQ('r','R',"right",cur->value)) {
3599 attr_align = apr_pstrdup(doc->pool, "right");
3612 return chtml20->out;
3617 * It is a handler who processes the H4 tag.
3619 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3620 * destination is specified.
3621 * @param node [i] The H4 tag node is specified.
3622 * @return The conversion result is returned.
3625 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
3627 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3628 Doc *doc = chtml20->doc;
3631 if (IS_CSS_ON(chtml20->entryp)) {
3632 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3635 return chtml20->out;
3640 * It is a handler who processes the H5 tag.
3642 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3643 * destination is specified.
3644 * @param node [i] The H5 tag node is specified.
3645 * @return The conversion result is returned.
3648 s_chtml20_start_h5_tag(void *pdoc, Node *node)
3654 char *attr_style = NULL;
3655 char *attr_align = NULL;
3657 chtml20 = GET_CHTML20(pdoc);
3661 for (attr = qs_get_attr(doc,node);
3663 attr = qs_get_next_attr(doc,attr)) {
3664 char *name = qs_get_attr_name(doc,attr);
3665 char *value = qs_get_attr_value(doc,attr);
3666 if (STRCASEEQ('a','A',"align", name)) {
3667 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3671 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3675 if (IS_CSS_ON(chtml20->entryp)) {
3676 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3678 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3679 css_property_t *cur;
3680 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3681 if (STRCASEEQ('l','L',"left", cur->value)) {
3682 attr_align = apr_pstrdup(doc->pool, "left");
3684 else if (STRCASEEQ('c','C',"center",cur->value)) {
3685 attr_align = apr_pstrdup(doc->pool, "center");
3687 else if (STRCASEEQ('r','R',"right",cur->value)) {
3688 attr_align = apr_pstrdup(doc->pool, "right");
3701 return chtml20->out;
3706 * It is a handler who processes the H5 tag.
3708 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3709 * destination is specified.
3710 * @param node [i] The H5 tag node is specified.
3711 * @return The conversion result is returned.
3714 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
3716 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3717 Doc *doc = chtml20->doc;
3720 if (IS_CSS_ON(chtml20->entryp)) {
3721 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3724 return chtml20->out;
3729 * It is a handler who processes the H6 tag.
3731 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3732 * destination is specified.
3733 * @param node [i] The H6 tag node is specified.
3734 * @return The conversion result is returned.
3737 s_chtml20_start_h6_tag(void *pdoc, Node *node)
3743 char *attr_style = NULL;
3744 char *attr_align = NULL;
3746 chtml20 = GET_CHTML20(pdoc);
3750 for (attr = qs_get_attr(doc,node);
3752 attr = qs_get_next_attr(doc,attr)) {
3753 char *name = qs_get_attr_name(doc,attr);
3754 char *value = qs_get_attr_value(doc,attr);
3755 if (STRCASEEQ('a','A',"align", name)) {
3756 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3760 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3764 if (IS_CSS_ON(chtml20->entryp)) {
3765 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3767 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3768 css_property_t *cur;
3769 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3770 if (STRCASEEQ('l','L',"left", cur->value)) {
3771 attr_align = apr_pstrdup(doc->pool, "left");
3773 else if (STRCASEEQ('c','C',"center",cur->value)) {
3774 attr_align = apr_pstrdup(doc->pool, "center");
3776 else if (STRCASEEQ('r','R',"right",cur->value)) {
3777 attr_align = apr_pstrdup(doc->pool, "right");
3790 return chtml20->out;
3795 * It is a handler who processes the H6 tag.
3797 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3798 * destination is specified.
3799 * @param node [i] The H6 tag node is specified.
3800 * @return The conversion result is returned.
3803 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
3805 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3806 Doc *doc = chtml20->doc;
3809 if (IS_CSS_ON(chtml20->entryp)) {
3810 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3813 return chtml20->out;
3818 * It is a handler who processes the PRE tag.
3820 * @param pdoc [i/o] The pointer to the XHTML structure at the output
3821 * destination is specified.
3822 * @param node [i] The PRE tag node is specified.
3823 * @return The conversion result is returned.
3826 s_chtml20_start_pre_tag(void *pdoc, Node *node)
3828 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3829 Doc *doc = chtml20->doc;
3831 char *attr_style = NULL;
3833 for (attr = qs_get_attr(doc,node);
3835 attr = qs_get_next_attr(doc,attr)) {
3836 char *nm = qs_get_attr_name(doc,attr);
3837 char *val = qs_get_attr_value(doc,attr);
3838 if (val && STRCASEEQ('s','S',"style", nm)) {
3843 if (IS_CSS_ON(chtml20->entryp)) {
3844 s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3846 chtml20->pre_flag++;
3848 return chtml20->out;
3853 * It is a handler who processes the PRE tag.
3855 * @param pdoc [i/o] The pointer to the XHTML structure at the output
3856 * destination is specified.
3857 * @param node [i] The PRE tag node is specified.
3858 * @return The conversion result is returned.
3861 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
3863 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3864 Doc *doc = chtml20->doc;
3867 chtml20->pre_flag--;
3868 if (IS_CSS_ON(chtml20->entryp)) {
3869 chxj_css_pop_prop_list(chtml20->css_prop_stack);
3872 return chtml20->out;
3877 * It is a handler who processes the P tag.
3879 * @param pdoc [i/o] The pointer to the XHTML structure at the output
3880 * destination is specified.
3881 * @param node [i] The P tag node is specified.
3882 * @return The conversion result is returned.
3885 s_chtml20_start_p_tag(void *pdoc, Node *node)
3891 char *attr_align = NULL;
3892 char *attr_style = NULL;
3893 char *attr_color = NULL;
3894 char *attr_blink = NULL;
3896 chtml20 = GET_CHTML20(pdoc);
3900 for (attr = qs_get_attr(doc,node);
3902 attr = qs_get_next_attr(doc,attr)) {
3903 char *nm = qs_get_attr_name(doc,attr);
3904 char *val = qs_get_attr_value(doc,attr);
3905 if (STRCASEEQ('a','A',"align", nm)) {
3906 /*----------------------------------------------------------------------*/
3907 /* CHTML 1.0 (W3C version 3.2) */
3908 /*----------------------------------------------------------------------*/
3909 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
3910 attr_align = apr_pstrdup(doc->buf.pool, val);
3914 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
3915 attr_style = apr_pstrdup(doc->buf.pool, val);
3918 if (IS_CSS_ON(chtml20->entryp)) {
3919 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
3921 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
3922 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
3923 css_property_t *text_deco_prop = chxj_css_get_property_value(doc, style, "text-decoration");
3924 css_property_t *cur;
3925 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
3926 if (STRCASEEQ('l','L',"left",cur->value)) {
3927 attr_align = apr_pstrdup(doc->pool, "left");
3929 else if (STRCASEEQ('c','C',"center",cur->value)) {
3930 attr_align = apr_pstrdup(doc->pool, "center");
3932 else if (STRCASEEQ('r','R',"right",cur->value)) {
3933 attr_align = apr_pstrdup(doc->pool, "right");
3936 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3937 if (cur->value && *cur->value) {
3938 attr_color = apr_pstrdup(doc->pool, cur->value);
3941 for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
3942 if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
3943 attr_blink = apr_pstrdup(doc->pool, cur->value);
3955 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
3956 memset(flg, 0, sizeof(*flg));
3958 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3959 W_L("<font color=\"");
3962 flg->with_font_flag = 1;
3966 flg->with_blink_flag = 1;
3968 node->userData = (void *)flg;
3969 return chtml20->out;
3974 * It is a handler who processes the P tag.
3976 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3977 * destination is specified.
3978 * @param node [i] The P tag node is specified.
3979 * @return The conversion result is returned.
3982 s_chtml20_end_p_tag(void *pdoc, Node *node)
3988 chtml20 = GET_CHTML20(pdoc);
3992 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
3993 if (flg && flg->with_font_flag) {
3996 if (flg && flg->with_blink_flag) {
4000 if (IS_CSS_ON(chtml20->entryp)) {
4001 chxj_css_pop_prop_list(chtml20->css_prop_stack);
4003 return chtml20->out;
4008 s_chtml20_chxjif_tag(void *pdoc, Node *node)
4015 chtml20 = GET_CHTML20(pdoc);
4019 for (child = qs_get_child_node(doc, node);
4021 child = qs_get_next_node(doc, child)) {
4024 s_chtml20_chxjif_tag(pdoc, child);
4032 * It is a handler who processes the TEXTARE tag.
4034 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4035 * destination is specified.
4036 * @param node [i] The TEXTAREA tag node is specified.
4037 * @return The conversion result is returned.
4040 s_chtml20_start_textarea_tag(void *pdoc, Node *node)
4046 char *attr_accesskey = NULL;
4047 char *attr_name = NULL;
4048 char *attr_rows = NULL;
4049 char *attr_cols = NULL;
4050 char *attr_istyle = NULL;
4051 char *attr_style = NULL;
4053 chtml20 = GET_CHTML20(pdoc);
4057 chtml20->textarea_flag++;
4058 for (attr = qs_get_attr(doc,node);
4060 attr = qs_get_next_attr(doc,attr)) {
4061 char *name = qs_get_attr_name(doc,attr);
4062 char *value = qs_get_attr_value(doc,attr);
4066 if (strcasecmp(name, "accesskey") == 0 && value && *value != 0) {
4067 attr_accesskey = value;
4073 if (strcasecmp(name, "name") == 0 && value && *value != 0) {
4080 if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
4087 if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
4094 if (strcasecmp(name, "istyle") == 0 && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
4095 attr_istyle = value;
4100 if (strcasecmp(name, "style") == 0 && value && *value) {
4110 if (IS_CSS_ON(chtml20->entryp)) {
4111 css_prop_list_t *style = s_chtml20_nopush_and_get_now_style(pdoc, node, attr_style);
4113 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
4114 css_property_t *cur;
4115 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
4116 if (strcasestr(cur->value, "<ja:n>")) {
4119 else if (strcasestr(cur->value, "<ja:en>")) {
4122 else if (strcasestr(cur->value, "<ja:hk>")) {
4125 else if (strcasestr(cur->value, "<ja:h>")) {
4133 if (attr_accesskey) {
4134 W_L(" accesskey=\"");
4135 W_V(attr_accesskey);
4159 return chtml20->out;
4164 * It is a handler who processes the TEXTAREA tag.
4166 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4167 * destination is specified.
4168 * @param node [i] The TEXTAREA tag node is specified.
4169 * @return The conversion result is returned.
4172 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
4174 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4175 Doc *doc = chtml20->doc;
4178 chtml20->textarea_flag--;
4180 return chtml20->out;
4185 s_chtml20_text_tag(void *pdoc, Node *child)
4196 apr_size_t z2h_input_len;
4198 chtml20 = GET_CHTML20(pdoc);
4202 textval = qs_get_node_value(doc,child);
4203 if (strlen(textval) == 0) {
4204 return chtml20->out;
4207 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
4208 memset(tmp, 0, qs_get_node_size(doc,child)+1);
4210 tdst = qs_alloc_zero_byte_string(doc->buf.pool);
4211 memset(one_byte, 0, sizeof(one_byte));
4214 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
4216 int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out, child);
4218 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
4222 if (is_sjis_kanji(textval[ii])) {
4223 one_byte[0] = textval[ii+0];
4224 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4225 one_byte[0] = textval[ii+1];
4226 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4230 if (chtml20->pre_flag) {
4231 one_byte[0] = textval[ii+0];
4232 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4235 if (chtml20->textarea_flag) {
4236 one_byte[0] = textval[ii+0];
4237 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4240 if (textval[ii] != '\r' && textval[ii] != '\n') {
4241 one_byte[0] = textval[ii+0];
4242 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4245 z2h_input_len = strlen(tdst);
4246 tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, chtml20->entryp);
4249 return chtml20->out;
4254 * It is a handler who processes the BLOCKQUOTE tag.
4256 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4257 * destination is specified.
4258 * @param node [i] The BLOCKQUOTE tag node is specified.
4259 * @return The conversion result is returned.
4262 s_chtml20_start_blockquote_tag(void *pdoc, Node *node)
4267 char *attr_style = NULL;
4268 char *attr_color = NULL;
4270 chtml20 = GET_CHTML20(pdoc);
4272 for (attr = qs_get_attr(doc,node);
4274 attr = qs_get_next_attr(doc,attr)) {
4275 char *nm = qs_get_attr_name(doc,attr);
4276 char *val = qs_get_attr_value(doc,attr);
4277 if (val && STRCASEEQ('s','S',"style", nm)) {
4281 if (IS_CSS_ON(chtml20->entryp)) {
4282 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
4284 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4285 css_property_t *cur;
4286 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4287 if (cur->value && *cur->value) {
4288 attr_color = apr_pstrdup(doc->pool, cur->value);
4293 W_L("<blockquote>");
4294 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
4295 memset(flg, 0, sizeof(*flg));
4297 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4298 W_L("<font color=\"");
4301 flg->with_font_flag = 1;
4303 node->userData = (void *)flg;
4304 return chtml20->out;
4309 * It is a handler who processes the BLOCKQUOTE tag.
4311 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4312 * destination is specified.
4313 * @param node [i] The BLOCKQUOTE tag node is specified.
4314 * @return The conversion result is returned.
4317 s_chtml20_end_blockquote_tag(void *pdoc, Node *node)
4319 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4320 Doc *doc = chtml20->doc;
4321 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
4322 if (flg && flg->with_font_flag) {
4325 W_L("</blockquote>");
4326 if (IS_CSS_ON(chtml20->entryp)) {
4327 chxj_css_pop_prop_list(chtml20->css_prop_stack);
4329 return chtml20->out;
4334 * It is a handler who processes the DIR tag.
4336 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4337 * destination is specified.
4338 * @param node [i] The DIR tag node is specified.
4339 * @return The conversion result is returned.
4342 s_chtml20_start_dir_tag(void *pdoc, Node *node)
4347 char *attr_style = NULL;
4348 char *attr_color = NULL;
4350 chtml20 = GET_CHTML20(pdoc);
4352 for (attr = qs_get_attr(doc,node);
4354 attr = qs_get_next_attr(doc,attr)) {
4355 char *nm = qs_get_attr_name(doc,attr);
4356 char *val = qs_get_attr_value(doc,attr);
4357 if (val && STRCASEEQ('s','S',"style", nm)) {
4361 if (IS_CSS_ON(chtml20->entryp)) {
4362 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
4364 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4365 css_property_t *cur;
4366 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4367 if (cur->value && *cur->value) {
4368 attr_color = apr_pstrdup(doc->pool, cur->value);
4374 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
4375 memset(flg, 0, sizeof(*flg));
4377 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4378 W_L("<font color=\"");
4381 flg->with_font_flag = 1;
4383 node->userData = (void *)flg;
4384 return chtml20->out;
4389 * It is a handler who processes the DIR tag.
4391 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4392 * destination is specified.
4393 * @param node [i] The DIR tag node is specified.
4394 * @return The conversion result is returned.
4397 s_chtml20_end_dir_tag(void *pdoc, Node *node)
4399 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4400 Doc *doc = chtml20->doc;
4402 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
4403 if (flg && flg->with_font_flag) {
4407 if (IS_CSS_ON(chtml20->entryp)) {
4408 chxj_css_pop_prop_list(chtml20->css_prop_stack);
4410 return chtml20->out;
4415 * It is a handler who processes the DL tag.
4417 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4418 * destination is specified.
4419 * @param node [i] The DL tag node is specified.
4420 * @return The conversion result is returned.
4423 s_chtml20_start_dl_tag(void *pdoc, Node *node)
4428 char *attr_style = NULL;
4429 char *attr_color = NULL;
4431 chtml20 = GET_CHTML20(pdoc);
4433 for (attr = qs_get_attr(doc,node);
4435 attr = qs_get_next_attr(doc,attr)) {
4436 char *nm = qs_get_attr_name(doc,attr);
4437 char *val = qs_get_attr_value(doc,attr);
4438 if (val && STRCASEEQ('s','S',"style", nm)) {
4442 if (IS_CSS_ON(chtml20->entryp)) {
4443 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
4445 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4446 css_property_t *cur;
4447 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4448 if (cur->value && *cur->value) {
4449 attr_color = apr_pstrdup(doc->pool, cur->value);
4455 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
4456 memset(flg, 0, sizeof(*flg));
4458 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4459 W_L("<font color=\"");
4462 flg->with_font_flag = 1;
4464 node->userData = (void *)flg;
4465 return chtml20->out;
4470 * It is a handler who processes the DL tag.
4472 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4473 * destination is specified.
4474 * @param node [i] The DL tag node is specified.
4475 * @return The conversion result is returned.
4478 s_chtml20_end_dl_tag(void *pdoc, Node *node)
4480 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4481 Doc *doc = chtml20->doc;
4482 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
4483 if (flg && flg->with_font_flag) {
4487 if (IS_CSS_ON(chtml20->entryp)) {
4488 chxj_css_pop_prop_list(chtml20->css_prop_stack);
4490 return chtml20->out;
4495 * It is a handler who processes the DT tag.
4497 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4498 * destination is specified.
4499 * @param node [i] The DT tag node is specified.
4500 * @return The conversion result is returned.
4503 s_chtml20_start_dt_tag(void *pdoc, Node *node)
4508 char *attr_style = NULL;
4509 char *attr_color = NULL;
4511 chtml20 = GET_CHTML20(pdoc);
4513 for (attr = qs_get_attr(doc,node);
4515 attr = qs_get_next_attr(doc,attr)) {
4516 char *nm = qs_get_attr_name(doc,attr);
4517 char *val = qs_get_attr_value(doc,attr);
4518 if (val && STRCASEEQ('s','S',"style", nm)) {
4522 if (IS_CSS_ON(chtml20->entryp)) {
4523 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
4525 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4526 css_property_t *cur;
4527 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4528 if (cur->value && *cur->value) {
4529 attr_color = apr_pstrdup(doc->pool, cur->value);
4535 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
4536 memset(flg, 0, sizeof(*flg));
4538 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4539 W_L("<font color=\"");
4542 flg->with_font_flag = 1;
4544 node->userData = (void *)flg;
4545 return chtml20->out;
4550 * It is a handler who processes the DT tag.
4552 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4553 * destination is specified.
4554 * @param node [i] The DT tag node is specified.
4555 * @return The conversion result is returned.
4558 s_chtml20_end_dt_tag(void *pdoc, Node *node)
4560 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4561 Doc *doc = chtml20->doc;
4562 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
4563 if (flg && flg->with_font_flag) {
4566 if (IS_CSS_ON(chtml20->entryp)) {
4567 chxj_css_pop_prop_list(chtml20->css_prop_stack);
4569 return chtml20->out;
4574 * It is a handler who processes the DD tag.
4576 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4577 * destination is specified.
4578 * @param node [i] The DD tag node is specified.
4579 * @return The conversion result is returned.
4582 s_chtml20_start_dd_tag(void *pdoc, Node *node)
4587 char *attr_style = NULL;
4588 char *attr_color = NULL;
4590 chtml20 = GET_CHTML20(pdoc);
4592 for (attr = qs_get_attr(doc,node);
4594 attr = qs_get_next_attr(doc,attr)) {
4595 char *nm = qs_get_attr_name(doc,attr);
4596 char *val = qs_get_attr_value(doc,attr);
4597 if (val && STRCASEEQ('s','S',"style", nm)) {
4601 if (IS_CSS_ON(chtml20->entryp)) {
4602 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
4604 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4605 css_property_t *cur;
4606 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4607 if (cur->value && *cur->value) {
4608 attr_color = apr_pstrdup(doc->pool, cur->value);
4614 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
4615 memset(flg, 0, sizeof(*flg));
4617 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4618 W_L("<font color=\"");
4621 flg->with_font_flag = 1;
4623 node->userData = (void *)flg;
4624 return chtml20->out;
4625 CHTML20_START_OF_TAG_WITH_CSS_FONT_COLOR("<dd>");
4631 * It is a handler who processes the DD tag.
4633 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4634 * destination is specified.
4635 * @param node [i] The DD tag node is specified.
4636 * @return The conversion result is returned.
4639 s_chtml20_end_dd_tag(void *pdoc, Node *node)
4641 CHTML20_END_OF_NO_CLOSE_TAG_WITH_FONT_TAG();
4647 * It is a handler who processes the MENU tag.
4649 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4650 * destination is specified.
4651 * @param node [i] The MENU tag node is specified.
4652 * @return The conversion result is returned.
4655 s_chtml20_start_menu_tag(void *pdoc, Node *node)
4657 CHTML20_START_OF_TAG_WITH_CSS_FONT_COLOR("<menu>");
4662 * It is a handler who processes the MENU tag.
4664 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4665 * destination is specified.
4666 * @param node [i] The MENU tag node is specified.
4667 * @return The conversion result is returned.
4670 s_chtml20_end_menu_tag(void *pdoc, Node *node)
4672 CHTML20_END_OF_CLOSE_TAG_WITH_FONT_TAG("</menu>");
4677 * It is a handler who processes the PLAINTEXT tag.
4679 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4680 * destination is specified.
4681 * @param node [i] The PLAINTEXT tag node is specified.
4682 * @return The conversion result is returned.
4685 s_chtml20_start_plaintext_tag(void *pdoc, Node *node)
4687 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4688 Doc *doc = chtml20->doc;
4691 s_chtml20_start_plaintext_tag_inner(pdoc,node);
4692 return chtml20->out;
4696 s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
4698 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4699 Doc *doc = chtml20->doc;
4702 for (child = qs_get_child_node(doc, node);
4704 child = qs_get_next_node(doc, child)) {
4706 s_chtml20_start_plaintext_tag_inner(pdoc, child);
4708 return chtml20->out;
4713 * It is a handler who processes the PLAINTEXT tag.
4715 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4716 * destination is specified.
4717 * @param node [i] The PLAINTEXT tag node is specified.
4718 * @return The conversion result is returned.
4721 s_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4723 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4724 return chtml20->out;
4728 * It is a handler who processes the BLINK tag.
4730 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4731 * destination is specified.
4732 * @param node [i] The BLINK tag node is specified.
4733 * @return The conversion result is returned.
4736 s_chtml20_start_blink_tag(void *pdoc, Node *node)
4738 CHTML20_START_OF_TAG_WITH_CSS_FONT_COLOR("<blink>");
4743 * It is a handler who processes the BLINK tag.
4745 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4746 * destination is specified.
4747 * @param node [i] The BLINK tag node is specified.
4748 * @return The conversion result is returned.
4751 s_chtml20_end_blink_tag(void *pdoc, Node *node)
4753 CHTML20_END_OF_CLOSE_TAG_WITH_FONT_TAG("</blink>");
4758 * It is a hanmarqueeer who processes the MARQUEE tag.
4760 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4761 * destination is specified.
4762 * @param node [i] The MARQUEE tag node is specified.
4763 * @return The conversion result is returned.
4766 s_chtml20_start_marquee_tag(void *pdoc, Node *node)
4768 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4769 Doc *doc = chtml20->doc;
4771 char *attr_direction = NULL;
4772 char *attr_behavior = NULL;
4773 char *attr_loop = NULL;
4774 char *attr_style = NULL;
4775 char *attr_color = NULL;
4776 /*--------------------------------------------------------------------------*/
4777 /* Get Attributes */
4778 /*--------------------------------------------------------------------------*/
4779 for (attr = qs_get_attr(doc,node);
4781 attr = qs_get_next_attr(doc,attr)) {
4782 char *name = qs_get_attr_name(doc,attr);
4783 char *value = qs_get_attr_value(doc,attr);
4784 if (STRCASEEQ('d','D',"direction", name)) {
4785 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
4786 attr_direction = value;
4789 else if (STRCASEEQ('b','B',"behavior",name)) {
4790 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
4791 attr_behavior = value;
4794 else if (STRCASEEQ('l','L',"loop",name)) {
4795 if (value && *value) {
4799 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4803 if (IS_CSS_ON(chtml20->entryp)) {
4804 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
4806 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4807 css_property_t *direction_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4808 css_property_t *style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4809 css_property_t *loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4810 css_property_t *cur;
4811 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4812 if (cur->value && *cur->value) {
4813 attr_color = apr_pstrdup(doc->pool, cur->value);
4816 for (cur = style_prop->next; cur != style_prop; cur = cur->next) {
4817 if (cur->value && *cur->value) {
4818 attr_behavior = apr_pstrdup(doc->pool, cur->value);
4821 for (cur = loop_prop->next; cur != loop_prop; cur = cur->next) {
4822 if (cur->value && *cur->value) {
4823 attr_loop = apr_pstrdup(doc->pool, cur->value);
4824 if (STRCASEEQ('i','I',"infinite",attr_loop)) {
4829 for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
4830 if (cur->value && *cur->value) {
4831 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4832 attr_direction = "right";
4834 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4835 attr_direction = "left";
4842 if (attr_direction) {
4843 W_L(" direction=\"");
4844 W_V(attr_direction);
4847 if (attr_behavior) {
4848 W_L(" behavior=\"");
4859 chtml20_flags_t *flg = (chtml20_flags_t *)apr_palloc(doc->pool, sizeof(chtml20_flags_t));
4860 memset(flg, 0, sizeof(*flg));
4862 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4863 W_L("<font color=\"");
4866 flg->with_font_flag = 1;
4868 node->userData = (void *)flg;
4869 return chtml20->out;
4874 * It is a hanmarqueeer who processes the MARQUEE tag.
4876 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4877 * destination is specified.
4878 * @param node [i] The MARQUEE tag node is specified.
4879 * @return The conversion result is returned.
4882 s_chtml20_end_marquee_tag(void *pdoc, Node *node)
4884 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4885 Doc *doc = chtml20->doc;
4886 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
4887 if (flg && flg->with_font_flag) {
4891 if (IS_CSS_ON(chtml20->entryp)) {
4892 chxj_css_pop_prop_list(chtml20->css_prop_stack);
4894 return chtml20->out;
4899 * * It is handler who processes the New Line Code.
4902 s_chtml20_newline_mark(void *pdoc, Node *UNUSED(node))
4904 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4905 Doc *doc = chtml20->doc;
4907 return chtml20->out;
4912 * It is a handler who processes the LINK tag.
4914 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4915 * destination is specified.
4916 * @param node [i] The LINK tag node is specified.
4917 * @return The conversion result is returned.
4920 s_chtml20_link_tag(void *pdoc, Node *node)
4929 chtml20 = GET_CHTML20(pdoc);
4932 if (! IS_CSS_ON(chtml20->entryp)) {
4933 return chtml20->out;
4936 for (attr = qs_get_attr(doc,node);
4938 attr = qs_get_next_attr(doc,attr)) {
4939 char *name = qs_get_attr_name(doc,attr);
4940 char *value = qs_get_attr_value(doc,attr);
4941 if (STRCASEEQ('r','R',"rel", name)) {
4942 if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
4946 else if (STRCASEEQ('h','H',"href", name)) {
4947 if (value && *value) {
4951 else if (STRCASEEQ('t','T',"type", name)) {
4952 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
4958 if (rel && href && type) {
4959 DBG(doc->r, "REQ[%X] start load CSS. url:[%s]", TO_ADDR(doc->r),href);
4960 chtml20->style = chxj_css_parse_from_uri(doc->r, doc->pool, chtml20->style, href);
4961 DBG(doc->r, "REQ[%X] end load CSS. url:[%s]", TO_ADDR(doc->r),href);
4964 return chtml20->out;
4968 static css_prop_list_t *
4969 s_chtml20_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4971 chtml20_t *chtml20 = GET_CHTML20(pdoc);
4972 Doc *doc = chtml20->doc;
4973 css_prop_list_t *last_css = NULL;
4974 if (IS_CSS_ON(chtml20->entryp)) {
4975 css_prop_list_t *dup_css;
4976 css_selector_t *selector;
4978 last_css = chxj_css_get_last_prop_list(chtml20->css_prop_stack);
4979 dup_css = chxj_dup_css_prop_list(doc, last_css);
4980 selector = chxj_css_find_selector(doc, chtml20->style, node);
4982 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4984 chxj_css_push_prop_list(chtml20->css_prop_stack, dup_css);
4985 last_css = chxj_css_get_last_prop_list(chtml20->css_prop_stack);
4986 if (style_attr_value) {
4987 css_stylesheet_t *ssheet = chxj_css_parse_style_attr(doc, NULL, apr_pstrdup(doc->pool, node->name), NULL, NULL, apr_pstrdup(doc->pool, style_attr_value));
4989 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4997 static css_prop_list_t *
4998 s_chtml20_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
5000 chtml20_t *chtml20 = GET_CHTML20(pdoc);
5001 Doc *doc = chtml20->doc;
5002 css_prop_list_t *last_css = NULL;
5003 if (IS_CSS_ON(chtml20->entryp)) {
5004 css_prop_list_t *dup_css;
5005 css_selector_t *selector;
5007 last_css = chxj_css_get_last_prop_list(chtml20->css_prop_stack);
5008 dup_css = chxj_dup_css_prop_list(doc, last_css);
5009 selector = chxj_css_find_selector(doc, chtml20->style, node);
5011 chxj_css_prop_list_merge_property(doc, dup_css, selector);
5015 if (style_attr_value) {
5016 css_stylesheet_t *ssheet = chxj_css_parse_style_attr(doc, NULL, apr_pstrdup(doc->pool, node->name), NULL, NULL, apr_pstrdup(doc->pool, style_attr_value));
5018 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
5027 * It is a handler who processes the SPAN tag.
5029 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5030 * destination is specified.
5031 * @param node [i] The SPAN tag node is specified.
5032 * @return The conversion result is returned.
5035 s_chtml20_start_span_tag(void *pdoc, Node *node)
5040 char *attr_style = NULL;
5041 char *attr_color = NULL;
5042 char *attr_align = NULL;
5043 char *attr_blink = NULL;
5044 char *attr_marquee = NULL;
5045 char *attr_marquee_dir = NULL;
5046 char *attr_marquee_style = NULL;
5047 char *attr_marquee_loop = NULL;
5049 chtml20 = GET_CHTML20(pdoc);
5052 for (attr = qs_get_attr(doc,node);
5054 attr = qs_get_next_attr(doc,attr)) {
5055 char *nm = qs_get_attr_name(doc,attr);
5056 char *val = qs_get_attr_value(doc,attr);
5057 if (val && STRCASEEQ('s','S',"style", nm)) {
5061 if (IS_CSS_ON(chtml20->entryp)) {
5062 css_prop_list_t *style = s_chtml20_push_and_get_now_style(pdoc, node, attr_style);
5064 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
5065 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
5066 css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
5067 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
5068 css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
5069 css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
5070 css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
5071 css_property_t *cur;
5072 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
5073 attr_color = apr_pstrdup(doc->pool, cur->value);
5075 for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
5076 if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
5077 attr_blink = apr_pstrdup(doc->pool, cur->value);
5080 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
5081 if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
5082 attr_marquee = apr_pstrdup(doc->pool, cur->value);
5085 for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
5086 if (cur->value && *cur->value) {
5087 if (STRCASEEQ('l','L',"ltr",cur->value)) {
5088 attr_marquee_dir = "right";
5090 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
5091 attr_marquee_dir = "left";
5095 for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
5096 if (cur->value && *cur->value) {
5097 if ( STRCASEEQ('s','S',"scroll",cur->value)
5098 || STRCASEEQ('s','S',"slide",cur->value)
5099 || STRCASEEQ('a','A',"alternate",cur->value)) {
5100 attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
5104 for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
5105 if (cur->value && *cur->value) {
5106 if (STRCASEEQ('i','I',"infinite",cur->value)) {
5107 attr_marquee_loop = "16";
5110 attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
5114 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
5115 if (STRCASEEQ('l','L',"left", cur->value)) {
5116 attr_align = apr_pstrdup(doc->pool, "left");
5118 else if (STRCASEEQ('c','C',"center",cur->value)) {
5119 attr_align = apr_pstrdup(doc->pool, "center");
5121 else if (STRCASEEQ('r','R',"right",cur->value)) {
5122 attr_align = apr_pstrdup(doc->pool, "right");
5127 if (attr_color || attr_align || attr_blink || attr_marquee) {
5128 chtml20_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
5129 memset(flg, 0, sizeof(*flg));
5132 flg->with_blink_flag = 1;
5136 if (attr_marquee_dir) {
5137 W_L(" direction=\"");
5138 W_V(attr_marquee_dir);
5141 if (attr_marquee_style) {
5142 W_L(" behavior=\"");
5143 W_V(attr_marquee_style);
5146 if (attr_marquee_loop) {
5148 W_V(attr_marquee_loop);
5152 flg->with_marquee_flag = 1;
5155 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5156 W_L("<font color=\"");
5159 flg->with_font_flag = 1;
5162 W_L("<div align=\"");
5165 flg->with_div_flag = 1;
5167 node->userData = flg;
5170 node->userData = NULL;
5172 return chtml20->out;
5177 * It is a handler who processes the SPAN tag.
5179 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5180 * destination is specified.
5181 * @param node [i] The SPAN tag node is specified.
5182 * @return The conversion result is returned.
5185 s_chtml20_end_span_tag(void *pdoc, Node *node)
5187 chtml20_t *chtml20 = GET_CHTML20(pdoc);
5188 Doc *doc = chtml20->doc;
5190 chtml20_flags_t *flg = (chtml20_flags_t *)node->userData;
5191 if (flg && flg->with_div_flag) {
5194 if (flg && flg->with_font_flag) {
5197 if (flg && flg->with_marquee_flag) {
5200 if (flg && flg->with_blink_flag) {
5203 if (IS_CSS_ON(chtml20->entryp)) {
5204 chxj_css_pop_prop_list(chtml20->css_prop_stack);
5206 return chtml20->out;
5211 * It is a handler who processes the STYLE tag.
5213 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5214 * destination is specified.
5215 * @param node [i] The STYLE tag node is specified.
5216 * @return The conversion result is returned.
5219 s_chtml20_style_tag(void *pdoc, Node *node)
5226 chtml20 = GET_CHTML20(pdoc);
5229 if (! IS_CSS_ON(chtml20->entryp)) {
5230 return chtml20->out;
5233 for (attr = qs_get_attr(doc,node);
5235 attr = qs_get_next_attr(doc,attr)) {
5236 char *name = qs_get_attr_name(doc,attr);
5237 char *value = qs_get_attr_value(doc,attr);
5238 if (STRCASEEQ('t','T',"type", name)) {
5239 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5245 Node *child = qs_get_child_node(doc, node);
5246 if (type && child) {
5247 char *name = qs_get_node_name(doc, child);
5248 if (STRCASEEQ('t','T',"text", name)) {
5249 char *value = qs_get_node_value(doc, child);
5250 DBG(doc->r, "REQ[%X] start load CSS. buf:[%s]", TO_ADDR(doc->r),value);
5251 chtml20->style = chxj_css_parse_style_value(doc, chtml20->style, value);
5252 DBG(doc->r, "REQ[%X] end load CSS. value:[%s]", TO_ADDR(doc->r),value);
5255 return chtml20->out;