2 * Copyright (C) 2005-2011 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_hdml.h"
18 #include "chxj_tag_util.h"
19 #include "chxj_str_util.h"
21 #include "chxj_img_conv.h"
22 #include "chxj_dump.h"
23 #include "chxj_qr_code.h"
24 #include "chxj_encoding.h"
26 #define CHECK_BOX_PREFIX "_chxj_c_"
27 #define RADIO_BUTTON_PREFIX "_chxj_r_"
28 #define SUBMIT_BUTTON_PREFIX "_chxj_s_"
30 #define GET_HDML(X) ((hdml_t *)(X))
32 static void s_init_hdml (hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec);
33 static char *s_s_get_form_no(request_rec *r, hdml_t *hdml);
36 static char *s_hdml_start_html_tag (void *pdoc, Node *node);
37 static char *s_hdml_end_html_tag (void *pdoc, Node *node);
38 static char *s_hdml_start_meta_tag (void *pdoc, Node *node);
39 static char *s_hdml_end_meta_tag (void *pdoc, Node *node);
40 static char *s_hdml_start_li_tag (void *pdoc, Node *node);
41 static char *s_hdml_end_li_tag (void *pdoc, Node *node);
42 static char *s_hdml_start_head_tag (void *pdoc, Node *node);
43 static char *s_hdml_end_head_tag (void *pdoc, Node *node);
44 static char *s_hdml_start_title_tag (void *pdoc, Node *node);
45 static char *s_hdml_end_title_tag (void *pdoc, Node *node);
46 static char *s_hdml_start_base_tag (void *pdoc, Node *node);
47 static char *s_hdml_end_base_tag (void *pdoc, Node *node);
48 static char *s_hdml_start_body_tag (void *pdoc, Node *node);
49 static char *s_hdml_end_body_tag (void *pdoc, Node *node);
50 static char *s_hdml_start_a_tag (void *pdoc, Node *node);
51 static char *s_hdml_end_a_tag (void *pdoc, Node *node);
52 static char *s_hdml_start_br_tag (void *pdoc, Node *node);
53 static char *s_hdml_end_br_tag (void *pdoc, Node *node);
54 static char *s_hdml_start_tr_tag (void *pdoc, Node *node);
55 static char *s_hdml_end_tr_tag (void *pdoc, Node *node);
56 static char *s_hdml_start_font_tag (void *pdoc, Node *node);
57 static char *s_hdml_end_font_tag (void *pdoc, Node *node);
58 static char *s_hdml_start_form_tag (void *pdoc, Node *node);
59 static char *s_hdml_end_form_tag (void *pdoc, Node *node);
60 static char *s_hdml_start_input_tag (void *pdoc, Node *node);
61 static char *s_hdml_end_input_tag (void *pdoc, Node *node);
62 static char *s_hdml_start_select_tag (void *pdoc, Node *node);
63 static char *s_hdml_end_select_tag (void *pdoc, Node *node);
64 static char *s_hdml_start_option_tag (void *pdoc, Node *node);
65 static char *s_hdml_end_option_tag (void *pdoc, Node *node);
66 static char *s_hdml_start_center_tag (void *pdoc, Node *node);
67 static char *s_hdml_end_center_tag (void *pdoc, Node *node);
68 static char *s_hdml_start_hr_tag (void *pdoc, Node *node);
69 static char *s_hdml_end_hr_tag (void *pdoc, Node *node);
70 static char *s_hdml_start_img_tag (void *pdoc, Node *node);
71 static char *s_hdml_end_img_tag (void *pdoc, Node *node);
72 static char *s_hdml_start_div_tag (void *pdoc, Node *node);
73 static char *s_hdml_end_div_tag (void *pdoc, Node *node);
74 static char *s_hdml_start_blockquote_tag(void *pdoc, Node *node);
75 static char *s_hdml_end_blockquote_tag (void *pdoc, Node *node);
76 static char *s_hdml_start_dir_tag (void *pdoc, Node *node);
77 static char *s_hdml_end_dir_tag (void *pdoc, Node *node);
78 static char *s_hdml_start_dt_tag (void *pdoc, Node *node);
79 static char *s_hdml_end_dt_tag (void *pdoc, Node *node);
80 static char *s_hdml_start_dd_tag (void *pdoc, Node *node);
81 static char *s_hdml_end_dd_tag (void *pdoc, Node *node);
82 static char *s_hdml_start_plaintext_tag (void *pdoc, Node *node);
83 static char *s_hdml_start_plaintext_tag_inner (void *pdoc, Node *node);
84 static char *s_hdml_end_plaintext_tag (void *pdoc, Node *node);
85 static char *s_hdml_start_pre_tag (void *pdoc, Node *node);
86 static char *s_hdml_end_pre_tag (void *pdoc, Node *node);
87 static char *s_hdml_start_textarea_tag (void *pdoc, Node *node);
88 static char *s_hdml_inner_textarea_tag_get_value(hdml_t *hdml, Node *node);
90 static char *((*s_get_form_no)(request_rec* r, hdml_t* hdml)) = s_s_get_form_no;
92 static void s_hdml_count_radio_tag (hdml_t* hdml, Node* node) ;
94 static void s_hdml_do_input_text_tag (hdml_t *hdml, Node *tag);
95 static void s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag);
96 static void s_hdml_do_input_submit_tag (hdml_t *hdml, Node *tag);
97 static void s_hdml_do_input_reset_tag (hdml_t *hdml, Node *tag);
98 static void s_hdml_do_input_hidden_tag (hdml_t *hdml, Node *tag);
99 static void s_hdml_do_input_radio_tag (hdml_t *hdml, Node *tag);
100 static void s_hdml_do_input_checkbox_tag(hdml_t *hdml, Node *tag);
101 static void s_hdml_tag_output_upper_half(hdml_t *hdml, Node* node);
103 static hdml_t *s_output_to_hdml_out (hdml_t *hdml, char *s);
104 static hdml_t *s_output_to_hdml_card (hdml_t *hdml, char *s);
105 static void s_output_to_postdata (hdml_t *hdml, char *s);
106 static void s_output_to_init_vars (hdml_t *hdml, char *s);
107 static int s_hdml_search_emoji (hdml_t *hdml, char *txt, char **rslt);
109 static char *s_hdml_chxjif_tag (void *pdoc, Node *node);
110 static char *s_hdml_text_tag (void *pdoc, Node *node);
113 tag_handler hdml_handler[] = {
116 s_hdml_start_html_tag,
121 s_hdml_start_meta_tag,
126 s_hdml_start_textarea_tag,
131 s_hdml_start_div_tag,
136 s_hdml_start_pre_tag,
141 s_hdml_start_dir_tag,
151 s_hdml_start_dir_tag,
156 s_hdml_start_div_tag,
161 s_hdml_start_div_tag,
166 s_hdml_start_div_tag,
171 s_hdml_start_div_tag,
176 s_hdml_start_div_tag,
181 s_hdml_start_div_tag,
186 s_hdml_start_head_tag,
191 s_hdml_start_title_tag,
192 s_hdml_end_title_tag,
196 s_hdml_start_base_tag,
201 s_hdml_start_body_tag,
236 s_hdml_start_font_tag,
241 s_hdml_start_form_tag,
246 s_hdml_start_input_tag,
247 s_hdml_end_input_tag,
251 s_hdml_start_center_tag,
252 s_hdml_end_center_tag,
261 s_hdml_start_img_tag,
266 s_hdml_start_select_tag,
267 s_hdml_end_select_tag,
271 s_hdml_start_option_tag,
272 s_hdml_end_option_tag,
276 s_hdml_start_div_tag,
341 s_hdml_start_blockquote_tag,
342 s_hdml_end_blockquote_tag,
346 s_hdml_start_dir_tag,
361 s_hdml_start_dir_tag,
366 s_hdml_start_plaintext_tag,
367 s_hdml_end_plaintext_tag,
397 * converts from CHTML to hdml.
399 * @param r [i] Requet_rec is appointed.
400 * @param spec [i] The result of the device specification processing which
401 * was done in advance is appointed.
402 * @param src [i] The character string before the converting is appointed.
403 * @return The character string after the converting is returned.
412 chxjconvrule_entry *entryp,
413 cookie_t *UNUSED(cookie)
424 /*--------------------------------------------------------------------------*/
426 /*--------------------------------------------------------------------------*/
428 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
430 DBG(r,"REQ[%X] found qrcode xml",TO_ADDR(r));
434 /*--------------------------------------------------------------------------*/
435 /* initialize hdml structure */
436 /*--------------------------------------------------------------------------*/
437 s_init_hdml(&hdml,&doc,r, spec);
439 hdml.entryp = entryp;
441 chxj_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
442 /*--------------------------------------------------------------------------*/
444 /*--------------------------------------------------------------------------*/
446 chxj_dump_out("[src] CHTML->HDML", src, srclen);
449 /*--------------------------------------------------------------------------*/
450 /* It is examined whether there is a location header. It ends without doing */
451 /* anything when is. */
452 /*--------------------------------------------------------------------------*/
453 buf = (char *)apr_table_get(r->headers_out, (const char *)"Location");
455 /*------------------------------------------------------------------------*/
456 /* The Location header generates tag in an initial HDML machine for the */
457 /* uncorrespon dence. */
458 /*------------------------------------------------------------------------*/
459 DBG(r,"REQ[%X] Location is not null[Location:%s]", TO_ADDR(r),buf);
460 s_output_to_hdml_out(&hdml,
461 "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\r\n"
462 "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\r\n"
463 "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
465 s_output_to_hdml_out(&hdml, buf);
466 s_output_to_hdml_out(&hdml,
471 dst = apr_pstrdup(r->pool, hdml.out);
474 /*------------------------------------------------------------------------*/
475 /* Here, the parsing of the received character string is done */
476 /*------------------------------------------------------------------------*/
477 char *ss = apr_palloc(r->pool, srclen + 1);
478 memset(ss, 0, srclen + 1);
479 memcpy(ss, src, srclen);
481 DBG(r,"REQ[%X] input strlen(src)=[%d]", TO_ADDR(r),(int)srclen);
482 DBG(r,"REQ[%X] [[[[%s]]]", TO_ADDR(r),src);
484 qs_init_malloc(&doc);
485 qs_init_root_node(&doc);
487 qs_parse_string(&doc, ss, srclen);
489 /*------------------------------------------------------------------------*/
490 /* The number of radiobuttons is counted. */
491 /*------------------------------------------------------------------------*/
492 s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
494 chxj_node_convert(spec,r,(void*)&hdml, &doc, qs_get_root(&doc), 0);
497 DBG(r,"REQ[%X] tmp=[%s]", TO_ADDR(r),dst);
498 qs_all_free(&doc,QX_LOGMARK);
501 /*--------------------------------------------------------------------------*/
503 /*--------------------------------------------------------------------------*/
505 chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
508 /*--------------------------------------------------------------------------*/
509 /* When there is no processing result, former character string is copied */
510 /* and it returns it. */
511 /*--------------------------------------------------------------------------*/
514 return apr_pstrdup(r->pool,src);
517 *dstlen = hdml.out_len;
519 /*--------------------------------------------------------------------------*/
520 /* Null is set at the end of the character string to make sure. */
521 /*--------------------------------------------------------------------------*/
522 dst[hdml.out_len] = 0;
529 * The HDML structure is initialized.
531 * @param hdml [i/o] The pointer to the HDML structure that wants to be
532 * initialized is specified.
533 * @param doc [i] The Doc structure that should be set to the initialized
534 * HDML structure is specified.
535 * @param r [i] To use POOL, the pointer to request_rec is specified.
536 * @param spec [i] The pointer to the device_table
539 s_init_hdml(hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec)
544 /*--------------------------------------------------------------------------*/
545 /* init hdml structure value */
546 /*--------------------------------------------------------------------------*/
547 memset(hdml, 0, sizeof(hdml_t));
549 hdml->card = qs_alloc_zero_byte_string(r->pool);
551 hdml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
552 hdml->doc->parse_mode = PARSE_MODE_CHTML;
554 for (ii=0; ii<MAX_FORM_COUNT; ii++) {
555 hdml->var_cnt[ii] = 0;
556 hdml->postdata[ii] = qs_alloc_zero_byte_string(r->pool);
559 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
560 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
561 hdml->radio_value_list[ii][jj] = NULL;
563 hdml->radio_name_list[ii] = NULL;
564 hdml->radio_out_cnt[ii] = 0;
565 hdml->radio_checked_value[ii] = NULL;
568 for (ii=0; ii<MAX_SUBMIT_BUTTON_COUNT; ii++)
569 hdml->submit_button[ii] = NULL;
571 hdml->init_vars = qs_alloc_zero_byte_string(r->pool);
575 hdml->form_cnt = apr_time_now();
576 hdml->out = qs_alloc_zero_byte_string(r->pool);
581 s_hdml_search_emoji(hdml_t *hdml, char *txt, char **rslt)
594 DBG(r,"REQ[%X] spec is NULL",TO_ADDR(r));
597 for (ee = hdml->conf->emoji;
600 unsigned char hex1byte;
601 unsigned char hex2byte;
603 DBG(r,"REQ[%X] emoji->imode is NULL",TO_ADDR(r));
607 hex1byte = ee->imode->hex1byte & 0xff;
608 hex2byte = ee->imode->hex2byte & 0xff;
610 if (ee->imode->string
611 && strlen(ee->imode->string) > 0
612 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
613 if (spec == NULL || spec->emoji_type == NULL) {
614 *rslt = apr_psprintf(r->pool,
617 return strlen(ee->imode->string);
620 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
621 *rslt = apr_psprintf(r->pool,
624 return strlen(ee->imode->string);
627 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
628 *rslt = apr_psprintf(r->pool,
631 return strlen(ee->imode->string);
634 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
635 *rslt = apr_psprintf(r->pool,
638 return strlen(ee->imode->string);
641 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
642 *rslt = apr_psprintf(r->pool,
645 return strlen(ee->imode->string);
648 *rslt = apr_psprintf(r->pool,
651 return strlen(ee->imode->string);
656 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
657 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
658 if (spec == NULL || spec->emoji_type == NULL) {
659 *rslt = apr_psprintf(r->pool,
665 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
666 *rslt = apr_psprintf(r->pool,
672 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
673 *rslt = apr_psprintf(r->pool,
679 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
680 *rslt = apr_psprintf(r->pool,
686 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
687 *rslt = apr_psprintf(r->pool,
693 *rslt = apr_psprintf(r->pool,
706 * It is a handler who processes the HTML tag.
708 * @param pdoc [i/o] The pointer to the HDML structure at the output
709 * destination is specified.
710 * @param node [i] The HTML tag node is specified.
711 * @return The conversion result is returned.
714 s_hdml_start_html_tag(void *pdoc, Node *UNUSED(node))
716 hdml_t *hdml = GET_HDML(pdoc);
718 s_output_to_hdml_out(hdml,
719 "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\r\n"
720 "<NODISPLAY NAME=D0>\r\n"
721 "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\r\n"
726 hdml->hdml_br_flag = 0;
733 * It is a handler who processes the HTML tag.
735 * @param pdoc [i/o] The pointer to the HDML structure at the output
736 * destination is specified.
737 * @param node [i] The HTML tag node is specified.
738 * @return The conversion result is returned.
741 s_hdml_end_html_tag(void *pdoc, Node *UNUSED(child))
743 hdml_t *hdml = GET_HDML(pdoc);
745 s_output_to_hdml_card(hdml,
746 "<NODISPLAY NAME=D1>\r\n"
747 "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
750 if (strlen(hdml->init_vars)) {
751 s_output_to_hdml_card(hdml, hdml->init_vars );
754 s_output_to_hdml_card(hdml, "_chxj_dmy=" );
757 s_output_to_hdml_card(hdml,
762 s_output_to_hdml_out(hdml, hdml->card );
763 s_output_to_hdml_out(hdml, "</HDML>\r\n");
765 hdml->hdml_end_flag = 1;
772 * It is a handler who processes the META tag.
774 * @param pdoc [i/o] The pointer to the HDML structure at the output
775 * destination is specified.
776 * @param node [i] The META tag node is specified.
777 * @return The conversion result is returned.
780 s_hdml_start_meta_tag(void *pdoc, Node *UNUSED(node))
782 hdml_t *hdml = GET_HDML(pdoc);
784 hdml->hdml_br_flag = 0;
793 * It is a handler who processes the META tag.
795 * @param pdoc [i/o] The pointer to the HDML structure at the output
796 * destination is specified.
797 * @param node [i] The META tag node is specified.
798 * @return The conversion result is returned.
801 s_hdml_end_meta_tag(void *pdoc, Node *UNUSED(child))
803 hdml_t *hdml = GET_HDML(pdoc);
810 * It is a handler who processes the HEAD tag.
812 * @param pdoc [i/o] The pointer to the HDML structure at the output
813 * destination is specified.
814 * @param node [i] The HEAD tag node is specified.
815 * @return The conversion result is returned.
818 s_hdml_start_head_tag(void *pdoc, Node *UNUSED(node))
820 hdml_t *hdml = GET_HDML(pdoc);
824 hdml->hdml_br_flag = 0;
831 * It is a handler who processes the HEAD tag.
833 * @param pdoc [i/o] The pointer to the HDML structure at the output
834 * destination is specified.
835 * @param node [i] The HEAD tag node is specified.
836 * @return The conversion result is returned.
839 s_hdml_end_head_tag(void *pdoc, Node *UNUSED(child))
841 hdml_t *hdml = GET_HDML(pdoc);
850 * It is a handler who processes the TITLE tag.
852 * @param pdoc [i/o] The pointer to the HDML structure at the output
853 * destination is specified.
854 * @param node [i] The TITLE tag node is specified.
855 * @return The conversion result is returned.
858 s_hdml_start_title_tag(void *pdoc, Node *UNUSED(node))
860 hdml_t *hdml = GET_HDML(pdoc);
862 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
864 hdml->found_title = 1;
865 hdml->hdml_br_flag = 0;
872 * It is a handler who processes the TITLE tag.
874 * @param pdoc [i/o] The pointer to the HDML structure at the output
875 * destination is specified.
876 * @param node [i] The TITLE tag node is specified.
877 * @return The conversion result is returned.
880 s_hdml_end_title_tag(void *pdoc, Node *UNUSED(child))
882 hdml_t *hdml = GET_HDML(pdoc);
884 s_output_to_hdml_out(hdml, "\">\r\n");
891 * It is a handler who processes the BASE tag.
893 * @param pdoc [i/o] The pointer to the HDML structure at the output
894 * destination is specified.
895 * @param node [i] The BASE tag node is specified.
896 * @return The conversion result is returned.
899 s_hdml_start_base_tag(void *pdoc, Node *UNUSED(node))
901 hdml_t *hdml = GET_HDML(pdoc);
903 hdml->hdml_br_flag = 0;
910 * It is a handler who processes the BASE tag.
912 * @param pdoc [i/o] The pointer to the HDML structure at the output
913 * destination is specified.
914 * @param node [i] The BASE tag node is specified.
915 * @return The conversion result is returned.
918 s_hdml_end_base_tag(void *pdoc, Node *UNUSED(child))
920 hdml_t *hdml = GET_HDML(pdoc);
927 * It is a handler who processes the BODY tag.
929 * @param pdoc [i/o] The pointer to the HDML structure at the output
930 * destination is specified.
931 * @param node [i] The BODY tag node is specified.
932 * @return The conversion result is returned.
935 s_hdml_start_body_tag(void *pdoc, Node *node)
941 hdml = GET_HDML(pdoc);
945 if (hdml->found_title == 0) {
946 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\r\n");
949 s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
950 /*--------------------------------*/
952 /*--------------------------------*/
953 for (attr = qs_get_attr(doc,node);
955 attr = qs_get_next_attr(doc,attr)) {
956 char *name = qs_get_attr_name(doc,attr);
958 if (STRCASEEQ('b','B',"bgcolor",name)) {
961 else if (STRCASEEQ('t','T',"text",name)) {
964 else if (STRCASEEQ('l','L',"link",name)) {
967 else if (STRCASEEQ('a','A',"alink",name)) {
970 else if (STRCASEEQ('v','V',"vlink",name)) {
974 s_output_to_hdml_out(hdml, ">\r\n");
975 hdml->hdml_br_flag = 0;
981 * It is a handler who processes the BODY tag.
983 * @param pdoc [i/o] The pointer to the HDML structure at the output
984 * destination is specified.
985 * @param node [i] The BODY tag node is specified.
986 * @return The conversion result is returned.
989 s_hdml_end_body_tag(void *pdoc, Node *UNUSED(child))
991 hdml_t *hdml = GET_HDML(pdoc);
993 s_output_to_hdml_out(hdml, "\r\n</DISPLAY>\r\n");
1000 * It is a handler who processes the A tag.
1002 * @param pdoc [i/o] The pointer to the HDML structure at the output
1003 * destination is specified.
1004 * @param node [i] The A tag node is specified.
1005 * @return The conversion result is returned.
1008 s_hdml_start_a_tag(void *pdoc, Node *node)
1014 hdml = GET_HDML(pdoc);
1017 s_hdml_tag_output_upper_half(hdml,node);
1019 s_output_to_hdml_out(hdml, "<A");
1022 /*------------------------------------*/
1023 /* Get Attributes */
1024 /*------------------------------------*/
1025 for (attr = qs_get_attr(doc,node);
1027 attr = qs_get_next_attr(doc,attr)) {
1028 char *name = qs_get_attr_name(doc,attr);
1029 char *value = qs_get_attr_value(doc,attr);
1030 if (STRCASEEQ('n','N',"name",name)) {
1033 else if (STRCASEEQ('h','H',"href",name)) {
1034 if (STRNCASEEQ('m','M',"mailto:",value,sizeof("mailto:")-1)) {
1035 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
1036 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1037 s_output_to_hdml_out(hdml, value );
1038 s_output_to_hdml_out(hdml, "\" " );
1040 else if (STRNCASEEQ('t','T',"tel:",value,sizeof("tel:")-1)) {
1041 s_output_to_hdml_out(hdml, " TASK=CALL NUMBER=\"");
1042 s_output_to_hdml_out(hdml, &value[4] );
1043 s_output_to_hdml_out(hdml, "\" " );
1046 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1047 s_output_to_hdml_out(hdml, value );
1048 s_output_to_hdml_out(hdml, "\"" );
1051 else if (STRCASEEQ('a','A',"accesskey",name) && value && *value) {
1052 if (strcasecmp(value, "0") != 0) {
1053 s_output_to_hdml_out(hdml, " ACCESSKEY=" );
1054 s_output_to_hdml_out(hdml, value );
1055 s_output_to_hdml_out(hdml, "" );
1058 else if (STRCASEEQ('c','C',"cti",name)) {
1061 else if (STRCASEEQ('i','I',"ijam",name)) {
1064 else if (STRCASEEQ('u','U',"utn",name)) {
1067 else if (STRCASEEQ('t','T',"telbook",name)) {
1070 else if (STRCASEEQ('k','K',"kana",name)) {
1073 else if (STRCASEEQ('e','E',"email",name)) {
1076 else if (STRCASEEQ('i','I',"ista",name)) {
1079 else if (STRCASEEQ('i','I',"ilet",name)) {
1082 else if (STRCASEEQ('i','I',"iswf",name)) {
1085 else if (STRCASEEQ('i','I',"irst",name)) {
1089 s_output_to_hdml_out(hdml, ">" );
1091 hdml->hdml_a_flag = 1;
1093 hdml->hdml_br_flag = 0;
1100 * It is a handler who processes the A tag.
1102 * @param pdoc [i/o] The pointer to the HDML structure at the output
1103 * destination is specified.
1104 * @param node [i] The A tag node is specified.
1105 * @return The conversion result is returned.
1108 s_hdml_end_a_tag(void *pdoc, Node *UNUSED(child))
1110 hdml_t *hdml = GET_HDML(pdoc);
1112 s_output_to_hdml_out(hdml, "</A>\r\n");
1114 hdml->hdml_a_flag = 0;
1121 * It is a handler who processes the BR tag.
1123 * @param pdoc [i/o] The pointer to the HDML structure at the output
1124 * destination is specified.
1125 * @param node [i] The BR tag node is specified.
1126 * @return The conversion result is returned.
1129 s_hdml_start_br_tag(void *pdoc, Node *UNUSED(node))
1131 hdml_t *hdml = GET_HDML(pdoc);
1133 if (hdml->in_center > 0) {
1134 hdml->in_center = 0;
1137 if (hdml->div_in_center > 0) {
1138 hdml->div_in_center = 0;
1141 s_output_to_hdml_out(hdml, "<BR>\r\n");
1142 hdml->hdml_br_flag = 1;
1149 * It is a handler who processes the BR tag.
1151 * @param pdoc [i/o] The pointer to the HDML structure at the output
1152 * destination is specified.
1153 * @param node [i] The BR tag node is specified.
1154 * @return The conversion result is returned.
1157 s_hdml_end_br_tag(void *pdoc, Node *UNUSED(child))
1159 hdml_t *hdml = GET_HDML(pdoc);
1166 * It is a handler who processes the TR tag.
1168 * @param pdoc [i/o] The pointer to the HDML structure at the output
1169 * destination is specified.
1170 * @param node [i] The TR tag node is specified.
1171 * @return The conversion result is returned.
1174 s_hdml_start_tr_tag(void *pdoc, Node *UNUSED(node))
1176 hdml_t *hdml = GET_HDML(pdoc);
1178 if (hdml->in_center > 0) {
1179 hdml->in_center = 0;
1182 if (hdml->div_in_center > 0) {
1183 hdml->div_in_center = 0;
1186 s_output_to_hdml_out(hdml, "<BR>\r\n");
1188 hdml->hdml_br_flag = 1;
1195 * It is a handler who processes the TR tag.
1197 * @param pdoc [i/o] The pointer to the HDML structure at the output
1198 * destination is specified.
1199 * @param node [i] The TR tag node is specified.
1200 * @return The conversion result is returned.
1203 s_hdml_end_tr_tag(void *pdoc, Node *UNUSED(child))
1205 hdml_t *hdml = GET_HDML(pdoc);
1212 * It is a handler who processes the FONT tag.
1214 * @param pdoc [i/o] The pointer to the HDML structure at the output
1215 * destination is specified.
1216 * @param node [i] The FONT tag node is specified.
1217 * @return The conversion result is returned.
1220 s_hdml_start_font_tag(void *pdoc, Node *UNUSED(node))
1222 hdml_t *hdml = GET_HDML(pdoc);
1229 * It is a handler who processes the FONT tag.
1231 * @param pdoc [i/o] The pointer to the HDML structure at the output
1232 * destination is specified.
1233 * @param node [i] The FONT tag node is specified.
1234 * @return The conversion result is returned.
1237 s_hdml_end_font_tag(void *pdoc, Node *UNUSED(child))
1239 hdml_t *hdml = GET_HDML(pdoc);
1246 * It is a handler who processes the FORM tag.
1248 * @param pdoc [i/o] The pointer to the HDML structure at the output
1249 * destination is specified.
1250 * @param node [i] The FORM tag node is specified.
1251 * @return The conversion result is returned.
1254 s_hdml_start_form_tag(void *pdoc, Node *node)
1262 hdml = GET_HDML(pdoc);
1267 hdml->form_tmp = apr_psprintf(r->pool,
1268 "<NODISPLAY NAME=F%d>\r\n",
1269 hdml->pure_form_cnt);
1270 hdml->form_tmp = apr_pstrcat(r->pool,
1272 "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",
1274 /* Get Attributes */
1275 for (attr = qs_get_attr(doc,node);
1277 attr = qs_get_next_attr(doc,attr)) {
1278 char *name = qs_get_attr_name(doc,attr);
1279 char *value = qs_get_attr_value(doc,attr);
1280 if (STRCASEEQ('a','A',"action",name)) {
1281 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
1282 act = apr_psprintf(r->pool, "%s", value);
1288 hdml->form_tmp = apr_pstrcat(r->pool,
1293 hdml->form_tmp = apr_pstrcat(r->pool,
1297 hdml->form_tmp = apr_pstrcat(r->pool,
1302 hdml->hdml_br_flag = 0;
1309 * handler of the form end tag.
1311 * @param pdoc [i/o] The pointer to the HDML structure at the output
1312 * destination is specified.
1313 * @param child [i] unused.
1314 * @return The HDML output result after it edits it is returned.
1317 s_hdml_end_form_tag(void *pdoc, Node *UNUSED(child))
1319 hdml_t *hdml = GET_HDML(pdoc);
1320 request_rec *r = hdml->doc->r;
1322 s_output_to_postdata(hdml, "_chxj_dmy=");
1324 hdml->form_tmp = apr_pstrcat(r->pool,
1326 hdml->postdata[hdml->pure_form_cnt],
1329 hdml->form_tmp = apr_pstrcat(r->pool,
1331 "\" CLEAR=TRUE >\r\n",
1333 hdml->form_tmp = apr_pstrcat(r->pool,
1338 s_output_to_hdml_card(hdml, hdml->form_tmp);
1340 hdml->form_tmp = NULL;
1341 hdml->pure_form_cnt++;
1348 * It is a handler that takes charge of the processing of the input tag.
1350 * @param pdoc [i/o] The pointer to the HDML structure at the output
1351 * destination is specified.
1352 * @param node [i] The tag node to be processed is specified.
1355 s_hdml_start_input_tag(void *pdoc, Node *node)
1357 hdml_t *hdml = GET_HDML(pdoc);
1358 Doc *doc = hdml->doc;
1361 /*--------------------------------------------------------------------------*/
1362 /* The attribute of the input tag is acquired. */
1363 /*--------------------------------------------------------------------------*/
1364 for (attr = qs_get_attr(doc,node);
1366 attr = qs_get_next_attr(doc,attr)) {
1367 char *name = qs_get_attr_name(doc,attr);
1368 char *value = qs_get_attr_value(doc,attr);
1369 if (STRCASEEQ('t','T',"type",name)) {
1370 if (STRCASEEQ('t','T',"text",value)) {
1371 /*--------------------------------------------------------------------*/
1372 /* "input type ='text'" tag is processed. */
1373 /*--------------------------------------------------------------------*/
1374 s_hdml_do_input_text_tag(hdml, node);
1376 else if (STRCASEEQ('p','P',"password",value)) {
1377 /*--------------------------------------------------------------------*/
1378 /* "input type='password'" tag is processed. */
1379 /*--------------------------------------------------------------------*/
1380 s_hdml_do_input_password_tag(hdml, node);
1382 else if (STRCASEEQ('s','S',"submit",value)) {
1383 /*--------------------------------------------------------------------*/
1384 /* "input type='submit'" tag is processed. */
1385 /*--------------------------------------------------------------------*/
1386 s_hdml_do_input_submit_tag(hdml, node);
1388 else if (STRCASEEQ('h','H',"hidden",value)) {
1389 /*--------------------------------------------------------------------*/
1390 /* "input type='hidden'" tag is processed. */
1391 /*--------------------------------------------------------------------*/
1392 s_hdml_do_input_hidden_tag(hdml, node);
1394 else if (STRCASEEQ('r','R',"radio",value)) {
1395 /*--------------------------------------------------------------------*/
1396 /* "input type='radio'" tag is processed. */
1397 /*--------------------------------------------------------------------*/
1398 s_hdml_do_input_radio_tag(hdml, node);
1400 else if (STRCASEEQ('c','C',"checkbox",value)) {
1401 /*--------------------------------------------------------------------*/
1402 /* "input type='checkbox'" tag is processed. */
1403 /*--------------------------------------------------------------------*/
1404 s_hdml_do_input_checkbox_tag(hdml, node);
1406 else if (STRCASEEQ('r','R',"reset",value)) {
1407 /*--------------------------------------------------------------------*/
1408 /* "input type='reset'" tag is processed. */
1409 /*--------------------------------------------------------------------*/
1410 s_hdml_do_input_reset_tag(hdml, node);
1413 else if (STRCASEEQ('n','N',"name",name)) {
1416 else if (STRCASEEQ('v','V',"value",name)) {
1419 else if (STRCASEEQ('s','S',"size",name)) {
1422 else if (STRCASEEQ('m','M',"maxlength",name)) {
1425 else if (STRCASEEQ('c','C',"checked",name)) {
1428 else if (STRCASEEQ('a','A',"accesskey",name)) {
1431 else if (STRCASEEQ('i','I',"istyle",name)) {
1435 hdml->hdml_br_flag = 0;
1442 * The substitution processing of tag "input type = text" is done.
1444 * @param hdml [i/o] The pointer to the HDML structure at the output
1445 * destination is specified.
1446 * @param tag [i] The tag node of input type=text is specified.
1449 s_hdml_do_input_text_tag(hdml_t *hdml, Node *tag)
1463 s_hdml_tag_output_upper_half(hdml, tag);
1466 s_output_to_hdml_out(hdml,
1467 apr_psprintf(r->pool,
1468 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1469 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1471 s_get_form_no(r, hdml),
1472 hdml->var_cnt[hdml->pure_form_cnt],
1473 s_get_form_no(r, hdml),
1474 hdml->var_cnt[hdml->pure_form_cnt]
1477 s_output_to_hdml_out(hdml,
1478 apr_psprintf(r->pool,
1479 "[$%s%02d]</A>\r\n" ,
1480 s_get_form_no(r, hdml),
1481 hdml->var_cnt[hdml->pure_form_cnt]));
1483 /*--------------------------------------------------------------------------*/
1484 /* ENTRY CARD is output here. */
1485 /*--------------------------------------------------------------------------*/
1486 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1487 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1488 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1494 nm = qs_get_name_attr(doc, tag, r->pool);
1496 nm = qs_alloc_zero_byte_string(r->pool);
1499 s_output_to_postdata(hdml,
1500 apr_psprintf(r->pool,
1503 s_get_form_no(r, hdml),
1504 hdml->var_cnt[hdml->pure_form_cnt]));
1506 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1507 is = qs_get_istyle_attr (doc, tag, r->pool);
1508 val = qs_get_value_attr (doc, tag, r->pool);
1510 fmt = qs_conv_istyle_to_format(r->pool, is);
1511 DBG(r,"REQ[%X] qs_conv_istyle_to_format end",TO_ADDR(r));
1515 for (ii=0; ii<strlen(mlen); ii++) {
1516 if (mlen[ii] < '0' || mlen[ii] > '9') {
1517 mlen = apr_psprintf(r->pool, "0");
1521 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1524 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1527 s_output_to_hdml_card(hdml,
1528 " MARKABLE=FALSE>\r\n"
1529 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1533 s_output_to_init_vars(hdml,
1534 apr_psprintf(r->pool,
1536 s_get_form_no(r, hdml),
1537 hdml->var_cnt[hdml->pure_form_cnt],
1538 chxj_escape_uri(r->pool,val)));
1541 s_output_to_init_vars(hdml,
1542 apr_psprintf(r->pool,
1544 s_get_form_no(r, hdml),
1545 hdml->var_cnt[hdml->pure_form_cnt]));
1547 hdml->var_cnt[hdml->pure_form_cnt]++;
1552 * The substitution processing of tag "input type = password" is done.
1554 * @param hdml [i/o] The pointer to the HDML structure at the output
1555 * destination is specified.
1556 * @param tag [i] The tag node of input type=password is specified.
1559 s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag)
1572 s_hdml_tag_output_upper_half(hdml, tag);
1575 s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1576 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1577 s_output_to_hdml_out(hdml,
1578 apr_psprintf(r->pool,
1579 "VARS=\"V=$%s%02d\" ",
1580 s_get_form_no(r, hdml),
1581 hdml->var_cnt[hdml->pure_form_cnt]));
1583 s_output_to_hdml_out(hdml,
1584 apr_psprintf(r->pool, "RECEIVE=%s%02d>" ,
1585 s_get_form_no(r, hdml),
1586 hdml->var_cnt[hdml->pure_form_cnt]));
1587 s_output_to_hdml_out(hdml,
1588 apr_psprintf(r->pool, "[$%s%02d]</A>\r\n" ,
1589 s_get_form_no(r, hdml),
1590 hdml->var_cnt[hdml->pure_form_cnt]));
1592 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1593 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1594 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1601 nm = qs_get_name_attr(doc, tag, r->pool);
1603 nm = qs_alloc_zero_byte_string(r->pool);
1606 s_output_to_postdata(hdml,
1607 apr_psprintf(r->pool,
1610 s_get_form_no(r, hdml),
1611 hdml->var_cnt[hdml->pure_form_cnt]));
1613 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1614 val = qs_get_value_attr (doc, tag, r->pool);
1615 /*--------------------------------------------------------------------------*/
1616 /* Default is a figure input. */
1617 /*--------------------------------------------------------------------------*/
1618 fmt = apr_psprintf(r->pool, "N");
1620 if (chxj_chk_numeric(mlen) != 0)
1621 mlen = apr_psprintf(r->pool, "0");
1622 s_output_to_hdml_card(hdml,
1623 apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1626 s_output_to_hdml_card(hdml,
1627 apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1629 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1631 s_output_to_hdml_card(hdml,
1632 " MARKABLE=FALSE>\r\n"
1633 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1637 s_output_to_init_vars(hdml,
1638 apr_psprintf(r->pool, "%s%02d=%s",
1639 s_get_form_no(r, hdml),
1640 hdml->var_cnt[hdml->pure_form_cnt],
1641 chxj_escape_uri(r->pool,val)));
1643 s_output_to_init_vars(hdml,
1644 apr_psprintf(r->pool, "%s%02d=",
1645 s_get_form_no(r, hdml),
1646 hdml->var_cnt[hdml->pure_form_cnt]));
1648 hdml->var_cnt[hdml->pure_form_cnt]++;
1653 * The substitution processing of tag "input type = submit" is done.
1655 * @param hdml [i/o] The pointer to the HDML structure at the output
1656 * destination is specified.
1657 * @param tag [i] The tag node of input type=submit is specified.
1660 s_hdml_do_input_submit_tag(hdml_t *hdml, Node *tag)
1662 Doc *doc = hdml->doc;
1663 request_rec *r = doc->r;
1667 s_hdml_tag_output_upper_half(hdml, tag);
1669 s_output_to_hdml_out(hdml,
1670 apr_psprintf(r->pool,
1671 "<A TASK=GO LABEL=OK DEST=#F%d ",
1672 hdml->pure_form_cnt));
1674 /*--------------------------------------------------------------------------*/
1675 /* get name and value attribute */
1676 /*--------------------------------------------------------------------------*/
1677 nm = qs_get_name_attr (doc, tag, r->pool);
1678 val = qs_get_value_attr (doc, tag, r->pool);
1681 s_output_to_hdml_out(hdml,
1682 apr_psprintf(r->pool, "VARS=\"%s=%s\" ",
1684 chxj_escape_uri(r->pool,val)));
1685 if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1686 s_output_to_postdata(hdml,
1687 apr_psprintf(r->pool,"%s%s=$%s",
1688 SUBMIT_BUTTON_PREFIX, nm, nm));
1691 s_output_to_hdml_out(hdml, ">" );
1693 s_output_to_hdml_out(hdml, val);
1695 s_output_to_hdml_out(hdml, "</A>\r\n" );
1700 * The substitution processing of tag "input type = reset" is done.
1702 * @param hdml [i/o] The pointer to the HDML structure at the output
1703 * destination is specified.
1704 * @param tag [i] The tag node of input type=submit is specified.
1707 s_hdml_do_input_reset_tag(hdml_t *hdml, Node *tag)
1709 Doc *doc = hdml->doc;
1710 request_rec *r = doc->r;
1714 s_hdml_tag_output_upper_half(hdml, tag);
1716 s_output_to_hdml_out(hdml,
1717 apr_psprintf(r->pool,
1718 "<A TASK=GO LABEL=OK DEST=#D0>"));
1720 /*--------------------------------------------------------------------------*/
1721 /* get name and value attribute */
1722 /*--------------------------------------------------------------------------*/
1723 nm = qs_get_name_attr (doc, tag, r->pool);
1724 val = qs_get_value_attr (doc, tag, r->pool);
1726 s_output_to_hdml_out(hdml, val);
1728 s_output_to_hdml_out(hdml, "</A>\r\n" );
1733 * The substitution processing of tag "input type = hidden" is done.
1735 * @param hdml [i/o] The pointer to the HDML structure at the output
1736 * destination is specified.
1737 * @param tag [i] The tag node of input type=hidden is specified.
1740 s_hdml_do_input_hidden_tag(hdml_t *hdml, Node *tag)
1742 Doc *doc = hdml->doc;
1743 request_rec *r = doc->r;
1747 /*--------------------------------------------------------------------------*/
1748 /* get name and value attribute */
1749 /*--------------------------------------------------------------------------*/
1750 nm = qs_get_name_attr (doc, tag, r->pool);
1751 val = qs_get_value_attr (doc, tag, r->pool);
1753 s_output_to_postdata(hdml,
1754 apr_psprintf(r->pool,
1757 chxj_escape_uri(r->pool, val)));
1762 * The substitution processing of tag "input type = radio" is done.
1764 * @param hdml [i/o] The pointer to the HDML structure at the output
1765 * destination is specified.
1766 * @param tag [i] The tag node of input type=radio is specified.
1769 s_hdml_do_input_radio_tag(hdml_t *hdml, Node *tag)
1771 Doc *doc = hdml->doc;
1772 request_rec *r = doc->r;
1780 s_hdml_tag_output_upper_half(hdml, tag);
1782 /*--------------------------------------------------------------------------*/
1783 /* get name and value attribute */
1784 /*--------------------------------------------------------------------------*/
1785 nm = qs_get_name_attr (doc, tag, r->pool);
1786 val = qs_get_value_attr (doc, tag, r->pool);
1787 /*--------------------------------------------------------------------------*/
1788 /* The same name is searched out from the list made beforehand. */
1789 /*--------------------------------------------------------------------------*/
1790 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1791 if (! hdml->radio_name_list[ii]) {
1793 DBG(r,"REQ[%X] Oops... radio list is null[%d]",TO_ADDR(r),ii);
1794 /*----------------------------------------------------------------------*/
1795 /* Processing is ended because it doesn't happen off the fly. */
1796 /*----------------------------------------------------------------------*/
1800 if (strcasecmp(hdml->radio_name_list[ii], nm) == 0)
1803 if (ii == MAX_RADIO_COUNT) {
1805 DBG(r,"REQ[%X] Oops... The same name was not in the list. ",TO_ADDR(r));
1806 /*------------------------------------------------------------------------*/
1807 /* Processing is ended because it doesn't happen off the fly. */
1808 /*------------------------------------------------------------------------*/
1812 s_output_to_hdml_out(hdml,
1813 apr_psprintf(r->pool,
1816 "DEST=#R%d VARS=\"VAL=%s\" "
1822 if (hdml->radio_out_cnt[ii] == 0) {
1823 s_output_to_hdml_card(hdml,
1824 apr_psprintf(r->pool,
1825 "<NODISPLAY NAME=R%d>\r\n",
1827 s_output_to_hdml_card(hdml,
1828 apr_psprintf(r->pool,
1830 "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1833 kk = hdml->radio_out_cnt[ii];
1834 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
1835 if (! hdml->radio_value_list[ii][jj])
1840 for (jj=0; jj<r_cnt; jj++) {
1841 if (! hdml->radio_value_list[ii][jj])
1845 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1846 if (hdml->radio_out_cnt[ii] == 0)
1847 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1850 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1851 if (hdml->radio_out_cnt[ii] == 0) {
1853 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1855 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1862 s_output_to_hdml_out(hdml,
1863 apr_psprintf(r->pool, "\" >$%s_%02d</A>",
1865 hdml->radio_out_cnt[ii]));
1866 if (! hdml->radio_out_cnt[ii]) {
1867 s_output_to_hdml_card(hdml, "\">\r\n" );
1868 s_output_to_hdml_card(hdml, "</NODISPLAY>\r\n");
1870 s_output_to_postdata(hdml, apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1872 for (jj=0; jj<r_cnt; jj++) {
1873 if (hdml->radio_value_list[ii][jj] && hdml->radio_checked_value[ii]) {
1874 if (strcasecmp(hdml->radio_value_list[ii][jj],
1875 hdml->radio_checked_value[ii]) == 0) {
1876 s_output_to_init_vars(hdml,
1877 apr_psprintf(r->pool,
1883 s_output_to_init_vars(hdml,
1884 apr_psprintf(r->pool,
1891 s_output_to_init_vars(hdml,
1892 apr_psprintf(r->pool,
1899 if (hdml->radio_checked_value[ii]) {
1900 DBG(r,"REQ[%x] radio button is checked. checked value is [%s]",
1902 hdml->radio_checked_value[ii]);
1903 s_output_to_init_vars(hdml,
1904 apr_psprintf(r->pool,
1907 hdml->radio_checked_value[ii]));
1910 DBG(r,"REQ[%X] radio button is not checked. checked value is []",TO_ADDR(r));
1911 s_output_to_init_vars(hdml,
1912 apr_psprintf(r->pool,
1917 hdml->radio_out_cnt[ii]++;
1922 * The substitution processing of tag "input type = checkbox" is done.
1924 * @param hdml [i/o] The pointer to the HDML structure at the output
1925 * destination is specified.
1926 * @param tag [i] The tag node of input type=checkbox is specified.
1929 s_hdml_do_input_checkbox_tag(hdml_t *hdml, Node *tag)
1931 Doc *doc = hdml->doc;
1932 request_rec *r = doc->r;
1937 /*--------------------------------------------------------------------------*/
1938 /* It is posted to the one without the checked attribute. */
1939 /* However, they were able to be removed with INPUT FILTER. */
1940 /*--------------------------------------------------------------------------*/
1941 if (! hdml->has_checkbox) {
1942 hdml->has_checkbox++;
1943 s_output_to_hdml_card(hdml,
1944 "<NODISPLAY NAME=\"_chk\">\r\n"
1945 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1946 "RETVALS=\"_uchk;$V;X\" >\r\n"
1948 "<NODISPLAY NAME=\"_uchk\">\r\n"
1949 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1950 "RETVALS=\"_chk;;_\" >\r\n"
1953 DBG(r,"REQ[%X] wrote checkbox hdml card.",TO_ADDR(r));
1956 /*--------------------------------------------------------------------------*/
1957 /* It is examined whether it is CHECKED. */
1958 /*--------------------------------------------------------------------------*/
1959 chk = qs_is_checked_checkbox_attr(doc, tag, r->pool);
1961 /*--------------------------------------------------------------------------*/
1962 /* The value of the name attribute and the value attribute is acquired */
1964 /*--------------------------------------------------------------------------*/
1965 val = qs_get_value_attr(doc, tag, r->pool);
1966 nm = qs_get_name_attr(doc, tag, r->pool);
1969 val = qs_alloc_zero_byte_string(r->pool);
1973 nm = qs_alloc_zero_byte_string(r->pool);
1976 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
1977 "<A TASK=GOSUB LABEL=\"check\" "
1978 "DEST=\"#$%s%02d\" "
1980 "RECEIVE=\"%s%02d;%s%02d;%s%02d\">"
1982 s_get_form_no(r, hdml),
1983 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1985 s_get_form_no(r, hdml),
1986 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1987 s_get_form_no(r, hdml),
1988 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1989 s_get_form_no(r, hdml),
1990 hdml->var_cnt[hdml->pure_form_cnt] + 2,
1991 s_get_form_no(r, hdml),
1992 hdml->var_cnt[hdml->pure_form_cnt] + 2));
1994 s_output_to_init_vars(hdml,
1995 apr_psprintf(r->pool,
1996 "%s%02d=_uchk&%s%02d=%s&%s%02d=X",
1997 s_get_form_no(r, hdml),
1998 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1999 s_get_form_no(r, hdml),
2000 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2001 chxj_escape_uri(r->pool,val),
2002 s_get_form_no(r, hdml),
2003 hdml->var_cnt[hdml->pure_form_cnt] + 2
2007 s_output_to_init_vars(hdml,
2008 apr_psprintf(r->pool,
2009 "%s%02d=_chk&%s%02d=&%s%02d=_",
2010 s_get_form_no(r, hdml),
2011 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2012 s_get_form_no(r, hdml),
2013 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2014 s_get_form_no(r, hdml),
2015 hdml->var_cnt[hdml->pure_form_cnt] + 2
2019 s_output_to_postdata(hdml,
2020 apr_psprintf(r->pool, "%s%s=$%s%02d",
2023 s_get_form_no(r, hdml),
2024 hdml->var_cnt[hdml->pure_form_cnt] + 1));
2026 hdml->var_cnt[hdml->pure_form_cnt] += 3;
2031 * The ISTYLE attribute is converted into the HDML form.
2033 * @param r [i] To use POOL, the pointer to request_rec is specified.
2034 * @param is [i] The value of the ISTYLE attribute is specified.
2035 * @return The ISTYLE attribute converted into the HDML form is returned.
2038 qs_conv_istyle_to_format(apr_pool_t *p, char *is)
2047 fmt = apr_psprintf(p, "M");
2050 fmt = apr_psprintf(p, "M");
2053 fmt = apr_psprintf(p, "m");
2056 fmt = apr_psprintf(p, "N");
2059 return apr_pstrdup(p, "M");
2067 * It is a handler who processes the INPUT tag.
2069 * @param pdoc [i/o] The pointer to the HDML structure at the output
2070 * destination is specified.
2071 * @param node [i] The INPUT tag node is specified.
2072 * @return The conversion result is returned.
2075 s_hdml_end_input_tag(void *pdoc, Node *UNUSED(child))
2077 hdml_t *hdml = GET_HDML(pdoc);
2084 * It is a handler who processes the CENTER tag.
2086 * @param pdoc [i/o] The pointer to the HDML structure at the output
2087 * destination is specified.
2088 * @param node [i] The CENTER tag node is specified.
2089 * @return The conversion result is returned.
2092 s_hdml_start_center_tag(void *pdoc, Node *UNUSED(node))
2094 hdml_t *hdml = GET_HDML(pdoc);
2099 if (hdml->hdml_br_flag == 0) {
2100 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2103 hdml = s_output_to_hdml_out(hdml, "<CENTER>");
2110 * It is a handler who processes the CENTER tag.
2112 * @param pdoc [i/o] The pointer to the HDML structure at the output
2113 * destination is specified.
2114 * @param node [i] The CENTER tag node is specified.
2115 * @return The conversion result is returned.
2118 s_hdml_end_center_tag(void *pdoc, Node *UNUSED(child))
2120 hdml_t *hdml = GET_HDML(pdoc);
2123 hdml->in_center = 0;
2125 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2126 hdml->hdml_br_flag = 1;
2133 * It is a handler who processes the HR tag.
2135 * @param pdoc [i/o] The pointer to the HDML structure at the output
2136 * destination is specified.
2137 * @param node [i] The HR tag node is specified.
2138 * @return The conversion result is returned.
2141 s_hdml_start_hr_tag(void *pdoc, Node *UNUSED(node))
2143 hdml_t *hdml = GET_HDML(pdoc);
2145 if (hdml->hdml_br_flag == 0) {
2146 s_output_to_hdml_out(hdml, "<BR>\r\n");
2147 if (hdml->in_center)
2150 if (hdml->div_in_center)
2151 hdml->div_in_center--;
2154 s_output_to_hdml_out(hdml, "<CENTER>\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c\x81\x7c<BR>\r\n");
2156 hdml->hdml_br_flag = 1;
2163 * It is a handler who processes the HR tag.
2165 * @param pdoc [i/o] The pointer to the HDML structure at the output
2166 * destination is specified.
2167 * @param node [i] The HR tag node is specified.
2168 * @return The conversion result is returned.
2171 s_hdml_end_hr_tag(void *pdoc, Node *UNUSED(child))
2173 hdml_t *hdml = GET_HDML(pdoc);
2180 * It is a handler who processes the LI tag.
2182 * @param pdoc [i/o] The pointer to the HDML structure at the output
2183 * destination is specified.
2184 * @param node [i] The LI tag node is specified.
2185 * @return The conversion result is returned.
2188 s_hdml_start_li_tag(void *pdoc, Node *UNUSED(node))
2190 hdml_t *hdml = GET_HDML(pdoc);
2193 if (hdml->hdml_br_flag == 0) {
2194 s_output_to_hdml_out(hdml, "<BR>\r\n");
2195 if (hdml->in_center)
2198 if (hdml->div_in_center)
2199 hdml->div_in_center--;
2201 s_output_to_hdml_out(hdml, "<WRAP>");
2202 for (i=0; i<hdml->dir_level; i++) {
2203 s_output_to_hdml_out(hdml, " ");
2205 hdml->hdml_br_flag = 1;
2211 * It is a handler who processes the LI tag.
2213 * @param pdoc [i/o] The pointer to the HDML structure at the output
2214 * destination is specified.
2215 * @param node [i] The LI tag node is specified.
2216 * @return The conversion result is returned.
2219 s_hdml_end_li_tag(void *pdoc, Node *UNUSED(child))
2221 hdml_t *hdml = GET_HDML(pdoc);
2222 if (hdml->hdml_br_flag == 0) {
2223 s_output_to_hdml_out(hdml, "<BR>\r\n");
2224 if (hdml->in_center)
2227 if (hdml->div_in_center)
2228 hdml->div_in_center--;
2230 hdml->hdml_br_flag = 1;
2236 * It is a handler who processes the IMG tag.
2238 * @param pdoc [i/o] The pointer to the HDML structure at the output
2239 * destination is specified.
2240 * @param node [i] The IMG tag node is specified.
2241 * @return The conversion result is returned.
2244 s_hdml_start_img_tag(void *pdoc, Node *node)
2248 #ifndef IMG_NOT_CONVERT_FILENAME
2255 hdml = GET_HDML(pdoc);
2257 #ifndef IMG_NOT_CONVERT_FILENAME
2261 s_hdml_tag_output_upper_half(hdml, node);
2263 out = apr_palloc(doc->r->pool, 1);
2265 out = apr_pstrcat(doc->r->pool, out, "<img", NULL);
2267 /* Get Attributes */
2268 for (attr = qs_get_attr(doc,node);
2270 attr = qs_get_next_attr(doc,attr)) {
2271 char *name = qs_get_attr_name(doc,attr);
2272 char *value = qs_get_attr_value(doc,attr);
2273 if (STRCASEEQ('s','S',"src",name) && value && *value) {
2274 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
2275 out = apr_pstrcat(doc->r->pool, out, " src=\"", NULL);
2276 #ifdef IMG_NOT_CONVERT_FILENAME
2277 out = apr_pstrcat(doc->r->pool, out, value, NULL);
2279 out = apr_pstrcat(doc->r->pool, out, chxj_img_conv(doc->r, spec,value), NULL);
2281 out = apr_pstrcat(doc->r->pool, out, "\"", NULL);
2283 else if (STRCASEEQ('a','A',"align",name)) {
2285 if (STRCASEEQ('r','R',"right", value)) {
2286 s_output_to_hdml_out(hdml, "<RIGHT>" );
2289 else if (STRCASEEQ('c','C',"center",value)) {
2290 s_output_to_hdml_out(hdml, "<CENTER>" );
2295 else if (STRCASEEQ('w','W',"width",name)) {
2298 else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2301 else if (STRCASEEQ('h','H',"hspace", name) && value && *value) {
2304 else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2307 else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2308 out = apr_pstrcat(doc->r->pool, out, " alt=\"", NULL);
2309 out = apr_pstrcat(doc->r->pool, out, value, NULL);
2310 out = apr_pstrcat(doc->r->pool, out, "\"", NULL);
2313 out = apr_pstrcat(doc->r->pool, out, ">", NULL);
2314 s_output_to_hdml_out(hdml, out);
2316 s_output_to_hdml_out(hdml, "<BR>");
2319 hdml->hdml_br_flag = 0;
2326 * It is a handler who processes the IMG tag.
2328 * @param pdoc [i/o] The pointer to the HDML structure at the output
2329 * destination is specified.
2330 * @param node [i] The IMG tag node is specified.
2331 * @return The conversion result is returned.
2334 s_hdml_end_img_tag(void *pdoc, Node *UNUSED(child))
2336 hdml_t *hdml = GET_HDML(pdoc);
2342 * It is a handler who processes the SELECT tag.
2344 * @param pdoc [i/o] The pointer to the HDML structure at the output
2345 * destination is specified.
2346 * @param node [i] The SELECT tag node is specified.
2347 * @return The conversion result is returned.
2350 s_hdml_start_select_tag(void *pdoc, Node *node)
2357 hdml = GET_HDML(pdoc);
2361 s_hdml_tag_output_upper_half(hdml, node);
2365 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2366 "<A TASK=GOSUB LABEL=\x91\x49\x91\xf0 "
2367 "VARS=\"V=$%s%02d\" DEST=#D%d "
2368 "RECEIVE=\"%s%02d;%s%02d\">"
2370 s_get_form_no(r, hdml),
2371 hdml->var_cnt[hdml->pure_form_cnt]+0,
2373 s_get_form_no(r, hdml),
2374 hdml->var_cnt[hdml->pure_form_cnt]+0,
2375 s_get_form_no(r, hdml),
2376 hdml->var_cnt[hdml->pure_form_cnt]+1,
2377 s_get_form_no(r, hdml),
2378 hdml->var_cnt[hdml->pure_form_cnt]+1));
2380 s_output_to_hdml_card(hdml,
2381 apr_psprintf(r->pool,
2382 "<CHOICE KEY=V NAME=D%d ", hdml->card_cnt));
2383 s_output_to_hdml_card(hdml,
2384 apr_psprintf(r->pool,
2385 "DEFAULT=$V METHOD=ALPHA MARKABLE=FALSE>\r\n"));
2386 /*--------------------------------------------------------------------------*/
2387 /* Get Attributes */
2388 /*--------------------------------------------------------------------------*/
2389 for (attr = qs_get_attr(doc,node);
2391 attr=qs_get_next_attr(doc,attr)) {
2392 char *name = qs_get_attr_name(doc,attr);
2393 char *value = qs_get_attr_value(doc,attr);
2394 char *selval = NULL;
2395 char *selvaltxt = NULL;
2397 if (STRCASEEQ('n','N',"name",name)) {
2398 s_output_to_postdata(hdml,
2399 apr_psprintf(r->pool, "%s=$%s%02d",
2401 s_get_form_no(r, hdml),
2402 hdml->var_cnt[hdml->pure_form_cnt]));
2403 selval = qs_get_selected_value(doc, node, r->pool);
2405 DBG(r,"REQ[%X] selected value not found",TO_ADDR(r));
2406 selval = qs_alloc_zero_byte_string(r->pool);
2409 DBG(r,"REQ[%X] selected value found[%s]" , TO_ADDR(r),selval);
2411 selvaltxt = qs_get_selected_value_text(doc, node, r->pool);
2413 selvaltxt = qs_alloc_zero_byte_string(r->pool);
2415 DBG(r,"REQ[%X] selvaltxt:[%s]",TO_ADDR(r),selvaltxt);
2417 s_output_to_init_vars(hdml,
2418 apr_psprintf(r->pool,
2419 "%s%02d=%s&%s%02d=%s",
2420 s_get_form_no(r, hdml),
2421 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2423 s_get_form_no(r, hdml),
2424 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2427 hdml->var_cnt[hdml->pure_form_cnt] += 2;
2431 hdml->hdml_br_flag = 0;
2437 * It is a handler who processes the SELECT tag.
2439 * @param pdoc [i/o] The pointer to the HDML structure at the output
2440 * destination is specified.
2441 * @param node [i] The SELECT tag node is specified.
2442 * @return The conversion result is returned.
2445 s_hdml_end_select_tag(void *pdoc, Node *UNUSED(node))
2447 hdml_t *hdml = GET_HDML(pdoc);
2449 s_output_to_hdml_card(hdml, "</CHOICE>\r\n");
2456 * It is a handler who processes the OPTION tag.
2458 * @param pdoc [i/o] The pointer to the HDML structure at the output
2459 * destination is specified.
2460 * @param node [i] The OPTION tag node is specified.
2461 * @return The conversion result is returned.
2464 s_hdml_start_option_tag(void *pdoc, Node *node)
2473 hdml = GET_HDML(pdoc);
2479 hdml->option_flag = 1;
2480 val = qs_get_value_attr(doc, node, r->pool);
2482 /*--------------------------------------------------------------------------*/
2483 /* The child node of the object tag node acquires the value in assumption */
2484 /* that is the TEXT node. */
2485 /*--------------------------------------------------------------------------*/
2486 child = qs_get_child_node(doc, node);
2488 txtval = apr_palloc(r->pool, 1);
2492 txtval = qs_get_node_value(doc, child);
2495 DBG(r,"REQ[%X] txtval:[%s]" , TO_ADDR(r),txtval);
2497 if (val && txtval) {
2498 s_output_to_hdml_card(hdml,
2499 apr_psprintf(r->pool,
2500 "<CE TASK=RETURN VALUE=\"%s\" "
2501 "RETVALS=\"$V;%s\">%s</CE>\r\n",
2503 qs_trim_string(r->pool,txtval),
2504 qs_trim_string(r->pool,txtval)));
2507 hdml->hdml_br_flag = 0;
2514 * It is a handler who processes the OPTION tag.
2516 * @param pdoc [i/o] The pointer to the HDML structure at the output
2517 * destination is specified.
2518 * @param node [i] The OPTION tag node is specified.
2519 * @return The conversion result is returned.
2522 s_hdml_end_option_tag(void *pdoc, Node *UNUSED(node))
2524 hdml_t *hdml = GET_HDML(pdoc);
2526 hdml->option_flag = 0;
2533 * It is a handler who processes the DIV tag.
2535 * @param pdoc [i/o] The pointer to the HDML structure at the output
2536 * destination is specified.
2537 * @param node [i] The DIV tag node is specified.
2538 * @return The conversion result is returned.
2541 s_hdml_start_div_tag(void *pdoc, Node *node)
2547 hdml = GET_HDML(pdoc);
2550 /*--------------------------------------------------------------------------*/
2551 /* If the br tag is not output immediately before the div tag appears, the */
2552 /* br tag is output. */
2553 /*--------------------------------------------------------------------------*/
2554 if (hdml->hdml_br_flag == 0) {
2555 hdml->hdml_br_flag = 1;
2556 s_output_to_hdml_out(hdml, "<BR>\r\n");
2559 /*--------------------------------------------------------------------------*/
2560 /* The object tag node is scanned. */
2561 /*--------------------------------------------------------------------------*/
2562 for (attr = qs_get_attr(doc,node);
2564 attr = qs_get_next_attr(doc,attr)) {
2565 char *name = qs_get_attr_name(doc,attr);
2566 char *value = qs_get_attr_value(doc,attr);
2567 if (STRCASEEQ('a','A',"align",name)) {
2568 if (STRCASEEQ('r','R',"right",value)) {
2569 hdml->div_right_flag = 1;
2570 s_output_to_hdml_out(hdml, "<RIGHT>");
2571 hdml->hdml_br_flag = 0;
2574 else if (STRCASEEQ('c','C',"center",value)) {
2575 hdml->div_center_flag = 1;
2576 s_output_to_hdml_out(hdml, "<CENTER>");
2577 hdml->hdml_br_flag = 0;
2582 hdml->hdml_br_flag = 0;
2589 * It is a handler who processes the DIV tag.
2591 * @param pdoc [i/o] The pointer to the HDML structure at the output
2592 * destination is specified.
2593 * @param node [i] The DIV tag node is specified.
2594 * @return The conversion result is returned.
2597 s_hdml_end_div_tag(void *pdoc, Node *UNUSED(node))
2599 hdml_t *hdml = GET_HDML(pdoc);
2600 request_rec *r = hdml->doc->r;
2602 if (hdml->div_right_flag == 1) {
2603 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2604 hdml->div_right_flag = 0;
2606 if (hdml->div_center_flag == 1) {
2607 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2608 hdml->div_center_flag = 0;
2609 hdml->div_in_center = 0;
2617 * It is a wrapper of the apr_pstrcat function.
2619 * @param r [i] To use POOL, the pointer to request_rec is specified.
2620 * @param o [i] The character string of connected origin is specified.
2621 * @param s [i] The character string connected with 'o' parameter is
2623 * @param len [i/o] The pointer to the area where the character string
2624 * length is stored is specified.
2625 * @return The character string after it connects it is returned.
2628 qs_out_apr_pstrcat(request_rec *r, char *o, char *s, int *len)
2630 *len = (strlen(s) + *len);
2631 return apr_pstrcat(r->pool, o, s, NULL);
2635 * The prepositive character string used to generate the variable for HDML is
2638 * @param r [i] To use POOL, the pointer to request_rec is specified.
2639 * @param hdml [i] The pointer to the HDML structure that maintains the seed
2640 * to generate it is specified.
2641 * @return The character string after it generates it is returned.
2644 s_s_get_form_no(request_rec *r, hdml_t *hdml)
2650 fc = hdml->form_cnt;
2652 apr_time_exp_tz(&tm, hdml->form_cnt, 0);
2654 result = apr_psprintf(r->pool, "%c",(int)('A' + ((fc / 100) % 26)));
2655 result = apr_pstrcat(r->pool, result,
2656 apr_psprintf(r->pool, "%02d%02d%02d",
2664 * The number of tag nodes .."Input type =' radio '".. is counted.
2666 * @param hdml [i] The pointer to the HDML structure is specified.
2667 * @param node [i] The first parents node that counts the radio tag node is
2671 s_hdml_count_radio_tag(hdml_t *hdml, Node *node)
2680 /*--------------------------------------------------------------------------*/
2681 /* All the child nodes of the specified node are scanned. */
2682 /*--------------------------------------------------------------------------*/
2683 for (child = qs_get_child_node(doc,node);
2685 child = qs_get_next_node(doc,child)) {
2694 name = qs_get_node_name(doc,child);
2695 if (strcasecmp(name, "input") != 0) {
2696 s_hdml_count_radio_tag(hdml, child);
2700 DBG(r,"REQ[%X] found input tag",TO_ADDR(r));
2702 type = qs_get_type_attr(doc, child, r->pool);
2704 ERR(r, "Oops! The input tag without the type attribute has been found.Please give a type.");
2708 if (strcasecmp(type, "radio") != 0)
2711 DBG(r, "REQ[%X] found type=radio",TO_ADDR(r));
2713 rname = qs_get_name_attr (doc, child, r->pool);
2714 rvalue = qs_get_value_attr(doc, child, r->pool);
2717 /*----------------------------------------------------------------------*/
2718 /* Oops!. The input tag without the name attribute has been found. */
2719 /*----------------------------------------------------------------------*/
2720 DBG(r,"REQ[%X] Oops!. The input tag without the name attribute has been found. Please give a name.",TO_ADDR(r));
2724 DBG(r,"REQ[%X] found name attribute",TO_ADDR(r));
2726 /*------------------------------------------------------------------------*/
2727 /* It scans in radio_name_list. When the same value exists, the */
2728 /* value is overwrited. */
2729 /* The value is written in a new area when not is. */
2730 /*------------------------------------------------------------------------*/
2731 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
2732 if (! hdml->radio_name_list[ii]) {
2733 DBG(r,"REQ[%X] new name:[%s]", TO_ADDR(r),rname);
2736 if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2737 DBG(r,"REQ[%X] already registered name:[%s]", TO_ADDR(r),rname);
2741 if (ii == MAX_RADIO_COUNT) {
2742 DBG(r, apr_psprintf(r->pool,
2743 "I do not understand the name of the radiobutton "
2744 "of %d piece or more. Please decrease "
2745 "the number of radiobuttons.",
2750 DBG(r,"REQ[%X] add radio name:[%s]" ,TO_ADDR(r),rname);
2752 hdml->radio_name_list[ii] = apr_pstrdup(r->pool, rname);
2754 /*------------------------------------------------------------------------*/
2755 /* It adds it to radio_value_list. */
2756 /*------------------------------------------------------------------------*/
2757 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) {
2758 if (!hdml->radio_value_list[ii][jj])
2761 if (jj == MAX_RADIO_VALUE_COUNT) {
2762 DBG(r, apr_psprintf(r->pool,
2763 "I do not understand the value of the radiobutton "
2764 "of %d piece or more. Please decrease "
2765 "the number of radiobuttons.",
2766 MAX_RADIO_VALUE_COUNT));
2769 hdml->radio_value_list[ii][jj] = apr_pstrdup(r->pool, rvalue);
2771 /*------------------------------------------------------------------------*/
2772 /* Now let's be the checked attribute or scan. */
2773 /*------------------------------------------------------------------------*/
2774 chkd = qs_get_checked_attr(hdml->doc, child, r->pool);
2776 DBG(r,apr_psprintf(r->pool,
2777 "The tag scanned now had the checked "
2778 "attribute. The value is [%s].",
2780 hdml->radio_checked_value[ii] = apr_pstrdup(r->pool, rvalue);
2787 * The character string is added, and output to the out member of the HDML
2790 * @param hdml [i/o] The pointer to the HDML structure that maintains the out
2791 * member at the output destination is specified.
2792 * @param s [i] The character string that should be output is specified.
2793 * @return The pointer to the HDML structure after it processes it is returned.
2796 s_output_to_hdml_out(hdml_t *hdml, char *s)
2798 hdml->out = qs_out_apr_pstrcat(hdml->doc->r, hdml->out, s, &hdml->out_len);
2805 * The character string is added, and output to the card member of the HDML
2808 * @param hdml [i/o] The pointer to the HDML structure that maintains the
2809 * card member at the output destination is specified.
2810 * @param s [i] The character string that should be output is specified.
2811 * @return The pointer to the HDML structure after it processes it is returned.
2814 s_output_to_hdml_card(hdml_t *hdml, char *s)
2816 hdml->card = qs_out_apr_pstrcat(hdml->doc->r, hdml->card, s, &hdml->card_len);
2824 * The data for the post is added, and output.
2826 * @param hdml [i/o] The pointer to the HDML structure at the output
2827 * destination is specified.
2828 * @param s [i] The character string that wants to output to postdata is
2832 s_output_to_postdata(hdml_t *hdml, char *s)
2834 request_rec *r = hdml->doc->r;
2836 if (strlen(hdml->postdata[hdml->pure_form_cnt])) {
2837 hdml->postdata[hdml->pure_form_cnt] =
2838 apr_pstrcat(r->pool,
2839 hdml->postdata[hdml->pure_form_cnt],
2843 hdml->postdata[hdml->pure_form_cnt] =
2844 apr_pstrcat(r->pool,
2845 hdml->postdata[hdml->pure_form_cnt],
2846 qs_trim_string(r->pool, s),
2849 DBG(r, "REQ[%X] POSTDATA:[%s]", TO_ADDR(r),hdml->postdata[hdml->pure_form_cnt] );
2855 * The tag output upper half.
2857 * @param hdml [i/o] The pointer to the HDML structure at the output
2858 * destination is specified.
2859 * @param node [i] The A tag node is specified.
2862 s_hdml_tag_output_upper_half(hdml_t *hdml, Node *UNUSED(node))
2864 if (hdml->hdml_br_flag == 1 && hdml->div_right_flag == 1) {
2865 s_output_to_hdml_out(hdml, "<RIGHT>");
2866 hdml->hdml_br_flag = 0;
2869 if (hdml->hdml_br_flag == 1
2871 && hdml->in_center == 0) {
2872 s_output_to_hdml_out(hdml, "<CENTER>");
2874 hdml->hdml_br_flag = 0;
2876 else if (hdml->hdml_br_flag == 1
2877 && hdml->div_center_flag > 0
2878 && hdml->div_in_center == 0) {
2879 s_output_to_hdml_out(hdml, "<CENTER>");
2880 hdml->div_in_center++;
2881 hdml->hdml_br_flag = 0;
2888 * The data for the init_vars is added, and output.
2890 * @param hdml [i/o] The pointer to the HDML structure at the output
2891 * destination is specified.
2892 * @param s [i] The character string that wants to output to postdata is
2896 s_output_to_init_vars(hdml_t *hdml, char *s)
2898 request_rec *r = hdml->doc->r;
2900 if (strlen(hdml->init_vars)) {
2901 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, "&", NULL);
2904 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, qs_trim_string(r->pool,s), NULL);
2906 DBG(r,"REQ[%X] INIT_VARS:[%s]",TO_ADDR(r),hdml->init_vars);
2912 s_hdml_chxjif_tag(void *pdoc, Node *node)
2918 hdml = GET_HDML(pdoc);
2921 for (child = qs_get_child_node(doc, node);
2923 child = qs_get_next_node(doc, child)) {
2924 s_output_to_hdml_out(hdml, child->otext);
2925 s_hdml_chxjif_tag(hdml, child);
2932 s_hdml_text_tag(void *pdoc, Node *child)
2942 int one_line_count = 0;
2945 hdml = GET_HDML(pdoc);
2949 textval = qs_get_node_value(doc,child);
2950 if (strlen(textval) == 0) {
2954 if (hdml->option_flag == 1) {
2958 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2959 memset(tmp, 0, qs_get_node_size(doc,child)+1);
2960 tdst = apr_palloc(r->pool, 1);
2966 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2968 int rtn = s_hdml_search_emoji(hdml, &textval[ii], &out);
2970 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2972 one_line_count+=(rtn-1);
2975 if (hdml->hdml_blockquote_flag) {
2976 if (one_line_count == 0) {
2977 tdst = qs_out_apr_pstrcat(r, tdst, "<WRAP> <TAB>", &tdst_len);
2979 if (is_sjis_kanji(textval[ii])) {
2980 one_byte[0] = textval[ii+0];
2981 one_byte[1] = textval[ii+1];
2983 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2988 one_byte[0] = textval[ii+0];
2990 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2992 if (one_byte[0] == '\n') {
2998 if (hdml->pre_flag) {
2999 if (one_line_count == 0) {
3000 tdst = qs_out_apr_pstrcat(r, tdst, "<LINE>", &tdst_len);
3002 if (is_sjis_kanji(textval[ii])) {
3003 one_byte[0] = textval[ii+0];
3004 one_byte[1] = textval[ii+1];
3006 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3011 one_byte[0] = textval[ii+0];
3013 if (one_byte[0] == ' ') {
3014 tdst = qs_out_apr_pstrcat(r, tdst, " ", &tdst_len);
3017 tdst = qs_out_apr_pstrcat(r, tdst, chxj_ap_escape_html(r->pool, one_byte), &tdst_len);
3020 if (one_byte[0] == '\n') {
3026 if (is_sjis_kanji(textval[ii])) {
3027 one_byte[0] = textval[ii+0];
3028 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3029 one_byte[0] = textval[ii+1];
3030 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3034 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3035 one_byte[0] = textval[ii+0];
3036 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3039 memcpy(tmp, textval, strlen(textval)-1);
3041 s_hdml_tag_output_upper_half(hdml, child->parent);
3042 s_output_to_hdml_out(hdml, tdst);
3043 hdml->hdml_br_flag = 0;
3050 * It is a handler who processes the BLOCKQUOTE tag.
3052 * @param pdoc [i/o] The pointer to the HDML structure at the output
3053 * destination is specified.
3054 * @param node [i] The BLOCKQUOTE tag node is specified.
3055 * @return The conversion result is returned.
3058 s_hdml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3060 hdml_t *hdml = GET_HDML(pdoc);
3061 hdml->hdml_blockquote_flag++;
3067 * It is a handler who processes the BLOCKQUOTE tag.
3069 * @param pdoc [i/o] The pointer to the HDML structure at the output
3070 * destination is specified.
3071 * @param node [i] The BLOCKQUOTE tag node is specified.
3072 * @return The conversion result is returned.
3075 s_hdml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3077 hdml_t *hdml = GET_HDML(pdoc);
3078 hdml->hdml_blockquote_flag--;
3079 s_output_to_hdml_out(hdml, "\r\n");
3085 * It is a handler who processes the DIR tag.
3087 * @param pdoc [i/o] The pointer to the HDML structure at the output
3088 * destination is specified.
3089 * @param node [i] The DIR tag node is specified.
3090 * @return The conversion result is returned.
3093 s_hdml_start_dir_tag(void *pdoc, Node *UNUSED(child))
3095 hdml_t *hdml = GET_HDML(pdoc);
3102 * It is a handler who processes the DIR tag.
3104 * @param pdoc [i/o] The pointer to the HDML structure at the output
3105 * destination is specified.
3106 * @param node [i] The DIR tag node is specified.
3107 * @return The conversion result is returned.
3110 s_hdml_end_dir_tag(void *pdoc, Node *UNUSED(child))
3112 hdml_t *hdml = GET_HDML(pdoc);
3119 * It is a handler who processes the DT tag.
3121 * @param pdoc [i/o] The pointer to the HDML structure at the output
3122 * destination is specified.
3123 * @param node [i] The DT tag node is specified.
3124 * @return The conversion result is returned.
3127 s_hdml_start_dt_tag(void *pdoc, Node *UNUSED(child))
3129 hdml_t *hdml = GET_HDML(pdoc);
3130 s_output_to_hdml_out(hdml, "<LINE>");
3136 * It is a handler who processes the DT tag.
3138 * @param pdoc [i/o] The pointer to the HDML structure at the output
3139 * destination is specified.
3140 * @param node [i] The DT tag node is specified.
3141 * @return The conversion result is returned.
3144 s_hdml_end_dt_tag(void *pdoc, Node *UNUSED(child))
3146 hdml_t *hdml = GET_HDML(pdoc);
3147 s_output_to_hdml_out(hdml, "\r\n");
3153 * It is a handler who processes the DD tag.
3155 * @param pdoc [i/o] The pointer to the HDML structure at the output
3156 * destination is specified.
3157 * @param node [i] The DD tag node is specified.
3158 * @return The conversion result is returned.
3161 s_hdml_start_dd_tag(void *pdoc, Node *UNUSED(child))
3163 hdml_t *hdml = GET_HDML(pdoc);
3164 s_output_to_hdml_out(hdml, "<WRAP> <TAB>");
3170 * It is a handler who processes the DD tag.
3172 * @param pdoc [i/o] The pointer to the HDML structure at the output
3173 * destination is specified.
3174 * @param node [i] The DD tag node is specified.
3175 * @return The conversion result is returned.
3178 s_hdml_end_dd_tag(void *pdoc, Node *UNUSED(child))
3180 hdml_t *hdml = GET_HDML(pdoc);
3181 s_output_to_hdml_out(hdml, "\r\n");
3187 * It is a handler who processes the PLAINTEXT tag.
3189 * @param pdoc [i/o] The pointer to the HDML structure at the output
3190 * destination is specified.
3191 * @param node [i] The PLAINTEXT tag node is specified.
3192 * @return The conversion result is returned.
3195 s_hdml_start_plaintext_tag(void *pdoc, Node *node)
3197 hdml_t *hdml = GET_HDML(pdoc);
3198 hdml->plaintext_value_len = 0;
3199 s_hdml_start_plaintext_tag_inner(pdoc,node);
3204 s_hdml_start_plaintext_tag_inner(void *pdoc, Node *node)
3206 hdml_t *hdml = GET_HDML(pdoc);
3207 Doc *doc = hdml->doc;
3209 for (child = qs_get_child_node(doc, node);
3211 child = qs_get_next_node(doc, child)) {
3213 char *str = chxj_ap_escape_html(doc->r->pool, child->otext);
3214 int len = strlen(str);
3216 for (i=0; i<len; i++) {
3217 if (hdml->plaintext_value_len == 0) {
3218 s_output_to_hdml_out(hdml, "<LINE>");
3220 if (is_sjis_kanji(child->otext[i]) && i + 1 < len) {
3221 oneChar[0] = child->otext[i+0];
3222 oneChar[1] = child->otext[i+1];
3224 s_output_to_hdml_out(hdml, oneChar);
3225 hdml->plaintext_value_len +=2;
3229 if (child->otext[i] == '\n') {
3230 hdml->plaintext_value_len = 0;
3233 s_output_to_hdml_out(hdml, oneChar);
3236 oneChar[0] = child->otext[i];
3238 s_output_to_hdml_out(hdml, oneChar);
3239 hdml->plaintext_value_len++;
3241 s_hdml_start_plaintext_tag_inner(pdoc, child);
3248 * It is a handler who processes the PLAINTEXT tag.
3250 * @param pdoc [i/o] The pointer to the HDML structure at the output
3251 * destination is specified.
3252 * @param node [i] The PLAINTEXT tag node is specified.
3253 * @return The conversion result is returned.
3256 s_hdml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3258 hdml_t *hdml = GET_HDML(pdoc);
3264 * It is a handler who processes the PRE tag.
3266 * @param pdoc [i/o] The pointer to the HDML structure at the output
3267 * destination is specified.
3268 * @param node [i] The PRE tag node is specified.
3269 * @return The conversion result is returned.
3272 s_hdml_start_pre_tag(void *pdoc, Node *UNUSED(node))
3278 hdml = GET_HDML(pdoc);
3288 * It is a handler who processes the PRE tag.
3290 * @param pdoc [i/o] The pointer to the HDML structure at the output
3291 * destination is specified.
3292 * @param node [i] The PRE tag node is specified.
3293 * @return The conversion result is returned.
3296 s_hdml_end_pre_tag(void *pdoc, Node *UNUSED(child))
3302 hdml = GET_HDML(pdoc);
3313 * handler of the TEXTAREA tag.
3315 * @param hdml [i/o] The pointer to the HDML structure at the output
3316 * destination is specified.
3317 * @param tag [i] Specified The TEXTAREA tag node.
3320 s_hdml_start_textarea_tag(void *pdoc, Node *node)
3330 hdml_t *hdml = GET_HDML(pdoc);
3335 s_hdml_tag_output_upper_half(hdml, node);
3338 s_output_to_hdml_out(hdml,
3339 apr_psprintf(r->pool,
3340 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
3341 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
3343 s_get_form_no(r, hdml),
3344 hdml->var_cnt[hdml->pure_form_cnt],
3345 s_get_form_no(r, hdml),
3346 hdml->var_cnt[hdml->pure_form_cnt]
3349 s_output_to_hdml_out(hdml,
3350 apr_psprintf(r->pool,
3351 "[$%s%02d]</A>\r\n" ,
3352 s_get_form_no(r, hdml),
3353 hdml->var_cnt[hdml->pure_form_cnt]));
3355 /*--------------------------------------------------------------------------*/
3356 /* ENTRY CARD is output here. */
3357 /*--------------------------------------------------------------------------*/
3358 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
3359 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
3360 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
3366 nm = qs_get_name_attr(doc, node, r->pool);
3368 nm = qs_alloc_zero_byte_string(r->pool);
3371 s_output_to_postdata(hdml,
3372 apr_psprintf(r->pool,
3375 s_get_form_no(r, hdml),
3376 hdml->var_cnt[hdml->pure_form_cnt]));
3378 mlen = qs_get_maxlength_attr (doc, node, r->pool);
3379 is = qs_get_istyle_attr (doc, node, r->pool);
3380 val = s_hdml_inner_textarea_tag_get_value(hdml, node);
3382 fmt = qs_conv_istyle_to_format(r->pool, is);
3385 for (ii=0; ii<strlen(mlen); ii++) {
3386 if (mlen[ii] < '0' || mlen[ii] > '9') {
3387 mlen = apr_psprintf(r->pool, "0");
3391 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
3394 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt));
3398 s_output_to_hdml_card(hdml,
3399 " MARKABLE=FALSE>\r\n"
3400 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
3403 s_output_to_init_vars(hdml,
3404 apr_psprintf(r->pool,
3406 s_get_form_no(r, hdml),
3407 hdml->var_cnt[hdml->pure_form_cnt],
3408 chxj_escape_uri(r->pool,val)));
3411 s_output_to_init_vars(hdml,
3412 apr_psprintf(r->pool,
3414 s_get_form_no(r, hdml),
3415 hdml->var_cnt[hdml->pure_form_cnt]));
3417 hdml->var_cnt[hdml->pure_form_cnt]++;
3422 s_hdml_inner_textarea_tag_get_value(hdml_t *hdml, Node *node)
3424 Doc *doc = hdml->doc;
3426 char *result = apr_pstrdup(doc->r->pool, "\0");
3427 for (child = qs_get_child_node(doc, node);
3429 child = qs_get_next_node(doc, child)) {
3430 char *textval = qs_get_node_value(doc,child);
3431 if (textval && *textval) {
3432 result = apr_pstrcat(doc->r->pool, result, textval, NULL);