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,
392 * converts from CHTML to hdml.
394 * @param r [i] Requet_rec is appointed.
395 * @param spec [i] The result of the device specification processing which
396 * was done in advance is appointed.
397 * @param src [i] The character string before the converting is appointed.
398 * @return The character string after the converting is returned.
407 chxjconvrule_entry *entryp,
408 cookie_t *UNUSED(cookie)
419 /*--------------------------------------------------------------------------*/
421 /*--------------------------------------------------------------------------*/
423 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
425 DBG(r,"i found qrcode xml");
428 DBG(r,"not found qrcode xml");
430 /*--------------------------------------------------------------------------*/
431 /* initialize hdml structure */
432 /*--------------------------------------------------------------------------*/
433 s_init_hdml(&hdml,&doc,r, spec);
435 hdml.entryp = entryp;
437 chxj_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
438 /*--------------------------------------------------------------------------*/
440 /*--------------------------------------------------------------------------*/
442 chxj_dump_out("[src] CHTML->HDML", src, srclen);
445 /*--------------------------------------------------------------------------*/
446 /* It is examined whether there is a location header. It ends without doing */
447 /* anything when is. */
448 /*--------------------------------------------------------------------------*/
449 buf = (char *)apr_table_get(r->headers_out, (const char *)"Location");
451 /*------------------------------------------------------------------------*/
452 /* The Location header generates tag in an initial HDML machine for the */
453 /* uncorrespon dence. */
454 /*------------------------------------------------------------------------*/
455 DBG(r, "Location is not null[Location:%s]", buf);
456 s_output_to_hdml_out(&hdml,
457 "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\r\n"
458 "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\r\n"
459 "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
461 s_output_to_hdml_out(&hdml, buf);
462 s_output_to_hdml_out(&hdml,
467 dst = apr_pstrdup(r->pool, hdml.out);
470 /*------------------------------------------------------------------------*/
471 /* Here, the parsing of the received character string is done */
472 /*------------------------------------------------------------------------*/
473 char *ss = apr_palloc(r->pool, srclen + 1);
474 memset(ss, 0, srclen + 1);
475 memcpy(ss, src, srclen);
477 DBG(r, "input strlen(src)=[%d]", (int)srclen);
478 DBG(r, "[[[[%s]]]", src);
480 qs_init_malloc(&doc);
481 qs_init_root_node(&doc);
483 qs_parse_string(&doc, ss, srclen);
485 /*------------------------------------------------------------------------*/
486 /* The number of radiobuttons is counted. */
487 /*------------------------------------------------------------------------*/
488 s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
490 chxj_node_convert(spec,r,(void*)&hdml, &doc, qs_get_root(&doc), 0);
493 DBG(r,"tmp=[%s]", dst);
494 qs_all_free(&doc,QX_LOGMARK);
497 /*--------------------------------------------------------------------------*/
499 /*--------------------------------------------------------------------------*/
501 chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
504 /*--------------------------------------------------------------------------*/
505 /* When there is no processing result, former character string is copied */
506 /* and it returns it. */
507 /*--------------------------------------------------------------------------*/
510 return apr_pstrdup(r->pool,src);
513 *dstlen = hdml.out_len;
515 /*--------------------------------------------------------------------------*/
516 /* Null is set at the end of the character string to make sure. */
517 /*--------------------------------------------------------------------------*/
518 dst[hdml.out_len] = 0;
525 * The HDML structure is initialized.
527 * @param hdml [i/o] The pointer to the HDML structure that wants to be
528 * initialized is specified.
529 * @param doc [i] The Doc structure that should be set to the initialized
530 * HDML structure is specified.
531 * @param r [i] To use POOL, the pointer to request_rec is specified.
532 * @param spec [i] The pointer to the device_table
535 s_init_hdml(hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec)
540 /*--------------------------------------------------------------------------*/
541 /* init hdml structure value */
542 /*--------------------------------------------------------------------------*/
543 memset(hdml, 0, sizeof(hdml_t));
545 hdml->card = qs_alloc_zero_byte_string(r->pool);
547 hdml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
548 hdml->doc->parse_mode = PARSE_MODE_CHTML;
550 for (ii=0; ii<MAX_FORM_COUNT; ii++) {
551 hdml->var_cnt[ii] = 0;
552 hdml->postdata[ii] = qs_alloc_zero_byte_string(r->pool);
555 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
556 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
557 hdml->radio_value_list[ii][jj] = NULL;
559 hdml->radio_name_list[ii] = NULL;
560 hdml->radio_out_cnt[ii] = 0;
561 hdml->radio_checked_value[ii] = NULL;
564 for (ii=0; ii<MAX_SUBMIT_BUTTON_COUNT; ii++)
565 hdml->submit_button[ii] = NULL;
567 hdml->init_vars = qs_alloc_zero_byte_string(r->pool);
571 hdml->form_cnt = apr_time_now();
572 hdml->out = qs_alloc_zero_byte_string(r->pool);
577 s_hdml_search_emoji(hdml_t *hdml, char *txt, char **rslt)
590 DBG(r,"spec is NULL");
593 for (ee = hdml->conf->emoji;
596 unsigned char hex1byte;
597 unsigned char hex2byte;
599 DBG(r, "emoji->imode is NULL");
603 hex1byte = ee->imode->hex1byte & 0xff;
604 hex2byte = ee->imode->hex2byte & 0xff;
606 if (ee->imode->string
607 && strlen(ee->imode->string) > 0
608 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
609 if (spec == NULL || spec->emoji_type == NULL) {
610 *rslt = apr_psprintf(r->pool,
613 return strlen(ee->imode->string);
616 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
617 *rslt = apr_psprintf(r->pool,
620 return strlen(ee->imode->string);
623 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
624 *rslt = apr_psprintf(r->pool,
627 return strlen(ee->imode->string);
630 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
631 *rslt = apr_psprintf(r->pool,
634 return strlen(ee->imode->string);
637 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
638 *rslt = apr_psprintf(r->pool,
641 return strlen(ee->imode->string);
644 *rslt = apr_psprintf(r->pool,
647 return strlen(ee->imode->string);
652 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
653 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
654 if (spec == NULL || spec->emoji_type == NULL) {
655 *rslt = apr_psprintf(r->pool,
661 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
662 *rslt = apr_psprintf(r->pool,
668 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
669 *rslt = apr_psprintf(r->pool,
675 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
676 *rslt = apr_psprintf(r->pool,
682 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
683 *rslt = apr_psprintf(r->pool,
689 *rslt = apr_psprintf(r->pool,
702 * It is a handler who processes the HTML tag.
704 * @param pdoc [i/o] The pointer to the HDML structure at the output
705 * destination is specified.
706 * @param node [i] The HTML tag node is specified.
707 * @return The conversion result is returned.
710 s_hdml_start_html_tag(void *pdoc, Node *UNUSED(node))
712 hdml_t *hdml = GET_HDML(pdoc);
714 s_output_to_hdml_out(hdml,
715 "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\r\n"
716 "<NODISPLAY NAME=D0>\r\n"
717 "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\r\n"
722 hdml->hdml_br_flag = 0;
729 * It is a handler who processes the HTML tag.
731 * @param pdoc [i/o] The pointer to the HDML structure at the output
732 * destination is specified.
733 * @param node [i] The HTML tag node is specified.
734 * @return The conversion result is returned.
737 s_hdml_end_html_tag(void *pdoc, Node *UNUSED(child))
739 hdml_t *hdml = GET_HDML(pdoc);
741 s_output_to_hdml_card(hdml,
742 "<NODISPLAY NAME=D1>\r\n"
743 "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
746 if (strlen(hdml->init_vars)) {
747 s_output_to_hdml_card(hdml, hdml->init_vars );
750 s_output_to_hdml_card(hdml, "_chxj_dmy=" );
753 s_output_to_hdml_card(hdml,
758 s_output_to_hdml_out(hdml, hdml->card );
759 s_output_to_hdml_out(hdml, "</HDML>\r\n");
761 hdml->hdml_end_flag = 1;
768 * It is a handler who processes the META tag.
770 * @param pdoc [i/o] The pointer to the HDML structure at the output
771 * destination is specified.
772 * @param node [i] The META tag node is specified.
773 * @return The conversion result is returned.
776 s_hdml_start_meta_tag(void *pdoc, Node *UNUSED(node))
778 hdml_t *hdml = GET_HDML(pdoc);
780 hdml->hdml_br_flag = 0;
789 * It is a handler who processes the META tag.
791 * @param pdoc [i/o] The pointer to the HDML structure at the output
792 * destination is specified.
793 * @param node [i] The META tag node is specified.
794 * @return The conversion result is returned.
797 s_hdml_end_meta_tag(void *pdoc, Node *UNUSED(child))
799 hdml_t *hdml = GET_HDML(pdoc);
806 * It is a handler who processes the HEAD tag.
808 * @param pdoc [i/o] The pointer to the HDML structure at the output
809 * destination is specified.
810 * @param node [i] The HEAD tag node is specified.
811 * @return The conversion result is returned.
814 s_hdml_start_head_tag(void *pdoc, Node *UNUSED(node))
816 hdml_t *hdml = GET_HDML(pdoc);
820 hdml->hdml_br_flag = 0;
827 * It is a handler who processes the HEAD tag.
829 * @param pdoc [i/o] The pointer to the HDML structure at the output
830 * destination is specified.
831 * @param node [i] The HEAD tag node is specified.
832 * @return The conversion result is returned.
835 s_hdml_end_head_tag(void *pdoc, Node *UNUSED(child))
837 hdml_t *hdml = GET_HDML(pdoc);
846 * It is a handler who processes the TITLE tag.
848 * @param pdoc [i/o] The pointer to the HDML structure at the output
849 * destination is specified.
850 * @param node [i] The TITLE tag node is specified.
851 * @return The conversion result is returned.
854 s_hdml_start_title_tag(void *pdoc, Node *UNUSED(node))
856 hdml_t *hdml = GET_HDML(pdoc);
858 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
860 hdml->found_title = 1;
861 hdml->hdml_br_flag = 0;
868 * It is a handler who processes the TITLE tag.
870 * @param pdoc [i/o] The pointer to the HDML structure at the output
871 * destination is specified.
872 * @param node [i] The TITLE tag node is specified.
873 * @return The conversion result is returned.
876 s_hdml_end_title_tag(void *pdoc, Node *UNUSED(child))
878 hdml_t *hdml = GET_HDML(pdoc);
880 s_output_to_hdml_out(hdml, "\">\r\n");
887 * It is a handler who processes the BASE tag.
889 * @param pdoc [i/o] The pointer to the HDML structure at the output
890 * destination is specified.
891 * @param node [i] The BASE tag node is specified.
892 * @return The conversion result is returned.
895 s_hdml_start_base_tag(void *pdoc, Node *UNUSED(node))
897 hdml_t *hdml = GET_HDML(pdoc);
899 hdml->hdml_br_flag = 0;
906 * It is a handler who processes the BASE tag.
908 * @param pdoc [i/o] The pointer to the HDML structure at the output
909 * destination is specified.
910 * @param node [i] The BASE tag node is specified.
911 * @return The conversion result is returned.
914 s_hdml_end_base_tag(void *pdoc, Node *UNUSED(child))
916 hdml_t *hdml = GET_HDML(pdoc);
923 * It is a handler who processes the BODY tag.
925 * @param pdoc [i/o] The pointer to the HDML structure at the output
926 * destination is specified.
927 * @param node [i] The BODY tag node is specified.
928 * @return The conversion result is returned.
931 s_hdml_start_body_tag(void *pdoc, Node *node)
937 hdml = GET_HDML(pdoc);
941 if (hdml->found_title == 0) {
942 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\r\n");
945 s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
946 /*--------------------------------*/
948 /*--------------------------------*/
949 for (attr = qs_get_attr(doc,node);
951 attr = qs_get_next_attr(doc,attr)) {
952 char *name = qs_get_attr_name(doc,attr);
954 if (STRCASEEQ('b','B',"bgcolor",name)) {
957 else if (STRCASEEQ('t','T',"text",name)) {
960 else if (STRCASEEQ('l','L',"link",name)) {
963 else if (STRCASEEQ('a','A',"alink",name)) {
966 else if (STRCASEEQ('v','V',"vlink",name)) {
970 s_output_to_hdml_out(hdml, ">\r\n");
971 hdml->hdml_br_flag = 0;
977 * It is a handler who processes the BODY tag.
979 * @param pdoc [i/o] The pointer to the HDML structure at the output
980 * destination is specified.
981 * @param node [i] The BODY tag node is specified.
982 * @return The conversion result is returned.
985 s_hdml_end_body_tag(void *pdoc, Node *UNUSED(child))
987 hdml_t *hdml = GET_HDML(pdoc);
989 s_output_to_hdml_out(hdml, "\r\n</DISPLAY>\r\n");
996 * It is a handler who processes the A tag.
998 * @param pdoc [i/o] The pointer to the HDML structure at the output
999 * destination is specified.
1000 * @param node [i] The A tag node is specified.
1001 * @return The conversion result is returned.
1004 s_hdml_start_a_tag(void *pdoc, Node *node)
1010 hdml = GET_HDML(pdoc);
1013 s_hdml_tag_output_upper_half(hdml,node);
1015 s_output_to_hdml_out(hdml, "<A");
1018 /*------------------------------------*/
1019 /* Get Attributes */
1020 /*------------------------------------*/
1021 for (attr = qs_get_attr(doc,node);
1023 attr = qs_get_next_attr(doc,attr)) {
1024 char *name = qs_get_attr_name(doc,attr);
1025 char *value = qs_get_attr_value(doc,attr);
1026 if (STRCASEEQ('n','N',"name",name)) {
1029 else if (STRCASEEQ('h','H',"href",name)) {
1030 if (STRNCASEEQ('m','M',"mailto:",value,sizeof("mailto:")-1)) {
1031 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
1032 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1033 s_output_to_hdml_out(hdml, value );
1034 s_output_to_hdml_out(hdml, "\" " );
1036 else if (STRNCASEEQ('t','T',"tel:",value,sizeof("tel:")-1)) {
1037 s_output_to_hdml_out(hdml, " TASK=CALL NUMBER=\"");
1038 s_output_to_hdml_out(hdml, &value[4] );
1039 s_output_to_hdml_out(hdml, "\" " );
1042 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1043 s_output_to_hdml_out(hdml, value );
1044 s_output_to_hdml_out(hdml, "\"" );
1047 else if (STRCASEEQ('a','A',"accesskey",name) && value && *value) {
1048 if (strcasecmp(value, "0") != 0) {
1049 s_output_to_hdml_out(hdml, " ACCESSKEY=" );
1050 s_output_to_hdml_out(hdml, value );
1051 s_output_to_hdml_out(hdml, "" );
1054 else if (STRCASEEQ('c','C',"cti",name)) {
1057 else if (STRCASEEQ('i','I',"ijam",name)) {
1060 else if (STRCASEEQ('u','U',"utn",name)) {
1063 else if (STRCASEEQ('t','T',"telbook",name)) {
1066 else if (STRCASEEQ('k','K',"kana",name)) {
1069 else if (STRCASEEQ('e','E',"email",name)) {
1072 else if (STRCASEEQ('i','I',"ista",name)) {
1075 else if (STRCASEEQ('i','I',"ilet",name)) {
1078 else if (STRCASEEQ('i','I',"iswf",name)) {
1081 else if (STRCASEEQ('i','I',"irst",name)) {
1085 s_output_to_hdml_out(hdml, ">" );
1087 hdml->hdml_a_flag = 1;
1089 hdml->hdml_br_flag = 0;
1096 * It is a handler who processes the A tag.
1098 * @param pdoc [i/o] The pointer to the HDML structure at the output
1099 * destination is specified.
1100 * @param node [i] The A tag node is specified.
1101 * @return The conversion result is returned.
1104 s_hdml_end_a_tag(void *pdoc, Node *UNUSED(child))
1106 hdml_t *hdml = GET_HDML(pdoc);
1108 s_output_to_hdml_out(hdml, "</A>\r\n");
1110 hdml->hdml_a_flag = 0;
1117 * It is a handler who processes the BR tag.
1119 * @param pdoc [i/o] The pointer to the HDML structure at the output
1120 * destination is specified.
1121 * @param node [i] The BR tag node is specified.
1122 * @return The conversion result is returned.
1125 s_hdml_start_br_tag(void *pdoc, Node *UNUSED(node))
1127 hdml_t *hdml = GET_HDML(pdoc);
1129 if (hdml->in_center > 0) {
1130 hdml->in_center = 0;
1133 if (hdml->div_in_center > 0) {
1134 hdml->div_in_center = 0;
1137 s_output_to_hdml_out(hdml, "<BR>\r\n");
1138 hdml->hdml_br_flag = 1;
1145 * It is a handler who processes the BR tag.
1147 * @param pdoc [i/o] The pointer to the HDML structure at the output
1148 * destination is specified.
1149 * @param node [i] The BR tag node is specified.
1150 * @return The conversion result is returned.
1153 s_hdml_end_br_tag(void *pdoc, Node *UNUSED(child))
1155 hdml_t *hdml = GET_HDML(pdoc);
1162 * It is a handler who processes the TR tag.
1164 * @param pdoc [i/o] The pointer to the HDML structure at the output
1165 * destination is specified.
1166 * @param node [i] The TR tag node is specified.
1167 * @return The conversion result is returned.
1170 s_hdml_start_tr_tag(void *pdoc, Node *UNUSED(node))
1172 hdml_t *hdml = GET_HDML(pdoc);
1174 if (hdml->in_center > 0) {
1175 hdml->in_center = 0;
1178 if (hdml->div_in_center > 0) {
1179 hdml->div_in_center = 0;
1182 s_output_to_hdml_out(hdml, "<BR>\r\n");
1184 hdml->hdml_br_flag = 1;
1191 * It is a handler who processes the TR tag.
1193 * @param pdoc [i/o] The pointer to the HDML structure at the output
1194 * destination is specified.
1195 * @param node [i] The TR tag node is specified.
1196 * @return The conversion result is returned.
1199 s_hdml_end_tr_tag(void *pdoc, Node *UNUSED(child))
1201 hdml_t *hdml = GET_HDML(pdoc);
1208 * It is a handler who processes the FONT tag.
1210 * @param pdoc [i/o] The pointer to the HDML structure at the output
1211 * destination is specified.
1212 * @param node [i] The FONT tag node is specified.
1213 * @return The conversion result is returned.
1216 s_hdml_start_font_tag(void *pdoc, Node *UNUSED(node))
1218 hdml_t *hdml = GET_HDML(pdoc);
1225 * It is a handler who processes the FONT tag.
1227 * @param pdoc [i/o] The pointer to the HDML structure at the output
1228 * destination is specified.
1229 * @param node [i] The FONT tag node is specified.
1230 * @return The conversion result is returned.
1233 s_hdml_end_font_tag(void *pdoc, Node *UNUSED(child))
1235 hdml_t *hdml = GET_HDML(pdoc);
1242 * It is a handler who processes the FORM tag.
1244 * @param pdoc [i/o] The pointer to the HDML structure at the output
1245 * destination is specified.
1246 * @param node [i] The FORM tag node is specified.
1247 * @return The conversion result is returned.
1250 s_hdml_start_form_tag(void *pdoc, Node *node)
1258 hdml = GET_HDML(pdoc);
1263 hdml->form_tmp = apr_psprintf(r->pool,
1264 "<NODISPLAY NAME=F%d>\r\n",
1265 hdml->pure_form_cnt);
1266 hdml->form_tmp = apr_pstrcat(r->pool,
1268 "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",
1270 /* Get Attributes */
1271 for (attr = qs_get_attr(doc,node);
1273 attr = qs_get_next_attr(doc,attr)) {
1274 char *name = qs_get_attr_name(doc,attr);
1275 char *value = qs_get_attr_value(doc,attr);
1276 if (STRCASEEQ('a','A',"action",name)) {
1277 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
1278 act = apr_psprintf(r->pool, "%s", value);
1284 hdml->form_tmp = apr_pstrcat(r->pool,
1289 hdml->form_tmp = apr_pstrcat(r->pool,
1293 hdml->form_tmp = apr_pstrcat(r->pool,
1298 hdml->hdml_br_flag = 0;
1305 * handler of the form end tag.
1307 * @param pdoc [i/o] The pointer to the HDML structure at the output
1308 * destination is specified.
1309 * @param child [i] unused.
1310 * @return The HDML output result after it edits it is returned.
1313 s_hdml_end_form_tag(void *pdoc, Node *UNUSED(child))
1315 hdml_t *hdml = GET_HDML(pdoc);
1316 request_rec *r = hdml->doc->r;
1318 s_output_to_postdata(hdml, "_chxj_dmy=");
1320 hdml->form_tmp = apr_pstrcat(r->pool,
1322 hdml->postdata[hdml->pure_form_cnt],
1325 hdml->form_tmp = apr_pstrcat(r->pool,
1327 "\" CLEAR=TRUE >\r\n",
1329 hdml->form_tmp = apr_pstrcat(r->pool,
1334 s_output_to_hdml_card(hdml, hdml->form_tmp);
1336 hdml->form_tmp = NULL;
1337 hdml->pure_form_cnt++;
1344 * It is a handler that takes charge of the processing of the input tag.
1346 * @param pdoc [i/o] The pointer to the HDML structure at the output
1347 * destination is specified.
1348 * @param node [i] The tag node to be processed is specified.
1351 s_hdml_start_input_tag(void *pdoc, Node *node)
1353 hdml_t *hdml = GET_HDML(pdoc);
1354 Doc *doc = hdml->doc;
1357 /*--------------------------------------------------------------------------*/
1358 /* The attribute of the input tag is acquired. */
1359 /*--------------------------------------------------------------------------*/
1360 for (attr = qs_get_attr(doc,node);
1362 attr = qs_get_next_attr(doc,attr)) {
1363 char *name = qs_get_attr_name(doc,attr);
1364 char *value = qs_get_attr_value(doc,attr);
1365 if (STRCASEEQ('t','T',"type",name)) {
1366 if (STRCASEEQ('t','T',"text",value)) {
1367 /*--------------------------------------------------------------------*/
1368 /* "input type ='text'" tag is processed. */
1369 /*--------------------------------------------------------------------*/
1370 s_hdml_do_input_text_tag(hdml, node);
1372 else if (STRCASEEQ('p','P',"password",value)) {
1373 /*--------------------------------------------------------------------*/
1374 /* "input type='password'" tag is processed. */
1375 /*--------------------------------------------------------------------*/
1376 s_hdml_do_input_password_tag(hdml, node);
1378 else if (STRCASEEQ('s','S',"submit",value)) {
1379 /*--------------------------------------------------------------------*/
1380 /* "input type='submit'" tag is processed. */
1381 /*--------------------------------------------------------------------*/
1382 s_hdml_do_input_submit_tag(hdml, node);
1384 else if (STRCASEEQ('h','H',"hidden",value)) {
1385 /*--------------------------------------------------------------------*/
1386 /* "input type='hidden'" tag is processed. */
1387 /*--------------------------------------------------------------------*/
1388 s_hdml_do_input_hidden_tag(hdml, node);
1390 else if (STRCASEEQ('r','R',"radio",value)) {
1391 /*--------------------------------------------------------------------*/
1392 /* "input type='radio'" tag is processed. */
1393 /*--------------------------------------------------------------------*/
1394 s_hdml_do_input_radio_tag(hdml, node);
1396 else if (STRCASEEQ('c','C',"checkbox",value)) {
1397 /*--------------------------------------------------------------------*/
1398 /* "input type='checkbox'" tag is processed. */
1399 /*--------------------------------------------------------------------*/
1400 s_hdml_do_input_checkbox_tag(hdml, node);
1402 else if (STRCASEEQ('r','R',"reset",value)) {
1403 /*--------------------------------------------------------------------*/
1404 /* "input type='reset'" tag is processed. */
1405 /*--------------------------------------------------------------------*/
1406 s_hdml_do_input_reset_tag(hdml, node);
1409 else if (STRCASEEQ('n','N',"name",name)) {
1412 else if (STRCASEEQ('v','V',"value",name)) {
1415 else if (STRCASEEQ('s','S',"size",name)) {
1418 else if (STRCASEEQ('m','M',"maxlength",name)) {
1421 else if (STRCASEEQ('c','C',"checked",name)) {
1424 else if (STRCASEEQ('a','A',"accesskey",name)) {
1427 else if (STRCASEEQ('i','I',"istyle",name)) {
1431 hdml->hdml_br_flag = 0;
1438 * The substitution processing of tag "input type = text" is done.
1440 * @param hdml [i/o] The pointer to the HDML structure at the output
1441 * destination is specified.
1442 * @param tag [i] The tag node of input type=text is specified.
1445 s_hdml_do_input_text_tag(hdml_t *hdml, Node *tag)
1459 s_hdml_tag_output_upper_half(hdml, tag);
1462 s_output_to_hdml_out(hdml,
1463 apr_psprintf(r->pool,
1464 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1465 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1467 s_get_form_no(r, hdml),
1468 hdml->var_cnt[hdml->pure_form_cnt],
1469 s_get_form_no(r, hdml),
1470 hdml->var_cnt[hdml->pure_form_cnt]
1473 s_output_to_hdml_out(hdml,
1474 apr_psprintf(r->pool,
1475 "[$%s%02d]</A>\r\n" ,
1476 s_get_form_no(r, hdml),
1477 hdml->var_cnt[hdml->pure_form_cnt]));
1479 /*--------------------------------------------------------------------------*/
1480 /* ENTRY CARD is output here. */
1481 /*--------------------------------------------------------------------------*/
1482 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1483 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1484 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1490 nm = qs_get_name_attr(doc, tag, r->pool);
1492 nm = qs_alloc_zero_byte_string(r->pool);
1495 s_output_to_postdata(hdml,
1496 apr_psprintf(r->pool,
1499 s_get_form_no(r, hdml),
1500 hdml->var_cnt[hdml->pure_form_cnt]));
1502 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1503 is = qs_get_istyle_attr (doc, tag, r->pool);
1504 val = qs_get_value_attr (doc, tag, r->pool);
1506 fmt = qs_conv_istyle_to_format(r->pool, is);
1507 DBG(r,"qs_conv_istyle_to_format end");
1511 for (ii=0; ii<strlen(mlen); ii++) {
1512 if (mlen[ii] < '0' || mlen[ii] > '9') {
1513 mlen = apr_psprintf(r->pool, "0");
1517 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1520 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1523 s_output_to_hdml_card(hdml,
1524 " MARKABLE=FALSE>\r\n"
1525 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1529 s_output_to_init_vars(hdml,
1530 apr_psprintf(r->pool,
1532 s_get_form_no(r, hdml),
1533 hdml->var_cnt[hdml->pure_form_cnt],
1534 chxj_escape_uri(r->pool,val)));
1537 s_output_to_init_vars(hdml,
1538 apr_psprintf(r->pool,
1540 s_get_form_no(r, hdml),
1541 hdml->var_cnt[hdml->pure_form_cnt]));
1543 hdml->var_cnt[hdml->pure_form_cnt]++;
1548 * The substitution processing of tag "input type = password" is done.
1550 * @param hdml [i/o] The pointer to the HDML structure at the output
1551 * destination is specified.
1552 * @param tag [i] The tag node of input type=password is specified.
1555 s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag)
1568 s_hdml_tag_output_upper_half(hdml, tag);
1571 s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1572 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1573 s_output_to_hdml_out(hdml,
1574 apr_psprintf(r->pool,
1575 "VARS=\"V=$%s%02d\" ",
1576 s_get_form_no(r, hdml),
1577 hdml->var_cnt[hdml->pure_form_cnt]));
1579 s_output_to_hdml_out(hdml,
1580 apr_psprintf(r->pool, "RECEIVE=%s%02d>" ,
1581 s_get_form_no(r, hdml),
1582 hdml->var_cnt[hdml->pure_form_cnt]));
1583 s_output_to_hdml_out(hdml,
1584 apr_psprintf(r->pool, "[$%s%02d]</A>\r\n" ,
1585 s_get_form_no(r, hdml),
1586 hdml->var_cnt[hdml->pure_form_cnt]));
1588 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1589 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1590 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1597 nm = qs_get_name_attr(doc, tag, r->pool);
1599 nm = qs_alloc_zero_byte_string(r->pool);
1602 s_output_to_postdata(hdml,
1603 apr_psprintf(r->pool,
1606 s_get_form_no(r, hdml),
1607 hdml->var_cnt[hdml->pure_form_cnt]));
1609 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1610 val = qs_get_value_attr (doc, tag, r->pool);
1611 /*--------------------------------------------------------------------------*/
1612 /* Default is a figure input. */
1613 /*--------------------------------------------------------------------------*/
1614 fmt = apr_psprintf(r->pool, "N");
1616 if (chxj_chk_numeric(mlen) != 0)
1617 mlen = apr_psprintf(r->pool, "0");
1618 s_output_to_hdml_card(hdml,
1619 apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1622 s_output_to_hdml_card(hdml,
1623 apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1625 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1627 s_output_to_hdml_card(hdml,
1628 " MARKABLE=FALSE>\r\n"
1629 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1633 s_output_to_init_vars(hdml,
1634 apr_psprintf(r->pool, "%s%02d=%s",
1635 s_get_form_no(r, hdml),
1636 hdml->var_cnt[hdml->pure_form_cnt],
1637 chxj_escape_uri(r->pool,val)));
1639 s_output_to_init_vars(hdml,
1640 apr_psprintf(r->pool, "%s%02d=",
1641 s_get_form_no(r, hdml),
1642 hdml->var_cnt[hdml->pure_form_cnt]));
1644 hdml->var_cnt[hdml->pure_form_cnt]++;
1649 * The substitution processing of tag "input type = submit" is done.
1651 * @param hdml [i/o] The pointer to the HDML structure at the output
1652 * destination is specified.
1653 * @param tag [i] The tag node of input type=submit is specified.
1656 s_hdml_do_input_submit_tag(hdml_t *hdml, Node *tag)
1658 Doc *doc = hdml->doc;
1659 request_rec *r = doc->r;
1663 s_hdml_tag_output_upper_half(hdml, tag);
1665 s_output_to_hdml_out(hdml,
1666 apr_psprintf(r->pool,
1667 "<A TASK=GO LABEL=OK DEST=#F%d ",
1668 hdml->pure_form_cnt));
1670 /*--------------------------------------------------------------------------*/
1671 /* get name and value attribute */
1672 /*--------------------------------------------------------------------------*/
1673 nm = qs_get_name_attr (doc, tag, r->pool);
1674 val = qs_get_value_attr (doc, tag, r->pool);
1677 s_output_to_hdml_out(hdml,
1678 apr_psprintf(r->pool, "VARS=\"%s=%s\" ",
1680 chxj_escape_uri(r->pool,val)));
1681 if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1682 s_output_to_postdata(hdml,
1683 apr_psprintf(r->pool,"%s%s=$%s",
1684 SUBMIT_BUTTON_PREFIX, nm, nm));
1687 s_output_to_hdml_out(hdml, ">" );
1689 s_output_to_hdml_out(hdml, val);
1691 s_output_to_hdml_out(hdml, "</A>\r\n" );
1696 * The substitution processing of tag "input type = reset" is done.
1698 * @param hdml [i/o] The pointer to the HDML structure at the output
1699 * destination is specified.
1700 * @param tag [i] The tag node of input type=submit is specified.
1703 s_hdml_do_input_reset_tag(hdml_t *hdml, Node *tag)
1705 Doc *doc = hdml->doc;
1706 request_rec *r = doc->r;
1710 s_hdml_tag_output_upper_half(hdml, tag);
1712 s_output_to_hdml_out(hdml,
1713 apr_psprintf(r->pool,
1714 "<A TASK=GO LABEL=OK DEST=#D0>"));
1716 /*--------------------------------------------------------------------------*/
1717 /* get name and value attribute */
1718 /*--------------------------------------------------------------------------*/
1719 nm = qs_get_name_attr (doc, tag, r->pool);
1720 val = qs_get_value_attr (doc, tag, r->pool);
1722 s_output_to_hdml_out(hdml, val);
1724 s_output_to_hdml_out(hdml, "</A>\r\n" );
1729 * The substitution processing of tag "input type = hidden" is done.
1731 * @param hdml [i/o] The pointer to the HDML structure at the output
1732 * destination is specified.
1733 * @param tag [i] The tag node of input type=hidden is specified.
1736 s_hdml_do_input_hidden_tag(hdml_t *hdml, Node *tag)
1738 Doc *doc = hdml->doc;
1739 request_rec *r = doc->r;
1743 /*--------------------------------------------------------------------------*/
1744 /* get name and value attribute */
1745 /*--------------------------------------------------------------------------*/
1746 nm = qs_get_name_attr (doc, tag, r->pool);
1747 val = qs_get_value_attr (doc, tag, r->pool);
1749 s_output_to_postdata(hdml,
1750 apr_psprintf(r->pool,
1753 chxj_escape_uri(r->pool, val)));
1758 * The substitution processing of tag "input type = radio" is done.
1760 * @param hdml [i/o] The pointer to the HDML structure at the output
1761 * destination is specified.
1762 * @param tag [i] The tag node of input type=radio is specified.
1765 s_hdml_do_input_radio_tag(hdml_t *hdml, Node *tag)
1767 Doc *doc = hdml->doc;
1768 request_rec *r = doc->r;
1776 s_hdml_tag_output_upper_half(hdml, tag);
1778 /*--------------------------------------------------------------------------*/
1779 /* get name and value attribute */
1780 /*--------------------------------------------------------------------------*/
1781 nm = qs_get_name_attr (doc, tag, r->pool);
1782 val = qs_get_value_attr (doc, tag, r->pool);
1783 /*--------------------------------------------------------------------------*/
1784 /* The same name is searched out from the list made beforehand. */
1785 /*--------------------------------------------------------------------------*/
1786 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1787 if (! hdml->radio_name_list[ii]) {
1789 DBG(r, "Oops... radio list is null[%d]", ii);
1790 /*----------------------------------------------------------------------*/
1791 /* Processing is ended because it doesn't happen off the fly. */
1792 /*----------------------------------------------------------------------*/
1796 if (strcasecmp(hdml->radio_name_list[ii], nm) == 0)
1799 if (ii == MAX_RADIO_COUNT) {
1801 DBG(r,"Oops... The same name was not in the list. ");
1802 /*------------------------------------------------------------------------*/
1803 /* Processing is ended because it doesn't happen off the fly. */
1804 /*------------------------------------------------------------------------*/
1808 s_output_to_hdml_out(hdml,
1809 apr_psprintf(r->pool,
1812 "DEST=#R%d VARS=\"VAL=%s\" "
1818 if (hdml->radio_out_cnt[ii] == 0) {
1819 s_output_to_hdml_card(hdml,
1820 apr_psprintf(r->pool,
1821 "<NODISPLAY NAME=R%d>\r\n",
1823 s_output_to_hdml_card(hdml,
1824 apr_psprintf(r->pool,
1826 "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1829 kk = hdml->radio_out_cnt[ii];
1830 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
1831 if (! hdml->radio_value_list[ii][jj])
1836 for (jj=0; jj<r_cnt; jj++) {
1837 if (! hdml->radio_value_list[ii][jj])
1841 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1842 if (hdml->radio_out_cnt[ii] == 0)
1843 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1846 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1847 if (hdml->radio_out_cnt[ii] == 0) {
1849 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1851 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1858 s_output_to_hdml_out(hdml,
1859 apr_psprintf(r->pool, "\" >$%s_%02d</A>",
1861 hdml->radio_out_cnt[ii]));
1862 if (! hdml->radio_out_cnt[ii]) {
1863 s_output_to_hdml_card(hdml, "\">\r\n" );
1864 s_output_to_hdml_card(hdml, "</NODISPLAY>\r\n");
1866 s_output_to_postdata(hdml, apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1868 for (jj=0; jj<r_cnt; jj++) {
1869 if (hdml->radio_value_list[ii][jj] && hdml->radio_checked_value[ii]) {
1870 if (strcasecmp(hdml->radio_value_list[ii][jj],
1871 hdml->radio_checked_value[ii]) == 0) {
1872 s_output_to_init_vars(hdml,
1873 apr_psprintf(r->pool,
1879 s_output_to_init_vars(hdml,
1880 apr_psprintf(r->pool,
1887 s_output_to_init_vars(hdml,
1888 apr_psprintf(r->pool,
1895 if (hdml->radio_checked_value[ii]) {
1896 DBG(r,"radio button is checked. checked value is [%s]",
1897 hdml->radio_checked_value[ii]);
1898 s_output_to_init_vars(hdml,
1899 apr_psprintf(r->pool,
1902 hdml->radio_checked_value[ii]));
1905 DBG(r,"radio button is not checked. checked value is []");
1906 s_output_to_init_vars(hdml,
1907 apr_psprintf(r->pool,
1912 hdml->radio_out_cnt[ii]++;
1917 * The substitution processing of tag "input type = checkbox" is done.
1919 * @param hdml [i/o] The pointer to the HDML structure at the output
1920 * destination is specified.
1921 * @param tag [i] The tag node of input type=checkbox is specified.
1924 s_hdml_do_input_checkbox_tag(hdml_t *hdml, Node *tag)
1926 Doc *doc = hdml->doc;
1927 request_rec *r = doc->r;
1932 /*--------------------------------------------------------------------------*/
1933 /* It is posted to the one without the checked attribute. */
1934 /* However, they were able to be removed with INPUT FILTER. */
1935 /*--------------------------------------------------------------------------*/
1936 if (! hdml->has_checkbox) {
1937 hdml->has_checkbox++;
1938 s_output_to_hdml_card(hdml,
1939 "<NODISPLAY NAME=\"_chk\">\r\n"
1940 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1941 "RETVALS=\"_uchk;$V;X\" >\r\n"
1943 "<NODISPLAY NAME=\"_uchk\">\r\n"
1944 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1945 "RETVALS=\"_chk;;_\" >\r\n"
1948 DBG(r, "wrote checkbox hdml card.");
1951 /*--------------------------------------------------------------------------*/
1952 /* It is examined whether it is CHECKED. */
1953 /*--------------------------------------------------------------------------*/
1954 chk = qs_is_checked_checkbox_attr(doc, tag, r->pool);
1956 /*--------------------------------------------------------------------------*/
1957 /* The value of the name attribute and the value attribute is acquired */
1959 /*--------------------------------------------------------------------------*/
1960 val = qs_get_value_attr(doc, tag, r->pool);
1961 nm = qs_get_name_attr(doc, tag, r->pool);
1964 val = qs_alloc_zero_byte_string(r->pool);
1968 nm = qs_alloc_zero_byte_string(r->pool);
1971 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
1972 "<A TASK=GOSUB LABEL=\"check\" "
1973 "DEST=\"#$%s%02d\" "
1975 "RECEIVE=\"%s%02d;%s%02d;%s%02d\">"
1977 s_get_form_no(r, hdml),
1978 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1980 s_get_form_no(r, hdml),
1981 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1982 s_get_form_no(r, hdml),
1983 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1984 s_get_form_no(r, hdml),
1985 hdml->var_cnt[hdml->pure_form_cnt] + 2,
1986 s_get_form_no(r, hdml),
1987 hdml->var_cnt[hdml->pure_form_cnt] + 2));
1989 s_output_to_init_vars(hdml,
1990 apr_psprintf(r->pool,
1991 "%s%02d=_uchk&%s%02d=%s&%s%02d=X",
1992 s_get_form_no(r, hdml),
1993 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1994 s_get_form_no(r, hdml),
1995 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1996 chxj_escape_uri(r->pool,val),
1997 s_get_form_no(r, hdml),
1998 hdml->var_cnt[hdml->pure_form_cnt] + 2
2002 s_output_to_init_vars(hdml,
2003 apr_psprintf(r->pool,
2004 "%s%02d=_chk&%s%02d=&%s%02d=_",
2005 s_get_form_no(r, hdml),
2006 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2007 s_get_form_no(r, hdml),
2008 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2009 s_get_form_no(r, hdml),
2010 hdml->var_cnt[hdml->pure_form_cnt] + 2
2014 s_output_to_postdata(hdml,
2015 apr_psprintf(r->pool, "%s%s=$%s%02d",
2018 s_get_form_no(r, hdml),
2019 hdml->var_cnt[hdml->pure_form_cnt] + 1));
2021 hdml->var_cnt[hdml->pure_form_cnt] += 3;
2026 * The ISTYLE attribute is converted into the HDML form.
2028 * @param r [i] To use POOL, the pointer to request_rec is specified.
2029 * @param is [i] The value of the ISTYLE attribute is specified.
2030 * @return The ISTYLE attribute converted into the HDML form is returned.
2033 qs_conv_istyle_to_format(apr_pool_t *p, char *is)
2042 fmt = apr_psprintf(p, "M");
2045 fmt = apr_psprintf(p, "M");
2048 fmt = apr_psprintf(p, "m");
2051 fmt = apr_psprintf(p, "N");
2054 return apr_pstrdup(p, "M");
2062 * It is a handler who processes the INPUT tag.
2064 * @param pdoc [i/o] The pointer to the HDML structure at the output
2065 * destination is specified.
2066 * @param node [i] The INPUT tag node is specified.
2067 * @return The conversion result is returned.
2070 s_hdml_end_input_tag(void *pdoc, Node *UNUSED(child))
2072 hdml_t *hdml = GET_HDML(pdoc);
2079 * It is a handler who processes the CENTER tag.
2081 * @param pdoc [i/o] The pointer to the HDML structure at the output
2082 * destination is specified.
2083 * @param node [i] The CENTER tag node is specified.
2084 * @return The conversion result is returned.
2087 s_hdml_start_center_tag(void *pdoc, Node *UNUSED(node))
2089 hdml_t *hdml = GET_HDML(pdoc);
2094 if (hdml->hdml_br_flag == 0) {
2095 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2098 hdml = s_output_to_hdml_out(hdml, "<CENTER>");
2105 * It is a handler who processes the CENTER tag.
2107 * @param pdoc [i/o] The pointer to the HDML structure at the output
2108 * destination is specified.
2109 * @param node [i] The CENTER tag node is specified.
2110 * @return The conversion result is returned.
2113 s_hdml_end_center_tag(void *pdoc, Node *UNUSED(child))
2115 hdml_t *hdml = GET_HDML(pdoc);
2118 hdml->in_center = 0;
2120 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2121 hdml->hdml_br_flag = 1;
2128 * It is a handler who processes the HR tag.
2130 * @param pdoc [i/o] The pointer to the HDML structure at the output
2131 * destination is specified.
2132 * @param node [i] The HR tag node is specified.
2133 * @return The conversion result is returned.
2136 s_hdml_start_hr_tag(void *pdoc, Node *UNUSED(node))
2138 hdml_t *hdml = GET_HDML(pdoc);
2140 if (hdml->hdml_br_flag == 0) {
2141 s_output_to_hdml_out(hdml, "<BR>\r\n");
2142 if (hdml->in_center)
2145 if (hdml->div_in_center)
2146 hdml->div_in_center--;
2149 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");
2151 hdml->hdml_br_flag = 1;
2158 * It is a handler who processes the HR tag.
2160 * @param pdoc [i/o] The pointer to the HDML structure at the output
2161 * destination is specified.
2162 * @param node [i] The HR tag node is specified.
2163 * @return The conversion result is returned.
2166 s_hdml_end_hr_tag(void *pdoc, Node *UNUSED(child))
2168 hdml_t *hdml = GET_HDML(pdoc);
2175 * It is a handler who processes the LI tag.
2177 * @param pdoc [i/o] The pointer to the HDML structure at the output
2178 * destination is specified.
2179 * @param node [i] The LI tag node is specified.
2180 * @return The conversion result is returned.
2183 s_hdml_start_li_tag(void *pdoc, Node *UNUSED(node))
2185 hdml_t *hdml = GET_HDML(pdoc);
2188 if (hdml->hdml_br_flag == 0) {
2189 s_output_to_hdml_out(hdml, "<BR>\r\n");
2190 if (hdml->in_center)
2193 if (hdml->div_in_center)
2194 hdml->div_in_center--;
2196 s_output_to_hdml_out(hdml, "<WRAP>");
2197 for (i=0; i<hdml->dir_level; i++) {
2198 s_output_to_hdml_out(hdml, " ");
2200 hdml->hdml_br_flag = 1;
2206 * It is a handler who processes the LI tag.
2208 * @param pdoc [i/o] The pointer to the HDML structure at the output
2209 * destination is specified.
2210 * @param node [i] The LI tag node is specified.
2211 * @return The conversion result is returned.
2214 s_hdml_end_li_tag(void *pdoc, Node *UNUSED(child))
2216 hdml_t *hdml = GET_HDML(pdoc);
2217 if (hdml->hdml_br_flag == 0) {
2218 s_output_to_hdml_out(hdml, "<BR>\r\n");
2219 if (hdml->in_center)
2222 if (hdml->div_in_center)
2223 hdml->div_in_center--;
2225 hdml->hdml_br_flag = 1;
2231 * It is a handler who processes the IMG tag.
2233 * @param pdoc [i/o] The pointer to the HDML structure at the output
2234 * destination is specified.
2235 * @param node [i] The IMG tag node is specified.
2236 * @return The conversion result is returned.
2239 s_hdml_start_img_tag(void *pdoc, Node *node)
2243 #ifndef IMG_NOT_CONVERT_FILENAME
2250 hdml = GET_HDML(pdoc);
2252 #ifndef IMG_NOT_CONVERT_FILENAME
2256 s_hdml_tag_output_upper_half(hdml, node);
2258 out = apr_palloc(doc->r->pool, 1);
2260 out = apr_pstrcat(doc->r->pool, out, "<img", NULL);
2262 /* Get Attributes */
2263 for (attr = qs_get_attr(doc,node);
2265 attr = qs_get_next_attr(doc,attr)) {
2266 char *name = qs_get_attr_name(doc,attr);
2267 char *value = qs_get_attr_value(doc,attr);
2268 if (STRCASEEQ('s','S',"src",name) && value && *value) {
2269 value = chxj_encoding_parameter(hdml->doc->r, value, 0);
2270 out = apr_pstrcat(doc->r->pool, out, " src=\"", NULL);
2271 #ifdef IMG_NOT_CONVERT_FILENAME
2272 out = apr_pstrcat(doc->r->pool, out, value, NULL);
2274 out = apr_pstrcat(doc->r->pool, out, chxj_img_conv(doc->r, spec,value), NULL);
2276 out = apr_pstrcat(doc->r->pool, out, "\"", NULL);
2278 else if (STRCASEEQ('a','A',"align",name)) {
2280 if (STRCASEEQ('r','R',"right", value)) {
2281 s_output_to_hdml_out(hdml, "<RIGHT>" );
2284 else if (STRCASEEQ('c','C',"center",value)) {
2285 s_output_to_hdml_out(hdml, "<CENTER>" );
2290 else if (STRCASEEQ('w','W',"width",name)) {
2293 else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2296 else if (STRCASEEQ('h','H',"hspace", name) && value && *value) {
2299 else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2302 else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2303 out = apr_pstrcat(doc->r->pool, out, " alt=\"", NULL);
2304 out = apr_pstrcat(doc->r->pool, out, value, NULL);
2305 out = apr_pstrcat(doc->r->pool, out, "\"", NULL);
2308 out = apr_pstrcat(doc->r->pool, out, ">", NULL);
2309 s_output_to_hdml_out(hdml, out);
2311 s_output_to_hdml_out(hdml, "<BR>");
2314 hdml->hdml_br_flag = 0;
2321 * It is a handler who processes the IMG tag.
2323 * @param pdoc [i/o] The pointer to the HDML structure at the output
2324 * destination is specified.
2325 * @param node [i] The IMG tag node is specified.
2326 * @return The conversion result is returned.
2329 s_hdml_end_img_tag(void *pdoc, Node *UNUSED(child))
2331 hdml_t *hdml = GET_HDML(pdoc);
2337 * It is a handler who processes the SELECT tag.
2339 * @param pdoc [i/o] The pointer to the HDML structure at the output
2340 * destination is specified.
2341 * @param node [i] The SELECT tag node is specified.
2342 * @return The conversion result is returned.
2345 s_hdml_start_select_tag(void *pdoc, Node *node)
2352 hdml = GET_HDML(pdoc);
2356 s_hdml_tag_output_upper_half(hdml, node);
2360 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2361 "<A TASK=GOSUB LABEL=\x91\x49\x91\xf0 "
2362 "VARS=\"V=$%s%02d\" DEST=#D%d "
2363 "RECEIVE=\"%s%02d;%s%02d\">"
2365 s_get_form_no(r, hdml),
2366 hdml->var_cnt[hdml->pure_form_cnt]+0,
2368 s_get_form_no(r, hdml),
2369 hdml->var_cnt[hdml->pure_form_cnt]+0,
2370 s_get_form_no(r, hdml),
2371 hdml->var_cnt[hdml->pure_form_cnt]+1,
2372 s_get_form_no(r, hdml),
2373 hdml->var_cnt[hdml->pure_form_cnt]+1));
2375 s_output_to_hdml_card(hdml,
2376 apr_psprintf(r->pool,
2377 "<CHOICE KEY=V NAME=D%d ", hdml->card_cnt));
2378 s_output_to_hdml_card(hdml,
2379 apr_psprintf(r->pool,
2380 "DEFAULT=$V METHOD=ALPHA MARKABLE=FALSE>\r\n"));
2381 /*--------------------------------------------------------------------------*/
2382 /* Get Attributes */
2383 /*--------------------------------------------------------------------------*/
2384 for (attr = qs_get_attr(doc,node);
2386 attr=qs_get_next_attr(doc,attr)) {
2387 char *name = qs_get_attr_name(doc,attr);
2388 char *value = qs_get_attr_value(doc,attr);
2389 char *selval = NULL;
2390 char *selvaltxt = NULL;
2392 if (STRCASEEQ('n','N',"name",name)) {
2393 s_output_to_postdata(hdml,
2394 apr_psprintf(r->pool, "%s=$%s%02d",
2396 s_get_form_no(r, hdml),
2397 hdml->var_cnt[hdml->pure_form_cnt]));
2398 selval = qs_get_selected_value(doc, node, r->pool);
2400 DBG(r, "selected value not found");
2401 selval = qs_alloc_zero_byte_string(r->pool);
2404 DBG(r, "selected value found[%s]" , selval);
2406 selvaltxt = qs_get_selected_value_text(doc, node, r->pool);
2408 selvaltxt = qs_alloc_zero_byte_string(r->pool);
2410 DBG(r, "selvaltxt:[%s]" ,selvaltxt);
2412 s_output_to_init_vars(hdml,
2413 apr_psprintf(r->pool,
2414 "%s%02d=%s&%s%02d=%s",
2415 s_get_form_no(r, hdml),
2416 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2418 s_get_form_no(r, hdml),
2419 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2422 hdml->var_cnt[hdml->pure_form_cnt] += 2;
2426 hdml->hdml_br_flag = 0;
2432 * It is a handler who processes the SELECT tag.
2434 * @param pdoc [i/o] The pointer to the HDML structure at the output
2435 * destination is specified.
2436 * @param node [i] The SELECT tag node is specified.
2437 * @return The conversion result is returned.
2440 s_hdml_end_select_tag(void *pdoc, Node *UNUSED(node))
2442 hdml_t *hdml = GET_HDML(pdoc);
2444 s_output_to_hdml_card(hdml, "</CHOICE>\r\n");
2451 * It is a handler who processes the OPTION tag.
2453 * @param pdoc [i/o] The pointer to the HDML structure at the output
2454 * destination is specified.
2455 * @param node [i] The OPTION tag node is specified.
2456 * @return The conversion result is returned.
2459 s_hdml_start_option_tag(void *pdoc, Node *node)
2468 hdml = GET_HDML(pdoc);
2474 hdml->option_flag = 1;
2475 val = qs_get_value_attr(doc, node, r->pool);
2477 /*--------------------------------------------------------------------------*/
2478 /* The child node of the object tag node acquires the value in assumption */
2479 /* that is the TEXT node. */
2480 /*--------------------------------------------------------------------------*/
2481 child = qs_get_child_node(doc, node);
2483 txtval = apr_palloc(r->pool, 1);
2487 txtval = qs_get_node_value(doc, child);
2490 DBG(r, "txtval:[%s]" , txtval);
2492 if (val && txtval) {
2493 s_output_to_hdml_card(hdml,
2494 apr_psprintf(r->pool,
2495 "<CE TASK=RETURN VALUE=\"%s\" "
2496 "RETVALS=\"$V;%s\">%s</CE>\r\n",
2498 qs_trim_string(r->pool,txtval),
2499 qs_trim_string(r->pool,txtval)));
2502 hdml->hdml_br_flag = 0;
2509 * It is a handler who processes the OPTION tag.
2511 * @param pdoc [i/o] The pointer to the HDML structure at the output
2512 * destination is specified.
2513 * @param node [i] The OPTION tag node is specified.
2514 * @return The conversion result is returned.
2517 s_hdml_end_option_tag(void *pdoc, Node *UNUSED(node))
2519 hdml_t *hdml = GET_HDML(pdoc);
2521 hdml->option_flag = 0;
2528 * It is a handler who processes the DIV tag.
2530 * @param pdoc [i/o] The pointer to the HDML structure at the output
2531 * destination is specified.
2532 * @param node [i] The DIV tag node is specified.
2533 * @return The conversion result is returned.
2536 s_hdml_start_div_tag(void *pdoc, Node *node)
2542 hdml = GET_HDML(pdoc);
2545 /*--------------------------------------------------------------------------*/
2546 /* If the br tag is not output immediately before the div tag appears, the */
2547 /* br tag is output. */
2548 /*--------------------------------------------------------------------------*/
2549 if (hdml->hdml_br_flag == 0) {
2550 hdml->hdml_br_flag = 1;
2551 s_output_to_hdml_out(hdml, "<BR>\r\n");
2554 /*--------------------------------------------------------------------------*/
2555 /* The object tag node is scanned. */
2556 /*--------------------------------------------------------------------------*/
2557 for (attr = qs_get_attr(doc,node);
2559 attr = qs_get_next_attr(doc,attr)) {
2560 char *name = qs_get_attr_name(doc,attr);
2561 char *value = qs_get_attr_value(doc,attr);
2562 if (STRCASEEQ('a','A',"align",name)) {
2563 if (STRCASEEQ('r','R',"right",value)) {
2564 hdml->div_right_flag = 1;
2565 s_output_to_hdml_out(hdml, "<RIGHT>");
2566 hdml->hdml_br_flag = 0;
2569 else if (STRCASEEQ('c','C',"center",value)) {
2570 hdml->div_center_flag = 1;
2571 s_output_to_hdml_out(hdml, "<CENTER>");
2572 hdml->hdml_br_flag = 0;
2577 hdml->hdml_br_flag = 0;
2584 * It is a handler who processes the DIV tag.
2586 * @param pdoc [i/o] The pointer to the HDML structure at the output
2587 * destination is specified.
2588 * @param node [i] The DIV tag node is specified.
2589 * @return The conversion result is returned.
2592 s_hdml_end_div_tag(void *pdoc, Node *UNUSED(node))
2594 hdml_t *hdml = GET_HDML(pdoc);
2595 request_rec *r = hdml->doc->r;
2597 if (hdml->div_right_flag == 1) {
2598 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2599 hdml->div_right_flag = 0;
2601 if (hdml->div_center_flag == 1) {
2602 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2603 hdml->div_center_flag = 0;
2604 hdml->div_in_center = 0;
2612 * It is a wrapper of the apr_pstrcat function.
2614 * @param r [i] To use POOL, the pointer to request_rec is specified.
2615 * @param o [i] The character string of connected origin is specified.
2616 * @param s [i] The character string connected with 'o' parameter is
2618 * @param len [i/o] The pointer to the area where the character string
2619 * length is stored is specified.
2620 * @return The character string after it connects it is returned.
2623 qs_out_apr_pstrcat(request_rec *r, char *o, char *s, int *len)
2625 *len = (strlen(s) + *len);
2626 return apr_pstrcat(r->pool, o, s, NULL);
2630 * The prepositive character string used to generate the variable for HDML is
2633 * @param r [i] To use POOL, the pointer to request_rec is specified.
2634 * @param hdml [i] The pointer to the HDML structure that maintains the seed
2635 * to generate it is specified.
2636 * @return The character string after it generates it is returned.
2639 s_s_get_form_no(request_rec *r, hdml_t *hdml)
2645 fc = hdml->form_cnt;
2647 apr_time_exp_tz(&tm, hdml->form_cnt, 0);
2649 result = apr_psprintf(r->pool, "%c",(int)('A' + ((fc / 100) % 26)));
2650 result = apr_pstrcat(r->pool, result,
2651 apr_psprintf(r->pool, "%02d%02d%02d",
2659 * The number of tag nodes .."Input type =' radio '".. is counted.
2661 * @param hdml [i] The pointer to the HDML structure is specified.
2662 * @param node [i] The first parents node that counts the radio tag node is
2666 s_hdml_count_radio_tag(hdml_t *hdml, Node *node)
2675 /*--------------------------------------------------------------------------*/
2676 /* All the child nodes of the specified node are scanned. */
2677 /*--------------------------------------------------------------------------*/
2678 for (child = qs_get_child_node(doc,node);
2680 child = qs_get_next_node(doc,child)) {
2689 name = qs_get_node_name(doc,child);
2690 if (strcasecmp(name, "input") != 0) {
2691 s_hdml_count_radio_tag(hdml, child);
2695 DBG(r,"found input tag");
2697 type = qs_get_type_attr(doc, child, r->pool);
2699 ERR(r, "Oops! The input tag without the type attribute has been found.Please give a type.");
2703 if (strcasecmp(type, "radio") != 0)
2706 DBG(r, "found type=radio");
2708 rname = qs_get_name_attr (doc, child, r->pool);
2709 rvalue = qs_get_value_attr(doc, child, r->pool);
2712 /*----------------------------------------------------------------------*/
2713 /* Oops!. The input tag without the name attribute has been found. */
2714 /*----------------------------------------------------------------------*/
2715 DBG(r, "Oops!. The input tag without the name attribute has been found. Please give a name.");
2719 DBG(r, "found name attribute");
2721 /*------------------------------------------------------------------------*/
2722 /* It scans in radio_name_list. When the same value exists, the */
2723 /* value is overwrited. */
2724 /* The value is written in a new area when not is. */
2725 /*------------------------------------------------------------------------*/
2726 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
2727 if (! hdml->radio_name_list[ii]) {
2728 DBG(r, "new name:[%s]", rname);
2731 if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2732 DBG(r, "already registered name:[%s]", rname);
2736 if (ii == MAX_RADIO_COUNT) {
2737 DBG(r, apr_psprintf(r->pool,
2738 "I do not understand the name of the radiobutton "
2739 "of %d piece or more. Please decrease "
2740 "the number of radiobuttons.",
2745 DBG(r,"add radio name:[%s]" ,rname);
2747 hdml->radio_name_list[ii] = apr_pstrdup(r->pool, rname);
2749 /*------------------------------------------------------------------------*/
2750 /* It adds it to radio_value_list. */
2751 /*------------------------------------------------------------------------*/
2752 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) {
2753 if (!hdml->radio_value_list[ii][jj])
2756 if (jj == MAX_RADIO_VALUE_COUNT) {
2757 DBG(r, apr_psprintf(r->pool,
2758 "I do not understand the value of the radiobutton "
2759 "of %d piece or more. Please decrease "
2760 "the number of radiobuttons.",
2761 MAX_RADIO_VALUE_COUNT));
2764 hdml->radio_value_list[ii][jj] = apr_pstrdup(r->pool, rvalue);
2766 /*------------------------------------------------------------------------*/
2767 /* Now let's be the checked attribute or scan. */
2768 /*------------------------------------------------------------------------*/
2769 chkd = qs_get_checked_attr(hdml->doc, child, r->pool);
2771 DBG(r,apr_psprintf(r->pool,
2772 "The tag scanned now had the checked "
2773 "attribute. The value is [%s].",
2775 hdml->radio_checked_value[ii] = apr_pstrdup(r->pool, rvalue);
2782 * The character string is added, and output to the out member of the HDML
2785 * @param hdml [i/o] The pointer to the HDML structure that maintains the out
2786 * member at the output destination is specified.
2787 * @param s [i] The character string that should be output is specified.
2788 * @return The pointer to the HDML structure after it processes it is returned.
2791 s_output_to_hdml_out(hdml_t *hdml, char *s)
2793 hdml->out = qs_out_apr_pstrcat(hdml->doc->r, hdml->out, s, &hdml->out_len);
2800 * The character string is added, and output to the card member of the HDML
2803 * @param hdml [i/o] The pointer to the HDML structure that maintains the
2804 * card member at the output destination is specified.
2805 * @param s [i] The character string that should be output is specified.
2806 * @return The pointer to the HDML structure after it processes it is returned.
2809 s_output_to_hdml_card(hdml_t *hdml, char *s)
2811 hdml->card = qs_out_apr_pstrcat(hdml->doc->r, hdml->card, s, &hdml->card_len);
2819 * The data for the post is added, and output.
2821 * @param hdml [i/o] The pointer to the HDML structure at the output
2822 * destination is specified.
2823 * @param s [i] The character string that wants to output to postdata is
2827 s_output_to_postdata(hdml_t *hdml, char *s)
2829 request_rec *r = hdml->doc->r;
2831 if (strlen(hdml->postdata[hdml->pure_form_cnt])) {
2832 hdml->postdata[hdml->pure_form_cnt] =
2833 apr_pstrcat(r->pool,
2834 hdml->postdata[hdml->pure_form_cnt],
2838 hdml->postdata[hdml->pure_form_cnt] =
2839 apr_pstrcat(r->pool,
2840 hdml->postdata[hdml->pure_form_cnt],
2841 qs_trim_string(r->pool, s),
2844 DBG(r, "POSTDATA:[%s]", hdml->postdata[hdml->pure_form_cnt] );
2850 * The tag output upper half.
2852 * @param hdml [i/o] The pointer to the HDML structure at the output
2853 * destination is specified.
2854 * @param node [i] The A tag node is specified.
2857 s_hdml_tag_output_upper_half(hdml_t *hdml, Node *UNUSED(node))
2859 if (hdml->hdml_br_flag == 1 && hdml->div_right_flag == 1) {
2860 s_output_to_hdml_out(hdml, "<RIGHT>");
2861 hdml->hdml_br_flag = 0;
2864 if (hdml->hdml_br_flag == 1
2866 && hdml->in_center == 0) {
2867 s_output_to_hdml_out(hdml, "<CENTER>");
2869 hdml->hdml_br_flag = 0;
2871 else if (hdml->hdml_br_flag == 1
2872 && hdml->div_center_flag > 0
2873 && hdml->div_in_center == 0) {
2874 s_output_to_hdml_out(hdml, "<CENTER>");
2875 hdml->div_in_center++;
2876 hdml->hdml_br_flag = 0;
2883 * The data for the init_vars is added, and output.
2885 * @param hdml [i/o] The pointer to the HDML structure at the output
2886 * destination is specified.
2887 * @param s [i] The character string that wants to output to postdata is
2891 s_output_to_init_vars(hdml_t *hdml, char *s)
2893 request_rec *r = hdml->doc->r;
2895 if (strlen(hdml->init_vars)) {
2896 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, "&", NULL);
2899 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, qs_trim_string(r->pool,s), NULL);
2901 DBG(r, "INIT_VARS:[%s]", hdml->init_vars);
2907 s_hdml_chxjif_tag(void *pdoc, Node *node)
2913 hdml = GET_HDML(pdoc);
2916 for (child = qs_get_child_node(doc, node);
2918 child = qs_get_next_node(doc, child)) {
2919 s_output_to_hdml_out(hdml, child->otext);
2920 s_hdml_chxjif_tag(hdml, child);
2927 s_hdml_text_tag(void *pdoc, Node *child)
2937 int one_line_count = 0;
2940 hdml = GET_HDML(pdoc);
2944 textval = qs_get_node_value(doc,child);
2945 if (strlen(textval) == 0) {
2949 if (hdml->option_flag == 1) {
2953 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2954 memset(tmp, 0, qs_get_node_size(doc,child)+1);
2955 tdst = apr_palloc(r->pool, 1);
2961 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2963 int rtn = s_hdml_search_emoji(hdml, &textval[ii], &out);
2965 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2967 one_line_count+=(rtn-1);
2970 if (hdml->hdml_blockquote_flag) {
2971 if (one_line_count == 0) {
2972 tdst = qs_out_apr_pstrcat(r, tdst, "<WRAP> <TAB>", &tdst_len);
2974 if (is_sjis_kanji(textval[ii])) {
2975 one_byte[0] = textval[ii+0];
2976 one_byte[1] = textval[ii+1];
2978 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2983 one_byte[0] = textval[ii+0];
2985 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2987 if (one_byte[0] == '\n') {
2993 if (hdml->pre_flag) {
2994 if (one_line_count == 0) {
2995 tdst = qs_out_apr_pstrcat(r, tdst, "<LINE>", &tdst_len);
2997 if (is_sjis_kanji(textval[ii])) {
2998 one_byte[0] = textval[ii+0];
2999 one_byte[1] = textval[ii+1];
3001 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3006 one_byte[0] = textval[ii+0];
3008 if (one_byte[0] == ' ') {
3009 tdst = qs_out_apr_pstrcat(r, tdst, " ", &tdst_len);
3012 tdst = qs_out_apr_pstrcat(r, tdst, chxj_ap_escape_html(r->pool, one_byte), &tdst_len);
3015 if (one_byte[0] == '\n') {
3021 if (is_sjis_kanji(textval[ii])) {
3022 one_byte[0] = textval[ii+0];
3023 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3024 one_byte[0] = textval[ii+1];
3025 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3029 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3030 one_byte[0] = textval[ii+0];
3031 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3034 memcpy(tmp, textval, strlen(textval)-1);
3036 s_hdml_tag_output_upper_half(hdml, child->parent);
3037 s_output_to_hdml_out(hdml, tdst);
3038 hdml->hdml_br_flag = 0;
3045 * It is a handler who processes the BLOCKQUOTE tag.
3047 * @param pdoc [i/o] The pointer to the HDML structure at the output
3048 * destination is specified.
3049 * @param node [i] The BLOCKQUOTE tag node is specified.
3050 * @return The conversion result is returned.
3053 s_hdml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3055 hdml_t *hdml = GET_HDML(pdoc);
3056 hdml->hdml_blockquote_flag++;
3062 * It is a handler who processes the BLOCKQUOTE tag.
3064 * @param pdoc [i/o] The pointer to the HDML structure at the output
3065 * destination is specified.
3066 * @param node [i] The BLOCKQUOTE tag node is specified.
3067 * @return The conversion result is returned.
3070 s_hdml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3072 hdml_t *hdml = GET_HDML(pdoc);
3073 hdml->hdml_blockquote_flag--;
3074 s_output_to_hdml_out(hdml, "\r\n");
3080 * It is a handler who processes the DIR tag.
3082 * @param pdoc [i/o] The pointer to the HDML structure at the output
3083 * destination is specified.
3084 * @param node [i] The DIR tag node is specified.
3085 * @return The conversion result is returned.
3088 s_hdml_start_dir_tag(void *pdoc, Node *UNUSED(child))
3090 hdml_t *hdml = GET_HDML(pdoc);
3097 * It is a handler who processes the DIR tag.
3099 * @param pdoc [i/o] The pointer to the HDML structure at the output
3100 * destination is specified.
3101 * @param node [i] The DIR tag node is specified.
3102 * @return The conversion result is returned.
3105 s_hdml_end_dir_tag(void *pdoc, Node *UNUSED(child))
3107 hdml_t *hdml = GET_HDML(pdoc);
3114 * It is a handler who processes the DT tag.
3116 * @param pdoc [i/o] The pointer to the HDML structure at the output
3117 * destination is specified.
3118 * @param node [i] The DT tag node is specified.
3119 * @return The conversion result is returned.
3122 s_hdml_start_dt_tag(void *pdoc, Node *UNUSED(child))
3124 hdml_t *hdml = GET_HDML(pdoc);
3125 s_output_to_hdml_out(hdml, "<LINE>");
3131 * It is a handler who processes the DT tag.
3133 * @param pdoc [i/o] The pointer to the HDML structure at the output
3134 * destination is specified.
3135 * @param node [i] The DT tag node is specified.
3136 * @return The conversion result is returned.
3139 s_hdml_end_dt_tag(void *pdoc, Node *UNUSED(child))
3141 hdml_t *hdml = GET_HDML(pdoc);
3142 s_output_to_hdml_out(hdml, "\r\n");
3148 * It is a handler who processes the DD tag.
3150 * @param pdoc [i/o] The pointer to the HDML structure at the output
3151 * destination is specified.
3152 * @param node [i] The DD tag node is specified.
3153 * @return The conversion result is returned.
3156 s_hdml_start_dd_tag(void *pdoc, Node *UNUSED(child))
3158 hdml_t *hdml = GET_HDML(pdoc);
3159 s_output_to_hdml_out(hdml, "<WRAP> <TAB>");
3165 * It is a handler who processes the DD tag.
3167 * @param pdoc [i/o] The pointer to the HDML structure at the output
3168 * destination is specified.
3169 * @param node [i] The DD tag node is specified.
3170 * @return The conversion result is returned.
3173 s_hdml_end_dd_tag(void *pdoc, Node *UNUSED(child))
3175 hdml_t *hdml = GET_HDML(pdoc);
3176 s_output_to_hdml_out(hdml, "\r\n");
3182 * It is a handler who processes the PLAINTEXT tag.
3184 * @param pdoc [i/o] The pointer to the HDML structure at the output
3185 * destination is specified.
3186 * @param node [i] The PLAINTEXT tag node is specified.
3187 * @return The conversion result is returned.
3190 s_hdml_start_plaintext_tag(void *pdoc, Node *node)
3192 hdml_t *hdml = GET_HDML(pdoc);
3193 hdml->plaintext_value_len = 0;
3194 s_hdml_start_plaintext_tag_inner(pdoc,node);
3199 s_hdml_start_plaintext_tag_inner(void *pdoc, Node *node)
3201 hdml_t *hdml = GET_HDML(pdoc);
3202 Doc *doc = hdml->doc;
3204 for (child = qs_get_child_node(doc, node);
3206 child = qs_get_next_node(doc, child)) {
3208 char *str = chxj_ap_escape_html(doc->r->pool, child->otext);
3209 int len = strlen(str);
3211 for (i=0; i<len; i++) {
3212 if (hdml->plaintext_value_len == 0) {
3213 s_output_to_hdml_out(hdml, "<LINE>");
3215 if (is_sjis_kanji(child->otext[i]) && i + 1 < len) {
3216 oneChar[0] = child->otext[i+0];
3217 oneChar[1] = child->otext[i+1];
3219 s_output_to_hdml_out(hdml, oneChar);
3220 hdml->plaintext_value_len +=2;
3224 if (child->otext[i] == '\n') {
3225 hdml->plaintext_value_len = 0;
3228 s_output_to_hdml_out(hdml, oneChar);
3231 oneChar[0] = child->otext[i];
3233 s_output_to_hdml_out(hdml, oneChar);
3234 hdml->plaintext_value_len++;
3236 s_hdml_start_plaintext_tag_inner(pdoc, child);
3243 * It is a handler who processes the PLAINTEXT tag.
3245 * @param pdoc [i/o] The pointer to the HDML structure at the output
3246 * destination is specified.
3247 * @param node [i] The PLAINTEXT tag node is specified.
3248 * @return The conversion result is returned.
3251 s_hdml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3253 hdml_t *hdml = GET_HDML(pdoc);
3259 * It is a handler who processes the PRE tag.
3261 * @param pdoc [i/o] The pointer to the HDML structure at the output
3262 * destination is specified.
3263 * @param node [i] The PRE tag node is specified.
3264 * @return The conversion result is returned.
3267 s_hdml_start_pre_tag(void *pdoc, Node *UNUSED(node))
3273 hdml = GET_HDML(pdoc);
3283 * It is a handler who processes the PRE tag.
3285 * @param pdoc [i/o] The pointer to the HDML structure at the output
3286 * destination is specified.
3287 * @param node [i] The PRE tag node is specified.
3288 * @return The conversion result is returned.
3291 s_hdml_end_pre_tag(void *pdoc, Node *UNUSED(child))
3297 hdml = GET_HDML(pdoc);
3308 * handler of the TEXTAREA tag.
3310 * @param hdml [i/o] The pointer to the HDML structure at the output
3311 * destination is specified.
3312 * @param tag [i] Specified The TEXTAREA tag node.
3315 s_hdml_start_textarea_tag(void *pdoc, Node *node)
3325 hdml_t *hdml = GET_HDML(pdoc);
3330 s_hdml_tag_output_upper_half(hdml, node);
3333 s_output_to_hdml_out(hdml,
3334 apr_psprintf(r->pool,
3335 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
3336 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
3338 s_get_form_no(r, hdml),
3339 hdml->var_cnt[hdml->pure_form_cnt],
3340 s_get_form_no(r, hdml),
3341 hdml->var_cnt[hdml->pure_form_cnt]
3344 s_output_to_hdml_out(hdml,
3345 apr_psprintf(r->pool,
3346 "[$%s%02d]</A>\r\n" ,
3347 s_get_form_no(r, hdml),
3348 hdml->var_cnt[hdml->pure_form_cnt]));
3350 /*--------------------------------------------------------------------------*/
3351 /* ENTRY CARD is output here. */
3352 /*--------------------------------------------------------------------------*/
3353 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
3354 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
3355 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
3361 nm = qs_get_name_attr(doc, node, r->pool);
3363 nm = qs_alloc_zero_byte_string(r->pool);
3366 s_output_to_postdata(hdml,
3367 apr_psprintf(r->pool,
3370 s_get_form_no(r, hdml),
3371 hdml->var_cnt[hdml->pure_form_cnt]));
3373 mlen = qs_get_maxlength_attr (doc, node, r->pool);
3374 is = qs_get_istyle_attr (doc, node, r->pool);
3375 val = s_hdml_inner_textarea_tag_get_value(hdml, node);
3377 fmt = qs_conv_istyle_to_format(r->pool, is);
3380 for (ii=0; ii<strlen(mlen); ii++) {
3381 if (mlen[ii] < '0' || mlen[ii] > '9') {
3382 mlen = apr_psprintf(r->pool, "0");
3386 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
3389 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt));
3393 s_output_to_hdml_card(hdml,
3394 " MARKABLE=FALSE>\r\n"
3395 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
3398 s_output_to_init_vars(hdml,
3399 apr_psprintf(r->pool,
3401 s_get_form_no(r, hdml),
3402 hdml->var_cnt[hdml->pure_form_cnt],
3403 chxj_escape_uri(r->pool,val)));
3406 s_output_to_init_vars(hdml,
3407 apr_psprintf(r->pool,
3409 s_get_form_no(r, hdml),
3410 hdml->var_cnt[hdml->pure_form_cnt]));
3412 hdml->var_cnt[hdml->pure_form_cnt]++;
3417 s_hdml_inner_textarea_tag_get_value(hdml_t *hdml, Node *node)
3419 Doc *doc = hdml->doc;
3421 char *result = apr_pstrdup(doc->r->pool, "\0");
3422 for (child = qs_get_child_node(doc, node);
3424 child = qs_get_next_node(doc, child)) {
3425 char *textval = qs_get_node_value(doc,child);
3426 if (textval && *textval) {
3427 result = apr_pstrcat(doc->r->pool, result, textval, NULL);