2 * Copyright (C) 2005-2009 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.
18 #include "chxj_chtml40.h"
19 #include "chxj_hdml.h"
20 #include "chxj_str_util.h"
21 #include "chxj_dump.h"
22 #include "chxj_img_conv.h"
23 #include "chxj_qr_code.h"
24 #include "chxj_encoding.h"
25 #include "chxj_header_inf.h"
27 #define GET_CHTML40(X) ((chtml40_t *)(X))
30 #define W_L(X) do { chtml40->out = BUFFERED_WRITE_LITERAL(chtml40->out, &doc->buf, (X)); } while(0)
31 #define W_V(X) do { chtml40->out = (X) ? BUFFERED_WRITE_VALUE(chtml40->out, &doc->buf, (X)) \
32 : BUFFERED_WRITE_LITERAL(chtml40->out, &doc->buf, ""); } while(0)
34 #define W_NLCODE() do { char *nlcode = TO_NLCODE(chtml40->conf); W_V(nlcode); } while (0)
36 #define CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE() \
37 if (IS_CSS_ON(chtml40->entryp)) { \
38 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style); \
40 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color"); \
41 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type"); \
42 css_property_t *cur; \
43 for (cur = color_prop->next; cur != color_prop; cur = cur->next) { \
44 if (cur->value && *cur->value) { \
45 attr_color = apr_pstrdup(doc->pool, cur->value); \
48 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) { \
49 if (cur->value && *cur->value) { \
50 attr_type = apr_pstrdup(doc->pool, cur->value); \
56 static char *s_chtml40_start_html_tag (void *pdoc, Node *node);
57 static char *s_chtml40_end_html_tag (void *pdoc, Node *node);
58 static char *s_chtml40_start_meta_tag (void *pdoc, Node *node);
59 static char *s_chtml40_end_meta_tag (void *pdoc, Node *node);
60 static char *s_chtml40_start_textarea_tag (void *pdoc, Node *node);
61 static char *s_chtml40_end_textarea_tag (void *pdoc, Node *node);
62 static char *s_chtml40_start_p_tag (void *pdoc, Node *node);
63 static char *s_chtml40_end_p_tag (void *pdoc, Node *node);
64 static char *s_chtml40_start_pre_tag (void *pdoc, Node *node);
65 static char *s_chtml40_end_pre_tag (void *pdoc, Node *node);
66 static char *s_chtml40_start_h1_tag (void *pdoc, Node *node);
67 static char *s_chtml40_end_h1_tag (void *pdoc, Node *node);
68 static char *s_chtml40_start_h2_tag (void *pdoc, Node *node);
69 static char *s_chtml40_end_h2_tag (void *pdoc, Node *node);
70 static char *s_chtml40_start_h3_tag (void *pdoc, Node *node);
71 static char *s_chtml40_end_h3_tag (void *pdoc, Node *node);
72 static char *s_chtml40_start_h4_tag (void *pdoc, Node *node);
73 static char *s_chtml40_end_h4_tag (void *pdoc, Node *node);
74 static char *s_chtml40_start_h5_tag (void *pdoc, Node *node);
75 static char *s_chtml40_end_h5_tag (void *pdoc, Node *node);
76 static char *s_chtml40_start_h6_tag (void *pdoc, Node *node);
77 static char *s_chtml40_end_h6_tag (void *pdoc, Node *node);
78 static char *s_chtml40_start_ul_tag (void *pdoc, Node *node);
79 static char *s_chtml40_end_ul_tag (void *pdoc, Node *node);
80 static char *s_chtml40_start_ol_tag (void *pdoc, Node *node);
81 static char *s_chtml40_end_ol_tag (void *pdoc, Node *node);
82 static char *s_chtml40_start_li_tag (void *pdoc, Node *node);
83 static char *s_chtml40_end_li_tag (void *pdoc, Node *node);
84 static char *s_chtml40_start_head_tag (void *pdoc, Node *node);
85 static char *s_chtml40_end_head_tag (void *pdoc, Node *node);
86 static char *s_chtml40_start_title_tag (void *pdoc, Node *node);
87 static char *s_chtml40_end_title_tag (void *pdoc, Node *node);
88 static char *s_chtml40_start_base_tag (void *pdoc, Node *node);
89 static char *s_chtml40_end_base_tag (void *pdoc, Node *node);
90 static char *s_chtml40_start_body_tag (void *pdoc, Node *node);
91 static char *s_chtml40_end_body_tag (void *pdoc, Node *node);
92 static char *s_chtml40_start_a_tag (void *pdoc, Node *node);
93 static char *s_chtml40_end_a_tag (void *pdoc, Node *node);
94 static char *s_chtml40_start_br_tag (void *pdoc, Node *node);
95 static char *s_chtml40_end_br_tag (void *pdoc, Node *node);
96 static char *s_chtml40_start_tr_tag (void *pdoc, Node *node);
97 static char *s_chtml40_end_tr_tag (void *pdoc, Node *node);
98 static char *s_chtml40_start_font_tag (void *pdoc, Node *node);
99 static char *s_chtml40_end_font_tag (void *pdoc, Node *node);
100 static char *s_chtml40_start_form_tag (void *pdoc, Node *node);
101 static char *s_chtml40_end_form_tag (void *pdoc, Node *node);
102 static char *s_chtml40_start_input_tag (void *pdoc, Node *node);
103 static char *s_chtml40_end_input_tag (void *pdoc, Node *node);
104 static char *s_chtml40_start_center_tag (void *pdoc, Node *node);
105 static char *s_chtml40_end_center_tag (void *pdoc, Node *node);
106 static char *s_chtml40_start_hr_tag (void *pdoc, Node *node);
107 static char *s_chtml40_end_hr_tag (void *pdoc, Node *node);
108 static char *s_chtml40_start_img_tag (void *pdoc, Node *node);
109 static char *s_chtml40_end_img_tag (void *pdoc, Node *node);
110 static char *s_chtml40_start_select_tag (void *pdoc, Node *node);
111 static char *s_chtml40_end_select_tag (void *pdoc, Node *node);
112 static char *s_chtml40_start_option_tag (void *pdoc, Node *node);
113 static char *s_chtml40_end_option_tag (void *pdoc, Node *node);
114 static char *s_chtml40_start_div_tag (void *pdoc, Node *node);
115 static char *s_chtml40_end_div_tag (void *pdoc, Node *node);
116 static char *s_chtml40_chxjif_tag (void *pdoc, Node *node);
117 static char *s_chtml40_text_tag (void *pdoc, Node *node);
118 static char *s_chtml40_start_blockquote_tag (void *pdoc, Node *node);
119 static char *s_chtml40_end_blockquote_tag (void *pdoc, Node *node);
120 static char *s_chtml40_start_dir_tag (void *pdoc, Node *node);
121 static char *s_chtml40_end_dir_tag (void *pdoc, Node *node);
122 static char *s_chtml40_start_dl_tag (void *pdoc, Node *node);
123 static char *s_chtml40_end_dl_tag (void *pdoc, Node *node);
124 static char *s_chtml40_start_dt_tag (void *pdoc, Node *node);
125 static char *s_chtml40_end_dt_tag (void *pdoc, Node *node);
126 static char *s_chtml40_start_dd_tag (void *pdoc, Node *node);
127 static char *s_chtml40_end_dd_tag (void *pdoc, Node *node);
128 static char *s_chtml40_start_marquee_tag (void *pdoc, Node *node);
129 static char *s_chtml40_end_marquee_tag (void *pdoc, Node *node);
130 static char *s_chtml40_start_blink_tag (void *pdoc, Node *node);
131 static char *s_chtml40_end_blink_tag (void *pdoc, Node *node);
132 static char *s_chtml40_start_menu_tag (void *pdoc, Node *node);
133 static char *s_chtml40_end_menu_tag (void *pdoc, Node *node);
134 static char *s_chtml40_start_plaintext_tag (void *pdoc, Node *node);
135 static char *s_chtml40_start_plaintext_tag_inner (void *pdoc, Node *node);
136 static char *s_chtml40_end_plaintext_tag (void *pdoc, Node *node);
137 static char *s_chtml40_newline_mark (void *pdoc, Node *node);
138 static char *s_chtml40_link_tag (void *pdoc, Node *node);
139 static char *s_chtml40_start_span_tag (void *pdoc, Node *node);
140 static char *s_chtml40_end_span_tag (void *pdoc, Node *node);
141 static char *s_chtml40_style_tag (void *pdoc, Node *node);
143 static void s_init_chtml40(chtml40_t *chtml, Doc *doc, request_rec *r, device_table *spec);
145 static int s_chtml40_search_emoji(chtml40_t *chtml, char *txt, char **rslt);
146 static css_prop_list_t *s_chtml40_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
147 static css_prop_list_t *s_chtml40_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
150 tag_handler chtml40_handler[] = {
153 s_chtml40_start_html_tag,
154 s_chtml40_end_html_tag,
158 s_chtml40_start_meta_tag,
159 s_chtml40_end_meta_tag,
163 s_chtml40_start_textarea_tag,
164 s_chtml40_end_textarea_tag,
168 s_chtml40_start_p_tag,
173 s_chtml40_start_pre_tag,
174 s_chtml40_end_pre_tag,
178 s_chtml40_start_ul_tag,
179 s_chtml40_end_ul_tag,
183 s_chtml40_start_li_tag,
184 s_chtml40_end_li_tag,
188 s_chtml40_start_ol_tag,
189 s_chtml40_end_ol_tag,
193 s_chtml40_start_h1_tag,
194 s_chtml40_end_h1_tag,
198 s_chtml40_start_h2_tag,
199 s_chtml40_end_h2_tag,
203 s_chtml40_start_h3_tag,
204 s_chtml40_end_h3_tag,
208 s_chtml40_start_h4_tag,
209 s_chtml40_end_h4_tag,
213 s_chtml40_start_h5_tag,
214 s_chtml40_end_h5_tag,
218 s_chtml40_start_h6_tag,
219 s_chtml40_end_h6_tag,
223 s_chtml40_start_head_tag,
224 s_chtml40_end_head_tag,
228 s_chtml40_start_title_tag,
229 s_chtml40_end_title_tag,
233 s_chtml40_start_base_tag,
234 s_chtml40_end_base_tag,
238 s_chtml40_start_body_tag,
239 s_chtml40_end_body_tag,
243 s_chtml40_start_a_tag,
248 s_chtml40_start_br_tag,
249 s_chtml40_end_br_tag,
258 s_chtml40_start_tr_tag,
259 s_chtml40_end_tr_tag,
273 s_chtml40_start_font_tag,
274 s_chtml40_end_font_tag,
278 s_chtml40_start_form_tag,
279 s_chtml40_end_form_tag,
283 s_chtml40_start_input_tag,
284 s_chtml40_end_input_tag,
288 s_chtml40_start_center_tag,
289 s_chtml40_end_center_tag,
293 s_chtml40_start_hr_tag,
294 s_chtml40_end_hr_tag,
298 s_chtml40_start_img_tag,
299 s_chtml40_end_img_tag,
303 s_chtml40_start_select_tag,
304 s_chtml40_end_select_tag,
308 s_chtml40_start_option_tag,
309 s_chtml40_end_option_tag,
313 s_chtml40_start_div_tag,
314 s_chtml40_end_div_tag,
318 s_chtml40_chxjif_tag,
338 s_chtml40_start_span_tag,
339 s_chtml40_end_span_tag,
363 s_chtml40_start_dt_tag,
364 s_chtml40_end_dt_tag,
378 s_chtml40_start_blockquote_tag,
379 s_chtml40_end_blockquote_tag,
383 s_chtml40_start_dir_tag,
384 s_chtml40_end_dir_tag,
388 s_chtml40_start_dl_tag,
389 s_chtml40_end_dl_tag,
393 s_chtml40_start_dd_tag,
394 s_chtml40_end_dd_tag,
398 s_chtml40_start_menu_tag,
399 s_chtml40_end_menu_tag,
403 s_chtml40_start_plaintext_tag,
404 s_chtml40_end_plaintext_tag,
408 s_chtml40_start_blink_tag,
409 s_chtml40_end_blink_tag,
413 s_chtml40_start_marquee_tag,
414 s_chtml40_end_marquee_tag,
423 s_chtml40_newline_mark,
430 * converts from CHTML5.0 to CHTML3.0.
432 * @param r [i] Requet_rec is appointed.
433 * @param spec [i] The result of the device specification processing which
434 * was done in advance is appointed.
435 * @param src [i] The character string before the converting is appointed.
436 * @return The character string after the converting is returned.
439 chxj_convert_chtml40(
445 chxjconvrule_entry *entryp,
454 DBG(r, "start chxj_convert_chtml40()");
456 /*--------------------------------------------------------------------------*/
458 /*--------------------------------------------------------------------------*/
460 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
462 DBG(r,"i found qrcode xml");
463 DBG(r, "end chxj_convert_chtml40()");
466 DBG(r,"not found qrcode xml");
468 /*--------------------------------------------------------------------------*/
469 /* The CHTML structure is initialized. */
470 /*--------------------------------------------------------------------------*/
471 s_init_chtml40(&chtml40, &doc, r, spec);
473 chtml40.entryp = entryp;
474 chtml40.cookie = cookie;
476 chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
478 /*--------------------------------------------------------------------------*/
479 /* The character string of the input is analyzed. */
480 /*--------------------------------------------------------------------------*/
481 qs_init_malloc(&doc);
482 qs_init_root_node(&doc);
484 ss = apr_pcalloc(r->pool, srclen + 1);
485 memset(ss, 0, srclen + 1);
486 memcpy(ss, src, srclen);
489 chxj_dump_out("[src] CHTML -> CHTML4.0", ss, srclen);
491 if (IS_CSS_ON(chtml40.entryp)) {
492 /* current property list */
493 chtml40.css_prop_stack = chxj_new_prop_list_stack(&doc);
496 chxj_buffered_write_init(r->pool, &doc.buf);
498 qs_parse_string(&doc,ss, strlen(ss));
500 /*--------------------------------------------------------------------------*/
501 /* It converts it from CHTML to CHTML. */
502 /*--------------------------------------------------------------------------*/
503 chxj_node_convert(spec,r,(void*)&chtml40, &doc, qs_get_root(&doc), 0);
504 chtml40.out = chxj_buffered_write_flush(chtml40.out, &doc.buf);
505 dst = apr_pstrdup(r->pool, chtml40.out);
506 chxj_buffered_write_terminate(&doc.buf);
508 qs_all_free(&doc,QX_LOGMARK);
511 dst = apr_pstrdup(r->pool,ss);
513 if (strlen(dst) == 0) {
514 dst = apr_psprintf(r->pool, "\n");
517 *dstlen = strlen(dst);
520 chxj_dump_out("[src] CHTML -> CHTML4.0", dst, *dstlen);
523 DBG(r, "end chxj_convert_chtml40()");
529 * The CHTML structure is initialized.
531 * @param chtml40 [i/o] The pointer to the HDML structure that wants to be
532 * initialized is specified.
533 * @param doc [i] The Doc structure that should be set to the initialized
534 * HDML structure is specified.
535 * @param r [i] To use POOL, the pointer to request_rec is specified.
536 * @param spec [i] The pointer to the device_table
539 s_init_chtml40(chtml40_t *chtml40, Doc *doc, request_rec *r, device_table *spec)
541 memset(doc, 0, sizeof(Doc));
542 memset(chtml40, 0, sizeof(chtml40_t));
546 chtml40->spec = spec;
547 chtml40->out = qs_alloc_zero_byte_string(r->pool);
548 chtml40->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
549 chtml40->doc->parse_mode = PARSE_MODE_CHTML;
554 * Corresponding EMOJI to a current character-code is retrieved.
555 * The substitution character string is stored in the rslt pointer if agreeing.
557 * @param chtml40 [i] The pointer to the CHTML structure is specified.
558 * @param txt [i] The character string to want to examine whether it is
559 * EMOJI is specified.
560 * @param rslt [o] The pointer to the pointer that stores the result is
562 * @return When corresponding EMOJI exists, it returns it excluding 0.
565 s_chtml40_search_emoji(chtml40_t *chtml40, char *txt, char **rslt)
572 spec = chtml40->spec;
578 DBG(r,"spec is NULL");
581 for (ee = chtml40->conf->emoji;
584 if (ee->imode == NULL) {
585 DBG(r, "emoji->imode is NULL");
589 if (ee->imode->string != NULL
590 && strlen(ee->imode->string) > 0
591 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
593 if (spec == NULL || spec->emoji_type == NULL) {
594 *rslt = apr_palloc(r->pool, 3);
595 (*rslt)[0] = ee->imode->hex1byte & 0xff;
596 (*rslt)[1] = ee->imode->hex2byte & 0xff;
598 return strlen(ee->imode->string);
610 chxj_chtml40_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
621 chtml40 = &__chtml40;
624 DBG(r, "REQ[%X] start chxj_chtml40_emoji_eonly_converter()", (apr_size_t)(unsigned int)r);
625 memset(doc, 0, sizeof(Doc));
626 memset(chtml40, 0, sizeof(chtml40_t));
630 chtml40->spec = spec;
631 chtml40->out = qs_alloc_zero_byte_string(r->pool);
632 chtml40->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
633 chtml40->doc->parse_mode = PARSE_MODE_CHTML;
635 apr_pool_create(&pool, r->pool);
637 chxj_buffered_write_init(pool, &doc->buf);
639 for (ii=0; ii<len; ii++) {
643 rtn = s_chtml40_search_emoji(chtml40, (char *)&src[ii], &out);
650 if (is_sjis_kanji(src[ii])) {
651 two_byte[0] = src[ii+0];
652 two_byte[1] = src[ii+1];
658 one_byte[0] = src[ii+0];
663 chtml40->out = chxj_buffered_write_flush(chtml40->out, &doc->buf);
665 DBG(r, "REQ[%X] end chxj_chtml40_emoji_eonly_converter()", (apr_size_t)(unsigned int)r);
671 * It is a handler who processes the HTML tag.
673 * @param pdoc [i/o] The pointer to the CHTML structure at the output
674 * destination is specified.
675 * @param node [i] The HTML tag node is specified.
676 * @return The conversion result is returned.
679 s_chtml40_start_html_tag(void *pdoc, Node *UNUSED(node))
681 chtml40_t *chtml40 = GET_CHTML40(pdoc);
682 Doc *doc = chtml40->doc;
684 /*--------------------------------------------------------------------------*/
686 /*--------------------------------------------------------------------------*/
694 * It is a handler who processes the HTML tag.
696 * @param pdoc [i/o] The pointer to the CHTML structure at the output
697 * destination is specified.
698 * @param node [i] The HTML tag node is specified.
699 * @return The conversion result is returned.
702 s_chtml40_end_html_tag(void *pdoc, Node *UNUSED(child))
704 chtml40_t *chtml40 = GET_CHTML40(pdoc);
705 Doc *doc = chtml40->doc;
713 * It is a handler who processes the META tag.
715 * @param pdoc [i/o] The pointer to the CHTML structure at the output
716 * destination is specified.
717 * @param node [i] The META tag node is specified.
718 * @return The conversion result is returned.
721 s_chtml40_start_meta_tag(void *pdoc, Node *node)
727 int content_type_flag;
730 chtml40 = GET_CHTML40(pdoc);
734 content_type_flag = 0;
738 /*--------------------------------------------------------------------------*/
740 /*--------------------------------------------------------------------------*/
741 for (attr = qs_get_attr(doc,node);
743 attr = qs_get_next_attr(doc,attr)) {
744 char *name = qs_get_attr_name(doc,attr);
745 char *value = qs_get_attr_value(doc,attr);
749 if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
750 /*----------------------------------------------------------------------*/
752 /*----------------------------------------------------------------------*/
753 W_L(" http-equiv=\"");
756 if (STRCASEEQ('c','C',"content-type", value))
757 content_type_flag = 1;
759 if (STRCASEEQ('r','R',"refresh", value))
766 if (strcasecmp(name, "content") == 0 && value && *value) {
767 if (content_type_flag) {
771 W_V(chxj_header_inf_set_content_type(r, "text/html; charset=SHIFT_JIS"));
779 buf = apr_pstrdup(r->pool, value);
780 url = strchr(buf, ';');
782 sec = apr_pstrdup(r->pool, buf);
785 url = chxj_encoding_parameter(r, url, 0);
786 url = chxj_add_cookie_parameter(r, url, chtml40->cookie);
816 * It is a handler who processes the META tag.
818 * @param pdoc [i/o] The pointer to the CHTML structure at the output
819 * destination is specified.
820 * @param node [i] The META tag node is specified.
821 * @return The conversion result is returned.
824 s_chtml40_end_meta_tag(void* pdoc, Node* UNUSED(child))
826 chtml40_t *chtml40 = GET_CHTML40(pdoc);
833 * It is a handler who processes the HEAD tag.
835 * @param pdoc [i/o] The pointer to the CHTML structure at the output
836 * destination is specified.
837 * @param node [i] The HEAD tag node is specified.
838 * @return The conversion result is returned.
841 s_chtml40_start_head_tag(void* pdoc, Node* UNUSED(node))
843 chtml40_t *chtml40 = GET_CHTML40(pdoc);
844 Doc *doc = chtml40->doc;
853 * It is a handler who processes the HEAD tag.
855 * @param pdoc [i/o] The pointer to the CHTML structure at the output
856 * destination is specified.
857 * @param node [i] The HEAD tag node is specified.
858 * @return The conversion result is returned.
861 s_chtml40_end_head_tag(void *pdoc, Node *UNUSED(node))
863 chtml40_t *chtml40 = GET_CHTML40(pdoc);
864 Doc *doc = chtml40->doc;
873 * It is a handler who processes the TITLE tag.
875 * @param pdoc [i/o] The pointer to the CHTML structure at the output
876 * destination is specified.
877 * @param node [i] The TITLE tag node is specified.
878 * @return The conversion result is returned.
881 s_chtml40_start_title_tag(void *pdoc, Node *UNUSED(node))
883 chtml40_t *chtml40 = GET_CHTML40(pdoc);
884 Doc *doc = chtml40->doc;
893 * It is a handler who processes the TITLE tag.
895 * @param pdoc [i/o] The pointer to the CHTML structure at the output
896 * destination is specified.
897 * @param node [i] The TITLE tag node is specified.
898 * @return The conversion result is returned.
901 s_chtml40_end_title_tag(void *pdoc, Node *UNUSED(child))
903 chtml40_t *chtml40 = GET_CHTML40(pdoc);
904 Doc *doc = chtml40->doc;
913 * It is a handler who processes the BASE tag.
915 * @param pdoc [i/o] The pointer to the CHTML structure at the output
916 * destination is specified.
917 * @param node [i] The BASE tag node is specified.
918 * @return The conversion result is returned.
921 s_chtml40_start_base_tag(void *pdoc, Node *node)
928 chtml40 = GET_CHTML40(pdoc);
933 /*--------------------------------------------------------------------------*/
935 /*--------------------------------------------------------------------------*/
936 for (attr = qs_get_attr(doc,node);
938 attr = qs_get_next_attr(doc,attr)) {
939 char *name = qs_get_attr_name(doc,attr);
940 char *value = qs_get_attr_value(doc,attr);
941 if (STRCASEEQ('h','H',"href", name)) {
954 * It is a handler who processes the BASE tag.
956 * @param pdoc [i/o] The pointer to the CHTML structure at the output
957 * destination is specified.
958 * @param node [i] The BASE tag node is specified.
959 * @return The conversion result is returned.
962 s_chtml40_end_base_tag(void *pdoc, Node *UNUSED(child))
964 chtml40_t *chtml40 = GET_CHTML40(pdoc);
971 * It is a handler who processes the BODY tag.
973 * @param pdoc [i/o] The pointer to the CHTML structure at the output
974 * destination is specified.
975 * @param node [i] The BODY tag node is specified.
976 * @return The conversion result is returned.
979 s_chtml40_start_body_tag(void *pdoc, Node *node)
985 char *attr_bgcolor = NULL;
986 char *attr_text = NULL;
987 char *attr_link = NULL;
988 char *attr_style = NULL;
989 char *attr_alink = NULL;
990 char *attr_vlink = NULL;
993 chtml40 = GET_CHTML40(pdoc);
997 /*--------------------------------------------------------------------------*/
999 /*--------------------------------------------------------------------------*/
1000 for (attr = qs_get_attr(doc,node);
1002 attr = qs_get_next_attr(doc,attr)) {
1003 char *name = qs_get_attr_name(doc,attr);
1004 char *value = qs_get_attr_value(doc,attr);
1005 if (STRCASEEQ('b','B', "bgcolor", name) && value && *value) {
1006 /*----------------------------------------------------------------------*/
1008 /*----------------------------------------------------------------------*/
1009 attr_bgcolor = value;
1011 else if (STRCASEEQ('t','T', "text", name) && value && *value) {
1012 /*----------------------------------------------------------------------*/
1014 /*----------------------------------------------------------------------*/
1017 else if (STRCASEEQ('l','L',"link", name) && value && *value) {
1018 /*----------------------------------------------------------------------*/
1020 /*----------------------------------------------------------------------*/
1023 else if (STRCASEEQ('a','A',"alink", name) && value && *value) {
1024 /*----------------------------------------------------------------------*/
1026 /*----------------------------------------------------------------------*/
1029 else if (STRCASEEQ('v','V',"vlink", name) && value && *value) {
1030 /*----------------------------------------------------------------------*/
1032 /*----------------------------------------------------------------------*/
1035 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1040 if (IS_CSS_ON(chtml40->entryp)) {
1041 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1043 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1044 css_property_t *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
1045 css_property_t *cur;
1046 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1047 if (cur->value && *cur->value) {
1048 attr_text = apr_pstrdup(doc->pool, cur->value);
1051 for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
1052 if (cur->value && *cur->value) {
1053 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
1057 if (chtml40->style) {
1058 css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, chtml40->style);
1059 css_selector_t *cur_sel;
1060 for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
1061 if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
1062 css_property_t *cur;
1063 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1064 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1065 attr_link = apr_pstrdup(doc->pool, cur->value);
1069 else if (cur_sel->name && strcasecmp(cur_sel->name, "a:visited") == 0) {
1070 css_property_t *cur;
1071 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1072 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1073 attr_vlink = apr_pstrdup(doc->pool, cur->value);
1077 else if (cur_sel->name && strcasecmp(cur_sel->name, "a:focus") == 0) {
1078 css_property_t *cur;
1079 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1080 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1081 attr_alink = apr_pstrdup(doc->pool, cur->value);
1091 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
1097 attr_text = chxj_css_rgb_func_to_value(doc->pool, attr_text);
1103 attr_link = chxj_css_rgb_func_to_value(doc->pool, attr_link);
1109 attr_alink = chxj_css_rgb_func_to_value(doc->pool, attr_alink);
1115 attr_vlink = chxj_css_rgb_func_to_value(doc->pool, attr_vlink);
1122 return chtml40->out;
1127 * It is a handler who processes the BODY tag.
1129 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1130 * destination is specified.
1131 * @param node [i] The BODY tag node is specified.
1132 * @return The conversion result is returned.
1135 s_chtml40_end_body_tag(void *pdoc, Node *UNUSED(child))
1140 chtml40 = GET_CHTML40(pdoc);
1144 if (IS_CSS_ON(chtml40->entryp)) {
1145 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1148 return chtml40->out;
1153 * It is a handler who processes the A tag.
1155 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1156 * destination is specified.
1157 * @param node [i] The A tag node is specified.
1158 * @return The conversion result is returned.
1161 s_chtml40_start_a_tag(void *pdoc, Node *node)
1167 char *attr_style = NULL;
1169 chtml40 = GET_CHTML40(pdoc);
1174 /*--------------------------------------------------------------------------*/
1175 /* Get Attributes */
1176 /*--------------------------------------------------------------------------*/
1177 for (attr = qs_get_attr(doc,node);
1179 attr = qs_get_next_attr(doc,attr)) {
1180 char *name = qs_get_attr_name(doc,attr);
1181 char *value = qs_get_attr_value(doc,attr);
1182 if (STRCASEEQ('n','N',"name", name)) {
1183 /*----------------------------------------------------------------------*/
1185 /*----------------------------------------------------------------------*/
1190 else if (STRCASEEQ('h','H',"href", name)) {
1191 /*----------------------------------------------------------------------*/
1193 /*----------------------------------------------------------------------*/
1194 value = chxj_encoding_parameter(r, value, 0);
1195 if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
1196 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
1202 else if (STRCASEEQ('a','A',"accesskey", name)) {
1203 /*----------------------------------------------------------------------*/
1205 /*----------------------------------------------------------------------*/
1206 W_L(" accesskey=\"");
1210 else if (STRCASEEQ('c','C',"cti", name)) {
1211 /*----------------------------------------------------------------------*/
1213 /*----------------------------------------------------------------------*/
1218 else if (STRCASEEQ('i','I',"ijam", name)) {
1219 /*----------------------------------------------------------------------*/
1221 /*----------------------------------------------------------------------*/
1224 else if (STRCASEEQ('u','U',"utn", name)) {
1225 /*----------------------------------------------------------------------*/
1227 /* It is special only for CHTML. */
1228 /*----------------------------------------------------------------------*/
1231 else if (STRCASEEQ('t','T',"telbook", name)) {
1232 /*----------------------------------------------------------------------*/
1234 /*----------------------------------------------------------------------*/
1237 else if (STRCASEEQ('k','K',"kana", name)) {
1238 /*----------------------------------------------------------------------*/
1240 /*----------------------------------------------------------------------*/
1243 else if (STRCASEEQ('e','E',"email", name)) {
1244 /*----------------------------------------------------------------------*/
1246 /*----------------------------------------------------------------------*/
1249 else if (STRCASEEQ('i','I',"ista", name)) {
1250 /*----------------------------------------------------------------------*/
1252 /*----------------------------------------------------------------------*/
1255 else if (STRCASEEQ('i','I',"ilet", name)) {
1256 /*----------------------------------------------------------------------*/
1258 /*----------------------------------------------------------------------*/
1261 else if (STRCASEEQ('i','I',"iswf", name)) {
1262 /*----------------------------------------------------------------------*/
1264 /*----------------------------------------------------------------------*/
1267 else if (STRCASEEQ('i','I',"irst", name)) {
1268 /*----------------------------------------------------------------------*/
1270 /*----------------------------------------------------------------------*/
1273 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1279 if (IS_CSS_ON(chtml40->entryp)) {
1280 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1283 return chtml40->out;
1288 * It is a handler who processes the A tag.
1290 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1291 * destination is specified.
1292 * @param node [i] The A tag node is specified.
1293 * @return The conversion result is returned.
1296 s_chtml40_end_a_tag(void *pdoc, Node *UNUSED(child))
1301 chtml40 = GET_CHTML40(pdoc);
1306 if (IS_CSS_ON(chtml40->entryp)) {
1307 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1310 return chtml40->out;
1315 * It is a handler who processes the BR tag.
1317 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1318 * destination is specified.
1319 * @param node [i] The BR tag node is specified.
1320 * @return The conversion result is returned.
1323 s_chtml40_start_br_tag(void *pdoc, Node *node)
1330 chtml40 = GET_CHTML40(pdoc);
1334 /*--------------------------------------------------------------------------*/
1335 /* Get Attributes */
1336 /*--------------------------------------------------------------------------*/
1337 for (attr = qs_get_attr(doc,node);
1339 attr = qs_get_next_attr(doc,attr)) {
1340 char *name = qs_get_attr_name(doc,attr);
1341 char *value = qs_get_attr_value(doc,attr);
1342 if (STRCASEEQ('c','C',"clear",name)) {
1343 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1352 return chtml40->out;
1357 * It is a handler who processes the BR tag.
1359 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1360 * destination is specified.
1361 * @param node [i] The BR tag node is specified.
1362 * @return The conversion result is returned.
1365 s_chtml40_end_br_tag(void *pdoc, Node *UNUSED(child))
1367 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1369 return chtml40->out;
1374 * It is a handler who processes the TR tag.
1376 * @param chtml40 [i/o] The pointer to the CHTML structure at the output
1377 * destination is specified.
1378 * @param node [i] The TR tag node is specified.
1379 * @return The conversion result is returned.
1382 s_chtml40_start_tr_tag(void *pdoc, Node *UNUSED(node))
1384 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1386 return chtml40->out;
1391 * It is a handler who processes the TR tag.
1393 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1394 * destination is specified.
1395 * @param node [i] The TR tag node is specified.
1396 * @return The conversion result is returned.
1399 s_chtml40_end_tr_tag(void *pdoc, Node *UNUSED(child))
1405 chtml40 = GET_CHTML40(pdoc);
1411 return chtml40->out;
1416 * It is a handler who processes the FONT tag.
1418 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1419 * destination is specified.
1420 * @param node [i] The FONT tag node is specified.
1421 * @return The conversion result is returned.
1424 s_chtml40_start_font_tag(void *pdoc, Node *node)
1430 char *attr_color = NULL;
1431 char *attr_style = NULL;
1433 chtml40 = GET_CHTML40(pdoc);
1437 /*--------------------------------------------------------------------------*/
1438 /* Get Attributes */
1439 /*--------------------------------------------------------------------------*/
1440 for (attr = qs_get_attr(doc,node);
1442 attr = qs_get_next_attr(doc,attr)) {
1443 char *name = qs_get_attr_name(doc,attr);
1444 char *value = qs_get_attr_value(doc,attr);
1445 if (STRCASEEQ('c','C',"color", name) && value && *value) {
1446 attr_color = apr_pstrdup(doc->buf.pool, value);
1449 else if (STRCASEEQ('s','S',"size", name)) {
1450 /*----------------------------------------------------------------------*/
1452 /*----------------------------------------------------------------------*/
1455 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1459 if (IS_CSS_ON(chtml40->entryp)) {
1460 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1462 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1463 css_property_t *cur;
1464 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1465 if (cur->value && *cur->value) {
1466 attr_color = apr_pstrdup(doc->pool, cur->value);
1472 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1473 W_L("<font color=\"");
1476 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(*flg));
1477 flg->with_font_flag = 1;
1478 node->userData = flg;
1481 node->userData = NULL;
1483 return chtml40->out;
1488 * It is a handler who processes the FONT tag.
1490 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1491 * destination is specified.
1492 * @param node [i] The FONT tag node is specified.
1493 * @return The conversion result is returned.
1496 s_chtml40_end_font_tag(void *pdoc, Node *node)
1502 chtml40 = GET_CHTML40(pdoc);
1506 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1507 if (flg && flg->with_font_flag) {
1510 if (IS_CSS_ON(chtml40->entryp)) {
1511 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1514 return chtml40->out;
1519 * It is a handler who processes the FORM tag.
1521 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1522 * destination is specified.
1523 * @param node [i] The FORM tag node is specified.
1524 * @return The conversion result is returned.
1527 s_chtml40_start_form_tag(void *pdoc, Node *node)
1533 char *attr_action = NULL;
1534 char *attr_method = NULL;
1535 char *attr_style = NULL;
1536 char *attr_color = NULL;
1537 char *attr_align = NULL;
1538 char *attr_utn = NULL;
1539 char *new_hidden_tag = NULL;
1541 chtml40 = GET_CHTML40(pdoc);
1545 /*--------------------------------------------------------------------------*/
1546 /* Get Attributes */
1547 /*--------------------------------------------------------------------------*/
1548 for (attr = qs_get_attr(doc,node);
1550 attr = qs_get_next_attr(doc,attr)) {
1551 char *name = qs_get_attr_name(doc,attr);
1552 char *value = qs_get_attr_value(doc,attr);
1556 if (strcasecmp(name, "action") == 0) {
1557 /*--------------------------------------------------------------------*/
1559 /*--------------------------------------------------------------------*/
1560 attr_action = value;
1566 if (strcasecmp(name, "method") == 0) {
1567 /*--------------------------------------------------------------------*/
1569 /*--------------------------------------------------------------------*/
1570 attr_method = value;
1576 if (strcasecmp(name, "utn") == 0) {
1577 /*--------------------------------------------------------------------*/
1579 /*--------------------------------------------------------------------*/
1586 if (strcasecmp(name, "style") == 0) {
1595 if (IS_CSS_ON(chtml40->entryp)) {
1596 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1598 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
1599 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1600 css_property_t *cur;
1601 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
1602 if (STRCASEEQ('l','L',"left", cur->value)) {
1603 attr_align = apr_pstrdup(doc->pool, "left");
1605 else if (STRCASEEQ('c','C',"center",cur->value)) {
1606 attr_align = apr_pstrdup(doc->pool, "center");
1608 else if (STRCASEEQ('r','R',"right",cur->value)) {
1609 attr_align = apr_pstrdup(doc->pool, "right");
1612 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1613 attr_color = apr_pstrdup(doc->pool, cur->value);
1618 int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1622 attr_action = chxj_encoding_parameter(r, attr_action, 0);
1623 attr_action = chxj_add_cookie_parameter(r, attr_action, chtml40->cookie);
1625 char *new_query_string = NULL;
1626 q = strchr(attr_action, '?');
1628 new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE, CHXJ_FALSE, chtml40->entryp);
1629 if (new_hidden_tag || new_query_string) {
1635 if (new_query_string) {
1637 W_V(new_query_string);
1650 if (new_hidden_tag) {
1651 W_V(new_hidden_tag);
1654 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
1655 memset(flg, 0, sizeof(*flg));
1657 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1658 W_L("<font color=\"");
1661 flg->with_font_flag = 1;
1664 W_L("<div align=\"");
1667 flg->with_div_flag = 1;
1669 node->userData = flg;
1671 return chtml40->out;
1676 * It is a handler who processes the FORM tag.
1678 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1679 * destination is specified.
1680 * @param node [i] The FORM tag node is specified.
1681 * @return The conversion result is returned.
1684 s_chtml40_end_form_tag(void *pdoc, Node *node)
1689 chtml40 = GET_CHTML40(pdoc);
1692 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1693 if (flg && flg->with_div_flag) {
1696 if (flg && flg->with_font_flag) {
1700 if (IS_CSS_ON(chtml40->entryp)) {
1701 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1704 return chtml40->out;
1709 * It is a handler who processes the INPUT tag.
1711 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1712 * destination is specified.
1713 * @param node [i] The INPUT tag node is specified.
1714 * @return The conversion result is returned.
1717 s_chtml40_start_input_tag(void *pdoc, Node *node)
1723 char *attr_accesskey = NULL;
1724 char *attr_max_length = NULL;
1725 char *attr_type = NULL;
1726 char *attr_name = NULL;
1727 char *attr_value = NULL;
1728 char *attr_istyle = NULL;
1729 char *attr_size = NULL;
1730 char *attr_checked = NULL;
1731 char *attr_style = NULL;
1733 chtml40 = GET_CHTML40(pdoc);
1737 /*--------------------------------------------------------------------------*/
1738 /* Get Attributes */
1739 /*--------------------------------------------------------------------------*/
1740 for (attr = qs_get_attr(doc,node);
1742 attr = qs_get_next_attr(doc,attr)) {
1743 char *name = qs_get_attr_name(doc,attr);
1744 char *value = qs_get_attr_value(doc,attr);
1745 if (STRCASEEQ('t','T',"type",name) && value && *value) {
1746 char *tmp_type = qs_trim_string(doc->buf.pool, value);
1747 if (tmp_type && (STRCASEEQ('t','T',"text", tmp_type) ||
1748 STRCASEEQ('p','P',"password",tmp_type) ||
1749 STRCASEEQ('c','C',"checkbox",tmp_type) ||
1750 STRCASEEQ('r','R',"radio", tmp_type) ||
1751 STRCASEEQ('h','H',"hidden", tmp_type) ||
1752 STRCASEEQ('s','S',"submit", tmp_type) ||
1753 STRCASEEQ('r','R',"reset", tmp_type))) {
1754 attr_type = tmp_type;
1757 else if (STRCASEEQ('n','N',"name",name) && value && *value) {
1760 else if (STRCASEEQ('v','V',"value",name) && value && *value) {
1763 else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
1764 attr_istyle = value;
1766 else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
1767 attr_max_length = value;
1769 else if (STRCASEEQ('c','C',"checked", name)) {
1770 attr_checked = value;
1772 else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
1773 attr_accesskey = value;
1775 else if (STRCASEEQ('s','S',"size", name) && value && *value) {
1778 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1783 if (IS_CSS_ON(chtml40->entryp)) {
1784 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
1786 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
1787 css_property_t *cur;
1788 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
1789 if (strcasestr(cur->value, "<ja:n>")) {
1792 else if (strcasestr(cur->value, "<ja:en>")) {
1795 else if (strcasestr(cur->value, "<ja:hk>")) {
1798 else if (strcasestr(cur->value, "<ja:h>")) {
1823 W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
1826 if (attr_accesskey) {
1827 W_L(" accesskey=\"");
1828 W_V(attr_accesskey);
1832 if (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4') {
1838 /*--------------------------------------------------------------------------*/
1839 /* The figure is default for the password. */
1840 /*--------------------------------------------------------------------------*/
1841 if (attr_max_length) {
1842 if (chxj_chk_numeric(attr_max_length) != 0) {
1843 attr_max_length = apr_psprintf(doc->buf.pool, "0");
1845 if (attr_istyle && *attr_istyle == '1') {
1846 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length) * 2);
1850 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length));
1859 return chtml40->out;
1864 * It is a handler who processes the INPUT tag.
1866 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1867 * destination is specified.
1868 * @param node [i] The INPUT tag node is specified.
1869 * @return The conversion result is returned.
1872 s_chtml40_end_input_tag(void *pdoc, Node *UNUSED(child))
1874 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1876 return chtml40->out;
1881 * It is a handler who processes the CENTER tag.
1883 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1884 * destination is specified.
1885 * @param node [i] The CENTER tag node is specified.
1886 * @return The conversion result is returned.
1889 s_chtml40_start_center_tag(void *pdoc, Node *node)
1894 char *attr_style = NULL;
1895 char *attr_color = NULL;
1897 chtml40 = GET_CHTML40(pdoc);
1900 for (attr = qs_get_attr(doc,node);
1902 attr = qs_get_next_attr(doc,attr)) {
1903 char *name = qs_get_attr_name(doc,attr);
1904 char *value = qs_get_attr_value(doc,attr);
1905 if (STRCASEEQ('s','S',"style",name) && value && *value) {
1909 if (IS_CSS_ON(chtml40->entryp)) {
1910 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1912 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1913 css_property_t *cur;
1914 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1915 if (cur->value && *cur->value) {
1916 attr_color = apr_pstrdup(doc->pool, cur->value);
1923 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
1924 memset(flg, 0, sizeof(*flg));
1926 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1927 W_L("<font color=\"");
1930 flg->with_font_flag = 1;
1932 node->userData = flg;
1934 return chtml40->out;
1939 * It is a handler who processes the CENTER tag.
1941 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1942 * destination is specified.
1943 * @param node [i] The CENTER tag node is specified.
1944 * @return The conversion result is returned.
1947 s_chtml40_end_center_tag(void *pdoc, Node *node)
1952 chtml40 = GET_CHTML40(pdoc);
1955 if (IS_CSS_ON(chtml40->entryp)) {
1956 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1958 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1959 if (flg && flg->with_font_flag) {
1964 return chtml40->out;
1969 * It is a handler who processes the HR tag.
1971 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1972 * destination is specified.
1973 * @param node [i] The HR tag node is specified.
1974 * @return The conversion result is returned.
1977 s_chtml40_start_hr_tag(void *pdoc, Node *node)
1983 char *attr_align = NULL;
1984 char *attr_size = NULL;
1985 char *attr_width = NULL;
1986 char *attr_noshade = NULL;
1987 char *attr_style = NULL;
1988 char *attr_color = NULL;
1990 chtml40 = GET_CHTML40(pdoc);
1994 for (attr = qs_get_attr(doc,node);
1996 attr = qs_get_next_attr(doc,attr)) {
1997 char *name = qs_get_attr_name (doc,attr);
1998 char *value = qs_get_attr_value(doc,attr);
2002 if (strcasecmp(name, "align") == 0) {
2003 /*--------------------------------------------------------------------*/
2005 /*--------------------------------------------------------------------*/
2006 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2014 if (strcasecmp(name, "size") == 0) {
2015 /*--------------------------------------------------------------------*/
2017 /*--------------------------------------------------------------------*/
2018 if (value && *value) {
2022 else if (strcasecmp(name, "style") == 0) {
2023 if (value && *value) {
2031 if (strcasecmp(name, "width") == 0) {
2032 /*--------------------------------------------------------------------*/
2034 /*--------------------------------------------------------------------*/
2035 if (value && *value) {
2043 if (strcasecmp(name, "noshade") == 0) {
2044 /*--------------------------------------------------------------------*/
2046 /*--------------------------------------------------------------------*/
2047 attr_noshade = apr_pstrdup(doc->pool, "noshade");
2053 if (strcasecmp(name, "color") == 0 && value && *value) {
2054 /*--------------------------------------------------------------------*/
2056 /*--------------------------------------------------------------------*/
2065 if (IS_CSS_ON(chtml40->entryp)) {
2066 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2068 css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2069 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2070 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2071 css_property_t *cur;
2072 for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2073 if (STRCASEEQ('s','S',"solid",cur->value)) {
2074 attr_noshade = "noshade";
2077 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2078 char *tmp = apr_pstrdup(doc->pool, cur->value);
2079 char *tmpp = strstr(tmp, "px");
2082 attr_size = apr_pstrdup(doc->pool, tmp);
2085 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2086 char *tmp = apr_pstrdup(doc->pool, cur->value);
2087 char *tmpp = strstr(tmp, "px");
2090 attr_width = apr_pstrdup(doc->pool, tmp);
2093 tmpp = strstr(tmp, "%");
2095 attr_width = apr_pstrdup(doc->pool, tmp);
2126 return chtml40->out;
2131 * It is a handler who processes the HR tag.
2133 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2134 * destination is specified.
2135 * @param node [i] The HR tag node is specified.
2136 * @return The conversion result is returned.
2139 s_chtml40_end_hr_tag(void *pdoc, Node *UNUSED(child))
2141 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2143 return chtml40->out;
2148 * It is a handler who processes the IMG tag.
2150 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2151 * destination is specified.
2152 * @param node [i] The IMG tag node is specified.
2153 * @return The conversion result is returned.
2156 s_chtml40_start_img_tag(void *pdoc, Node *node)
2162 char *attr_src = NULL;
2163 char *attr_align = NULL;
2164 char *attr_style = NULL;
2165 char *attr_alt = NULL;
2166 char *attr_width = NULL;
2167 char *attr_height = NULL;
2168 char *attr_hspace = NULL;
2169 char *attr_vspace = NULL;
2170 #ifndef IMG_NOT_CONVERT_FILENAME
2174 chtml40 = GET_CHTML40(pdoc);
2175 #ifndef IMG_NOT_CONVERT_FILENAME
2176 spec = chtml40->spec;
2181 /*--------------------------------------------------------------------------*/
2182 /* Get Attributes */
2183 /*--------------------------------------------------------------------------*/
2184 for (attr = qs_get_attr(doc,node);
2186 attr = qs_get_next_attr(doc,attr)) {
2187 char *name = qs_get_attr_name (doc,attr);
2188 char *value = qs_get_attr_value(doc,attr);
2192 if (strcasecmp(name, "src") == 0) {
2193 /*--------------------------------------------------------------------*/
2195 /*--------------------------------------------------------------------*/
2196 #ifdef IMG_NOT_CONVERT_FILENAME
2197 value = chxj_encoding_parameter(r, value, 0);
2198 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
2199 value = chxj_add_cookie_no_update_parameter(r, value);
2202 value = chxj_img_conv(r,spec,value);
2203 value = chxj_encoding_parameter(r, value, 0);
2204 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
2205 value = chxj_add_cookie_no_update_parameter(r, value);
2209 else if (strcasecmp(name,"style") == 0 && value && *value) {
2216 if (strcasecmp(name, "align" ) == 0) {
2217 /*--------------------------------------------------------------------*/
2219 /*--------------------------------------------------------------------*/
2220 /*--------------------------------------------------------------------*/
2222 /*--------------------------------------------------------------------*/
2224 if (STRCASEEQ('t','T',"top", value) ||
2225 STRCASEEQ('m','M',"middle",value) ||
2226 STRCASEEQ('b','B',"bottom",value) ||
2227 STRCASEEQ('l','L',"left", value) ||
2228 STRCASEEQ('r','R',"right", value)) {
2231 else if (STRCASEEQ('c','C',"center", value)) {
2232 attr_align = apr_pstrdup(doc->pool, "middle");
2236 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2237 /*--------------------------------------------------------------------*/
2239 /*--------------------------------------------------------------------*/
2246 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2247 /*--------------------------------------------------------------------*/
2249 /*--------------------------------------------------------------------*/
2256 if (strcasecmp(name, "height") == 0 && value && *value) {
2257 /*--------------------------------------------------------------------*/
2259 /*--------------------------------------------------------------------*/
2260 attr_height = value;
2263 if (strcasecmp(name, "hspace") == 0 && value && *value) {
2264 /*--------------------------------------------------------------------*/
2266 /*--------------------------------------------------------------------*/
2267 attr_hspace = value;
2273 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2274 /*--------------------------------------------------------------------*/
2276 /*--------------------------------------------------------------------*/
2277 attr_vspace = value;
2286 if (IS_CSS_ON(chtml40->entryp)) {
2287 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2289 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2290 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2291 css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
2292 css_property_t *cur;
2293 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2294 attr_height = apr_pstrdup(doc->pool, cur->value);
2296 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2297 attr_width = apr_pstrdup(doc->pool, cur->value);
2299 for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
2300 attr_align = apr_pstrdup(doc->pool, cur->value);
2342 return chtml40->out;
2347 * It is a handler who processes the IMG tag.
2349 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2350 * destination is specified.
2351 * @param node [i] The IMG tag node is specified.
2352 * @return The conversion result is returned.
2355 s_chtml40_end_img_tag(void *pdoc, Node *UNUSED(child))
2357 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2359 return chtml40->out;
2364 * It is a handler who processes the SELECT tag.
2366 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2367 * destination is specified.
2368 * @param node [i] The SELECT tag node is specified.
2369 * @return The conversion result is returned.
2372 s_chtml40_start_select_tag(void *pdoc, Node *node)
2374 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2375 Doc *doc = chtml40->doc;
2378 char *multiple = NULL;
2380 char *attr_style = NULL;
2383 for (attr = qs_get_attr(doc,node);
2385 attr = qs_get_next_attr(doc,attr)) {
2386 char *nm = qs_get_attr_name(doc,attr);
2387 char *val = qs_get_attr_value(doc,attr);
2388 if (STRCASEEQ('s','S',"size", nm)) {
2389 /*----------------------------------------------------------------------*/
2390 /* CHTML 1.0 version 2.0 */
2391 /*----------------------------------------------------------------------*/
2392 size = apr_pstrdup(doc->buf.pool, val);
2394 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2395 /*----------------------------------------------------------------------*/
2396 /* CHTML 1.0 version 2.0 */
2397 /*----------------------------------------------------------------------*/
2398 attr_style = apr_pstrdup(doc->buf.pool, val);
2400 else if (STRCASEEQ('n','N',"name", nm)) {
2401 /*----------------------------------------------------------------------*/
2402 /* CHTML 1.0 version 2.0 */
2403 /*----------------------------------------------------------------------*/
2404 name = apr_pstrdup(doc->buf.pool, val);
2406 else if (STRCASEEQ('m','M',"multiple", nm)) {
2407 /*----------------------------------------------------------------------*/
2408 /* CHTML 1.0 version 2.0 */
2409 /*----------------------------------------------------------------------*/
2410 multiple = apr_pstrdup(doc->buf.pool, val);
2413 if (size && *size) {
2418 if (name && *name) {
2427 if (IS_CSS_ON(chtml40->entryp)) {
2428 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2430 return chtml40->out;
2435 * It is a handler who processes the SELECT tag.
2437 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2438 * destination is specified.
2439 * @param node [i] The SELECT tag node is specified.
2440 * @return The conversion result is returned.
2443 s_chtml40_end_select_tag(void *pdoc, Node *UNUSED(child))
2445 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2446 Doc *doc = chtml40->doc;
2449 if (IS_CSS_ON(chtml40->entryp)) {
2450 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2452 return chtml40->out;
2457 * It is a handler who processes the OPTION tag.
2459 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2460 * destination is specified.
2461 * @param node [i] The OPTION tag node is specified.
2462 * @return The conversion result is returned.
2465 s_chtml40_start_option_tag(void *pdoc, Node *node)
2473 char *attr_style = NULL;
2475 chtml40 = GET_CHTML40(pdoc);
2482 for (attr = qs_get_attr(doc,node);
2484 attr = qs_get_next_attr(doc,attr)) {
2485 char *nm = qs_get_attr_name(doc,attr);
2486 char *val = qs_get_attr_value(doc,attr);
2487 if (STRCASEEQ('s','S',"selected", nm)) {
2488 /*----------------------------------------------------------------------*/
2489 /* CHTML 1.0 version 2.0 */
2490 /*----------------------------------------------------------------------*/
2491 selected = apr_pstrdup(doc->buf.pool, val);
2493 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2494 /*----------------------------------------------------------------------*/
2495 /* CHTML 1.0 version 2.0 */
2496 /*----------------------------------------------------------------------*/
2497 attr_style = apr_pstrdup(doc->buf.pool, val);
2499 else if (STRCASEEQ('v','V',"value", nm)) {
2500 /*----------------------------------------------------------------------*/
2501 /* CHTML 1.0 version 2.0 */
2502 /*----------------------------------------------------------------------*/
2503 value = apr_pstrdup(doc->buf.pool, val);
2516 if (IS_CSS_ON(chtml40->entryp)) {
2517 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2520 return chtml40->out;
2525 * It is a handler who processes the OPTION tag.
2527 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2528 * destination is specified.
2529 * @param node [i] The OPTION tag node is specified.
2530 * @return The conversion result is returned.
2533 s_chtml40_end_option_tag(void *pdoc, Node *UNUSED(child))
2535 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2538 if (IS_CSS_ON(chtml40->entryp)) {
2539 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2542 return chtml40->out;
2547 * It is a handler who processes the DIV tag.
2549 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2550 * destination is specified.
2551 * @param node [i] The DIV tag node is specified.
2552 * @return The conversion result is returned.
2555 s_chtml40_start_div_tag(void *pdoc, Node *node)
2561 char *attr_style = NULL;
2562 char *attr_align = NULL;
2563 char *attr_display = NULL;
2564 char *attr_decoration = NULL;
2565 char *attr_wap_marquee_style = NULL;
2566 char *attr_wap_marquee_dir = NULL;
2567 char *attr_wap_marquee_loop = NULL;
2568 char *attr_color = NULL;
2569 char *attr_bgcolor = NULL;
2571 chtml40 = GET_CHTML40(pdoc);
2575 for (attr = qs_get_attr(doc,node);
2577 attr = qs_get_next_attr(doc,attr)) {
2578 char *nm = qs_get_attr_name(doc,attr);
2579 char *val = qs_get_attr_value(doc,attr);
2580 if (STRCASEEQ('a','A', "align", nm)) {
2581 /*----------------------------------------------------------------------*/
2582 /* CHTML 1.0 (W3C version 3.2) */
2583 /*----------------------------------------------------------------------*/
2584 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2585 attr_align = apr_pstrdup(doc->buf.pool, val);
2588 else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
2589 attr_style = apr_pstrdup(doc->buf.pool, val);
2593 if (IS_CSS_ON(chtml40->entryp)) {
2594 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2596 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
2597 css_property_t *text_decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
2598 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
2599 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2600 css_property_t *background_color_prop = chxj_css_get_property_value(doc, style, "background-color");
2601 css_property_t *background_prop = chxj_css_get_property_value(doc, style, "background");
2603 css_property_t *cur;
2604 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
2605 if (strcasecmp("-wap-marquee", cur->value) == 0) {
2606 attr_display = apr_pstrdup(doc->pool, cur->value);
2609 for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
2610 if (STRCASEEQ('b','B',"blink", cur->value)) {
2611 attr_decoration = apr_pstrdup(doc->pool, cur->value);
2614 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2615 attr_color = apr_pstrdup(doc->pool, cur->value);
2616 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2618 for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
2619 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
2620 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
2622 for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
2623 char *ss = strchr(cur->value, '#');
2625 ss = strstr(cur->value, "rgb");
2628 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
2629 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
2632 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2633 attr_align = apr_pstrdup(doc->pool, cur->value);
2636 css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
2637 css_property_t *wap_marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
2638 css_property_t *wap_marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
2639 for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
2640 if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
2641 attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
2644 for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
2645 if (STRCASEEQ('l','L',"ltr",cur->value)) {
2646 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "right");
2648 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
2649 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "left");
2652 for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
2653 if (STRCASEEQ('i','I',"infinite",cur->value)) {
2654 attr_wap_marquee_loop = apr_pstrdup(doc->pool, "16");
2657 attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
2663 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
2664 memset(flg, 0, sizeof(*flg));
2671 flg->with_div_flag = 1;
2675 flg->with_div_flag = 1;
2678 if (attr_bgcolor && (STRCASEEQ('w','W',"white",attr_color) || STRCASEEQ('#','#',"#ffffff",attr_color))) {
2682 W_L("<font color=\"");
2685 flg->with_font_flag = 1;
2688 if (attr_decoration) {
2690 flg->with_blink_flag = 1;
2694 if (attr_wap_marquee_style) {
2695 W_L(" behavior=\"");
2696 W_V(attr_wap_marquee_style);
2699 if (attr_wap_marquee_dir) {
2700 W_L(" direction=\"");
2701 W_V(attr_wap_marquee_dir);
2704 if (attr_wap_marquee_loop) {
2706 W_V(attr_wap_marquee_loop);
2710 flg->with_marquee_flag = 1;
2712 node->userData = flg;
2714 return chtml40->out;
2719 * It is a handler who processes the DIV tag.
2721 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2722 * destination is specified.
2723 * @param node [i] The DIV tag node is specified.
2724 * @return The conversion result is returned.
2727 s_chtml40_end_div_tag(void *pdoc, Node *node)
2729 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2730 Doc *doc = chtml40->doc;
2732 chtml40_flags_t *flg = node->userData;
2733 if (flg && flg->with_marquee_flag) {
2736 if (flg && flg->with_blink_flag) {
2739 if (flg && flg->with_font_flag) {
2742 if (flg && flg->with_div_flag) {
2745 if (IS_CSS_ON(chtml40->entryp)) {
2746 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2748 node->userData = NULL;
2750 return chtml40->out;
2755 * It is a handler who processes the UL tag.
2757 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2758 * destination is specified.
2759 * @param node [i] The UL tag node is specified.
2760 * @return The conversion result is returned.
2763 s_chtml40_start_ul_tag(void *pdoc, Node *node)
2765 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2766 Doc *doc = chtml40->doc;
2768 char *attr_type = NULL;
2769 char *attr_style = NULL;
2770 /*--------------------------------------------------------------------------*/
2771 /* Get Attributes */
2772 /*--------------------------------------------------------------------------*/
2773 for (attr = qs_get_attr(doc,node);
2775 attr = qs_get_next_attr(doc,attr)) {
2776 char *name = qs_get_attr_name(doc,attr);
2777 char *value = qs_get_attr_value(doc,attr);
2778 if (STRCASEEQ('t','T',"type",name)) {
2779 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2783 else if (value && *value && STRCASEEQ('s','S',"style", name)) {
2787 if (IS_CSS_ON(chtml40->entryp)) {
2788 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2790 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2791 css_property_t *cur;
2792 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2793 if (STRCASEEQ('d','D',"disc",cur->value)) {
2794 attr_type = apr_pstrdup(doc->pool, "disc");
2796 else if (STRCASEEQ('c','C',"circle",cur->value)) {
2797 attr_type = apr_pstrdup(doc->pool, "circle");
2799 else if (STRCASEEQ('s','S',"square",cur->value)) {
2800 attr_type = apr_pstrdup(doc->pool, "square");
2813 return chtml40->out;
2818 * It is a handler who processes the UL tag.
2820 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2821 * destination is specified.
2822 * @param node [i] The UL tag node is specified.
2823 * @return The conversion result is returned.
2826 s_chtml40_end_ul_tag(void *pdoc, Node *UNUSED(child))
2828 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2829 Doc *doc = chtml40->doc;
2832 if (IS_CSS_ON(chtml40->entryp)) {
2833 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2836 return chtml40->out;
2841 * It is a handler who processes the PRE tag.
2843 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2844 * destination is specified.
2845 * @param node [i] The PRE tag node is specified.
2846 * @return The conversion result is returned.
2849 s_chtml40_start_pre_tag(void *pdoc, Node *node)
2851 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2852 Doc *doc = chtml40->doc;
2854 char *attr_style = NULL;
2856 for (attr = qs_get_attr(doc,node);
2858 attr = qs_get_next_attr(doc,attr)) {
2859 char *nm = qs_get_attr_name(doc,attr);
2860 char *val = qs_get_attr_value(doc,attr);
2861 if (val && STRCASEEQ('s','S',"style", nm)) {
2866 if (IS_CSS_ON(chtml40->entryp)) {
2867 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2870 chtml40->pre_flag++;
2873 return chtml40->out;
2878 * It is a handler who processes the PRE tag.
2880 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2881 * destination is specified.
2882 * @param node [i] The PRE tag node is specified.
2883 * @return The conversion result is returned.
2886 s_chtml40_end_pre_tag(void *pdoc, Node *UNUSED(child))
2888 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2889 Doc *doc = chtml40->doc;
2892 chtml40->pre_flag--;
2893 if (IS_CSS_ON(chtml40->entryp)) {
2894 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2897 return chtml40->out;
2902 * It is a handler who processes the P tag.
2904 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2905 * destination is specified.
2906 * @param node [i] The P tag node is specified.
2907 * @return The conversion result is returned.
2910 s_chtml40_start_p_tag(void *pdoc, Node *node)
2916 char *attr_align = NULL;
2917 char *attr_style = NULL;
2918 char *attr_color = NULL;
2919 char *attr_blink = NULL;
2921 chtml40 = GET_CHTML40(pdoc);
2925 for (attr = qs_get_attr(doc,node);
2927 attr = qs_get_next_attr(doc,attr)) {
2928 char *nm = qs_get_attr_name(doc,attr);
2929 char *val = qs_get_attr_value(doc,attr);
2930 if (STRCASEEQ('a','A',"align", nm)) {
2931 /*----------------------------------------------------------------------*/
2932 /* CHTML 1.0 (W3C version 3.2) */
2933 /*----------------------------------------------------------------------*/
2934 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2935 attr_align = apr_pstrdup(doc->buf.pool, val);
2939 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2940 attr_style = apr_pstrdup(doc->buf.pool, val);
2943 if (IS_CSS_ON(chtml40->entryp)) {
2944 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2946 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2947 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
2948 css_property_t *text_deco_prop = chxj_css_get_property_value(doc, style, "text-decoration");
2949 css_property_t *cur;
2950 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2951 if (STRCASEEQ('l','L',"left",cur->value)) {
2952 attr_align = apr_pstrdup(doc->pool, "left");
2954 else if (STRCASEEQ('c','C',"center",cur->value)) {
2955 attr_align = apr_pstrdup(doc->pool, "center");
2957 else if (STRCASEEQ('r','R',"right",cur->value)) {
2958 attr_align = apr_pstrdup(doc->pool, "right");
2961 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2962 if (cur->value && *cur->value) {
2963 attr_color = apr_pstrdup(doc->pool, cur->value);
2966 for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
2967 if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
2968 attr_blink = apr_pstrdup(doc->pool, cur->value);
2981 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
2982 memset(flg, 0, sizeof(*flg));
2984 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2985 W_L("<font color=\"");
2988 flg->with_font_flag = 1;
2992 flg->with_blink_flag = 1;
2994 node->userData = (void *)flg;
2996 return chtml40->out;
3001 * It is a handler who processes the P tag.
3003 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3004 * destination is specified.
3005 * @param node [i] The P tag node is specified.
3006 * @return The conversion result is returned.
3009 s_chtml40_end_p_tag(void *pdoc, Node *node)
3014 chtml40 = GET_CHTML40(pdoc);
3017 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
3018 if (flg->with_font_flag) {
3021 if (flg->with_blink_flag) {
3025 if (IS_CSS_ON(chtml40->entryp)) {
3026 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3029 return chtml40->out;
3034 * It is a handler who processes the OL tag.
3036 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3037 * destination is specified.
3038 * @param node [i] The OL tag node is specified.
3039 * @return The conversion result is returned.
3042 s_chtml40_start_ol_tag(void *pdoc, Node *node)
3048 char *attr_style = NULL;
3049 char *attr_start = NULL;
3050 char *attr_type = NULL;
3052 chtml40 = GET_CHTML40(pdoc);
3056 /*--------------------------------------------------------------------------*/
3057 /* Get Attributes */
3058 /*--------------------------------------------------------------------------*/
3059 for (attr = qs_get_attr(doc,node);
3061 attr = qs_get_next_attr(doc,attr)) {
3062 char *name = qs_get_attr_name(doc,attr);
3063 char *value = qs_get_attr_value(doc,attr);
3064 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
3067 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
3070 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3074 if (IS_CSS_ON(chtml40->entryp)) {
3075 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3077 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3078 css_property_t *cur;
3079 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3080 if (STRCASEEQ('d','D',"decimal", cur->value)) {
3081 attr_type = apr_pstrdup(doc->pool, "1");
3083 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3084 attr_type = apr_pstrdup(doc->pool, "A");
3086 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3087 attr_type = apr_pstrdup(doc->pool, "a");
3105 return chtml40->out;
3110 * It is a handler who processes the OL tag.
3112 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3113 * destination is specified.
3114 * @param node [i] The OL tag node is specified.
3115 * @return The conversion result is returned.
3118 s_chtml40_end_ol_tag(void *pdoc, Node *UNUSED(node))
3120 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3121 Doc *doc = chtml40->doc;
3124 if (IS_CSS_ON(chtml40->entryp)) {
3125 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3128 return chtml40->out;
3133 * It is a handler who processes the LI tag.
3135 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3136 * destination is specified.
3137 * @param node [i] The LI tag node is specified.
3138 * @return The conversion result is returned.
3141 s_chtml40_start_li_tag(void *pdoc, Node *node)
3143 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3144 Doc *doc = chtml40->doc;
3146 char *attr_type = NULL;
3147 char *attr_value = NULL;
3148 char *attr_style = NULL;
3150 /*--------------------------------------------------------------------------*/
3151 /* Get Attributes */
3152 /*--------------------------------------------------------------------------*/
3153 for (attr = qs_get_attr(doc,node);
3155 attr = qs_get_next_attr(doc,attr)) {
3156 char *name = qs_get_attr_name(doc,attr);
3157 char *value = qs_get_attr_value(doc,attr);
3158 if (STRCASEEQ('t','T',"type",name)) {
3159 if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
3163 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
3166 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3170 if (IS_CSS_ON(chtml40->entryp)) {
3171 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3173 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3174 css_property_t *cur;
3175 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3176 if (STRCASEEQ('d','D',"decimal", cur->value)) {
3177 attr_type = apr_pstrdup(doc->pool, "1");
3179 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3180 attr_type = apr_pstrdup(doc->pool, "A");
3182 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3183 attr_type = apr_pstrdup(doc->pool, "a");
3185 else if (STRCASEEQ('d','D',"disc", cur->value)) {
3186 attr_type = apr_pstrdup(doc->pool, "disc");
3188 else if (STRCASEEQ('s','S',"square", cur->value)) {
3189 attr_type = apr_pstrdup(doc->pool, "square");
3191 else if (STRCASEEQ('c','C',"circle", cur->value)) {
3192 attr_type = apr_pstrdup(doc->pool, "circle");
3210 return chtml40->out;
3215 * It is a handler who processes the LI tag.
3217 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3218 * destination is specified.
3219 * @param node [i] The LI tag node is specified.
3220 * @return The conversion result is returned.
3223 s_chtml40_end_li_tag(void *pdoc, Node *UNUSED(child))
3225 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3227 if (IS_CSS_ON(chtml40->entryp)) {
3228 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3230 return chtml40->out;
3235 * It is a handler who processes the H1 tag.
3237 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3238 * destination is specified.
3239 * @param node [i] The H1 tag node is specified.
3240 * @return The conversion result is returned.
3243 s_chtml40_start_h1_tag(void *pdoc, Node *node)
3249 char *attr_style = NULL;
3250 char *attr_align = NULL;
3252 chtml40 = GET_CHTML40(pdoc);
3256 for (attr = qs_get_attr(doc,node);
3258 attr = qs_get_next_attr(doc,attr)) {
3259 char *name = qs_get_attr_name(doc,attr);
3260 char *value = qs_get_attr_value(doc,attr);
3261 if (STRCASEEQ('a','A',"align", name)) {
3262 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3266 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3270 if (IS_CSS_ON(chtml40->entryp)) {
3271 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3273 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3274 css_property_t *cur;
3275 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3276 if (STRCASEEQ('l','L',"left", cur->value)) {
3277 attr_align = apr_pstrdup(doc->pool, "left");
3279 else if (STRCASEEQ('c','C',"center",cur->value)) {
3280 attr_align = apr_pstrdup(doc->pool, "center");
3282 else if (STRCASEEQ('r','R',"right",cur->value)) {
3283 attr_align = apr_pstrdup(doc->pool, "right");
3296 return chtml40->out;
3301 * It is a handler who processes the H1 tag.
3303 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3304 * destination is specified.
3305 * @param node [i] The H1 tag node is specified.
3306 * @return The conversion result is returned.
3309 s_chtml40_end_h1_tag(void *pdoc, Node *UNUSED(child))
3314 chtml40 = GET_CHTML40(pdoc);
3318 if (IS_CSS_ON(chtml40->entryp)) {
3319 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3322 return chtml40->out;
3327 * It is a handler who processes the H2 tag.
3329 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3330 * destination is specified.
3331 * @param node [i] The H2 tag node is specified.
3332 * @return The conversion result is returned.
3335 s_chtml40_start_h2_tag(void *pdoc, Node *node)
3341 char *attr_style = NULL;
3342 char *attr_align = NULL;
3344 chtml40 = GET_CHTML40(pdoc);
3348 for (attr = qs_get_attr(doc,node);
3350 attr = qs_get_next_attr(doc,attr)) {
3351 char *name = qs_get_attr_name(doc,attr);
3352 char *value = qs_get_attr_value(doc,attr);
3353 if (STRCASEEQ('a','A',"align", name)) {
3354 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3358 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3362 if (IS_CSS_ON(chtml40->entryp)) {
3363 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3365 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3366 css_property_t *cur;
3367 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3368 if (STRCASEEQ('l','L',"left", cur->value)) {
3369 attr_align = apr_pstrdup(doc->pool, "left");
3371 else if (STRCASEEQ('c','C',"center",cur->value)) {
3372 attr_align = apr_pstrdup(doc->pool, "center");
3374 else if (STRCASEEQ('r','R',"right",cur->value)) {
3375 attr_align = apr_pstrdup(doc->pool, "right");
3388 return chtml40->out;
3393 * It is a handler who processes the H2 tag.
3395 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3396 * destination is specified.
3397 * @param node [i] The H2 tag node is specified.
3398 * @return The conversion result is returned.
3401 s_chtml40_end_h2_tag(void *pdoc, Node *UNUSED(child))
3403 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3404 Doc *doc = chtml40->doc;
3407 if (IS_CSS_ON(chtml40->entryp)) {
3408 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3411 return chtml40->out;
3416 * It is a handler who processes the H3 tag.
3418 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3419 * destination is specified.
3420 * @param node [i] The H3 tag node is specified.
3421 * @return The conversion result is returned.
3424 s_chtml40_start_h3_tag(void *pdoc, Node *node)
3430 char *attr_style = NULL;
3431 char *attr_align = NULL;
3433 chtml40 = GET_CHTML40(pdoc);
3437 for (attr = qs_get_attr(doc,node);
3439 attr = qs_get_next_attr(doc,attr)) {
3440 char *name = qs_get_attr_name(doc,attr);
3441 char *value = qs_get_attr_value(doc,attr);
3442 if (STRCASEEQ('a','A',"align", name)) {
3443 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3447 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3451 if (IS_CSS_ON(chtml40->entryp)) {
3452 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3454 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3455 css_property_t *cur;
3456 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3457 if (STRCASEEQ('l','L',"left", cur->value)) {
3458 attr_align = apr_pstrdup(doc->pool, "left");
3460 else if (STRCASEEQ('c','C',"center",cur->value)) {
3461 attr_align = apr_pstrdup(doc->pool, "center");
3463 else if (STRCASEEQ('r','R',"right",cur->value)) {
3464 attr_align = apr_pstrdup(doc->pool, "right");
3477 return chtml40->out;
3482 * It is a handler who processes the H3 tag.
3484 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3485 * destination is specified.
3486 * @param node [i] The H3 tag node is specified.
3487 * @return The conversion result is returned.
3490 s_chtml40_end_h3_tag(void *pdoc, Node *UNUSED(child))
3492 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3493 Doc *doc = chtml40->doc;
3496 if (IS_CSS_ON(chtml40->entryp)) {
3497 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3500 return chtml40->out;
3505 * It is a handler who processes the H4 tag.
3507 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3508 * destination is specified.
3509 * @param node [i] The H4 tag node is specified.
3510 * @return The conversion result is returned.
3513 s_chtml40_start_h4_tag(void *pdoc, Node *node)
3519 char *attr_style = NULL;
3520 char *attr_align = NULL;
3522 chtml40 = GET_CHTML40(pdoc);
3526 for (attr = qs_get_attr(doc,node);
3528 attr = qs_get_next_attr(doc,attr)) {
3529 char *name = qs_get_attr_name(doc,attr);
3530 char *value = qs_get_attr_value(doc,attr);
3531 if (STRCASEEQ('a','A',"align", name)) {
3532 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3536 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3540 if (IS_CSS_ON(chtml40->entryp)) {
3541 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3543 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3544 css_property_t *cur;
3545 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3546 if (STRCASEEQ('l','L',"left", cur->value)) {
3547 attr_align = apr_pstrdup(doc->pool, "left");
3549 else if (STRCASEEQ('c','C',"center",cur->value)) {
3550 attr_align = apr_pstrdup(doc->pool, "center");
3552 else if (STRCASEEQ('r','R',"right",cur->value)) {
3553 attr_align = apr_pstrdup(doc->pool, "right");
3566 return chtml40->out;
3571 * It is a handler who processes the H4 tag.
3573 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3574 * destination is specified.
3575 * @param node [i] The H4 tag node is specified.
3576 * @return The conversion result is returned.
3579 s_chtml40_end_h4_tag(void *pdoc, Node *UNUSED(child))
3581 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3582 Doc *doc = chtml40->doc;
3585 if (IS_CSS_ON(chtml40->entryp)) {
3586 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3589 return chtml40->out;
3594 * It is a handler who processes the H5 tag.
3596 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3597 * destination is specified.
3598 * @param node [i] The H5 tag node is specified.
3599 * @return The conversion result is returned.
3602 s_chtml40_start_h5_tag(void *pdoc, Node *node)
3608 char *attr_style = NULL;
3609 char *attr_align = NULL;
3611 chtml40 = GET_CHTML40(pdoc);
3615 for (attr = qs_get_attr(doc,node);
3617 attr = qs_get_next_attr(doc,attr)) {
3618 char *name = qs_get_attr_name(doc,attr);
3619 char *value = qs_get_attr_value(doc,attr);
3620 if (STRCASEEQ('a','A',"align", name)) {
3621 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3625 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3629 if (IS_CSS_ON(chtml40->entryp)) {
3630 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3632 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3633 css_property_t *cur;
3634 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3635 if (STRCASEEQ('l','L',"left", cur->value)) {
3636 attr_align = apr_pstrdup(doc->pool, "left");
3638 else if (STRCASEEQ('c','C',"center",cur->value)) {
3639 attr_align = apr_pstrdup(doc->pool, "center");
3641 else if (STRCASEEQ('r','R',"right",cur->value)) {
3642 attr_align = apr_pstrdup(doc->pool, "right");
3655 return chtml40->out;
3660 * It is a handler who processes the H5 tag.
3662 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3663 * destination is specified.
3664 * @param node [i] The H5 tag node is specified.
3665 * @return The conversion result is returned.
3668 s_chtml40_end_h5_tag(void *pdoc, Node *UNUSED(child))
3670 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3671 Doc *doc = chtml40->doc;
3674 if (IS_CSS_ON(chtml40->entryp)) {
3675 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3678 return chtml40->out;
3683 * It is a handler who processes the H6 tag.
3685 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3686 * destination is specified.
3687 * @param node [i] The H6 tag node is specified.
3688 * @return The conversion result is returned.
3691 s_chtml40_start_h6_tag(void *pdoc, Node *node)
3697 char *attr_style = NULL;
3698 char *attr_align = NULL;
3700 chtml40 = GET_CHTML40(pdoc);
3704 for (attr = qs_get_attr(doc,node);
3706 attr = qs_get_next_attr(doc,attr)) {
3707 char *name = qs_get_attr_name(doc,attr);
3708 char *value = qs_get_attr_value(doc,attr);
3709 if (STRCASEEQ('a','A',"align", name)) {
3710 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3714 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3718 if (IS_CSS_ON(chtml40->entryp)) {
3719 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3721 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3722 css_property_t *cur;
3723 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3724 if (STRCASEEQ('l','L',"left", cur->value)) {
3725 attr_align = apr_pstrdup(doc->pool, "left");
3727 else if (STRCASEEQ('c','C',"center",cur->value)) {
3728 attr_align = apr_pstrdup(doc->pool, "center");
3730 else if (STRCASEEQ('r','R',"right",cur->value)) {
3731 attr_align = apr_pstrdup(doc->pool, "right");
3744 return chtml40->out;
3749 * It is a handler who processes the H6 tag.
3751 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3752 * destination is specified.
3753 * @param node [i] The H6 tag node is specified.
3754 * @return The conversion result is returned.
3757 s_chtml40_end_h6_tag(void *pdoc, Node *UNUSED(child))
3759 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3760 Doc *doc = chtml40->doc;
3763 if (IS_CSS_ON(chtml40->entryp)) {
3764 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3767 return chtml40->out;
3772 * It is a handler who processes the TEXTARE tag.
3774 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3775 * destination is specified.
3776 * @param node [i] The TEXTAREA tag node is specified.
3777 * @return The conversion result is returned.
3780 s_chtml40_start_textarea_tag(void *pdoc, Node *node)
3786 char *attr_accesskey = NULL;
3787 char *attr_name = NULL;
3788 char *attr_rows = NULL;
3789 char *attr_cols = NULL;
3790 char *attr_istyle = NULL;
3791 char *attr_style = NULL;
3793 chtml40 = GET_CHTML40(pdoc);
3797 chtml40->textarea_flag++;
3799 for (attr = qs_get_attr(doc,node);
3801 attr = qs_get_next_attr(doc,attr)) {
3802 char *name = qs_get_attr_name(doc,attr);
3803 char *value = qs_get_attr_value(doc,attr);
3804 if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3805 attr_accesskey = value;
3807 else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3808 attr_istyle = value;
3810 else if (STRCASEEQ('n','N',"name", name) && value && *value) {
3813 else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
3816 else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
3819 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3823 if (IS_CSS_ON(chtml40->entryp)) {
3824 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
3826 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3827 css_property_t *cur;
3828 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3829 if (strcasestr(cur->value, "<ja:n>")) {
3832 else if (strcasestr(cur->value, "<ja:en>")) {
3835 else if (strcasestr(cur->value, "<ja:hk>")) {
3838 else if (strcasestr(cur->value, "<ja:h>")) {
3845 if (attr_accesskey) {
3846 W_L(" accesskey=\"");
3847 W_V(attr_accesskey);
3871 return chtml40->out;
3876 * It is a handler who processes the TEXTAREA tag.
3878 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3879 * destination is specified.
3880 * @param node [i] The TEXTAREA tag node is specified.
3881 * @return The conversion result is returned.
3884 s_chtml40_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3886 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3887 Doc *doc = chtml40->doc;
3890 chtml40->textarea_flag--;
3892 return chtml40->out;
3897 s_chtml40_chxjif_tag(void *pdoc, Node *node)
3904 chtml40 = GET_CHTML40(pdoc);
3908 for (child = qs_get_child_node(doc, node);
3910 child = qs_get_next_node(doc, child)) {
3912 s_chtml40_chxjif_tag(chtml40, child);
3920 s_chtml40_text_tag(void *pdoc, Node *child)
3933 chtml40 = GET_CHTML40(pdoc);
3937 textval = qs_get_node_value(doc,child);
3938 if (strlen(textval) == 0) {
3939 return chtml40->out;
3942 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3943 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3945 tdst = qs_alloc_zero_byte_string(doc->buf.pool);
3946 memset(one_byte, 0, sizeof(one_byte));
3949 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3951 int rtn = s_chtml40_search_emoji(chtml40, &textval[ii], &out);
3953 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3958 if (is_sjis_kanji(textval[ii])) {
3959 one_byte[0] = textval[ii+0];
3960 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3961 one_byte[0] = textval[ii+1];
3962 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3965 else if (chtml40->pre_flag) {
3966 one_byte[0] = textval[ii+0];
3967 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3969 else if (chtml40->textarea_flag) {
3970 one_byte[0] = textval[ii+0];
3971 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3973 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3974 one_byte[0] = textval[ii+0];
3975 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3979 return chtml40->out;
3984 * It is a handler who processes the BLOCKQUOTE tag.
3986 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3987 * destination is specified.
3988 * @param node [i] The BLOCKQUOTE tag node is specified.
3989 * @return The conversion result is returned.
3992 s_chtml40_start_blockquote_tag(void *pdoc, Node *node)
3997 char *attr_style = NULL;
3998 char *attr_color = NULL;
4000 chtml40 = GET_CHTML40(pdoc);
4002 for (attr = qs_get_attr(doc,node);
4004 attr = qs_get_next_attr(doc,attr)) {
4005 char *nm = qs_get_attr_name(doc,attr);
4006 char *val = qs_get_attr_value(doc,attr);
4007 if (val && STRCASEEQ('s','S',"style", nm)) {
4011 if (IS_CSS_ON(chtml40->entryp)) {
4012 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4014 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4015 css_property_t *cur;
4016 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4017 if (cur->value && *cur->value) {
4018 attr_color = apr_pstrdup(doc->pool, cur->value);
4023 W_L("<blockquote>");
4024 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4025 memset(flg, 0, sizeof(*flg));
4027 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4028 W_L("<font color=\"");
4031 flg->with_font_flag = 1;
4033 node->userData = (void *)flg;
4034 return chtml40->out;
4039 * It is a handler who processes the BLOCKQUOTE tag.
4041 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4042 * destination is specified.
4043 * @param node [i] The BLOCKQUOTE tag node is specified.
4044 * @return The conversion result is returned.
4047 s_chtml40_end_blockquote_tag(void *pdoc, Node *node)
4049 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4050 Doc *doc = chtml40->doc;
4051 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4052 if (flg && flg->with_font_flag) {
4055 W_L("</blockquote>");
4056 if (IS_CSS_ON(chtml40->entryp)) {
4057 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4059 return chtml40->out;
4064 * It is a handler who processes the DIR tag.
4066 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4067 * destination is specified.
4068 * @param node [i] The DIR tag node is specified.
4069 * @return The conversion result is returned.
4072 s_chtml40_start_dir_tag(void *pdoc, Node *node)
4074 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4075 Doc *doc = chtml40->doc;
4077 char *attr_style = NULL;
4078 char *attr_color = NULL;
4079 char *attr_type = NULL;
4080 for (attr = qs_get_attr(doc,node);
4082 attr = qs_get_next_attr(doc,attr)) {
4083 char *name = qs_get_attr_name(doc,attr);
4084 char *value = qs_get_attr_value(doc,attr);
4085 if (STRCASEEQ('t','T',"type",name)) {
4086 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4090 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4094 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4102 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4103 memset(flg, 0, sizeof(*flg));
4105 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4106 W_L("<font color=\"");
4109 flg->with_font_flag = 1;
4111 node->userData = (void *)flg;
4112 return chtml40->out;
4117 * It is a handler who processes the DIR tag.
4119 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4120 * destination is specified.
4121 * @param node [i] The DIR tag node is specified.
4122 * @return The conversion result is returned.
4125 s_chtml40_end_dir_tag(void *pdoc, Node *node)
4127 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4128 Doc *doc = chtml40->doc;
4129 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4130 if (flg && flg->with_font_flag) {
4134 if (IS_CSS_ON(chtml40->entryp)) {
4135 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4137 return chtml40->out;
4142 * It is a handler who processes the DL tag.
4144 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4145 * destination is specified.
4146 * @param node [i] The DL tag node is specified.
4147 * @return The conversion result is returned.
4150 s_chtml40_start_dl_tag(void *pdoc, Node *node)
4155 char *attr_style = NULL;
4156 char *attr_color = NULL;
4158 chtml40 = GET_CHTML40(pdoc);
4160 for (attr = qs_get_attr(doc,node);
4162 attr = qs_get_next_attr(doc,attr)) {
4163 char *nm = qs_get_attr_name(doc,attr);
4164 char *val = qs_get_attr_value(doc,attr);
4165 if (val && STRCASEEQ('s','S',"style", nm)) {
4169 if (IS_CSS_ON(chtml40->entryp)) {
4170 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4172 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4173 css_property_t *cur;
4174 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4175 if (cur->value && *cur->value) {
4176 attr_color = apr_pstrdup(doc->pool, cur->value);
4182 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4183 memset(flg, 0, sizeof(*flg));
4185 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4186 W_L("<font color=\"");
4189 flg->with_font_flag = 1;
4191 node->userData = (void *)flg;
4192 return chtml40->out;
4197 * It is a handler who processes the DL tag.
4199 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4200 * destination is specified.
4201 * @param node [i] The DL tag node is specified.
4202 * @return The conversion result is returned.
4205 s_chtml40_end_dl_tag(void *pdoc, Node *node)
4207 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4208 Doc *doc = chtml40->doc;
4209 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4210 if (flg && flg->with_font_flag) {
4214 if (IS_CSS_ON(chtml40->entryp)) {
4215 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4217 return chtml40->out;
4222 * It is a handler who processes the DT tag.
4224 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4225 * destination is specified.
4226 * @param node [i] The DT tag node is specified.
4227 * @return The conversion result is returned.
4230 s_chtml40_start_dt_tag(void *pdoc, Node *node)
4235 char *attr_style = NULL;
4236 char *attr_color = NULL;
4238 chtml40 = GET_CHTML40(pdoc);
4240 for (attr = qs_get_attr(doc,node);
4242 attr = qs_get_next_attr(doc,attr)) {
4243 char *nm = qs_get_attr_name(doc,attr);
4244 char *val = qs_get_attr_value(doc,attr);
4245 if (val && STRCASEEQ('s','S',"style", nm)) {
4249 if (IS_CSS_ON(chtml40->entryp)) {
4250 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4252 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4253 css_property_t *cur;
4254 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4255 if (cur->value && *cur->value) {
4256 attr_color = apr_pstrdup(doc->pool, cur->value);
4262 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4263 memset(flg, 0, sizeof(*flg));
4265 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4266 W_L("<font color=\"");
4269 flg->with_font_flag = 1;
4271 node->userData = (void *)flg;
4272 return chtml40->out;
4277 * It is a handler who processes the DT tag.
4279 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4280 * destination is specified.
4281 * @param node [i] The DT tag node is specified.
4282 * @return The conversion result is returned.
4285 s_chtml40_end_dt_tag(void *pdoc, Node *node)
4287 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4288 Doc *doc = chtml40->doc;
4289 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4290 if (flg && flg->with_font_flag) {
4293 if (IS_CSS_ON(chtml40->entryp)) {
4294 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4296 return chtml40->out;
4301 * It is a handler who processes the DD tag.
4303 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4304 * destination is specified.
4305 * @param node [i] The DD tag node is specified.
4306 * @return The conversion result is returned.
4309 s_chtml40_start_dd_tag(void *pdoc, Node *node)
4314 char *attr_style = NULL;
4315 char *attr_color = NULL;
4317 chtml40 = GET_CHTML40(pdoc);
4319 for (attr = qs_get_attr(doc,node);
4321 attr = qs_get_next_attr(doc,attr)) {
4322 char *nm = qs_get_attr_name(doc,attr);
4323 char *val = qs_get_attr_value(doc,attr);
4324 if (val && STRCASEEQ('s','S',"style", nm)) {
4328 if (IS_CSS_ON(chtml40->entryp)) {
4329 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4331 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4332 css_property_t *cur;
4333 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4334 if (cur->value && *cur->value) {
4335 attr_color = apr_pstrdup(doc->pool, cur->value);
4341 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4342 memset(flg, 0, sizeof(*flg));
4344 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4345 W_L("<font color=\"");
4348 flg->with_font_flag = 1;
4350 node->userData = (void *)flg;
4351 return chtml40->out;
4356 * It is a handler who processes the DD tag.
4358 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4359 * destination is specified.
4360 * @param node [i] The DD tag node is specified.
4361 * @return The conversion result is returned.
4364 s_chtml40_end_dd_tag(void *pdoc, Node *node)
4366 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4367 Doc *doc = chtml40->doc;
4368 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4369 if (flg && flg->with_font_flag) {
4372 if (IS_CSS_ON(chtml40->entryp)) {
4373 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4375 return chtml40->out;
4380 * It is a handler who processes the MARQUEE tag.
4382 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4383 * destination is specified.
4384 * @param node [i] The MARQUEE tag node is specified.
4385 * @return The conversion result is returned.
4388 s_chtml40_start_marquee_tag(void *pdoc, Node *node)
4390 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4391 Doc *doc = chtml40->doc;
4393 char *attr_direction = NULL;
4394 char *attr_behavior = NULL;
4395 char *attr_loop = NULL;
4396 char *attr_style = NULL;
4397 char *attr_color = NULL;
4398 /*--------------------------------------------------------------------------*/
4399 /* Get Attributes */
4400 /*--------------------------------------------------------------------------*/
4401 for (attr = qs_get_attr(doc,node);
4403 attr = qs_get_next_attr(doc,attr)) {
4404 char *name = qs_get_attr_name(doc,attr);
4405 char *value = qs_get_attr_value(doc,attr);
4406 if (STRCASEEQ('d','D',"direction", name)) {
4407 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
4408 attr_direction = value;
4411 else if (STRCASEEQ('b','B',"behavior",name)) {
4412 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
4413 attr_behavior = value;
4416 else if (STRCASEEQ('l','L',"loop",name)) {
4417 if (value && *value) {
4421 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4425 if (IS_CSS_ON(chtml40->entryp)) {
4426 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4428 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4429 css_property_t *direction_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4430 css_property_t *style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4431 css_property_t *loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4432 css_property_t *cur;
4433 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4434 if (cur->value && *cur->value) {
4435 attr_color = apr_pstrdup(doc->pool, cur->value);
4438 for (cur = style_prop->next; cur != style_prop; cur = cur->next) {
4439 if (cur->value && *cur->value) {
4440 attr_behavior = apr_pstrdup(doc->pool, cur->value);
4443 for (cur = loop_prop->next; cur != loop_prop; cur = cur->next) {
4444 if (cur->value && *cur->value) {
4445 attr_loop = apr_pstrdup(doc->pool, cur->value);
4446 if (STRCASEEQ('i','I',"infinite",attr_loop)) {
4451 for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
4452 if (cur->value && *cur->value) {
4453 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4454 attr_direction = "right";
4456 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4457 attr_direction = "left";
4464 if (attr_direction) {
4465 W_L(" direction=\"");
4466 W_V(attr_direction);
4469 if (attr_behavior) {
4470 W_L(" behavior=\"");
4481 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4482 memset(flg, 0, sizeof(*flg));
4484 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4485 W_L("<font color=\"");
4488 flg->with_font_flag = 1;
4490 node->userData = (void *)flg;
4491 return chtml40->out;
4496 * It is a handler who processes the MARQUEE tag.
4498 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4499 * destination is specified.
4500 * @param node [i] The MARQUEE tag node is specified.
4501 * @return The conversion result is returned.
4504 s_chtml40_end_marquee_tag(void *pdoc, Node *node)
4506 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4507 Doc *doc = chtml40->doc;
4508 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4509 if (flg && flg->with_font_flag) {
4513 if (IS_CSS_ON(chtml40->entryp)) {
4514 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4516 return chtml40->out;
4521 * It is a handler who processes the BLINK tag.
4523 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4524 * destination is specified.
4525 * @param node [i] The BLINK tag node is specified.
4526 * @return The conversion result is returned.
4529 s_chtml40_start_blink_tag(void *pdoc, Node *node)
4534 char *attr_style = NULL;
4535 char *attr_color = NULL;
4537 chtml40 = GET_CHTML40(pdoc);
4539 for (attr = qs_get_attr(doc,node);
4541 attr = qs_get_next_attr(doc,attr)) {
4542 char *nm = qs_get_attr_name(doc,attr);
4543 char *val = qs_get_attr_value(doc,attr);
4544 if (val && STRCASEEQ('s','S',"style", nm)) {
4548 if (IS_CSS_ON(chtml40->entryp)) {
4549 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4551 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4552 css_property_t *cur;
4553 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4554 if (cur->value && *cur->value) {
4555 attr_color = apr_pstrdup(doc->pool, cur->value);
4561 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4562 memset(flg, 0, sizeof(*flg));
4564 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4565 W_L("<font color=\"");
4568 flg->with_font_flag = 1;
4570 node->userData = (void *)flg;
4571 return chtml40->out;
4576 * It is a handler who processes the BLINK tag.
4578 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4579 * destination is specified.
4580 * @param node [i] The BLINK tag node is specified.
4581 * @return The conversion result is returned.
4584 s_chtml40_end_blink_tag(void *pdoc, Node *node)
4586 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4587 Doc *doc = chtml40->doc;
4588 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4589 if (flg && flg->with_font_flag) {
4593 if (IS_CSS_ON(chtml40->entryp)) {
4594 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4596 return chtml40->out;
4601 * It is a handler who processes the MENU tag.
4603 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4604 * destination is specified.
4605 * @param node [i] The MENU tag node is specified.
4606 * @return The conversion result is returned.
4609 s_chtml40_start_menu_tag(void *pdoc, Node *node)
4611 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4612 Doc *doc = chtml40->doc;
4614 char *attr_style = NULL;
4615 char *attr_type = NULL;
4616 char *attr_color = NULL;
4617 /*--------------------------------------------------------------------------*/
4618 /* Get Attributes */
4619 /*--------------------------------------------------------------------------*/
4620 for (attr = qs_get_attr(doc,node);
4622 attr = qs_get_next_attr(doc,attr)) {
4623 char *name = qs_get_attr_name(doc,attr);
4624 char *value = qs_get_attr_value(doc,attr);
4625 if (STRCASEEQ('t','T',"type",name)) {
4626 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4630 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4634 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4642 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4643 memset(flg, 0, sizeof(*flg));
4645 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4646 W_L("<font color=\"");
4649 flg->with_font_flag = 1;
4651 node->userData = (void *)flg;
4653 return chtml40->out;
4658 * It is a handler who processes the MENU tag.
4660 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4661 * destination is specified.
4662 * @param node [i] The MENU tag node is specified.
4663 * @return The conversion result is returned.
4666 s_chtml40_end_menu_tag(void *pdoc, Node *node)
4668 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4669 Doc *doc = chtml40->doc;
4670 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4671 if (flg && flg->with_font_flag) {
4675 if (IS_CSS_ON(chtml40->entryp)) {
4676 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4678 return chtml40->out;
4683 * It is a handler who processes the PLAINTEXT tag.
4685 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4686 * destination is specified.
4687 * @param node [i] The PLAINTEXT tag node is specified.
4688 * @return The conversion result is returned.
4691 s_chtml40_start_plaintext_tag(void *pdoc, Node *node)
4693 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4694 Doc *doc = chtml40->doc;
4696 s_chtml40_start_plaintext_tag_inner(pdoc,node);
4697 return chtml40->out;
4701 s_chtml40_start_plaintext_tag_inner(void *pdoc, Node *node)
4703 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4704 Doc *doc = chtml40->doc;
4706 for (child = qs_get_child_node(doc, node);
4708 child = qs_get_next_node(doc, child)) {
4710 s_chtml40_start_plaintext_tag_inner(pdoc, child);
4712 return chtml40->out;
4717 * It is a handler who processes the PLAINTEXT tag.
4719 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4720 * destination is specified.
4721 * @param node [i] The PLAINTEXT tag node is specified.
4722 * @return The conversion result is returned.
4725 s_chtml40_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4727 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4728 return chtml40->out;
4733 * It is handler who processes the New Line Code.
4736 s_chtml40_newline_mark(void *pdoc, Node *UNUSED(node))
4738 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4739 Doc *doc = chtml40->doc;
4741 return chtml40->out;
4746 * It is a handler who processes the LINK tag.
4748 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4749 * destination is specified.
4750 * @param node [i] The LINK tag node is specified.
4751 * @return The conversion result is returned.
4754 s_chtml40_link_tag(void *pdoc, Node *node)
4763 chtml40 = GET_CHTML40(pdoc);
4766 if (! IS_CSS_ON(chtml40->entryp)) {
4767 return chtml40->out;
4770 for (attr = qs_get_attr(doc,node);
4772 attr = qs_get_next_attr(doc,attr)) {
4773 char *name = qs_get_attr_name(doc,attr);
4774 char *value = qs_get_attr_value(doc,attr);
4775 if (STRCASEEQ('r','R',"rel", name)) {
4776 if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
4780 else if (STRCASEEQ('h','H',"href", name)) {
4781 if (value && *value) {
4785 else if (STRCASEEQ('t','T',"type", name)) {
4786 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
4792 if (rel && href && type) {
4793 DBG(doc->r, "start load CSS. url:[%s]", href);
4794 chtml40->style = chxj_css_parse_from_uri(doc->r, doc->pool, chtml40->style, href);
4795 DBG(doc->r, "end load CSS. url:[%s]", href);
4798 return chtml40->out;
4801 static css_prop_list_t *
4802 s_chtml40_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4804 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4805 Doc *doc = chtml40->doc;
4806 css_prop_list_t *last_css = NULL;
4807 if (IS_CSS_ON(chtml40->entryp)) {
4808 css_prop_list_t *dup_css;
4809 css_selector_t *selector;
4811 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4812 dup_css = chxj_dup_css_prop_list(doc, last_css);
4813 selector = chxj_css_find_selector(doc, chtml40->style, node);
4815 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4817 chxj_css_push_prop_list(chtml40->css_prop_stack, dup_css);
4818 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4820 if (style_attr_value) {
4821 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));
4823 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4831 static css_prop_list_t *
4832 s_chtml40_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4834 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4835 Doc *doc = chtml40->doc;
4836 css_prop_list_t *last_css = NULL;
4837 if (IS_CSS_ON(chtml40->entryp)) {
4838 css_prop_list_t *dup_css;
4839 css_selector_t *selector;
4841 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4842 dup_css = chxj_dup_css_prop_list(doc, last_css);
4843 selector = chxj_css_find_selector(doc, chtml40->style, node);
4845 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4849 if (style_attr_value) {
4850 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));
4852 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4862 * It is a handler who processes the SPAN tag.
4864 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4865 * destination is specified.
4866 * @param node [i] The SPAN tag node is specified.
4867 * @return The conversion result is returned.
4870 s_chtml40_start_span_tag(void *pdoc, Node *node)
4875 char *attr_style = NULL;
4876 char *attr_color = NULL;
4877 char *attr_align = NULL;
4878 char *attr_blink = NULL;
4879 char *attr_marquee = NULL;
4880 char *attr_marquee_dir = NULL;
4881 char *attr_marquee_style = NULL;
4882 char *attr_marquee_loop = NULL;
4884 chtml40 = GET_CHTML40(pdoc);
4887 for (attr = qs_get_attr(doc,node);
4889 attr = qs_get_next_attr(doc,attr)) {
4890 char *nm = qs_get_attr_name(doc,attr);
4891 char *val = qs_get_attr_value(doc,attr);
4892 if (val && STRCASEEQ('s','S',"style", nm)) {
4896 if (IS_CSS_ON(chtml40->entryp)) {
4897 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4899 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4900 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
4901 css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
4902 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
4903 css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4904 css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4905 css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4906 css_property_t *cur;
4907 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4908 attr_color = apr_pstrdup(doc->pool, cur->value);
4910 for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
4911 if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
4912 attr_blink = apr_pstrdup(doc->pool, cur->value);
4915 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
4916 if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
4917 attr_marquee = apr_pstrdup(doc->pool, cur->value);
4920 for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
4921 if (cur->value && *cur->value) {
4922 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4923 attr_marquee_dir = "right";
4925 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4926 attr_marquee_dir = "left";
4930 for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
4931 if (cur->value && *cur->value) {
4932 if ( STRCASEEQ('s','S',"scroll",cur->value)
4933 || STRCASEEQ('s','S',"slide",cur->value)
4934 || STRCASEEQ('a','A',"alternate",cur->value)) {
4935 attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
4939 for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
4940 if (cur->value && *cur->value) {
4941 if (STRCASEEQ('i','I',"infinite",cur->value)) {
4942 attr_marquee_loop = "16";
4945 attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
4949 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
4950 if (STRCASEEQ('l','L',"left", cur->value)) {
4951 attr_align = apr_pstrdup(doc->pool, "left");
4953 else if (STRCASEEQ('c','C',"center",cur->value)) {
4954 attr_align = apr_pstrdup(doc->pool, "center");
4956 else if (STRCASEEQ('r','R',"right",cur->value)) {
4957 attr_align = apr_pstrdup(doc->pool, "right");
4962 if (attr_color || attr_align || attr_blink || attr_marquee) {
4963 chtml40_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4964 memset(flg, 0, sizeof(*flg));
4967 flg->with_blink_flag = 1;
4971 if (attr_marquee_dir) {
4972 W_L(" direction=\"");
4973 W_V(attr_marquee_dir);
4976 if (attr_marquee_style) {
4977 W_L(" behavior=\"");
4978 W_V(attr_marquee_style);
4981 if (attr_marquee_loop) {
4983 W_V(attr_marquee_loop);
4987 flg->with_marquee_flag = 1;
4990 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4991 W_L("<font color=\"");
4994 flg->with_font_flag = 1;
4997 W_L("<div align=\"");
5000 flg->with_div_flag = 1;
5002 node->userData = flg;
5005 node->userData = NULL;
5007 return chtml40->out;
5012 * It is a handler who processes the SPAN tag.
5014 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5015 * destination is specified.
5016 * @param node [i] The SPAN tag node is specified.
5017 * @return The conversion result is returned.
5020 s_chtml40_end_span_tag(void *pdoc, Node *node)
5022 chtml40_t *chtml40 = GET_CHTML40(pdoc);
5023 Doc *doc = chtml40->doc;
5025 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
5026 if (flg && flg->with_div_flag) {
5029 if (flg && flg->with_font_flag) {
5032 if (flg && flg->with_marquee_flag) {
5035 if (flg && flg->with_blink_flag) {
5038 if (IS_CSS_ON(chtml40->entryp)) {
5039 chxj_css_pop_prop_list(chtml40->css_prop_stack);
5041 return chtml40->out;
5046 * It is a handler who processes the STYLE tag.
5048 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5049 * destination is specified.
5050 * @param node [i] The STYLE tag node is specified.
5051 * @return The conversion result is returned.
5054 s_chtml40_style_tag(void *pdoc, Node *node)
5061 chtml40 = GET_CHTML40(pdoc);
5064 if (! IS_CSS_ON(chtml40->entryp)) {
5065 return chtml40->out;
5068 for (attr = qs_get_attr(doc,node);
5070 attr = qs_get_next_attr(doc,attr)) {
5071 char *name = qs_get_attr_name(doc,attr);
5072 char *value = qs_get_attr_value(doc,attr);
5073 if (STRCASEEQ('t','T',"type", name)) {
5074 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5080 Node *child = qs_get_child_node(doc, node);
5081 if (type && child) {
5082 char *name = qs_get_node_name(doc, child);
5083 if (STRCASEEQ('t','T',"text", name)) {
5084 char *value = qs_get_node_value(doc, child);
5085 DBG(doc->r, "start load CSS. buf:[%s]", value);
5086 chtml40->style = chxj_css_parse_style_value(doc, chtml40->style, value);
5087 DBG(doc->r, "end load CSS. value:[%s]", value);
5090 return chtml40->out;