2 * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include "chxj_chtml20.h"
18 #include "chxj_hdml.h"
19 #include "chxj_str_util.h"
20 #include "chxj_dump.h"
21 #include "chxj_img_conv.h"
22 #include "chxj_qr_code.h"
23 #include "chxj_encoding.h"
24 #include "chxj_buffered_write.h"
27 #define GET_CHTML20(X) ((chtml20_t*)(X))
28 #define W_L(X) do { chtml20->out = BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, (X)); } while(0)
29 #define W_V(X) do { chtml20->out = (X) ? BUFFERED_WRITE_VALUE(chtml20->out, &doc->buf, (X)) \
30 : BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, ""); } while(0)
32 static char *s_chtml20_start_html_tag (void *pdoc, Node *node);
33 static char *s_chtml20_end_html_tag (void *pdoc, Node *node);
34 static char *s_chtml20_start_meta_tag (void *pdoc, Node *node);
35 static char *s_chtml20_end_meta_tag (void *pdoc, Node *node);
36 static char *s_chtml20_start_textarea_tag(void *pdoc, Node *node);
37 static char *s_chtml20_end_textarea_tag (void *pdoc, Node *node);
38 static char *s_chtml20_start_p_tag (void *pdoc, Node *node);
39 static char *s_chtml20_end_p_tag (void *pdoc, Node *node);
40 static char *s_chtml20_start_pre_tag (void *pdoc, Node *node);
41 static char *s_chtml20_end_pre_tag (void *pdoc, Node *node);
42 static char *s_chtml20_start_h1_tag (void *pdoc, Node *node);
43 static char *s_chtml20_end_h1_tag (void *pdoc, Node *node);
44 static char *s_chtml20_start_h2_tag (void *pdoc, Node *node);
45 static char *s_chtml20_end_h2_tag (void *pdoc, Node *node);
46 static char *s_chtml20_start_h3_tag (void *pdoc, Node *node);
47 static char *s_chtml20_end_h3_tag (void *pdoc, Node *node);
48 static char *s_chtml20_start_h4_tag (void *pdoc, Node *node);
49 static char *s_chtml20_end_h4_tag (void *pdoc, Node *node);
50 static char *s_chtml20_start_h5_tag (void *pdoc, Node *node);
51 static char *s_chtml20_end_h5_tag (void *pdoc, Node *node);
52 static char *s_chtml20_start_h6_tag (void *pdoc, Node *node);
53 static char *s_chtml20_end_h6_tag (void *pdoc, Node *node);
54 static char *s_chtml20_start_ul_tag (void *pdoc, Node *node);
55 static char *s_chtml20_end_ul_tag (void *pdoc, Node *node);
56 static char *s_chtml20_start_ol_tag (void *pdoc, Node *node);
57 static char *s_chtml20_end_ol_tag (void *pdoc, Node *node);
58 static char *s_chtml20_start_li_tag (void *pdoc, Node *node);
59 static char *s_chtml20_end_li_tag (void *pdoc, Node *node);
60 static char *s_chtml20_start_head_tag (void *pdoc, Node *node);
61 static char *s_chtml20_end_head_tag (void *pdoc, Node *node);
62 static char *s_chtml20_start_title_tag (void *pdoc, Node *node);
63 static char *s_chtml20_end_title_tag (void *pdoc, Node *node);
64 static char *s_chtml20_start_base_tag (void *pdoc, Node *node);
65 static char *s_chtml20_end_base_tag (void *pdoc, Node *node);
66 static char *s_chtml20_start_body_tag (void *pdoc, Node *node);
67 static char *s_chtml20_end_body_tag (void *pdoc, Node *node);
68 static char *s_chtml20_start_a_tag (void *pdoc, Node *node);
69 static char *s_chtml20_end_a_tag (void *pdoc, Node *node);
70 static char *s_chtml20_start_br_tag (void *pdoc, Node *node);
71 static char *s_chtml20_end_br_tag (void *pdoc, Node *node);
72 static char *s_chtml20_start_tr_tag (void *pdoc, Node *node);
73 static char *s_chtml20_end_tr_tag (void *pdoc, Node *node);
74 static char *s_chtml20_start_font_tag (void *pdoc, Node *node);
75 static char *s_chtml20_end_font_tag (void *pdoc, Node *node);
76 static char *s_chtml20_start_form_tag (void *pdoc, Node *node);
77 static char *s_chtml20_end_form_tag (void *pdoc, Node *node);
78 static char *s_chtml20_start_input_tag (void *pdoc, Node *node);
79 static char *s_chtml20_end_input_tag (void *pdoc, Node *node);
80 static char *s_chtml20_start_center_tag (void *pdoc, Node *node);
81 static char *s_chtml20_end_center_tag (void *pdoc, Node *node);
82 static char *s_chtml20_start_hr_tag (void *pdoc, Node *node);
83 static char *s_chtml20_end_hr_tag (void *pdoc, Node *node);
84 static char *s_chtml20_start_img_tag (void *pdoc, Node *node);
85 static char *s_chtml20_end_img_tag (void *pdoc, Node *node);
86 static char *s_chtml20_start_select_tag (void *pdoc, Node *node);
87 static char *s_chtml20_end_select_tag (void *pdoc, Node *node);
88 static char *s_chtml20_start_option_tag (void *pdoc, Node *node);
89 static char *s_chtml20_end_option_tag (void *pdoc, Node *node);
90 static char *s_chtml20_start_div_tag (void *pdoc, Node *node);
91 static char *s_chtml20_end_div_tag (void *pdoc, Node *node);
92 static char *s_chtml20_start_blockquote_tag(void *pdoc, Node *node);
93 static char *s_chtml20_end_blockquote_tag (void *pdoc, Node *node);
94 static char *s_chtml20_start_dir_tag (void *pdoc, Node *node);
95 static char *s_chtml20_end_dir_tag (void *pdoc, Node *node);
96 static char *s_chtml20_start_dl_tag (void *pdoc, Node *node);
97 static char *s_chtml20_end_dl_tag (void *pdoc, Node *node);
98 static char *s_chtml20_start_dt_tag (void *pdoc, Node *node);
99 static char *s_chtml20_end_dt_tag (void *pdoc, Node *node);
100 static char *s_chtml20_start_dd_tag (void *pdoc, Node *node);
101 static char *s_chtml20_end_dd_tag (void *pdoc, Node *node);
102 static char *s_chtml20_start_menu_tag (void *pdoc, Node *node);
103 static char *s_chtml20_end_menu_tag (void *pdoc, Node *node);
104 static char *s_chtml20_start_plaintext_tag (void *pdoc, Node *node);
105 static char *s_chtml20_start_plaintext_tag_inner (void *pdoc, Node *node);
106 static char *s_chtml20_end_plaintext_tag (void *pdoc, Node *node);
107 static char *s_chtml20_start_blink_tag (void *pdoc, Node *node);
108 static char *s_chtml20_end_blink_tag (void *pdoc, Node *node);
109 static char *s_chtml20_start_marquee_tag (void *pdoc, Node *node);
110 static char *s_chtml20_end_marquee_tag (void *pdoc, Node *node);
112 static void s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
114 static int s_chtml20_search_emoji(chtml20_t *chtml, char *txt, char **rslt);
116 static char *s_chtml20_chxjif_tag(void *pdoc, Node *node);
117 static char *s_chtml20_text_tag(void *pdoc, Node *node);
120 tag_handler chtml20_handler[] = {
123 s_chtml20_start_html_tag,
124 s_chtml20_end_html_tag,
128 s_chtml20_start_meta_tag,
129 s_chtml20_end_meta_tag,
133 s_chtml20_start_textarea_tag,
134 s_chtml20_end_textarea_tag,
138 s_chtml20_start_p_tag,
143 s_chtml20_start_pre_tag,
144 s_chtml20_end_pre_tag,
148 s_chtml20_start_ul_tag,
149 s_chtml20_end_ul_tag,
153 s_chtml20_start_li_tag,
154 s_chtml20_end_li_tag,
158 s_chtml20_start_ol_tag,
159 s_chtml20_end_ol_tag,
163 s_chtml20_start_h1_tag,
164 s_chtml20_end_h1_tag,
168 s_chtml20_start_h2_tag,
169 s_chtml20_end_h2_tag,
173 s_chtml20_start_h3_tag,
174 s_chtml20_end_h3_tag,
178 s_chtml20_start_h4_tag,
179 s_chtml20_end_h4_tag,
183 s_chtml20_start_h5_tag,
184 s_chtml20_end_h5_tag,
188 s_chtml20_start_h6_tag,
189 s_chtml20_end_h6_tag,
193 s_chtml20_start_head_tag,
194 s_chtml20_end_head_tag,
198 s_chtml20_start_title_tag,
199 s_chtml20_end_title_tag,
203 s_chtml20_start_base_tag,
204 s_chtml20_end_base_tag,
208 s_chtml20_start_body_tag,
209 s_chtml20_end_body_tag,
213 s_chtml20_start_a_tag,
218 s_chtml20_start_br_tag,
219 s_chtml20_end_br_tag,
228 s_chtml20_start_tr_tag,
229 s_chtml20_end_tr_tag,
243 s_chtml20_start_font_tag,
244 s_chtml20_end_font_tag,
248 s_chtml20_start_form_tag,
249 s_chtml20_end_form_tag,
253 s_chtml20_start_input_tag,
254 s_chtml20_end_input_tag,
258 s_chtml20_start_center_tag,
259 s_chtml20_end_center_tag,
263 s_chtml20_start_hr_tag,
264 s_chtml20_end_hr_tag,
268 s_chtml20_start_img_tag,
269 s_chtml20_end_img_tag,
273 s_chtml20_start_select_tag,
274 s_chtml20_end_select_tag,
278 s_chtml20_start_option_tag,
279 s_chtml20_end_option_tag,
283 s_chtml20_start_div_tag,
284 s_chtml20_end_div_tag,
288 s_chtml20_chxjif_tag,
333 s_chtml20_start_dt_tag,
334 s_chtml20_end_dt_tag,
348 s_chtml20_start_blockquote_tag,
349 s_chtml20_end_blockquote_tag,
353 s_chtml20_start_dir_tag,
354 s_chtml20_end_dir_tag,
358 s_chtml20_start_dl_tag,
359 s_chtml20_end_dl_tag,
363 s_chtml20_start_dd_tag,
364 s_chtml20_end_dd_tag,
368 s_chtml20_start_menu_tag,
369 s_chtml20_end_menu_tag,
373 s_chtml20_start_plaintext_tag,
374 s_chtml20_end_plaintext_tag,
378 s_chtml20_start_blink_tag,
379 s_chtml20_end_blink_tag,
383 s_chtml20_start_marquee_tag,
384 s_chtml20_end_marquee_tag,
389 * converts from CHTML5.0 to CHTML2.0.
391 * @param r [i] Requet_rec is appointed.
392 * @param spec [i] The result of the device specification processing which
393 * was done in advance is appointed.
394 * @param src [i] The character string before the converting is appointed.
395 * @return The character string after the converting is returned.
398 chxj_exchange_chtml20(
404 chxjconvrule_entry *entryp,
413 /*--------------------------------------------------------------------------*/
415 /*--------------------------------------------------------------------------*/
417 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
419 DBG(r,"i found qrcode xml");
422 DBG(r,"not found qrcode xml");
424 /*--------------------------------------------------------------------------*/
425 /* The CHTML structure is initialized. */
426 /*--------------------------------------------------------------------------*/
427 s_init_chtml20(&chtml20, &doc, r, spec);
430 chtml20.entryp = entryp;
431 chtml20.cookie = cookie;
433 chxj_set_content_type(r, "text/html; charset=Windows-31J");
435 /*--------------------------------------------------------------------------*/
436 /* The character string of the input is analyzed. */
437 /*--------------------------------------------------------------------------*/
438 qs_init_malloc(&doc);
439 qs_init_root_node(&doc);
441 ss = apr_pcalloc(r->pool, srclen + 1);
442 memset(ss, 0, srclen + 1);
443 memcpy(ss, src, srclen);
446 chxj_dump_out("[src] CHTML -> CHTML2.0", ss, srclen);
449 qs_parse_string(&doc,ss, strlen(ss));
451 chxj_buffered_write_init(r->pool, &doc.buf);
452 /*--------------------------------------------------------------------------*/
453 /* It converts it from CHTML to CHTML. */
454 /*--------------------------------------------------------------------------*/
455 chxj_node_exchange(spec,r,(void *)&chtml20, &doc, qs_get_root(&doc), 0);
456 chtml20.out = chxj_buffered_write_flush(chtml20.out, &doc.buf);
457 dst = apr_pstrdup(r->pool, chtml20.out);
458 chxj_buffered_write_terminate(&doc.buf);
460 qs_all_free(&doc,QX_LOGMARK);
463 return apr_pstrdup(r->pool,ss);
466 if (strlen(dst) == 0) {
467 dst = apr_psprintf(r->pool, "\n");
470 *dstlen = strlen(dst);
473 chxj_dump_out("[dst] CHTML -> CHTML2.0", dst, *dstlen);
480 * The CHTML structure is initialized.
482 * @param chtml20 [i/o] The pointer to the HDML structure that wants to be
483 * initialized is specified.
484 * @param doc [i] The Doc structure that should be set to the initialized
485 * HDML structure is specified.
486 * @param r [i] To use POOL, the pointer to request_rec is specified.
487 * @param spec [i] The pointer to the device_table
490 s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
492 memset(doc, 0, sizeof(Doc));
493 memset(chtml20, 0, sizeof(chtml20_t));
497 chtml20->spec = spec;
498 chtml20->out = qs_alloc_zero_byte_string(r);
499 chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
501 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
506 * Corresponding EMOJI to a current character-code is retrieved.
507 * The substitution character string is stored in the rslt pointer if agreeing.
509 * @param chtml20 [i] The pointer to the CHTML structure is specified.
510 * @param txt [i] The character string to want to examine whether it is
511 * EMOJI is specified.
512 * @param rslt [o] The pointer to the pointer that stores the result is
514 * @return When corresponding EMOJI exists, it returns it excluding 0.
517 s_chtml20_search_emoji(chtml20_t *chtml20, char *txt, char **rslt)
524 spec = chtml20->spec;
530 DBG(r,"spec is NULL");
532 for (ee = chtml20->conf->emoji;
536 if (ee->imode == NULL) {
537 DBG(r,"emoji->imode is NULL");
541 if (ee->imode->string != NULL
542 && strlen(ee->imode->string) > 0
543 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
544 if (spec == NULL || spec->emoji_type == NULL) {
545 *rslt = apr_palloc(r->pool, 3);
546 (*rslt)[0] = ee->imode->hex1byte & 0xff;
547 (*rslt)[1] = ee->imode->hex2byte & 0xff;
549 return strlen(ee->imode->string);
561 * It is a handler who processes the HTML tag.
563 * @param pdoc [i/o] The pointer to the CHTML structure at the output
564 * destination is specified.
565 * @param node [i] The HTML tag node is specified.
566 * @return The conversion result is returned.
569 s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
575 chtml20 = GET_CHTML20(pdoc);
579 /*--------------------------------------------------------------------------*/
581 /*--------------------------------------------------------------------------*/
588 * It is a handler who processes the HTML tag.
590 * @param pdoc [i/o] The pointer to the CHTML structure at the output
591 * destination is specified.
592 * @param node [i] The HTML tag node is specified.
593 * @return The conversion result is returned.
596 s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child))
602 chtml20 = GET_CHTML20(pdoc);
612 * It is a handler who processes the META tag.
614 * @param pdoc [i/o] The pointer to the CHTML structure at the output
615 * destination is specified.
616 * @param node [i] The META tag node is specified.
617 * @return The conversion result is returned.
620 s_chtml20_start_meta_tag(void *pdoc, Node *node)
626 int content_type_flag;
629 chtml20 = GET_CHTML20(pdoc);
633 content_type_flag = 0;
637 /*--------------------------------------------------------------------------*/
639 /*--------------------------------------------------------------------------*/
640 for (attr = qs_get_attr(doc,node);
642 attr = qs_get_next_attr(doc,attr)) {
643 char *name = qs_get_attr_name(doc,attr);
644 char *value = qs_get_attr_value(doc,attr);
648 if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
649 /*----------------------------------------------------------------------*/
651 /*----------------------------------------------------------------------*/
652 W_L(" http-equiv=\"");
655 if (STRCASEEQ('c','C',"content-type", value)) {
656 content_type_flag = 1;
658 if (STRCASEEQ('r','R',"refresh", value)) {
666 if (strcasecmp(name, "content") == 0 && value && *value) {
667 if (content_type_flag) {
670 W_L("=\"text/html; charset=Windows-31J\"");
672 else if (refresh_flag) {
673 char *buf = apr_pstrdup(r->pool, value);
677 url = strchr(buf, ';');
679 sec = apr_pstrdup(r->pool, buf);
682 url = chxj_encoding_parameter(r, url);
683 url = chxj_add_cookie_parameter(r, url, chtml20->cookie);
713 * It is a handler who processes the META tag.
715 * @param pdoc [i/o] The pointer to the CHTML structure at the output
716 * destination is specified.
717 * @param node [i] The META tag node is specified.
718 * @return The conversion result is returned.
721 s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child))
725 chtml20 = GET_CHTML20(pdoc);
732 * It is a handler who processes the HEAD tag.
734 * @param pdoc [i/o] The pointer to the CHTML structure at the output
735 * destination is specified.
736 * @param node [i] The HEAD tag node is specified.
737 * @return The conversion result is returned.
740 s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node))
746 chtml20 = GET_CHTML20(pdoc);
756 * It is a handler who processes the HEAD tag.
758 * @param pdoc [i/o] The pointer to the CHTML structure at the output
759 * destination is specified.
760 * @param node [i] The HEAD tag node is specified.
761 * @return The conversion result is returned.
764 s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child))
770 chtml20 = GET_CHTML20(pdoc);
780 * It is a handler who processes the TITLE tag.
782 * @param pdoc [i/o] The pointer to the CHTML structure at the output
783 * destination is specified.
784 * @param node [i] The TITLE tag node is specified.
785 * @return The conversion result is returned.
788 s_chtml20_start_title_tag(void *pdoc, Node *UNUSED(node))
794 chtml20 = GET_CHTML20(pdoc);
804 * It is a handler who processes the TITLE tag.
806 * @param pdoc [i/o] The pointer to the CHTML structure at the output
807 * destination is specified.
808 * @param node [i] The TITLE tag node is specified.
809 * @return The conversion result is returned.
812 s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
818 chtml20 = GET_CHTML20(pdoc);
828 * It is a handler who processes the BASE tag.
830 * @param pdoc [i/o] The pointer to the CHTML structure at the output
831 * destination is specified.
832 * @param node [i] The BASE tag node is specified.
833 * @return The conversion result is returned.
836 s_chtml20_start_base_tag(void *pdoc, Node *node)
843 chtml20 = GET_CHTML20(pdoc);
848 /*--------------------------------------------------------------------------*/
850 /*--------------------------------------------------------------------------*/
851 for (attr = qs_get_attr(doc,node);
853 attr = qs_get_next_attr(doc,attr)) {
858 name = qs_get_attr_name(doc,attr);
859 value = qs_get_attr_value(doc,attr);
861 if (STRCASEEQ('h','H',"href", name)) {
873 * It is a handler who processes the BASE tag.
875 * @param pdoc [i/o] The pointer to the CHTML structure at the output
876 * destination is specified.
877 * @param node [i] The BASE tag node is specified.
878 * @return The conversion result is returned.
881 s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child))
887 chtml20 = GET_CHTML20(pdoc);
896 * It is a handler who processes the BODY tag.
898 * @param pdoc [i/o] The pointer to the CHTML structure at the output
899 * destination is specified.
900 * @param node [i] The BODY tag node is specified.
901 * @return The conversion result is returned.
904 s_chtml20_start_body_tag(void *pdoc, Node *node)
911 chtml20 = GET_CHTML20(pdoc);
916 /*--------------------------------------------------------------------------*/
918 /*--------------------------------------------------------------------------*/
919 for (attr = qs_get_attr(doc,node);
921 attr = qs_get_next_attr(doc,attr)) {
925 name = qs_get_attr_name(doc,attr);
926 value = qs_get_attr_value(doc,attr);
931 if (strcasecmp(name, "bgcolor") == 0 && value && *value != 0) {
932 /*----------------------------------------------------------------------*/
934 /*----------------------------------------------------------------------*/
943 if (strcasecmp(name, "text") == 0 && value && *value != 0) {
944 /*----------------------------------------------------------------------*/
946 /*----------------------------------------------------------------------*/
955 if (strcasecmp(name, "link") == 0 && value && *value != 0) {
956 /*----------------------------------------------------------------------*/
958 /*----------------------------------------------------------------------*/
967 if (strcasecmp(name, "alink") == 0) {
968 /*----------------------------------------------------------------------*/
970 /*----------------------------------------------------------------------*/
977 if (strcasecmp(name, "vlink") == 0) {
978 /*----------------------------------------------------------------------*/
980 /*----------------------------------------------------------------------*/
995 * It is a handler who processes the BODY tag.
997 * @param pdoc [i/o] The pointer to the CHTML structure at the output
998 * destination is specified.
999 * @param node [i] The BODY tag node is specified.
1000 * @return The conversion result is returned.
1003 s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child))
1009 chtml20 = GET_CHTML20(pdoc);
1014 return chtml20->out;
1019 * It is a handler who processes the A tag.
1021 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1022 * destination is specified.
1023 * @param node [i] The A tag node is specified.
1024 * @return The conversion result is returned.
1027 s_chtml20_start_a_tag(void *pdoc, Node *node)
1034 chtml20 = GET_CHTML20(pdoc);
1039 /*--------------------------------------------------------------------------*/
1040 /* Get Attributes */
1041 /*--------------------------------------------------------------------------*/
1042 for (attr = qs_get_attr(doc,node);
1044 attr = qs_get_next_attr(doc,attr)) {
1045 char *name = qs_get_attr_name(doc,attr);
1046 char *value = qs_get_attr_value(doc,attr);
1050 if (strcasecmp(name, "name") == 0) {
1051 /*--------------------------------------------------------------------*/
1053 /*--------------------------------------------------------------------*/
1062 if (strcasecmp(name, "href") == 0) {
1063 /*--------------------------------------------------------------------*/
1065 /*--------------------------------------------------------------------*/
1066 value = chxj_encoding_parameter(r, value);
1067 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1076 if (strcasecmp(name, "accesskey") == 0) {
1077 /*--------------------------------------------------------------------*/
1079 /*--------------------------------------------------------------------*/
1080 W_L(" accesskey=\"");
1088 if (strcasecmp(name, "cti") == 0) {
1089 /*--------------------------------------------------------------------*/
1091 /*--------------------------------------------------------------------*/
1100 if (strcasecmp(name, "ijam") == 0) {
1101 /*--------------------------------------------------------------------*/
1103 /*--------------------------------------------------------------------*/
1107 if (strcasecmp(name, "ista") == 0) {
1108 /*--------------------------------------------------------------------*/
1110 /*--------------------------------------------------------------------*/
1114 if (strcasecmp(name, "ilet") == 0) {
1115 /*--------------------------------------------------------------------*/
1117 /*--------------------------------------------------------------------*/
1121 if (strcasecmp(name, "iswf") == 0) {
1122 /*--------------------------------------------------------------------*/
1124 /*--------------------------------------------------------------------*/
1128 if (strcasecmp(name, "irst") == 0) {
1129 /*--------------------------------------------------------------------*/
1131 /*--------------------------------------------------------------------*/
1138 if (strcasecmp(name, "utn") == 0) {
1139 /*--------------------------------------------------------------------*/
1141 /*--------------------------------------------------------------------*/
1148 if (strcasecmp(name, "telbook") == 0) {
1149 /*--------------------------------------------------------------------*/
1151 /*--------------------------------------------------------------------*/
1158 if (strcasecmp(name, "kana") == 0) {
1159 /*--------------------------------------------------------------------*/
1161 /*--------------------------------------------------------------------*/
1168 if (strcasecmp(name, "email") == 0) {
1169 /*--------------------------------------------------------------------*/
1171 /*--------------------------------------------------------------------*/
1181 return chtml20->out;
1186 * It is a handler who processes the A tag.
1188 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1189 * destination is specified.
1190 * @param node [i] The A tag node is specified.
1191 * @return The conversion result is returned.
1194 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
1200 chtml20 = GET_CHTML20(pdoc);
1205 return chtml20->out;
1210 * It is a handler who processes the BR tag.
1212 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1213 * destination is specified.
1214 * @param node [i] The BR tag node is specified.
1215 * @return The conversion result is returned.
1218 s_chtml20_start_br_tag(void *pdoc, Node *node)
1225 chtml20 = GET_CHTML20(pdoc);
1230 /*--------------------------------------------------------------------------*/
1231 /* Get Attributes */
1232 /*--------------------------------------------------------------------------*/
1233 for (attr = qs_get_attr(doc,node);
1235 attr = qs_get_next_attr(doc,attr)) {
1239 name = qs_get_attr_name(doc,attr);
1240 value = qs_get_attr_value(doc,attr);
1242 if (STRCASEEQ('c','C',"clear",name)) {
1243 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1251 return chtml20->out;
1256 * It is a handler who processes the BR tag.
1258 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1259 * destination is specified.
1260 * @param node [i] The BR tag node is specified.
1261 * @return The conversion result is returned.
1264 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
1270 chtml20 = GET_CHTML20(pdoc);
1274 return chtml20->out;
1279 * It is a handler who processes the TR tag.
1281 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1282 * destination is specified.
1283 * @param node [i] The TR tag node is specified.
1284 * @return The conversion result is returned.
1287 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
1293 chtml20 = GET_CHTML20(pdoc);
1297 return chtml20->out;
1302 * It is a handler who processes the TR tag.
1304 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1305 * destination is specified.
1306 * @param node [i] The TR tag node is specified.
1307 * @return The conversion result is returned.
1310 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
1316 chtml20 = GET_CHTML20(pdoc);
1321 return chtml20->out;
1326 * It is a handler who processes the FONT tag.
1328 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1329 * destination is specified.
1330 * @param node [i] The FONT tag node is specified.
1331 * @return The conversion result is returned.
1334 s_chtml20_start_font_tag(void *pdoc, Node *node)
1341 chtml20 = GET_CHTML20(pdoc);
1347 /*--------------------------------------------------------------------------*/
1348 /* Get Attributes */
1349 /*--------------------------------------------------------------------------*/
1350 for (attr = qs_get_attr(doc,node);
1352 attr = qs_get_next_attr(doc,attr)) {
1357 name = qs_get_attr_name(doc,attr);
1358 value = qs_get_attr_value(doc,attr);
1363 if (strcasecmp(name, "color") == 0) {
1372 if (strcasecmp(name, "size") == 0) {
1373 /*--------------------------------------------------------------------*/
1375 /*--------------------------------------------------------------------*/
1385 return chtml20->out;
1390 * It is a handler who processes the FONT tag.
1392 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1393 * destination is specified.
1394 * @param node [i] The FONT tag node is specified.
1395 * @return The conversion result is returned.
1398 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child))
1404 chtml20 = GET_CHTML20(pdoc);
1409 return chtml20->out;
1414 * It is a handler who processes the FORM tag.
1416 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1417 * destination is specified.
1418 * @param node [i] The FORM tag node is specified.
1419 * @return The conversion result is returned.
1422 s_chtml20_start_form_tag(void *pdoc, Node *node)
1429 chtml20 = GET_CHTML20(pdoc);
1434 /*--------------------------------------------------------------------------*/
1435 /* Get Attributes */
1436 /*--------------------------------------------------------------------------*/
1437 for (attr = qs_get_attr(doc,node);
1439 attr = qs_get_next_attr(doc,attr)) {
1444 name = qs_get_attr_name(doc,attr);
1445 value = qs_get_attr_value(doc,attr);
1450 if (strcasecmp(name, "action") == 0) {
1451 /*--------------------------------------------------------------------*/
1453 /*--------------------------------------------------------------------*/
1454 value = chxj_encoding_parameter(r, value);
1455 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1465 if (strcasecmp(name, "method") == 0) {
1466 /*--------------------------------------------------------------------*/
1468 /*--------------------------------------------------------------------*/
1477 if (strcasecmp(name, "utn") == 0) {
1478 /*--------------------------------------------------------------------*/
1480 /*--------------------------------------------------------------------*/
1490 return chtml20->out;
1495 * It is a handler who processes the FORM tag.
1497 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1498 * destination is specified.
1499 * @param node [i] The FORM tag node is specified.
1500 * @return The conversion result is returned.
1503 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child))
1509 chtml20 = GET_CHTML20(pdoc);
1514 return chtml20->out;
1519 * It is a handler who processes the INPUT tag.
1521 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1522 * destination is specified.
1523 * @param node [i] The INPUT tag node is specified.
1524 * @return The conversion result is returned.
1527 s_chtml20_start_input_tag(void *pdoc, Node *node)
1532 char *max_length = NULL;
1536 char *istyle = NULL;
1538 char *checked = NULL;
1539 char *accesskey = NULL;
1541 chtml20 = GET_CHTML20(pdoc);
1547 /*--------------------------------------------------------------------------*/
1548 /* Get Attributes */
1549 /*--------------------------------------------------------------------------*/
1551 type = qs_get_type_attr(doc, node, r);
1552 name = qs_get_name_attr(doc, node, r);
1553 value = qs_get_value_attr(doc,node,r);
1554 istyle = qs_get_istyle_attr(doc,node,r);
1555 max_length = qs_get_maxlength_attr(doc,node,r);
1556 checked = qs_get_checked_attr(doc,node,r);
1557 accesskey = qs_get_accesskey_attr(doc, node, r);
1558 size = qs_get_size_attr(doc, node, r);
1561 type = qs_trim_string(doc->buf.pool, type);
1562 if (type && (STRCASEEQ('t','T',"text", type) ||
1563 STRCASEEQ('p','P',"password",type) ||
1564 STRCASEEQ('c','C',"checkbox",type) ||
1565 STRCASEEQ('r','R',"radio", type) ||
1566 STRCASEEQ('h','H',"hidden", type) ||
1567 STRCASEEQ('s','S',"submit", type) ||
1568 STRCASEEQ('r','R',"reset", type))) {
1574 if (size && *size) {
1579 if (name && *name) {
1584 if (value && *value) {
1589 if (accesskey && *accesskey) {
1590 W_L(" accesskey=\"");
1595 /*------------------------------------------------------------------------*/
1597 /*------------------------------------------------------------------------*/
1598 if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1605 /*--------------------------------------------------------------------------*/
1606 /* The figure is default for the password. */
1607 /*--------------------------------------------------------------------------*/
1608 if (max_length && *max_length) {
1609 if (chxj_chk_numeric(max_length) != 0) {
1610 max_length = apr_psprintf(doc->buf.pool, "0");
1612 if (istyle && *istyle == '1') {
1613 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1617 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1626 return chtml20->out;
1631 * It is a handler who processes the INPUT tag.
1633 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1634 * destination is specified.
1635 * @param node [i] The INPUT tag node is specified.
1636 * @return The conversion result is returned.
1639 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child))
1645 chtml20 = GET_CHTML20(pdoc);
1649 return chtml20->out;
1654 * It is a handler who processes the CENTER tag.
1656 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1657 * destination is specified.
1658 * @param node [i] The CENTER tag node is specified.
1659 * @return The conversion result is returned.
1662 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node))
1668 chtml20 = GET_CHTML20(pdoc);
1673 return chtml20->out;
1678 * It is a handler who processes the CENTER tag.
1680 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1681 * destination is specified.
1682 * @param node [i] The CENTER tag node is specified.
1683 * @return The conversion result is returned.
1686 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child))
1692 chtml20 = GET_CHTML20(pdoc);
1697 return chtml20->out;
1702 * It is a handler who processes the UL tag.
1704 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1705 * destination is specified.
1706 * @param node [i] The UL tag node is specified.
1707 * @return The conversion result is returned.
1710 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node))
1716 chtml20 = GET_CHTML20(pdoc);
1721 return chtml20->out;
1726 * It is a handler who processes the UL tag.
1728 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1729 * destination is specified.
1730 * @param node [i] The UL tag node is specified.
1731 * @return The conversion result is returned.
1734 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
1740 chtml20 = GET_CHTML20(pdoc);
1745 return chtml20->out;
1750 * It is a handler who processes the OL tag.
1752 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1753 * destination is specified.
1754 * @param node [i] The OL tag node is specified.
1755 * @return The conversion result is returned.
1758 s_chtml20_start_ol_tag(void *pdoc, Node *node)
1765 chtml20 = GET_CHTML20(pdoc);
1770 /*--------------------------------------------------------------------------*/
1771 /* Get Attributes */
1772 /*--------------------------------------------------------------------------*/
1773 for (attr = qs_get_attr(doc,node);
1775 attr = qs_get_next_attr(doc,attr)) {
1776 char *name = qs_get_attr_name(doc,attr);
1777 char *value = qs_get_attr_value(doc,attr);
1778 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1783 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1790 return chtml20->out;
1795 * It is a handler who processes the OL tag.
1797 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1798 * destination is specified.
1799 * @param node [i] The OL tag node is specified.
1800 * @return The conversion result is returned.
1803 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
1809 chtml20 = GET_CHTML20(pdoc);
1814 return chtml20->out;
1819 * It is a handler who processes the LI tag.
1821 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1822 * destination is specified.
1823 * @param node [i] The LI tag node is specified.
1824 * @return The conversion result is returned.
1827 s_chtml20_start_li_tag(void *pdoc, Node *node)
1834 chtml20 = GET_CHTML20(pdoc);
1839 /*--------------------------------------------------------------------------*/
1840 /* Get Attributes */
1841 /*--------------------------------------------------------------------------*/
1842 for (attr = qs_get_attr(doc,node);
1844 attr = qs_get_next_attr(doc,attr)) {
1845 char *name = qs_get_attr_name(doc,attr);
1846 char *value = qs_get_attr_value(doc,attr);
1847 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1852 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1859 return chtml20->out;
1864 * It is a handler who processes the LI tag.
1866 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1867 * destination is specified.
1868 * @param node [i] The LI tag node is specified.
1869 * @return The conversion result is returned.
1872 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
1874 chtml20_t *chtml20 = GET_CHTML20(pdoc);
1875 return chtml20->out;
1880 * It is a handler who processes the HR tag.
1882 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1883 * destination is specified.
1884 * @param node [i] The HR tag node is specified.
1885 * @return The conversion result is returned.
1888 s_chtml20_start_hr_tag(void *pdoc, Node *node)
1895 chtml20 = GET_CHTML20(pdoc);
1901 for (attr = qs_get_attr(doc,node);
1903 attr = qs_get_next_attr(doc,attr)) {
1908 name = qs_get_attr_name(doc,attr);
1909 value = qs_get_attr_value(doc,attr);
1914 if (strcasecmp(name, "align") == 0) {
1915 /*--------------------------------------------------------------------*/
1917 /*--------------------------------------------------------------------*/
1918 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1928 if (strcasecmp(name, "size") == 0) {
1929 /*--------------------------------------------------------------------*/
1931 /*--------------------------------------------------------------------*/
1932 if (value && value[0] != '\0') {
1942 if (strcasecmp(name, "width") == 0) {
1943 /*--------------------------------------------------------------------*/
1945 /*--------------------------------------------------------------------*/
1946 if (value && value[0] != '\0') {
1956 if (strcasecmp(name, "noshade") == 0) {
1957 /*--------------------------------------------------------------------*/
1959 /*--------------------------------------------------------------------*/
1966 if (strcasecmp(name, "color") == 0) {
1967 /*--------------------------------------------------------------------*/
1969 /*--------------------------------------------------------------------*/
1979 return chtml20->out;
1984 * It is a handler who processes the HR tag.
1986 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1987 * destination is specified.
1988 * @param node [i] The HR tag node is specified.
1989 * @return The conversion result is returned.
1992 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
1998 chtml20 = GET_CHTML20(pdoc);
2002 return chtml20->out;
2007 * It is a handler who processes the IMG tag.
2009 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2010 * destination is specified.
2011 * @param node [i] The IMG tag node is specified.
2012 * @return The conversion result is returned.
2015 s_chtml20_start_img_tag(void *pdoc, Node *node)
2021 #ifndef IMG_NOT_CONVERT_FILENAME
2025 chtml20 = GET_CHTML20(pdoc);
2029 #ifndef IMG_NOT_CONVERT_FILENAME
2030 spec = chtml20->spec;
2034 /*-------------------------------------------------------------------------*/
2035 /* Get Attributes */
2036 /*-------------------------------------------------------------------------*/
2037 for (attr = qs_get_attr(doc,node);
2039 attr = qs_get_next_attr(doc,attr)) {
2040 char *name = qs_get_attr_name(doc,attr);
2041 char *value = qs_get_attr_value(doc,attr);
2045 if (strcasecmp(name, "src") == 0) {
2046 /*-------------------------------------------------------------------*/
2048 /*-------------------------------------------------------------------*/
2049 #ifdef IMG_NOT_CONVERT_FILENAME
2050 value = chxj_encoding_parameter(r, value);
2051 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2053 value = apr_psprintf(doc->buf.pool,
2056 (strchr(value, '?')) ? '&' : '?',
2057 CHXJ_COOKIE_NOUPDATE_PARAM);
2063 value = chxj_img_conv(r, spec, value);
2064 value = chxj_encoding_parameter(r, value);
2065 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2067 value = apr_psprintf(doc->buf.pool,
2070 (strchr(value, '?')) ? '&' : '?',
2071 CHXJ_COOKIE_NOUPDATE_PARAM);
2082 if (strcasecmp(name, "align" ) == 0) {
2083 /*--------------------------------------------------------------------*/
2085 /*--------------------------------------------------------------------*/
2086 if (value && (STRCASEEQ('t','T',"top", value) ||
2087 STRCASEEQ('m','M',"middle",value) ||
2088 STRCASEEQ('b','B',"bottom",value) ||
2089 STRCASEEQ('l','L',"left", value) ||
2090 STRCASEEQ('r','R',"right", value))) {
2096 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2097 /*--------------------------------------------------------------------*/
2099 /*--------------------------------------------------------------------*/
2108 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2109 /*--------------------------------------------------------------------*/
2111 /*--------------------------------------------------------------------*/
2120 if (strcasecmp(name, "height") == 0 && value && *value) {
2121 /*--------------------------------------------------------------------*/
2123 /*--------------------------------------------------------------------*/
2128 else if (strcasecmp(name, "hspace") == 0 && value && *value) {
2129 /*--------------------------------------------------------------------*/
2131 /*--------------------------------------------------------------------*/
2140 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2141 /*--------------------------------------------------------------------*/
2143 /*--------------------------------------------------------------------*/
2155 return chtml20->out;
2160 * It is a handler who processes the IMG tag.
2162 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2163 * destination is specified.
2164 * @param node [i] The IMG tag node is specified.
2165 * @return The conversion result is returned.
2168 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
2174 chtml20 = GET_CHTML20(pdoc);
2178 return chtml20->out;
2183 * It is a handler who processes the SELECT tag.
2185 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2186 * destination is specified.
2187 * @param node [i] The SELECT tag node is specified.
2188 * @return The conversion result is returned.
2191 s_chtml20_start_select_tag(void *pdoc, Node *child)
2198 chtml20 = GET_CHTML20(pdoc);
2204 char *multiple = NULL;
2207 for (attr = qs_get_attr(doc,child);
2209 attr = qs_get_next_attr(doc,attr)) {
2210 char *nm = qs_get_attr_name(doc,attr);
2211 char *val = qs_get_attr_value(doc,attr);
2215 if (strcasecmp(nm, "size") == 0) {
2216 /*--------------------------------------------------------------------*/
2217 /* CHTML 1.0 version 2.0 */
2218 /*--------------------------------------------------------------------*/
2219 size = apr_pstrdup(doc->buf.pool, val);
2225 if (strcasecmp(nm, "name") == 0) {
2226 /*--------------------------------------------------------------------*/
2227 /* CHTML 1.0 version 2.0 */
2228 /*--------------------------------------------------------------------*/
2229 name = apr_pstrdup(doc->buf.pool, val);
2235 if (strcasecmp(nm, "multiple") == 0) {
2236 /*--------------------------------------------------------------------*/
2237 /* CHTML 1.0 version 2.0 */
2238 /*--------------------------------------------------------------------*/
2239 multiple = apr_pstrdup(doc->buf.pool, val);
2247 if (size && *size) {
2252 if (name && *name) {
2261 return chtml20->out;
2266 * It is a handler who processes the SELECT tag.
2268 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2269 * destination is specified.
2270 * @param node [i] The SELECT tag node is specified.
2271 * @return The conversion result is returned.
2274 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2280 chtml20 = GET_CHTML20(pdoc);
2285 return chtml20->out;
2290 * It is a handler who processes the OPTION tag.
2292 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2293 * destination is specified.
2294 * @param node [i] The OPTION tag node is specified.
2295 * @return The conversion result is returned.
2298 s_chtml20_start_option_tag(void *pdoc, Node *child)
2305 chtml20 = GET_CHTML20(pdoc);
2309 char *selected = NULL;
2313 for (attr = qs_get_attr(doc,child);
2315 attr = qs_get_next_attr(doc,attr)) {
2320 nm = qs_get_attr_name(doc,attr);
2321 val = qs_get_attr_value(doc,attr);
2326 if (strcasecmp(nm, "selected") == 0) {
2327 /*--------------------------------------------------------------------*/
2328 /* CHTML 1.0 version 2.0 */
2329 /*--------------------------------------------------------------------*/
2330 selected = apr_pstrdup(doc->buf.pool, val);
2336 if (strcasecmp(nm, "value") == 0) {
2337 /*--------------------------------------------------------------------*/
2338 /* CHTML 1.0 version 2.0 */
2339 /*--------------------------------------------------------------------*/
2340 value = apr_pstrdup(doc->buf.pool, val);
2349 if (value && *value) {
2359 return chtml20->out;
2364 * It is a handler who processes the OPTION tag.
2366 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2367 * destination is specified.
2368 * @param node [i] The OPTION tag node is specified.
2369 * @return The conversion result is returned.
2372 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2378 chtml20 = GET_CHTML20(pdoc);
2384 return chtml20->out;
2389 * It is a handler who processes the DIV tag.
2391 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2392 * destination is specified.
2393 * @param node [i] The DIV tag node is specified.
2394 * @return The conversion result is returned.
2397 s_chtml20_start_div_tag(void *pdoc, Node *child)
2404 chtml20 = GET_CHTML20(pdoc);
2412 for (attr = qs_get_attr(doc,child);
2414 attr = qs_get_next_attr(doc,attr)) {
2419 nm = qs_get_attr_name(doc,attr);
2420 val = qs_get_attr_value(doc,attr);
2422 if (STRCASEEQ('a','A', "align", nm)) {
2423 /*----------------------------------------------------------------------*/
2424 /* CHTML 1.0 (W3C version 3.2) */
2425 /*----------------------------------------------------------------------*/
2426 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2427 align = apr_pstrdup(doc->buf.pool, val);
2439 return chtml20->out;
2444 * It is a handler who processes the DIV tag.
2446 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2447 * destination is specified.
2448 * @param node [i] The DIV tag node is specified.
2449 * @return The conversion result is returned.
2452 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2458 chtml20 = GET_CHTML20(pdoc);
2463 return chtml20->out;
2468 * It is a handler who processes the H1 tag.
2470 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2471 * destination is specified.
2472 * @param node [i] The H1 tag node is specified.
2473 * @return The conversion result is returned.
2476 s_chtml20_start_h1_tag(void *pdoc, Node *node)
2483 chtml20 = GET_CHTML20(pdoc);
2488 for (attr = qs_get_attr(doc,node);
2490 attr = qs_get_next_attr(doc,attr)) {
2493 name = qs_get_attr_name(doc,attr);
2494 value = qs_get_attr_value(doc,attr);
2495 if (STRCASEEQ('a','A',"align", name)) {
2496 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2505 return chtml20->out;
2510 * It is a handler who processes the H1 tag.
2512 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2513 * destination is specified.
2514 * @param node [i] The H1 tag node is specified.
2515 * @return The conversion result is returned.
2518 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
2524 chtml20 = GET_CHTML20(pdoc);
2529 return chtml20->out;
2534 * It is a handler who processes the H2 tag.
2536 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2537 * destination is specified.
2538 * @param node [i] The H2 tag node is specified.
2539 * @return The conversion result is returned.
2542 s_chtml20_start_h2_tag(void *pdoc, Node *node)
2549 chtml20 = GET_CHTML20(pdoc);
2554 for (attr = qs_get_attr(doc,node);
2556 attr = qs_get_next_attr(doc,attr)) {
2559 name = qs_get_attr_name(doc,attr);
2560 value = qs_get_attr_value(doc,attr);
2561 if (STRCASEEQ('a','A',"align", name)) {
2562 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2571 return chtml20->out;
2576 * It is a handler who processes the H2 tag.
2578 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2579 * destination is specified.
2580 * @param node [i] The H2 tag node is specified.
2581 * @return The conversion result is returned.
2584 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
2590 chtml20 = GET_CHTML20(pdoc);
2595 return chtml20->out;
2600 * It is a handler who processes the H3 tag.
2602 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2603 * destination is specified.
2604 * @param node [i] The H3 tag node is specified.
2605 * @return The conversion result is returned.
2608 s_chtml20_start_h3_tag(void *pdoc, Node *node)
2615 chtml20 = GET_CHTML20(pdoc);
2620 for (attr = qs_get_attr(doc,node);
2622 attr = qs_get_next_attr(doc,attr)) {
2625 name = qs_get_attr_name(doc,attr);
2626 value = qs_get_attr_value(doc,attr);
2627 if (STRCASEEQ('a','A',"align", name)) {
2628 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2637 return chtml20->out;
2642 * It is a handler who processes the H3 tag.
2644 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2645 * destination is specified.
2646 * @param node [i] The H3 tag node is specified.
2647 * @return The conversion result is returned.
2650 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
2656 chtml20 = GET_CHTML20(pdoc);
2661 return chtml20->out;
2666 * It is a handler who processes the H4 tag.
2668 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2669 * destination is specified.
2670 * @param node [i] The H4 tag node is specified.
2671 * @return The conversion result is returned.
2674 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2681 chtml20 = GET_CHTML20(pdoc);
2686 for (attr = qs_get_attr(doc,node);
2688 attr = qs_get_next_attr(doc,attr)) {
2691 name = qs_get_attr_name(doc,attr);
2692 value = qs_get_attr_value(doc,attr);
2693 if (STRCASEEQ('a','A',"align", name)) {
2694 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2703 return chtml20->out;
2708 * It is a handler who processes the H4 tag.
2710 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2711 * destination is specified.
2712 * @param node [i] The H4 tag node is specified.
2713 * @return The conversion result is returned.
2716 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
2722 chtml20 = GET_CHTML20(pdoc);
2727 return chtml20->out;
2732 * It is a handler who processes the H5 tag.
2734 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2735 * destination is specified.
2736 * @param node [i] The H5 tag node is specified.
2737 * @return The conversion result is returned.
2740 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2747 chtml20 = GET_CHTML20(pdoc);
2752 for (attr = qs_get_attr(doc,node);
2754 attr = qs_get_next_attr(doc,attr)) {
2757 name = qs_get_attr_name(doc,attr);
2758 value = qs_get_attr_value(doc,attr);
2759 if (STRCASEEQ('a','A',"align", name)) {
2760 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2769 return chtml20->out;
2774 * It is a handler who processes the H5 tag.
2776 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2777 * destination is specified.
2778 * @param node [i] The H5 tag node is specified.
2779 * @return The conversion result is returned.
2782 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
2788 chtml20 = GET_CHTML20(pdoc);
2793 return chtml20->out;
2798 * It is a handler who processes the H6 tag.
2800 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2801 * destination is specified.
2802 * @param node [i] The H6 tag node is specified.
2803 * @return The conversion result is returned.
2806 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2813 chtml20 = GET_CHTML20(pdoc);
2818 for (attr = qs_get_attr(doc,node);
2820 attr = qs_get_next_attr(doc,attr)) {
2823 name = qs_get_attr_name(doc,attr);
2824 value = qs_get_attr_value(doc,attr);
2825 if (STRCASEEQ('a','A',"align", name)) {
2826 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2835 return chtml20->out;
2840 * It is a handler who processes the H6 tag.
2842 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2843 * destination is specified.
2844 * @param node [i] The H6 tag node is specified.
2845 * @return The conversion result is returned.
2848 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
2854 chtml20 = GET_CHTML20(pdoc);
2859 return chtml20->out;
2864 * It is a handler who processes the PRE tag.
2866 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2867 * destination is specified.
2868 * @param node [i] The PRE tag node is specified.
2869 * @return The conversion result is returned.
2872 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node))
2878 chtml20 = GET_CHTML20(pdoc);
2882 chtml20->pre_flag++;
2884 return chtml20->out;
2889 * It is a handler who processes the PRE tag.
2891 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2892 * destination is specified.
2893 * @param node [i] The PRE tag node is specified.
2894 * @return The conversion result is returned.
2897 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
2903 chtml20 = GET_CHTML20(pdoc);
2908 chtml20->pre_flag--;
2910 return chtml20->out;
2915 * It is a handler who processes the P tag.
2917 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2918 * destination is specified.
2919 * @param node [i] The P tag node is specified.
2920 * @return The conversion result is returned.
2923 s_chtml20_start_p_tag(void *pdoc, Node *node)
2931 chtml20 = GET_CHTML20(pdoc);
2936 for (attr = qs_get_attr(doc,node);
2938 attr = qs_get_next_attr(doc,attr)) {
2939 char *nm = qs_get_attr_name(doc,attr);
2940 char *val = qs_get_attr_value(doc,attr);
2941 if (STRCASEEQ('a','A',"align", nm)) {
2942 /*----------------------------------------------------------------------*/
2943 /* CHTML 1.0 (W3C version 3.2) */
2944 /*----------------------------------------------------------------------*/
2945 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2946 align = apr_pstrdup(doc->buf.pool, val);
2957 return chtml20->out;
2962 * It is a handler who processes the P tag.
2964 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2965 * destination is specified.
2966 * @param node [i] The P tag node is specified.
2967 * @return The conversion result is returned.
2970 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child))
2976 chtml20 = GET_CHTML20(pdoc);
2981 return chtml20->out;
2986 s_chtml20_chxjif_tag(void *pdoc, Node *node)
2993 chtml20 = GET_CHTML20(pdoc);
2997 for (child = qs_get_child_node(doc, node);
2999 child = qs_get_next_node(doc, child)) {
3002 s_chtml20_chxjif_tag(pdoc, child);
3010 * It is a handler who processes the TEXTARE tag.
3012 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3013 * destination is specified.
3014 * @param node [i] The TEXTAREA tag node is specified.
3015 * @return The conversion result is returned.
3018 s_chtml20_start_textarea_tag(void *pdoc, Node *node)
3025 chtml20 = GET_CHTML20(pdoc);
3029 chtml20->textarea_flag++;
3031 for (attr = qs_get_attr(doc,node);
3033 attr = qs_get_next_attr(doc,attr)) {
3034 char *name = qs_get_attr_name(doc,attr);
3035 char *value = qs_get_attr_value(doc,attr);
3039 if (strcasecmp(name, "accesskey") == 0 && value && *value != 0) {
3040 W_L(" accesskey=\"");
3048 if (strcasecmp(name, "name") == 0 && value && *value != 0) {
3057 if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
3066 if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
3075 if (strcasecmp(name, "istyle") == 0 && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3087 return chtml20->out;
3092 * It is a handler who processes the TEXTAREA tag.
3094 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3095 * destination is specified.
3096 * @param node [i] The TEXTAREA tag node is specified.
3097 * @return The conversion result is returned.
3100 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3106 chtml20 = GET_CHTML20(pdoc);
3111 chtml20->textarea_flag--;
3113 return chtml20->out;
3118 s_chtml20_text_tag(void *pdoc, Node *child)
3130 chtml20 = GET_CHTML20(pdoc);
3134 textval = qs_get_node_value(doc,child);
3135 if (strlen(textval) == 0) {
3136 return chtml20->out;
3139 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3140 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3142 tdst = qs_alloc_zero_byte_string(r);
3143 memset(one_byte, 0, sizeof(one_byte));
3146 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3148 int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3150 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3154 if (is_sjis_kanji(textval[ii])) {
3155 one_byte[0] = textval[ii+0];
3156 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3157 one_byte[0] = textval[ii+1];
3158 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3162 if (chtml20->pre_flag) {
3163 one_byte[0] = textval[ii+0];
3164 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3167 if (chtml20->textarea_flag) {
3168 one_byte[0] = textval[ii+0];
3169 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3172 if (textval[ii] != '\r' && textval[ii] != '\n') {
3173 one_byte[0] = textval[ii+0];
3174 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3178 return chtml20->out;
3183 * It is a handler who processes the BLOCKQUOTE tag.
3185 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3186 * destination is specified.
3187 * @param node [i] The BLOCKQUOTE tag node is specified.
3188 * @return The conversion result is returned.
3191 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3195 chtml20 = GET_CHTML20(pdoc);
3197 W_L("<blockquote>");
3198 return chtml20->out;
3203 * It is a handler who processes the BLOCKQUOTE tag.
3205 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3206 * destination is specified.
3207 * @param node [i] The BLOCKQUOTE tag node is specified.
3208 * @return The conversion result is returned.
3211 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3216 chtml20 = GET_CHTML20(pdoc);
3218 W_L("</blockquote>");
3219 return chtml20->out;
3224 * It is a handler who processes the DIR tag.
3226 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3227 * destination is specified.
3228 * @param node [i] The DIR tag node is specified.
3229 * @return The conversion result is returned.
3232 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3236 chtml20 = GET_CHTML20(pdoc);
3239 return chtml20->out;
3244 * It is a handler who processes the DIR tag.
3246 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3247 * destination is specified.
3248 * @param node [i] The DIR tag node is specified.
3249 * @return The conversion result is returned.
3252 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3257 chtml20 = GET_CHTML20(pdoc);
3260 return chtml20->out;
3265 * It is a handler who processes the DL tag.
3267 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3268 * destination is specified.
3269 * @param node [i] The DL tag node is specified.
3270 * @return The conversion result is returned.
3273 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3277 chtml20 = GET_CHTML20(pdoc);
3280 return chtml20->out;
3285 * It is a handler who processes the DL tag.
3287 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3288 * destination is specified.
3289 * @param node [i] The DL tag node is specified.
3290 * @return The conversion result is returned.
3293 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3297 chtml20 = GET_CHTML20(pdoc);
3300 return chtml20->out;
3305 * It is a handter who processes the DT tag.
3307 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3308 * destination is specified.
3309 * @param node [i] The DT tag node is specified.
3310 * @return The conversion result is returned.
3313 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3317 chtml20 = GET_CHTML20(pdoc);
3320 return chtml20->out;
3325 * It is a handter who processes the DT tag.
3327 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3328 * destination is specified.
3329 * @param node [i] The DT tag node is specified.
3330 * @return The conversion result is returned.
3333 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3336 chtml20 = GET_CHTML20(pdoc);
3337 return chtml20->out;
3342 * It is a handder who processes the DD tag.
3344 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3345 * destination is specified.
3346 * @param node [i] The DD tag node is specified.
3347 * @return The conversion result is returned.
3350 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3354 chtml20 = GET_CHTML20(pdoc);
3357 return chtml20->out;
3362 * It is a handder who processes the DD tag.
3364 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3365 * destination is specified.
3366 * @param node [i] The DD tag node is specified.
3367 * @return The conversion result is returned.
3370 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
3373 chtml20 = GET_CHTML20(pdoc);
3374 return chtml20->out;
3379 * It is a hanmenuer who processes the MENU tag.
3381 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3382 * destination is specified.
3383 * @param node [i] The MENU tag node is specified.
3384 * @return The conversion result is returned.
3387 s_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
3391 chtml20 = GET_CHTML20(pdoc);
3394 return chtml20->out;
3399 * It is a hanmenuer who processes the MENU tag.
3401 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3402 * destination is specified.
3403 * @param node [i] The MENU tag node is specified.
3404 * @return The conversion result is returned.
3407 s_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
3409 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3410 Doc *doc = chtml20->doc;
3412 return chtml20->out;
3417 * It is a hanplaintexter who processes the PLAINTEXT tag.
3419 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3420 * destination is specified.
3421 * @param node [i] The PLAINTEXT tag node is specified.
3422 * @return The conversion result is returned.
3425 s_chtml20_start_plaintext_tag(void *pdoc, Node *node)
3430 chtml20 = GET_CHTML20(pdoc);
3433 s_chtml20_start_plaintext_tag_inner(pdoc,node);
3434 return chtml20->out;
3438 s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
3443 chtml20 = GET_CHTML20(pdoc);
3445 for (child = qs_get_child_node(doc, node);
3447 child = qs_get_next_node(doc, child)) {
3449 s_chtml20_start_plaintext_tag_inner(pdoc, child);
3451 return chtml20->out;
3456 * It is a hanplaintexter who processes the PLAINTEXT tag.
3458 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3459 * destination is specified.
3460 * @param node [i] The PLAINTEXT tag node is specified.
3461 * @return The conversion result is returned.
3464 s_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3466 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3467 return chtml20->out;
3471 * It is a hanblinker who processes the BLINK tag.
3473 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3474 * destination is specified.
3475 * @param node [i] The BLINK tag node is specified.
3476 * @return The conversion result is returned.
3479 s_chtml20_start_blink_tag(void *pdoc, Node *UNUSED(child))
3481 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3482 Doc *doc = chtml20->doc;
3484 return chtml20->out;
3489 * It is a hanblinker who processes the BLINK tag.
3491 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3492 * destination is specified.
3493 * @param node [i] The BLINK tag node is specified.
3494 * @return The conversion result is returned.
3497 s_chtml20_end_blink_tag(void *pdoc, Node *UNUSED(child))
3499 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3500 Doc *doc = chtml20->doc;
3502 return chtml20->out;
3507 * It is a hanmarqueeer who processes the MARQUEE tag.
3509 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3510 * destination is specified.
3511 * @param node [i] The MARQUEE tag node is specified.
3512 * @return The conversion result is returned.
3515 s_chtml20_start_marquee_tag(void *pdoc, Node *node)
3517 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3518 Doc *doc = chtml20->doc;
3521 /*--------------------------------------------------------------------------*/
3522 /* Get Attributes */
3523 /*--------------------------------------------------------------------------*/
3524 for (attr = qs_get_attr(doc,node);
3526 attr = qs_get_next_attr(doc,attr)) {
3527 char *name = qs_get_attr_name(doc,attr);
3528 char *value = qs_get_attr_value(doc,attr);
3529 if (STRCASEEQ('d','D',"direction", name)) {
3530 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3531 W_L(" direction=\"");
3536 else if (STRCASEEQ('b','B',"behavior",name)) {
3537 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3538 W_L(" behavior=\"");
3543 else if (STRCASEEQ('l','L',"loop",name)) {
3544 if (value && *value) {
3552 return chtml20->out;
3557 * It is a hanmarqueeer who processes the MARQUEE tag.
3559 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3560 * destination is specified.
3561 * @param node [i] The MARQUEE tag node is specified.
3562 * @return The conversion result is returned.
3565 s_chtml20_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3567 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3568 Doc *doc = chtml20->doc;
3570 return chtml20->out;