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"
26 #include "chxj_conv_z2h.h"
28 #define GET_CHTML40(X) ((chtml40_t *)(X))
31 #define W_L(X) do { chtml40->out = BUFFERED_WRITE_LITERAL(chtml40->out, &doc->buf, (X)); } while(0)
32 #define W_V(X) do { chtml40->out = (X) ? BUFFERED_WRITE_VALUE(chtml40->out, &doc->buf, (X)) \
33 : BUFFERED_WRITE_LITERAL(chtml40->out, &doc->buf, ""); } while(0)
35 #define W_NLCODE() do { char *nlcode = TO_NLCODE(chtml40->conf); W_V(nlcode); } while (0)
37 #define CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE() \
38 if (IS_CSS_ON(chtml40->entryp)) { \
39 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style); \
41 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color"); \
42 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type"); \
43 css_property_t *cur; \
44 for (cur = color_prop->next; cur != color_prop; cur = cur->next) { \
45 if (cur->value && *cur->value) { \
46 attr_color = apr_pstrdup(doc->pool, cur->value); \
49 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) { \
50 if (cur->value && *cur->value) { \
51 attr_type = apr_pstrdup(doc->pool, cur->value); \
57 static char *s_chtml40_start_html_tag (void *pdoc, Node *node);
58 static char *s_chtml40_end_html_tag (void *pdoc, Node *node);
59 static char *s_chtml40_start_meta_tag (void *pdoc, Node *node);
60 static char *s_chtml40_end_meta_tag (void *pdoc, Node *node);
61 static char *s_chtml40_start_textarea_tag (void *pdoc, Node *node);
62 static char *s_chtml40_end_textarea_tag (void *pdoc, Node *node);
63 static char *s_chtml40_start_p_tag (void *pdoc, Node *node);
64 static char *s_chtml40_end_p_tag (void *pdoc, Node *node);
65 static char *s_chtml40_start_pre_tag (void *pdoc, Node *node);
66 static char *s_chtml40_end_pre_tag (void *pdoc, Node *node);
67 static char *s_chtml40_start_h1_tag (void *pdoc, Node *node);
68 static char *s_chtml40_end_h1_tag (void *pdoc, Node *node);
69 static char *s_chtml40_start_h2_tag (void *pdoc, Node *node);
70 static char *s_chtml40_end_h2_tag (void *pdoc, Node *node);
71 static char *s_chtml40_start_h3_tag (void *pdoc, Node *node);
72 static char *s_chtml40_end_h3_tag (void *pdoc, Node *node);
73 static char *s_chtml40_start_h4_tag (void *pdoc, Node *node);
74 static char *s_chtml40_end_h4_tag (void *pdoc, Node *node);
75 static char *s_chtml40_start_h5_tag (void *pdoc, Node *node);
76 static char *s_chtml40_end_h5_tag (void *pdoc, Node *node);
77 static char *s_chtml40_start_h6_tag (void *pdoc, Node *node);
78 static char *s_chtml40_end_h6_tag (void *pdoc, Node *node);
79 static char *s_chtml40_start_ul_tag (void *pdoc, Node *node);
80 static char *s_chtml40_end_ul_tag (void *pdoc, Node *node);
81 static char *s_chtml40_start_ol_tag (void *pdoc, Node *node);
82 static char *s_chtml40_end_ol_tag (void *pdoc, Node *node);
83 static char *s_chtml40_start_li_tag (void *pdoc, Node *node);
84 static char *s_chtml40_end_li_tag (void *pdoc, Node *node);
85 static char *s_chtml40_start_head_tag (void *pdoc, Node *node);
86 static char *s_chtml40_end_head_tag (void *pdoc, Node *node);
87 static char *s_chtml40_start_title_tag (void *pdoc, Node *node);
88 static char *s_chtml40_end_title_tag (void *pdoc, Node *node);
89 static char *s_chtml40_start_base_tag (void *pdoc, Node *node);
90 static char *s_chtml40_end_base_tag (void *pdoc, Node *node);
91 static char *s_chtml40_start_body_tag (void *pdoc, Node *node);
92 static char *s_chtml40_end_body_tag (void *pdoc, Node *node);
93 static char *s_chtml40_start_a_tag (void *pdoc, Node *node);
94 static char *s_chtml40_end_a_tag (void *pdoc, Node *node);
95 static char *s_chtml40_start_br_tag (void *pdoc, Node *node);
96 static char *s_chtml40_end_br_tag (void *pdoc, Node *node);
97 static char *s_chtml40_start_tr_tag (void *pdoc, Node *node);
98 static char *s_chtml40_end_tr_tag (void *pdoc, Node *node);
99 static char *s_chtml40_start_font_tag (void *pdoc, Node *node);
100 static char *s_chtml40_end_font_tag (void *pdoc, Node *node);
101 static char *s_chtml40_start_form_tag (void *pdoc, Node *node);
102 static char *s_chtml40_end_form_tag (void *pdoc, Node *node);
103 static char *s_chtml40_start_input_tag (void *pdoc, Node *node);
104 static char *s_chtml40_end_input_tag (void *pdoc, Node *node);
105 static char *s_chtml40_start_center_tag (void *pdoc, Node *node);
106 static char *s_chtml40_end_center_tag (void *pdoc, Node *node);
107 static char *s_chtml40_start_hr_tag (void *pdoc, Node *node);
108 static char *s_chtml40_end_hr_tag (void *pdoc, Node *node);
109 static char *s_chtml40_start_img_tag (void *pdoc, Node *node);
110 static char *s_chtml40_end_img_tag (void *pdoc, Node *node);
111 static char *s_chtml40_start_select_tag (void *pdoc, Node *node);
112 static char *s_chtml40_end_select_tag (void *pdoc, Node *node);
113 static char *s_chtml40_start_option_tag (void *pdoc, Node *node);
114 static char *s_chtml40_end_option_tag (void *pdoc, Node *node);
115 static char *s_chtml40_start_div_tag (void *pdoc, Node *node);
116 static char *s_chtml40_end_div_tag (void *pdoc, Node *node);
117 static char *s_chtml40_chxjif_tag (void *pdoc, Node *node);
118 static char *s_chtml40_text_tag (void *pdoc, Node *node);
119 static char *s_chtml40_start_blockquote_tag (void *pdoc, Node *node);
120 static char *s_chtml40_end_blockquote_tag (void *pdoc, Node *node);
121 static char *s_chtml40_start_dir_tag (void *pdoc, Node *node);
122 static char *s_chtml40_end_dir_tag (void *pdoc, Node *node);
123 static char *s_chtml40_start_dl_tag (void *pdoc, Node *node);
124 static char *s_chtml40_end_dl_tag (void *pdoc, Node *node);
125 static char *s_chtml40_start_dt_tag (void *pdoc, Node *node);
126 static char *s_chtml40_end_dt_tag (void *pdoc, Node *node);
127 static char *s_chtml40_start_dd_tag (void *pdoc, Node *node);
128 static char *s_chtml40_end_dd_tag (void *pdoc, Node *node);
129 static char *s_chtml40_start_marquee_tag (void *pdoc, Node *node);
130 static char *s_chtml40_end_marquee_tag (void *pdoc, Node *node);
131 static char *s_chtml40_start_blink_tag (void *pdoc, Node *node);
132 static char *s_chtml40_end_blink_tag (void *pdoc, Node *node);
133 static char *s_chtml40_start_menu_tag (void *pdoc, Node *node);
134 static char *s_chtml40_end_menu_tag (void *pdoc, Node *node);
135 static char *s_chtml40_start_plaintext_tag (void *pdoc, Node *node);
136 static char *s_chtml40_start_plaintext_tag_inner (void *pdoc, Node *node);
137 static char *s_chtml40_end_plaintext_tag (void *pdoc, Node *node);
138 static char *s_chtml40_newline_mark (void *pdoc, Node *node);
139 static char *s_chtml40_link_tag (void *pdoc, Node *node);
140 static char *s_chtml40_start_span_tag (void *pdoc, Node *node);
141 static char *s_chtml40_end_span_tag (void *pdoc, Node *node);
142 static char *s_chtml40_style_tag (void *pdoc, Node *node);
144 static void s_init_chtml40(chtml40_t *chtml, Doc *doc, request_rec *r, device_table *spec);
146 static int s_chtml40_search_emoji(chtml40_t *chtml, char *txt, char **rslt);
147 static css_prop_list_t *s_chtml40_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
148 static css_prop_list_t *s_chtml40_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
151 tag_handler chtml40_handler[] = {
154 s_chtml40_start_html_tag,
155 s_chtml40_end_html_tag,
159 s_chtml40_start_meta_tag,
160 s_chtml40_end_meta_tag,
164 s_chtml40_start_textarea_tag,
165 s_chtml40_end_textarea_tag,
169 s_chtml40_start_p_tag,
174 s_chtml40_start_pre_tag,
175 s_chtml40_end_pre_tag,
179 s_chtml40_start_ul_tag,
180 s_chtml40_end_ul_tag,
184 s_chtml40_start_li_tag,
185 s_chtml40_end_li_tag,
189 s_chtml40_start_ol_tag,
190 s_chtml40_end_ol_tag,
194 s_chtml40_start_h1_tag,
195 s_chtml40_end_h1_tag,
199 s_chtml40_start_h2_tag,
200 s_chtml40_end_h2_tag,
204 s_chtml40_start_h3_tag,
205 s_chtml40_end_h3_tag,
209 s_chtml40_start_h4_tag,
210 s_chtml40_end_h4_tag,
214 s_chtml40_start_h5_tag,
215 s_chtml40_end_h5_tag,
219 s_chtml40_start_h6_tag,
220 s_chtml40_end_h6_tag,
224 s_chtml40_start_head_tag,
225 s_chtml40_end_head_tag,
229 s_chtml40_start_title_tag,
230 s_chtml40_end_title_tag,
234 s_chtml40_start_base_tag,
235 s_chtml40_end_base_tag,
239 s_chtml40_start_body_tag,
240 s_chtml40_end_body_tag,
244 s_chtml40_start_a_tag,
249 s_chtml40_start_br_tag,
250 s_chtml40_end_br_tag,
259 s_chtml40_start_tr_tag,
260 s_chtml40_end_tr_tag,
274 s_chtml40_start_font_tag,
275 s_chtml40_end_font_tag,
279 s_chtml40_start_form_tag,
280 s_chtml40_end_form_tag,
284 s_chtml40_start_input_tag,
285 s_chtml40_end_input_tag,
289 s_chtml40_start_center_tag,
290 s_chtml40_end_center_tag,
294 s_chtml40_start_hr_tag,
295 s_chtml40_end_hr_tag,
299 s_chtml40_start_img_tag,
300 s_chtml40_end_img_tag,
304 s_chtml40_start_select_tag,
305 s_chtml40_end_select_tag,
309 s_chtml40_start_option_tag,
310 s_chtml40_end_option_tag,
314 s_chtml40_start_div_tag,
315 s_chtml40_end_div_tag,
319 s_chtml40_chxjif_tag,
339 s_chtml40_start_span_tag,
340 s_chtml40_end_span_tag,
364 s_chtml40_start_dt_tag,
365 s_chtml40_end_dt_tag,
379 s_chtml40_start_blockquote_tag,
380 s_chtml40_end_blockquote_tag,
384 s_chtml40_start_dir_tag,
385 s_chtml40_end_dir_tag,
389 s_chtml40_start_dl_tag,
390 s_chtml40_end_dl_tag,
394 s_chtml40_start_dd_tag,
395 s_chtml40_end_dd_tag,
399 s_chtml40_start_menu_tag,
400 s_chtml40_end_menu_tag,
404 s_chtml40_start_plaintext_tag,
405 s_chtml40_end_plaintext_tag,
409 s_chtml40_start_blink_tag,
410 s_chtml40_end_blink_tag,
414 s_chtml40_start_marquee_tag,
415 s_chtml40_end_marquee_tag,
424 s_chtml40_newline_mark,
431 * converts from CHTML5.0 to CHTML3.0.
433 * @param r [i] Requet_rec is appointed.
434 * @param spec [i] The result of the device specification processing which
435 * was done in advance is appointed.
436 * @param src [i] The character string before the converting is appointed.
437 * @return The character string after the converting is returned.
440 chxj_convert_chtml40(
446 chxjconvrule_entry *entryp,
455 DBG(r, "start chxj_convert_chtml40()");
457 /*--------------------------------------------------------------------------*/
459 /*--------------------------------------------------------------------------*/
461 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
463 DBG(r,"i found qrcode xml");
464 DBG(r, "end chxj_convert_chtml40()");
467 DBG(r,"not found qrcode xml");
469 /*--------------------------------------------------------------------------*/
470 /* The CHTML structure is initialized. */
471 /*--------------------------------------------------------------------------*/
472 s_init_chtml40(&chtml40, &doc, r, spec);
474 chtml40.entryp = entryp;
475 chtml40.cookie = cookie;
477 chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
479 /*--------------------------------------------------------------------------*/
480 /* The character string of the input is analyzed. */
481 /*--------------------------------------------------------------------------*/
482 qs_init_malloc(&doc);
483 qs_init_root_node(&doc);
485 ss = apr_pcalloc(r->pool, srclen + 1);
486 memset(ss, 0, srclen + 1);
487 memcpy(ss, src, srclen);
490 chxj_dump_out("[src] CHTML -> CHTML4.0", ss, srclen);
492 if (IS_CSS_ON(chtml40.entryp)) {
493 /* current property list */
494 chtml40.css_prop_stack = chxj_new_prop_list_stack(&doc);
497 chxj_buffered_write_init(r->pool, &doc.buf);
499 qs_parse_string(&doc,ss, strlen(ss));
501 /*--------------------------------------------------------------------------*/
502 /* It converts it from CHTML to CHTML. */
503 /*--------------------------------------------------------------------------*/
504 chxj_node_convert(spec,r,(void*)&chtml40, &doc, qs_get_root(&doc), 0);
505 chtml40.out = chxj_buffered_write_flush(chtml40.out, &doc.buf);
506 dst = apr_pstrdup(r->pool, chtml40.out);
507 chxj_buffered_write_terminate(&doc.buf);
509 qs_all_free(&doc,QX_LOGMARK);
512 dst = apr_pstrdup(r->pool,ss);
514 if (strlen(dst) == 0) {
515 dst = apr_psprintf(r->pool, "\n");
518 *dstlen = strlen(dst);
521 chxj_dump_out("[src] CHTML -> CHTML4.0", dst, *dstlen);
524 DBG(r, "end chxj_convert_chtml40()");
530 * The CHTML structure is initialized.
532 * @param chtml40 [i/o] The pointer to the HDML structure that wants to be
533 * initialized is specified.
534 * @param doc [i] The Doc structure that should be set to the initialized
535 * HDML structure is specified.
536 * @param r [i] To use POOL, the pointer to request_rec is specified.
537 * @param spec [i] The pointer to the device_table
540 s_init_chtml40(chtml40_t *chtml40, Doc *doc, request_rec *r, device_table *spec)
542 memset(doc, 0, sizeof(Doc));
543 memset(chtml40, 0, sizeof(chtml40_t));
547 chtml40->spec = spec;
548 chtml40->out = qs_alloc_zero_byte_string(r->pool);
549 chtml40->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
550 chtml40->doc->parse_mode = PARSE_MODE_CHTML;
555 * Corresponding EMOJI to a current character-code is retrieved.
556 * The substitution character string is stored in the rslt pointer if agreeing.
558 * @param chtml40 [i] The pointer to the CHTML structure is specified.
559 * @param txt [i] The character string to want to examine whether it is
560 * EMOJI is specified.
561 * @param rslt [o] The pointer to the pointer that stores the result is
563 * @return When corresponding EMOJI exists, it returns it excluding 0.
566 s_chtml40_search_emoji(chtml40_t *chtml40, char *txt, char **rslt)
573 spec = chtml40->spec;
579 DBG(r,"spec is NULL");
582 for (ee = chtml40->conf->emoji;
585 if (ee->imode == NULL) {
586 DBG(r, "emoji->imode is NULL");
590 if (ee->imode->string != NULL
591 && strlen(ee->imode->string) > 0
592 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
594 if (spec == NULL || spec->emoji_type == NULL) {
595 *rslt = apr_palloc(r->pool, 3);
596 (*rslt)[0] = ee->imode->hex1byte & 0xff;
597 (*rslt)[1] = ee->imode->hex2byte & 0xff;
599 return strlen(ee->imode->string);
611 chxj_chtml40_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
622 chtml40 = &__chtml40;
625 DBG(r, "REQ[%X] start chxj_chtml40_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
626 memset(doc, 0, sizeof(Doc));
627 memset(chtml40, 0, sizeof(chtml40_t));
631 chtml40->spec = spec;
632 chtml40->out = qs_alloc_zero_byte_string(r->pool);
633 chtml40->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
634 chtml40->doc->parse_mode = PARSE_MODE_CHTML;
636 apr_pool_create(&pool, r->pool);
638 chxj_buffered_write_init(pool, &doc->buf);
640 for (ii=0; ii<len; ii++) {
644 rtn = s_chtml40_search_emoji(chtml40, (char *)&src[ii], &out);
651 if (is_sjis_kanji(src[ii])) {
652 two_byte[0] = src[ii+0];
653 two_byte[1] = src[ii+1];
659 one_byte[0] = src[ii+0];
664 chtml40->out = chxj_buffered_write_flush(chtml40->out, &doc->buf);
666 DBG(r, "REQ[%X] end chxj_chtml40_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
672 * It is a handler who processes the HTML tag.
674 * @param pdoc [i/o] The pointer to the CHTML structure at the output
675 * destination is specified.
676 * @param node [i] The HTML tag node is specified.
677 * @return The conversion result is returned.
680 s_chtml40_start_html_tag(void *pdoc, Node *UNUSED(node))
682 chtml40_t *chtml40 = GET_CHTML40(pdoc);
683 Doc *doc = chtml40->doc;
685 /*--------------------------------------------------------------------------*/
687 /*--------------------------------------------------------------------------*/
695 * It is a handler who processes the HTML tag.
697 * @param pdoc [i/o] The pointer to the CHTML structure at the output
698 * destination is specified.
699 * @param node [i] The HTML tag node is specified.
700 * @return The conversion result is returned.
703 s_chtml40_end_html_tag(void *pdoc, Node *UNUSED(child))
705 chtml40_t *chtml40 = GET_CHTML40(pdoc);
706 Doc *doc = chtml40->doc;
714 * It is a handler who processes the META tag.
716 * @param pdoc [i/o] The pointer to the CHTML structure at the output
717 * destination is specified.
718 * @param node [i] The META tag node is specified.
719 * @return The conversion result is returned.
722 s_chtml40_start_meta_tag(void *pdoc, Node *node)
728 int content_type_flag;
731 chtml40 = GET_CHTML40(pdoc);
735 content_type_flag = 0;
739 /*--------------------------------------------------------------------------*/
741 /*--------------------------------------------------------------------------*/
742 for (attr = qs_get_attr(doc,node);
744 attr = qs_get_next_attr(doc,attr)) {
745 char *name = qs_get_attr_name(doc,attr);
746 char *value = qs_get_attr_value(doc,attr);
750 if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
751 /*----------------------------------------------------------------------*/
753 /*----------------------------------------------------------------------*/
754 W_L(" http-equiv=\"");
757 if (STRCASEEQ('c','C',"content-type", value))
758 content_type_flag = 1;
760 if (STRCASEEQ('r','R',"refresh", value))
767 if (strcasecmp(name, "content") == 0 && value && *value) {
768 if (content_type_flag) {
772 W_V(chxj_header_inf_set_content_type(r, "text/html; charset=SHIFT_JIS"));
780 buf = apr_pstrdup(r->pool, value);
781 url = strchr(buf, ';');
783 sec = apr_pstrdup(r->pool, buf);
786 url = chxj_encoding_parameter(r, url, 0);
787 url = chxj_add_cookie_parameter(r, url, chtml40->cookie);
817 * It is a handler who processes the META tag.
819 * @param pdoc [i/o] The pointer to the CHTML structure at the output
820 * destination is specified.
821 * @param node [i] The META tag node is specified.
822 * @return The conversion result is returned.
825 s_chtml40_end_meta_tag(void* pdoc, Node* UNUSED(child))
827 chtml40_t *chtml40 = GET_CHTML40(pdoc);
834 * It is a handler who processes the HEAD tag.
836 * @param pdoc [i/o] The pointer to the CHTML structure at the output
837 * destination is specified.
838 * @param node [i] The HEAD tag node is specified.
839 * @return The conversion result is returned.
842 s_chtml40_start_head_tag(void* pdoc, Node* UNUSED(node))
844 chtml40_t *chtml40 = GET_CHTML40(pdoc);
845 Doc *doc = chtml40->doc;
854 * It is a handler who processes the HEAD tag.
856 * @param pdoc [i/o] The pointer to the CHTML structure at the output
857 * destination is specified.
858 * @param node [i] The HEAD tag node is specified.
859 * @return The conversion result is returned.
862 s_chtml40_end_head_tag(void *pdoc, Node *UNUSED(node))
864 chtml40_t *chtml40 = GET_CHTML40(pdoc);
865 Doc *doc = chtml40->doc;
874 * It is a handler who processes the TITLE tag.
876 * @param pdoc [i/o] The pointer to the CHTML structure at the output
877 * destination is specified.
878 * @param node [i] The TITLE tag node is specified.
879 * @return The conversion result is returned.
882 s_chtml40_start_title_tag(void *pdoc, Node *UNUSED(node))
884 chtml40_t *chtml40 = GET_CHTML40(pdoc);
885 Doc *doc = chtml40->doc;
894 * It is a handler who processes the TITLE tag.
896 * @param pdoc [i/o] The pointer to the CHTML structure at the output
897 * destination is specified.
898 * @param node [i] The TITLE tag node is specified.
899 * @return The conversion result is returned.
902 s_chtml40_end_title_tag(void *pdoc, Node *UNUSED(child))
904 chtml40_t *chtml40 = GET_CHTML40(pdoc);
905 Doc *doc = chtml40->doc;
914 * It is a handler who processes the BASE tag.
916 * @param pdoc [i/o] The pointer to the CHTML structure at the output
917 * destination is specified.
918 * @param node [i] The BASE tag node is specified.
919 * @return The conversion result is returned.
922 s_chtml40_start_base_tag(void *pdoc, Node *node)
929 chtml40 = GET_CHTML40(pdoc);
934 /*--------------------------------------------------------------------------*/
936 /*--------------------------------------------------------------------------*/
937 for (attr = qs_get_attr(doc,node);
939 attr = qs_get_next_attr(doc,attr)) {
940 char *name = qs_get_attr_name(doc,attr);
941 char *value = qs_get_attr_value(doc,attr);
942 if (STRCASEEQ('h','H',"href", name)) {
955 * It is a handler who processes the BASE tag.
957 * @param pdoc [i/o] The pointer to the CHTML structure at the output
958 * destination is specified.
959 * @param node [i] The BASE tag node is specified.
960 * @return The conversion result is returned.
963 s_chtml40_end_base_tag(void *pdoc, Node *UNUSED(child))
965 chtml40_t *chtml40 = GET_CHTML40(pdoc);
972 * It is a handler who processes the BODY tag.
974 * @param pdoc [i/o] The pointer to the CHTML structure at the output
975 * destination is specified.
976 * @param node [i] The BODY tag node is specified.
977 * @return The conversion result is returned.
980 s_chtml40_start_body_tag(void *pdoc, Node *node)
986 char *attr_bgcolor = NULL;
987 char *attr_text = NULL;
988 char *attr_link = NULL;
989 char *attr_style = NULL;
990 char *attr_alink = NULL;
991 char *attr_vlink = NULL;
994 chtml40 = GET_CHTML40(pdoc);
998 /*--------------------------------------------------------------------------*/
1000 /*--------------------------------------------------------------------------*/
1001 for (attr = qs_get_attr(doc,node);
1003 attr = qs_get_next_attr(doc,attr)) {
1004 char *name = qs_get_attr_name(doc,attr);
1005 char *value = qs_get_attr_value(doc,attr);
1006 if (STRCASEEQ('b','B', "bgcolor", name) && value && *value) {
1007 /*----------------------------------------------------------------------*/
1009 /*----------------------------------------------------------------------*/
1010 attr_bgcolor = value;
1012 else if (STRCASEEQ('t','T', "text", name) && value && *value) {
1013 /*----------------------------------------------------------------------*/
1015 /*----------------------------------------------------------------------*/
1018 else if (STRCASEEQ('l','L',"link", name) && value && *value) {
1019 /*----------------------------------------------------------------------*/
1021 /*----------------------------------------------------------------------*/
1024 else if (STRCASEEQ('a','A',"alink", name) && value && *value) {
1025 /*----------------------------------------------------------------------*/
1027 /*----------------------------------------------------------------------*/
1030 else if (STRCASEEQ('v','V',"vlink", name) && value && *value) {
1031 /*----------------------------------------------------------------------*/
1033 /*----------------------------------------------------------------------*/
1036 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1041 if (IS_CSS_ON(chtml40->entryp)) {
1042 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1044 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1045 css_property_t *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
1046 css_property_t *cur;
1047 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1048 if (cur->value && *cur->value) {
1049 attr_text = apr_pstrdup(doc->pool, cur->value);
1052 for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
1053 if (cur->value && *cur->value) {
1054 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
1058 if (chtml40->style) {
1059 css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, chtml40->style);
1060 css_selector_t *cur_sel;
1061 for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
1062 if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
1063 css_property_t *cur;
1064 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1065 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1066 attr_link = apr_pstrdup(doc->pool, cur->value);
1070 else if (cur_sel->name && strcasecmp(cur_sel->name, "a:visited") == 0) {
1071 css_property_t *cur;
1072 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1073 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1074 attr_vlink = apr_pstrdup(doc->pool, cur->value);
1078 else if (cur_sel->name && strcasecmp(cur_sel->name, "a:focus") == 0) {
1079 css_property_t *cur;
1080 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1081 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1082 attr_alink = apr_pstrdup(doc->pool, cur->value);
1092 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
1098 attr_text = chxj_css_rgb_func_to_value(doc->pool, attr_text);
1104 attr_link = chxj_css_rgb_func_to_value(doc->pool, attr_link);
1110 attr_alink = chxj_css_rgb_func_to_value(doc->pool, attr_alink);
1116 attr_vlink = chxj_css_rgb_func_to_value(doc->pool, attr_vlink);
1123 return chtml40->out;
1128 * It is a handler who processes the BODY tag.
1130 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1131 * destination is specified.
1132 * @param node [i] The BODY tag node is specified.
1133 * @return The conversion result is returned.
1136 s_chtml40_end_body_tag(void *pdoc, Node *UNUSED(child))
1141 chtml40 = GET_CHTML40(pdoc);
1145 if (IS_CSS_ON(chtml40->entryp)) {
1146 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1149 return chtml40->out;
1154 * It is a handler who processes the A tag.
1156 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1157 * destination is specified.
1158 * @param node [i] The A tag node is specified.
1159 * @return The conversion result is returned.
1162 s_chtml40_start_a_tag(void *pdoc, Node *node)
1168 char *attr_style = NULL;
1170 chtml40 = GET_CHTML40(pdoc);
1175 /*--------------------------------------------------------------------------*/
1176 /* Get Attributes */
1177 /*--------------------------------------------------------------------------*/
1178 for (attr = qs_get_attr(doc,node);
1180 attr = qs_get_next_attr(doc,attr)) {
1181 char *name = qs_get_attr_name(doc,attr);
1182 char *value = qs_get_attr_value(doc,attr);
1183 if (STRCASEEQ('n','N',"name", name)) {
1184 /*----------------------------------------------------------------------*/
1186 /*----------------------------------------------------------------------*/
1191 else if (STRCASEEQ('h','H',"href", name)) {
1192 /*----------------------------------------------------------------------*/
1194 /*----------------------------------------------------------------------*/
1195 value = chxj_encoding_parameter(r, value, 0);
1196 if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
1197 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
1203 else if (STRCASEEQ('a','A',"accesskey", name)) {
1204 /*----------------------------------------------------------------------*/
1206 /*----------------------------------------------------------------------*/
1207 W_L(" accesskey=\"");
1211 else if (STRCASEEQ('c','C',"cti", name)) {
1212 /*----------------------------------------------------------------------*/
1214 /*----------------------------------------------------------------------*/
1219 else if (STRCASEEQ('i','I',"ijam", name)) {
1220 /*----------------------------------------------------------------------*/
1222 /*----------------------------------------------------------------------*/
1225 else if (STRCASEEQ('u','U',"utn", name)) {
1226 /*----------------------------------------------------------------------*/
1228 /* It is special only for CHTML. */
1229 /*----------------------------------------------------------------------*/
1232 else if (STRCASEEQ('t','T',"telbook", name)) {
1233 /*----------------------------------------------------------------------*/
1235 /*----------------------------------------------------------------------*/
1238 else if (STRCASEEQ('k','K',"kana", name)) {
1239 /*----------------------------------------------------------------------*/
1241 /*----------------------------------------------------------------------*/
1244 else if (STRCASEEQ('e','E',"email", name)) {
1245 /*----------------------------------------------------------------------*/
1247 /*----------------------------------------------------------------------*/
1250 else if (STRCASEEQ('i','I',"ista", name)) {
1251 /*----------------------------------------------------------------------*/
1253 /*----------------------------------------------------------------------*/
1256 else if (STRCASEEQ('i','I',"ilet", name)) {
1257 /*----------------------------------------------------------------------*/
1259 /*----------------------------------------------------------------------*/
1262 else if (STRCASEEQ('i','I',"iswf", name)) {
1263 /*----------------------------------------------------------------------*/
1265 /*----------------------------------------------------------------------*/
1268 else if (STRCASEEQ('i','I',"irst", name)) {
1269 /*----------------------------------------------------------------------*/
1271 /*----------------------------------------------------------------------*/
1274 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1280 if (IS_CSS_ON(chtml40->entryp)) {
1281 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1284 return chtml40->out;
1289 * It is a handler who processes the A tag.
1291 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1292 * destination is specified.
1293 * @param node [i] The A tag node is specified.
1294 * @return The conversion result is returned.
1297 s_chtml40_end_a_tag(void *pdoc, Node *UNUSED(child))
1302 chtml40 = GET_CHTML40(pdoc);
1307 if (IS_CSS_ON(chtml40->entryp)) {
1308 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1311 return chtml40->out;
1316 * It is a handler who processes the BR tag.
1318 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1319 * destination is specified.
1320 * @param node [i] The BR tag node is specified.
1321 * @return The conversion result is returned.
1324 s_chtml40_start_br_tag(void *pdoc, Node *node)
1331 chtml40 = GET_CHTML40(pdoc);
1335 /*--------------------------------------------------------------------------*/
1336 /* Get Attributes */
1337 /*--------------------------------------------------------------------------*/
1338 for (attr = qs_get_attr(doc,node);
1340 attr = qs_get_next_attr(doc,attr)) {
1341 char *name = qs_get_attr_name(doc,attr);
1342 char *value = qs_get_attr_value(doc,attr);
1343 if (STRCASEEQ('c','C',"clear",name)) {
1344 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1353 return chtml40->out;
1358 * It is a handler who processes the BR tag.
1360 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1361 * destination is specified.
1362 * @param node [i] The BR tag node is specified.
1363 * @return The conversion result is returned.
1366 s_chtml40_end_br_tag(void *pdoc, Node *UNUSED(child))
1368 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1370 return chtml40->out;
1375 * It is a handler who processes the TR tag.
1377 * @param chtml40 [i/o] The pointer to the CHTML structure at the output
1378 * destination is specified.
1379 * @param node [i] The TR tag node is specified.
1380 * @return The conversion result is returned.
1383 s_chtml40_start_tr_tag(void *pdoc, Node *UNUSED(node))
1385 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1387 return chtml40->out;
1392 * It is a handler who processes the TR tag.
1394 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1395 * destination is specified.
1396 * @param node [i] The TR tag node is specified.
1397 * @return The conversion result is returned.
1400 s_chtml40_end_tr_tag(void *pdoc, Node *UNUSED(child))
1406 chtml40 = GET_CHTML40(pdoc);
1412 return chtml40->out;
1417 * It is a handler who processes the FONT tag.
1419 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1420 * destination is specified.
1421 * @param node [i] The FONT tag node is specified.
1422 * @return The conversion result is returned.
1425 s_chtml40_start_font_tag(void *pdoc, Node *node)
1431 char *attr_color = NULL;
1432 char *attr_style = NULL;
1434 chtml40 = GET_CHTML40(pdoc);
1438 /*--------------------------------------------------------------------------*/
1439 /* Get Attributes */
1440 /*--------------------------------------------------------------------------*/
1441 for (attr = qs_get_attr(doc,node);
1443 attr = qs_get_next_attr(doc,attr)) {
1444 char *name = qs_get_attr_name(doc,attr);
1445 char *value = qs_get_attr_value(doc,attr);
1446 if (STRCASEEQ('c','C',"color", name) && value && *value) {
1447 attr_color = apr_pstrdup(doc->buf.pool, value);
1450 else if (STRCASEEQ('s','S',"size", name)) {
1451 /*----------------------------------------------------------------------*/
1453 /*----------------------------------------------------------------------*/
1456 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1460 if (IS_CSS_ON(chtml40->entryp)) {
1461 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1463 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1464 css_property_t *cur;
1465 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1466 if (cur->value && *cur->value) {
1467 attr_color = apr_pstrdup(doc->pool, cur->value);
1473 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1474 W_L("<font color=\"");
1477 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(*flg));
1478 flg->with_font_flag = 1;
1479 node->userData = flg;
1482 node->userData = NULL;
1484 return chtml40->out;
1489 * It is a handler who processes the FONT tag.
1491 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1492 * destination is specified.
1493 * @param node [i] The FONT tag node is specified.
1494 * @return The conversion result is returned.
1497 s_chtml40_end_font_tag(void *pdoc, Node *node)
1503 chtml40 = GET_CHTML40(pdoc);
1507 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1508 if (flg && flg->with_font_flag) {
1511 if (IS_CSS_ON(chtml40->entryp)) {
1512 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1515 return chtml40->out;
1520 * It is a handler who processes the FORM tag.
1522 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1523 * destination is specified.
1524 * @param node [i] The FORM tag node is specified.
1525 * @return The conversion result is returned.
1528 s_chtml40_start_form_tag(void *pdoc, Node *node)
1534 char *attr_action = NULL;
1535 char *attr_method = NULL;
1536 char *attr_style = NULL;
1537 char *attr_color = NULL;
1538 char *attr_align = NULL;
1539 char *attr_utn = NULL;
1540 char *new_hidden_tag = NULL;
1542 chtml40 = GET_CHTML40(pdoc);
1546 /*--------------------------------------------------------------------------*/
1547 /* Get Attributes */
1548 /*--------------------------------------------------------------------------*/
1549 for (attr = qs_get_attr(doc,node);
1551 attr = qs_get_next_attr(doc,attr)) {
1552 char *name = qs_get_attr_name(doc,attr);
1553 char *value = qs_get_attr_value(doc,attr);
1557 if (strcasecmp(name, "action") == 0) {
1558 /*--------------------------------------------------------------------*/
1560 /*--------------------------------------------------------------------*/
1561 attr_action = value;
1567 if (strcasecmp(name, "method") == 0) {
1568 /*--------------------------------------------------------------------*/
1570 /*--------------------------------------------------------------------*/
1571 attr_method = value;
1577 if (strcasecmp(name, "utn") == 0) {
1578 /*--------------------------------------------------------------------*/
1580 /*--------------------------------------------------------------------*/
1587 if (strcasecmp(name, "style") == 0) {
1596 if (IS_CSS_ON(chtml40->entryp)) {
1597 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1599 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
1600 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1601 css_property_t *cur;
1602 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
1603 if (STRCASEEQ('l','L',"left", cur->value)) {
1604 attr_align = apr_pstrdup(doc->pool, "left");
1606 else if (STRCASEEQ('c','C',"center",cur->value)) {
1607 attr_align = apr_pstrdup(doc->pool, "center");
1609 else if (STRCASEEQ('r','R',"right",cur->value)) {
1610 attr_align = apr_pstrdup(doc->pool, "right");
1613 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1614 attr_color = apr_pstrdup(doc->pool, cur->value);
1619 int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1623 attr_action = chxj_encoding_parameter(r, attr_action, 0);
1624 attr_action = chxj_add_cookie_parameter(r, attr_action, chtml40->cookie);
1626 char *new_query_string = NULL;
1627 q = strchr(attr_action, '?');
1629 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);
1630 if (new_hidden_tag || new_query_string) {
1636 if (new_query_string) {
1638 W_V(new_query_string);
1651 if (new_hidden_tag) {
1652 W_V(new_hidden_tag);
1655 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
1656 memset(flg, 0, sizeof(*flg));
1658 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1659 W_L("<font color=\"");
1662 flg->with_font_flag = 1;
1665 W_L("<div align=\"");
1668 flg->with_div_flag = 1;
1670 node->userData = flg;
1672 return chtml40->out;
1677 * It is a handler who processes the FORM tag.
1679 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1680 * destination is specified.
1681 * @param node [i] The FORM tag node is specified.
1682 * @return The conversion result is returned.
1685 s_chtml40_end_form_tag(void *pdoc, Node *node)
1690 chtml40 = GET_CHTML40(pdoc);
1693 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1694 if (flg && flg->with_div_flag) {
1697 if (flg && flg->with_font_flag) {
1701 if (IS_CSS_ON(chtml40->entryp)) {
1702 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1705 return chtml40->out;
1710 * It is a handler who processes the INPUT tag.
1712 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1713 * destination is specified.
1714 * @param node [i] The INPUT tag node is specified.
1715 * @return The conversion result is returned.
1718 s_chtml40_start_input_tag(void *pdoc, Node *node)
1724 char *attr_accesskey = NULL;
1725 char *attr_max_length = NULL;
1726 char *attr_type = NULL;
1727 char *attr_name = NULL;
1728 char *attr_value = NULL;
1729 char *attr_istyle = NULL;
1730 char *attr_size = NULL;
1731 char *attr_checked = NULL;
1732 char *attr_style = NULL;
1734 chtml40 = GET_CHTML40(pdoc);
1738 /*--------------------------------------------------------------------------*/
1739 /* Get Attributes */
1740 /*--------------------------------------------------------------------------*/
1741 for (attr = qs_get_attr(doc,node);
1743 attr = qs_get_next_attr(doc,attr)) {
1744 char *name = qs_get_attr_name(doc,attr);
1745 char *value = qs_get_attr_value(doc,attr);
1746 if (STRCASEEQ('t','T',"type",name) && value && *value) {
1747 char *tmp_type = qs_trim_string(doc->buf.pool, value);
1748 if (tmp_type && (STRCASEEQ('t','T',"text", tmp_type) ||
1749 STRCASEEQ('p','P',"password",tmp_type) ||
1750 STRCASEEQ('c','C',"checkbox",tmp_type) ||
1751 STRCASEEQ('r','R',"radio", tmp_type) ||
1752 STRCASEEQ('h','H',"hidden", tmp_type) ||
1753 STRCASEEQ('s','S',"submit", tmp_type) ||
1754 STRCASEEQ('r','R',"reset", tmp_type))) {
1755 attr_type = tmp_type;
1758 else if (STRCASEEQ('n','N',"name",name) && value && *value) {
1761 else if (STRCASEEQ('v','V',"value",name) && value && *value) {
1764 else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
1765 attr_istyle = value;
1767 else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
1768 attr_max_length = value;
1770 else if (STRCASEEQ('c','C',"checked", name)) {
1771 attr_checked = value;
1773 else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
1774 attr_accesskey = value;
1776 else if (STRCASEEQ('s','S',"size", name) && value && *value) {
1779 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1784 if (IS_CSS_ON(chtml40->entryp)) {
1785 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
1787 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
1788 css_property_t *cur;
1789 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
1790 if (strcasestr(cur->value, "<ja:n>")) {
1793 else if (strcasestr(cur->value, "<ja:en>")) {
1796 else if (strcasestr(cur->value, "<ja:hk>")) {
1799 else if (strcasestr(cur->value, "<ja:h>")) {
1823 if (attr_type && (STRCASEEQ('s','S',"submit",attr_type) || STRCASEEQ('r','R',"reset",attr_type))) {
1824 apr_size_t value_len = strlen(attr_value);
1825 attr_value = chxj_conv_z2h(r, attr_value, &value_len, chtml40->entryp);
1829 W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
1832 if (attr_accesskey) {
1833 W_L(" accesskey=\"");
1834 W_V(attr_accesskey);
1838 if (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4') {
1844 /*--------------------------------------------------------------------------*/
1845 /* The figure is default for the password. */
1846 /*--------------------------------------------------------------------------*/
1847 if (attr_max_length) {
1848 if (chxj_chk_numeric(attr_max_length) != 0) {
1849 attr_max_length = apr_psprintf(doc->buf.pool, "0");
1851 if (attr_istyle && *attr_istyle == '1') {
1852 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length) * 2);
1856 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length));
1865 return chtml40->out;
1870 * It is a handler who processes the INPUT tag.
1872 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1873 * destination is specified.
1874 * @param node [i] The INPUT tag node is specified.
1875 * @return The conversion result is returned.
1878 s_chtml40_end_input_tag(void *pdoc, Node *UNUSED(child))
1880 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1882 return chtml40->out;
1887 * It is a handler who processes the CENTER tag.
1889 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1890 * destination is specified.
1891 * @param node [i] The CENTER tag node is specified.
1892 * @return The conversion result is returned.
1895 s_chtml40_start_center_tag(void *pdoc, Node *node)
1900 char *attr_style = NULL;
1901 char *attr_color = NULL;
1903 chtml40 = GET_CHTML40(pdoc);
1906 for (attr = qs_get_attr(doc,node);
1908 attr = qs_get_next_attr(doc,attr)) {
1909 char *name = qs_get_attr_name(doc,attr);
1910 char *value = qs_get_attr_value(doc,attr);
1911 if (STRCASEEQ('s','S',"style",name) && value && *value) {
1915 if (IS_CSS_ON(chtml40->entryp)) {
1916 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1918 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1919 css_property_t *cur;
1920 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1921 if (cur->value && *cur->value) {
1922 attr_color = apr_pstrdup(doc->pool, cur->value);
1929 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
1930 memset(flg, 0, sizeof(*flg));
1932 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1933 W_L("<font color=\"");
1936 flg->with_font_flag = 1;
1938 node->userData = flg;
1940 return chtml40->out;
1945 * It is a handler who processes the CENTER tag.
1947 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1948 * destination is specified.
1949 * @param node [i] The CENTER tag node is specified.
1950 * @return The conversion result is returned.
1953 s_chtml40_end_center_tag(void *pdoc, Node *node)
1958 chtml40 = GET_CHTML40(pdoc);
1961 if (IS_CSS_ON(chtml40->entryp)) {
1962 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1964 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1965 if (flg && flg->with_font_flag) {
1970 return chtml40->out;
1975 * It is a handler who processes the HR tag.
1977 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1978 * destination is specified.
1979 * @param node [i] The HR tag node is specified.
1980 * @return The conversion result is returned.
1983 s_chtml40_start_hr_tag(void *pdoc, Node *node)
1989 char *attr_align = NULL;
1990 char *attr_size = NULL;
1991 char *attr_width = NULL;
1992 char *attr_noshade = NULL;
1993 char *attr_style = NULL;
1994 char *attr_color = NULL;
1996 chtml40 = GET_CHTML40(pdoc);
2000 for (attr = qs_get_attr(doc,node);
2002 attr = qs_get_next_attr(doc,attr)) {
2003 char *name = qs_get_attr_name (doc,attr);
2004 char *value = qs_get_attr_value(doc,attr);
2008 if (strcasecmp(name, "align") == 0) {
2009 /*--------------------------------------------------------------------*/
2011 /*--------------------------------------------------------------------*/
2012 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2020 if (strcasecmp(name, "size") == 0) {
2021 /*--------------------------------------------------------------------*/
2023 /*--------------------------------------------------------------------*/
2024 if (value && *value) {
2028 else if (strcasecmp(name, "style") == 0) {
2029 if (value && *value) {
2037 if (strcasecmp(name, "width") == 0) {
2038 /*--------------------------------------------------------------------*/
2040 /*--------------------------------------------------------------------*/
2041 if (value && *value) {
2049 if (strcasecmp(name, "noshade") == 0) {
2050 /*--------------------------------------------------------------------*/
2052 /*--------------------------------------------------------------------*/
2053 attr_noshade = apr_pstrdup(doc->pool, "noshade");
2059 if (strcasecmp(name, "color") == 0 && value && *value) {
2060 /*--------------------------------------------------------------------*/
2062 /*--------------------------------------------------------------------*/
2071 if (IS_CSS_ON(chtml40->entryp)) {
2072 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2074 css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2075 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2076 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2077 css_property_t *cur;
2078 for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2079 if (STRCASEEQ('s','S',"solid",cur->value)) {
2080 attr_noshade = "noshade";
2083 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2084 char *tmp = apr_pstrdup(doc->pool, cur->value);
2085 char *tmpp = strstr(tmp, "px");
2088 attr_size = apr_pstrdup(doc->pool, tmp);
2091 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2092 char *tmp = apr_pstrdup(doc->pool, cur->value);
2093 char *tmpp = strstr(tmp, "px");
2096 attr_width = apr_pstrdup(doc->pool, tmp);
2099 tmpp = strstr(tmp, "%");
2101 attr_width = apr_pstrdup(doc->pool, tmp);
2132 return chtml40->out;
2137 * It is a handler who processes the HR tag.
2139 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2140 * destination is specified.
2141 * @param node [i] The HR tag node is specified.
2142 * @return The conversion result is returned.
2145 s_chtml40_end_hr_tag(void *pdoc, Node *UNUSED(child))
2147 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2149 return chtml40->out;
2154 * It is a handler who processes the IMG tag.
2156 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2157 * destination is specified.
2158 * @param node [i] The IMG tag node is specified.
2159 * @return The conversion result is returned.
2162 s_chtml40_start_img_tag(void *pdoc, Node *node)
2168 char *attr_src = NULL;
2169 char *attr_align = NULL;
2170 char *attr_style = NULL;
2171 char *attr_alt = NULL;
2172 char *attr_width = NULL;
2173 char *attr_height = NULL;
2174 char *attr_hspace = NULL;
2175 char *attr_vspace = NULL;
2176 #ifndef IMG_NOT_CONVERT_FILENAME
2180 chtml40 = GET_CHTML40(pdoc);
2181 #ifndef IMG_NOT_CONVERT_FILENAME
2182 spec = chtml40->spec;
2187 /*--------------------------------------------------------------------------*/
2188 /* Get Attributes */
2189 /*--------------------------------------------------------------------------*/
2190 for (attr = qs_get_attr(doc,node);
2192 attr = qs_get_next_attr(doc,attr)) {
2193 char *name = qs_get_attr_name (doc,attr);
2194 char *value = qs_get_attr_value(doc,attr);
2198 if (strcasecmp(name, "src") == 0) {
2199 /*--------------------------------------------------------------------*/
2201 /*--------------------------------------------------------------------*/
2202 #ifdef IMG_NOT_CONVERT_FILENAME
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);
2208 value = chxj_img_conv(r,spec,value);
2209 value = chxj_encoding_parameter(r, value, 0);
2210 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
2211 value = chxj_add_cookie_no_update_parameter(r, value);
2215 else if (strcasecmp(name,"style") == 0 && value && *value) {
2222 if (strcasecmp(name, "align" ) == 0) {
2223 /*--------------------------------------------------------------------*/
2225 /*--------------------------------------------------------------------*/
2226 /*--------------------------------------------------------------------*/
2228 /*--------------------------------------------------------------------*/
2230 if (STRCASEEQ('t','T',"top", value) ||
2231 STRCASEEQ('m','M',"middle",value) ||
2232 STRCASEEQ('b','B',"bottom",value) ||
2233 STRCASEEQ('l','L',"left", value) ||
2234 STRCASEEQ('r','R',"right", value)) {
2237 else if (STRCASEEQ('c','C',"center", value)) {
2238 attr_align = apr_pstrdup(doc->pool, "middle");
2242 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2243 /*--------------------------------------------------------------------*/
2245 /*--------------------------------------------------------------------*/
2252 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2253 /*--------------------------------------------------------------------*/
2255 /*--------------------------------------------------------------------*/
2262 if (strcasecmp(name, "height") == 0 && value && *value) {
2263 /*--------------------------------------------------------------------*/
2265 /*--------------------------------------------------------------------*/
2266 attr_height = value;
2269 if (strcasecmp(name, "hspace") == 0 && value && *value) {
2270 /*--------------------------------------------------------------------*/
2272 /*--------------------------------------------------------------------*/
2273 attr_hspace = value;
2279 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2280 /*--------------------------------------------------------------------*/
2282 /*--------------------------------------------------------------------*/
2283 attr_vspace = value;
2292 if (IS_CSS_ON(chtml40->entryp)) {
2293 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2295 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2296 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2297 css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
2298 css_property_t *cur;
2299 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2300 attr_height = apr_pstrdup(doc->pool, cur->value);
2302 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2303 attr_width = apr_pstrdup(doc->pool, cur->value);
2305 for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
2306 attr_align = apr_pstrdup(doc->pool, cur->value);
2348 return chtml40->out;
2353 * It is a handler who processes the IMG tag.
2355 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2356 * destination is specified.
2357 * @param node [i] The IMG tag node is specified.
2358 * @return The conversion result is returned.
2361 s_chtml40_end_img_tag(void *pdoc, Node *UNUSED(child))
2363 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2365 return chtml40->out;
2370 * It is a handler who processes the SELECT tag.
2372 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2373 * destination is specified.
2374 * @param node [i] The SELECT tag node is specified.
2375 * @return The conversion result is returned.
2378 s_chtml40_start_select_tag(void *pdoc, Node *node)
2380 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2381 Doc *doc = chtml40->doc;
2384 char *multiple = NULL;
2386 char *attr_style = NULL;
2389 for (attr = qs_get_attr(doc,node);
2391 attr = qs_get_next_attr(doc,attr)) {
2392 char *nm = qs_get_attr_name(doc,attr);
2393 char *val = qs_get_attr_value(doc,attr);
2394 if (STRCASEEQ('s','S',"size", nm)) {
2395 /*----------------------------------------------------------------------*/
2396 /* CHTML 1.0 version 2.0 */
2397 /*----------------------------------------------------------------------*/
2398 size = apr_pstrdup(doc->buf.pool, val);
2400 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2401 /*----------------------------------------------------------------------*/
2402 /* CHTML 1.0 version 2.0 */
2403 /*----------------------------------------------------------------------*/
2404 attr_style = apr_pstrdup(doc->buf.pool, val);
2406 else if (STRCASEEQ('n','N',"name", nm)) {
2407 /*----------------------------------------------------------------------*/
2408 /* CHTML 1.0 version 2.0 */
2409 /*----------------------------------------------------------------------*/
2410 name = apr_pstrdup(doc->buf.pool, val);
2412 else if (STRCASEEQ('m','M',"multiple", nm)) {
2413 /*----------------------------------------------------------------------*/
2414 /* CHTML 1.0 version 2.0 */
2415 /*----------------------------------------------------------------------*/
2416 multiple = apr_pstrdup(doc->buf.pool, val);
2419 if (size && *size) {
2424 if (name && *name) {
2433 if (IS_CSS_ON(chtml40->entryp)) {
2434 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2436 return chtml40->out;
2441 * It is a handler who processes the SELECT tag.
2443 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2444 * destination is specified.
2445 * @param node [i] The SELECT tag node is specified.
2446 * @return The conversion result is returned.
2449 s_chtml40_end_select_tag(void *pdoc, Node *UNUSED(child))
2451 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2452 Doc *doc = chtml40->doc;
2455 if (IS_CSS_ON(chtml40->entryp)) {
2456 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2458 return chtml40->out;
2463 * It is a handler who processes the OPTION tag.
2465 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2466 * destination is specified.
2467 * @param node [i] The OPTION tag node is specified.
2468 * @return The conversion result is returned.
2471 s_chtml40_start_option_tag(void *pdoc, Node *node)
2479 char *attr_style = NULL;
2481 chtml40 = GET_CHTML40(pdoc);
2488 for (attr = qs_get_attr(doc,node);
2490 attr = qs_get_next_attr(doc,attr)) {
2491 char *nm = qs_get_attr_name(doc,attr);
2492 char *val = qs_get_attr_value(doc,attr);
2493 if (STRCASEEQ('s','S',"selected", nm)) {
2494 /*----------------------------------------------------------------------*/
2495 /* CHTML 1.0 version 2.0 */
2496 /*----------------------------------------------------------------------*/
2497 selected = apr_pstrdup(doc->buf.pool, val);
2499 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2500 /*----------------------------------------------------------------------*/
2501 /* CHTML 1.0 version 2.0 */
2502 /*----------------------------------------------------------------------*/
2503 attr_style = apr_pstrdup(doc->buf.pool, val);
2505 else if (STRCASEEQ('v','V',"value", nm)) {
2506 /*----------------------------------------------------------------------*/
2507 /* CHTML 1.0 version 2.0 */
2508 /*----------------------------------------------------------------------*/
2509 value = apr_pstrdup(doc->buf.pool, val);
2522 if (IS_CSS_ON(chtml40->entryp)) {
2523 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2526 return chtml40->out;
2531 * It is a handler who processes the OPTION tag.
2533 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2534 * destination is specified.
2535 * @param node [i] The OPTION tag node is specified.
2536 * @return The conversion result is returned.
2539 s_chtml40_end_option_tag(void *pdoc, Node *UNUSED(child))
2541 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2544 if (IS_CSS_ON(chtml40->entryp)) {
2545 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2548 return chtml40->out;
2553 * It is a handler who processes the DIV tag.
2555 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2556 * destination is specified.
2557 * @param node [i] The DIV tag node is specified.
2558 * @return The conversion result is returned.
2561 s_chtml40_start_div_tag(void *pdoc, Node *node)
2567 char *attr_style = NULL;
2568 char *attr_align = NULL;
2569 char *attr_display = NULL;
2570 char *attr_decoration = NULL;
2571 char *attr_wap_marquee_style = NULL;
2572 char *attr_wap_marquee_dir = NULL;
2573 char *attr_wap_marquee_loop = NULL;
2574 char *attr_color = NULL;
2575 char *attr_bgcolor = NULL;
2577 chtml40 = GET_CHTML40(pdoc);
2581 for (attr = qs_get_attr(doc,node);
2583 attr = qs_get_next_attr(doc,attr)) {
2584 char *nm = qs_get_attr_name(doc,attr);
2585 char *val = qs_get_attr_value(doc,attr);
2586 if (STRCASEEQ('a','A', "align", nm)) {
2587 /*----------------------------------------------------------------------*/
2588 /* CHTML 1.0 (W3C version 3.2) */
2589 /*----------------------------------------------------------------------*/
2590 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2591 attr_align = apr_pstrdup(doc->buf.pool, val);
2594 else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
2595 attr_style = apr_pstrdup(doc->buf.pool, val);
2599 if (IS_CSS_ON(chtml40->entryp)) {
2600 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2602 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
2603 css_property_t *text_decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
2604 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
2605 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2606 css_property_t *background_color_prop = chxj_css_get_property_value(doc, style, "background-color");
2607 css_property_t *background_prop = chxj_css_get_property_value(doc, style, "background");
2609 css_property_t *cur;
2610 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
2611 if (strcasecmp("-wap-marquee", cur->value) == 0) {
2612 attr_display = apr_pstrdup(doc->pool, cur->value);
2615 for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
2616 if (STRCASEEQ('b','B',"blink", cur->value)) {
2617 attr_decoration = apr_pstrdup(doc->pool, cur->value);
2620 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2621 attr_color = apr_pstrdup(doc->pool, cur->value);
2622 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2624 for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
2625 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
2626 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
2628 for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
2629 char *ss = strchr(cur->value, '#');
2631 ss = strstr(cur->value, "rgb");
2634 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
2635 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
2638 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2639 attr_align = apr_pstrdup(doc->pool, cur->value);
2642 css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
2643 css_property_t *wap_marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
2644 css_property_t *wap_marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
2645 for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
2646 if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
2647 attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
2650 for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
2651 if (STRCASEEQ('l','L',"ltr",cur->value)) {
2652 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "right");
2654 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
2655 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "left");
2658 for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
2659 if (STRCASEEQ('i','I',"infinite",cur->value)) {
2660 attr_wap_marquee_loop = apr_pstrdup(doc->pool, "16");
2663 attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
2669 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
2670 memset(flg, 0, sizeof(*flg));
2677 flg->with_div_flag = 1;
2681 flg->with_div_flag = 1;
2684 if (attr_bgcolor && (STRCASEEQ('w','W',"white",attr_color) || STRCASEEQ('#','#',"#ffffff",attr_color))) {
2688 W_L("<font color=\"");
2691 flg->with_font_flag = 1;
2694 if (attr_decoration) {
2696 flg->with_blink_flag = 1;
2700 if (attr_wap_marquee_style) {
2701 W_L(" behavior=\"");
2702 W_V(attr_wap_marquee_style);
2705 if (attr_wap_marquee_dir) {
2706 W_L(" direction=\"");
2707 W_V(attr_wap_marquee_dir);
2710 if (attr_wap_marquee_loop) {
2712 W_V(attr_wap_marquee_loop);
2716 flg->with_marquee_flag = 1;
2718 node->userData = flg;
2720 return chtml40->out;
2725 * It is a handler who processes the DIV tag.
2727 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2728 * destination is specified.
2729 * @param node [i] The DIV tag node is specified.
2730 * @return The conversion result is returned.
2733 s_chtml40_end_div_tag(void *pdoc, Node *node)
2735 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2736 Doc *doc = chtml40->doc;
2738 chtml40_flags_t *flg = node->userData;
2739 if (flg && flg->with_marquee_flag) {
2742 if (flg && flg->with_blink_flag) {
2745 if (flg && flg->with_font_flag) {
2748 if (flg && flg->with_div_flag) {
2751 if (IS_CSS_ON(chtml40->entryp)) {
2752 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2754 node->userData = NULL;
2756 return chtml40->out;
2761 * It is a handler who processes the UL tag.
2763 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2764 * destination is specified.
2765 * @param node [i] The UL tag node is specified.
2766 * @return The conversion result is returned.
2769 s_chtml40_start_ul_tag(void *pdoc, Node *node)
2771 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2772 Doc *doc = chtml40->doc;
2774 char *attr_type = NULL;
2775 char *attr_style = NULL;
2776 /*--------------------------------------------------------------------------*/
2777 /* Get Attributes */
2778 /*--------------------------------------------------------------------------*/
2779 for (attr = qs_get_attr(doc,node);
2781 attr = qs_get_next_attr(doc,attr)) {
2782 char *name = qs_get_attr_name(doc,attr);
2783 char *value = qs_get_attr_value(doc,attr);
2784 if (STRCASEEQ('t','T',"type",name)) {
2785 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2789 else if (value && *value && STRCASEEQ('s','S',"style", name)) {
2793 if (IS_CSS_ON(chtml40->entryp)) {
2794 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2796 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2797 css_property_t *cur;
2798 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2799 if (STRCASEEQ('d','D',"disc",cur->value)) {
2800 attr_type = apr_pstrdup(doc->pool, "disc");
2802 else if (STRCASEEQ('c','C',"circle",cur->value)) {
2803 attr_type = apr_pstrdup(doc->pool, "circle");
2805 else if (STRCASEEQ('s','S',"square",cur->value)) {
2806 attr_type = apr_pstrdup(doc->pool, "square");
2819 return chtml40->out;
2824 * It is a handler who processes the UL tag.
2826 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2827 * destination is specified.
2828 * @param node [i] The UL tag node is specified.
2829 * @return The conversion result is returned.
2832 s_chtml40_end_ul_tag(void *pdoc, Node *UNUSED(child))
2834 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2835 Doc *doc = chtml40->doc;
2838 if (IS_CSS_ON(chtml40->entryp)) {
2839 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2842 return chtml40->out;
2847 * It is a handler who processes the PRE tag.
2849 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2850 * destination is specified.
2851 * @param node [i] The PRE tag node is specified.
2852 * @return The conversion result is returned.
2855 s_chtml40_start_pre_tag(void *pdoc, Node *node)
2857 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2858 Doc *doc = chtml40->doc;
2860 char *attr_style = NULL;
2862 for (attr = qs_get_attr(doc,node);
2864 attr = qs_get_next_attr(doc,attr)) {
2865 char *nm = qs_get_attr_name(doc,attr);
2866 char *val = qs_get_attr_value(doc,attr);
2867 if (val && STRCASEEQ('s','S',"style", nm)) {
2872 if (IS_CSS_ON(chtml40->entryp)) {
2873 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2876 chtml40->pre_flag++;
2879 return chtml40->out;
2884 * It is a handler who processes the PRE tag.
2886 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2887 * destination is specified.
2888 * @param node [i] The PRE tag node is specified.
2889 * @return The conversion result is returned.
2892 s_chtml40_end_pre_tag(void *pdoc, Node *UNUSED(child))
2894 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2895 Doc *doc = chtml40->doc;
2898 chtml40->pre_flag--;
2899 if (IS_CSS_ON(chtml40->entryp)) {
2900 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2903 return chtml40->out;
2908 * It is a handler who processes the P tag.
2910 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2911 * destination is specified.
2912 * @param node [i] The P tag node is specified.
2913 * @return The conversion result is returned.
2916 s_chtml40_start_p_tag(void *pdoc, Node *node)
2922 char *attr_align = NULL;
2923 char *attr_style = NULL;
2924 char *attr_color = NULL;
2925 char *attr_blink = NULL;
2927 chtml40 = GET_CHTML40(pdoc);
2931 for (attr = qs_get_attr(doc,node);
2933 attr = qs_get_next_attr(doc,attr)) {
2934 char *nm = qs_get_attr_name(doc,attr);
2935 char *val = qs_get_attr_value(doc,attr);
2936 if (STRCASEEQ('a','A',"align", nm)) {
2937 /*----------------------------------------------------------------------*/
2938 /* CHTML 1.0 (W3C version 3.2) */
2939 /*----------------------------------------------------------------------*/
2940 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2941 attr_align = apr_pstrdup(doc->buf.pool, val);
2945 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2946 attr_style = apr_pstrdup(doc->buf.pool, val);
2949 if (IS_CSS_ON(chtml40->entryp)) {
2950 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2952 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2953 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
2954 css_property_t *text_deco_prop = chxj_css_get_property_value(doc, style, "text-decoration");
2955 css_property_t *cur;
2956 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2957 if (STRCASEEQ('l','L',"left",cur->value)) {
2958 attr_align = apr_pstrdup(doc->pool, "left");
2960 else if (STRCASEEQ('c','C',"center",cur->value)) {
2961 attr_align = apr_pstrdup(doc->pool, "center");
2963 else if (STRCASEEQ('r','R',"right",cur->value)) {
2964 attr_align = apr_pstrdup(doc->pool, "right");
2967 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2968 if (cur->value && *cur->value) {
2969 attr_color = apr_pstrdup(doc->pool, cur->value);
2972 for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
2973 if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
2974 attr_blink = apr_pstrdup(doc->pool, cur->value);
2987 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
2988 memset(flg, 0, sizeof(*flg));
2990 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2991 W_L("<font color=\"");
2994 flg->with_font_flag = 1;
2998 flg->with_blink_flag = 1;
3000 node->userData = (void *)flg;
3002 return chtml40->out;
3007 * It is a handler who processes the P tag.
3009 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3010 * destination is specified.
3011 * @param node [i] The P tag node is specified.
3012 * @return The conversion result is returned.
3015 s_chtml40_end_p_tag(void *pdoc, Node *node)
3020 chtml40 = GET_CHTML40(pdoc);
3023 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
3024 if (flg->with_font_flag) {
3027 if (flg->with_blink_flag) {
3031 if (IS_CSS_ON(chtml40->entryp)) {
3032 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3035 return chtml40->out;
3040 * It is a handler who processes the OL tag.
3042 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3043 * destination is specified.
3044 * @param node [i] The OL tag node is specified.
3045 * @return The conversion result is returned.
3048 s_chtml40_start_ol_tag(void *pdoc, Node *node)
3054 char *attr_style = NULL;
3055 char *attr_start = NULL;
3056 char *attr_type = NULL;
3058 chtml40 = GET_CHTML40(pdoc);
3062 /*--------------------------------------------------------------------------*/
3063 /* Get Attributes */
3064 /*--------------------------------------------------------------------------*/
3065 for (attr = qs_get_attr(doc,node);
3067 attr = qs_get_next_attr(doc,attr)) {
3068 char *name = qs_get_attr_name(doc,attr);
3069 char *value = qs_get_attr_value(doc,attr);
3070 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
3073 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
3076 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3080 if (IS_CSS_ON(chtml40->entryp)) {
3081 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3083 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3084 css_property_t *cur;
3085 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3086 if (STRCASEEQ('d','D',"decimal", cur->value)) {
3087 attr_type = apr_pstrdup(doc->pool, "1");
3089 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3090 attr_type = apr_pstrdup(doc->pool, "A");
3092 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3093 attr_type = apr_pstrdup(doc->pool, "a");
3122 return chtml40->out;
3127 * It is a handler who processes the OL tag.
3129 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3130 * destination is specified.
3131 * @param node [i] The OL tag node is specified.
3132 * @return The conversion result is returned.
3135 s_chtml40_end_ol_tag(void *pdoc, Node *UNUSED(node))
3137 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3138 Doc *doc = chtml40->doc;
3141 if (IS_CSS_ON(chtml40->entryp)) {
3142 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3145 return chtml40->out;
3150 * It is a handler who processes the LI tag.
3152 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3153 * destination is specified.
3154 * @param node [i] The LI tag node is specified.
3155 * @return The conversion result is returned.
3158 s_chtml40_start_li_tag(void *pdoc, Node *node)
3160 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3161 Doc *doc = chtml40->doc;
3163 char *attr_type = NULL;
3164 char *attr_value = NULL;
3165 char *attr_style = NULL;
3167 /*--------------------------------------------------------------------------*/
3168 /* Get Attributes */
3169 /*--------------------------------------------------------------------------*/
3170 for (attr = qs_get_attr(doc,node);
3172 attr = qs_get_next_attr(doc,attr)) {
3173 char *name = qs_get_attr_name(doc,attr);
3174 char *value = qs_get_attr_value(doc,attr);
3175 if (STRCASEEQ('t','T',"type",name)) {
3176 if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
3180 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
3183 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3187 if (IS_CSS_ON(chtml40->entryp)) {
3188 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3190 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3191 css_property_t *cur;
3192 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3193 if (STRCASEEQ('d','D',"decimal", cur->value)) {
3194 attr_type = apr_pstrdup(doc->pool, "1");
3196 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3197 attr_type = apr_pstrdup(doc->pool, "A");
3199 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3200 attr_type = apr_pstrdup(doc->pool, "a");
3202 else if (STRCASEEQ('d','D',"disc", cur->value)) {
3203 attr_type = apr_pstrdup(doc->pool, "disc");
3205 else if (STRCASEEQ('s','S',"square", cur->value)) {
3206 attr_type = apr_pstrdup(doc->pool, "square");
3208 else if (STRCASEEQ('c','C',"circle", cur->value)) {
3209 attr_type = apr_pstrdup(doc->pool, "circle");
3227 return chtml40->out;
3232 * It is a handler who processes the LI tag.
3234 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3235 * destination is specified.
3236 * @param node [i] The LI tag node is specified.
3237 * @return The conversion result is returned.
3240 s_chtml40_end_li_tag(void *pdoc, Node *UNUSED(child))
3242 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3244 if (IS_CSS_ON(chtml40->entryp)) {
3245 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3247 return chtml40->out;
3252 * It is a handler who processes the H1 tag.
3254 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3255 * destination is specified.
3256 * @param node [i] The H1 tag node is specified.
3257 * @return The conversion result is returned.
3260 s_chtml40_start_h1_tag(void *pdoc, Node *node)
3266 char *attr_style = NULL;
3267 char *attr_align = NULL;
3269 chtml40 = GET_CHTML40(pdoc);
3273 for (attr = qs_get_attr(doc,node);
3275 attr = qs_get_next_attr(doc,attr)) {
3276 char *name = qs_get_attr_name(doc,attr);
3277 char *value = qs_get_attr_value(doc,attr);
3278 if (STRCASEEQ('a','A',"align", name)) {
3279 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3283 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3287 if (IS_CSS_ON(chtml40->entryp)) {
3288 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3290 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3291 css_property_t *cur;
3292 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3293 if (STRCASEEQ('l','L',"left", cur->value)) {
3294 attr_align = apr_pstrdup(doc->pool, "left");
3296 else if (STRCASEEQ('c','C',"center",cur->value)) {
3297 attr_align = apr_pstrdup(doc->pool, "center");
3299 else if (STRCASEEQ('r','R',"right",cur->value)) {
3300 attr_align = apr_pstrdup(doc->pool, "right");
3313 return chtml40->out;
3318 * It is a handler who processes the H1 tag.
3320 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3321 * destination is specified.
3322 * @param node [i] The H1 tag node is specified.
3323 * @return The conversion result is returned.
3326 s_chtml40_end_h1_tag(void *pdoc, Node *UNUSED(child))
3331 chtml40 = GET_CHTML40(pdoc);
3335 if (IS_CSS_ON(chtml40->entryp)) {
3336 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3339 return chtml40->out;
3344 * It is a handler who processes the H2 tag.
3346 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3347 * destination is specified.
3348 * @param node [i] The H2 tag node is specified.
3349 * @return The conversion result is returned.
3352 s_chtml40_start_h2_tag(void *pdoc, Node *node)
3358 char *attr_style = NULL;
3359 char *attr_align = NULL;
3361 chtml40 = GET_CHTML40(pdoc);
3365 for (attr = qs_get_attr(doc,node);
3367 attr = qs_get_next_attr(doc,attr)) {
3368 char *name = qs_get_attr_name(doc,attr);
3369 char *value = qs_get_attr_value(doc,attr);
3370 if (STRCASEEQ('a','A',"align", name)) {
3371 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3375 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3379 if (IS_CSS_ON(chtml40->entryp)) {
3380 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3382 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3383 css_property_t *cur;
3384 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3385 if (STRCASEEQ('l','L',"left", cur->value)) {
3386 attr_align = apr_pstrdup(doc->pool, "left");
3388 else if (STRCASEEQ('c','C',"center",cur->value)) {
3389 attr_align = apr_pstrdup(doc->pool, "center");
3391 else if (STRCASEEQ('r','R',"right",cur->value)) {
3392 attr_align = apr_pstrdup(doc->pool, "right");
3405 return chtml40->out;
3410 * It is a handler who processes the H2 tag.
3412 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3413 * destination is specified.
3414 * @param node [i] The H2 tag node is specified.
3415 * @return The conversion result is returned.
3418 s_chtml40_end_h2_tag(void *pdoc, Node *UNUSED(child))
3420 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3421 Doc *doc = chtml40->doc;
3424 if (IS_CSS_ON(chtml40->entryp)) {
3425 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3428 return chtml40->out;
3433 * It is a handler who processes the H3 tag.
3435 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3436 * destination is specified.
3437 * @param node [i] The H3 tag node is specified.
3438 * @return The conversion result is returned.
3441 s_chtml40_start_h3_tag(void *pdoc, Node *node)
3447 char *attr_style = NULL;
3448 char *attr_align = NULL;
3450 chtml40 = GET_CHTML40(pdoc);
3454 for (attr = qs_get_attr(doc,node);
3456 attr = qs_get_next_attr(doc,attr)) {
3457 char *name = qs_get_attr_name(doc,attr);
3458 char *value = qs_get_attr_value(doc,attr);
3459 if (STRCASEEQ('a','A',"align", name)) {
3460 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3464 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3468 if (IS_CSS_ON(chtml40->entryp)) {
3469 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3471 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3472 css_property_t *cur;
3473 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3474 if (STRCASEEQ('l','L',"left", cur->value)) {
3475 attr_align = apr_pstrdup(doc->pool, "left");
3477 else if (STRCASEEQ('c','C',"center",cur->value)) {
3478 attr_align = apr_pstrdup(doc->pool, "center");
3480 else if (STRCASEEQ('r','R',"right",cur->value)) {
3481 attr_align = apr_pstrdup(doc->pool, "right");
3494 return chtml40->out;
3499 * It is a handler who processes the H3 tag.
3501 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3502 * destination is specified.
3503 * @param node [i] The H3 tag node is specified.
3504 * @return The conversion result is returned.
3507 s_chtml40_end_h3_tag(void *pdoc, Node *UNUSED(child))
3509 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3510 Doc *doc = chtml40->doc;
3513 if (IS_CSS_ON(chtml40->entryp)) {
3514 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3517 return chtml40->out;
3522 * It is a handler who processes the H4 tag.
3524 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3525 * destination is specified.
3526 * @param node [i] The H4 tag node is specified.
3527 * @return The conversion result is returned.
3530 s_chtml40_start_h4_tag(void *pdoc, Node *node)
3536 char *attr_style = NULL;
3537 char *attr_align = NULL;
3539 chtml40 = GET_CHTML40(pdoc);
3543 for (attr = qs_get_attr(doc,node);
3545 attr = qs_get_next_attr(doc,attr)) {
3546 char *name = qs_get_attr_name(doc,attr);
3547 char *value = qs_get_attr_value(doc,attr);
3548 if (STRCASEEQ('a','A',"align", name)) {
3549 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3553 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3557 if (IS_CSS_ON(chtml40->entryp)) {
3558 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3560 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3561 css_property_t *cur;
3562 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3563 if (STRCASEEQ('l','L',"left", cur->value)) {
3564 attr_align = apr_pstrdup(doc->pool, "left");
3566 else if (STRCASEEQ('c','C',"center",cur->value)) {
3567 attr_align = apr_pstrdup(doc->pool, "center");
3569 else if (STRCASEEQ('r','R',"right",cur->value)) {
3570 attr_align = apr_pstrdup(doc->pool, "right");
3583 return chtml40->out;
3588 * It is a handler who processes the H4 tag.
3590 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3591 * destination is specified.
3592 * @param node [i] The H4 tag node is specified.
3593 * @return The conversion result is returned.
3596 s_chtml40_end_h4_tag(void *pdoc, Node *UNUSED(child))
3598 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3599 Doc *doc = chtml40->doc;
3602 if (IS_CSS_ON(chtml40->entryp)) {
3603 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3606 return chtml40->out;
3611 * It is a handler who processes the H5 tag.
3613 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3614 * destination is specified.
3615 * @param node [i] The H5 tag node is specified.
3616 * @return The conversion result is returned.
3619 s_chtml40_start_h5_tag(void *pdoc, Node *node)
3625 char *attr_style = NULL;
3626 char *attr_align = NULL;
3628 chtml40 = GET_CHTML40(pdoc);
3632 for (attr = qs_get_attr(doc,node);
3634 attr = qs_get_next_attr(doc,attr)) {
3635 char *name = qs_get_attr_name(doc,attr);
3636 char *value = qs_get_attr_value(doc,attr);
3637 if (STRCASEEQ('a','A',"align", name)) {
3638 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3642 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3646 if (IS_CSS_ON(chtml40->entryp)) {
3647 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3649 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3650 css_property_t *cur;
3651 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3652 if (STRCASEEQ('l','L',"left", cur->value)) {
3653 attr_align = apr_pstrdup(doc->pool, "left");
3655 else if (STRCASEEQ('c','C',"center",cur->value)) {
3656 attr_align = apr_pstrdup(doc->pool, "center");
3658 else if (STRCASEEQ('r','R',"right",cur->value)) {
3659 attr_align = apr_pstrdup(doc->pool, "right");
3678 return chtml40->out;
3683 * It is a handler who processes the H5 tag.
3685 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3686 * destination is specified.
3687 * @param node [i] The H5 tag node is specified.
3688 * @return The conversion result is returned.
3691 s_chtml40_end_h5_tag(void *pdoc, Node *UNUSED(child))
3693 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3694 Doc *doc = chtml40->doc;
3697 if (IS_CSS_ON(chtml40->entryp)) {
3698 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3701 return chtml40->out;
3706 * It is a handler who processes the H6 tag.
3708 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3709 * destination is specified.
3710 * @param node [i] The H6 tag node is specified.
3711 * @return The conversion result is returned.
3714 s_chtml40_start_h6_tag(void *pdoc, Node *node)
3720 char *attr_style = NULL;
3721 char *attr_align = NULL;
3723 chtml40 = GET_CHTML40(pdoc);
3727 for (attr = qs_get_attr(doc,node);
3729 attr = qs_get_next_attr(doc,attr)) {
3730 char *name = qs_get_attr_name(doc,attr);
3731 char *value = qs_get_attr_value(doc,attr);
3732 if (STRCASEEQ('a','A',"align", name)) {
3733 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3737 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3741 if (IS_CSS_ON(chtml40->entryp)) {
3742 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3744 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3745 css_property_t *cur;
3746 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3747 if (STRCASEEQ('l','L',"left", cur->value)) {
3748 attr_align = apr_pstrdup(doc->pool, "left");
3750 else if (STRCASEEQ('c','C',"center",cur->value)) {
3751 attr_align = apr_pstrdup(doc->pool, "center");
3753 else if (STRCASEEQ('r','R',"right",cur->value)) {
3754 attr_align = apr_pstrdup(doc->pool, "right");
3767 return chtml40->out;
3772 * It is a handler who processes the H6 tag.
3774 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3775 * destination is specified.
3776 * @param node [i] The H6 tag node is specified.
3777 * @return The conversion result is returned.
3780 s_chtml40_end_h6_tag(void *pdoc, Node *UNUSED(child))
3782 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3783 Doc *doc = chtml40->doc;
3786 if (IS_CSS_ON(chtml40->entryp)) {
3787 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3790 return chtml40->out;
3795 * It is a handler who processes the TEXTARE tag.
3797 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3798 * destination is specified.
3799 * @param node [i] The TEXTAREA tag node is specified.
3800 * @return The conversion result is returned.
3803 s_chtml40_start_textarea_tag(void *pdoc, Node *node)
3809 char *attr_accesskey = NULL;
3810 char *attr_name = NULL;
3811 char *attr_rows = NULL;
3812 char *attr_cols = NULL;
3813 char *attr_istyle = NULL;
3814 char *attr_style = NULL;
3816 chtml40 = GET_CHTML40(pdoc);
3820 chtml40->textarea_flag++;
3822 for (attr = qs_get_attr(doc,node);
3824 attr = qs_get_next_attr(doc,attr)) {
3825 char *name = qs_get_attr_name(doc,attr);
3826 char *value = qs_get_attr_value(doc,attr);
3827 if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3828 attr_accesskey = value;
3830 else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3831 attr_istyle = value;
3833 else if (STRCASEEQ('n','N',"name", name) && value && *value) {
3836 else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
3839 else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
3842 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3846 if (IS_CSS_ON(chtml40->entryp)) {
3847 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
3849 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3850 css_property_t *cur;
3851 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3852 if (strcasestr(cur->value, "<ja:n>")) {
3855 else if (strcasestr(cur->value, "<ja:en>")) {
3858 else if (strcasestr(cur->value, "<ja:hk>")) {
3861 else if (strcasestr(cur->value, "<ja:h>")) {
3868 if (attr_accesskey) {
3869 W_L(" accesskey=\"");
3870 W_V(attr_accesskey);
3894 return chtml40->out;
3899 * It is a handler who processes the TEXTAREA tag.
3901 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3902 * destination is specified.
3903 * @param node [i] The TEXTAREA tag node is specified.
3904 * @return The conversion result is returned.
3907 s_chtml40_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3909 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3910 Doc *doc = chtml40->doc;
3913 chtml40->textarea_flag--;
3915 return chtml40->out;
3920 s_chtml40_chxjif_tag(void *pdoc, Node *node)
3927 chtml40 = GET_CHTML40(pdoc);
3931 for (child = qs_get_child_node(doc, node);
3933 child = qs_get_next_node(doc, child)) {
3935 s_chtml40_chxjif_tag(chtml40, child);
3943 s_chtml40_text_tag(void *pdoc, Node *child)
3955 apr_size_t z2h_input_len;
3957 chtml40 = GET_CHTML40(pdoc);
3961 textval = qs_get_node_value(doc,child);
3962 if (strlen(textval) == 0) {
3963 return chtml40->out;
3966 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3967 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3969 tdst = qs_alloc_zero_byte_string(doc->buf.pool);
3970 memset(one_byte, 0, sizeof(one_byte));
3973 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3975 int rtn = s_chtml40_search_emoji(chtml40, &textval[ii], &out);
3977 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3982 if (is_sjis_kanji(textval[ii])) {
3983 one_byte[0] = textval[ii+0];
3984 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3985 one_byte[0] = textval[ii+1];
3986 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3989 else if (chtml40->pre_flag) {
3990 one_byte[0] = textval[ii+0];
3991 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3993 else if (chtml40->textarea_flag) {
3994 one_byte[0] = textval[ii+0];
3995 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3997 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3998 one_byte[0] = textval[ii+0];
3999 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4002 z2h_input_len = strlen(tdst);
4003 tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, chtml40->entryp);
4005 return chtml40->out;
4010 * It is a handler who processes the BLOCKQUOTE tag.
4012 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4013 * destination is specified.
4014 * @param node [i] The BLOCKQUOTE tag node is specified.
4015 * @return The conversion result is returned.
4018 s_chtml40_start_blockquote_tag(void *pdoc, Node *node)
4023 char *attr_style = NULL;
4024 char *attr_color = NULL;
4026 chtml40 = GET_CHTML40(pdoc);
4028 for (attr = qs_get_attr(doc,node);
4030 attr = qs_get_next_attr(doc,attr)) {
4031 char *nm = qs_get_attr_name(doc,attr);
4032 char *val = qs_get_attr_value(doc,attr);
4033 if (val && STRCASEEQ('s','S',"style", nm)) {
4037 if (IS_CSS_ON(chtml40->entryp)) {
4038 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4040 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4041 css_property_t *cur;
4042 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4043 if (cur->value && *cur->value) {
4044 attr_color = apr_pstrdup(doc->pool, cur->value);
4049 W_L("<blockquote>");
4050 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4051 memset(flg, 0, sizeof(*flg));
4053 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4054 W_L("<font color=\"");
4057 flg->with_font_flag = 1;
4059 node->userData = (void *)flg;
4060 return chtml40->out;
4065 * It is a handler who processes the BLOCKQUOTE tag.
4067 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4068 * destination is specified.
4069 * @param node [i] The BLOCKQUOTE tag node is specified.
4070 * @return The conversion result is returned.
4073 s_chtml40_end_blockquote_tag(void *pdoc, Node *node)
4075 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4076 Doc *doc = chtml40->doc;
4077 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4078 if (flg && flg->with_font_flag) {
4081 W_L("</blockquote>");
4082 if (IS_CSS_ON(chtml40->entryp)) {
4083 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4085 return chtml40->out;
4090 * It is a handler who processes the DIR tag.
4092 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4093 * destination is specified.
4094 * @param node [i] The DIR tag node is specified.
4095 * @return The conversion result is returned.
4098 s_chtml40_start_dir_tag(void *pdoc, Node *node)
4100 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4101 Doc *doc = chtml40->doc;
4103 char *attr_style = NULL;
4104 char *attr_color = NULL;
4105 char *attr_type = NULL;
4106 for (attr = qs_get_attr(doc,node);
4108 attr = qs_get_next_attr(doc,attr)) {
4109 char *name = qs_get_attr_name(doc,attr);
4110 char *value = qs_get_attr_value(doc,attr);
4111 if (STRCASEEQ('t','T',"type",name)) {
4112 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4116 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4120 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4128 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4129 memset(flg, 0, sizeof(*flg));
4131 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4132 W_L("<font color=\"");
4135 flg->with_font_flag = 1;
4137 node->userData = (void *)flg;
4138 return chtml40->out;
4143 * It is a handler who processes the DIR tag.
4145 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4146 * destination is specified.
4147 * @param node [i] The DIR tag node is specified.
4148 * @return The conversion result is returned.
4151 s_chtml40_end_dir_tag(void *pdoc, Node *node)
4153 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4154 Doc *doc = chtml40->doc;
4155 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4156 if (flg && flg->with_font_flag) {
4160 if (IS_CSS_ON(chtml40->entryp)) {
4161 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4163 return chtml40->out;
4168 * It is a handler who processes the DL tag.
4170 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4171 * destination is specified.
4172 * @param node [i] The DL tag node is specified.
4173 * @return The conversion result is returned.
4176 s_chtml40_start_dl_tag(void *pdoc, Node *node)
4181 char *attr_style = NULL;
4182 char *attr_color = NULL;
4184 chtml40 = GET_CHTML40(pdoc);
4186 for (attr = qs_get_attr(doc,node);
4188 attr = qs_get_next_attr(doc,attr)) {
4189 char *nm = qs_get_attr_name(doc,attr);
4190 char *val = qs_get_attr_value(doc,attr);
4191 if (val && STRCASEEQ('s','S',"style", nm)) {
4195 if (IS_CSS_ON(chtml40->entryp)) {
4196 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4198 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4199 css_property_t *cur;
4200 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4201 if (cur->value && *cur->value) {
4202 attr_color = apr_pstrdup(doc->pool, cur->value);
4208 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4209 memset(flg, 0, sizeof(*flg));
4211 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4212 W_L("<font color=\"");
4215 flg->with_font_flag = 1;
4217 node->userData = (void *)flg;
4218 return chtml40->out;
4223 * It is a handler who processes the DL tag.
4225 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4226 * destination is specified.
4227 * @param node [i] The DL tag node is specified.
4228 * @return The conversion result is returned.
4231 s_chtml40_end_dl_tag(void *pdoc, Node *node)
4233 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4234 Doc *doc = chtml40->doc;
4235 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4236 if (flg && flg->with_font_flag) {
4240 if (IS_CSS_ON(chtml40->entryp)) {
4241 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4243 return chtml40->out;
4248 * It is a handler who processes the DT tag.
4250 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4251 * destination is specified.
4252 * @param node [i] The DT tag node is specified.
4253 * @return The conversion result is returned.
4256 s_chtml40_start_dt_tag(void *pdoc, Node *node)
4261 char *attr_style = NULL;
4262 char *attr_color = NULL;
4264 chtml40 = GET_CHTML40(pdoc);
4266 for (attr = qs_get_attr(doc,node);
4268 attr = qs_get_next_attr(doc,attr)) {
4269 char *nm = qs_get_attr_name(doc,attr);
4270 char *val = qs_get_attr_value(doc,attr);
4271 if (val && STRCASEEQ('s','S',"style", nm)) {
4275 if (IS_CSS_ON(chtml40->entryp)) {
4276 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4278 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4279 css_property_t *cur;
4280 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4281 if (cur->value && *cur->value) {
4282 attr_color = apr_pstrdup(doc->pool, cur->value);
4288 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4289 memset(flg, 0, sizeof(*flg));
4291 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4292 W_L("<font color=\"");
4295 flg->with_font_flag = 1;
4297 node->userData = (void *)flg;
4298 return chtml40->out;
4303 * It is a handler who processes the DT tag.
4305 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4306 * destination is specified.
4307 * @param node [i] The DT tag node is specified.
4308 * @return The conversion result is returned.
4311 s_chtml40_end_dt_tag(void *pdoc, Node *node)
4313 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4314 Doc *doc = chtml40->doc;
4315 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4316 if (flg && flg->with_font_flag) {
4319 if (IS_CSS_ON(chtml40->entryp)) {
4320 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4322 return chtml40->out;
4327 * It is a handler who processes the DD tag.
4329 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4330 * destination is specified.
4331 * @param node [i] The DD tag node is specified.
4332 * @return The conversion result is returned.
4335 s_chtml40_start_dd_tag(void *pdoc, Node *node)
4340 char *attr_style = NULL;
4341 char *attr_color = NULL;
4343 chtml40 = GET_CHTML40(pdoc);
4345 for (attr = qs_get_attr(doc,node);
4347 attr = qs_get_next_attr(doc,attr)) {
4348 char *nm = qs_get_attr_name(doc,attr);
4349 char *val = qs_get_attr_value(doc,attr);
4350 if (val && STRCASEEQ('s','S',"style", nm)) {
4354 if (IS_CSS_ON(chtml40->entryp)) {
4355 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4357 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4358 css_property_t *cur;
4359 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4360 if (cur->value && *cur->value) {
4361 attr_color = apr_pstrdup(doc->pool, cur->value);
4367 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4368 memset(flg, 0, sizeof(*flg));
4370 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4371 W_L("<font color=\"");
4374 flg->with_font_flag = 1;
4376 node->userData = (void *)flg;
4377 return chtml40->out;
4382 * It is a handler who processes the DD tag.
4384 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4385 * destination is specified.
4386 * @param node [i] The DD tag node is specified.
4387 * @return The conversion result is returned.
4390 s_chtml40_end_dd_tag(void *pdoc, Node *node)
4392 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4393 Doc *doc = chtml40->doc;
4394 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4395 if (flg && flg->with_font_flag) {
4398 if (IS_CSS_ON(chtml40->entryp)) {
4399 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4401 return chtml40->out;
4406 * It is a handler who processes the MARQUEE tag.
4408 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4409 * destination is specified.
4410 * @param node [i] The MARQUEE tag node is specified.
4411 * @return The conversion result is returned.
4414 s_chtml40_start_marquee_tag(void *pdoc, Node *node)
4416 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4417 Doc *doc = chtml40->doc;
4419 char *attr_direction = NULL;
4420 char *attr_behavior = NULL;
4421 char *attr_loop = NULL;
4422 char *attr_style = NULL;
4423 char *attr_color = NULL;
4424 /*--------------------------------------------------------------------------*/
4425 /* Get Attributes */
4426 /*--------------------------------------------------------------------------*/
4427 for (attr = qs_get_attr(doc,node);
4429 attr = qs_get_next_attr(doc,attr)) {
4430 char *name = qs_get_attr_name(doc,attr);
4431 char *value = qs_get_attr_value(doc,attr);
4432 if (STRCASEEQ('d','D',"direction", name)) {
4433 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
4434 attr_direction = value;
4437 else if (STRCASEEQ('b','B',"behavior",name)) {
4438 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
4439 attr_behavior = value;
4442 else if (STRCASEEQ('l','L',"loop",name)) {
4443 if (value && *value) {
4447 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4451 if (IS_CSS_ON(chtml40->entryp)) {
4452 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4454 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4455 css_property_t *direction_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4456 css_property_t *style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4457 css_property_t *loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4458 css_property_t *cur;
4459 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4460 if (cur->value && *cur->value) {
4461 attr_color = apr_pstrdup(doc->pool, cur->value);
4464 for (cur = style_prop->next; cur != style_prop; cur = cur->next) {
4465 if (cur->value && *cur->value) {
4466 attr_behavior = apr_pstrdup(doc->pool, cur->value);
4469 for (cur = loop_prop->next; cur != loop_prop; cur = cur->next) {
4470 if (cur->value && *cur->value) {
4471 attr_loop = apr_pstrdup(doc->pool, cur->value);
4472 if (STRCASEEQ('i','I',"infinite",attr_loop)) {
4477 for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
4478 if (cur->value && *cur->value) {
4479 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4480 attr_direction = "right";
4482 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4483 attr_direction = "left";
4490 if (attr_direction) {
4491 W_L(" direction=\"");
4492 W_V(attr_direction);
4495 if (attr_behavior) {
4496 W_L(" behavior=\"");
4507 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4508 memset(flg, 0, sizeof(*flg));
4510 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4511 W_L("<font color=\"");
4514 flg->with_font_flag = 1;
4516 node->userData = (void *)flg;
4517 return chtml40->out;
4522 * It is a handler who processes the MARQUEE tag.
4524 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4525 * destination is specified.
4526 * @param node [i] The MARQUEE tag node is specified.
4527 * @return The conversion result is returned.
4530 s_chtml40_end_marquee_tag(void *pdoc, Node *node)
4532 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4533 Doc *doc = chtml40->doc;
4534 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4535 if (flg && flg->with_font_flag) {
4539 if (IS_CSS_ON(chtml40->entryp)) {
4540 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4542 return chtml40->out;
4547 * It is a handler who processes the BLINK tag.
4549 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4550 * destination is specified.
4551 * @param node [i] The BLINK tag node is specified.
4552 * @return The conversion result is returned.
4555 s_chtml40_start_blink_tag(void *pdoc, Node *node)
4560 char *attr_style = NULL;
4561 char *attr_color = NULL;
4563 chtml40 = GET_CHTML40(pdoc);
4565 for (attr = qs_get_attr(doc,node);
4567 attr = qs_get_next_attr(doc,attr)) {
4568 char *nm = qs_get_attr_name(doc,attr);
4569 char *val = qs_get_attr_value(doc,attr);
4570 if (val && STRCASEEQ('s','S',"style", nm)) {
4574 if (IS_CSS_ON(chtml40->entryp)) {
4575 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4577 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4578 css_property_t *cur;
4579 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4580 if (cur->value && *cur->value) {
4581 attr_color = apr_pstrdup(doc->pool, cur->value);
4587 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4588 memset(flg, 0, sizeof(*flg));
4590 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4591 W_L("<font color=\"");
4594 flg->with_font_flag = 1;
4596 node->userData = (void *)flg;
4597 return chtml40->out;
4602 * It is a handler who processes the BLINK tag.
4604 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4605 * destination is specified.
4606 * @param node [i] The BLINK tag node is specified.
4607 * @return The conversion result is returned.
4610 s_chtml40_end_blink_tag(void *pdoc, Node *node)
4612 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4613 Doc *doc = chtml40->doc;
4614 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4615 if (flg && flg->with_font_flag) {
4619 if (IS_CSS_ON(chtml40->entryp)) {
4620 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4622 return chtml40->out;
4627 * It is a handler who processes the MENU tag.
4629 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4630 * destination is specified.
4631 * @param node [i] The MENU tag node is specified.
4632 * @return The conversion result is returned.
4635 s_chtml40_start_menu_tag(void *pdoc, Node *node)
4637 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4638 Doc *doc = chtml40->doc;
4640 char *attr_style = NULL;
4641 char *attr_type = NULL;
4642 char *attr_color = NULL;
4643 /*--------------------------------------------------------------------------*/
4644 /* Get Attributes */
4645 /*--------------------------------------------------------------------------*/
4646 for (attr = qs_get_attr(doc,node);
4648 attr = qs_get_next_attr(doc,attr)) {
4649 char *name = qs_get_attr_name(doc,attr);
4650 char *value = qs_get_attr_value(doc,attr);
4651 if (STRCASEEQ('t','T',"type",name)) {
4652 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4656 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4660 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4668 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4669 memset(flg, 0, sizeof(*flg));
4671 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4672 W_L("<font color=\"");
4675 flg->with_font_flag = 1;
4677 node->userData = (void *)flg;
4679 return chtml40->out;
4684 * It is a handler who processes the MENU tag.
4686 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4687 * destination is specified.
4688 * @param node [i] The MENU tag node is specified.
4689 * @return The conversion result is returned.
4692 s_chtml40_end_menu_tag(void *pdoc, Node *node)
4694 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4695 Doc *doc = chtml40->doc;
4696 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4697 if (flg && flg->with_font_flag) {
4701 if (IS_CSS_ON(chtml40->entryp)) {
4702 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4704 return chtml40->out;
4709 * It is a handler who processes the PLAINTEXT tag.
4711 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4712 * destination is specified.
4713 * @param node [i] The PLAINTEXT tag node is specified.
4714 * @return The conversion result is returned.
4717 s_chtml40_start_plaintext_tag(void *pdoc, Node *node)
4719 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4720 Doc *doc = chtml40->doc;
4722 s_chtml40_start_plaintext_tag_inner(pdoc,node);
4723 return chtml40->out;
4727 s_chtml40_start_plaintext_tag_inner(void *pdoc, Node *node)
4729 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4730 Doc *doc = chtml40->doc;
4732 for (child = qs_get_child_node(doc, node);
4734 child = qs_get_next_node(doc, child)) {
4736 s_chtml40_start_plaintext_tag_inner(pdoc, child);
4738 return chtml40->out;
4743 * It is a handler who processes the PLAINTEXT tag.
4745 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4746 * destination is specified.
4747 * @param node [i] The PLAINTEXT tag node is specified.
4748 * @return The conversion result is returned.
4751 s_chtml40_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4753 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4754 return chtml40->out;
4759 * It is handler who processes the New Line Code.
4762 s_chtml40_newline_mark(void *pdoc, Node *UNUSED(node))
4764 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4765 Doc *doc = chtml40->doc;
4767 return chtml40->out;
4772 * It is a handler who processes the LINK tag.
4774 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4775 * destination is specified.
4776 * @param node [i] The LINK tag node is specified.
4777 * @return The conversion result is returned.
4780 s_chtml40_link_tag(void *pdoc, Node *node)
4789 chtml40 = GET_CHTML40(pdoc);
4792 if (! IS_CSS_ON(chtml40->entryp)) {
4793 return chtml40->out;
4796 for (attr = qs_get_attr(doc,node);
4798 attr = qs_get_next_attr(doc,attr)) {
4799 char *name = qs_get_attr_name(doc,attr);
4800 char *value = qs_get_attr_value(doc,attr);
4801 if (STRCASEEQ('r','R',"rel", name)) {
4802 if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
4806 else if (STRCASEEQ('h','H',"href", name)) {
4807 if (value && *value) {
4811 else if (STRCASEEQ('t','T',"type", name)) {
4812 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
4818 if (rel && href && type) {
4819 DBG(doc->r, "start load CSS. url:[%s]", href);
4820 chtml40->style = chxj_css_parse_from_uri(doc->r, doc->pool, chtml40->style, href);
4821 DBG(doc->r, "end load CSS. url:[%s]", href);
4824 return chtml40->out;
4827 static css_prop_list_t *
4828 s_chtml40_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4830 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4831 Doc *doc = chtml40->doc;
4832 css_prop_list_t *last_css = NULL;
4833 if (IS_CSS_ON(chtml40->entryp)) {
4834 css_prop_list_t *dup_css;
4835 css_selector_t *selector;
4837 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4838 dup_css = chxj_dup_css_prop_list(doc, last_css);
4839 selector = chxj_css_find_selector(doc, chtml40->style, node);
4841 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4843 chxj_css_push_prop_list(chtml40->css_prop_stack, dup_css);
4844 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4846 if (style_attr_value) {
4847 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));
4849 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4857 static css_prop_list_t *
4858 s_chtml40_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4860 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4861 Doc *doc = chtml40->doc;
4862 css_prop_list_t *last_css = NULL;
4863 if (IS_CSS_ON(chtml40->entryp)) {
4864 css_prop_list_t *dup_css;
4865 css_selector_t *selector;
4867 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4868 dup_css = chxj_dup_css_prop_list(doc, last_css);
4869 selector = chxj_css_find_selector(doc, chtml40->style, node);
4871 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4875 if (style_attr_value) {
4876 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));
4878 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4888 * It is a handler who processes the SPAN tag.
4890 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4891 * destination is specified.
4892 * @param node [i] The SPAN tag node is specified.
4893 * @return The conversion result is returned.
4896 s_chtml40_start_span_tag(void *pdoc, Node *node)
4901 char *attr_style = NULL;
4902 char *attr_color = NULL;
4903 char *attr_align = NULL;
4904 char *attr_blink = NULL;
4905 char *attr_marquee = NULL;
4906 char *attr_marquee_dir = NULL;
4907 char *attr_marquee_style = NULL;
4908 char *attr_marquee_loop = NULL;
4910 chtml40 = GET_CHTML40(pdoc);
4913 for (attr = qs_get_attr(doc,node);
4915 attr = qs_get_next_attr(doc,attr)) {
4916 char *nm = qs_get_attr_name(doc,attr);
4917 char *val = qs_get_attr_value(doc,attr);
4918 if (val && STRCASEEQ('s','S',"style", nm)) {
4922 if (IS_CSS_ON(chtml40->entryp)) {
4923 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4925 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4926 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
4927 css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
4928 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
4929 css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4930 css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4931 css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4932 css_property_t *cur;
4933 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4934 attr_color = apr_pstrdup(doc->pool, cur->value);
4936 for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
4937 if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
4938 attr_blink = apr_pstrdup(doc->pool, cur->value);
4941 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
4942 if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
4943 attr_marquee = apr_pstrdup(doc->pool, cur->value);
4946 for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
4947 if (cur->value && *cur->value) {
4948 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4949 attr_marquee_dir = "right";
4951 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4952 attr_marquee_dir = "left";
4956 for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
4957 if (cur->value && *cur->value) {
4958 if ( STRCASEEQ('s','S',"scroll",cur->value)
4959 || STRCASEEQ('s','S',"slide",cur->value)
4960 || STRCASEEQ('a','A',"alternate",cur->value)) {
4961 attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
4965 for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
4966 if (cur->value && *cur->value) {
4967 if (STRCASEEQ('i','I',"infinite",cur->value)) {
4968 attr_marquee_loop = "16";
4971 attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
4975 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
4976 if (STRCASEEQ('l','L',"left", cur->value)) {
4977 attr_align = apr_pstrdup(doc->pool, "left");
4979 else if (STRCASEEQ('c','C',"center",cur->value)) {
4980 attr_align = apr_pstrdup(doc->pool, "center");
4982 else if (STRCASEEQ('r','R',"right",cur->value)) {
4983 attr_align = apr_pstrdup(doc->pool, "right");
4988 if (attr_color || attr_align || attr_blink || attr_marquee) {
4989 chtml40_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4990 memset(flg, 0, sizeof(*flg));
4993 flg->with_blink_flag = 1;
4997 if (attr_marquee_dir) {
4998 W_L(" direction=\"");
4999 W_V(attr_marquee_dir);
5002 if (attr_marquee_style) {
5003 W_L(" behavior=\"");
5004 W_V(attr_marquee_style);
5007 if (attr_marquee_loop) {
5009 W_V(attr_marquee_loop);
5013 flg->with_marquee_flag = 1;
5016 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5017 W_L("<font color=\"");
5020 flg->with_font_flag = 1;
5023 W_L("<div align=\"");
5026 flg->with_div_flag = 1;
5028 node->userData = flg;
5031 node->userData = NULL;
5033 return chtml40->out;
5038 * It is a handler who processes the SPAN tag.
5040 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5041 * destination is specified.
5042 * @param node [i] The SPAN tag node is specified.
5043 * @return The conversion result is returned.
5046 s_chtml40_end_span_tag(void *pdoc, Node *node)
5048 chtml40_t *chtml40 = GET_CHTML40(pdoc);
5049 Doc *doc = chtml40->doc;
5051 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
5052 if (flg && flg->with_div_flag) {
5055 if (flg && flg->with_font_flag) {
5058 if (flg && flg->with_marquee_flag) {
5061 if (flg && flg->with_blink_flag) {
5064 if (IS_CSS_ON(chtml40->entryp)) {
5065 chxj_css_pop_prop_list(chtml40->css_prop_stack);
5067 return chtml40->out;
5072 * It is a handler who processes the STYLE tag.
5074 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5075 * destination is specified.
5076 * @param node [i] The STYLE tag node is specified.
5077 * @return The conversion result is returned.
5080 s_chtml40_style_tag(void *pdoc, Node *node)
5087 chtml40 = GET_CHTML40(pdoc);
5090 if (! IS_CSS_ON(chtml40->entryp)) {
5091 return chtml40->out;
5094 for (attr = qs_get_attr(doc,node);
5096 attr = qs_get_next_attr(doc,attr)) {
5097 char *name = qs_get_attr_name(doc,attr);
5098 char *value = qs_get_attr_value(doc,attr);
5099 if (STRCASEEQ('t','T',"type", name)) {
5100 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5106 Node *child = qs_get_child_node(doc, node);
5107 if (type && child) {
5108 char *name = qs_get_node_name(doc, child);
5109 if (STRCASEEQ('t','T',"text", name)) {
5110 char *value = qs_get_node_value(doc, child);
5111 DBG(doc->r, "start load CSS. buf:[%s]", value);
5112 chtml40->style = chxj_css_parse_style_value(doc, chtml40->style, value);
5113 DBG(doc->r, "end load CSS. value:[%s]", value);
5116 return chtml40->out;