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);
105 static void s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
107 static int s_chtml20_search_emoji(chtml20_t *chtml, char *txt, char **rslt);
109 static char *s_chtml20_chxjif_tag(void *pdoc, Node *node);
110 static char *s_chtml20_text_tag(void *pdoc, Node *node);
113 tag_handler chtml20_handler[] = {
116 s_chtml20_start_html_tag,
117 s_chtml20_end_html_tag,
121 s_chtml20_start_meta_tag,
122 s_chtml20_end_meta_tag,
126 s_chtml20_start_textarea_tag,
127 s_chtml20_end_textarea_tag,
131 s_chtml20_start_p_tag,
136 s_chtml20_start_pre_tag,
137 s_chtml20_end_pre_tag,
141 s_chtml20_start_ul_tag,
142 s_chtml20_end_ul_tag,
146 s_chtml20_start_li_tag,
147 s_chtml20_end_li_tag,
151 s_chtml20_start_ol_tag,
152 s_chtml20_end_ol_tag,
156 s_chtml20_start_h1_tag,
157 s_chtml20_end_h1_tag,
161 s_chtml20_start_h2_tag,
162 s_chtml20_end_h2_tag,
166 s_chtml20_start_h3_tag,
167 s_chtml20_end_h3_tag,
171 s_chtml20_start_h4_tag,
172 s_chtml20_end_h4_tag,
176 s_chtml20_start_h5_tag,
177 s_chtml20_end_h5_tag,
181 s_chtml20_start_h6_tag,
182 s_chtml20_end_h6_tag,
186 s_chtml20_start_head_tag,
187 s_chtml20_end_head_tag,
191 s_chtml20_start_title_tag,
192 s_chtml20_end_title_tag,
196 s_chtml20_start_base_tag,
197 s_chtml20_end_base_tag,
201 s_chtml20_start_body_tag,
202 s_chtml20_end_body_tag,
206 s_chtml20_start_a_tag,
211 s_chtml20_start_br_tag,
212 s_chtml20_end_br_tag,
221 s_chtml20_start_tr_tag,
222 s_chtml20_end_tr_tag,
236 s_chtml20_start_font_tag,
237 s_chtml20_end_font_tag,
241 s_chtml20_start_form_tag,
242 s_chtml20_end_form_tag,
246 s_chtml20_start_input_tag,
247 s_chtml20_end_input_tag,
251 s_chtml20_start_center_tag,
252 s_chtml20_end_center_tag,
256 s_chtml20_start_hr_tag,
257 s_chtml20_end_hr_tag,
261 s_chtml20_start_img_tag,
262 s_chtml20_end_img_tag,
266 s_chtml20_start_select_tag,
267 s_chtml20_end_select_tag,
271 s_chtml20_start_option_tag,
272 s_chtml20_end_option_tag,
276 s_chtml20_start_div_tag,
277 s_chtml20_end_div_tag,
281 s_chtml20_chxjif_tag,
326 s_chtml20_start_dt_tag,
327 s_chtml20_end_dt_tag,
341 s_chtml20_start_blockquote_tag,
342 s_chtml20_end_blockquote_tag,
346 s_chtml20_start_dir_tag,
347 s_chtml20_end_dir_tag,
351 s_chtml20_start_dl_tag,
352 s_chtml20_end_dl_tag,
356 s_chtml20_start_dd_tag,
357 s_chtml20_end_dd_tag,
361 s_chtml20_start_menu_tag,
362 s_chtml20_end_menu_tag,
372 * converts from CHTML5.0 to CHTML2.0.
374 * @param r [i] Requet_rec is appointed.
375 * @param spec [i] The result of the device specification processing which
376 * was done in advance is appointed.
377 * @param src [i] The character string before the converting is appointed.
378 * @return The character string after the converting is returned.
381 chxj_exchange_chtml20(
387 chxjconvrule_entry *entryp,
396 /*--------------------------------------------------------------------------*/
398 /*--------------------------------------------------------------------------*/
400 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
402 DBG(r,"i found qrcode xml");
405 DBG(r,"not found qrcode xml");
407 /*--------------------------------------------------------------------------*/
408 /* The CHTML structure is initialized. */
409 /*--------------------------------------------------------------------------*/
410 s_init_chtml20(&chtml20, &doc, r, spec);
413 chtml20.entryp = entryp;
414 chtml20.cookie = cookie;
416 chxj_set_content_type(r, "text/html; charset=Windows-31J");
418 /*--------------------------------------------------------------------------*/
419 /* The character string of the input is analyzed. */
420 /*--------------------------------------------------------------------------*/
421 qs_init_malloc(&doc);
422 qs_init_root_node(&doc);
424 ss = apr_pcalloc(r->pool, srclen + 1);
425 memset(ss, 0, srclen + 1);
426 memcpy(ss, src, srclen);
429 chxj_dump_out("[src] CHTML -> CHTML2.0", ss, srclen);
432 qs_parse_string(&doc,ss, strlen(ss));
434 chxj_buffered_write_init(r->pool, &doc.buf);
435 /*--------------------------------------------------------------------------*/
436 /* It converts it from CHTML to CHTML. */
437 /*--------------------------------------------------------------------------*/
438 chxj_node_exchange(spec,r,(void *)&chtml20, &doc, qs_get_root(&doc), 0);
439 chtml20.out = chxj_buffered_write_flush(chtml20.out, &doc.buf);
440 dst = apr_pstrdup(r->pool, chtml20.out);
441 chxj_buffered_write_terminate(&doc.buf);
443 qs_all_free(&doc,QX_LOGMARK);
446 return apr_pstrdup(r->pool,ss);
449 if (strlen(dst) == 0) {
450 dst = apr_psprintf(r->pool, "\n");
453 *dstlen = strlen(dst);
456 chxj_dump_out("[dst] CHTML -> CHTML2.0", dst, *dstlen);
463 * The CHTML structure is initialized.
465 * @param chtml20 [i/o] The pointer to the HDML structure that wants to be
466 * initialized is specified.
467 * @param doc [i] The Doc structure that should be set to the initialized
468 * HDML structure is specified.
469 * @param r [i] To use POOL, the pointer to request_rec is specified.
470 * @param spec [i] The pointer to the device_table
473 s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
475 memset(doc, 0, sizeof(Doc));
476 memset(chtml20, 0, sizeof(chtml20_t));
480 chtml20->spec = spec;
481 chtml20->out = qs_alloc_zero_byte_string(r);
482 chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
484 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
489 * Corresponding EMOJI to a current character-code is retrieved.
490 * The substitution character string is stored in the rslt pointer if agreeing.
492 * @param chtml20 [i] The pointer to the CHTML structure is specified.
493 * @param txt [i] The character string to want to examine whether it is
494 * EMOJI is specified.
495 * @param rslt [o] The pointer to the pointer that stores the result is
497 * @return When corresponding EMOJI exists, it returns it excluding 0.
500 s_chtml20_search_emoji(chtml20_t *chtml20, char *txt, char **rslt)
507 spec = chtml20->spec;
513 DBG(r,"spec is NULL");
515 for (ee = chtml20->conf->emoji;
519 if (ee->imode == NULL) {
520 DBG(r,"emoji->imode is NULL");
524 if (ee->imode->string != NULL
525 && strlen(ee->imode->string) > 0
526 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
527 if (spec == NULL || spec->emoji_type == NULL) {
528 *rslt = apr_palloc(r->pool, 3);
529 (*rslt)[0] = ee->imode->hex1byte & 0xff;
530 (*rslt)[1] = ee->imode->hex2byte & 0xff;
532 return strlen(ee->imode->string);
544 * It is a handler who processes the HTML tag.
546 * @param pdoc [i/o] The pointer to the CHTML structure at the output
547 * destination is specified.
548 * @param node [i] The HTML tag node is specified.
549 * @return The conversion result is returned.
552 s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
558 chtml20 = GET_CHTML20(pdoc);
562 /*--------------------------------------------------------------------------*/
564 /*--------------------------------------------------------------------------*/
571 * It is a handler who processes the HTML tag.
573 * @param pdoc [i/o] The pointer to the CHTML structure at the output
574 * destination is specified.
575 * @param node [i] The HTML tag node is specified.
576 * @return The conversion result is returned.
579 s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child))
585 chtml20 = GET_CHTML20(pdoc);
595 * It is a handler who processes the META tag.
597 * @param pdoc [i/o] The pointer to the CHTML structure at the output
598 * destination is specified.
599 * @param node [i] The META tag node is specified.
600 * @return The conversion result is returned.
603 s_chtml20_start_meta_tag(void *pdoc, Node *node)
609 int content_type_flag;
612 chtml20 = GET_CHTML20(pdoc);
616 content_type_flag = 0;
620 /*--------------------------------------------------------------------------*/
622 /*--------------------------------------------------------------------------*/
623 for (attr = qs_get_attr(doc,node);
625 attr = qs_get_next_attr(doc,attr)) {
630 name = qs_get_attr_name(doc,attr);
631 value = qs_get_attr_value(doc,attr);
636 if (strcasecmp(name, "http-equiv") == 0) {
637 /*----------------------------------------------------------------------*/
639 /*----------------------------------------------------------------------*/
640 W_L(" http-equiv=\"");
643 if (STRCASEEQ('c','C',"content-type", value)) {
644 content_type_flag = 1;
646 if (STRCASEEQ('r','R',"refresh", value)) {
654 if (strcasecmp(name, "content") == 0) {
655 if (content_type_flag) {
658 W_L("=\"text/html; charset=Windows-31J\"");
660 else if (refresh_flag) {
661 char *buf = apr_pstrdup(r->pool, value);
665 url = strchr(buf, ';');
667 sec = apr_pstrdup(r->pool, buf);
670 url = chxj_encoding_parameter(r, url);
671 url = chxj_add_cookie_parameter(r, url, chtml20->cookie);
701 * It is a handler who processes the META tag.
703 * @param pdoc [i/o] The pointer to the CHTML structure at the output
704 * destination is specified.
705 * @param node [i] The META tag node is specified.
706 * @return The conversion result is returned.
709 s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child))
713 chtml20 = GET_CHTML20(pdoc);
720 * It is a handler who processes the HEAD tag.
722 * @param pdoc [i/o] The pointer to the CHTML structure at the output
723 * destination is specified.
724 * @param node [i] The HEAD tag node is specified.
725 * @return The conversion result is returned.
728 s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node))
734 chtml20 = GET_CHTML20(pdoc);
744 * It is a handler who processes the HEAD tag.
746 * @param pdoc [i/o] The pointer to the CHTML structure at the output
747 * destination is specified.
748 * @param node [i] The HEAD tag node is specified.
749 * @return The conversion result is returned.
752 s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child))
758 chtml20 = GET_CHTML20(pdoc);
768 * It is a handler who processes the TITLE tag.
770 * @param pdoc [i/o] The pointer to the CHTML structure at the output
771 * destination is specified.
772 * @param node [i] The TITLE tag node is specified.
773 * @return The conversion result is returned.
776 s_chtml20_start_title_tag(void *pdoc, Node *UNUSED(node))
782 chtml20 = GET_CHTML20(pdoc);
792 * It is a handler who processes the TITLE tag.
794 * @param pdoc [i/o] The pointer to the CHTML structure at the output
795 * destination is specified.
796 * @param node [i] The TITLE tag node is specified.
797 * @return The conversion result is returned.
800 s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
806 chtml20 = GET_CHTML20(pdoc);
816 * It is a handler who processes the BASE tag.
818 * @param pdoc [i/o] The pointer to the CHTML structure at the output
819 * destination is specified.
820 * @param node [i] The BASE tag node is specified.
821 * @return The conversion result is returned.
824 s_chtml20_start_base_tag(void *pdoc, Node *node)
831 chtml20 = GET_CHTML20(pdoc);
836 /*--------------------------------------------------------------------------*/
838 /*--------------------------------------------------------------------------*/
839 for (attr = qs_get_attr(doc,node);
841 attr = qs_get_next_attr(doc,attr)) {
846 name = qs_get_attr_name(doc,attr);
847 value = qs_get_attr_value(doc,attr);
849 if (STRCASEEQ('h','H',"href", name)) {
861 * It is a handler who processes the BASE tag.
863 * @param pdoc [i/o] The pointer to the CHTML structure at the output
864 * destination is specified.
865 * @param node [i] The BASE tag node is specified.
866 * @return The conversion result is returned.
869 s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child))
875 chtml20 = GET_CHTML20(pdoc);
884 * It is a handler who processes the BODY tag.
886 * @param pdoc [i/o] The pointer to the CHTML structure at the output
887 * destination is specified.
888 * @param node [i] The BODY tag node is specified.
889 * @return The conversion result is returned.
892 s_chtml20_start_body_tag(void *pdoc, Node *node)
899 chtml20 = GET_CHTML20(pdoc);
904 /*--------------------------------------------------------------------------*/
906 /*--------------------------------------------------------------------------*/
907 for (attr = qs_get_attr(doc,node);
909 attr = qs_get_next_attr(doc,attr)) {
913 name = qs_get_attr_name(doc,attr);
914 value = qs_get_attr_value(doc,attr);
919 if (strcasecmp(name, "bgcolor") == 0 && value && *value != 0) {
920 /*----------------------------------------------------------------------*/
922 /*----------------------------------------------------------------------*/
931 if (strcasecmp(name, "text") == 0 && value && *value != 0) {
932 /*----------------------------------------------------------------------*/
934 /*----------------------------------------------------------------------*/
943 if (strcasecmp(name, "link") == 0 && value && *value != 0) {
944 /*----------------------------------------------------------------------*/
946 /*----------------------------------------------------------------------*/
955 if (strcasecmp(name, "alink") == 0) {
956 /*----------------------------------------------------------------------*/
958 /*----------------------------------------------------------------------*/
965 if (strcasecmp(name, "vlink") == 0) {
966 /*----------------------------------------------------------------------*/
968 /*----------------------------------------------------------------------*/
983 * It is a handler who processes the BODY tag.
985 * @param pdoc [i/o] The pointer to the CHTML structure at the output
986 * destination is specified.
987 * @param node [i] The BODY tag node is specified.
988 * @return The conversion result is returned.
991 s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child))
997 chtml20 = GET_CHTML20(pdoc);
1002 return chtml20->out;
1007 * It is a handler who processes the A tag.
1009 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1010 * destination is specified.
1011 * @param node [i] The A tag node is specified.
1012 * @return The conversion result is returned.
1015 s_chtml20_start_a_tag(void *pdoc, Node *node)
1022 chtml20 = GET_CHTML20(pdoc);
1027 /*--------------------------------------------------------------------------*/
1028 /* Get Attributes */
1029 /*--------------------------------------------------------------------------*/
1030 for (attr = qs_get_attr(doc,node);
1032 attr = qs_get_next_attr(doc,attr)) {
1037 name = qs_get_attr_name(doc,attr);
1038 value = qs_get_attr_value(doc,attr);
1043 if (strcasecmp(name, "name") == 0) {
1044 /*--------------------------------------------------------------------*/
1046 /*--------------------------------------------------------------------*/
1055 if (strcasecmp(name, "href") == 0) {
1056 /*--------------------------------------------------------------------*/
1058 /*--------------------------------------------------------------------*/
1059 value = chxj_encoding_parameter(r, value);
1060 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1069 if (strcasecmp(name, "accesskey") == 0) {
1070 /*--------------------------------------------------------------------*/
1072 /*--------------------------------------------------------------------*/
1073 W_L(" accesskey=\"");
1081 if (strcasecmp(name, "cti") == 0) {
1082 /*--------------------------------------------------------------------*/
1084 /*--------------------------------------------------------------------*/
1093 if (strcasecmp(name, "ijam") == 0) {
1094 /*--------------------------------------------------------------------*/
1096 /*--------------------------------------------------------------------*/
1100 if (strcasecmp(name, "ista") == 0) {
1101 /*--------------------------------------------------------------------*/
1103 /*--------------------------------------------------------------------*/
1107 if (strcasecmp(name, "ilet") == 0) {
1108 /*--------------------------------------------------------------------*/
1110 /*--------------------------------------------------------------------*/
1114 if (strcasecmp(name, "iswf") == 0) {
1115 /*--------------------------------------------------------------------*/
1117 /*--------------------------------------------------------------------*/
1121 if (strcasecmp(name, "irst") == 0) {
1122 /*--------------------------------------------------------------------*/
1124 /*--------------------------------------------------------------------*/
1131 if (strcasecmp(name, "utn") == 0) {
1132 /*--------------------------------------------------------------------*/
1134 /*--------------------------------------------------------------------*/
1141 if (strcasecmp(name, "telbook") == 0) {
1142 /*--------------------------------------------------------------------*/
1144 /*--------------------------------------------------------------------*/
1151 if (strcasecmp(name, "kana") == 0) {
1152 /*--------------------------------------------------------------------*/
1154 /*--------------------------------------------------------------------*/
1161 if (strcasecmp(name, "email") == 0) {
1162 /*--------------------------------------------------------------------*/
1164 /*--------------------------------------------------------------------*/
1174 return chtml20->out;
1179 * It is a handler who processes the A tag.
1181 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1182 * destination is specified.
1183 * @param node [i] The A tag node is specified.
1184 * @return The conversion result is returned.
1187 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
1193 chtml20 = GET_CHTML20(pdoc);
1198 return chtml20->out;
1203 * It is a handler who processes the BR tag.
1205 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1206 * destination is specified.
1207 * @param node [i] The BR tag node is specified.
1208 * @return The conversion result is returned.
1211 s_chtml20_start_br_tag(void *pdoc, Node *node)
1218 chtml20 = GET_CHTML20(pdoc);
1223 /*--------------------------------------------------------------------------*/
1224 /* Get Attributes */
1225 /*--------------------------------------------------------------------------*/
1226 for (attr = qs_get_attr(doc,node);
1228 attr = qs_get_next_attr(doc,attr)) {
1232 name = qs_get_attr_name(doc,attr);
1233 value = qs_get_attr_value(doc,attr);
1235 if (STRCASEEQ('c','C',"clear",name)) {
1236 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1244 return chtml20->out;
1249 * It is a handler who processes the BR tag.
1251 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1252 * destination is specified.
1253 * @param node [i] The BR tag node is specified.
1254 * @return The conversion result is returned.
1257 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
1263 chtml20 = GET_CHTML20(pdoc);
1267 return chtml20->out;
1272 * It is a handler who processes the TR tag.
1274 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1275 * destination is specified.
1276 * @param node [i] The TR tag node is specified.
1277 * @return The conversion result is returned.
1280 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
1286 chtml20 = GET_CHTML20(pdoc);
1290 return chtml20->out;
1295 * It is a handler who processes the TR tag.
1297 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1298 * destination is specified.
1299 * @param node [i] The TR tag node is specified.
1300 * @return The conversion result is returned.
1303 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
1309 chtml20 = GET_CHTML20(pdoc);
1314 return chtml20->out;
1319 * It is a handler who processes the FONT tag.
1321 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1322 * destination is specified.
1323 * @param node [i] The FONT tag node is specified.
1324 * @return The conversion result is returned.
1327 s_chtml20_start_font_tag(void *pdoc, Node *node)
1334 chtml20 = GET_CHTML20(pdoc);
1340 /*--------------------------------------------------------------------------*/
1341 /* Get Attributes */
1342 /*--------------------------------------------------------------------------*/
1343 for (attr = qs_get_attr(doc,node);
1345 attr = qs_get_next_attr(doc,attr)) {
1350 name = qs_get_attr_name(doc,attr);
1351 value = qs_get_attr_value(doc,attr);
1356 if (strcasecmp(name, "color") == 0) {
1365 if (strcasecmp(name, "size") == 0) {
1366 /*--------------------------------------------------------------------*/
1368 /*--------------------------------------------------------------------*/
1378 return chtml20->out;
1383 * It is a handler who processes the FONT tag.
1385 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1386 * destination is specified.
1387 * @param node [i] The FONT tag node is specified.
1388 * @return The conversion result is returned.
1391 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child))
1397 chtml20 = GET_CHTML20(pdoc);
1402 return chtml20->out;
1407 * It is a handler who processes the FORM tag.
1409 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1410 * destination is specified.
1411 * @param node [i] The FORM tag node is specified.
1412 * @return The conversion result is returned.
1415 s_chtml20_start_form_tag(void *pdoc, Node *node)
1422 chtml20 = GET_CHTML20(pdoc);
1427 /*--------------------------------------------------------------------------*/
1428 /* Get Attributes */
1429 /*--------------------------------------------------------------------------*/
1430 for (attr = qs_get_attr(doc,node);
1432 attr = qs_get_next_attr(doc,attr)) {
1437 name = qs_get_attr_name(doc,attr);
1438 value = qs_get_attr_value(doc,attr);
1443 if (strcasecmp(name, "action") == 0) {
1444 /*--------------------------------------------------------------------*/
1446 /*--------------------------------------------------------------------*/
1447 value = chxj_encoding_parameter(r, value);
1448 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1458 if (strcasecmp(name, "method") == 0) {
1459 /*--------------------------------------------------------------------*/
1461 /*--------------------------------------------------------------------*/
1470 if (strcasecmp(name, "utn") == 0) {
1471 /*--------------------------------------------------------------------*/
1473 /*--------------------------------------------------------------------*/
1483 return chtml20->out;
1488 * It is a handler who processes the FORM tag.
1490 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1491 * destination is specified.
1492 * @param node [i] The FORM tag node is specified.
1493 * @return The conversion result is returned.
1496 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child))
1502 chtml20 = GET_CHTML20(pdoc);
1507 return chtml20->out;
1512 * It is a handler who processes the INPUT tag.
1514 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1515 * destination is specified.
1516 * @param node [i] The INPUT tag node is specified.
1517 * @return The conversion result is returned.
1520 s_chtml20_start_input_tag(void *pdoc, Node *node)
1525 char *max_length = NULL;
1529 char *istyle = NULL;
1531 char *checked = NULL;
1532 char *accesskey = NULL;
1534 chtml20 = GET_CHTML20(pdoc);
1540 /*--------------------------------------------------------------------------*/
1541 /* Get Attributes */
1542 /*--------------------------------------------------------------------------*/
1544 type = qs_get_type_attr(doc, node, r);
1545 name = qs_get_name_attr(doc, node, r);
1546 value = qs_get_value_attr(doc,node,r);
1547 istyle = qs_get_istyle_attr(doc,node,r);
1548 max_length = qs_get_maxlength_attr(doc,node,r);
1549 checked = qs_get_checked_attr(doc,node,r);
1550 accesskey = qs_get_accesskey_attr(doc, node, r);
1551 size = qs_get_size_attr(doc, node, r);
1554 type = qs_trim_string(doc->buf.pool, type);
1555 if (type && (STRCASEEQ('t','T',"text", type) ||
1556 STRCASEEQ('p','P',"password",type) ||
1557 STRCASEEQ('c','C',"checkbox",type) ||
1558 STRCASEEQ('r','R',"radio", type) ||
1559 STRCASEEQ('h','H',"hidden", type) ||
1560 STRCASEEQ('s','S',"submit", type) ||
1561 STRCASEEQ('r','R',"reset", type))) {
1568 if (size && *size) {
1574 if (name && *name) {
1580 if (value && *value) {
1586 if (accesskey && *accesskey) {
1587 W_L(" accesskey=\"");
1593 /*------------------------------------------------------------------------*/
1595 /*------------------------------------------------------------------------*/
1596 if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1603 /*--------------------------------------------------------------------------*/
1604 /* The figure is default for the password. */
1605 /*--------------------------------------------------------------------------*/
1606 if (max_length && *max_length) {
1607 if (chxj_chk_numeric(max_length) != 0) {
1608 max_length = apr_psprintf(doc->buf.pool, "0");
1610 if (istyle && *istyle == '1') {
1611 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1615 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1624 return chtml20->out;
1629 * It is a handler who processes the INPUT tag.
1631 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1632 * destination is specified.
1633 * @param node [i] The INPUT tag node is specified.
1634 * @return The conversion result is returned.
1637 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child))
1643 chtml20 = GET_CHTML20(pdoc);
1647 return chtml20->out;
1652 * It is a handler who processes the CENTER tag.
1654 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1655 * destination is specified.
1656 * @param node [i] The CENTER tag node is specified.
1657 * @return The conversion result is returned.
1660 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node))
1666 chtml20 = GET_CHTML20(pdoc);
1671 return chtml20->out;
1676 * It is a handler who processes the CENTER tag.
1678 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1679 * destination is specified.
1680 * @param node [i] The CENTER tag node is specified.
1681 * @return The conversion result is returned.
1684 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child))
1690 chtml20 = GET_CHTML20(pdoc);
1695 return chtml20->out;
1700 * It is a handler who processes the UL tag.
1702 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1703 * destination is specified.
1704 * @param node [i] The UL tag node is specified.
1705 * @return The conversion result is returned.
1708 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node))
1714 chtml20 = GET_CHTML20(pdoc);
1719 return chtml20->out;
1724 * It is a handler who processes the UL tag.
1726 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1727 * destination is specified.
1728 * @param node [i] The UL tag node is specified.
1729 * @return The conversion result is returned.
1732 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
1738 chtml20 = GET_CHTML20(pdoc);
1743 return chtml20->out;
1748 * It is a handler who processes the OL tag.
1750 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1751 * destination is specified.
1752 * @param node [i] The OL tag node is specified.
1753 * @return The conversion result is returned.
1756 s_chtml20_start_ol_tag(void *pdoc, Node *node)
1763 chtml20 = GET_CHTML20(pdoc);
1768 /*--------------------------------------------------------------------------*/
1769 /* Get Attributes */
1770 /*--------------------------------------------------------------------------*/
1771 for (attr = qs_get_attr(doc,node);
1773 attr = qs_get_next_attr(doc,attr)) {
1774 char *name = qs_get_attr_name(doc,attr);
1775 char *value = qs_get_attr_value(doc,attr);
1776 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1781 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1788 return chtml20->out;
1793 * It is a handler who processes the OL tag.
1795 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1796 * destination is specified.
1797 * @param node [i] The OL tag node is specified.
1798 * @return The conversion result is returned.
1801 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
1807 chtml20 = GET_CHTML20(pdoc);
1812 return chtml20->out;
1817 * It is a handler who processes the LI tag.
1819 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1820 * destination is specified.
1821 * @param node [i] The LI tag node is specified.
1822 * @return The conversion result is returned.
1825 s_chtml20_start_li_tag(void *pdoc, Node *node)
1832 chtml20 = GET_CHTML20(pdoc);
1837 /*--------------------------------------------------------------------------*/
1838 /* Get Attributes */
1839 /*--------------------------------------------------------------------------*/
1840 for (attr = qs_get_attr(doc,node);
1842 attr = qs_get_next_attr(doc,attr)) {
1843 char *name = qs_get_attr_name(doc,attr);
1844 char *value = qs_get_attr_value(doc,attr);
1845 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1850 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1857 return chtml20->out;
1862 * It is a handler who processes the LI tag.
1864 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1865 * destination is specified.
1866 * @param node [i] The LI tag node is specified.
1867 * @return The conversion result is returned.
1870 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
1872 chtml20_t *chtml20 = GET_CHTML20(pdoc);
1873 return chtml20->out;
1878 * It is a handler who processes the HR tag.
1880 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1881 * destination is specified.
1882 * @param node [i] The HR tag node is specified.
1883 * @return The conversion result is returned.
1886 s_chtml20_start_hr_tag(void *pdoc, Node *node)
1893 chtml20 = GET_CHTML20(pdoc);
1899 for (attr = qs_get_attr(doc,node);
1901 attr = qs_get_next_attr(doc,attr)) {
1906 name = qs_get_attr_name(doc,attr);
1907 value = qs_get_attr_value(doc,attr);
1912 if (strcasecmp(name, "align") == 0) {
1913 /*--------------------------------------------------------------------*/
1915 /*--------------------------------------------------------------------*/
1916 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1926 if (strcasecmp(name, "size") == 0) {
1927 /*--------------------------------------------------------------------*/
1929 /*--------------------------------------------------------------------*/
1930 if (value && value[0] != '\0') {
1940 if (strcasecmp(name, "width") == 0) {
1941 /*--------------------------------------------------------------------*/
1943 /*--------------------------------------------------------------------*/
1944 if (value && value[0] != '\0') {
1954 if (strcasecmp(name, "noshade") == 0) {
1955 /*--------------------------------------------------------------------*/
1957 /*--------------------------------------------------------------------*/
1964 if (strcasecmp(name, "color") == 0) {
1965 /*--------------------------------------------------------------------*/
1967 /*--------------------------------------------------------------------*/
1977 return chtml20->out;
1982 * It is a handler who processes the HR tag.
1984 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1985 * destination is specified.
1986 * @param node [i] The HR tag node is specified.
1987 * @return The conversion result is returned.
1990 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
1996 chtml20 = GET_CHTML20(pdoc);
2000 return chtml20->out;
2005 * It is a handler who processes the IMG tag.
2007 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2008 * destination is specified.
2009 * @param node [i] The IMG tag node is specified.
2010 * @return The conversion result is returned.
2013 s_chtml20_start_img_tag(void *pdoc, Node *node)
2019 #ifndef IMG_NOT_CONVERT_FILENAME
2023 chtml20 = GET_CHTML20(pdoc);
2027 #ifndef IMG_NOT_CONVERT_FILENAME
2028 spec = chtml20->spec;
2032 /*-------------------------------------------------------------------------*/
2033 /* Get Attributes */
2034 /*-------------------------------------------------------------------------*/
2035 for (attr = qs_get_attr(doc,node);
2037 attr = qs_get_next_attr(doc,attr)) {
2042 name = qs_get_attr_name(doc,attr);
2043 value = qs_get_attr_value(doc,attr);
2048 if (strcasecmp(name, "src") == 0) {
2049 /*-------------------------------------------------------------------*/
2051 /*-------------------------------------------------------------------*/
2052 #ifdef IMG_NOT_CONVERT_FILENAME
2053 value = chxj_encoding_parameter(r, value);
2054 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2056 value = apr_psprintf(doc->buf.pool,
2059 (strchr(value, '?')) ? '&' : '?',
2060 CHXJ_COOKIE_NOUPDATE_PARAM);
2066 value = chxj_img_conv(r, spec, value);
2067 value = chxj_encoding_parameter(r, value);
2068 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2070 value = apr_psprintf(doc->buf.pool,
2073 (strchr(value, '?')) ? '&' : '?',
2074 CHXJ_COOKIE_NOUPDATE_PARAM);
2085 if (strcasecmp(name, "align" ) == 0) {
2086 /*--------------------------------------------------------------------*/
2088 /*--------------------------------------------------------------------*/
2089 if (value && (STRCASEEQ('t','T',"top", value) ||
2090 STRCASEEQ('m','M',"middle",value) ||
2091 STRCASEEQ('b','B',"bottom",value) ||
2092 STRCASEEQ('l','L',"left", value) ||
2093 STRCASEEQ('r','R',"right", value))) {
2099 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2100 /*--------------------------------------------------------------------*/
2102 /*--------------------------------------------------------------------*/
2111 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2112 /*--------------------------------------------------------------------*/
2114 /*--------------------------------------------------------------------*/
2123 if (strcasecmp(name, "height") == 0 && value && *value) {
2124 /*--------------------------------------------------------------------*/
2126 /*--------------------------------------------------------------------*/
2131 else if (strcasecmp(name, "hspace") == 0 && value && *value) {
2132 /*--------------------------------------------------------------------*/
2134 /*--------------------------------------------------------------------*/
2143 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2144 /*--------------------------------------------------------------------*/
2146 /*--------------------------------------------------------------------*/
2158 return chtml20->out;
2163 * It is a handler who processes the IMG tag.
2165 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2166 * destination is specified.
2167 * @param node [i] The IMG tag node is specified.
2168 * @return The conversion result is returned.
2171 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
2177 chtml20 = GET_CHTML20(pdoc);
2181 return chtml20->out;
2186 * It is a handler who processes the SELECT tag.
2188 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2189 * destination is specified.
2190 * @param node [i] The SELECT tag node is specified.
2191 * @return The conversion result is returned.
2194 s_chtml20_start_select_tag(void *pdoc, Node *child)
2201 chtml20 = GET_CHTML20(pdoc);
2209 for (attr = qs_get_attr(doc,child);
2211 attr = qs_get_next_attr(doc,attr)) {
2216 nm = qs_get_attr_name(doc,attr);
2217 val = qs_get_attr_value(doc,attr);
2222 if (strcasecmp(nm, "size") == 0) {
2223 /*--------------------------------------------------------------------*/
2224 /* CHTML 1.0 version 2.0 */
2225 /*--------------------------------------------------------------------*/
2226 size = apr_pstrdup(doc->buf.pool, val);
2232 if (strcasecmp(nm, "name") == 0) {
2233 /*--------------------------------------------------------------------*/
2234 /* CHTML 1.0 version 2.0 */
2235 /*--------------------------------------------------------------------*/
2236 name = apr_pstrdup(doc->buf.pool, val);
2242 if (strcasecmp(nm, "multiple") == 0) {
2243 /*--------------------------------------------------------------------*/
2244 /* CHTML 1.0 version 2.0 */
2245 /*--------------------------------------------------------------------*/
2268 return chtml20->out;
2273 * It is a handler who processes the SELECT tag.
2275 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2276 * destination is specified.
2277 * @param node [i] The SELECT tag node is specified.
2278 * @return The conversion result is returned.
2281 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2287 chtml20 = GET_CHTML20(pdoc);
2291 W_L("</select>\r\n");
2292 return chtml20->out;
2297 * It is a handler who processes the OPTION tag.
2299 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2300 * destination is specified.
2301 * @param node [i] The OPTION tag node is specified.
2302 * @return The conversion result is returned.
2305 s_chtml20_start_option_tag(void *pdoc, Node *child)
2312 chtml20 = GET_CHTML20(pdoc);
2316 char *selected = NULL;
2320 for (attr = qs_get_attr(doc,child);
2322 attr = qs_get_next_attr(doc,attr)) {
2327 nm = qs_get_attr_name(doc,attr);
2328 val = qs_get_attr_value(doc,attr);
2333 if (strcasecmp(nm, "selected") == 0) {
2334 /*--------------------------------------------------------------------*/
2335 /* CHTML 1.0 version 2.0 */
2336 /*--------------------------------------------------------------------*/
2337 selected = apr_pstrdup(doc->buf.pool, val);
2343 if (strcasecmp(nm, "value") == 0) {
2344 /*--------------------------------------------------------------------*/
2345 /* CHTML 1.0 version 2.0 */
2346 /*--------------------------------------------------------------------*/
2347 value = apr_pstrdup(doc->buf.pool, val);
2356 if (value && *value) {
2366 return chtml20->out;
2371 * It is a handler who processes the OPTION tag.
2373 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2374 * destination is specified.
2375 * @param node [i] The OPTION tag node is specified.
2376 * @return The conversion result is returned.
2379 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2385 chtml20 = GET_CHTML20(pdoc);
2391 return chtml20->out;
2396 * It is a handler who processes the DIV tag.
2398 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2399 * destination is specified.
2400 * @param node [i] The DIV tag node is specified.
2401 * @return The conversion result is returned.
2404 s_chtml20_start_div_tag(void *pdoc, Node *child)
2411 chtml20 = GET_CHTML20(pdoc);
2419 for (attr = qs_get_attr(doc,child);
2421 attr = qs_get_next_attr(doc,attr)) {
2426 nm = qs_get_attr_name(doc,attr);
2427 val = qs_get_attr_value(doc,attr);
2429 if (STRCASEEQ('a','A', "align", nm)) {
2430 /*----------------------------------------------------------------------*/
2431 /* CHTML 1.0 (W3C version 3.2) */
2432 /*----------------------------------------------------------------------*/
2433 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2434 align = apr_pstrdup(doc->buf.pool, val);
2446 return chtml20->out;
2451 * It is a handler who processes the DIV tag.
2453 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2454 * destination is specified.
2455 * @param node [i] The DIV tag node is specified.
2456 * @return The conversion result is returned.
2459 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2465 chtml20 = GET_CHTML20(pdoc);
2470 return chtml20->out;
2475 * It is a handler who processes the H1 tag.
2477 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2478 * destination is specified.
2479 * @param node [i] The H1 tag node is specified.
2480 * @return The conversion result is returned.
2483 s_chtml20_start_h1_tag(void *pdoc, Node *node)
2490 chtml20 = GET_CHTML20(pdoc);
2495 for (attr = qs_get_attr(doc,node);
2497 attr = qs_get_next_attr(doc,attr)) {
2500 name = qs_get_attr_name(doc,attr);
2501 value = qs_get_attr_value(doc,attr);
2502 if (STRCASEEQ('a','A',"align", name)) {
2503 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2512 return chtml20->out;
2517 * It is a handler who processes the H1 tag.
2519 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2520 * destination is specified.
2521 * @param node [i] The H1 tag node is specified.
2522 * @return The conversion result is returned.
2525 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
2531 chtml20 = GET_CHTML20(pdoc);
2536 return chtml20->out;
2541 * It is a handler who processes the H2 tag.
2543 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2544 * destination is specified.
2545 * @param node [i] The H2 tag node is specified.
2546 * @return The conversion result is returned.
2549 s_chtml20_start_h2_tag(void *pdoc, Node *node)
2556 chtml20 = GET_CHTML20(pdoc);
2561 for (attr = qs_get_attr(doc,node);
2563 attr = qs_get_next_attr(doc,attr)) {
2566 name = qs_get_attr_name(doc,attr);
2567 value = qs_get_attr_value(doc,attr);
2568 if (STRCASEEQ('a','A',"align", name)) {
2569 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2578 return chtml20->out;
2583 * It is a handler who processes the H2 tag.
2585 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2586 * destination is specified.
2587 * @param node [i] The H2 tag node is specified.
2588 * @return The conversion result is returned.
2591 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
2597 chtml20 = GET_CHTML20(pdoc);
2602 return chtml20->out;
2607 * It is a handler who processes the H3 tag.
2609 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2610 * destination is specified.
2611 * @param node [i] The H3 tag node is specified.
2612 * @return The conversion result is returned.
2615 s_chtml20_start_h3_tag(void *pdoc, Node *node)
2622 chtml20 = GET_CHTML20(pdoc);
2627 for (attr = qs_get_attr(doc,node);
2629 attr = qs_get_next_attr(doc,attr)) {
2632 name = qs_get_attr_name(doc,attr);
2633 value = qs_get_attr_value(doc,attr);
2634 if (STRCASEEQ('a','A',"align", name)) {
2635 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2644 return chtml20->out;
2649 * It is a handler who processes the H3 tag.
2651 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2652 * destination is specified.
2653 * @param node [i] The H3 tag node is specified.
2654 * @return The conversion result is returned.
2657 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
2663 chtml20 = GET_CHTML20(pdoc);
2668 return chtml20->out;
2673 * It is a handler who processes the H4 tag.
2675 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2676 * destination is specified.
2677 * @param node [i] The H4 tag node is specified.
2678 * @return The conversion result is returned.
2681 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2688 chtml20 = GET_CHTML20(pdoc);
2693 for (attr = qs_get_attr(doc,node);
2695 attr = qs_get_next_attr(doc,attr)) {
2698 name = qs_get_attr_name(doc,attr);
2699 value = qs_get_attr_value(doc,attr);
2700 if (STRCASEEQ('a','A',"align", name)) {
2701 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2710 return chtml20->out;
2715 * It is a handler who processes the H4 tag.
2717 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2718 * destination is specified.
2719 * @param node [i] The H4 tag node is specified.
2720 * @return The conversion result is returned.
2723 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
2729 chtml20 = GET_CHTML20(pdoc);
2734 return chtml20->out;
2739 * It is a handler who processes the H5 tag.
2741 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2742 * destination is specified.
2743 * @param node [i] The H5 tag node is specified.
2744 * @return The conversion result is returned.
2747 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2754 chtml20 = GET_CHTML20(pdoc);
2759 for (attr = qs_get_attr(doc,node);
2761 attr = qs_get_next_attr(doc,attr)) {
2764 name = qs_get_attr_name(doc,attr);
2765 value = qs_get_attr_value(doc,attr);
2766 if (STRCASEEQ('a','A',"align", name)) {
2767 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2776 return chtml20->out;
2781 * It is a handler who processes the H5 tag.
2783 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2784 * destination is specified.
2785 * @param node [i] The H5 tag node is specified.
2786 * @return The conversion result is returned.
2789 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
2795 chtml20 = GET_CHTML20(pdoc);
2800 return chtml20->out;
2805 * It is a handler who processes the H6 tag.
2807 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2808 * destination is specified.
2809 * @param node [i] The H6 tag node is specified.
2810 * @return The conversion result is returned.
2813 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2820 chtml20 = GET_CHTML20(pdoc);
2825 for (attr = qs_get_attr(doc,node);
2827 attr = qs_get_next_attr(doc,attr)) {
2830 name = qs_get_attr_name(doc,attr);
2831 value = qs_get_attr_value(doc,attr);
2832 if (STRCASEEQ('a','A',"align", name)) {
2833 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2842 return chtml20->out;
2847 * It is a handler who processes the H6 tag.
2849 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2850 * destination is specified.
2851 * @param node [i] The H6 tag node is specified.
2852 * @return The conversion result is returned.
2855 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
2861 chtml20 = GET_CHTML20(pdoc);
2866 return chtml20->out;
2871 * It is a handler who processes the PRE tag.
2873 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2874 * destination is specified.
2875 * @param node [i] The PRE tag node is specified.
2876 * @return The conversion result is returned.
2879 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node))
2885 chtml20 = GET_CHTML20(pdoc);
2889 chtml20->pre_flag++;
2891 return chtml20->out;
2896 * It is a handler who processes the PRE tag.
2898 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2899 * destination is specified.
2900 * @param node [i] The PRE tag node is specified.
2901 * @return The conversion result is returned.
2904 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
2910 chtml20 = GET_CHTML20(pdoc);
2915 chtml20->pre_flag--;
2917 return chtml20->out;
2922 * It is a handler who processes the P tag.
2924 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2925 * destination is specified.
2926 * @param node [i] The P tag node is specified.
2927 * @return The conversion result is returned.
2930 s_chtml20_start_p_tag(void *pdoc, Node *node)
2938 chtml20 = GET_CHTML20(pdoc);
2943 for (attr = qs_get_attr(doc,node);
2945 attr = qs_get_next_attr(doc,attr)) {
2946 char *nm = qs_get_attr_name(doc,attr);
2947 char *val = qs_get_attr_value(doc,attr);
2948 if (STRCASEEQ('a','A',"align", nm)) {
2949 /*----------------------------------------------------------------------*/
2950 /* CHTML 1.0 (W3C version 3.2) */
2951 /*----------------------------------------------------------------------*/
2952 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2953 align = apr_pstrdup(doc->buf.pool, val);
2964 return chtml20->out;
2969 * It is a handler who processes the P tag.
2971 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2972 * destination is specified.
2973 * @param node [i] The P tag node is specified.
2974 * @return The conversion result is returned.
2977 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child))
2983 chtml20 = GET_CHTML20(pdoc);
2988 return chtml20->out;
2993 s_chtml20_chxjif_tag(void *pdoc, Node *node)
3000 chtml20 = GET_CHTML20(pdoc);
3004 for (child = qs_get_child_node(doc, node);
3006 child = qs_get_next_node(doc, child)) {
3009 s_chtml20_chxjif_tag(pdoc, child);
3017 * It is a handler who processes the TEXTARE tag.
3019 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3020 * destination is specified.
3021 * @param node [i] The TEXTAREA tag node is specified.
3022 * @return The conversion result is returned.
3025 s_chtml20_start_textarea_tag(void *pdoc, Node *node)
3032 chtml20 = GET_CHTML20(pdoc);
3036 chtml20->textarea_flag++;
3038 for (attr = qs_get_attr(doc,node);
3040 attr = qs_get_next_attr(doc,attr)) {
3045 name = qs_get_attr_name(doc,attr);
3046 value = qs_get_attr_value(doc,attr);
3051 if (strcasecmp(name, "name") == 0) {
3060 if (strcasecmp(name, "rows") == 0) {
3069 if (strcasecmp(name, "cols") == 0) {
3081 return chtml20->out;
3086 * It is a handler who processes the TEXTAREA tag.
3088 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3089 * destination is specified.
3090 * @param node [i] The TEXTAREA tag node is specified.
3091 * @return The conversion result is returned.
3094 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3100 chtml20 = GET_CHTML20(pdoc);
3104 W_L("</textarea>\r\n");
3105 chtml20->textarea_flag--;
3107 return chtml20->out;
3112 s_chtml20_text_tag(void *pdoc, Node *child)
3124 chtml20 = GET_CHTML20(pdoc);
3128 textval = qs_get_node_value(doc,child);
3129 textval = qs_trim_string(doc->buf.pool, textval);
3130 if (strlen(textval) == 0)
3131 return chtml20->out;
3133 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3134 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3136 tdst = qs_alloc_zero_byte_string(r);
3137 memset(one_byte, 0, sizeof(one_byte));
3140 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3142 int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3144 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3148 if (is_sjis_kanji(textval[ii])) {
3149 one_byte[0] = textval[ii+0];
3150 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3151 one_byte[0] = textval[ii+1];
3152 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3156 if (chtml20->pre_flag) {
3157 one_byte[0] = textval[ii+0];
3158 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3161 if (chtml20->textarea_flag) {
3162 one_byte[0] = textval[ii+0];
3163 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3166 if (textval[ii] != '\r' && textval[ii] != '\n') {
3167 one_byte[0] = textval[ii+0];
3168 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3172 return chtml20->out;
3177 * It is a handler who processes the BLOCKQUOTE tag.
3179 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3180 * destination is specified.
3181 * @param node [i] The BLOCKQUOTE tag node is specified.
3182 * @return The conversion result is returned.
3185 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3189 chtml20 = GET_CHTML20(pdoc);
3191 W_L("<blockquote>");
3192 return chtml20->out;
3197 * It is a handler who processes the BLOCKQUOTE tag.
3199 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3200 * destination is specified.
3201 * @param node [i] The BLOCKQUOTE tag node is specified.
3202 * @return The conversion result is returned.
3205 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3210 chtml20 = GET_CHTML20(pdoc);
3212 W_L("</blockquote>");
3213 return chtml20->out;
3218 * It is a handler who processes the DIR tag.
3220 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3221 * destination is specified.
3222 * @param node [i] The DIR tag node is specified.
3223 * @return The conversion result is returned.
3226 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3230 chtml20 = GET_CHTML20(pdoc);
3233 return chtml20->out;
3238 * It is a handler who processes the DIR tag.
3240 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3241 * destination is specified.
3242 * @param node [i] The DIR tag node is specified.
3243 * @return The conversion result is returned.
3246 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3251 chtml20 = GET_CHTML20(pdoc);
3254 return chtml20->out;
3259 * It is a handler who processes the DL tag.
3261 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3262 * destination is specified.
3263 * @param node [i] The DL tag node is specified.
3264 * @return The conversion result is returned.
3267 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3271 chtml20 = GET_CHTML20(pdoc);
3274 return chtml20->out;
3279 * It is a handler who processes the DL tag.
3281 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3282 * destination is specified.
3283 * @param node [i] The DL tag node is specified.
3284 * @return The conversion result is returned.
3287 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3291 chtml20 = GET_CHTML20(pdoc);
3294 return chtml20->out;
3299 * It is a handter who processes the DT tag.
3301 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3302 * destination is specified.
3303 * @param node [i] The DT tag node is specified.
3304 * @return The conversion result is returned.
3307 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3311 chtml20 = GET_CHTML20(pdoc);
3314 return chtml20->out;
3319 * It is a handter who processes the DT tag.
3321 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3322 * destination is specified.
3323 * @param node [i] The DT tag node is specified.
3324 * @return The conversion result is returned.
3327 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3330 chtml20 = GET_CHTML20(pdoc);
3331 return chtml20->out;
3336 * It is a handder who processes the DD tag.
3338 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3339 * destination is specified.
3340 * @param node [i] The DD tag node is specified.
3341 * @return The conversion result is returned.
3344 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3348 chtml20 = GET_CHTML20(pdoc);
3351 return chtml20->out;
3356 * It is a handder who processes the DD tag.
3358 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3359 * destination is specified.
3360 * @param node [i] The DD tag node is specified.
3361 * @return The conversion result is returned.
3364 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
3367 chtml20 = GET_CHTML20(pdoc);
3368 return chtml20->out;
3373 * It is a hanmenuer who processes the MENU tag.
3375 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3376 * destination is specified.
3377 * @param node [i] The MENU tag node is specified.
3378 * @return The conversion result is returned.
3381 s_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
3385 chtml20 = GET_CHTML20(pdoc);
3388 return chtml20->out;
3393 * It is a hanmenuer who processes the MENU tag.
3395 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3396 * destination is specified.
3397 * @param node [i] The MENU tag node is specified.
3398 * @return The conversion result is returned.
3401 s_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
3403 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3404 Doc *doc = chtml20->doc;
3406 return chtml20->out;