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,
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_convert(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->pool);
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->pool);
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->pool);
561 hdml->form_cnt = apr_time_now();
562 hdml->out = qs_alloc_zero_byte_string(r->pool);
567 s_hdml_search_emoji(hdml_t *hdml, char *txt, char **rslt)
580 DBG(r,"spec is NULL");
583 for (ee = hdml->conf->emoji;
586 unsigned char hex1byte;
587 unsigned char hex2byte;
589 DBG(r, "emoji->imode is NULL");
593 hex1byte = ee->imode->hex1byte & 0xff;
594 hex2byte = ee->imode->hex2byte & 0xff;
596 if (ee->imode->string
597 && strlen(ee->imode->string) > 0
598 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
599 if (spec == NULL || spec->emoji_type == NULL) {
600 *rslt = apr_psprintf(r->pool,
603 return strlen(ee->imode->string);
606 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
607 *rslt = apr_psprintf(r->pool,
610 return strlen(ee->imode->string);
613 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
614 *rslt = apr_psprintf(r->pool,
617 return strlen(ee->imode->string);
620 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
621 *rslt = apr_psprintf(r->pool,
624 return strlen(ee->imode->string);
627 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
628 *rslt = apr_psprintf(r->pool,
631 return strlen(ee->imode->string);
634 *rslt = apr_psprintf(r->pool,
637 return strlen(ee->imode->string);
642 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
643 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
644 if (spec == NULL || spec->emoji_type == NULL) {
645 *rslt = apr_psprintf(r->pool,
651 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
652 *rslt = apr_psprintf(r->pool,
658 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
659 *rslt = apr_psprintf(r->pool,
665 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
666 *rslt = apr_psprintf(r->pool,
672 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
673 *rslt = apr_psprintf(r->pool,
679 *rslt = apr_psprintf(r->pool,
692 * It is a handler who processes the HTML tag.
694 * @param pdoc [i/o] The pointer to the HDML structure at the output
695 * destination is specified.
696 * @param node [i] The HTML tag node is specified.
697 * @return The conversion result is returned.
700 s_hdml_start_html_tag(void *pdoc, Node *UNUSED(node))
702 hdml_t *hdml = GET_HDML(pdoc);
704 s_output_to_hdml_out(hdml,
705 "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\r\n"
706 "<NODISPLAY NAME=D0>\r\n"
707 "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\r\n"
712 hdml->hdml_br_flag = 0;
719 * It is a handler who processes the HTML tag.
721 * @param pdoc [i/o] The pointer to the HDML structure at the output
722 * destination is specified.
723 * @param node [i] The HTML tag node is specified.
724 * @return The conversion result is returned.
727 s_hdml_end_html_tag(void *pdoc, Node *UNUSED(child))
729 hdml_t *hdml = GET_HDML(pdoc);
731 s_output_to_hdml_card(hdml,
732 "<NODISPLAY NAME=D1>\r\n"
733 "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
736 if (strlen(hdml->init_vars)) {
737 s_output_to_hdml_card(hdml, hdml->init_vars );
740 s_output_to_hdml_card(hdml, "_chxj_dmy=" );
743 s_output_to_hdml_card(hdml,
748 s_output_to_hdml_out(hdml, hdml->card );
749 s_output_to_hdml_out(hdml, "</HDML>\r\n");
751 hdml->hdml_end_flag = 1;
758 * It is a handler who processes the META tag.
760 * @param pdoc [i/o] The pointer to the HDML structure at the output
761 * destination is specified.
762 * @param node [i] The META tag node is specified.
763 * @return The conversion result is returned.
766 s_hdml_start_meta_tag(void *pdoc, Node *UNUSED(node))
768 hdml_t *hdml = GET_HDML(pdoc);
770 hdml->hdml_br_flag = 0;
779 * It is a handler who processes the META tag.
781 * @param pdoc [i/o] The pointer to the HDML structure at the output
782 * destination is specified.
783 * @param node [i] The META tag node is specified.
784 * @return The conversion result is returned.
787 s_hdml_end_meta_tag(void *pdoc, Node *UNUSED(child))
789 hdml_t *hdml = GET_HDML(pdoc);
796 * It is a handler who processes the HEAD tag.
798 * @param pdoc [i/o] The pointer to the HDML structure at the output
799 * destination is specified.
800 * @param node [i] The HEAD tag node is specified.
801 * @return The conversion result is returned.
804 s_hdml_start_head_tag(void *pdoc, Node *UNUSED(node))
806 hdml_t *hdml = GET_HDML(pdoc);
810 hdml->hdml_br_flag = 0;
817 * It is a handler who processes the HEAD tag.
819 * @param pdoc [i/o] The pointer to the HDML structure at the output
820 * destination is specified.
821 * @param node [i] The HEAD tag node is specified.
822 * @return The conversion result is returned.
825 s_hdml_end_head_tag(void *pdoc, Node *UNUSED(child))
827 hdml_t *hdml = GET_HDML(pdoc);
836 * It is a handler who processes the TITLE tag.
838 * @param pdoc [i/o] The pointer to the HDML structure at the output
839 * destination is specified.
840 * @param node [i] The TITLE tag node is specified.
841 * @return The conversion result is returned.
844 s_hdml_start_title_tag(void *pdoc, Node *UNUSED(node))
846 hdml_t *hdml = GET_HDML(pdoc);
848 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
850 hdml->found_title = 1;
851 hdml->hdml_br_flag = 0;
858 * It is a handler who processes the TITLE tag.
860 * @param pdoc [i/o] The pointer to the HDML structure at the output
861 * destination is specified.
862 * @param node [i] The TITLE tag node is specified.
863 * @return The conversion result is returned.
866 s_hdml_end_title_tag(void *pdoc, Node *UNUSED(child))
868 hdml_t *hdml = GET_HDML(pdoc);
870 s_output_to_hdml_out(hdml, "\">\r\n");
877 * It is a handler who processes the BASE tag.
879 * @param pdoc [i/o] The pointer to the HDML structure at the output
880 * destination is specified.
881 * @param node [i] The BASE tag node is specified.
882 * @return The conversion result is returned.
885 s_hdml_start_base_tag(void *pdoc, Node *UNUSED(node))
887 hdml_t *hdml = GET_HDML(pdoc);
889 hdml->hdml_br_flag = 0;
896 * It is a handler who processes the BASE tag.
898 * @param pdoc [i/o] The pointer to the HDML structure at the output
899 * destination is specified.
900 * @param node [i] The BASE tag node is specified.
901 * @return The conversion result is returned.
904 s_hdml_end_base_tag(void *pdoc, Node *UNUSED(child))
906 hdml_t *hdml = GET_HDML(pdoc);
913 * It is a handler who processes the BODY tag.
915 * @param pdoc [i/o] The pointer to the HDML structure at the output
916 * destination is specified.
917 * @param node [i] The BODY tag node is specified.
918 * @return The conversion result is returned.
921 s_hdml_start_body_tag(void *pdoc, Node *node)
927 hdml = GET_HDML(pdoc);
931 if (hdml->found_title == 0) {
932 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\r\n");
935 s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
936 /*--------------------------------*/
938 /*--------------------------------*/
939 for (attr = qs_get_attr(doc,node);
941 attr = qs_get_next_attr(doc,attr)) {
942 char *name = qs_get_attr_name(doc,attr);
944 if (STRCASEEQ('b','B',"bgcolor",name)) {
947 else if (STRCASEEQ('t','T',"text",name)) {
950 else if (STRCASEEQ('l','L',"link",name)) {
953 else if (STRCASEEQ('a','A',"alink",name)) {
956 else if (STRCASEEQ('v','V',"vlink",name)) {
960 s_output_to_hdml_out(hdml, ">\r\n");
961 hdml->hdml_br_flag = 0;
967 * It is a handler who processes the BODY tag.
969 * @param pdoc [i/o] The pointer to the HDML structure at the output
970 * destination is specified.
971 * @param node [i] The BODY tag node is specified.
972 * @return The conversion result is returned.
975 s_hdml_end_body_tag(void *pdoc, Node *UNUSED(child))
977 hdml_t *hdml = GET_HDML(pdoc);
979 s_output_to_hdml_out(hdml, "\r\n</DISPLAY>\r\n");
986 * It is a handler who processes the A tag.
988 * @param pdoc [i/o] The pointer to the HDML structure at the output
989 * destination is specified.
990 * @param node [i] The A tag node is specified.
991 * @return The conversion result is returned.
994 s_hdml_start_a_tag(void *pdoc, Node *node)
1000 hdml = GET_HDML(pdoc);
1003 s_hdml_tag_output_upper_half(hdml,node);
1005 s_output_to_hdml_out(hdml, "<A");
1008 /*------------------------------------*/
1009 /* Get Attributes */
1010 /*------------------------------------*/
1011 for (attr = qs_get_attr(doc,node);
1013 attr = qs_get_next_attr(doc,attr)) {
1014 char *name = qs_get_attr_name(doc,attr);
1015 char *value = qs_get_attr_value(doc,attr);
1016 if (STRCASEEQ('n','N',"name",name)) {
1019 else if (STRCASEEQ('h','H',"href",name)) {
1020 if (STRNCASEEQ('m','M',"mailto:",value,sizeof("mailto:")-1)) {
1021 value = chxj_encoding_parameter(hdml->doc->r, value);
1022 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1023 s_output_to_hdml_out(hdml, value );
1024 s_output_to_hdml_out(hdml, "\" " );
1026 else if (STRNCASEEQ('t','T',"tel:",value,sizeof("tel:")-1)) {
1027 s_output_to_hdml_out(hdml, " TASK=CALL NUMBER=\"");
1028 s_output_to_hdml_out(hdml, &value[4] );
1029 s_output_to_hdml_out(hdml, "\" " );
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, "\"" );
1037 else if (STRCASEEQ('a','A',"accesskey",name) && value && *value) {
1038 if (strcasecmp(value, "0") != 0) {
1039 s_output_to_hdml_out(hdml, " ACCESSKEY=" );
1040 s_output_to_hdml_out(hdml, value );
1041 s_output_to_hdml_out(hdml, "" );
1044 else if (STRCASEEQ('c','C',"cti",name)) {
1047 else if (STRCASEEQ('i','I',"ijam",name)) {
1050 else if (STRCASEEQ('u','U',"utn",name)) {
1053 else if (STRCASEEQ('t','T',"telbook",name)) {
1056 else if (STRCASEEQ('k','K',"kana",name)) {
1059 else if (STRCASEEQ('e','E',"email",name)) {
1062 else if (STRCASEEQ('i','I',"ista",name)) {
1065 else if (STRCASEEQ('i','I',"ilet",name)) {
1068 else if (STRCASEEQ('i','I',"iswf",name)) {
1071 else if (STRCASEEQ('i','I',"irst",name)) {
1075 s_output_to_hdml_out(hdml, ">" );
1077 hdml->hdml_a_flag = 1;
1079 hdml->hdml_br_flag = 0;
1086 * It is a handler who processes the A tag.
1088 * @param pdoc [i/o] The pointer to the HDML structure at the output
1089 * destination is specified.
1090 * @param node [i] The A tag node is specified.
1091 * @return The conversion result is returned.
1094 s_hdml_end_a_tag(void *pdoc, Node *UNUSED(child))
1096 hdml_t *hdml = GET_HDML(pdoc);
1098 s_output_to_hdml_out(hdml, "</A>\r\n");
1100 hdml->hdml_a_flag = 0;
1107 * It is a handler who processes the BR tag.
1109 * @param pdoc [i/o] The pointer to the HDML structure at the output
1110 * destination is specified.
1111 * @param node [i] The BR tag node is specified.
1112 * @return The conversion result is returned.
1115 s_hdml_start_br_tag(void *pdoc, Node *UNUSED(node))
1117 hdml_t *hdml = GET_HDML(pdoc);
1119 if (hdml->in_center > 0) {
1120 hdml->in_center = 0;
1123 if (hdml->div_in_center > 0) {
1124 hdml->div_in_center = 0;
1127 s_output_to_hdml_out(hdml, "<BR>\r\n");
1128 hdml->hdml_br_flag = 1;
1135 * It is a handler who processes the BR tag.
1137 * @param pdoc [i/o] The pointer to the HDML structure at the output
1138 * destination is specified.
1139 * @param node [i] The BR tag node is specified.
1140 * @return The conversion result is returned.
1143 s_hdml_end_br_tag(void *pdoc, Node *UNUSED(child))
1145 hdml_t *hdml = GET_HDML(pdoc);
1152 * It is a handler who processes the TR tag.
1154 * @param pdoc [i/o] The pointer to the HDML structure at the output
1155 * destination is specified.
1156 * @param node [i] The TR tag node is specified.
1157 * @return The conversion result is returned.
1160 s_hdml_start_tr_tag(void *pdoc, Node *UNUSED(node))
1162 hdml_t *hdml = GET_HDML(pdoc);
1164 if (hdml->in_center > 0) {
1165 hdml->in_center = 0;
1168 if (hdml->div_in_center > 0) {
1169 hdml->div_in_center = 0;
1172 s_output_to_hdml_out(hdml, "<BR>\r\n");
1174 hdml->hdml_br_flag = 1;
1181 * It is a handler who processes the TR tag.
1183 * @param pdoc [i/o] The pointer to the HDML structure at the output
1184 * destination is specified.
1185 * @param node [i] The TR tag node is specified.
1186 * @return The conversion result is returned.
1189 s_hdml_end_tr_tag(void *pdoc, Node *UNUSED(child))
1191 hdml_t *hdml = GET_HDML(pdoc);
1198 * It is a handler who processes the FONT tag.
1200 * @param pdoc [i/o] The pointer to the HDML structure at the output
1201 * destination is specified.
1202 * @param node [i] The FONT tag node is specified.
1203 * @return The conversion result is returned.
1206 s_hdml_start_font_tag(void *pdoc, Node *UNUSED(node))
1208 hdml_t *hdml = GET_HDML(pdoc);
1215 * It is a handler who processes the FONT tag.
1217 * @param pdoc [i/o] The pointer to the HDML structure at the output
1218 * destination is specified.
1219 * @param node [i] The FONT tag node is specified.
1220 * @return The conversion result is returned.
1223 s_hdml_end_font_tag(void *pdoc, Node *UNUSED(child))
1225 hdml_t *hdml = GET_HDML(pdoc);
1232 * It is a handler who processes the FORM tag.
1234 * @param pdoc [i/o] The pointer to the HDML structure at the output
1235 * destination is specified.
1236 * @param node [i] The FORM tag node is specified.
1237 * @return The conversion result is returned.
1240 s_hdml_start_form_tag(void *pdoc, Node *node)
1248 hdml = GET_HDML(pdoc);
1253 hdml->form_tmp = apr_psprintf(r->pool,
1254 "<NODISPLAY NAME=F%d>\r\n",
1255 hdml->pure_form_cnt);
1256 hdml->form_tmp = apr_pstrcat(r->pool,
1258 "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",
1260 /* Get Attributes */
1261 for (attr = qs_get_attr(doc,node);
1263 attr = qs_get_next_attr(doc,attr)) {
1264 char *name = qs_get_attr_name(doc,attr);
1265 char *value = qs_get_attr_value(doc,attr);
1266 if (STRCASEEQ('a','A',"action",name)) {
1267 value = chxj_encoding_parameter(hdml->doc->r, value);
1268 act = apr_psprintf(r->pool, "%s", value);
1274 hdml->form_tmp = apr_pstrcat(r->pool,
1279 hdml->form_tmp = apr_pstrcat(r->pool,
1283 hdml->form_tmp = apr_pstrcat(r->pool,
1288 hdml->hdml_br_flag = 0;
1295 * handler of the form end tag.
1297 * @param pdoc [i/o] The pointer to the HDML structure at the output
1298 * destination is specified.
1299 * @param child [i] unused.
1300 * @return The HDML output result after it edits it is returned.
1303 s_hdml_end_form_tag(void *pdoc, Node *UNUSED(child))
1305 hdml_t *hdml = GET_HDML(pdoc);
1306 request_rec *r = hdml->doc->r;
1308 s_output_to_postdata(hdml, "_chxj_dmy=");
1310 hdml->form_tmp = apr_pstrcat(r->pool,
1312 hdml->postdata[hdml->pure_form_cnt],
1315 hdml->form_tmp = apr_pstrcat(r->pool,
1317 "\" CLEAR=TRUE >\r\n",
1319 hdml->form_tmp = apr_pstrcat(r->pool,
1324 s_output_to_hdml_card(hdml, hdml->form_tmp);
1326 hdml->form_tmp = NULL;
1327 hdml->pure_form_cnt++;
1334 * It is a handler that takes charge of the processing of the input tag.
1336 * @param pdoc [i/o] The pointer to the HDML structure at the output
1337 * destination is specified.
1338 * @param node [i] The tag node to be processed is specified.
1341 s_hdml_start_input_tag(void *pdoc, Node *node)
1343 hdml_t *hdml = GET_HDML(pdoc);
1344 Doc *doc = hdml->doc;
1347 /*--------------------------------------------------------------------------*/
1348 /* The attribute of the input tag is acquired. */
1349 /*--------------------------------------------------------------------------*/
1350 for (attr = qs_get_attr(doc,node);
1352 attr = qs_get_next_attr(doc,attr)) {
1353 char *name = qs_get_attr_name(doc,attr);
1354 char *value = qs_get_attr_value(doc,attr);
1355 if (STRCASEEQ('t','T',"type",name)) {
1356 if (STRCASEEQ('t','T',"text",value)) {
1357 /*--------------------------------------------------------------------*/
1358 /* "input type ='text'" tag is processed. */
1359 /*--------------------------------------------------------------------*/
1360 s_hdml_do_input_text_tag(hdml, node);
1362 else if (STRCASEEQ('p','P',"password",value)) {
1363 /*--------------------------------------------------------------------*/
1364 /* "input type='password'" tag is processed. */
1365 /*--------------------------------------------------------------------*/
1366 s_hdml_do_input_password_tag(hdml, node);
1368 else if (STRCASEEQ('s','S',"submit",value)) {
1369 /*--------------------------------------------------------------------*/
1370 /* "input type='submit'" tag is processed. */
1371 /*--------------------------------------------------------------------*/
1372 s_hdml_do_input_submit_tag(hdml, node);
1374 else if (STRCASEEQ('h','H',"hidden",value)) {
1375 /*--------------------------------------------------------------------*/
1376 /* "input type='hidden'" tag is processed. */
1377 /*--------------------------------------------------------------------*/
1378 s_hdml_do_input_hidden_tag(hdml, node);
1380 else if (STRCASEEQ('r','R',"radio",value)) {
1381 /*--------------------------------------------------------------------*/
1382 /* "input type='radio'" tag is processed. */
1383 /*--------------------------------------------------------------------*/
1384 s_hdml_do_input_radio_tag(hdml, node);
1386 else if (STRCASEEQ('c','C',"checkbox",value)) {
1387 /*--------------------------------------------------------------------*/
1388 /* "input type='checkbox'" tag is processed. */
1389 /*--------------------------------------------------------------------*/
1390 s_hdml_do_input_checkbox_tag(hdml, node);
1392 else if (STRCASEEQ('r','R',"reset",value)) {
1393 /*--------------------------------------------------------------------*/
1394 /* "input type='reset'" tag is processed. */
1395 /*--------------------------------------------------------------------*/
1396 s_hdml_do_input_reset_tag(hdml, node);
1399 else if (STRCASEEQ('n','N',"name",name)) {
1402 else if (STRCASEEQ('v','V',"value",name)) {
1405 else if (STRCASEEQ('s','S',"size",name)) {
1408 else if (STRCASEEQ('m','M',"maxlength",name)) {
1411 else if (STRCASEEQ('c','C',"checked",name)) {
1414 else if (STRCASEEQ('a','A',"accesskey",name)) {
1417 else if (STRCASEEQ('i','I',"istyle",name)) {
1421 hdml->hdml_br_flag = 0;
1428 * The substitution processing of tag "input type = text" is done.
1430 * @param hdml [i/o] The pointer to the HDML structure at the output
1431 * destination is specified.
1432 * @param tag [i] The tag node of input type=text is specified.
1435 s_hdml_do_input_text_tag(hdml_t *hdml, Node *tag)
1449 s_hdml_tag_output_upper_half(hdml, tag);
1452 s_output_to_hdml_out(hdml,
1453 apr_psprintf(r->pool,
1454 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1455 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1457 s_get_form_no(r, hdml),
1458 hdml->var_cnt[hdml->pure_form_cnt],
1459 s_get_form_no(r, hdml),
1460 hdml->var_cnt[hdml->pure_form_cnt]
1463 s_output_to_hdml_out(hdml,
1464 apr_psprintf(r->pool,
1465 "[$%s%02d]</A>\r\n" ,
1466 s_get_form_no(r, hdml),
1467 hdml->var_cnt[hdml->pure_form_cnt]));
1469 /*--------------------------------------------------------------------------*/
1470 /* ENTRY CARD is output here. */
1471 /*--------------------------------------------------------------------------*/
1472 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1473 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1474 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1480 nm = qs_get_name_attr(doc, tag, r->pool);
1482 nm = qs_alloc_zero_byte_string(r->pool);
1485 s_output_to_postdata(hdml,
1486 apr_psprintf(r->pool,
1489 s_get_form_no(r, hdml),
1490 hdml->var_cnt[hdml->pure_form_cnt]));
1492 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1493 is = qs_get_istyle_attr (doc, tag, r->pool);
1494 val = qs_get_value_attr (doc, tag, r->pool);
1496 fmt = qs_conv_istyle_to_format(r, is);
1497 DBG(r,"qs_conv_istyle_to_format end");
1501 for (ii=0; ii<strlen(mlen); ii++) {
1502 if (mlen[ii] < '0' || mlen[ii] > '9') {
1503 mlen = apr_psprintf(r->pool, "0");
1507 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1510 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1513 s_output_to_hdml_card(hdml,
1514 " MARKABLE=FALSE>\r\n"
1515 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1519 s_output_to_init_vars(hdml,
1520 apr_psprintf(r->pool,
1522 s_get_form_no(r, hdml),
1523 hdml->var_cnt[hdml->pure_form_cnt],
1524 chxj_escape_uri(r->pool,val)));
1527 s_output_to_init_vars(hdml,
1528 apr_psprintf(r->pool,
1530 s_get_form_no(r, hdml),
1531 hdml->var_cnt[hdml->pure_form_cnt]));
1533 hdml->var_cnt[hdml->pure_form_cnt]++;
1538 * The substitution processing of tag "input type = password" is done.
1540 * @param hdml [i/o] The pointer to the HDML structure at the output
1541 * destination is specified.
1542 * @param tag [i] The tag node of input type=password is specified.
1545 s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag)
1558 s_hdml_tag_output_upper_half(hdml, tag);
1561 s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1562 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1563 s_output_to_hdml_out(hdml,
1564 apr_psprintf(r->pool,
1565 "VARS=\"V=$%s%02d\" ",
1566 s_get_form_no(r, hdml),
1567 hdml->var_cnt[hdml->pure_form_cnt]));
1569 s_output_to_hdml_out(hdml,
1570 apr_psprintf(r->pool, "RECEIVE=%s%02d>" ,
1571 s_get_form_no(r, hdml),
1572 hdml->var_cnt[hdml->pure_form_cnt]));
1573 s_output_to_hdml_out(hdml,
1574 apr_psprintf(r->pool, "[$%s%02d]</A>\r\n" ,
1575 s_get_form_no(r, hdml),
1576 hdml->var_cnt[hdml->pure_form_cnt]));
1578 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1579 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1580 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1587 nm = qs_get_name_attr(doc, tag, r->pool);
1589 nm = qs_alloc_zero_byte_string(r->pool);
1592 s_output_to_postdata(hdml,
1593 apr_psprintf(r->pool,
1596 s_get_form_no(r, hdml),
1597 hdml->var_cnt[hdml->pure_form_cnt]));
1599 mlen = qs_get_maxlength_attr (doc, tag, r->pool);
1600 val = qs_get_value_attr (doc, tag, r->pool);
1601 /*--------------------------------------------------------------------------*/
1602 /* Default is a figure input. */
1603 /*--------------------------------------------------------------------------*/
1604 fmt = apr_psprintf(r->pool, "N");
1606 if (chxj_chk_numeric(mlen) != 0)
1607 mlen = apr_psprintf(r->pool, "0");
1608 s_output_to_hdml_card(hdml,
1609 apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1612 s_output_to_hdml_card(hdml,
1613 apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1615 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1617 s_output_to_hdml_card(hdml,
1618 " MARKABLE=FALSE>\r\n"
1619 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1623 s_output_to_init_vars(hdml,
1624 apr_psprintf(r->pool, "%s%02d=%s",
1625 s_get_form_no(r, hdml),
1626 hdml->var_cnt[hdml->pure_form_cnt],
1627 chxj_escape_uri(r->pool,val)));
1629 s_output_to_init_vars(hdml,
1630 apr_psprintf(r->pool, "%s%02d=",
1631 s_get_form_no(r, hdml),
1632 hdml->var_cnt[hdml->pure_form_cnt]));
1634 hdml->var_cnt[hdml->pure_form_cnt]++;
1639 * The substitution processing of tag "input type = submit" is done.
1641 * @param hdml [i/o] The pointer to the HDML structure at the output
1642 * destination is specified.
1643 * @param tag [i] The tag node of input type=submit is specified.
1646 s_hdml_do_input_submit_tag(hdml_t *hdml, Node *tag)
1648 Doc *doc = hdml->doc;
1649 request_rec *r = doc->r;
1653 s_hdml_tag_output_upper_half(hdml, tag);
1655 s_output_to_hdml_out(hdml,
1656 apr_psprintf(r->pool,
1657 "<A TASK=GO LABEL=OK DEST=#F%d ",
1658 hdml->pure_form_cnt));
1660 /*--------------------------------------------------------------------------*/
1661 /* get name and value attribute */
1662 /*--------------------------------------------------------------------------*/
1663 nm = qs_get_name_attr (doc, tag, r->pool);
1664 val = qs_get_value_attr (doc, tag, r->pool);
1667 s_output_to_hdml_out(hdml,
1668 apr_psprintf(r->pool, "VARS=\"%s=%s\" ",
1670 chxj_escape_uri(r->pool,val)));
1671 if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1672 s_output_to_postdata(hdml,
1673 apr_psprintf(r->pool,"%s%s=$%s",
1674 SUBMIT_BUTTON_PREFIX, nm, nm));
1677 s_output_to_hdml_out(hdml, ">" );
1679 s_output_to_hdml_out(hdml, val);
1681 s_output_to_hdml_out(hdml, "</A>\r\n" );
1686 * The substitution processing of tag "input type = reset" is done.
1688 * @param hdml [i/o] The pointer to the HDML structure at the output
1689 * destination is specified.
1690 * @param tag [i] The tag node of input type=submit is specified.
1693 s_hdml_do_input_reset_tag(hdml_t *hdml, Node *tag)
1695 Doc *doc = hdml->doc;
1696 request_rec *r = doc->r;
1700 s_hdml_tag_output_upper_half(hdml, tag);
1702 s_output_to_hdml_out(hdml,
1703 apr_psprintf(r->pool,
1704 "<A TASK=GO LABEL=OK DEST=#D0>"));
1706 /*--------------------------------------------------------------------------*/
1707 /* get name and value attribute */
1708 /*--------------------------------------------------------------------------*/
1709 nm = qs_get_name_attr (doc, tag, r->pool);
1710 val = qs_get_value_attr (doc, tag, r->pool);
1712 s_output_to_hdml_out(hdml, val);
1714 s_output_to_hdml_out(hdml, "</A>\r\n" );
1719 * The substitution processing of tag "input type = hidden" is done.
1721 * @param hdml [i/o] The pointer to the HDML structure at the output
1722 * destination is specified.
1723 * @param tag [i] The tag node of input type=hidden is specified.
1726 s_hdml_do_input_hidden_tag(hdml_t *hdml, Node *tag)
1728 Doc *doc = hdml->doc;
1729 request_rec *r = doc->r;
1733 /*--------------------------------------------------------------------------*/
1734 /* get name and value attribute */
1735 /*--------------------------------------------------------------------------*/
1736 nm = qs_get_name_attr (doc, tag, r->pool);
1737 val = qs_get_value_attr (doc, tag, r->pool);
1739 s_output_to_postdata(hdml,
1740 apr_psprintf(r->pool,
1743 chxj_escape_uri(r->pool, val)));
1748 * The substitution processing of tag "input type = radio" is done.
1750 * @param hdml [i/o] The pointer to the HDML structure at the output
1751 * destination is specified.
1752 * @param tag [i] The tag node of input type=radio is specified.
1755 s_hdml_do_input_radio_tag(hdml_t *hdml, Node *tag)
1757 Doc *doc = hdml->doc;
1758 request_rec *r = doc->r;
1766 s_hdml_tag_output_upper_half(hdml, tag);
1768 /*--------------------------------------------------------------------------*/
1769 /* get name and value attribute */
1770 /*--------------------------------------------------------------------------*/
1771 nm = qs_get_name_attr (doc, tag, r->pool);
1772 val = qs_get_value_attr (doc, tag, r->pool);
1773 /*--------------------------------------------------------------------------*/
1774 /* The same name is searched out from the list made beforehand. */
1775 /*--------------------------------------------------------------------------*/
1776 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1777 if (! hdml->radio_name_list[ii]) {
1779 DBG(r, "Oops... radio list is null[%d]", ii);
1780 /*----------------------------------------------------------------------*/
1781 /* Processing is ended because it doesn't happen off the fly. */
1782 /*----------------------------------------------------------------------*/
1786 if (strcasecmp(hdml->radio_name_list[ii], nm) == 0)
1789 if (ii == MAX_RADIO_COUNT) {
1791 DBG(r,"Oops... The same name was not in the list. ");
1792 /*------------------------------------------------------------------------*/
1793 /* Processing is ended because it doesn't happen off the fly. */
1794 /*------------------------------------------------------------------------*/
1798 s_output_to_hdml_out(hdml,
1799 apr_psprintf(r->pool,
1802 "DEST=#R%d VARS=\"VAL=%s\" "
1808 if (hdml->radio_out_cnt[ii] == 0) {
1809 s_output_to_hdml_card(hdml,
1810 apr_psprintf(r->pool,
1811 "<NODISPLAY NAME=R%d>\r\n",
1813 s_output_to_hdml_card(hdml,
1814 apr_psprintf(r->pool,
1816 "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1819 kk = hdml->radio_out_cnt[ii];
1820 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
1821 if (! hdml->radio_value_list[ii][jj])
1826 for (jj=0; jj<r_cnt; jj++) {
1827 if (! hdml->radio_value_list[ii][jj])
1831 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1832 if (hdml->radio_out_cnt[ii] == 0)
1833 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1836 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1837 if (hdml->radio_out_cnt[ii] == 0) {
1839 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1841 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1848 s_output_to_hdml_out(hdml,
1849 apr_psprintf(r->pool, "\" >$%s_%02d</A>",
1851 hdml->radio_out_cnt[ii]));
1852 if (! hdml->radio_out_cnt[ii]) {
1853 s_output_to_hdml_card(hdml, "\">\r\n" );
1854 s_output_to_hdml_card(hdml, "</NODISPLAY>\r\n");
1856 s_output_to_postdata(hdml, apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1858 for (jj=0; jj<r_cnt; jj++) {
1859 if (hdml->radio_value_list[ii][jj] && hdml->radio_checked_value[ii]) {
1860 if (strcasecmp(hdml->radio_value_list[ii][jj],
1861 hdml->radio_checked_value[ii]) == 0) {
1862 s_output_to_init_vars(hdml,
1863 apr_psprintf(r->pool,
1869 s_output_to_init_vars(hdml,
1870 apr_psprintf(r->pool,
1877 s_output_to_init_vars(hdml,
1878 apr_psprintf(r->pool,
1885 if (hdml->radio_checked_value[ii]) {
1886 DBG(r,"radio button is checked. checked value is [%s]",
1887 hdml->radio_checked_value[ii]);
1888 s_output_to_init_vars(hdml,
1889 apr_psprintf(r->pool,
1892 hdml->radio_checked_value[ii]));
1895 DBG(r,"radio button is not checked. checked value is []");
1896 s_output_to_init_vars(hdml,
1897 apr_psprintf(r->pool,
1902 hdml->radio_out_cnt[ii]++;
1907 * The substitution processing of tag "input type = checkbox" is done.
1909 * @param hdml [i/o] The pointer to the HDML structure at the output
1910 * destination is specified.
1911 * @param tag [i] The tag node of input type=checkbox is specified.
1914 s_hdml_do_input_checkbox_tag(hdml_t *hdml, Node *tag)
1916 Doc *doc = hdml->doc;
1917 request_rec *r = doc->r;
1922 /*--------------------------------------------------------------------------*/
1923 /* It is posted to the one without the checked attribute. */
1924 /* However, they were able to be removed with INPUT FILTER. */
1925 /*--------------------------------------------------------------------------*/
1926 if (! hdml->has_checkbox) {
1927 hdml->has_checkbox++;
1928 s_output_to_hdml_card(hdml,
1929 "<NODISPLAY NAME=\"_chk\">\r\n"
1930 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1931 "RETVALS=\"_uchk;$V;X\" >\r\n"
1933 "<NODISPLAY NAME=\"_uchk\">\r\n"
1934 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
1935 "RETVALS=\"_chk;;_\" >\r\n"
1938 DBG(r, "wrote checkbox hdml card.");
1941 /*--------------------------------------------------------------------------*/
1942 /* It is examined whether it is CHECKED. */
1943 /*--------------------------------------------------------------------------*/
1944 chk = qs_is_checked_checkbox_attr(doc, tag, r->pool);
1946 /*--------------------------------------------------------------------------*/
1947 /* The value of the name attribute and the value attribute is acquired */
1949 /*--------------------------------------------------------------------------*/
1950 val = qs_get_value_attr(doc, tag, r->pool);
1951 nm = qs_get_name_attr(doc, tag, r->pool);
1954 val = qs_alloc_zero_byte_string(r->pool);
1958 nm = qs_alloc_zero_byte_string(r->pool);
1961 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
1962 "<A TASK=GOSUB LABEL=\"check\" "
1963 "DEST=\"#$%s%02d\" "
1965 "RECEIVE=\"%s%02d;%s%02d;%s%02d\">"
1967 s_get_form_no(r, hdml),
1968 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1970 s_get_form_no(r, hdml),
1971 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1972 s_get_form_no(r, hdml),
1973 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1974 s_get_form_no(r, hdml),
1975 hdml->var_cnt[hdml->pure_form_cnt] + 2,
1976 s_get_form_no(r, hdml),
1977 hdml->var_cnt[hdml->pure_form_cnt] + 2));
1979 s_output_to_init_vars(hdml,
1980 apr_psprintf(r->pool,
1981 "%s%02d=_uchk&%s%02d=%s&%s%02d=X",
1982 s_get_form_no(r, hdml),
1983 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1984 s_get_form_no(r, hdml),
1985 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1986 chxj_escape_uri(r->pool,val),
1987 s_get_form_no(r, hdml),
1988 hdml->var_cnt[hdml->pure_form_cnt] + 2
1992 s_output_to_init_vars(hdml,
1993 apr_psprintf(r->pool,
1994 "%s%02d=_chk&%s%02d=&%s%02d=_",
1995 s_get_form_no(r, hdml),
1996 hdml->var_cnt[hdml->pure_form_cnt] + 0,
1997 s_get_form_no(r, hdml),
1998 hdml->var_cnt[hdml->pure_form_cnt] + 1,
1999 s_get_form_no(r, hdml),
2000 hdml->var_cnt[hdml->pure_form_cnt] + 2
2004 s_output_to_postdata(hdml,
2005 apr_psprintf(r->pool, "%s%s=$%s%02d",
2008 s_get_form_no(r, hdml),
2009 hdml->var_cnt[hdml->pure_form_cnt] + 1));
2011 hdml->var_cnt[hdml->pure_form_cnt] += 3;
2016 * The ISTYLE attribute is converted into the HDML form.
2018 * @param r [i] To use POOL, the pointer to request_rec is specified.
2019 * @param is [i] The value of the ISTYLE attribute is specified.
2020 * @return The ISTYLE attribute converted into the HDML form is returned.
2023 qs_conv_istyle_to_format(request_rec *r, char *is)
2032 fmt = apr_psprintf(r->pool, "M");
2035 fmt = apr_psprintf(r->pool, "M");
2038 fmt = apr_psprintf(r->pool, "m");
2041 fmt = apr_psprintf(r->pool, "N");
2052 * It is a handler who processes the INPUT tag.
2054 * @param pdoc [i/o] The pointer to the HDML structure at the output
2055 * destination is specified.
2056 * @param node [i] The INPUT tag node is specified.
2057 * @return The conversion result is returned.
2060 s_hdml_end_input_tag(void *pdoc, Node *UNUSED(child))
2062 hdml_t *hdml = GET_HDML(pdoc);
2069 * It is a handler who processes the CENTER tag.
2071 * @param pdoc [i/o] The pointer to the HDML structure at the output
2072 * destination is specified.
2073 * @param node [i] The CENTER tag node is specified.
2074 * @return The conversion result is returned.
2077 s_hdml_start_center_tag(void *pdoc, Node *UNUSED(node))
2079 hdml_t *hdml = GET_HDML(pdoc);
2084 if (hdml->hdml_br_flag == 0) {
2085 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2088 hdml = s_output_to_hdml_out(hdml, "<CENTER>");
2095 * It is a handler who processes the CENTER tag.
2097 * @param pdoc [i/o] The pointer to the HDML structure at the output
2098 * destination is specified.
2099 * @param node [i] The CENTER tag node is specified.
2100 * @return The conversion result is returned.
2103 s_hdml_end_center_tag(void *pdoc, Node *UNUSED(child))
2105 hdml_t *hdml = GET_HDML(pdoc);
2108 hdml->in_center = 0;
2110 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2111 hdml->hdml_br_flag = 1;
2118 * It is a handler who processes the HR tag.
2120 * @param pdoc [i/o] The pointer to the HDML structure at the output
2121 * destination is specified.
2122 * @param node [i] The HR tag node is specified.
2123 * @return The conversion result is returned.
2126 s_hdml_start_hr_tag(void *pdoc, Node *UNUSED(node))
2128 hdml_t *hdml = GET_HDML(pdoc);
2130 if (hdml->hdml_br_flag == 0) {
2131 s_output_to_hdml_out(hdml, "<BR>\r\n");
2132 if (hdml->in_center)
2135 if (hdml->div_in_center)
2136 hdml->div_in_center--;
2139 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");
2141 hdml->hdml_br_flag = 1;
2148 * It is a handler who processes the HR tag.
2150 * @param pdoc [i/o] The pointer to the HDML structure at the output
2151 * destination is specified.
2152 * @param node [i] The HR tag node is specified.
2153 * @return The conversion result is returned.
2156 s_hdml_end_hr_tag(void *pdoc, Node *UNUSED(child))
2158 hdml_t *hdml = GET_HDML(pdoc);
2165 * It is a handler who processes the LI tag.
2167 * @param pdoc [i/o] The pointer to the HDML structure at the output
2168 * destination is specified.
2169 * @param node [i] The LI tag node is specified.
2170 * @return The conversion result is returned.
2173 s_hdml_start_li_tag(void *pdoc, Node *UNUSED(node))
2175 hdml_t *hdml = GET_HDML(pdoc);
2178 if (hdml->hdml_br_flag == 0) {
2179 s_output_to_hdml_out(hdml, "<BR>\r\n");
2180 if (hdml->in_center)
2183 if (hdml->div_in_center)
2184 hdml->div_in_center--;
2186 s_output_to_hdml_out(hdml, "<WRAP>");
2187 for (i=0; i<hdml->dir_level; i++) {
2188 s_output_to_hdml_out(hdml, " ");
2190 hdml->hdml_br_flag = 1;
2196 * It is a handler who processes the LI tag.
2198 * @param pdoc [i/o] The pointer to the HDML structure at the output
2199 * destination is specified.
2200 * @param node [i] The LI tag node is specified.
2201 * @return The conversion result is returned.
2204 s_hdml_end_li_tag(void *pdoc, Node *UNUSED(child))
2206 hdml_t *hdml = GET_HDML(pdoc);
2207 if (hdml->hdml_br_flag == 0) {
2208 s_output_to_hdml_out(hdml, "<BR>\r\n");
2209 if (hdml->in_center)
2212 if (hdml->div_in_center)
2213 hdml->div_in_center--;
2215 hdml->hdml_br_flag = 1;
2221 * It is a handler who processes the IMG tag.
2223 * @param pdoc [i/o] The pointer to the HDML structure at the output
2224 * destination is specified.
2225 * @param node [i] The IMG tag node is specified.
2226 * @return The conversion result is returned.
2229 s_hdml_start_img_tag(void *pdoc, Node *node)
2233 #ifndef IMG_NOT_CONVERT_FILENAME
2240 hdml = GET_HDML(pdoc);
2242 #ifndef IMG_NOT_CONVERT_FILENAME
2246 s_hdml_tag_output_upper_half(hdml, node);
2248 out = apr_palloc(doc->r->pool, 1);
2250 out = apr_pstrcat(doc->r->pool, out, "<img", NULL);
2252 /* Get Attributes */
2253 for (attr = qs_get_attr(doc,node);
2255 attr = qs_get_next_attr(doc,attr)) {
2256 char *name = qs_get_attr_name(doc,attr);
2257 char *value = qs_get_attr_value(doc,attr);
2258 if (STRCASEEQ('s','S',"src",name) && value && *value) {
2259 value = chxj_encoding_parameter(hdml->doc->r, value);
2260 out = apr_pstrcat(doc->r->pool, out, " src=\"", NULL);
2261 #ifdef IMG_NOT_CONVERT_FILENAME
2262 out = apr_pstrcat(doc->r->pool, out, value, NULL);
2264 out = apr_pstrcat(doc->r->pool, out, chxj_img_conv(doc->r, spec,value), NULL);
2266 out = apr_pstrcat(doc->r->pool, out, "\"", NULL);
2268 else if (STRCASEEQ('a','A',"align",name)) {
2270 if (STRCASEEQ('r','R',"right", value)) {
2271 s_output_to_hdml_out(hdml, "<RIGHT>" );
2274 else if (STRCASEEQ('c','C',"center",value)) {
2275 s_output_to_hdml_out(hdml, "<CENTER>" );
2280 else if (STRCASEEQ('w','W',"width",name)) {
2283 else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2286 else if (STRCASEEQ('h','H',"hspace", name) && value && *value) {
2289 else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2292 else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2293 out = apr_pstrcat(doc->r->pool, out, " alt=\"", NULL);
2294 out = apr_pstrcat(doc->r->pool, out, value, NULL);
2295 out = apr_pstrcat(doc->r->pool, out, "\"", NULL);
2298 out = apr_pstrcat(doc->r->pool, out, ">", NULL);
2299 s_output_to_hdml_out(hdml, out);
2301 s_output_to_hdml_out(hdml, "<BR>");
2304 hdml->hdml_br_flag = 0;
2311 * It is a handler who processes the IMG tag.
2313 * @param pdoc [i/o] The pointer to the HDML structure at the output
2314 * destination is specified.
2315 * @param node [i] The IMG tag node is specified.
2316 * @return The conversion result is returned.
2319 s_hdml_end_img_tag(void *pdoc, Node *UNUSED(child))
2321 hdml_t *hdml = GET_HDML(pdoc);
2327 * It is a handler who processes the SELECT tag.
2329 * @param pdoc [i/o] The pointer to the HDML structure at the output
2330 * destination is specified.
2331 * @param node [i] The SELECT tag node is specified.
2332 * @return The conversion result is returned.
2335 s_hdml_start_select_tag(void *pdoc, Node *node)
2342 hdml = GET_HDML(pdoc);
2346 s_hdml_tag_output_upper_half(hdml, node);
2350 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2351 "<A TASK=GOSUB LABEL=\x91\x49\x91\xf0 "
2352 "VARS=\"V=$%s%02d\" DEST=#D%d "
2353 "RECEIVE=\"%s%02d;%s%02d\">"
2355 s_get_form_no(r, hdml),
2356 hdml->var_cnt[hdml->pure_form_cnt]+0,
2358 s_get_form_no(r, hdml),
2359 hdml->var_cnt[hdml->pure_form_cnt]+0,
2360 s_get_form_no(r, hdml),
2361 hdml->var_cnt[hdml->pure_form_cnt]+1,
2362 s_get_form_no(r, hdml),
2363 hdml->var_cnt[hdml->pure_form_cnt]+1));
2365 s_output_to_hdml_card(hdml,
2366 apr_psprintf(r->pool,
2367 "<CHOICE KEY=V NAME=D%d ", hdml->card_cnt));
2368 s_output_to_hdml_card(hdml,
2369 apr_psprintf(r->pool,
2370 "DEFAULT=$V METHOD=ALPHA MARKABLE=FALSE>\r\n"));
2371 /*--------------------------------------------------------------------------*/
2372 /* Get Attributes */
2373 /*--------------------------------------------------------------------------*/
2374 for (attr = qs_get_attr(doc,node);
2376 attr=qs_get_next_attr(doc,attr)) {
2377 char *name = qs_get_attr_name(doc,attr);
2378 char *value = qs_get_attr_value(doc,attr);
2379 char *selval = NULL;
2380 char *selvaltxt = NULL;
2382 if (STRCASEEQ('n','N',"name",name)) {
2383 s_output_to_postdata(hdml,
2384 apr_psprintf(r->pool, "%s=$%s%02d",
2386 s_get_form_no(r, hdml),
2387 hdml->var_cnt[hdml->pure_form_cnt]));
2388 selval = qs_get_selected_value(doc, node, r->pool);
2390 DBG(r, "selected value not found");
2391 selval = qs_alloc_zero_byte_string(r->pool);
2394 DBG(r, "selected value found[%s]" , selval);
2396 selvaltxt = qs_get_selected_value_text(doc, node, r->pool);
2398 selvaltxt = qs_alloc_zero_byte_string(r->pool);
2400 DBG(r, "selvaltxt:[%s]" ,selvaltxt);
2402 s_output_to_init_vars(hdml,
2403 apr_psprintf(r->pool,
2404 "%s%02d=%s&%s%02d=%s",
2405 s_get_form_no(r, hdml),
2406 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2408 s_get_form_no(r, hdml),
2409 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2412 hdml->var_cnt[hdml->pure_form_cnt] += 2;
2416 hdml->hdml_br_flag = 0;
2422 * It is a handler who processes the SELECT tag.
2424 * @param pdoc [i/o] The pointer to the HDML structure at the output
2425 * destination is specified.
2426 * @param node [i] The SELECT tag node is specified.
2427 * @return The conversion result is returned.
2430 s_hdml_end_select_tag(void *pdoc, Node *UNUSED(node))
2432 hdml_t *hdml = GET_HDML(pdoc);
2434 s_output_to_hdml_card(hdml, "</CHOICE>\r\n");
2441 * It is a handler who processes the OPTION tag.
2443 * @param pdoc [i/o] The pointer to the HDML structure at the output
2444 * destination is specified.
2445 * @param node [i] The OPTION tag node is specified.
2446 * @return The conversion result is returned.
2449 s_hdml_start_option_tag(void *pdoc, Node *node)
2458 hdml = GET_HDML(pdoc);
2464 hdml->option_flag = 1;
2465 val = qs_get_value_attr(doc, node, r->pool);
2467 /*--------------------------------------------------------------------------*/
2468 /* The child node of the object tag node acquires the value in assumption */
2469 /* that is the TEXT node. */
2470 /*--------------------------------------------------------------------------*/
2471 child = qs_get_child_node(doc, node);
2473 txtval = apr_palloc(r->pool, 1);
2477 txtval = qs_get_node_value(doc, child);
2480 DBG(r, "txtval:[%s]" , txtval);
2482 if (val && txtval) {
2483 s_output_to_hdml_card(hdml,
2484 apr_psprintf(r->pool,
2485 "<CE TASK=RETURN VALUE=\"%s\" "
2486 "RETVALS=\"$V;%s\">%s</CE>\r\n",
2488 qs_trim_string(r->pool,txtval),
2489 qs_trim_string(r->pool,txtval)));
2492 hdml->hdml_br_flag = 0;
2499 * It is a handler who processes the OPTION tag.
2501 * @param pdoc [i/o] The pointer to the HDML structure at the output
2502 * destination is specified.
2503 * @param node [i] The OPTION tag node is specified.
2504 * @return The conversion result is returned.
2507 s_hdml_end_option_tag(void *pdoc, Node *UNUSED(node))
2509 hdml_t *hdml = GET_HDML(pdoc);
2511 hdml->option_flag = 0;
2518 * It is a handler who processes the DIV tag.
2520 * @param pdoc [i/o] The pointer to the HDML structure at the output
2521 * destination is specified.
2522 * @param node [i] The DIV tag node is specified.
2523 * @return The conversion result is returned.
2526 s_hdml_start_div_tag(void *pdoc, Node *node)
2532 hdml = GET_HDML(pdoc);
2535 /*--------------------------------------------------------------------------*/
2536 /* If the br tag is not output immediately before the div tag appears, the */
2537 /* br tag is output. */
2538 /*--------------------------------------------------------------------------*/
2539 if (hdml->hdml_br_flag == 0) {
2540 hdml->hdml_br_flag = 1;
2541 s_output_to_hdml_out(hdml, "<BR>\r\n");
2544 /*--------------------------------------------------------------------------*/
2545 /* The object tag node is scanned. */
2546 /*--------------------------------------------------------------------------*/
2547 for (attr = qs_get_attr(doc,node);
2549 attr = qs_get_next_attr(doc,attr)) {
2550 char *name = qs_get_attr_name(doc,attr);
2551 char *value = qs_get_attr_value(doc,attr);
2552 if (STRCASEEQ('a','A',"align",name)) {
2553 if (STRCASEEQ('r','R',"right",value)) {
2554 hdml->div_right_flag = 1;
2555 s_output_to_hdml_out(hdml, "<RIGHT>");
2556 hdml->hdml_br_flag = 0;
2559 else if (STRCASEEQ('c','C',"center",value)) {
2560 hdml->div_center_flag = 1;
2561 s_output_to_hdml_out(hdml, "<CENTER>");
2562 hdml->hdml_br_flag = 0;
2567 hdml->hdml_br_flag = 0;
2574 * It is a handler who processes the DIV tag.
2576 * @param pdoc [i/o] The pointer to the HDML structure at the output
2577 * destination is specified.
2578 * @param node [i] The DIV tag node is specified.
2579 * @return The conversion result is returned.
2582 s_hdml_end_div_tag(void *pdoc, Node *UNUSED(node))
2584 hdml_t *hdml = GET_HDML(pdoc);
2585 request_rec *r = hdml->doc->r;
2587 if (hdml->div_right_flag == 1) {
2588 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2589 hdml->div_right_flag = 0;
2591 if (hdml->div_center_flag == 1) {
2592 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2593 hdml->div_center_flag = 0;
2594 hdml->div_in_center = 0;
2602 * It is a wrapper of the apr_pstrcat function.
2604 * @param r [i] To use POOL, the pointer to request_rec is specified.
2605 * @param o [i] The character string of connected origin is specified.
2606 * @param s [i] The character string connected with 'o' parameter is
2608 * @param len [i/o] The pointer to the area where the character string
2609 * length is stored is specified.
2610 * @return The character string after it connects it is returned.
2613 qs_out_apr_pstrcat(request_rec *r, char *o, char *s, int *len)
2615 *len = (strlen(s) + *len);
2616 return apr_pstrcat(r->pool, o, s, NULL);
2620 * The prepositive character string used to generate the variable for HDML is
2623 * @param r [i] To use POOL, the pointer to request_rec is specified.
2624 * @param hdml [i] The pointer to the HDML structure that maintains the seed
2625 * to generate it is specified.
2626 * @return The character string after it generates it is returned.
2629 s_s_get_form_no(request_rec *r, hdml_t *hdml)
2635 fc = hdml->form_cnt;
2637 apr_time_exp_tz(&tm, hdml->form_cnt, 0);
2639 result = apr_psprintf(r->pool, "%c",(int)('A' + ((fc / 100) % 26)));
2640 result = apr_pstrcat(r->pool, result,
2641 apr_psprintf(r->pool, "%02d%02d%02d",
2649 * The number of tag nodes .."Input type =' radio '".. is counted.
2651 * @param hdml [i] The pointer to the HDML structure is specified.
2652 * @param node [i] The first parents node that counts the radio tag node is
2656 s_hdml_count_radio_tag(hdml_t *hdml, Node *node)
2665 /*--------------------------------------------------------------------------*/
2666 /* All the child nodes of the specified node are scanned. */
2667 /*--------------------------------------------------------------------------*/
2668 for (child = qs_get_child_node(doc,node);
2670 child = qs_get_next_node(doc,child)) {
2679 name = qs_get_node_name(doc,child);
2680 if (strcasecmp(name, "input") != 0) {
2681 s_hdml_count_radio_tag(hdml, child);
2685 DBG(r,"found input tag");
2687 type = qs_get_type_attr(doc, child, r->pool);
2689 ERR(r, "Oops! The input tag without the type attribute has been found.Please give a type.");
2693 if (strcasecmp(type, "radio") != 0)
2696 DBG(r, "found type=radio");
2698 rname = qs_get_name_attr (doc, child, r->pool);
2699 rvalue = qs_get_value_attr(doc, child, r->pool);
2702 /*----------------------------------------------------------------------*/
2703 /* Oops!. The input tag without the name attribute has been found. */
2704 /*----------------------------------------------------------------------*/
2705 DBG(r, "Oops!. The input tag without the name attribute has been found. Please give a name.");
2709 DBG(r, "found name attribute");
2711 /*------------------------------------------------------------------------*/
2712 /* It scans in radio_name_list. When the same value exists, the */
2713 /* value is overwrited. */
2714 /* The value is written in a new area when not is. */
2715 /*------------------------------------------------------------------------*/
2716 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
2717 if (! hdml->radio_name_list[ii]) {
2718 DBG(r, "new name:[%s]", rname);
2721 if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2722 DBG(r, "already registered name:[%s]", rname);
2726 if (ii == MAX_RADIO_COUNT) {
2727 DBG(r, apr_psprintf(r->pool,
2728 "I do not understand the name of the radiobutton "
2729 "of %d piece or more. Please decrease "
2730 "the number of radiobuttons.",
2735 DBG(r,"add radio name:[%s]" ,rname);
2737 hdml->radio_name_list[ii] = apr_pstrdup(r->pool, rname);
2739 /*------------------------------------------------------------------------*/
2740 /* It adds it to radio_value_list. */
2741 /*------------------------------------------------------------------------*/
2742 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) {
2743 if (!hdml->radio_value_list[ii][jj])
2746 if (jj == MAX_RADIO_VALUE_COUNT) {
2747 DBG(r, apr_psprintf(r->pool,
2748 "I do not understand the value of the radiobutton "
2749 "of %d piece or more. Please decrease "
2750 "the number of radiobuttons.",
2751 MAX_RADIO_VALUE_COUNT));
2754 hdml->radio_value_list[ii][jj] = apr_pstrdup(r->pool, rvalue);
2756 /*------------------------------------------------------------------------*/
2757 /* Now let's be the checked attribute or scan. */
2758 /*------------------------------------------------------------------------*/
2759 chkd = qs_get_checked_attr(hdml->doc, child, r->pool);
2761 DBG(r,apr_psprintf(r->pool,
2762 "The tag scanned now had the checked "
2763 "attribute. The value is [%s].",
2765 hdml->radio_checked_value[ii] = apr_pstrdup(r->pool, rvalue);
2772 * The character string is added, and output to the out member of the HDML
2775 * @param hdml [i/o] The pointer to the HDML structure that maintains the out
2776 * member at the output destination is specified.
2777 * @param s [i] The character string that should be output is specified.
2778 * @return The pointer to the HDML structure after it processes it is returned.
2781 s_output_to_hdml_out(hdml_t *hdml, char *s)
2783 hdml->out = qs_out_apr_pstrcat(hdml->doc->r, hdml->out, s, &hdml->out_len);
2790 * The character string is added, and output to the card member of the HDML
2793 * @param hdml [i/o] The pointer to the HDML structure that maintains the
2794 * card member at the output destination is specified.
2795 * @param s [i] The character string that should be output is specified.
2796 * @return The pointer to the HDML structure after it processes it is returned.
2799 s_output_to_hdml_card(hdml_t *hdml, char *s)
2801 hdml->card = qs_out_apr_pstrcat(hdml->doc->r, hdml->card, s, &hdml->card_len);
2809 * The data for the post is added, and output.
2811 * @param hdml [i/o] The pointer to the HDML structure at the output
2812 * destination is specified.
2813 * @param s [i] The character string that wants to output to postdata is
2817 s_output_to_postdata(hdml_t *hdml, char *s)
2819 request_rec *r = hdml->doc->r;
2821 if (strlen(hdml->postdata[hdml->pure_form_cnt])) {
2822 hdml->postdata[hdml->pure_form_cnt] =
2823 apr_pstrcat(r->pool,
2824 hdml->postdata[hdml->pure_form_cnt],
2828 hdml->postdata[hdml->pure_form_cnt] =
2829 apr_pstrcat(r->pool,
2830 hdml->postdata[hdml->pure_form_cnt],
2831 qs_trim_string(r->pool, s),
2834 DBG(r, "POSTDATA:[%s]", hdml->postdata[hdml->pure_form_cnt] );
2840 * The tag output upper half.
2842 * @param hdml [i/o] The pointer to the HDML structure at the output
2843 * destination is specified.
2844 * @param node [i] The A tag node is specified.
2847 s_hdml_tag_output_upper_half(hdml_t *hdml, Node *UNUSED(node))
2849 if (hdml->hdml_br_flag == 1 && hdml->div_right_flag == 1) {
2850 s_output_to_hdml_out(hdml, "<RIGHT>");
2851 hdml->hdml_br_flag = 0;
2854 if (hdml->hdml_br_flag == 1
2856 && hdml->in_center == 0) {
2857 s_output_to_hdml_out(hdml, "<CENTER>");
2859 hdml->hdml_br_flag = 0;
2861 else if (hdml->hdml_br_flag == 1
2862 && hdml->div_center_flag > 0
2863 && hdml->div_in_center == 0) {
2864 s_output_to_hdml_out(hdml, "<CENTER>");
2865 hdml->div_in_center++;
2866 hdml->hdml_br_flag = 0;
2873 * The data for the init_vars is added, and output.
2875 * @param hdml [i/o] The pointer to the HDML structure at the output
2876 * destination is specified.
2877 * @param s [i] The character string that wants to output to postdata is
2881 s_output_to_init_vars(hdml_t *hdml, char *s)
2883 request_rec *r = hdml->doc->r;
2885 if (strlen(hdml->init_vars)) {
2886 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, "&", NULL);
2889 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, qs_trim_string(r->pool,s), NULL);
2891 DBG(r, "INIT_VARS:[%s]", hdml->init_vars);
2897 s_hdml_chxjif_tag(void *pdoc, Node *node)
2903 hdml = GET_HDML(pdoc);
2906 for (child = qs_get_child_node(doc, node);
2908 child = qs_get_next_node(doc, child)) {
2909 s_output_to_hdml_out(hdml, child->otext);
2910 s_hdml_chxjif_tag(hdml, child);
2917 s_hdml_text_tag(void *pdoc, Node *child)
2927 int one_line_count = 0;
2930 hdml = GET_HDML(pdoc);
2934 textval = qs_get_node_value(doc,child);
2935 if (strlen(textval) == 0) {
2939 if (hdml->option_flag == 1) {
2943 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
2944 memset(tmp, 0, qs_get_node_size(doc,child)+1);
2945 tdst = apr_palloc(r->pool, 1);
2951 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
2953 int rtn = s_hdml_search_emoji(hdml, &textval[ii], &out);
2955 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
2957 one_line_count+=(rtn-1);
2960 if (hdml->hdml_blockquote_flag) {
2961 if (one_line_count == 0) {
2962 tdst = qs_out_apr_pstrcat(r, tdst, "<WRAP> <TAB>", &tdst_len);
2964 if (is_sjis_kanji(textval[ii])) {
2965 one_byte[0] = textval[ii+0];
2966 one_byte[1] = textval[ii+1];
2968 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2973 one_byte[0] = textval[ii+0];
2975 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2977 if (one_byte[0] == '\n') {
2983 if (hdml->pre_flag) {
2984 if (one_line_count == 0) {
2985 tdst = qs_out_apr_pstrcat(r, tdst, "<LINE>", &tdst_len);
2987 if (is_sjis_kanji(textval[ii])) {
2988 one_byte[0] = textval[ii+0];
2989 one_byte[1] = textval[ii+1];
2991 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
2996 one_byte[0] = textval[ii+0];
2998 if (one_byte[0] == ' ') {
2999 tdst = qs_out_apr_pstrcat(r, tdst, " ", &tdst_len);
3002 tdst = qs_out_apr_pstrcat(r, tdst, chxj_ap_escape_html(r->pool, one_byte), &tdst_len);
3005 if (one_byte[0] == '\n') {
3011 if (is_sjis_kanji(textval[ii])) {
3012 one_byte[0] = textval[ii+0];
3013 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3014 one_byte[0] = textval[ii+1];
3015 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3019 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3020 one_byte[0] = textval[ii+0];
3021 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3024 memcpy(tmp, textval, strlen(textval)-1);
3026 s_hdml_tag_output_upper_half(hdml, child->parent);
3027 s_output_to_hdml_out(hdml, tdst);
3028 hdml->hdml_br_flag = 0;
3035 * It is a handler who processes the BLOCKQUOTE tag.
3037 * @param pdoc [i/o] The pointer to the HDML structure at the output
3038 * destination is specified.
3039 * @param node [i] The BLOCKQUOTE tag node is specified.
3040 * @return The conversion result is returned.
3043 s_hdml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3045 hdml_t *hdml = GET_HDML(pdoc);
3046 hdml->hdml_blockquote_flag++;
3052 * It is a handler who processes the BLOCKQUOTE tag.
3054 * @param pdoc [i/o] The pointer to the HDML structure at the output
3055 * destination is specified.
3056 * @param node [i] The BLOCKQUOTE tag node is specified.
3057 * @return The conversion result is returned.
3060 s_hdml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3062 hdml_t *hdml = GET_HDML(pdoc);
3063 hdml->hdml_blockquote_flag--;
3064 s_output_to_hdml_out(hdml, "\r\n");
3070 * It is a handler who processes the DIR tag.
3072 * @param pdoc [i/o] The pointer to the HDML structure at the output
3073 * destination is specified.
3074 * @param node [i] The DIR tag node is specified.
3075 * @return The conversion result is returned.
3078 s_hdml_start_dir_tag(void *pdoc, Node *UNUSED(child))
3080 hdml_t *hdml = GET_HDML(pdoc);
3087 * It is a handler who processes the DIR tag.
3089 * @param pdoc [i/o] The pointer to the HDML structure at the output
3090 * destination is specified.
3091 * @param node [i] The DIR tag node is specified.
3092 * @return The conversion result is returned.
3095 s_hdml_end_dir_tag(void *pdoc, Node *UNUSED(child))
3097 hdml_t *hdml = GET_HDML(pdoc);
3104 * It is a handler who processes the DT tag.
3106 * @param pdoc [i/o] The pointer to the HDML structure at the output
3107 * destination is specified.
3108 * @param node [i] The DT tag node is specified.
3109 * @return The conversion result is returned.
3112 s_hdml_start_dt_tag(void *pdoc, Node *UNUSED(child))
3114 hdml_t *hdml = GET_HDML(pdoc);
3115 s_output_to_hdml_out(hdml, "<LINE>");
3121 * It is a handler who processes the DT tag.
3123 * @param pdoc [i/o] The pointer to the HDML structure at the output
3124 * destination is specified.
3125 * @param node [i] The DT tag node is specified.
3126 * @return The conversion result is returned.
3129 s_hdml_end_dt_tag(void *pdoc, Node *UNUSED(child))
3131 hdml_t *hdml = GET_HDML(pdoc);
3132 s_output_to_hdml_out(hdml, "\r\n");
3138 * It is a handler who processes the DD tag.
3140 * @param pdoc [i/o] The pointer to the HDML structure at the output
3141 * destination is specified.
3142 * @param node [i] The DD tag node is specified.
3143 * @return The conversion result is returned.
3146 s_hdml_start_dd_tag(void *pdoc, Node *UNUSED(child))
3148 hdml_t *hdml = GET_HDML(pdoc);
3149 s_output_to_hdml_out(hdml, "<WRAP> <TAB>");
3155 * It is a handler who processes the DD tag.
3157 * @param pdoc [i/o] The pointer to the HDML structure at the output
3158 * destination is specified.
3159 * @param node [i] The DD tag node is specified.
3160 * @return The conversion result is returned.
3163 s_hdml_end_dd_tag(void *pdoc, Node *UNUSED(child))
3165 hdml_t *hdml = GET_HDML(pdoc);
3166 s_output_to_hdml_out(hdml, "\r\n");
3172 * It is a handler who processes the PLAINTEXT tag.
3174 * @param pdoc [i/o] The pointer to the HDML structure at the output
3175 * destination is specified.
3176 * @param node [i] The PLAINTEXT tag node is specified.
3177 * @return The conversion result is returned.
3180 s_hdml_start_plaintext_tag(void *pdoc, Node *node)
3182 hdml_t *hdml = GET_HDML(pdoc);
3183 hdml->plaintext_value_len = 0;
3184 s_hdml_start_plaintext_tag_inner(pdoc,node);
3189 s_hdml_start_plaintext_tag_inner(void *pdoc, Node *node)
3191 hdml_t *hdml = GET_HDML(pdoc);
3192 Doc *doc = hdml->doc;
3194 for (child = qs_get_child_node(doc, node);
3196 child = qs_get_next_node(doc, child)) {
3198 char *str = chxj_ap_escape_html(doc->r->pool, child->otext);
3199 int len = strlen(str);
3201 for (i=0; i<len; i++) {
3202 if (hdml->plaintext_value_len == 0) {
3203 s_output_to_hdml_out(hdml, "<LINE>");
3205 if (is_sjis_kanji(child->otext[i]) && i + 1 < len) {
3206 oneChar[0] = child->otext[i+0];
3207 oneChar[1] = child->otext[i+1];
3209 s_output_to_hdml_out(hdml, oneChar);
3210 hdml->plaintext_value_len +=2;
3214 if (child->otext[i] == '\n') {
3215 hdml->plaintext_value_len = 0;
3218 s_output_to_hdml_out(hdml, oneChar);
3221 oneChar[0] = child->otext[i];
3223 s_output_to_hdml_out(hdml, oneChar);
3224 hdml->plaintext_value_len++;
3226 s_hdml_start_plaintext_tag_inner(pdoc, child);
3233 * It is a handler who processes the PLAINTEXT tag.
3235 * @param pdoc [i/o] The pointer to the HDML structure at the output
3236 * destination is specified.
3237 * @param node [i] The PLAINTEXT tag node is specified.
3238 * @return The conversion result is returned.
3241 s_hdml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3243 hdml_t *hdml = GET_HDML(pdoc);
3249 * It is a handler who processes the PRE tag.
3251 * @param pdoc [i/o] The pointer to the HDML structure at the output
3252 * destination is specified.
3253 * @param node [i] The PRE tag node is specified.
3254 * @return The conversion result is returned.
3257 s_hdml_start_pre_tag(void *pdoc, Node *UNUSED(node))
3263 hdml = GET_HDML(pdoc);
3273 * It is a handler who processes the PRE tag.
3275 * @param pdoc [i/o] The pointer to the HDML structure at the output
3276 * destination is specified.
3277 * @param node [i] The PRE tag node is specified.
3278 * @return The conversion result is returned.
3281 s_hdml_end_pre_tag(void *pdoc, Node *UNUSED(child))
3287 hdml = GET_HDML(pdoc);
3298 * handler of the TEXTAREA tag.
3300 * @param hdml [i/o] The pointer to the HDML structure at the output
3301 * destination is specified.
3302 * @param tag [i] Specified The TEXTAREA tag node.
3305 s_hdml_start_textarea_tag(void *pdoc, Node *node)
3315 hdml_t *hdml = GET_HDML(pdoc);
3320 s_hdml_tag_output_upper_half(hdml, node);
3323 s_output_to_hdml_out(hdml,
3324 apr_psprintf(r->pool,
3325 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
3326 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
3328 s_get_form_no(r, hdml),
3329 hdml->var_cnt[hdml->pure_form_cnt],
3330 s_get_form_no(r, hdml),
3331 hdml->var_cnt[hdml->pure_form_cnt]
3334 s_output_to_hdml_out(hdml,
3335 apr_psprintf(r->pool,
3336 "[$%s%02d]</A>\r\n" ,
3337 s_get_form_no(r, hdml),
3338 hdml->var_cnt[hdml->pure_form_cnt]));
3340 /*--------------------------------------------------------------------------*/
3341 /* ENTRY CARD is output here. */
3342 /*--------------------------------------------------------------------------*/
3343 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
3344 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
3345 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
3351 nm = qs_get_name_attr(doc, node, r->pool);
3353 nm = qs_alloc_zero_byte_string(r->pool);
3356 s_output_to_postdata(hdml,
3357 apr_psprintf(r->pool,
3360 s_get_form_no(r, hdml),
3361 hdml->var_cnt[hdml->pure_form_cnt]));
3363 mlen = qs_get_maxlength_attr (doc, node, r->pool);
3364 is = qs_get_istyle_attr (doc, node, r->pool);
3365 val = s_hdml_inner_textarea_tag_get_value(hdml, node);
3367 fmt = qs_conv_istyle_to_format(r, is);
3370 for (ii=0; ii<strlen(mlen); ii++) {
3371 if (mlen[ii] < '0' || mlen[ii] > '9') {
3372 mlen = apr_psprintf(r->pool, "0");
3376 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
3379 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt));
3383 s_output_to_hdml_card(hdml,
3384 " MARKABLE=FALSE>\r\n"
3385 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
3388 s_output_to_init_vars(hdml,
3389 apr_psprintf(r->pool,
3391 s_get_form_no(r, hdml),
3392 hdml->var_cnt[hdml->pure_form_cnt],
3393 chxj_escape_uri(r->pool,val)));
3396 s_output_to_init_vars(hdml,
3397 apr_psprintf(r->pool,
3399 s_get_form_no(r, hdml),
3400 hdml->var_cnt[hdml->pure_form_cnt]));
3402 hdml->var_cnt[hdml->pure_form_cnt]++;
3407 s_hdml_inner_textarea_tag_get_value(hdml_t *hdml, Node *node)
3409 Doc *doc = hdml->doc;
3411 char *result = apr_pstrdup(doc->r->pool, "\0");
3412 for (child = qs_get_child_node(doc, node);
3414 child = qs_get_next_node(doc, child)) {
3415 char *textval = qs_get_node_value(doc,child);
3416 if (textval && *textval) {
3417 result = apr_pstrcat(doc->r->pool, result, textval, NULL);