2 * Copyright (C) 2005-2009 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,"i found qrcode xml");
433 DBG(r,"not found qrcode xml");
435 /*--------------------------------------------------------------------------*/
436 /* initialize hdml structure */
437 /*--------------------------------------------------------------------------*/
438 s_init_hdml(&hdml,&doc,r, spec);
440 hdml.entryp = entryp;
442 chxj_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
443 /*--------------------------------------------------------------------------*/
445 /*--------------------------------------------------------------------------*/
447 chxj_dump_out("[src] CHTML->HDML", src, srclen);
450 /*--------------------------------------------------------------------------*/
451 /* It is examined whether there is a location header. It ends without doing */
452 /* anything when is. */
453 /*--------------------------------------------------------------------------*/
454 buf = (char *)apr_table_get(r->headers_out, (const char *)"Location");
456 /*------------------------------------------------------------------------*/
457 /* The Location header generates tag in an initial HDML machine for the */
458 /* uncorrespon dence. */
459 /*------------------------------------------------------------------------*/
460 DBG(r, "Location is not null[Location:%s]", buf);
461 s_output_to_hdml_out(&hdml,
462 "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\r\n"
463 "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\r\n"
464 "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
466 s_output_to_hdml_out(&hdml, buf);
467 s_output_to_hdml_out(&hdml,
472 dst = apr_pstrdup(r->pool, hdml.out);
475 /*------------------------------------------------------------------------*/
476 /* Here, the parsing of the received character string is done */
477 /*------------------------------------------------------------------------*/
478 char *ss = apr_palloc(r->pool, srclen + 1);
479 memset(ss, 0, srclen + 1);
480 memcpy(ss, src, srclen);
482 DBG(r, "input strlen(src)=[%d]", (int)srclen);
483 DBG(r, "[[[[%s]]]", src);
485 qs_init_malloc(&doc);
486 qs_init_root_node(&doc);
488 qs_parse_string(&doc, ss, srclen);
490 /*------------------------------------------------------------------------*/
491 /* The number of radiobuttons is counted. */
492 /*------------------------------------------------------------------------*/
493 s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
495 chxj_node_convert(spec,r,(void*)&hdml, &doc, qs_get_root(&doc), 0);
498 DBG(r,"tmp=[%s]", dst);
499 qs_all_free(&doc,QX_LOGMARK);
502 /*--------------------------------------------------------------------------*/
504 /*--------------------------------------------------------------------------*/
506 chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
509 /*--------------------------------------------------------------------------*/
510 /* When there is no processing result, former character string is copied */
511 /* and it returns it. */
512 /*--------------------------------------------------------------------------*/
515 return apr_pstrdup(r->pool,src);
518 *dstlen = hdml.out_len;
520 /*--------------------------------------------------------------------------*/
521 /* Null is set at the end of the character string to make sure. */
522 /*--------------------------------------------------------------------------*/
523 dst[hdml.out_len] = 0;
530 * The HDML structure is initialized.
532 * @param hdml [i/o] The pointer to the HDML structure that wants to be
533 * initialized is specified.
534 * @param doc [i] The Doc structure that should be set to the initialized
535 * HDML structure is specified.
536 * @param r [i] To use POOL, the pointer to request_rec is specified.
537 * @param spec [i] The pointer to the device_table
540 s_init_hdml(hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec)
545 /*--------------------------------------------------------------------------*/
546 /* init hdml structure value */
547 /*--------------------------------------------------------------------------*/
548 memset(hdml, 0, sizeof(hdml_t));
550 hdml->card = qs_alloc_zero_byte_string(r->pool);
552 hdml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
553 hdml->doc->parse_mode = PARSE_MODE_CHTML;
555 for (ii=0; ii<MAX_FORM_COUNT; ii++) {
556 hdml->var_cnt[ii] = 0;
557 hdml->postdata[ii] = qs_alloc_zero_byte_string(r->pool);
560 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
561 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
562 hdml->radio_value_list[ii][jj] = NULL;
564 hdml->radio_name_list[ii] = NULL;
565 hdml->radio_out_cnt[ii] = 0;
566 hdml->radio_checked_value[ii] = NULL;
569 for (ii=0; ii<MAX_SUBMIT_BUTTON_COUNT; ii++)
570 hdml->submit_button[ii] = NULL;
572 hdml->init_vars = qs_alloc_zero_byte_string(r->pool);
576 hdml->form_cnt = apr_time_now();
577 hdml->out = qs_alloc_zero_byte_string(r->pool);
582 s_hdml_search_emoji(hdml_t *hdml, char *txt, char **rslt)
595 DBG(r,"spec is NULL");
598 for (ee = hdml->conf->emoji;
601 unsigned char hex1byte;
602 unsigned char hex2byte;
604 DBG(r, "emoji->imode is NULL");
608 hex1byte = ee->imode->hex1byte & 0xff;
609 hex2byte = ee->imode->hex2byte & 0xff;
611 if (ee->imode->string
612 && strlen(ee->imode->string) > 0
613 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
614 if (spec == NULL || spec->emoji_type == NULL) {
615 *rslt = apr_psprintf(r->pool,
618 return strlen(ee->imode->string);
621 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
622 *rslt = apr_psprintf(r->pool,
625 return strlen(ee->imode->string);
628 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
629 *rslt = apr_psprintf(r->pool,
632 return strlen(ee->imode->string);
635 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
636 *rslt = apr_psprintf(r->pool,
639 return strlen(ee->imode->string);
642 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
643 *rslt = apr_psprintf(r->pool,
646 return strlen(ee->imode->string);
649 *rslt = apr_psprintf(r->pool,
652 return strlen(ee->imode->string);
657 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
658 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
659 if (spec == NULL || spec->emoji_type == NULL) {
660 *rslt = apr_psprintf(r->pool,
666 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
667 *rslt = apr_psprintf(r->pool,
673 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
674 *rslt = apr_psprintf(r->pool,
680 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
681 *rslt = apr_psprintf(r->pool,
687 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
688 *rslt = apr_psprintf(r->pool,
694 *rslt = apr_psprintf(r->pool,
707 * It is a handler who processes the HTML tag.
709 * @param pdoc [i/o] The pointer to the HDML structure at the output
710 * destination is specified.
711 * @param node [i] The HTML tag node is specified.
712 * @return The conversion result is returned.
715 s_hdml_start_html_tag(void *pdoc, Node *UNUSED(node))
717 hdml_t *hdml = GET_HDML(pdoc);
719 s_output_to_hdml_out(hdml,
720 "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\r\n"
721 "<NODISPLAY NAME=D0>\r\n"
722 "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\r\n"
727 hdml->hdml_br_flag = 0;
734 * It is a handler who processes the HTML tag.
736 * @param pdoc [i/o] The pointer to the HDML structure at the output
737 * destination is specified.
738 * @param node [i] The HTML tag node is specified.
739 * @return The conversion result is returned.
742 s_hdml_end_html_tag(void *pdoc, Node *UNUSED(child))
744 hdml_t *hdml = GET_HDML(pdoc);
746 s_output_to_hdml_card(hdml,
747 "<NODISPLAY NAME=D1>\r\n"
748 "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
751 if (strlen(hdml->init_vars)) {
752 s_output_to_hdml_card(hdml, hdml->init_vars );
755 s_output_to_hdml_card(hdml, "_chxj_dmy=" );
758 s_output_to_hdml_card(hdml,
763 s_output_to_hdml_out(hdml, hdml->card );
764 s_output_to_hdml_out(hdml, "</HDML>\r\n");
766 hdml->hdml_end_flag = 1;
773 * It is a handler who processes the META tag.
775 * @param pdoc [i/o] The pointer to the HDML structure at the output
776 * destination is specified.
777 * @param node [i] The META tag node is specified.
778 * @return The conversion result is returned.
781 s_hdml_start_meta_tag(void *pdoc, Node *UNUSED(node))
783 hdml_t *hdml = GET_HDML(pdoc);
785 hdml->hdml_br_flag = 0;
794 * It is a handler who processes the META tag.
796 * @param pdoc [i/o] The pointer to the HDML structure at the output
797 * destination is specified.
798 * @param node [i] The META tag node is specified.
799 * @return The conversion result is returned.
802 s_hdml_end_meta_tag(void *pdoc, Node *UNUSED(child))
804 hdml_t *hdml = GET_HDML(pdoc);
811 * It is a handler who processes the HEAD tag.
813 * @param pdoc [i/o] The pointer to the HDML structure at the output
814 * destination is specified.
815 * @param node [i] The HEAD tag node is specified.
816 * @return The conversion result is returned.
819 s_hdml_start_head_tag(void *pdoc, Node *UNUSED(node))
821 hdml_t *hdml = GET_HDML(pdoc);
825 hdml->hdml_br_flag = 0;
832 * It is a handler who processes the HEAD tag.
834 * @param pdoc [i/o] The pointer to the HDML structure at the output
835 * destination is specified.
836 * @param node [i] The HEAD tag node is specified.
837 * @return The conversion result is returned.
840 s_hdml_end_head_tag(void *pdoc, Node *UNUSED(child))
842 hdml_t *hdml = GET_HDML(pdoc);
851 * It is a handler who processes the TITLE tag.
853 * @param pdoc [i/o] The pointer to the HDML structure at the output
854 * destination is specified.
855 * @param node [i] The TITLE tag node is specified.
856 * @return The conversion result is returned.
859 s_hdml_start_title_tag(void *pdoc, Node *UNUSED(node))
861 hdml_t *hdml = GET_HDML(pdoc);
863 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
865 hdml->found_title = 1;
866 hdml->hdml_br_flag = 0;
873 * It is a handler who processes the TITLE tag.
875 * @param pdoc [i/o] The pointer to the HDML structure at the output
876 * destination is specified.
877 * @param node [i] The TITLE tag node is specified.
878 * @return The conversion result is returned.
881 s_hdml_end_title_tag(void *pdoc, Node *UNUSED(child))
883 hdml_t *hdml = GET_HDML(pdoc);
885 s_output_to_hdml_out(hdml, "\">\r\n");
892 * It is a handler who processes the BASE tag.
894 * @param pdoc [i/o] The pointer to the HDML structure at the output
895 * destination is specified.
896 * @param node [i] The BASE tag node is specified.
897 * @return The conversion result is returned.
900 s_hdml_start_base_tag(void *pdoc, Node *UNUSED(node))
902 hdml_t *hdml = GET_HDML(pdoc);
904 hdml->hdml_br_flag = 0;
911 * It is a handler who processes the BASE tag.
913 * @param pdoc [i/o] The pointer to the HDML structure at the output
914 * destination is specified.
915 * @param node [i] The BASE tag node is specified.
916 * @return The conversion result is returned.
919 s_hdml_end_base_tag(void *pdoc, Node *UNUSED(child))
921 hdml_t *hdml = GET_HDML(pdoc);
928 * It is a handler who processes the BODY tag.
930 * @param pdoc [i/o] The pointer to the HDML structure at the output
931 * destination is specified.
932 * @param node [i] The BODY tag node is specified.
933 * @return The conversion result is returned.
936 s_hdml_start_body_tag(void *pdoc, Node *node)
942 hdml = GET_HDML(pdoc);
946 if (hdml->found_title == 0) {
947 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\r\n");
950 s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
951 /*--------------------------------*/
953 /*--------------------------------*/
954 for (attr = qs_get_attr(doc,node);
956 attr = qs_get_next_attr(doc,attr)) {
957 char *name = qs_get_attr_name(doc,attr);
959 if (STRCASEEQ('b','B',"bgcolor",name)) {
962 else if (STRCASEEQ('t','T',"text",name)) {
965 else if (STRCASEEQ('l','L',"link",name)) {
968 else if (STRCASEEQ('a','A',"alink",name)) {
971 else if (STRCASEEQ('v','V',"vlink",name)) {
975 s_output_to_hdml_out(hdml, ">\r\n");
976 hdml->hdml_br_flag = 0;
982 * It is a handler who processes the BODY tag.
984 * @param pdoc [i/o] The pointer to the HDML structure at the output
985 * destination is specified.
986 * @param node [i] The BODY tag node is specified.
987 * @return The conversion result is returned.
990 s_hdml_end_body_tag(void *pdoc, Node *UNUSED(child))
992 hdml_t *hdml = GET_HDML(pdoc);
994 s_output_to_hdml_out(hdml, "\r\n</DISPLAY>\r\n");
1001 * It is a handler who processes the A tag.
1003 * @param pdoc [i/o] The pointer to the HDML structure at the output
1004 * destination is specified.
1005 * @param node [i] The A tag node is specified.
1006 * @return The conversion result is returned.
1009 s_hdml_start_a_tag(void *pdoc, Node *node)
1015 hdml = GET_HDML(pdoc);
1018 s_hdml_tag_output_upper_half(hdml,node);
1020 s_output_to_hdml_out(hdml, "<A");
1023 /*------------------------------------*/
1024 /* Get Attributes */
1025 /*------------------------------------*/
1026 for (attr = qs_get_attr(doc,node);
1028 attr = qs_get_next_attr(doc,attr)) {
1029 char *name = qs_get_attr_name(doc,attr);
1030 char *value = qs_get_attr_value(doc,attr);
1031 if (STRCASEEQ('n','N',"name",name)) {
1034 else if (STRCASEEQ('h','H',"href",name)) {
1035 if (STRNCASEEQ('m','M',"mailto:",value,sizeof("mailto:")-1)) {
1036 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
1037 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1038 s_output_to_hdml_out(hdml, value );
1039 s_output_to_hdml_out(hdml, "\" " );
1041 else if (STRNCASEEQ('t','T',"tel:",value,sizeof("tel:")-1)) {
1042 s_output_to_hdml_out(hdml, " TASK=CALL NUMBER=\"");
1043 s_output_to_hdml_out(hdml, &value[4] );
1044 s_output_to_hdml_out(hdml, "\" " );
1047 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1048 s_output_to_hdml_out(hdml, value );
1049 s_output_to_hdml_out(hdml, "\"" );
1052 else if (STRCASEEQ('a','A',"accesskey",name) && value && *value) {
1053 if (strcasecmp(value, "0") != 0) {
1054 s_output_to_hdml_out(hdml, " ACCESSKEY=" );
1055 s_output_to_hdml_out(hdml, value );
1056 s_output_to_hdml_out(hdml, "" );
1059 else if (STRCASEEQ('c','C',"cti",name)) {
1062 else if (STRCASEEQ('i','I',"ijam",name)) {
1065 else if (STRCASEEQ('u','U',"utn",name)) {
1068 else if (STRCASEEQ('t','T',"telbook",name)) {
1071 else if (STRCASEEQ('k','K',"kana",name)) {
1074 else if (STRCASEEQ('e','E',"email",name)) {
1077 else if (STRCASEEQ('i','I',"ista",name)) {
1080 else if (STRCASEEQ('i','I',"ilet",name)) {
1083 else if (STRCASEEQ('i','I',"iswf",name)) {
1086 else if (STRCASEEQ('i','I',"irst",name)) {
1090 s_output_to_hdml_out(hdml, ">" );
1092 hdml->hdml_a_flag = 1;
1094 hdml->hdml_br_flag = 0;
1101 * It is a handler who processes the A tag.
1103 * @param pdoc [i/o] The pointer to the HDML structure at the output
1104 * destination is specified.
1105 * @param node [i] The A tag node is specified.
1106 * @return The conversion result is returned.
1109 s_hdml_end_a_tag(void *pdoc, Node *UNUSED(child))
1111 hdml_t *hdml = GET_HDML(pdoc);
1113 s_output_to_hdml_out(hdml, "</A>\r\n");
1115 hdml->hdml_a_flag = 0;
1122 * It is a handler who processes the BR tag.
1124 * @param pdoc [i/o] The pointer to the HDML 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_hdml_start_br_tag(void *pdoc, Node *UNUSED(node))
1132 hdml_t *hdml = GET_HDML(pdoc);
1134 if (hdml->in_center > 0) {
1135 hdml->in_center = 0;
1138 if (hdml->div_in_center > 0) {
1139 hdml->div_in_center = 0;
1142 s_output_to_hdml_out(hdml, "<BR>\r\n");
1143 hdml->hdml_br_flag = 1;
1150 * It is a handler who processes the BR tag.
1152 * @param pdoc [i/o] The pointer to the HDML structure at the output
1153 * destination is specified.
1154 * @param node [i] The BR tag node is specified.
1155 * @return The conversion result is returned.
1158 s_hdml_end_br_tag(void *pdoc, Node *UNUSED(child))
1160 hdml_t *hdml = GET_HDML(pdoc);
1167 * It is a handler who processes the TR tag.
1169 * @param pdoc [i/o] The pointer to the HDML structure at the output
1170 * destination is specified.
1171 * @param node [i] The TR tag node is specified.
1172 * @return The conversion result is returned.
1175 s_hdml_start_tr_tag(void *pdoc, Node *UNUSED(node))
1177 hdml_t *hdml = GET_HDML(pdoc);
1179 if (hdml->in_center > 0) {
1180 hdml->in_center = 0;
1183 if (hdml->div_in_center > 0) {
1184 hdml->div_in_center = 0;
1187 s_output_to_hdml_out(hdml, "<BR>\r\n");
1189 hdml->hdml_br_flag = 1;
1196 * It is a handler who processes the TR tag.
1198 * @param pdoc [i/o] The pointer to the HDML structure at the output
1199 * destination is specified.
1200 * @param node [i] The TR tag node is specified.
1201 * @return The conversion result is returned.
1204 s_hdml_end_tr_tag(void *pdoc, Node *UNUSED(child))
1206 hdml_t *hdml = GET_HDML(pdoc);
1213 * It is a handler who processes the FONT tag.
1215 * @param pdoc [i/o] The pointer to the HDML structure at the output
1216 * destination is specified.
1217 * @param node [i] The FONT tag node is specified.
1218 * @return The conversion result is returned.
1221 s_hdml_start_font_tag(void *pdoc, Node *UNUSED(node))
1223 hdml_t *hdml = GET_HDML(pdoc);
1230 * It is a handler who processes the FONT tag.
1232 * @param pdoc [i/o] The pointer to the HDML structure at the output
1233 * destination is specified.
1234 * @param node [i] The FONT tag node is specified.
1235 * @return The conversion result is returned.
1238 s_hdml_end_font_tag(void *pdoc, Node *UNUSED(child))
1240 hdml_t *hdml = GET_HDML(pdoc);
1247 * It is a handler who processes the FORM tag.
1249 * @param pdoc [i/o] The pointer to the HDML structure at the output
1250 * destination is specified.
1251 * @param node [i] The FORM tag node is specified.
1252 * @return The conversion result is returned.
1255 s_hdml_start_form_tag(void *pdoc, Node *node)
1263 hdml = GET_HDML(pdoc);
1268 hdml->form_tmp = apr_psprintf(r->pool,
1269 "<NODISPLAY NAME=F%d>\r\n",
1270 hdml->pure_form_cnt);
1271 hdml->form_tmp = apr_pstrcat(r->pool,
1273 "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",
1275 /* Get Attributes */
1276 for (attr = qs_get_attr(doc,node);
1278 attr = qs_get_next_attr(doc,attr)) {
1279 char *name = qs_get_attr_name(doc,attr);
1280 char *value = qs_get_attr_value(doc,attr);
1281 if (STRCASEEQ('a','A',"action",name)) {
1282 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
1283 act = apr_psprintf(r->pool, "%s", value);
1289 hdml->form_tmp = apr_pstrcat(r->pool,
1294 hdml->form_tmp = apr_pstrcat(r->pool,
1298 hdml->form_tmp = apr_pstrcat(r->pool,
1303 hdml->hdml_br_flag = 0;
1310 * handler of the form end tag.
1312 * @param pdoc [i/o] The pointer to the HDML structure at the output
1313 * destination is specified.
1314 * @param child [i] unused.
1315 * @return The HDML output result after it edits it is returned.
1318 s_hdml_end_form_tag(void *pdoc, Node *UNUSED(child))
1320 hdml_t *hdml = GET_HDML(pdoc);
1321 request_rec *r = hdml->doc->r;
1323 s_output_to_postdata(hdml, "_chxj_dmy=");
1325 hdml->form_tmp = apr_pstrcat(r->pool,
1327 hdml->postdata[hdml->pure_form_cnt],
1330 hdml->form_tmp = apr_pstrcat(r->pool,
1332 "\" CLEAR=TRUE >\r\n",
1334 hdml->form_tmp = apr_pstrcat(r->pool,
1339 s_output_to_hdml_card(hdml, hdml->form_tmp);
1341 hdml->form_tmp = NULL;
1342 hdml->pure_form_cnt++;
1349 * It is a handler that takes charge of the processing of the input tag.
1351 * @param pdoc [i/o] The pointer to the HDML structure at the output
1352 * destination is specified.
1353 * @param node [i] The tag node to be processed is specified.
1356 s_hdml_start_input_tag(void *pdoc, Node *node)
1358 hdml_t *hdml = GET_HDML(pdoc);
1359 Doc *doc = hdml->doc;
1362 /*--------------------------------------------------------------------------*/
1363 /* The attribute of the input tag is acquired. */
1364 /*--------------------------------------------------------------------------*/
1365 for (attr = qs_get_attr(doc,node);
1367 attr = qs_get_next_attr(doc,attr)) {
1368 char *name = qs_get_attr_name(doc,attr);
1369 char *value = qs_get_attr_value(doc,attr);
1370 if (STRCASEEQ('t','T',"type",name)) {
1371 if (STRCASEEQ('t','T',"text",value)) {
1372 /*--------------------------------------------------------------------*/
1373 /* "input type ='text'" tag is processed. */
1374 /*--------------------------------------------------------------------*/
1375 s_hdml_do_input_text_tag(hdml, node);
1377 else if (STRCASEEQ('p','P',"password",value)) {
1378 /*--------------------------------------------------------------------*/
1379 /* "input type='password'" tag is processed. */
1380 /*--------------------------------------------------------------------*/
1381 s_hdml_do_input_password_tag(hdml, node);
1383 else if (STRCASEEQ('s','S',"submit",value)) {
1384 /*--------------------------------------------------------------------*/
1385 /* "input type='submit'" tag is processed. */
1386 /*--------------------------------------------------------------------*/
1387 s_hdml_do_input_submit_tag(hdml, node);
1389 else if (STRCASEEQ('h','H',"hidden",value)) {
1390 /*--------------------------------------------------------------------*/
1391 /* "input type='hidden'" tag is processed. */
1392 /*--------------------------------------------------------------------*/
1393 s_hdml_do_input_hidden_tag(hdml, node);
1395 else if (STRCASEEQ('r','R',"radio",value)) {
1396 /*--------------------------------------------------------------------*/
1397 /* "input type='radio'" tag is processed. */
1398 /*--------------------------------------------------------------------*/
1399 s_hdml_do_input_radio_tag(hdml, node);
1401 else if (STRCASEEQ('c','C',"checkbox",value)) {
1402 /*--------------------------------------------------------------------*/
1403 /* "input type='checkbox'" tag is processed. */
1404 /*--------------------------------------------------------------------*/
1405 s_hdml_do_input_checkbox_tag(hdml, node);
1407 else if (STRCASEEQ('r','R',"reset",value)) {
1408 /*--------------------------------------------------------------------*/
1409 /* "input type='reset'" tag is processed. */
1410 /*--------------------------------------------------------------------*/
1411 s_hdml_do_input_reset_tag(hdml, node);
1414 else if (STRCASEEQ('n','N',"name",name)) {
1417 else if (STRCASEEQ('v','V',"value",name)) {
1420 else if (STRCASEEQ('s','S',"size",name)) {
1423 else if (STRCASEEQ('m','M',"maxlength",name)) {
1426 else if (STRCASEEQ('c','C',"checked",name)) {
1429 else if (STRCASEEQ('a','A',"accesskey",name)) {
1432 else if (STRCASEEQ('i','I',"istyle",name)) {
1436 hdml->hdml_br_flag = 0;
1443 * The substitution processing of tag "input type = text" is done.
1445 * @param hdml [i/o] The pointer to the HDML structure at the output
1446 * destination is specified.
1447 * @param tag [i] The tag node of input type=text is specified.
1450 s_hdml_do_input_text_tag(hdml_t *hdml, Node *tag)
1464 s_hdml_tag_output_upper_half(hdml, tag);
1467 s_output_to_hdml_out(hdml,
1468 apr_psprintf(r->pool,
1469 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1470 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1472 s_get_form_no(r, hdml),
1473 hdml->var_cnt[hdml->pure_form_cnt],
1474 s_get_form_no(r, hdml),
1475 hdml->var_cnt[hdml->pure_form_cnt]
1478 s_output_to_hdml_out(hdml,
1479 apr_psprintf(r->pool,
1480 "[$%s%02d]</A>\r\n" ,
1481 s_get_form_no(r, hdml),
1482 hdml->var_cnt[hdml->pure_form_cnt]));
1484 /*--------------------------------------------------------------------------*/
1485 /* ENTRY CARD is output here. */
1486 /*--------------------------------------------------------------------------*/
1487 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1488 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1489 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1495 nm = qs_get_name_attr(doc, tag, r->pool);
1497 nm = qs_alloc_zero_byte_string(r->pool);
1500 s_output_to_postdata(hdml,
1501 apr_psprintf(r->pool,
1504 s_get_form_no(r, hdml),
1505 hdml->var_cnt[hdml->pure_form_cnt]));
1507 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1508 is = qs_get_istyle_attr (doc, tag, r->pool);
1509 val = qs_get_value_attr (doc, tag, r->pool);
1511 fmt = qs_conv_istyle_to_format(r->pool, is);
1512 DBG(r,"qs_conv_istyle_to_format end");
1516 for (ii=0; ii<strlen(mlen); ii++) {
1517 if (mlen[ii] < '0' || mlen[ii] > '9') {
1518 mlen = apr_psprintf(r->pool, "0");
1522 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1525 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1528 s_output_to_hdml_card(hdml,
1529 " MARKABLE=FALSE>\r\n"
1530 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1534 s_output_to_init_vars(hdml,
1535 apr_psprintf(r->pool,
1537 s_get_form_no(r, hdml),
1538 hdml->var_cnt[hdml->pure_form_cnt],
1539 chxj_escape_uri(r->pool,val)));
1542 s_output_to_init_vars(hdml,
1543 apr_psprintf(r->pool,
1545 s_get_form_no(r, hdml),
1546 hdml->var_cnt[hdml->pure_form_cnt]));
1548 hdml->var_cnt[hdml->pure_form_cnt]++;
1553 * The substitution processing of tag "input type = password" is done.
1555 * @param hdml [i/o] The pointer to the HDML structure at the output
1556 * destination is specified.
1557 * @param tag [i] The tag node of input type=password is specified.
1560 s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag)
1573 s_hdml_tag_output_upper_half(hdml, tag);
1576 s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1577 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1578 s_output_to_hdml_out(hdml,
1579 apr_psprintf(r->pool,
1580 "VARS=\"V=$%s%02d\" ",
1581 s_get_form_no(r, hdml),
1582 hdml->var_cnt[hdml->pure_form_cnt]));
1584 s_output_to_hdml_out(hdml,
1585 apr_psprintf(r->pool, "RECEIVE=%s%02d>" ,
1586 s_get_form_no(r, hdml),
1587 hdml->var_cnt[hdml->pure_form_cnt]));
1588 s_output_to_hdml_out(hdml,
1589 apr_psprintf(r->pool, "[$%s%02d]</A>\r\n" ,
1590 s_get_form_no(r, hdml),
1591 hdml->var_cnt[hdml->pure_form_cnt]));
1593 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1594 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1595 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1602 nm = qs_get_name_attr(doc, tag, r->pool);
1604 nm = qs_alloc_zero_byte_string(r->pool);
1607 s_output_to_postdata(hdml,
1608 apr_psprintf(r->pool,
1611 s_get_form_no(r, hdml),
1612 hdml->var_cnt[hdml->pure_form_cnt]));
1614 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1615 val = qs_get_value_attr (doc, tag, r->pool);
1616 /*--------------------------------------------------------------------------*/
1617 /* Default is a figure input. */
1618 /*--------------------------------------------------------------------------*/
1619 fmt = apr_psprintf(r->pool, "N");
1621 if (chxj_chk_numeric(mlen) != 0)
1622 mlen = apr_psprintf(r->pool, "0");
1623 s_output_to_hdml_card(hdml,
1624 apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1627 s_output_to_hdml_card(hdml,
1628 apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1630 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1632 s_output_to_hdml_card(hdml,
1633 " MARKABLE=FALSE>\r\n"
1634 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1638 s_output_to_init_vars(hdml,
1639 apr_psprintf(r->pool, "%s%02d=%s",
1640 s_get_form_no(r, hdml),
1641 hdml->var_cnt[hdml->pure_form_cnt],
1642 chxj_escape_uri(r->pool,val)));
1644 s_output_to_init_vars(hdml,
1645 apr_psprintf(r->pool, "%s%02d=",
1646 s_get_form_no(r, hdml),
1647 hdml->var_cnt[hdml->pure_form_cnt]));
1649 hdml->var_cnt[hdml->pure_form_cnt]++;
1654 * The substitution processing of tag "input type = submit" is done.
1656 * @param hdml [i/o] The pointer to the HDML structure at the output
1657 * destination is specified.
1658 * @param tag [i] The tag node of input type=submit is specified.
1661 s_hdml_do_input_submit_tag(hdml_t *hdml, Node *tag)
1663 Doc *doc = hdml->doc;
1664 request_rec *r = doc->r;
1668 s_hdml_tag_output_upper_half(hdml, tag);
1670 s_output_to_hdml_out(hdml,
1671 apr_psprintf(r->pool,
1672 "<A TASK=GO LABEL=OK DEST=#F%d ",
1673 hdml->pure_form_cnt));
1675 /*--------------------------------------------------------------------------*/
1676 /* get name and value attribute */
1677 /*--------------------------------------------------------------------------*/
1678 nm = qs_get_name_attr (doc, tag, r->pool);
1679 val = qs_get_value_attr (doc, tag, r->pool);
1682 s_output_to_hdml_out(hdml,
1683 apr_psprintf(r->pool, "VARS=\"%s=%s\" ",
1685 chxj_escape_uri(r->pool,val)));
1686 if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1687 s_output_to_postdata(hdml,
1688 apr_psprintf(r->pool,"%s%s=$%s",
1689 SUBMIT_BUTTON_PREFIX, nm, nm));
1692 s_output_to_hdml_out(hdml, ">" );
1694 s_output_to_hdml_out(hdml, val);
1696 s_output_to_hdml_out(hdml, "</A>\r\n" );
1701 * The substitution processing of tag "input type = reset" is done.
1703 * @param hdml [i/o] The pointer to the HDML structure at the output
1704 * destination is specified.
1705 * @param tag [i] The tag node of input type=submit is specified.
1708 s_hdml_do_input_reset_tag(hdml_t *hdml, Node *tag)
1710 Doc *doc = hdml->doc;
1711 request_rec *r = doc->r;
1715 s_hdml_tag_output_upper_half(hdml, tag);
1717 s_output_to_hdml_out(hdml,
1718 apr_psprintf(r->pool,
1719 "<A TASK=GO LABEL=OK DEST=#D0>"));
1721 /*--------------------------------------------------------------------------*/
1722 /* get name and value attribute */
1723 /*--------------------------------------------------------------------------*/
1724 nm = qs_get_name_attr (doc, tag, r->pool);
1725 val = qs_get_value_attr (doc, tag, r->pool);
1727 s_output_to_hdml_out(hdml, val);
1729 s_output_to_hdml_out(hdml, "</A>\r\n" );
1734 * The substitution processing of tag "input type = hidden" is done.
1736 * @param hdml [i/o] The pointer to the HDML structure at the output
1737 * destination is specified.
1738 * @param tag [i] The tag node of input type=hidden is specified.
1741 s_hdml_do_input_hidden_tag(hdml_t *hdml, Node *tag)
1743 Doc *doc = hdml->doc;
1744 request_rec *r = doc->r;
1748 /*--------------------------------------------------------------------------*/
1749 /* get name and value attribute */
1750 /*--------------------------------------------------------------------------*/
1751 nm = qs_get_name_attr (doc, tag, r->pool);
1752 val = qs_get_value_attr (doc, tag, r->pool);
1754 s_output_to_postdata(hdml,
1755 apr_psprintf(r->pool,
1758 chxj_escape_uri(r->pool, val)));
1763 * The substitution processing of tag "input type = radio" is done.
1765 * @param hdml [i/o] The pointer to the HDML structure at the output
1766 * destination is specified.
1767 * @param tag [i] The tag node of input type=radio is specified.
1770 s_hdml_do_input_radio_tag(hdml_t *hdml, Node *tag)
1772 Doc *doc = hdml->doc;
1773 request_rec *r = doc->r;
1781 s_hdml_tag_output_upper_half(hdml, tag);
1783 /*--------------------------------------------------------------------------*/
1784 /* get name and value attribute */
1785 /*--------------------------------------------------------------------------*/
1786 nm = qs_get_name_attr (doc, tag, r->pool);
1787 val = qs_get_value_attr (doc, tag, r->pool);
1788 /*--------------------------------------------------------------------------*/
1789 /* The same name is searched out from the list made beforehand. */
1790 /*--------------------------------------------------------------------------*/
1791 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1792 if (! hdml->radio_name_list[ii]) {
1794 DBG(r, "Oops... radio list is null[%d]", ii);
1795 /*----------------------------------------------------------------------*/
1796 /* Processing is ended because it doesn't happen off the fly. */
1797 /*----------------------------------------------------------------------*/
1801 if (strcasecmp(hdml->radio_name_list[ii], nm) == 0)
1804 if (ii == MAX_RADIO_COUNT) {
1806 DBG(r,"Oops... The same name was not in the list. ");
1807 /*------------------------------------------------------------------------*/
1808 /* Processing is ended because it doesn't happen off the fly. */
1809 /*------------------------------------------------------------------------*/
1813 s_output_to_hdml_out(hdml,
1814 apr_psprintf(r->pool,
1817 "DEST=#R%d VARS=\"VAL=%s\" "
1823 if (hdml->radio_out_cnt[ii] == 0) {
1824 s_output_to_hdml_card(hdml,
1825 apr_psprintf(r->pool,
1826 "<NODISPLAY NAME=R%d>\r\n",
1828 s_output_to_hdml_card(hdml,
1829 apr_psprintf(r->pool,
1831 "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1834 kk = hdml->radio_out_cnt[ii];
1835 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
1836 if (! hdml->radio_value_list[ii][jj])
1841 for (jj=0; jj<r_cnt; jj++) {
1842 if (! hdml->radio_value_list[ii][jj])
1846 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1847 if (hdml->radio_out_cnt[ii] == 0)
1848 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1851 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1852 if (hdml->radio_out_cnt[ii] == 0) {
1854 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1856 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1863 s_output_to_hdml_out(hdml,
1864 apr_psprintf(r->pool, "\" >$%s_%02d</A>",
1866 hdml->radio_out_cnt[ii]));
1867 if (! hdml->radio_out_cnt[ii]) {
1868 s_output_to_hdml_card(hdml, "\">\r\n" );
1869 s_output_to_hdml_card(hdml, "</NODISPLAY>\r\n");
1871 s_output_to_postdata(hdml, apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1873 for (jj=0; jj<r_cnt; jj++) {
1874 if (hdml->radio_value_list[ii][jj] && hdml->radio_checked_value[ii]) {
1875 if (strcasecmp(hdml->radio_value_list[ii][jj],
1876 hdml->radio_checked_value[ii]) == 0) {
1877 s_output_to_init_vars(hdml,
1878 apr_psprintf(r->pool,
1884 s_output_to_init_vars(hdml,
1885 apr_psprintf(r->pool,
1892 s_output_to_init_vars(hdml,
1893 apr_psprintf(r->pool,
1900 if (hdml->radio_checked_value[ii]) {
1901 DBG(r,"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,"radio button is not checked. checked value is []");
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, "wrote checkbox hdml card.");
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, "selected value not found");
2406 selval = qs_alloc_zero_byte_string(r->pool);
2409 DBG(r, "selected value found[%s]" , selval);
2411 selvaltxt = qs_get_selected_value_text(doc, node, r->pool);
2413 selvaltxt = qs_alloc_zero_byte_string(r->pool);
2415 DBG(r, "selvaltxt:[%s]" ,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, "txtval:[%s]" , 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,"found input tag");
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, "found type=radio");
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, "Oops!. The input tag without the name attribute has been found. Please give a name.");
2724 DBG(r, "found name attribute");
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, "new name:[%s]", rname);
2736 if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2737 DBG(r, "already registered name:[%s]", 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,"add radio name:[%s]" ,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, "POSTDATA:[%s]", 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, "INIT_VARS:[%s]", 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);