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_jhtml.h"
18 #include "chxj_hdml.h"
19 #include "chxj_dump.h"
20 #include "chxj_img_conv.h"
21 #include "chxj_qr_code.h"
22 #include "chxj_encoding.h"
23 #include "chxj_url_encode.h"
26 #define GET_JHTML(X) ((jhtml_t *)(X))
29 #define W_L(X) do { jhtml->out = BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, (X)); } while(0)
30 #define W_V(X) do { jhtml->out = (X) ? BUFFERED_WRITE_VALUE(jhtml->out, &doc->buf, (X)) \
31 : BUFFERED_WRITE_LITERAL(jhtml->out, &doc->buf, ""); } while(0)
33 static char *s_jhtml_start_html_tag (void *pdoc, Node *node);
34 static char *s_jhtml_end_html_tag (void *pdoc, Node *node);
35 static char *s_jhtml_start_meta_tag (void *pdoc, Node *node);
36 static char *s_jhtml_end_meta_tag (void *pdoc, Node *node);
37 static char *s_jhtml_start_head_tag (void *pdoc, Node *node);
38 static char *s_jhtml_end_head_tag (void *pdoc, Node *node);
39 static char *s_jhtml_start_title_tag (void *pdoc, Node *node);
40 static char *s_jhtml_end_title_tag (void *pdoc, Node *node);
41 static char *s_jhtml_start_base_tag (void *pdoc, Node *node);
42 static char *s_jhtml_end_base_tag (void *pdoc, Node *node);
43 static char *s_jhtml_start_body_tag (void *pdoc, Node *node);
44 static char *s_jhtml_end_body_tag (void *pdoc, Node *node);
45 static char *s_jhtml_start_a_tag (void *pdoc, Node *node);
46 static char *s_jhtml_end_a_tag (void *pdoc, Node *node);
47 static char *s_jhtml_start_pre_tag (void *pdoc, Node *node);
48 static char *s_jhtml_end_pre_tag (void *pdoc, Node *node);
49 static char *s_jhtml_start_p_tag (void *pdoc, Node *node);
50 static char *s_jhtml_end_p_tag (void *pdoc, Node *node);
51 static char *s_jhtml_start_ul_tag (void *pdoc, Node *node);
52 static char *s_jhtml_end_ul_tag (void *pdoc, Node *node);
53 static char *s_jhtml_start_ol_tag (void *pdoc, Node *node);
54 static char *s_jhtml_end_ol_tag (void *pdoc, Node *node);
55 static char *s_jhtml_start_li_tag (void *pdoc, Node *node);
56 static char *s_jhtml_end_li_tag (void *pdoc, Node *node);
57 static char *s_jhtml_start_br_tag (void *pdoc, Node *node);
58 static char *s_jhtml_end_br_tag (void *pdoc, Node *node);
59 static char *s_jhtml_start_tr_tag (void *pdoc, Node *node);
60 static char *s_jhtml_end_tr_tag (void *pdoc, Node *node);
61 static char *s_jhtml_start_font_tag (void *pdoc, Node *node);
62 static char *s_jhtml_end_font_tag (void *pdoc, Node *node);
63 static char *s_jhtml_start_form_tag (void *pdoc, Node *node);
64 static char *s_jhtml_end_form_tag (void *pdoc, Node *node);
65 static char *s_jhtml_start_input_tag (void *pdoc, Node *node);
66 static char *s_jhtml_end_input_tag (void *pdoc, Node *node);
67 static char *s_jhtml_start_center_tag (void *pdoc, Node *node);
68 static char *s_jhtml_end_center_tag (void *pdoc, Node *node);
69 static char *s_jhtml_start_hr_tag (void *pdoc, Node *node);
70 static char *s_jhtml_end_hr_tag (void *pdoc, Node *node);
71 static char *s_jhtml_start_img_tag (void *pdoc, Node *node);
72 static char *s_jhtml_end_img_tag (void *pdoc, Node *node);
73 static char *s_jhtml_start_select_tag (void *pdoc, Node *node);
74 static char *s_jhtml_end_select_tag (void *pdoc, Node *node);
75 static char *s_jhtml_start_option_tag (void *pdoc, Node *node);
76 static char *s_jhtml_end_option_tag (void *pdoc, Node *node);
77 static char *s_jhtml_start_div_tag (void *pdoc, Node *node);
78 static char *s_jhtml_end_div_tag (void *pdoc, Node *node);
79 static char *s_jhtml_start_textarea_tag (void *pdoc, Node *node);
80 static char *s_jhtml_end_textarea_tag (void *pdoc, Node *node);
81 static char *s_jhtml_start_b_tag (void *pdoc, Node *node);
82 static char *s_jhtml_end_b_tag (void *pdoc, Node *node);
83 static char *s_jhtml_chxjif_tag (void *pdoc, Node *node);
84 static char *s_jhtml_text_tag (void *pdoc, Node *node);
86 static void s_init_jhtml(jhtml_t *jhtml, Doc *doc, request_rec *r, device_table *spec);
88 static int s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt);
90 static char *chxj_istyle_to_mode(request_rec *r, const char *s);
94 tag_handler jhtml_handler[] = {
97 s_jhtml_start_html_tag,
102 s_jhtml_start_meta_tag,
103 s_jhtml_end_meta_tag,
107 s_jhtml_start_textarea_tag,
108 s_jhtml_end_textarea_tag,
117 s_jhtml_start_pre_tag,
122 s_jhtml_start_ul_tag,
127 s_jhtml_start_li_tag,
132 s_jhtml_start_ol_tag,
167 s_jhtml_start_head_tag,
168 s_jhtml_end_head_tag,
172 s_jhtml_start_title_tag,
173 s_jhtml_end_title_tag,
177 s_jhtml_start_base_tag,
178 s_jhtml_end_base_tag,
182 s_jhtml_start_body_tag,
183 s_jhtml_end_body_tag,
192 s_jhtml_start_br_tag,
202 s_jhtml_start_tr_tag,
217 s_jhtml_start_font_tag,
218 s_jhtml_end_font_tag,
222 s_jhtml_start_form_tag,
223 s_jhtml_end_form_tag,
227 s_jhtml_start_input_tag,
228 s_jhtml_end_input_tag,
232 s_jhtml_start_center_tag,
233 s_jhtml_end_center_tag,
237 s_jhtml_start_hr_tag,
242 s_jhtml_start_img_tag,
247 s_jhtml_start_select_tag,
248 s_jhtml_end_select_tag,
252 s_jhtml_start_option_tag,
253 s_jhtml_end_option_tag,
257 s_jhtml_start_div_tag,
364 * converts from CHTML5.0 to JHTML.
366 * @param r [i] Requet_rec is appointed.
367 * @param spec [i] The result of the device specification processing which
368 * was done in advance is appointed.
369 * @param src [i] The character string before the converting is appointed.
370 * @return The character string after the converting is returned.
379 chxjconvrule_entry *entryp,
390 /*--------------------------------------------------------------------------*/
392 /*--------------------------------------------------------------------------*/
394 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
396 DBG(r,"I found qrcode xml");
399 DBG(r,"not found qrcode xml");
401 /*--------------------------------------------------------------------------*/
402 /* The CHTML structure is initialized. */
403 /*--------------------------------------------------------------------------*/
404 s_init_jhtml(&jhtml, &doc, r, spec);
406 jhtml.entryp = entryp;
407 jhtml.cookie = cookie;
409 chxj_set_content_type(r, "text/html; charset=Windows-31J");
411 /*--------------------------------------------------------------------------*/
412 /* The character string of the input is analyzed. */
413 /*--------------------------------------------------------------------------*/
414 qs_init_malloc(&doc);
415 qs_init_root_node(&doc);
417 ss = apr_pcalloc(r->pool, srclen + 1);
419 memset(ss, 0, srclen + 1);
420 memcpy(ss, src, srclen);
423 chxj_dump_out("[src] CHTML -> JHTML", ss, srclen);
426 qs_parse_string(&doc,ss,strlen(ss));
428 chxj_buffered_write_init(r->pool, &doc.buf);
429 /*--------------------------------------------------------------------------*/
430 /* It converts it from CHTML to JHTML. */
431 /*--------------------------------------------------------------------------*/
432 chxj_node_exchange(spec,r,(void*)&jhtml, &doc, qs_get_root(&doc), 0);
433 jhtml.out = chxj_buffered_write_flush(jhtml.out, &doc.buf);
434 dst = apr_pstrdup(r->pool, jhtml.out);
435 chxj_buffered_write_terminate(&doc.buf);
438 qs_all_free(&doc,QX_LOGMARK);
441 return apr_pstrdup(r->pool,ss);
444 dst = apr_psprintf(r->pool, "\n");
446 *dstlen = strlen(dst);
449 chxj_dump_out("[dst] CHTML -> JHTML", dst, *dstlen);
457 * The CHTML structure is initialized.
459 * @param jhtml [i/o] The pointer to the JHTML structure that wants to be
460 * initialized is specified.
461 * @param doc [i] The Doc structure that should be set to the initialized
462 * JHTML structure is specified.
463 * @param r [i] To use POOL, the pointer to request_rec is specified.
464 * @param spec [i] The pointer to the device_table
467 s_init_jhtml(jhtml_t* jhtml, Doc* doc, request_rec* r, device_table* spec)
469 memset(doc, 0, sizeof(Doc));
470 memset(jhtml, 0, sizeof(jhtml_t));
475 jhtml->out = qs_alloc_zero_byte_string(r);
476 jhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
477 jhtml->doc->parse_mode = PARSE_MODE_CHTML;
482 * Corresponding EMOJI to a current character-code is retrieved.
483 * The substitution character string is stored in the rslt pointer if agreeing.
485 * @param jhtml [i] The pointer to the CHTML structure is specified.
486 * @param txt [i] The character string to want to examine whether it is
487 * EMOJI is specified.
488 * @param rslt [o] The pointer to the pointer that stores the result is
490 * @return When corresponding EMOJI exists, it returns it excluding 0.
493 s_jhtml_search_emoji(jhtml_t *jhtml, char *txt, char **rslt)
505 if (! spec) DBG(r,"spec is NULL");
507 for (ee = jhtml->conf->emoji;
511 unsigned char hex1byte;
512 unsigned char hex2byte;
515 DBG(r,"emoji->imode is NULL");
519 hex1byte = ee->imode->hex1byte & 0xff;
520 hex2byte = ee->imode->hex2byte & 0xff;
522 if (ee->imode->string
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_psprintf(r->pool,"
\e%s
\ f", ee->jphone->string);
527 return strlen(ee->imode->string);
534 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
535 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
536 if (spec == NULL || spec->emoji_type == NULL) {
537 *rslt = apr_psprintf(r->pool,"
\e%s
\ f", ee->jphone->string);
550 * It is a handler who processes the HTML tag.
552 * @param pdoc [i/o] The pointer to the CHTML structure at the output
553 * destination is specified.
554 * @param node [i] The HTML tag node is specified.
555 * @return The conversion result is returned.
558 s_jhtml_start_html_tag(void *pdoc, Node *UNUSED(node))
565 jhtml = GET_JHTML(pdoc);
568 DBG(r, "start s_jhtml_start_html_tag()");
570 /*--------------------------------------------------------------------------*/
572 /*--------------------------------------------------------------------------*/
575 DBG(r, "end s_jhtml_start_html_tag()");
582 * It is a handler who processes the HTML tag.
584 * @param pdoc [i/o] The pointer to the CHTML structure at the output
585 * destination is specified.
586 * @param node [i] The HTML tag node is specified.
587 * @return The conversion result is returned.
590 s_jhtml_end_html_tag(void *pdoc, Node *UNUSED(child))
592 jhtml_t *jhtml = GET_JHTML(pdoc);
593 Doc *doc = jhtml->doc;
602 * It is a handler who processes the META tag.
604 * @param pdoc [i/o] The pointer to the CHTML structure at the output
605 * destination is specified.
606 * @param node [i] The META tag node is specified.
607 * @return The conversion result is returned.
610 s_jhtml_start_meta_tag(void *pdoc, Node *node)
616 int content_type_flag;
619 jhtml = GET_JHTML(pdoc);
623 content_type_flag = 0;
626 /*--------------------------------------------------------------------------*/
628 /*--------------------------------------------------------------------------*/
629 for (attr = qs_get_attr(doc,node);
631 attr = qs_get_next_attr(doc,attr)) {
632 char *name = qs_get_attr_name(doc,attr);
633 char *value = qs_get_attr_value(doc,attr);
637 if (strcasecmp(name, "http-equiv") == 0) {
638 /*----------------------------------------------------------------------*/
640 /*----------------------------------------------------------------------*/
641 W_L(" http-equiv=\"");
644 if (STRCASEEQ('c','C',"content-type",value)) {
645 content_type_flag = 1;
647 if (STRCASEEQ('r','R',"refresh",value)) {
655 if (strcasecmp(name, "content") == 0) {
656 /*----------------------------------------------------------------------*/
658 /*----------------------------------------------------------------------*/
659 if (content_type_flag) {
663 W_L("text/html; charset=Windows-31J");
672 buf = apr_pstrdup(r->pool, value);
674 url = strchr(buf, ';');
676 sec = apr_pstrdup(r->pool, buf);
679 url = chxj_encoding_parameter(r, url);
680 url = chxj_add_cookie_parameter(r, url, jhtml->cookie);
710 * It is a handler who processes the META tag.
712 * @param pdoc [i/o] The pointer to the CHTML structure at the output
713 * destination is specified.
714 * @param node [i] The META tag node is specified.
715 * @return The conversion result is returned.
718 s_jhtml_end_meta_tag(void *pdoc, Node *UNUSED(child))
720 jhtml_t *jhtml = GET_JHTML(pdoc);
727 * It is a handler who processes the HEAD tag.
729 * @param pdoc [i/o] The pointer to the CHTML structure at the output
730 * destination is specified.
731 * @param node [i] The HEAD tag node is specified.
732 * @return The conversion result is returned.
735 s_jhtml_start_head_tag(void *pdoc, Node *UNUSED(node))
741 jhtml = GET_JHTML(pdoc);
751 * It is a handler who processes the HEAD tag.
753 * @param pdoc [i/o] The pointer to the CHTML structure at the output
754 * destination is specified.
755 * @param node [i] The HEAD tag node is specified.
756 * @return The conversion result is returned.
759 s_jhtml_end_head_tag(void *pdoc, Node *UNUSED(child))
765 jhtml = GET_JHTML(pdoc);
775 * It is a handler who processes the TITLE tag.
777 * @param pdoc [i/o] The pointer to the CHTML structure at the output
778 * destination is specified.
779 * @param node [i] The TITLE tag node is specified.
780 * @return The conversion result is returned.
783 s_jhtml_start_title_tag(void *pdoc, Node *UNUSED(node))
789 jhtml = GET_JHTML(pdoc);
799 * It is a handler who processes the TITLE tag.
801 * @param pdoc [i/o] The pointer to the CHTML structure at the output
802 * destination is specified.
803 * @param node [i] The TITLE tag node is specified.
804 * @return The conversion result is returned.
807 s_jhtml_end_title_tag(void *pdoc, Node *UNUSED(child))
813 jhtml = GET_JHTML(pdoc);
823 * It is a handler who processes the BASE tag.
825 * @param pdoc [i/o] The pointer to the CHTML structure at the output
826 * destination is specified.
827 * @param node [i] The BASE tag node is specified.
828 * @return The conversion result is returned.
831 s_jhtml_start_base_tag(void *pdoc, Node *node)
838 jhtml = GET_JHTML(pdoc);
843 /*--------------------------------------------------------------------------*/
845 /*--------------------------------------------------------------------------*/
846 for (attr = qs_get_attr(doc,node);
848 attr = qs_get_next_attr(doc,attr)) {
849 char *name = qs_get_attr_name(doc,attr);
850 char *value = qs_get_attr_value(doc,attr);
851 if (STRCASEEQ('h','H',"href",name)) {
863 * It is a handler who processes the BASE tag.
865 * @param pdoc [i/o] The pointer to the CHTML structure at the output
866 * destination is specified.
867 * @param node [i] The BASE tag node is specified.
868 * @return The conversion result is returned.
871 s_jhtml_end_base_tag(void *pdoc, Node *UNUSED(child))
873 jhtml_t *jhtml = GET_JHTML(pdoc);
879 * It is a handler who processes the BODY tag.
881 * @param pdoc [i/o] The pointer to the CHTML structure at the output
882 * destination is specified.
883 * @param node [i] The BODY tag node is specified.
884 * @return The conversion result is returned.
887 s_jhtml_start_body_tag(void *pdoc, Node *node)
894 jhtml = GET_JHTML(pdoc);
899 /*--------------------------------------------------------------------------*/
901 /*--------------------------------------------------------------------------*/
902 for (attr = qs_get_attr(doc,node);
904 attr = qs_get_next_attr(doc,attr)) {
905 char *name = qs_get_attr_name(doc,attr);
906 char *value = qs_get_attr_value(doc,attr);
907 if (STRCASEEQ('b','B',"bgcolor",name)) {
908 /*----------------------------------------------------------------------*/
910 /*----------------------------------------------------------------------*/
915 else if (STRCASEEQ('t','T',"text",name)) {
916 /*----------------------------------------------------------------------*/
918 /*----------------------------------------------------------------------*/
923 else if (STRCASEEQ('l','L',"link",name)) {
924 /*----------------------------------------------------------------------*/
926 /*----------------------------------------------------------------------*/
931 else if (STRCASEEQ('a','A',"alink",name)) {
932 /*----------------------------------------------------------------------*/
934 /*----------------------------------------------------------------------*/
937 else if (STRCASEEQ('v','V',"vlink",name)) {
938 /*----------------------------------------------------------------------*/
940 /*----------------------------------------------------------------------*/
950 * It is a handler who processes the BODY tag.
952 * @param pdoc [i/o] The pointer to the CHTML structure at the output
953 * destination is specified.
954 * @param node [i] The BODY tag node is specified.
955 * @return The conversion result is returned.
958 s_jhtml_end_body_tag(void *pdoc, Node *UNUSED(child))
964 jhtml = GET_JHTML(pdoc);
974 * It is a handler who processes the A tag.
976 * @param pdoc [i/o] The pointer to the CHTML structure at the output
977 * destination is specified.
978 * @param node [i] The A tag node is specified.
979 * @return The conversion result is returned.
982 s_jhtml_start_a_tag(void *pdoc, Node *node)
989 jhtml = GET_JHTML(pdoc);
994 /*--------------------------------------------------------------------------*/
996 /*--------------------------------------------------------------------------*/
997 for (attr = qs_get_attr(doc,node);
999 attr = qs_get_next_attr(doc,attr)) {
1000 char *name = qs_get_attr_name(doc,attr);
1001 char *value = qs_get_attr_value(doc,attr);
1002 if (STRCASEEQ('n','N',"name",name)) {
1003 /*----------------------------------------------------------------------*/
1005 /*----------------------------------------------------------------------*/
1010 else if (STRCASEEQ('h','H',"href",name)) {
1011 /*----------------------------------------------------------------------*/
1013 /*----------------------------------------------------------------------*/
1014 value = chxj_encoding_parameter(r, value);
1015 value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1020 else if (STRCASEEQ('a','A',"accesskey",name)) {
1021 /*----------------------------------------------------------------------*/
1023 /*----------------------------------------------------------------------*/
1024 W_L(" accesskey=\"");
1028 else if (STRCASEEQ('c','C',"cti",name)) {
1029 /*----------------------------------------------------------------------*/
1031 /*----------------------------------------------------------------------*/
1036 else if (STRCASEEQ('i','I',"ijam",name)) {
1037 /*----------------------------------------------------------------------*/
1039 /*----------------------------------------------------------------------*/
1042 else if (STRCASEEQ('u','U',"utn",name)) {
1043 /*----------------------------------------------------------------------*/
1045 /* It is special only for CHTML. */
1046 /*----------------------------------------------------------------------*/
1049 else if (STRCASEEQ('t','T',"telbook",name)) {
1050 /*----------------------------------------------------------------------*/
1052 /*----------------------------------------------------------------------*/
1055 else if (STRCASEEQ('k','K',"kana",name)) {
1056 /*----------------------------------------------------------------------*/
1058 /*----------------------------------------------------------------------*/
1061 else if (STRCASEEQ('e','E',"email",name)) {
1062 /*----------------------------------------------------------------------*/
1064 /*----------------------------------------------------------------------*/
1067 else if (STRCASEEQ('i','I',"ista",name)) {
1068 /*----------------------------------------------------------------------*/
1070 /*----------------------------------------------------------------------*/
1073 else if (STRCASEEQ('i','I',"ilet",name)) {
1074 /*----------------------------------------------------------------------*/
1076 /*----------------------------------------------------------------------*/
1079 else if (STRCASEEQ('i','I',"iswf",name)) {
1080 /*----------------------------------------------------------------------*/
1082 /*----------------------------------------------------------------------*/
1085 else if (STRCASEEQ('i','I',"irst",name)) {
1086 /*----------------------------------------------------------------------*/
1088 /*----------------------------------------------------------------------*/
1098 * It is a handler who processes the A tag.
1100 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1101 * destination is specified.
1102 * @param node [i] The A tag node is specified.
1103 * @return The conversion result is returned.
1106 s_jhtml_end_a_tag(void *pdoc, Node *UNUSED(child))
1112 jhtml = GET_JHTML(pdoc);
1122 * It is a handler who processes the BR tag.
1124 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1125 * destination is specified.
1126 * @param node [i] The BR tag node is specified.
1127 * @return The conversion result is returned.
1130 s_jhtml_start_br_tag(void *pdoc, Node *UNUSED(node))
1136 jhtml = GET_JHTML(pdoc);
1146 * It is a handler who processes the BR tag.
1148 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1149 * destination is specified.
1150 * @param node [i] The BR tag node is specified.
1151 * @return The conversion result is returned.
1154 s_jhtml_end_br_tag(void *pdoc, Node *UNUSED(child))
1156 jhtml_t *jhtml = GET_JHTML(pdoc);
1162 * It is a handler who processes the TR tag.
1164 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1165 * destination is specified.
1166 * @param node [i] The TR tag node is specified.
1167 * @return The conversion result is returned.
1170 s_jhtml_start_tr_tag(void* pdoc, Node* UNUSED(node))
1176 jhtml = GET_JHTML(pdoc);
1186 * It is a handler who processes the TR tag.
1188 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1189 * destination is specified.
1190 * @param node [i] The TR tag node is specified.
1191 * @return The conversion result is returned.
1194 s_jhtml_end_tr_tag(void* pdoc, Node* UNUSED(child))
1198 jhtml = GET_JHTML(pdoc);
1205 * It is a handler who processes the FONT tag.
1207 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1208 * destination is specified.
1209 * @param node [i] The FONT tag node is specified.
1210 * @return The conversion result is returned.
1213 s_jhtml_start_font_tag(void* pdoc, Node* node)
1220 jhtml = GET_JHTML(pdoc);
1225 /*--------------------------------------------------------------------------*/
1226 /* Get Attributes */
1227 /*--------------------------------------------------------------------------*/
1228 for (attr = qs_get_attr(doc,node);
1230 attr = qs_get_next_attr(doc,attr)) {
1235 name = qs_get_attr_name(doc,attr);
1236 value = qs_get_attr_value(doc,attr);
1238 if (STRCASEEQ('c','C',"color",name)) {
1243 else if (STRCASEEQ('s','S',"size",name)) {
1244 /*----------------------------------------------------------------------*/
1246 /*----------------------------------------------------------------------*/
1257 * It is a handler who processes the FONT tag.
1259 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1260 * destination is specified.
1261 * @param node [i] The FONT tag node is specified.
1262 * @return The conversion result is returned.
1265 s_jhtml_end_font_tag(void* pdoc, Node* UNUSED(child))
1271 jhtml = GET_JHTML(pdoc);
1281 * It is a handler who processes the FORM tag.
1283 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1284 * destination is specified.
1285 * @param node [i] The FORM tag node is specified.
1286 * @return The conversion result is returned.
1289 s_jhtml_start_form_tag(void* pdoc, Node* node)
1296 jhtml = GET_JHTML(pdoc);
1301 /*--------------------------------------------------------------------------*/
1302 /* Get Attributes */
1303 /*--------------------------------------------------------------------------*/
1304 for (attr = qs_get_attr(doc,node);
1306 attr = qs_get_next_attr(doc,attr)) {
1311 name = qs_get_attr_name(doc,attr);
1312 value = qs_get_attr_value(doc,attr);
1314 if (STRCASEEQ('a','A',"action",name)) {
1315 /*----------------------------------------------------------------------*/
1317 /*----------------------------------------------------------------------*/
1322 else if (STRCASEEQ('m','M',"method",name)) {
1323 /*----------------------------------------------------------------------*/
1325 /*----------------------------------------------------------------------*/
1330 else if (STRCASEEQ('u','U',"utn",name)) {
1331 /*----------------------------------------------------------------------*/
1333 /* It is special only for CHTML. */
1334 /*----------------------------------------------------------------------*/
1340 if (jhtml->cookie && jhtml->cookie->cookie_id) {
1341 char *vv = apr_psprintf(doc->buf.pool, "%s<input type='hidden' name='%s' value='%s'>",
1344 chxj_url_decode(r, jhtml->cookie->cookie_id));
1353 * It is a handler who processes the FORM tag.
1355 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1356 * destination is specified.
1357 * @param node [i] The FORM tag node is specified.
1358 * @return The conversion result is returned.
1361 s_jhtml_end_form_tag(void* pdoc, Node* UNUSED(child))
1363 jhtml_t* jhtml = GET_JHTML(pdoc);
1364 Doc* doc = jhtml->doc;
1372 * It is a handler who processes the INPUT tag.
1374 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1375 * destination is specified.
1376 * @param node [i] The INPUT tag node is specified.
1377 * @return The conversion result is returned.
1380 s_jhtml_start_input_tag(void* pdoc, Node* node)
1394 jhtml = GET_JHTML(pdoc);
1407 /*--------------------------------------------------------------------------*/
1408 /* Get Attributes */
1409 /*--------------------------------------------------------------------------*/
1410 type = qs_get_type_attr(doc, node, r);
1411 name = qs_get_name_attr(doc, node, r);
1412 value = qs_get_value_attr(doc,node,r);
1413 istyle = qs_get_istyle_attr(doc,node,r);
1414 max_length = qs_get_maxlength_attr(doc,node,r);
1415 checked = qs_get_checked_attr(doc,node,r);
1416 accesskey = qs_get_accesskey_attr(doc, node, r);
1417 size = qs_get_size_attr(doc, node, r);
1440 W_L(" accesskey=\"");
1445 /*------------------------------------------------------------------------*/
1447 /*------------------------------------------------------------------------*/
1448 if (STRCASEEQ('p','P',"password", type) && ! jhtml->entryp->pc_flag ) {
1454 char *vv = chxj_istyle_to_mode(r,istyle);
1460 else if (istyle == NULL && type != NULL && STRCASEEQ('p','P',"password",type)) {
1465 /*--------------------------------------------------------------------------*/
1466 /* The figure is default for the password. */
1467 /*--------------------------------------------------------------------------*/
1469 W_L(" maxlength=\"");
1483 * It is a handler who processes the INPUT tag.
1485 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1486 * destination is specified.
1487 * @param node [i] The INPUT tag node is specified.
1488 * @return The conversion result is returned.
1491 s_jhtml_end_input_tag(void* pdoc, Node* UNUSED(child))
1493 jhtml_t* jhtml = GET_JHTML(pdoc);
1500 * It is a handler who processes the CENTER tag.
1502 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1503 * destination is specified.
1504 * @param node [i] The CENTER tag node is specified.
1505 * @return The conversion result is returned.
1508 s_jhtml_start_center_tag(void* pdoc, Node* UNUSED(node))
1510 jhtml_t* jhtml = GET_JHTML(pdoc);
1511 Doc* doc = jhtml->doc;
1519 * It is a handler who processes the CENTER tag.
1521 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1522 * destination is specified.
1523 * @param node [i] The CENTER tag node is specified.
1524 * @return The conversion result is returned.
1527 s_jhtml_end_center_tag(void* pdoc, Node* UNUSED(child))
1533 jhtml = GET_JHTML(pdoc);
1543 * It is a handler who processes the li tag.
1545 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1546 * destination is specified.
1547 * @param node [i] The li tag node is specified.
1548 * @return The conversion result is returned.
1551 s_jhtml_start_li_tag(void* pdoc, Node* UNUSED(node))
1557 jhtml = GET_JHTML(pdoc);
1567 * It is a handler who processes the li tag.
1569 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1570 * destination is specified.
1571 * @param node [i] The li tag node is specified.
1572 * @return The conversion result is returned.
1575 s_jhtml_end_li_tag(void* pdoc, Node* UNUSED(child))
1581 jhtml = GET_JHTML(pdoc);
1591 * It is a handler who processes the OL tag.
1593 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1594 * destination is specified.
1595 * @param node [i] The OL tag node is specified.
1596 * @return The conversion result is returned.
1599 s_jhtml_start_ol_tag(void* pdoc, Node* UNUSED(node))
1605 jhtml = GET_JHTML(pdoc);
1615 * It is a handler who processes the OL tag.
1617 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1618 * destination is specified.
1619 * @param node [i] The OL tag node is specified.
1620 * @return The conversion result is returned.
1623 s_jhtml_end_ol_tag(void* pdoc, Node* UNUSED(child))
1629 jhtml = GET_JHTML(pdoc);
1639 * It is a handler who processes the P tag.
1641 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1642 * destination is specified.
1643 * @param node [i] The P tag node is specified.
1644 * @return The conversion result is returned.
1647 s_jhtml_start_p_tag(void* pdoc, Node* UNUSED(node))
1653 jhtml = GET_JHTML(pdoc);
1663 * It is a handler who processes the P tag.
1665 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1666 * destination is specified.
1667 * @param node [i] The P tag node is specified.
1668 * @return The conversion result is returned.
1671 s_jhtml_end_p_tag(void* pdoc, Node* UNUSED(child))
1673 jhtml_t* jhtml = GET_JHTML(pdoc);
1674 Doc* doc = jhtml->doc;
1682 * It is a handler who processes the PRE tag.
1684 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1685 * destination is specified.
1686 * @param node [i] The PRE tag node is specified.
1687 * @return The conversion result is returned.
1690 s_jhtml_start_pre_tag(void* pdoc, Node* UNUSED(node))
1692 jhtml_t* jhtml = GET_JHTML(pdoc);
1693 Doc* doc = jhtml->doc;
1702 * It is a handler who processes the PRE tag.
1704 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1705 * destination is specified.
1706 * @param node [i] The PRE tag node is specified.
1707 * @return The conversion result is returned.
1710 s_jhtml_end_pre_tag(void* pdoc, Node* UNUSED(child))
1712 jhtml_t* jhtml = GET_JHTML(pdoc);
1713 Doc* doc = jhtml->doc;
1723 * It is a handler who processes the UL tag.
1725 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1726 * destination is specified.
1727 * @param node [i] The UL tag node is specified.
1728 * @return The conversion result is returned.
1731 s_jhtml_start_ul_tag(void* pdoc, Node* UNUSED(node))
1733 jhtml_t* jhtml = GET_JHTML(pdoc);
1734 Doc* doc = jhtml->doc;
1742 * It is a handler who processes the UL tag.
1744 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1745 * destination is specified.
1746 * @param node [i] The UL tag node is specified.
1747 * @return The conversion result is returned.
1750 s_jhtml_end_ul_tag(void* pdoc, Node* UNUSED(child))
1752 jhtml_t* jhtml = GET_JHTML(pdoc);
1753 Doc* doc = jhtml->doc;
1761 * It is a handler who processes the HR tag.
1763 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1764 * destination is specified.
1765 * @param node [i] The HR tag node is specified.
1766 * @return The conversion result is returned.
1769 s_jhtml_start_hr_tag(void* pdoc, Node* node)
1771 jhtml_t* jhtml = GET_JHTML(pdoc);
1772 Doc* doc = jhtml->doc;
1776 for (attr = qs_get_attr(doc,node);
1778 attr = qs_get_next_attr(doc,attr)) {
1779 char* name = qs_get_attr_name(doc,attr);
1780 char* value = qs_get_attr_value(doc,attr);
1781 if (STRCASEEQ('a','A',"align",name)) {
1782 /*----------------------------------------------------------------------*/
1784 /*----------------------------------------------------------------------*/
1789 else if (STRCASEEQ('s','S',"size",name)) {
1790 /*----------------------------------------------------------------------*/
1792 /*----------------------------------------------------------------------*/
1797 else if (STRCASEEQ('w','W',"width",name)) {
1798 /*----------------------------------------------------------------------*/
1800 /*----------------------------------------------------------------------*/
1805 else if (STRCASEEQ('n','N',"noshade",name)) {
1806 /*----------------------------------------------------------------------*/
1808 /*----------------------------------------------------------------------*/
1811 else if (STRCASEEQ('c','C',"color",name)) {
1812 /*----------------------------------------------------------------------*/
1814 /*----------------------------------------------------------------------*/
1824 * It is a handler who processes the HR tag.
1826 * @param jhtml [i/o] The pointer to the CHTML structure at the output
1827 * destination is specified.
1828 * @param node [i] The HR tag node is specified.
1829 * @return The conversion result is returned.
1832 s_jhtml_end_hr_tag(void* pdoc, Node* UNUSED(child))
1834 jhtml_t* jhtml = GET_JHTML(pdoc);
1841 * It is a handler who processes the IMG tag.
1843 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1844 * destination is specified.
1845 * @param node [i] The IMG tag node is specified.
1846 * @return The conversion result is returned.
1849 s_jhtml_start_img_tag(void* pdoc, Node* node)
1851 jhtml_t* jhtml = GET_JHTML(pdoc);
1852 Doc* doc = jhtml->doc;
1853 request_rec* r = doc->r;
1855 #ifndef IMG_NOT_CONVERT_FILENAME
1856 device_table* spec = jhtml->spec;
1860 /*--------------------------------------------------------------------------*/
1861 /* Get Attributes */
1862 /*--------------------------------------------------------------------------*/
1863 for (attr = qs_get_attr(doc,node);
1865 attr = qs_get_next_attr(doc,attr)) {
1866 char* name = qs_get_attr_name(doc,attr);
1867 char* value = qs_get_attr_value(doc,attr);
1869 if (STRCASEEQ('s','S',"src",name)) {
1870 /*----------------------------------------------------------------------*/
1872 /*----------------------------------------------------------------------*/
1873 #ifdef IMG_NOT_CONVERT_FILENAME
1874 value = chxj_encoding_parameter(r, value);
1875 value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1877 value = apr_psprintf(r->pool,
1880 (strchr(value, '?')) ? '&' : '?',
1881 CHXJ_COOKIE_NOUPDATE_PARAM);
1887 value = chxj_img_conv(r, spec, value);
1888 value = chxj_encoding_parameter(r, value);
1889 value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1891 value = apr_psprintf(r->pool,
1894 (strchr(value, '?')) ? '&' : '?',
1895 CHXJ_COOKIE_NOUPDATE_PARAM);
1902 else if (STRCASEEQ('a','A',"align",name)) {
1903 /*----------------------------------------------------------------------*/
1905 /*----------------------------------------------------------------------*/
1910 else if (STRCASEEQ('w','W',"width",name)) {
1911 /*----------------------------------------------------------------------*/
1913 /*----------------------------------------------------------------------*/
1918 else if (STRCASEEQ('h','H',"height",name)) {
1919 /*----------------------------------------------------------------------*/
1921 /*----------------------------------------------------------------------*/
1926 else if (STRCASEEQ('h','H',"hspace",name)) {
1927 /*----------------------------------------------------------------------*/
1929 /*----------------------------------------------------------------------*/
1934 else if (STRCASEEQ('v','V',"vspace",name)) {
1935 /*----------------------------------------------------------------------*/
1937 /*----------------------------------------------------------------------*/
1942 else if (STRCASEEQ('a','A',"alt",name)) {
1943 /*----------------------------------------------------------------------*/
1945 /*----------------------------------------------------------------------*/
1950 else if (STRCASEEQ('a','A',"align",name)) {
1951 /*----------------------------------------------------------------------*/
1953 /*----------------------------------------------------------------------*/
1963 * It is a handler who processes the IMG tag.
1965 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1966 * destination is specified.
1967 * @param node [i] The IMG tag node is specified.
1968 * @return The conversion result is returned.
1971 s_jhtml_end_img_tag(void* pdoc, Node* UNUSED(child))
1973 jhtml_t* jhtml = GET_JHTML(pdoc);
1980 * It is a handler who processes the SELECT tag.
1982 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1983 * destination is specified.
1984 * @param node [i] The SELECT tag node is specified.
1985 * @return The conversion result is returned.
1988 s_jhtml_start_select_tag(void* pdoc, Node* child)
1990 jhtml_t* jhtml = GET_JHTML(pdoc);
1991 Doc* doc = jhtml->doc;
1998 for (attr = qs_get_attr(doc,child);
2000 attr = qs_get_next_attr(doc,attr)) {
2001 char* nm = qs_get_attr_name(doc,attr);
2002 char* val = qs_get_attr_value(doc,attr);
2004 if (STRCASEEQ('s','S',"size",nm)) {
2005 /*----------------------------------------------------------------------*/
2006 /* CHTML 1.0 version 2.0 */
2007 /*----------------------------------------------------------------------*/
2008 size = apr_pstrdup(doc->buf.pool, val);
2010 else if (STRCASEEQ('n','N',"name",nm)) {
2011 /*----------------------------------------------------------------------*/
2012 /* CHTML 1.0 version 2.0 */
2013 /*----------------------------------------------------------------------*/
2014 name = apr_pstrdup(doc->buf.pool, val);
2016 else if (STRCASEEQ('m','M',"multiple",nm)) {
2017 /*----------------------------------------------------------------------*/
2018 /* CHTML 1.0 version 2.0 */
2019 /*----------------------------------------------------------------------*/
2040 * It is a handler who processes the SELECT tag.
2042 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2043 * destination is specified.
2044 * @param node [i] The SELECT tag node is specified.
2045 * @return The conversion result is returned.
2048 s_jhtml_end_select_tag(void* pdoc, Node* UNUSED(child))
2050 jhtml_t* jhtml = GET_JHTML(pdoc);
2051 Doc* doc = jhtml->doc;
2058 * It is a handler who processes the OPTION tag.
2060 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2061 * destination is specified.
2062 * @param node [i] The OPTION tag node is specified.
2063 * @return The conversion result is returned.
2066 s_jhtml_start_option_tag(void* pdoc, Node* child)
2068 jhtml_t* jhtml = GET_JHTML(pdoc);
2069 Doc* doc = jhtml->doc;
2072 char* selected = NULL;
2076 for (attr = qs_get_attr(doc,child);
2078 attr = qs_get_next_attr(doc,attr)) {
2079 char* nm = qs_get_attr_name(doc,attr);
2080 char* val = qs_get_attr_value(doc,attr);
2082 if (STRCASEEQ('s','S',"selected",nm)) {
2083 /*----------------------------------------------------------------------*/
2084 /* CHTML 1.0 version 2.0 */
2085 /*----------------------------------------------------------------------*/
2086 selected = apr_pstrdup(doc->buf.pool, val);
2088 else if (STRCASEEQ('v','V',"value",nm)) {
2089 /*----------------------------------------------------------------------*/
2090 /* CHTML 1.0 version 2.0 */
2091 /*----------------------------------------------------------------------*/
2092 value = apr_pstrdup(doc->buf.pool, val);
2114 * It is a handler who processes the OPTION tag.
2116 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2117 * destination is specified.
2118 * @param node [i] The OPTION tag node is specified.
2119 * @return The conversion result is returned.
2122 s_jhtml_end_option_tag(void* pdoc, Node* UNUSED(child))
2126 jhtml = GET_JHTML(pdoc);
2135 * It is a handler who processes the DIV tag.
2137 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2138 * destination is specified.
2139 * @param node [i] The DIV tag node is specified.
2140 * @return The conversion result is returned.
2143 s_jhtml_start_div_tag(void* pdoc, Node* child)
2152 jhtml = GET_JHTML(pdoc);
2159 for (attr = qs_get_attr(doc,child);
2161 attr = qs_get_next_attr(doc,attr)) {
2166 nm = qs_get_attr_name(doc,attr);
2167 val = qs_get_attr_value(doc,attr);
2169 if (STRCASEEQ('a','A',"align",nm)) {
2170 /*----------------------------------------------------------------------*/
2171 /* CHTML 1.0 (W3C version 3.2) */
2172 /*----------------------------------------------------------------------*/
2173 align = apr_pstrdup(doc->buf.pool, val);
2188 * It is a handler who processes the DIV tag.
2190 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2191 * destination is specified.
2192 * @param node [i] The DIV tag node is specified.
2193 * @return The conversion result is returned.
2196 s_jhtml_end_div_tag(void* pdoc, Node* UNUSED(child))
2202 jhtml = GET_JHTML(pdoc);
2212 chxj_istyle_to_mode(request_rec* r, const char* s)
2218 case '1': return apr_psprintf(r->pool, "hiragana");
2219 case '2': return apr_psprintf(r->pool, "hankakukana");
2220 case '3': return apr_psprintf(r->pool, "alphabet");
2221 case '4': return apr_psprintf(r->pool, "numeric");
2223 tmp = apr_palloc(r->pool, 1);
2225 return apr_pstrdup(r->pool, tmp);
2229 tmp = apr_palloc(r->pool, 1);
2231 return apr_pstrdup(r->pool,tmp);
2236 s_jhtml_chxjif_tag(void* pdoc, Node* node)
2243 jhtml = GET_JHTML(pdoc);
2247 for (child = qs_get_child_node(doc, node);
2249 child = qs_get_next_node(doc, child)) {
2251 s_jhtml_chxjif_tag(jhtml, child);
2258 * It is a handler who processes the TEXTARE tag.
2260 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2261 * destination is specified.
2262 * @param node [i] The TEXTAREA tag node is specified.
2263 * @return The conversion result is returned.
2266 s_jhtml_start_textarea_tag(void* pdoc, Node* node)
2273 jhtml = GET_JHTML(pdoc);
2277 jhtml->textarea_flag++;
2279 for (attr = qs_get_attr(doc,node);
2281 attr = qs_get_next_attr(doc,attr)) {
2286 name = qs_get_attr_name(doc,attr);
2287 value = qs_get_attr_value(doc,attr);
2289 if (STRCASEEQ('n','N',"name",name)) {
2294 else if (STRCASEEQ('r','R',"rows",name)) {
2299 else if (STRCASEEQ('c','C',"cols",name)) {
2311 * It is a handler who processes the TEXTAREA tag.
2313 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2314 * destination is specified.
2315 * @param node [i] The TEXTAREA tag node is specified.
2316 * @return The conversion result is returned.
2319 s_jhtml_end_textarea_tag(void* pdoc, Node* UNUSED(child))
2325 jhtml = GET_JHTML(pdoc);
2329 W_L("</textarea>\r\n");
2330 jhtml->textarea_flag--;
2337 * It is a handler who processes the B tag.
2339 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2340 * destination is specified.
2341 * @param node [i] The B tag node is specified.
2342 * @return The conversion result is returned.
2345 s_jhtml_start_b_tag(void* pdoc, Node* UNUSED(node))
2351 jhtml = GET_JHTML(pdoc);
2361 * It is a handler who processes the B tag.
2363 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2364 * destination is specified.
2365 * @param node [i] The B tag node is specified.
2366 * @return The conversion result is returned.
2369 s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child))
2371 jhtml_t* jhtml = GET_JHTML(pdoc);
2372 Doc* doc = jhtml->doc;
2379 s_jhtml_text_tag(void* pdoc, Node* child)
2391 jhtml = GET_JHTML(pdoc);
2395 textval = qs_get_node_value(doc,child);
2396 textval = qs_trim_string(doc->buf.pool, textval);
2397 if (strlen(textval) == 0)
2400 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2401 memset(tmp, 0, qs_get_node_size(doc,child)+1);
2403 tdst = qs_alloc_zero_byte_string(r);
2404 memset(one_byte, 0, sizeof(one_byte));
2407 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2409 int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
2411 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2416 if (is_sjis_kanji(textval[ii])) {
2417 one_byte[0] = textval[ii+0];
2418 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2419 one_byte[0] = textval[ii+1];
2420 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2424 if (jhtml->pre_flag) {
2425 one_byte[0] = textval[ii+0];
2426 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2429 if (jhtml->textarea_flag) {
2430 one_byte[0] = textval[ii+0];
2431 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2434 if (textval[ii] != '\r' && textval[ii] != '\n') {
2435 one_byte[0] = textval[ii+0];
2436 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);