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);
108 static void s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
110 static int s_chtml20_search_emoji(chtml20_t *chtml, char *txt, char **rslt);
112 static char *s_chtml20_chxjif_tag(void *pdoc, Node *node);
113 static char *s_chtml20_text_tag(void *pdoc, Node *node);
116 tag_handler chtml20_handler[] = {
119 s_chtml20_start_html_tag,
120 s_chtml20_end_html_tag,
124 s_chtml20_start_meta_tag,
125 s_chtml20_end_meta_tag,
129 s_chtml20_start_textarea_tag,
130 s_chtml20_end_textarea_tag,
134 s_chtml20_start_p_tag,
139 s_chtml20_start_pre_tag,
140 s_chtml20_end_pre_tag,
144 s_chtml20_start_ul_tag,
145 s_chtml20_end_ul_tag,
149 s_chtml20_start_li_tag,
150 s_chtml20_end_li_tag,
154 s_chtml20_start_ol_tag,
155 s_chtml20_end_ol_tag,
159 s_chtml20_start_h1_tag,
160 s_chtml20_end_h1_tag,
164 s_chtml20_start_h2_tag,
165 s_chtml20_end_h2_tag,
169 s_chtml20_start_h3_tag,
170 s_chtml20_end_h3_tag,
174 s_chtml20_start_h4_tag,
175 s_chtml20_end_h4_tag,
179 s_chtml20_start_h5_tag,
180 s_chtml20_end_h5_tag,
184 s_chtml20_start_h6_tag,
185 s_chtml20_end_h6_tag,
189 s_chtml20_start_head_tag,
190 s_chtml20_end_head_tag,
194 s_chtml20_start_title_tag,
195 s_chtml20_end_title_tag,
199 s_chtml20_start_base_tag,
200 s_chtml20_end_base_tag,
204 s_chtml20_start_body_tag,
205 s_chtml20_end_body_tag,
209 s_chtml20_start_a_tag,
214 s_chtml20_start_br_tag,
215 s_chtml20_end_br_tag,
224 s_chtml20_start_tr_tag,
225 s_chtml20_end_tr_tag,
239 s_chtml20_start_font_tag,
240 s_chtml20_end_font_tag,
244 s_chtml20_start_form_tag,
245 s_chtml20_end_form_tag,
249 s_chtml20_start_input_tag,
250 s_chtml20_end_input_tag,
254 s_chtml20_start_center_tag,
255 s_chtml20_end_center_tag,
259 s_chtml20_start_hr_tag,
260 s_chtml20_end_hr_tag,
264 s_chtml20_start_img_tag,
265 s_chtml20_end_img_tag,
269 s_chtml20_start_select_tag,
270 s_chtml20_end_select_tag,
274 s_chtml20_start_option_tag,
275 s_chtml20_end_option_tag,
279 s_chtml20_start_div_tag,
280 s_chtml20_end_div_tag,
284 s_chtml20_chxjif_tag,
329 s_chtml20_start_dt_tag,
330 s_chtml20_end_dt_tag,
344 s_chtml20_start_blockquote_tag,
345 s_chtml20_end_blockquote_tag,
349 s_chtml20_start_dir_tag,
350 s_chtml20_end_dir_tag,
354 s_chtml20_start_dl_tag,
355 s_chtml20_end_dl_tag,
359 s_chtml20_start_dd_tag,
360 s_chtml20_end_dd_tag,
364 s_chtml20_start_menu_tag,
365 s_chtml20_end_menu_tag,
369 s_chtml20_start_plaintext_tag,
370 s_chtml20_end_plaintext_tag,
375 * converts from CHTML5.0 to CHTML2.0.
377 * @param r [i] Requet_rec is appointed.
378 * @param spec [i] The result of the device specification processing which
379 * was done in advance is appointed.
380 * @param src [i] The character string before the converting is appointed.
381 * @return The character string after the converting is returned.
384 chxj_exchange_chtml20(
390 chxjconvrule_entry *entryp,
399 /*--------------------------------------------------------------------------*/
401 /*--------------------------------------------------------------------------*/
403 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
405 DBG(r,"i found qrcode xml");
408 DBG(r,"not found qrcode xml");
410 /*--------------------------------------------------------------------------*/
411 /* The CHTML structure is initialized. */
412 /*--------------------------------------------------------------------------*/
413 s_init_chtml20(&chtml20, &doc, r, spec);
416 chtml20.entryp = entryp;
417 chtml20.cookie = cookie;
419 chxj_set_content_type(r, "text/html; charset=Windows-31J");
421 /*--------------------------------------------------------------------------*/
422 /* The character string of the input is analyzed. */
423 /*--------------------------------------------------------------------------*/
424 qs_init_malloc(&doc);
425 qs_init_root_node(&doc);
427 ss = apr_pcalloc(r->pool, srclen + 1);
428 memset(ss, 0, srclen + 1);
429 memcpy(ss, src, srclen);
432 chxj_dump_out("[src] CHTML -> CHTML2.0", ss, srclen);
435 qs_parse_string(&doc,ss, strlen(ss));
437 chxj_buffered_write_init(r->pool, &doc.buf);
438 /*--------------------------------------------------------------------------*/
439 /* It converts it from CHTML to CHTML. */
440 /*--------------------------------------------------------------------------*/
441 chxj_node_exchange(spec,r,(void *)&chtml20, &doc, qs_get_root(&doc), 0);
442 chtml20.out = chxj_buffered_write_flush(chtml20.out, &doc.buf);
443 dst = apr_pstrdup(r->pool, chtml20.out);
444 chxj_buffered_write_terminate(&doc.buf);
446 qs_all_free(&doc,QX_LOGMARK);
449 return apr_pstrdup(r->pool,ss);
452 if (strlen(dst) == 0) {
453 dst = apr_psprintf(r->pool, "\n");
456 *dstlen = strlen(dst);
459 chxj_dump_out("[dst] CHTML -> CHTML2.0", dst, *dstlen);
466 * The CHTML structure is initialized.
468 * @param chtml20 [i/o] The pointer to the HDML structure that wants to be
469 * initialized is specified.
470 * @param doc [i] The Doc structure that should be set to the initialized
471 * HDML structure is specified.
472 * @param r [i] To use POOL, the pointer to request_rec is specified.
473 * @param spec [i] The pointer to the device_table
476 s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
478 memset(doc, 0, sizeof(Doc));
479 memset(chtml20, 0, sizeof(chtml20_t));
483 chtml20->spec = spec;
484 chtml20->out = qs_alloc_zero_byte_string(r);
485 chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
487 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
492 * Corresponding EMOJI to a current character-code is retrieved.
493 * The substitution character string is stored in the rslt pointer if agreeing.
495 * @param chtml20 [i] The pointer to the CHTML structure is specified.
496 * @param txt [i] The character string to want to examine whether it is
497 * EMOJI is specified.
498 * @param rslt [o] The pointer to the pointer that stores the result is
500 * @return When corresponding EMOJI exists, it returns it excluding 0.
503 s_chtml20_search_emoji(chtml20_t *chtml20, char *txt, char **rslt)
510 spec = chtml20->spec;
516 DBG(r,"spec is NULL");
518 for (ee = chtml20->conf->emoji;
522 if (ee->imode == NULL) {
523 DBG(r,"emoji->imode is NULL");
527 if (ee->imode->string != NULL
528 && strlen(ee->imode->string) > 0
529 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
530 if (spec == NULL || spec->emoji_type == NULL) {
531 *rslt = apr_palloc(r->pool, 3);
532 (*rslt)[0] = ee->imode->hex1byte & 0xff;
533 (*rslt)[1] = ee->imode->hex2byte & 0xff;
535 return strlen(ee->imode->string);
547 * It is a handler who processes the HTML tag.
549 * @param pdoc [i/o] The pointer to the CHTML structure at the output
550 * destination is specified.
551 * @param node [i] The HTML tag node is specified.
552 * @return The conversion result is returned.
555 s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
561 chtml20 = GET_CHTML20(pdoc);
565 /*--------------------------------------------------------------------------*/
567 /*--------------------------------------------------------------------------*/
574 * It is a handler who processes the HTML tag.
576 * @param pdoc [i/o] The pointer to the CHTML structure at the output
577 * destination is specified.
578 * @param node [i] The HTML tag node is specified.
579 * @return The conversion result is returned.
582 s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child))
588 chtml20 = GET_CHTML20(pdoc);
598 * It is a handler who processes the META tag.
600 * @param pdoc [i/o] The pointer to the CHTML structure at the output
601 * destination is specified.
602 * @param node [i] The META tag node is specified.
603 * @return The conversion result is returned.
606 s_chtml20_start_meta_tag(void *pdoc, Node *node)
612 int content_type_flag;
615 chtml20 = GET_CHTML20(pdoc);
619 content_type_flag = 0;
623 /*--------------------------------------------------------------------------*/
625 /*--------------------------------------------------------------------------*/
626 for (attr = qs_get_attr(doc,node);
628 attr = qs_get_next_attr(doc,attr)) {
633 name = qs_get_attr_name(doc,attr);
634 value = qs_get_attr_value(doc,attr);
639 if (strcasecmp(name, "http-equiv") == 0) {
640 /*----------------------------------------------------------------------*/
642 /*----------------------------------------------------------------------*/
643 W_L(" http-equiv=\"");
646 if (STRCASEEQ('c','C',"content-type", value)) {
647 content_type_flag = 1;
649 if (STRCASEEQ('r','R',"refresh", value)) {
657 if (strcasecmp(name, "content") == 0) {
658 if (content_type_flag) {
661 W_L("=\"text/html; charset=Windows-31J\"");
663 else if (refresh_flag) {
664 char *buf = apr_pstrdup(r->pool, value);
668 url = strchr(buf, ';');
670 sec = apr_pstrdup(r->pool, buf);
673 url = chxj_encoding_parameter(r, url);
674 url = chxj_add_cookie_parameter(r, url, chtml20->cookie);
704 * It is a handler who processes the META tag.
706 * @param pdoc [i/o] The pointer to the CHTML structure at the output
707 * destination is specified.
708 * @param node [i] The META tag node is specified.
709 * @return The conversion result is returned.
712 s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child))
716 chtml20 = GET_CHTML20(pdoc);
723 * It is a handler who processes the HEAD tag.
725 * @param pdoc [i/o] The pointer to the CHTML structure at the output
726 * destination is specified.
727 * @param node [i] The HEAD tag node is specified.
728 * @return The conversion result is returned.
731 s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node))
737 chtml20 = GET_CHTML20(pdoc);
747 * It is a handler who processes the HEAD tag.
749 * @param pdoc [i/o] The pointer to the CHTML structure at the output
750 * destination is specified.
751 * @param node [i] The HEAD tag node is specified.
752 * @return The conversion result is returned.
755 s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child))
761 chtml20 = GET_CHTML20(pdoc);
771 * It is a handler who processes the TITLE tag.
773 * @param pdoc [i/o] The pointer to the CHTML structure at the output
774 * destination is specified.
775 * @param node [i] The TITLE tag node is specified.
776 * @return The conversion result is returned.
779 s_chtml20_start_title_tag(void *pdoc, Node *UNUSED(node))
785 chtml20 = GET_CHTML20(pdoc);
795 * It is a handler who processes the TITLE tag.
797 * @param pdoc [i/o] The pointer to the CHTML structure at the output
798 * destination is specified.
799 * @param node [i] The TITLE tag node is specified.
800 * @return The conversion result is returned.
803 s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
809 chtml20 = GET_CHTML20(pdoc);
819 * It is a handler who processes the BASE tag.
821 * @param pdoc [i/o] The pointer to the CHTML structure at the output
822 * destination is specified.
823 * @param node [i] The BASE tag node is specified.
824 * @return The conversion result is returned.
827 s_chtml20_start_base_tag(void *pdoc, Node *node)
834 chtml20 = GET_CHTML20(pdoc);
839 /*--------------------------------------------------------------------------*/
841 /*--------------------------------------------------------------------------*/
842 for (attr = qs_get_attr(doc,node);
844 attr = qs_get_next_attr(doc,attr)) {
849 name = qs_get_attr_name(doc,attr);
850 value = qs_get_attr_value(doc,attr);
852 if (STRCASEEQ('h','H',"href", name)) {
864 * It is a handler who processes the BASE tag.
866 * @param pdoc [i/o] The pointer to the CHTML structure at the output
867 * destination is specified.
868 * @param node [i] The BASE tag node is specified.
869 * @return The conversion result is returned.
872 s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child))
878 chtml20 = GET_CHTML20(pdoc);
887 * It is a handler who processes the BODY tag.
889 * @param pdoc [i/o] The pointer to the CHTML structure at the output
890 * destination is specified.
891 * @param node [i] The BODY tag node is specified.
892 * @return The conversion result is returned.
895 s_chtml20_start_body_tag(void *pdoc, Node *node)
902 chtml20 = GET_CHTML20(pdoc);
907 /*--------------------------------------------------------------------------*/
909 /*--------------------------------------------------------------------------*/
910 for (attr = qs_get_attr(doc,node);
912 attr = qs_get_next_attr(doc,attr)) {
916 name = qs_get_attr_name(doc,attr);
917 value = qs_get_attr_value(doc,attr);
922 if (strcasecmp(name, "bgcolor") == 0 && value && *value != 0) {
923 /*----------------------------------------------------------------------*/
925 /*----------------------------------------------------------------------*/
934 if (strcasecmp(name, "text") == 0 && value && *value != 0) {
935 /*----------------------------------------------------------------------*/
937 /*----------------------------------------------------------------------*/
946 if (strcasecmp(name, "link") == 0 && value && *value != 0) {
947 /*----------------------------------------------------------------------*/
949 /*----------------------------------------------------------------------*/
958 if (strcasecmp(name, "alink") == 0) {
959 /*----------------------------------------------------------------------*/
961 /*----------------------------------------------------------------------*/
968 if (strcasecmp(name, "vlink") == 0) {
969 /*----------------------------------------------------------------------*/
971 /*----------------------------------------------------------------------*/
986 * It is a handler who processes the BODY tag.
988 * @param pdoc [i/o] The pointer to the CHTML structure at the output
989 * destination is specified.
990 * @param node [i] The BODY tag node is specified.
991 * @return The conversion result is returned.
994 s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child))
1000 chtml20 = GET_CHTML20(pdoc);
1005 return chtml20->out;
1010 * It is a handler who processes the A tag.
1012 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1013 * destination is specified.
1014 * @param node [i] The A tag node is specified.
1015 * @return The conversion result is returned.
1018 s_chtml20_start_a_tag(void *pdoc, Node *node)
1025 chtml20 = GET_CHTML20(pdoc);
1030 /*--------------------------------------------------------------------------*/
1031 /* Get Attributes */
1032 /*--------------------------------------------------------------------------*/
1033 for (attr = qs_get_attr(doc,node);
1035 attr = qs_get_next_attr(doc,attr)) {
1040 name = qs_get_attr_name(doc,attr);
1041 value = qs_get_attr_value(doc,attr);
1046 if (strcasecmp(name, "name") == 0) {
1047 /*--------------------------------------------------------------------*/
1049 /*--------------------------------------------------------------------*/
1058 if (strcasecmp(name, "href") == 0) {
1059 /*--------------------------------------------------------------------*/
1061 /*--------------------------------------------------------------------*/
1062 value = chxj_encoding_parameter(r, value);
1063 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1072 if (strcasecmp(name, "accesskey") == 0) {
1073 /*--------------------------------------------------------------------*/
1075 /*--------------------------------------------------------------------*/
1076 W_L(" accesskey=\"");
1084 if (strcasecmp(name, "cti") == 0) {
1085 /*--------------------------------------------------------------------*/
1087 /*--------------------------------------------------------------------*/
1096 if (strcasecmp(name, "ijam") == 0) {
1097 /*--------------------------------------------------------------------*/
1099 /*--------------------------------------------------------------------*/
1103 if (strcasecmp(name, "ista") == 0) {
1104 /*--------------------------------------------------------------------*/
1106 /*--------------------------------------------------------------------*/
1110 if (strcasecmp(name, "ilet") == 0) {
1111 /*--------------------------------------------------------------------*/
1113 /*--------------------------------------------------------------------*/
1117 if (strcasecmp(name, "iswf") == 0) {
1118 /*--------------------------------------------------------------------*/
1120 /*--------------------------------------------------------------------*/
1124 if (strcasecmp(name, "irst") == 0) {
1125 /*--------------------------------------------------------------------*/
1127 /*--------------------------------------------------------------------*/
1134 if (strcasecmp(name, "utn") == 0) {
1135 /*--------------------------------------------------------------------*/
1137 /*--------------------------------------------------------------------*/
1144 if (strcasecmp(name, "telbook") == 0) {
1145 /*--------------------------------------------------------------------*/
1147 /*--------------------------------------------------------------------*/
1154 if (strcasecmp(name, "kana") == 0) {
1155 /*--------------------------------------------------------------------*/
1157 /*--------------------------------------------------------------------*/
1164 if (strcasecmp(name, "email") == 0) {
1165 /*--------------------------------------------------------------------*/
1167 /*--------------------------------------------------------------------*/
1177 return chtml20->out;
1182 * It is a handler who processes the A tag.
1184 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1185 * destination is specified.
1186 * @param node [i] The A tag node is specified.
1187 * @return The conversion result is returned.
1190 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
1196 chtml20 = GET_CHTML20(pdoc);
1201 return chtml20->out;
1206 * It is a handler who processes the BR tag.
1208 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1209 * destination is specified.
1210 * @param node [i] The BR tag node is specified.
1211 * @return The conversion result is returned.
1214 s_chtml20_start_br_tag(void *pdoc, Node *node)
1221 chtml20 = GET_CHTML20(pdoc);
1226 /*--------------------------------------------------------------------------*/
1227 /* Get Attributes */
1228 /*--------------------------------------------------------------------------*/
1229 for (attr = qs_get_attr(doc,node);
1231 attr = qs_get_next_attr(doc,attr)) {
1235 name = qs_get_attr_name(doc,attr);
1236 value = qs_get_attr_value(doc,attr);
1238 if (STRCASEEQ('c','C',"clear",name)) {
1239 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1247 return chtml20->out;
1252 * It is a handler who processes the BR tag.
1254 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1255 * destination is specified.
1256 * @param node [i] The BR tag node is specified.
1257 * @return The conversion result is returned.
1260 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
1266 chtml20 = GET_CHTML20(pdoc);
1270 return chtml20->out;
1275 * It is a handler who processes the TR tag.
1277 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1278 * destination is specified.
1279 * @param node [i] The TR tag node is specified.
1280 * @return The conversion result is returned.
1283 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
1289 chtml20 = GET_CHTML20(pdoc);
1293 return chtml20->out;
1298 * It is a handler who processes the TR tag.
1300 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1301 * destination is specified.
1302 * @param node [i] The TR tag node is specified.
1303 * @return The conversion result is returned.
1306 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
1312 chtml20 = GET_CHTML20(pdoc);
1317 return chtml20->out;
1322 * It is a handler who processes the FONT tag.
1324 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1325 * destination is specified.
1326 * @param node [i] The FONT tag node is specified.
1327 * @return The conversion result is returned.
1330 s_chtml20_start_font_tag(void *pdoc, Node *node)
1337 chtml20 = GET_CHTML20(pdoc);
1343 /*--------------------------------------------------------------------------*/
1344 /* Get Attributes */
1345 /*--------------------------------------------------------------------------*/
1346 for (attr = qs_get_attr(doc,node);
1348 attr = qs_get_next_attr(doc,attr)) {
1353 name = qs_get_attr_name(doc,attr);
1354 value = qs_get_attr_value(doc,attr);
1359 if (strcasecmp(name, "color") == 0) {
1368 if (strcasecmp(name, "size") == 0) {
1369 /*--------------------------------------------------------------------*/
1371 /*--------------------------------------------------------------------*/
1381 return chtml20->out;
1386 * It is a handler who processes the FONT tag.
1388 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1389 * destination is specified.
1390 * @param node [i] The FONT tag node is specified.
1391 * @return The conversion result is returned.
1394 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child))
1400 chtml20 = GET_CHTML20(pdoc);
1405 return chtml20->out;
1410 * It is a handler who processes the FORM tag.
1412 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1413 * destination is specified.
1414 * @param node [i] The FORM tag node is specified.
1415 * @return The conversion result is returned.
1418 s_chtml20_start_form_tag(void *pdoc, Node *node)
1425 chtml20 = GET_CHTML20(pdoc);
1430 /*--------------------------------------------------------------------------*/
1431 /* Get Attributes */
1432 /*--------------------------------------------------------------------------*/
1433 for (attr = qs_get_attr(doc,node);
1435 attr = qs_get_next_attr(doc,attr)) {
1440 name = qs_get_attr_name(doc,attr);
1441 value = qs_get_attr_value(doc,attr);
1446 if (strcasecmp(name, "action") == 0) {
1447 /*--------------------------------------------------------------------*/
1449 /*--------------------------------------------------------------------*/
1450 value = chxj_encoding_parameter(r, value);
1451 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1461 if (strcasecmp(name, "method") == 0) {
1462 /*--------------------------------------------------------------------*/
1464 /*--------------------------------------------------------------------*/
1473 if (strcasecmp(name, "utn") == 0) {
1474 /*--------------------------------------------------------------------*/
1476 /*--------------------------------------------------------------------*/
1486 return chtml20->out;
1491 * It is a handler who processes the FORM tag.
1493 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1494 * destination is specified.
1495 * @param node [i] The FORM tag node is specified.
1496 * @return The conversion result is returned.
1499 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child))
1505 chtml20 = GET_CHTML20(pdoc);
1510 return chtml20->out;
1515 * It is a handler who processes the INPUT tag.
1517 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1518 * destination is specified.
1519 * @param node [i] The INPUT tag node is specified.
1520 * @return The conversion result is returned.
1523 s_chtml20_start_input_tag(void *pdoc, Node *node)
1528 char *max_length = NULL;
1532 char *istyle = NULL;
1534 char *checked = NULL;
1535 char *accesskey = NULL;
1537 chtml20 = GET_CHTML20(pdoc);
1543 /*--------------------------------------------------------------------------*/
1544 /* Get Attributes */
1545 /*--------------------------------------------------------------------------*/
1547 type = qs_get_type_attr(doc, node, r);
1548 name = qs_get_name_attr(doc, node, r);
1549 value = qs_get_value_attr(doc,node,r);
1550 istyle = qs_get_istyle_attr(doc,node,r);
1551 max_length = qs_get_maxlength_attr(doc,node,r);
1552 checked = qs_get_checked_attr(doc,node,r);
1553 accesskey = qs_get_accesskey_attr(doc, node, r);
1554 size = qs_get_size_attr(doc, node, r);
1557 type = qs_trim_string(doc->buf.pool, type);
1558 if (type && (STRCASEEQ('t','T',"text", type) ||
1559 STRCASEEQ('p','P',"password",type) ||
1560 STRCASEEQ('c','C',"checkbox",type) ||
1561 STRCASEEQ('r','R',"radio", type) ||
1562 STRCASEEQ('h','H',"hidden", type) ||
1563 STRCASEEQ('s','S',"submit", type) ||
1564 STRCASEEQ('r','R',"reset", type))) {
1571 if (size && *size) {
1577 if (name && *name) {
1583 if (value && *value) {
1589 if (accesskey && *accesskey) {
1590 W_L(" accesskey=\"");
1596 /*------------------------------------------------------------------------*/
1598 /*------------------------------------------------------------------------*/
1599 if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1606 /*--------------------------------------------------------------------------*/
1607 /* The figure is default for the password. */
1608 /*--------------------------------------------------------------------------*/
1609 if (max_length && *max_length) {
1610 if (chxj_chk_numeric(max_length) != 0) {
1611 max_length = apr_psprintf(doc->buf.pool, "0");
1613 if (istyle && *istyle == '1') {
1614 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1618 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1627 return chtml20->out;
1632 * It is a handler who processes the INPUT tag.
1634 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1635 * destination is specified.
1636 * @param node [i] The INPUT tag node is specified.
1637 * @return The conversion result is returned.
1640 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child))
1646 chtml20 = GET_CHTML20(pdoc);
1650 return chtml20->out;
1655 * It is a handler who processes the CENTER tag.
1657 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1658 * destination is specified.
1659 * @param node [i] The CENTER tag node is specified.
1660 * @return The conversion result is returned.
1663 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node))
1669 chtml20 = GET_CHTML20(pdoc);
1674 return chtml20->out;
1679 * It is a handler who processes the CENTER tag.
1681 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1682 * destination is specified.
1683 * @param node [i] The CENTER tag node is specified.
1684 * @return The conversion result is returned.
1687 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child))
1693 chtml20 = GET_CHTML20(pdoc);
1698 return chtml20->out;
1703 * It is a handler who processes the UL tag.
1705 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1706 * destination is specified.
1707 * @param node [i] The UL tag node is specified.
1708 * @return The conversion result is returned.
1711 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node))
1717 chtml20 = GET_CHTML20(pdoc);
1722 return chtml20->out;
1727 * It is a handler who processes the UL tag.
1729 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1730 * destination is specified.
1731 * @param node [i] The UL tag node is specified.
1732 * @return The conversion result is returned.
1735 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
1741 chtml20 = GET_CHTML20(pdoc);
1746 return chtml20->out;
1751 * It is a handler who processes the OL tag.
1753 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1754 * destination is specified.
1755 * @param node [i] The OL tag node is specified.
1756 * @return The conversion result is returned.
1759 s_chtml20_start_ol_tag(void *pdoc, Node *node)
1766 chtml20 = GET_CHTML20(pdoc);
1771 /*--------------------------------------------------------------------------*/
1772 /* Get Attributes */
1773 /*--------------------------------------------------------------------------*/
1774 for (attr = qs_get_attr(doc,node);
1776 attr = qs_get_next_attr(doc,attr)) {
1777 char *name = qs_get_attr_name(doc,attr);
1778 char *value = qs_get_attr_value(doc,attr);
1779 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1784 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1791 return chtml20->out;
1796 * It is a handler who processes the OL tag.
1798 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1799 * destination is specified.
1800 * @param node [i] The OL tag node is specified.
1801 * @return The conversion result is returned.
1804 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
1810 chtml20 = GET_CHTML20(pdoc);
1815 return chtml20->out;
1820 * It is a handler who processes the LI tag.
1822 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1823 * destination is specified.
1824 * @param node [i] The LI tag node is specified.
1825 * @return The conversion result is returned.
1828 s_chtml20_start_li_tag(void *pdoc, Node *node)
1835 chtml20 = GET_CHTML20(pdoc);
1840 /*--------------------------------------------------------------------------*/
1841 /* Get Attributes */
1842 /*--------------------------------------------------------------------------*/
1843 for (attr = qs_get_attr(doc,node);
1845 attr = qs_get_next_attr(doc,attr)) {
1846 char *name = qs_get_attr_name(doc,attr);
1847 char *value = qs_get_attr_value(doc,attr);
1848 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1853 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1860 return chtml20->out;
1865 * It is a handler who processes the LI tag.
1867 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1868 * destination is specified.
1869 * @param node [i] The LI tag node is specified.
1870 * @return The conversion result is returned.
1873 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
1875 chtml20_t *chtml20 = GET_CHTML20(pdoc);
1876 return chtml20->out;
1881 * It is a handler who processes the HR tag.
1883 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1884 * destination is specified.
1885 * @param node [i] The HR tag node is specified.
1886 * @return The conversion result is returned.
1889 s_chtml20_start_hr_tag(void *pdoc, Node *node)
1896 chtml20 = GET_CHTML20(pdoc);
1902 for (attr = qs_get_attr(doc,node);
1904 attr = qs_get_next_attr(doc,attr)) {
1909 name = qs_get_attr_name(doc,attr);
1910 value = qs_get_attr_value(doc,attr);
1915 if (strcasecmp(name, "align") == 0) {
1916 /*--------------------------------------------------------------------*/
1918 /*--------------------------------------------------------------------*/
1919 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1929 if (strcasecmp(name, "size") == 0) {
1930 /*--------------------------------------------------------------------*/
1932 /*--------------------------------------------------------------------*/
1933 if (value && value[0] != '\0') {
1943 if (strcasecmp(name, "width") == 0) {
1944 /*--------------------------------------------------------------------*/
1946 /*--------------------------------------------------------------------*/
1947 if (value && value[0] != '\0') {
1957 if (strcasecmp(name, "noshade") == 0) {
1958 /*--------------------------------------------------------------------*/
1960 /*--------------------------------------------------------------------*/
1967 if (strcasecmp(name, "color") == 0) {
1968 /*--------------------------------------------------------------------*/
1970 /*--------------------------------------------------------------------*/
1980 return chtml20->out;
1985 * It is a handler who processes the HR tag.
1987 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1988 * destination is specified.
1989 * @param node [i] The HR tag node is specified.
1990 * @return The conversion result is returned.
1993 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
1999 chtml20 = GET_CHTML20(pdoc);
2003 return chtml20->out;
2008 * It is a handler who processes the IMG tag.
2010 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2011 * destination is specified.
2012 * @param node [i] The IMG tag node is specified.
2013 * @return The conversion result is returned.
2016 s_chtml20_start_img_tag(void *pdoc, Node *node)
2022 #ifndef IMG_NOT_CONVERT_FILENAME
2026 chtml20 = GET_CHTML20(pdoc);
2030 #ifndef IMG_NOT_CONVERT_FILENAME
2031 spec = chtml20->spec;
2035 /*-------------------------------------------------------------------------*/
2036 /* Get Attributes */
2037 /*-------------------------------------------------------------------------*/
2038 for (attr = qs_get_attr(doc,node);
2040 attr = qs_get_next_attr(doc,attr)) {
2045 name = qs_get_attr_name(doc,attr);
2046 value = qs_get_attr_value(doc,attr);
2051 if (strcasecmp(name, "src") == 0) {
2052 /*-------------------------------------------------------------------*/
2054 /*-------------------------------------------------------------------*/
2055 #ifdef IMG_NOT_CONVERT_FILENAME
2056 value = chxj_encoding_parameter(r, value);
2057 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2059 value = apr_psprintf(doc->buf.pool,
2062 (strchr(value, '?')) ? '&' : '?',
2063 CHXJ_COOKIE_NOUPDATE_PARAM);
2069 value = chxj_img_conv(r, spec, value);
2070 value = chxj_encoding_parameter(r, value);
2071 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2073 value = apr_psprintf(doc->buf.pool,
2076 (strchr(value, '?')) ? '&' : '?',
2077 CHXJ_COOKIE_NOUPDATE_PARAM);
2088 if (strcasecmp(name, "align" ) == 0) {
2089 /*--------------------------------------------------------------------*/
2091 /*--------------------------------------------------------------------*/
2092 if (value && (STRCASEEQ('t','T',"top", value) ||
2093 STRCASEEQ('m','M',"middle",value) ||
2094 STRCASEEQ('b','B',"bottom",value) ||
2095 STRCASEEQ('l','L',"left", value) ||
2096 STRCASEEQ('r','R',"right", value))) {
2102 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2103 /*--------------------------------------------------------------------*/
2105 /*--------------------------------------------------------------------*/
2114 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2115 /*--------------------------------------------------------------------*/
2117 /*--------------------------------------------------------------------*/
2126 if (strcasecmp(name, "height") == 0 && value && *value) {
2127 /*--------------------------------------------------------------------*/
2129 /*--------------------------------------------------------------------*/
2134 else if (strcasecmp(name, "hspace") == 0 && value && *value) {
2135 /*--------------------------------------------------------------------*/
2137 /*--------------------------------------------------------------------*/
2146 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2147 /*--------------------------------------------------------------------*/
2149 /*--------------------------------------------------------------------*/
2161 return chtml20->out;
2166 * It is a handler who processes the IMG tag.
2168 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2169 * destination is specified.
2170 * @param node [i] The IMG tag node is specified.
2171 * @return The conversion result is returned.
2174 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
2180 chtml20 = GET_CHTML20(pdoc);
2184 return chtml20->out;
2189 * It is a handler who processes the SELECT tag.
2191 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2192 * destination is specified.
2193 * @param node [i] The SELECT tag node is specified.
2194 * @return The conversion result is returned.
2197 s_chtml20_start_select_tag(void *pdoc, Node *child)
2204 chtml20 = GET_CHTML20(pdoc);
2210 char *multiple = NULL;
2213 for (attr = qs_get_attr(doc,child);
2215 attr = qs_get_next_attr(doc,attr)) {
2216 char *nm = qs_get_attr_name(doc,attr);
2217 char *val = qs_get_attr_value(doc,attr);
2221 if (strcasecmp(nm, "size") == 0) {
2222 /*--------------------------------------------------------------------*/
2223 /* CHTML 1.0 version 2.0 */
2224 /*--------------------------------------------------------------------*/
2225 size = apr_pstrdup(doc->buf.pool, val);
2231 if (strcasecmp(nm, "name") == 0) {
2232 /*--------------------------------------------------------------------*/
2233 /* CHTML 1.0 version 2.0 */
2234 /*--------------------------------------------------------------------*/
2235 name = apr_pstrdup(doc->buf.pool, val);
2241 if (strcasecmp(nm, "multiple") == 0) {
2242 /*--------------------------------------------------------------------*/
2243 /* CHTML 1.0 version 2.0 */
2244 /*--------------------------------------------------------------------*/
2245 multiple = apr_pstrdup(doc->buf.pool, val);
2253 if (size && *size) {
2258 if (name && *name) {
2267 return chtml20->out;
2272 * It is a handler who processes the SELECT tag.
2274 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2275 * destination is specified.
2276 * @param node [i] The SELECT tag node is specified.
2277 * @return The conversion result is returned.
2280 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2286 chtml20 = GET_CHTML20(pdoc);
2291 return chtml20->out;
2296 * It is a handler who processes the OPTION tag.
2298 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2299 * destination is specified.
2300 * @param node [i] The OPTION tag node is specified.
2301 * @return The conversion result is returned.
2304 s_chtml20_start_option_tag(void *pdoc, Node *child)
2311 chtml20 = GET_CHTML20(pdoc);
2315 char *selected = NULL;
2319 for (attr = qs_get_attr(doc,child);
2321 attr = qs_get_next_attr(doc,attr)) {
2326 nm = qs_get_attr_name(doc,attr);
2327 val = qs_get_attr_value(doc,attr);
2332 if (strcasecmp(nm, "selected") == 0) {
2333 /*--------------------------------------------------------------------*/
2334 /* CHTML 1.0 version 2.0 */
2335 /*--------------------------------------------------------------------*/
2336 selected = apr_pstrdup(doc->buf.pool, val);
2342 if (strcasecmp(nm, "value") == 0) {
2343 /*--------------------------------------------------------------------*/
2344 /* CHTML 1.0 version 2.0 */
2345 /*--------------------------------------------------------------------*/
2346 value = apr_pstrdup(doc->buf.pool, val);
2355 if (value && *value) {
2365 return chtml20->out;
2370 * It is a handler who processes the OPTION tag.
2372 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2373 * destination is specified.
2374 * @param node [i] The OPTION tag node is specified.
2375 * @return The conversion result is returned.
2378 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2384 chtml20 = GET_CHTML20(pdoc);
2390 return chtml20->out;
2395 * It is a handler who processes the DIV tag.
2397 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2398 * destination is specified.
2399 * @param node [i] The DIV tag node is specified.
2400 * @return The conversion result is returned.
2403 s_chtml20_start_div_tag(void *pdoc, Node *child)
2410 chtml20 = GET_CHTML20(pdoc);
2418 for (attr = qs_get_attr(doc,child);
2420 attr = qs_get_next_attr(doc,attr)) {
2425 nm = qs_get_attr_name(doc,attr);
2426 val = qs_get_attr_value(doc,attr);
2428 if (STRCASEEQ('a','A', "align", nm)) {
2429 /*----------------------------------------------------------------------*/
2430 /* CHTML 1.0 (W3C version 3.2) */
2431 /*----------------------------------------------------------------------*/
2432 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2433 align = apr_pstrdup(doc->buf.pool, val);
2445 return chtml20->out;
2450 * It is a handler who processes the DIV tag.
2452 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2453 * destination is specified.
2454 * @param node [i] The DIV tag node is specified.
2455 * @return The conversion result is returned.
2458 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2464 chtml20 = GET_CHTML20(pdoc);
2469 return chtml20->out;
2474 * It is a handler who processes the H1 tag.
2476 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2477 * destination is specified.
2478 * @param node [i] The H1 tag node is specified.
2479 * @return The conversion result is returned.
2482 s_chtml20_start_h1_tag(void *pdoc, Node *node)
2489 chtml20 = GET_CHTML20(pdoc);
2494 for (attr = qs_get_attr(doc,node);
2496 attr = qs_get_next_attr(doc,attr)) {
2499 name = qs_get_attr_name(doc,attr);
2500 value = qs_get_attr_value(doc,attr);
2501 if (STRCASEEQ('a','A',"align", name)) {
2502 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2511 return chtml20->out;
2516 * It is a handler who processes the H1 tag.
2518 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2519 * destination is specified.
2520 * @param node [i] The H1 tag node is specified.
2521 * @return The conversion result is returned.
2524 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
2530 chtml20 = GET_CHTML20(pdoc);
2535 return chtml20->out;
2540 * It is a handler who processes the H2 tag.
2542 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2543 * destination is specified.
2544 * @param node [i] The H2 tag node is specified.
2545 * @return The conversion result is returned.
2548 s_chtml20_start_h2_tag(void *pdoc, Node *node)
2555 chtml20 = GET_CHTML20(pdoc);
2560 for (attr = qs_get_attr(doc,node);
2562 attr = qs_get_next_attr(doc,attr)) {
2565 name = qs_get_attr_name(doc,attr);
2566 value = qs_get_attr_value(doc,attr);
2567 if (STRCASEEQ('a','A',"align", name)) {
2568 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2577 return chtml20->out;
2582 * It is a handler who processes the H2 tag.
2584 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2585 * destination is specified.
2586 * @param node [i] The H2 tag node is specified.
2587 * @return The conversion result is returned.
2590 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
2596 chtml20 = GET_CHTML20(pdoc);
2601 return chtml20->out;
2606 * It is a handler who processes the H3 tag.
2608 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2609 * destination is specified.
2610 * @param node [i] The H3 tag node is specified.
2611 * @return The conversion result is returned.
2614 s_chtml20_start_h3_tag(void *pdoc, Node *node)
2621 chtml20 = GET_CHTML20(pdoc);
2626 for (attr = qs_get_attr(doc,node);
2628 attr = qs_get_next_attr(doc,attr)) {
2631 name = qs_get_attr_name(doc,attr);
2632 value = qs_get_attr_value(doc,attr);
2633 if (STRCASEEQ('a','A',"align", name)) {
2634 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2643 return chtml20->out;
2648 * It is a handler who processes the H3 tag.
2650 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2651 * destination is specified.
2652 * @param node [i] The H3 tag node is specified.
2653 * @return The conversion result is returned.
2656 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
2662 chtml20 = GET_CHTML20(pdoc);
2667 return chtml20->out;
2672 * It is a handler who processes the H4 tag.
2674 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2675 * destination is specified.
2676 * @param node [i] The H4 tag node is specified.
2677 * @return The conversion result is returned.
2680 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2687 chtml20 = GET_CHTML20(pdoc);
2692 for (attr = qs_get_attr(doc,node);
2694 attr = qs_get_next_attr(doc,attr)) {
2697 name = qs_get_attr_name(doc,attr);
2698 value = qs_get_attr_value(doc,attr);
2699 if (STRCASEEQ('a','A',"align", name)) {
2700 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2709 return chtml20->out;
2714 * It is a handler who processes the H4 tag.
2716 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2717 * destination is specified.
2718 * @param node [i] The H4 tag node is specified.
2719 * @return The conversion result is returned.
2722 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
2728 chtml20 = GET_CHTML20(pdoc);
2733 return chtml20->out;
2738 * It is a handler who processes the H5 tag.
2740 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2741 * destination is specified.
2742 * @param node [i] The H5 tag node is specified.
2743 * @return The conversion result is returned.
2746 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2753 chtml20 = GET_CHTML20(pdoc);
2758 for (attr = qs_get_attr(doc,node);
2760 attr = qs_get_next_attr(doc,attr)) {
2763 name = qs_get_attr_name(doc,attr);
2764 value = qs_get_attr_value(doc,attr);
2765 if (STRCASEEQ('a','A',"align", name)) {
2766 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2775 return chtml20->out;
2780 * It is a handler who processes the H5 tag.
2782 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2783 * destination is specified.
2784 * @param node [i] The H5 tag node is specified.
2785 * @return The conversion result is returned.
2788 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
2794 chtml20 = GET_CHTML20(pdoc);
2799 return chtml20->out;
2804 * It is a handler who processes the H6 tag.
2806 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2807 * destination is specified.
2808 * @param node [i] The H6 tag node is specified.
2809 * @return The conversion result is returned.
2812 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2819 chtml20 = GET_CHTML20(pdoc);
2824 for (attr = qs_get_attr(doc,node);
2826 attr = qs_get_next_attr(doc,attr)) {
2829 name = qs_get_attr_name(doc,attr);
2830 value = qs_get_attr_value(doc,attr);
2831 if (STRCASEEQ('a','A',"align", name)) {
2832 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2841 return chtml20->out;
2846 * It is a handler who processes the H6 tag.
2848 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2849 * destination is specified.
2850 * @param node [i] The H6 tag node is specified.
2851 * @return The conversion result is returned.
2854 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
2860 chtml20 = GET_CHTML20(pdoc);
2865 return chtml20->out;
2870 * It is a handler who processes the PRE tag.
2872 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2873 * destination is specified.
2874 * @param node [i] The PRE tag node is specified.
2875 * @return The conversion result is returned.
2878 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node))
2884 chtml20 = GET_CHTML20(pdoc);
2888 chtml20->pre_flag++;
2890 return chtml20->out;
2895 * It is a handler who processes the PRE tag.
2897 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2898 * destination is specified.
2899 * @param node [i] The PRE tag node is specified.
2900 * @return The conversion result is returned.
2903 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
2909 chtml20 = GET_CHTML20(pdoc);
2914 chtml20->pre_flag--;
2916 return chtml20->out;
2921 * It is a handler who processes the P tag.
2923 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2924 * destination is specified.
2925 * @param node [i] The P tag node is specified.
2926 * @return The conversion result is returned.
2929 s_chtml20_start_p_tag(void *pdoc, Node *node)
2937 chtml20 = GET_CHTML20(pdoc);
2942 for (attr = qs_get_attr(doc,node);
2944 attr = qs_get_next_attr(doc,attr)) {
2945 char *nm = qs_get_attr_name(doc,attr);
2946 char *val = qs_get_attr_value(doc,attr);
2947 if (STRCASEEQ('a','A',"align", nm)) {
2948 /*----------------------------------------------------------------------*/
2949 /* CHTML 1.0 (W3C version 3.2) */
2950 /*----------------------------------------------------------------------*/
2951 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2952 align = apr_pstrdup(doc->buf.pool, val);
2963 return chtml20->out;
2968 * It is a handler who processes the P tag.
2970 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2971 * destination is specified.
2972 * @param node [i] The P tag node is specified.
2973 * @return The conversion result is returned.
2976 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child))
2982 chtml20 = GET_CHTML20(pdoc);
2987 return chtml20->out;
2992 s_chtml20_chxjif_tag(void *pdoc, Node *node)
2999 chtml20 = GET_CHTML20(pdoc);
3003 for (child = qs_get_child_node(doc, node);
3005 child = qs_get_next_node(doc, child)) {
3008 s_chtml20_chxjif_tag(pdoc, child);
3016 * It is a handler who processes the TEXTARE tag.
3018 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3019 * destination is specified.
3020 * @param node [i] The TEXTAREA tag node is specified.
3021 * @return The conversion result is returned.
3024 s_chtml20_start_textarea_tag(void *pdoc, Node *node)
3031 chtml20 = GET_CHTML20(pdoc);
3035 chtml20->textarea_flag++;
3037 for (attr = qs_get_attr(doc,node);
3039 attr = qs_get_next_attr(doc,attr)) {
3044 name = qs_get_attr_name(doc,attr);
3045 value = qs_get_attr_value(doc,attr);
3050 if (strcasecmp(name, "name") == 0) {
3059 if (strcasecmp(name, "rows") == 0) {
3068 if (strcasecmp(name, "cols") == 0) {
3080 return chtml20->out;
3085 * It is a handler who processes the TEXTAREA tag.
3087 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3088 * destination is specified.
3089 * @param node [i] The TEXTAREA tag node is specified.
3090 * @return The conversion result is returned.
3093 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3099 chtml20 = GET_CHTML20(pdoc);
3103 W_L("</textarea>\r\n");
3104 chtml20->textarea_flag--;
3106 return chtml20->out;
3111 s_chtml20_text_tag(void *pdoc, Node *child)
3123 chtml20 = GET_CHTML20(pdoc);
3127 textval = qs_get_node_value(doc,child);
3128 if (strlen(textval) == 0) {
3129 return chtml20->out;
3132 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3133 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3135 tdst = qs_alloc_zero_byte_string(r);
3136 memset(one_byte, 0, sizeof(one_byte));
3139 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3141 int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3143 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3147 if (is_sjis_kanji(textval[ii])) {
3148 one_byte[0] = textval[ii+0];
3149 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3150 one_byte[0] = textval[ii+1];
3151 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3155 if (chtml20->pre_flag) {
3156 one_byte[0] = textval[ii+0];
3157 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3160 if (chtml20->textarea_flag) {
3161 one_byte[0] = textval[ii+0];
3162 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3165 if (textval[ii] != '\r' && textval[ii] != '\n') {
3166 one_byte[0] = textval[ii+0];
3167 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3171 return chtml20->out;
3176 * It is a handler who processes the BLOCKQUOTE tag.
3178 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3179 * destination is specified.
3180 * @param node [i] The BLOCKQUOTE tag node is specified.
3181 * @return The conversion result is returned.
3184 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3188 chtml20 = GET_CHTML20(pdoc);
3190 W_L("<blockquote>");
3191 return chtml20->out;
3196 * It is a handler who processes the BLOCKQUOTE tag.
3198 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3199 * destination is specified.
3200 * @param node [i] The BLOCKQUOTE tag node is specified.
3201 * @return The conversion result is returned.
3204 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3209 chtml20 = GET_CHTML20(pdoc);
3211 W_L("</blockquote>");
3212 return chtml20->out;
3217 * It is a handler who processes the DIR tag.
3219 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3220 * destination is specified.
3221 * @param node [i] The DIR tag node is specified.
3222 * @return The conversion result is returned.
3225 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3229 chtml20 = GET_CHTML20(pdoc);
3232 return chtml20->out;
3237 * It is a handler who processes the DIR tag.
3239 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3240 * destination is specified.
3241 * @param node [i] The DIR tag node is specified.
3242 * @return The conversion result is returned.
3245 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3250 chtml20 = GET_CHTML20(pdoc);
3253 return chtml20->out;
3258 * It is a handler who processes the DL tag.
3260 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3261 * destination is specified.
3262 * @param node [i] The DL tag node is specified.
3263 * @return The conversion result is returned.
3266 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3270 chtml20 = GET_CHTML20(pdoc);
3273 return chtml20->out;
3278 * It is a handler who processes the DL tag.
3280 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3281 * destination is specified.
3282 * @param node [i] The DL tag node is specified.
3283 * @return The conversion result is returned.
3286 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3290 chtml20 = GET_CHTML20(pdoc);
3293 return chtml20->out;
3298 * It is a handter who processes the DT tag.
3300 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3301 * destination is specified.
3302 * @param node [i] The DT tag node is specified.
3303 * @return The conversion result is returned.
3306 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3310 chtml20 = GET_CHTML20(pdoc);
3313 return chtml20->out;
3318 * It is a handter who processes the DT tag.
3320 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3321 * destination is specified.
3322 * @param node [i] The DT tag node is specified.
3323 * @return The conversion result is returned.
3326 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3329 chtml20 = GET_CHTML20(pdoc);
3330 return chtml20->out;
3335 * It is a handder who processes the DD tag.
3337 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3338 * destination is specified.
3339 * @param node [i] The DD tag node is specified.
3340 * @return The conversion result is returned.
3343 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3347 chtml20 = GET_CHTML20(pdoc);
3350 return chtml20->out;
3355 * It is a handder who processes the DD tag.
3357 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3358 * destination is specified.
3359 * @param node [i] The DD tag node is specified.
3360 * @return The conversion result is returned.
3363 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
3366 chtml20 = GET_CHTML20(pdoc);
3367 return chtml20->out;
3372 * It is a hanmenuer who processes the MENU tag.
3374 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3375 * destination is specified.
3376 * @param node [i] The MENU tag node is specified.
3377 * @return The conversion result is returned.
3380 s_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
3384 chtml20 = GET_CHTML20(pdoc);
3387 return chtml20->out;
3392 * It is a hanmenuer who processes the MENU tag.
3394 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3395 * destination is specified.
3396 * @param node [i] The MENU tag node is specified.
3397 * @return The conversion result is returned.
3400 s_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
3402 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3403 Doc *doc = chtml20->doc;
3405 return chtml20->out;
3410 * It is a hanplaintexter who processes the PLAINTEXT tag.
3412 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3413 * destination is specified.
3414 * @param node [i] The PLAINTEXT tag node is specified.
3415 * @return The conversion result is returned.
3418 s_chtml20_start_plaintext_tag(void *pdoc, Node *node)
3423 chtml20 = GET_CHTML20(pdoc);
3426 s_chtml20_start_plaintext_tag_inner(pdoc,node);
3427 return chtml20->out;
3431 s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
3436 chtml20 = GET_CHTML20(pdoc);
3438 for (child = qs_get_child_node(doc, node);
3440 child = qs_get_next_node(doc, child)) {
3442 s_chtml20_start_plaintext_tag_inner(pdoc, child);
3444 return chtml20->out;
3449 * It is a hanplaintexter who processes the PLAINTEXT tag.
3451 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3452 * destination is specified.
3453 * @param node [i] The PLAINTEXT tag node is specified.
3454 * @return The conversion result is returned.
3457 s_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3459 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3460 return chtml20->out;