2 * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include "chxj_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,
382 * converts from CHTML to hdml.
384 * @param r [i] Requet_rec is appointed.
385 * @param spec [i] The result of the device specification processing which
386 * was done in advance is appointed.
387 * @param src [i] The character string before the converting is appointed.
388 * @return The character string after the converting is returned.
397 chxjconvrule_entry* entryp,
398 cookie_t* UNUSED(cookie)
409 /*--------------------------------------------------------------------------*/
411 /*--------------------------------------------------------------------------*/
413 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
415 DBG(r,"i found qrcode xml");
418 DBG(r,"not found qrcode xml");
420 /*--------------------------------------------------------------------------*/
421 /* initialize hdml structure */
422 /*--------------------------------------------------------------------------*/
423 s_init_hdml(&hdml,&doc,r, spec);
425 hdml.entryp = entryp;
427 chxj_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
428 /*--------------------------------------------------------------------------*/
430 /*--------------------------------------------------------------------------*/
432 chxj_dump_out("[src] CHTML->HDML", src, srclen);
435 /*--------------------------------------------------------------------------*/
436 /* It is examined whether there is a location header. It ends without doing */
437 /* anything when is. */
438 /*--------------------------------------------------------------------------*/
439 buf = (char*)apr_table_get(r->headers_out, (const char*)"Location");
441 /*------------------------------------------------------------------------*/
442 /* The Location header generates tag in an initial HDML machine for the */
443 /* uncorrespon dence. */
444 /*------------------------------------------------------------------------*/
445 DBG(r, "Location is not null[Location:%s]", buf);
446 s_output_to_hdml_out(&hdml,
447 "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\r\n"
448 "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\r\n"
449 "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
451 s_output_to_hdml_out(&hdml, buf);
452 s_output_to_hdml_out(&hdml,
457 dst = apr_pstrdup(r->pool, hdml.out);
460 /*------------------------------------------------------------------------*/
461 /* Here, the parsing of the received character string is done */
462 /*------------------------------------------------------------------------*/
463 char *ss = apr_palloc(r->pool, srclen + 1);
464 memset(ss, 0, srclen + 1);
465 memcpy(ss, src, srclen);
467 DBG(r, "input strlen(src)=[%d]", (int)srclen);
468 DBG(r, "[[[[%s]]]", src);
470 qs_init_malloc(&doc);
471 qs_init_root_node(&doc);
473 qs_parse_string(&doc, ss, srclen);
475 /*------------------------------------------------------------------------*/
476 /* The number of radiobuttons is counted. */
477 /*------------------------------------------------------------------------*/
478 s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
480 chxj_node_exchange(spec,r,(void*)&hdml, &doc, qs_get_root(&doc), 0);
483 DBG(r,"tmp=[%s]", dst);
484 qs_all_free(&doc,QX_LOGMARK);
487 /*--------------------------------------------------------------------------*/
489 /*--------------------------------------------------------------------------*/
491 chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
494 /*--------------------------------------------------------------------------*/
495 /* When there is no processing result, former character string is copied */
496 /* and it returns it. */
497 /*--------------------------------------------------------------------------*/
500 return apr_pstrdup(r->pool,src);
503 *dstlen = hdml.out_len;
505 /*--------------------------------------------------------------------------*/
506 /* Null is set at the end of the character string to make sure. */
507 /*--------------------------------------------------------------------------*/
508 dst[hdml.out_len] = 0;
515 * The HDML structure is initialized.
517 * @param hdml [i/o] The pointer to the HDML structure that wants to be
518 * initialized is specified.
519 * @param doc [i] The Doc structure that should be set to the initialized
520 * HDML structure is specified.
521 * @param r [i] To use POOL, the pointer to request_rec is specified.
522 * @param spec [i] The pointer to the device_table
525 s_init_hdml(hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec)
530 /*--------------------------------------------------------------------------*/
531 /* init hdml structure value */
532 /*--------------------------------------------------------------------------*/
533 memset(hdml, 0, sizeof(hdml_t));
535 hdml->card = qs_alloc_zero_byte_string(r);
537 hdml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
538 hdml->doc->parse_mode = PARSE_MODE_CHTML;
540 for (ii=0; ii<MAX_FORM_COUNT; ii++) {
541 hdml->var_cnt[ii] = 0;
542 hdml->postdata[ii] = qs_alloc_zero_byte_string(r);
545 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
546 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
547 hdml->radio_value_list[ii][jj] = NULL;
549 hdml->radio_name_list[ii] = NULL;
550 hdml->radio_out_cnt[ii] = 0;
551 hdml->radio_checked_value[ii] = NULL;
554 for (ii=0; ii<MAX_SUBMIT_BUTTON_COUNT; ii++)
555 hdml->submit_button[ii] = NULL;
557 hdml->init_vars = qs_alloc_zero_byte_string(r);
561 hdml->form_cnt = apr_time_now();
562 hdml->out = qs_alloc_zero_byte_string(r);
567 s_hdml_search_emoji(hdml_t* hdml, char* txt, char** rslt)
580 DBG(r,"spec is NULL");
582 for (ee = hdml->conf->emoji;
586 unsigned char hex1byte;
587 unsigned char hex2byte;
590 DBG(r, "emoji->imode is NULL");
594 hex1byte = ee->imode->hex1byte & 0xff;
595 hex2byte = ee->imode->hex2byte & 0xff;
597 if (ee->imode->string
598 && strlen(ee->imode->string) > 0
599 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
600 if (spec == NULL || spec->emoji_type == NULL) {
601 *rslt = apr_psprintf(r->pool,
604 return strlen(ee->imode->string);
607 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
608 *rslt = apr_psprintf(r->pool,
611 return strlen(ee->imode->string);
614 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
615 *rslt = apr_psprintf(r->pool,
618 return strlen(ee->imode->string);
621 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
622 *rslt = apr_psprintf(r->pool,
625 return strlen(ee->imode->string);
628 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
629 *rslt = apr_psprintf(r->pool,
632 return strlen(ee->imode->string);
635 *rslt = apr_psprintf(r->pool,
638 return strlen(ee->imode->string);
643 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
644 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
645 if (spec == NULL || spec->emoji_type == NULL) {
646 *rslt = apr_psprintf(r->pool,
652 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
653 *rslt = apr_psprintf(r->pool,
659 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
660 *rslt = apr_psprintf(r->pool,
666 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
667 *rslt = apr_psprintf(r->pool,
673 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
674 *rslt = apr_psprintf(r->pool,
680 *rslt = apr_psprintf(r->pool,
693 * It is a handler who processes the HTML tag.
695 * @param pdoc [i/o] The pointer to the HDML structure at the output
696 * destination is specified.
697 * @param node [i] The HTML tag node is specified.
698 * @return The conversion result is returned.
701 s_hdml_start_html_tag(void* pdoc, Node* UNUSED(node))
705 hdml = GET_HDML(pdoc);
707 s_output_to_hdml_out(hdml,
708 "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\r\n"
709 "<NODISPLAY NAME=D0>\r\n"
710 "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\r\n"
715 hdml->hdml_br_flag = 0;
722 * It is a handler who processes the HTML tag.
724 * @param pdoc [i/o] The pointer to the HDML structure at the output
725 * destination is specified.
726 * @param node [i] The HTML tag node is specified.
727 * @return The conversion result is returned.
730 s_hdml_end_html_tag(void* pdoc, Node* UNUSED(child))
734 hdml = GET_HDML(pdoc);
736 s_output_to_hdml_card(hdml,
737 "<NODISPLAY NAME=D1>\r\n"
738 "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
741 if (strlen(hdml->init_vars))
742 s_output_to_hdml_card(hdml, hdml->init_vars );
744 s_output_to_hdml_card(hdml, "_chxj_dmy=" );
746 s_output_to_hdml_card(hdml,
751 s_output_to_hdml_out(hdml, hdml->card );
752 s_output_to_hdml_out(hdml, "</HDML>\r\n");
754 hdml->hdml_end_flag = 1;
761 * It is a handler who processes the META tag.
763 * @param pdoc [i/o] The pointer to the HDML structure at the output
764 * destination is specified.
765 * @param node [i] The META tag node is specified.
766 * @return The conversion result is returned.
769 s_hdml_start_meta_tag(void* pdoc, Node* UNUSED(node))
773 hdml = GET_HDML(pdoc);
775 hdml->hdml_br_flag = 0;
784 * It is a handler who processes the META tag.
786 * @param pdoc [i/o] The pointer to the HDML structure at the output
787 * destination is specified.
788 * @param node [i] The META tag node is specified.
789 * @return The conversion result is returned.
792 s_hdml_end_meta_tag(void* pdoc, Node* UNUSED(child))
796 hdml = GET_HDML(pdoc);
803 * It is a handler who processes the HEAD tag.
805 * @param pdoc [i/o] The pointer to the HDML structure at the output
806 * destination is specified.
807 * @param node [i] The HEAD tag node is specified.
808 * @return The conversion result is returned.
811 s_hdml_start_head_tag(void* pdoc, Node* UNUSED(node))
815 hdml = GET_HDML(pdoc);
819 hdml->hdml_br_flag = 0;
826 * It is a handler who processes the HEAD tag.
828 * @param pdoc [i/o] The pointer to the HDML structure at the output
829 * destination is specified.
830 * @param node [i] The HEAD tag node is specified.
831 * @return The conversion result is returned.
834 s_hdml_end_head_tag(void* pdoc, Node* UNUSED(child))
838 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))
858 hdml = GET_HDML(pdoc);
860 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
862 hdml->found_title = 1;
863 hdml->hdml_br_flag = 0;
870 * It is a handler who processes the TITLE tag.
872 * @param pdoc [i/o] The pointer to the HDML structure at the output
873 * destination is specified.
874 * @param node [i] The TITLE tag node is specified.
875 * @return The conversion result is returned.
878 s_hdml_end_title_tag(void* pdoc, Node* UNUSED(child))
882 hdml = GET_HDML(pdoc);
884 s_output_to_hdml_out(hdml, "\">\r\n");
891 * It is a handler who processes the BASE tag.
893 * @param pdoc [i/o] The pointer to the HDML structure at the output
894 * destination is specified.
895 * @param node [i] The BASE tag node is specified.
896 * @return The conversion result is returned.
899 s_hdml_start_base_tag(void* pdoc, Node* UNUSED(node))
903 hdml = GET_HDML(pdoc);
905 hdml->hdml_br_flag = 0;
912 * It is a handler who processes the BASE tag.
914 * @param pdoc [i/o] The pointer to the HDML structure at the output
915 * destination is specified.
916 * @param node [i] The BASE tag node is specified.
917 * @return The conversion result is returned.
920 s_hdml_end_base_tag(void* pdoc, Node* UNUSED(child))
924 hdml = GET_HDML(pdoc);
931 * It is a handler who processes the BODY tag.
933 * @param pdoc [i/o] The pointer to the HDML structure at the output
934 * destination is specified.
935 * @param node [i] The BODY tag node is specified.
936 * @return The conversion result is returned.
939 s_hdml_start_body_tag(void* pdoc, Node* node)
945 hdml = GET_HDML(pdoc);
949 if (hdml->found_title == 0)
950 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\r\n");
952 s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
954 /*--------------------------------*/
956 /*--------------------------------*/
957 for (attr = qs_get_attr(doc,node);
959 attr = qs_get_next_attr(doc,attr)) {
963 name = qs_get_attr_name(doc,attr);
965 if ((*name == 'b' || *name == 'B') && strcasecmp(name, "bgcolor") == 0) {
969 if ((*name == 't' || *name == 'T') && strcasecmp(name, "text") == 0) {
973 if ((*name == 'l' || *name == 'L') && strcasecmp(name, "link") == 0) {
977 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alink") == 0) {
981 if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vlink") == 0) {
986 s_output_to_hdml_out(hdml, ">\r\n");
988 hdml->hdml_br_flag = 0;
995 * It is a handler who processes the BODY tag.
997 * @param pdoc [i/o] The pointer to the HDML structure at the output
998 * destination is specified.
999 * @param node [i] The BODY tag node is specified.
1000 * @return The conversion result is returned.
1003 s_hdml_end_body_tag(void* pdoc, Node* UNUSED(child))
1007 hdml = GET_HDML(pdoc);
1009 s_output_to_hdml_out(hdml, "\r\n</DISPLAY>\r\n");
1016 * It is a handler who processes the A tag.
1018 * @param pdoc [i/o] The pointer to the HDML structure at the output
1019 * destination is specified.
1020 * @param node [i] The A tag node is specified.
1021 * @return The conversion result is returned.
1024 s_hdml_start_a_tag(void *pdoc, Node *node)
1030 hdml = GET_HDML(pdoc);
1033 s_hdml_tag_output_upper_half(hdml,node);
1035 s_output_to_hdml_out(hdml, "<A");
1038 /*------------------------------------*/
1039 /* Get Attributes */
1040 /*------------------------------------*/
1041 for (attr = qs_get_attr(doc,node);
1043 attr = qs_get_next_attr(doc,attr)) {
1044 char *name = qs_get_attr_name(doc,attr);
1045 char *value = qs_get_attr_value(doc,attr);
1046 if (STRCASEEQ('n','N',"name",name)) {
1049 else if (STRCASEEQ('h','H',"href",name)) {
1050 if ((*value == 'm' || *value == 'M') && strncasecmp(value, "mailto:", 7) == 0) {
1051 value = chxj_encoding_parameter(hdml->doc->r, value);
1052 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1053 s_output_to_hdml_out(hdml, value );
1054 s_output_to_hdml_out(hdml, "\" " );
1057 if ((*value == 't' || *value == 'T') && strncasecmp(value, "tel:", 4) == 0) {
1058 s_output_to_hdml_out(hdml, " TASK=CALL NUMBER=\"");
1059 s_output_to_hdml_out(hdml, &value[4] );
1060 s_output_to_hdml_out(hdml, "\" " );
1063 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1064 s_output_to_hdml_out(hdml, value );
1065 s_output_to_hdml_out(hdml, "\"" );
1069 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0 && value && *value) {
1070 if (strcasecmp(value, "0") != 0) {
1071 s_output_to_hdml_out(hdml, " ACCESSKEY=" );
1072 s_output_to_hdml_out(hdml, value );
1073 s_output_to_hdml_out(hdml, "" );
1077 if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cti") == 0) {
1081 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ijam") == 0) {
1085 if ((*name == 'u' || *name == 'U') && strcasecmp(name, "utn") == 0) {
1089 if ((*name == 't' || *name == 'T') && strcasecmp(name, "telbook") == 0) {
1093 if ((*name == 'k' || *name == 'K') && strcasecmp(name, "kana") == 0) {
1097 if ((*name == 'e' || *name == 'E') && strcasecmp(name, "email") == 0) {
1101 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ista") == 0) {
1105 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ilet") == 0) {
1109 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "iswf") == 0) {
1113 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "irst") == 0) {
1117 s_output_to_hdml_out(hdml, ">" );
1119 hdml->hdml_a_flag = 1;
1121 hdml->hdml_br_flag = 0;
1128 * It is a handler who processes the A tag.
1130 * @param pdoc [i/o] The pointer to the HDML structure at the output
1131 * destination is specified.
1132 * @param node [i] The A tag node is specified.
1133 * @return The conversion result is returned.
1136 s_hdml_end_a_tag(void* pdoc, Node* UNUSED(child))
1140 hdml = GET_HDML(pdoc);
1142 s_output_to_hdml_out(hdml, "</A>\r\n");
1144 hdml->hdml_a_flag = 0;
1151 * It is a handler who processes the BR tag.
1153 * @param pdoc [i/o] The pointer to the HDML structure at the output
1154 * destination is specified.
1155 * @param node [i] The BR tag node is specified.
1156 * @return The conversion result is returned.
1159 s_hdml_start_br_tag(void* pdoc, Node* UNUSED(node))
1163 hdml = GET_HDML(pdoc);
1165 if (hdml->in_center > 0)
1166 hdml->in_center = 0;
1168 if (hdml->div_in_center > 0)
1169 hdml->div_in_center = 0;
1171 s_output_to_hdml_out(hdml, "<BR>\r\n");
1173 hdml->hdml_br_flag = 1;
1180 * It is a handler who processes the BR tag.
1182 * @param pdoc [i/o] The pointer to the HDML structure at the output
1183 * destination is specified.
1184 * @param node [i] The BR tag node is specified.
1185 * @return The conversion result is returned.
1188 s_hdml_end_br_tag(void* pdoc, Node* UNUSED(child))
1192 hdml = GET_HDML(pdoc);
1199 * It is a handler who processes the TR tag.
1201 * @param pdoc [i/o] The pointer to the HDML structure at the output
1202 * destination is specified.
1203 * @param node [i] The TR tag node is specified.
1204 * @return The conversion result is returned.
1207 s_hdml_start_tr_tag(void* pdoc, Node* UNUSED(node))
1211 hdml = GET_HDML(pdoc);
1213 if (hdml->in_center > 0)
1214 hdml->in_center = 0;
1216 if (hdml->div_in_center > 0)
1217 hdml->div_in_center = 0;
1219 s_output_to_hdml_out(hdml, "<BR>\r\n");
1221 hdml->hdml_br_flag = 1;
1228 * It is a handler who processes the TR tag.
1230 * @param pdoc [i/o] The pointer to the HDML structure at the output
1231 * destination is specified.
1232 * @param node [i] The TR tag node is specified.
1233 * @return The conversion result is returned.
1236 s_hdml_end_tr_tag(void* pdoc, Node* UNUSED(child))
1240 hdml = GET_HDML(pdoc);
1247 * It is a handler who processes the FONT tag.
1249 * @param pdoc [i/o] The pointer to the HDML structure at the output
1250 * destination is specified.
1251 * @param node [i] The FONT tag node is specified.
1252 * @return The conversion result is returned.
1255 s_hdml_start_font_tag(void* pdoc, Node* UNUSED(node))
1259 hdml = GET_HDML(pdoc);
1266 * It is a handler who processes the FONT tag.
1268 * @param pdoc [i/o] The pointer to the HDML structure at the output
1269 * destination is specified.
1270 * @param node [i] The FONT tag node is specified.
1271 * @return The conversion result is returned.
1274 s_hdml_end_font_tag(void* pdoc, Node* UNUSED(child))
1278 hdml = GET_HDML(pdoc);
1285 * It is a handler who processes the FORM tag.
1287 * @param pdoc [i/o] The pointer to the HDML structure at the output
1288 * destination is specified.
1289 * @param node [i] The FORM tag node is specified.
1290 * @return The conversion result is returned.
1293 s_hdml_start_form_tag(void* pdoc, Node* node)
1301 hdml = GET_HDML(pdoc);
1306 hdml->form_tmp = apr_psprintf(r->pool,
1307 "<NODISPLAY NAME=F%d>\r\n",
1308 hdml->pure_form_cnt);
1309 hdml->form_tmp = apr_pstrcat(r->pool,
1311 "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",
1313 /* Get Attributes */
1314 for (attr = qs_get_attr(doc,node);
1316 attr = qs_get_next_attr(doc,attr)) {
1321 name = qs_get_attr_name(doc,attr);
1322 value = qs_get_attr_value(doc,attr);
1324 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "action") == 0) {
1325 value = chxj_encoding_parameter(hdml->doc->r, value);
1326 act = apr_psprintf(r->pool, "%s", value);
1332 hdml->form_tmp = apr_pstrcat(r->pool,
1337 hdml->form_tmp = apr_pstrcat(r->pool,
1341 hdml->form_tmp = apr_pstrcat(r->pool,
1346 hdml->hdml_br_flag = 0;
1353 * handler of the form end tag.
1355 * @param pdoc [i/o] The pointer to the HDML structure at the output
1356 * destination is specified.
1357 * @param child [i] unused.
1358 * @return The HDML output result after it edits it is returned.
1361 s_hdml_end_form_tag(void* pdoc, Node* UNUSED(child))
1366 hdml = GET_HDML(pdoc);
1369 s_output_to_postdata(hdml, "_chxj_dmy=");
1371 hdml->form_tmp = apr_pstrcat(r->pool,
1373 hdml->postdata[hdml->pure_form_cnt],
1376 hdml->form_tmp = apr_pstrcat(r->pool,
1378 "\" CLEAR=TRUE >\r\n",
1380 hdml->form_tmp = apr_pstrcat(r->pool,
1385 s_output_to_hdml_card(hdml, hdml->form_tmp);
1387 hdml->form_tmp = NULL;
1388 hdml->pure_form_cnt++;
1395 * It is a handler that takes charge of the processing of the input tag.
1397 * @param pdoc [i/o] The pointer to the HDML structure at the output
1398 * destination is specified.
1399 * @param node [i] The tag node to be processed is specified.
1402 s_hdml_start_input_tag(void* pdoc, Node* node)
1408 hdml = GET_HDML(pdoc);
1411 /*--------------------------------------------------------------------------*/
1412 /* The attribute of the input tag is acquired. */
1413 /*--------------------------------------------------------------------------*/
1414 for (attr = qs_get_attr(doc,node);
1416 attr = qs_get_next_attr(doc,attr)) {
1421 name = qs_get_attr_name(doc,attr);
1422 value = qs_get_attr_value(doc,attr);
1424 if (STRCASEEQ('t','T',"type",name)) {
1425 if (STRCASEEQ('t','T',"text",value)) {
1426 /*--------------------------------------------------------------------*/
1427 /* "input type ='text'" tag is processed. */
1428 /*--------------------------------------------------------------------*/
1429 s_hdml_do_input_text_tag(hdml, node);
1431 else if (STRCASEEQ('p','P',"password",value)) {
1432 /*--------------------------------------------------------------------*/
1433 /* "input type='password'" tag is processed. */
1434 /*--------------------------------------------------------------------*/
1435 s_hdml_do_input_password_tag(hdml, node);
1437 else if (STRCASEEQ('s','S',"submit",value)) {
1438 /*--------------------------------------------------------------------*/
1439 /* "input type='submit'" tag is processed. */
1440 /*--------------------------------------------------------------------*/
1441 s_hdml_do_input_submit_tag(hdml, node);
1443 else if (STRCASEEQ('h','H',"hidden",value)) {
1444 /*--------------------------------------------------------------------*/
1445 /* "input type='hidden'" tag is processed. */
1446 /*--------------------------------------------------------------------*/
1447 s_hdml_do_input_hidden_tag(hdml, node);
1449 else if (STRCASEEQ('r','R',"radio",value)) {
1450 /*--------------------------------------------------------------------*/
1451 /* "input type='radio'" tag is processed. */
1452 /*--------------------------------------------------------------------*/
1453 s_hdml_do_input_radio_tag(hdml, node);
1455 else if (STRCASEEQ('c','C',"checkbox",value)) {
1456 /*--------------------------------------------------------------------*/
1457 /* "input type='checkbox'" tag is processed. */
1458 /*--------------------------------------------------------------------*/
1459 s_hdml_do_input_checkbox_tag(hdml, node);
1461 else if (STRCASEEQ('r','R',"reset",value)) {
1462 /*--------------------------------------------------------------------*/
1463 /* "input type='reset'" tag is processed. */
1464 /*--------------------------------------------------------------------*/
1465 s_hdml_do_input_reset_tag(hdml, node);
1468 else if (STRCASEEQ('n','N',"name",name)) {
1471 else if (STRCASEEQ('v','V',"value",name)) {
1474 else if (STRCASEEQ('s','S',"size",name)) {
1477 else if (STRCASEEQ('m','M',"maxlength",name)) {
1480 else if (STRCASEEQ('c','C',"checked",name)) {
1483 else if (STRCASEEQ('a','A',"accesskey",name)) {
1486 else if (STRCASEEQ('i','I',"istyle",name)) {
1491 hdml->hdml_br_flag = 0;
1498 * The substitution processing of tag "input type = text" is done.
1500 * @param hdml [i/o] The pointer to the HDML structure at the output
1501 * destination is specified.
1502 * @param tag [i] The tag node of input type=text is specified.
1505 s_hdml_do_input_text_tag(hdml_t *hdml, Node *tag)
1519 s_hdml_tag_output_upper_half(hdml, tag);
1522 s_output_to_hdml_out(hdml,
1523 apr_psprintf(r->pool,
1524 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1525 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1527 s_get_form_no(r, hdml),
1528 hdml->var_cnt[hdml->pure_form_cnt],
1529 s_get_form_no(r, hdml),
1530 hdml->var_cnt[hdml->pure_form_cnt]
1533 s_output_to_hdml_out(hdml,
1534 apr_psprintf(r->pool,
1535 "[$%s%02d]</A>\r\n" ,
1536 s_get_form_no(r, hdml),
1537 hdml->var_cnt[hdml->pure_form_cnt]));
1539 /*--------------------------------------------------------------------------*/
1540 /* ENTRY CARD is output here. */
1541 /*--------------------------------------------------------------------------*/
1542 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1543 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1544 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1550 nm = qs_get_name_attr(doc, tag, r);
1552 nm = qs_alloc_zero_byte_string(r);
1555 s_output_to_postdata(hdml,
1556 apr_psprintf(r->pool,
1559 s_get_form_no(r, hdml),
1560 hdml->var_cnt[hdml->pure_form_cnt]));
1562 mlen = qs_get_maxlength_attr (doc, tag, r);
1563 is = qs_get_istyle_attr (doc, tag, r);
1564 val = qs_get_value_attr (doc, tag, r);
1566 fmt = qs_conv_istyle_to_format(r, is);
1567 DBG(r,"qs_conv_istyle_to_format end");
1571 for (ii=0; ii<strlen(mlen); ii++) {
1572 if (mlen[ii] < '0' || mlen[ii] > '9') {
1573 mlen = apr_psprintf(r->pool, "0");
1577 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1580 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1583 s_output_to_hdml_card(hdml,
1584 " MARKABLE=FALSE>\r\n"
1585 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1589 s_output_to_init_vars(hdml,
1590 apr_psprintf(r->pool,
1592 s_get_form_no(r, hdml),
1593 hdml->var_cnt[hdml->pure_form_cnt],
1594 chxj_escape_uri(r->pool,val)));
1596 s_output_to_init_vars(hdml,
1597 apr_psprintf(r->pool,
1599 s_get_form_no(r, hdml),
1600 hdml->var_cnt[hdml->pure_form_cnt]));
1602 hdml->var_cnt[hdml->pure_form_cnt]++;
1607 * The substitution processing of tag "input type = password" is done.
1609 * @param hdml [i/o] The pointer to the HDML structure at the output
1610 * destination is specified.
1611 * @param tag [i] The tag node of input type=password is specified.
1614 s_hdml_do_input_password_tag(hdml_t* hdml, Node* tag)
1627 s_hdml_tag_output_upper_half(hdml, tag);
1630 s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1631 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1632 s_output_to_hdml_out(hdml,
1633 apr_psprintf(r->pool,
1634 "VARS=\"V=$%s%02d\" ",
1635 s_get_form_no(r, hdml),
1636 hdml->var_cnt[hdml->pure_form_cnt]));
1638 s_output_to_hdml_out(hdml,
1639 apr_psprintf(r->pool, "RECEIVE=%s%02d>" ,
1640 s_get_form_no(r, hdml),
1641 hdml->var_cnt[hdml->pure_form_cnt]));
1642 s_output_to_hdml_out(hdml,
1643 apr_psprintf(r->pool, "[$%s%02d]</A>\r\n" ,
1644 s_get_form_no(r, hdml),
1645 hdml->var_cnt[hdml->pure_form_cnt]));
1647 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1648 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1649 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1656 nm = qs_get_name_attr(doc, tag, r);
1658 nm = qs_alloc_zero_byte_string(r);
1660 s_output_to_postdata(hdml,
1661 apr_psprintf(r->pool,
1664 s_get_form_no(r, hdml),
1665 hdml->var_cnt[hdml->pure_form_cnt]));
1667 mlen = qs_get_maxlength_attr (doc, tag, r);
1668 val = qs_get_value_attr (doc, tag, r);
1669 /*--------------------------------------------------------------------------*/
1670 /* Default is a figure input. */
1671 /*--------------------------------------------------------------------------*/
1672 fmt = apr_psprintf(r->pool, "N");
1674 if (chxj_chk_numeric(mlen) != 0)
1675 mlen = apr_psprintf(r->pool, "0");
1676 s_output_to_hdml_card(hdml,
1677 apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1680 s_output_to_hdml_card(hdml,
1681 apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1683 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1685 s_output_to_hdml_card(hdml,
1686 " MARKABLE=FALSE>\r\n"
1687 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1691 s_output_to_init_vars(hdml,
1692 apr_psprintf(r->pool, "%s%02d=%s",
1693 s_get_form_no(r, hdml),
1694 hdml->var_cnt[hdml->pure_form_cnt],
1695 chxj_escape_uri(r->pool,val)));
1697 s_output_to_init_vars(hdml,
1698 apr_psprintf(r->pool, "%s%02d=",
1699 s_get_form_no(r, hdml),
1700 hdml->var_cnt[hdml->pure_form_cnt]));
1702 hdml->var_cnt[hdml->pure_form_cnt]++;
1706 * The substitution processing of tag "input type = submit" is done.
1708 * @param hdml [i/o] The pointer to the HDML structure at the output
1709 * destination is specified.
1710 * @param tag [i] The tag node of input type=submit is specified.
1713 s_hdml_do_input_submit_tag(hdml_t* hdml, Node* tag)
1715 Doc* doc = hdml->doc;
1716 request_rec* r = doc->r;
1720 s_hdml_tag_output_upper_half(hdml, tag);
1722 s_output_to_hdml_out(hdml,
1723 apr_psprintf(r->pool,
1724 "<A TASK=GO LABEL=OK DEST=#F%d ",
1725 hdml->pure_form_cnt));
1727 /*--------------------------------------------------------------------------*/
1728 /* get name and value attribute */
1729 /*--------------------------------------------------------------------------*/
1730 nm = qs_get_name_attr (doc, tag, r);
1731 val = qs_get_value_attr (doc, tag, r);
1734 s_output_to_hdml_out(hdml,
1735 apr_psprintf(r->pool, "VARS=\"%s=%s\" ",
1737 chxj_escape_uri(r->pool,val)));
1738 if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1739 s_output_to_postdata(hdml,
1740 apr_psprintf(r->pool,"%s%s=$%s",
1741 SUBMIT_BUTTON_PREFIX, nm, nm));
1744 s_output_to_hdml_out(hdml, ">" );
1746 s_output_to_hdml_out(hdml, val);
1748 s_output_to_hdml_out(hdml, "</A>\r\n" );
1753 * The substitution processing of tag "input type = reset" is done.
1755 * @param hdml [i/o] The pointer to the HDML structure at the output
1756 * destination is specified.
1757 * @param tag [i] The tag node of input type=submit is specified.
1760 s_hdml_do_input_reset_tag(hdml_t *hdml, Node *tag)
1762 Doc *doc = hdml->doc;
1763 request_rec *r = doc->r;
1767 s_hdml_tag_output_upper_half(hdml, tag);
1769 s_output_to_hdml_out(hdml,
1770 apr_psprintf(r->pool,
1771 "<A TASK=GO LABEL=OK DEST=#D0>"));
1773 /*--------------------------------------------------------------------------*/
1774 /* get name and value attribute */
1775 /*--------------------------------------------------------------------------*/
1776 nm = qs_get_name_attr (doc, tag, r);
1777 val = qs_get_value_attr (doc, tag, r);
1779 s_output_to_hdml_out(hdml, val);
1781 s_output_to_hdml_out(hdml, "</A>\r\n" );
1786 * The substitution processing of tag "input type = hidden" is done.
1788 * @param hdml [i/o] The pointer to the HDML structure at the output
1789 * destination is specified.
1790 * @param tag [i] The tag node of input type=hidden is specified.
1793 s_hdml_do_input_hidden_tag(hdml_t* hdml, Node* tag)
1795 Doc* doc = hdml->doc;
1796 request_rec* r = doc->r;
1800 /*--------------------------------------------------------------------------*/
1801 /* get name and value attribute */
1802 /*--------------------------------------------------------------------------*/
1803 nm = qs_get_name_attr (doc, tag, r);
1804 val = qs_get_value_attr (doc, tag, r);
1807 s_output_to_postdata(hdml,
1808 apr_psprintf(r->pool,
1811 chxj_escape_uri(r->pool, val)));
1816 * The substitution processing of tag "input type = radio" is done.
1818 * @param hdml [i/o] The pointer to the HDML structure at the output
1819 * destination is specified.
1820 * @param tag [i] The tag node of input type=radio is specified.
1823 s_hdml_do_input_radio_tag(hdml_t* hdml, Node* tag)
1825 Doc* doc = hdml->doc;
1826 request_rec* r = doc->r;
1834 s_hdml_tag_output_upper_half(hdml, tag);
1836 /*--------------------------------------------------------------------------*/
1837 /* get name and value attribute */
1838 /*--------------------------------------------------------------------------*/
1839 nm = qs_get_name_attr (doc, tag, r);
1840 val = qs_get_value_attr (doc, tag, r);
1842 /*--------------------------------------------------------------------------*/
1843 /* The same name is searched out from the list made beforehand. */
1844 /*--------------------------------------------------------------------------*/
1845 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1846 if (! hdml->radio_name_list[ii]) {
1848 DBG(r, "Oops... radio list is null[%d]", ii);
1849 /*----------------------------------------------------------------------*/
1850 /* Processing is ended because it doesn't happen off the fly. */
1851 /*----------------------------------------------------------------------*/
1855 if (strcasecmp(hdml->radio_name_list[ii], nm) == 0)
1858 if (ii == MAX_RADIO_COUNT) {
1860 DBG(r,"Oops... The same name was not in the list. ");
1861 /*------------------------------------------------------------------------*/
1862 /* Processing is ended because it doesn't happen off the fly. */
1863 /*------------------------------------------------------------------------*/
1867 s_output_to_hdml_out(hdml,
1868 apr_psprintf(r->pool,
1871 "DEST=#R%d VARS=\"VAL=%s\" "
1877 if (hdml->radio_out_cnt[ii] == 0) {
1878 s_output_to_hdml_card(hdml,
1879 apr_psprintf(r->pool,
1880 "<NODISPLAY NAME=R%d>\r\n",
1882 s_output_to_hdml_card(hdml,
1883 apr_psprintf(r->pool,
1885 "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1888 kk = hdml->radio_out_cnt[ii];
1889 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
1890 if (! hdml->radio_value_list[ii][jj])
1895 for (jj=0; jj<r_cnt; jj++) {
1896 if (! hdml->radio_value_list[ii][jj])
1900 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1901 if (hdml->radio_out_cnt[ii] == 0)
1902 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1905 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1906 if (hdml->radio_out_cnt[ii] == 0) {
1908 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1910 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1917 s_output_to_hdml_out(hdml,
1918 apr_psprintf(r->pool, "\" >$%s_%02d</A>",
1920 hdml->radio_out_cnt[ii]));
1921 if (! hdml->radio_out_cnt[ii]) {
1922 s_output_to_hdml_card(hdml, "\">\r\n" );
1923 s_output_to_hdml_card(hdml, "</NODISPLAY>\r\n");
1925 s_output_to_postdata(hdml, apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1927 for (jj=0; jj<r_cnt; jj++) {
1928 if (hdml->radio_value_list[ii][jj] && hdml->radio_checked_value[ii]) {
1929 if (strcasecmp(hdml->radio_value_list[ii][jj],
1930 hdml->radio_checked_value[ii]) == 0) {
1931 s_output_to_init_vars(hdml,
1932 apr_psprintf(r->pool,
1938 s_output_to_init_vars(hdml,
1939 apr_psprintf(r->pool,
1946 s_output_to_init_vars(hdml,
1947 apr_psprintf(r->pool,
1954 if (hdml->radio_checked_value[ii]) {
1955 DBG(r,"radio button is checked. checked value is [%s]",
1956 hdml->radio_checked_value[ii]);
1957 s_output_to_init_vars(hdml,
1958 apr_psprintf(r->pool,
1961 hdml->radio_checked_value[ii]));
1964 DBG(r,"radio button is not checked. checked value is []");
1965 s_output_to_init_vars(hdml,
1966 apr_psprintf(r->pool,
1971 hdml->radio_out_cnt[ii]++;
1975 * The substitution processing of tag "input type = checkbox" is done.
1977 * @param hdml [i/o] The pointer to the HDML structure at the output
1978 * destination is specified.
1979 * @param tag [i] The tag node of input type=checkbox is specified.
1982 s_hdml_do_input_checkbox_tag(hdml_t* hdml, Node* tag)
1984 Doc* doc = hdml->doc;
1985 request_rec* r = doc->r;
1990 /*--------------------------------------------------------------------------*/
1991 /* It is posted to the one without the checked attribute. */
1992 /* However, they were able to be removed with INPUT FILTER. */
1993 /*--------------------------------------------------------------------------*/
1994 if (! hdml->has_checkbox) {
1995 hdml->has_checkbox++;
1996 s_output_to_hdml_card(hdml,
1997 "<NODISPLAY NAME=\"_chk\">\r\n"
1998 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1999 "RETVALS=\"_uchk;$V;X\" >\r\n"
2001 "<NODISPLAY NAME=\"_uchk\">\r\n"
2002 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
2003 "RETVALS=\"_chk;;_\" >\r\n"
2006 DBG(r, "wrote checkbox hdml card.");
2009 /*--------------------------------------------------------------------------*/
2010 /* It is examined whether it is CHECKED. */
2011 /*--------------------------------------------------------------------------*/
2012 chk = qs_is_checked_checkbox_attr(doc, tag, r);
2014 /*--------------------------------------------------------------------------*/
2015 /* The value of the name attribute and the value attribute is acquired */
2017 /*--------------------------------------------------------------------------*/
2018 val = qs_get_value_attr(doc, tag, r);
2019 nm = qs_get_name_attr(doc, tag, r);
2022 val = qs_alloc_zero_byte_string(r);
2025 nm = qs_alloc_zero_byte_string(r);
2027 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2028 "<A TASK=GOSUB LABEL=\"check\" "
2029 "DEST=\"#$%s%02d\" "
2031 "RECEIVE=\"%s%02d;%s%02d;%s%02d\">"
2033 s_get_form_no(r, hdml),
2034 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2036 s_get_form_no(r, hdml),
2037 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2038 s_get_form_no(r, hdml),
2039 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2040 s_get_form_no(r, hdml),
2041 hdml->var_cnt[hdml->pure_form_cnt] + 2,
2042 s_get_form_no(r, hdml),
2043 hdml->var_cnt[hdml->pure_form_cnt] + 2));
2045 s_output_to_init_vars(hdml,
2046 apr_psprintf(r->pool,
2047 "%s%02d=_uchk&%s%02d=%s&%s%02d=X",
2048 s_get_form_no(r, hdml),
2049 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2050 s_get_form_no(r, hdml),
2051 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2052 chxj_escape_uri(r->pool,val),
2053 s_get_form_no(r, hdml),
2054 hdml->var_cnt[hdml->pure_form_cnt] + 2
2058 s_output_to_init_vars(hdml,
2059 apr_psprintf(r->pool,
2060 "%s%02d=_chk&%s%02d=&%s%02d=_",
2061 s_get_form_no(r, hdml),
2062 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2063 s_get_form_no(r, hdml),
2064 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2065 s_get_form_no(r, hdml),
2066 hdml->var_cnt[hdml->pure_form_cnt] + 2
2070 s_output_to_postdata(hdml,
2071 apr_psprintf(r->pool, "%s%s=$%s%02d",
2074 s_get_form_no(r, hdml),
2075 hdml->var_cnt[hdml->pure_form_cnt] + 1));
2077 hdml->var_cnt[hdml->pure_form_cnt] += 3;
2081 * The ISTYLE attribute is converted into the HDML form.
2083 * @param r [i] To use POOL, the pointer to request_rec is specified.
2084 * @param is [i] The value of the ISTYLE attribute is specified.
2085 * @return The ISTYLE attribute converted into the HDML form is returned.
2088 qs_conv_istyle_to_format(request_rec* r, char* is)
2097 fmt = apr_psprintf(r->pool, "M");
2100 fmt = apr_psprintf(r->pool, "M");
2103 fmt = apr_psprintf(r->pool, "m");
2106 fmt = apr_psprintf(r->pool, "N");
2117 * It is a handler who processes the INPUT tag.
2119 * @param pdoc [i/o] The pointer to the HDML structure at the output
2120 * destination is specified.
2121 * @param node [i] The INPUT tag node is specified.
2122 * @return The conversion result is returned.
2125 s_hdml_end_input_tag(void* pdoc, Node* UNUSED(child))
2129 hdml = GET_HDML(pdoc);
2136 * It is a handler who processes the CENTER tag.
2138 * @param pdoc [i/o] The pointer to the HDML structure at the output
2139 * destination is specified.
2140 * @param node [i] The CENTER tag node is specified.
2141 * @return The conversion result is returned.
2144 s_hdml_start_center_tag(void* pdoc, Node* UNUSED(node))
2148 hdml = GET_HDML(pdoc);
2153 if (hdml->hdml_br_flag == 0)
2154 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2156 hdml = s_output_to_hdml_out(hdml, "<CENTER>");
2163 * It is a handler who processes the CENTER tag.
2165 * @param pdoc [i/o] The pointer to the HDML structure at the output
2166 * destination is specified.
2167 * @param node [i] The CENTER tag node is specified.
2168 * @return The conversion result is returned.
2171 s_hdml_end_center_tag(void* pdoc, Node* UNUSED(child))
2175 hdml = GET_HDML(pdoc);
2178 hdml->in_center = 0;
2180 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2181 hdml->hdml_br_flag = 1;
2188 * It is a handler who processes the HR tag.
2190 * @param pdoc [i/o] The pointer to the HDML structure at the output
2191 * destination is specified.
2192 * @param node [i] The HR tag node is specified.
2193 * @return The conversion result is returned.
2196 s_hdml_start_hr_tag(void* pdoc, Node* UNUSED(node))
2200 hdml = GET_HDML(pdoc);
2202 if (hdml->hdml_br_flag == 0) {
2203 s_output_to_hdml_out(hdml, "<BR>\r\n");
2204 if (hdml->in_center)
2207 if (hdml->div_in_center)
2208 hdml->div_in_center--;
2211 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");
2213 hdml->hdml_br_flag = 1;
2220 * It is a handler who processes the HR tag.
2222 * @param pdoc [i/o] The pointer to the HDML structure at the output
2223 * destination is specified.
2224 * @param node [i] The HR tag node is specified.
2225 * @return The conversion result is returned.
2228 s_hdml_end_hr_tag(void* pdoc, Node* UNUSED(child))
2232 hdml = GET_HDML(pdoc);
2239 * It is a handler who processes the LI tag.
2241 * @param pdoc [i/o] The pointer to the HDML structure at the output
2242 * destination is specified.
2243 * @param node [i] The LI tag node is specified.
2244 * @return The conversion result is returned.
2247 s_hdml_start_li_tag(void *pdoc, Node *UNUSED(node))
2249 hdml_t *hdml = GET_HDML(pdoc);
2252 if (hdml->hdml_br_flag == 0) {
2253 s_output_to_hdml_out(hdml, "<BR>\r\n");
2254 if (hdml->in_center)
2257 if (hdml->div_in_center)
2258 hdml->div_in_center--;
2260 s_output_to_hdml_out(hdml, "<WRAP>");
2261 for (i=0; i<hdml->dir_level; i++) {
2262 s_output_to_hdml_out(hdml, " ");
2264 hdml->hdml_br_flag = 1;
2270 * It is a handler who processes the LI tag.
2272 * @param pdoc [i/o] The pointer to the HDML structure at the output
2273 * destination is specified.
2274 * @param node [i] The LI tag node is specified.
2275 * @return The conversion result is returned.
2278 s_hdml_end_li_tag(void *pdoc, Node *UNUSED(child))
2280 hdml_t *hdml = GET_HDML(pdoc);
2281 if (hdml->hdml_br_flag == 0) {
2282 s_output_to_hdml_out(hdml, "<BR>\r\n");
2283 if (hdml->in_center)
2286 if (hdml->div_in_center)
2287 hdml->div_in_center--;
2289 hdml->hdml_br_flag = 1;
2295 * It is a handler who processes the IMG tag.
2297 * @param pdoc [i/o] The pointer to the HDML structure at the output
2298 * destination is specified.
2299 * @param node [i] The IMG tag node is specified.
2300 * @return The conversion result is returned.
2303 s_hdml_start_img_tag(void *pdoc, Node *node)
2307 #ifndef IMG_NOT_CONVERT_FILENAME
2312 hdml = GET_HDML(pdoc);
2314 #ifndef IMG_NOT_CONVERT_FILENAME
2318 s_hdml_tag_output_upper_half(hdml, node);
2320 s_output_to_hdml_out(hdml, "<img");
2322 /* Get Attributes */
2323 for (attr = qs_get_attr(doc,node);
2325 attr = qs_get_next_attr(doc,attr)) {
2327 char *name = qs_get_attr_name(doc,attr);
2328 char *value = qs_get_attr_value(doc,attr);
2329 if (STRCASEEQ('s','S',"src",name) && value && *value) {
2330 value = chxj_encoding_parameter(hdml->doc->r, value);
2331 s_output_to_hdml_out(hdml, " src=\"");
2332 #ifdef IMG_NOT_CONVERT_FILENAME
2333 s_output_to_hdml_out(hdml, value );
2335 s_output_to_hdml_out(hdml, chxj_img_conv(doc->r, spec,value));
2337 s_output_to_hdml_out(hdml, "\"" );
2339 else if (STRCASEEQ('a','A',"align",name)) {
2340 if (value && (STRCASEEQ('t','T',"top", value) ||
2341 STRCASEEQ('m','M',"middle",value) ||
2342 STRCASEEQ('b','B',"bottom",value) ||
2343 STRCASEEQ('l','L',"left", value) ||
2344 STRCASEEQ('r','R',"right", value))) {
2345 s_output_to_hdml_out(hdml, " align=\"" );
2346 s_output_to_hdml_out(hdml, value );
2347 s_output_to_hdml_out(hdml, "\"" );
2350 else if (STRCASEEQ('w','W',"width",name) && value && *value) {
2351 s_output_to_hdml_out(hdml, " width=\"");
2352 s_output_to_hdml_out(hdml, value );
2353 s_output_to_hdml_out(hdml, "\"" );
2355 else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2356 s_output_to_hdml_out(hdml, " height=\"");
2357 s_output_to_hdml_out(hdml, value );
2358 s_output_to_hdml_out(hdml, "\"" );
2360 else if (STRCASEEQ('h','H',"hspace", name) && value && *value) {
2361 s_output_to_hdml_out(hdml, " hspace=\"");
2362 s_output_to_hdml_out(hdml, value );
2363 s_output_to_hdml_out(hdml, "\"" );
2365 else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2366 s_output_to_hdml_out(hdml, " vspace=\"");
2367 s_output_to_hdml_out(hdml, value );
2368 s_output_to_hdml_out(hdml, "\"" );
2370 else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2371 s_output_to_hdml_out(hdml, " alt=\"" );
2372 s_output_to_hdml_out(hdml, value );
2373 s_output_to_hdml_out(hdml, "\"" );
2376 s_output_to_hdml_out(hdml, ">" );
2378 hdml->hdml_br_flag = 0;
2385 * It is a handler who processes the IMG tag.
2387 * @param pdoc [i/o] The pointer to the HDML structure at the output
2388 * destination is specified.
2389 * @param node [i] The IMG tag node is specified.
2390 * @return The conversion result is returned.
2393 s_hdml_end_img_tag(void *pdoc, Node *UNUSED(child))
2395 hdml_t *hdml = GET_HDML(pdoc);
2401 * It is a handler who processes the SELECT tag.
2403 * @param pdoc [i/o] The pointer to the HDML structure at the output
2404 * destination is specified.
2405 * @param node [i] The SELECT tag node is specified.
2406 * @return The conversion result is returned.
2409 s_hdml_start_select_tag(void* pdoc, Node* node)
2416 hdml = GET_HDML(pdoc);
2420 s_hdml_tag_output_upper_half(hdml, node);
2424 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2425 "<A TASK=GOSUB LABEL=\x91\x49\x91\xf0 "
2426 "VARS=\"V=$%s%02d\" DEST=#D%d "
2427 "RECEIVE=\"%s%02d;%s%02d\">"
2429 s_get_form_no(r, hdml),
2430 hdml->var_cnt[hdml->pure_form_cnt]+0,
2432 s_get_form_no(r, hdml),
2433 hdml->var_cnt[hdml->pure_form_cnt]+0,
2434 s_get_form_no(r, hdml),
2435 hdml->var_cnt[hdml->pure_form_cnt]+1,
2436 s_get_form_no(r, hdml),
2437 hdml->var_cnt[hdml->pure_form_cnt]+1));
2439 s_output_to_hdml_card(hdml,
2440 apr_psprintf(r->pool,
2441 "<CHOICE KEY=V NAME=D%d ", hdml->card_cnt));
2442 s_output_to_hdml_card(hdml,
2443 apr_psprintf(r->pool,
2444 "DEFAULT=$V METHOD=ALPHA MARKABLE=FALSE>\r\n"));
2445 /*--------------------------------------------------------------------------*/
2446 /* Get Attributes */
2447 /*--------------------------------------------------------------------------*/
2448 for (attr = qs_get_attr(doc,node);
2450 attr=qs_get_next_attr(doc,attr)) {
2452 char* name = qs_get_attr_name(doc,attr);
2453 char* value = qs_get_attr_value(doc,attr);
2454 char* selval = NULL;
2455 char* selvaltxt = NULL;
2457 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
2459 s_output_to_postdata(hdml,
2460 apr_psprintf(r->pool, "%s=$%s%02d",
2462 s_get_form_no(r, hdml),
2463 hdml->var_cnt[hdml->pure_form_cnt]));
2464 selval = qs_get_selected_value(doc, node, r);
2466 DBG(r, "selected value not found");
2467 selval = qs_alloc_zero_byte_string(r);
2470 DBG(r, "selected value found[%s]" , selval);
2472 selvaltxt = qs_get_selected_value_text(doc, node, r);
2474 selvaltxt = qs_alloc_zero_byte_string(r);
2476 DBG(r, "selvaltxt:[%s]" ,selvaltxt);
2478 s_output_to_init_vars(hdml,
2479 apr_psprintf(r->pool,
2480 "%s%02d=%s&%s%02d=%s",
2481 s_get_form_no(r, hdml),
2482 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2484 s_get_form_no(r, hdml),
2485 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2488 hdml->var_cnt[hdml->pure_form_cnt] += 2;
2493 hdml->hdml_br_flag = 0;
2499 * It is a handler who processes the SELECT tag.
2501 * @param pdoc [i/o] The pointer to the HDML structure at the output
2502 * destination is specified.
2503 * @param node [i] The SELECT tag node is specified.
2504 * @return The conversion result is returned.
2507 s_hdml_end_select_tag(void* pdoc, Node* UNUSED(node))
2511 hdml = GET_HDML(pdoc);
2513 s_output_to_hdml_card(hdml, "</CHOICE>\r\n");
2520 * It is a handler who processes the OPTION tag.
2522 * @param pdoc [i/o] The pointer to the HDML structure at the output
2523 * destination is specified.
2524 * @param node [i] The OPTION tag node is specified.
2525 * @return The conversion result is returned.
2528 s_hdml_start_option_tag(void *pdoc, Node *node)
2537 hdml = GET_HDML(pdoc);
2543 hdml->option_flag = 1;
2544 val = qs_get_value_attr(doc, node, r);
2546 /*--------------------------------------------------------------------------*/
2547 /* The child node of the object tag node acquires the value in assumption */
2548 /* that is the TEXT node. */
2549 /*--------------------------------------------------------------------------*/
2550 child = qs_get_child_node(doc, node);
2552 txtval = apr_palloc(r->pool, 1);
2556 txtval = qs_get_node_value(doc, child);
2558 DBG(r, "txtval:[%s]" , txtval);
2560 if (val && txtval) {
2561 s_output_to_hdml_card(hdml,
2562 apr_psprintf(r->pool,
2563 "<CE TASK=RETURN VALUE=\"%s\" "
2564 "RETVALS=\"$V;%s\">%s</CE>\r\n",
2566 qs_trim_string(r->pool,txtval),
2567 qs_trim_string(r->pool,txtval)));
2570 hdml->hdml_br_flag = 0;
2577 * It is a handler who processes the OPTION tag.
2579 * @param pdoc [i/o] The pointer to the HDML structure at the output
2580 * destination is specified.
2581 * @param node [i] The OPTION tag node is specified.
2582 * @return The conversion result is returned.
2585 s_hdml_end_option_tag(void* pdoc, Node* UNUSED(node))
2589 hdml = GET_HDML(pdoc);
2591 hdml->option_flag = 0;
2598 * It is a handler who processes the DIV tag.
2600 * @param pdoc [i/o] The pointer to the HDML structure at the output
2601 * destination is specified.
2602 * @param node [i] The DIV tag node is specified.
2603 * @return The conversion result is returned.
2606 s_hdml_start_div_tag(void *pdoc, Node *node)
2612 hdml = GET_HDML(pdoc);
2615 /*--------------------------------------------------------------------------*/
2616 /* If the br tag is not output immediately before the div tag appears, the */
2617 /* br tag is output. */
2618 /*--------------------------------------------------------------------------*/
2619 if (hdml->hdml_br_flag == 0) {
2620 hdml->hdml_br_flag = 1;
2621 s_output_to_hdml_out(hdml, "<BR>\r\n");
2624 /*--------------------------------------------------------------------------*/
2625 /* The object tag node is scanned. */
2626 /*--------------------------------------------------------------------------*/
2627 for (attr = qs_get_attr(doc,node);
2629 attr = qs_get_next_attr(doc,attr)) {
2630 char *name = qs_get_attr_name(doc,attr);
2631 char *value = qs_get_attr_value(doc,attr);
2632 if (STRCASEEQ('a','A',"align",name)) {
2633 if (STRCASEEQ('r','R',"right",value)) {
2634 hdml->div_right_flag = 1;
2635 s_output_to_hdml_out(hdml, "<RIGHT>");
2636 hdml->hdml_br_flag = 0;
2639 else if (STRCASEEQ('c','C',"center",value)) {
2640 hdml->div_center_flag = 1;
2641 s_output_to_hdml_out(hdml, "<CENTER>");
2642 hdml->hdml_br_flag = 0;
2647 hdml->hdml_br_flag = 0;
2654 * It is a handler who processes the DIV tag.
2656 * @param pdoc [i/o] The pointer to the HDML structure at the output
2657 * destination is specified.
2658 * @param node [i] The DIV tag node is specified.
2659 * @return The conversion result is returned.
2662 s_hdml_end_div_tag(void *pdoc, Node *UNUSED(node))
2667 hdml = GET_HDML(pdoc);
2670 if (hdml->div_right_flag == 1) {
2671 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2672 hdml->div_right_flag = 0;
2674 if (hdml->div_center_flag == 1) {
2675 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2676 hdml->div_center_flag = 0;
2677 hdml->div_in_center = 0;
2685 * It is a wrapper of the apr_pstrcat function.
2687 * @param r [i] To use POOL, the pointer to request_rec is specified.
2688 * @param o [i] The character string of connected origin is specified.
2689 * @param s [i] The character string connected with 'o' parameter is
2691 * @param len [i/o] The pointer to the area where the character string
2692 * length is stored is specified.
2693 * @return The character string after it connects it is returned.
2696 qs_out_apr_pstrcat(request_rec *r, char *o, char *s, int *len)
2698 *len = (strlen(s) + *len);
2699 return apr_pstrcat(r->pool, o, s, NULL);
2703 * The prepositive character string used to generate the variable for HDML is
2706 * @param r [i] To use POOL, the pointer to request_rec is specified.
2707 * @param hdml [i] The pointer to the HDML structure that maintains the seed
2708 * to generate it is specified.
2709 * @return The character string after it generates it is returned.
2712 s_s_get_form_no(request_rec *r, hdml_t *hdml)
2718 fc = hdml->form_cnt;
2720 apr_time_exp_tz(&tm, hdml->form_cnt, 0);
2722 result = apr_psprintf(r->pool, "%c",(int)('A' + ((fc / 100) % 26)));
2723 result = apr_pstrcat(r->pool, result,
2724 apr_psprintf(r->pool, "%02d%02d%02d",
2732 * The number of tag nodes .."Input type =' radio '".. is counted.
2734 * @param hdml [i] The pointer to the HDML structure is specified.
2735 * @param node [i] The first parents node that counts the radio tag node is
2739 s_hdml_count_radio_tag(hdml_t* hdml, Node* node)
2748 /*--------------------------------------------------------------------------*/
2749 /* All the child nodes of the specified node are scanned. */
2750 /*--------------------------------------------------------------------------*/
2751 for (child = qs_get_child_node(doc,node);
2753 child = qs_get_next_node(doc,child)) {
2764 name = qs_get_node_name(doc,child);
2765 if (strcasecmp(name, "input") != 0) {
2766 s_hdml_count_radio_tag(hdml, child);
2770 DBG(r,"found input tag");
2772 type = qs_get_type_attr(doc, child, r);
2774 ERR(r, "Oops! The input tag without the type attribute has been found.Please give a type.");
2778 if (strcasecmp(type, "radio") != 0)
2781 DBG(r, "found type=radio");
2783 rname = qs_get_name_attr (doc, child, r);
2784 rvalue = qs_get_value_attr(doc, child, r);
2787 /*----------------------------------------------------------------------*/
2788 /* Oops!. The input tag without the name attribute has been found. */
2789 /*----------------------------------------------------------------------*/
2790 DBG(r, "Oops!. The input tag without the name attribute has been found. Please give a name.");
2794 DBG(r, "found name attribute");
2796 /*------------------------------------------------------------------------*/
2797 /* It scans in radio_name_list. When the same value exists, the */
2798 /* value is overwrited. */
2799 /* The value is written in a new area when not is. */
2800 /*------------------------------------------------------------------------*/
2801 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
2802 if (! hdml->radio_name_list[ii]) {
2803 DBG(r, "new name:[%s]", rname);
2806 if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2807 DBG(r, "already registered name:[%s]", rname);
2811 if (ii == MAX_RADIO_COUNT) {
2812 DBG(r, apr_psprintf(r->pool,
2813 "I do not understand the name of the radiobutton "
2814 "of %d piece or more. Please decrease "
2815 "the number of radiobuttons.",
2820 DBG(r,"add radio name:[%s]" ,rname);
2822 hdml->radio_name_list[ii] = apr_pstrdup(r->pool, rname);
2824 /*------------------------------------------------------------------------*/
2825 /* It adds it to radio_value_list. */
2826 /*------------------------------------------------------------------------*/
2827 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) {
2828 if (!hdml->radio_value_list[ii][jj])
2831 if (jj == MAX_RADIO_VALUE_COUNT) {
2832 DBG(r, apr_psprintf(r->pool,
2833 "I do not understand the value of the radiobutton "
2834 "of %d piece or more. Please decrease "
2835 "the number of radiobuttons.",
2836 MAX_RADIO_VALUE_COUNT));
2839 hdml->radio_value_list[ii][jj] = apr_pstrdup(r->pool, rvalue);
2841 /*------------------------------------------------------------------------*/
2842 /* Now let's be the checked attribute or scan. */
2843 /*------------------------------------------------------------------------*/
2844 chkd = qs_get_checked_attr(hdml->doc, child, hdml->doc->r);
2846 DBG(r,apr_psprintf(r->pool,
2847 "The tag scanned now had the checked "
2848 "attribute. The value is [%s].",
2850 hdml->radio_checked_value[ii] = apr_pstrdup(r->pool, rvalue);
2857 * The character string is added, and output to the out member of the HDML
2860 * @param hdml [i/o] The pointer to the HDML structure that maintains the out
2861 * member at the output destination is specified.
2862 * @param s [i] The character string that should be output is specified.
2863 * @return The pointer to the HDML structure after it processes it is returned.
2866 s_output_to_hdml_out(hdml_t *hdml, char *s)
2868 hdml->out = qs_out_apr_pstrcat(hdml->doc->r, hdml->out, s, &hdml->out_len);
2875 * The character string is added, and output to the card member of the HDML
2878 * @param hdml [i/o] The pointer to the HDML structure that maintains the
2879 * card member at the output destination is specified.
2880 * @param s [i] The character string that should be output is specified.
2881 * @return The pointer to the HDML structure after it processes it is returned.
2884 s_output_to_hdml_card(hdml_t* hdml, char* s)
2886 hdml->card = qs_out_apr_pstrcat(hdml->doc->r, hdml->card, s, &hdml->card_len);
2894 * The data for the post is added, and output.
2896 * @param hdml [i/o] The pointer to the HDML structure at the output
2897 * destination is specified.
2898 * @param s [i] The character string that wants to output to postdata is
2902 s_output_to_postdata(hdml_t* hdml, char* s)
2908 if (strlen(hdml->postdata[hdml->pure_form_cnt]))
2909 hdml->postdata[hdml->pure_form_cnt] =
2910 apr_pstrcat(r->pool,
2911 hdml->postdata[hdml->pure_form_cnt],
2915 hdml->postdata[hdml->pure_form_cnt] =
2916 apr_pstrcat(r->pool,
2917 hdml->postdata[hdml->pure_form_cnt],
2918 qs_trim_string(r->pool, s),
2921 DBG(r, "POSTDATA:[%s]", hdml->postdata[hdml->pure_form_cnt] );
2927 * The tag output upper half.
2929 * @param hdml [i/o] The pointer to the HDML structure at the output
2930 * destination is specified.
2931 * @param node [i] The A tag node is specified.
2934 s_hdml_tag_output_upper_half(hdml_t *hdml, Node *UNUSED(node))
2936 if (hdml->hdml_br_flag == 1
2937 && hdml->div_right_flag == 1) {
2938 s_output_to_hdml_out(hdml, "<RIGHT>");
2939 hdml->hdml_br_flag = 0;
2942 if (hdml->hdml_br_flag == 1
2944 && hdml->in_center == 0) {
2945 s_output_to_hdml_out(hdml, "<CENTER>");
2947 hdml->hdml_br_flag = 0;
2950 if (hdml->hdml_br_flag == 1
2951 && hdml->div_center_flag > 0
2952 && hdml->div_in_center == 0) {
2953 s_output_to_hdml_out(hdml, "<CENTER>");
2954 hdml->div_in_center++;
2955 hdml->hdml_br_flag = 0;
2962 * The data for the init_vars is added, and output.
2964 * @param hdml [i/o] The pointer to the HDML structure at the output
2965 * destination is specified.
2966 * @param s [i] The character string that wants to output to postdata is
2970 s_output_to_init_vars(hdml_t* hdml, char* s)
2972 request_rec* r = hdml->doc->r;
2974 if (strlen(hdml->init_vars))
2975 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, "&", NULL);
2977 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, qs_trim_string(r->pool,s), NULL);
2979 DBG(r, "INIT_VARS:[%s]", hdml->init_vars);
2985 s_hdml_chxjif_tag(void* pdoc, Node* node)
2991 hdml = GET_HDML(pdoc);
2994 for (child = qs_get_child_node(doc, node);
2996 child = qs_get_next_node(doc, child)) {
2997 s_output_to_hdml_out(hdml, child->otext);
2998 s_hdml_chxjif_tag(hdml, child);
3004 s_hdml_text_tag(void* pdoc, Node* child)
3014 int one_line_count = 0;
3017 hdml = GET_HDML(pdoc);
3021 textval = qs_get_node_value(doc,child);
3022 if (strlen(textval) == 0) {
3026 if (hdml->option_flag == 1) {
3030 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3031 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3032 tdst = apr_palloc(r->pool, 1);
3038 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3040 int rtn = s_hdml_search_emoji(hdml, &textval[ii], &out);
3042 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3044 one_line_count+=(rtn-1);
3047 if (hdml->hdml_blockquote_flag) {
3048 if (one_line_count == 0) {
3049 tdst = qs_out_apr_pstrcat(r, tdst, "<WRAP> <TAB>", &tdst_len);
3051 if (is_sjis_kanji(textval[ii])) {
3052 one_byte[0] = textval[ii+0];
3053 one_byte[1] = textval[ii+1];
3055 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3060 one_byte[0] = textval[ii+0];
3062 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3064 if (one_byte[0] == '\n') {
3070 if (hdml->pre_flag) {
3071 if (one_line_count == 0) {
3072 tdst = qs_out_apr_pstrcat(r, tdst, "<LINE>", &tdst_len);
3074 if (is_sjis_kanji(textval[ii])) {
3075 one_byte[0] = textval[ii+0];
3076 one_byte[1] = textval[ii+1];
3078 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3083 one_byte[0] = textval[ii+0];
3085 if (one_byte[0] == ' ') {
3086 tdst = qs_out_apr_pstrcat(r, tdst, " ", &tdst_len);
3089 tdst = qs_out_apr_pstrcat(r, tdst, chxj_ap_escape_html(r->pool, one_byte), &tdst_len);
3092 if (one_byte[0] == '\n') {
3098 if (is_sjis_kanji(textval[ii])) {
3099 one_byte[0] = textval[ii+0];
3100 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3101 one_byte[0] = textval[ii+1];
3102 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3106 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3107 one_byte[0] = textval[ii+0];
3108 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3111 memcpy(tmp, textval, strlen(textval)-1);
3113 s_hdml_tag_output_upper_half(hdml, child->parent);
3114 s_output_to_hdml_out(hdml, tdst);
3115 hdml->hdml_br_flag = 0;
3122 * It is a handler who processes the BLOCKQUOTE tag.
3124 * @param pdoc [i/o] The pointer to the HDML structure at the output
3125 * destination is specified.
3126 * @param node [i] The BLOCKQUOTE tag node is specified.
3127 * @return The conversion result is returned.
3130 s_hdml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3132 hdml_t *hdml = GET_HDML(pdoc);
3133 hdml->hdml_blockquote_flag++;
3139 * It is a handler who processes the BLOCKQUOTE tag.
3141 * @param pdoc [i/o] The pointer to the HDML structure at the output
3142 * destination is specified.
3143 * @param node [i] The BLOCKQUOTE tag node is specified.
3144 * @return The conversion result is returned.
3147 s_hdml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3149 hdml_t *hdml = GET_HDML(pdoc);
3150 hdml->hdml_blockquote_flag--;
3151 s_output_to_hdml_out(hdml, "\r\n");
3157 * It is a handler who processes the DIR tag.
3159 * @param pdoc [i/o] The pointer to the HDML structure at the output
3160 * destination is specified.
3161 * @param node [i] The DIR tag node is specified.
3162 * @return The conversion result is returned.
3165 s_hdml_start_dir_tag(void *pdoc, Node *UNUSED(child))
3167 hdml_t *hdml = GET_HDML(pdoc);
3174 * It is a handler who processes the DIR tag.
3176 * @param pdoc [i/o] The pointer to the HDML structure at the output
3177 * destination is specified.
3178 * @param node [i] The DIR tag node is specified.
3179 * @return The conversion result is returned.
3182 s_hdml_end_dir_tag(void *pdoc, Node *UNUSED(child))
3184 hdml_t *hdml = GET_HDML(pdoc);
3191 * It is a handler who processes the DT tag.
3193 * @param pdoc [i/o] The pointer to the HDML structure at the output
3194 * destination is specified.
3195 * @param node [i] The DT tag node is specified.
3196 * @return The conversion result is returned.
3199 s_hdml_start_dt_tag(void *pdoc, Node *UNUSED(child))
3201 hdml_t *hdml = GET_HDML(pdoc);
3202 s_output_to_hdml_out(hdml, "<LINE>");
3208 * It is a handler who processes the DT tag.
3210 * @param pdoc [i/o] The pointer to the HDML structure at the output
3211 * destination is specified.
3212 * @param node [i] The DT tag node is specified.
3213 * @return The conversion result is returned.
3216 s_hdml_end_dt_tag(void *pdoc, Node *UNUSED(child))
3218 hdml_t *hdml = GET_HDML(pdoc);
3219 s_output_to_hdml_out(hdml, "\r\n");
3225 * It is a handler who processes the DD tag.
3227 * @param pdoc [i/o] The pointer to the HDML structure at the output
3228 * destination is specified.
3229 * @param node [i] The DD tag node is specified.
3230 * @return The conversion result is returned.
3233 s_hdml_start_dd_tag(void *pdoc, Node *UNUSED(child))
3235 hdml_t *hdml = GET_HDML(pdoc);
3236 s_output_to_hdml_out(hdml, "<WRAP> <TAB>");
3242 * It is a handler who processes the DD tag.
3244 * @param pdoc [i/o] The pointer to the HDML structure at the output
3245 * destination is specified.
3246 * @param node [i] The DD tag node is specified.
3247 * @return The conversion result is returned.
3250 s_hdml_end_dd_tag(void *pdoc, Node *UNUSED(child))
3252 hdml_t *hdml = GET_HDML(pdoc);
3253 s_output_to_hdml_out(hdml, "\r\n");
3259 * It is a handler who processes the PLAINTEXT tag.
3261 * @param pdoc [i/o] The pointer to the HDML structure at the output
3262 * destination is specified.
3263 * @param node [i] The PLAINTEXT tag node is specified.
3264 * @return The conversion result is returned.
3267 s_hdml_start_plaintext_tag(void *pdoc, Node *node)
3269 hdml_t *hdml = GET_HDML(pdoc);
3270 hdml->plaintext_value_len = 0;
3271 s_hdml_start_plaintext_tag_inner(pdoc,node);
3276 s_hdml_start_plaintext_tag_inner(void *pdoc, Node *node)
3278 hdml_t *hdml = GET_HDML(pdoc);
3279 Doc *doc = hdml->doc;
3281 for (child = qs_get_child_node(doc, node);
3283 child = qs_get_next_node(doc, child)) {
3285 char *str = chxj_ap_escape_html(doc->r->pool, child->otext);
3286 int len = strlen(str);
3288 for (i=0; i<len; i++) {
3289 if (hdml->plaintext_value_len == 0) {
3290 s_output_to_hdml_out(hdml, "<LINE>");
3292 if (is_sjis_kanji(child->otext[i]) && i + 1 < len) {
3293 oneChar[0] = child->otext[i+0];
3294 oneChar[1] = child->otext[i+1];
3296 s_output_to_hdml_out(hdml, oneChar);
3297 hdml->plaintext_value_len +=2;
3301 if (child->otext[i] == '\n') {
3302 hdml->plaintext_value_len = 0;
3305 s_output_to_hdml_out(hdml, oneChar);
3308 oneChar[0] = child->otext[i];
3310 s_output_to_hdml_out(hdml, oneChar);
3311 hdml->plaintext_value_len++;
3313 s_hdml_start_plaintext_tag_inner(pdoc, child);
3320 * It is a handler who processes the PLAINTEXT tag.
3322 * @param pdoc [i/o] The pointer to the HDML structure at the output
3323 * destination is specified.
3324 * @param node [i] The PLAINTEXT tag node is specified.
3325 * @return The conversion result is returned.
3328 s_hdml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3330 hdml_t *hdml = GET_HDML(pdoc);
3336 * It is a handler who processes the PRE tag.
3338 * @param pdoc [i/o] The pointer to the HDML structure at the output
3339 * destination is specified.
3340 * @param node [i] The PRE tag node is specified.
3341 * @return The conversion result is returned.
3344 s_hdml_start_pre_tag(void *pdoc, Node *UNUSED(node))
3350 hdml = GET_HDML(pdoc);
3360 * It is a handler who processes the PRE tag.
3362 * @param pdoc [i/o] The pointer to the HDML structure at the output
3363 * destination is specified.
3364 * @param node [i] The PRE tag node is specified.
3365 * @return The conversion result is returned.
3368 s_hdml_end_pre_tag(void *pdoc, Node *UNUSED(child))
3374 hdml = GET_HDML(pdoc);
3385 * handler of the TEXTAREA tag.
3387 * @param hdml [i/o] The pointer to the HDML structure at the output
3388 * destination is specified.
3389 * @param tag [i] Specified The TEXTAREA tag node.
3392 s_hdml_start_textarea_tag(void *pdoc, Node *node)
3402 hdml_t *hdml = GET_HDML(pdoc);
3407 s_hdml_tag_output_upper_half(hdml, node);
3410 s_output_to_hdml_out(hdml,
3411 apr_psprintf(r->pool,
3412 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
3413 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
3415 s_get_form_no(r, hdml),
3416 hdml->var_cnt[hdml->pure_form_cnt],
3417 s_get_form_no(r, hdml),
3418 hdml->var_cnt[hdml->pure_form_cnt]
3421 s_output_to_hdml_out(hdml,
3422 apr_psprintf(r->pool,
3423 "[$%s%02d]</A>\r\n" ,
3424 s_get_form_no(r, hdml),
3425 hdml->var_cnt[hdml->pure_form_cnt]));
3427 /*--------------------------------------------------------------------------*/
3428 /* ENTRY CARD is output here. */
3429 /*--------------------------------------------------------------------------*/
3430 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
3431 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
3432 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
3438 nm = qs_get_name_attr(doc, node, r);
3440 nm = qs_alloc_zero_byte_string(r);
3443 s_output_to_postdata(hdml,
3444 apr_psprintf(r->pool,
3447 s_get_form_no(r, hdml),
3448 hdml->var_cnt[hdml->pure_form_cnt]));
3450 mlen = qs_get_maxlength_attr (doc, node, r);
3451 is = qs_get_istyle_attr (doc, node, r);
3452 val = s_hdml_inner_textarea_tag_get_value(hdml, node);
3454 fmt = qs_conv_istyle_to_format(r, is);
3457 for (ii=0; ii<strlen(mlen); ii++) {
3458 if (mlen[ii] < '0' || mlen[ii] > '9') {
3459 mlen = apr_psprintf(r->pool, "0");
3463 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
3466 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt));
3470 s_output_to_hdml_card(hdml,
3471 " MARKABLE=FALSE>\r\n"
3472 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
3475 s_output_to_init_vars(hdml,
3476 apr_psprintf(r->pool,
3478 s_get_form_no(r, hdml),
3479 hdml->var_cnt[hdml->pure_form_cnt],
3480 chxj_escape_uri(r->pool,val)));
3483 s_output_to_init_vars(hdml,
3484 apr_psprintf(r->pool,
3486 s_get_form_no(r, hdml),
3487 hdml->var_cnt[hdml->pure_form_cnt]));
3489 hdml->var_cnt[hdml->pure_form_cnt]++;
3494 s_hdml_inner_textarea_tag_get_value(hdml_t *hdml, Node *node)
3496 Doc *doc = hdml->doc;
3498 char *result = apr_pstrdup(doc->r->pool, "\0");
3499 for (child = qs_get_child_node(doc, node);
3501 child = qs_get_next_node(doc, child)) {
3502 char *textval = qs_get_node_value(doc,child);
3503 if (textval && *textval) {
3504 result = apr_pstrcat(doc->r->pool, result, textval, NULL);