2 * Copyright (C) 2005-2011 Atsushi Konno All rights reserved.
3 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
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, Node *node);
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,
324 s_chtml40_chxjif_tag,
344 s_chtml40_start_span_tag,
345 s_chtml40_end_span_tag,
369 s_chtml40_start_dt_tag,
370 s_chtml40_end_dt_tag,
384 s_chtml40_start_blockquote_tag,
385 s_chtml40_end_blockquote_tag,
389 s_chtml40_start_dir_tag,
390 s_chtml40_end_dir_tag,
394 s_chtml40_start_dl_tag,
395 s_chtml40_end_dl_tag,
399 s_chtml40_start_dd_tag,
400 s_chtml40_end_dd_tag,
404 s_chtml40_start_menu_tag,
405 s_chtml40_end_menu_tag,
409 s_chtml40_start_plaintext_tag,
410 s_chtml40_end_plaintext_tag,
414 s_chtml40_start_blink_tag,
415 s_chtml40_end_blink_tag,
419 s_chtml40_start_marquee_tag,
420 s_chtml40_end_marquee_tag,
429 s_chtml40_newline_mark,
451 * converts from CHTML5.0 to CHTML3.0.
453 * @param r [i] Requet_rec is appointed.
454 * @param spec [i] The result of the device specification processing which
455 * was done in advance is appointed.
456 * @param src [i] The character string before the converting is appointed.
457 * @return The character string after the converting is returned.
460 chxj_convert_chtml40(
466 chxjconvrule_entry *entryp,
475 DBG(r, "start chxj_convert_chtml40()");
477 /*--------------------------------------------------------------------------*/
479 /*--------------------------------------------------------------------------*/
481 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
483 DBG(r,"i found qrcode xml");
484 DBG(r, "end chxj_convert_chtml40()");
487 DBG(r,"not found qrcode xml");
489 /*--------------------------------------------------------------------------*/
490 /* The CHTML structure is initialized. */
491 /*--------------------------------------------------------------------------*/
492 s_init_chtml40(&chtml40, &doc, r, spec);
494 chtml40.entryp = entryp;
495 chtml40.cookie = cookie;
497 chxj_set_content_type(r, chxj_header_inf_set_content_type(r, "text/html; charset=Windows-31J"));
499 /*--------------------------------------------------------------------------*/
500 /* The character string of the input is analyzed. */
501 /*--------------------------------------------------------------------------*/
502 qs_init_malloc(&doc);
503 qs_init_root_node(&doc);
505 ss = apr_pcalloc(r->pool, srclen + 1);
506 memset(ss, 0, srclen + 1);
507 memcpy(ss, src, srclen);
510 chxj_dump_out("[src] CHTML -> CHTML4.0", ss, srclen);
512 if (IS_CSS_ON(chtml40.entryp)) {
513 /* current property list */
514 chtml40.css_prop_stack = chxj_new_prop_list_stack(&doc);
517 chxj_buffered_write_init(r->pool, &doc.buf);
519 qs_parse_string(&doc,ss, strlen(ss));
521 /*--------------------------------------------------------------------------*/
522 /* It converts it from CHTML to CHTML. */
523 /*--------------------------------------------------------------------------*/
524 chxj_node_convert(spec,r,(void*)&chtml40, &doc, qs_get_root(&doc), 0);
525 chtml40.out = chxj_buffered_write_flush(chtml40.out, &doc.buf);
526 dst = apr_pstrdup(r->pool, chtml40.out);
527 chxj_buffered_write_terminate(&doc.buf);
529 qs_all_free(&doc,QX_LOGMARK);
532 dst = apr_pstrdup(r->pool,ss);
534 if (strlen(dst) == 0) {
535 dst = apr_psprintf(r->pool, "\n");
538 *dstlen = strlen(dst);
541 chxj_dump_out("[src] CHTML -> CHTML4.0", dst, *dstlen);
544 DBG(r, "end chxj_convert_chtml40()");
550 * The CHTML structure is initialized.
552 * @param chtml40 [i/o] The pointer to the HDML structure that wants to be
553 * initialized is specified.
554 * @param doc [i] The Doc structure that should be set to the initialized
555 * HDML structure is specified.
556 * @param r [i] To use POOL, the pointer to request_rec is specified.
557 * @param spec [i] The pointer to the device_table
560 s_init_chtml40(chtml40_t *chtml40, Doc *doc, request_rec *r, device_table *spec)
562 memset(doc, 0, sizeof(Doc));
563 memset(chtml40, 0, sizeof(chtml40_t));
567 chtml40->spec = spec;
568 chtml40->out = qs_alloc_zero_byte_string(r->pool);
569 chtml40->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
570 chtml40->doc->parse_mode = PARSE_MODE_CHTML;
575 * Corresponding EMOJI to a current character-code is retrieved.
576 * The substitution character string is stored in the rslt pointer if agreeing.
578 * @param chtml40 [i] The pointer to the CHTML structure is specified.
579 * @param txt [i] The character string to want to examine whether it is
580 * EMOJI is specified.
581 * @param rslt [o] The pointer to the pointer that stores the result is
583 * @param node [i] The current node to check whether tag is span/font for CHXJ_IMODE_EMOJI_COLOR_AUTO.
584 * @return When corresponding EMOJI exists, it returns it excluding 0.
587 s_chtml40_search_emoji(chtml40_t *chtml40, char *txt, char **rslt, Node *node)
594 spec = chtml40->spec;
600 DBG(r,"spec is NULL");
603 for (ee = chtml40->conf->emoji;
606 if (ee->imode == NULL) {
607 DBG(r, "emoji->imode is NULL");
611 if (ee->imode->string != NULL
612 && strlen(ee->imode->string) > 0
613 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
615 if (spec == NULL || spec->emoji_type == NULL) {
616 *rslt = apr_palloc(r->pool, 3);
617 (*rslt)[0] = ee->imode->hex1byte & 0xff;
618 (*rslt)[1] = ee->imode->hex2byte & 0xff;
621 if(chtml40->conf->imode_emoji_color >= CHXJ_IMODE_EMOJI_COLOR_AUTO ){
622 if(ee->imode->color != NULL){
623 if(chtml40->conf->imode_emoji_color == CHXJ_IMODE_EMOJI_COLOR_AUTO && node != NULL ){
624 if(strcasecmp(node->parent->name, "span") == 0 ||
625 strcasecmp(node->parent->name, "font") == 0 ){
626 return strlen(ee->imode->string);
629 char *tmp = apr_pstrdup(r->pool,*rslt);
630 *rslt = apr_psprintf(r->pool,
631 "<font color=\"%s\">%s</font>",ee->imode->color,tmp);
634 return strlen(ee->imode->string);
646 chxj_chtml40_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
657 chtml40 = &__chtml40;
660 DBG(r, "REQ[%X] start chxj_chtml40_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
661 memset(doc, 0, sizeof(Doc));
662 memset(chtml40, 0, sizeof(chtml40_t));
666 chtml40->spec = spec;
667 chtml40->out = qs_alloc_zero_byte_string(r->pool);
668 chtml40->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
669 chtml40->doc->parse_mode = PARSE_MODE_CHTML;
671 apr_pool_create(&pool, r->pool);
673 chxj_buffered_write_init(pool, &doc->buf);
675 for (ii=0; ii<len; ii++) {
679 rtn = s_chtml40_search_emoji(chtml40, (char *)&src[ii], &out, NULL);
686 if (is_sjis_kanji(src[ii])) {
687 two_byte[0] = src[ii+0];
688 two_byte[1] = src[ii+1];
694 one_byte[0] = src[ii+0];
699 chtml40->out = chxj_buffered_write_flush(chtml40->out, &doc->buf);
701 DBG(r, "REQ[%X] end chxj_chtml40_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
707 * It is a handler who processes the HTML tag.
709 * @param pdoc [i/o] The pointer to the CHTML structure at the output
710 * destination is specified.
711 * @param node [i] The HTML tag node is specified.
712 * @return The conversion result is returned.
715 s_chtml40_start_html_tag(void *pdoc, Node *UNUSED(node))
717 chtml40_t *chtml40 = GET_CHTML40(pdoc);
718 Doc *doc = chtml40->doc;
720 /*--------------------------------------------------------------------------*/
722 /*--------------------------------------------------------------------------*/
730 * It is a handler who processes the HTML tag.
732 * @param pdoc [i/o] The pointer to the CHTML structure at the output
733 * destination is specified.
734 * @param node [i] The HTML tag node is specified.
735 * @return The conversion result is returned.
738 s_chtml40_end_html_tag(void *pdoc, Node *UNUSED(child))
740 chtml40_t *chtml40 = GET_CHTML40(pdoc);
741 Doc *doc = chtml40->doc;
749 * It is a handler who processes the META tag.
751 * @param pdoc [i/o] The pointer to the CHTML structure at the output
752 * destination is specified.
753 * @param node [i] The META tag node is specified.
754 * @return The conversion result is returned.
757 s_chtml40_start_meta_tag(void *pdoc, Node *node)
763 int content_type_flag;
766 chtml40 = GET_CHTML40(pdoc);
770 content_type_flag = 0;
774 /*--------------------------------------------------------------------------*/
776 /*--------------------------------------------------------------------------*/
777 for (attr = qs_get_attr(doc,node);
779 attr = qs_get_next_attr(doc,attr)) {
780 char *name = qs_get_attr_name(doc,attr);
781 char *value = qs_get_attr_value(doc,attr);
785 if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
786 /*----------------------------------------------------------------------*/
788 /*----------------------------------------------------------------------*/
789 W_L(" http-equiv=\"");
792 if (STRCASEEQ('c','C',"content-type", value))
793 content_type_flag = 1;
795 if (STRCASEEQ('r','R',"refresh", value))
802 if (strcasecmp(name, "content") == 0 && value && *value) {
803 if (content_type_flag) {
807 W_V(chxj_header_inf_set_content_type(r, "text/html; charset=SHIFT_JIS"));
815 buf = apr_pstrdup(r->pool, value);
816 url = strchr(buf, ';');
818 sec = apr_pstrdup(r->pool, buf);
821 url = chxj_encoding_parameter(r, url, 0);
822 url = chxj_add_cookie_parameter(r, url, chtml40->cookie);
852 * It is a handler who processes the META tag.
854 * @param pdoc [i/o] The pointer to the CHTML structure at the output
855 * destination is specified.
856 * @param node [i] The META tag node is specified.
857 * @return The conversion result is returned.
860 s_chtml40_end_meta_tag(void* pdoc, Node* UNUSED(child))
862 chtml40_t *chtml40 = GET_CHTML40(pdoc);
869 * It is a handler who processes the HEAD tag.
871 * @param pdoc [i/o] The pointer to the CHTML structure at the output
872 * destination is specified.
873 * @param node [i] The HEAD tag node is specified.
874 * @return The conversion result is returned.
877 s_chtml40_start_head_tag(void* pdoc, Node* UNUSED(node))
879 chtml40_t *chtml40 = GET_CHTML40(pdoc);
880 Doc *doc = chtml40->doc;
889 * It is a handler who processes the HEAD tag.
891 * @param pdoc [i/o] The pointer to the CHTML structure at the output
892 * destination is specified.
893 * @param node [i] The HEAD tag node is specified.
894 * @return The conversion result is returned.
897 s_chtml40_end_head_tag(void *pdoc, Node *UNUSED(node))
899 chtml40_t *chtml40 = GET_CHTML40(pdoc);
900 Doc *doc = chtml40->doc;
909 * It is a handler who processes the TITLE tag.
911 * @param pdoc [i/o] The pointer to the CHTML structure at the output
912 * destination is specified.
913 * @param node [i] The TITLE tag node is specified.
914 * @return The conversion result is returned.
917 s_chtml40_start_title_tag(void *pdoc, Node *UNUSED(node))
919 chtml40_t *chtml40 = GET_CHTML40(pdoc);
920 Doc *doc = chtml40->doc;
929 * It is a handler who processes the TITLE tag.
931 * @param pdoc [i/o] The pointer to the CHTML structure at the output
932 * destination is specified.
933 * @param node [i] The TITLE tag node is specified.
934 * @return The conversion result is returned.
937 s_chtml40_end_title_tag(void *pdoc, Node *UNUSED(child))
939 chtml40_t *chtml40 = GET_CHTML40(pdoc);
940 Doc *doc = chtml40->doc;
949 * It is a handler who processes the BASE tag.
951 * @param pdoc [i/o] The pointer to the CHTML structure at the output
952 * destination is specified.
953 * @param node [i] The BASE tag node is specified.
954 * @return The conversion result is returned.
957 s_chtml40_start_base_tag(void *pdoc, Node *node)
964 chtml40 = GET_CHTML40(pdoc);
969 /*--------------------------------------------------------------------------*/
971 /*--------------------------------------------------------------------------*/
972 for (attr = qs_get_attr(doc,node);
974 attr = qs_get_next_attr(doc,attr)) {
975 char *name = qs_get_attr_name(doc,attr);
976 char *value = qs_get_attr_value(doc,attr);
977 if (STRCASEEQ('h','H',"href", name)) {
990 * It is a handler who processes the BASE tag.
992 * @param pdoc [i/o] The pointer to the CHTML structure at the output
993 * destination is specified.
994 * @param node [i] The BASE tag node is specified.
995 * @return The conversion result is returned.
998 s_chtml40_end_base_tag(void *pdoc, Node *UNUSED(child))
1000 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1002 return chtml40->out;
1007 * It is a handler who processes the BODY tag.
1009 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1010 * destination is specified.
1011 * @param node [i] The BODY tag node is specified.
1012 * @return The conversion result is returned.
1015 s_chtml40_start_body_tag(void *pdoc, Node *node)
1021 char *attr_bgcolor = NULL;
1022 char *attr_text = NULL;
1023 char *attr_link = NULL;
1024 char *attr_style = NULL;
1025 char *attr_alink = NULL;
1026 char *attr_vlink = NULL;
1029 chtml40 = GET_CHTML40(pdoc);
1033 /*--------------------------------------------------------------------------*/
1034 /* Get Attributes */
1035 /*--------------------------------------------------------------------------*/
1036 for (attr = qs_get_attr(doc,node);
1038 attr = qs_get_next_attr(doc,attr)) {
1039 char *name = qs_get_attr_name(doc,attr);
1040 char *value = qs_get_attr_value(doc,attr);
1041 if (STRCASEEQ('b','B', "bgcolor", name) && value && *value) {
1042 /*----------------------------------------------------------------------*/
1044 /*----------------------------------------------------------------------*/
1045 attr_bgcolor = value;
1047 else if (STRCASEEQ('t','T', "text", name) && value && *value) {
1048 /*----------------------------------------------------------------------*/
1050 /*----------------------------------------------------------------------*/
1053 else if (STRCASEEQ('l','L',"link", name) && value && *value) {
1054 /*----------------------------------------------------------------------*/
1056 /*----------------------------------------------------------------------*/
1059 else if (STRCASEEQ('a','A',"alink", name) && value && *value) {
1060 /*----------------------------------------------------------------------*/
1062 /*----------------------------------------------------------------------*/
1065 else if (STRCASEEQ('v','V',"vlink", name) && value && *value) {
1066 /*----------------------------------------------------------------------*/
1068 /*----------------------------------------------------------------------*/
1071 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1076 if (IS_CSS_ON(chtml40->entryp)) {
1077 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1079 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1080 css_property_t *bgcolor_prop = chxj_css_get_property_value(doc, style, "background-color");
1081 css_property_t *cur;
1082 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1083 if (cur->value && *cur->value) {
1084 attr_text = apr_pstrdup(doc->pool, cur->value);
1087 for (cur = bgcolor_prop->next; cur != bgcolor_prop; cur = cur->next) {
1088 if (cur->value && *cur->value) {
1089 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
1093 if (chtml40->style) {
1094 css_stylesheet_t *pseudos = chxj_find_pseudo_selectors(doc, chtml40->style);
1095 css_selector_t *cur_sel;
1096 for (cur_sel = pseudos->selector_head.next; cur_sel != &pseudos->selector_head; cur_sel = cur_sel->next) {
1097 if (cur_sel->name && strcasecmp(cur_sel->name, "a:link") == 0) {
1098 css_property_t *cur;
1099 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1100 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1101 attr_link = apr_pstrdup(doc->pool, cur->value);
1105 else if (cur_sel->name && strcasecmp(cur_sel->name, "a:visited") == 0) {
1106 css_property_t *cur;
1107 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1108 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1109 attr_vlink = apr_pstrdup(doc->pool, cur->value);
1113 else if (cur_sel->name && strcasecmp(cur_sel->name, "a:focus") == 0) {
1114 css_property_t *cur;
1115 for (cur = cur_sel->property_head.next; cur != &cur_sel->property_head; cur = cur->next) {
1116 if (cur->name && strcasecmp(cur->name, "color") == 0) {
1117 attr_alink = apr_pstrdup(doc->pool, cur->value);
1127 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
1133 attr_text = chxj_css_rgb_func_to_value(doc->pool, attr_text);
1139 attr_link = chxj_css_rgb_func_to_value(doc->pool, attr_link);
1145 attr_alink = chxj_css_rgb_func_to_value(doc->pool, attr_alink);
1151 attr_vlink = chxj_css_rgb_func_to_value(doc->pool, attr_vlink);
1158 return chtml40->out;
1163 * It is a handler who processes the BODY tag.
1165 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1166 * destination is specified.
1167 * @param node [i] The BODY tag node is specified.
1168 * @return The conversion result is returned.
1171 s_chtml40_end_body_tag(void *pdoc, Node *UNUSED(child))
1176 chtml40 = GET_CHTML40(pdoc);
1180 if (IS_CSS_ON(chtml40->entryp)) {
1181 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1184 return chtml40->out;
1189 * It is a handler who processes the A tag.
1191 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1192 * destination is specified.
1193 * @param node [i] The A tag node is specified.
1194 * @return The conversion result is returned.
1197 s_chtml40_start_a_tag(void *pdoc, Node *node)
1203 char *attr_style = NULL;
1205 chtml40 = GET_CHTML40(pdoc);
1210 /*--------------------------------------------------------------------------*/
1211 /* Get Attributes */
1212 /*--------------------------------------------------------------------------*/
1213 for (attr = qs_get_attr(doc,node);
1215 attr = qs_get_next_attr(doc,attr)) {
1216 char *name = qs_get_attr_name(doc,attr);
1217 char *value = qs_get_attr_value(doc,attr);
1218 if (STRCASEEQ('n','N',"name", name)) {
1219 /*----------------------------------------------------------------------*/
1221 /*----------------------------------------------------------------------*/
1226 else if (STRCASEEQ('h','H',"href", name)) {
1227 /*----------------------------------------------------------------------*/
1229 /*----------------------------------------------------------------------*/
1230 value = chxj_encoding_parameter(r, value, 0);
1231 if (! chxj_starts_with(value, "mailto:") && ! chxj_starts_with(value, "tel:")) {
1232 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
1238 else if (STRCASEEQ('a','A',"accesskey", name)) {
1239 /*----------------------------------------------------------------------*/
1241 /*----------------------------------------------------------------------*/
1242 W_L(" accesskey=\"");
1246 else if (STRCASEEQ('c','C',"cti", name)) {
1247 /*----------------------------------------------------------------------*/
1249 /*----------------------------------------------------------------------*/
1254 else if (STRCASEEQ('i','I',"ijam", name)) {
1255 /*----------------------------------------------------------------------*/
1257 /*----------------------------------------------------------------------*/
1260 else if (STRCASEEQ('u','U',"utn", name)) {
1261 /*----------------------------------------------------------------------*/
1263 /* It is special only for CHTML. */
1264 /*----------------------------------------------------------------------*/
1267 else if (STRCASEEQ('t','T',"telbook", name)) {
1268 /*----------------------------------------------------------------------*/
1270 /*----------------------------------------------------------------------*/
1273 else if (STRCASEEQ('k','K',"kana", name)) {
1274 /*----------------------------------------------------------------------*/
1276 /*----------------------------------------------------------------------*/
1279 else if (STRCASEEQ('e','E',"email", name)) {
1280 /*----------------------------------------------------------------------*/
1282 /*----------------------------------------------------------------------*/
1285 else if (STRCASEEQ('i','I',"ista", name)) {
1286 /*----------------------------------------------------------------------*/
1288 /*----------------------------------------------------------------------*/
1291 else if (STRCASEEQ('i','I',"ilet", name)) {
1292 /*----------------------------------------------------------------------*/
1294 /*----------------------------------------------------------------------*/
1297 else if (STRCASEEQ('i','I',"iswf", name)) {
1298 /*----------------------------------------------------------------------*/
1300 /*----------------------------------------------------------------------*/
1303 else if (STRCASEEQ('i','I',"irst", name)) {
1304 /*----------------------------------------------------------------------*/
1306 /*----------------------------------------------------------------------*/
1309 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1315 if (IS_CSS_ON(chtml40->entryp)) {
1316 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1319 return chtml40->out;
1324 * It is a handler who processes the A tag.
1326 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1327 * destination is specified.
1328 * @param node [i] The A tag node is specified.
1329 * @return The conversion result is returned.
1332 s_chtml40_end_a_tag(void *pdoc, Node *UNUSED(child))
1337 chtml40 = GET_CHTML40(pdoc);
1342 if (IS_CSS_ON(chtml40->entryp)) {
1343 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1346 return chtml40->out;
1351 * It is a handler who processes the BR tag.
1353 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1354 * destination is specified.
1355 * @param node [i] The BR tag node is specified.
1356 * @return The conversion result is returned.
1359 s_chtml40_start_br_tag(void *pdoc, Node *node)
1366 chtml40 = GET_CHTML40(pdoc);
1370 /*--------------------------------------------------------------------------*/
1371 /* Get Attributes */
1372 /*--------------------------------------------------------------------------*/
1373 for (attr = qs_get_attr(doc,node);
1375 attr = qs_get_next_attr(doc,attr)) {
1376 char *name = qs_get_attr_name(doc,attr);
1377 char *value = qs_get_attr_value(doc,attr);
1378 if (STRCASEEQ('c','C',"clear",name)) {
1379 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1388 return chtml40->out;
1393 * It is a handler who processes the BR tag.
1395 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1396 * destination is specified.
1397 * @param node [i] The BR tag node is specified.
1398 * @return The conversion result is returned.
1401 s_chtml40_end_br_tag(void *pdoc, Node *UNUSED(child))
1403 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1405 return chtml40->out;
1410 * It is a handler who processes the TR tag.
1412 * @param chtml40 [i/o] The pointer to the CHTML structure at the output
1413 * destination is specified.
1414 * @param node [i] The TR tag node is specified.
1415 * @return The conversion result is returned.
1418 s_chtml40_start_tr_tag(void *pdoc, Node *UNUSED(node))
1420 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1422 return chtml40->out;
1427 * It is a handler who processes the TR tag.
1429 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1430 * destination is specified.
1431 * @param node [i] The TR tag node is specified.
1432 * @return The conversion result is returned.
1435 s_chtml40_end_tr_tag(void *pdoc, Node *UNUSED(child))
1441 chtml40 = GET_CHTML40(pdoc);
1447 return chtml40->out;
1452 * It is a handler who processes the FONT tag.
1454 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1455 * destination is specified.
1456 * @param node [i] The FONT tag node is specified.
1457 * @return The conversion result is returned.
1460 s_chtml40_start_font_tag(void *pdoc, Node *node)
1466 char *attr_color = NULL;
1467 char *attr_style = NULL;
1469 chtml40 = GET_CHTML40(pdoc);
1473 /*--------------------------------------------------------------------------*/
1474 /* Get Attributes */
1475 /*--------------------------------------------------------------------------*/
1476 for (attr = qs_get_attr(doc,node);
1478 attr = qs_get_next_attr(doc,attr)) {
1479 char *name = qs_get_attr_name(doc,attr);
1480 char *value = qs_get_attr_value(doc,attr);
1481 if (STRCASEEQ('c','C',"color", name) && value && *value) {
1482 attr_color = apr_pstrdup(doc->buf.pool, value);
1485 else if (STRCASEEQ('s','S',"size", name)) {
1486 /*----------------------------------------------------------------------*/
1488 /*----------------------------------------------------------------------*/
1491 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1495 if (IS_CSS_ON(chtml40->entryp)) {
1496 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1498 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1499 css_property_t *cur;
1500 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1501 if (cur->value && *cur->value) {
1502 attr_color = apr_pstrdup(doc->pool, cur->value);
1508 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1509 W_L("<font color=\"");
1512 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(*flg));
1513 flg->with_font_flag = 1;
1514 node->userData = flg;
1517 node->userData = NULL;
1519 return chtml40->out;
1524 * It is a handler who processes the FONT tag.
1526 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1527 * destination is specified.
1528 * @param node [i] The FONT tag node is specified.
1529 * @return The conversion result is returned.
1532 s_chtml40_end_font_tag(void *pdoc, Node *node)
1538 chtml40 = GET_CHTML40(pdoc);
1542 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1543 if (flg && flg->with_font_flag) {
1546 if (IS_CSS_ON(chtml40->entryp)) {
1547 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1550 return chtml40->out;
1555 * It is a handler who processes the FORM tag.
1557 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1558 * destination is specified.
1559 * @param node [i] The FORM tag node is specified.
1560 * @return The conversion result is returned.
1563 s_chtml40_start_form_tag(void *pdoc, Node *node)
1569 char *attr_action = NULL;
1570 char *attr_method = NULL;
1571 char *attr_style = NULL;
1572 char *attr_color = NULL;
1573 char *attr_align = NULL;
1574 char *attr_utn = NULL;
1575 char *new_hidden_tag = NULL;
1577 chtml40 = GET_CHTML40(pdoc);
1581 /*--------------------------------------------------------------------------*/
1582 /* Get Attributes */
1583 /*--------------------------------------------------------------------------*/
1584 for (attr = qs_get_attr(doc,node);
1586 attr = qs_get_next_attr(doc,attr)) {
1587 char *name = qs_get_attr_name(doc,attr);
1588 char *value = qs_get_attr_value(doc,attr);
1592 if (strcasecmp(name, "action") == 0) {
1593 /*--------------------------------------------------------------------*/
1595 /*--------------------------------------------------------------------*/
1596 attr_action = value;
1602 if (strcasecmp(name, "method") == 0) {
1603 /*--------------------------------------------------------------------*/
1605 /*--------------------------------------------------------------------*/
1606 attr_method = value;
1612 if (strcasecmp(name, "utn") == 0) {
1613 /*--------------------------------------------------------------------*/
1615 /*--------------------------------------------------------------------*/
1622 if (strcasecmp(name, "style") == 0) {
1631 if (IS_CSS_ON(chtml40->entryp)) {
1632 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1634 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
1635 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1636 css_property_t *cur;
1637 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
1638 if (STRCASEEQ('l','L',"left", cur->value)) {
1639 attr_align = apr_pstrdup(doc->pool, "left");
1641 else if (STRCASEEQ('c','C',"center",cur->value)) {
1642 attr_align = apr_pstrdup(doc->pool, "center");
1644 else if (STRCASEEQ('r','R',"right",cur->value)) {
1645 attr_align = apr_pstrdup(doc->pool, "right");
1648 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1649 attr_color = apr_pstrdup(doc->pool, cur->value);
1654 int post_flag = (attr_method && strcasecmp(attr_method, "post") == 0) ? 1 : 0;
1658 attr_action = chxj_encoding_parameter(r, attr_action, 0);
1659 attr_action = chxj_add_cookie_parameter(r, attr_action, chtml40->cookie);
1661 char *new_query_string = NULL;
1662 q = strchr(attr_action, '?');
1664 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);
1665 if (new_hidden_tag || new_query_string) {
1671 if (new_query_string) {
1673 W_V(new_query_string);
1686 if (new_hidden_tag) {
1687 W_V(new_hidden_tag);
1690 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
1691 memset(flg, 0, sizeof(*flg));
1693 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1694 W_L("<font color=\"");
1697 flg->with_font_flag = 1;
1700 W_L("<div align=\"");
1703 flg->with_div_flag = 1;
1705 node->userData = flg;
1707 return chtml40->out;
1712 * It is a handler who processes the FORM tag.
1714 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1715 * destination is specified.
1716 * @param node [i] The FORM tag node is specified.
1717 * @return The conversion result is returned.
1720 s_chtml40_end_form_tag(void *pdoc, Node *node)
1725 chtml40 = GET_CHTML40(pdoc);
1728 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
1729 if (flg && flg->with_div_flag) {
1732 if (flg && flg->with_font_flag) {
1736 if (IS_CSS_ON(chtml40->entryp)) {
1737 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1740 return chtml40->out;
1745 * It is a handler who processes the INPUT tag.
1747 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1748 * destination is specified.
1749 * @param node [i] The INPUT tag node is specified.
1750 * @return The conversion result is returned.
1753 s_chtml40_start_input_tag(void *pdoc, Node *node)
1759 char *attr_accesskey = NULL;
1760 char *attr_max_length = NULL;
1761 char *attr_type = NULL;
1762 char *attr_name = NULL;
1763 char *attr_value = NULL;
1764 char *attr_istyle = NULL;
1765 char *attr_size = NULL;
1766 char *attr_checked = NULL;
1767 char *attr_style = NULL;
1769 chtml40 = GET_CHTML40(pdoc);
1773 /*--------------------------------------------------------------------------*/
1774 /* Get Attributes */
1775 /*--------------------------------------------------------------------------*/
1776 for (attr = qs_get_attr(doc,node);
1778 attr = qs_get_next_attr(doc,attr)) {
1779 char *name = qs_get_attr_name(doc,attr);
1780 char *value = qs_get_attr_value(doc,attr);
1781 if (STRCASEEQ('t','T',"type",name) && value && *value) {
1782 char *tmp_type = qs_trim_string(doc->buf.pool, value);
1783 if (tmp_type && (STRCASEEQ('t','T',"text", tmp_type) ||
1784 STRCASEEQ('p','P',"password",tmp_type) ||
1785 STRCASEEQ('c','C',"checkbox",tmp_type) ||
1786 STRCASEEQ('r','R',"radio", tmp_type) ||
1787 STRCASEEQ('h','H',"hidden", tmp_type) ||
1788 STRCASEEQ('s','S',"submit", tmp_type) ||
1789 STRCASEEQ('r','R',"reset", tmp_type))) {
1790 attr_type = tmp_type;
1793 else if (STRCASEEQ('n','N',"name",name) && value && *value) {
1796 else if (STRCASEEQ('v','V',"value",name) && value && *value) {
1799 else if (STRCASEEQ('i','I',"istyle",name) && value && *value) {
1800 attr_istyle = value;
1802 else if (STRCASEEQ('m','M',"maxlength",name) && value && *value) {
1803 attr_max_length = value;
1805 else if (STRCASEEQ('c','C',"checked", name)) {
1806 attr_checked = value;
1808 else if (STRCASEEQ('a','A',"accesskey", name) && value && *value) {
1809 attr_accesskey = value;
1811 else if (STRCASEEQ('s','S',"size", name) && value && *value) {
1814 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
1819 if (IS_CSS_ON(chtml40->entryp)) {
1820 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
1822 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
1823 css_property_t *cur;
1824 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
1825 if (strcasestr(cur->value, "<ja:n>")) {
1828 else if (strcasestr(cur->value, "<ja:en>")) {
1831 else if (strcasestr(cur->value, "<ja:hk>")) {
1834 else if (strcasestr(cur->value, "<ja:h>")) {
1858 if (attr_type && (STRCASEEQ('s','S',"submit",attr_type) || STRCASEEQ('r','R',"reset",attr_type))) {
1859 apr_size_t value_len = strlen(attr_value);
1860 attr_value = chxj_conv_z2h(r, attr_value, &value_len, chtml40->entryp);
1864 W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
1867 if (attr_accesskey) {
1868 W_L(" accesskey=\"");
1869 W_V(attr_accesskey);
1873 if (*attr_istyle == '1' || *attr_istyle == '2' || *attr_istyle == '3' || *attr_istyle == '4') {
1879 /*--------------------------------------------------------------------------*/
1880 /* The figure is default for the password. */
1881 /*--------------------------------------------------------------------------*/
1882 if (attr_max_length) {
1883 if (chxj_chk_numeric(attr_max_length) != 0) {
1884 attr_max_length = apr_psprintf(doc->buf.pool, "0");
1886 if (attr_istyle && *attr_istyle == '1') {
1887 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length) * 2);
1891 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(attr_max_length));
1900 return chtml40->out;
1905 * It is a handler who processes the INPUT tag.
1907 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1908 * destination is specified.
1909 * @param node [i] The INPUT tag node is specified.
1910 * @return The conversion result is returned.
1913 s_chtml40_end_input_tag(void *pdoc, Node *UNUSED(child))
1915 chtml40_t *chtml40 = GET_CHTML40(pdoc);
1917 return chtml40->out;
1922 * It is a handler who processes the CENTER tag.
1924 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1925 * destination is specified.
1926 * @param node [i] The CENTER tag node is specified.
1927 * @return The conversion result is returned.
1930 s_chtml40_start_center_tag(void *pdoc, Node *node)
1935 char *attr_style = NULL;
1936 char *attr_color = NULL;
1938 chtml40 = GET_CHTML40(pdoc);
1941 for (attr = qs_get_attr(doc,node);
1943 attr = qs_get_next_attr(doc,attr)) {
1944 char *name = qs_get_attr_name(doc,attr);
1945 char *value = qs_get_attr_value(doc,attr);
1946 if (STRCASEEQ('s','S',"style",name) && value && *value) {
1950 if (IS_CSS_ON(chtml40->entryp)) {
1951 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
1953 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
1954 css_property_t *cur;
1955 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
1956 if (cur->value && *cur->value) {
1957 attr_color = apr_pstrdup(doc->pool, cur->value);
1964 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
1965 memset(flg, 0, sizeof(*flg));
1967 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
1968 W_L("<font color=\"");
1971 flg->with_font_flag = 1;
1973 node->userData = flg;
1975 return chtml40->out;
1980 * It is a handler who processes the CENTER tag.
1982 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1983 * destination is specified.
1984 * @param node [i] The CENTER tag node is specified.
1985 * @return The conversion result is returned.
1988 s_chtml40_end_center_tag(void *pdoc, Node *node)
1993 chtml40 = GET_CHTML40(pdoc);
1996 if (IS_CSS_ON(chtml40->entryp)) {
1997 chxj_css_pop_prop_list(chtml40->css_prop_stack);
1999 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
2000 if (flg && flg->with_font_flag) {
2005 return chtml40->out;
2010 * It is a handler who processes the HR tag.
2012 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2013 * destination is specified.
2014 * @param node [i] The HR tag node is specified.
2015 * @return The conversion result is returned.
2018 s_chtml40_start_hr_tag(void *pdoc, Node *node)
2024 char *attr_align = NULL;
2025 char *attr_size = NULL;
2026 char *attr_width = NULL;
2027 char *attr_noshade = NULL;
2028 char *attr_style = NULL;
2029 char *attr_color = NULL;
2031 chtml40 = GET_CHTML40(pdoc);
2035 for (attr = qs_get_attr(doc,node);
2037 attr = qs_get_next_attr(doc,attr)) {
2038 char *name = qs_get_attr_name (doc,attr);
2039 char *value = qs_get_attr_value(doc,attr);
2043 if (strcasecmp(name, "align") == 0) {
2044 /*--------------------------------------------------------------------*/
2046 /*--------------------------------------------------------------------*/
2047 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2055 if (strcasecmp(name, "size") == 0) {
2056 /*--------------------------------------------------------------------*/
2058 /*--------------------------------------------------------------------*/
2059 if (value && *value) {
2063 else if (strcasecmp(name, "style") == 0) {
2064 if (value && *value) {
2072 if (strcasecmp(name, "width") == 0) {
2073 /*--------------------------------------------------------------------*/
2075 /*--------------------------------------------------------------------*/
2076 if (value && *value) {
2084 if (strcasecmp(name, "noshade") == 0) {
2085 /*--------------------------------------------------------------------*/
2087 /*--------------------------------------------------------------------*/
2088 attr_noshade = apr_pstrdup(doc->pool, "noshade");
2094 if (strcasecmp(name, "color") == 0 && value && *value) {
2095 /*--------------------------------------------------------------------*/
2097 /*--------------------------------------------------------------------*/
2106 if (IS_CSS_ON(chtml40->entryp)) {
2107 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2109 css_property_t *border_style_prop = chxj_css_get_property_value(doc, style, "border-style");
2110 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2111 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2112 css_property_t *cur;
2113 for (cur = border_style_prop->next; cur != border_style_prop; cur = cur->next) {
2114 if (STRCASEEQ('s','S',"solid",cur->value)) {
2115 attr_noshade = "noshade";
2118 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2119 char *tmp = apr_pstrdup(doc->pool, cur->value);
2120 char *tmpp = strstr(tmp, "px");
2123 attr_size = apr_pstrdup(doc->pool, tmp);
2126 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2127 char *tmp = apr_pstrdup(doc->pool, cur->value);
2128 char *tmpp = strstr(tmp, "px");
2131 attr_width = apr_pstrdup(doc->pool, tmp);
2134 tmpp = strstr(tmp, "%");
2136 attr_width = apr_pstrdup(doc->pool, tmp);
2167 return chtml40->out;
2172 * It is a handler who processes the HR tag.
2174 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2175 * destination is specified.
2176 * @param node [i] The HR tag node is specified.
2177 * @return The conversion result is returned.
2180 s_chtml40_end_hr_tag(void *pdoc, Node *UNUSED(child))
2182 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2184 return chtml40->out;
2189 * It is a handler who processes the IMG tag.
2191 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2192 * destination is specified.
2193 * @param node [i] The IMG tag node is specified.
2194 * @return The conversion result is returned.
2197 s_chtml40_start_img_tag(void *pdoc, Node *node)
2203 char *attr_src = NULL;
2204 char *attr_align = NULL;
2205 char *attr_style = NULL;
2206 char *attr_alt = NULL;
2207 char *attr_width = NULL;
2208 char *attr_height = NULL;
2209 char *attr_hspace = NULL;
2210 char *attr_vspace = NULL;
2211 #ifndef IMG_NOT_CONVERT_FILENAME
2215 chtml40 = GET_CHTML40(pdoc);
2216 #ifndef IMG_NOT_CONVERT_FILENAME
2217 spec = chtml40->spec;
2222 /*--------------------------------------------------------------------------*/
2223 /* Get Attributes */
2224 /*--------------------------------------------------------------------------*/
2225 for (attr = qs_get_attr(doc,node);
2227 attr = qs_get_next_attr(doc,attr)) {
2228 char *name = qs_get_attr_name (doc,attr);
2229 char *value = qs_get_attr_value(doc,attr);
2233 if (strcasecmp(name, "src") == 0) {
2234 /*--------------------------------------------------------------------*/
2236 /*--------------------------------------------------------------------*/
2237 #ifdef IMG_NOT_CONVERT_FILENAME
2238 value = chxj_encoding_parameter(r, value, 0);
2239 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
2240 value = chxj_add_cookie_no_update_parameter(r, value);
2241 value = chxj_img_rewrite_parameter(r,chtml40->conf,value);
2244 value = chxj_img_conv(r,spec,value);
2245 value = chxj_encoding_parameter(r, value, 0);
2246 value = chxj_add_cookie_parameter(r, value, chtml40->cookie);
2247 value = chxj_add_cookie_no_update_parameter(r, value);
2248 value = chxj_img_rewrite_parameter(r,chtml40->conf,value);
2252 else if (strcasecmp(name,"style") == 0 && value && *value) {
2259 if (strcasecmp(name, "align" ) == 0) {
2260 /*--------------------------------------------------------------------*/
2262 /*--------------------------------------------------------------------*/
2263 /*--------------------------------------------------------------------*/
2265 /*--------------------------------------------------------------------*/
2267 if (STRCASEEQ('t','T',"top", value) ||
2268 STRCASEEQ('m','M',"middle",value) ||
2269 STRCASEEQ('b','B',"bottom",value) ||
2270 STRCASEEQ('l','L',"left", value) ||
2271 STRCASEEQ('r','R',"right", value)) {
2274 else if (STRCASEEQ('c','C',"center", value)) {
2275 attr_align = apr_pstrdup(doc->pool, "middle");
2279 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2280 /*--------------------------------------------------------------------*/
2282 /*--------------------------------------------------------------------*/
2289 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2290 /*--------------------------------------------------------------------*/
2292 /*--------------------------------------------------------------------*/
2299 if (strcasecmp(name, "height") == 0 && value && *value) {
2300 /*--------------------------------------------------------------------*/
2302 /*--------------------------------------------------------------------*/
2303 attr_height = value;
2306 if (strcasecmp(name, "hspace") == 0 && value && *value) {
2307 /*--------------------------------------------------------------------*/
2309 /*--------------------------------------------------------------------*/
2310 attr_hspace = value;
2316 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2317 /*--------------------------------------------------------------------*/
2319 /*--------------------------------------------------------------------*/
2320 attr_vspace = value;
2329 if (IS_CSS_ON(chtml40->entryp)) {
2330 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2332 css_property_t *height_prop = chxj_css_get_property_value(doc, style, "height");
2333 css_property_t *width_prop = chxj_css_get_property_value(doc, style, "width");
2334 css_property_t *valign_prop = chxj_css_get_property_value(doc, style, "vertical-align");
2335 css_property_t *cur;
2336 for (cur = height_prop->next; cur != height_prop; cur = cur->next) {
2337 attr_height = apr_pstrdup(doc->pool, cur->value);
2339 for (cur = width_prop->next; cur != width_prop; cur = cur->next) {
2340 attr_width = apr_pstrdup(doc->pool, cur->value);
2342 for (cur = valign_prop->next; cur != valign_prop; cur = cur->next) {
2343 attr_align = apr_pstrdup(doc->pool, cur->value);
2385 return chtml40->out;
2390 * It is a handler who processes the IMG tag.
2392 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2393 * destination is specified.
2394 * @param node [i] The IMG tag node is specified.
2395 * @return The conversion result is returned.
2398 s_chtml40_end_img_tag(void *pdoc, Node *UNUSED(child))
2400 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2402 return chtml40->out;
2407 * It is a handler who processes the SELECT tag.
2409 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2410 * destination is specified.
2411 * @param node [i] The SELECT tag node is specified.
2412 * @return The conversion result is returned.
2415 s_chtml40_start_select_tag(void *pdoc, Node *node)
2417 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2418 Doc *doc = chtml40->doc;
2421 char *multiple = NULL;
2423 char *attr_style = NULL;
2426 for (attr = qs_get_attr(doc,node);
2428 attr = qs_get_next_attr(doc,attr)) {
2429 char *nm = qs_get_attr_name(doc,attr);
2430 char *val = qs_get_attr_value(doc,attr);
2431 if (STRCASEEQ('s','S',"size", nm)) {
2432 /*----------------------------------------------------------------------*/
2433 /* CHTML 1.0 version 2.0 */
2434 /*----------------------------------------------------------------------*/
2435 size = apr_pstrdup(doc->buf.pool, val);
2437 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2438 /*----------------------------------------------------------------------*/
2439 /* CHTML 1.0 version 2.0 */
2440 /*----------------------------------------------------------------------*/
2441 attr_style = apr_pstrdup(doc->buf.pool, val);
2443 else if (STRCASEEQ('n','N',"name", nm)) {
2444 /*----------------------------------------------------------------------*/
2445 /* CHTML 1.0 version 2.0 */
2446 /*----------------------------------------------------------------------*/
2447 name = apr_pstrdup(doc->buf.pool, val);
2449 else if (STRCASEEQ('m','M',"multiple", nm)) {
2450 /*----------------------------------------------------------------------*/
2451 /* CHTML 1.0 version 2.0 */
2452 /*----------------------------------------------------------------------*/
2453 multiple = apr_pstrdup(doc->buf.pool, val);
2456 if (size && *size) {
2461 if (name && *name) {
2470 if (IS_CSS_ON(chtml40->entryp)) {
2471 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2473 return chtml40->out;
2478 * It is a handler who processes the SELECT tag.
2480 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2481 * destination is specified.
2482 * @param node [i] The SELECT tag node is specified.
2483 * @return The conversion result is returned.
2486 s_chtml40_end_select_tag(void *pdoc, Node *UNUSED(child))
2488 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2489 Doc *doc = chtml40->doc;
2492 if (IS_CSS_ON(chtml40->entryp)) {
2493 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2495 return chtml40->out;
2500 * It is a handler who processes the OPTION tag.
2502 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2503 * destination is specified.
2504 * @param node [i] The OPTION tag node is specified.
2505 * @return The conversion result is returned.
2508 s_chtml40_start_option_tag(void *pdoc, Node *node)
2516 char *attr_style = NULL;
2518 chtml40 = GET_CHTML40(pdoc);
2525 for (attr = qs_get_attr(doc,node);
2527 attr = qs_get_next_attr(doc,attr)) {
2528 char *nm = qs_get_attr_name(doc,attr);
2529 char *val = qs_get_attr_value(doc,attr);
2530 if (STRCASEEQ('s','S',"selected", nm)) {
2531 /*----------------------------------------------------------------------*/
2532 /* CHTML 1.0 version 2.0 */
2533 /*----------------------------------------------------------------------*/
2534 selected = apr_pstrdup(doc->buf.pool, val);
2536 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2537 /*----------------------------------------------------------------------*/
2538 /* CHTML 1.0 version 2.0 */
2539 /*----------------------------------------------------------------------*/
2540 attr_style = apr_pstrdup(doc->buf.pool, val);
2542 else if (STRCASEEQ('v','V',"value", nm)) {
2543 /*----------------------------------------------------------------------*/
2544 /* CHTML 1.0 version 2.0 */
2545 /*----------------------------------------------------------------------*/
2546 value = apr_pstrdup(doc->buf.pool, val);
2559 if (IS_CSS_ON(chtml40->entryp)) {
2560 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2563 return chtml40->out;
2568 * It is a handler who processes the OPTION tag.
2570 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2571 * destination is specified.
2572 * @param node [i] The OPTION tag node is specified.
2573 * @return The conversion result is returned.
2576 s_chtml40_end_option_tag(void *pdoc, Node *UNUSED(child))
2578 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2581 if (IS_CSS_ON(chtml40->entryp)) {
2582 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2585 return chtml40->out;
2590 * It is a handler who processes the DIV tag.
2592 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2593 * destination is specified.
2594 * @param node [i] The DIV tag node is specified.
2595 * @return The conversion result is returned.
2598 s_chtml40_start_div_tag(void *pdoc, Node *node)
2604 char *attr_style = NULL;
2605 char *attr_align = NULL;
2606 char *attr_display = NULL;
2607 char *attr_decoration = NULL;
2608 char *attr_wap_marquee_style = NULL;
2609 char *attr_wap_marquee_dir = NULL;
2610 char *attr_wap_marquee_loop = NULL;
2611 char *attr_color = NULL;
2612 char *attr_bgcolor = NULL;
2614 chtml40 = GET_CHTML40(pdoc);
2618 for (attr = qs_get_attr(doc,node);
2620 attr = qs_get_next_attr(doc,attr)) {
2621 char *nm = qs_get_attr_name(doc,attr);
2622 char *val = qs_get_attr_value(doc,attr);
2623 if (STRCASEEQ('a','A', "align", nm)) {
2624 /*----------------------------------------------------------------------*/
2625 /* CHTML 1.0 (W3C version 3.2) */
2626 /*----------------------------------------------------------------------*/
2627 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2628 attr_align = apr_pstrdup(doc->buf.pool, val);
2631 else if (STRCASEEQ('s','S',"style",nm) && val && *val) {
2632 attr_style = apr_pstrdup(doc->buf.pool, val);
2636 if (IS_CSS_ON(chtml40->entryp)) {
2637 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
2639 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
2640 css_property_t *text_decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
2641 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
2642 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2643 css_property_t *background_color_prop = chxj_css_get_property_value(doc, style, "background-color");
2644 css_property_t *background_prop = chxj_css_get_property_value(doc, style, "background");
2646 css_property_t *cur;
2647 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
2648 if (strcasecmp("-wap-marquee", cur->value) == 0) {
2649 attr_display = apr_pstrdup(doc->pool, cur->value);
2652 for (cur = text_decoration_prop->next; cur != text_decoration_prop; cur = cur->next) {
2653 if (STRCASEEQ('b','B',"blink", cur->value)) {
2654 attr_decoration = apr_pstrdup(doc->pool, cur->value);
2657 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
2658 attr_color = apr_pstrdup(doc->pool, cur->value);
2659 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
2661 for (cur = background_color_prop->next; cur != background_color_prop; cur = cur->next) {
2662 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
2663 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
2665 for (cur = background_prop->next; cur != background_prop; cur = cur->next) {
2666 char *ss = strchr(cur->value, '#');
2668 ss = strstr(cur->value, "rgb");
2671 attr_bgcolor = apr_pstrdup(doc->pool, cur->value);
2672 attr_bgcolor = chxj_css_rgb_func_to_value(doc->pool, attr_bgcolor);
2675 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2676 attr_align = apr_pstrdup(doc->pool, cur->value);
2679 css_property_t *wap_marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
2680 css_property_t *wap_marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
2681 css_property_t *wap_marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
2682 for (cur = wap_marquee_style_prop->next; cur != wap_marquee_style_prop; cur = cur->next) {
2683 if (STRCASEEQ('s','S',"scroll", cur->value) || STRCASEEQ('s','S',"slide",cur->value) || STRCASEEQ('a','A',"alternate",cur->value)) {
2684 attr_wap_marquee_style = apr_pstrdup(doc->pool, cur->value);
2687 for (cur = wap_marquee_dir_prop->next; cur != wap_marquee_dir_prop; cur = cur->next) {
2688 if (STRCASEEQ('l','L',"ltr",cur->value)) {
2689 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "right");
2691 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
2692 attr_wap_marquee_dir = apr_pstrdup(doc->pool, "left");
2695 for (cur = wap_marquee_loop_prop->next; cur != wap_marquee_loop_prop; cur = cur->next) {
2696 if (STRCASEEQ('i','I',"infinite",cur->value)) {
2697 attr_wap_marquee_loop = apr_pstrdup(doc->pool, "16");
2700 attr_wap_marquee_loop = apr_pstrdup(doc->pool, cur->value);
2706 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
2707 memset(flg, 0, sizeof(*flg));
2714 flg->with_div_flag = 1;
2718 flg->with_div_flag = 1;
2721 if (attr_bgcolor && (STRCASEEQ('w','W',"white",attr_color) || STRCASEEQ('#','#',"#ffffff",attr_color))) {
2725 W_L("<font color=\"");
2728 flg->with_font_flag = 1;
2731 if (attr_decoration) {
2733 flg->with_blink_flag = 1;
2737 if (attr_wap_marquee_style) {
2738 W_L(" behavior=\"");
2739 W_V(attr_wap_marquee_style);
2742 if (attr_wap_marquee_dir) {
2743 W_L(" direction=\"");
2744 W_V(attr_wap_marquee_dir);
2747 if (attr_wap_marquee_loop) {
2749 W_V(attr_wap_marquee_loop);
2753 flg->with_marquee_flag = 1;
2755 node->userData = flg;
2757 return chtml40->out;
2762 * It is a handler who processes the DIV tag.
2764 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2765 * destination is specified.
2766 * @param node [i] The DIV tag node is specified.
2767 * @return The conversion result is returned.
2770 s_chtml40_end_div_tag(void *pdoc, Node *node)
2772 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2773 Doc *doc = chtml40->doc;
2775 chtml40_flags_t *flg = node->userData;
2776 if (flg && flg->with_marquee_flag) {
2779 if (flg && flg->with_blink_flag) {
2782 if (flg && flg->with_font_flag) {
2785 if (flg && flg->with_div_flag) {
2788 if (IS_CSS_ON(chtml40->entryp)) {
2789 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2791 node->userData = NULL;
2793 return chtml40->out;
2798 * It is a handler who processes the UL tag.
2800 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2801 * destination is specified.
2802 * @param node [i] The UL tag node is specified.
2803 * @return The conversion result is returned.
2806 s_chtml40_start_ul_tag(void *pdoc, Node *node)
2808 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2809 Doc *doc = chtml40->doc;
2811 char *attr_type = NULL;
2812 char *attr_style = NULL;
2813 /*--------------------------------------------------------------------------*/
2814 /* Get Attributes */
2815 /*--------------------------------------------------------------------------*/
2816 for (attr = qs_get_attr(doc,node);
2818 attr = qs_get_next_attr(doc,attr)) {
2819 char *name = qs_get_attr_name(doc,attr);
2820 char *value = qs_get_attr_value(doc,attr);
2821 if (STRCASEEQ('t','T',"type",name)) {
2822 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
2826 else if (value && *value && STRCASEEQ('s','S',"style", name)) {
2830 if (IS_CSS_ON(chtml40->entryp)) {
2831 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2833 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
2834 css_property_t *cur;
2835 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
2836 if (STRCASEEQ('d','D',"disc",cur->value)) {
2837 attr_type = apr_pstrdup(doc->pool, "disc");
2839 else if (STRCASEEQ('c','C',"circle",cur->value)) {
2840 attr_type = apr_pstrdup(doc->pool, "circle");
2842 else if (STRCASEEQ('s','S',"square",cur->value)) {
2843 attr_type = apr_pstrdup(doc->pool, "square");
2856 return chtml40->out;
2861 * It is a handler who processes the UL tag.
2863 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2864 * destination is specified.
2865 * @param node [i] The UL tag node is specified.
2866 * @return The conversion result is returned.
2869 s_chtml40_end_ul_tag(void *pdoc, Node *UNUSED(child))
2871 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2872 Doc *doc = chtml40->doc;
2875 if (IS_CSS_ON(chtml40->entryp)) {
2876 chxj_css_pop_prop_list(chtml40->css_prop_stack);
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_start_pre_tag(void *pdoc, Node *node)
2894 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2895 Doc *doc = chtml40->doc;
2897 char *attr_style = NULL;
2899 for (attr = qs_get_attr(doc,node);
2901 attr = qs_get_next_attr(doc,attr)) {
2902 char *nm = qs_get_attr_name(doc,attr);
2903 char *val = qs_get_attr_value(doc,attr);
2904 if (val && STRCASEEQ('s','S',"style", nm)) {
2909 if (IS_CSS_ON(chtml40->entryp)) {
2910 s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2913 chtml40->pre_flag++;
2916 return chtml40->out;
2921 * It is a handler who processes the PRE tag.
2923 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2924 * destination is specified.
2925 * @param node [i] The PRE tag node is specified.
2926 * @return The conversion result is returned.
2929 s_chtml40_end_pre_tag(void *pdoc, Node *UNUSED(child))
2931 chtml40_t *chtml40 = GET_CHTML40(pdoc);
2932 Doc *doc = chtml40->doc;
2935 chtml40->pre_flag--;
2936 if (IS_CSS_ON(chtml40->entryp)) {
2937 chxj_css_pop_prop_list(chtml40->css_prop_stack);
2940 return chtml40->out;
2945 * It is a handler who processes the P tag.
2947 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2948 * destination is specified.
2949 * @param node [i] The P tag node is specified.
2950 * @return The conversion result is returned.
2953 s_chtml40_start_p_tag(void *pdoc, Node *node)
2959 char *attr_align = NULL;
2960 char *attr_style = NULL;
2961 char *attr_color = NULL;
2962 char *attr_blink = NULL;
2964 chtml40 = GET_CHTML40(pdoc);
2968 for (attr = qs_get_attr(doc,node);
2970 attr = qs_get_next_attr(doc,attr)) {
2971 char *nm = qs_get_attr_name(doc,attr);
2972 char *val = qs_get_attr_value(doc,attr);
2973 if (STRCASEEQ('a','A',"align", nm)) {
2974 /*----------------------------------------------------------------------*/
2975 /* CHTML 1.0 (W3C version 3.2) */
2976 /*----------------------------------------------------------------------*/
2977 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2978 attr_align = apr_pstrdup(doc->buf.pool, val);
2982 else if (STRCASEEQ('s','S',"style", nm) && val && *val) {
2983 attr_style = apr_pstrdup(doc->buf.pool, val);
2986 if (IS_CSS_ON(chtml40->entryp)) {
2987 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
2989 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
2990 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
2991 css_property_t *text_deco_prop = chxj_css_get_property_value(doc, style, "text-decoration");
2992 css_property_t *cur;
2993 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
2994 if (STRCASEEQ('l','L',"left",cur->value)) {
2995 attr_align = apr_pstrdup(doc->pool, "left");
2997 else if (STRCASEEQ('c','C',"center",cur->value)) {
2998 attr_align = apr_pstrdup(doc->pool, "center");
3000 else if (STRCASEEQ('r','R',"right",cur->value)) {
3001 attr_align = apr_pstrdup(doc->pool, "right");
3004 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
3005 if (cur->value && *cur->value) {
3006 attr_color = apr_pstrdup(doc->pool, cur->value);
3009 for (cur = text_deco_prop->next; cur != text_deco_prop; cur = cur->next) {
3010 if (cur->value && *cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
3011 attr_blink = apr_pstrdup(doc->pool, cur->value);
3024 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
3025 memset(flg, 0, sizeof(*flg));
3027 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
3028 W_L("<font color=\"");
3031 flg->with_font_flag = 1;
3035 flg->with_blink_flag = 1;
3037 node->userData = (void *)flg;
3039 return chtml40->out;
3044 * It is a handler who processes the P tag.
3046 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3047 * destination is specified.
3048 * @param node [i] The P tag node is specified.
3049 * @return The conversion result is returned.
3052 s_chtml40_end_p_tag(void *pdoc, Node *node)
3057 chtml40 = GET_CHTML40(pdoc);
3060 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
3061 if (flg->with_font_flag) {
3064 if (flg->with_blink_flag) {
3068 if (IS_CSS_ON(chtml40->entryp)) {
3069 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3072 return chtml40->out;
3077 * It is a handler who processes the OL tag.
3079 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3080 * destination is specified.
3081 * @param node [i] The OL tag node is specified.
3082 * @return The conversion result is returned.
3085 s_chtml40_start_ol_tag(void *pdoc, Node *node)
3091 char *attr_style = NULL;
3092 char *attr_start = NULL;
3093 char *attr_type = NULL;
3095 chtml40 = GET_CHTML40(pdoc);
3099 /*--------------------------------------------------------------------------*/
3100 /* Get Attributes */
3101 /*--------------------------------------------------------------------------*/
3102 for (attr = qs_get_attr(doc,node);
3104 attr = qs_get_next_attr(doc,attr)) {
3105 char *name = qs_get_attr_name(doc,attr);
3106 char *value = qs_get_attr_value(doc,attr);
3107 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
3110 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
3113 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3117 if (IS_CSS_ON(chtml40->entryp)) {
3118 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3120 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3121 css_property_t *cur;
3122 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3123 if (STRCASEEQ('d','D',"decimal", cur->value)) {
3124 attr_type = apr_pstrdup(doc->pool, "1");
3126 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3127 attr_type = apr_pstrdup(doc->pool, "A");
3129 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3130 attr_type = apr_pstrdup(doc->pool, "a");
3148 return chtml40->out;
3153 * It is a handler who processes the OL tag.
3155 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3156 * destination is specified.
3157 * @param node [i] The OL tag node is specified.
3158 * @return The conversion result is returned.
3161 s_chtml40_end_ol_tag(void *pdoc, Node *UNUSED(node))
3163 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3164 Doc *doc = chtml40->doc;
3167 if (IS_CSS_ON(chtml40->entryp)) {
3168 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3171 return chtml40->out;
3176 * It is a handler who processes the LI tag.
3178 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3179 * destination is specified.
3180 * @param node [i] The LI tag node is specified.
3181 * @return The conversion result is returned.
3184 s_chtml40_start_li_tag(void *pdoc, Node *node)
3186 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3187 Doc *doc = chtml40->doc;
3189 char *attr_type = NULL;
3190 char *attr_value = NULL;
3191 char *attr_style = NULL;
3193 /*--------------------------------------------------------------------------*/
3194 /* Get Attributes */
3195 /*--------------------------------------------------------------------------*/
3196 for (attr = qs_get_attr(doc,node);
3198 attr = qs_get_next_attr(doc,attr)) {
3199 char *name = qs_get_attr_name(doc,attr);
3200 char *value = qs_get_attr_value(doc,attr);
3201 if (STRCASEEQ('t','T',"type",name)) {
3202 if (value && (*value == '1' || *value == 'a' || *value == 'A' || STRCASEEQ('d','D',"disc",value) || STRCASEEQ('s','S',"square",value) || STRCASEEQ('c','C',"circle",value))) {
3206 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
3209 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3213 if (IS_CSS_ON(chtml40->entryp)) {
3214 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3216 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
3217 css_property_t *cur;
3218 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3219 if (STRCASEEQ('d','D',"decimal", cur->value)) {
3220 attr_type = apr_pstrdup(doc->pool, "1");
3222 else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
3223 attr_type = apr_pstrdup(doc->pool, "A");
3225 else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
3226 attr_type = apr_pstrdup(doc->pool, "a");
3228 else if (STRCASEEQ('d','D',"disc", cur->value)) {
3229 attr_type = apr_pstrdup(doc->pool, "disc");
3231 else if (STRCASEEQ('s','S',"square", cur->value)) {
3232 attr_type = apr_pstrdup(doc->pool, "square");
3234 else if (STRCASEEQ('c','C',"circle", cur->value)) {
3235 attr_type = apr_pstrdup(doc->pool, "circle");
3253 return chtml40->out;
3258 * It is a handler who processes the LI tag.
3260 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3261 * destination is specified.
3262 * @param node [i] The LI tag node is specified.
3263 * @return The conversion result is returned.
3266 s_chtml40_end_li_tag(void *pdoc, Node *UNUSED(child))
3268 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3270 if (IS_CSS_ON(chtml40->entryp)) {
3271 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3273 return chtml40->out;
3278 * It is a handler who processes the H1 tag.
3280 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3281 * destination is specified.
3282 * @param node [i] The H1 tag node is specified.
3283 * @return The conversion result is returned.
3286 s_chtml40_start_h1_tag(void *pdoc, Node *node)
3292 char *attr_style = NULL;
3293 char *attr_align = NULL;
3295 chtml40 = GET_CHTML40(pdoc);
3299 for (attr = qs_get_attr(doc,node);
3301 attr = qs_get_next_attr(doc,attr)) {
3302 char *name = qs_get_attr_name(doc,attr);
3303 char *value = qs_get_attr_value(doc,attr);
3304 if (STRCASEEQ('a','A',"align", name)) {
3305 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3309 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3313 if (IS_CSS_ON(chtml40->entryp)) {
3314 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3316 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3317 css_property_t *cur;
3318 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3319 if (STRCASEEQ('l','L',"left", cur->value)) {
3320 attr_align = apr_pstrdup(doc->pool, "left");
3322 else if (STRCASEEQ('c','C',"center",cur->value)) {
3323 attr_align = apr_pstrdup(doc->pool, "center");
3325 else if (STRCASEEQ('r','R',"right",cur->value)) {
3326 attr_align = apr_pstrdup(doc->pool, "right");
3339 return chtml40->out;
3344 * It is a handler who processes the H1 tag.
3346 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3347 * destination is specified.
3348 * @param node [i] The H1 tag node is specified.
3349 * @return The conversion result is returned.
3352 s_chtml40_end_h1_tag(void *pdoc, Node *UNUSED(child))
3357 chtml40 = GET_CHTML40(pdoc);
3361 if (IS_CSS_ON(chtml40->entryp)) {
3362 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3365 return chtml40->out;
3370 * It is a handler who processes the H2 tag.
3372 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3373 * destination is specified.
3374 * @param node [i] The H2 tag node is specified.
3375 * @return The conversion result is returned.
3378 s_chtml40_start_h2_tag(void *pdoc, Node *node)
3384 char *attr_style = NULL;
3385 char *attr_align = NULL;
3387 chtml40 = GET_CHTML40(pdoc);
3391 for (attr = qs_get_attr(doc,node);
3393 attr = qs_get_next_attr(doc,attr)) {
3394 char *name = qs_get_attr_name(doc,attr);
3395 char *value = qs_get_attr_value(doc,attr);
3396 if (STRCASEEQ('a','A',"align", name)) {
3397 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3401 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3405 if (IS_CSS_ON(chtml40->entryp)) {
3406 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3408 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3409 css_property_t *cur;
3410 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3411 if (STRCASEEQ('l','L',"left", cur->value)) {
3412 attr_align = apr_pstrdup(doc->pool, "left");
3414 else if (STRCASEEQ('c','C',"center",cur->value)) {
3415 attr_align = apr_pstrdup(doc->pool, "center");
3417 else if (STRCASEEQ('r','R',"right",cur->value)) {
3418 attr_align = apr_pstrdup(doc->pool, "right");
3431 return chtml40->out;
3436 * It is a handler who processes the H2 tag.
3438 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3439 * destination is specified.
3440 * @param node [i] The H2 tag node is specified.
3441 * @return The conversion result is returned.
3444 s_chtml40_end_h2_tag(void *pdoc, Node *UNUSED(child))
3446 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3447 Doc *doc = chtml40->doc;
3450 if (IS_CSS_ON(chtml40->entryp)) {
3451 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3454 return chtml40->out;
3459 * It is a handler who processes the H3 tag.
3461 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3462 * destination is specified.
3463 * @param node [i] The H3 tag node is specified.
3464 * @return The conversion result is returned.
3467 s_chtml40_start_h3_tag(void *pdoc, Node *node)
3473 char *attr_style = NULL;
3474 char *attr_align = NULL;
3476 chtml40 = GET_CHTML40(pdoc);
3480 for (attr = qs_get_attr(doc,node);
3482 attr = qs_get_next_attr(doc,attr)) {
3483 char *name = qs_get_attr_name(doc,attr);
3484 char *value = qs_get_attr_value(doc,attr);
3485 if (STRCASEEQ('a','A',"align", name)) {
3486 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3490 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3494 if (IS_CSS_ON(chtml40->entryp)) {
3495 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3497 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3498 css_property_t *cur;
3499 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3500 if (STRCASEEQ('l','L',"left", cur->value)) {
3501 attr_align = apr_pstrdup(doc->pool, "left");
3503 else if (STRCASEEQ('c','C',"center",cur->value)) {
3504 attr_align = apr_pstrdup(doc->pool, "center");
3506 else if (STRCASEEQ('r','R',"right",cur->value)) {
3507 attr_align = apr_pstrdup(doc->pool, "right");
3520 return chtml40->out;
3525 * It is a handler who processes the H3 tag.
3527 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3528 * destination is specified.
3529 * @param node [i] The H3 tag node is specified.
3530 * @return The conversion result is returned.
3533 s_chtml40_end_h3_tag(void *pdoc, Node *UNUSED(child))
3535 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3536 Doc *doc = chtml40->doc;
3539 if (IS_CSS_ON(chtml40->entryp)) {
3540 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3543 return chtml40->out;
3548 * It is a handler who processes the H4 tag.
3550 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3551 * destination is specified.
3552 * @param node [i] The H4 tag node is specified.
3553 * @return The conversion result is returned.
3556 s_chtml40_start_h4_tag(void *pdoc, Node *node)
3562 char *attr_style = NULL;
3563 char *attr_align = NULL;
3565 chtml40 = GET_CHTML40(pdoc);
3569 for (attr = qs_get_attr(doc,node);
3571 attr = qs_get_next_attr(doc,attr)) {
3572 char *name = qs_get_attr_name(doc,attr);
3573 char *value = qs_get_attr_value(doc,attr);
3574 if (STRCASEEQ('a','A',"align", name)) {
3575 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3579 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3583 if (IS_CSS_ON(chtml40->entryp)) {
3584 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3586 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3587 css_property_t *cur;
3588 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3589 if (STRCASEEQ('l','L',"left", cur->value)) {
3590 attr_align = apr_pstrdup(doc->pool, "left");
3592 else if (STRCASEEQ('c','C',"center",cur->value)) {
3593 attr_align = apr_pstrdup(doc->pool, "center");
3595 else if (STRCASEEQ('r','R',"right",cur->value)) {
3596 attr_align = apr_pstrdup(doc->pool, "right");
3609 return chtml40->out;
3614 * It is a handler who processes the H4 tag.
3616 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3617 * destination is specified.
3618 * @param node [i] The H4 tag node is specified.
3619 * @return The conversion result is returned.
3622 s_chtml40_end_h4_tag(void *pdoc, Node *UNUSED(child))
3624 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3625 Doc *doc = chtml40->doc;
3628 if (IS_CSS_ON(chtml40->entryp)) {
3629 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3632 return chtml40->out;
3637 * It is a handler who processes the H5 tag.
3639 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3640 * destination is specified.
3641 * @param node [i] The H5 tag node is specified.
3642 * @return The conversion result is returned.
3645 s_chtml40_start_h5_tag(void *pdoc, Node *node)
3651 char *attr_style = NULL;
3652 char *attr_align = NULL;
3654 chtml40 = GET_CHTML40(pdoc);
3658 for (attr = qs_get_attr(doc,node);
3660 attr = qs_get_next_attr(doc,attr)) {
3661 char *name = qs_get_attr_name(doc,attr);
3662 char *value = qs_get_attr_value(doc,attr);
3663 if (STRCASEEQ('a','A',"align", name)) {
3664 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3668 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3672 if (IS_CSS_ON(chtml40->entryp)) {
3673 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3675 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3676 css_property_t *cur;
3677 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3678 if (STRCASEEQ('l','L',"left", cur->value)) {
3679 attr_align = apr_pstrdup(doc->pool, "left");
3681 else if (STRCASEEQ('c','C',"center",cur->value)) {
3682 attr_align = apr_pstrdup(doc->pool, "center");
3684 else if (STRCASEEQ('r','R',"right",cur->value)) {
3685 attr_align = apr_pstrdup(doc->pool, "right");
3698 return chtml40->out;
3703 * It is a handler who processes the H5 tag.
3705 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3706 * destination is specified.
3707 * @param node [i] The H5 tag node is specified.
3708 * @return The conversion result is returned.
3711 s_chtml40_end_h5_tag(void *pdoc, Node *UNUSED(child))
3713 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3714 Doc *doc = chtml40->doc;
3717 if (IS_CSS_ON(chtml40->entryp)) {
3718 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3721 return chtml40->out;
3726 * It is a handler who processes the H6 tag.
3728 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3729 * destination is specified.
3730 * @param node [i] The H6 tag node is specified.
3731 * @return The conversion result is returned.
3734 s_chtml40_start_h6_tag(void *pdoc, Node *node)
3740 char *attr_style = NULL;
3741 char *attr_align = NULL;
3743 chtml40 = GET_CHTML40(pdoc);
3747 for (attr = qs_get_attr(doc,node);
3749 attr = qs_get_next_attr(doc,attr)) {
3750 char *name = qs_get_attr_name(doc,attr);
3751 char *value = qs_get_attr_value(doc,attr);
3752 if (STRCASEEQ('a','A',"align", name)) {
3753 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
3757 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
3761 if (IS_CSS_ON(chtml40->entryp)) {
3762 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
3764 css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "text-align");
3765 css_property_t *cur;
3766 for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
3767 if (STRCASEEQ('l','L',"left", cur->value)) {
3768 attr_align = apr_pstrdup(doc->pool, "left");
3770 else if (STRCASEEQ('c','C',"center",cur->value)) {
3771 attr_align = apr_pstrdup(doc->pool, "center");
3773 else if (STRCASEEQ('r','R',"right",cur->value)) {
3774 attr_align = apr_pstrdup(doc->pool, "right");
3787 return chtml40->out;
3792 * It is a handler who processes the H6 tag.
3794 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3795 * destination is specified.
3796 * @param node [i] The H6 tag node is specified.
3797 * @return The conversion result is returned.
3800 s_chtml40_end_h6_tag(void *pdoc, Node *UNUSED(child))
3802 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3803 Doc *doc = chtml40->doc;
3806 if (IS_CSS_ON(chtml40->entryp)) {
3807 chxj_css_pop_prop_list(chtml40->css_prop_stack);
3810 return chtml40->out;
3815 * It is a handler who processes the TEXTARE tag.
3817 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3818 * destination is specified.
3819 * @param node [i] The TEXTAREA tag node is specified.
3820 * @return The conversion result is returned.
3823 s_chtml40_start_textarea_tag(void *pdoc, Node *node)
3829 char *attr_accesskey = NULL;
3830 char *attr_name = NULL;
3831 char *attr_rows = NULL;
3832 char *attr_cols = NULL;
3833 char *attr_istyle = NULL;
3834 char *attr_style = NULL;
3836 chtml40 = GET_CHTML40(pdoc);
3840 chtml40->textarea_flag++;
3842 for (attr = qs_get_attr(doc,node);
3844 attr = qs_get_next_attr(doc,attr)) {
3845 char *name = qs_get_attr_name(doc,attr);
3846 char *value = qs_get_attr_value(doc,attr);
3847 if (STRCASEEQ('a','A',"accesskey",name) && value && *value != 0) {
3848 attr_accesskey = value;
3850 else if (STRCASEEQ('i','I',"istyle", name) && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3851 attr_istyle = value;
3853 else if (STRCASEEQ('n','N',"name", name) && value && *value) {
3856 else if (STRCASEEQ('r','R',"rows", name) && value && *value) {
3859 else if (STRCASEEQ('c','C',"cols", name) && value && *value) {
3862 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
3866 if (IS_CSS_ON(chtml40->entryp)) {
3867 css_prop_list_t *style = s_chtml40_nopush_and_get_now_style(pdoc, node, attr_style);
3869 css_property_t *wap_input_format = chxj_css_get_property_value(doc, style, "-wap-input-format");
3870 css_property_t *cur;
3871 for (cur = wap_input_format->next; cur != wap_input_format; cur = cur->next) {
3872 if (strcasestr(cur->value, "<ja:n>")) {
3875 else if (strcasestr(cur->value, "<ja:en>")) {
3878 else if (strcasestr(cur->value, "<ja:hk>")) {
3881 else if (strcasestr(cur->value, "<ja:h>")) {
3888 if (attr_accesskey) {
3889 W_L(" accesskey=\"");
3890 W_V(attr_accesskey);
3914 return chtml40->out;
3919 * It is a handler who processes the TEXTAREA tag.
3921 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3922 * destination is specified.
3923 * @param node [i] The TEXTAREA tag node is specified.
3924 * @return The conversion result is returned.
3927 s_chtml40_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3929 chtml40_t *chtml40 = GET_CHTML40(pdoc);
3930 Doc *doc = chtml40->doc;
3933 chtml40->textarea_flag--;
3935 return chtml40->out;
3940 s_chtml40_chxjif_tag(void *pdoc, Node *node)
3947 chtml40 = GET_CHTML40(pdoc);
3951 for (child = qs_get_child_node(doc, node);
3953 child = qs_get_next_node(doc, child)) {
3955 s_chtml40_chxjif_tag(chtml40, child);
3963 s_chtml40_text_tag(void *pdoc, Node *child)
3975 apr_size_t z2h_input_len;
3977 chtml40 = GET_CHTML40(pdoc);
3981 textval = qs_get_node_value(doc,child);
3982 if (strlen(textval) == 0) {
3983 return chtml40->out;
3986 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3987 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3989 tdst = qs_alloc_zero_byte_string(doc->buf.pool);
3990 memset(one_byte, 0, sizeof(one_byte));
3993 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3995 int rtn = s_chtml40_search_emoji(chtml40, &textval[ii], &out, child);
3997 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
4002 if (is_sjis_kanji(textval[ii])) {
4003 one_byte[0] = textval[ii+0];
4004 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4005 one_byte[0] = textval[ii+1];
4006 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4009 else if (chtml40->pre_flag) {
4010 one_byte[0] = textval[ii+0];
4011 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4013 else if (chtml40->textarea_flag) {
4014 one_byte[0] = textval[ii+0];
4015 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4017 else if (textval[ii] != '\r' && textval[ii] != '\n') {
4018 one_byte[0] = textval[ii+0];
4019 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
4022 z2h_input_len = strlen(tdst);
4023 tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, chtml40->entryp);
4025 return chtml40->out;
4030 * It is a handler who processes the BLOCKQUOTE tag.
4032 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4033 * destination is specified.
4034 * @param node [i] The BLOCKQUOTE tag node is specified.
4035 * @return The conversion result is returned.
4038 s_chtml40_start_blockquote_tag(void *pdoc, Node *node)
4043 char *attr_style = NULL;
4044 char *attr_color = NULL;
4046 chtml40 = GET_CHTML40(pdoc);
4048 for (attr = qs_get_attr(doc,node);
4050 attr = qs_get_next_attr(doc,attr)) {
4051 char *nm = qs_get_attr_name(doc,attr);
4052 char *val = qs_get_attr_value(doc,attr);
4053 if (val && STRCASEEQ('s','S',"style", nm)) {
4057 if (IS_CSS_ON(chtml40->entryp)) {
4058 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4060 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4061 css_property_t *cur;
4062 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4063 if (cur->value && *cur->value) {
4064 attr_color = apr_pstrdup(doc->pool, cur->value);
4069 W_L("<blockquote>");
4070 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4071 memset(flg, 0, sizeof(*flg));
4073 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4074 W_L("<font color=\"");
4077 flg->with_font_flag = 1;
4079 node->userData = (void *)flg;
4080 return chtml40->out;
4085 * It is a handler who processes the BLOCKQUOTE tag.
4087 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4088 * destination is specified.
4089 * @param node [i] The BLOCKQUOTE tag node is specified.
4090 * @return The conversion result is returned.
4093 s_chtml40_end_blockquote_tag(void *pdoc, Node *node)
4095 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4096 Doc *doc = chtml40->doc;
4097 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4098 if (flg && flg->with_font_flag) {
4101 W_L("</blockquote>");
4102 if (IS_CSS_ON(chtml40->entryp)) {
4103 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4105 return chtml40->out;
4110 * It is a handler who processes the DIR tag.
4112 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4113 * destination is specified.
4114 * @param node [i] The DIR tag node is specified.
4115 * @return The conversion result is returned.
4118 s_chtml40_start_dir_tag(void *pdoc, Node *node)
4120 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4121 Doc *doc = chtml40->doc;
4123 char *attr_style = NULL;
4124 char *attr_color = NULL;
4125 char *attr_type = NULL;
4126 for (attr = qs_get_attr(doc,node);
4128 attr = qs_get_next_attr(doc,attr)) {
4129 char *name = qs_get_attr_name(doc,attr);
4130 char *value = qs_get_attr_value(doc,attr);
4131 if (STRCASEEQ('t','T',"type",name)) {
4132 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4136 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4140 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4148 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4149 memset(flg, 0, sizeof(*flg));
4151 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4152 W_L("<font color=\"");
4155 flg->with_font_flag = 1;
4157 node->userData = (void *)flg;
4158 return chtml40->out;
4163 * It is a handler who processes the DIR tag.
4165 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4166 * destination is specified.
4167 * @param node [i] The DIR tag node is specified.
4168 * @return The conversion result is returned.
4171 s_chtml40_end_dir_tag(void *pdoc, Node *node)
4173 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4174 Doc *doc = chtml40->doc;
4175 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4176 if (flg && flg->with_font_flag) {
4180 if (IS_CSS_ON(chtml40->entryp)) {
4181 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4183 return chtml40->out;
4188 * It is a handler who processes the DL tag.
4190 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4191 * destination is specified.
4192 * @param node [i] The DL tag node is specified.
4193 * @return The conversion result is returned.
4196 s_chtml40_start_dl_tag(void *pdoc, Node *node)
4201 char *attr_style = NULL;
4202 char *attr_color = NULL;
4204 chtml40 = GET_CHTML40(pdoc);
4206 for (attr = qs_get_attr(doc,node);
4208 attr = qs_get_next_attr(doc,attr)) {
4209 char *nm = qs_get_attr_name(doc,attr);
4210 char *val = qs_get_attr_value(doc,attr);
4211 if (val && STRCASEEQ('s','S',"style", nm)) {
4215 if (IS_CSS_ON(chtml40->entryp)) {
4216 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4218 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4219 css_property_t *cur;
4220 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4221 if (cur->value && *cur->value) {
4222 attr_color = apr_pstrdup(doc->pool, cur->value);
4228 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4229 memset(flg, 0, sizeof(*flg));
4231 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4232 W_L("<font color=\"");
4235 flg->with_font_flag = 1;
4237 node->userData = (void *)flg;
4238 return chtml40->out;
4243 * It is a handler who processes the DL tag.
4245 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4246 * destination is specified.
4247 * @param node [i] The DL tag node is specified.
4248 * @return The conversion result is returned.
4251 s_chtml40_end_dl_tag(void *pdoc, Node *node)
4253 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4254 Doc *doc = chtml40->doc;
4255 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4256 if (flg && flg->with_font_flag) {
4260 if (IS_CSS_ON(chtml40->entryp)) {
4261 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4263 return chtml40->out;
4268 * It is a handler who processes the DT tag.
4270 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4271 * destination is specified.
4272 * @param node [i] The DT tag node is specified.
4273 * @return The conversion result is returned.
4276 s_chtml40_start_dt_tag(void *pdoc, Node *node)
4281 char *attr_style = NULL;
4282 char *attr_color = NULL;
4284 chtml40 = GET_CHTML40(pdoc);
4286 for (attr = qs_get_attr(doc,node);
4288 attr = qs_get_next_attr(doc,attr)) {
4289 char *nm = qs_get_attr_name(doc,attr);
4290 char *val = qs_get_attr_value(doc,attr);
4291 if (val && STRCASEEQ('s','S',"style", nm)) {
4295 if (IS_CSS_ON(chtml40->entryp)) {
4296 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4298 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4299 css_property_t *cur;
4300 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4301 if (cur->value && *cur->value) {
4302 attr_color = apr_pstrdup(doc->pool, cur->value);
4308 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4309 memset(flg, 0, sizeof(*flg));
4311 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4312 W_L("<font color=\"");
4315 flg->with_font_flag = 1;
4317 node->userData = (void *)flg;
4318 return chtml40->out;
4323 * It is a handler who processes the DT tag.
4325 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4326 * destination is specified.
4327 * @param node [i] The DT tag node is specified.
4328 * @return The conversion result is returned.
4331 s_chtml40_end_dt_tag(void *pdoc, Node *node)
4333 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4334 Doc *doc = chtml40->doc;
4335 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4336 if (flg && flg->with_font_flag) {
4339 if (IS_CSS_ON(chtml40->entryp)) {
4340 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4342 return chtml40->out;
4347 * It is a handler who processes the DD tag.
4349 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4350 * destination is specified.
4351 * @param node [i] The DD tag node is specified.
4352 * @return The conversion result is returned.
4355 s_chtml40_start_dd_tag(void *pdoc, Node *node)
4360 char *attr_style = NULL;
4361 char *attr_color = NULL;
4363 chtml40 = GET_CHTML40(pdoc);
4365 for (attr = qs_get_attr(doc,node);
4367 attr = qs_get_next_attr(doc,attr)) {
4368 char *nm = qs_get_attr_name(doc,attr);
4369 char *val = qs_get_attr_value(doc,attr);
4370 if (val && STRCASEEQ('s','S',"style", nm)) {
4374 if (IS_CSS_ON(chtml40->entryp)) {
4375 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4377 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4378 css_property_t *cur;
4379 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4380 if (cur->value && *cur->value) {
4381 attr_color = apr_pstrdup(doc->pool, cur->value);
4387 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4388 memset(flg, 0, sizeof(*flg));
4390 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4391 W_L("<font color=\"");
4394 flg->with_font_flag = 1;
4396 node->userData = (void *)flg;
4397 return chtml40->out;
4402 * It is a handler who processes the DD tag.
4404 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4405 * destination is specified.
4406 * @param node [i] The DD tag node is specified.
4407 * @return The conversion result is returned.
4410 s_chtml40_end_dd_tag(void *pdoc, Node *node)
4412 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4413 Doc *doc = chtml40->doc;
4414 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4415 if (flg && flg->with_font_flag) {
4418 if (IS_CSS_ON(chtml40->entryp)) {
4419 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4421 return chtml40->out;
4426 * It is a handler who processes the MARQUEE tag.
4428 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4429 * destination is specified.
4430 * @param node [i] The MARQUEE tag node is specified.
4431 * @return The conversion result is returned.
4434 s_chtml40_start_marquee_tag(void *pdoc, Node *node)
4436 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4437 Doc *doc = chtml40->doc;
4439 char *attr_direction = NULL;
4440 char *attr_behavior = NULL;
4441 char *attr_loop = NULL;
4442 char *attr_style = NULL;
4443 char *attr_color = NULL;
4444 /*--------------------------------------------------------------------------*/
4445 /* Get Attributes */
4446 /*--------------------------------------------------------------------------*/
4447 for (attr = qs_get_attr(doc,node);
4449 attr = qs_get_next_attr(doc,attr)) {
4450 char *name = qs_get_attr_name(doc,attr);
4451 char *value = qs_get_attr_value(doc,attr);
4452 if (STRCASEEQ('d','D',"direction", name)) {
4453 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
4454 attr_direction = value;
4457 else if (STRCASEEQ('b','B',"behavior",name)) {
4458 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
4459 attr_behavior = value;
4462 else if (STRCASEEQ('l','L',"loop",name)) {
4463 if (value && *value) {
4467 else if (STRCASEEQ('s','S',"style",name) && value && *value) {
4471 if (IS_CSS_ON(chtml40->entryp)) {
4472 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4474 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4475 css_property_t *direction_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4476 css_property_t *style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4477 css_property_t *loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4478 css_property_t *cur;
4479 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4480 if (cur->value && *cur->value) {
4481 attr_color = apr_pstrdup(doc->pool, cur->value);
4484 for (cur = style_prop->next; cur != style_prop; cur = cur->next) {
4485 if (cur->value && *cur->value) {
4486 attr_behavior = apr_pstrdup(doc->pool, cur->value);
4489 for (cur = loop_prop->next; cur != loop_prop; cur = cur->next) {
4490 if (cur->value && *cur->value) {
4491 attr_loop = apr_pstrdup(doc->pool, cur->value);
4492 if (STRCASEEQ('i','I',"infinite",attr_loop)) {
4497 for (cur = direction_prop->next; cur != direction_prop; cur = cur->next) {
4498 if (cur->value && *cur->value) {
4499 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4500 attr_direction = "right";
4502 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4503 attr_direction = "left";
4510 if (attr_direction) {
4511 W_L(" direction=\"");
4512 W_V(attr_direction);
4515 if (attr_behavior) {
4516 W_L(" behavior=\"");
4527 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4528 memset(flg, 0, sizeof(*flg));
4530 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4531 W_L("<font color=\"");
4534 flg->with_font_flag = 1;
4536 node->userData = (void *)flg;
4537 return chtml40->out;
4542 * It is a handler who processes the MARQUEE tag.
4544 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4545 * destination is specified.
4546 * @param node [i] The MARQUEE tag node is specified.
4547 * @return The conversion result is returned.
4550 s_chtml40_end_marquee_tag(void *pdoc, Node *node)
4552 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4553 Doc *doc = chtml40->doc;
4554 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4555 if (flg && flg->with_font_flag) {
4559 if (IS_CSS_ON(chtml40->entryp)) {
4560 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4562 return chtml40->out;
4567 * It is a handler who processes the BLINK tag.
4569 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4570 * destination is specified.
4571 * @param node [i] The BLINK tag node is specified.
4572 * @return The conversion result is returned.
4575 s_chtml40_start_blink_tag(void *pdoc, Node *node)
4580 char *attr_style = NULL;
4581 char *attr_color = NULL;
4583 chtml40 = GET_CHTML40(pdoc);
4585 for (attr = qs_get_attr(doc,node);
4587 attr = qs_get_next_attr(doc,attr)) {
4588 char *nm = qs_get_attr_name(doc,attr);
4589 char *val = qs_get_attr_value(doc,attr);
4590 if (val && STRCASEEQ('s','S',"style", nm)) {
4594 if (IS_CSS_ON(chtml40->entryp)) {
4595 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4597 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4598 css_property_t *cur;
4599 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4600 if (cur->value && *cur->value) {
4601 attr_color = apr_pstrdup(doc->pool, cur->value);
4607 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4608 memset(flg, 0, sizeof(*flg));
4610 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4611 W_L("<font color=\"");
4614 flg->with_font_flag = 1;
4616 node->userData = (void *)flg;
4617 return chtml40->out;
4622 * It is a handler who processes the BLINK tag.
4624 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4625 * destination is specified.
4626 * @param node [i] The BLINK tag node is specified.
4627 * @return The conversion result is returned.
4630 s_chtml40_end_blink_tag(void *pdoc, Node *node)
4632 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4633 Doc *doc = chtml40->doc;
4634 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4635 if (flg && flg->with_font_flag) {
4639 if (IS_CSS_ON(chtml40->entryp)) {
4640 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4642 return chtml40->out;
4647 * It is a handler who processes the MENU tag.
4649 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4650 * destination is specified.
4651 * @param node [i] The MENU tag node is specified.
4652 * @return The conversion result is returned.
4655 s_chtml40_start_menu_tag(void *pdoc, Node *node)
4657 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4658 Doc *doc = chtml40->doc;
4660 char *attr_style = NULL;
4661 char *attr_type = NULL;
4662 char *attr_color = NULL;
4663 /*--------------------------------------------------------------------------*/
4664 /* Get Attributes */
4665 /*--------------------------------------------------------------------------*/
4666 for (attr = qs_get_attr(doc,node);
4668 attr = qs_get_next_attr(doc,attr)) {
4669 char *name = qs_get_attr_name(doc,attr);
4670 char *value = qs_get_attr_value(doc,attr);
4671 if (STRCASEEQ('t','T',"type",name)) {
4672 if (value && (STRCASEEQ('d','D',"disc",value) || STRCASEEQ('c','C',"circle",value) || STRCASEEQ('s','S',"square",value))) {
4676 else if (STRCASEEQ('s','S',"style", name) && value && *value) {
4680 CHTML40_GET_CSS_COLOR_AND_LIST_STYLE_TYPE();
4688 chtml40_flags_t *flg = (chtml40_flags_t *)apr_palloc(doc->pool, sizeof(chtml40_flags_t));
4689 memset(flg, 0, sizeof(*flg));
4691 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
4692 W_L("<font color=\"");
4695 flg->with_font_flag = 1;
4697 node->userData = (void *)flg;
4699 return chtml40->out;
4704 * It is a handler who processes the MENU tag.
4706 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4707 * destination is specified.
4708 * @param node [i] The MENU tag node is specified.
4709 * @return The conversion result is returned.
4712 s_chtml40_end_menu_tag(void *pdoc, Node *node)
4714 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4715 Doc *doc = chtml40->doc;
4716 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
4717 if (flg && flg->with_font_flag) {
4721 if (IS_CSS_ON(chtml40->entryp)) {
4722 chxj_css_pop_prop_list(chtml40->css_prop_stack);
4724 return chtml40->out;
4729 * It is a handler who processes the PLAINTEXT tag.
4731 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4732 * destination is specified.
4733 * @param node [i] The PLAINTEXT tag node is specified.
4734 * @return The conversion result is returned.
4737 s_chtml40_start_plaintext_tag(void *pdoc, Node *node)
4739 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4740 Doc *doc = chtml40->doc;
4742 s_chtml40_start_plaintext_tag_inner(pdoc,node);
4743 return chtml40->out;
4747 s_chtml40_start_plaintext_tag_inner(void *pdoc, Node *node)
4749 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4750 Doc *doc = chtml40->doc;
4752 for (child = qs_get_child_node(doc, node);
4754 child = qs_get_next_node(doc, child)) {
4756 s_chtml40_start_plaintext_tag_inner(pdoc, child);
4758 return chtml40->out;
4763 * It is a handler who processes the PLAINTEXT tag.
4765 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4766 * destination is specified.
4767 * @param node [i] The PLAINTEXT tag node is specified.
4768 * @return The conversion result is returned.
4771 s_chtml40_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
4773 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4774 return chtml40->out;
4779 * It is handler who processes the New Line Code.
4782 s_chtml40_newline_mark(void *pdoc, Node *UNUSED(node))
4784 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4785 Doc *doc = chtml40->doc;
4787 return chtml40->out;
4792 * It is a handler who processes the LINK tag.
4794 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4795 * destination is specified.
4796 * @param node [i] The LINK tag node is specified.
4797 * @return The conversion result is returned.
4800 s_chtml40_link_tag(void *pdoc, Node *node)
4809 chtml40 = GET_CHTML40(pdoc);
4812 if (! IS_CSS_ON(chtml40->entryp)) {
4813 return chtml40->out;
4816 for (attr = qs_get_attr(doc,node);
4818 attr = qs_get_next_attr(doc,attr)) {
4819 char *name = qs_get_attr_name(doc,attr);
4820 char *value = qs_get_attr_value(doc,attr);
4821 if (STRCASEEQ('r','R',"rel", name)) {
4822 if (value && *value && STRCASEEQ('s','S',"stylesheet", value)) {
4826 else if (STRCASEEQ('h','H',"href", name)) {
4827 if (value && *value) {
4831 else if (STRCASEEQ('t','T',"type", name)) {
4832 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
4838 if (rel && href && type) {
4839 DBG(doc->r, "start load CSS. url:[%s]", href);
4840 chtml40->style = chxj_css_parse_from_uri(doc->r, doc->pool, chtml40->style, href);
4841 DBG(doc->r, "end load CSS. url:[%s]", href);
4844 return chtml40->out;
4847 static css_prop_list_t *
4848 s_chtml40_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4850 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4851 Doc *doc = chtml40->doc;
4852 css_prop_list_t *last_css = NULL;
4853 if (IS_CSS_ON(chtml40->entryp)) {
4854 css_prop_list_t *dup_css;
4855 css_selector_t *selector;
4857 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4858 dup_css = chxj_dup_css_prop_list(doc, last_css);
4859 selector = chxj_css_find_selector(doc, chtml40->style, node);
4861 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4863 chxj_css_push_prop_list(chtml40->css_prop_stack, dup_css);
4864 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4866 if (style_attr_value) {
4867 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));
4869 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4877 static css_prop_list_t *
4878 s_chtml40_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value)
4880 chtml40_t *chtml40 = GET_CHTML40(pdoc);
4881 Doc *doc = chtml40->doc;
4882 css_prop_list_t *last_css = NULL;
4883 if (IS_CSS_ON(chtml40->entryp)) {
4884 css_prop_list_t *dup_css;
4885 css_selector_t *selector;
4887 last_css = chxj_css_get_last_prop_list(chtml40->css_prop_stack);
4888 dup_css = chxj_dup_css_prop_list(doc, last_css);
4889 selector = chxj_css_find_selector(doc, chtml40->style, node);
4891 chxj_css_prop_list_merge_property(doc, dup_css, selector);
4895 if (style_attr_value) {
4896 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));
4898 chxj_css_prop_list_merge_property(doc, last_css, ssheet->selector_head.next);
4908 * It is a handler who processes the SPAN tag.
4910 * @param pdoc [i/o] The pointer to the CHTML structure at the output
4911 * destination is specified.
4912 * @param node [i] The SPAN tag node is specified.
4913 * @return The conversion result is returned.
4916 s_chtml40_start_span_tag(void *pdoc, Node *node)
4921 char *attr_style = NULL;
4922 char *attr_color = NULL;
4923 char *attr_align = NULL;
4924 char *attr_blink = NULL;
4925 char *attr_marquee = NULL;
4926 char *attr_marquee_dir = NULL;
4927 char *attr_marquee_style = NULL;
4928 char *attr_marquee_loop = NULL;
4930 chtml40 = GET_CHTML40(pdoc);
4933 for (attr = qs_get_attr(doc,node);
4935 attr = qs_get_next_attr(doc,attr)) {
4936 char *nm = qs_get_attr_name(doc,attr);
4937 char *val = qs_get_attr_value(doc,attr);
4938 if (val && STRCASEEQ('s','S',"style", nm)) {
4942 if (IS_CSS_ON(chtml40->entryp)) {
4943 css_prop_list_t *style = s_chtml40_push_and_get_now_style(pdoc, node, attr_style);
4945 css_property_t *color_prop = chxj_css_get_property_value(doc, style, "color");
4946 css_property_t *text_align_prop = chxj_css_get_property_value(doc, style, "text-align");
4947 css_property_t *decoration_prop = chxj_css_get_property_value(doc, style, "text-decoration");
4948 css_property_t *display_prop = chxj_css_get_property_value(doc, style, "display");
4949 css_property_t *marquee_dir_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-dir");
4950 css_property_t *marquee_style_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-style");
4951 css_property_t *marquee_loop_prop = chxj_css_get_property_value(doc, style, "-wap-marquee-loop");
4952 css_property_t *cur;
4953 for (cur = color_prop->next; cur != color_prop; cur = cur->next) {
4954 attr_color = apr_pstrdup(doc->pool, cur->value);
4956 for (cur = decoration_prop->next; cur != decoration_prop; cur = cur->next) {
4957 if (cur->value && STRCASEEQ('b','B',"blink",cur->value)) {
4958 attr_blink = apr_pstrdup(doc->pool, cur->value);
4961 for (cur = display_prop->next; cur != display_prop; cur = cur->next) {
4962 if (cur->value && strcasecmp("-wap-marquee",cur->value) == 0) {
4963 attr_marquee = apr_pstrdup(doc->pool, cur->value);
4966 for (cur = marquee_dir_prop->next; cur != marquee_dir_prop; cur = cur->next) {
4967 if (cur->value && *cur->value) {
4968 if (STRCASEEQ('l','L',"ltr",cur->value)) {
4969 attr_marquee_dir = "right";
4971 else if (STRCASEEQ('r','R',"rtl",cur->value)) {
4972 attr_marquee_dir = "left";
4976 for (cur = marquee_style_prop->next; cur != marquee_style_prop; cur = cur->next) {
4977 if (cur->value && *cur->value) {
4978 if ( STRCASEEQ('s','S',"scroll",cur->value)
4979 || STRCASEEQ('s','S',"slide",cur->value)
4980 || STRCASEEQ('a','A',"alternate",cur->value)) {
4981 attr_marquee_style = apr_pstrdup(doc->pool, cur->value);
4985 for (cur = marquee_loop_prop->next; cur != marquee_loop_prop; cur = cur->next) {
4986 if (cur->value && *cur->value) {
4987 if (STRCASEEQ('i','I',"infinite",cur->value)) {
4988 attr_marquee_loop = "16";
4991 attr_marquee_loop = apr_pstrdup(doc->pool, cur->value);
4995 for (cur = text_align_prop->next; cur != text_align_prop; cur = cur->next) {
4996 if (STRCASEEQ('l','L',"left", cur->value)) {
4997 attr_align = apr_pstrdup(doc->pool, "left");
4999 else if (STRCASEEQ('c','C',"center",cur->value)) {
5000 attr_align = apr_pstrdup(doc->pool, "center");
5002 else if (STRCASEEQ('r','R',"right",cur->value)) {
5003 attr_align = apr_pstrdup(doc->pool, "right");
5008 if (attr_color || attr_align || attr_blink || attr_marquee) {
5009 chtml40_flags_t *flg = apr_palloc(doc->pool, sizeof(*flg));
5010 memset(flg, 0, sizeof(*flg));
5013 flg->with_blink_flag = 1;
5017 if (attr_marquee_dir) {
5018 W_L(" direction=\"");
5019 W_V(attr_marquee_dir);
5022 if (attr_marquee_style) {
5023 W_L(" behavior=\"");
5024 W_V(attr_marquee_style);
5027 if (attr_marquee_loop) {
5029 W_V(attr_marquee_loop);
5033 flg->with_marquee_flag = 1;
5036 attr_color = chxj_css_rgb_func_to_value(doc->pool, attr_color);
5037 W_L("<font color=\"");
5040 flg->with_font_flag = 1;
5043 W_L("<div align=\"");
5046 flg->with_div_flag = 1;
5048 node->userData = flg;
5051 node->userData = NULL;
5053 return chtml40->out;
5058 * It is a handler who processes the SPAN tag.
5060 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5061 * destination is specified.
5062 * @param node [i] The SPAN tag node is specified.
5063 * @return The conversion result is returned.
5066 s_chtml40_end_span_tag(void *pdoc, Node *node)
5068 chtml40_t *chtml40 = GET_CHTML40(pdoc);
5069 Doc *doc = chtml40->doc;
5071 chtml40_flags_t *flg = (chtml40_flags_t *)node->userData;
5072 if (flg && flg->with_div_flag) {
5075 if (flg && flg->with_font_flag) {
5078 if (flg && flg->with_marquee_flag) {
5081 if (flg && flg->with_blink_flag) {
5084 if (IS_CSS_ON(chtml40->entryp)) {
5085 chxj_css_pop_prop_list(chtml40->css_prop_stack);
5087 return chtml40->out;
5092 * It is a handler who processes the STYLE tag.
5094 * @param pdoc [i/o] The pointer to the CHTML structure at the output
5095 * destination is specified.
5096 * @param node [i] The STYLE tag node is specified.
5097 * @return The conversion result is returned.
5100 s_chtml40_style_tag(void *pdoc, Node *node)
5107 chtml40 = GET_CHTML40(pdoc);
5110 if (! IS_CSS_ON(chtml40->entryp)) {
5111 return chtml40->out;
5114 for (attr = qs_get_attr(doc,node);
5116 attr = qs_get_next_attr(doc,attr)) {
5117 char *name = qs_get_attr_name(doc,attr);
5118 char *value = qs_get_attr_value(doc,attr);
5119 if (STRCASEEQ('t','T',"type", name)) {
5120 if (value && *value && STRCASEEQ('t','T',"text/css",value)) {
5126 Node *child = qs_get_child_node(doc, node);
5127 if (type && child) {
5128 char *name = qs_get_node_name(doc, child);
5129 if (STRCASEEQ('t','T',"text", name)) {
5130 char *value = qs_get_node_value(doc, child);
5131 DBG(doc->r, "start load CSS. buf:[%s]", value);
5132 chtml40->style = chxj_css_parse_style_value(doc, chtml40->style, value);
5133 DBG(doc->r, "end load CSS. value:[%s]", value);
5136 return chtml40->out;