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);
103 static void s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
105 static int s_chtml20_search_emoji(chtml20_t *chtml, char *txt, char **rslt);
107 static char *s_chtml20_chxjif_tag(void *pdoc, Node *node);
108 static char *s_chtml20_text_tag(void *pdoc, Node *node);
111 tag_handler chtml20_handler[] = {
114 s_chtml20_start_html_tag,
115 s_chtml20_end_html_tag,
119 s_chtml20_start_meta_tag,
120 s_chtml20_end_meta_tag,
124 s_chtml20_start_textarea_tag,
125 s_chtml20_end_textarea_tag,
129 s_chtml20_start_p_tag,
134 s_chtml20_start_pre_tag,
135 s_chtml20_end_pre_tag,
139 s_chtml20_start_ul_tag,
140 s_chtml20_end_ul_tag,
144 s_chtml20_start_li_tag,
145 s_chtml20_end_li_tag,
149 s_chtml20_start_ol_tag,
150 s_chtml20_end_ol_tag,
154 s_chtml20_start_h1_tag,
155 s_chtml20_end_h1_tag,
159 s_chtml20_start_h2_tag,
160 s_chtml20_end_h2_tag,
164 s_chtml20_start_h3_tag,
165 s_chtml20_end_h3_tag,
169 s_chtml20_start_h4_tag,
170 s_chtml20_end_h4_tag,
174 s_chtml20_start_h5_tag,
175 s_chtml20_end_h5_tag,
179 s_chtml20_start_h6_tag,
180 s_chtml20_end_h6_tag,
184 s_chtml20_start_head_tag,
185 s_chtml20_end_head_tag,
189 s_chtml20_start_title_tag,
190 s_chtml20_end_title_tag,
194 s_chtml20_start_base_tag,
195 s_chtml20_end_base_tag,
199 s_chtml20_start_body_tag,
200 s_chtml20_end_body_tag,
204 s_chtml20_start_a_tag,
209 s_chtml20_start_br_tag,
210 s_chtml20_end_br_tag,
219 s_chtml20_start_tr_tag,
220 s_chtml20_end_tr_tag,
234 s_chtml20_start_font_tag,
235 s_chtml20_end_font_tag,
239 s_chtml20_start_form_tag,
240 s_chtml20_end_form_tag,
244 s_chtml20_start_input_tag,
245 s_chtml20_end_input_tag,
249 s_chtml20_start_center_tag,
250 s_chtml20_end_center_tag,
254 s_chtml20_start_hr_tag,
255 s_chtml20_end_hr_tag,
259 s_chtml20_start_img_tag,
260 s_chtml20_end_img_tag,
264 s_chtml20_start_select_tag,
265 s_chtml20_end_select_tag,
269 s_chtml20_start_option_tag,
270 s_chtml20_end_option_tag,
274 s_chtml20_start_div_tag,
275 s_chtml20_end_div_tag,
279 s_chtml20_chxjif_tag,
324 s_chtml20_start_dt_tag,
325 s_chtml20_end_dt_tag,
339 s_chtml20_start_blockquote_tag,
340 s_chtml20_end_blockquote_tag,
344 s_chtml20_start_dir_tag,
345 s_chtml20_end_dir_tag,
349 s_chtml20_start_dl_tag,
350 s_chtml20_end_dl_tag,
354 s_chtml20_start_dd_tag,
355 s_chtml20_end_dd_tag,
370 * converts from CHTML5.0 to CHTML2.0.
372 * @param r [i] Requet_rec is appointed.
373 * @param spec [i] The result of the device specification processing which
374 * was done in advance is appointed.
375 * @param src [i] The character string before the converting is appointed.
376 * @return The character string after the converting is returned.
379 chxj_exchange_chtml20(
385 chxjconvrule_entry *entryp,
394 /*--------------------------------------------------------------------------*/
396 /*--------------------------------------------------------------------------*/
398 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
400 DBG(r,"i found qrcode xml");
403 DBG(r,"not found qrcode xml");
405 /*--------------------------------------------------------------------------*/
406 /* The CHTML structure is initialized. */
407 /*--------------------------------------------------------------------------*/
408 s_init_chtml20(&chtml20, &doc, r, spec);
411 chtml20.entryp = entryp;
412 chtml20.cookie = cookie;
414 chxj_set_content_type(r, "text/html; charset=Windows-31J");
416 /*--------------------------------------------------------------------------*/
417 /* The character string of the input is analyzed. */
418 /*--------------------------------------------------------------------------*/
419 qs_init_malloc(&doc);
420 qs_init_root_node(&doc);
422 ss = apr_pcalloc(r->pool, srclen + 1);
423 memset(ss, 0, srclen + 1);
424 memcpy(ss, src, srclen);
427 chxj_dump_out("[src] CHTML -> CHTML2.0", ss, srclen);
430 qs_parse_string(&doc,ss, strlen(ss));
432 chxj_buffered_write_init(r->pool, &doc.buf);
433 /*--------------------------------------------------------------------------*/
434 /* It converts it from CHTML to CHTML. */
435 /*--------------------------------------------------------------------------*/
436 chxj_node_exchange(spec,r,(void *)&chtml20, &doc, qs_get_root(&doc), 0);
437 chtml20.out = chxj_buffered_write_flush(chtml20.out, &doc.buf);
438 dst = apr_pstrdup(r->pool, chtml20.out);
439 chxj_buffered_write_terminate(&doc.buf);
441 qs_all_free(&doc,QX_LOGMARK);
444 return apr_pstrdup(r->pool,ss);
447 if (strlen(dst) == 0) {
448 dst = apr_psprintf(r->pool, "\n");
451 *dstlen = strlen(dst);
454 chxj_dump_out("[dst] CHTML -> CHTML2.0", dst, *dstlen);
461 * The CHTML structure is initialized.
463 * @param chtml20 [i/o] The pointer to the HDML structure that wants to be
464 * initialized is specified.
465 * @param doc [i] The Doc structure that should be set to the initialized
466 * HDML structure is specified.
467 * @param r [i] To use POOL, the pointer to request_rec is specified.
468 * @param spec [i] The pointer to the device_table
471 s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
473 memset(doc, 0, sizeof(Doc));
474 memset(chtml20, 0, sizeof(chtml20_t));
478 chtml20->spec = spec;
479 chtml20->out = qs_alloc_zero_byte_string(r);
480 chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
482 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
487 * Corresponding EMOJI to a current character-code is retrieved.
488 * The substitution character string is stored in the rslt pointer if agreeing.
490 * @param chtml20 [i] The pointer to the CHTML structure is specified.
491 * @param txt [i] The character string to want to examine whether it is
492 * EMOJI is specified.
493 * @param rslt [o] The pointer to the pointer that stores the result is
495 * @return When corresponding EMOJI exists, it returns it excluding 0.
498 s_chtml20_search_emoji(chtml20_t *chtml20, char *txt, char **rslt)
505 spec = chtml20->spec;
511 DBG(r,"spec is NULL");
513 for (ee = chtml20->conf->emoji;
517 if (ee->imode == NULL) {
518 DBG(r,"emoji->imode is NULL");
522 if (ee->imode->string != NULL
523 && strlen(ee->imode->string) > 0
524 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
525 if (spec == NULL || spec->emoji_type == NULL) {
526 *rslt = apr_palloc(r->pool, 3);
527 (*rslt)[0] = ee->imode->hex1byte & 0xff;
528 (*rslt)[1] = ee->imode->hex2byte & 0xff;
530 return strlen(ee->imode->string);
542 * It is a handler who processes the HTML tag.
544 * @param pdoc [i/o] The pointer to the CHTML structure at the output
545 * destination is specified.
546 * @param node [i] The HTML tag node is specified.
547 * @return The conversion result is returned.
550 s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
556 chtml20 = GET_CHTML20(pdoc);
560 /*--------------------------------------------------------------------------*/
562 /*--------------------------------------------------------------------------*/
569 * It is a handler who processes the HTML tag.
571 * @param pdoc [i/o] The pointer to the CHTML structure at the output
572 * destination is specified.
573 * @param node [i] The HTML tag node is specified.
574 * @return The conversion result is returned.
577 s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child))
583 chtml20 = GET_CHTML20(pdoc);
593 * It is a handler who processes the META tag.
595 * @param pdoc [i/o] The pointer to the CHTML structure at the output
596 * destination is specified.
597 * @param node [i] The META tag node is specified.
598 * @return The conversion result is returned.
601 s_chtml20_start_meta_tag(void *pdoc, Node *node)
607 int content_type_flag;
610 chtml20 = GET_CHTML20(pdoc);
614 content_type_flag = 0;
618 /*--------------------------------------------------------------------------*/
620 /*--------------------------------------------------------------------------*/
621 for (attr = qs_get_attr(doc,node);
623 attr = qs_get_next_attr(doc,attr)) {
628 name = qs_get_attr_name(doc,attr);
629 value = qs_get_attr_value(doc,attr);
634 if (strcasecmp(name, "http-equiv") == 0) {
635 /*----------------------------------------------------------------------*/
637 /*----------------------------------------------------------------------*/
638 W_L(" http-equiv=\"");
641 if (STRCASEEQ('c','C',"content-type", value)) {
642 content_type_flag = 1;
644 if (STRCASEEQ('r','R',"refresh", value)) {
652 if (strcasecmp(name, "content") == 0) {
653 if (content_type_flag) {
656 W_L("=\"text/html; charset=Windows-31J\"");
658 else if (refresh_flag) {
659 char *buf = apr_pstrdup(r->pool, value);
663 url = strchr(buf, ';');
665 sec = apr_pstrdup(r->pool, buf);
668 url = chxj_encoding_parameter(r, url);
669 url = chxj_add_cookie_parameter(r, url, chtml20->cookie);
699 * It is a handler who processes the META tag.
701 * @param pdoc [i/o] The pointer to the CHTML structure at the output
702 * destination is specified.
703 * @param node [i] The META tag node is specified.
704 * @return The conversion result is returned.
707 s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child))
711 chtml20 = GET_CHTML20(pdoc);
718 * It is a handler who processes the HEAD tag.
720 * @param pdoc [i/o] The pointer to the CHTML structure at the output
721 * destination is specified.
722 * @param node [i] The HEAD tag node is specified.
723 * @return The conversion result is returned.
726 s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node))
732 chtml20 = GET_CHTML20(pdoc);
742 * It is a handler who processes the HEAD tag.
744 * @param pdoc [i/o] The pointer to the CHTML structure at the output
745 * destination is specified.
746 * @param node [i] The HEAD tag node is specified.
747 * @return The conversion result is returned.
750 s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child))
756 chtml20 = GET_CHTML20(pdoc);
766 * It is a handler who processes the TITLE tag.
768 * @param pdoc [i/o] The pointer to the CHTML structure at the output
769 * destination is specified.
770 * @param node [i] The TITLE tag node is specified.
771 * @return The conversion result is returned.
774 s_chtml20_start_title_tag(void *pdoc, Node *UNUSED(node))
780 chtml20 = GET_CHTML20(pdoc);
790 * It is a handler who processes the TITLE tag.
792 * @param pdoc [i/o] The pointer to the CHTML structure at the output
793 * destination is specified.
794 * @param node [i] The TITLE tag node is specified.
795 * @return The conversion result is returned.
798 s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
804 chtml20 = GET_CHTML20(pdoc);
814 * It is a handler who processes the BASE tag.
816 * @param pdoc [i/o] The pointer to the CHTML structure at the output
817 * destination is specified.
818 * @param node [i] The BASE tag node is specified.
819 * @return The conversion result is returned.
822 s_chtml20_start_base_tag(void *pdoc, Node *node)
829 chtml20 = GET_CHTML20(pdoc);
834 /*--------------------------------------------------------------------------*/
836 /*--------------------------------------------------------------------------*/
837 for (attr = qs_get_attr(doc,node);
839 attr = qs_get_next_attr(doc,attr)) {
844 name = qs_get_attr_name(doc,attr);
845 value = qs_get_attr_value(doc,attr);
847 if (STRCASEEQ('h','H',"href", name)) {
859 * It is a handler who processes the BASE tag.
861 * @param pdoc [i/o] The pointer to the CHTML structure at the output
862 * destination is specified.
863 * @param node [i] The BASE tag node is specified.
864 * @return The conversion result is returned.
867 s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child))
873 chtml20 = GET_CHTML20(pdoc);
882 * It is a handler who processes the BODY tag.
884 * @param pdoc [i/o] The pointer to the CHTML structure at the output
885 * destination is specified.
886 * @param node [i] The BODY tag node is specified.
887 * @return The conversion result is returned.
890 s_chtml20_start_body_tag(void *pdoc, Node *node)
897 chtml20 = GET_CHTML20(pdoc);
902 /*--------------------------------------------------------------------------*/
904 /*--------------------------------------------------------------------------*/
905 for (attr = qs_get_attr(doc,node);
907 attr = qs_get_next_attr(doc,attr)) {
911 name = qs_get_attr_name(doc,attr);
912 value = qs_get_attr_value(doc,attr);
917 if (strcasecmp(name, "bgcolor") == 0 && value && *value != 0) {
918 /*----------------------------------------------------------------------*/
920 /*----------------------------------------------------------------------*/
929 if (strcasecmp(name, "text") == 0 && value && *value != 0) {
930 /*----------------------------------------------------------------------*/
932 /*----------------------------------------------------------------------*/
941 if (strcasecmp(name, "link") == 0 && value && *value != 0) {
942 /*----------------------------------------------------------------------*/
944 /*----------------------------------------------------------------------*/
953 if (strcasecmp(name, "alink") == 0) {
954 /*----------------------------------------------------------------------*/
956 /*----------------------------------------------------------------------*/
963 if (strcasecmp(name, "vlink") == 0) {
964 /*----------------------------------------------------------------------*/
966 /*----------------------------------------------------------------------*/
981 * It is a handler who processes the BODY tag.
983 * @param pdoc [i/o] The pointer to the CHTML structure at the output
984 * destination is specified.
985 * @param node [i] The BODY tag node is specified.
986 * @return The conversion result is returned.
989 s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child))
995 chtml20 = GET_CHTML20(pdoc);
1000 return chtml20->out;
1005 * It is a handler who processes the A tag.
1007 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1008 * destination is specified.
1009 * @param node [i] The A tag node is specified.
1010 * @return The conversion result is returned.
1013 s_chtml20_start_a_tag(void *pdoc, Node *node)
1020 chtml20 = GET_CHTML20(pdoc);
1025 /*--------------------------------------------------------------------------*/
1026 /* Get Attributes */
1027 /*--------------------------------------------------------------------------*/
1028 for (attr = qs_get_attr(doc,node);
1030 attr = qs_get_next_attr(doc,attr)) {
1035 name = qs_get_attr_name(doc,attr);
1036 value = qs_get_attr_value(doc,attr);
1041 if (strcasecmp(name, "name") == 0) {
1042 /*--------------------------------------------------------------------*/
1044 /*--------------------------------------------------------------------*/
1053 if (strcasecmp(name, "href") == 0) {
1054 /*--------------------------------------------------------------------*/
1056 /*--------------------------------------------------------------------*/
1057 value = chxj_encoding_parameter(r, value);
1058 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1067 if (strcasecmp(name, "accesskey") == 0) {
1068 /*--------------------------------------------------------------------*/
1070 /*--------------------------------------------------------------------*/
1071 W_L(" accesskey=\"");
1079 if (strcasecmp(name, "cti") == 0) {
1080 /*--------------------------------------------------------------------*/
1082 /*--------------------------------------------------------------------*/
1091 if (strcasecmp(name, "ijam") == 0) {
1092 /*--------------------------------------------------------------------*/
1094 /*--------------------------------------------------------------------*/
1098 if (strcasecmp(name, "ista") == 0) {
1099 /*--------------------------------------------------------------------*/
1101 /*--------------------------------------------------------------------*/
1105 if (strcasecmp(name, "ilet") == 0) {
1106 /*--------------------------------------------------------------------*/
1108 /*--------------------------------------------------------------------*/
1112 if (strcasecmp(name, "iswf") == 0) {
1113 /*--------------------------------------------------------------------*/
1115 /*--------------------------------------------------------------------*/
1119 if (strcasecmp(name, "irst") == 0) {
1120 /*--------------------------------------------------------------------*/
1122 /*--------------------------------------------------------------------*/
1129 if (strcasecmp(name, "utn") == 0) {
1130 /*--------------------------------------------------------------------*/
1132 /*--------------------------------------------------------------------*/
1139 if (strcasecmp(name, "telbook") == 0) {
1140 /*--------------------------------------------------------------------*/
1142 /*--------------------------------------------------------------------*/
1149 if (strcasecmp(name, "kana") == 0) {
1150 /*--------------------------------------------------------------------*/
1152 /*--------------------------------------------------------------------*/
1159 if (strcasecmp(name, "email") == 0) {
1160 /*--------------------------------------------------------------------*/
1162 /*--------------------------------------------------------------------*/
1172 return chtml20->out;
1177 * It is a handler who processes the A tag.
1179 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1180 * destination is specified.
1181 * @param node [i] The A tag node is specified.
1182 * @return The conversion result is returned.
1185 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
1191 chtml20 = GET_CHTML20(pdoc);
1196 return chtml20->out;
1201 * It is a handler who processes the BR tag.
1203 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1204 * destination is specified.
1205 * @param node [i] The BR tag node is specified.
1206 * @return The conversion result is returned.
1209 s_chtml20_start_br_tag(void *pdoc, Node *node)
1216 chtml20 = GET_CHTML20(pdoc);
1221 /*--------------------------------------------------------------------------*/
1222 /* Get Attributes */
1223 /*--------------------------------------------------------------------------*/
1224 for (attr = qs_get_attr(doc,node);
1226 attr = qs_get_next_attr(doc,attr)) {
1230 name = qs_get_attr_name(doc,attr);
1231 value = qs_get_attr_value(doc,attr);
1233 if (STRCASEEQ('c','C',"clear",name)) {
1234 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1242 return chtml20->out;
1247 * It is a handler who processes the BR tag.
1249 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1250 * destination is specified.
1251 * @param node [i] The BR tag node is specified.
1252 * @return The conversion result is returned.
1255 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
1261 chtml20 = GET_CHTML20(pdoc);
1265 return chtml20->out;
1270 * It is a handler who processes the TR tag.
1272 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1273 * destination is specified.
1274 * @param node [i] The TR tag node is specified.
1275 * @return The conversion result is returned.
1278 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
1284 chtml20 = GET_CHTML20(pdoc);
1288 return chtml20->out;
1293 * It is a handler who processes the TR tag.
1295 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1296 * destination is specified.
1297 * @param node [i] The TR tag node is specified.
1298 * @return The conversion result is returned.
1301 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
1307 chtml20 = GET_CHTML20(pdoc);
1312 return chtml20->out;
1317 * It is a handler who processes the FONT tag.
1319 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1320 * destination is specified.
1321 * @param node [i] The FONT tag node is specified.
1322 * @return The conversion result is returned.
1325 s_chtml20_start_font_tag(void *pdoc, Node *node)
1332 chtml20 = GET_CHTML20(pdoc);
1338 /*--------------------------------------------------------------------------*/
1339 /* Get Attributes */
1340 /*--------------------------------------------------------------------------*/
1341 for (attr = qs_get_attr(doc,node);
1343 attr = qs_get_next_attr(doc,attr)) {
1348 name = qs_get_attr_name(doc,attr);
1349 value = qs_get_attr_value(doc,attr);
1354 if (strcasecmp(name, "color") == 0) {
1363 if (strcasecmp(name, "size") == 0) {
1364 /*--------------------------------------------------------------------*/
1366 /*--------------------------------------------------------------------*/
1376 return chtml20->out;
1381 * It is a handler who processes the FONT tag.
1383 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1384 * destination is specified.
1385 * @param node [i] The FONT tag node is specified.
1386 * @return The conversion result is returned.
1389 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child))
1395 chtml20 = GET_CHTML20(pdoc);
1400 return chtml20->out;
1405 * It is a handler who processes the FORM tag.
1407 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1408 * destination is specified.
1409 * @param node [i] The FORM tag node is specified.
1410 * @return The conversion result is returned.
1413 s_chtml20_start_form_tag(void *pdoc, Node *node)
1420 chtml20 = GET_CHTML20(pdoc);
1425 /*--------------------------------------------------------------------------*/
1426 /* Get Attributes */
1427 /*--------------------------------------------------------------------------*/
1428 for (attr = qs_get_attr(doc,node);
1430 attr = qs_get_next_attr(doc,attr)) {
1435 name = qs_get_attr_name(doc,attr);
1436 value = qs_get_attr_value(doc,attr);
1441 if (strcasecmp(name, "action") == 0) {
1442 /*--------------------------------------------------------------------*/
1444 /*--------------------------------------------------------------------*/
1445 value = chxj_encoding_parameter(r, value);
1446 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1456 if (strcasecmp(name, "method") == 0) {
1457 /*--------------------------------------------------------------------*/
1459 /*--------------------------------------------------------------------*/
1468 if (strcasecmp(name, "utn") == 0) {
1469 /*--------------------------------------------------------------------*/
1471 /*--------------------------------------------------------------------*/
1481 return chtml20->out;
1486 * It is a handler who processes the FORM tag.
1488 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1489 * destination is specified.
1490 * @param node [i] The FORM tag node is specified.
1491 * @return The conversion result is returned.
1494 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child))
1500 chtml20 = GET_CHTML20(pdoc);
1505 return chtml20->out;
1510 * It is a handler who processes the INPUT tag.
1512 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1513 * destination is specified.
1514 * @param node [i] The INPUT tag node is specified.
1515 * @return The conversion result is returned.
1518 s_chtml20_start_input_tag(void *pdoc, Node *node)
1523 char *max_length = NULL;
1527 char *istyle = NULL;
1529 char *checked = NULL;
1530 char *accesskey = NULL;
1532 chtml20 = GET_CHTML20(pdoc);
1538 /*--------------------------------------------------------------------------*/
1539 /* Get Attributes */
1540 /*--------------------------------------------------------------------------*/
1542 type = qs_get_type_attr(doc, node, r);
1543 name = qs_get_name_attr(doc, node, r);
1544 value = qs_get_value_attr(doc,node,r);
1545 istyle = qs_get_istyle_attr(doc,node,r);
1546 max_length = qs_get_maxlength_attr(doc,node,r);
1547 checked = qs_get_checked_attr(doc,node,r);
1548 accesskey = qs_get_accesskey_attr(doc, node, r);
1549 size = qs_get_size_attr(doc, node, r);
1552 type = qs_trim_string(doc->buf.pool, type);
1553 if (type && (STRCASEEQ('t','T',"text", type) ||
1554 STRCASEEQ('p','P',"password",type) ||
1555 STRCASEEQ('c','C',"checkbox",type) ||
1556 STRCASEEQ('r','R',"radio", type) ||
1557 STRCASEEQ('h','H',"hidden", type) ||
1558 STRCASEEQ('s','S',"submit", type) ||
1559 STRCASEEQ('r','R',"reset", type))) {
1566 if (size && *size) {
1572 if (name && *name) {
1578 if (value && *value) {
1584 if (accesskey && *accesskey) {
1585 W_L(" accesskey=\"");
1591 /*------------------------------------------------------------------------*/
1593 /*------------------------------------------------------------------------*/
1594 if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1601 /*--------------------------------------------------------------------------*/
1602 /* The figure is default for the password. */
1603 /*--------------------------------------------------------------------------*/
1604 if (max_length && *max_length) {
1605 if (chxj_chk_numeric(max_length) != 0) {
1606 max_length = apr_psprintf(doc->buf.pool, "0");
1608 if (istyle && *istyle == '1') {
1609 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1613 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1622 return chtml20->out;
1627 * It is a handler who processes the INPUT tag.
1629 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1630 * destination is specified.
1631 * @param node [i] The INPUT tag node is specified.
1632 * @return The conversion result is returned.
1635 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child))
1641 chtml20 = GET_CHTML20(pdoc);
1645 return chtml20->out;
1650 * It is a handler who processes the CENTER tag.
1652 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1653 * destination is specified.
1654 * @param node [i] The CENTER tag node is specified.
1655 * @return The conversion result is returned.
1658 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node))
1664 chtml20 = GET_CHTML20(pdoc);
1669 return chtml20->out;
1674 * It is a handler who processes the CENTER tag.
1676 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1677 * destination is specified.
1678 * @param node [i] The CENTER tag node is specified.
1679 * @return The conversion result is returned.
1682 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child))
1688 chtml20 = GET_CHTML20(pdoc);
1693 return chtml20->out;
1698 * It is a handler who processes the UL tag.
1700 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1701 * destination is specified.
1702 * @param node [i] The UL tag node is specified.
1703 * @return The conversion result is returned.
1706 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node))
1712 chtml20 = GET_CHTML20(pdoc);
1717 return chtml20->out;
1722 * It is a handler who processes the UL tag.
1724 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1725 * destination is specified.
1726 * @param node [i] The UL tag node is specified.
1727 * @return The conversion result is returned.
1730 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
1736 chtml20 = GET_CHTML20(pdoc);
1741 return chtml20->out;
1746 * It is a handler who processes the OL tag.
1748 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1749 * destination is specified.
1750 * @param node [i] The OL tag node is specified.
1751 * @return The conversion result is returned.
1754 s_chtml20_start_ol_tag(void *pdoc, Node *UNUSED(node))
1760 chtml20 = GET_CHTML20(pdoc);
1765 return chtml20->out;
1770 * It is a handler who processes the OL tag.
1772 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1773 * destination is specified.
1774 * @param node [i] The OL tag node is specified.
1775 * @return The conversion result is returned.
1778 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
1784 chtml20 = GET_CHTML20(pdoc);
1789 return chtml20->out;
1794 * It is a handler who processes the LI tag.
1796 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1797 * destination is specified.
1798 * @param node [i] The LI tag node is specified.
1799 * @return The conversion result is returned.
1802 s_chtml20_start_li_tag(void *pdoc, Node *node)
1809 chtml20 = GET_CHTML20(pdoc);
1814 /*--------------------------------------------------------------------------*/
1815 /* Get Attributes */
1816 /*--------------------------------------------------------------------------*/
1817 for (attr = qs_get_attr(doc,node);
1819 attr = qs_get_next_attr(doc,attr)) {
1820 char *name = qs_get_attr_name(doc,attr);
1821 char *value = qs_get_attr_value(doc,attr);
1822 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1827 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1834 return chtml20->out;
1839 * It is a handler who processes the LI tag.
1841 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1842 * destination is specified.
1843 * @param node [i] The LI tag node is specified.
1844 * @return The conversion result is returned.
1847 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
1849 chtml20_t *chtml20 = GET_CHTML20(pdoc);
1850 return chtml20->out;
1855 * It is a handler who processes the HR tag.
1857 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1858 * destination is specified.
1859 * @param node [i] The HR tag node is specified.
1860 * @return The conversion result is returned.
1863 s_chtml20_start_hr_tag(void *pdoc, Node *node)
1870 chtml20 = GET_CHTML20(pdoc);
1876 for (attr = qs_get_attr(doc,node);
1878 attr = qs_get_next_attr(doc,attr)) {
1883 name = qs_get_attr_name(doc,attr);
1884 value = qs_get_attr_value(doc,attr);
1889 if (strcasecmp(name, "align") == 0) {
1890 /*--------------------------------------------------------------------*/
1892 /*--------------------------------------------------------------------*/
1893 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1903 if (strcasecmp(name, "size") == 0) {
1904 /*--------------------------------------------------------------------*/
1906 /*--------------------------------------------------------------------*/
1907 if (value && value[0] != '\0') {
1917 if (strcasecmp(name, "width") == 0) {
1918 /*--------------------------------------------------------------------*/
1920 /*--------------------------------------------------------------------*/
1921 if (value && value[0] != '\0') {
1931 if (strcasecmp(name, "noshade") == 0) {
1932 /*--------------------------------------------------------------------*/
1934 /*--------------------------------------------------------------------*/
1941 if (strcasecmp(name, "color") == 0) {
1942 /*--------------------------------------------------------------------*/
1944 /*--------------------------------------------------------------------*/
1954 return chtml20->out;
1959 * It is a handler who processes the HR tag.
1961 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1962 * destination is specified.
1963 * @param node [i] The HR tag node is specified.
1964 * @return The conversion result is returned.
1967 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
1973 chtml20 = GET_CHTML20(pdoc);
1977 return chtml20->out;
1982 * It is a handler who processes the IMG tag.
1984 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1985 * destination is specified.
1986 * @param node [i] The IMG tag node is specified.
1987 * @return The conversion result is returned.
1990 s_chtml20_start_img_tag(void *pdoc, Node *node)
1996 #ifndef IMG_NOT_CONVERT_FILENAME
2000 chtml20 = GET_CHTML20(pdoc);
2004 #ifndef IMG_NOT_CONVERT_FILENAME
2005 spec = chtml20->spec;
2009 /*-------------------------------------------------------------------------*/
2010 /* Get Attributes */
2011 /*-------------------------------------------------------------------------*/
2012 for (attr = qs_get_attr(doc,node);
2014 attr = qs_get_next_attr(doc,attr)) {
2019 name = qs_get_attr_name(doc,attr);
2020 value = qs_get_attr_value(doc,attr);
2025 if (strcasecmp(name, "src") == 0) {
2026 /*-------------------------------------------------------------------*/
2028 /*-------------------------------------------------------------------*/
2029 #ifdef IMG_NOT_CONVERT_FILENAME
2030 value = chxj_encoding_parameter(r, value);
2031 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2033 value = apr_psprintf(doc->buf.pool,
2036 (strchr(value, '?')) ? '&' : '?',
2037 CHXJ_COOKIE_NOUPDATE_PARAM);
2043 value = chxj_img_conv(r, spec, value);
2044 value = chxj_encoding_parameter(r, value);
2045 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2047 value = apr_psprintf(doc->buf.pool,
2050 (strchr(value, '?')) ? '&' : '?',
2051 CHXJ_COOKIE_NOUPDATE_PARAM);
2062 if (strcasecmp(name, "align" ) == 0) {
2063 /*--------------------------------------------------------------------*/
2065 /*--------------------------------------------------------------------*/
2066 if (value && (STRCASEEQ('t','T',"top", value) ||
2067 STRCASEEQ('m','M',"middle",value) ||
2068 STRCASEEQ('b','B',"bottom",value) ||
2069 STRCASEEQ('l','L',"left", value) ||
2070 STRCASEEQ('r','R',"right", value))) {
2076 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2077 /*--------------------------------------------------------------------*/
2079 /*--------------------------------------------------------------------*/
2088 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2089 /*--------------------------------------------------------------------*/
2091 /*--------------------------------------------------------------------*/
2100 if (strcasecmp(name, "height") == 0 && value && *value) {
2101 /*--------------------------------------------------------------------*/
2103 /*--------------------------------------------------------------------*/
2108 else if (strcasecmp(name, "hspace") == 0 && value && *value) {
2109 /*--------------------------------------------------------------------*/
2111 /*--------------------------------------------------------------------*/
2120 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2121 /*--------------------------------------------------------------------*/
2123 /*--------------------------------------------------------------------*/
2135 return chtml20->out;
2140 * It is a handler who processes the IMG tag.
2142 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2143 * destination is specified.
2144 * @param node [i] The IMG tag node is specified.
2145 * @return The conversion result is returned.
2148 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
2154 chtml20 = GET_CHTML20(pdoc);
2158 return chtml20->out;
2163 * It is a handler who processes the SELECT tag.
2165 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2166 * destination is specified.
2167 * @param node [i] The SELECT tag node is specified.
2168 * @return The conversion result is returned.
2171 s_chtml20_start_select_tag(void *pdoc, Node *child)
2178 chtml20 = GET_CHTML20(pdoc);
2186 for (attr = qs_get_attr(doc,child);
2188 attr = qs_get_next_attr(doc,attr)) {
2193 nm = qs_get_attr_name(doc,attr);
2194 val = qs_get_attr_value(doc,attr);
2199 if (strcasecmp(nm, "size") == 0) {
2200 /*--------------------------------------------------------------------*/
2201 /* CHTML 1.0 version 2.0 */
2202 /*--------------------------------------------------------------------*/
2203 size = apr_pstrdup(doc->buf.pool, val);
2209 if (strcasecmp(nm, "name") == 0) {
2210 /*--------------------------------------------------------------------*/
2211 /* CHTML 1.0 version 2.0 */
2212 /*--------------------------------------------------------------------*/
2213 name = apr_pstrdup(doc->buf.pool, val);
2219 if (strcasecmp(nm, "multiple") == 0) {
2220 /*--------------------------------------------------------------------*/
2221 /* CHTML 1.0 version 2.0 */
2222 /*--------------------------------------------------------------------*/
2245 return chtml20->out;
2250 * It is a handler who processes the SELECT tag.
2252 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2253 * destination is specified.
2254 * @param node [i] The SELECT tag node is specified.
2255 * @return The conversion result is returned.
2258 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2264 chtml20 = GET_CHTML20(pdoc);
2268 W_L("</select>\r\n");
2269 return chtml20->out;
2274 * It is a handler who processes the OPTION tag.
2276 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2277 * destination is specified.
2278 * @param node [i] The OPTION tag node is specified.
2279 * @return The conversion result is returned.
2282 s_chtml20_start_option_tag(void *pdoc, Node *child)
2289 chtml20 = GET_CHTML20(pdoc);
2293 char *selected = NULL;
2297 for (attr = qs_get_attr(doc,child);
2299 attr = qs_get_next_attr(doc,attr)) {
2304 nm = qs_get_attr_name(doc,attr);
2305 val = qs_get_attr_value(doc,attr);
2310 if (strcasecmp(nm, "selected") == 0) {
2311 /*--------------------------------------------------------------------*/
2312 /* CHTML 1.0 version 2.0 */
2313 /*--------------------------------------------------------------------*/
2314 selected = apr_pstrdup(doc->buf.pool, val);
2320 if (strcasecmp(nm, "value") == 0) {
2321 /*--------------------------------------------------------------------*/
2322 /* CHTML 1.0 version 2.0 */
2323 /*--------------------------------------------------------------------*/
2324 value = apr_pstrdup(doc->buf.pool, val);
2346 return chtml20->out;
2351 * It is a handler who processes the OPTION tag.
2353 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2354 * destination is specified.
2355 * @param node [i] The OPTION tag node is specified.
2356 * @return The conversion result is returned.
2359 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2365 chtml20 = GET_CHTML20(pdoc);
2371 return chtml20->out;
2376 * It is a handler who processes the DIV tag.
2378 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2379 * destination is specified.
2380 * @param node [i] The DIV tag node is specified.
2381 * @return The conversion result is returned.
2384 s_chtml20_start_div_tag(void *pdoc, Node *child)
2391 chtml20 = GET_CHTML20(pdoc);
2399 for (attr = qs_get_attr(doc,child);
2401 attr = qs_get_next_attr(doc,attr)) {
2406 nm = qs_get_attr_name(doc,attr);
2407 val = qs_get_attr_value(doc,attr);
2409 if (STRCASEEQ('a','A', "align", nm)) {
2410 /*----------------------------------------------------------------------*/
2411 /* CHTML 1.0 (W3C version 3.2) */
2412 /*----------------------------------------------------------------------*/
2413 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2414 align = apr_pstrdup(doc->buf.pool, val);
2426 return chtml20->out;
2431 * It is a handler who processes the DIV tag.
2433 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2434 * destination is specified.
2435 * @param node [i] The DIV tag node is specified.
2436 * @return The conversion result is returned.
2439 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2445 chtml20 = GET_CHTML20(pdoc);
2450 return chtml20->out;
2455 * It is a handler who processes the H1 tag.
2457 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2458 * destination is specified.
2459 * @param node [i] The H1 tag node is specified.
2460 * @return The conversion result is returned.
2463 s_chtml20_start_h1_tag(void *pdoc, Node *node)
2470 chtml20 = GET_CHTML20(pdoc);
2475 for (attr = qs_get_attr(doc,node);
2477 attr = qs_get_next_attr(doc,attr)) {
2480 name = qs_get_attr_name(doc,attr);
2481 value = qs_get_attr_value(doc,attr);
2482 if (STRCASEEQ('a','A',"align", name)) {
2483 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2492 return chtml20->out;
2497 * It is a handler who processes the H1 tag.
2499 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2500 * destination is specified.
2501 * @param node [i] The H1 tag node is specified.
2502 * @return The conversion result is returned.
2505 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
2511 chtml20 = GET_CHTML20(pdoc);
2516 return chtml20->out;
2521 * It is a handler who processes the H2 tag.
2523 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2524 * destination is specified.
2525 * @param node [i] The H2 tag node is specified.
2526 * @return The conversion result is returned.
2529 s_chtml20_start_h2_tag(void *pdoc, Node *node)
2536 chtml20 = GET_CHTML20(pdoc);
2541 for (attr = qs_get_attr(doc,node);
2543 attr = qs_get_next_attr(doc,attr)) {
2546 name = qs_get_attr_name(doc,attr);
2547 value = qs_get_attr_value(doc,attr);
2548 if (STRCASEEQ('a','A',"align", name)) {
2549 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2558 return chtml20->out;
2563 * It is a handler who processes the H2 tag.
2565 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2566 * destination is specified.
2567 * @param node [i] The H2 tag node is specified.
2568 * @return The conversion result is returned.
2571 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
2577 chtml20 = GET_CHTML20(pdoc);
2582 return chtml20->out;
2587 * It is a handler who processes the H3 tag.
2589 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2590 * destination is specified.
2591 * @param node [i] The H3 tag node is specified.
2592 * @return The conversion result is returned.
2595 s_chtml20_start_h3_tag(void *pdoc, Node *node)
2602 chtml20 = GET_CHTML20(pdoc);
2607 for (attr = qs_get_attr(doc,node);
2609 attr = qs_get_next_attr(doc,attr)) {
2612 name = qs_get_attr_name(doc,attr);
2613 value = qs_get_attr_value(doc,attr);
2614 if (STRCASEEQ('a','A',"align", name)) {
2615 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2624 return chtml20->out;
2629 * It is a handler who processes the H3 tag.
2631 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2632 * destination is specified.
2633 * @param node [i] The H3 tag node is specified.
2634 * @return The conversion result is returned.
2637 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
2643 chtml20 = GET_CHTML20(pdoc);
2648 return chtml20->out;
2653 * It is a handler who processes the H4 tag.
2655 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2656 * destination is specified.
2657 * @param node [i] The H4 tag node is specified.
2658 * @return The conversion result is returned.
2661 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2668 chtml20 = GET_CHTML20(pdoc);
2673 for (attr = qs_get_attr(doc,node);
2675 attr = qs_get_next_attr(doc,attr)) {
2678 name = qs_get_attr_name(doc,attr);
2679 value = qs_get_attr_value(doc,attr);
2680 if (STRCASEEQ('a','A',"align", name)) {
2681 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2690 return chtml20->out;
2695 * It is a handler who processes the H4 tag.
2697 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2698 * destination is specified.
2699 * @param node [i] The H4 tag node is specified.
2700 * @return The conversion result is returned.
2703 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
2709 chtml20 = GET_CHTML20(pdoc);
2714 return chtml20->out;
2719 * It is a handler who processes the H5 tag.
2721 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2722 * destination is specified.
2723 * @param node [i] The H5 tag node is specified.
2724 * @return The conversion result is returned.
2727 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2734 chtml20 = GET_CHTML20(pdoc);
2739 for (attr = qs_get_attr(doc,node);
2741 attr = qs_get_next_attr(doc,attr)) {
2744 name = qs_get_attr_name(doc,attr);
2745 value = qs_get_attr_value(doc,attr);
2746 if (STRCASEEQ('a','A',"align", name)) {
2747 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2756 return chtml20->out;
2761 * It is a handler who processes the H5 tag.
2763 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2764 * destination is specified.
2765 * @param node [i] The H5 tag node is specified.
2766 * @return The conversion result is returned.
2769 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
2775 chtml20 = GET_CHTML20(pdoc);
2780 return chtml20->out;
2785 * It is a handler who processes the H6 tag.
2787 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2788 * destination is specified.
2789 * @param node [i] The H6 tag node is specified.
2790 * @return The conversion result is returned.
2793 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2800 chtml20 = GET_CHTML20(pdoc);
2805 for (attr = qs_get_attr(doc,node);
2807 attr = qs_get_next_attr(doc,attr)) {
2810 name = qs_get_attr_name(doc,attr);
2811 value = qs_get_attr_value(doc,attr);
2812 if (STRCASEEQ('a','A',"align", name)) {
2813 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2822 return chtml20->out;
2827 * It is a handler who processes the H6 tag.
2829 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2830 * destination is specified.
2831 * @param node [i] The H6 tag node is specified.
2832 * @return The conversion result is returned.
2835 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
2841 chtml20 = GET_CHTML20(pdoc);
2846 return chtml20->out;
2851 * It is a handler who processes the PRE tag.
2853 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2854 * destination is specified.
2855 * @param node [i] The PRE tag node is specified.
2856 * @return The conversion result is returned.
2859 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node))
2865 chtml20 = GET_CHTML20(pdoc);
2869 chtml20->pre_flag++;
2871 return chtml20->out;
2876 * It is a handler who processes the PRE tag.
2878 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2879 * destination is specified.
2880 * @param node [i] The PRE tag node is specified.
2881 * @return The conversion result is returned.
2884 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
2890 chtml20 = GET_CHTML20(pdoc);
2895 chtml20->pre_flag--;
2897 return chtml20->out;
2902 * It is a handler who processes the P tag.
2904 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2905 * destination is specified.
2906 * @param node [i] The P tag node is specified.
2907 * @return The conversion result is returned.
2910 s_chtml20_start_p_tag(void *pdoc, Node *UNUSED(node))
2916 chtml20 = GET_CHTML20(pdoc);
2921 return chtml20->out;
2926 * It is a handler who processes the P tag.
2928 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2929 * destination is specified.
2930 * @param node [i] The P tag node is specified.
2931 * @return The conversion result is returned.
2934 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child))
2940 chtml20 = GET_CHTML20(pdoc);
2945 return chtml20->out;
2950 s_chtml20_chxjif_tag(void *pdoc, Node *node)
2957 chtml20 = GET_CHTML20(pdoc);
2961 for (child = qs_get_child_node(doc, node);
2963 child = qs_get_next_node(doc, child)) {
2966 s_chtml20_chxjif_tag(pdoc, child);
2974 * It is a handler who processes the TEXTARE tag.
2976 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2977 * destination is specified.
2978 * @param node [i] The TEXTAREA tag node is specified.
2979 * @return The conversion result is returned.
2982 s_chtml20_start_textarea_tag(void *pdoc, Node *node)
2989 chtml20 = GET_CHTML20(pdoc);
2993 chtml20->textarea_flag++;
2995 for (attr = qs_get_attr(doc,node);
2997 attr = qs_get_next_attr(doc,attr)) {
3002 name = qs_get_attr_name(doc,attr);
3003 value = qs_get_attr_value(doc,attr);
3008 if (strcasecmp(name, "name") == 0) {
3017 if (strcasecmp(name, "rows") == 0) {
3026 if (strcasecmp(name, "cols") == 0) {
3038 return chtml20->out;
3043 * It is a handler who processes the TEXTAREA tag.
3045 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3046 * destination is specified.
3047 * @param node [i] The TEXTAREA tag node is specified.
3048 * @return The conversion result is returned.
3051 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3057 chtml20 = GET_CHTML20(pdoc);
3061 W_L("</textarea>\r\n");
3062 chtml20->textarea_flag--;
3064 return chtml20->out;
3069 s_chtml20_text_tag(void *pdoc, Node *child)
3081 chtml20 = GET_CHTML20(pdoc);
3085 textval = qs_get_node_value(doc,child);
3086 textval = qs_trim_string(doc->buf.pool, textval);
3087 if (strlen(textval) == 0)
3088 return chtml20->out;
3090 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3091 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3093 tdst = qs_alloc_zero_byte_string(r);
3094 memset(one_byte, 0, sizeof(one_byte));
3097 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3099 int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3101 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3105 if (is_sjis_kanji(textval[ii])) {
3106 one_byte[0] = textval[ii+0];
3107 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3108 one_byte[0] = textval[ii+1];
3109 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3113 if (chtml20->pre_flag) {
3114 one_byte[0] = textval[ii+0];
3115 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3118 if (chtml20->textarea_flag) {
3119 one_byte[0] = textval[ii+0];
3120 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3123 if (textval[ii] != '\r' && textval[ii] != '\n') {
3124 one_byte[0] = textval[ii+0];
3125 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3129 return chtml20->out;
3134 * It is a handler who processes the BLOCKQUOTE tag.
3136 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3137 * destination is specified.
3138 * @param node [i] The BLOCKQUOTE tag node is specified.
3139 * @return The conversion result is returned.
3142 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3146 chtml20 = GET_CHTML20(pdoc);
3148 W_L("<blockquote>");
3149 return chtml20->out;
3154 * It is a handler who processes the BLOCKQUOTE tag.
3156 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3157 * destination is specified.
3158 * @param node [i] The BLOCKQUOTE tag node is specified.
3159 * @return The conversion result is returned.
3162 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3167 chtml20 = GET_CHTML20(pdoc);
3169 W_L("</blockquote>");
3170 return chtml20->out;
3175 * It is a handler who processes the DIR tag.
3177 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3178 * destination is specified.
3179 * @param node [i] The DIR tag node is specified.
3180 * @return The conversion result is returned.
3183 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3187 chtml20 = GET_CHTML20(pdoc);
3190 return chtml20->out;
3195 * It is a handler who processes the DIR tag.
3197 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3198 * destination is specified.
3199 * @param node [i] The DIR tag node is specified.
3200 * @return The conversion result is returned.
3203 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3208 chtml20 = GET_CHTML20(pdoc);
3211 return chtml20->out;
3216 * It is a handler who processes the DL tag.
3218 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3219 * destination is specified.
3220 * @param node [i] The DL tag node is specified.
3221 * @return The conversion result is returned.
3224 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3228 chtml20 = GET_CHTML20(pdoc);
3231 return chtml20->out;
3236 * It is a handler who processes the DL tag.
3238 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3239 * destination is specified.
3240 * @param node [i] The DL tag node is specified.
3241 * @return The conversion result is returned.
3244 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3248 chtml20 = GET_CHTML20(pdoc);
3251 return chtml20->out;
3256 * It is a handter who processes the DT tag.
3258 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3259 * destination is specified.
3260 * @param node [i] The DT tag node is specified.
3261 * @return The conversion result is returned.
3264 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3268 chtml20 = GET_CHTML20(pdoc);
3271 return chtml20->out;
3276 * It is a handter who processes the DT tag.
3278 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3279 * destination is specified.
3280 * @param node [i] The DT tag node is specified.
3281 * @return The conversion result is returned.
3284 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3287 chtml20 = GET_CHTML20(pdoc);
3288 return chtml20->out;
3293 * It is a handder who processes the DD tag.
3295 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3296 * destination is specified.
3297 * @param node [i] The DD tag node is specified.
3298 * @return The conversion result is returned.
3301 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3305 chtml20 = GET_CHTML20(pdoc);
3308 return chtml20->out;
3313 * It is a handder who processes the DD tag.
3315 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3316 * destination is specified.
3317 * @param node [i] The DD tag node is specified.
3318 * @return The conversion result is returned.
3321 s_chtml20_end_dd_tag(void *pdoc, Node *UNUSED(child))
3324 chtml20 = GET_CHTML20(pdoc);
3325 return chtml20->out;