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)) {
1049 name = qs_get_attr_name(doc,attr);
1050 value = qs_get_attr_value(doc,attr);
1055 if (strcasecmp(name, "name") == 0) {
1056 /*--------------------------------------------------------------------*/
1058 /*--------------------------------------------------------------------*/
1067 if (strcasecmp(name, "href") == 0) {
1068 /*--------------------------------------------------------------------*/
1070 /*--------------------------------------------------------------------*/
1071 value = chxj_encoding_parameter(r, value);
1072 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1081 if (strcasecmp(name, "accesskey") == 0) {
1082 /*--------------------------------------------------------------------*/
1084 /*--------------------------------------------------------------------*/
1085 W_L(" accesskey=\"");
1093 if (strcasecmp(name, "cti") == 0) {
1094 /*--------------------------------------------------------------------*/
1096 /*--------------------------------------------------------------------*/
1105 if (strcasecmp(name, "ijam") == 0) {
1106 /*--------------------------------------------------------------------*/
1108 /*--------------------------------------------------------------------*/
1112 if (strcasecmp(name, "ista") == 0) {
1113 /*--------------------------------------------------------------------*/
1115 /*--------------------------------------------------------------------*/
1119 if (strcasecmp(name, "ilet") == 0) {
1120 /*--------------------------------------------------------------------*/
1122 /*--------------------------------------------------------------------*/
1126 if (strcasecmp(name, "iswf") == 0) {
1127 /*--------------------------------------------------------------------*/
1129 /*--------------------------------------------------------------------*/
1133 if (strcasecmp(name, "irst") == 0) {
1134 /*--------------------------------------------------------------------*/
1136 /*--------------------------------------------------------------------*/
1143 if (strcasecmp(name, "utn") == 0) {
1144 /*--------------------------------------------------------------------*/
1146 /*--------------------------------------------------------------------*/
1153 if (strcasecmp(name, "telbook") == 0) {
1154 /*--------------------------------------------------------------------*/
1156 /*--------------------------------------------------------------------*/
1163 if (strcasecmp(name, "kana") == 0) {
1164 /*--------------------------------------------------------------------*/
1166 /*--------------------------------------------------------------------*/
1173 if (strcasecmp(name, "email") == 0) {
1174 /*--------------------------------------------------------------------*/
1176 /*--------------------------------------------------------------------*/
1186 return chtml20->out;
1191 * It is a handler who processes the A tag.
1193 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1194 * destination is specified.
1195 * @param node [i] The A tag node is specified.
1196 * @return The conversion result is returned.
1199 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
1205 chtml20 = GET_CHTML20(pdoc);
1210 return chtml20->out;
1215 * It is a handler who processes the BR tag.
1217 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1218 * destination is specified.
1219 * @param node [i] The BR tag node is specified.
1220 * @return The conversion result is returned.
1223 s_chtml20_start_br_tag(void *pdoc, Node *node)
1230 chtml20 = GET_CHTML20(pdoc);
1235 /*--------------------------------------------------------------------------*/
1236 /* Get Attributes */
1237 /*--------------------------------------------------------------------------*/
1238 for (attr = qs_get_attr(doc,node);
1240 attr = qs_get_next_attr(doc,attr)) {
1244 name = qs_get_attr_name(doc,attr);
1245 value = qs_get_attr_value(doc,attr);
1247 if (STRCASEEQ('c','C',"clear",name)) {
1248 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1256 return chtml20->out;
1261 * It is a handler who processes the BR tag.
1263 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1264 * destination is specified.
1265 * @param node [i] The BR tag node is specified.
1266 * @return The conversion result is returned.
1269 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
1275 chtml20 = GET_CHTML20(pdoc);
1279 return chtml20->out;
1284 * It is a handler who processes the TR tag.
1286 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1287 * destination is specified.
1288 * @param node [i] The TR tag node is specified.
1289 * @return The conversion result is returned.
1292 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
1298 chtml20 = GET_CHTML20(pdoc);
1302 return chtml20->out;
1307 * It is a handler who processes the TR tag.
1309 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1310 * destination is specified.
1311 * @param node [i] The TR tag node is specified.
1312 * @return The conversion result is returned.
1315 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
1321 chtml20 = GET_CHTML20(pdoc);
1326 return chtml20->out;
1331 * It is a handler who processes the FONT tag.
1333 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1334 * destination is specified.
1335 * @param node [i] The FONT tag node is specified.
1336 * @return The conversion result is returned.
1339 s_chtml20_start_font_tag(void *pdoc, Node *node)
1346 chtml20 = GET_CHTML20(pdoc);
1352 /*--------------------------------------------------------------------------*/
1353 /* Get Attributes */
1354 /*--------------------------------------------------------------------------*/
1355 for (attr = qs_get_attr(doc,node);
1357 attr = qs_get_next_attr(doc,attr)) {
1362 name = qs_get_attr_name(doc,attr);
1363 value = qs_get_attr_value(doc,attr);
1368 if (strcasecmp(name, "color") == 0) {
1377 if (strcasecmp(name, "size") == 0) {
1378 /*--------------------------------------------------------------------*/
1380 /*--------------------------------------------------------------------*/
1390 return chtml20->out;
1395 * It is a handler who processes the FONT tag.
1397 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1398 * destination is specified.
1399 * @param node [i] The FONT tag node is specified.
1400 * @return The conversion result is returned.
1403 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child))
1409 chtml20 = GET_CHTML20(pdoc);
1414 return chtml20->out;
1419 * It is a handler who processes the FORM tag.
1421 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1422 * destination is specified.
1423 * @param node [i] The FORM tag node is specified.
1424 * @return The conversion result is returned.
1427 s_chtml20_start_form_tag(void *pdoc, Node *node)
1434 chtml20 = GET_CHTML20(pdoc);
1439 /*--------------------------------------------------------------------------*/
1440 /* Get Attributes */
1441 /*--------------------------------------------------------------------------*/
1442 for (attr = qs_get_attr(doc,node);
1444 attr = qs_get_next_attr(doc,attr)) {
1449 name = qs_get_attr_name(doc,attr);
1450 value = qs_get_attr_value(doc,attr);
1455 if (strcasecmp(name, "action") == 0) {
1456 /*--------------------------------------------------------------------*/
1458 /*--------------------------------------------------------------------*/
1459 value = chxj_encoding_parameter(r, value);
1460 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1470 if (strcasecmp(name, "method") == 0) {
1471 /*--------------------------------------------------------------------*/
1473 /*--------------------------------------------------------------------*/
1482 if (strcasecmp(name, "utn") == 0) {
1483 /*--------------------------------------------------------------------*/
1485 /*--------------------------------------------------------------------*/
1495 return chtml20->out;
1500 * It is a handler who processes the FORM tag.
1502 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1503 * destination is specified.
1504 * @param node [i] The FORM tag node is specified.
1505 * @return The conversion result is returned.
1508 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child))
1514 chtml20 = GET_CHTML20(pdoc);
1519 return chtml20->out;
1524 * It is a handler who processes the INPUT tag.
1526 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1527 * destination is specified.
1528 * @param node [i] The INPUT tag node is specified.
1529 * @return The conversion result is returned.
1532 s_chtml20_start_input_tag(void *pdoc, Node *node)
1537 char *max_length = NULL;
1541 char *istyle = NULL;
1543 char *checked = NULL;
1544 char *accesskey = NULL;
1546 chtml20 = GET_CHTML20(pdoc);
1552 /*--------------------------------------------------------------------------*/
1553 /* Get Attributes */
1554 /*--------------------------------------------------------------------------*/
1556 type = qs_get_type_attr(doc, node, r);
1557 name = qs_get_name_attr(doc, node, r);
1558 value = qs_get_value_attr(doc,node,r);
1559 istyle = qs_get_istyle_attr(doc,node,r);
1560 max_length = qs_get_maxlength_attr(doc,node,r);
1561 checked = qs_get_checked_attr(doc,node,r);
1562 accesskey = qs_get_accesskey_attr(doc, node, r);
1563 size = qs_get_size_attr(doc, node, r);
1566 type = qs_trim_string(doc->buf.pool, type);
1567 if (type && (STRCASEEQ('t','T',"text", type) ||
1568 STRCASEEQ('p','P',"password",type) ||
1569 STRCASEEQ('c','C',"checkbox",type) ||
1570 STRCASEEQ('r','R',"radio", type) ||
1571 STRCASEEQ('h','H',"hidden", type) ||
1572 STRCASEEQ('s','S',"submit", type) ||
1573 STRCASEEQ('r','R',"reset", type))) {
1579 if (size && *size) {
1584 if (name && *name) {
1589 if (value && *value) {
1594 if (accesskey && *accesskey) {
1595 W_L(" accesskey=\"");
1600 /*------------------------------------------------------------------------*/
1602 /*------------------------------------------------------------------------*/
1603 if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1610 /*--------------------------------------------------------------------------*/
1611 /* The figure is default for the password. */
1612 /*--------------------------------------------------------------------------*/
1613 if (max_length && *max_length) {
1614 if (chxj_chk_numeric(max_length) != 0) {
1615 max_length = apr_psprintf(doc->buf.pool, "0");
1617 if (istyle && *istyle == '1') {
1618 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1622 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1631 return chtml20->out;
1636 * It is a handler who processes the INPUT tag.
1638 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1639 * destination is specified.
1640 * @param node [i] The INPUT tag node is specified.
1641 * @return The conversion result is returned.
1644 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child))
1650 chtml20 = GET_CHTML20(pdoc);
1654 return chtml20->out;
1659 * It is a handler who processes the CENTER tag.
1661 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1662 * destination is specified.
1663 * @param node [i] The CENTER tag node is specified.
1664 * @return The conversion result is returned.
1667 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node))
1673 chtml20 = GET_CHTML20(pdoc);
1678 return chtml20->out;
1683 * It is a handler who processes the CENTER tag.
1685 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1686 * destination is specified.
1687 * @param node [i] The CENTER tag node is specified.
1688 * @return The conversion result is returned.
1691 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child))
1697 chtml20 = GET_CHTML20(pdoc);
1702 return chtml20->out;
1707 * It is a handler who processes the UL tag.
1709 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1710 * destination is specified.
1711 * @param node [i] The UL tag node is specified.
1712 * @return The conversion result is returned.
1715 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node))
1721 chtml20 = GET_CHTML20(pdoc);
1726 return chtml20->out;
1731 * It is a handler who processes the UL tag.
1733 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1734 * destination is specified.
1735 * @param node [i] The UL tag node is specified.
1736 * @return The conversion result is returned.
1739 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
1745 chtml20 = GET_CHTML20(pdoc);
1750 return chtml20->out;
1755 * It is a handler who processes the OL tag.
1757 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1758 * destination is specified.
1759 * @param node [i] The OL tag node is specified.
1760 * @return The conversion result is returned.
1763 s_chtml20_start_ol_tag(void *pdoc, Node *node)
1770 chtml20 = GET_CHTML20(pdoc);
1775 /*--------------------------------------------------------------------------*/
1776 /* Get Attributes */
1777 /*--------------------------------------------------------------------------*/
1778 for (attr = qs_get_attr(doc,node);
1780 attr = qs_get_next_attr(doc,attr)) {
1781 char *name = qs_get_attr_name(doc,attr);
1782 char *value = qs_get_attr_value(doc,attr);
1783 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1788 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1795 return chtml20->out;
1800 * It is a handler who processes the OL tag.
1802 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1803 * destination is specified.
1804 * @param node [i] The OL tag node is specified.
1805 * @return The conversion result is returned.
1808 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
1814 chtml20 = GET_CHTML20(pdoc);
1819 return chtml20->out;
1824 * It is a handler who processes the LI tag.
1826 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1827 * destination is specified.
1828 * @param node [i] The LI tag node is specified.
1829 * @return The conversion result is returned.
1832 s_chtml20_start_li_tag(void *pdoc, Node *node)
1839 chtml20 = GET_CHTML20(pdoc);
1844 /*--------------------------------------------------------------------------*/
1845 /* Get Attributes */
1846 /*--------------------------------------------------------------------------*/
1847 for (attr = qs_get_attr(doc,node);
1849 attr = qs_get_next_attr(doc,attr)) {
1850 char *name = qs_get_attr_name(doc,attr);
1851 char *value = qs_get_attr_value(doc,attr);
1852 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1857 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1864 return chtml20->out;
1869 * It is a handler who processes the LI tag.
1871 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1872 * destination is specified.
1873 * @param node [i] The LI tag node is specified.
1874 * @return The conversion result is returned.
1877 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
1879 chtml20_t *chtml20 = GET_CHTML20(pdoc);
1880 return chtml20->out;
1885 * It is a handler who processes the HR tag.
1887 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1888 * destination is specified.
1889 * @param node [i] The HR tag node is specified.
1890 * @return The conversion result is returned.
1893 s_chtml20_start_hr_tag(void *pdoc, Node *node)
1900 chtml20 = GET_CHTML20(pdoc);
1906 for (attr = qs_get_attr(doc,node);
1908 attr = qs_get_next_attr(doc,attr)) {
1913 name = qs_get_attr_name(doc,attr);
1914 value = qs_get_attr_value(doc,attr);
1919 if (strcasecmp(name, "align") == 0) {
1920 /*--------------------------------------------------------------------*/
1922 /*--------------------------------------------------------------------*/
1923 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1933 if (strcasecmp(name, "size") == 0) {
1934 /*--------------------------------------------------------------------*/
1936 /*--------------------------------------------------------------------*/
1937 if (value && value[0] != '\0') {
1947 if (strcasecmp(name, "width") == 0) {
1948 /*--------------------------------------------------------------------*/
1950 /*--------------------------------------------------------------------*/
1951 if (value && value[0] != '\0') {
1961 if (strcasecmp(name, "noshade") == 0) {
1962 /*--------------------------------------------------------------------*/
1964 /*--------------------------------------------------------------------*/
1971 if (strcasecmp(name, "color") == 0) {
1972 /*--------------------------------------------------------------------*/
1974 /*--------------------------------------------------------------------*/
1984 return chtml20->out;
1989 * It is a handler who processes the HR tag.
1991 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1992 * destination is specified.
1993 * @param node [i] The HR tag node is specified.
1994 * @return The conversion result is returned.
1997 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
2003 chtml20 = GET_CHTML20(pdoc);
2007 return chtml20->out;
2012 * It is a handler who processes the IMG tag.
2014 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2015 * destination is specified.
2016 * @param node [i] The IMG tag node is specified.
2017 * @return The conversion result is returned.
2020 s_chtml20_start_img_tag(void *pdoc, Node *node)
2026 #ifndef IMG_NOT_CONVERT_FILENAME
2030 chtml20 = GET_CHTML20(pdoc);
2034 #ifndef IMG_NOT_CONVERT_FILENAME
2035 spec = chtml20->spec;
2039 /*-------------------------------------------------------------------------*/
2040 /* Get Attributes */
2041 /*-------------------------------------------------------------------------*/
2042 for (attr = qs_get_attr(doc,node);
2044 attr = qs_get_next_attr(doc,attr)) {
2045 char *name = qs_get_attr_name(doc,attr);
2046 char *value = qs_get_attr_value(doc,attr);
2050 if (strcasecmp(name, "src") == 0) {
2051 /*-------------------------------------------------------------------*/
2053 /*-------------------------------------------------------------------*/
2054 #ifdef IMG_NOT_CONVERT_FILENAME
2055 value = chxj_encoding_parameter(r, value);
2056 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2058 value = apr_psprintf(doc->buf.pool,
2061 (strchr(value, '?')) ? '&' : '?',
2062 CHXJ_COOKIE_NOUPDATE_PARAM);
2068 value = chxj_img_conv(r, spec, value);
2069 value = chxj_encoding_parameter(r, value);
2070 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2072 value = apr_psprintf(doc->buf.pool,
2075 (strchr(value, '?')) ? '&' : '?',
2076 CHXJ_COOKIE_NOUPDATE_PARAM);
2087 if (strcasecmp(name, "align" ) == 0) {
2088 /*--------------------------------------------------------------------*/
2090 /*--------------------------------------------------------------------*/
2091 if (value && (STRCASEEQ('t','T',"top", value) ||
2092 STRCASEEQ('m','M',"middle",value) ||
2093 STRCASEEQ('b','B',"bottom",value) ||
2094 STRCASEEQ('l','L',"left", value) ||
2095 STRCASEEQ('r','R',"right", value))) {
2101 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2102 /*--------------------------------------------------------------------*/
2104 /*--------------------------------------------------------------------*/
2113 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2114 /*--------------------------------------------------------------------*/
2116 /*--------------------------------------------------------------------*/
2125 if (strcasecmp(name, "height") == 0 && value && *value) {
2126 /*--------------------------------------------------------------------*/
2128 /*--------------------------------------------------------------------*/
2133 else if (strcasecmp(name, "hspace") == 0 && value && *value) {
2134 /*--------------------------------------------------------------------*/
2136 /*--------------------------------------------------------------------*/
2145 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2146 /*--------------------------------------------------------------------*/
2148 /*--------------------------------------------------------------------*/
2160 return chtml20->out;
2165 * It is a handler who processes the IMG tag.
2167 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2168 * destination is specified.
2169 * @param node [i] The IMG tag node is specified.
2170 * @return The conversion result is returned.
2173 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
2179 chtml20 = GET_CHTML20(pdoc);
2183 return chtml20->out;
2188 * It is a handler who processes the SELECT tag.
2190 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2191 * destination is specified.
2192 * @param node [i] The SELECT tag node is specified.
2193 * @return The conversion result is returned.
2196 s_chtml20_start_select_tag(void *pdoc, Node *child)
2203 chtml20 = GET_CHTML20(pdoc);
2209 char *multiple = NULL;
2212 for (attr = qs_get_attr(doc,child);
2214 attr = qs_get_next_attr(doc,attr)) {
2215 char *nm = qs_get_attr_name(doc,attr);
2216 char *val = qs_get_attr_value(doc,attr);
2220 if (strcasecmp(nm, "size") == 0) {
2221 /*--------------------------------------------------------------------*/
2222 /* CHTML 1.0 version 2.0 */
2223 /*--------------------------------------------------------------------*/
2224 size = apr_pstrdup(doc->buf.pool, val);
2230 if (strcasecmp(nm, "name") == 0) {
2231 /*--------------------------------------------------------------------*/
2232 /* CHTML 1.0 version 2.0 */
2233 /*--------------------------------------------------------------------*/
2234 name = apr_pstrdup(doc->buf.pool, val);
2240 if (strcasecmp(nm, "multiple") == 0) {
2241 /*--------------------------------------------------------------------*/
2242 /* CHTML 1.0 version 2.0 */
2243 /*--------------------------------------------------------------------*/
2244 multiple = apr_pstrdup(doc->buf.pool, val);
2252 if (size && *size) {
2257 if (name && *name) {
2266 return chtml20->out;
2271 * It is a handler who processes the SELECT tag.
2273 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2274 * destination is specified.
2275 * @param node [i] The SELECT tag node is specified.
2276 * @return The conversion result is returned.
2279 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2285 chtml20 = GET_CHTML20(pdoc);
2290 return chtml20->out;
2295 * It is a handler who processes the OPTION tag.
2297 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2298 * destination is specified.
2299 * @param node [i] The OPTION tag node is specified.
2300 * @return The conversion result is returned.
2303 s_chtml20_start_option_tag(void *pdoc, Node *child)
2310 chtml20 = GET_CHTML20(pdoc);
2314 char *selected = NULL;
2318 for (attr = qs_get_attr(doc,child);
2320 attr = qs_get_next_attr(doc,attr)) {
2325 nm = qs_get_attr_name(doc,attr);
2326 val = qs_get_attr_value(doc,attr);
2331 if (strcasecmp(nm, "selected") == 0) {
2332 /*--------------------------------------------------------------------*/
2333 /* CHTML 1.0 version 2.0 */
2334 /*--------------------------------------------------------------------*/
2335 selected = apr_pstrdup(doc->buf.pool, val);
2341 if (strcasecmp(nm, "value") == 0) {
2342 /*--------------------------------------------------------------------*/
2343 /* CHTML 1.0 version 2.0 */
2344 /*--------------------------------------------------------------------*/
2345 value = apr_pstrdup(doc->buf.pool, val);
2354 if (value && *value) {
2364 return chtml20->out;
2369 * It is a handler who processes the OPTION tag.
2371 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2372 * destination is specified.
2373 * @param node [i] The OPTION tag node is specified.
2374 * @return The conversion result is returned.
2377 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2383 chtml20 = GET_CHTML20(pdoc);
2389 return chtml20->out;
2394 * It is a handler who processes the DIV tag.
2396 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2397 * destination is specified.
2398 * @param node [i] The DIV tag node is specified.
2399 * @return The conversion result is returned.
2402 s_chtml20_start_div_tag(void *pdoc, Node *child)
2409 chtml20 = GET_CHTML20(pdoc);
2417 for (attr = qs_get_attr(doc,child);
2419 attr = qs_get_next_attr(doc,attr)) {
2424 nm = qs_get_attr_name(doc,attr);
2425 val = qs_get_attr_value(doc,attr);
2427 if (STRCASEEQ('a','A', "align", nm)) {
2428 /*----------------------------------------------------------------------*/
2429 /* CHTML 1.0 (W3C version 3.2) */
2430 /*----------------------------------------------------------------------*/
2431 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2432 align = apr_pstrdup(doc->buf.pool, val);
2444 return chtml20->out;
2449 * It is a handler who processes the DIV tag.
2451 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2452 * destination is specified.
2453 * @param node [i] The DIV tag node is specified.
2454 * @return The conversion result is returned.
2457 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2463 chtml20 = GET_CHTML20(pdoc);
2468 return chtml20->out;
2473 * It is a handler who processes the H1 tag.
2475 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2476 * destination is specified.
2477 * @param node [i] The H1 tag node is specified.
2478 * @return The conversion result is returned.
2481 s_chtml20_start_h1_tag(void *pdoc, Node *node)
2488 chtml20 = GET_CHTML20(pdoc);
2493 for (attr = qs_get_attr(doc,node);
2495 attr = qs_get_next_attr(doc,attr)) {
2498 name = qs_get_attr_name(doc,attr);
2499 value = qs_get_attr_value(doc,attr);
2500 if (STRCASEEQ('a','A',"align", name)) {
2501 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2510 return chtml20->out;
2515 * It is a handler who processes the H1 tag.
2517 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2518 * destination is specified.
2519 * @param node [i] The H1 tag node is specified.
2520 * @return The conversion result is returned.
2523 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
2529 chtml20 = GET_CHTML20(pdoc);
2534 return chtml20->out;
2539 * It is a handler who processes the H2 tag.
2541 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2542 * destination is specified.
2543 * @param node [i] The H2 tag node is specified.
2544 * @return The conversion result is returned.
2547 s_chtml20_start_h2_tag(void *pdoc, Node *node)
2554 chtml20 = GET_CHTML20(pdoc);
2559 for (attr = qs_get_attr(doc,node);
2561 attr = qs_get_next_attr(doc,attr)) {
2564 name = qs_get_attr_name(doc,attr);
2565 value = qs_get_attr_value(doc,attr);
2566 if (STRCASEEQ('a','A',"align", name)) {
2567 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2576 return chtml20->out;
2581 * It is a handler who processes the H2 tag.
2583 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2584 * destination is specified.
2585 * @param node [i] The H2 tag node is specified.
2586 * @return The conversion result is returned.
2589 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
2595 chtml20 = GET_CHTML20(pdoc);
2600 return chtml20->out;
2605 * It is a handler who processes the H3 tag.
2607 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2608 * destination is specified.
2609 * @param node [i] The H3 tag node is specified.
2610 * @return The conversion result is returned.
2613 s_chtml20_start_h3_tag(void *pdoc, Node *node)
2620 chtml20 = GET_CHTML20(pdoc);
2625 for (attr = qs_get_attr(doc,node);
2627 attr = qs_get_next_attr(doc,attr)) {
2630 name = qs_get_attr_name(doc,attr);
2631 value = qs_get_attr_value(doc,attr);
2632 if (STRCASEEQ('a','A',"align", name)) {
2633 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2642 return chtml20->out;
2647 * It is a handler who processes the H3 tag.
2649 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2650 * destination is specified.
2651 * @param node [i] The H3 tag node is specified.
2652 * @return The conversion result is returned.
2655 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
2661 chtml20 = GET_CHTML20(pdoc);
2666 return chtml20->out;
2671 * It is a handler who processes the H4 tag.
2673 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2674 * destination is specified.
2675 * @param node [i] The H4 tag node is specified.
2676 * @return The conversion result is returned.
2679 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2686 chtml20 = GET_CHTML20(pdoc);
2691 for (attr = qs_get_attr(doc,node);
2693 attr = qs_get_next_attr(doc,attr)) {
2696 name = qs_get_attr_name(doc,attr);
2697 value = qs_get_attr_value(doc,attr);
2698 if (STRCASEEQ('a','A',"align", name)) {
2699 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2708 return chtml20->out;
2713 * It is a handler who processes the H4 tag.
2715 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2716 * destination is specified.
2717 * @param node [i] The H4 tag node is specified.
2718 * @return The conversion result is returned.
2721 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
2727 chtml20 = GET_CHTML20(pdoc);
2732 return chtml20->out;
2737 * It is a handler who processes the H5 tag.
2739 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2740 * destination is specified.
2741 * @param node [i] The H5 tag node is specified.
2742 * @return The conversion result is returned.
2745 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2752 chtml20 = GET_CHTML20(pdoc);
2757 for (attr = qs_get_attr(doc,node);
2759 attr = qs_get_next_attr(doc,attr)) {
2762 name = qs_get_attr_name(doc,attr);
2763 value = qs_get_attr_value(doc,attr);
2764 if (STRCASEEQ('a','A',"align", name)) {
2765 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2774 return chtml20->out;
2779 * It is a handler who processes the H5 tag.
2781 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2782 * destination is specified.
2783 * @param node [i] The H5 tag node is specified.
2784 * @return The conversion result is returned.
2787 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
2793 chtml20 = GET_CHTML20(pdoc);
2798 return chtml20->out;
2803 * It is a handler who processes the H6 tag.
2805 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2806 * destination is specified.
2807 * @param node [i] The H6 tag node is specified.
2808 * @return The conversion result is returned.
2811 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2818 chtml20 = GET_CHTML20(pdoc);
2823 for (attr = qs_get_attr(doc,node);
2825 attr = qs_get_next_attr(doc,attr)) {
2828 name = qs_get_attr_name(doc,attr);
2829 value = qs_get_attr_value(doc,attr);
2830 if (STRCASEEQ('a','A',"align", name)) {
2831 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2840 return chtml20->out;
2845 * It is a handler who processes the H6 tag.
2847 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2848 * destination is specified.
2849 * @param node [i] The H6 tag node is specified.
2850 * @return The conversion result is returned.
2853 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
2859 chtml20 = GET_CHTML20(pdoc);
2864 return chtml20->out;
2869 * It is a handler who processes the PRE tag.
2871 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2872 * destination is specified.
2873 * @param node [i] The PRE tag node is specified.
2874 * @return The conversion result is returned.
2877 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node))
2883 chtml20 = GET_CHTML20(pdoc);
2887 chtml20->pre_flag++;
2889 return chtml20->out;
2894 * It is a handler who processes the PRE tag.
2896 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2897 * destination is specified.
2898 * @param node [i] The PRE tag node is specified.
2899 * @return The conversion result is returned.
2902 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
2908 chtml20 = GET_CHTML20(pdoc);
2913 chtml20->pre_flag--;
2915 return chtml20->out;
2920 * It is a handler who processes the P tag.
2922 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2923 * destination is specified.
2924 * @param node [i] The P tag node is specified.
2925 * @return The conversion result is returned.
2928 s_chtml20_start_p_tag(void *pdoc, Node *node)
2936 chtml20 = GET_CHTML20(pdoc);
2941 for (attr = qs_get_attr(doc,node);
2943 attr = qs_get_next_attr(doc,attr)) {
2944 char *nm = qs_get_attr_name(doc,attr);
2945 char *val = qs_get_attr_value(doc,attr);
2946 if (STRCASEEQ('a','A',"align", nm)) {
2947 /*----------------------------------------------------------------------*/
2948 /* CHTML 1.0 (W3C version 3.2) */
2949 /*----------------------------------------------------------------------*/
2950 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2951 align = apr_pstrdup(doc->buf.pool, val);
2962 return chtml20->out;
2967 * It is a handler who processes the P tag.
2969 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2970 * destination is specified.
2971 * @param node [i] The P tag node is specified.
2972 * @return The conversion result is returned.
2975 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child))
2981 chtml20 = GET_CHTML20(pdoc);
2986 return chtml20->out;
2991 s_chtml20_chxjif_tag(void *pdoc, Node *node)
2998 chtml20 = GET_CHTML20(pdoc);
3002 for (child = qs_get_child_node(doc, node);
3004 child = qs_get_next_node(doc, child)) {
3007 s_chtml20_chxjif_tag(pdoc, child);
3015 * It is a handler who processes the TEXTARE tag.
3017 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3018 * destination is specified.
3019 * @param node [i] The TEXTAREA tag node is specified.
3020 * @return The conversion result is returned.
3023 s_chtml20_start_textarea_tag(void *pdoc, Node *node)
3030 chtml20 = GET_CHTML20(pdoc);
3034 chtml20->textarea_flag++;
3036 for (attr = qs_get_attr(doc,node);
3038 attr = qs_get_next_attr(doc,attr)) {
3039 char *name = qs_get_attr_name(doc,attr);
3040 char *value = qs_get_attr_value(doc,attr);
3044 if (strcasecmp(name, "accesskey") == 0 && value && *value != 0) {
3045 W_L(" accesskey=\"");
3053 if (strcasecmp(name, "name") == 0 && value && *value != 0) {
3062 if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
3071 if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
3080 if (strcasecmp(name, "istyle") == 0 && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3092 return chtml20->out;
3097 * It is a handler who processes the TEXTAREA tag.
3099 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3100 * destination is specified.
3101 * @param node [i] The TEXTAREA tag node is specified.
3102 * @return The conversion result is returned.
3105 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3111 chtml20 = GET_CHTML20(pdoc);
3116 chtml20->textarea_flag--;
3118 return chtml20->out;
3123 s_chtml20_text_tag(void *pdoc, Node *child)
3135 chtml20 = GET_CHTML20(pdoc);
3139 textval = qs_get_node_value(doc,child);
3140 if (strlen(textval) == 0) {
3141 return chtml20->out;
3144 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3145 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3147 tdst = qs_alloc_zero_byte_string(r);
3148 memset(one_byte, 0, sizeof(one_byte));
3151 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3153 int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3155 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3159 if (is_sjis_kanji(textval[ii])) {
3160 one_byte[0] = textval[ii+0];
3161 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3162 one_byte[0] = textval[ii+1];
3163 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3167 if (chtml20->pre_flag) {
3168 one_byte[0] = textval[ii+0];
3169 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3172 if (chtml20->textarea_flag) {
3173 one_byte[0] = textval[ii+0];
3174 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3177 if (textval[ii] != '\r' && textval[ii] != '\n') {
3178 one_byte[0] = textval[ii+0];
3179 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3183 return chtml20->out;
3188 * It is a handler who processes the BLOCKQUOTE tag.
3190 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3191 * destination is specified.
3192 * @param node [i] The BLOCKQUOTE tag node is specified.
3193 * @return The conversion result is returned.
3196 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3200 chtml20 = GET_CHTML20(pdoc);
3202 W_L("<blockquote>");
3203 return chtml20->out;
3208 * It is a handler who processes the BLOCKQUOTE tag.
3210 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3211 * destination is specified.
3212 * @param node [i] The BLOCKQUOTE tag node is specified.
3213 * @return The conversion result is returned.
3216 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3221 chtml20 = GET_CHTML20(pdoc);
3223 W_L("</blockquote>");
3224 return chtml20->out;
3229 * It is a handler who processes the DIR tag.
3231 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3232 * destination is specified.
3233 * @param node [i] The DIR tag node is specified.
3234 * @return The conversion result is returned.
3237 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3241 chtml20 = GET_CHTML20(pdoc);
3244 return chtml20->out;
3249 * It is a handler who processes the DIR tag.
3251 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3252 * destination is specified.
3253 * @param node [i] The DIR tag node is specified.
3254 * @return The conversion result is returned.
3257 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3262 chtml20 = GET_CHTML20(pdoc);
3265 return chtml20->out;
3270 * It is a handler who processes the DL tag.
3272 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3273 * destination is specified.
3274 * @param node [i] The DL tag node is specified.
3275 * @return The conversion result is returned.
3278 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3282 chtml20 = GET_CHTML20(pdoc);
3285 return chtml20->out;
3290 * It is a handler who processes the DL tag.
3292 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3293 * destination is specified.
3294 * @param node [i] The DL tag node is specified.
3295 * @return The conversion result is returned.
3298 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3302 chtml20 = GET_CHTML20(pdoc);
3305 return chtml20->out;
3310 * It is a handter who processes the DT tag.
3312 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3313 * destination is specified.
3314 * @param node [i] The DT tag node is specified.
3315 * @return The conversion result is returned.
3318 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3322 chtml20 = GET_CHTML20(pdoc);
3325 return chtml20->out;
3330 * It is a handter who processes the DT tag.
3332 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3333 * destination is specified.
3334 * @param node [i] The DT tag node is specified.
3335 * @return The conversion result is returned.
3338 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3341 chtml20 = GET_CHTML20(pdoc);
3342 return chtml20->out;
3347 * It is a handder who processes the DD tag.
3349 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3350 * destination is specified.
3351 * @param node [i] The DD tag node is specified.
3352 * @return The conversion result is returned.
3355 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3359 chtml20 = GET_CHTML20(pdoc);
3362 return chtml20->out;
3367 * It is a handder who processes the DD tag.
3369 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3370 * destination is specified.
3371 * @param node [i] The DD tag node is specified.
3372 * @return The conversion result is returned.
3375 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
3378 chtml20 = GET_CHTML20(pdoc);
3379 return chtml20->out;
3384 * It is a hanmenuer who processes the MENU tag.
3386 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3387 * destination is specified.
3388 * @param node [i] The MENU tag node is specified.
3389 * @return The conversion result is returned.
3392 s_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
3396 chtml20 = GET_CHTML20(pdoc);
3399 return chtml20->out;
3404 * It is a hanmenuer who processes the MENU tag.
3406 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3407 * destination is specified.
3408 * @param node [i] The MENU tag node is specified.
3409 * @return The conversion result is returned.
3412 s_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
3414 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3415 Doc *doc = chtml20->doc;
3417 return chtml20->out;
3422 * It is a hanplaintexter who processes the PLAINTEXT tag.
3424 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3425 * destination is specified.
3426 * @param node [i] The PLAINTEXT tag node is specified.
3427 * @return The conversion result is returned.
3430 s_chtml20_start_plaintext_tag(void *pdoc, Node *node)
3435 chtml20 = GET_CHTML20(pdoc);
3438 s_chtml20_start_plaintext_tag_inner(pdoc,node);
3439 return chtml20->out;
3443 s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
3448 chtml20 = GET_CHTML20(pdoc);
3450 for (child = qs_get_child_node(doc, node);
3452 child = qs_get_next_node(doc, child)) {
3454 s_chtml20_start_plaintext_tag_inner(pdoc, child);
3456 return chtml20->out;
3461 * It is a hanplaintexter who processes the PLAINTEXT tag.
3463 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3464 * destination is specified.
3465 * @param node [i] The PLAINTEXT tag node is specified.
3466 * @return The conversion result is returned.
3469 s_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3471 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3472 return chtml20->out;
3476 * It is a hanblinker who processes the BLINK tag.
3478 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3479 * destination is specified.
3480 * @param node [i] The BLINK tag node is specified.
3481 * @return The conversion result is returned.
3484 s_chtml20_start_blink_tag(void *pdoc, Node *UNUSED(child))
3486 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3487 Doc *doc = chtml20->doc;
3489 return chtml20->out;
3494 * It is a hanblinker who processes the BLINK tag.
3496 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3497 * destination is specified.
3498 * @param node [i] The BLINK tag node is specified.
3499 * @return The conversion result is returned.
3502 s_chtml20_end_blink_tag(void *pdoc, Node *UNUSED(child))
3504 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3505 Doc *doc = chtml20->doc;
3507 return chtml20->out;
3512 * It is a hanmarqueeer who processes the MARQUEE tag.
3514 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3515 * destination is specified.
3516 * @param node [i] The MARQUEE tag node is specified.
3517 * @return The conversion result is returned.
3520 s_chtml20_start_marquee_tag(void *pdoc, Node *node)
3522 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3523 Doc *doc = chtml20->doc;
3526 /*--------------------------------------------------------------------------*/
3527 /* Get Attributes */
3528 /*--------------------------------------------------------------------------*/
3529 for (attr = qs_get_attr(doc,node);
3531 attr = qs_get_next_attr(doc,attr)) {
3532 char *name = qs_get_attr_name(doc,attr);
3533 char *value = qs_get_attr_value(doc,attr);
3534 if (STRCASEEQ('d','D',"direction", name)) {
3535 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3536 W_L(" direction=\"");
3541 else if (STRCASEEQ('b','B',"behavior",name)) {
3542 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3543 W_L(" behavior=\"");
3548 else if (STRCASEEQ('l','L',"loop",name)) {
3549 if (value && *value) {
3557 return chtml20->out;
3562 * It is a hanmarqueeer who processes the MARQUEE tag.
3564 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3565 * destination is specified.
3566 * @param node [i] The MARQUEE tag node is specified.
3567 * @return The conversion result is returned.
3570 s_chtml20_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3572 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3573 Doc *doc = chtml20->doc;
3575 return chtml20->out;