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))
1196 jhtml_t *jhtml = GET_JHTML(pdoc);
1202 * It is a handler who processes the FONT tag.
1204 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1205 * destination is specified.
1206 * @param node [i] The FONT tag node is specified.
1207 * @return The conversion result is returned.
1210 s_jhtml_start_font_tag(void* pdoc, Node* node)
1217 jhtml = GET_JHTML(pdoc);
1222 /*--------------------------------------------------------------------------*/
1223 /* Get Attributes */
1224 /*--------------------------------------------------------------------------*/
1225 for (attr = qs_get_attr(doc,node);
1227 attr = qs_get_next_attr(doc,attr)) {
1232 name = qs_get_attr_name(doc,attr);
1233 value = qs_get_attr_value(doc,attr);
1235 if (STRCASEEQ('c','C',"color",name)) {
1240 else if (STRCASEEQ('s','S',"size",name)) {
1241 /*----------------------------------------------------------------------*/
1243 /*----------------------------------------------------------------------*/
1254 * It is a handler who processes the FONT tag.
1256 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1257 * destination is specified.
1258 * @param node [i] The FONT tag node is specified.
1259 * @return The conversion result is returned.
1262 s_jhtml_end_font_tag(void* pdoc, Node* UNUSED(child))
1268 jhtml = GET_JHTML(pdoc);
1278 * It is a handler who processes the FORM tag.
1280 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1281 * destination is specified.
1282 * @param node [i] The FORM tag node is specified.
1283 * @return The conversion result is returned.
1286 s_jhtml_start_form_tag(void* pdoc, Node* node)
1293 jhtml = GET_JHTML(pdoc);
1298 /*--------------------------------------------------------------------------*/
1299 /* Get Attributes */
1300 /*--------------------------------------------------------------------------*/
1301 for (attr = qs_get_attr(doc,node);
1303 attr = qs_get_next_attr(doc,attr)) {
1308 name = qs_get_attr_name(doc,attr);
1309 value = qs_get_attr_value(doc,attr);
1311 if (STRCASEEQ('a','A',"action",name)) {
1312 /*----------------------------------------------------------------------*/
1314 /*----------------------------------------------------------------------*/
1319 else if (STRCASEEQ('m','M',"method",name)) {
1320 /*----------------------------------------------------------------------*/
1322 /*----------------------------------------------------------------------*/
1327 else if (STRCASEEQ('u','U',"utn",name)) {
1328 /*----------------------------------------------------------------------*/
1330 /* It is special only for CHTML. */
1331 /*----------------------------------------------------------------------*/
1337 if (jhtml->cookie && jhtml->cookie->cookie_id) {
1338 char *vv = apr_psprintf(doc->buf.pool, "%s<input type='hidden' name='%s' value='%s'>",
1341 chxj_url_decode(r, jhtml->cookie->cookie_id));
1350 * It is a handler who processes the FORM tag.
1352 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1353 * destination is specified.
1354 * @param node [i] The FORM tag node is specified.
1355 * @return The conversion result is returned.
1358 s_jhtml_end_form_tag(void* pdoc, Node* UNUSED(child))
1360 jhtml_t* jhtml = GET_JHTML(pdoc);
1361 Doc* doc = jhtml->doc;
1369 * It is a handler who processes the INPUT tag.
1371 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1372 * destination is specified.
1373 * @param node [i] The INPUT tag node is specified.
1374 * @return The conversion result is returned.
1377 s_jhtml_start_input_tag(void* pdoc, Node* node)
1391 jhtml = GET_JHTML(pdoc);
1404 /*--------------------------------------------------------------------------*/
1405 /* Get Attributes */
1406 /*--------------------------------------------------------------------------*/
1407 type = qs_get_type_attr(doc, node, r);
1408 name = qs_get_name_attr(doc, node, r);
1409 value = qs_get_value_attr(doc,node,r);
1410 istyle = qs_get_istyle_attr(doc,node,r);
1411 max_length = qs_get_maxlength_attr(doc,node,r);
1412 checked = qs_get_checked_attr(doc,node,r);
1413 accesskey = qs_get_accesskey_attr(doc, node, r);
1414 size = qs_get_size_attr(doc, node, r);
1437 W_L(" accesskey=\"");
1442 /*------------------------------------------------------------------------*/
1444 /*------------------------------------------------------------------------*/
1445 if (STRCASEEQ('p','P',"password", type) && ! jhtml->entryp->pc_flag ) {
1451 char *vv = chxj_istyle_to_mode(r,istyle);
1457 else if (istyle == NULL && type != NULL && STRCASEEQ('p','P',"password",type)) {
1462 /*--------------------------------------------------------------------------*/
1463 /* The figure is default for the password. */
1464 /*--------------------------------------------------------------------------*/
1466 W_L(" maxlength=\"");
1480 * It is a handler who processes the INPUT tag.
1482 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1483 * destination is specified.
1484 * @param node [i] The INPUT tag node is specified.
1485 * @return The conversion result is returned.
1488 s_jhtml_end_input_tag(void* pdoc, Node* UNUSED(child))
1490 jhtml_t* jhtml = GET_JHTML(pdoc);
1497 * It is a handler who processes the CENTER tag.
1499 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1500 * destination is specified.
1501 * @param node [i] The CENTER tag node is specified.
1502 * @return The conversion result is returned.
1505 s_jhtml_start_center_tag(void* pdoc, Node* UNUSED(node))
1507 jhtml_t* jhtml = GET_JHTML(pdoc);
1508 Doc* doc = jhtml->doc;
1516 * It is a handler who processes the CENTER tag.
1518 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1519 * destination is specified.
1520 * @param node [i] The CENTER tag node is specified.
1521 * @return The conversion result is returned.
1524 s_jhtml_end_center_tag(void* pdoc, Node* UNUSED(child))
1530 jhtml = GET_JHTML(pdoc);
1540 * It is a handler who processes the li tag.
1542 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1543 * destination is specified.
1544 * @param node [i] The li tag node is specified.
1545 * @return The conversion result is returned.
1548 s_jhtml_start_li_tag(void* pdoc, Node* UNUSED(node))
1554 jhtml = GET_JHTML(pdoc);
1564 * It is a handler who processes the li tag.
1566 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1567 * destination is specified.
1568 * @param node [i] The li tag node is specified.
1569 * @return The conversion result is returned.
1572 s_jhtml_end_li_tag(void* pdoc, Node* UNUSED(child))
1578 jhtml = GET_JHTML(pdoc);
1588 * It is a handler who processes the OL tag.
1590 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1591 * destination is specified.
1592 * @param node [i] The OL tag node is specified.
1593 * @return The conversion result is returned.
1596 s_jhtml_start_ol_tag(void* pdoc, Node* UNUSED(node))
1602 jhtml = GET_JHTML(pdoc);
1612 * It is a handler who processes the OL tag.
1614 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1615 * destination is specified.
1616 * @param node [i] The OL tag node is specified.
1617 * @return The conversion result is returned.
1620 s_jhtml_end_ol_tag(void* pdoc, Node* UNUSED(child))
1626 jhtml = GET_JHTML(pdoc);
1636 * It is a handler who processes the P tag.
1638 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1639 * destination is specified.
1640 * @param node [i] The P tag node is specified.
1641 * @return The conversion result is returned.
1644 s_jhtml_start_p_tag(void* pdoc, Node* UNUSED(node))
1650 jhtml = GET_JHTML(pdoc);
1660 * It is a handler who processes the P tag.
1662 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1663 * destination is specified.
1664 * @param node [i] The P tag node is specified.
1665 * @return The conversion result is returned.
1668 s_jhtml_end_p_tag(void* pdoc, Node* UNUSED(child))
1670 jhtml_t* jhtml = GET_JHTML(pdoc);
1671 Doc* doc = jhtml->doc;
1679 * It is a handler who processes the PRE tag.
1681 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1682 * destination is specified.
1683 * @param node [i] The PRE tag node is specified.
1684 * @return The conversion result is returned.
1687 s_jhtml_start_pre_tag(void* pdoc, Node* UNUSED(node))
1689 jhtml_t* jhtml = GET_JHTML(pdoc);
1690 Doc* doc = jhtml->doc;
1699 * It is a handler who processes the PRE tag.
1701 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1702 * destination is specified.
1703 * @param node [i] The PRE tag node is specified.
1704 * @return The conversion result is returned.
1707 s_jhtml_end_pre_tag(void* pdoc, Node* UNUSED(child))
1709 jhtml_t* jhtml = GET_JHTML(pdoc);
1710 Doc* doc = jhtml->doc;
1720 * It is a handler who processes the UL tag.
1722 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1723 * destination is specified.
1724 * @param node [i] The UL tag node is specified.
1725 * @return The conversion result is returned.
1728 s_jhtml_start_ul_tag(void* pdoc, Node* UNUSED(node))
1730 jhtml_t* jhtml = GET_JHTML(pdoc);
1731 Doc* doc = jhtml->doc;
1739 * It is a handler who processes the UL tag.
1741 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1742 * destination is specified.
1743 * @param node [i] The UL tag node is specified.
1744 * @return The conversion result is returned.
1747 s_jhtml_end_ul_tag(void* pdoc, Node* UNUSED(child))
1749 jhtml_t* jhtml = GET_JHTML(pdoc);
1750 Doc* doc = jhtml->doc;
1758 * It is a handler who processes the HR tag.
1760 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1761 * destination is specified.
1762 * @param node [i] The HR tag node is specified.
1763 * @return The conversion result is returned.
1766 s_jhtml_start_hr_tag(void* pdoc, Node* node)
1768 jhtml_t* jhtml = GET_JHTML(pdoc);
1769 Doc* doc = jhtml->doc;
1773 for (attr = qs_get_attr(doc,node);
1775 attr = qs_get_next_attr(doc,attr)) {
1776 char* name = qs_get_attr_name(doc,attr);
1777 char* value = qs_get_attr_value(doc,attr);
1778 if (STRCASEEQ('a','A',"align",name)) {
1779 /*----------------------------------------------------------------------*/
1781 /*----------------------------------------------------------------------*/
1786 else if (STRCASEEQ('s','S',"size",name)) {
1787 /*----------------------------------------------------------------------*/
1789 /*----------------------------------------------------------------------*/
1794 else if (STRCASEEQ('w','W',"width",name)) {
1795 /*----------------------------------------------------------------------*/
1797 /*----------------------------------------------------------------------*/
1802 else if (STRCASEEQ('n','N',"noshade",name)) {
1803 /*----------------------------------------------------------------------*/
1805 /*----------------------------------------------------------------------*/
1808 else if (STRCASEEQ('c','C',"color",name)) {
1809 /*----------------------------------------------------------------------*/
1811 /*----------------------------------------------------------------------*/
1821 * It is a handler who processes the HR tag.
1823 * @param jhtml [i/o] The pointer to the CHTML structure at the output
1824 * destination is specified.
1825 * @param node [i] The HR tag node is specified.
1826 * @return The conversion result is returned.
1829 s_jhtml_end_hr_tag(void* pdoc, Node* UNUSED(child))
1831 jhtml_t* jhtml = GET_JHTML(pdoc);
1838 * It is a handler who processes the IMG tag.
1840 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1841 * destination is specified.
1842 * @param node [i] The IMG tag node is specified.
1843 * @return The conversion result is returned.
1846 s_jhtml_start_img_tag(void* pdoc, Node* node)
1848 jhtml_t* jhtml = GET_JHTML(pdoc);
1849 Doc* doc = jhtml->doc;
1850 request_rec* r = doc->r;
1852 #ifndef IMG_NOT_CONVERT_FILENAME
1853 device_table* spec = jhtml->spec;
1857 /*--------------------------------------------------------------------------*/
1858 /* Get Attributes */
1859 /*--------------------------------------------------------------------------*/
1860 for (attr = qs_get_attr(doc,node);
1862 attr = qs_get_next_attr(doc,attr)) {
1863 char* name = qs_get_attr_name(doc,attr);
1864 char* value = qs_get_attr_value(doc,attr);
1866 if (STRCASEEQ('s','S',"src",name)) {
1867 /*----------------------------------------------------------------------*/
1869 /*----------------------------------------------------------------------*/
1870 #ifdef IMG_NOT_CONVERT_FILENAME
1871 value = chxj_encoding_parameter(r, value);
1872 value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1874 value = apr_psprintf(r->pool,
1877 (strchr(value, '?')) ? '&' : '?',
1878 CHXJ_COOKIE_NOUPDATE_PARAM);
1884 value = chxj_img_conv(r, spec, value);
1885 value = chxj_encoding_parameter(r, value);
1886 value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
1888 value = apr_psprintf(r->pool,
1891 (strchr(value, '?')) ? '&' : '?',
1892 CHXJ_COOKIE_NOUPDATE_PARAM);
1899 else if (STRCASEEQ('a','A',"align",name)) {
1900 /*----------------------------------------------------------------------*/
1902 /*----------------------------------------------------------------------*/
1907 else if (STRCASEEQ('w','W',"width",name)) {
1908 /*----------------------------------------------------------------------*/
1910 /*----------------------------------------------------------------------*/
1915 else if (STRCASEEQ('h','H',"height",name)) {
1916 /*----------------------------------------------------------------------*/
1918 /*----------------------------------------------------------------------*/
1923 else if (STRCASEEQ('h','H',"hspace",name)) {
1924 /*----------------------------------------------------------------------*/
1926 /*----------------------------------------------------------------------*/
1931 else if (STRCASEEQ('v','V',"vspace",name)) {
1932 /*----------------------------------------------------------------------*/
1934 /*----------------------------------------------------------------------*/
1939 else if (STRCASEEQ('a','A',"alt",name)) {
1940 /*----------------------------------------------------------------------*/
1942 /*----------------------------------------------------------------------*/
1947 else if (STRCASEEQ('a','A',"align",name)) {
1948 /*----------------------------------------------------------------------*/
1950 /*----------------------------------------------------------------------*/
1960 * It is a handler who processes the IMG tag.
1962 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1963 * destination is specified.
1964 * @param node [i] The IMG tag node is specified.
1965 * @return The conversion result is returned.
1968 s_jhtml_end_img_tag(void* pdoc, Node* UNUSED(child))
1970 jhtml_t* jhtml = GET_JHTML(pdoc);
1977 * It is a handler who processes the SELECT tag.
1979 * @param pdoc [i/o] The pointer to the CHTML structure at the output
1980 * destination is specified.
1981 * @param node [i] The SELECT tag node is specified.
1982 * @return The conversion result is returned.
1985 s_jhtml_start_select_tag(void* pdoc, Node* child)
1987 jhtml_t* jhtml = GET_JHTML(pdoc);
1988 Doc* doc = jhtml->doc;
1995 for (attr = qs_get_attr(doc,child);
1997 attr = qs_get_next_attr(doc,attr)) {
1998 char* nm = qs_get_attr_name(doc,attr);
1999 char* val = qs_get_attr_value(doc,attr);
2001 if (STRCASEEQ('s','S',"size",nm)) {
2002 /*----------------------------------------------------------------------*/
2003 /* CHTML 1.0 version 2.0 */
2004 /*----------------------------------------------------------------------*/
2005 size = apr_pstrdup(doc->buf.pool, val);
2007 else if (STRCASEEQ('n','N',"name",nm)) {
2008 /*----------------------------------------------------------------------*/
2009 /* CHTML 1.0 version 2.0 */
2010 /*----------------------------------------------------------------------*/
2011 name = apr_pstrdup(doc->buf.pool, val);
2013 else if (STRCASEEQ('m','M',"multiple",nm)) {
2014 /*----------------------------------------------------------------------*/
2015 /* CHTML 1.0 version 2.0 */
2016 /*----------------------------------------------------------------------*/
2037 * It is a handler who processes the SELECT tag.
2039 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2040 * destination is specified.
2041 * @param node [i] The SELECT tag node is specified.
2042 * @return The conversion result is returned.
2045 s_jhtml_end_select_tag(void* pdoc, Node* UNUSED(child))
2047 jhtml_t* jhtml = GET_JHTML(pdoc);
2048 Doc* doc = jhtml->doc;
2055 * It is a handler who processes the OPTION tag.
2057 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2058 * destination is specified.
2059 * @param node [i] The OPTION tag node is specified.
2060 * @return The conversion result is returned.
2063 s_jhtml_start_option_tag(void* pdoc, Node* child)
2065 jhtml_t* jhtml = GET_JHTML(pdoc);
2066 Doc* doc = jhtml->doc;
2069 char* selected = NULL;
2073 for (attr = qs_get_attr(doc,child);
2075 attr = qs_get_next_attr(doc,attr)) {
2076 char* nm = qs_get_attr_name(doc,attr);
2077 char* val = qs_get_attr_value(doc,attr);
2079 if (STRCASEEQ('s','S',"selected",nm)) {
2080 /*----------------------------------------------------------------------*/
2081 /* CHTML 1.0 version 2.0 */
2082 /*----------------------------------------------------------------------*/
2083 selected = apr_pstrdup(doc->buf.pool, val);
2085 else if (STRCASEEQ('v','V',"value",nm)) {
2086 /*----------------------------------------------------------------------*/
2087 /* CHTML 1.0 version 2.0 */
2088 /*----------------------------------------------------------------------*/
2089 value = apr_pstrdup(doc->buf.pool, val);
2111 * It is a handler who processes the OPTION tag.
2113 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2114 * destination is specified.
2115 * @param node [i] The OPTION tag node is specified.
2116 * @return The conversion result is returned.
2119 s_jhtml_end_option_tag(void* pdoc, Node* UNUSED(child))
2123 jhtml = GET_JHTML(pdoc);
2132 * It is a handler who processes the DIV tag.
2134 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2135 * destination is specified.
2136 * @param node [i] The DIV tag node is specified.
2137 * @return The conversion result is returned.
2140 s_jhtml_start_div_tag(void* pdoc, Node* child)
2149 jhtml = GET_JHTML(pdoc);
2156 for (attr = qs_get_attr(doc,child);
2158 attr = qs_get_next_attr(doc,attr)) {
2163 nm = qs_get_attr_name(doc,attr);
2164 val = qs_get_attr_value(doc,attr);
2166 if (STRCASEEQ('a','A',"align",nm)) {
2167 /*----------------------------------------------------------------------*/
2168 /* CHTML 1.0 (W3C version 3.2) */
2169 /*----------------------------------------------------------------------*/
2170 align = apr_pstrdup(doc->buf.pool, val);
2185 * It is a handler who processes the DIV tag.
2187 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2188 * destination is specified.
2189 * @param node [i] The DIV tag node is specified.
2190 * @return The conversion result is returned.
2193 s_jhtml_end_div_tag(void* pdoc, Node* UNUSED(child))
2199 jhtml = GET_JHTML(pdoc);
2209 chxj_istyle_to_mode(request_rec* r, const char* s)
2215 case '1': return apr_psprintf(r->pool, "hiragana");
2216 case '2': return apr_psprintf(r->pool, "hankakukana");
2217 case '3': return apr_psprintf(r->pool, "alphabet");
2218 case '4': return apr_psprintf(r->pool, "numeric");
2220 tmp = apr_palloc(r->pool, 1);
2222 return apr_pstrdup(r->pool, tmp);
2226 tmp = apr_palloc(r->pool, 1);
2228 return apr_pstrdup(r->pool,tmp);
2233 s_jhtml_chxjif_tag(void* pdoc, Node* node)
2240 jhtml = GET_JHTML(pdoc);
2244 for (child = qs_get_child_node(doc, node);
2246 child = qs_get_next_node(doc, child)) {
2248 s_jhtml_chxjif_tag(jhtml, child);
2255 * It is a handler who processes the TEXTARE tag.
2257 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2258 * destination is specified.
2259 * @param node [i] The TEXTAREA tag node is specified.
2260 * @return The conversion result is returned.
2263 s_jhtml_start_textarea_tag(void* pdoc, Node* node)
2270 jhtml = GET_JHTML(pdoc);
2274 jhtml->textarea_flag++;
2276 for (attr = qs_get_attr(doc,node);
2278 attr = qs_get_next_attr(doc,attr)) {
2283 name = qs_get_attr_name(doc,attr);
2284 value = qs_get_attr_value(doc,attr);
2286 if (STRCASEEQ('n','N',"name",name)) {
2291 else if (STRCASEEQ('r','R',"rows",name)) {
2296 else if (STRCASEEQ('c','C',"cols",name)) {
2308 * It is a handler who processes the TEXTAREA tag.
2310 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2311 * destination is specified.
2312 * @param node [i] The TEXTAREA tag node is specified.
2313 * @return The conversion result is returned.
2316 s_jhtml_end_textarea_tag(void* pdoc, Node* UNUSED(child))
2322 jhtml = GET_JHTML(pdoc);
2326 W_L("</textarea>\r\n");
2327 jhtml->textarea_flag--;
2334 * It is a handler who processes the B tag.
2336 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2337 * destination is specified.
2338 * @param node [i] The B tag node is specified.
2339 * @return The conversion result is returned.
2342 s_jhtml_start_b_tag(void* pdoc, Node* UNUSED(node))
2348 jhtml = GET_JHTML(pdoc);
2358 * It is a handler who processes the B tag.
2360 * @param pdoc [i/o] The pointer to the CHTML structure at the output
2361 * destination is specified.
2362 * @param node [i] The B tag node is specified.
2363 * @return The conversion result is returned.
2366 s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child))
2368 jhtml_t* jhtml = GET_JHTML(pdoc);
2369 Doc* doc = jhtml->doc;
2376 s_jhtml_text_tag(void* pdoc, Node* child)
2388 jhtml = GET_JHTML(pdoc);
2392 textval = qs_get_node_value(doc,child);
2393 textval = qs_trim_string(doc->buf.pool, textval);
2394 if (strlen(textval) == 0)
2397 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2398 memset(tmp, 0, qs_get_node_size(doc,child)+1);
2400 tdst = qs_alloc_zero_byte_string(r);
2401 memset(one_byte, 0, sizeof(one_byte));
2404 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2406 int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
2408 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2413 if (is_sjis_kanji(textval[ii])) {
2414 one_byte[0] = textval[ii+0];
2415 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2416 one_byte[0] = textval[ii+1];
2417 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2421 if (jhtml->pre_flag) {
2422 one_byte[0] = textval[ii+0];
2423 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2426 if (jhtml->textarea_flag) {
2427 one_byte[0] = textval[ii+0];
2428 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2431 if (textval[ii] != '\r' && textval[ii] != '\n') {
2432 one_byte[0] = textval[ii+0];
2433 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);