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 (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");
3111 return chtml40->out;
3116 * It is a handler who processes the OL tag.
3118 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3119 * destination is specified.
3120 * @param node [i] The OL tag node is specified.
3121 * @return The conversion result is returned.
3124 s_chtml40_end_ol_tag(void *pdoc, Node *UNUSED(node))
3126 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3127 Doc *doc = chtml40->doc;
3130 if (IS_CSS_ON(chtml40->entryp)) {
3131 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3134 return chtml40->out;
3139 * It is a handler who processes the LI tag.
3141 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3142 * destination is specified.
3143 * @param node [i] The LI tag node is specified.
3144 * @return The conversion result is returned.
3147 s_chtml40_start_li_tag(void *pdoc, Node *node)
3149 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3150 Doc *doc = chtml40->doc;
3152 char *attr_type = NULL;
3153 char *attr_value = NULL;
3154 char *attr_style = NULL;
3156 /*--------------------------------------------------------------------------*/
3157 /* Get Attributes */
3158 /*--------------------------------------------------------------------------*/
3159 for (attr = qs_get_attr(doc,node);
3161 attr = qs_get_next_attr(doc,attr)) {
3162 char *name = qs_get_attr_name(doc,attr);
3163 char *value = qs_get_attr_value(doc,attr);
3164 if (STRCASEEQ('t','T',"type",name)) {
3165 if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
3169 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
3172 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3176 if (IS_CSS_ON(chtml40->entryp)) {
3177 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3179 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3180 css_property_t *cur;
3181 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3182 if (STRCASEEQ('d','D',"decimal", cur->value)) {
3183 attr_type = apr_pstrdup(doc->pool, "1");
3185 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3186 attr_type = apr_pstrdup(doc->pool, "A");
3188 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3189 attr_type = apr_pstrdup(doc->pool, "a");
3191 else if (STRCASEEQ('d','D',"disc", cur->value)) {
3192 attr_type = apr_pstrdup(doc->pool, "disc");
3194 else if (STRCASEEQ('s','S',"square", cur->value)) {
3195 attr_type = apr_pstrdup(doc->pool, "square");
3197 else if (STRCASEEQ('c','C',"circle", cur->value)) {
3198 attr_type = apr_pstrdup(doc->pool, "circle");
3216 return chtml40->out;
3221 * It is a handler who processes the LI tag.
3223 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3224 * destination is specified.
3225 * @param node [i] The LI tag node is specified.
3226 * @return The conversion result is returned.
3229 s_chtml40_end_li_tag(void *pdoc, Node *UNUSED(child))
3231 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3233 if (IS_CSS_ON(chtml40->entryp)) {
3234 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3236 return chtml40->out;
3241 * It is a handler who processes the H1 tag.
3243 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3244 * destination is specified.
3245 * @param node [i] The H1 tag node is specified.
3246 * @return The conversion result is returned.
3249 s_chtml40_start_h1_tag(void *pdoc, Node *node)
3255 char *attr_style = NULL;
3256 char *attr_align = NULL;
3258 chtml40 = GET_CHTML40(pdoc);
3262 for (attr = qs_get_attr(doc,node);
3264 attr = qs_get_next_attr(doc,attr)) {
3265 char *name = qs_get_attr_name(doc,attr);
3266 char *value = qs_get_attr_value(doc,attr);
3267 if (STRCASEEQ('a','A',"align", name)) {
3268 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3272 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3276 if (IS_CSS_ON(chtml40->entryp)) {
3277 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3279 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3280 css_property_t *cur;
3281 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3282 if (STRCASEEQ('l','L',"left", cur->value)) {
3283 attr_align = apr_pstrdup(doc->pool, "left");
3285 else if (STRCASEEQ('c','C',"center",cur->value)) {
3286 attr_align = apr_pstrdup(doc->pool, "center");
3288 else if (STRCASEEQ('r','R',"right",cur->value)) {
3289 attr_align = apr_pstrdup(doc->pool, "right");
3302 return chtml40->out;
3307 * It is a handler who processes the H1 tag.
3309 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3310 * destination is specified.
3311 * @param node [i] The H1 tag node is specified.
3312 * @return The conversion result is returned.
3315 s_chtml40_end_h1_tag(void *pdoc, Node *UNUSED(child))
3320 chtml40 = GET_CHTML40(pdoc);
3324 if (IS_CSS_ON(chtml40->entryp)) {
3325 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3328 return chtml40->out;
3333 * It is a handler who processes the H2 tag.
3335 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3336 * destination is specified.
3337 * @param node [i] The H2 tag node is specified.
3338 * @return The conversion result is returned.
3341 s_chtml40_start_h2_tag(void *pdoc, Node *node)
3347 char *attr_style = NULL;
3348 char *attr_align = NULL;
3350 chtml40 = GET_CHTML40(pdoc);
3354 for (attr = qs_get_attr(doc,node);
3356 attr = qs_get_next_attr(doc,attr)) {
3357 char *name = qs_get_attr_name(doc,attr);
3358 char *value = qs_get_attr_value(doc,attr);
3359 if (STRCASEEQ('a','A',"align", name)) {
3360 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3364 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3368 if (IS_CSS_ON(chtml40->entryp)) {
3369 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3371 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3372 css_property_t *cur;
3373 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3374 if (STRCASEEQ('l','L',"left", cur->value)) {
3375 attr_align = apr_pstrdup(doc->pool, "left");
3377 else if (STRCASEEQ('c','C',"center",cur->value)) {
3378 attr_align = apr_pstrdup(doc->pool, "center");
3380 else if (STRCASEEQ('r','R',"right",cur->value)) {
3381 attr_align = apr_pstrdup(doc->pool, "right");
3394 return chtml40->out;
3399 * It is a handler who processes the H2 tag.
3401 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3402 * destination is specified.
3403 * @param node [i] The H2 tag node is specified.
3404 * @return The conversion result is returned.
3407 s_chtml40_end_h2_tag(void *pdoc, Node *UNUSED(child))
3409 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3410 Doc *doc = chtml40->doc;
3413 if (IS_CSS_ON(chtml40->entryp)) {
3414 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3417 return chtml40->out;
3422 * It is a handler who processes the H3 tag.
3424 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3425 * destination is specified.
3426 * @param node [i] The H3 tag node is specified.
3427 * @return The conversion result is returned.
3430 s_chtml40_start_h3_tag(void *pdoc, Node *node)
3436 char *attr_style = NULL;
3437 char *attr_align = NULL;
3439 chtml40 = GET_CHTML40(pdoc);
3443 for (attr = qs_get_attr(doc,node);
3445 attr = qs_get_next_attr(doc,attr)) {
3446 char *name = qs_get_attr_name(doc,attr);
3447 char *value = qs_get_attr_value(doc,attr);
3448 if (STRCASEEQ('a','A',"align", name)) {
3449 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3453 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3457 if (IS_CSS_ON(chtml40->entryp)) {
3458 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3460 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3461 css_property_t *cur;
3462 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3463 if (STRCASEEQ('l','L',"left", cur->value)) {
3464 attr_align = apr_pstrdup(doc->pool, "left");
3466 else if (STRCASEEQ('c','C',"center",cur->value)) {
3467 attr_align = apr_pstrdup(doc->pool, "center");
3469 else if (STRCASEEQ('r','R',"right",cur->value)) {
3470 attr_align = apr_pstrdup(doc->pool, "right");
3483 return chtml40->out;
3488 * It is a handler who processes the H3 tag.
3490 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3491 * destination is specified.
3492 * @param node [i] The H3 tag node is specified.
3493 * @return The conversion result is returned.
3496 s_chtml40_end_h3_tag(void *pdoc, Node *UNUSED(child))
3498 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3499 Doc *doc = chtml40->doc;
3502 if (IS_CSS_ON(chtml40->entryp)) {
3503 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3506 return chtml40->out;
3511 * It is a handler who processes the H4 tag.
3513 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3514 * destination is specified.
3515 * @param node [i] The H4 tag node is specified.
3516 * @return The conversion result is returned.
3519 s_chtml40_start_h4_tag(void *pdoc, Node *node)
3525 char *attr_style = NULL;
3526 char *attr_align = NULL;
3528 chtml40 = GET_CHTML40(pdoc);
3532 for (attr = qs_get_attr(doc,node);
3534 attr = qs_get_next_attr(doc,attr)) {
3535 char *name = qs_get_attr_name(doc,attr);
3536 char *value = qs_get_attr_value(doc,attr);
3537 if (STRCASEEQ('a','A',"align", name)) {
3538 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3542 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3546 if (IS_CSS_ON(chtml40->entryp)) {
3547 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3549 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3550 css_property_t *cur;
3551 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3552 if (STRCASEEQ('l','L',"left", cur->value)) {
3553 attr_align = apr_pstrdup(doc->pool, "left");
3555 else if (STRCASEEQ('c','C',"center",cur->value)) {
3556 attr_align = apr_pstrdup(doc->pool, "center");
3558 else if (STRCASEEQ('r','R',"right",cur->value)) {
3559 attr_align = apr_pstrdup(doc->pool, "right");
3572 return chtml40->out;
3577 * It is a handler who processes the H4 tag.
3579 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3580 * destination is specified.
3581 * @param node [i] The H4 tag node is specified.
3582 * @return The conversion result is returned.
3585 s_chtml40_end_h4_tag(void *pdoc, Node *UNUSED(child))
3587 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3588 Doc *doc = chtml40->doc;
3591 if (IS_CSS_ON(chtml40->entryp)) {
3592 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3595 return chtml40->out;
3600 * It is a handler who processes the H5 tag.
3602 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3603 * destination is specified.
3604 * @param node [i] The H5 tag node is specified.
3605 * @return The conversion result is returned.
3608 s_chtml40_start_h5_tag(void *pdoc, Node *node)
3614 char *attr_style = NULL;
3615 char *attr_align = NULL;
3617 chtml40 = GET_CHTML40(pdoc);
3621 for (attr = qs_get_attr(doc,node);
3623 attr = qs_get_next_attr(doc,attr)) {
3624 char *name = qs_get_attr_name(doc,attr);
3625 char *value = qs_get_attr_value(doc,attr);
3626 if (STRCASEEQ('a','A',"align", name)) {
3627 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3631 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3635 if (IS_CSS_ON(chtml40->entryp)) {
3636 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3638 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3639 css_property_t *cur;
3640 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3641 if (STRCASEEQ('l','L',"left", cur->value)) {
3642 attr_align = apr_pstrdup(doc->pool, "left");
3644 else if (STRCASEEQ('c','C',"center",cur->value)) {
3645 attr_align = apr_pstrdup(doc->pool, "center");
3647 else if (STRCASEEQ('r','R',"right",cur->value)) {
3648 attr_align = apr_pstrdup(doc->pool, "right");
3661 return chtml40->out;
3666 * It is a handler who processes the H5 tag.
3668 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3669 * destination is specified.
3670 * @param node [i] The H5 tag node is specified.
3671 * @return The conversion result is returned.
3674 s_chtml40_end_h5_tag(void *pdoc, Node *UNUSED(child))
3676 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3677 Doc *doc = chtml40->doc;
3680 if (IS_CSS_ON(chtml40->entryp)) {
3681 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3684 return chtml40->out;
3689 * It is a handler who processes the H6 tag.
3691 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3692 * destination is specified.
3693 * @param node [i] The H6 tag node is specified.
3694 * @return The conversion result is returned.
3697 s_chtml40_start_h6_tag(void *pdoc, Node *node)
3703 char *attr_style = NULL;
3704 char *attr_align = NULL;
3706 chtml40 = GET_CHTML40(pdoc);
3710 for (attr = qs_get_attr(doc,node);
3712 attr = qs_get_next_attr(doc,attr)) {
3713 char *name = qs_get_attr_name(doc,attr);
3714 char *value = qs_get_attr_value(doc,attr);
3715 if (STRCASEEQ('a','A',"align", name)) {
3716 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3720 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3724 if (IS_CSS_ON(chtml40->entryp)) {
3725 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3727 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3728 css_property_t *cur;
3729 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3730 if (STRCASEEQ('l','L',"left", cur->value)) {
3731 attr_align = apr_pstrdup(doc->pool, "left");
3733 else if (STRCASEEQ('c','C',"center",cur->value)) {
3734 attr_align = apr_pstrdup(doc->pool, "center");
3736 else if (STRCASEEQ('r','R',"right",cur->value)) {
3737 attr_align = apr_pstrdup(doc->pool, "right");
3750 return chtml40->out;
3755 * It is a handler who processes the H6 tag.
3757 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3758 * destination is specified.
3759 * @param node [i] The H6 tag node is specified.
3760 * @return The conversion result is returned.
3763 s_chtml40_end_h6_tag(void *pdoc, Node *UNUSED(child))
3765 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3766 Doc *doc = chtml40->doc;
3769 if (IS_CSS_ON(chtml40->entryp)) {
3770 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3773 return chtml40->out;
3778 * It is a handler who processes the TEXTARE tag.
3780 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3781 * destination is specified.
3782 * @param node [i] The TEXTAREA tag node is specified.
3783 * @return The conversion result is returned.
3786 s_chtml40_start_textarea_tag(void *pdoc, Node *node)
3792 char *attr_accesskey = NULL;
3793 char *attr_name = NULL;
3794 char *attr_rows = NULL;
3795 char *attr_cols = NULL;
3796 char *attr_istyle = NULL;
3797 char *attr_style = NULL;
3799 chtml40 = GET_CHTML40(pdoc);
3803 chtml40->textarea_flag++;
3805 for (attr = qs_get_attr(doc,node);
3807 attr = qs_get_next_attr(doc,attr)) {
3808 char *name = qs_get_attr_name(doc,attr);
3809 char *value = qs_get_attr_value(doc,attr);
3810 if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3811 attr_accesskey = value;
3813 else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3814 attr_istyle = value;
3816 else if (STRCASEEQ('n','N',"name", name) && value && *value) {
3819 else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
3822 else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
3825 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3829 if (IS_CSS_ON(chtml40->entryp)) {
3830 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
3832 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3833 css_property_t *cur;
3834 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3835 if (strcasestr(cur->value, "<ja:n>")) {
3838 else if (strcasestr(cur->value, "<ja:en>")) {
3841 else if (strcasestr(cur->value, "<ja:hk>")) {
3844 else if (strcasestr(cur->value, "<ja:h>")) {
3851 if (attr_accesskey) {
3852 W_L(" accesskey=\"");
3853 W_V(attr_accesskey);
3877 return chtml40->out;
3882 * It is a handler who processes the TEXTAREA tag.
3884 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3885 * destination is specified.
3886 * @param node [i] The TEXTAREA tag node is specified.
3887 * @return The conversion result is returned.
3890 s_chtml40_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3892 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3893 Doc *doc = chtml40->doc;
3896 chtml40->textarea_flag--;
3898 return chtml40->out;
3903 s_chtml40_chxjif_tag(void *pdoc, Node *node)
3910 chtml40 = GET_CHTML40(pdoc);
3914 for (child = qs_get_child_node(doc, node);
3916 child = qs_get_next_node(doc, child)) {
3918 s_chtml40_chxjif_tag(chtml40, child);
3926 s_chtml40_text_tag(void *pdoc, Node *child)
3938 apr_size_t z2h_input_len;
3940 chtml40 = GET_CHTML40(pdoc);
3944 textval = qs_get_node_value(doc,child);
3945 if (strlen(textval) == 0) {
3946 return chtml40->out;
3949 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3950 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3952 tdst = qs_alloc_zero_byte_string(doc->buf.pool);
3953 memset(one_byte, 0, sizeof(one_byte));
3956 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3958 int rtn = s_chtml40_search_emoji(chtml40, &textval[ii], &out);
3960 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3965 if (is_sjis_kanji(textval[ii])) {
3966 one_byte[0] = textval[ii+0];
3967 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3968 one_byte[0] = textval[ii+1];
3969 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3972 else if (chtml40->pre_flag) {
3973 one_byte[0] = textval[ii+0];
3974 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3976 else if (chtml40->textarea_flag) {
3977 one_byte[0] = textval[ii+0];
3978 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3980 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3981 one_byte[0] = textval[ii+0];
3982 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3985 z2h_input_len = strlen(tdst);
3986 tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, chtml40->entryp);
3988 return chtml40->out;
3993 * It is a handler who processes the BLOCKQUOTE tag.
3995 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3996 * destination is specified.
3997 * @param node [i] The BLOCKQUOTE tag node is specified.
3998 * @return The conversion result is returned.
4001 s_chtml40_start_blockquote_tag(void *pdoc, Node *node)
4006 char *attr_style = NULL;
4007 char *attr_color = NULL;
4009 chtml40 = GET_CHTML40(pdoc);
4011 for (attr = qs_get_attr(doc,node);
4013 attr = qs_get_next_attr(doc,attr)) {
4014 char *nm = qs_get_attr_name(doc,attr);
4015 char *val = qs_get_attr_value(doc,attr);
4016 if (val && STRCASEEQ('s','S',"style", nm)) {
4020 if (IS_CSS_ON(chtml40->entryp)) {
4021 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4023 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4024 css_property_t *cur;
4025 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4026 if (cur->value && *cur->value) {
4027 attr_color = apr_pstrdup(doc->pool, cur->value);
4032 W_L("<blockquote>");
4033 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4034 memset(flg, 0, sizeof(*flg));
4036 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4037 W_L("<font color=\"");
4040 flg->with_font_flag = 1;
4042 node->userData = (void *)flg;
4043 return chtml40->out;
4048 * It is a handler who processes the BLOCKQUOTE tag.
4050 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4051 * destination is specified.
4052 * @param node [i] The BLOCKQUOTE tag node is specified.
4053 * @return The conversion result is returned.
4056 s_chtml40_end_blockquote_tag(void *pdoc, Node *node)
4058 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4059 Doc *doc = chtml40->doc;
4060 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4061 if (flg && flg->with_font_flag) {
4064 W_L("</blockquote>");
4065 if (IS_CSS_ON(chtml40->entryp)) {
4066 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4068 return chtml40->out;
4073 * It is a handler who processes the DIR tag.
4075 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4076 * destination is specified.
4077 * @param node [i] The DIR tag node is specified.
4078 * @return The conversion result is returned.
4081 s_chtml40_start_dir_tag(void *pdoc, Node *node)
4083 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4084 Doc *doc = chtml40->doc;
4086 char *attr_style = NULL;
4087 char *attr_color = NULL;
4088 char *attr_type = NULL;
4089 for (attr = qs_get_attr(doc,node);
4091 attr = qs_get_next_attr(doc,attr)) {
4092 char *name = qs_get_attr_name(doc,attr);
4093 char *value = qs_get_attr_value(doc,attr);
4094 if (STRCASEEQ('t','T',"type",name)) {
4095 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4099 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4103 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4111 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4112 memset(flg, 0, sizeof(*flg));
4114 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4115 W_L("<font color=\"");
4118 flg->with_font_flag = 1;
4120 node->userData = (void *)flg;
4121 return chtml40->out;
4126 * It is a handler who processes the DIR tag.
4128 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4129 * destination is specified.
4130 * @param node [i] The DIR tag node is specified.
4131 * @return The conversion result is returned.
4134 s_chtml40_end_dir_tag(void *pdoc, Node *node)
4136 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4137 Doc *doc = chtml40->doc;
4138 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4139 if (flg && flg->with_font_flag) {
4143 if (IS_CSS_ON(chtml40->entryp)) {
4144 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4146 return chtml40->out;
4151 * It is a handler who processes the DL tag.
4153 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4154 * destination is specified.
4155 * @param node [i] The DL tag node is specified.
4156 * @return The conversion result is returned.
4159 s_chtml40_start_dl_tag(void *pdoc, Node *node)
4164 char *attr_style = NULL;
4165 char *attr_color = NULL;
4167 chtml40 = GET_CHTML40(pdoc);
4169 for (attr = qs_get_attr(doc,node);
4171 attr = qs_get_next_attr(doc,attr)) {
4172 char *nm = qs_get_attr_name(doc,attr);
4173 char *val = qs_get_attr_value(doc,attr);
4174 if (val && STRCASEEQ('s','S',"style", nm)) {
4178 if (IS_CSS_ON(chtml40->entryp)) {
4179 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4181 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4182 css_property_t *cur;
4183 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4184 if (cur->value && *cur->value) {
4185 attr_color = apr_pstrdup(doc->pool, cur->value);
4191 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4192 memset(flg, 0, sizeof(*flg));
4194 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4195 W_L("<font color=\"");
4198 flg->with_font_flag = 1;
4200 node->userData = (void *)flg;
4201 return chtml40->out;
4206 * It is a handler who processes the DL tag.
4208 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4209 * destination is specified.
4210 * @param node [i] The DL tag node is specified.
4211 * @return The conversion result is returned.
4214 s_chtml40_end_dl_tag(void *pdoc, Node *node)
4216 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4217 Doc *doc = chtml40->doc;
4218 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4219 if (flg && flg->with_font_flag) {
4223 if (IS_CSS_ON(chtml40->entryp)) {
4224 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4226 return chtml40->out;
4231 * It is a handler who processes the DT tag.
4233 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4234 * destination is specified.
4235 * @param node [i] The DT tag node is specified.
4236 * @return The conversion result is returned.
4239 s_chtml40_start_dt_tag(void *pdoc, Node *node)
4244 char *attr_style = NULL;
4245 char *attr_color = NULL;
4247 chtml40 = GET_CHTML40(pdoc);
4249 for (attr = qs_get_attr(doc,node);
4251 attr = qs_get_next_attr(doc,attr)) {
4252 char *nm = qs_get_attr_name(doc,attr);
4253 char *val = qs_get_attr_value(doc,attr);
4254 if (val && STRCASEEQ('s','S',"style", nm)) {
4258 if (IS_CSS_ON(chtml40->entryp)) {
4259 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4261 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4262 css_property_t *cur;
4263 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4264 if (cur->value && *cur->value) {
4265 attr_color = apr_pstrdup(doc->pool, cur->value);
4271 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4272 memset(flg, 0, sizeof(*flg));
4274 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4275 W_L("<font color=\"");
4278 flg->with_font_flag = 1;
4280 node->userData = (void *)flg;
4281 return chtml40->out;
4286 * It is a handler who processes the DT tag.
4288 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4289 * destination is specified.
4290 * @param node [i] The DT tag node is specified.
4291 * @return The conversion result is returned.
4294 s_chtml40_end_dt_tag(void *pdoc, Node *node)
4296 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4297 Doc *doc = chtml40->doc;
4298 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4299 if (flg && flg->with_font_flag) {
4302 if (IS_CSS_ON(chtml40->entryp)) {
4303 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4305 return chtml40->out;
4310 * It is a handler who processes the DD tag.
4312 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4313 * destination is specified.
4314 * @param node [i] The DD tag node is specified.
4315 * @return The conversion result is returned.
4318 s_chtml40_start_dd_tag(void *pdoc, Node *node)
4323 char *attr_style = NULL;
4324 char *attr_color = NULL;
4326 chtml40 = GET_CHTML40(pdoc);
4328 for (attr = qs_get_attr(doc,node);
4330 attr = qs_get_next_attr(doc,attr)) {
4331 char *nm = qs_get_attr_name(doc,attr);
4332 char *val = qs_get_attr_value(doc,attr);
4333 if (val && STRCASEEQ('s','S',"style", nm)) {
4337 if (IS_CSS_ON(chtml40->entryp)) {
4338 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4340 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4341 css_property_t *cur;
4342 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4343 if (cur->value && *cur->value) {
4344 attr_color = apr_pstrdup(doc->pool, cur->value);
4350 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4351 memset(flg, 0, sizeof(*flg));
4353 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4354 W_L("<font color=\"");
4357 flg->with_font_flag = 1;
4359 node->userData = (void *)flg;
4360 return chtml40->out;
4365 * It is a handler who processes the DD tag.
4367 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4368 * destination is specified.
4369 * @param node [i] The DD tag node is specified.
4370 * @return The conversion result is returned.
4373 s_chtml40_end_dd_tag(void *pdoc, Node *node)
4375 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4376 Doc *doc = chtml40->doc;
4377 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4378 if (flg && flg->with_font_flag) {
4381 if (IS_CSS_ON(chtml40->entryp)) {
4382 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4384 return chtml40->out;
4389 * It is a handler who processes the MARQUEE tag.
4391 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4392 * destination is specified.
4393 * @param node [i] The MARQUEE tag node is specified.
4394 * @return The conversion result is returned.
4397 s_chtml40_start_marquee_tag(void *pdoc, Node *node)
4399 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4400 Doc *doc = chtml40->doc;
4402 char *attr_direction = NULL;
4403 char *attr_behavior = NULL;
4404 char *attr_loop = NULL;
4405 char *attr_style = NULL;
4406 char *attr_color = NULL;
4407 /*--------------------------------------------------------------------------*/
4408 /* Get Attributes */
4409 /*--------------------------------------------------------------------------*/
4410 for (attr = qs_get_attr(doc,node);
4412 attr = qs_get_next_attr(doc,attr)) {
4413 char *name = qs_get_attr_name(doc,attr);
4414 char *value = qs_get_attr_value(doc,attr);
4415 if (STRCASEEQ('d','D',"direction", name)) {
4416 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
4417 attr_direction = value;
4420 else if (STRCASEEQ('b','B',"behavior",name)) {
4421 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
4422 attr_behavior = value;
4425 else if (STRCASEEQ('l','L',"loop",name)) {
4426 if (value && *value) {
4430 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4434 if (IS_CSS_ON(chtml40->entryp)) {
4435 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4437 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4438 css_property_t *direction_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4439 css_property_t *style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4440 css_property_t *loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4441 css_property_t *cur;
4442 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4443 if (cur->value && *cur->value) {
4444 attr_color = apr_pstrdup(doc->pool, cur->value);
4447 for (cur = style_prop->next; cur != style_prop; cur = cur->next) {
4448 if (cur->value && *cur->value) {
4449 attr_behavior = apr_pstrdup(doc->pool, cur->value);
4452 for (cur = loop_prop->next; cur != loop_prop; cur = cur->next) {
4453 if (cur->value && *cur->value) {
4454 attr_loop = apr_pstrdup(doc->pool, cur->value);
4455 if (STRCASEEQ('i','I',"infinite",attr_loop)) {
4460 for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
4461 if (cur->value && *cur->value) {
4462 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4463 attr_direction = "right";
4465 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4466 attr_direction = "left";
4473 if (attr_direction) {
4474 W_L(" direction=\"");
4475 W_V(attr_direction);
4478 if (attr_behavior) {
4479 W_L(" behavior=\"");
4490 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4491 memset(flg, 0, sizeof(*flg));
4493 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4494 W_L("<font color=\"");
4497 flg->with_font_flag = 1;
4499 node->userData = (void *)flg;
4500 return chtml40->out;
4505 * It is a handler who processes the MARQUEE tag.
4507 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4508 * destination is specified.
4509 * @param node [i] The MARQUEE tag node is specified.
4510 * @return The conversion result is returned.
4513 s_chtml40_end_marquee_tag(void *pdoc, Node *node)
4515 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4516 Doc *doc = chtml40->doc;
4517 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4518 if (flg && flg->with_font_flag) {
4522 if (IS_CSS_ON(chtml40->entryp)) {
4523 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4525 return chtml40->out;
4530 * It is a handler who processes the BLINK tag.
4532 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4533 * destination is specified.
4534 * @param node [i] The BLINK tag node is specified.
4535 * @return The conversion result is returned.
4538 s_chtml40_start_blink_tag(void *pdoc, Node *node)
4543 char *attr_style = NULL;
4544 char *attr_color = NULL;
4546 chtml40 = GET_CHTML40(pdoc);
4548 for (attr = qs_get_attr(doc,node);
4550 attr = qs_get_next_attr(doc,attr)) {
4551 char *nm = qs_get_attr_name(doc,attr);
4552 char *val = qs_get_attr_value(doc,attr);
4553 if (val && STRCASEEQ('s','S',"style", nm)) {
4557 if (IS_CSS_ON(chtml40->entryp)) {
4558 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4560 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4561 css_property_t *cur;
4562 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4563 if (cur->value && *cur->value) {
4564 attr_color = apr_pstrdup(doc->pool, cur->value);
4570 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4571 memset(flg, 0, sizeof(*flg));
4573 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4574 W_L("<font color=\"");
4577 flg->with_font_flag = 1;
4579 node->userData = (void *)flg;
4580 return chtml40->out;
4585 * It is a handler who processes the BLINK tag.
4587 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4588 * destination is specified.
4589 * @param node [i] The BLINK tag node is specified.
4590 * @return The conversion result is returned.
4593 s_chtml40_end_blink_tag(void *pdoc, Node *node)
4595 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4596 Doc *doc = chtml40->doc;
4597 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4598 if (flg && flg->with_font_flag) {
4602 if (IS_CSS_ON(chtml40->entryp)) {
4603 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4605 return chtml40->out;
4610 * It is a handler who processes the MENU tag.
4612 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4613 * destination is specified.
4614 * @param node [i] The MENU tag node is specified.
4615 * @return The conversion result is returned.
4618 s_chtml40_start_menu_tag(void *pdoc, Node *node)
4620 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4621 Doc *doc = chtml40->doc;
4623 char *attr_style = NULL;
4624 char *attr_type = NULL;
4625 char *attr_color = NULL;
4626 /*--------------------------------------------------------------------------*/
4627 /* Get Attributes */
4628 /*--------------------------------------------------------------------------*/
4629 for (attr = qs_get_attr(doc,node);
4631 attr = qs_get_next_attr(doc,attr)) {
4632 char *name = qs_get_attr_name(doc,attr);
4633 char *value = qs_get_attr_value(doc,attr);
4634 if (STRCASEEQ('t','T',"type",name)) {
4635 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4639 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4643 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4651 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4652 memset(flg, 0, sizeof(*flg));
4654 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4655 W_L("<font color=\"");
4658 flg->with_font_flag = 1;
4660 node->userData = (void *)flg;
4662 return chtml40->out;
4667 * It is a handler who processes the MENU tag.
4669 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4670 * destination is specified.
4671 * @param node [i] The MENU tag node is specified.
4672 * @return The conversion result is returned.
4675 s_chtml40_end_menu_tag(void *pdoc, Node *node)
4677 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4678 Doc *doc = chtml40->doc;
4679 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4680 if (flg && flg->with_font_flag) {
4684 if (IS_CSS_ON(chtml40->entryp)) {
4685 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4687 return chtml40->out;
4692 * It is a handler who processes the PLAINTEXT tag.
4694 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4695 * destination is specified.
4696 * @param node [i] The PLAINTEXT tag node is specified.
4697 * @return The conversion result is returned.
4700 s_chtml40_start_plaintext_tag(void *pdoc, Node *node)
4702 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4703 Doc *doc = chtml40->doc;
4705 s_chtml40_start_plaintext_tag_inner(pdoc,node);
4706 return chtml40->out;
4710 s_chtml40_start_plaintext_tag_inner(void *pdoc, Node *node)
4712 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4713 Doc *doc = chtml40->doc;
4715 for (child = qs_get_child_node(doc, node);
4717 child = qs_get_next_node(doc, child)) {
4719 s_chtml40_start_plaintext_tag_inner(pdoc, child);
4721 return chtml40->out;
4726 * It is a handler who processes the PLAINTEXT tag.
4728 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4729 * destination is specified.
4730 * @param node [i] The PLAINTEXT tag node is specified.
4731 * @return The conversion result is returned.
4734 s_chtml40_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4736 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4737 return chtml40->out;
4742 * It is handler who processes the New Line Code.
4745 s_chtml40_newline_mark(void *pdoc, Node *UNUSED(node))
4747 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4748 Doc *doc = chtml40->doc;
4750 return chtml40->out;
4755 * It is a handler who processes the LINK tag.
4757 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4758 * destination is specified.
4759 * @param node [i] The LINK tag node is specified.
4760 * @return The conversion result is returned.
4763 s_chtml40_link_tag(void *pdoc, Node *node)
4772 chtml40 = GET_CHTML40(pdoc);
4775 if (! IS_CSS_ON(chtml40->entryp)) {
4776 return chtml40->out;
4779 for (attr = qs_get_attr(doc,node);
4781 attr = qs_get_next_attr(doc,attr)) {
4782 char *name = qs_get_attr_name(doc,attr);
4783 char *value = qs_get_attr_value(doc,attr);
4784 if (STRCASEEQ('r','R',"rel", name)) {
4785 if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
4789 else if (STRCASEEQ('h','H',"href", name)) {
4790 if (value && *value) {
4794 else if (STRCASEEQ('t','T',"type", name)) {
4795 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
4801 if (rel && href && type) {
4802 DBG(doc->r, "start load CSS. url:[%s]", href);
4803 chtml40->style = chxj_css_parse_from_uri(doc->r, doc->pool, chtml40->style, href);
4804 DBG(doc->r, "end load CSS. url:[%s]", href);
4807 return chtml40->out;
4810 static css_prop_list_t *
4811 s_chtml40_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4813 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4814 Doc *doc = chtml40->doc;
4815 css_prop_list_t *last_css = NULL;
4816 if (IS_CSS_ON(chtml40->entryp)) {
4817 css_prop_list_t *dup_css;
4818 css_selector_t *selector;
4820 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4821 dup_css = chxj_dup_css_prop_list(doc, last_css);
4822 selector = chxj_css_find_selector(doc, chtml40->style, node);
4824 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4826 chxj_css_push_prop_list(chtml40->css_prop_stack, dup_css);
4827 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4829 if (style_attr_value) {
4830 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));
4832 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4840 static css_prop_list_t *
4841 s_chtml40_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4843 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4844 Doc *doc = chtml40->doc;
4845 css_prop_list_t *last_css = NULL;
4846 if (IS_CSS_ON(chtml40->entryp)) {
4847 css_prop_list_t *dup_css;
4848 css_selector_t *selector;
4850 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4851 dup_css = chxj_dup_css_prop_list(doc, last_css);
4852 selector = chxj_css_find_selector(doc, chtml40->style, node);
4854 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4858 if (style_attr_value) {
4859 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));
4861 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4871 * It is a handler who processes the SPAN tag.
4873 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4874 * destination is specified.
4875 * @param node [i] The SPAN tag node is specified.
4876 * @return The conversion result is returned.
4879 s_chtml40_start_span_tag(void *pdoc, Node *node)
4884 char *attr_style = NULL;
4885 char *attr_color = NULL;
4886 char *attr_align = NULL;
4887 char *attr_blink = NULL;
4888 char *attr_marquee = NULL;
4889 char *attr_marquee_dir = NULL;
4890 char *attr_marquee_style = NULL;
4891 char *attr_marquee_loop = NULL;
4893 chtml40 = GET_CHTML40(pdoc);
4896 for (attr = qs_get_attr(doc,node);
4898 attr = qs_get_next_attr(doc,attr)) {
4899 char *nm = qs_get_attr_name(doc,attr);
4900 char *val = qs_get_attr_value(doc,attr);
4901 if (val && STRCASEEQ('s','S',"style", nm)) {
4905 if (IS_CSS_ON(chtml40->entryp)) {
4906 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4908 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4909 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
4910 css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
4911 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
4912 css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4913 css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4914 css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4915 css_property_t *cur;
4916 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4917 attr_color = apr_pstrdup(doc->pool, cur->value);
4919 for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
4920 if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
4921 attr_blink = apr_pstrdup(doc->pool, cur->value);
4924 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
4925 if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
4926 attr_marquee = apr_pstrdup(doc->pool, cur->value);
4929 for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
4930 if (cur->value && *cur->value) {
4931 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4932 attr_marquee_dir = "right";
4934 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4935 attr_marquee_dir = "left";
4939 for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
4940 if (cur->value && *cur->value) {
4941 if ( STRCASEEQ('s','S',"scroll",cur->value)
4942 || STRCASEEQ('s','S',"slide",cur->value)
4943 || STRCASEEQ('a','A',"alternate",cur->value)) {
4944 attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
4948 for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
4949 if (cur->value && *cur->value) {
4950 if (STRCASEEQ('i','I',"infinite",cur->value)) {
4951 attr_marquee_loop = "16";
4954 attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
4958 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
4959 if (STRCASEEQ('l','L',"left", cur->value)) {
4960 attr_align = apr_pstrdup(doc->pool, "left");
4962 else if (STRCASEEQ('c','C',"center",cur->value)) {
4963 attr_align = apr_pstrdup(doc->pool, "center");
4965 else if (STRCASEEQ('r','R',"right",cur->value)) {
4966 attr_align = apr_pstrdup(doc->pool, "right");
4971 if (attr_color || attr_align || attr_blink || attr_marquee) {
4972 chtml40_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
4973 memset(flg, 0, sizeof(*flg));
4976 flg->with_blink_flag = 1;
4980 if (attr_marquee_dir) {
4981 W_L(" direction=\"");
4982 W_V(attr_marquee_dir);
4985 if (attr_marquee_style) {
4986 W_L(" behavior=\"");
4987 W_V(attr_marquee_style);
4990 if (attr_marquee_loop) {
4992 W_V(attr_marquee_loop);
4996 flg->with_marquee_flag = 1;
4999 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5000 W_L("<font color=\"");
5003 flg->with_font_flag = 1;
5006 W_L("<div align=\"");
5009 flg->with_div_flag = 1;
5011 node->userData = flg;
5014 node->userData = NULL;
5016 return chtml40->out;
5021 * It is a handler who processes the SPAN tag.
5023 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5024 * destination is specified.
5025 * @param node [i] The SPAN tag node is specified.
5026 * @return The conversion result is returned.
5029 s_chtml40_end_span_tag(void *pdoc, Node *node)
5031 chtml40_t *chtml40 = GET_CHTML40(pdoc);
5032 Doc *doc = chtml40->doc;
5034 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
5035 if (flg && flg->with_div_flag) {
5038 if (flg && flg->with_font_flag) {
5041 if (flg && flg->with_marquee_flag) {
5044 if (flg && flg->with_blink_flag) {
5047 if (IS_CSS_ON(chtml40->entryp)) {
5048 chxj_css_pop_prop_list(chtml40->css_prop_stack);
5050 return chtml40->out;
5055 * It is a handler who processes the STYLE tag.
5057 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5058 * destination is specified.
5059 * @param node [i] The STYLE tag node is specified.
5060 * @return The conversion result is returned.
5063 s_chtml40_style_tag(void *pdoc, Node *node)
5070 chtml40 = GET_CHTML40(pdoc);
5073 if (! IS_CSS_ON(chtml40->entryp)) {
5074 return chtml40->out;
5077 for (attr = qs_get_attr(doc,node);
5079 attr = qs_get_next_attr(doc,attr)) {
5080 char *name = qs_get_attr_name(doc,attr);
5081 char *value = qs_get_attr_value(doc,attr);
5082 if (STRCASEEQ('t','T',"type", name)) {
5083 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5089 Node *child = qs_get_child_node(doc, node);
5090 if (type && child) {
5091 char *name = qs_get_node_name(doc, child);
5092 if (STRCASEEQ('t','T',"text", name)) {
5093 char *value = qs_get_node_value(doc, child);
5094 DBG(doc->r, "start load CSS. buf:[%s]", value);
5095 chtml40->style = chxj_css_parse_style_value(doc, chtml40->style, value);
5096 DBG(doc->r, "end load CSS. value:[%s]", value);
5099 return chtml40->out;