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);
88 static char *((*s_get_form_no)(request_rec* r, hdml_t* hdml)) = s_s_get_form_no;
90 static void s_hdml_count_radio_tag (hdml_t* hdml, Node* node) ;
92 static void s_hdml_do_input_text_tag (hdml_t *hdml, Node *tag);
93 static void s_hdml_do_input_password_tag(hdml_t *hdml, Node *tag);
94 static void s_hdml_do_input_submit_tag (hdml_t *hdml, Node *tag);
95 static void s_hdml_do_input_reset_tag (hdml_t *hdml, Node *tag);
96 static void s_hdml_do_input_hidden_tag (hdml_t *hdml, Node *tag);
97 static void s_hdml_do_input_radio_tag (hdml_t *hdml, Node *tag);
98 static void s_hdml_do_input_checkbox_tag(hdml_t *hdml, Node *tag);
99 static void s_hdml_tag_output_upper_half(hdml_t *hdml, Node* node);
101 static hdml_t *s_output_to_hdml_out (hdml_t *hdml, char *s);
102 static hdml_t *s_output_to_hdml_card (hdml_t *hdml, char *s);
103 static void s_output_to_postdata (hdml_t *hdml, char *s);
104 static void s_output_to_init_vars (hdml_t *hdml, char *s);
105 static int s_hdml_search_emoji (hdml_t *hdml, char *txt, char **rslt);
107 static char *s_hdml_chxjif_tag (void *pdoc, Node *node);
108 static char *s_hdml_text_tag (void *pdoc, Node *node);
111 tag_handler hdml_handler[] = {
114 s_hdml_start_html_tag,
119 s_hdml_start_meta_tag,
129 s_hdml_start_div_tag,
134 s_hdml_start_pre_tag,
149 s_hdml_start_dir_tag,
154 s_hdml_start_div_tag,
159 s_hdml_start_div_tag,
164 s_hdml_start_div_tag,
169 s_hdml_start_div_tag,
174 s_hdml_start_div_tag,
179 s_hdml_start_div_tag,
184 s_hdml_start_head_tag,
189 s_hdml_start_title_tag,
190 s_hdml_end_title_tag,
194 s_hdml_start_base_tag,
199 s_hdml_start_body_tag,
234 s_hdml_start_font_tag,
239 s_hdml_start_form_tag,
244 s_hdml_start_input_tag,
245 s_hdml_end_input_tag,
249 s_hdml_start_center_tag,
250 s_hdml_end_center_tag,
259 s_hdml_start_img_tag,
264 s_hdml_start_select_tag,
265 s_hdml_end_select_tag,
269 s_hdml_start_option_tag,
270 s_hdml_end_option_tag,
274 s_hdml_start_div_tag,
339 s_hdml_start_blockquote_tag,
340 s_hdml_end_blockquote_tag,
344 s_hdml_start_dir_tag,
359 s_hdml_start_dir_tag,
364 s_hdml_start_plaintext_tag,
365 s_hdml_end_plaintext_tag,
380 * converts from CHTML to hdml.
382 * @param r [i] Requet_rec is appointed.
383 * @param spec [i] The result of the device specification processing which
384 * was done in advance is appointed.
385 * @param src [i] The character string before the converting is appointed.
386 * @return The character string after the converting is returned.
395 chxjconvrule_entry* entryp,
396 cookie_t* UNUSED(cookie)
407 /*--------------------------------------------------------------------------*/
409 /*--------------------------------------------------------------------------*/
411 dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
413 DBG(r,"i found qrcode xml");
416 DBG(r,"not found qrcode xml");
418 /*--------------------------------------------------------------------------*/
419 /* initialize hdml structure */
420 /*--------------------------------------------------------------------------*/
421 s_init_hdml(&hdml,&doc,r, spec);
423 hdml.entryp = entryp;
425 chxj_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
426 /*--------------------------------------------------------------------------*/
428 /*--------------------------------------------------------------------------*/
430 chxj_dump_out("[src] CHTML->HDML", src, srclen);
433 /*--------------------------------------------------------------------------*/
434 /* It is examined whether there is a location header. It ends without doing */
435 /* anything when is. */
436 /*--------------------------------------------------------------------------*/
437 buf = (char*)apr_table_get(r->headers_out, (const char*)"Location");
439 /*------------------------------------------------------------------------*/
440 /* The Location header generates tag in an initial HDML machine for the */
441 /* uncorrespon dence. */
442 /*------------------------------------------------------------------------*/
443 DBG(r, "Location is not null[Location:%s]", buf);
444 s_output_to_hdml_out(&hdml,
445 "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\r\n"
446 "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\r\n"
447 "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
449 s_output_to_hdml_out(&hdml, buf);
450 s_output_to_hdml_out(&hdml,
455 dst = apr_pstrdup(r->pool, hdml.out);
458 /*------------------------------------------------------------------------*/
459 /* Here, the parsing of the received character string is done */
460 /*------------------------------------------------------------------------*/
461 char *ss = apr_palloc(r->pool, srclen + 1);
462 memset(ss, 0, srclen + 1);
463 memcpy(ss, src, srclen);
465 DBG(r, "input strlen(src)=[%d]", (int)srclen);
466 DBG(r, "[[[[%s]]]", src);
468 qs_init_malloc(&doc);
469 qs_init_root_node(&doc);
471 qs_parse_string(&doc, ss, srclen);
473 /*------------------------------------------------------------------------*/
474 /* The number of radiobuttons is counted. */
475 /*------------------------------------------------------------------------*/
476 s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
478 chxj_node_exchange(spec,r,(void*)&hdml, &doc, qs_get_root(&doc), 0);
481 DBG(r,"tmp=[%s]", dst);
482 qs_all_free(&doc,QX_LOGMARK);
485 /*--------------------------------------------------------------------------*/
487 /*--------------------------------------------------------------------------*/
489 chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
492 /*--------------------------------------------------------------------------*/
493 /* When there is no processing result, former character string is copied */
494 /* and it returns it. */
495 /*--------------------------------------------------------------------------*/
498 return apr_pstrdup(r->pool,src);
501 *dstlen = hdml.out_len;
503 /*--------------------------------------------------------------------------*/
504 /* Null is set at the end of the character string to make sure. */
505 /*--------------------------------------------------------------------------*/
506 dst[hdml.out_len] = 0;
513 * The HDML structure is initialized.
515 * @param hdml [i/o] The pointer to the HDML structure that wants to be
516 * initialized is specified.
517 * @param doc [i] The Doc structure that should be set to the initialized
518 * HDML structure is specified.
519 * @param r [i] To use POOL, the pointer to request_rec is specified.
520 * @param spec [i] The pointer to the device_table
523 s_init_hdml(hdml_t *hdml, Doc *doc, request_rec *r, device_table *spec)
528 /*--------------------------------------------------------------------------*/
529 /* init hdml structure value */
530 /*--------------------------------------------------------------------------*/
531 memset(hdml, 0, sizeof(hdml_t));
533 hdml->card = qs_alloc_zero_byte_string(r);
535 hdml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
536 hdml->doc->parse_mode = PARSE_MODE_CHTML;
538 for (ii=0; ii<MAX_FORM_COUNT; ii++) {
539 hdml->var_cnt[ii] = 0;
540 hdml->postdata[ii] = qs_alloc_zero_byte_string(r);
543 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
544 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
545 hdml->radio_value_list[ii][jj] = NULL;
547 hdml->radio_name_list[ii] = NULL;
548 hdml->radio_out_cnt[ii] = 0;
549 hdml->radio_checked_value[ii] = NULL;
552 for (ii=0; ii<MAX_SUBMIT_BUTTON_COUNT; ii++)
553 hdml->submit_button[ii] = NULL;
555 hdml->init_vars = qs_alloc_zero_byte_string(r);
559 hdml->form_cnt = apr_time_now();
560 hdml->out = qs_alloc_zero_byte_string(r);
565 s_hdml_search_emoji(hdml_t* hdml, char* txt, char** rslt)
578 DBG(r,"spec is NULL");
580 for (ee = hdml->conf->emoji;
584 unsigned char hex1byte;
585 unsigned char hex2byte;
588 DBG(r, "emoji->imode is NULL");
592 hex1byte = ee->imode->hex1byte & 0xff;
593 hex2byte = ee->imode->hex2byte & 0xff;
595 if (ee->imode->string
596 && strlen(ee->imode->string) > 0
597 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
598 if (spec == NULL || spec->emoji_type == NULL) {
599 *rslt = apr_psprintf(r->pool,
602 return strlen(ee->imode->string);
605 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
606 *rslt = apr_psprintf(r->pool,
609 return strlen(ee->imode->string);
612 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
613 *rslt = apr_psprintf(r->pool,
616 return strlen(ee->imode->string);
619 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
620 *rslt = apr_psprintf(r->pool,
623 return strlen(ee->imode->string);
626 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
627 *rslt = apr_psprintf(r->pool,
630 return strlen(ee->imode->string);
633 *rslt = apr_psprintf(r->pool,
636 return strlen(ee->imode->string);
641 && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
642 && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
643 if (spec == NULL || spec->emoji_type == NULL) {
644 *rslt = apr_psprintf(r->pool,
650 if (strcasecmp(hdml->spec->emoji_type, "a") == 0) {
651 *rslt = apr_psprintf(r->pool,
657 if (strcasecmp(hdml->spec->emoji_type, "b") == 0) {
658 *rslt = apr_psprintf(r->pool,
664 if (strcasecmp(hdml->spec->emoji_type, "c") == 0) {
665 *rslt = apr_psprintf(r->pool,
671 if (strcasecmp(hdml->spec->emoji_type, "d") == 0) {
672 *rslt = apr_psprintf(r->pool,
678 *rslt = apr_psprintf(r->pool,
691 * It is a handler who processes the HTML tag.
693 * @param pdoc [i/o] The pointer to the HDML structure at the output
694 * destination is specified.
695 * @param node [i] The HTML tag node is specified.
696 * @return The conversion result is returned.
699 s_hdml_start_html_tag(void* pdoc, Node* UNUSED(node))
703 hdml = GET_HDML(pdoc);
705 s_output_to_hdml_out(hdml,
706 "<HDML VERSION=3.0 TTL=0 MARKABLE=TRUE>\r\n"
707 "<NODISPLAY NAME=D0>\r\n"
708 "<ACTION TYPE=ACCEPT TASK=GOSUB DEST=#D1 NEXT=#D2 CLEAR=TRUE>\r\n"
713 hdml->hdml_br_flag = 0;
720 * It is a handler who processes the HTML tag.
722 * @param pdoc [i/o] The pointer to the HDML structure at the output
723 * destination is specified.
724 * @param node [i] The HTML tag node is specified.
725 * @return The conversion result is returned.
728 s_hdml_end_html_tag(void* pdoc, Node* UNUSED(child))
732 hdml = GET_HDML(pdoc);
734 s_output_to_hdml_card(hdml,
735 "<NODISPLAY NAME=D1>\r\n"
736 "<ACTION TYPE=ACCEPT TASK=RETURN VARS=\""
739 if (strlen(hdml->init_vars))
740 s_output_to_hdml_card(hdml, hdml->init_vars );
742 s_output_to_hdml_card(hdml, "_chxj_dmy=" );
744 s_output_to_hdml_card(hdml,
749 s_output_to_hdml_out(hdml, hdml->card );
750 s_output_to_hdml_out(hdml, "</HDML>\r\n");
752 hdml->hdml_end_flag = 1;
759 * It is a handler who processes the META tag.
761 * @param pdoc [i/o] The pointer to the HDML structure at the output
762 * destination is specified.
763 * @param node [i] The META tag node is specified.
764 * @return The conversion result is returned.
767 s_hdml_start_meta_tag(void* pdoc, Node* UNUSED(node))
771 hdml = GET_HDML(pdoc);
773 hdml->hdml_br_flag = 0;
782 * It is a handler who processes the META tag.
784 * @param pdoc [i/o] The pointer to the HDML structure at the output
785 * destination is specified.
786 * @param node [i] The META tag node is specified.
787 * @return The conversion result is returned.
790 s_hdml_end_meta_tag(void* pdoc, Node* UNUSED(child))
794 hdml = GET_HDML(pdoc);
801 * It is a handler who processes the HEAD tag.
803 * @param pdoc [i/o] The pointer to the HDML structure at the output
804 * destination is specified.
805 * @param node [i] The HEAD tag node is specified.
806 * @return The conversion result is returned.
809 s_hdml_start_head_tag(void* pdoc, Node* UNUSED(node))
813 hdml = GET_HDML(pdoc);
817 hdml->hdml_br_flag = 0;
824 * It is a handler who processes the HEAD tag.
826 * @param pdoc [i/o] The pointer to the HDML structure at the output
827 * destination is specified.
828 * @param node [i] The HEAD tag node is specified.
829 * @return The conversion result is returned.
832 s_hdml_end_head_tag(void* pdoc, Node* UNUSED(child))
836 hdml = GET_HDML(pdoc);
844 * It is a handler who processes the TITLE tag.
846 * @param pdoc [i/o] The pointer to the HDML structure at the output
847 * destination is specified.
848 * @param node [i] The TITLE tag node is specified.
849 * @return The conversion result is returned.
852 s_hdml_start_title_tag(void* pdoc, Node* UNUSED(node))
856 hdml = GET_HDML(pdoc);
858 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"");
860 hdml->found_title = 1;
861 hdml->hdml_br_flag = 0;
868 * It is a handler who processes the TITLE tag.
870 * @param pdoc [i/o] The pointer to the HDML structure at the output
871 * destination is specified.
872 * @param node [i] The TITLE tag node is specified.
873 * @return The conversion result is returned.
876 s_hdml_end_title_tag(void* pdoc, Node* UNUSED(child))
880 hdml = GET_HDML(pdoc);
882 s_output_to_hdml_out(hdml, "\">\r\n");
889 * It is a handler who processes the BASE tag.
891 * @param pdoc [i/o] The pointer to the HDML structure at the output
892 * destination is specified.
893 * @param node [i] The BASE tag node is specified.
894 * @return The conversion result is returned.
897 s_hdml_start_base_tag(void* pdoc, Node* UNUSED(node))
901 hdml = GET_HDML(pdoc);
903 hdml->hdml_br_flag = 0;
910 * It is a handler who processes the BASE tag.
912 * @param pdoc [i/o] The pointer to the HDML structure at the output
913 * destination is specified.
914 * @param node [i] The BASE tag node is specified.
915 * @return The conversion result is returned.
918 s_hdml_end_base_tag(void* pdoc, Node* UNUSED(child))
922 hdml = GET_HDML(pdoc);
929 * It is a handler who processes the BODY tag.
931 * @param pdoc [i/o] The pointer to the HDML structure at the output
932 * destination is specified.
933 * @param node [i] The BODY tag node is specified.
934 * @return The conversion result is returned.
937 s_hdml_start_body_tag(void* pdoc, Node* node)
943 hdml = GET_HDML(pdoc);
947 if (hdml->found_title == 0)
948 s_output_to_hdml_out(hdml, "<DISPLAY NAME=D2 TITLE=\"NO TITLE\">\r\n");
950 s_output_to_hdml_out(hdml, "<ACTION TYPE=ACCEPT TASK=NOOP LABEL=\" \"");
952 /*--------------------------------*/
954 /*--------------------------------*/
955 for (attr = qs_get_attr(doc,node);
957 attr = qs_get_next_attr(doc,attr)) {
961 name = qs_get_attr_name(doc,attr);
963 if ((*name == 'b' || *name == 'B') && strcasecmp(name, "bgcolor") == 0) {
967 if ((*name == 't' || *name == 'T') && strcasecmp(name, "text") == 0) {
971 if ((*name == 'l' || *name == 'L') && strcasecmp(name, "link") == 0) {
975 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alink") == 0) {
979 if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vlink") == 0) {
984 s_output_to_hdml_out(hdml, ">\r\n");
986 hdml->hdml_br_flag = 0;
993 * It is a handler who processes the BODY tag.
995 * @param pdoc [i/o] The pointer to the HDML structure at the output
996 * destination is specified.
997 * @param node [i] The BODY tag node is specified.
998 * @return The conversion result is returned.
1001 s_hdml_end_body_tag(void* pdoc, Node* UNUSED(child))
1005 hdml = GET_HDML(pdoc);
1007 s_output_to_hdml_out(hdml, "\r\n</DISPLAY>\r\n");
1014 * It is a handler who processes the A tag.
1016 * @param pdoc [i/o] The pointer to the HDML structure at the output
1017 * destination is specified.
1018 * @param node [i] The A tag node is specified.
1019 * @return The conversion result is returned.
1022 s_hdml_start_a_tag(void* pdoc, Node* node)
1028 hdml = GET_HDML(pdoc);
1031 s_hdml_tag_output_upper_half(hdml,node);
1033 s_output_to_hdml_out(hdml, "<A");
1036 /*------------------------------------*/
1037 /* Get Attributes */
1038 /*------------------------------------*/
1039 for (attr = qs_get_attr(doc,node);
1041 attr = qs_get_next_attr(doc,attr)) {
1046 name = qs_get_attr_name(doc,attr);
1047 value = qs_get_attr_value(doc,attr);
1049 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
1053 if ((*name == 'h' || *name == 'H') && strcasecmp(name, "href") == 0) {
1054 if ((*value == 'm' || *value == 'M')
1055 && strncasecmp(value, "mailto:", 7) == 0) {
1056 value = chxj_encoding_parameter(hdml->doc->r, value);
1057 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1058 s_output_to_hdml_out(hdml, value );
1059 s_output_to_hdml_out(hdml, "\" " );
1062 if ((*value == 't' || *value == 'T')
1063 && strncasecmp(value, "tel:", 4) == 0) {
1065 s_output_to_hdml_out(hdml, " TASK=CALL NUMBER=\"");
1066 s_output_to_hdml_out(hdml, &value[4] );
1067 s_output_to_hdml_out(hdml, "\" " );
1070 s_output_to_hdml_out(hdml, " TASK=GO DEST=\"" );
1071 s_output_to_hdml_out(hdml, value );
1072 s_output_to_hdml_out(hdml, "\"" );
1076 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0 && value && *value) {
1077 if (strcasecmp(value, "0") != 0) {
1078 s_output_to_hdml_out(hdml, " ACCESSKEY=" );
1079 s_output_to_hdml_out(hdml, value );
1080 s_output_to_hdml_out(hdml, "" );
1084 if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cti") == 0) {
1088 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ijam") == 0) {
1092 if ((*name == 'u' || *name == 'U') && strcasecmp(name, "utn") == 0) {
1096 if ((*name == 't' || *name == 'T') && strcasecmp(name, "telbook") == 0) {
1100 if ((*name == 'k' || *name == 'K') && strcasecmp(name, "kana") == 0) {
1104 if ((*name == 'e' || *name == 'E') && strcasecmp(name, "email") == 0) {
1108 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ista") == 0) {
1112 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ilet") == 0) {
1116 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "iswf") == 0) {
1120 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "irst") == 0) {
1124 s_output_to_hdml_out(hdml, ">" );
1126 hdml->hdml_a_flag = 1;
1128 hdml->hdml_br_flag = 0;
1135 * It is a handler who processes the A tag.
1137 * @param pdoc [i/o] The pointer to the HDML structure at the output
1138 * destination is specified.
1139 * @param node [i] The A tag node is specified.
1140 * @return The conversion result is returned.
1143 s_hdml_end_a_tag(void* pdoc, Node* UNUSED(child))
1147 hdml = GET_HDML(pdoc);
1149 s_output_to_hdml_out(hdml, "</A>\r\n");
1151 hdml->hdml_a_flag = 0;
1158 * It is a handler who processes the BR tag.
1160 * @param pdoc [i/o] The pointer to the HDML structure at the output
1161 * destination is specified.
1162 * @param node [i] The BR tag node is specified.
1163 * @return The conversion result is returned.
1166 s_hdml_start_br_tag(void* pdoc, Node* UNUSED(node))
1170 hdml = GET_HDML(pdoc);
1172 if (hdml->in_center > 0)
1173 hdml->in_center = 0;
1175 if (hdml->div_in_center > 0)
1176 hdml->div_in_center = 0;
1178 s_output_to_hdml_out(hdml, "<BR>\r\n");
1180 hdml->hdml_br_flag = 1;
1187 * It is a handler who processes the BR tag.
1189 * @param pdoc [i/o] The pointer to the HDML structure at the output
1190 * destination is specified.
1191 * @param node [i] The BR tag node is specified.
1192 * @return The conversion result is returned.
1195 s_hdml_end_br_tag(void* pdoc, Node* UNUSED(child))
1199 hdml = GET_HDML(pdoc);
1206 * It is a handler who processes the TR tag.
1208 * @param pdoc [i/o] The pointer to the HDML structure at the output
1209 * destination is specified.
1210 * @param node [i] The TR tag node is specified.
1211 * @return The conversion result is returned.
1214 s_hdml_start_tr_tag(void* pdoc, Node* UNUSED(node))
1218 hdml = GET_HDML(pdoc);
1220 if (hdml->in_center > 0)
1221 hdml->in_center = 0;
1223 if (hdml->div_in_center > 0)
1224 hdml->div_in_center = 0;
1226 s_output_to_hdml_out(hdml, "<BR>\r\n");
1228 hdml->hdml_br_flag = 1;
1235 * It is a handler who processes the TR tag.
1237 * @param pdoc [i/o] The pointer to the HDML structure at the output
1238 * destination is specified.
1239 * @param node [i] The TR tag node is specified.
1240 * @return The conversion result is returned.
1243 s_hdml_end_tr_tag(void* pdoc, Node* UNUSED(child))
1247 hdml = GET_HDML(pdoc);
1254 * It is a handler who processes the FONT tag.
1256 * @param pdoc [i/o] The pointer to the HDML structure at the output
1257 * destination is specified.
1258 * @param node [i] The FONT tag node is specified.
1259 * @return The conversion result is returned.
1262 s_hdml_start_font_tag(void* pdoc, Node* UNUSED(node))
1266 hdml = GET_HDML(pdoc);
1273 * It is a handler who processes the FONT tag.
1275 * @param pdoc [i/o] The pointer to the HDML structure at the output
1276 * destination is specified.
1277 * @param node [i] The FONT tag node is specified.
1278 * @return The conversion result is returned.
1281 s_hdml_end_font_tag(void* pdoc, Node* UNUSED(child))
1285 hdml = GET_HDML(pdoc);
1292 * It is a handler who processes the FORM tag.
1294 * @param pdoc [i/o] The pointer to the HDML structure at the output
1295 * destination is specified.
1296 * @param node [i] The FORM tag node is specified.
1297 * @return The conversion result is returned.
1300 s_hdml_start_form_tag(void* pdoc, Node* node)
1308 hdml = GET_HDML(pdoc);
1313 hdml->form_tmp = apr_psprintf(r->pool,
1314 "<NODISPLAY NAME=F%d>\r\n",
1315 hdml->pure_form_cnt);
1316 hdml->form_tmp = apr_pstrcat(r->pool,
1318 "<ACTION TYPE=ACCEPT TASK=GO METHOD=POST DEST=\"",
1320 /* Get Attributes */
1321 for (attr = qs_get_attr(doc,node);
1323 attr = qs_get_next_attr(doc,attr)) {
1328 name = qs_get_attr_name(doc,attr);
1329 value = qs_get_attr_value(doc,attr);
1331 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "action") == 0) {
1332 value = chxj_encoding_parameter(hdml->doc->r, value);
1333 act = apr_psprintf(r->pool, "%s", value);
1339 hdml->form_tmp = apr_pstrcat(r->pool,
1344 hdml->form_tmp = apr_pstrcat(r->pool,
1348 hdml->form_tmp = apr_pstrcat(r->pool,
1353 hdml->hdml_br_flag = 0;
1360 * handler of the form end tag.
1362 * @param pdoc [i/o] The pointer to the HDML structure at the output
1363 * destination is specified.
1364 * @param child [i] unused.
1365 * @return The HDML output result after it edits it is returned.
1368 s_hdml_end_form_tag(void* pdoc, Node* UNUSED(child))
1373 hdml = GET_HDML(pdoc);
1376 s_output_to_postdata(hdml, "_chxj_dmy=");
1378 hdml->form_tmp = apr_pstrcat(r->pool,
1380 hdml->postdata[hdml->pure_form_cnt],
1383 hdml->form_tmp = apr_pstrcat(r->pool,
1385 "\" CLEAR=TRUE >\r\n",
1387 hdml->form_tmp = apr_pstrcat(r->pool,
1392 s_output_to_hdml_card(hdml, hdml->form_tmp);
1394 hdml->form_tmp = NULL;
1395 hdml->pure_form_cnt++;
1402 * It is a handler that takes charge of the processing of the input tag.
1404 * @param pdoc [i/o] The pointer to the HDML structure at the output
1405 * destination is specified.
1406 * @param node [i] The tag node to be processed is specified.
1409 s_hdml_start_input_tag(void* pdoc, Node* node)
1415 hdml = GET_HDML(pdoc);
1418 /*--------------------------------------------------------------------------*/
1419 /* The attribute of the input tag is acquired. */
1420 /*--------------------------------------------------------------------------*/
1421 for (attr = qs_get_attr(doc,node);
1423 attr = qs_get_next_attr(doc,attr)) {
1428 name = qs_get_attr_name(doc,attr);
1429 value = qs_get_attr_value(doc,attr);
1431 if (STRCASEEQ('t','T',"type",name)) {
1432 if (STRCASEEQ('t','T',"text",value)) {
1433 /*--------------------------------------------------------------------*/
1434 /* "input type ='text'" tag is processed. */
1435 /*--------------------------------------------------------------------*/
1436 s_hdml_do_input_text_tag(hdml, node);
1438 else if (STRCASEEQ('p','P',"password",value)) {
1439 /*--------------------------------------------------------------------*/
1440 /* "input type='password'" tag is processed. */
1441 /*--------------------------------------------------------------------*/
1442 s_hdml_do_input_password_tag(hdml, node);
1444 else if (STRCASEEQ('s','S',"submit",value)) {
1445 /*--------------------------------------------------------------------*/
1446 /* "input type='submit'" tag is processed. */
1447 /*--------------------------------------------------------------------*/
1448 s_hdml_do_input_submit_tag(hdml, node);
1450 else if (STRCASEEQ('h','H',"hidden",value)) {
1451 /*--------------------------------------------------------------------*/
1452 /* "input type='hidden'" tag is processed. */
1453 /*--------------------------------------------------------------------*/
1454 s_hdml_do_input_hidden_tag(hdml, node);
1456 else if (STRCASEEQ('r','R',"radio",value)) {
1457 /*--------------------------------------------------------------------*/
1458 /* "input type='radio'" tag is processed. */
1459 /*--------------------------------------------------------------------*/
1460 s_hdml_do_input_radio_tag(hdml, node);
1462 else if (STRCASEEQ('c','C',"checkbox",value)) {
1463 /*--------------------------------------------------------------------*/
1464 /* "input type='checkbox'" tag is processed. */
1465 /*--------------------------------------------------------------------*/
1466 s_hdml_do_input_checkbox_tag(hdml, node);
1468 else if (STRCASEEQ('r','R',"reset",value)) {
1469 /*--------------------------------------------------------------------*/
1470 /* "input type='reset'" tag is processed. */
1471 /*--------------------------------------------------------------------*/
1472 s_hdml_do_input_reset_tag(hdml, node);
1475 else if (STRCASEEQ('n','N',"name",name)) {
1478 else if (STRCASEEQ('v','V',"value",name)) {
1481 else if (STRCASEEQ('s','S',"size",name)) {
1484 else if (STRCASEEQ('m','M',"maxlength",name)) {
1487 else if (STRCASEEQ('c','C',"checked",name)) {
1490 else if (STRCASEEQ('a','A',"accesskey",name)) {
1493 else if (STRCASEEQ('i','I',"istyle",name)) {
1498 hdml->hdml_br_flag = 0;
1505 * The substitution processing of tag "input type = text" is done.
1507 * @param hdml [i/o] The pointer to the HDML structure at the output
1508 * destination is specified.
1509 * @param tag [i] The tag node of input type=text is specified.
1512 s_hdml_do_input_text_tag(hdml_t *hdml, Node *tag)
1526 s_hdml_tag_output_upper_half(hdml, tag);
1529 s_output_to_hdml_out(hdml,
1530 apr_psprintf(r->pool,
1531 "<A TASK=GOSUB LABEL=\x93\xfc\x97\xcd DEST=#D%d "
1532 "VARS=\"V=$%s%02d\" RECEIVE=%s%02d>",
1534 s_get_form_no(r, hdml),
1535 hdml->var_cnt[hdml->pure_form_cnt],
1536 s_get_form_no(r, hdml),
1537 hdml->var_cnt[hdml->pure_form_cnt]
1540 s_output_to_hdml_out(hdml,
1541 apr_psprintf(r->pool,
1542 "[$%s%02d]</A>\r\n" ,
1543 s_get_form_no(r, hdml),
1544 hdml->var_cnt[hdml->pure_form_cnt]));
1546 /*--------------------------------------------------------------------------*/
1547 /* ENTRY CARD is output here. */
1548 /*--------------------------------------------------------------------------*/
1549 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1550 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1551 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1557 nm = qs_get_name_attr(doc, tag, r);
1559 nm = qs_alloc_zero_byte_string(r);
1562 s_output_to_postdata(hdml,
1563 apr_psprintf(r->pool,
1566 s_get_form_no(r, hdml),
1567 hdml->var_cnt[hdml->pure_form_cnt]));
1569 mlen = qs_get_maxlength_attr (doc, tag, r);
1570 is = qs_get_istyle_attr (doc, tag, r);
1571 val = qs_get_value_attr (doc, tag, r);
1573 fmt = qs_conv_istyle_to_format(r, is);
1574 DBG(r,"qs_conv_istyle_to_format end");
1578 for (ii=0; ii<strlen(mlen); ii++) {
1579 if (mlen[ii] < '0' || mlen[ii] > '9') {
1580 mlen = apr_psprintf(r->pool, "0");
1584 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=%d%s", atoi(mlen), fmt));
1587 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1590 s_output_to_hdml_card(hdml,
1591 " MARKABLE=FALSE>\r\n"
1592 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
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],
1601 chxj_escape_uri(r->pool,val)));
1603 s_output_to_init_vars(hdml,
1604 apr_psprintf(r->pool,
1606 s_get_form_no(r, hdml),
1607 hdml->var_cnt[hdml->pure_form_cnt]));
1609 hdml->var_cnt[hdml->pure_form_cnt]++;
1614 * The substitution processing of tag "input type = password" is done.
1616 * @param hdml [i/o] The pointer to the HDML structure at the output
1617 * destination is specified.
1618 * @param tag [i] The tag node of input type=password is specified.
1621 s_hdml_do_input_password_tag(hdml_t* hdml, Node* tag)
1634 s_hdml_tag_output_upper_half(hdml, tag);
1637 s_output_to_hdml_out(hdml, "<A TASK=GOSUB LABEL=\"\x93\xfc\x97\xcd\" DEST=");
1638 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "#D%d ", hdml->card_cnt));
1639 s_output_to_hdml_out(hdml,
1640 apr_psprintf(r->pool,
1641 "VARS=\"V=$%s%02d\" ",
1642 s_get_form_no(r, hdml),
1643 hdml->var_cnt[hdml->pure_form_cnt]));
1645 s_output_to_hdml_out(hdml,
1646 apr_psprintf(r->pool, "RECEIVE=%s%02d>" ,
1647 s_get_form_no(r, hdml),
1648 hdml->var_cnt[hdml->pure_form_cnt]));
1649 s_output_to_hdml_out(hdml,
1650 apr_psprintf(r->pool, "[$%s%02d]</A>\r\n" ,
1651 s_get_form_no(r, hdml),
1652 hdml->var_cnt[hdml->pure_form_cnt]));
1654 s_output_to_hdml_card(hdml, "<ENTRY NAME=" );
1655 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "D%d ", hdml->card_cnt));
1656 s_output_to_hdml_card(hdml, " KEY=V DEFAULT=$V " );
1663 nm = qs_get_name_attr(doc, tag, r);
1665 nm = qs_alloc_zero_byte_string(r);
1667 s_output_to_postdata(hdml,
1668 apr_psprintf(r->pool,
1671 s_get_form_no(r, hdml),
1672 hdml->var_cnt[hdml->pure_form_cnt]));
1674 mlen = qs_get_maxlength_attr (doc, tag, r);
1675 val = qs_get_value_attr (doc, tag, r);
1676 /*--------------------------------------------------------------------------*/
1677 /* Default is a figure input. */
1678 /*--------------------------------------------------------------------------*/
1679 fmt = apr_psprintf(r->pool, "N");
1681 if (chxj_chk_numeric(mlen) != 0)
1682 mlen = apr_psprintf(r->pool, "0");
1683 s_output_to_hdml_card(hdml,
1684 apr_psprintf(r->pool, " FORMAT=%d%s", chxj_atoi(mlen), fmt));
1687 s_output_to_hdml_card(hdml,
1688 apr_psprintf(r->pool, " FORMAT=*%s", fmt) );
1690 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, " NOECHO=TRUE "));
1692 s_output_to_hdml_card(hdml,
1693 " MARKABLE=FALSE>\r\n"
1694 "<ACTION TYPE=ACCEPT TASK=RETURN RETVALS=$V>\r\n"
1698 s_output_to_init_vars(hdml,
1699 apr_psprintf(r->pool, "%s%02d=%s",
1700 s_get_form_no(r, hdml),
1701 hdml->var_cnt[hdml->pure_form_cnt],
1702 chxj_escape_uri(r->pool,val)));
1704 s_output_to_init_vars(hdml,
1705 apr_psprintf(r->pool, "%s%02d=",
1706 s_get_form_no(r, hdml),
1707 hdml->var_cnt[hdml->pure_form_cnt]));
1709 hdml->var_cnt[hdml->pure_form_cnt]++;
1713 * The substitution processing of tag "input type = submit" is done.
1715 * @param hdml [i/o] The pointer to the HDML structure at the output
1716 * destination is specified.
1717 * @param tag [i] The tag node of input type=submit is specified.
1720 s_hdml_do_input_submit_tag(hdml_t* hdml, Node* tag)
1722 Doc* doc = hdml->doc;
1723 request_rec* r = doc->r;
1727 s_hdml_tag_output_upper_half(hdml, tag);
1729 s_output_to_hdml_out(hdml,
1730 apr_psprintf(r->pool,
1731 "<A TASK=GO LABEL=OK DEST=#F%d ",
1732 hdml->pure_form_cnt));
1734 /*--------------------------------------------------------------------------*/
1735 /* get name and value attribute */
1736 /*--------------------------------------------------------------------------*/
1737 nm = qs_get_name_attr (doc, tag, r);
1738 val = qs_get_value_attr (doc, tag, r);
1741 s_output_to_hdml_out(hdml,
1742 apr_psprintf(r->pool, "VARS=\"%s=%s\" ",
1744 chxj_escape_uri(r->pool,val)));
1745 if (strstr(hdml->postdata[hdml->pure_form_cnt], nm) == NULL) {
1746 s_output_to_postdata(hdml,
1747 apr_psprintf(r->pool,"%s%s=$%s",
1748 SUBMIT_BUTTON_PREFIX, nm, nm));
1751 s_output_to_hdml_out(hdml, ">" );
1753 s_output_to_hdml_out(hdml, val);
1755 s_output_to_hdml_out(hdml, "</A>\r\n" );
1760 * The substitution processing of tag "input type = reset" is done.
1762 * @param hdml [i/o] The pointer to the HDML structure at the output
1763 * destination is specified.
1764 * @param tag [i] The tag node of input type=submit is specified.
1767 s_hdml_do_input_reset_tag(hdml_t *hdml, Node *tag)
1769 Doc *doc = hdml->doc;
1770 request_rec *r = doc->r;
1774 s_hdml_tag_output_upper_half(hdml, tag);
1776 s_output_to_hdml_out(hdml,
1777 apr_psprintf(r->pool,
1778 "<A TASK=GO LABEL=OK DEST=#D0>"));
1780 /*--------------------------------------------------------------------------*/
1781 /* get name and value attribute */
1782 /*--------------------------------------------------------------------------*/
1783 nm = qs_get_name_attr (doc, tag, r);
1784 val = qs_get_value_attr (doc, tag, r);
1786 s_output_to_hdml_out(hdml, val);
1788 s_output_to_hdml_out(hdml, "</A>\r\n" );
1793 * The substitution processing of tag "input type = hidden" is done.
1795 * @param hdml [i/o] The pointer to the HDML structure at the output
1796 * destination is specified.
1797 * @param tag [i] The tag node of input type=hidden is specified.
1800 s_hdml_do_input_hidden_tag(hdml_t* hdml, Node* tag)
1802 Doc* doc = hdml->doc;
1803 request_rec* r = doc->r;
1807 /*--------------------------------------------------------------------------*/
1808 /* get name and value attribute */
1809 /*--------------------------------------------------------------------------*/
1810 nm = qs_get_name_attr (doc, tag, r);
1811 val = qs_get_value_attr (doc, tag, r);
1814 s_output_to_postdata(hdml,
1815 apr_psprintf(r->pool,
1818 chxj_escape_uri(r->pool, val)));
1823 * The substitution processing of tag "input type = radio" is done.
1825 * @param hdml [i/o] The pointer to the HDML structure at the output
1826 * destination is specified.
1827 * @param tag [i] The tag node of input type=radio is specified.
1830 s_hdml_do_input_radio_tag(hdml_t* hdml, Node* tag)
1832 Doc* doc = hdml->doc;
1833 request_rec* r = doc->r;
1841 s_hdml_tag_output_upper_half(hdml, tag);
1843 /*--------------------------------------------------------------------------*/
1844 /* get name and value attribute */
1845 /*--------------------------------------------------------------------------*/
1846 nm = qs_get_name_attr (doc, tag, r);
1847 val = qs_get_value_attr (doc, tag, r);
1849 /*--------------------------------------------------------------------------*/
1850 /* The same name is searched out from the list made beforehand. */
1851 /*--------------------------------------------------------------------------*/
1852 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
1853 if (! hdml->radio_name_list[ii]) {
1855 DBG(r, "Oops... radio list is null[%d]", ii);
1856 /*----------------------------------------------------------------------*/
1857 /* Processing is ended because it doesn't happen off the fly. */
1858 /*----------------------------------------------------------------------*/
1862 if (strcasecmp(hdml->radio_name_list[ii], nm) == 0)
1865 if (ii == MAX_RADIO_COUNT) {
1867 DBG(r,"Oops... The same name was not in the list. ");
1868 /*------------------------------------------------------------------------*/
1869 /* Processing is ended because it doesn't happen off the fly. */
1870 /*------------------------------------------------------------------------*/
1874 s_output_to_hdml_out(hdml,
1875 apr_psprintf(r->pool,
1877 "LABEL=\"\x93\xfc\x97\xcd\" "
1878 "DEST=#R%d VARS=\"VAL=%s\" "
1884 if (hdml->radio_out_cnt[ii] == 0) {
1885 s_output_to_hdml_card(hdml,
1886 apr_psprintf(r->pool,
1887 "<NODISPLAY NAME=R%d>\r\n",
1889 s_output_to_hdml_card(hdml,
1890 apr_psprintf(r->pool,
1892 "TYPE=ACCEPT TASK=RETURN RETVALS=\"$VAL;"));
1895 kk = hdml->radio_out_cnt[ii];
1896 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++)
1897 if (! hdml->radio_value_list[ii][jj])
1902 for (jj=0; jj<r_cnt; jj++) {
1903 if (! hdml->radio_value_list[ii][jj])
1907 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, ";"));
1908 if (hdml->radio_out_cnt[ii] == 0)
1909 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, ";"));
1912 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "%s_%02d", nm, kk));
1913 if (hdml->radio_out_cnt[ii] == 0) {
1915 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "X"));
1917 s_output_to_hdml_card(hdml, apr_psprintf(r->pool, "_"));
1924 s_output_to_hdml_out(hdml,
1925 apr_psprintf(r->pool, "\" >$%s_%02d</A>",
1927 hdml->radio_out_cnt[ii]));
1928 if (! hdml->radio_out_cnt[ii]) {
1929 s_output_to_hdml_card(hdml, "\">\r\n" );
1930 s_output_to_hdml_card(hdml, "</NODISPLAY>\r\n");
1932 s_output_to_postdata(hdml, apr_psprintf(r->pool, "%s%s=$%s", RADIO_BUTTON_PREFIX, nm, nm));
1934 for (jj=0; jj<r_cnt; jj++) {
1935 if (hdml->radio_value_list[ii][jj] && hdml->radio_checked_value[ii]) {
1936 if (strcasecmp(hdml->radio_value_list[ii][jj],
1937 hdml->radio_checked_value[ii]) == 0) {
1938 s_output_to_init_vars(hdml,
1939 apr_psprintf(r->pool,
1945 s_output_to_init_vars(hdml,
1946 apr_psprintf(r->pool,
1953 s_output_to_init_vars(hdml,
1954 apr_psprintf(r->pool,
1961 if (hdml->radio_checked_value[ii]) {
1962 DBG(r,"radio button is checked. checked value is [%s]",
1963 hdml->radio_checked_value[ii]);
1964 s_output_to_init_vars(hdml,
1965 apr_psprintf(r->pool,
1968 hdml->radio_checked_value[ii]));
1971 DBG(r,"radio button is not checked. checked value is []");
1972 s_output_to_init_vars(hdml,
1973 apr_psprintf(r->pool,
1978 hdml->radio_out_cnt[ii]++;
1982 * The substitution processing of tag "input type = checkbox" is done.
1984 * @param hdml [i/o] The pointer to the HDML structure at the output
1985 * destination is specified.
1986 * @param tag [i] The tag node of input type=checkbox is specified.
1989 s_hdml_do_input_checkbox_tag(hdml_t* hdml, Node* tag)
1991 Doc* doc = hdml->doc;
1992 request_rec* r = doc->r;
1997 /*--------------------------------------------------------------------------*/
1998 /* It is posted to the one without the checked attribute. */
1999 /* However, they were able to be removed with INPUT FILTER. */
2000 /*--------------------------------------------------------------------------*/
2001 if (! hdml->has_checkbox) {
2002 hdml->has_checkbox++;
2003 s_output_to_hdml_card(hdml,
2004 "<NODISPLAY NAME=\"_chk\">\r\n"
2005 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
2006 "RETVALS=\"_uchk;$V;X\" >\r\n"
2008 "<NODISPLAY NAME=\"_uchk\">\r\n"
2009 "<ACTION TYPE=\"ACCEPT\" TASK=\"RETURN\" "
2010 "RETVALS=\"_chk;;_\" >\r\n"
2013 DBG(r, "wrote checkbox hdml card.");
2016 /*--------------------------------------------------------------------------*/
2017 /* It is examined whether it is CHECKED. */
2018 /*--------------------------------------------------------------------------*/
2019 chk = qs_is_checked_checkbox_attr(doc, tag, r);
2021 /*--------------------------------------------------------------------------*/
2022 /* The value of the name attribute and the value attribute is acquired */
2024 /*--------------------------------------------------------------------------*/
2025 val = qs_get_value_attr(doc, tag, r);
2026 nm = qs_get_name_attr(doc, tag, r);
2029 val = qs_alloc_zero_byte_string(r);
2032 nm = qs_alloc_zero_byte_string(r);
2034 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2035 "<A TASK=GOSUB LABEL=\"a\xaf\xb8\" "
2036 "DEST=\"#$%s%02d\" "
2038 "RECEIVE=\"%s%02d;%s%02d;%s%02d\">"
2040 s_get_form_no(r, hdml),
2041 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2043 s_get_form_no(r, hdml),
2044 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2045 s_get_form_no(r, hdml),
2046 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2047 s_get_form_no(r, hdml),
2048 hdml->var_cnt[hdml->pure_form_cnt] + 2,
2049 s_get_form_no(r, hdml),
2050 hdml->var_cnt[hdml->pure_form_cnt] + 2));
2052 s_output_to_init_vars(hdml,
2053 apr_psprintf(r->pool,
2054 "%s%02d=_uchk&%s%02d=%s&%s%02d=X",
2055 s_get_form_no(r, hdml),
2056 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2057 s_get_form_no(r, hdml),
2058 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2059 chxj_escape_uri(r->pool,val),
2060 s_get_form_no(r, hdml),
2061 hdml->var_cnt[hdml->pure_form_cnt] + 2
2065 s_output_to_init_vars(hdml,
2066 apr_psprintf(r->pool,
2067 "%s%02d=_chk&%s%02d=&%s%02d=_",
2068 s_get_form_no(r, hdml),
2069 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2070 s_get_form_no(r, hdml),
2071 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2072 s_get_form_no(r, hdml),
2073 hdml->var_cnt[hdml->pure_form_cnt] + 2
2077 s_output_to_postdata(hdml,
2078 apr_psprintf(r->pool, "%s%s=$%s%02d",
2081 s_get_form_no(r, hdml),
2082 hdml->var_cnt[hdml->pure_form_cnt] + 1));
2084 hdml->var_cnt[hdml->pure_form_cnt] += 3;
2088 * The ISTYLE attribute is converted into the HDML form.
2090 * @param r [i] To use POOL, the pointer to request_rec is specified.
2091 * @param is [i] The value of the ISTYLE attribute is specified.
2092 * @return The ISTYLE attribute converted into the HDML form is returned.
2095 qs_conv_istyle_to_format(request_rec* r, char* is)
2104 fmt = apr_psprintf(r->pool, "M");
2107 fmt = apr_psprintf(r->pool, "M");
2110 fmt = apr_psprintf(r->pool, "m");
2113 fmt = apr_psprintf(r->pool, "N");
2124 * It is a handler who processes the INPUT tag.
2126 * @param pdoc [i/o] The pointer to the HDML structure at the output
2127 * destination is specified.
2128 * @param node [i] The INPUT tag node is specified.
2129 * @return The conversion result is returned.
2132 s_hdml_end_input_tag(void* pdoc, Node* UNUSED(child))
2136 hdml = GET_HDML(pdoc);
2143 * It is a handler who processes the CENTER tag.
2145 * @param pdoc [i/o] The pointer to the HDML structure at the output
2146 * destination is specified.
2147 * @param node [i] The CENTER tag node is specified.
2148 * @return The conversion result is returned.
2151 s_hdml_start_center_tag(void* pdoc, Node* UNUSED(node))
2155 hdml = GET_HDML(pdoc);
2160 if (hdml->hdml_br_flag == 0)
2161 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2163 hdml = s_output_to_hdml_out(hdml, "<CENTER>");
2170 * It is a handler who processes the CENTER tag.
2172 * @param pdoc [i/o] The pointer to the HDML structure at the output
2173 * destination is specified.
2174 * @param node [i] The CENTER tag node is specified.
2175 * @return The conversion result is returned.
2178 s_hdml_end_center_tag(void* pdoc, Node* UNUSED(child))
2182 hdml = GET_HDML(pdoc);
2185 hdml->in_center = 0;
2187 hdml = s_output_to_hdml_out(hdml, "<BR>\r\n");
2188 hdml->hdml_br_flag = 1;
2195 * It is a handler who processes the HR tag.
2197 * @param pdoc [i/o] The pointer to the HDML structure at the output
2198 * destination is specified.
2199 * @param node [i] The HR tag node is specified.
2200 * @return The conversion result is returned.
2203 s_hdml_start_hr_tag(void* pdoc, Node* UNUSED(node))
2207 hdml = GET_HDML(pdoc);
2209 if (hdml->hdml_br_flag == 0) {
2210 s_output_to_hdml_out(hdml, "<BR>\r\n");
2211 if (hdml->in_center)
2214 if (hdml->div_in_center)
2215 hdml->div_in_center--;
2218 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");
2220 hdml->hdml_br_flag = 1;
2227 * It is a handler who processes the HR tag.
2229 * @param pdoc [i/o] The pointer to the HDML structure at the output
2230 * destination is specified.
2231 * @param node [i] The HR tag node is specified.
2232 * @return The conversion result is returned.
2235 s_hdml_end_hr_tag(void* pdoc, Node* UNUSED(child))
2239 hdml = GET_HDML(pdoc);
2246 * It is a handler who processes the LI tag.
2248 * @param pdoc [i/o] The pointer to the HDML structure at the output
2249 * destination is specified.
2250 * @param node [i] The LI tag node is specified.
2251 * @return The conversion result is returned.
2254 s_hdml_start_li_tag(void *pdoc, Node *UNUSED(node))
2256 hdml_t *hdml = GET_HDML(pdoc);
2259 if (hdml->hdml_br_flag == 0) {
2260 s_output_to_hdml_out(hdml, "<BR>\r\n");
2261 if (hdml->in_center)
2264 if (hdml->div_in_center)
2265 hdml->div_in_center--;
2267 s_output_to_hdml_out(hdml, "<WRAP>");
2268 for (i=0; i<hdml->dir_level; i++) {
2269 s_output_to_hdml_out(hdml, " ");
2271 hdml->hdml_br_flag = 1;
2277 * It is a handler who processes the LI tag.
2279 * @param pdoc [i/o] The pointer to the HDML structure at the output
2280 * destination is specified.
2281 * @param node [i] The LI tag node is specified.
2282 * @return The conversion result is returned.
2285 s_hdml_end_li_tag(void *pdoc, Node *UNUSED(child))
2287 hdml_t *hdml = GET_HDML(pdoc);
2288 if (hdml->hdml_br_flag == 0) {
2289 s_output_to_hdml_out(hdml, "<BR>\r\n");
2290 if (hdml->in_center)
2293 if (hdml->div_in_center)
2294 hdml->div_in_center--;
2296 hdml->hdml_br_flag = 1;
2302 * It is a handler who processes the IMG tag.
2304 * @param pdoc [i/o] The pointer to the HDML structure at the output
2305 * destination is specified.
2306 * @param node [i] The IMG tag node is specified.
2307 * @return The conversion result is returned.
2310 s_hdml_start_img_tag(void *pdoc, Node *node)
2314 #ifndef IMG_NOT_CONVERT_FILENAME
2319 hdml = GET_HDML(pdoc);
2321 #ifndef IMG_NOT_CONVERT_FILENAME
2325 s_hdml_tag_output_upper_half(hdml, node);
2327 s_output_to_hdml_out(hdml, "<img");
2329 /* Get Attributes */
2330 for (attr = qs_get_attr(doc,node);
2332 attr = qs_get_next_attr(doc,attr)) {
2334 char *name = qs_get_attr_name(doc,attr);
2335 char *value = qs_get_attr_value(doc,attr);
2336 if (STRCASEEQ('s','S',"src",name) && value && *value) {
2337 value = chxj_encoding_parameter(hdml->doc->r, value);
2338 s_output_to_hdml_out(hdml, " src=\"");
2339 #ifdef IMG_NOT_CONVERT_FILENAME
2340 s_output_to_hdml_out(hdml, value );
2342 s_output_to_hdml_out(hdml, chxj_img_conv(doc->r, spec,value));
2344 s_output_to_hdml_out(hdml, "\"" );
2346 else if (STRCASEEQ('a','A',"align",name)) {
2347 if (value && (STRCASEEQ('t','T',"top", value) ||
2348 STRCASEEQ('m','M',"middle",value) ||
2349 STRCASEEQ('b','B',"bottom",value) ||
2350 STRCASEEQ('l','L',"left", value) ||
2351 STRCASEEQ('r','R',"right", value))) {
2352 s_output_to_hdml_out(hdml, " align=\"" );
2353 s_output_to_hdml_out(hdml, value );
2354 s_output_to_hdml_out(hdml, "\"" );
2357 else if (STRCASEEQ('w','W',"width",name) && value && *value) {
2358 s_output_to_hdml_out(hdml, " width=\"");
2359 s_output_to_hdml_out(hdml, value );
2360 s_output_to_hdml_out(hdml, "\"" );
2362 else if (STRCASEEQ('h','H',"height",name) && value && *value) {
2363 s_output_to_hdml_out(hdml, " height=\"");
2364 s_output_to_hdml_out(hdml, value );
2365 s_output_to_hdml_out(hdml, "\"" );
2367 else if (STRCASEEQ('h','H',"hspace", name) && value && *value) {
2368 s_output_to_hdml_out(hdml, " hspace=\"");
2369 s_output_to_hdml_out(hdml, value );
2370 s_output_to_hdml_out(hdml, "\"" );
2372 else if (STRCASEEQ('v','V',"vspace",name) && value && *value) {
2373 s_output_to_hdml_out(hdml, " vspace=\"");
2374 s_output_to_hdml_out(hdml, value );
2375 s_output_to_hdml_out(hdml, "\"" );
2377 else if (STRCASEEQ('a','A',"alt",name) && value && *value) {
2378 s_output_to_hdml_out(hdml, " alt=\"" );
2379 s_output_to_hdml_out(hdml, value );
2380 s_output_to_hdml_out(hdml, "\"" );
2383 s_output_to_hdml_out(hdml, ">" );
2385 hdml->hdml_br_flag = 0;
2392 * It is a handler who processes the IMG tag.
2394 * @param pdoc [i/o] The pointer to the HDML structure at the output
2395 * destination is specified.
2396 * @param node [i] The IMG tag node is specified.
2397 * @return The conversion result is returned.
2400 s_hdml_end_img_tag(void *pdoc, Node *UNUSED(child))
2402 hdml_t *hdml = GET_HDML(pdoc);
2408 * It is a handler who processes the SELECT tag.
2410 * @param pdoc [i/o] The pointer to the HDML structure at the output
2411 * destination is specified.
2412 * @param node [i] The SELECT tag node is specified.
2413 * @return The conversion result is returned.
2416 s_hdml_start_select_tag(void* pdoc, Node* node)
2423 hdml = GET_HDML(pdoc);
2427 s_hdml_tag_output_upper_half(hdml, node);
2431 s_output_to_hdml_out(hdml, apr_psprintf(r->pool,
2432 "<A TASK=GOSUB LABEL=\x91\x49\x91\xf0 "
2433 "VARS=\"V=$%s%02d\" DEST=#D%d "
2434 "RECEIVE=\"%s%02d;%s%02d\">"
2436 s_get_form_no(r, hdml),
2437 hdml->var_cnt[hdml->pure_form_cnt]+0,
2439 s_get_form_no(r, hdml),
2440 hdml->var_cnt[hdml->pure_form_cnt]+0,
2441 s_get_form_no(r, hdml),
2442 hdml->var_cnt[hdml->pure_form_cnt]+1,
2443 s_get_form_no(r, hdml),
2444 hdml->var_cnt[hdml->pure_form_cnt]+1));
2446 s_output_to_hdml_card(hdml,
2447 apr_psprintf(r->pool,
2448 "<CHOICE KEY=V NAME=D%d ", hdml->card_cnt));
2449 s_output_to_hdml_card(hdml,
2450 apr_psprintf(r->pool,
2451 "DEFAULT=$V METHOD=ALPHA MARKABLE=FALSE>\r\n"));
2452 /*--------------------------------------------------------------------------*/
2453 /* Get Attributes */
2454 /*--------------------------------------------------------------------------*/
2455 for (attr = qs_get_attr(doc,node);
2457 attr=qs_get_next_attr(doc,attr)) {
2459 char* name = qs_get_attr_name(doc,attr);
2460 char* value = qs_get_attr_value(doc,attr);
2461 char* selval = NULL;
2462 char* selvaltxt = NULL;
2464 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
2466 s_output_to_postdata(hdml,
2467 apr_psprintf(r->pool, "%s=$%s%02d",
2469 s_get_form_no(r, hdml),
2470 hdml->var_cnt[hdml->pure_form_cnt]));
2471 selval = qs_get_selected_value(doc, node, r);
2473 DBG(r, "selected value not found");
2474 selval = qs_alloc_zero_byte_string(r);
2477 DBG(r, "selected value found[%s]" , selval);
2479 selvaltxt = qs_get_selected_value_text(doc, node, r);
2481 selvaltxt = qs_alloc_zero_byte_string(r);
2483 DBG(r, "selvaltxt:[%s]" ,selvaltxt);
2485 s_output_to_init_vars(hdml,
2486 apr_psprintf(r->pool,
2487 "%s%02d=%s&%s%02d=%s",
2488 s_get_form_no(r, hdml),
2489 hdml->var_cnt[hdml->pure_form_cnt] + 0,
2491 s_get_form_no(r, hdml),
2492 hdml->var_cnt[hdml->pure_form_cnt] + 1,
2495 hdml->var_cnt[hdml->pure_form_cnt] += 2;
2500 hdml->hdml_br_flag = 0;
2506 * It is a handler who processes the SELECT tag.
2508 * @param pdoc [i/o] The pointer to the HDML structure at the output
2509 * destination is specified.
2510 * @param node [i] The SELECT tag node is specified.
2511 * @return The conversion result is returned.
2514 s_hdml_end_select_tag(void* pdoc, Node* UNUSED(node))
2518 hdml = GET_HDML(pdoc);
2520 s_output_to_hdml_card(hdml, "</CHOICE>\r\n");
2527 * It is a handler who processes the OPTION tag.
2529 * @param pdoc [i/o] The pointer to the HDML structure at the output
2530 * destination is specified.
2531 * @param node [i] The OPTION tag node is specified.
2532 * @return The conversion result is returned.
2535 s_hdml_start_option_tag(void *pdoc, Node *node)
2544 hdml = GET_HDML(pdoc);
2550 hdml->option_flag = 1;
2551 val = qs_get_value_attr(doc, node, r);
2553 /*--------------------------------------------------------------------------*/
2554 /* The child node of the object tag node acquires the value in assumption */
2555 /* that is the TEXT node. */
2556 /*--------------------------------------------------------------------------*/
2557 child = qs_get_child_node(doc, node);
2559 txtval = apr_palloc(r->pool, 1);
2563 txtval = qs_get_node_value(doc, child);
2565 DBG(r, "txtval:[%s]" , txtval);
2567 if (val && txtval) {
2568 s_output_to_hdml_card(hdml,
2569 apr_psprintf(r->pool,
2570 "<CE TASK=RETURN VALUE=\"%s\" "
2571 "RETVALS=\"$V;%s\">%s</CE>\r\n",
2573 qs_trim_string(r->pool,txtval),
2574 qs_trim_string(r->pool,txtval)));
2577 hdml->hdml_br_flag = 0;
2584 * It is a handler who processes the OPTION tag.
2586 * @param pdoc [i/o] The pointer to the HDML structure at the output
2587 * destination is specified.
2588 * @param node [i] The OPTION tag node is specified.
2589 * @return The conversion result is returned.
2592 s_hdml_end_option_tag(void* pdoc, Node* UNUSED(node))
2596 hdml = GET_HDML(pdoc);
2598 hdml->option_flag = 0;
2605 * It is a handler who processes the DIV tag.
2607 * @param pdoc [i/o] The pointer to the HDML structure at the output
2608 * destination is specified.
2609 * @param node [i] The DIV tag node is specified.
2610 * @return The conversion result is returned.
2613 s_hdml_start_div_tag(void *pdoc, Node *node)
2619 hdml = GET_HDML(pdoc);
2622 /*--------------------------------------------------------------------------*/
2623 /* If the br tag is not output immediately before the div tag appears, the */
2624 /* br tag is output. */
2625 /*--------------------------------------------------------------------------*/
2626 if (hdml->hdml_br_flag == 0) {
2627 hdml->hdml_br_flag = 1;
2628 s_output_to_hdml_out(hdml, "<BR>\r\n");
2631 /*--------------------------------------------------------------------------*/
2632 /* The object tag node is scanned. */
2633 /*--------------------------------------------------------------------------*/
2634 for (attr = qs_get_attr(doc,node);
2636 attr = qs_get_next_attr(doc,attr)) {
2637 char *name = qs_get_attr_name(doc,attr);
2638 char *value = qs_get_attr_value(doc,attr);
2639 if (STRCASEEQ('a','A',"align",name)) {
2640 if (STRCASEEQ('r','R',"right",value)) {
2641 hdml->div_right_flag = 1;
2642 s_output_to_hdml_out(hdml, "<RIGHT>");
2643 hdml->hdml_br_flag = 0;
2646 else if (STRCASEEQ('c','C',"center",value)) {
2647 hdml->div_center_flag = 1;
2648 s_output_to_hdml_out(hdml, "<CENTER>");
2649 hdml->hdml_br_flag = 0;
2654 hdml->hdml_br_flag = 0;
2661 * It is a handler who processes the DIV tag.
2663 * @param pdoc [i/o] The pointer to the HDML structure at the output
2664 * destination is specified.
2665 * @param node [i] The DIV tag node is specified.
2666 * @return The conversion result is returned.
2669 s_hdml_end_div_tag(void *pdoc, Node *UNUSED(node))
2674 hdml = GET_HDML(pdoc);
2677 if (hdml->div_right_flag == 1) {
2678 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2679 hdml->div_right_flag = 0;
2681 if (hdml->div_center_flag == 1) {
2682 s_output_to_hdml_out(hdml, apr_psprintf(r->pool, "<BR>\r\n"));
2683 hdml->div_center_flag = 0;
2684 hdml->div_in_center = 0;
2692 * It is a wrapper of the apr_pstrcat function.
2694 * @param r [i] To use POOL, the pointer to request_rec is specified.
2695 * @param o [i] The character string of connected origin is specified.
2696 * @param s [i] The character string connected with 'o' parameter is
2698 * @param len [i/o] The pointer to the area where the character string
2699 * length is stored is specified.
2700 * @return The character string after it connects it is returned.
2703 qs_out_apr_pstrcat(request_rec *r, char *o, char *s, int *len)
2705 *len = (strlen(s) + *len);
2706 return apr_pstrcat(r->pool, o, s, NULL);
2710 * The prepositive character string used to generate the variable for HDML is
2713 * @param r [i] To use POOL, the pointer to request_rec is specified.
2714 * @param hdml [i] The pointer to the HDML structure that maintains the seed
2715 * to generate it is specified.
2716 * @return The character string after it generates it is returned.
2719 s_s_get_form_no(request_rec *r, hdml_t *hdml)
2725 fc = hdml->form_cnt;
2727 apr_time_exp_tz(&tm, hdml->form_cnt, 0);
2729 result = apr_psprintf(r->pool, "%c",(int)('A' + ((fc / 100) % 26)));
2730 result = apr_pstrcat(r->pool, result,
2731 apr_psprintf(r->pool, "%02d%02d%02d",
2739 * The number of tag nodes .."Input type =' radio '".. is counted.
2741 * @param hdml [i] The pointer to the HDML structure is specified.
2742 * @param node [i] The first parents node that counts the radio tag node is
2746 s_hdml_count_radio_tag(hdml_t* hdml, Node* node)
2755 /*--------------------------------------------------------------------------*/
2756 /* All the child nodes of the specified node are scanned. */
2757 /*--------------------------------------------------------------------------*/
2758 for (child = qs_get_child_node(doc,node);
2760 child = qs_get_next_node(doc,child)) {
2771 name = qs_get_node_name(doc,child);
2772 if (strcasecmp(name, "input") != 0) {
2773 s_hdml_count_radio_tag(hdml, child);
2777 DBG(r,"found input tag");
2779 type = qs_get_type_attr(doc, child, r);
2781 ERR(r, "Oops! The input tag without the type attribute has been found.Please give a type.");
2785 if (strcasecmp(type, "radio") != 0)
2788 DBG(r, "found type=radio");
2790 rname = qs_get_name_attr (doc, child, r);
2791 rvalue = qs_get_value_attr(doc, child, r);
2794 /*----------------------------------------------------------------------*/
2795 /* Oops!. The input tag without the name attribute has been found. */
2796 /*----------------------------------------------------------------------*/
2797 DBG(r, "Oops!. The input tag without the name attribute has been found. Please give a name.");
2801 DBG(r, "found name attribute");
2803 /*------------------------------------------------------------------------*/
2804 /* It scans in radio_name_list. When the same value exists, the */
2805 /* value is overwrited. */
2806 /* The value is written in a new area when not is. */
2807 /*------------------------------------------------------------------------*/
2808 for (ii=0; ii<MAX_RADIO_COUNT; ii++) {
2809 if (! hdml->radio_name_list[ii]) {
2810 DBG(r, "new name:[%s]", rname);
2813 if (strcasecmp(hdml->radio_name_list[ii], rname) == 0) {
2814 DBG(r, "already registered name:[%s]", rname);
2818 if (ii == MAX_RADIO_COUNT) {
2819 DBG(r, apr_psprintf(r->pool,
2820 "I do not understand the name of the radiobutton "
2821 "of %d piece or more. Please decrease "
2822 "the number of radiobuttons.",
2827 DBG(r,"add radio name:[%s]" ,rname);
2829 hdml->radio_name_list[ii] = apr_pstrdup(r->pool, rname);
2831 /*------------------------------------------------------------------------*/
2832 /* It adds it to radio_value_list. */
2833 /*------------------------------------------------------------------------*/
2834 for (jj=0; jj<MAX_RADIO_VALUE_COUNT; jj++) {
2835 if (!hdml->radio_value_list[ii][jj])
2838 if (jj == MAX_RADIO_VALUE_COUNT) {
2839 DBG(r, apr_psprintf(r->pool,
2840 "I do not understand the value of the radiobutton "
2841 "of %d piece or more. Please decrease "
2842 "the number of radiobuttons.",
2843 MAX_RADIO_VALUE_COUNT));
2846 hdml->radio_value_list[ii][jj] = apr_pstrdup(r->pool, rvalue);
2848 /*------------------------------------------------------------------------*/
2849 /* Now let's be the checked attribute or scan. */
2850 /*------------------------------------------------------------------------*/
2851 chkd = qs_get_checked_attr(hdml->doc, child, hdml->doc->r);
2853 DBG(r,apr_psprintf(r->pool,
2854 "The tag scanned now had the checked "
2855 "attribute. The value is [%s].",
2857 hdml->radio_checked_value[ii] = apr_pstrdup(r->pool, rvalue);
2864 * The character string is added, and output to the out member of the HDML
2867 * @param hdml [i/o] The pointer to the HDML structure that maintains the out
2868 * member at the output destination is specified.
2869 * @param s [i] The character string that should be output is specified.
2870 * @return The pointer to the HDML structure after it processes it is returned.
2873 s_output_to_hdml_out(hdml_t *hdml, char *s)
2875 hdml->out = qs_out_apr_pstrcat(hdml->doc->r, hdml->out, s, &hdml->out_len);
2882 * The character string is added, and output to the card member of the HDML
2885 * @param hdml [i/o] The pointer to the HDML structure that maintains the
2886 * card member at the output destination is specified.
2887 * @param s [i] The character string that should be output is specified.
2888 * @return The pointer to the HDML structure after it processes it is returned.
2891 s_output_to_hdml_card(hdml_t* hdml, char* s)
2893 hdml->card = qs_out_apr_pstrcat(hdml->doc->r, hdml->card, s, &hdml->card_len);
2901 * The data for the post is added, and output.
2903 * @param hdml [i/o] The pointer to the HDML structure at the output
2904 * destination is specified.
2905 * @param s [i] The character string that wants to output to postdata is
2909 s_output_to_postdata(hdml_t* hdml, char* s)
2915 if (strlen(hdml->postdata[hdml->pure_form_cnt]))
2916 hdml->postdata[hdml->pure_form_cnt] =
2917 apr_pstrcat(r->pool,
2918 hdml->postdata[hdml->pure_form_cnt],
2922 hdml->postdata[hdml->pure_form_cnt] =
2923 apr_pstrcat(r->pool,
2924 hdml->postdata[hdml->pure_form_cnt],
2925 qs_trim_string(r->pool, s),
2928 DBG(r, "POSTDATA:[%s]", hdml->postdata[hdml->pure_form_cnt] );
2934 * The tag output upper half.
2936 * @param hdml [i/o] The pointer to the HDML structure at the output
2937 * destination is specified.
2938 * @param node [i] The A tag node is specified.
2941 s_hdml_tag_output_upper_half(hdml_t* hdml, Node* UNUSED(node))
2943 if (hdml->hdml_br_flag == 1
2944 && hdml->div_right_flag == 1) {
2945 s_output_to_hdml_out(hdml, "<RIGHT>");
2946 hdml->hdml_br_flag = 0;
2949 if (hdml->hdml_br_flag == 1
2951 && hdml->in_center == 0) {
2952 s_output_to_hdml_out(hdml, "<CENTER>");
2954 hdml->hdml_br_flag = 0;
2957 if (hdml->hdml_br_flag == 1
2958 && hdml->div_center_flag > 0
2959 && hdml->div_in_center == 0) {
2960 s_output_to_hdml_out(hdml, "<CENTER>");
2961 hdml->div_in_center++;
2962 hdml->hdml_br_flag = 0;
2969 * The data for the init_vars is added, and output.
2971 * @param hdml [i/o] The pointer to the HDML structure at the output
2972 * destination is specified.
2973 * @param s [i] The character string that wants to output to postdata is
2977 s_output_to_init_vars(hdml_t* hdml, char* s)
2979 request_rec* r = hdml->doc->r;
2981 if (strlen(hdml->init_vars))
2982 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, "&", NULL);
2984 hdml->init_vars = apr_pstrcat(r->pool, hdml->init_vars, qs_trim_string(r->pool,s), NULL);
2986 DBG(r, "INIT_VARS:[%s]", hdml->init_vars);
2992 s_hdml_chxjif_tag(void* pdoc, Node* node)
2998 hdml = GET_HDML(pdoc);
3001 for (child = qs_get_child_node(doc, node);
3003 child = qs_get_next_node(doc, child)) {
3004 s_output_to_hdml_out(hdml, child->otext);
3005 s_hdml_chxjif_tag(hdml, child);
3011 s_hdml_text_tag(void* pdoc, Node* child)
3021 int one_line_count = 0;
3024 hdml = GET_HDML(pdoc);
3028 textval = qs_get_node_value(doc,child);
3029 if (strlen(textval) == 0) {
3033 if (hdml->option_flag == 1) {
3037 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
3038 memset(tmp, 0, qs_get_node_size(doc,child)+1);
3039 tdst = apr_palloc(r->pool, 1);
3045 for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
3047 int rtn = s_hdml_search_emoji(hdml, &textval[ii], &out);
3049 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
3051 one_line_count+=(rtn-1);
3054 if (hdml->hdml_blockquote_flag) {
3055 if (one_line_count == 0) {
3056 tdst = qs_out_apr_pstrcat(r, tdst, "<WRAP> <TAB>", &tdst_len);
3058 if (is_sjis_kanji(textval[ii])) {
3059 one_byte[0] = textval[ii+0];
3060 one_byte[1] = textval[ii+1];
3062 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3067 one_byte[0] = textval[ii+0];
3069 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3071 if (one_byte[0] == '\n') {
3077 if (hdml->pre_flag) {
3078 if (one_line_count == 0) {
3079 tdst = qs_out_apr_pstrcat(r, tdst, "<LINE>", &tdst_len);
3081 if (is_sjis_kanji(textval[ii])) {
3082 one_byte[0] = textval[ii+0];
3083 one_byte[1] = textval[ii+1];
3085 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3090 one_byte[0] = textval[ii+0];
3092 if (one_byte[0] == ' ') {
3093 tdst = qs_out_apr_pstrcat(r, tdst, " ", &tdst_len);
3096 tdst = qs_out_apr_pstrcat(r, tdst, chxj_ap_escape_html(r->pool, one_byte), &tdst_len);
3099 if (one_byte[0] == '\n') {
3105 if (is_sjis_kanji(textval[ii])) {
3106 one_byte[0] = textval[ii+0];
3107 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3108 one_byte[0] = textval[ii+1];
3109 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3113 else if (textval[ii] != '\r' && textval[ii] != '\n') {
3114 one_byte[0] = textval[ii+0];
3115 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
3118 memcpy(tmp, textval, strlen(textval)-1);
3120 s_hdml_tag_output_upper_half(hdml, child->parent);
3121 s_output_to_hdml_out(hdml, tdst);
3122 hdml->hdml_br_flag = 0;
3129 * It is a handler who processes the BLOCKQUOTE tag.
3131 * @param pdoc [i/o] The pointer to the HDML structure at the output
3132 * destination is specified.
3133 * @param node [i] The BLOCKQUOTE tag node is specified.
3134 * @return The conversion result is returned.
3137 s_hdml_start_blockquote_tag(void *pdoc, Node *UNUSED(child))
3139 hdml_t *hdml = GET_HDML(pdoc);
3140 hdml->hdml_blockquote_flag++;
3146 * It is a handler who processes the BLOCKQUOTE tag.
3148 * @param pdoc [i/o] The pointer to the HDML structure at the output
3149 * destination is specified.
3150 * @param node [i] The BLOCKQUOTE tag node is specified.
3151 * @return The conversion result is returned.
3154 s_hdml_end_blockquote_tag(void *pdoc, Node *UNUSED(child))
3156 hdml_t *hdml = GET_HDML(pdoc);
3157 hdml->hdml_blockquote_flag--;
3158 s_output_to_hdml_out(hdml, "\r\n");
3164 * It is a handler who processes the DIR tag.
3166 * @param pdoc [i/o] The pointer to the HDML structure at the output
3167 * destination is specified.
3168 * @param node [i] The DIR tag node is specified.
3169 * @return The conversion result is returned.
3172 s_hdml_start_dir_tag(void *pdoc, Node *UNUSED(child))
3174 hdml_t *hdml = GET_HDML(pdoc);
3181 * It is a handler who processes the DIR tag.
3183 * @param pdoc [i/o] The pointer to the HDML structure at the output
3184 * destination is specified.
3185 * @param node [i] The DIR tag node is specified.
3186 * @return The conversion result is returned.
3189 s_hdml_end_dir_tag(void *pdoc, Node *UNUSED(child))
3191 hdml_t *hdml = GET_HDML(pdoc);
3198 * It is a handler who processes the DT tag.
3200 * @param pdoc [i/o] The pointer to the HDML structure at the output
3201 * destination is specified.
3202 * @param node [i] The DT tag node is specified.
3203 * @return The conversion result is returned.
3206 s_hdml_start_dt_tag(void *pdoc, Node *UNUSED(child))
3208 hdml_t *hdml = GET_HDML(pdoc);
3209 s_output_to_hdml_out(hdml, "<LINE>");
3215 * It is a handler who processes the DT tag.
3217 * @param pdoc [i/o] The pointer to the HDML structure at the output
3218 * destination is specified.
3219 * @param node [i] The DT tag node is specified.
3220 * @return The conversion result is returned.
3223 s_hdml_end_dt_tag(void *pdoc, Node *UNUSED(child))
3225 hdml_t *hdml = GET_HDML(pdoc);
3226 s_output_to_hdml_out(hdml, "\r\n");
3232 * It is a handler who processes the DD tag.
3234 * @param pdoc [i/o] The pointer to the HDML structure at the output
3235 * destination is specified.
3236 * @param node [i] The DD tag node is specified.
3237 * @return The conversion result is returned.
3240 s_hdml_start_dd_tag(void *pdoc, Node *UNUSED(child))
3242 hdml_t *hdml = GET_HDML(pdoc);
3243 s_output_to_hdml_out(hdml, "<WRAP> <TAB>");
3249 * It is a handler who processes the DD tag.
3251 * @param pdoc [i/o] The pointer to the HDML structure at the output
3252 * destination is specified.
3253 * @param node [i] The DD tag node is specified.
3254 * @return The conversion result is returned.
3257 s_hdml_end_dd_tag(void *pdoc, Node *UNUSED(child))
3259 hdml_t *hdml = GET_HDML(pdoc);
3260 s_output_to_hdml_out(hdml, "\r\n");
3266 * It is a handler who processes the PLAINTEXT tag.
3268 * @param pdoc [i/o] The pointer to the HDML structure at the output
3269 * destination is specified.
3270 * @param node [i] The PLAINTEXT tag node is specified.
3271 * @return The conversion result is returned.
3274 s_hdml_start_plaintext_tag(void *pdoc, Node *node)
3276 hdml_t *hdml = GET_HDML(pdoc);
3277 hdml->plaintext_value_len = 0;
3278 s_hdml_start_plaintext_tag_inner(pdoc,node);
3283 s_hdml_start_plaintext_tag_inner(void *pdoc, Node *node)
3285 hdml_t *hdml = GET_HDML(pdoc);
3286 Doc *doc = hdml->doc;
3288 for (child = qs_get_child_node(doc, node);
3290 child = qs_get_next_node(doc, child)) {
3292 char *str = chxj_ap_escape_html(doc->r->pool, child->otext);
3293 int len = strlen(str);
3295 for (i=0; i<len; i++) {
3296 if (hdml->plaintext_value_len == 0) {
3297 s_output_to_hdml_out(hdml, "<LINE>");
3299 if (is_sjis_kanji(child->otext[i]) && i + 1 < len) {
3300 oneChar[0] = child->otext[i+0];
3301 oneChar[1] = child->otext[i+1];
3303 s_output_to_hdml_out(hdml, oneChar);
3304 hdml->plaintext_value_len +=2;
3308 if (child->otext[i] == '\n') {
3309 hdml->plaintext_value_len = 0;
3312 s_output_to_hdml_out(hdml, oneChar);
3315 oneChar[0] = child->otext[i];
3317 s_output_to_hdml_out(hdml, oneChar);
3318 hdml->plaintext_value_len++;
3320 s_hdml_start_plaintext_tag_inner(pdoc, child);
3327 * It is a handler who processes the PLAINTEXT tag.
3329 * @param pdoc [i/o] The pointer to the HDML structure at the output
3330 * destination is specified.
3331 * @param node [i] The PLAINTEXT tag node is specified.
3332 * @return The conversion result is returned.
3335 s_hdml_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
3337 hdml_t *hdml = GET_HDML(pdoc);
3343 * It is a handler who processes the PRE tag.
3345 * @param pdoc [i/o] The pointer to the HDML structure at the output
3346 * destination is specified.
3347 * @param node [i] The PRE tag node is specified.
3348 * @return The conversion result is returned.
3351 s_hdml_start_pre_tag(void *pdoc, Node *UNUSED(node))
3357 hdml = GET_HDML(pdoc);
3367 * It is a handler who processes the PRE tag.
3369 * @param pdoc [i/o] The pointer to the HDML structure at the output
3370 * destination is specified.
3371 * @param node [i] The PRE tag node is specified.
3372 * @return The conversion result is returned.
3375 s_hdml_end_pre_tag(void *pdoc, Node *UNUSED(child))
3381 hdml = GET_HDML(pdoc);