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))
30 #define W_L(X) do { chtml20->out = BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, (X)); } while(0)
31 #define W_V(X) do { chtml20->out = (X) ? BUFFERED_WRITE_VALUE(chtml20->out, &doc->buf, (X)) \
32 : BUFFERED_WRITE_LITERAL(chtml20->out, &doc->buf, ""); } while(0)
34 static char *s_chtml20_start_html_tag (void *pdoc, Node *node);
35 static char *s_chtml20_end_html_tag (void *pdoc, Node *node);
36 static char *s_chtml20_start_meta_tag (void *pdoc, Node *node);
37 static char *s_chtml20_end_meta_tag (void *pdoc, Node *node);
38 static char *s_chtml20_start_textarea_tag(void *pdoc, Node *node);
39 static char *s_chtml20_end_textarea_tag (void *pdoc, Node *node);
40 static char *s_chtml20_start_p_tag (void *pdoc, Node *node);
41 static char *s_chtml20_end_p_tag (void *pdoc, Node *node);
42 static char *s_chtml20_start_pre_tag (void *pdoc, Node *node);
43 static char *s_chtml20_end_pre_tag (void *pdoc, Node *node);
44 static char *s_chtml20_start_h1_tag (void *pdoc, Node *node);
45 static char *s_chtml20_end_h1_tag (void *pdoc, Node *node);
46 static char *s_chtml20_start_h2_tag (void *pdoc, Node *node);
47 static char *s_chtml20_end_h2_tag (void *pdoc, Node *node);
48 static char *s_chtml20_start_h3_tag (void *pdoc, Node *node);
49 static char *s_chtml20_end_h3_tag (void *pdoc, Node *node);
50 static char *s_chtml20_start_h4_tag (void *pdoc, Node *node);
51 static char *s_chtml20_end_h4_tag (void *pdoc, Node *node);
52 static char *s_chtml20_start_h5_tag (void *pdoc, Node *node);
53 static char *s_chtml20_end_h5_tag (void *pdoc, Node *node);
54 static char *s_chtml20_start_h6_tag (void *pdoc, Node *node);
55 static char *s_chtml20_end_h6_tag (void *pdoc, Node *node);
56 static char *s_chtml20_start_ul_tag (void *pdoc, Node *node);
57 static char *s_chtml20_end_ul_tag (void *pdoc, Node *node);
58 static char *s_chtml20_start_ol_tag (void *pdoc, Node *node);
59 static char *s_chtml20_end_ol_tag (void *pdoc, Node *node);
60 static char *s_chtml20_start_li_tag (void *pdoc, Node *node);
61 static char *s_chtml20_end_li_tag (void *pdoc, Node *node);
62 static char *s_chtml20_start_head_tag (void *pdoc, Node *node);
63 static char *s_chtml20_end_head_tag (void *pdoc, Node *node);
64 static char *s_chtml20_start_title_tag (void *pdoc, Node *node);
65 static char *s_chtml20_end_title_tag (void *pdoc, Node *node);
66 static char *s_chtml20_start_base_tag (void *pdoc, Node *node);
67 static char *s_chtml20_end_base_tag (void *pdoc, Node *node);
68 static char *s_chtml20_start_body_tag (void *pdoc, Node *node);
69 static char *s_chtml20_end_body_tag (void *pdoc, Node *node);
70 static char *s_chtml20_start_a_tag (void *pdoc, Node *node);
71 static char *s_chtml20_end_a_tag (void *pdoc, Node *node);
72 static char *s_chtml20_start_br_tag (void *pdoc, Node *node);
73 static char *s_chtml20_end_br_tag (void *pdoc, Node *node);
74 static char *s_chtml20_start_tr_tag (void *pdoc, Node *node);
75 static char *s_chtml20_end_tr_tag (void *pdoc, Node *node);
76 static char *s_chtml20_start_font_tag (void *pdoc, Node *node);
77 static char *s_chtml20_end_font_tag (void *pdoc, Node *node);
78 static char *s_chtml20_start_form_tag (void *pdoc, Node *node);
79 static char *s_chtml20_end_form_tag (void *pdoc, Node *node);
80 static char *s_chtml20_start_input_tag (void *pdoc, Node *node);
81 static char *s_chtml20_end_input_tag (void *pdoc, Node *node);
82 static char *s_chtml20_start_center_tag (void *pdoc, Node *node);
83 static char *s_chtml20_end_center_tag (void *pdoc, Node *node);
84 static char *s_chtml20_start_hr_tag (void *pdoc, Node *node);
85 static char *s_chtml20_end_hr_tag (void *pdoc, Node *node);
86 static char *s_chtml20_start_img_tag (void *pdoc, Node *node);
87 static char *s_chtml20_end_img_tag (void *pdoc, Node *node);
88 static char *s_chtml20_start_select_tag (void *pdoc, Node *node);
89 static char *s_chtml20_end_select_tag (void *pdoc, Node *node);
90 static char *s_chtml20_start_option_tag (void *pdoc, Node *node);
91 static char *s_chtml20_end_option_tag (void *pdoc, Node *node);
92 static char *s_chtml20_start_div_tag (void *pdoc, Node *node);
93 static char *s_chtml20_end_div_tag (void *pdoc, Node *node);
94 static char *s_chtml20_start_blockquote_tag(void *pdoc, Node *node);
95 static char *s_chtml20_end_blockquote_tag (void *pdoc, Node *node);
96 static char *s_chtml20_start_dir_tag (void *pdoc, Node *node);
97 static char *s_chtml20_end_dir_tag (void *pdoc, Node *node);
98 static char *s_chtml20_start_dl_tag (void *pdoc, Node *node);
99 static char *s_chtml20_end_dl_tag (void *pdoc, Node *node);
100 static char *s_chtml20_start_dt_tag (void *pdoc, Node *node);
101 static char *s_chtml20_end_dt_tag (void *pdoc, Node *node);
102 static char *s_chtml20_start_dd_tag (void *pdoc, Node *node);
103 static char *s_chtml20_end_dd_tag (void *pdoc, Node *node);
104 static char *s_chtml20_start_menu_tag (void *pdoc, Node *node);
105 static char *s_chtml20_end_menu_tag (void *pdoc, Node *node);
106 static char *s_chtml20_start_plaintext_tag (void *pdoc, Node *node);
107 static char *s_chtml20_start_plaintext_tag_inner (void *pdoc, Node *node);
108 static char *s_chtml20_end_plaintext_tag (void *pdoc, Node *node);
109 static char *s_chtml20_start_blink_tag (void *pdoc, Node *node);
110 static char *s_chtml20_end_blink_tag (void *pdoc, Node *node);
111 static char *s_chtml20_start_marquee_tag (void *pdoc, Node *node);
112 static char *s_chtml20_end_marquee_tag (void *pdoc, Node *node);
114 static void s_init_chtml20(chtml20_t *chtml, Doc *doc, request_rec *r, device_table *spec);
116 static int s_chtml20_search_emoji(chtml20_t *chtml, char *txt, char **rslt);
118 static char *s_chtml20_chxjif_tag(void *pdoc, Node *node);
119 static char *s_chtml20_text_tag(void *pdoc, Node *node);
122 tag_handler chtml20_handler[] = {
125 s_chtml20_start_html_tag,
126 s_chtml20_end_html_tag,
130 s_chtml20_start_meta_tag,
131 s_chtml20_end_meta_tag,
135 s_chtml20_start_textarea_tag,
136 s_chtml20_end_textarea_tag,
140 s_chtml20_start_p_tag,
145 s_chtml20_start_pre_tag,
146 s_chtml20_end_pre_tag,
150 s_chtml20_start_ul_tag,
151 s_chtml20_end_ul_tag,
155 s_chtml20_start_li_tag,
156 s_chtml20_end_li_tag,
160 s_chtml20_start_ol_tag,
161 s_chtml20_end_ol_tag,
165 s_chtml20_start_h1_tag,
166 s_chtml20_end_h1_tag,
170 s_chtml20_start_h2_tag,
171 s_chtml20_end_h2_tag,
175 s_chtml20_start_h3_tag,
176 s_chtml20_end_h3_tag,
180 s_chtml20_start_h4_tag,
181 s_chtml20_end_h4_tag,
185 s_chtml20_start_h5_tag,
186 s_chtml20_end_h5_tag,
190 s_chtml20_start_h6_tag,
191 s_chtml20_end_h6_tag,
195 s_chtml20_start_head_tag,
196 s_chtml20_end_head_tag,
200 s_chtml20_start_title_tag,
201 s_chtml20_end_title_tag,
205 s_chtml20_start_base_tag,
206 s_chtml20_end_base_tag,
210 s_chtml20_start_body_tag,
211 s_chtml20_end_body_tag,
215 s_chtml20_start_a_tag,
220 s_chtml20_start_br_tag,
221 s_chtml20_end_br_tag,
230 s_chtml20_start_tr_tag,
231 s_chtml20_end_tr_tag,
245 s_chtml20_start_font_tag,
246 s_chtml20_end_font_tag,
250 s_chtml20_start_form_tag,
251 s_chtml20_end_form_tag,
255 s_chtml20_start_input_tag,
256 s_chtml20_end_input_tag,
260 s_chtml20_start_center_tag,
261 s_chtml20_end_center_tag,
265 s_chtml20_start_hr_tag,
266 s_chtml20_end_hr_tag,
270 s_chtml20_start_img_tag,
271 s_chtml20_end_img_tag,
275 s_chtml20_start_select_tag,
276 s_chtml20_end_select_tag,
280 s_chtml20_start_option_tag,
281 s_chtml20_end_option_tag,
285 s_chtml20_start_div_tag,
286 s_chtml20_end_div_tag,
290 s_chtml20_chxjif_tag,
335 s_chtml20_start_dt_tag,
336 s_chtml20_end_dt_tag,
350 s_chtml20_start_blockquote_tag,
351 s_chtml20_end_blockquote_tag,
355 s_chtml20_start_dir_tag,
356 s_chtml20_end_dir_tag,
360 s_chtml20_start_dl_tag,
361 s_chtml20_end_dl_tag,
365 s_chtml20_start_dd_tag,
366 s_chtml20_end_dd_tag,
370 s_chtml20_start_menu_tag,
371 s_chtml20_end_menu_tag,
375 s_chtml20_start_plaintext_tag,
376 s_chtml20_end_plaintext_tag,
380 s_chtml20_start_blink_tag,
381 s_chtml20_end_blink_tag,
385 s_chtml20_start_marquee_tag,
386 s_chtml20_end_marquee_tag,
391 * converts from CHTML5.0 to CHTML2.0.
393 * @param r [i] Requet_rec is appointed.
394 * @param spec [i] The result of the device specification processing which
395 * was done in advance is appointed.
396 * @param src [i] The character string before the converting is appointed.
397 * @return The character string after the converting is returned.
400 chxj_exchange_chtml20(
406 chxjconvrule_entry *entryp,
415 /*--------------------------------------------------------------------------*/
417 /*--------------------------------------------------------------------------*/
419 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
421 DBG(r,"i found qrcode xml");
424 DBG(r,"not found qrcode xml");
426 /*--------------------------------------------------------------------------*/
427 /* The CHTML structure is initialized. */
428 /*--------------------------------------------------------------------------*/
429 s_init_chtml20(&chtml20, &doc, r, spec);
432 chtml20.entryp = entryp;
433 chtml20.cookie = cookie;
435 chxj_set_content_type(r, "text/html; charset=Windows-31J");
437 /*--------------------------------------------------------------------------*/
438 /* The character string of the input is analyzed. */
439 /*--------------------------------------------------------------------------*/
440 qs_init_malloc(&doc);
441 qs_init_root_node(&doc);
443 ss = apr_pcalloc(r->pool, srclen + 1);
444 memset(ss, 0, srclen + 1);
445 memcpy(ss, src, srclen);
448 chxj_dump_out("[src] CHTML -> CHTML2.0", ss, srclen);
451 qs_parse_string(&doc,ss, strlen(ss));
453 chxj_buffered_write_init(r->pool, &doc.buf);
454 /*--------------------------------------------------------------------------*/
455 /* It converts it from CHTML to CHTML. */
456 /*--------------------------------------------------------------------------*/
457 chxj_node_exchange(spec,r,(void *)&chtml20, &doc, qs_get_root(&doc), 0);
458 chtml20.out = chxj_buffered_write_flush(chtml20.out, &doc.buf);
459 dst = apr_pstrdup(r->pool, chtml20.out);
460 chxj_buffered_write_terminate(&doc.buf);
462 qs_all_free(&doc,QX_LOGMARK);
465 return apr_pstrdup(r->pool,ss);
468 if (strlen(dst) == 0) {
469 dst = apr_psprintf(r->pool, "\n");
472 *dstlen = strlen(dst);
475 chxj_dump_out("[dst] CHTML -> CHTML2.0", dst, *dstlen);
482 * The CHTML structure is initialized.
484 * @param chtml20 [i/o] The pointer to the HDML structure that wants to be
485 * initialized is specified.
486 * @param doc [i] The Doc structure that should be set to the initialized
487 * HDML structure is specified.
488 * @param r [i] To use POOL, the pointer to request_rec is specified.
489 * @param spec [i] The pointer to the device_table
492 s_init_chtml20(chtml20_t *chtml20, Doc *doc, request_rec *r, device_table *spec)
494 memset(doc, 0, sizeof(Doc));
495 memset(chtml20, 0, sizeof(chtml20_t));
499 chtml20->spec = spec;
500 chtml20->out = qs_alloc_zero_byte_string(r);
501 chtml20->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
503 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
508 * Corresponding EMOJI to a current character-code is retrieved.
509 * The substitution character string is stored in the rslt pointer if agreeing.
511 * @param chtml20 [i] The pointer to the CHTML structure is specified.
512 * @param txt [i] The character string to want to examine whether it is
513 * EMOJI is specified.
514 * @param rslt [o] The pointer to the pointer that stores the result is
516 * @return When corresponding EMOJI exists, it returns it excluding 0.
519 s_chtml20_search_emoji(chtml20_t *chtml20, char *txt, char **rslt)
526 spec = chtml20->spec;
532 DBG(r,"spec is NULL");
534 for (ee = chtml20->conf->emoji;
538 if (ee->imode == NULL) {
539 DBG(r,"emoji->imode is NULL");
543 if (ee->imode->string != NULL
544 && strlen(ee->imode->string) > 0
545 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
546 if (spec == NULL || spec->emoji_type == NULL) {
547 *rslt = apr_palloc(r->pool, 3);
548 (*rslt)[0] = ee->imode->hex1byte & 0xff;
549 (*rslt)[1] = ee->imode->hex2byte & 0xff;
551 return strlen(ee->imode->string);
563 * It is a handler who processes the HTML tag.
565 * @param pdoc [i/o] The pointer to the CHTML structure at the output
566 * destination is specified.
567 * @param node [i] The HTML tag node is specified.
568 * @return The conversion result is returned.
571 s_chtml20_start_html_tag(void *pdoc, Node *UNUSED(node))
577 chtml20 = GET_CHTML20(pdoc);
581 /*--------------------------------------------------------------------------*/
583 /*--------------------------------------------------------------------------*/
590 * It is a handler who processes the HTML tag.
592 * @param pdoc [i/o] The pointer to the CHTML structure at the output
593 * destination is specified.
594 * @param node [i] The HTML tag node is specified.
595 * @return The conversion result is returned.
598 s_chtml20_end_html_tag(void *pdoc, Node *UNUSED(child))
604 chtml20 = GET_CHTML20(pdoc);
614 * It is a handler who processes the META tag.
616 * @param pdoc [i/o] The pointer to the CHTML structure at the output
617 * destination is specified.
618 * @param node [i] The META tag node is specified.
619 * @return The conversion result is returned.
622 s_chtml20_start_meta_tag(void *pdoc, Node *node)
628 int content_type_flag;
631 chtml20 = GET_CHTML20(pdoc);
635 content_type_flag = 0;
639 /*--------------------------------------------------------------------------*/
641 /*--------------------------------------------------------------------------*/
642 for (attr = qs_get_attr(doc,node);
644 attr = qs_get_next_attr(doc,attr)) {
645 char *name = qs_get_attr_name(doc,attr);
646 char *value = qs_get_attr_value(doc,attr);
650 if (strcasecmp(name, "http-equiv") == 0 && value && *value) {
651 /*----------------------------------------------------------------------*/
653 /*----------------------------------------------------------------------*/
654 W_L(" http-equiv=\"");
657 if (STRCASEEQ('c','C',"content-type", value)) {
658 content_type_flag = 1;
660 if (STRCASEEQ('r','R',"refresh", value)) {
668 if (strcasecmp(name, "content") == 0 && value && *value) {
669 if (content_type_flag) {
672 W_L("=\"text/html; charset=Windows-31J\"");
674 else if (refresh_flag) {
675 char *buf = apr_pstrdup(r->pool, value);
679 url = strchr(buf, ';');
681 sec = apr_pstrdup(r->pool, buf);
684 url = chxj_encoding_parameter(r, url);
685 url = chxj_add_cookie_parameter(r, url, chtml20->cookie);
715 * It is a handler who processes the META tag.
717 * @param pdoc [i/o] The pointer to the CHTML structure at the output
718 * destination is specified.
719 * @param node [i] The META tag node is specified.
720 * @return The conversion result is returned.
723 s_chtml20_end_meta_tag(void *pdoc, Node *UNUSED(child))
727 chtml20 = GET_CHTML20(pdoc);
734 * It is a handler who processes the HEAD tag.
736 * @param pdoc [i/o] The pointer to the CHTML structure at the output
737 * destination is specified.
738 * @param node [i] The HEAD tag node is specified.
739 * @return The conversion result is returned.
742 s_chtml20_start_head_tag(void *pdoc, Node *UNUSED(node))
748 chtml20 = GET_CHTML20(pdoc);
758 * It is a handler who processes the HEAD tag.
760 * @param pdoc [i/o] The pointer to the CHTML structure at the output
761 * destination is specified.
762 * @param node [i] The HEAD tag node is specified.
763 * @return The conversion result is returned.
766 s_chtml20_end_head_tag(void *pdoc, Node *UNUSED(child))
772 chtml20 = GET_CHTML20(pdoc);
782 * It is a handler who processes the TITLE tag.
784 * @param pdoc [i/o] The pointer to the CHTML structure at the output
785 * destination is specified.
786 * @param node [i] The TITLE tag node is specified.
787 * @return The conversion result is returned.
790 s_chtml20_start_title_tag(void *pdoc, Node *UNUSED(node))
796 chtml20 = GET_CHTML20(pdoc);
806 * It is a handler who processes the TITLE tag.
808 * @param pdoc [i/o] The pointer to the CHTML structure at the output
809 * destination is specified.
810 * @param node [i] The TITLE tag node is specified.
811 * @return The conversion result is returned.
814 s_chtml20_end_title_tag(void *pdoc, Node *UNUSED(child))
820 chtml20 = GET_CHTML20(pdoc);
830 * It is a handler who processes the BASE tag.
832 * @param pdoc [i/o] The pointer to the CHTML structure at the output
833 * destination is specified.
834 * @param node [i] The BASE tag node is specified.
835 * @return The conversion result is returned.
838 s_chtml20_start_base_tag(void *pdoc, Node *node)
845 chtml20 = GET_CHTML20(pdoc);
850 /*--------------------------------------------------------------------------*/
852 /*--------------------------------------------------------------------------*/
853 for (attr = qs_get_attr(doc,node);
855 attr = qs_get_next_attr(doc,attr)) {
860 name = qs_get_attr_name(doc,attr);
861 value = qs_get_attr_value(doc,attr);
863 if (STRCASEEQ('h','H',"href", name)) {
875 * It is a handler who processes the BASE tag.
877 * @param pdoc [i/o] The pointer to the CHTML structure at the output
878 * destination is specified.
879 * @param node [i] The BASE tag node is specified.
880 * @return The conversion result is returned.
883 s_chtml20_end_base_tag(void *pdoc, Node *UNUSED(child))
889 chtml20 = GET_CHTML20(pdoc);
898 * It is a handler who processes the BODY tag.
900 * @param pdoc [i/o] The pointer to the CHTML structure at the output
901 * destination is specified.
902 * @param node [i] The BODY tag node is specified.
903 * @return The conversion result is returned.
906 s_chtml20_start_body_tag(void *pdoc, Node *node)
913 chtml20 = GET_CHTML20(pdoc);
918 /*--------------------------------------------------------------------------*/
920 /*--------------------------------------------------------------------------*/
921 for (attr = qs_get_attr(doc,node);
923 attr = qs_get_next_attr(doc,attr)) {
927 name = qs_get_attr_name(doc,attr);
928 value = qs_get_attr_value(doc,attr);
933 if (strcasecmp(name, "bgcolor") == 0 && value && *value != 0) {
934 /*----------------------------------------------------------------------*/
936 /*----------------------------------------------------------------------*/
945 if (strcasecmp(name, "text") == 0 && value && *value != 0) {
946 /*----------------------------------------------------------------------*/
948 /*----------------------------------------------------------------------*/
957 if (strcasecmp(name, "link") == 0 && value && *value != 0) {
958 /*----------------------------------------------------------------------*/
960 /*----------------------------------------------------------------------*/
969 if (strcasecmp(name, "alink") == 0) {
970 /*----------------------------------------------------------------------*/
972 /*----------------------------------------------------------------------*/
979 if (strcasecmp(name, "vlink") == 0) {
980 /*----------------------------------------------------------------------*/
982 /*----------------------------------------------------------------------*/
997 * It is a handler who processes the BODY tag.
999 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1000 * destination is specified.
1001 * @param node [i] The BODY tag node is specified.
1002 * @return The conversion result is returned.
1005 s_chtml20_end_body_tag(void *pdoc, Node *UNUSED(child))
1011 chtml20 = GET_CHTML20(pdoc);
1016 return chtml20->out;
1021 * It is a handler who processes the A tag.
1023 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1024 * destination is specified.
1025 * @param node [i] The A tag node is specified.
1026 * @return The conversion result is returned.
1029 s_chtml20_start_a_tag(void *pdoc, Node *node)
1036 chtml20 = GET_CHTML20(pdoc);
1041 /*--------------------------------------------------------------------------*/
1042 /* Get Attributes */
1043 /*--------------------------------------------------------------------------*/
1044 for (attr = qs_get_attr(doc,node);
1046 attr = qs_get_next_attr(doc,attr)) {
1047 char *name = qs_get_attr_name(doc,attr);
1048 char *value = qs_get_attr_value(doc,attr);
1052 if (strcasecmp(name, "name") == 0) {
1053 /*--------------------------------------------------------------------*/
1055 /*--------------------------------------------------------------------*/
1064 if (strcasecmp(name, "href") == 0) {
1065 /*--------------------------------------------------------------------*/
1067 /*--------------------------------------------------------------------*/
1068 value = chxj_encoding_parameter(r, value);
1069 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1078 if (strcasecmp(name, "accesskey") == 0) {
1079 /*--------------------------------------------------------------------*/
1081 /*--------------------------------------------------------------------*/
1082 W_L(" accesskey=\"");
1090 if (strcasecmp(name, "cti") == 0) {
1091 /*--------------------------------------------------------------------*/
1093 /*--------------------------------------------------------------------*/
1102 if (strcasecmp(name, "ijam") == 0) {
1103 /*--------------------------------------------------------------------*/
1105 /*--------------------------------------------------------------------*/
1109 if (strcasecmp(name, "ista") == 0) {
1110 /*--------------------------------------------------------------------*/
1112 /*--------------------------------------------------------------------*/
1116 if (strcasecmp(name, "ilet") == 0) {
1117 /*--------------------------------------------------------------------*/
1119 /*--------------------------------------------------------------------*/
1123 if (strcasecmp(name, "iswf") == 0) {
1124 /*--------------------------------------------------------------------*/
1126 /*--------------------------------------------------------------------*/
1130 if (strcasecmp(name, "irst") == 0) {
1131 /*--------------------------------------------------------------------*/
1133 /*--------------------------------------------------------------------*/
1140 if (strcasecmp(name, "utn") == 0) {
1141 /*--------------------------------------------------------------------*/
1143 /*--------------------------------------------------------------------*/
1150 if (strcasecmp(name, "telbook") == 0) {
1151 /*--------------------------------------------------------------------*/
1153 /*--------------------------------------------------------------------*/
1160 if (strcasecmp(name, "kana") == 0) {
1161 /*--------------------------------------------------------------------*/
1163 /*--------------------------------------------------------------------*/
1170 if (strcasecmp(name, "email") == 0) {
1171 /*--------------------------------------------------------------------*/
1173 /*--------------------------------------------------------------------*/
1183 return chtml20->out;
1188 * It is a handler who processes the A tag.
1190 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1191 * destination is specified.
1192 * @param node [i] The A tag node is specified.
1193 * @return The conversion result is returned.
1196 s_chtml20_end_a_tag(void *pdoc, Node *UNUSED(child))
1202 chtml20 = GET_CHTML20(pdoc);
1207 return chtml20->out;
1212 * It is a handler who processes the BR tag.
1214 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1215 * destination is specified.
1216 * @param node [i] The BR tag node is specified.
1217 * @return The conversion result is returned.
1220 s_chtml20_start_br_tag(void *pdoc, Node *node)
1227 chtml20 = GET_CHTML20(pdoc);
1232 /*--------------------------------------------------------------------------*/
1233 /* Get Attributes */
1234 /*--------------------------------------------------------------------------*/
1235 for (attr = qs_get_attr(doc,node);
1237 attr = qs_get_next_attr(doc,attr)) {
1241 name = qs_get_attr_name(doc,attr);
1242 value = qs_get_attr_value(doc,attr);
1244 if (STRCASEEQ('c','C',"clear",name)) {
1245 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('a','A',"all",value))) {
1253 return chtml20->out;
1258 * It is a handler who processes the BR tag.
1260 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1261 * destination is specified.
1262 * @param node [i] The BR tag node is specified.
1263 * @return The conversion result is returned.
1266 s_chtml20_end_br_tag(void *pdoc, Node *UNUSED(child))
1272 chtml20 = GET_CHTML20(pdoc);
1276 return chtml20->out;
1281 * It is a handler who processes the TR tag.
1283 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1284 * destination is specified.
1285 * @param node [i] The TR tag node is specified.
1286 * @return The conversion result is returned.
1289 s_chtml20_start_tr_tag(void *pdoc, Node *UNUSED(node))
1295 chtml20 = GET_CHTML20(pdoc);
1299 return chtml20->out;
1304 * It is a handler who processes the TR tag.
1306 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1307 * destination is specified.
1308 * @param node [i] The TR tag node is specified.
1309 * @return The conversion result is returned.
1312 s_chtml20_end_tr_tag(void *pdoc, Node *UNUSED(child))
1318 chtml20 = GET_CHTML20(pdoc);
1323 return chtml20->out;
1328 * It is a handler who processes the FONT tag.
1330 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1331 * destination is specified.
1332 * @param node [i] The FONT tag node is specified.
1333 * @return The conversion result is returned.
1336 s_chtml20_start_font_tag(void *pdoc, Node *node)
1343 chtml20 = GET_CHTML20(pdoc);
1349 /*--------------------------------------------------------------------------*/
1350 /* Get Attributes */
1351 /*--------------------------------------------------------------------------*/
1352 for (attr = qs_get_attr(doc,node);
1354 attr = qs_get_next_attr(doc,attr)) {
1359 name = qs_get_attr_name(doc,attr);
1360 value = qs_get_attr_value(doc,attr);
1365 if (strcasecmp(name, "color") == 0) {
1374 if (strcasecmp(name, "size") == 0) {
1375 /*--------------------------------------------------------------------*/
1377 /*--------------------------------------------------------------------*/
1387 return chtml20->out;
1392 * It is a handler who processes the FONT tag.
1394 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1395 * destination is specified.
1396 * @param node [i] The FONT tag node is specified.
1397 * @return The conversion result is returned.
1400 s_chtml20_end_font_tag(void *pdoc, Node *UNUSED(child))
1406 chtml20 = GET_CHTML20(pdoc);
1411 return chtml20->out;
1416 * It is a handler who processes the FORM tag.
1418 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1419 * destination is specified.
1420 * @param node [i] The FORM tag node is specified.
1421 * @return The conversion result is returned.
1424 s_chtml20_start_form_tag(void *pdoc, Node *node)
1431 chtml20 = GET_CHTML20(pdoc);
1436 /*--------------------------------------------------------------------------*/
1437 /* Get Attributes */
1438 /*--------------------------------------------------------------------------*/
1439 for (attr = qs_get_attr(doc,node);
1441 attr = qs_get_next_attr(doc,attr)) {
1446 name = qs_get_attr_name(doc,attr);
1447 value = qs_get_attr_value(doc,attr);
1452 if (strcasecmp(name, "action") == 0) {
1453 /*--------------------------------------------------------------------*/
1455 /*--------------------------------------------------------------------*/
1456 value = chxj_encoding_parameter(r, value);
1457 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
1467 if (strcasecmp(name, "method") == 0) {
1468 /*--------------------------------------------------------------------*/
1470 /*--------------------------------------------------------------------*/
1479 if (strcasecmp(name, "utn") == 0) {
1480 /*--------------------------------------------------------------------*/
1482 /*--------------------------------------------------------------------*/
1492 return chtml20->out;
1497 * It is a handler who processes the FORM tag.
1499 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1500 * destination is specified.
1501 * @param node [i] The FORM tag node is specified.
1502 * @return The conversion result is returned.
1505 s_chtml20_end_form_tag(void *pdoc, Node *UNUSED(child))
1511 chtml20 = GET_CHTML20(pdoc);
1516 return chtml20->out;
1521 * It is a handler who processes the INPUT tag.
1523 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1524 * destination is specified.
1525 * @param node [i] The INPUT tag node is specified.
1526 * @return The conversion result is returned.
1529 s_chtml20_start_input_tag(void *pdoc, Node *node)
1534 char *max_length = NULL;
1538 char *istyle = NULL;
1540 char *checked = NULL;
1541 char *accesskey = NULL;
1543 chtml20 = GET_CHTML20(pdoc);
1549 /*--------------------------------------------------------------------------*/
1550 /* Get Attributes */
1551 /*--------------------------------------------------------------------------*/
1553 type = qs_get_type_attr(doc, node, r);
1554 name = qs_get_name_attr(doc, node, r);
1555 value = qs_get_value_attr(doc,node,r);
1556 istyle = qs_get_istyle_attr(doc,node,r);
1557 max_length = qs_get_maxlength_attr(doc,node,r);
1558 checked = qs_get_checked_attr(doc,node,r);
1559 accesskey = qs_get_accesskey_attr(doc, node, r);
1560 size = qs_get_size_attr(doc, node, r);
1563 type = qs_trim_string(doc->buf.pool, type);
1564 if (type && (STRCASEEQ('t','T',"text", type) ||
1565 STRCASEEQ('p','P',"password",type) ||
1566 STRCASEEQ('c','C',"checkbox",type) ||
1567 STRCASEEQ('r','R',"radio", type) ||
1568 STRCASEEQ('h','H',"hidden", type) ||
1569 STRCASEEQ('s','S',"submit", type) ||
1570 STRCASEEQ('r','R',"reset", type))) {
1576 if (size && *size) {
1581 if (name && *name) {
1586 if (value && *value) {
1591 if (accesskey && *accesskey) {
1592 W_L(" accesskey=\"");
1597 /*------------------------------------------------------------------------*/
1599 /*------------------------------------------------------------------------*/
1600 if (*istyle == '1' || *istyle == '2' || *istyle == '3' || *istyle == '4') {
1607 /*--------------------------------------------------------------------------*/
1608 /* The figure is default for the password. */
1609 /*--------------------------------------------------------------------------*/
1610 if (max_length && *max_length) {
1611 if (chxj_chk_numeric(max_length) != 0) {
1612 max_length = apr_psprintf(doc->buf.pool, "0");
1614 if (istyle && *istyle == '1') {
1615 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length) * 2);
1619 char *vv = apr_psprintf(doc->buf.pool, " maxlength=\"%d\"", chxj_atoi(max_length));
1628 return chtml20->out;
1633 * It is a handler who processes the INPUT tag.
1635 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1636 * destination is specified.
1637 * @param node [i] The INPUT tag node is specified.
1638 * @return The conversion result is returned.
1641 s_chtml20_end_input_tag(void *pdoc, Node *UNUSED(child))
1647 chtml20 = GET_CHTML20(pdoc);
1651 return chtml20->out;
1656 * It is a handler who processes the CENTER tag.
1658 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1659 * destination is specified.
1660 * @param node [i] The CENTER tag node is specified.
1661 * @return The conversion result is returned.
1664 s_chtml20_start_center_tag(void *pdoc, Node *UNUSED(node))
1670 chtml20 = GET_CHTML20(pdoc);
1675 return chtml20->out;
1680 * It is a handler who processes the CENTER tag.
1682 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1683 * destination is specified.
1684 * @param node [i] The CENTER tag node is specified.
1685 * @return The conversion result is returned.
1688 s_chtml20_end_center_tag(void *pdoc, Node *UNUSED(child))
1694 chtml20 = GET_CHTML20(pdoc);
1699 return chtml20->out;
1704 * It is a handler who processes the UL tag.
1706 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1707 * destination is specified.
1708 * @param node [i] The UL tag node is specified.
1709 * @return The conversion result is returned.
1712 s_chtml20_start_ul_tag(void *pdoc, Node *UNUSED(node))
1718 chtml20 = GET_CHTML20(pdoc);
1723 return chtml20->out;
1728 * It is a handler who processes the UL tag.
1730 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1731 * destination is specified.
1732 * @param node [i] The UL tag node is specified.
1733 * @return The conversion result is returned.
1736 s_chtml20_end_ul_tag(void *pdoc, Node *UNUSED(child))
1742 chtml20 = GET_CHTML20(pdoc);
1747 return chtml20->out;
1752 * It is a handler who processes the OL tag.
1754 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1755 * destination is specified.
1756 * @param node [i] The OL tag node is specified.
1757 * @return The conversion result is returned.
1760 s_chtml20_start_ol_tag(void *pdoc, Node *node)
1767 chtml20 = GET_CHTML20(pdoc);
1772 /*--------------------------------------------------------------------------*/
1773 /* Get Attributes */
1774 /*--------------------------------------------------------------------------*/
1775 for (attr = qs_get_attr(doc,node);
1777 attr = qs_get_next_attr(doc,attr)) {
1778 char *name = qs_get_attr_name(doc,attr);
1779 char *value = qs_get_attr_value(doc,attr);
1780 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1785 else if (STRCASEEQ('s','S',"start",name) && value && *value) {
1792 return chtml20->out;
1797 * It is a handler who processes the OL tag.
1799 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1800 * destination is specified.
1801 * @param node [i] The OL tag node is specified.
1802 * @return The conversion result is returned.
1805 s_chtml20_end_ol_tag(void *pdoc, Node *UNUSED(child))
1811 chtml20 = GET_CHTML20(pdoc);
1816 return chtml20->out;
1821 * It is a handler who processes the LI tag.
1823 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1824 * destination is specified.
1825 * @param node [i] The LI tag node is specified.
1826 * @return The conversion result is returned.
1829 s_chtml20_start_li_tag(void *pdoc, Node *node)
1836 chtml20 = GET_CHTML20(pdoc);
1841 /*--------------------------------------------------------------------------*/
1842 /* Get Attributes */
1843 /*--------------------------------------------------------------------------*/
1844 for (attr = qs_get_attr(doc,node);
1846 attr = qs_get_next_attr(doc,attr)) {
1847 char *name = qs_get_attr_name(doc,attr);
1848 char *value = qs_get_attr_value(doc,attr);
1849 if (STRCASEEQ('t','T',"type",name) && value && (*value == '1' || *value == 'a' || *value == 'A')) {
1854 else if (STRCASEEQ('v','V',"value", name) && value && *value) {
1861 return chtml20->out;
1866 * It is a handler who processes the LI tag.
1868 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1869 * destination is specified.
1870 * @param node [i] The LI tag node is specified.
1871 * @return The conversion result is returned.
1874 s_chtml20_end_li_tag(void *pdoc, Node *UNUSED(child))
1876 chtml20_t *chtml20 = GET_CHTML20(pdoc);
1877 return chtml20->out;
1882 * It is a handler who processes the HR tag.
1884 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1885 * destination is specified.
1886 * @param node [i] The HR tag node is specified.
1887 * @return The conversion result is returned.
1890 s_chtml20_start_hr_tag(void *pdoc, Node *node)
1897 chtml20 = GET_CHTML20(pdoc);
1903 for (attr = qs_get_attr(doc,node);
1905 attr = qs_get_next_attr(doc,attr)) {
1910 name = qs_get_attr_name(doc,attr);
1911 value = qs_get_attr_value(doc,attr);
1916 if (strcasecmp(name, "align") == 0) {
1917 /*--------------------------------------------------------------------*/
1919 /*--------------------------------------------------------------------*/
1920 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
1930 if (strcasecmp(name, "size") == 0) {
1931 /*--------------------------------------------------------------------*/
1933 /*--------------------------------------------------------------------*/
1934 if (value && value[0] != '\0') {
1944 if (strcasecmp(name, "width") == 0) {
1945 /*--------------------------------------------------------------------*/
1947 /*--------------------------------------------------------------------*/
1948 if (value && value[0] != '\0') {
1958 if (strcasecmp(name, "noshade") == 0) {
1959 /*--------------------------------------------------------------------*/
1961 /*--------------------------------------------------------------------*/
1968 if (strcasecmp(name, "color") == 0) {
1969 /*--------------------------------------------------------------------*/
1971 /*--------------------------------------------------------------------*/
1981 return chtml20->out;
1986 * It is a handler who processes the HR tag.
1988 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1989 * destination is specified.
1990 * @param node [i] The HR tag node is specified.
1991 * @return The conversion result is returned.
1994 s_chtml20_end_hr_tag(void *pdoc, Node *UNUSED(child))
2000 chtml20 = GET_CHTML20(pdoc);
2004 return chtml20->out;
2009 * It is a handler who processes the IMG tag.
2011 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2012 * destination is specified.
2013 * @param node [i] The IMG tag node is specified.
2014 * @return The conversion result is returned.
2017 s_chtml20_start_img_tag(void *pdoc, Node *node)
2023 #ifndef IMG_NOT_CONVERT_FILENAME
2027 chtml20 = GET_CHTML20(pdoc);
2031 #ifndef IMG_NOT_CONVERT_FILENAME
2032 spec = chtml20->spec;
2036 /*-------------------------------------------------------------------------*/
2037 /* Get Attributes */
2038 /*-------------------------------------------------------------------------*/
2039 for (attr = qs_get_attr(doc,node);
2041 attr = qs_get_next_attr(doc,attr)) {
2042 char *name = qs_get_attr_name(doc,attr);
2043 char *value = qs_get_attr_value(doc,attr);
2047 if (strcasecmp(name, "src") == 0) {
2048 /*-------------------------------------------------------------------*/
2050 /*-------------------------------------------------------------------*/
2051 #ifdef IMG_NOT_CONVERT_FILENAME
2052 value = chxj_encoding_parameter(r, value);
2053 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2055 value = apr_psprintf(doc->buf.pool,
2058 (strchr(value, '?')) ? '&' : '?',
2059 CHXJ_COOKIE_NOUPDATE_PARAM);
2065 value = chxj_img_conv(r, spec, value);
2066 value = chxj_encoding_parameter(r, value);
2067 value = chxj_add_cookie_parameter(r, value, chtml20->cookie);
2069 value = apr_psprintf(doc->buf.pool,
2072 (strchr(value, '?')) ? '&' : '?',
2073 CHXJ_COOKIE_NOUPDATE_PARAM);
2084 if (strcasecmp(name, "align" ) == 0) {
2085 /*--------------------------------------------------------------------*/
2087 /*--------------------------------------------------------------------*/
2088 if (value && (STRCASEEQ('t','T',"top", value) ||
2089 STRCASEEQ('m','M',"middle",value) ||
2090 STRCASEEQ('b','B',"bottom",value) ||
2091 STRCASEEQ('l','L',"left", value) ||
2092 STRCASEEQ('r','R',"right", value))) {
2098 else if (strcasecmp(name, "alt" ) == 0 && value && *value) {
2099 /*--------------------------------------------------------------------*/
2101 /*--------------------------------------------------------------------*/
2110 if (strcasecmp(name, "width" ) == 0 && value && *value) {
2111 /*--------------------------------------------------------------------*/
2113 /*--------------------------------------------------------------------*/
2122 if (strcasecmp(name, "height") == 0 && value && *value) {
2123 /*--------------------------------------------------------------------*/
2125 /*--------------------------------------------------------------------*/
2130 else if (strcasecmp(name, "hspace") == 0 && value && *value) {
2131 /*--------------------------------------------------------------------*/
2133 /*--------------------------------------------------------------------*/
2142 if (strcasecmp(name, "vspace") == 0 && value && *value) {
2143 /*--------------------------------------------------------------------*/
2145 /*--------------------------------------------------------------------*/
2157 return chtml20->out;
2162 * It is a handler who processes the IMG tag.
2164 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2165 * destination is specified.
2166 * @param node [i] The IMG tag node is specified.
2167 * @return The conversion result is returned.
2170 s_chtml20_end_img_tag(void *pdoc, Node *UNUSED(child))
2176 chtml20 = GET_CHTML20(pdoc);
2180 return chtml20->out;
2185 * It is a handler who processes the SELECT tag.
2187 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2188 * destination is specified.
2189 * @param node [i] The SELECT tag node is specified.
2190 * @return The conversion result is returned.
2193 s_chtml20_start_select_tag(void *pdoc, Node *child)
2200 chtml20 = GET_CHTML20(pdoc);
2206 char *multiple = NULL;
2209 for (attr = qs_get_attr(doc,child);
2211 attr = qs_get_next_attr(doc,attr)) {
2212 char *nm = qs_get_attr_name(doc,attr);
2213 char *val = qs_get_attr_value(doc,attr);
2217 if (strcasecmp(nm, "size") == 0) {
2218 /*--------------------------------------------------------------------*/
2219 /* CHTML 1.0 version 2.0 */
2220 /*--------------------------------------------------------------------*/
2221 size = apr_pstrdup(doc->buf.pool, val);
2227 if (strcasecmp(nm, "name") == 0) {
2228 /*--------------------------------------------------------------------*/
2229 /* CHTML 1.0 version 2.0 */
2230 /*--------------------------------------------------------------------*/
2231 name = apr_pstrdup(doc->buf.pool, val);
2237 if (strcasecmp(nm, "multiple") == 0) {
2238 /*--------------------------------------------------------------------*/
2239 /* CHTML 1.0 version 2.0 */
2240 /*--------------------------------------------------------------------*/
2241 multiple = apr_pstrdup(doc->buf.pool, val);
2249 if (size && *size) {
2254 if (name && *name) {
2263 return chtml20->out;
2268 * It is a handler who processes the SELECT tag.
2270 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2271 * destination is specified.
2272 * @param node [i] The SELECT tag node is specified.
2273 * @return The conversion result is returned.
2276 s_chtml20_end_select_tag(void *pdoc, Node *UNUSED(child))
2282 chtml20 = GET_CHTML20(pdoc);
2287 return chtml20->out;
2292 * It is a handler who processes the OPTION tag.
2294 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2295 * destination is specified.
2296 * @param node [i] The OPTION tag node is specified.
2297 * @return The conversion result is returned.
2300 s_chtml20_start_option_tag(void *pdoc, Node *child)
2307 chtml20 = GET_CHTML20(pdoc);
2311 char *selected = NULL;
2315 for (attr = qs_get_attr(doc,child);
2317 attr = qs_get_next_attr(doc,attr)) {
2322 nm = qs_get_attr_name(doc,attr);
2323 val = qs_get_attr_value(doc,attr);
2328 if (strcasecmp(nm, "selected") == 0) {
2329 /*--------------------------------------------------------------------*/
2330 /* CHTML 1.0 version 2.0 */
2331 /*--------------------------------------------------------------------*/
2332 selected = apr_pstrdup(doc->buf.pool, val);
2338 if (strcasecmp(nm, "value") == 0) {
2339 /*--------------------------------------------------------------------*/
2340 /* CHTML 1.0 version 2.0 */
2341 /*--------------------------------------------------------------------*/
2342 value = apr_pstrdup(doc->buf.pool, val);
2351 if (value && *value) {
2361 return chtml20->out;
2366 * It is a handler who processes the OPTION tag.
2368 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2369 * destination is specified.
2370 * @param node [i] The OPTION tag node is specified.
2371 * @return The conversion result is returned.
2374 s_chtml20_end_option_tag(void *pdoc, Node *UNUSED(child))
2380 chtml20 = GET_CHTML20(pdoc);
2386 return chtml20->out;
2391 * It is a handler who processes the DIV tag.
2393 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2394 * destination is specified.
2395 * @param node [i] The DIV tag node is specified.
2396 * @return The conversion result is returned.
2399 s_chtml20_start_div_tag(void *pdoc, Node *child)
2406 chtml20 = GET_CHTML20(pdoc);
2414 for (attr = qs_get_attr(doc,child);
2416 attr = qs_get_next_attr(doc,attr)) {
2418 char *nm = qs_get_attr_name(doc,attr);
2419 char *val = qs_get_attr_value(doc,attr);
2420 if (STRCASEEQ('a','A', "align", nm)) {
2421 /*----------------------------------------------------------------------*/
2422 /* CHTML 1.0 (W3C version 3.2) */
2423 /*----------------------------------------------------------------------*/
2424 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2425 align = apr_pstrdup(doc->buf.pool, val);
2437 return chtml20->out;
2442 * It is a handler who processes the DIV tag.
2444 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2445 * destination is specified.
2446 * @param node [i] The DIV tag node is specified.
2447 * @return The conversion result is returned.
2450 s_chtml20_end_div_tag(void *pdoc, Node *UNUSED(child))
2455 chtml20 = GET_CHTML20(pdoc);
2459 return chtml20->out;
2464 * It is a handler who processes the H1 tag.
2466 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2467 * destination is specified.
2468 * @param node [i] The H1 tag node is specified.
2469 * @return The conversion result is returned.
2472 s_chtml20_start_h1_tag(void *pdoc, Node *node)
2479 chtml20 = GET_CHTML20(pdoc);
2484 for (attr = qs_get_attr(doc,node);
2486 attr = qs_get_next_attr(doc,attr)) {
2487 char *name = qs_get_attr_name(doc,attr);
2488 char *value = qs_get_attr_value(doc,attr);
2489 if (STRCASEEQ('a','A',"align", name)) {
2490 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2499 return chtml20->out;
2504 * It is a handler who processes the H1 tag.
2506 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2507 * destination is specified.
2508 * @param node [i] The H1 tag node is specified.
2509 * @return The conversion result is returned.
2512 s_chtml20_end_h1_tag(void *pdoc, Node *UNUSED(child))
2517 chtml20 = GET_CHTML20(pdoc);
2521 return chtml20->out;
2526 * It is a handler who processes the H2 tag.
2528 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2529 * destination is specified.
2530 * @param node [i] The H2 tag node is specified.
2531 * @return The conversion result is returned.
2534 s_chtml20_start_h2_tag(void *pdoc, Node *node)
2541 chtml20 = GET_CHTML20(pdoc);
2546 for (attr = qs_get_attr(doc,node);
2548 attr = qs_get_next_attr(doc,attr)) {
2549 char *name = qs_get_attr_name(doc,attr);
2550 char *value = qs_get_attr_value(doc,attr);
2551 if (STRCASEEQ('a','A',"align", name)) {
2552 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2561 return chtml20->out;
2566 * It is a handler who processes the H2 tag.
2568 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2569 * destination is specified.
2570 * @param node [i] The H2 tag node is specified.
2571 * @return The conversion result is returned.
2574 s_chtml20_end_h2_tag(void *pdoc, Node *UNUSED(child))
2579 chtml20 = GET_CHTML20(pdoc);
2583 return chtml20->out;
2588 * It is a handler who processes the H3 tag.
2590 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2591 * destination is specified.
2592 * @param node [i] The H3 tag node is specified.
2593 * @return The conversion result is returned.
2596 s_chtml20_start_h3_tag(void *pdoc, Node *node)
2603 chtml20 = GET_CHTML20(pdoc);
2608 for (attr = qs_get_attr(doc,node);
2610 attr = qs_get_next_attr(doc,attr)) {
2611 char *name = qs_get_attr_name(doc,attr);
2612 char *value = qs_get_attr_value(doc,attr);
2613 if (STRCASEEQ('a','A',"align", name)) {
2614 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2623 return chtml20->out;
2628 * It is a handler who processes the H3 tag.
2630 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2631 * destination is specified.
2632 * @param node [i] The H3 tag node is specified.
2633 * @return The conversion result is returned.
2636 s_chtml20_end_h3_tag(void *pdoc, Node *UNUSED(child))
2641 chtml20 = GET_CHTML20(pdoc);
2645 return chtml20->out;
2650 * It is a handler who processes the H4 tag.
2652 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2653 * destination is specified.
2654 * @param node [i] The H4 tag node is specified.
2655 * @return The conversion result is returned.
2658 s_chtml20_start_h4_tag(void *pdoc, Node *node)
2665 chtml20 = GET_CHTML20(pdoc);
2670 for (attr = qs_get_attr(doc,node);
2672 attr = qs_get_next_attr(doc,attr)) {
2673 char *name = qs_get_attr_name(doc,attr);
2674 char *value = qs_get_attr_value(doc,attr);
2675 if (STRCASEEQ('a','A',"align", name)) {
2676 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2685 return chtml20->out;
2690 * It is a handler who processes the H4 tag.
2692 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2693 * destination is specified.
2694 * @param node [i] The H4 tag node is specified.
2695 * @return The conversion result is returned.
2698 s_chtml20_end_h4_tag(void *pdoc, Node *UNUSED(child))
2704 chtml20 = GET_CHTML20(pdoc);
2709 return chtml20->out;
2714 * It is a handler who processes the H5 tag.
2716 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2717 * destination is specified.
2718 * @param node [i] The H5 tag node is specified.
2719 * @return The conversion result is returned.
2722 s_chtml20_start_h5_tag(void *pdoc, Node *node)
2729 chtml20 = GET_CHTML20(pdoc);
2734 for (attr = qs_get_attr(doc,node);
2736 attr = qs_get_next_attr(doc,attr)) {
2737 char *name = qs_get_attr_name(doc,attr);
2738 char *value = qs_get_attr_value(doc,attr);
2739 if (STRCASEEQ('a','A',"align", name)) {
2740 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2749 return chtml20->out;
2754 * It is a handler who processes the H5 tag.
2756 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2757 * destination is specified.
2758 * @param node [i] The H5 tag node is specified.
2759 * @return The conversion result is returned.
2762 s_chtml20_end_h5_tag(void *pdoc, Node *UNUSED(child))
2767 chtml20 = GET_CHTML20(pdoc);
2771 return chtml20->out;
2776 * It is a handler who processes the H6 tag.
2778 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2779 * destination is specified.
2780 * @param node [i] The H6 tag node is specified.
2781 * @return The conversion result is returned.
2784 s_chtml20_start_h6_tag(void *pdoc, Node *node)
2791 chtml20 = GET_CHTML20(pdoc);
2796 for (attr = qs_get_attr(doc,node);
2798 attr = qs_get_next_attr(doc,attr)) {
2799 char *name = qs_get_attr_name(doc,attr);
2800 char *value = qs_get_attr_value(doc,attr);
2801 if (STRCASEEQ('a','A',"align", name)) {
2802 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value) || STRCASEEQ('c','C',"center",value))) {
2811 return chtml20->out;
2816 * It is a handler who processes the H6 tag.
2818 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2819 * destination is specified.
2820 * @param node [i] The H6 tag node is specified.
2821 * @return The conversion result is returned.
2824 s_chtml20_end_h6_tag(void *pdoc, Node *UNUSED(child))
2829 chtml20 = GET_CHTML20(pdoc);
2833 return chtml20->out;
2838 * It is a handler who processes the PRE tag.
2840 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2841 * destination is specified.
2842 * @param node [i] The PRE tag node is specified.
2843 * @return The conversion result is returned.
2846 s_chtml20_start_pre_tag(void *pdoc, Node *UNUSED(node))
2851 chtml20 = GET_CHTML20(pdoc);
2854 chtml20->pre_flag++;
2856 return chtml20->out;
2861 * It is a handler who processes the PRE tag.
2863 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2864 * destination is specified.
2865 * @param node [i] The PRE tag node is specified.
2866 * @return The conversion result is returned.
2869 s_chtml20_end_pre_tag(void *pdoc, Node *UNUSED(child))
2874 chtml20 = GET_CHTML20(pdoc);
2878 chtml20->pre_flag--;
2880 return chtml20->out;
2885 * It is a handler who processes the P tag.
2887 * @param pdoc [i/o] The pointer to the XHTML structure at the output
2888 * destination is specified.
2889 * @param node [i] The P tag node is specified.
2890 * @return The conversion result is returned.
2893 s_chtml20_start_p_tag(void *pdoc, Node *node)
2901 chtml20 = GET_CHTML20(pdoc);
2906 for (attr = qs_get_attr(doc,node);
2908 attr = qs_get_next_attr(doc,attr)) {
2909 char *nm = qs_get_attr_name(doc,attr);
2910 char *val = qs_get_attr_value(doc,attr);
2911 if (STRCASEEQ('a','A',"align", nm)) {
2912 /*----------------------------------------------------------------------*/
2913 /* CHTML 1.0 (W3C version 3.2) */
2914 /*----------------------------------------------------------------------*/
2915 if (val && (STRCASEEQ('l','L',"left",val) || STRCASEEQ('r','R',"right",val) || STRCASEEQ('c','C',"center",val))) {
2916 align = apr_pstrdup(doc->buf.pool, val);
2927 return chtml20->out;
2932 * It is a handler who processes the P tag.
2934 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2935 * destination is specified.
2936 * @param node [i] The P tag node is specified.
2937 * @return The conversion result is returned.
2940 s_chtml20_end_p_tag(void *pdoc, Node *UNUSED(child))
2946 chtml20 = GET_CHTML20(pdoc);
2951 return chtml20->out;
2956 s_chtml20_chxjif_tag(void *pdoc, Node *node)
2963 chtml20 = GET_CHTML20(pdoc);
2967 for (child = qs_get_child_node(doc, node);
2969 child = qs_get_next_node(doc, child)) {
2972 s_chtml20_chxjif_tag(pdoc, child);
2980 * It is a handler who processes the TEXTARE tag.
2982 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2983 * destination is specified.
2984 * @param node [i] The TEXTAREA tag node is specified.
2985 * @return The conversion result is returned.
2988 s_chtml20_start_textarea_tag(void *pdoc, Node *node)
2995 chtml20 = GET_CHTML20(pdoc);
2999 chtml20->textarea_flag++;
3001 for (attr = qs_get_attr(doc,node);
3003 attr = qs_get_next_attr(doc,attr)) {
3004 char *name = qs_get_attr_name(doc,attr);
3005 char *value = qs_get_attr_value(doc,attr);
3009 if (strcasecmp(name, "accesskey") == 0 && value && *value != 0) {
3010 W_L(" accesskey=\"");
3018 if (strcasecmp(name, "name") == 0 && value && *value != 0) {
3027 if (strcasecmp(name, "rows") == 0 && value && *value != 0) {
3036 if (strcasecmp(name, "cols") == 0 && value && *value != 0) {
3045 if (strcasecmp(name, "istyle") == 0 && value && (*value == '1' || *value == '2' || *value == '3' || *value == '4')) {
3057 return chtml20->out;
3062 * It is a handler who processes the TEXTAREA tag.
3064 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3065 * destination is specified.
3066 * @param node [i] The TEXTAREA tag node is specified.
3067 * @return The conversion result is returned.
3070 s_chtml20_end_textarea_tag(void *pdoc, Node *UNUSED(child))
3075 chtml20 = GET_CHTML20(pdoc);
3079 chtml20->textarea_flag--;
3081 return chtml20->out;
3086 s_chtml20_text_tag(void *pdoc, Node *child)
3098 chtml20 = GET_CHTML20(pdoc);
3102 textval = qs_get_node_value(doc,child);
3103 if (strlen(textval) == 0) {
3104 return chtml20->out;
3107 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3108 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3110 tdst = qs_alloc_zero_byte_string(r);
3111 memset(one_byte, 0, sizeof(one_byte));
3114 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3116 int rtn = s_chtml20_search_emoji(chtml20, &textval[ii], &out);
3118 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3122 if (is_sjis_kanji(textval[ii])) {
3123 one_byte[0] = textval[ii+0];
3124 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3125 one_byte[0] = textval[ii+1];
3126 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3130 if (chtml20->pre_flag) {
3131 one_byte[0] = textval[ii+0];
3132 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3135 if (chtml20->textarea_flag) {
3136 one_byte[0] = textval[ii+0];
3137 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3140 if (textval[ii] != '\r' && textval[ii] != '\n') {
3141 one_byte[0] = textval[ii+0];
3142 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3146 return chtml20->out;
3151 * It is a handler who processes the BLOCKQUOTE tag.
3153 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3154 * destination is specified.
3155 * @param node [i] The BLOCKQUOTE tag node is specified.
3156 * @return The conversion result is returned.
3159 s_chtml20_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3161 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3162 Doc *doc = chtml20->doc;
3163 W_L("<blockquote>");
3164 return chtml20->out;
3169 * It is a handler who processes the BLOCKQUOTE tag.
3171 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3172 * destination is specified.
3173 * @param node [i] The BLOCKQUOTE tag node is specified.
3174 * @return The conversion result is returned.
3177 s_chtml20_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3179 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3180 Doc *doc = chtml20->doc;
3181 W_L("</blockquote>");
3182 return chtml20->out;
3187 * It is a handler who processes the DIR tag.
3189 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3190 * destination is specified.
3191 * @param node [i] The DIR tag node is specified.
3192 * @return The conversion result is returned.
3195 s_chtml20_start_dir_tag(void *pdoc, Node *UNUSED(child))
3197 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3198 Doc *doc = chtml20->doc;
3200 return chtml20->out;
3205 * It is a handler who processes the DIR tag.
3207 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3208 * destination is specified.
3209 * @param node [i] The DIR tag node is specified.
3210 * @return The conversion result is returned.
3213 s_chtml20_end_dir_tag(void *pdoc, Node *UNUSED(child))
3215 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3216 Doc *doc = chtml20->doc;
3219 return chtml20->out;
3224 * It is a handler who processes the DL tag.
3226 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3227 * destination is specified.
3228 * @param node [i] The DL tag node is specified.
3229 * @return The conversion result is returned.
3232 s_chtml20_start_dl_tag(void *pdoc, Node *UNUSED(child))
3234 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3235 Doc *doc = chtml20->doc;
3237 return chtml20->out;
3242 * It is a handler who processes the DL tag.
3244 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3245 * destination is specified.
3246 * @param node [i] The DL tag node is specified.
3247 * @return The conversion result is returned.
3250 s_chtml20_end_dl_tag(void *pdoc, Node *UNUSED(child))
3252 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3253 Doc *doc = chtml20->doc;
3255 return chtml20->out;
3260 * It is a handter who processes the DT tag.
3262 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3263 * destination is specified.
3264 * @param node [i] The DT tag node is specified.
3265 * @return The conversion result is returned.
3268 s_chtml20_start_dt_tag(void *pdoc, Node *UNUSED(child))
3270 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3271 Doc *doc = chtml20->doc;
3273 return chtml20->out;
3278 * It is a handter who processes the DT tag.
3280 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3281 * destination is specified.
3282 * @param node [i] The DT tag node is specified.
3283 * @return The conversion result is returned.
3286 s_chtml20_end_dt_tag(void *pdoc, Node *UNUSED(child))
3288 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3290 return chtml20->out;
3295 * It is a handder who processes the DD tag.
3297 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3298 * destination is specified.
3299 * @param node [i] The DD tag node is specified.
3300 * @return The conversion result is returned.
3303 s_chtml20_start_dd_tag(void *pdoc, Node *UNUSED(child))
3305 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3306 Doc *doc = chtml20->doc;
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))
3323 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3325 return chtml20->out;
3330 * It is a hanmenuer who processes the MENU tag.
3332 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3333 * destination is specified.
3334 * @param node [i] The MENU tag node is specified.
3335 * @return The conversion result is returned.
3338 s_chtml20_start_menu_tag(void *pdoc, Node *UNUSED(child))
3342 chtml20 = GET_CHTML20(pdoc);
3345 return chtml20->out;
3350 * It is a hanmenuer who processes the MENU tag.
3352 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3353 * destination is specified.
3354 * @param node [i] The MENU tag node is specified.
3355 * @return The conversion result is returned.
3358 s_chtml20_end_menu_tag(void *pdoc, Node *UNUSED(child))
3360 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3361 Doc *doc = chtml20->doc;
3364 return chtml20->out;
3369 * It is a hanplaintexter who processes the PLAINTEXT tag.
3371 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3372 * destination is specified.
3373 * @param node [i] The PLAINTEXT tag node is specified.
3374 * @return The conversion result is returned.
3377 s_chtml20_start_plaintext_tag(void *pdoc, Node *node)
3382 chtml20 = GET_CHTML20(pdoc);
3386 s_chtml20_start_plaintext_tag_inner(pdoc,node);
3387 return chtml20->out;
3391 s_chtml20_start_plaintext_tag_inner(void *pdoc, Node *node)
3397 chtml20 = GET_CHTML20(pdoc);
3400 for (child = qs_get_child_node(doc, node);
3402 child = qs_get_next_node(doc, child)) {
3404 s_chtml20_start_plaintext_tag_inner(pdoc, child);
3406 return chtml20->out;
3411 * It is a hanplaintexter who processes the PLAINTEXT tag.
3413 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3414 * destination is specified.
3415 * @param node [i] The PLAINTEXT tag node is specified.
3416 * @return The conversion result is returned.
3419 s_chtml20_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3421 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3422 return chtml20->out;
3426 * It is a hanblinker who processes the BLINK tag.
3428 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3429 * destination is specified.
3430 * @param node [i] The BLINK tag node is specified.
3431 * @return The conversion result is returned.
3434 s_chtml20_start_blink_tag(void *pdoc, Node *UNUSED(child))
3436 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3437 Doc *doc = chtml20->doc;
3439 return chtml20->out;
3444 * It is a hanblinker who processes the BLINK tag.
3446 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3447 * destination is specified.
3448 * @param node [i] The BLINK tag node is specified.
3449 * @return The conversion result is returned.
3452 s_chtml20_end_blink_tag(void *pdoc, Node *UNUSED(child))
3454 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3455 Doc *doc = chtml20->doc;
3457 return chtml20->out;
3462 * It is a hanmarqueeer who processes the MARQUEE tag.
3464 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3465 * destination is specified.
3466 * @param node [i] The MARQUEE tag node is specified.
3467 * @return The conversion result is returned.
3470 s_chtml20_start_marquee_tag(void *pdoc, Node *node)
3472 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3473 Doc *doc = chtml20->doc;
3476 /*--------------------------------------------------------------------------*/
3477 /* Get Attributes */
3478 /*--------------------------------------------------------------------------*/
3479 for (attr = qs_get_attr(doc,node);
3481 attr = qs_get_next_attr(doc,attr)) {
3482 char *name = qs_get_attr_name(doc,attr);
3483 char *value = qs_get_attr_value(doc,attr);
3484 if (STRCASEEQ('d','D',"direction", name)) {
3485 if (value && (STRCASEEQ('l','L',"left",value) || STRCASEEQ('r','R',"right",value))) {
3486 W_L(" direction=\"");
3491 else if (STRCASEEQ('b','B',"behavior",name)) {
3492 if (value && (STRCASEEQ('s','S',"scroll",value) || STRCASEEQ('s','S',"slide",value) || STRCASEEQ('a','A',"alternate",value))) {
3493 W_L(" behavior=\"");
3498 else if (STRCASEEQ('l','L',"loop",name)) {
3499 if (value && *value) {
3507 return chtml20->out;
3512 * It is a hanmarqueeer who processes the MARQUEE tag.
3514 * @param pdoc [i/o] The pointer to the CHTML structure at the output
3515 * destination is specified.
3516 * @param node [i] The MARQUEE tag node is specified.
3517 * @return The conversion result is returned.
3520 s_chtml20_end_marquee_tag(void *pdoc, Node *UNUSED(child))
3522 chtml20_t *chtml20 = GET_CHTML20(pdoc);
3523 Doc *doc = chtml20->doc;
3525 return chtml20->out;